summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2015-12-14 12:02:32 +0900
committerDaiki Ueno <ueno@gnu.org>2015-12-14 12:32:33 +0900
commita2e0a31298a4c29f770965e15593f5fef89dcde9 (patch)
tree0ca346f01db56b7ff691ada32b387a605d269db2
parent6e6f6ee91f04bebcf295df9ee11c4e8422ef7b4c (diff)
downloadexternal_gettext-a2e0a31298a4c29f770965e15593f5fef89dcde9.zip
external_gettext-a2e0a31298a4c29f770965e15593f5fef89dcde9.tar.gz
external_gettext-a2e0a31298a4c29f770965e15593f5fef89dcde9.tar.bz2
gnulib-local: Update included libxml2 to 2.9.3
* gnulib-local/lib/libxml/*: Update from libxml2 2.9.3. Add buf.[ch], enc.h, save.h, triodef.h, trionan.[ch]. Enable XPath and XPointer support. * gnulib-local/modules/libxml (Files): Add new files from libxml2 2.9.3.
-rw-r--r--gnulib-local/lib/libxml/COPYING14
-rw-r--r--gnulib-local/lib/libxml/DOCBparser.c12
-rw-r--r--gnulib-local/lib/libxml/DOCBparser.in.h18
-rw-r--r--gnulib-local/lib/libxml/HTMLparser.c1603
-rw-r--r--gnulib-local/lib/libxml/HTMLparser.in.h49
-rw-r--r--gnulib-local/lib/libxml/HTMLtree.c258
-rw-r--r--gnulib-local/lib/libxml/HTMLtree.in.h38
-rw-r--r--gnulib-local/lib/libxml/README40
-rw-r--r--gnulib-local/lib/libxml/SAX.c2
-rw-r--r--gnulib-local/lib/libxml/SAX.in.h74
-rw-r--r--gnulib-local/lib/libxml/SAX2.c404
-rw-r--r--gnulib-local/lib/libxml/SAX2.in.h74
-rw-r--r--gnulib-local/lib/libxml/buf.c1345
-rw-r--r--gnulib-local/lib/libxml/buf.h72
-rw-r--r--gnulib-local/lib/libxml/c14n.c942
-rw-r--r--gnulib-local/lib/libxml/c14n.in.h65
-rw-r--r--gnulib-local/lib/libxml/catalog.c171
-rw-r--r--gnulib-local/lib/libxml/catalog.in.h70
-rw-r--r--gnulib-local/lib/libxml/chvalid.c164
-rw-r--r--gnulib-local/lib/libxml/debugXML.c224
-rw-r--r--gnulib-local/lib/libxml/debugXML.in.h52
-rw-r--r--gnulib-local/lib/libxml/dict.c625
-rw-r--r--gnulib-local/lib/libxml/dict.in.h21
-rw-r--r--gnulib-local/lib/libxml/elfgcchack.h17808
-rw-r--r--gnulib-local/lib/libxml/enc.h32
-rw-r--r--gnulib-local/lib/libxml/encoding.c1500
-rw-r--r--gnulib-local/lib/libxml/encoding.in.h42
-rw-r--r--gnulib-local/lib/libxml/entities.c279
-rw-r--r--gnulib-local/lib/libxml/entities.in.h45
-rw-r--r--gnulib-local/lib/libxml/error.c126
-rw-r--r--gnulib-local/lib/libxml/globals.c54
-rw-r--r--gnulib-local/lib/libxml/globals.in.h74
-rw-r--r--gnulib-local/lib/libxml/hash.c97
-rw-r--r--gnulib-local/lib/libxml/hash.in.h48
-rw-r--r--gnulib-local/lib/libxml/legacy.c32
-rw-r--r--gnulib-local/lib/libxml/libxml.h33
-rw-r--r--gnulib-local/lib/libxml/list.c80
-rw-r--r--gnulib-local/lib/libxml/list.in.h52
-rw-r--r--gnulib-local/lib/libxml/nanoftp.c332
-rw-r--r--gnulib-local/lib/libxml/nanoftp.in.h68
-rw-r--r--gnulib-local/lib/libxml/nanohttp.c609
-rw-r--r--gnulib-local/lib/libxml/nanohttp.in.h26
-rw-r--r--gnulib-local/lib/libxml/parser.c5533
-rw-r--r--gnulib-local/lib/libxml/parser.in.h175
-rw-r--r--gnulib-local/lib/libxml/parserInternals.c378
-rw-r--r--gnulib-local/lib/libxml/parserInternals.in.h206
-rw-r--r--gnulib-local/lib/libxml/pattern.c196
-rw-r--r--gnulib-local/lib/libxml/relaxng.c428
-rw-r--r--gnulib-local/lib/libxml/relaxng.in.h67
-rw-r--r--gnulib-local/lib/libxml/save.h35
-rw-r--r--gnulib-local/lib/libxml/schemasInternals.in.h4
-rw-r--r--gnulib-local/lib/libxml/schematron.c119
-rw-r--r--gnulib-local/lib/libxml/schematron.in.h44
-rw-r--r--gnulib-local/lib/libxml/threads.c584
-rw-r--r--gnulib-local/lib/libxml/threads.in.h34
-rw-r--r--gnulib-local/lib/libxml/timsort.h518
-rw-r--r--gnulib-local/lib/libxml/tree.c1668
-rw-r--r--gnulib-local/lib/libxml/tree.in.h489
-rw-r--r--gnulib-local/lib/libxml/triodef.h228
-rw-r--r--gnulib-local/lib/libxml/trionan.c914
-rw-r--r--gnulib-local/lib/libxml/trionan.h84
-rw-r--r--gnulib-local/lib/libxml/uri.c2203
-rw-r--r--gnulib-local/lib/libxml/uri.in.h43
-rw-r--r--gnulib-local/lib/libxml/valid.c649
-rw-r--r--gnulib-local/lib/libxml/valid.in.h148
-rw-r--r--gnulib-local/lib/libxml/xinclude.c255
-rw-r--r--gnulib-local/lib/libxml/xinclude.in.h14
-rw-r--r--gnulib-local/lib/libxml/xlink.c12
-rw-r--r--gnulib-local/lib/libxml/xlink.in.h14
-rw-r--r--gnulib-local/lib/libxml/xmlIO.c666
-rw-r--r--gnulib-local/lib/libxml/xmlIO.in.h138
-rw-r--r--gnulib-local/lib/libxml/xmlautomata.in.h44
-rw-r--r--gnulib-local/lib/libxml/xmlerror.in.h85
-rw-r--r--gnulib-local/lib/libxml/xmlexports.in.h9
-rw-r--r--gnulib-local/lib/libxml/xmlmemory.c192
-rw-r--r--gnulib-local/lib/libxml/xmlmemory.in.h62
-rw-r--r--gnulib-local/lib/libxml/xmlmodule.c25
-rw-r--r--gnulib-local/lib/libxml/xmlmodule.in.h2
-rw-r--r--gnulib-local/lib/libxml/xmlreader.c1241
-rw-r--r--gnulib-local/lib/libxml/xmlreader.in.h226
-rw-r--r--gnulib-local/lib/libxml/xmlregexp.c750
-rw-r--r--gnulib-local/lib/libxml/xmlregexp.in.h42
-rw-r--r--gnulib-local/lib/libxml/xmlsave.c782
-rw-r--r--gnulib-local/lib/libxml/xmlsave.in.h6
-rw-r--r--gnulib-local/lib/libxml/xmlschemas.c3147
-rw-r--r--gnulib-local/lib/libxml/xmlschemas.in.h80
-rw-r--r--gnulib-local/lib/libxml/xmlschemastypes.c394
-rw-r--r--gnulib-local/lib/libxml/xmlschemastypes.in.h40
-rw-r--r--gnulib-local/lib/libxml/xmlstring.c36
-rw-r--r--gnulib-local/lib/libxml/xmlstring.in.h8
-rw-r--r--gnulib-local/lib/libxml/xmlunicode.c1270
-rw-r--r--gnulib-local/lib/libxml/xmlversion.in.h108
-rw-r--r--gnulib-local/lib/libxml/xmlwriter.c436
-rw-r--r--gnulib-local/lib/libxml/xmlwriter.in.h83
-rw-r--r--gnulib-local/lib/libxml/xpath.c2357
-rw-r--r--gnulib-local/lib/libxml/xpath.in.h108
-rw-r--r--gnulib-local/lib/libxml/xpathInternals.in.h160
-rw-r--r--gnulib-local/lib/libxml/xpointer.c170
-rw-r--r--gnulib-local/lib/libxml/xpointer.in.h46
-rw-r--r--gnulib-local/modules/libxml16
100 files changed, 42919 insertions, 12526 deletions
diff --git a/gnulib-local/lib/libxml/COPYING b/gnulib-local/lib/libxml/COPYING
index 417e955..d613185 100644
--- a/gnulib-local/lib/libxml/COPYING
+++ b/gnulib-local/lib/libxml/COPYING
@@ -2,7 +2,7 @@ Except where otherwise noted in the source code (e.g. the files hash.c,
list.c and the trio files, which are covered by a similar licence but
with different Copyright notices) all the files are:
- Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved.
+ Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -17,11 +17,7 @@ all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON-
-NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the name of Daniel Veillard shall not
-be used in advertising or otherwise to promote the sale, use or other deal-
-ings in this Software without prior written authorization from him.
-
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/gnulib-local/lib/libxml/DOCBparser.c b/gnulib-local/lib/libxml/DOCBparser.c
index 3573743..f12511b 100644
--- a/gnulib-local/lib/libxml/DOCBparser.c
+++ b/gnulib-local/lib/libxml/DOCBparser.c
@@ -53,7 +53,7 @@ docbEncodeEntities(unsigned char *out ATTRIBUTE_UNUSED,
/**
* docbParseDocument:
* @ctxt: an SGML parser context
- *
+ *
* parse an SGML document (and build a tree if using the standard SAX
* interface).
*
@@ -163,12 +163,12 @@ docbCreatePushParserCtxt(docbSAXHandlerPtr sax ATTRIBUTE_UNUSED,
* @cur: a pointer to an array of xmlChar
* @encoding: a free form C string describing the SGML document encoding, or NULL
* @sax: the SAX handler block
- * @userData: if using SAX, this pointer will be provided on callbacks.
+ * @userData: if using SAX, this pointer will be provided on callbacks.
*
* parse an SGML in-memory document and build a tree.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
- *
+ *
* Returns the resulting document tree
*/
@@ -196,7 +196,7 @@ docbSAXParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
* @encoding: a free form C string describing the SGML document encoding, or NULL
*
* parse an SGML in-memory document and build a tree.
- *
+ *
* Returns the resulting document tree
*/
@@ -221,7 +221,7 @@ docbParseDoc(xmlChar * cur ATTRIBUTE_UNUSED,
* @filename: the filename
* @encoding: the SGML document encoding, or NULL
*
- * Create a parser context for a file content.
+ * Create a parser context for a file content.
* Automatic support for ZLIB/Compress compressed document is provided
* by default if found at compile-time.
*
@@ -247,7 +247,7 @@ docbCreateFileParserCtxt(const char *filename ATTRIBUTE_UNUSED,
* @filename: the filename
* @encoding: a free form C string describing the SGML document encoding, or NULL
* @sax: the SAX handler block
- * @userData: if using SAX, this pointer will be provided on callbacks.
+ * @userData: if using SAX, this pointer will be provided on callbacks.
*
* parse an SGML file and build a tree. Automatic support for ZLIB/Compress
* compressed document is provided by default if found at compile-time.
diff --git a/gnulib-local/lib/libxml/DOCBparser.in.h b/gnulib-local/lib/libxml/DOCBparser.in.h
index 461d4ee..9394fa7 100644
--- a/gnulib-local/lib/libxml/DOCBparser.in.h
+++ b/gnulib-local/lib/libxml/DOCBparser.in.h
@@ -47,44 +47,44 @@ XMLPUBFUN int XMLCALL
const unsigned char *in,
int *inlen, int quoteChar);
-XMLPUBFUN docbDocPtr XMLCALL
+XMLPUBFUN docbDocPtr XMLCALL
docbSAXParseDoc (xmlChar *cur,
const char *encoding,
docbSAXHandlerPtr sax,
void *userData);
-XMLPUBFUN docbDocPtr XMLCALL
+XMLPUBFUN docbDocPtr XMLCALL
docbParseDoc (xmlChar *cur,
const char *encoding);
-XMLPUBFUN docbDocPtr XMLCALL
+XMLPUBFUN docbDocPtr XMLCALL
docbSAXParseFile (const char *filename,
const char *encoding,
docbSAXHandlerPtr sax,
void *userData);
-XMLPUBFUN docbDocPtr XMLCALL
+XMLPUBFUN docbDocPtr XMLCALL
docbParseFile (const char *filename,
const char *encoding);
/**
* Interfaces for the Push mode.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
docbFreeParserCtxt (docbParserCtxtPtr ctxt);
-XMLPUBFUN docbParserCtxtPtr XMLCALL
+XMLPUBFUN docbParserCtxtPtr XMLCALL
docbCreatePushParserCtxt(docbSAXHandlerPtr sax,
void *user_data,
const char *chunk,
int size,
const char *filename,
xmlCharEncoding enc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
docbParseChunk (docbParserCtxtPtr ctxt,
const char *chunk,
int size,
int terminate);
-XMLPUBFUN docbParserCtxtPtr XMLCALL
+XMLPUBFUN docbParserCtxtPtr XMLCALL
docbCreateFileParserCtxt(const char *filename,
const char *encoding);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
docbParseDocument (docbParserCtxtPtr ctxt);
#ifdef __cplusplus
diff --git a/gnulib-local/lib/libxml/HTMLparser.c b/gnulib-local/lib/libxml/HTMLparser.c
index 5e23ad7..b729197 100644
--- a/gnulib-local/lib/libxml/HTMLparser.c
+++ b/gnulib-local/lib/libxml/HTMLparser.c
@@ -44,6 +44,9 @@
#include <libxml/globals.h>
#include <libxml/uri.h>
+#include "buf.h"
+#include "enc.h"
+
#define HTML_MAX_NAMELEN 1000
#define HTML_PARSER_BIG_BUFFER_SIZE 1000
#define HTML_PARSER_BUFFER_SIZE 100
@@ -59,7 +62,7 @@ static void htmlParseComment(htmlParserCtxtPtr ctxt);
/************************************************************************
* *
- * Some factorized error routines *
+ * Some factorized error routines *
* *
************************************************************************/
@@ -147,7 +150,7 @@ htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
/************************************************************************
* *
- * Parser stacks related functions and macros *
+ * Parser stacks related functions and macros *
* *
************************************************************************/
@@ -163,6 +166,10 @@ htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
static int
htmlnamePush(htmlParserCtxtPtr ctxt, const xmlChar * value)
{
+ if ((ctxt->html < 3) && (xmlStrEqual(value, BAD_CAST "head")))
+ ctxt->html = 3;
+ if ((ctxt->html < 10) && (xmlStrEqual(value, BAD_CAST "body")))
+ ctxt->html = 10;
if (ctxt->nameNr >= ctxt->nameMax) {
ctxt->nameMax *= 2;
ctxt->nameTab = (const xmlChar * *)
@@ -205,6 +212,59 @@ htmlnamePop(htmlParserCtxtPtr ctxt)
return (ret);
}
+/**
+ * htmlNodeInfoPush:
+ * @ctxt: an HTML parser context
+ * @value: the node info
+ *
+ * Pushes a new element name on top of the node info stack
+ *
+ * Returns 0 in case of error, the index in the stack otherwise
+ */
+static int
+htmlNodeInfoPush(htmlParserCtxtPtr ctxt, htmlParserNodeInfo *value)
+{
+ if (ctxt->nodeInfoNr >= ctxt->nodeInfoMax) {
+ if (ctxt->nodeInfoMax == 0)
+ ctxt->nodeInfoMax = 5;
+ ctxt->nodeInfoMax *= 2;
+ ctxt->nodeInfoTab = (htmlParserNodeInfo *)
+ xmlRealloc((htmlParserNodeInfo *)ctxt->nodeInfoTab,
+ ctxt->nodeInfoMax *
+ sizeof(ctxt->nodeInfoTab[0]));
+ if (ctxt->nodeInfoTab == NULL) {
+ htmlErrMemory(ctxt, NULL);
+ return (0);
+ }
+ }
+ ctxt->nodeInfoTab[ctxt->nodeInfoNr] = *value;
+ ctxt->nodeInfo = &ctxt->nodeInfoTab[ctxt->nodeInfoNr];
+ return (ctxt->nodeInfoNr++);
+}
+
+/**
+ * htmlNodeInfoPop:
+ * @ctxt: an HTML parser context
+ *
+ * Pops the top element name from the node info stack
+ *
+ * Returns 0 in case of error, the pointer to NodeInfo otherwise
+ */
+static htmlParserNodeInfo *
+htmlNodeInfoPop(htmlParserCtxtPtr ctxt)
+{
+ if (ctxt->nodeInfoNr <= 0)
+ return (NULL);
+ ctxt->nodeInfoNr--;
+ if (ctxt->nodeInfoNr < 0)
+ return (NULL);
+ if (ctxt->nodeInfoNr > 0)
+ ctxt->nodeInfo = &ctxt->nodeInfoTab[ctxt->nodeInfoNr - 1];
+ else
+ ctxt->nodeInfo = NULL;
+ return &ctxt->nodeInfoTab[ctxt->nodeInfoNr];
+}
+
/*
* Macros for accessing the content. Those should be used only by the parser,
* and not exported.
@@ -263,8 +323,6 @@ htmlnamePop(htmlParserCtxtPtr ctxt)
#define NEXT xmlNextChar(ctxt)
#define RAW (ctxt->token ? -1 : (*ctxt->input->cur))
-#define NXT(val) ctxt->input->cur[(val)]
-#define CUR_PTR ctxt->input->cur
#define NEXTL(l) do { \
@@ -273,7 +331,7 @@ htmlnamePop(htmlParserCtxtPtr ctxt)
} else ctxt->input->col++; \
ctxt->token = 0; ctxt->input->cur += l; ctxt->nbChars++; \
} while (0)
-
+
/************
\
if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt); \
@@ -288,6 +346,58 @@ htmlnamePop(htmlParserCtxtPtr ctxt)
else i += xmlCopyChar(l,&b[i],v)
/**
+ * htmlFindEncoding:
+ * @the HTML parser context
+ *
+ * Ty to find and encoding in the current data available in the input
+ * buffer this is needed to try to switch to the proper encoding when
+ * one face a character error.
+ * That's an heuristic, since it's operating outside of parsing it could
+ * try to use a meta which had been commented out, that's the reason it
+ * should only be used in case of error, not as a default.
+ *
+ * Returns an encoding string or NULL if not found, the string need to
+ * be freed
+ */
+static xmlChar *
+htmlFindEncoding(xmlParserCtxtPtr ctxt) {
+ const xmlChar *start, *cur, *end;
+
+ if ((ctxt == NULL) || (ctxt->input == NULL) ||
+ (ctxt->input->encoding != NULL) || (ctxt->input->buf == NULL) ||
+ (ctxt->input->buf->encoder != NULL))
+ return(NULL);
+ if ((ctxt->input->cur == NULL) || (ctxt->input->end == NULL))
+ return(NULL);
+
+ start = ctxt->input->cur;
+ end = ctxt->input->end;
+ /* we also expect the input buffer to be zero terminated */
+ if (*end != 0)
+ return(NULL);
+
+ cur = xmlStrcasestr(start, BAD_CAST "HTTP-EQUIV");
+ if (cur == NULL)
+ return(NULL);
+ cur = xmlStrcasestr(cur, BAD_CAST "CONTENT");
+ if (cur == NULL)
+ return(NULL);
+ cur = xmlStrcasestr(cur, BAD_CAST "CHARSET=");
+ if (cur == NULL)
+ return(NULL);
+ cur += 8;
+ start = cur;
+ while (((*cur >= 'A') && (*cur <= 'Z')) ||
+ ((*cur >= 'a') && (*cur <= 'z')) ||
+ ((*cur >= '0') && (*cur <= '9')) ||
+ (*cur == '-') || (*cur == '_') || (*cur == ':') || (*cur == '/'))
+ cur++;
+ if (cur == start)
+ return(NULL);
+ return(xmlStrndup(start, cur - start));
+}
+
+/**
* htmlCurrentChar:
* @ctxt: the HTML parser context
* @len: pointer to the length of the char read
@@ -309,7 +419,7 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
if (ctxt->token != 0) {
*len = 0;
return(ctxt->token);
- }
+ }
if (ctxt->charset == XML_CHAR_ENCODING_UTF8) {
/*
* We are supposed to handle UTF8, check it's valid
@@ -318,7 +428,7 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
* UCS-4 range (hex.) UTF-8 octet sequence (binary)
* 0000 0000-0000 007F 0xxxxxxx
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx
- * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
+ * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
*
* Check for the 0x110000 limit too
*/
@@ -328,19 +438,25 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
c = *cur;
if (c & 0x80) {
- if (cur[1] == 0)
+ if (cur[1] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+ cur = ctxt->input->cur;
+ }
if ((cur[1] & 0xc0) != 0x80)
goto encoding_error;
if ((c & 0xe0) == 0xe0) {
- if (cur[2] == 0)
+ if (cur[2] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+ cur = ctxt->input->cur;
+ }
if ((cur[2] & 0xc0) != 0x80)
goto encoding_error;
if ((c & 0xf0) == 0xf0) {
- if (cur[3] == 0)
+ if (cur[3] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+ cur = ctxt->input->cur;
+ }
if (((c & 0xf8) != 0xf0) ||
((cur[3] & 0xc0) != 0x80))
goto encoding_error;
@@ -366,9 +482,16 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
if (!IS_CHAR(val)) {
htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
"Char 0x%X out of allowed range\n", val);
- }
+ }
return(val);
} else {
+ if ((*ctxt->input->cur == 0) &&
+ (ctxt->input->cur < ctxt->input->end)) {
+ htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
+ "Char 0x%X out of allowed range\n", 0);
+ *len = 1;
+ return(' ');
+ }
/* 1-byte code */
*len = 1;
return((int) *ctxt->input->cur);
@@ -386,8 +509,28 @@ htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
/*
* Humm this is bad, do an automatic flow conversion
*/
- xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_8859_1);
- ctxt->charset = XML_CHAR_ENCODING_UTF8;
+ {
+ xmlChar * guess;
+ xmlCharEncodingHandlerPtr handler;
+
+ guess = htmlFindEncoding(ctxt);
+ if (guess == NULL) {
+ xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_8859_1);
+ } else {
+ if (ctxt->input->encoding != NULL)
+ xmlFree((xmlChar *) ctxt->input->encoding);
+ ctxt->input->encoding = guess;
+ handler = xmlFindCharEncodingHandler((const char *) guess);
+ if (handler != NULL) {
+ xmlSwitchToEncoding(ctxt, handler);
+ } else {
+ htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
+ "Unsupported encoding %s", guess, NULL);
+ }
+ }
+ ctxt->charset = XML_CHAR_ENCODING_UTF8;
+ }
+
return(xmlCurrentChar(ctxt, len));
encoding_error:
@@ -401,15 +544,19 @@ encoding_error:
{
char buffer[150];
- snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
- ctxt->input->cur[0], ctxt->input->cur[1],
- ctxt->input->cur[2], ctxt->input->cur[3]);
+ if (ctxt->input->end - ctxt->input->cur >= 4) {
+ snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
+ ctxt->input->cur[0], ctxt->input->cur[1],
+ ctxt->input->cur[2], ctxt->input->cur[3]);
+ } else {
+ snprintf(buffer, 149, "Bytes: 0x%02X\n", ctxt->input->cur[0]);
+ }
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
"Input is not proper UTF-8, indicate encoding !\n",
BAD_CAST buffer, NULL);
}
- ctxt->charset = XML_CHAR_ENCODING_8859_1;
+ ctxt->charset = XML_CHAR_ENCODING_8859_1;
*len = 1;
return((int) *ctxt->input->cur);
}
@@ -449,7 +596,7 @@ htmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
/************************************************************************
* *
- * The list of HTML elements and their properties *
+ * The list of HTML elements and their properties *
* *
************************************************************************/
@@ -472,11 +619,11 @@ htmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
#define NB_FONTSTYLE 8
#define PHRASE "em", "strong", "dfn", "code", "samp", "kbd", "var", "cite", "abbr", "acronym"
#define NB_PHRASE 10
-#define SPECIAL "a", "img", "applet", "object", "font", "basefont", "br", "script", "map", "q", "sub", "sup", "span", "bdo", "iframe"
-#define NB_SPECIAL 15
-#define INLINE PCDATA FONTSTYLE PHRASE SPECIAL FORMCTRL
+#define SPECIAL "a", "img", "applet", "embed", "object", "font", "basefont", "br", "script", "map", "q", "sub", "sup", "span", "bdo", "iframe"
+#define NB_SPECIAL 16
+#define INLINE FONTSTYLE, PHRASE, SPECIAL, FORMCTRL
#define NB_INLINE NB_PCDATA + NB_FONTSTYLE + NB_PHRASE + NB_SPECIAL + NB_FORMCTRL
-#define BLOCK HEADING, LIST "pre", "p", "dl", "div", "center", "noscript", "noframes", "blockquote", "form", "isindex", "hr", "table", "fieldset", "address"
+#define BLOCK HEADING, LIST, "pre", "p", "dl", "div", "center", "noscript", "noframes", "blockquote", "form", "isindex", "hr", "table", "fieldset", "address"
#define NB_BLOCK NB_HEADING + NB_LIST + 14
#define FORMCTRL "input", "select", "textarea", "label", "button"
#define NB_FORMCTRL 5
@@ -572,6 +719,7 @@ static const char* const version_attr[] = { "version", NULL } ;
static const char* const html_content[] = { "head", "body", "frameset", NULL } ;
static const char* const iframe_attrs[] = { COREATTRS, "longdesc", "name", "src", "frameborder", "marginwidth", "marginheight", "scrolling", "align", "height", "width", NULL } ;
static const char* const img_attrs[] = { ATTRS, "longdesc", "name", "height", "width", "usemap", "ismap", NULL } ;
+static const char* const embed_attrs[] = { COREATTRS, "align", "alt", "border", "code", "codebase", "frameborder", "height", "hidden", "hspace", "name", "palette", "pluginspace", "pluginurl", "src", "type", "units", "vspace", "width", NULL } ;
static const char* const input_attrs[] = { ATTRS, "type", "name", "value", "checked", "disabled", "readonly", "size", "maxlength", "src", "alt", "usemap", "ismap", "tabindex", "accesskey", "onfocus", "onblur", "onselect", "onchange", "accept", NULL } ;
static const char* const prompt_attrs[] = { COREATTRS, I18N, "prompt", NULL } ;
static const char* const label_attrs[] = { ATTRS, "for", "accesskey", "onfocus", "onblur", NULL } ;
@@ -582,7 +730,7 @@ static const char* const map_contents[] = { BLOCK, "area", NULL } ;
static const char* const name_attr[] = { "name", NULL } ;
static const char* const action_attr[] = { "action", NULL } ;
static const char* const blockli_elt[] = { BLOCK, "li", NULL } ;
-static const char* const meta_attrs[] = { I18N, "http-equiv", "name", "scheme", NULL } ;
+static const char* const meta_attrs[] = { I18N, "http-equiv", "name", "scheme", "charset", NULL } ;
static const char* const content_attr[] = { "content", NULL } ;
static const char* const type_attr[] = { "type", NULL } ;
static const char* const noframes_content[] = { "body", FLOW MODIFIER, NULL } ;
@@ -601,7 +749,7 @@ static const char* const language_attr[] = { "language", NULL } ;
static const char* const select_content[] = { "optgroup", "option", NULL } ;
static const char* const select_attrs[] = { ATTRS, "name", "size", "multiple", "disabled", "tabindex", "onfocus", "onblur", "onchange", NULL } ;
static const char* const style_attrs[] = { I18N, "media", "title", NULL } ;
-static const char* const table_attrs[] = { ATTRS "summary", "width", "border", "frame", "rules", "cellspacing", "cellpadding", "datapagesize", NULL } ;
+static const char* const table_attrs[] = { ATTRS, "summary", "width", "border", "frame", "rules", "cellspacing", "cellpadding", "datapagesize", NULL } ;
static const char* const table_depr[] = { "align", "bgcolor", NULL } ;
static const char* const table_contents[] = { "caption", "col", "colgroup", "thead", "tfoot", "tbody", "tr", NULL} ;
static const char* const tr_elt[] = { "tr", NULL } ;
@@ -698,7 +846,7 @@ html40ElementTable[] = {
DECL html_flow, NULL, DECL html_attrs, DECL align_attr, NULL
},
{ "dl", 0, 0, 0, 0, 0, 0, 0, "definition list ",
- DECL dl_contents , "dd" , html_attrs, DECL compact_attr, NULL
+ DECL dl_contents , "dd" , DECL html_attrs, DECL compact_attr, NULL
},
{ "dt", 0, 1, 0, 0, 0, 0, 0, "definition term ",
DECL html_inline, NULL, DECL html_attrs, NULL, NULL
@@ -706,6 +854,9 @@ html40ElementTable[] = {
{ "em", 0, 3, 0, 0, 0, 0, 1, "emphasis",
DECL html_inline, NULL, DECL html_attrs, NULL, NULL
},
+{ "embed", 0, 1, 0, 0, 1, 1, 1, "generic embedded object ",
+ EMPTY, NULL, DECL embed_attrs, NULL, NULL
+},
{ "fieldset", 0, 0, 0, 0, 0, 0, 0, "form control group ",
DECL fieldset_contents , NULL, DECL html_attrs, NULL, NULL
},
@@ -755,7 +906,7 @@ html40ElementTable[] = {
DECL html_flow, NULL, NULL, DECL iframe_attrs, NULL
},
{ "img", 0, 2, 2, 1, 0, 0, 1, "embedded image ",
- EMPTY, NULL, DECL img_attrs, DECL align_attr, src_alt_attrs
+ EMPTY, NULL, DECL img_attrs, DECL align_attr, DECL src_alt_attrs
},
{ "input", 0, 2, 2, 1, 0, 0, 1, "form control ",
EMPTY, NULL, DECL input_attrs , DECL align_attr, NULL
@@ -782,7 +933,7 @@ html40ElementTable[] = {
EMPTY, NULL, DECL link_attrs, DECL target_attr, NULL
},
{ "map", 0, 0, 0, 0, 0, 0, 2, "client-side image map ",
- DECL map_contents , NULL, DECL html_attrs , NULL, name_attr
+ DECL map_contents , NULL, DECL html_attrs , NULL, DECL name_attr
},
{ "menu", 0, 0, 0, 0, 1, 1, 0, "menu list ",
DECL blockli_elt , NULL, NULL, DECL compact_attrs, NULL
@@ -803,7 +954,7 @@ html40ElementTable[] = {
DECL li_elt , "li" , DECL html_attrs, DECL ol_attrs, NULL
},
{ "optgroup", 0, 0, 0, 0, 0, 0, 0, "option group ",
- option_elt , "option", DECL optgroup_attrs, NULL, DECL label_attr
+ DECL option_elt , "option", DECL optgroup_attrs, NULL, DECL label_attr
},
{ "option", 0, 1, 0, 0, 0, 0, 0, "selectable choice " ,
DECL html_pcdata, NULL, DECL option_attrs, NULL, NULL
@@ -812,7 +963,7 @@ html40ElementTable[] = {
DECL html_inline, NULL, DECL html_attrs, DECL align_attr, NULL
},
{ "param", 0, 2, 2, 1, 0, 0, 0, "named property value ",
- EMPTY, NULL, DECL param_attrs, NULL, name_attr
+ EMPTY, NULL, DECL param_attrs, NULL, DECL name_attr
},
{ "pre", 0, 0, 0, 0, 0, 0, 0, "preformatted text ",
DECL pre_content, NULL, DECL html_attrs, DECL width_attr, NULL
@@ -930,18 +1081,18 @@ static const char * const htmlStartClose[] = {
"listing", "xmp", NULL,
"ol", "p", "head", "ul", NULL,
"menu", "p", "head", "ul", NULL,
-"p", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", NULL,
+"p", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", FONTSTYLE, NULL,
"div", "p", "head", NULL,
-"noscript", "p", "head", NULL,
+"noscript", "p", NULL,
"center", "font", "b", "i", "p", "head", NULL,
-"a", "a", NULL,
+"a", "a", "head", NULL,
"caption", "p", NULL,
"colgroup", "caption", "colgroup", "col", "p", NULL,
"col", "caption", "col", "p", NULL,
"table", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", "pre",
"listing", "xmp", "a", NULL,
"th", "th", "td", "p", "span", "font", "a", "b", "i", "u", NULL,
-"td", "th", "td", "p", "span", "font", "a", "b", "i", "u", NULL,
+"td", "th", "td", "p", "span", "font", "a", "b", "i", "u", NULL,
"tr", "th", "td", "tr", "caption", "col", "colgroup", "p", NULL,
"thead", "caption", "col", "colgroup", NULL,
"tfoot", "th", "td", "tr", "caption", "col", "colgroup", "thead",
@@ -952,6 +1103,43 @@ static const char * const htmlStartClose[] = {
"option", "option", NULL,
"fieldset", "legend", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6",
"pre", "listing", "xmp", "a", NULL,
+/* most tags in in FONTSTYLE, PHRASE and SPECIAL should close <head> */
+"tt", "head", NULL,
+"i", "head", NULL,
+"b", "head", NULL,
+"u", "head", NULL,
+"s", "head", NULL,
+"strike", "head", NULL,
+"big", "head", NULL,
+"small", "head", NULL,
+
+"em", "head", NULL,
+"strong", "head", NULL,
+"dfn", "head", NULL,
+"code", "head", NULL,
+"samp", "head", NULL,
+"kbd", "head", NULL,
+"var", "head", NULL,
+"cite", "head", NULL,
+"abbr", "head", NULL,
+"acronym", "head", NULL,
+
+/* "a" */
+"img", "head", NULL,
+/* "applet" */
+/* "embed" */
+/* "object" */
+"font", "head", NULL,
+/* "basefont" */
+"br", "head", NULL,
+/* "script" */
+"map", "head", NULL,
+"q", "head", NULL,
+"sub", "head", NULL,
+"sup", "head", NULL,
+"span", "head", NULL,
+"bdo", "head", NULL,
+"iframe", "head", NULL,
NULL
};
@@ -989,7 +1177,7 @@ static const char *const htmlScriptAttributes[] = {
"onfocus",
"onblur",
"onsubmit",
- "onrest",
+ "onreset",
"onchange",
"onselect"
};
@@ -1000,7 +1188,7 @@ static const char *const htmlScriptAttributes[] = {
* elements the parser can decide how to handle extra endtags.
* Endtags are only allowed to close elements with lower or equal
* priority.
- */
+ */
typedef struct {
const char *name;
@@ -1027,7 +1215,7 @@ static int htmlStartCloseIndexinitialized = 0;
/************************************************************************
* *
- * functions to handle HTML specific data *
+ * functions to handle HTML specific data *
* *
************************************************************************/
@@ -1077,7 +1265,7 @@ htmlTagLookup(const xmlChar *tag) {
/**
* htmlGetEndPriority:
* @name: The name of the element to look up the priority for.
- *
+ *
* Return value: The "endtag" priority.
**/
static int
@@ -1156,7 +1344,7 @@ htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag)
* A missplaced endtag can only close elements with lower
* or equal priority, so if we find an element with higher
* priority before we find an element with
- * matching name, we just ignore this endtag
+ * matching name, we just ignore this endtag
*/
if (htmlGetEndPriority(ctxt->nameTab[i]) > priority)
return;
@@ -1207,7 +1395,7 @@ htmlAutoCloseOnEnd(htmlParserCtxtPtr ctxt)
* called when a new tag has been detected and generates the
* appropriates closes if possible/needed.
* If newtag is NULL this mean we are at the end of the resource
- * and we should check
+ * and we should check
*/
static void
htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag)
@@ -1295,6 +1483,10 @@ htmlIsAutoClosed(htmlDocPtr doc, htmlNodePtr elem) {
*/
static void
htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
+ int i;
+
+ if (ctxt->options & HTML_PARSE_NOIMPLIED)
+ return;
if (!htmlOmittedDefaultValue)
return;
if (xmlStrEqual(newtag, BAD_CAST"html"))
@@ -1306,24 +1498,31 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
}
if ((xmlStrEqual(newtag, BAD_CAST"body")) || (xmlStrEqual(newtag, BAD_CAST"head")))
return;
- if ((ctxt->nameNr <= 1) &&
+ if ((ctxt->nameNr <= 1) &&
((xmlStrEqual(newtag, BAD_CAST"script")) ||
(xmlStrEqual(newtag, BAD_CAST"style")) ||
(xmlStrEqual(newtag, BAD_CAST"meta")) ||
(xmlStrEqual(newtag, BAD_CAST"link")) ||
(xmlStrEqual(newtag, BAD_CAST"title")) ||
(xmlStrEqual(newtag, BAD_CAST"base")))) {
- /*
- * dropped OBJECT ... i you put it first BODY will be
- * assumed !
- */
- htmlnamePush(ctxt, BAD_CAST"head");
- if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
- ctxt->sax->startElement(ctxt->userData, BAD_CAST"head", NULL);
+ if (ctxt->html >= 3) {
+ /* we already saw or generated an <head> before */
+ return;
+ }
+ /*
+ * dropped OBJECT ... i you put it first BODY will be
+ * assumed !
+ */
+ htmlnamePush(ctxt, BAD_CAST"head");
+ if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
+ ctxt->sax->startElement(ctxt->userData, BAD_CAST"head", NULL);
} else if ((!xmlStrEqual(newtag, BAD_CAST"noframes")) &&
(!xmlStrEqual(newtag, BAD_CAST"frame")) &&
(!xmlStrEqual(newtag, BAD_CAST"frameset"))) {
- int i;
+ if (ctxt->html >= 10) {
+ /* we already saw or generated a <body> before */
+ return;
+ }
for (i = 0;i < ctxt->nameNr;i++) {
if (xmlStrEqual(ctxt->nameTab[i], BAD_CAST"body")) {
return;
@@ -1332,7 +1531,7 @@ htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) {
return;
}
}
-
+
htmlnamePush(ctxt, BAD_CAST"body");
if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL))
ctxt->sax->startElement(ctxt->userData, BAD_CAST"body", NULL);
@@ -1394,12 +1593,12 @@ htmlIsScriptAttribute(const xmlChar *name) {
unsigned int i;
if (name == NULL)
- return(0);
+ return(0);
/*
* all script attributes start with 'on'
*/
if ((name[0] != 'o') || (name[1] != 'n'))
- return(0);
+ return(0);
for (i = 0;
i < sizeof(htmlScriptAttributes)/sizeof(htmlScriptAttributes[0]);
i++) {
@@ -1411,7 +1610,7 @@ htmlIsScriptAttribute(const xmlChar *name) {
/************************************************************************
* *
- * The list of HTML predefined entities *
+ * The list of HTML predefined entities *
* *
************************************************************************/
@@ -1825,7 +2024,7 @@ UTF8ToHtml(unsigned char* out, int *outlen,
if (inend - in < trailing) {
break;
- }
+ }
for ( ; trailing; trailing--) {
if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))
@@ -1842,6 +2041,8 @@ UTF8ToHtml(unsigned char* out, int *outlen,
} else {
int len;
const htmlEntityDesc * ent;
+ const char *cp;
+ char nbuf[16];
/*
* Try to lookup a predefined HTML entity for it
@@ -1849,16 +2050,16 @@ UTF8ToHtml(unsigned char* out, int *outlen,
ent = htmlEntityValueLookup(c);
if (ent == NULL) {
- /* no chance for this in Ascii */
- *outlen = out - outstart;
- *inlen = processed - instart;
- return(-2);
+ snprintf(nbuf, sizeof(nbuf), "#%u", c);
+ cp = nbuf;
}
- len = strlen(ent->name);
+ else
+ cp = ent->name;
+ len = strlen(cp);
if (out + 2 + len >= outend)
break;
*out++ = '&';
- memcpy(out, ent->name, len);
+ memcpy(out, cp, len);
out += len;
*out++ = ';';
}
@@ -2013,7 +2214,7 @@ htmlNewInputStream(htmlParserCtxtPtr ctxt) {
* *
************************************************************************/
/*
- * all tags allowing pc data from the html 4.01 loose dtd
+ * all tags allowing pc data from the html 4.01 loose dtd
* NOTE: it might be more apropriate to integrate this information
* into the html40ElementTable array but I don't want to risk any
* binary incomptibility
@@ -2073,7 +2274,7 @@ static int areBlanks(htmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
if (lastChild == NULL) {
if ((ctxt->node->type != XML_ELEMENT_NODE) &&
(ctxt->node->content != NULL)) return(0);
- /* keep ws in constructs like ...<b> </b>...
+ /* keep ws in constructs like ...<b> </b>...
for all tags "b" allowing PCDATA */
for ( i = 0; i < sizeof(allowPCData)/sizeof(allowPCData[0]); i++ ) {
if ( xmlStrEqual(ctxt->name, BAD_CAST allowPCData[i]) ) {
@@ -2083,7 +2284,7 @@ static int areBlanks(htmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
} else if (xmlNodeIsText(lastChild)) {
return(0);
} else {
- /* keep ws in constructs like <p><b>xy</b> <i>z</i><p>
+ /* keep ws in constructs like <p><b>xy</b> <i>z</i><p>
for all tags "p" allowing PCDATA */
for ( i = 0; i < sizeof(allowPCData)/sizeof(allowPCData[0]); i++ ) {
if ( xmlStrEqual(lastChild->name, BAD_CAST allowPCData[i]) ) {
@@ -2123,7 +2324,7 @@ htmlNewDocNoDtD(const xmlChar *URI, const xmlChar *ExternalID) {
cur->intSubset = NULL;
cur->doc = cur;
cur->name = NULL;
- cur->children = NULL;
+ cur->children = NULL;
cur->extSubset = NULL;
cur->oldNs = NULL;
cur->encoding = NULL;
@@ -2133,6 +2334,7 @@ htmlNewDocNoDtD(const xmlChar *URI, const xmlChar *ExternalID) {
cur->refs = NULL;
cur->_private = NULL;
cur->charset = XML_CHAR_ENCODING_UTF8;
+ cur->properties = XML_DOC_HTML | XML_DOC_USERBUILT;
if ((ExternalID != NULL) ||
(URI != NULL))
xmlCreateIntSubset(cur, BAD_CAST "html", ExternalID, URI);
@@ -2190,21 +2392,54 @@ htmlParseHTMLName(htmlParserCtxtPtr ctxt) {
xmlChar loc[HTML_PARSER_BUFFER_SIZE];
if (!IS_ASCII_LETTER(CUR) && (CUR != '_') &&
- (CUR != ':')) return(NULL);
+ (CUR != ':') && (CUR != '.')) return(NULL);
while ((i < HTML_PARSER_BUFFER_SIZE) &&
((IS_ASCII_LETTER(CUR)) || (IS_ASCII_DIGIT(CUR)) ||
- (CUR == ':') || (CUR == '-') || (CUR == '_'))) {
+ (CUR == ':') || (CUR == '-') || (CUR == '_') ||
+ (CUR == '.'))) {
if ((CUR >= 'A') && (CUR <= 'Z')) loc[i] = CUR + 0x20;
else loc[i] = CUR;
i++;
-
+
NEXT;
}
-
+
return(xmlDictLookup(ctxt->dict, loc, i));
}
+
+/**
+ * htmlParseHTMLName_nonInvasive:
+ * @ctxt: an HTML parser context
+ *
+ * parse an HTML tag or attribute name, note that we convert it to lowercase
+ * since HTML names are not case-sensitive, this doesn't consume the data
+ * from the stream, it's a look-ahead
+ *
+ * Returns the Tag Name parsed or NULL
+ */
+
+static const xmlChar *
+htmlParseHTMLName_nonInvasive(htmlParserCtxtPtr ctxt) {
+ int i = 0;
+ xmlChar loc[HTML_PARSER_BUFFER_SIZE];
+
+ if (!IS_ASCII_LETTER(NXT(1)) && (NXT(1) != '_') &&
+ (NXT(1) != ':')) return(NULL);
+
+ while ((i < HTML_PARSER_BUFFER_SIZE) &&
+ ((IS_ASCII_LETTER(NXT(1+i))) || (IS_ASCII_DIGIT(NXT(1+i))) ||
+ (NXT(1+i) == ':') || (NXT(1+i) == '-') || (NXT(1+i) == '_'))) {
+ if ((NXT(1+i) >= 'A') && (NXT(1+i) <= 'Z')) loc[i] = NXT(1+i) + 0x20;
+ else loc[i] = NXT(1+i);
+ i++;
+ }
+
+ return(xmlDictLookup(ctxt->dict, loc, i));
+}
+
+
/**
* htmlParseName:
* @ctxt: an HTML parser context
@@ -2268,7 +2503,7 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) {
while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
((IS_LETTER(c)) || (IS_DIGIT(c)) ||
(c == '.') || (c == '-') ||
- (c == '_') || (c == ':') ||
+ (c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
if (count++ > 100) {
@@ -2287,7 +2522,7 @@ htmlParseNameComplex(xmlParserCtxtPtr ctxt) {
* htmlParseHTMLAttribute:
* @ctxt: an HTML parser context
* @stop: a char stop value
- *
+ *
* parse an HTML attribute value till the stop (quote), if
* stop is 0 then it stops at the first space
*
@@ -2332,13 +2567,13 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
{ *out++ =((c >> 6) & 0x1F) | 0xC0; bits= 0; }
else if (c < 0x10000)
{ *out++ =((c >> 12) & 0x0F) | 0xE0; bits= 6; }
- else
+ else
{ *out++ =((c >> 18) & 0x07) | 0xF0; bits= 12; }
-
+
for ( ; bits >= 0; bits-= 6) {
*out++ = ((c >> bits) & 0x3F) | 0x80;
}
-
+
if (out - buffer > buffer_size - 100) {
int indx = out - buffer;
@@ -2384,9 +2619,9 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
{ *out++ =((c >> 6) & 0x1F) | 0xC0; bits= 0; }
else if (c < 0x10000)
{ *out++ =((c >> 12) & 0x0F) | 0xE0; bits= 6; }
- else
+ else
{ *out++ =((c >> 18) & 0x07) | 0xF0; bits= 12; }
-
+
for ( ; bits >= 0; bits-= 6) {
*out++ = ((c >> bits) & 0x3F) | 0x80;
}
@@ -2409,16 +2644,16 @@ htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) {
{ *out++ =((c >> 6) & 0x1F) | 0xC0; bits= 0; }
else if (c < 0x10000)
{ *out++ =((c >> 12) & 0x0F) | 0xE0; bits= 6; }
- else
+ else
{ *out++ =((c >> 18) & 0x07) | 0xF0; bits= 12; }
-
+
for ( ; bits >= 0; bits-= 6) {
*out++ = ((c >> bits) & 0x3F) | 0x80;
}
NEXT;
}
}
- *out++ = 0;
+ *out = 0;
return(buffer);
}
@@ -2479,7 +2714,7 @@ htmlParseEntityRef(htmlParserCtxtPtr ctxt, const xmlChar **str) {
* parse a value for an attribute
* Note: the parser won't do substitution of entities here, this
* will be handled later in xmlStringGetNodeList, unless it was
- * asked for ctxt->replaceEntities != 0
+ * asked for ctxt->replaceEntities != 0
*
* Returns the AttValue parsed or NULL.
*/
@@ -2520,7 +2755,7 @@ htmlParseAttValue(htmlParserCtxtPtr ctxt) {
/**
* htmlParseSystemLiteral:
* @ctxt: an HTML parser context
- *
+ *
* parse an HTML Literal
*
* [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
@@ -2561,7 +2796,7 @@ htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) {
htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_STARTED,
" or ' expected\n", NULL, NULL);
}
-
+
return(ret);
}
@@ -2610,7 +2845,7 @@ htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) {
htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_STARTED,
"PubidLiteral \" or ' expected\n", NULL, NULL);
}
-
+
return(ret);
}
@@ -2644,23 +2879,7 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
SHRINK;
cur = CUR_CHAR(l);
while (IS_CHAR_CH(cur)) {
- if ((cur == '<') && (NXT(1) == '!') && (NXT(2) == '-') &&
- (NXT(3) == '-')) {
- if ((nbchar != 0) && (ctxt->sax != NULL) && (!ctxt->disableSAX)) {
- if (ctxt->sax->cdataBlock!= NULL) {
- /*
- * Insert as CDATA, which is the same as HTML_PRESERVE_NODE
- */
- ctxt->sax->cdataBlock(ctxt->userData, buf, nbchar);
- } else if (ctxt->sax->characters != NULL) {
- ctxt->sax->characters(ctxt->userData, buf, nbchar);
- }
- }
- nbchar = 0;
- htmlParseComment(ctxt);
- cur = CUR_CHAR(l);
- continue;
- } else if ((cur == '<') && (NXT(1) == '/')) {
+ if ((cur == '<') && (NXT(1) == '/')) {
/*
* One should break here, the specification is clear:
* Authors should therefore escape "</" within the content.
@@ -2673,8 +2892,8 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
* CDATA.
*/
if (ctxt->recovery) {
- if (xmlStrncasecmp(ctxt->name, ctxt->input->cur+2,
- xmlStrlen(ctxt->name)) == 0)
+ if (xmlStrncasecmp(ctxt->name, ctxt->input->cur+2,
+ xmlStrlen(ctxt->name)) == 0)
{
break; /* while */
} else {
@@ -2684,7 +2903,7 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
}
} else {
if (((NXT(2) >= 'A') && (NXT(2) <= 'Z')) ||
- ((NXT(2) >= 'a') && (NXT(2) <= 'z')))
+ ((NXT(2) >= 'a') && (NXT(2) <= 'z')))
{
break; /* while */
}
@@ -2708,9 +2927,11 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
}
if ((!(IS_CHAR_CH(cur))) && (!((cur == 0) && (ctxt->progressive)))) {
- htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
- "Invalid char in CDATA 0x%X\n", cur);
- NEXT;
+ htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
+ "Invalid char in CDATA 0x%X\n", cur);
+ if (ctxt->input->cur < ctxt->input->end) {
+ NEXT;
+ }
}
if ((nbchar != 0) && (ctxt->sax != NULL) && (!ctxt->disableSAX)) {
@@ -2727,8 +2948,9 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
/**
- * htmlParseCharData:
+ * htmlParseCharDataInternal:
* @ctxt: an HTML parser context
+ * @readahead: optional read ahead character in ascii range
*
* parse a CharData section.
* if we are within a CDATA section ']]>' marks an end of section.
@@ -2737,26 +2959,40 @@ htmlParseScript(htmlParserCtxtPtr ctxt) {
*/
static void
-htmlParseCharData(htmlParserCtxtPtr ctxt) {
- xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 5];
+htmlParseCharDataInternal(htmlParserCtxtPtr ctxt, int readahead) {
+ xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 6];
int nbchar = 0;
int cur, l;
+ int chunk = 0;
+
+ if (readahead)
+ buf[nbchar++] = readahead;
SHRINK;
cur = CUR_CHAR(l);
while (((cur != '<') || (ctxt->token == '<')) &&
- ((cur != '&') || (ctxt->token == '&')) &&
- (IS_CHAR(cur))) {
- COPY_BUF(l,buf,nbchar,cur);
+ ((cur != '&') || (ctxt->token == '&')) &&
+ (cur != 0)) {
+ if (!(IS_CHAR(cur))) {
+ htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR,
+ "Invalid char in CDATA 0x%X\n", cur);
+ } else {
+ COPY_BUF(l,buf,nbchar,cur);
+ }
if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) {
/*
* Ok the segment is to be consumed as chars.
*/
if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
if (areBlanks(ctxt, buf, nbchar)) {
- if (ctxt->sax->ignorableWhitespace != NULL)
- ctxt->sax->ignorableWhitespace(ctxt->userData,
- buf, nbchar);
+ if (ctxt->keepBlanks) {
+ if (ctxt->sax->characters != NULL)
+ ctxt->sax->characters(ctxt->userData, buf, nbchar);
+ } else {
+ if (ctxt->sax->ignorableWhitespace != NULL)
+ ctxt->sax->ignorableWhitespace(ctxt->userData,
+ buf, nbchar);
+ }
} else {
htmlCheckParagraph(ctxt);
if (ctxt->sax->characters != NULL)
@@ -2766,6 +3002,12 @@ htmlParseCharData(htmlParserCtxtPtr ctxt) {
nbchar = 0;
}
NEXTL(l);
+ chunk++;
+ if (chunk > HTML_PARSER_BUFFER_SIZE) {
+ chunk = 0;
+ SHRINK;
+ GROW;
+ }
cur = CUR_CHAR(l);
if (cur == 0) {
SHRINK;
@@ -2781,8 +3023,14 @@ htmlParseCharData(htmlParserCtxtPtr ctxt) {
*/
if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
if (areBlanks(ctxt, buf, nbchar)) {
- if (ctxt->sax->ignorableWhitespace != NULL)
- ctxt->sax->ignorableWhitespace(ctxt->userData, buf, nbchar);
+ if (ctxt->keepBlanks) {
+ if (ctxt->sax->characters != NULL)
+ ctxt->sax->characters(ctxt->userData, buf, nbchar);
+ } else {
+ if (ctxt->sax->ignorableWhitespace != NULL)
+ ctxt->sax->ignorableWhitespace(ctxt->userData,
+ buf, nbchar);
+ }
} else {
htmlCheckParagraph(ctxt);
if (ctxt->sax->characters != NULL)
@@ -2799,6 +3047,21 @@ htmlParseCharData(htmlParserCtxtPtr ctxt) {
}
/**
+ * htmlParseCharData:
+ * @ctxt: an HTML parser context
+ *
+ * parse a CharData section.
+ * if we are within a CDATA section ']]>' marks an end of section.
+ *
+ * [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
+ */
+
+static void
+htmlParseCharData(htmlParserCtxtPtr ctxt) {
+ htmlParseCharDataInternal(ctxt, 0);
+}
+
+/**
* htmlParseExternalID:
* @ctxt: an HTML parser context
* @publicID: a xmlChar** receiving PubidLiteral
@@ -2960,7 +3223,7 @@ htmlParsePI(htmlParserCtxtPtr ctxt) {
}
xmlFree(buf);
} else {
- htmlParseErr(ctxt, XML_ERR_PI_NOT_STARTED,
+ htmlParseErr(ctxt, XML_ERR_PI_NOT_STARTED,
"PI is not started correctly", NULL, NULL);
}
ctxt->instate = state;
@@ -3001,12 +3264,17 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
ctxt->instate = state;
return;
}
+ len = 0;
+ buf[len] = 0;
q = CUR_CHAR(ql);
+ if (!IS_CHAR(q))
+ goto unfinished;
NEXTL(ql);
r = CUR_CHAR(rl);
+ if (!IS_CHAR(r))
+ goto unfinished;
NEXTL(rl);
cur = CUR_CHAR(l);
- len = 0;
while (IS_CHAR(cur) &&
((cur != '>') ||
(r != '-') || (q != '-'))) {
@@ -3037,18 +3305,20 @@ htmlParseComment(htmlParserCtxtPtr ctxt) {
}
}
buf[len] = 0;
- if (!IS_CHAR(cur)) {
- htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
- "Comment not terminated \n<!--%.50s\n", buf, NULL);
- xmlFree(buf);
- } else {
+ if (IS_CHAR(cur)) {
NEXT;
if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
(!ctxt->disableSAX))
ctxt->sax->comment(ctxt->userData, buf);
xmlFree(buf);
+ ctxt->instate = state;
+ return;
}
- ctxt->instate = state;
+
+unfinished:
+ htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
+ "Comment not terminated \n<!--%.50s\n", buf, NULL);
+ xmlFree(buf);
}
/**
@@ -3076,7 +3346,7 @@ htmlParseCharRef(htmlParserCtxtPtr ctxt) {
((NXT(2) == 'x') || NXT(2) == 'X')) {
SKIP(3);
while (CUR != ';') {
- if ((CUR >= '0') && (CUR <= '9'))
+ if ((CUR >= '0') && (CUR <= '9'))
val = val * 16 + (CUR - '0');
else if ((CUR >= 'a') && (CUR <= 'f'))
val = val * 16 + (CUR - 'a') + 10;
@@ -3084,9 +3354,9 @@ htmlParseCharRef(htmlParserCtxtPtr ctxt) {
val = val * 16 + (CUR - 'A') + 10;
else {
htmlParseErr(ctxt, XML_ERR_INVALID_HEX_CHARREF,
- "htmlParseCharRef: invalid hexadecimal value\n",
+ "htmlParseCharRef: missing semicolon\n",
NULL, NULL);
- return(0);
+ break;
}
NEXT;
}
@@ -3095,13 +3365,13 @@ htmlParseCharRef(htmlParserCtxtPtr ctxt) {
} else if ((CUR == '&') && (NXT(1) == '#')) {
SKIP(2);
while (CUR != ';') {
- if ((CUR >= '0') && (CUR <= '9'))
+ if ((CUR >= '0') && (CUR <= '9'))
val = val * 10 + (CUR - '0');
else {
htmlParseErr(ctxt, XML_ERR_INVALID_DEC_CHARREF,
- "htmlParseCharRef: invalid decimal value\n",
+ "htmlParseCharRef: missing semicolon\n",
NULL, NULL);
- return(0);
+ break;
}
NEXT;
}
@@ -3131,7 +3401,7 @@ htmlParseCharRef(htmlParserCtxtPtr ctxt) {
*
* parse a DOCTYPE declaration
*
- * [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S?
+ * [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S?
* ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
*/
@@ -3235,11 +3505,6 @@ htmlParseAttribute(htmlParserCtxtPtr ctxt, xmlChar **value) {
NEXT;
SKIP_BLANKS;
val = htmlParseAttValue(ctxt);
- } else if (htmlIsBooleanAttr(name)) {
- /*
- * assume a minimized attribute
- */
- val = xmlStrdup(name);
}
*value = val;
@@ -3247,34 +3512,26 @@ htmlParseAttribute(htmlParserCtxtPtr ctxt, xmlChar **value) {
}
/**
- * htmlCheckEncoding:
+ * htmlCheckEncodingDirect:
* @ctxt: an HTML parser context
* @attvalue: the attribute value
*
- * Checks an http-equiv attribute from a Meta tag to detect
+ * Checks an attribute value to detect
* the encoding
* If a new encoding is detected the parser is switched to decode
* it and pass UTF8
*/
static void
-htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
- const xmlChar *encoding;
+htmlCheckEncodingDirect(htmlParserCtxtPtr ctxt, const xmlChar *encoding) {
- if ((ctxt == NULL) || (attvalue == NULL))
+ if ((ctxt == NULL) || (encoding == NULL) ||
+ (ctxt->options & HTML_PARSE_IGNORE_ENC))
return;
- /* do not change encoding */
+ /* do not change encoding */
if (ctxt->input->encoding != NULL)
return;
- encoding = xmlStrcasestr(attvalue, BAD_CAST"charset=");
- if (encoding != NULL) {
- encoding += 8;
- } else {
- encoding = xmlStrcasestr(attvalue, BAD_CAST"charset =");
- if (encoding != NULL)
- encoding += 9;
- }
if (encoding != NULL) {
xmlCharEncoding enc;
xmlCharEncodingHandlerPtr handler;
@@ -3290,7 +3547,7 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
* registered set of known encodings
*/
if (enc != XML_CHAR_ENCODING_ERROR) {
- if (((enc == XML_CHAR_ENCODING_UTF16LE) ||
+ if (((enc == XML_CHAR_ENCODING_UTF16LE) ||
(enc == XML_CHAR_ENCODING_UTF16BE) ||
(enc == XML_CHAR_ENCODING_UCS4LE) ||
(enc == XML_CHAR_ENCODING_UCS4BE)) &&
@@ -3312,7 +3569,9 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
xmlSwitchToEncoding(ctxt, handler);
ctxt->charset = XML_CHAR_ENCODING_UTF8;
} else {
- ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING;
+ htmlParseErr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
+ "htmlCheckEncoding: unknown encoding %s\n",
+ encoding, NULL);
}
}
@@ -3327,22 +3586,51 @@ htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
* convert as much as possible to the parser reading buffer.
*/
processed = ctxt->input->cur - ctxt->input->base;
- xmlBufferShrink(ctxt->input->buf->buffer, processed);
- nbchars = xmlCharEncInFunc(ctxt->input->buf->encoder,
- ctxt->input->buf->buffer,
- ctxt->input->buf->raw);
+ xmlBufShrink(ctxt->input->buf->buffer, processed);
+ nbchars = xmlCharEncInput(ctxt->input->buf, 1);
if (nbchars < 0) {
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
"htmlCheckEncoding: encoder error\n",
NULL, NULL);
}
- ctxt->input->base =
- ctxt->input->cur = ctxt->input->buf->buffer->content;
+ xmlBufResetInput(ctxt->input->buf->buffer, ctxt->input);
}
}
}
/**
+ * htmlCheckEncoding:
+ * @ctxt: an HTML parser context
+ * @attvalue: the attribute value
+ *
+ * Checks an http-equiv attribute from a Meta tag to detect
+ * the encoding
+ * If a new encoding is detected the parser is switched to decode
+ * it and pass UTF8
+ */
+static void
+htmlCheckEncoding(htmlParserCtxtPtr ctxt, const xmlChar *attvalue) {
+ const xmlChar *encoding;
+
+ if (!attvalue)
+ return;
+
+ encoding = xmlStrcasestr(attvalue, BAD_CAST"charset");
+ if (encoding != NULL) {
+ encoding += 7;
+ }
+ /*
+ * skip blank
+ */
+ if (encoding && IS_BLANK_CH(*encoding))
+ encoding = xmlStrcasestr(attvalue, BAD_CAST"=");
+ if (encoding && *encoding == '=') {
+ encoding ++;
+ htmlCheckEncodingDirect(ctxt, encoding);
+ }
+}
+
+/**
* htmlCheckMeta:
* @ctxt: an HTML parser context
* @atts: the attributes values
@@ -3366,6 +3654,8 @@ htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
if ((value != NULL) && (!xmlStrcasecmp(att, BAD_CAST"http-equiv"))
&& (!xmlStrcasecmp(value, BAD_CAST"Content-Type")))
http = 1;
+ else if ((value != NULL) && (!xmlStrcasecmp(att, BAD_CAST"charset")))
+ htmlCheckEncodingDirect(ctxt, value);
else if ((value != NULL) && (!xmlStrcasecmp(att, BAD_CAST"content")))
content = value;
att = atts[i++];
@@ -3378,7 +3668,7 @@ htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
/**
* htmlParseStartTag:
* @ctxt: an HTML parser context
- *
+ *
* parse a start of tag either for rule element or
* EmptyElement. In both case we don't parse the tag closing chars.
*
@@ -3392,7 +3682,7 @@ htmlCheckMeta(htmlParserCtxtPtr ctxt, const xmlChar **atts) {
*
* [NS 10] EmptyElement ::= '<' QName (S Attribute)* S? '/>'
*
- * Returns 0 in case of success and -1 in case of error.
+ * Returns 0 in case of success, -1 in case of error and 1 if discarded
*/
static int
@@ -3405,12 +3695,15 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
int maxatts;
int meta = 0;
int i;
+ int discardtag = 0;
if ((ctxt == NULL) || (ctxt->input == NULL)) {
htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
"htmlParseStartTag: context error\n", NULL, NULL);
return -1;
}
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(-1);
if (CUR != '<') return -1;
NEXT;
@@ -3423,8 +3716,17 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
htmlParseErr(ctxt, XML_ERR_NAME_REQUIRED,
"htmlParseStartTag: invalid element name\n",
NULL, NULL);
+ /* if recover preserve text on classic misconstructs */
+ if ((ctxt->recovery) && ((IS_BLANK_CH(CUR)) || (CUR == '<') ||
+ (CUR == '=') || (CUR == '>') || (((CUR >= '0') && (CUR <= '9'))))) {
+ htmlParseCharDataInternal(ctxt, '<');
+ return(-1);
+ }
+
+
/* Dump the bogus tag like browsers do */
- while ((IS_CHAR_CH(CUR)) && (CUR != '>'))
+ while ((IS_CHAR_CH(CUR)) && (CUR != '>') &&
+ (ctxt->instate != XML_PARSER_EOF))
NEXT;
return -1;
}
@@ -3449,14 +3751,16 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"htmlParseStartTag: misplaced <html> tag\n",
name, NULL);
- return 0;
+ discardtag = 1;
+ ctxt->depth++;
}
- if ((ctxt->nameNr != 1) &&
+ if ((ctxt->nameNr != 1) &&
(xmlStrEqual(name, BAD_CAST"head"))) {
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"htmlParseStartTag: misplaced <head> tag\n",
name, NULL);
- return 0;
+ discardtag = 1;
+ ctxt->depth++;
}
if (xmlStrEqual(name, BAD_CAST"body")) {
int indx;
@@ -3465,9 +3769,8 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"htmlParseStartTag: misplaced <body> tag\n",
name, NULL);
- while ((IS_CHAR_CH(CUR)) && (CUR != '>'))
- NEXT;
- return 0;
+ discardtag = 1;
+ ctxt->depth++;
}
}
}
@@ -3479,7 +3782,7 @@ htmlParseStartTag(htmlParserCtxtPtr ctxt) {
*/
SKIP_BLANKS;
while ((IS_CHAR_CH(CUR)) &&
- (CUR != '>') &&
+ (CUR != '>') &&
((CUR != '/') || (NXT(1) != '>'))) {
long cons = ctxt->nbChars;
@@ -3560,18 +3863,20 @@ failed:
/*
* Handle specific association to the META tag
*/
- if (meta)
+ if (meta && (nbatts != 0))
htmlCheckMeta(ctxt, atts);
/*
* SAX: Start of Element !
*/
- htmlnamePush(ctxt, name);
- if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) {
- if (nbatts != 0)
- ctxt->sax->startElement(ctxt->userData, name, atts);
- else
- ctxt->sax->startElement(ctxt->userData, name, NULL);
+ if (!discardtag) {
+ htmlnamePush(ctxt, name);
+ if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) {
+ if (nbatts != 0)
+ ctxt->sax->startElement(ctxt->userData, name, atts);
+ else
+ ctxt->sax->startElement(ctxt->userData, name, NULL);
+ }
}
if (atts != NULL) {
@@ -3581,7 +3886,7 @@ failed:
}
}
- return 0;
+ return(discardtag);
}
/**
@@ -3616,7 +3921,6 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt)
name = htmlParseHTMLName(ctxt);
if (name == NULL)
return (0);
-
/*
* We should definitely be at the ending "S? '>'" part
*/
@@ -3637,6 +3941,18 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt)
NEXT;
/*
+ * if we ignored misplaced tags in htmlParseStartTag don't pop them
+ * out now.
+ */
+ if ((ctxt->depth > 0) &&
+ (xmlStrEqual(name, BAD_CAST "html") ||
+ xmlStrEqual(name, BAD_CAST "body") ||
+ xmlStrEqual(name, BAD_CAST "head"))) {
+ ctxt->depth--;
+ return (0);
+ }
+
+ /*
* If the name read is not one of the element in the parsing stack
* then return, it's just an error.
*/
@@ -3677,6 +3993,7 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt)
if ((oldname != NULL) && (xmlStrEqual(oldname, name))) {
if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
ctxt->sax->endElement(ctxt->userData, name);
+ htmlNodeInfoPop(ctxt);
htmlnamePop(ctxt);
ret = 1;
} else {
@@ -3690,7 +4007,7 @@ htmlParseEndTag(htmlParserCtxtPtr ctxt)
/**
* htmlParseReference:
* @ctxt: an HTML parser context
- *
+ *
* parse and handle entity references in content,
* this will end-up in a call to character() since this is either a
* CharRef, or a predefined entity.
@@ -3714,7 +4031,7 @@ htmlParseReference(htmlParserCtxtPtr ctxt) {
else if (c < 0x800) { out[i++]=((c >> 6) & 0x1F) | 0xC0; bits= 0; }
else if (c < 0x10000) { out[i++]=((c >> 12) & 0x0F) | 0xE0; bits= 6; }
else { out[i++]=((c >> 18) & 0x07) | 0xF0; bits= 12; }
-
+
for ( ; bits >= 0; bits-= 6) {
out[i++]= ((c >> bits) & 0x3F) | 0x80;
}
@@ -3749,9 +4066,9 @@ htmlParseReference(htmlParserCtxtPtr ctxt) {
{ out[i++]=((c >> 6) & 0x1F) | 0xC0; bits= 0; }
else if (c < 0x10000)
{ out[i++]=((c >> 12) & 0x0F) | 0xE0; bits= 6; }
- else
+ else
{ out[i++]=((c >> 18) & 0x07) | 0xF0; bits= 12; }
-
+
for ( ; bits >= 0; bits-= 6) {
out[i++]= ((c >> bits) & 0x3F) | 0x80;
}
@@ -3769,12 +4086,14 @@ htmlParseReference(htmlParserCtxtPtr ctxt) {
* @ctxt: an HTML parser context
*
* Parse a content: comment, sub-element, reference or text.
+ * Kept for compatibility with old code
*/
static void
htmlParseContent(htmlParserCtxtPtr ctxt) {
xmlChar *currentNode;
int depth;
+ const xmlChar *name;
currentNode = xmlStrdup(ctxt->name);
depth = ctxt->nameNr;
@@ -3782,6 +4101,10 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
long cons = ctxt->nbChars;
GROW;
+
+ if (ctxt->instate == XML_PARSER_EOF)
+ break;
+
/*
* Our tag or one of it's parent or children is ending.
*/
@@ -3795,6 +4118,31 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
continue; /* while */
}
+ else if ((CUR == '<') &&
+ ((IS_ASCII_LETTER(NXT(1))) ||
+ (NXT(1) == '_') || (NXT(1) == ':'))) {
+ name = htmlParseHTMLName_nonInvasive(ctxt);
+ if (name == NULL) {
+ htmlParseErr(ctxt, XML_ERR_NAME_REQUIRED,
+ "htmlParseStartTag: invalid element name\n",
+ NULL, NULL);
+ /* Dump the bogus tag like browsers do */
+ while ((IS_CHAR_CH(CUR)) && (CUR != '>'))
+ NEXT;
+
+ if (currentNode != NULL)
+ xmlFree(currentNode);
+ return;
+ }
+
+ if (ctxt->name != NULL) {
+ if (htmlCheckAutoClose(name, ctxt->name) == 1) {
+ htmlAutoClose(ctxt, name);
+ continue;
+ }
+ }
+ }
+
/*
* Has this node been popped out during parsing of
* the next element
@@ -3851,7 +4199,7 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
/*
* Fourth case : a reference. If if has not been resolved,
- * parsing returns it's Name, create the node
+ * parsing returns it's Name, create the node
*/
else if (CUR == '&') {
htmlParseReference(ctxt);
@@ -3887,23 +4235,11 @@ htmlParseContent(htmlParserCtxtPtr ctxt) {
}
/**
- * htmlParseContent:
- * @ctxt: an HTML parser context
- *
- * Parse a content: comment, sub-element, reference or text.
- */
-
-void
-__htmlParseContent(void *ctxt) {
- if (ctxt != NULL)
- htmlParseContent((htmlParserCtxtPtr) ctxt);
-}
-
-/**
* htmlParseElement:
* @ctxt: an HTML parser context
*
* parse an HTML element, this is highly recursive
+ * this is kept for compatibility with previous code versions
*
* [39] element ::= EmptyElemTag | STag content ETag
*
@@ -3925,6 +4261,10 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
"htmlParseElement: context error\n", NULL, NULL);
return;
}
+
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
+
/* Capture start position */
if (ctxt->record_info) {
node_info.begin_pos = ctxt->input->consumed +
@@ -3934,7 +4274,7 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
failed = htmlParseStartTag(ctxt);
name = ctxt->name;
- if (failed || (name == NULL)) {
+ if ((failed == -1) || (name == NULL)) {
if (CUR == '>')
NEXT;
return;
@@ -3969,10 +4309,10 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
/*
* end of parsing of this node.
*/
- if (xmlStrEqual(name, ctxt->name)) {
+ if (xmlStrEqual(name, ctxt->name)) {
nodePop(ctxt);
htmlnamePop(ctxt);
- }
+ }
/*
* Capture end position and add node
@@ -4006,8 +4346,8 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
oldptr = ctxt->input->cur;
htmlParseContent(ctxt);
if (oldptr==ctxt->input->cur) break;
- if (ctxt->nameNr < depth) break;
- }
+ if (ctxt->nameNr < depth) break;
+ }
/*
* Capture end position and add node
@@ -4027,10 +4367,305 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
xmlFree(currentNode);
}
+static void
+htmlParserFinishElementParsing(htmlParserCtxtPtr ctxt) {
+ /*
+ * Capture end position and add node
+ */
+ if ( ctxt->node != NULL && ctxt->record_info ) {
+ ctxt->nodeInfo->end_pos = ctxt->input->consumed +
+ (CUR_PTR - ctxt->input->base);
+ ctxt->nodeInfo->end_line = ctxt->input->line;
+ ctxt->nodeInfo->node = ctxt->node;
+ xmlParserAddNodeInfo(ctxt, ctxt->nodeInfo);
+ htmlNodeInfoPop(ctxt);
+ }
+ if (!IS_CHAR_CH(CUR)) {
+ htmlAutoCloseOnEnd(ctxt);
+ }
+}
+
+/**
+ * htmlParseElementInternal:
+ * @ctxt: an HTML parser context
+ *
+ * parse an HTML element, new version, non recursive
+ *
+ * [39] element ::= EmptyElemTag | STag content ETag
+ *
+ * [41] Attribute ::= Name Eq AttValue
+ */
+
+static void
+htmlParseElementInternal(htmlParserCtxtPtr ctxt) {
+ const xmlChar *name;
+ const htmlElemDesc * info;
+ htmlParserNodeInfo node_info = { 0, };
+ int failed;
+
+ if ((ctxt == NULL) || (ctxt->input == NULL)) {
+ htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
+ "htmlParseElementInternal: context error\n", NULL, NULL);
+ return;
+ }
+
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
+
+ /* Capture start position */
+ if (ctxt->record_info) {
+ node_info.begin_pos = ctxt->input->consumed +
+ (CUR_PTR - ctxt->input->base);
+ node_info.begin_line = ctxt->input->line;
+ }
+
+ failed = htmlParseStartTag(ctxt);
+ name = ctxt->name;
+ if ((failed == -1) || (name == NULL)) {
+ if (CUR == '>')
+ NEXT;
+ return;
+ }
+
+ /*
+ * Lookup the info for that element.
+ */
+ info = htmlTagLookup(name);
+ if (info == NULL) {
+ htmlParseErr(ctxt, XML_HTML_UNKNOWN_TAG,
+ "Tag %s invalid\n", name, NULL);
+ }
+
+ /*
+ * Check for an Empty Element labeled the XML/SGML way
+ */
+ if ((CUR == '/') && (NXT(1) == '>')) {
+ SKIP(2);
+ if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
+ ctxt->sax->endElement(ctxt->userData, name);
+ htmlnamePop(ctxt);
+ return;
+ }
+
+ if (CUR == '>') {
+ NEXT;
+ } else {
+ htmlParseErr(ctxt, XML_ERR_GT_REQUIRED,
+ "Couldn't find end of Start Tag %s\n", name, NULL);
+
+ /*
+ * end of parsing of this node.
+ */
+ if (xmlStrEqual(name, ctxt->name)) {
+ nodePop(ctxt);
+ htmlnamePop(ctxt);
+ }
+
+ if (ctxt->record_info)
+ htmlNodeInfoPush(ctxt, &node_info);
+ htmlParserFinishElementParsing(ctxt);
+ return;
+ }
+
+ /*
+ * Check for an Empty Element from DTD definition
+ */
+ if ((info != NULL) && (info->empty)) {
+ if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL))
+ ctxt->sax->endElement(ctxt->userData, name);
+ htmlnamePop(ctxt);
+ return;
+ }
+
+ if (ctxt->record_info)
+ htmlNodeInfoPush(ctxt, &node_info);
+}
+
+/**
+ * htmlParseContentInternal:
+ * @ctxt: an HTML parser context
+ *
+ * Parse a content: comment, sub-element, reference or text.
+ * New version for non recursive htmlParseElementInternal
+ */
+
+static void
+htmlParseContentInternal(htmlParserCtxtPtr ctxt) {
+ xmlChar *currentNode;
+ int depth;
+ const xmlChar *name;
+
+ currentNode = xmlStrdup(ctxt->name);
+ depth = ctxt->nameNr;
+ while (1) {
+ long cons = ctxt->nbChars;
+
+ GROW;
+
+ if (ctxt->instate == XML_PARSER_EOF)
+ break;
+
+ /*
+ * Our tag or one of it's parent or children is ending.
+ */
+ if ((CUR == '<') && (NXT(1) == '/')) {
+ if (htmlParseEndTag(ctxt) &&
+ ((currentNode != NULL) || (ctxt->nameNr == 0))) {
+ if (currentNode != NULL)
+ xmlFree(currentNode);
+
+ currentNode = xmlStrdup(ctxt->name);
+ depth = ctxt->nameNr;
+ }
+ continue; /* while */
+ }
+
+ else if ((CUR == '<') &&
+ ((IS_ASCII_LETTER(NXT(1))) ||
+ (NXT(1) == '_') || (NXT(1) == ':'))) {
+ name = htmlParseHTMLName_nonInvasive(ctxt);
+ if (name == NULL) {
+ htmlParseErr(ctxt, XML_ERR_NAME_REQUIRED,
+ "htmlParseStartTag: invalid element name\n",
+ NULL, NULL);
+ /* Dump the bogus tag like browsers do */
+ while ((IS_CHAR_CH(CUR)) && (CUR != '>'))
+ NEXT;
+
+ htmlParserFinishElementParsing(ctxt);
+ if (currentNode != NULL)
+ xmlFree(currentNode);
+
+ currentNode = xmlStrdup(ctxt->name);
+ depth = ctxt->nameNr;
+ continue;
+ }
+
+ if (ctxt->name != NULL) {
+ if (htmlCheckAutoClose(name, ctxt->name) == 1) {
+ htmlAutoClose(ctxt, name);
+ continue;
+ }
+ }
+ }
+
+ /*
+ * Has this node been popped out during parsing of
+ * the next element
+ */
+ if ((ctxt->nameNr > 0) && (depth >= ctxt->nameNr) &&
+ (!xmlStrEqual(currentNode, ctxt->name)))
+ {
+ htmlParserFinishElementParsing(ctxt);
+ if (currentNode != NULL) xmlFree(currentNode);
+
+ currentNode = xmlStrdup(ctxt->name);
+ depth = ctxt->nameNr;
+ continue;
+ }
+
+ if ((CUR != 0) && ((xmlStrEqual(currentNode, BAD_CAST"script")) ||
+ (xmlStrEqual(currentNode, BAD_CAST"style")))) {
+ /*
+ * Handle SCRIPT/STYLE separately
+ */
+ htmlParseScript(ctxt);
+ } else {
+ /*
+ * Sometimes DOCTYPE arrives in the middle of the document
+ */
+ if ((CUR == '<') && (NXT(1) == '!') &&
+ (UPP(2) == 'D') && (UPP(3) == 'O') &&
+ (UPP(4) == 'C') && (UPP(5) == 'T') &&
+ (UPP(6) == 'Y') && (UPP(7) == 'P') &&
+ (UPP(8) == 'E')) {
+ htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
+ "Misplaced DOCTYPE declaration\n",
+ BAD_CAST "DOCTYPE" , NULL);
+ htmlParseDocTypeDecl(ctxt);
+ }
+
+ /*
+ * First case : a comment
+ */
+ if ((CUR == '<') && (NXT(1) == '!') &&
+ (NXT(2) == '-') && (NXT(3) == '-')) {
+ htmlParseComment(ctxt);
+ }
+
+ /*
+ * Second case : a Processing Instruction.
+ */
+ else if ((CUR == '<') && (NXT(1) == '?')) {
+ htmlParsePI(ctxt);
+ }
+
+ /*
+ * Third case : a sub-element.
+ */
+ else if (CUR == '<') {
+ htmlParseElementInternal(ctxt);
+ if (currentNode != NULL) xmlFree(currentNode);
+
+ currentNode = xmlStrdup(ctxt->name);
+ depth = ctxt->nameNr;
+ }
+
+ /*
+ * Fourth case : a reference. If if has not been resolved,
+ * parsing returns it's Name, create the node
+ */
+ else if (CUR == '&') {
+ htmlParseReference(ctxt);
+ }
+
+ /*
+ * Fifth case : end of the resource
+ */
+ else if (CUR == 0) {
+ htmlAutoCloseOnEnd(ctxt);
+ break;
+ }
+
+ /*
+ * Last case, text. Note that References are handled directly.
+ */
+ else {
+ htmlParseCharData(ctxt);
+ }
+
+ if (cons == ctxt->nbChars) {
+ if (ctxt->node != NULL) {
+ htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR,
+ "detected an error in element content\n",
+ NULL, NULL);
+ }
+ break;
+ }
+ }
+ GROW;
+ }
+ if (currentNode != NULL) xmlFree(currentNode);
+}
+
+/**
+ * htmlParseContent:
+ * @ctxt: an HTML parser context
+ *
+ * Parse a content: comment, sub-element, reference or text.
+ * This is the entry point when called from parser.c
+ */
+
+void
+__htmlParseContent(void *ctxt) {
+ if (ctxt != NULL)
+ htmlParseContentInternal((htmlParserCtxtPtr) ctxt);
+}
+
/**
* htmlParseDocument:
* @ctxt: an HTML parser context
- *
+ *
* parse an HTML document (and build a tree if using the standard SAX
* interface).
*
@@ -4040,6 +4675,8 @@ htmlParseElement(htmlParserCtxtPtr ctxt) {
int
htmlParseDocument(htmlParserCtxtPtr ctxt) {
+ xmlChar start[4];
+ xmlCharEncoding enc;
xmlDtdPtr dtd;
xmlInitParser();
@@ -4052,6 +4689,7 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
return(XML_ERR_INTERNAL_ERROR);
}
ctxt->html = 1;
+ ctxt->linenumbers = 1;
GROW;
/*
* SAX: beginning of the document processing.
@@ -4059,12 +4697,29 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
+ if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) &&
+ ((ctxt->input->end - ctxt->input->cur) >= 4)) {
+ /*
+ * Get the 4 first bytes and decode the charset
+ * if enc != XML_CHAR_ENCODING_NONE
+ * plug some encoding conversion routines.
+ */
+ start[0] = RAW;
+ start[1] = NXT(1);
+ start[2] = NXT(2);
+ start[3] = NXT(3);
+ enc = xmlDetectCharEncoding(&start[0], 4);
+ if (enc != XML_CHAR_ENCODING_NONE) {
+ xmlSwitchEncoding(ctxt, enc);
+ }
+ }
+
/*
* Wipe out everything which is before the first '<'
*/
SKIP_BLANKS;
if (CUR == 0) {
- htmlParseErr(ctxt, XML_ERR_DOCUMENT_EMPTY,
+ htmlParseErr(ctxt, XML_ERR_DOCUMENT_EMPTY,
"Document is empty\n", NULL, NULL);
}
@@ -4078,10 +4733,10 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
while (((CUR == '<') && (NXT(1) == '!') &&
(NXT(2) == '-') && (NXT(3) == '-')) ||
((CUR == '<') && (NXT(1) == '?'))) {
- htmlParseComment(ctxt);
- htmlParsePI(ctxt);
+ htmlParseComment(ctxt);
+ htmlParsePI(ctxt);
SKIP_BLANKS;
- }
+ }
/*
@@ -4103,15 +4758,15 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
while (((CUR == '<') && (NXT(1) == '!') &&
(NXT(2) == '-') && (NXT(3) == '-')) ||
((CUR == '<') && (NXT(1) == '?'))) {
- htmlParseComment(ctxt);
- htmlParsePI(ctxt);
+ htmlParseComment(ctxt);
+ htmlParsePI(ctxt);
SKIP_BLANKS;
- }
+ }
/*
* Time to start parsing the tree itself
*/
- htmlParseContent(ctxt);
+ htmlParseContentInternal(ctxt);
/*
* autoclose
@@ -4126,11 +4781,11 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
ctxt->sax->endDocument(ctxt->userData);
- if (ctxt->myDoc != NULL) {
+ if ((!(ctxt->options & HTML_PARSE_NODEFDTD)) && (ctxt->myDoc != NULL)) {
dtd = xmlGetIntSubset(ctxt->myDoc);
if (dtd == NULL)
- ctxt->myDoc->intSubset =
- xmlCreateIntSubset(ctxt->myDoc, BAD_CAST "html",
+ ctxt->myDoc->intSubset =
+ xmlCreateIntSubset(ctxt->myDoc, BAD_CAST "html",
BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN",
BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd");
}
@@ -4176,7 +4831,7 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
memset(sax, 0, sizeof(htmlSAXHandler));
/* Allocate the Input stack */
- ctxt->inputTab = (htmlParserInputPtr *)
+ ctxt->inputTab = (htmlParserInputPtr *)
xmlMalloc(5 * sizeof(htmlParserInputPtr));
if (ctxt->inputTab == NULL) {
htmlErrMemory(NULL, "htmlInitParserCtxt: out of memory\n");
@@ -4214,7 +4869,7 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
if (ctxt->nameTab == NULL) {
htmlErrMemory(NULL, "htmlInitParserCtxt: out of memory\n");
ctxt->nameNr = 0;
- ctxt->nameMax = 10;
+ ctxt->nameMax = 0;
ctxt->name = NULL;
ctxt->nodeNr = 0;
ctxt->nodeMax = 0;
@@ -4228,6 +4883,10 @@ htmlInitParserCtxt(htmlParserCtxtPtr ctxt)
ctxt->nameMax = 10;
ctxt->name = NULL;
+ ctxt->nodeInfoTab = NULL;
+ ctxt->nodeInfoNr = 0;
+ ctxt->nodeInfoMax = 0;
+
if (sax == NULL) ctxt->sax = (xmlSAXHandlerPtr) &htmlDefaultSAXHandler;
else {
ctxt->sax = sax;
@@ -4327,9 +4986,7 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) {
input->filename = NULL;
input->buf = buf;
- input->base = input->buf->buffer->content;
- input->cur = input->buf->buffer->content;
- input->end = &input->buf->buffer->content[input->buf->buffer->use];
+ xmlBufResetInput(buf->buffer, input);
inputPush(ctxt, input);
return(ctxt);
@@ -4347,8 +5004,7 @@ htmlCreateMemoryParserCtxt(const char *buffer, int size) {
* Returns the new parser context or NULL
*/
static htmlParserCtxtPtr
-htmlCreateDocParserCtxt(const xmlChar *cur,
- const char *encoding ATTRIBUTE_UNUSED) {
+htmlCreateDocParserCtxt(const xmlChar *cur, const char *encoding) {
int len;
htmlParserCtxtPtr ctxt;
@@ -4356,6 +5012,8 @@ htmlCreateDocParserCtxt(const xmlChar *cur,
return(NULL);
len = xmlStrlen(cur);
ctxt = htmlCreateMemoryParserCtxt((char *)cur, len);
+ if (ctxt == NULL)
+ return(NULL);
if (encoding != NULL) {
xmlCharEncoding enc;
@@ -4373,7 +5031,7 @@ htmlCreateDocParserCtxt(const xmlChar *cur,
xmlSwitchEncoding(ctxt, enc);
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
htmlParseErr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
- "Unsupported encoding %s\n",
+ "Unsupported encoding %s\n",
(const xmlChar *) encoding, NULL);
}
} else {
@@ -4396,7 +5054,7 @@ htmlCreateDocParserCtxt(const xmlChar *cur,
#ifdef LIBXML_PUSH_ENABLED
/************************************************************************
* *
- * Progressive parsing interfaces *
+ * Progressive parsing interfaces *
* *
************************************************************************/
@@ -4420,85 +5078,190 @@ htmlCreateDocParserCtxt(const xmlChar *cur,
*/
static int
htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
- xmlChar next, xmlChar third, int iscomment) {
+ xmlChar next, xmlChar third, int iscomment,
+ int ignoreattrval)
+{
int base, len;
htmlParserInputPtr in;
const xmlChar *buf;
int incomment = 0;
+ int invalue = 0;
+ char valdellim = 0x0;
in = ctxt->input;
- if (in == NULL) return(-1);
+ if (in == NULL)
+ return (-1);
+
base = in->cur - in->base;
- if (base < 0) return(-1);
+ if (base < 0)
+ return (-1);
+
if (ctxt->checkIndex > base)
base = ctxt->checkIndex;
+
if (in->buf == NULL) {
- buf = in->base;
- len = in->length;
+ buf = in->base;
+ len = in->length;
} else {
- buf = in->buf->buffer->content;
- len = in->buf->buffer->use;
+ buf = xmlBufContent(in->buf->buffer);
+ len = xmlBufUse(in->buf->buffer);
}
+
/* take into account the sequence length */
- if (third) len -= 2;
- else if (next) len --;
- for (;base < len;base++) {
- if (!incomment && (base + 4 < len) && !iscomment) {
- if ((buf[base] == '<') && (buf[base + 1] == '!') &&
- (buf[base + 2] == '-') && (buf[base + 3] == '-')) {
- incomment = 1;
- /* do not increment past <! - some people use <!--> */
- base += 2;
- }
- }
- if (incomment) {
- if (base + 3 > len)
- return(-1);
- if ((buf[base] == '-') && (buf[base + 1] == '-') &&
- (buf[base + 2] == '>')) {
- incomment = 0;
- base += 2;
- }
- continue;
- }
+ if (third)
+ len -= 2;
+ else if (next)
+ len--;
+ for (; base < len; base++) {
+ if ((!incomment) && (base + 4 < len) && (!iscomment)) {
+ if ((buf[base] == '<') && (buf[base + 1] == '!') &&
+ (buf[base + 2] == '-') && (buf[base + 3] == '-')) {
+ incomment = 1;
+ /* do not increment past <! - some people use <!--> */
+ base += 2;
+ }
+ }
+ if (ignoreattrval) {
+ if (buf[base] == '"' || buf[base] == '\'') {
+ if (invalue) {
+ if (buf[base] == valdellim) {
+ invalue = 0;
+ continue;
+ }
+ } else {
+ valdellim = buf[base];
+ invalue = 1;
+ continue;
+ }
+ } else if (invalue) {
+ continue;
+ }
+ }
+ if (incomment) {
+ if (base + 3 > len)
+ return (-1);
+ if ((buf[base] == '-') && (buf[base + 1] == '-') &&
+ (buf[base + 2] == '>')) {
+ incomment = 0;
+ base += 2;
+ }
+ continue;
+ }
if (buf[base] == first) {
- if (third != 0) {
- if ((buf[base + 1] != next) ||
- (buf[base + 2] != third)) continue;
- } else if (next != 0) {
- if (buf[base + 1] != next) continue;
- }
- ctxt->checkIndex = 0;
+ if (third != 0) {
+ if ((buf[base + 1] != next) || (buf[base + 2] != third))
+ continue;
+ } else if (next != 0) {
+ if (buf[base + 1] != next)
+ continue;
+ }
+ ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
- if (next == 0)
- xmlGenericError(xmlGenericErrorContext,
- "HPP: lookup '%c' found at %d\n",
- first, base);
- else if (third == 0)
- xmlGenericError(xmlGenericErrorContext,
- "HPP: lookup '%c%c' found at %d\n",
- first, next, base);
- else
- xmlGenericError(xmlGenericErrorContext,
- "HPP: lookup '%c%c%c' found at %d\n",
- first, next, third, base);
+ if (next == 0)
+ xmlGenericError(xmlGenericErrorContext,
+ "HPP: lookup '%c' found at %d\n",
+ first, base);
+ else if (third == 0)
+ xmlGenericError(xmlGenericErrorContext,
+ "HPP: lookup '%c%c' found at %d\n",
+ first, next, base);
+ else
+ xmlGenericError(xmlGenericErrorContext,
+ "HPP: lookup '%c%c%c' found at %d\n",
+ first, next, third, base);
#endif
- return(base - (in->cur - in->base));
- }
+ return (base - (in->cur - in->base));
+ }
}
- ctxt->checkIndex = base;
+ if ((!incomment) && (!invalue))
+ ctxt->checkIndex = base;
#ifdef DEBUG_PUSH
if (next == 0)
- xmlGenericError(xmlGenericErrorContext,
- "HPP: lookup '%c' failed\n", first);
+ xmlGenericError(xmlGenericErrorContext,
+ "HPP: lookup '%c' failed\n", first);
else if (third == 0)
- xmlGenericError(xmlGenericErrorContext,
- "HPP: lookup '%c%c' failed\n", first, next);
- else
- xmlGenericError(xmlGenericErrorContext,
- "HPP: lookup '%c%c%c' failed\n", first, next, third);
+ xmlGenericError(xmlGenericErrorContext,
+ "HPP: lookup '%c%c' failed\n", first, next);
+ else
+ xmlGenericError(xmlGenericErrorContext,
+ "HPP: lookup '%c%c%c' failed\n", first, next,
+ third);
#endif
- return(-1);
+ return (-1);
+}
+
+/**
+ * htmlParseLookupChars:
+ * @ctxt: an HTML parser context
+ * @stop: Array of chars, which stop the lookup.
+ * @stopLen: Length of stop-Array
+ *
+ * Try to find if any char of the stop-Array is available in the input
+ * stream.
+ * This function has a side effect of (possibly) incrementing ctxt->checkIndex
+ * to avoid rescanning sequences of bytes, it DOES change the state of the
+ * parser, do not use liberally.
+ *
+ * Returns the index to the current parsing point if a stopChar
+ * is available, -1 otherwise.
+ */
+static int
+htmlParseLookupChars(htmlParserCtxtPtr ctxt, const xmlChar * stop,
+ int stopLen)
+{
+ int base, len;
+ htmlParserInputPtr in;
+ const xmlChar *buf;
+ int incomment = 0;
+ int i;
+
+ in = ctxt->input;
+ if (in == NULL)
+ return (-1);
+
+ base = in->cur - in->base;
+ if (base < 0)
+ return (-1);
+
+ if (ctxt->checkIndex > base)
+ base = ctxt->checkIndex;
+
+ if (in->buf == NULL) {
+ buf = in->base;
+ len = in->length;
+ } else {
+ buf = xmlBufContent(in->buf->buffer);
+ len = xmlBufUse(in->buf->buffer);
+ }
+
+ for (; base < len; base++) {
+ if (!incomment && (base + 4 < len)) {
+ if ((buf[base] == '<') && (buf[base + 1] == '!') &&
+ (buf[base + 2] == '-') && (buf[base + 3] == '-')) {
+ incomment = 1;
+ /* do not increment past <! - some people use <!--> */
+ base += 2;
+ }
+ }
+ if (incomment) {
+ if (base + 3 > len)
+ return (-1);
+ if ((buf[base] == '-') && (buf[base + 1] == '-') &&
+ (buf[base + 2] == '>')) {
+ incomment = 0;
+ base += 2;
+ }
+ continue;
+ }
+ for (i = 0; i < stopLen; ++i) {
+ if (buf[base] == stop[i]) {
+ ctxt->checkIndex = 0;
+ return (base - (in->cur - in->base));
+ }
+ }
+ }
+ ctxt->checkIndex = base;
+ return (-1);
}
/**
@@ -4517,6 +5280,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
int avail = 0;
xmlChar cur, next;
+ htmlParserNodeInfo node_info;
+
#ifdef DEBUG_PUSH
switch (ctxt->instate) {
case XML_PARSER_EOF:
@@ -4577,10 +5342,10 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
if (in->buf == NULL)
avail = in->length - (in->cur - in->base);
else
- avail = in->buf->buffer->use - (in->cur - in->base);
+ avail = xmlBufUse(in->buf->buffer) - (in->cur - in->base);
if ((avail == 0) && (terminate)) {
htmlAutoCloseOnEnd(ctxt);
- if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) {
+ if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) {
/*
* SAX: end of the document processing.
*/
@@ -4613,7 +5378,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
if (in->buf == NULL)
avail = in->length - (in->cur - in->base);
else
- avail = in->buf->buffer->use - (in->cur - in->base);
+ avail = xmlBufUse(in->buf->buffer) - (in->cur - in->base);
}
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
ctxt->sax->setDocumentLocator(ctxt->userData,
@@ -4630,7 +5395,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
+ (htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -4655,15 +5420,28 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
if (in->buf == NULL)
avail = in->length - (in->cur - in->base);
else
- avail = in->buf->buffer->use - (in->cur - in->base);
- if (avail < 2)
+ avail = xmlBufUse(in->buf->buffer) - (in->cur - in->base);
+ /*
+ * no chars in buffer
+ */
+ if (avail < 1)
goto done;
+ /*
+ * not enouth chars in buffer
+ */
+ if (avail < 2) {
+ if (!terminate)
+ goto done;
+ else
+ next = ' ';
+ } else {
+ next = in->cur[1];
+ }
cur = in->cur[0];
- next = in->cur[1];
if ((cur == '<') && (next == '!') &&
(in->cur[2] == '-') && (in->cur[3] == '-')) {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '-', '-', '>', 1) < 0))
+ (htmlParseLookupSequence(ctxt, '-', '-', '>', 1, 1) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -4673,7 +5451,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
ctxt->instate = XML_PARSER_MISC;
} else if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
+ (htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -4687,7 +5465,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
+ (htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -4715,15 +5493,15 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
if (in->buf == NULL)
avail = in->length - (in->cur - in->base);
else
- avail = in->buf->buffer->use - (in->cur - in->base);
- if (avail < 2)
+ avail = xmlBufUse(in->buf->buffer) - (in->cur - in->base);
+ if (avail < 2)
goto done;
cur = in->cur[0];
next = in->cur[1];
if ((cur == '<') && (next == '!') &&
(in->cur[2] == '-') && (in->cur[3] == '-')) {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '-', '-', '>', 1) < 0))
+ (htmlParseLookupSequence(ctxt, '-', '-', '>', 1, 1) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -4733,7 +5511,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
ctxt->instate = XML_PARSER_PROLOG;
} else if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
+ (htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -4756,7 +5534,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
if (in->buf == NULL)
avail = in->length - (in->cur - in->base);
else
- avail = in->buf->buffer->use - (in->cur - in->base);
+ avail = xmlBufUse(in->buf->buffer) - (in->cur - in->base);
if (avail < 1)
goto done;
cur = in->cur[0];
@@ -4770,7 +5548,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
if ((cur == '<') && (next == '!') &&
(in->cur[2] == '-') && (in->cur[3] == '-')) {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '-', '-', '>', 1) < 0))
+ (htmlParseLookupSequence(ctxt, '-', '-', '>', 1, 1) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -4780,7 +5558,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
ctxt->instate = XML_PARSER_EPILOG;
} else if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
+ (htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -4809,8 +5587,22 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
int failed;
const htmlElemDesc * info;
- if (avail < 2)
+ /*
+ * no chars in buffer
+ */
+ if (avail < 1)
goto done;
+ /*
+ * not enouth chars in buffer
+ */
+ if (avail < 2) {
+ if (!terminate)
+ goto done;
+ else
+ next = ' ';
+ } else {
+ next = in->cur[1];
+ }
cur = in->cur[0];
if (cur != '<') {
ctxt->instate = XML_PARSER_CONTENT;
@@ -4820,7 +5612,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
#endif
break;
}
- if (in->cur[1] == '/') {
+ if (next == '/') {
ctxt->instate = XML_PARSER_END_TAG;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
@@ -4830,12 +5622,20 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
break;
}
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
+ (htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
goto done;
+ /* Capture start position */
+ if (ctxt->record_info) {
+ node_info.begin_pos = ctxt->input->consumed +
+ (CUR_PTR - ctxt->input->base);
+ node_info.begin_line = ctxt->input->line;
+ }
+
+
failed = htmlParseStartTag(ctxt);
name = ctxt->name;
- if (failed ||
+ if ((failed == -1) ||
(name == NULL)) {
if (CUR == '>')
NEXT;
@@ -4877,10 +5677,13 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
/*
* end of parsing of this node.
*/
- if (xmlStrEqual(name, ctxt->name)) {
+ if (xmlStrEqual(name, ctxt->name)) {
nodePop(ctxt);
htmlnamePop(ctxt);
- }
+ }
+
+ if (ctxt->record_info)
+ htmlNodeInfoPush(ctxt, &node_info);
ctxt->instate = XML_PARSER_CONTENT;
#ifdef DEBUG_PUSH
@@ -4898,6 +5701,10 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
ctxt->sax->endElement(ctxt->userData, name);
htmlnamePop(ctxt);
}
+
+ if (ctxt->record_info)
+ htmlNodeInfoPush(ctxt, &node_info);
+
ctxt->instate = XML_PARSER_CONTENT;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -4925,14 +5732,20 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
if ((cur != '<') && (cur != '&')) {
if (ctxt->sax != NULL) {
if (IS_BLANK_CH(cur)) {
- if (ctxt->sax->ignorableWhitespace != NULL)
- ctxt->sax->ignorableWhitespace(
- ctxt->userData, &cur, 1);
+ if (ctxt->keepBlanks) {
+ if (ctxt->sax->characters != NULL)
+ ctxt->sax->characters(
+ ctxt->userData, &in->cur[0], 1);
+ } else {
+ if (ctxt->sax->ignorableWhitespace != NULL)
+ ctxt->sax->ignorableWhitespace(
+ ctxt->userData, &in->cur[0], 1);
+ }
} else {
htmlCheckParagraph(ctxt);
if (ctxt->sax->characters != NULL)
ctxt->sax->characters(
- ctxt->userData, &cur, 1);
+ ctxt->userData, &in->cur[0], 1);
}
}
ctxt->token = 0;
@@ -4955,7 +5768,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
int idx;
xmlChar val;
- idx = htmlParseLookupSequence(ctxt, '<', '/', 0, 0);
+ idx = htmlParseLookupSequence(ctxt, '<', '/', 0, 0, 0);
if (idx < 0)
goto done;
val = in->cur[idx + 2];
@@ -4982,7 +5795,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
(UPP(6) == 'Y') && (UPP(7) == 'P') &&
(UPP(8) == 'E')) {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
+ (htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
goto done;
htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR,
"Misplaced DOCTYPE declaration\n",
@@ -4992,7 +5805,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
(in->cur[2] == '-') && (in->cur[3] == '-')) {
if ((!terminate) &&
(htmlParseLookupSequence(
- ctxt, '-', '-', '>', 1) < 0))
+ ctxt, '-', '-', '>', 1, 1) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -5002,7 +5815,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
ctxt->instate = XML_PARSER_CONTENT;
} else if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
+ (htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -5030,7 +5843,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
break;
} else if (cur == '&') {
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, ';', 0, 0, 0) < 0))
+ (htmlParseLookupChars(ctxt,
+ BAD_CAST "; >/", 4) < 0))
goto done;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -5046,7 +5860,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
* data detection.
*/
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '<', 0, 0, 0) < 0))
+ (htmlParseLookupChars(ctxt, BAD_CAST "<&", 2) < 0))
goto done;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
@@ -5072,7 +5886,7 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
if (avail < 2)
goto done;
if ((!terminate) &&
- (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0))
+ (htmlParseLookupSequence(ctxt, '>', 0, 0, 0, 1) < 0))
goto done;
htmlParseEndTag(ctxt);
if (ctxt->nameNr == 0) {
@@ -5199,10 +6013,10 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
}
}
-done:
+done:
if ((avail == 0) && (terminate)) {
htmlAutoCloseOnEnd(ctxt);
- if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) {
+ if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) {
/*
* SAX: end of the document processing.
*/
@@ -5211,14 +6025,14 @@ done:
ctxt->sax->endDocument(ctxt->userData);
}
}
- if ((ctxt->myDoc != NULL) &&
+ if ((!(ctxt->options & HTML_PARSE_NODEFDTD)) && (ctxt->myDoc != NULL) &&
((terminate) || (ctxt->instate == XML_PARSER_EOF) ||
(ctxt->instate == XML_PARSER_EPILOG))) {
xmlDtdPtr dtd;
dtd = xmlGetIntSubset(ctxt->myDoc);
if (dtd == NULL)
- ctxt->myDoc->intSubset =
- xmlCreateIntSubset(ctxt->myDoc, BAD_CAST "html",
+ ctxt->myDoc->intSubset =
+ xmlCreateIntSubset(ctxt->myDoc, BAD_CAST "html",
BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN",
BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd");
}
@@ -5249,20 +6063,17 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
}
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
(ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF)) {
- int base = ctxt->input->base - ctxt->input->buf->buffer->content;
- int cur = ctxt->input->cur - ctxt->input->base;
+ size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
+ size_t cur = ctxt->input->cur - ctxt->input->base;
int res;
-
- res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+
+ res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
if (res < 0) {
ctxt->errNo = XML_PARSER_EOF;
ctxt->disableSAX = 1;
return (XML_PARSER_EOF);
}
- ctxt->input->base = ctxt->input->buf->buffer->content + base;
- ctxt->input->cur = ctxt->input->base + cur;
- ctxt->input->end =
- &ctxt->input->buf->buffer->content[ctxt->input->buf->buffer->use];
+ xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
#endif
@@ -5277,13 +6088,16 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
if ((in->encoder != NULL) && (in->buffer != NULL) &&
(in->raw != NULL)) {
int nbchars;
-
- nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
+ size_t base = xmlBufGetInputBase(in->buffer, ctxt->input);
+ size_t current = ctxt->input->cur - ctxt->input->base;
+
+ nbchars = xmlCharEncInput(in, terminate);
if (nbchars < 0) {
htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING,
"encoder error\n", NULL, NULL);
return(XML_ERR_INVALID_ENCODING);
}
+ xmlBufSetInputBaseCur(in->buffer, ctxt->input, base, current);
}
}
}
@@ -5294,14 +6108,14 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
(ctxt->instate != XML_PARSER_MISC)) {
ctxt->errNo = XML_ERR_DOCUMENT_END;
ctxt->wellFormed = 0;
- }
+ }
if (ctxt->instate != XML_PARSER_EOF) {
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
ctxt->sax->endDocument(ctxt->userData);
}
ctxt->instate = XML_PARSER_EOF;
}
- return((xmlParserErrors) ctxt->errNo);
+ return((xmlParserErrors) ctxt->errNo);
}
/************************************************************************
@@ -5326,7 +6140,7 @@ htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size,
* Returns the new parser context or NULL
*/
htmlParserCtxtPtr
-htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
+htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
const char *chunk, int size, const char *filename,
xmlCharEncoding enc) {
htmlParserCtxtPtr ctxt;
@@ -5357,7 +6171,7 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
memcpy(ctxt->sax, sax, sizeof(htmlSAXHandler));
if (user_data != NULL)
ctxt->userData = user_data;
- }
+ }
if (filename == NULL) {
ctxt->directory = NULL;
} else {
@@ -5377,24 +6191,18 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
inputStream->filename = (char *)
xmlCanonicPath((const xmlChar *) filename);
inputStream->buf = buf;
- inputStream->base = inputStream->buf->buffer->content;
- inputStream->cur = inputStream->buf->buffer->content;
- inputStream->end =
- &inputStream->buf->buffer->content[inputStream->buf->buffer->use];
+ xmlBufResetInput(buf->buffer, inputStream);
inputPush(ctxt, inputStream);
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
- (ctxt->input->buf != NULL)) {
- int base = ctxt->input->base - ctxt->input->buf->buffer->content;
- int cur = ctxt->input->cur - ctxt->input->base;
+ (ctxt->input->buf != NULL)) {
+ size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
+ size_t cur = ctxt->input->cur - ctxt->input->base;
- xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+ xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
- ctxt->input->base = ctxt->input->buf->buffer->content + base;
- ctxt->input->cur = ctxt->input->base + cur;
- ctxt->input->end =
- &ctxt->input->buf->buffer->content[ctxt->input->buf->buffer->use];
+ xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size);
#endif
@@ -5410,12 +6218,12 @@ htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data,
* @cur: a pointer to an array of xmlChar
* @encoding: a free form C string describing the HTML document encoding, or NULL
* @sax: the SAX handler block
- * @userData: if using SAX, this pointer will be provided on callbacks.
+ * @userData: if using SAX, this pointer will be provided on callbacks.
*
* Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks
* to handle parse events. If sax is NULL, fallback to the default DOM
* behavior and return a tree.
- *
+ *
* Returns the resulting document tree unless SAX is NULL or the document is
* not well formed.
*/
@@ -5432,7 +6240,7 @@ htmlSAXParseDoc(xmlChar *cur, const char *encoding, htmlSAXHandlerPtr sax, void
ctxt = htmlCreateDocParserCtxt(cur, encoding);
if (ctxt == NULL) return(NULL);
- if (sax != NULL) {
+ if (sax != NULL) {
if (ctxt->sax != NULL) xmlFree (ctxt->sax);
ctxt->sax = sax;
ctxt->userData = userData;
@@ -5445,7 +6253,7 @@ htmlSAXParseDoc(xmlChar *cur, const char *encoding, htmlSAXHandlerPtr sax, void
ctxt->userData = NULL;
}
htmlFreeParserCtxt(ctxt);
-
+
return(ret);
}
@@ -5455,7 +6263,7 @@ htmlSAXParseDoc(xmlChar *cur, const char *encoding, htmlSAXHandlerPtr sax, void
* @encoding: a free form C string describing the HTML document encoding, or NULL
*
* parse an HTML in-memory document and build a tree.
- *
+ *
* Returns the resulting document tree
*/
@@ -5470,7 +6278,7 @@ htmlParseDoc(xmlChar *cur, const char *encoding) {
* @filename: the filename
* @encoding: a free form C string describing the HTML document encoding, or NULL
*
- * Create a parser context for a file content.
+ * Create a parser context for a file content.
* Automatic support for ZLIB/Compress compressed document is provided
* by default if found at compile-time.
*
@@ -5502,7 +6310,7 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
xmlFreeParserCtxt(ctxt);
return(NULL);
}
-
+
inputStream = xmlLoadExternalEntity(canonicFilename, NULL, ctxt);
xmlFree(canonicFilename);
if (inputStream == NULL) {
@@ -5514,15 +6322,19 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
/* set encoding */
if (encoding) {
- content = xmlMallocAtomic (xmlStrlen(content_line) + strlen(encoding) + 1);
- if (content) {
- strcpy ((char *)content, (char *)content_line);
- strcat ((char *)content, (char *)encoding);
- htmlCheckEncoding (ctxt, content);
- xmlFree (content);
+ size_t l = strlen(encoding);
+
+ if (l < 1000) {
+ content = xmlMallocAtomic (xmlStrlen(content_line) + l + 1);
+ if (content) {
+ strcpy ((char *)content, (char *)content_line);
+ strcat ((char *)content, (char *)encoding);
+ htmlCheckEncoding (ctxt, content);
+ xmlFree (content);
+ }
}
}
-
+
return(ctxt);
}
@@ -5531,7 +6343,7 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
* @filename: the filename
* @encoding: a free form C string describing the HTML document encoding, or NULL
* @sax: the SAX handler block
- * @userData: if using SAX, this pointer will be provided on callbacks.
+ * @userData: if using SAX, this pointer will be provided on callbacks.
*
* parse an HTML file and build a tree. Automatic support for ZLIB/Compress
* compressed document is provided by default if found at compile-time.
@@ -5543,7 +6355,7 @@ htmlCreateFileParserCtxt(const char *filename, const char *encoding)
*/
htmlDocPtr
-htmlSAXParseFile(const char *filename, const char *encoding, htmlSAXHandlerPtr sax,
+htmlSAXParseFile(const char *filename, const char *encoding, htmlSAXHandlerPtr sax,
void *userData) {
htmlDocPtr ret;
htmlParserCtxtPtr ctxt;
@@ -5567,7 +6379,7 @@ htmlSAXParseFile(const char *filename, const char *encoding, htmlSAXHandlerPtr s
ctxt->userData = NULL;
}
htmlFreeParserCtxt(ctxt);
-
+
return(ret);
}
@@ -5589,7 +6401,7 @@ htmlParseFile(const char *filename, const char *encoding) {
/**
* htmlHandleOmittedElem:
- * @val: int 0 or 1
+ * @val: int 0 or 1
*
* Set and return the previous value for handling HTML omitted tags.
*
@@ -5729,7 +6541,7 @@ htmlNodeStatus(const htmlNodePtr node, int legacy) {
* current scope
*/
#define DICT_FREE(str) \
- if ((str) && ((!dict) || \
+ if ((str) && ((!dict) || \
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
xmlFree((char *)(str));
@@ -5744,7 +6556,7 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
{
xmlParserInputPtr input;
xmlDictPtr dict;
-
+
if (ctxt == NULL)
return;
@@ -5796,6 +6608,7 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
ctxt->wellFormed = 1;
ctxt->nsWellFormed = 1;
+ ctxt->disableSAX = 0;
ctxt->valid = 1;
ctxt->vctxt.userData = ctxt;
ctxt->vctxt.error = xmlParserValidityError;
@@ -5806,7 +6619,7 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
ctxt->inSubset = 0;
ctxt->errNo = XML_ERR_OK;
ctxt->depth = 0;
- ctxt->charset = XML_CHAR_ENCODING_UTF8;
+ ctxt->charset = XML_CHAR_ENCODING_NONE;
ctxt->catalogs = NULL;
xmlInitNodeInfoSeq(&ctxt->node_seq);
@@ -5871,6 +6684,22 @@ htmlCtxtUseOptions(htmlParserCtxtPtr ctxt, int options)
ctxt->options |= HTML_PARSE_COMPACT;
options -= HTML_PARSE_COMPACT;
}
+ if (options & XML_PARSE_HUGE) {
+ ctxt->options |= XML_PARSE_HUGE;
+ options -= XML_PARSE_HUGE;
+ }
+ if (options & HTML_PARSE_NODEFDTD) {
+ ctxt->options |= HTML_PARSE_NODEFDTD;
+ options -= HTML_PARSE_NODEFDTD;
+ }
+ if (options & HTML_PARSE_IGNORE_ENC) {
+ ctxt->options |= HTML_PARSE_IGNORE_ENC;
+ options -= HTML_PARSE_IGNORE_ENC;
+ }
+ if (options & HTML_PARSE_NOIMPLIED) {
+ ctxt->options |= HTML_PARSE_NOIMPLIED;
+ options -= HTML_PARSE_NOIMPLIED;
+ }
ctxt->dictNames = 0;
return (options);
}
@@ -5884,7 +6713,7 @@ htmlCtxtUseOptions(htmlParserCtxtPtr ctxt, int options)
* @reuse: keep the context for reuse
*
* Common front-end for the htmlRead functions
- *
+ *
* Returns the resulting document tree or NULL
*/
static htmlDocPtr
@@ -5892,15 +6721,19 @@ htmlDoRead(htmlParserCtxtPtr ctxt, const char *URL, const char *encoding,
int options, int reuse)
{
htmlDocPtr ret;
-
+
htmlCtxtUseOptions(ctxt, options);
ctxt->html = 1;
if (encoding != NULL) {
xmlCharEncodingHandlerPtr hdlr;
hdlr = xmlFindCharEncodingHandler(encoding);
- if (hdlr != NULL)
+ if (hdlr != NULL) {
xmlSwitchToEncoding(ctxt, hdlr);
+ if (ctxt->input->encoding != NULL)
+ xmlFree((xmlChar *) ctxt->input->encoding);
+ ctxt->input->encoding = xmlStrdup((xmlChar *)encoding);
+ }
}
if ((URL != NULL) && (ctxt->input != NULL) &&
(ctxt->input->filename == NULL))
@@ -5926,7 +6759,7 @@ htmlDoRead(htmlParserCtxtPtr ctxt, const char *URL, const char *encoding,
* @options: a combination of htmlParserOption(s)
*
* parse an XML in-memory document and build a tree.
- *
+ *
* Returns the resulting document tree
*/
htmlDocPtr
@@ -5951,7 +6784,7 @@ htmlReadDoc(const xmlChar * cur, const char *URL, const char *encoding, int opti
* @options: a combination of htmlParserOption(s)
*
* parse an XML file from the filesystem or the network.
- *
+ *
* Returns the resulting document tree
*/
htmlDocPtr
@@ -5975,7 +6808,7 @@ htmlReadFile(const char *filename, const char *encoding, int options)
* @options: a combination of htmlParserOption(s)
*
* parse an XML in-memory document and build a tree.
- *
+ *
* Returns the resulting document tree
*/
htmlDocPtr
@@ -6001,7 +6834,7 @@ htmlReadMemory(const char *buffer, int size, const char *URL, const char *encodi
* @options: a combination of htmlParserOption(s)
*
* parse an XML from a file descriptor and build a tree.
- *
+ *
* Returns the resulting document tree
*/
htmlDocPtr
@@ -6013,6 +6846,7 @@ htmlReadFd(int fd, const char *URL, const char *encoding, int options)
if (fd < 0)
return (NULL);
+ xmlInitParser();
xmlInitParser();
input = xmlParserInputBufferCreateFd(fd, XML_CHAR_ENCODING_NONE);
@@ -6043,7 +6877,7 @@ htmlReadFd(int fd, const char *URL, const char *encoding, int options)
* @options: a combination of htmlParserOption(s)
*
* parse an HTML document from I/O functions and source and build a tree.
- *
+ *
* Returns the resulting document tree
*/
htmlDocPtr
@@ -6060,8 +6894,11 @@ htmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
XML_CHAR_ENCODING_NONE);
- if (input == NULL)
+ if (input == NULL) {
+ if (ioclose != NULL)
+ ioclose(ioctx);
return (NULL);
+ }
ctxt = htmlNewParserCtxt();
if (ctxt == NULL) {
xmlFreeParserInputBuffer(input);
@@ -6087,7 +6924,7 @@ htmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
*
* parse an XML in-memory document and build a tree.
* This reuses the existing @ctxt parser context
- *
+ *
* Returns the resulting document tree
*/
htmlDocPtr
@@ -6100,6 +6937,7 @@ htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur,
return (NULL);
if (ctxt == NULL)
return (NULL);
+ xmlInitParser();
htmlCtxtReset(ctxt);
@@ -6120,7 +6958,7 @@ htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur,
*
* parse an XML file from the filesystem or the network.
* This reuses the existing @ctxt parser context
- *
+ *
* Returns the resulting document tree
*/
htmlDocPtr
@@ -6133,6 +6971,7 @@ htmlCtxtReadFile(htmlParserCtxtPtr ctxt, const char *filename,
return (NULL);
if (ctxt == NULL)
return (NULL);
+ xmlInitParser();
htmlCtxtReset(ctxt);
@@ -6155,7 +6994,7 @@ htmlCtxtReadFile(htmlParserCtxtPtr ctxt, const char *filename,
*
* parse an XML in-memory document and build a tree.
* This reuses the existing @ctxt parser context
- *
+ *
* Returns the resulting document tree
*/
htmlDocPtr
@@ -6169,6 +7008,7 @@ htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size,
return (NULL);
if (buffer == NULL)
return (NULL);
+ xmlInitParser();
htmlCtxtReset(ctxt);
@@ -6197,7 +7037,7 @@ htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size,
*
* parse an XML from a file descriptor and build a tree.
* This reuses the existing @ctxt parser context
- *
+ *
* Returns the resulting document tree
*/
htmlDocPtr
@@ -6211,6 +7051,7 @@ htmlCtxtReadFd(htmlParserCtxtPtr ctxt, int fd,
return (NULL);
if (ctxt == NULL)
return (NULL);
+ xmlInitParser();
htmlCtxtReset(ctxt);
@@ -6239,7 +7080,7 @@ htmlCtxtReadFd(htmlParserCtxtPtr ctxt, int fd,
*
* parse an HTML document from I/O functions and source and build a tree.
* This reuses the existing @ctxt parser context
- *
+ *
* Returns the resulting document tree
*/
htmlDocPtr
@@ -6255,13 +7096,17 @@ htmlCtxtReadIO(htmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
return (NULL);
if (ctxt == NULL)
return (NULL);
+ xmlInitParser();
htmlCtxtReset(ctxt);
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
XML_CHAR_ENCODING_NONE);
- if (input == NULL)
+ if (input == NULL) {
+ if (ioclose != NULL)
+ ioclose(ioctx);
return (NULL);
+ }
stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
if (stream == NULL) {
xmlFreeParserInputBuffer(input);
diff --git a/gnulib-local/lib/libxml/HTMLparser.in.h b/gnulib-local/lib/libxml/HTMLparser.in.h
index 05905e4..551186c 100644
--- a/gnulib-local/lib/libxml/HTMLparser.in.h
+++ b/gnulib-local/lib/libxml/HTMLparser.in.h
@@ -83,87 +83,87 @@ struct _htmlEntityDesc {
/*
* There is only few public functions.
*/
-XMLPUBFUN const htmlElemDesc * XMLCALL
+XMLPUBFUN const htmlElemDesc * XMLCALL
htmlTagLookup (const xmlChar *tag);
-XMLPUBFUN const htmlEntityDesc * XMLCALL
+XMLPUBFUN const htmlEntityDesc * XMLCALL
htmlEntityLookup(const xmlChar *name);
-XMLPUBFUN const htmlEntityDesc * XMLCALL
+XMLPUBFUN const htmlEntityDesc * XMLCALL
htmlEntityValueLookup(unsigned int value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlIsAutoClosed(htmlDocPtr doc,
htmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlAutoCloseTag(htmlDocPtr doc,
const xmlChar *name,
htmlNodePtr elem);
-XMLPUBFUN const htmlEntityDesc * XMLCALL
+XMLPUBFUN const htmlEntityDesc * XMLCALL
htmlParseEntityRef(htmlParserCtxtPtr ctxt,
const xmlChar **str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlParseCharRef(htmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
htmlParseElement(htmlParserCtxtPtr ctxt);
-XMLPUBFUN htmlParserCtxtPtr XMLCALL
+XMLPUBFUN htmlParserCtxtPtr XMLCALL
htmlNewParserCtxt(void);
-XMLPUBFUN htmlParserCtxtPtr XMLCALL
+XMLPUBFUN htmlParserCtxtPtr XMLCALL
htmlCreateMemoryParserCtxt(const char *buffer,
int size);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlParseDocument(htmlParserCtxtPtr ctxt);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr XMLCALL
htmlSAXParseDoc (xmlChar *cur,
const char *encoding,
htmlSAXHandlerPtr sax,
void *userData);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr XMLCALL
htmlParseDoc (xmlChar *cur,
const char *encoding);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr XMLCALL
htmlSAXParseFile(const char *filename,
const char *encoding,
htmlSAXHandlerPtr sax,
void *userData);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr XMLCALL
htmlParseFile (const char *filename,
const char *encoding);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
UTF8ToHtml (unsigned char *out,
int *outlen,
const unsigned char *in,
int *inlen);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlEncodeEntities(unsigned char *out,
int *outlen,
const unsigned char *in,
int *inlen, int quoteChar);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlIsScriptAttribute(const xmlChar *name);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlHandleOmittedElem(int val);
#ifdef LIBXML_PUSH_ENABLED
/**
* Interfaces for the Push mode.
*/
-XMLPUBFUN htmlParserCtxtPtr XMLCALL
+XMLPUBFUN htmlParserCtxtPtr XMLCALL
htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax,
void *user_data,
const char *chunk,
int size,
const char *filename,
xmlCharEncoding enc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlParseChunk (htmlParserCtxtPtr ctxt,
const char *chunk,
int size,
int terminate);
#endif /* LIBXML_PUSH_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
htmlFreeParserCtxt (htmlParserCtxtPtr ctxt);
/*
@@ -177,12 +177,15 @@ XMLPUBFUN void XMLCALL
*/
typedef enum {
HTML_PARSE_RECOVER = 1<<0, /* Relaxed parsing */
+ HTML_PARSE_NODEFDTD = 1<<2, /* do not default a doctype if not found */
HTML_PARSE_NOERROR = 1<<5, /* suppress error reports */
HTML_PARSE_NOWARNING= 1<<6, /* suppress warning reports */
HTML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
HTML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
HTML_PARSE_NONET = 1<<11,/* Forbid network access */
- HTML_PARSE_COMPACT = 1<<16 /* compact small text nodes */
+ HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */
+ HTML_PARSE_COMPACT = 1<<16,/* compact small text nodes */
+ HTML_PARSE_IGNORE_ENC=1<<21 /* ignore internal document encoding hint */
} htmlParserOption;
XMLPUBFUN void XMLCALL
diff --git a/gnulib-local/lib/libxml/HTMLtree.c b/gnulib-local/lib/libxml/HTMLtree.c
index c1e5a0a..2fd0c9c 100644
--- a/gnulib-local/lib/libxml/HTMLtree.c
+++ b/gnulib-local/lib/libxml/HTMLtree.c
@@ -30,16 +30,18 @@
#include <libxml/globals.h>
#include <libxml/uri.h>
+#include "buf.h"
+
/************************************************************************
* *
- * Getting/Setting encoding meta tags *
+ * Getting/Setting encoding meta tags *
* *
************************************************************************/
/**
* htmlGetMetaEncoding:
* @doc: the document
- *
+ *
* Encoding definition lookup in the Meta tags
*
* Returns the current encoding as flagged in the HTML source
@@ -126,17 +128,17 @@ found_meta:
found_content:
encoding = xmlStrstr(content, BAD_CAST"charset=");
- if (encoding == NULL)
+ if (encoding == NULL)
encoding = xmlStrstr(content, BAD_CAST"Charset=");
- if (encoding == NULL)
+ if (encoding == NULL)
encoding = xmlStrstr(content, BAD_CAST"CHARSET=");
if (encoding != NULL) {
encoding += 8;
} else {
encoding = xmlStrstr(content, BAD_CAST"charset =");
- if (encoding == NULL)
+ if (encoding == NULL)
encoding = xmlStrstr(content, BAD_CAST"Charset =");
- if (encoding == NULL)
+ if (encoding == NULL)
encoding = xmlStrstr(content, BAD_CAST"CHARSET =");
if (encoding != NULL)
encoding += 9;
@@ -151,7 +153,7 @@ found_content:
* htmlSetMetaEncoding:
* @doc: the document
* @encoding: the encoding string
- *
+ *
* Sets the current encoding in the Meta tags
* NOTE: this will not change the document content encoding, just
* the META flag associated.
@@ -160,14 +162,19 @@ found_content:
*/
int
htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) {
- htmlNodePtr cur, meta;
- const xmlChar *content;
+ htmlNodePtr cur, meta = NULL, head = NULL;
+ const xmlChar *content = NULL;
char newcontent[100];
+ newcontent[0] = 0;
if (doc == NULL)
return(-1);
+ /* html isn't a real encoding it's just libxml2 way to get entities */
+ if (!xmlStrcasecmp(encoding, BAD_CAST "html"))
+ return(-1);
+
if (encoding != NULL) {
snprintf(newcontent, sizeof(newcontent), "text/html; charset=%s",
(char *)encoding);
@@ -201,39 +208,24 @@ htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) {
if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) {
if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0)
break;
- if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0)
+ if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0) {
+ head = cur->parent;
goto found_meta;
+ }
}
cur = cur->next;
}
if (cur == NULL)
return(-1);
found_head:
- if (cur->children == NULL) {
- if (encoding == NULL)
- return(0);
- meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL);
- xmlAddChild(cur, meta);
- xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type");
- xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent);
- return(0);
- }
+ head = cur;
+ if (cur->children == NULL)
+ goto create;
cur = cur->children;
found_meta:
- if (encoding != NULL) {
- /*
- * Create a new Meta element with the right attributes
- */
-
- meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL);
- xmlAddPrevSibling(cur, meta);
- xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type");
- xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent);
- }
-
/*
- * Search and destroy all the remaining the meta elements carrying
+ * Search and update all the remaining the meta elements carrying
* encoding informations
*/
while (cur != NULL) {
@@ -253,11 +245,11 @@ found_meta:
if ((!xmlStrcasecmp(attr->name, BAD_CAST"http-equiv"))
&& (!xmlStrcasecmp(value, BAD_CAST"Content-Type")))
http = 1;
- else
+ else
{
- if ((value != NULL) &&
- (!xmlStrcasecmp(attr->name, BAD_CAST"content")))
- content = value;
+ if ((value != NULL) &&
+ (!xmlStrcasecmp(attr->name, BAD_CAST"content")))
+ content = value;
}
if ((http != 0) && (content != NULL))
break;
@@ -266,16 +258,41 @@ found_meta:
}
if ((http != 0) && (content != NULL)) {
meta = cur;
- cur = cur->next;
- xmlUnlinkNode(meta);
- xmlFreeNode(meta);
- continue;
+ break;
}
}
}
cur = cur->next;
}
+create:
+ if (meta == NULL) {
+ if ((encoding != NULL) && (head != NULL)) {
+ /*
+ * Create a new Meta element with the right attributes
+ */
+
+ meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL);
+ if (head->children == NULL)
+ xmlAddChild(head, meta);
+ else
+ xmlAddPrevSibling(head->children, meta);
+ xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type");
+ xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent);
+ }
+ } else {
+ /* remove the meta tag if NULL is passed */
+ if (encoding == NULL) {
+ xmlUnlinkNode(meta);
+ xmlFreeNode(meta);
+ }
+ /* change the document only if there is a real encoding change */
+ else if (xmlStrcasestr(content, encoding) == NULL) {
+ xmlSetProp(meta, BAD_CAST"content", BAD_CAST newcontent);
+ }
+ }
+
+
return(0);
}
@@ -299,7 +316,7 @@ static const char* htmlBooleanAttrs[] = {
* @name: the name of the attribute to check
*
* Determine if a given attribute is a boolean attribute.
- *
+ *
* returns: false if the attribute is not boolean, true otherwise.
*/
int
@@ -316,9 +333,14 @@ htmlIsBooleanAttr(const xmlChar *name)
}
#ifdef LIBXML_OUTPUT_ENABLED
+/*
+ * private routine exported from xmlIO.c
+ */
+xmlOutputBufferPtr
+xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
/************************************************************************
* *
- * Output error handlers *
+ * Output error handlers *
* *
************************************************************************/
/**
@@ -367,17 +389,13 @@ htmlSaveErr(int code, xmlNodePtr node, const char *extra)
/************************************************************************
* *
- * Dumping HTML tree content to a simple buffer *
+ * Dumping HTML tree content to a simple buffer *
* *
************************************************************************/
-static int
-htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
- int format);
-
/**
- * htmlNodeDumpFormat:
- * @buf: the HTML buffer output
+ * htmlBufNodeDumpFormat:
+ * @buf: the xmlBufPtr output
* @doc: the document
* @cur: the current node
* @format: should formatting spaces been added
@@ -386,10 +404,10 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
*
* Returns the number of byte written or -1 in case of error
*/
-static int
-htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
+static size_t
+htmlBufNodeDumpFormat(xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur,
int format) {
- unsigned int use;
+ size_t use;
int ret;
xmlOutputBufferPtr outbuf;
@@ -412,10 +430,10 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
outbuf->context = NULL;
outbuf->written = 0;
- use = buf->use;
+ use = xmlBufUse(buf);
htmlNodeDumpFormatOutput(outbuf, doc, cur, NULL, format);
xmlFree(outbuf);
- ret = buf->use - use;
+ ret = xmlBufUse(buf) - use;
return (ret);
}
@@ -432,9 +450,24 @@ htmlNodeDumpFormat(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
*/
int
htmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur) {
+ xmlBufPtr buffer;
+ size_t ret;
+
+ if ((buf == NULL) || (cur == NULL))
+ return(-1);
+
xmlInitParser();
+ buffer = xmlBufFromBuffer(buf);
+ if (buffer == NULL)
+ return(-1);
+
+ ret = htmlBufNodeDumpFormat(buffer, doc, cur, 1);
- return(htmlNodeDumpFormat(buf, doc, cur, 1));
+ xmlBufBackToBuffer(buffer);
+
+ if (ret > INT_MAX)
+ return(-1);
+ return((int) ret);
}
/**
@@ -467,7 +500,7 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
if (enc != XML_CHAR_ENCODING_UTF8) {
handler = xmlFindCharEncodingHandler(encoding);
if (handler == NULL)
- return(-1);
+ htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
}
}
@@ -479,7 +512,7 @@ htmlNodeDumpFileFormat(FILE *out, xmlDocPtr doc,
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
- /*
+ /*
* save the content to a temp buffer.
*/
buf = xmlOutputBufferCreateFile(out, handler);
@@ -548,11 +581,9 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
}
handler = xmlFindCharEncodingHandler(encoding);
- if (handler == NULL) {
- *mem = NULL;
- *size = 0;
- return;
- }
+ if (handler == NULL)
+ htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
+
} else {
handler = xmlFindCharEncodingHandler(encoding);
}
@@ -566,22 +597,22 @@ htmlDocDumpMemoryFormat(xmlDocPtr cur, xmlChar**mem, int *size, int format) {
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
- buf = xmlAllocOutputBuffer(handler);
+ buf = xmlAllocOutputBufferInternal(handler);
if (buf == NULL) {
*mem = NULL;
*size = 0;
return;
}
- htmlDocContentDumpFormatOutput(buf, cur, NULL, format);
+ htmlDocContentDumpFormatOutput(buf, cur, NULL, format);
xmlOutputBufferFlush(buf);
if (buf->conv != NULL) {
- *size = buf->conv->use;
- *mem = xmlStrndup(buf->conv->content, *size);
+ *size = xmlBufUse(buf->conv);
+ *mem = xmlStrndup(xmlBufContent(buf->conv), *size);
} else {
- *size = buf->buffer->use;
- *mem = xmlStrndup(buf->buffer->content, *size);
+ *size = xmlBufUse(buf->buffer);
+ *mem = xmlStrndup(xmlBufContent(buf->buffer), *size);
}
(void)xmlOutputBufferClose(buf);
}
@@ -603,7 +634,7 @@ htmlDocDumpMemory(xmlDocPtr cur, xmlChar**mem, int *size) {
/************************************************************************
* *
- * Dumping HTML tree content to an I/O output buffer *
+ * Dumping HTML tree content to an I/O output buffer *
* *
************************************************************************/
@@ -614,7 +645,7 @@ void xmlNsListDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur);
* @buf: the HTML buffer output
* @doc: the document
* @encoding: the encoding string
- *
+ *
* TODO: check whether encoding is needed
*
* Dump the HTML document DTD, if any.
@@ -632,14 +663,15 @@ htmlDtdDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
xmlOutputBufferWriteString(buf, (const char *)cur->name);
if (cur->ExternalID != NULL) {
xmlOutputBufferWriteString(buf, " PUBLIC ");
- xmlBufferWriteQuotedString(buf->buffer, cur->ExternalID);
+ xmlBufWriteQuotedString(buf->buffer, cur->ExternalID);
if (cur->SystemID != NULL) {
xmlOutputBufferWriteString(buf, " ");
- xmlBufferWriteQuotedString(buf->buffer, cur->SystemID);
- }
- } else if (cur->SystemID != NULL) {
+ xmlBufWriteQuotedString(buf->buffer, cur->SystemID);
+ }
+ } else if (cur->SystemID != NULL &&
+ xmlStrcmp(cur->SystemID, BAD_CAST "about:legacy-compat")) {
xmlOutputBufferWriteString(buf, " SYSTEM ");
- xmlBufferWriteQuotedString(buf->buffer, cur->SystemID);
+ xmlBufWriteQuotedString(buf->buffer, cur->SystemID);
}
xmlOutputBufferWriteString(buf, ">\n");
}
@@ -659,9 +691,10 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
xmlChar *value;
/*
- * TODO: The html output method should not escape a & character
- * occurring in an attribute value immediately followed by
- * a { character (see Section B.7.1 of the HTML 4.0 Recommendation).
+ * The html output method should not escape a & character
+ * occurring in an attribute value immediately followed by
+ * a { character (see Section B.7.1 of the HTML 4.0 Recommendation).
+ * This is implemented in xmlEncodeEntitiesReentrant
*/
if (cur == NULL) {
@@ -684,20 +717,51 @@ htmlAttrDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlAttrPtr cur,
(!xmlStrcasecmp(cur->name, BAD_CAST "src")) ||
((!xmlStrcasecmp(cur->name, BAD_CAST "name")) &&
(!xmlStrcasecmp(cur->parent->name, BAD_CAST "a"))))) {
- xmlChar *escaped;
xmlChar *tmp = value;
+ /* xmlURIEscapeStr() escapes '"' so it can be safely used. */
+ xmlBufCCat(buf->buffer, "\"");
while (IS_BLANK_CH(*tmp)) tmp++;
- escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+");
- if (escaped != NULL) {
- xmlBufferWriteQuotedString(buf->buffer, escaped);
- xmlFree(escaped);
- } else {
- xmlBufferWriteQuotedString(buf->buffer, value);
+ /* URI Escape everything, except server side includes. */
+ for ( ; ; ) {
+ xmlChar *escaped;
+ xmlChar endChar;
+ xmlChar *end = NULL;
+ xmlChar *start = (xmlChar *)xmlStrstr(tmp, BAD_CAST "<!--");
+ if (start != NULL) {
+ end = (xmlChar *)xmlStrstr(tmp, BAD_CAST "-->");
+ if (end != NULL) {
+ *start = '\0';
+ }
+ }
+
+ /* Escape the whole string, or until start (set to '\0'). */
+ escaped = xmlURIEscapeStr(tmp, BAD_CAST"@/:=?;#%&,+");
+ if (escaped != NULL) {
+ xmlBufCat(buf->buffer, escaped);
+ xmlFree(escaped);
+ } else {
+ xmlBufCat(buf->buffer, tmp);
+ }
+
+ if (end == NULL) { /* Everything has been written. */
+ break;
+ }
+
+ /* Do not escape anything within server side includes. */
+ *start = '<'; /* Restore the first character of "<!--". */
+ end += 3; /* strlen("-->") */
+ endChar = *end;
+ *end = '\0';
+ xmlBufCat(buf->buffer, start);
+ *end = endChar;
+ tmp = end;
}
+
+ xmlBufCCat(buf->buffer, "\"");
} else {
- xmlBufferWriteQuotedString(buf->buffer, value);
+ xmlBufWriteQuotedString(buf->buffer, value);
}
xmlFree(value);
} else {
@@ -780,6 +844,10 @@ htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf, xmlDocPtr doc,
htmlDocContentDumpOutput(buf, (xmlDocPtr) cur, encoding);
return;
}
+ if (cur->type == XML_ATTRIBUTE_NODE) {
+ htmlAttrDumpOutput(buf, doc, (xmlAttrPtr) cur, encoding);
+ return;
+ }
if (cur->type == HTML_TEXT_NODE) {
if (cur->content != NULL) {
if (((cur->name == (const xmlChar *)xmlStringText) ||
@@ -1043,7 +1111,7 @@ htmlDocDump(FILE *f, xmlDocPtr cur) {
handler = xmlFindCharEncodingHandler(encoding);
if (handler == NULL)
- return(-1);
+ htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
} else {
handler = xmlFindCharEncodingHandler(encoding);
}
@@ -1083,7 +1151,7 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
if ((cur == NULL) || (filename == NULL))
return(-1);
-
+
xmlInitParser();
encoding = (const char *) htmlGetMetaEncoding(cur);
@@ -1102,7 +1170,7 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
handler = xmlFindCharEncodingHandler(encoding);
if (handler == NULL)
- return(-1);
+ htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
}
}
@@ -1114,7 +1182,7 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
- /*
+ /*
* save the content to a temp buffer.
*/
buf = xmlOutputBufferCreateFilename(filename, handler, cur->compression);
@@ -1134,7 +1202,7 @@ htmlSaveFile(const char *filename, xmlDocPtr cur) {
* @encoding: the document encoding
*
* Dump an HTML document to a file using a given encoding.
- *
+ *
* returns: the number of byte written or -1 in case of failure.
*/
int
@@ -1146,7 +1214,7 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
if ((cur == NULL) || (filename == NULL))
return(-1);
-
+
xmlInitParser();
if (encoding != NULL) {
@@ -1163,9 +1231,9 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
handler = xmlFindCharEncodingHandler(encoding);
if (handler == NULL)
- return(-1);
- htmlSetMetaEncoding(cur, (const xmlChar *) encoding);
+ htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
}
+ htmlSetMetaEncoding(cur, (const xmlChar *) encoding);
} else {
htmlSetMetaEncoding(cur, (const xmlChar *) "UTF-8");
}
@@ -1178,7 +1246,7 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
if (handler == NULL)
handler = xmlFindCharEncodingHandler("ascii");
- /*
+ /*
* save the content to a temp buffer.
*/
buf = xmlOutputBufferCreateFilename(filename, handler, 0);
@@ -1198,7 +1266,7 @@ htmlSaveFileFormat(const char *filename, xmlDocPtr cur,
*
* Dump an HTML document to a file using a given encoding
* and formatting returns/spaces are added.
- *
+ *
* returns: the number of byte written or -1 in case of failure.
*/
int
diff --git a/gnulib-local/lib/libxml/HTMLtree.in.h b/gnulib-local/lib/libxml/HTMLtree.in.h
index 6ea8207..c0e1103 100644
--- a/gnulib-local/lib/libxml/HTMLtree.in.h
+++ b/gnulib-local/lib/libxml/HTMLtree.in.h
@@ -62,78 +62,78 @@ extern "C" {
XMLPUBFUN htmlDocPtr XMLCALL
htmlNewDoc (const xmlChar *URI,
const xmlChar *ExternalID);
-XMLPUBFUN htmlDocPtr XMLCALL
+XMLPUBFUN htmlDocPtr XMLCALL
htmlNewDocNoDtD (const xmlChar *URI,
const xmlChar *ExternalID);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
htmlGetMetaEncoding (htmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlSetMetaEncoding (htmlDocPtr doc,
const xmlChar *encoding);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
htmlDocDumpMemory (xmlDocPtr cur,
xmlChar **mem,
int *size);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
htmlDocDumpMemoryFormat (xmlDocPtr cur,
xmlChar **mem,
int *size,
int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlDocDump (FILE *f,
xmlDocPtr cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlSaveFile (const char *filename,
xmlDocPtr cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlNodeDump (xmlBufferPtr buf,
xmlDocPtr doc,
xmlNodePtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
htmlNodeDumpFile (FILE *out,
xmlDocPtr doc,
xmlNodePtr cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlNodeDumpFileFormat (FILE *out,
xmlDocPtr doc,
xmlNodePtr cur,
const char *encoding,
int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlSaveFileEnc (const char *filename,
xmlDocPtr cur,
const char *encoding);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlSaveFileFormat (const char *filename,
xmlDocPtr cur,
const char *encoding,
int format);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
htmlNodeDumpFormatOutput(xmlOutputBufferPtr buf,
xmlDocPtr doc,
xmlNodePtr cur,
const char *encoding,
int format);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
htmlDocContentDumpOutput(xmlOutputBufferPtr buf,
xmlDocPtr cur,
const char *encoding);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
htmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf,
xmlDocPtr cur,
const char *encoding,
int format);
-XMLPUBFUN void XMLCALL
- htmlNodeDumpOutput (xmlOutputBufferPtr buf,
+XMLPUBFUN void XMLCALL
+ htmlNodeDumpOutput (xmlOutputBufferPtr buf,
xmlDocPtr doc,
- xmlNodePtr cur,
+ xmlNodePtr cur,
const char *encoding);
#endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
htmlIsBooleanAttr (const xmlChar *name);
diff --git a/gnulib-local/lib/libxml/README b/gnulib-local/lib/libxml/README
index dfcc32f..749e671 100644
--- a/gnulib-local/lib/libxml/README
+++ b/gnulib-local/lib/libxml/README
@@ -1 +1,39 @@
-This is not part of the GNU gettext program, but is used with GNU gettext.
+
+ XML toolkit from the GNOME project
+
+Full documentation is available on-line at
+ http://xmlsoft.org/
+
+This code is released under the MIT Licence see the Copyright file.
+
+To build on an Unixised setup:
+ ./configure ; make ; make install
+To build on Windows:
+ see instructions on win32/Readme.txt
+
+To assert build quality:
+ on an Unixised setup:
+ run make tests
+ otherwise:
+ There is 3 standalone tools runtest.c runsuite.c testapi.c, which
+ should compile as part of the build or as any application would.
+ Launch them from this directory to get results, runtest checks
+ the proper functionning of libxml2 main APIs while testapi does
+ a full coverage check. Report failures to the list.
+
+To report bugs, follow the instructions at:
+ http://xmlsoft.org/bugs.html
+
+A mailing-list xml@gnome.org is available, to subscribe:
+ http://mail.gnome.org/mailman/listinfo/xml
+
+The list archive is at:
+ http://mail.gnome.org/archives/xml/
+
+All technical answers asked privately will be automatically answered on
+the list and archived for public access unless privacy is explicitly
+required and justified.
+
+Daniel Veillard
+
+$Id$
diff --git a/gnulib-local/lib/libxml/SAX.c b/gnulib-local/lib/libxml/SAX.c
index 8e5d460..292af57 100644
--- a/gnulib-local/lib/libxml/SAX.c
+++ b/gnulib-local/lib/libxml/SAX.c
@@ -41,7 +41,7 @@
void
initxmlDefaultSAXHandler(xmlSAXHandlerV1 *hdlr, int warning)
{
-
+
if(hdlr->initialized == 1)
return;
diff --git a/gnulib-local/lib/libxml/SAX.in.h b/gnulib-local/lib/libxml/SAX.in.h
index 0ca161b..20093ce 100644
--- a/gnulib-local/lib/libxml/SAX.in.h
+++ b/gnulib-local/lib/libxml/SAX.in.h
@@ -25,53 +25,53 @@ extern "C" {
#endif
XMLPUBFUN const xmlChar * XMLCALL
getPublicId (void *ctx);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
getSystemId (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
setDocumentLocator (void *ctx,
xmlSAXLocatorPtr loc);
-
-XMLPUBFUN int XMLCALL
+
+XMLPUBFUN int XMLCALL
getLineNumber (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
getColumnNumber (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
isStandalone (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
hasInternalSubset (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
hasExternalSubset (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
internalSubset (void *ctx,
const xmlChar *name,
const xmlChar *ExternalID,
const xmlChar *SystemID);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
externalSubset (void *ctx,
const xmlChar *name,
const xmlChar *ExternalID,
const xmlChar *SystemID);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr XMLCALL
getEntity (void *ctx,
const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr XMLCALL
getParameterEntity (void *ctx,
const xmlChar *name);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr XMLCALL
resolveEntity (void *ctx,
const xmlChar *publicId,
const xmlChar *systemId);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
entityDecl (void *ctx,
const xmlChar *name,
int type,
const xmlChar *publicId,
const xmlChar *systemId,
xmlChar *content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
attributeDecl (void *ctx,
const xmlChar *elem,
const xmlChar *fullname,
@@ -79,87 +79,87 @@ XMLPUBFUN void XMLCALL
int def,
const xmlChar *defaultValue,
xmlEnumerationPtr tree);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
elementDecl (void *ctx,
const xmlChar *name,
int type,
xmlElementContentPtr content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
notationDecl (void *ctx,
const xmlChar *name,
const xmlChar *publicId,
const xmlChar *systemId);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
unparsedEntityDecl (void *ctx,
const xmlChar *name,
const xmlChar *publicId,
const xmlChar *systemId,
const xmlChar *notationName);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
startDocument (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
endDocument (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
attribute (void *ctx,
const xmlChar *fullname,
const xmlChar *value);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
startElement (void *ctx,
const xmlChar *fullname,
const xmlChar **atts);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
endElement (void *ctx,
const xmlChar *name);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
reference (void *ctx,
const xmlChar *name);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
characters (void *ctx,
const xmlChar *ch,
int len);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
ignorableWhitespace (void *ctx,
const xmlChar *ch,
int len);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
processingInstruction (void *ctx,
const xmlChar *target,
const xmlChar *data);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
globalNamespace (void *ctx,
const xmlChar *href,
const xmlChar *prefix);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
setNamespace (void *ctx,
const xmlChar *name);
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr XMLCALL
getNamespace (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
checkNamespace (void *ctx,
xmlChar *nameSpace);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
namespaceDecl (void *ctx,
const xmlChar *href,
const xmlChar *prefix);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
comment (void *ctx,
const xmlChar *value);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
cdataBlock (void *ctx,
const xmlChar *value,
int len);
#ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
initxmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr,
int warning);
#ifdef LIBXML_HTML_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
inithtmlDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
#endif
#ifdef LIBXML_DOCB_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
initdocbDefaultSAXHandler (xmlSAXHandlerV1 *hdlr);
#endif
#endif /* LIBXML_SAX1_ENABLED */
diff --git a/gnulib-local/lib/libxml/SAX2.c b/gnulib-local/lib/libxml/SAX2.c
index 7d4ab64..ffef3e1 100644
--- a/gnulib-local/lib/libxml/SAX2.c
+++ b/gnulib-local/lib/libxml/SAX2.c
@@ -11,6 +11,7 @@
#include "libxml.h"
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#include <libxml/xmlmemory.h>
#include <libxml/tree.h>
#include <libxml/parser.h>
@@ -26,6 +27,11 @@
#include <libxml/HTMLtree.h>
#include <libxml/globals.h>
+/* Define SIZE_T_MAX unless defined through <limits.h>. */
+#ifndef SIZE_T_MAX
+# define SIZE_T_MAX ((size_t)-1)
+#endif /* !SIZE_T_MAX */
+
/* #define DEBUG_SAX2 */
/* #define DEBUG_SAX2_TREE */
@@ -39,7 +45,7 @@
*> values "system" and "public". I have made the default be "system" to
*> match yours.
*/
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
@@ -51,12 +57,29 @@
*/
static void
xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt, const char *msg) {
+ xmlStructuredErrorFunc schannel = NULL;
+ const char *str1 = "out of memory\n";
+
if (ctxt != NULL) {
- if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
- ctxt->sax->error(ctxt->userData, "%s: out of memory\n", msg);
+ ctxt->errNo = XML_ERR_NO_MEMORY;
+ if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
+ schannel = ctxt->sax->serror;
+ __xmlRaiseError(schannel,
+ ctxt->vctxt.error, ctxt->vctxt.userData,
+ ctxt, NULL, XML_FROM_PARSER, XML_ERR_NO_MEMORY,
+ XML_ERR_ERROR, NULL, 0, (const char *) str1,
+ NULL, NULL, 0, 0,
+ msg, (const char *) str1, NULL);
ctxt->errNo = XML_ERR_NO_MEMORY;
ctxt->instate = XML_PARSER_EOF;
ctxt->disableSAX = 1;
+ } else {
+ __xmlRaiseError(schannel,
+ NULL, NULL,
+ ctxt, NULL, XML_FROM_PARSER, XML_ERR_NO_MEMORY,
+ XML_ERR_ERROR, NULL, 0, (const char *) str1,
+ NULL, NULL, 0, 0,
+ msg, (const char *) str1, NULL);
}
}
@@ -120,7 +143,7 @@ xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
if (ctxt != NULL)
ctxt->errNo = error;
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
- XML_ERR_FATAL, NULL, 0,
+ XML_ERR_FATAL, NULL, 0,
(const char *) str1, (const char *) str2,
NULL, 0, 0, msg, str1, str2);
if (ctxt != NULL) {
@@ -151,7 +174,7 @@ xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
if (ctxt != NULL)
ctxt->errNo = error;
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
- XML_ERR_WARNING, NULL, 0,
+ XML_ERR_WARNING, NULL, 0,
(const char *) str1, NULL,
NULL, 0, 0, msg, str1);
}
@@ -176,7 +199,7 @@ xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
if (ctxt != NULL)
ctxt->errNo = error;
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
- XML_ERR_ERROR, NULL, 0,
+ XML_ERR_ERROR, NULL, 0,
(const char *) str1, (const char *) str2,
NULL, 0, 0, msg, str1, str2);
}
@@ -200,7 +223,7 @@ xmlNsWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
if (ctxt != NULL)
ctxt->errNo = error;
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
- XML_ERR_WARNING, NULL, 0,
+ XML_ERR_WARNING, NULL, 0,
(const char *) str1, (const char *) str2,
NULL, 0, 0, msg, str1, str2);
}
@@ -234,7 +257,7 @@ xmlSAX2GetSystemId(void *ctx)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL);
- return((const xmlChar *) ctxt->input->filename);
+ return((const xmlChar *) ctxt->input->filename);
}
/**
@@ -349,7 +372,7 @@ xmlSAX2InternalSubset(void *ctx, const xmlChar *name,
xmlFreeDtd(dtd);
ctxt->myDoc->intSubset = NULL;
}
- ctxt->myDoc->intSubset =
+ ctxt->myDoc->intSubset =
xmlCreateIntSubset(ctxt->myDoc, name, ExternalID, SystemID);
if (ctxt->myDoc->intSubset == NULL)
xmlSAX2ErrMemory(ctxt, "xmlSAX2InternalSubset");
@@ -388,6 +411,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
xmlParserInputPtr input = NULL;
xmlCharEncoding enc;
int oldcharset;
+ const xmlChar *oldencoding;
/*
* Ask the Entity resolver to load the damn thing
@@ -409,6 +433,8 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
oldinputMax = ctxt->inputMax;
oldinputTab = ctxt->inputTab;
oldcharset = ctxt->charset;
+ oldencoding = ctxt->encoding;
+ ctxt->encoding = NULL;
ctxt->inputTab = (xmlParserInputPtr *)
xmlMalloc(5 * sizeof(xmlParserInputPtr));
@@ -419,6 +445,7 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
ctxt->inputMax = oldinputMax;
ctxt->inputTab = oldinputTab;
ctxt->charset = oldcharset;
+ ctxt->encoding = oldencoding;
return;
}
ctxt->inputNr = 0;
@@ -464,6 +491,11 @@ xmlSAX2ExternalSubset(void *ctx, const xmlChar *name,
ctxt->inputMax = oldinputMax;
ctxt->inputTab = oldinputTab;
ctxt->charset = oldcharset;
+ if ((ctxt->encoding != NULL) &&
+ ((ctxt->dict == NULL) ||
+ (!xmlDictOwns(ctxt->dict, ctxt->encoding))))
+ xmlFree((xmlChar *) ctxt->encoding);
+ ctxt->encoding = oldencoding;
/* ctxt->wellFormed = oldwellFormed; */
}
}
@@ -568,6 +600,7 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name)
* parse the external entity
*/
xmlNodePtr children;
+ unsigned long oldnbent = ctxt->nbentities;
val = xmlParseCtxtExternalEntity(ctxt, ret->URI,
ret->ExternalID, &children);
@@ -580,7 +613,11 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name)
return(NULL);
}
ret->owner = 1;
- ret->checked = 1;
+ if (ret->checked == 0) {
+ ret->checked = (ctxt->nbentities - oldnbent + 1) * 2;
+ if ((ret->content != NULL) && (xmlStrchr(ret->content, '<')))
+ ret->checked |= 1;
+ }
}
return(ret);
}
@@ -614,8 +651,8 @@ xmlSAX2GetParameterEntity(void *ctx, const xmlChar *name)
/**
* xmlSAX2EntityDecl:
* @ctx: the user data (XML parser context)
- * @name: the entity name
- * @type: the entity type
+ * @name: the entity name
+ * @type: the entity type
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
* @content: the entity value (without processing).
@@ -650,7 +687,7 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
base = ctxt->input->filename;
if (base == NULL)
base = ctxt->directory;
-
+
URI = xmlBuildURI(systemId, (const xmlChar *) base);
ent->URI = URI;
}
@@ -659,7 +696,7 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
systemId, content);
if ((ent == NULL) && (ctxt->pedantic) &&
(ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
- ctxt->sax->warning(ctxt->userData,
+ ctxt->sax->warning(ctxt->userData,
"Entity(%s) already defined in the external subset\n", name);
if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
xmlChar *URI;
@@ -669,7 +706,7 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
base = ctxt->input->filename;
if (base == NULL)
base = ctxt->directory;
-
+
URI = xmlBuildURI(systemId, (const xmlChar *) base);
ent->URI = URI;
}
@@ -684,8 +721,8 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
* xmlSAX2AttributeDecl:
* @ctx: the user data (XML parser context)
* @elem: the name of the element
- * @fullname: the attribute name
- * @type: the attribute type
+ * @fullname: the attribute name
+ * @type: the attribute type
* @def: the type of default value
* @defaultValue: the attribute default value
* @tree: the tree of enumerated value set
@@ -728,7 +765,7 @@ xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
(xmlAttributeDefault) def, defaultValue, tree);
else if (ctxt->inSubset == 2)
attr = xmlAddAttributeDecl(&ctxt->vctxt, ctxt->myDoc->extSubset, elem,
- name, prefix, (xmlAttributeType) type,
+ name, prefix, (xmlAttributeType) type,
(xmlAttributeDefault) def, defaultValue, tree);
else {
xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
@@ -754,8 +791,8 @@ xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
/**
* xmlSAX2ElementDecl:
* @ctx: the user data (XML parser context)
- * @name: the element name
- * @type: the element type
+ * @name: the element name
+ * @type: the element type
* @content: the element value tree
*
* An element definition has been parsed
@@ -876,7 +913,7 @@ xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name,
publicId, systemId, notationName);
if ((ent == NULL) && (ctxt->pedantic) &&
(ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
- ctxt->sax->warning(ctxt->userData,
+ ctxt->sax->warning(ctxt->userData,
"Entity(%s) already defined in the internal subset\n", name);
if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
xmlChar *URI;
@@ -886,7 +923,7 @@ xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name,
base = ctxt->input->filename;
if (base == NULL)
base = ctxt->directory;
-
+
URI = xmlBuildURI(systemId, (const xmlChar *) base);
ent->URI = URI;
}
@@ -896,7 +933,7 @@ xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name,
publicId, systemId, notationName);
if ((ent == NULL) && (ctxt->pedantic) &&
(ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
- ctxt->sax->warning(ctxt->userData,
+ ctxt->sax->warning(ctxt->userData,
"Entity(%s) already defined in the external subset\n", name);
if ((ent != NULL) && (ent->URI == NULL) && (systemId != NULL)) {
xmlChar *URI;
@@ -906,7 +943,7 @@ xmlSAX2UnparsedEntityDecl(void *ctx, const xmlChar *name,
base = ctxt->input->filename;
if (base == NULL)
base = ctxt->directory;
-
+
URI = xmlBuildURI(systemId, (const xmlChar *) base);
ent->URI = URI;
}
@@ -961,6 +998,8 @@ xmlSAX2StartDocument(void *ctx)
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartDocument");
return;
}
+ ctxt->myDoc->properties = XML_DOC_HTML;
+ ctxt->myDoc->parseFlags = ctxt->options;
#else
xmlGenericError(xmlGenericErrorContext,
"libxml2 built without HTML support\n");
@@ -972,6 +1011,10 @@ xmlSAX2StartDocument(void *ctx)
} else {
doc = ctxt->myDoc = xmlNewDoc(ctxt->version);
if (doc != NULL) {
+ doc->properties = 0;
+ if (ctxt->options & XML_PARSE_OLD10)
+ doc->properties |= XML_DOC_OLD10;
+ doc->parseFlags = ctxt->options;
if (ctxt->encoding != NULL)
doc->encoding = xmlStrdup(ctxt->encoding);
else
@@ -1035,7 +1078,7 @@ xmlSAX2EndDocument(void *ctx)
}
}
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
/**
* xmlSAX2AttributeInternal:
* @ctx: the user data (XML parser context)
@@ -1059,25 +1102,31 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
xmlChar *nval;
xmlNsPtr namespace;
- /*
- * Split the full name into a namespace prefix and the tag name
- */
- name = xmlSplitQName(ctxt, fullname, &ns);
- if ((name != NULL) && (name[0] == 0)) {
- if (xmlStrEqual(ns, BAD_CAST "xmlns")) {
- xmlNsErrMsg(ctxt, XML_ERR_NS_DECL_ERROR,
- "invalid namespace declaration '%s'\n",
- fullname, NULL);
- } else {
- xmlNsWarnMsg(ctxt, XML_WAR_NS_COLUMN,
- "Avoid attribute ending with ':' like '%s'\n",
- fullname, NULL);
- }
- if (ns != NULL)
- xmlFree(ns);
- ns = NULL;
- xmlFree(name);
+ if (ctxt->html) {
name = xmlStrdup(fullname);
+ ns = NULL;
+ namespace = NULL;
+ } else {
+ /*
+ * Split the full name into a namespace prefix and the tag name
+ */
+ name = xmlSplitQName(ctxt, fullname, &ns);
+ if ((name != NULL) && (name[0] == 0)) {
+ if (xmlStrEqual(ns, BAD_CAST "xmlns")) {
+ xmlNsErrMsg(ctxt, XML_ERR_NS_DECL_ERROR,
+ "invalid namespace declaration '%s'\n",
+ fullname, NULL);
+ } else {
+ xmlNsWarnMsg(ctxt, XML_WAR_NS_COLUMN,
+ "Avoid attribute ending with ':' like '%s'\n",
+ fullname, NULL);
+ }
+ if (ns != NULL)
+ xmlFree(ns);
+ ns = NULL;
+ xmlFree(name);
+ name = xmlStrdup(fullname);
+ }
}
if (name == NULL) {
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
@@ -1086,24 +1135,33 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
return;
}
+#ifdef LIBXML_HTML_ENABLED
+ if ((ctxt->html) &&
+ (value == NULL) && (htmlIsBooleanAttr(fullname))) {
+ nval = xmlStrdup(fullname);
+ value = (const xmlChar *) nval;
+ } else
+#endif
+ {
#ifdef LIBXML_VALID_ENABLED
- /*
- * Do the last stage of the attribute normalization
- * Needed for HTML too:
- * http://www.w3.org/TR/html4/types.html#h-6.2
- */
- ctxt->vctxt.valid = 1;
- nval = xmlValidCtxtNormalizeAttributeValue(&ctxt->vctxt,
- ctxt->myDoc, ctxt->node,
- fullname, value);
- if (ctxt->vctxt.valid != 1) {
- ctxt->valid = 0;
- }
- if (nval != NULL)
- value = nval;
+ /*
+ * Do the last stage of the attribute normalization
+ * Needed for HTML too:
+ * http://www.w3.org/TR/html4/types.html#h-6.2
+ */
+ ctxt->vctxt.valid = 1;
+ nval = xmlValidCtxtNormalizeAttributeValue(&ctxt->vctxt,
+ ctxt->myDoc, ctxt->node,
+ fullname, value);
+ if (ctxt->vctxt.valid != 1) {
+ ctxt->valid = 0;
+ }
+ if (nval != NULL)
+ value = nval;
#else
- nval = NULL;
+ nval = NULL;
#endif /* LIBXML_VALID_ENABLED */
+ }
/*
* Check whether it's a namespace definition
@@ -1119,6 +1177,12 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
0,0,0);
ctxt->depth--;
+ if (val == NULL) {
+ xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
+ if (name != NULL)
+ xmlFree(name);
+ return;
+ }
} else {
val = (xmlChar *) value;
}
@@ -1129,12 +1193,12 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
uri = xmlParseURI((const char *)val);
if (uri == NULL) {
if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
- ctxt->sax->warning(ctxt->userData,
+ ctxt->sax->warning(ctxt->userData,
"xmlns: %s not a valid URI\n", val);
} else {
if (uri->scheme == NULL) {
if ((ctxt->sax != NULL) && (ctxt->sax->warning != NULL))
- ctxt->sax->warning(ctxt->userData,
+ ctxt->sax->warning(ctxt->userData,
"xmlns: URI %s is not absolute\n", val);
}
xmlFreeURI(uri);
@@ -1154,7 +1218,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,
ctxt->node, prefix, nsret, val);
#endif /* LIBXML_VALID_ENABLED */
- if (name != NULL)
+ if (name != NULL)
xmlFree(name);
if (nval != NULL)
xmlFree(nval);
@@ -1176,7 +1240,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
if (val == NULL) {
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
xmlFree(ns);
- if (name != NULL)
+ if (name != NULL)
xmlFree(name);
return;
}
@@ -1217,7 +1281,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
ctxt->valid &= xmlValidateOneNamespace(&ctxt->vctxt, ctxt->myDoc,
ctxt->node, prefix, nsret, value);
#endif /* LIBXML_VALID_ENABLED */
- if (name != NULL)
+ if (name != NULL)
xmlFree(name);
if (nval != NULL)
xmlFree(nval);
@@ -1227,30 +1291,32 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
}
if (ns != NULL) {
- xmlAttrPtr prop;
namespace = xmlSearchNs(ctxt->myDoc, ctxt->node, ns);
+
if (namespace == NULL) {
xmlNsErrMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
"Namespace prefix %s of attribute %s is not defined\n",
ns, name);
- }
-
- prop = ctxt->node->properties;
- while (prop != NULL) {
- if (prop->ns != NULL) {
- if ((xmlStrEqual(name, prop->name)) &&
- ((namespace == prop->ns) ||
- (xmlStrEqual(namespace->href, prop->ns->href)))) {
- xmlNsErrMsg(ctxt, XML_ERR_ATTRIBUTE_REDEFINED,
- "Attribute %s in %s redefined\n",
- name, namespace->href);
- ctxt->wellFormed = 0;
- if (ctxt->recovery == 0) ctxt->disableSAX = 1;
- goto error;
- }
- }
- prop = prop->next;
- }
+ } else {
+ xmlAttrPtr prop;
+
+ prop = ctxt->node->properties;
+ while (prop != NULL) {
+ if (prop->ns != NULL) {
+ if ((xmlStrEqual(name, prop->name)) &&
+ ((namespace == prop->ns) ||
+ (xmlStrEqual(namespace->href, prop->ns->href)))) {
+ xmlNsErrMsg(ctxt, XML_ERR_ATTRIBUTE_REDEFINED,
+ "Attribute %s in %s redefined\n",
+ name, namespace->href);
+ ctxt->wellFormed = 0;
+ if (ctxt->recovery == 0) ctxt->disableSAX = 1;
+ goto error;
+ }
+ }
+ prop = prop->next;
+ }
+ }
} else {
namespace = NULL;
}
@@ -1281,7 +1347,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
#ifdef LIBXML_VALID_ENABLED
if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
ctxt->myDoc && ctxt->myDoc->intSubset) {
-
+
/*
* If we don't substitute entities, the validation should be
* done on a value with replaced entities anyway.
@@ -1293,7 +1359,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
0,0,0);
ctxt->depth--;
-
+
if (val == NULL)
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
ctxt->myDoc, ctxt->node, ret, value);
@@ -1350,7 +1416,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
error:
if (nval != NULL)
xmlFree(nval);
- if (ns != NULL)
+ if (ns != NULL)
xmlFree(ns);
}
@@ -1401,6 +1467,10 @@ process_external_subset:
} else {
fulln = xmlStrdup(attr->name);
}
+ if (fulln == NULL) {
+ xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElement");
+ break;
+ }
/*
* Check that the attribute is not declared in the
@@ -1423,6 +1493,7 @@ process_external_subset:
(const char *)fulln,
(const char *)attr->elem);
}
+ xmlFree(fulln);
}
attr = attr->nexth;
}
@@ -1444,7 +1515,7 @@ process_external_subset:
* - this is a namespace prefix
* - the user required for completion in the tree
* like XSLT
- * - there isn't already an attribute definition
+ * - there isn't already an attribute definition
* in the internal subset overriding it.
*/
if (((attr->prefix != NULL) &&
@@ -1533,17 +1604,17 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
/*
* First check on validity:
*/
- if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
+ if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
((ctxt->myDoc->intSubset == NULL) ||
- ((ctxt->myDoc->intSubset->notations == NULL) &&
+ ((ctxt->myDoc->intSubset->notations == NULL) &&
(ctxt->myDoc->intSubset->elements == NULL) &&
- (ctxt->myDoc->intSubset->attributes == NULL) &&
+ (ctxt->myDoc->intSubset->attributes == NULL) &&
(ctxt->myDoc->intSubset->entities == NULL)))) {
xmlErrValid(ctxt, XML_ERR_NO_DTD,
"Validation failed: no DTD found !", NULL, NULL);
ctxt->validate = 0;
}
-
+
/*
* Split the full name into a namespace prefix and the tag name
@@ -1721,7 +1792,6 @@ void
xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
- xmlParserNodeInfo node_info;
xmlNodePtr cur;
if (ctx == NULL) return;
@@ -1732,13 +1802,13 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
else
xmlGenericError(xmlGenericErrorContext, "SAX.xmlSAX2EndElement(%s)\n", name);
#endif
-
+
/* Capture end position and add node */
if (cur != NULL && ctxt->record_info) {
- node_info.end_pos = ctxt->input->cur - ctxt->input->base;
- node_info.end_line = ctxt->input->line;
- node_info.node = cur;
- xmlParserAddNodeInfo(ctxt, &node_info);
+ ctxt->nodeInfo->end_pos = ctxt->input->cur - ctxt->input->base;
+ ctxt->nodeInfo->end_line = ctxt->input->line;
+ ctxt->nodeInfo->node = cur;
+ xmlParserAddNodeInfo(ctxt, ctxt->nodeInfo);
}
ctxt->nodemem = -1;
@@ -1749,7 +1819,7 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
cur);
#endif /* LIBXML_VALID_ENABLED */
-
+
/*
* end of parsing of this node.
*/
@@ -1758,15 +1828,15 @@ xmlSAX2EndElement(void *ctx, const xmlChar *name ATTRIBUTE_UNUSED)
#endif
nodePop(ctxt);
}
-#endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLE */
+#endif /* LIBXML_SAX1_ENABLED || LIBXML_HTML_ENABLED || LIBXML_LEGACY_ENABLED */
/*
* xmlSAX2TextNode:
* @ctxt: the parser context
* @str: the input string
* @len: the string length
- *
- * Remove the entities from an attribute value
+ *
+ * Callback for a text node
*
* Returns the newly allocated string or NULL if not needed or error
*/
@@ -1799,7 +1869,7 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
if ((len < (int) (2 * sizeof(void *))) &&
(ctxt->options & XML_PARSE_COMPACT)) {
- /* store the string in the node overrithing properties and nsDef */
+ /* store the string in the node overriding properties and nsDef */
xmlChar *tmp = (xmlChar *) &(ret->properties);
memcpy(tmp, str, len);
tmp[len] = 0;
@@ -1831,6 +1901,18 @@ skip:
} else
ret->content = (xmlChar *) intern;
+ if (ctxt->linenumbers) {
+ if (ctxt->input != NULL) {
+ if (ctxt->input->line < 65535)
+ ret->line = (short) ctxt->input->line;
+ else {
+ ret->line = 65535;
+ if (ctxt->options & XML_PARSE_BIG_LINES)
+ ret->psvi = (void *) (long) ctxt->input->line;
+ }
+ }
+ }
+
if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
xmlRegisterNodeDefaultValue(ret);
return(ret);
@@ -1842,7 +1924,7 @@ skip:
* @ctxt: the parser context
* @str: the input string
* @len: the string length
- *
+ *
* Remove the entities from an attribute value
*
* Returns the newly allocated string or NULL if not needed or error
@@ -1908,7 +1990,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
memset(ret, 0, sizeof(xmlAttr));
ret->type = XML_ATTRIBUTE_NODE;
- ret->parent = ctxt->node;
+ ret->parent = ctxt->node;
ret->doc = ctxt->myDoc;
ret->ns = namespace;
@@ -1932,7 +2014,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
xmlRegisterNodeDefaultValue((xmlNodePtr)ret);
} else {
if (ctxt->dictNames)
- ret = xmlNewNsPropEatName(ctxt->node, namespace,
+ ret = xmlNewNsPropEatName(ctxt->node, namespace,
(xmlChar *) localname, NULL);
else
ret = xmlNewNsProp(ctxt->node, namespace, localname, NULL);
@@ -2018,7 +2100,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
xmlChar *nvalnorm;
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(localname, prefix, fn, 50);
if (fullname != NULL) {
ctxt->vctxt.valid = 1;
@@ -2069,6 +2151,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
*/
if (dup == NULL)
dup = xmlStrndup(value, valueend - value);
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
#ifdef LIBXML_VALID_ENABLED
if (xmlValidateNCName(dup, 1) != 0) {
xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
@@ -2076,6 +2159,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
(const char *) dup, NULL);
}
#endif
+#endif
xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
} else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
/* might be worth duplicate entry points and not copy */
@@ -2125,6 +2209,7 @@ xmlSAX2StartElementNs(void *ctx,
xmlNodePtr parent;
xmlNsPtr last = NULL, ns;
const xmlChar *uri, *pref;
+ xmlChar *lname = NULL;
int i, j;
if (ctx == NULL) return;
@@ -2132,18 +2217,32 @@ xmlSAX2StartElementNs(void *ctx,
/*
* First check on validity:
*/
- if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
+ if (ctxt->validate && (ctxt->myDoc->extSubset == NULL) &&
((ctxt->myDoc->intSubset == NULL) ||
- ((ctxt->myDoc->intSubset->notations == NULL) &&
+ ((ctxt->myDoc->intSubset->notations == NULL) &&
(ctxt->myDoc->intSubset->elements == NULL) &&
- (ctxt->myDoc->intSubset->attributes == NULL) &&
+ (ctxt->myDoc->intSubset->attributes == NULL) &&
(ctxt->myDoc->intSubset->entities == NULL)))) {
- xmlErrValid(ctxt, XML_ERR_NO_DTD,
+ xmlErrValid(ctxt, XML_DTD_NO_DTD,
"Validation failed: no DTD found !", NULL, NULL);
ctxt->validate = 0;
}
/*
+ * Take care of the rare case of an undefined namespace prefix
+ */
+ if ((prefix != NULL) && (URI == NULL)) {
+ if (ctxt->dictNames) {
+ const xmlChar *fullname;
+
+ fullname = xmlDictQLookup(ctxt->dict, prefix, localname);
+ if (fullname != NULL)
+ localname = fullname;
+ } else {
+ lname = xmlBuildQName(localname, prefix, NULL, 0);
+ }
+ }
+ /*
* allocate the node
*/
if (ctxt->freeElems != NULL) {
@@ -2156,7 +2255,10 @@ xmlSAX2StartElementNs(void *ctx,
if (ctxt->dictNames)
ret->name = localname;
else {
- ret->name = xmlStrdup(localname);
+ if (lname == NULL)
+ ret->name = xmlStrdup(localname);
+ else
+ ret->name = lname;
if (ret->name == NULL) {
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
return;
@@ -2166,10 +2268,13 @@ xmlSAX2StartElementNs(void *ctx,
xmlRegisterNodeDefaultValue(ret);
} else {
if (ctxt->dictNames)
- ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
+ ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
(xmlChar *) localname, NULL);
- else
+ else if (lname == NULL)
ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
+ else
+ ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
+ (xmlChar *) lname, NULL);
if (ret == NULL) {
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
return;
@@ -2184,7 +2289,7 @@ xmlSAX2StartElementNs(void *ctx,
}
}
- if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
+ if (parent == NULL) {
xmlAddChild((xmlNodePtr) ctxt->myDoc, (xmlNodePtr) ret);
}
/*
@@ -2204,8 +2309,12 @@ xmlSAX2StartElementNs(void *ctx,
if ((URI != NULL) && (prefix == pref))
ret->ns = ns;
} else {
- xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
- return;
+ /*
+ * any out of memory error would already have been raised
+ * but we can't be garanteed it's the actual error due to the
+ * API, best is to skip in this case
+ */
+ continue;
}
#ifdef LIBXML_VALID_ENABLED
if ((!ctxt->html) && ctxt->validate && ctxt->wellFormed &&
@@ -2256,9 +2365,14 @@ xmlSAX2StartElementNs(void *ctx,
xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
return;
}
- xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
- "Namespace prefix %s was not found\n",
- prefix, NULL);
+ if (prefix != NULL)
+ xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
+ "Namespace prefix %s was not found\n",
+ prefix, NULL);
+ else
+ xmlNsWarnMsg(ctxt, XML_NS_ERR_UNDEFINED_NAMESPACE,
+ "Namespace default prefix was not found\n",
+ NULL, NULL);
}
}
@@ -2267,8 +2381,33 @@ xmlSAX2StartElementNs(void *ctx,
*/
if (nb_attributes > 0) {
for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
+ /*
+ * Handle the rare case of an undefined atribute prefix
+ */
+ if ((attributes[j+1] != NULL) && (attributes[j+2] == NULL)) {
+ if (ctxt->dictNames) {
+ const xmlChar *fullname;
+
+ fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
+ attributes[j]);
+ if (fullname != NULL) {
+ xmlSAX2AttributeNs(ctxt, fullname, NULL,
+ attributes[j+3], attributes[j+4]);
+ continue;
+ }
+ } else {
+ lname = xmlBuildQName(attributes[j], attributes[j+1],
+ NULL, 0);
+ if (lname != NULL) {
+ xmlSAX2AttributeNs(ctxt, lname, NULL,
+ attributes[j+3], attributes[j+4]);
+ xmlFree(lname);
+ continue;
+ }
+ }
+ }
xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
- attributes[j+3], attributes[j+4]);
+ attributes[j+3], attributes[j+4]);
}
}
@@ -2339,7 +2478,7 @@ xmlSAX2EndElementNs(void *ctx,
* @ctx: the user data (XML parser context)
* @name: The entity name
*
- * called when an entity xmlSAX2Reference is detected.
+ * called when an entity xmlSAX2Reference is detected.
*/
void
xmlSAX2Reference(void *ctx, const xmlChar *name)
@@ -2360,7 +2499,9 @@ xmlSAX2Reference(void *ctx, const xmlChar *name)
xmlGenericError(xmlGenericErrorContext,
"add xmlSAX2Reference %s to %s \n", name, ctxt->node->name);
#endif
- xmlAddChild(ctxt->node, ret);
+ if (xmlAddChild(ctxt->node, ret) == NULL) {
+ xmlFreeNode(ret);
+ }
}
/**
@@ -2437,9 +2578,23 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
(xmlDictOwns(ctxt->dict, lastChild->content))) {
lastChild->content = xmlStrdup(lastChild->content);
}
+ if (lastChild->content == NULL) {
+ xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: xmlStrdup returned NULL");
+ return;
+ }
+ if (((size_t)ctxt->nodelen + (size_t)len > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters: huge text node");
+ return;
+ }
+ if ((size_t)ctxt->nodelen > SIZE_T_MAX - (size_t)len ||
+ (size_t)ctxt->nodemem + (size_t)len > SIZE_T_MAX / 2) {
+ xmlSAX2ErrMemory(ctxt, "xmlSAX2Characters overflow prevented");
+ return;
+ }
if (ctxt->nodelen + len >= ctxt->nodemem) {
xmlChar *newbuf;
- int size;
+ size_t size;
size = ctxt->nodemem + len;
size *= 2;
@@ -2520,7 +2675,6 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
ret = xmlNewDocPI(ctxt->myDoc, target, data);
if (ret == NULL) return;
- parent = ctxt->node;
if (ctxt->linenumbers) {
if (ctxt->input != NULL) {
@@ -2537,7 +2691,7 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
return;
}
- if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
+ if (parent == NULL) {
#ifdef DEBUG_SAX_TREE
xmlGenericError(xmlGenericErrorContext,
"Setting PI %s as root\n", target);
@@ -2598,7 +2752,7 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
xmlAddChild((xmlNodePtr) ctxt->myDoc->extSubset, ret);
return;
}
- if ((ctxt->myDoc->children == NULL) || (parent == NULL)) {
+ if (parent == NULL) {
#ifdef DEBUG_SAX_TREE
xmlGenericError(xmlGenericErrorContext,
"Setting xmlSAX2Comment as root\n");
diff --git a/gnulib-local/lib/libxml/SAX2.in.h b/gnulib-local/lib/libxml/SAX2.in.h
index 8d2db02..a55212e 100644
--- a/gnulib-local/lib/libxml/SAX2.in.h
+++ b/gnulib-local/lib/libxml/SAX2.in.h
@@ -23,53 +23,53 @@ extern "C" {
#endif
XMLPUBFUN const xmlChar * XMLCALL
xmlSAX2GetPublicId (void *ctx);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlSAX2GetSystemId (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2SetDocumentLocator (void *ctx,
xmlSAXLocatorPtr loc);
-
-XMLPUBFUN int XMLCALL
+
+XMLPUBFUN int XMLCALL
xmlSAX2GetLineNumber (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSAX2GetColumnNumber (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSAX2IsStandalone (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSAX2HasInternalSubset (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSAX2HasExternalSubset (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2InternalSubset (void *ctx,
const xmlChar *name,
const xmlChar *ExternalID,
const xmlChar *SystemID);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2ExternalSubset (void *ctx,
const xmlChar *name,
const xmlChar *ExternalID,
const xmlChar *SystemID);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr XMLCALL
xmlSAX2GetEntity (void *ctx,
const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr XMLCALL
xmlSAX2GetParameterEntity (void *ctx,
const xmlChar *name);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr XMLCALL
xmlSAX2ResolveEntity (void *ctx,
const xmlChar *publicId,
const xmlChar *systemId);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2EntityDecl (void *ctx,
const xmlChar *name,
int type,
const xmlChar *publicId,
const xmlChar *systemId,
xmlChar *content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2AttributeDecl (void *ctx,
const xmlChar *elem,
const xmlChar *fullname,
@@ -77,36 +77,38 @@ XMLPUBFUN void XMLCALL
int def,
const xmlChar *defaultValue,
xmlEnumerationPtr tree);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2ElementDecl (void *ctx,
const xmlChar *name,
int type,
xmlElementContentPtr content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2NotationDecl (void *ctx,
const xmlChar *name,
const xmlChar *publicId,
const xmlChar *systemId);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2UnparsedEntityDecl (void *ctx,
const xmlChar *name,
const xmlChar *publicId,
const xmlChar *systemId,
const xmlChar *notationName);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2StartDocument (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2EndDocument (void *ctx);
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
-XMLPUBFUN void XMLCALL
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
+ defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || \
+ defined(LIBXML_LEGACY_ENABLED)
+XMLPUBFUN void XMLCALL
xmlSAX2StartElement (void *ctx,
const xmlChar *fullname,
const xmlChar **atts);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2EndElement (void *ctx,
const xmlChar *name);
-#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED */
+#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED or LIBXML_LEGACY_ENABLED */
XMLPUBFUN void XMLCALL
xmlSAX2StartElementNs (void *ctx,
const xmlChar *localname,
@@ -122,25 +124,25 @@ XMLPUBFUN void XMLCALL
const xmlChar *localname,
const xmlChar *prefix,
const xmlChar *URI);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2Reference (void *ctx,
const xmlChar *name);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2Characters (void *ctx,
const xmlChar *ch,
int len);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2IgnorableWhitespace (void *ctx,
const xmlChar *ch,
int len);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2ProcessingInstruction (void *ctx,
const xmlChar *target,
const xmlChar *data);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2Comment (void *ctx,
const xmlChar *value);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2CDataBlock (void *ctx,
const xmlChar *value,
int len);
@@ -153,22 +155,22 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlSAXVersion (xmlSAXHandler *hdlr,
int version);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2InitDefaultSAXHandler (xmlSAXHandler *hdlr,
int warning);
#ifdef LIBXML_HTML_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
htmlDefaultSAXHandlerInit (void);
#endif
#ifdef LIBXML_DOCB_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSAX2InitDocbDefaultSAXHandler(xmlSAXHandler *hdlr);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
docbDefaultSAXHandlerInit (void);
#endif
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDefaultSAXHandlerInit (void);
#ifdef __cplusplus
}
diff --git a/gnulib-local/lib/libxml/buf.c b/gnulib-local/lib/libxml/buf.c
new file mode 100644
index 0000000..07922ff
--- /dev/null
+++ b/gnulib-local/lib/libxml/buf.c
@@ -0,0 +1,1345 @@
+/*
+ * buf.c: memory buffers for libxml2
+ *
+ * new buffer structures and entry points to simplify the maintainance
+ * of libxml2 and ensure we keep good control over memory allocations
+ * and stay 64 bits clean.
+ * The new entry point use the xmlBufPtr opaque structure and
+ * xmlBuf...() counterparts to the old xmlBuf...() functions
+ *
+ * See Copyright for the status of this software.
+ *
+ * daniel@veillard.com
+ */
+
+#define IN_LIBXML
+#include "libxml.h"
+
+#include <string.h> /* for memset() only ! */
+#include <limits.h>
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#include <libxml/tree.h>
+#include <libxml/globals.h>
+#include <libxml/tree.h>
+#include <libxml/parserInternals.h> /* for XML_MAX_TEXT_LENGTH */
+#include "buf.h"
+
+#define WITH_BUFFER_COMPAT
+
+/**
+ * xmlBuf:
+ *
+ * A buffer structure. The base of the structure is somehow compatible
+ * with struct _xmlBuffer to limit risks on application which accessed
+ * directly the input->buf->buffer structures.
+ */
+
+struct _xmlBuf {
+ xmlChar *content; /* The buffer content UTF8 */
+ unsigned int compat_use; /* for binary compatibility */
+ unsigned int compat_size; /* for binary compatibility */
+ xmlBufferAllocationScheme alloc; /* The realloc method */
+ xmlChar *contentIO; /* in IO mode we may have a different base */
+ size_t use; /* The buffer size used */
+ size_t size; /* The buffer size */
+ xmlBufferPtr buffer; /* wrapper for an old buffer */
+ int error; /* an error code if a failure occured */
+};
+
+#ifdef WITH_BUFFER_COMPAT
+/*
+ * Macro for compatibility with xmlBuffer to be used after an xmlBuf
+ * is updated. This makes sure the compat fields are updated too.
+ */
+#define UPDATE_COMPAT(buf) \
+ if (buf->size < INT_MAX) buf->compat_size = buf->size; \
+ else buf->compat_size = INT_MAX; \
+ if (buf->use < INT_MAX) buf->compat_use = buf->use; \
+ else buf->compat_use = INT_MAX;
+
+/*
+ * Macro for compatibility with xmlBuffer to be used in all the xmlBuf
+ * entry points, it checks that the compat fields have not been modified
+ * by direct call to xmlBuffer function from code compiled before 2.9.0 .
+ */
+#define CHECK_COMPAT(buf) \
+ if (buf->size != (size_t) buf->compat_size) \
+ if (buf->compat_size < INT_MAX) \
+ buf->size = buf->compat_size; \
+ if (buf->use != (size_t) buf->compat_use) \
+ if (buf->compat_use < INT_MAX) \
+ buf->use = buf->compat_use;
+
+#else /* ! WITH_BUFFER_COMPAT */
+#define UPDATE_COMPAT(buf)
+#define CHECK_COMPAT(buf)
+#endif /* WITH_BUFFER_COMPAT */
+
+/**
+ * xmlBufMemoryError:
+ * @extra: extra informations
+ *
+ * Handle an out of memory condition
+ * To be improved...
+ */
+static void
+xmlBufMemoryError(xmlBufPtr buf, const char *extra)
+{
+ __xmlSimpleError(XML_FROM_BUFFER, XML_ERR_NO_MEMORY, NULL, NULL, extra);
+ if ((buf) && (buf->error == 0))
+ buf->error = XML_ERR_NO_MEMORY;
+}
+
+/**
+ * xmlBufOverflowError:
+ * @extra: extra informations
+ *
+ * Handle a buffer overflow error
+ * To be improved...
+ */
+static void
+xmlBufOverflowError(xmlBufPtr buf, const char *extra)
+{
+ __xmlSimpleError(XML_FROM_BUFFER, XML_BUF_OVERFLOW, NULL, NULL, extra);
+ if ((buf) && (buf->error == 0))
+ buf->error = XML_BUF_OVERFLOW;
+}
+
+
+/**
+ * xmlBufCreate:
+ *
+ * routine to create an XML buffer.
+ * returns the new structure.
+ */
+xmlBufPtr
+xmlBufCreate(void) {
+ xmlBufPtr ret;
+
+ ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));
+ if (ret == NULL) {
+ xmlBufMemoryError(NULL, "creating buffer");
+ return(NULL);
+ }
+ ret->compat_use = 0;
+ ret->use = 0;
+ ret->error = 0;
+ ret->buffer = NULL;
+ ret->size = xmlDefaultBufferSize;
+ ret->compat_size = xmlDefaultBufferSize;
+ ret->alloc = xmlBufferAllocScheme;
+ ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
+ if (ret->content == NULL) {
+ xmlBufMemoryError(ret, "creating buffer");
+ xmlFree(ret);
+ return(NULL);
+ }
+ ret->content[0] = 0;
+ ret->contentIO = NULL;
+ return(ret);
+}
+
+/**
+ * xmlBufCreateSize:
+ * @size: initial size of buffer
+ *
+ * routine to create an XML buffer.
+ * returns the new structure.
+ */
+xmlBufPtr
+xmlBufCreateSize(size_t size) {
+ xmlBufPtr ret;
+
+ ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));
+ if (ret == NULL) {
+ xmlBufMemoryError(NULL, "creating buffer");
+ return(NULL);
+ }
+ ret->compat_use = 0;
+ ret->use = 0;
+ ret->error = 0;
+ ret->buffer = NULL;
+ ret->alloc = xmlBufferAllocScheme;
+ ret->size = (size ? size+2 : 0); /* +1 for ending null */
+ ret->compat_size = (int) ret->size;
+ if (ret->size){
+ ret->content = (xmlChar *) xmlMallocAtomic(ret->size * sizeof(xmlChar));
+ if (ret->content == NULL) {
+ xmlBufMemoryError(ret, "creating buffer");
+ xmlFree(ret);
+ return(NULL);
+ }
+ ret->content[0] = 0;
+ } else
+ ret->content = NULL;
+ ret->contentIO = NULL;
+ return(ret);
+}
+
+/**
+ * xmlBufDetach:
+ * @buf: the buffer
+ *
+ * Remove the string contained in a buffer and give it back to the
+ * caller. The buffer is reset to an empty content.
+ * This doesn't work with immutable buffers as they can't be reset.
+ *
+ * Returns the previous string contained by the buffer.
+ */
+xmlChar *
+xmlBufDetach(xmlBufPtr buf) {
+ xmlChar *ret;
+
+ if (buf == NULL)
+ return(NULL);
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
+ return(NULL);
+ if (buf->buffer != NULL)
+ return(NULL);
+ if (buf->error)
+ return(NULL);
+
+ ret = buf->content;
+ buf->content = NULL;
+ buf->size = 0;
+ buf->use = 0;
+ buf->compat_use = 0;
+ buf->compat_size = 0;
+
+ return ret;
+}
+
+
+/**
+ * xmlBufCreateStatic:
+ * @mem: the memory area
+ * @size: the size in byte
+ *
+ * routine to create an XML buffer from an immutable memory area.
+ * The area won't be modified nor copied, and is expected to be
+ * present until the end of the buffer lifetime.
+ *
+ * returns the new structure.
+ */
+xmlBufPtr
+xmlBufCreateStatic(void *mem, size_t size) {
+ xmlBufPtr ret;
+
+ if ((mem == NULL) || (size == 0))
+ return(NULL);
+
+ ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));
+ if (ret == NULL) {
+ xmlBufMemoryError(NULL, "creating buffer");
+ return(NULL);
+ }
+ if (size < INT_MAX) {
+ ret->compat_use = size;
+ ret->compat_size = size;
+ } else {
+ ret->compat_use = INT_MAX;
+ ret->compat_size = INT_MAX;
+ }
+ ret->use = size;
+ ret->size = size;
+ ret->alloc = XML_BUFFER_ALLOC_IMMUTABLE;
+ ret->content = (xmlChar *) mem;
+ ret->error = 0;
+ ret->buffer = NULL;
+ return(ret);
+}
+
+/**
+ * xmlBufGetAllocationScheme:
+ * @buf: the buffer
+ *
+ * Get the buffer allocation scheme
+ *
+ * Returns the scheme or -1 in case of error
+ */
+int
+xmlBufGetAllocationScheme(xmlBufPtr buf) {
+ if (buf == NULL) {
+#ifdef DEBUG_BUFFER
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlBufGetAllocationScheme: buf == NULL\n");
+#endif
+ return(-1);
+ }
+ return(buf->alloc);
+}
+
+/**
+ * xmlBufSetAllocationScheme:
+ * @buf: the buffer to tune
+ * @scheme: allocation scheme to use
+ *
+ * Sets the allocation scheme for this buffer
+ *
+ * returns 0 in case of success and -1 in case of failure
+ */
+int
+xmlBufSetAllocationScheme(xmlBufPtr buf,
+ xmlBufferAllocationScheme scheme) {
+ if ((buf == NULL) || (buf->error != 0)) {
+#ifdef DEBUG_BUFFER
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlBufSetAllocationScheme: buf == NULL or in error\n");
+#endif
+ return(-1);
+ }
+ if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
+ (buf->alloc == XML_BUFFER_ALLOC_IO))
+ return(-1);
+ if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
+ (scheme == XML_BUFFER_ALLOC_EXACT) ||
+ (scheme == XML_BUFFER_ALLOC_HYBRID) ||
+ (scheme == XML_BUFFER_ALLOC_IMMUTABLE) ||
+ (scheme == XML_BUFFER_ALLOC_BOUNDED)) {
+ buf->alloc = scheme;
+ if (buf->buffer)
+ buf->buffer->alloc = scheme;
+ return(0);
+ }
+ /*
+ * Switching a buffer ALLOC_IO has the side effect of initializing
+ * the contentIO field with the current content
+ */
+ if (scheme == XML_BUFFER_ALLOC_IO) {
+ buf->alloc = XML_BUFFER_ALLOC_IO;
+ buf->contentIO = buf->content;
+ }
+ return(-1);
+}
+
+/**
+ * xmlBufFree:
+ * @buf: the buffer to free
+ *
+ * Frees an XML buffer. It frees both the content and the structure which
+ * encapsulate it.
+ */
+void
+xmlBufFree(xmlBufPtr buf) {
+ if (buf == NULL) {
+#ifdef DEBUG_BUFFER
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlBufFree: buf == NULL\n");
+#endif
+ return;
+ }
+
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
+ (buf->contentIO != NULL)) {
+ xmlFree(buf->contentIO);
+ } else if ((buf->content != NULL) &&
+ (buf->alloc != XML_BUFFER_ALLOC_IMMUTABLE)) {
+ xmlFree(buf->content);
+ }
+ xmlFree(buf);
+}
+
+/**
+ * xmlBufEmpty:
+ * @buf: the buffer
+ *
+ * empty a buffer.
+ */
+void
+xmlBufEmpty(xmlBufPtr buf) {
+ if ((buf == NULL) || (buf->error != 0)) return;
+ if (buf->content == NULL) return;
+ CHECK_COMPAT(buf)
+ buf->use = 0;
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) {
+ buf->content = BAD_CAST "";
+ } else if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
+ (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+
+ buf->size += start_buf;
+ buf->content = buf->contentIO;
+ buf->content[0] = 0;
+ } else {
+ buf->content[0] = 0;
+ }
+ UPDATE_COMPAT(buf)
+}
+
+/**
+ * xmlBufShrink:
+ * @buf: the buffer to dump
+ * @len: the number of xmlChar to remove
+ *
+ * Remove the beginning of an XML buffer.
+ * NOTE that this routine behaviour differs from xmlBufferShrink()
+ * as it will return 0 on error instead of -1 due to size_t being
+ * used as the return type.
+ *
+ * Returns the number of byte removed or 0 in case of failure
+ */
+size_t
+xmlBufShrink(xmlBufPtr buf, size_t len) {
+ if ((buf == NULL) || (buf->error != 0)) return(0);
+ CHECK_COMPAT(buf)
+ if (len == 0) return(0);
+ if (len > buf->use) return(0);
+
+ buf->use -= len;
+ if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
+ ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL))) {
+ /*
+ * we just move the content pointer, but also make sure
+ * the perceived buffer size has shrinked accordingly
+ */
+ buf->content += len;
+ buf->size -= len;
+
+ /*
+ * sometimes though it maybe be better to really shrink
+ * on IO buffers
+ */
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+ if (start_buf >= buf->size) {
+ memmove(buf->contentIO, &buf->content[0], buf->use);
+ buf->content = buf->contentIO;
+ buf->content[buf->use] = 0;
+ buf->size += start_buf;
+ }
+ }
+ } else {
+ memmove(buf->content, &buf->content[len], buf->use);
+ buf->content[buf->use] = 0;
+ }
+ UPDATE_COMPAT(buf)
+ return(len);
+}
+
+/**
+ * xmlBufGrowInternal:
+ * @buf: the buffer
+ * @len: the minimum free size to allocate
+ *
+ * Grow the available space of an XML buffer, @len is the target value
+ * Error checking should be done on buf->error since using the return
+ * value doesn't work that well
+ *
+ * Returns 0 in case of error or the length made available otherwise
+ */
+static size_t
+xmlBufGrowInternal(xmlBufPtr buf, size_t len) {
+ size_t size;
+ xmlChar *newbuf;
+
+ if ((buf == NULL) || (buf->error != 0)) return(0);
+ CHECK_COMPAT(buf)
+
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
+ if (buf->use + len < buf->size)
+ return(buf->size - buf->use);
+
+ /*
+ * Windows has a BIG problem on realloc timing, so we try to double
+ * the buffer size (if that's enough) (bug 146697)
+ * Apparently BSD too, and it's probably best for linux too
+ * On an embedded system this may be something to change
+ */
+#if 1
+ if (buf->size > (size_t) len)
+ size = buf->size * 2;
+ else
+ size = buf->use + len + 100;
+#else
+ size = buf->use + len + 100;
+#endif
+
+ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
+ /*
+ * Used to provide parsing limits
+ */
+ if ((buf->use + len >= XML_MAX_TEXT_LENGTH) ||
+ (buf->size >= XML_MAX_TEXT_LENGTH)) {
+ xmlBufMemoryError(buf, "buffer error: text too long\n");
+ return(0);
+ }
+ if (size >= XML_MAX_TEXT_LENGTH)
+ size = XML_MAX_TEXT_LENGTH;
+ }
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+
+ newbuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + size);
+ if (newbuf == NULL) {
+ xmlBufMemoryError(buf, "growing buffer");
+ return(0);
+ }
+ buf->contentIO = newbuf;
+ buf->content = newbuf + start_buf;
+ } else {
+ newbuf = (xmlChar *) xmlRealloc(buf->content, size);
+ if (newbuf == NULL) {
+ xmlBufMemoryError(buf, "growing buffer");
+ return(0);
+ }
+ buf->content = newbuf;
+ }
+ buf->size = size;
+ UPDATE_COMPAT(buf)
+ return(buf->size - buf->use);
+}
+
+/**
+ * xmlBufGrow:
+ * @buf: the buffer
+ * @len: the minimum free size to allocate
+ *
+ * Grow the available space of an XML buffer, @len is the target value
+ * This is been kept compatible with xmlBufferGrow() as much as possible
+ *
+ * Returns -1 in case of error or the length made available otherwise
+ */
+int
+xmlBufGrow(xmlBufPtr buf, int len) {
+ size_t ret;
+
+ if ((buf == NULL) || (len < 0)) return(-1);
+ if (len == 0)
+ return(0);
+ ret = xmlBufGrowInternal(buf, len);
+ if (buf->error != 0)
+ return(-1);
+ return((int) ret);
+}
+
+/**
+ * xmlBufInflate:
+ * @buf: the buffer
+ * @len: the minimum extra free size to allocate
+ *
+ * Grow the available space of an XML buffer, adding at least @len bytes
+ *
+ * Returns 0 if successful or -1 in case of error
+ */
+int
+xmlBufInflate(xmlBufPtr buf, size_t len) {
+ if (buf == NULL) return(-1);
+ xmlBufGrowInternal(buf, len + buf->size);
+ if (buf->error)
+ return(-1);
+ return(0);
+}
+
+/**
+ * xmlBufDump:
+ * @file: the file output
+ * @buf: the buffer to dump
+ *
+ * Dumps an XML buffer to a FILE *.
+ * Returns the number of #xmlChar written
+ */
+size_t
+xmlBufDump(FILE *file, xmlBufPtr buf) {
+ size_t ret;
+
+ if ((buf == NULL) || (buf->error != 0)) {
+#ifdef DEBUG_BUFFER
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlBufDump: buf == NULL or in error\n");
+#endif
+ return(0);
+ }
+ if (buf->content == NULL) {
+#ifdef DEBUG_BUFFER
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlBufDump: buf->content == NULL\n");
+#endif
+ return(0);
+ }
+ CHECK_COMPAT(buf)
+ if (file == NULL)
+ file = stdout;
+ ret = fwrite(buf->content, sizeof(xmlChar), buf->use, file);
+ return(ret);
+}
+
+/**
+ * xmlBufContent:
+ * @buf: the buffer
+ *
+ * Function to extract the content of a buffer
+ *
+ * Returns the internal content
+ */
+
+xmlChar *
+xmlBufContent(const xmlBuf *buf)
+{
+ if ((!buf) || (buf->error))
+ return NULL;
+
+ return(buf->content);
+}
+
+/**
+ * xmlBufEnd:
+ * @buf: the buffer
+ *
+ * Function to extract the end of the content of a buffer
+ *
+ * Returns the end of the internal content or NULL in case of error
+ */
+
+xmlChar *
+xmlBufEnd(xmlBufPtr buf)
+{
+ if ((!buf) || (buf->error))
+ return NULL;
+ CHECK_COMPAT(buf)
+
+ return(&buf->content[buf->use]);
+}
+
+/**
+ * xmlBufAddLen:
+ * @buf: the buffer
+ * @len: the size which were added at the end
+ *
+ * Sometime data may be added at the end of the buffer without
+ * using the xmlBuf APIs that is used to expand the used space
+ * and set the zero terminating at the end of the buffer
+ *
+ * Returns -1 in case of error and 0 otherwise
+ */
+int
+xmlBufAddLen(xmlBufPtr buf, size_t len) {
+ if ((buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ if (len > (buf->size - buf->use))
+ return(-1);
+ buf->use += len;
+ UPDATE_COMPAT(buf)
+ if (buf->size > buf->use)
+ buf->content[buf->use] = 0;
+ else
+ return(-1);
+ return(0);
+}
+
+/**
+ * xmlBufErase:
+ * @buf: the buffer
+ * @len: the size to erase at the end
+ *
+ * Sometime data need to be erased at the end of the buffer
+ *
+ * Returns -1 in case of error and 0 otherwise
+ */
+int
+xmlBufErase(xmlBufPtr buf, size_t len) {
+ if ((buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ if (len > buf->use)
+ return(-1);
+ buf->use -= len;
+ buf->content[buf->use] = 0;
+ UPDATE_COMPAT(buf)
+ return(0);
+}
+
+/**
+ * xmlBufLength:
+ * @buf: the buffer
+ *
+ * Function to get the length of a buffer
+ *
+ * Returns the length of data in the internal content
+ */
+
+size_t
+xmlBufLength(const xmlBufPtr buf)
+{
+ if ((!buf) || (buf->error))
+ return 0;
+ CHECK_COMPAT(buf)
+
+ return(buf->use);
+}
+
+/**
+ * xmlBufUse:
+ * @buf: the buffer
+ *
+ * Function to get the length of a buffer
+ *
+ * Returns the length of data in the internal content
+ */
+
+size_t
+xmlBufUse(const xmlBufPtr buf)
+{
+ if ((!buf) || (buf->error))
+ return 0;
+ CHECK_COMPAT(buf)
+
+ return(buf->use);
+}
+
+/**
+ * xmlBufAvail:
+ * @buf: the buffer
+ *
+ * Function to find how much free space is allocated but not
+ * used in the buffer. It does not account for the terminating zero
+ * usually needed
+ *
+ * Returns the amount or 0 if none or an error occured
+ */
+
+size_t
+xmlBufAvail(const xmlBufPtr buf)
+{
+ if ((!buf) || (buf->error))
+ return 0;
+ CHECK_COMPAT(buf)
+
+ return(buf->size - buf->use);
+}
+
+/**
+ * xmlBufIsEmpty:
+ * @buf: the buffer
+ *
+ * Tell if a buffer is empty
+ *
+ * Returns 0 if no, 1 if yes and -1 in case of error
+ */
+int
+xmlBufIsEmpty(const xmlBufPtr buf)
+{
+ if ((!buf) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+
+ return(buf->use == 0);
+}
+
+/**
+ * xmlBufResize:
+ * @buf: the buffer to resize
+ * @size: the desired size
+ *
+ * Resize a buffer to accommodate minimum size of @size.
+ *
+ * Returns 0 in case of problems, 1 otherwise
+ */
+int
+xmlBufResize(xmlBufPtr buf, size_t size)
+{
+ unsigned int newSize;
+ xmlChar* rebuf = NULL;
+ size_t start_buf;
+
+ if ((buf == NULL) || (buf->error))
+ return(0);
+ CHECK_COMPAT(buf)
+
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
+ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
+ /*
+ * Used to provide parsing limits
+ */
+ if (size >= XML_MAX_TEXT_LENGTH) {
+ xmlBufMemoryError(buf, "buffer error: text too long\n");
+ return(0);
+ }
+ }
+
+ /* Don't resize if we don't have to */
+ if (size < buf->size)
+ return 1;
+
+ /* figure out new size */
+ switch (buf->alloc){
+ case XML_BUFFER_ALLOC_IO:
+ case XML_BUFFER_ALLOC_DOUBLEIT:
+ /*take care of empty case*/
+ newSize = (buf->size ? buf->size*2 : size + 10);
+ while (size > newSize) {
+ if (newSize > UINT_MAX / 2) {
+ xmlBufMemoryError(buf, "growing buffer");
+ return 0;
+ }
+ newSize *= 2;
+ }
+ break;
+ case XML_BUFFER_ALLOC_EXACT:
+ newSize = size+10;
+ break;
+ case XML_BUFFER_ALLOC_HYBRID:
+ if (buf->use < BASE_BUFFER_SIZE)
+ newSize = size;
+ else {
+ newSize = buf->size * 2;
+ while (size > newSize) {
+ if (newSize > UINT_MAX / 2) {
+ xmlBufMemoryError(buf, "growing buffer");
+ return 0;
+ }
+ newSize *= 2;
+ }
+ }
+ break;
+
+ default:
+ newSize = size+10;
+ break;
+ }
+
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ start_buf = buf->content - buf->contentIO;
+
+ if (start_buf > newSize) {
+ /* move data back to start */
+ memmove(buf->contentIO, buf->content, buf->use);
+ buf->content = buf->contentIO;
+ buf->content[buf->use] = 0;
+ buf->size += start_buf;
+ } else {
+ rebuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + newSize);
+ if (rebuf == NULL) {
+ xmlBufMemoryError(buf, "growing buffer");
+ return 0;
+ }
+ buf->contentIO = rebuf;
+ buf->content = rebuf + start_buf;
+ }
+ } else {
+ if (buf->content == NULL) {
+ rebuf = (xmlChar *) xmlMallocAtomic(newSize);
+ } else if (buf->size - buf->use < 100) {
+ rebuf = (xmlChar *) xmlRealloc(buf->content, newSize);
+ } else {
+ /*
+ * if we are reallocating a buffer far from being full, it's
+ * better to make a new allocation and copy only the used range
+ * and free the old one.
+ */
+ rebuf = (xmlChar *) xmlMallocAtomic(newSize);
+ if (rebuf != NULL) {
+ memcpy(rebuf, buf->content, buf->use);
+ xmlFree(buf->content);
+ rebuf[buf->use] = 0;
+ }
+ }
+ if (rebuf == NULL) {
+ xmlBufMemoryError(buf, "growing buffer");
+ return 0;
+ }
+ buf->content = rebuf;
+ }
+ buf->size = newSize;
+ UPDATE_COMPAT(buf)
+
+ return 1;
+}
+
+/**
+ * xmlBufAdd:
+ * @buf: the buffer to dump
+ * @str: the #xmlChar string
+ * @len: the number of #xmlChar to add
+ *
+ * Add a string range to an XML buffer. if len == -1, the length of
+ * str is recomputed.
+ *
+ * Returns 0 successful, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+int
+xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len) {
+ unsigned int needSize;
+
+ if ((str == NULL) || (buf == NULL) || (buf->error))
+ return -1;
+ CHECK_COMPAT(buf)
+
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
+ if (len < -1) {
+#ifdef DEBUG_BUFFER
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlBufAdd: len < 0\n");
+#endif
+ return -1;
+ }
+ if (len == 0) return 0;
+
+ if (len < 0)
+ len = xmlStrlen(str);
+
+ if (len < 0) return -1;
+ if (len == 0) return 0;
+
+ needSize = buf->use + len + 2;
+ if (needSize > buf->size){
+ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
+ /*
+ * Used to provide parsing limits
+ */
+ if (needSize >= XML_MAX_TEXT_LENGTH) {
+ xmlBufMemoryError(buf, "buffer error: text too long\n");
+ return(-1);
+ }
+ }
+ if (!xmlBufResize(buf, needSize)){
+ xmlBufMemoryError(buf, "growing buffer");
+ return XML_ERR_NO_MEMORY;
+ }
+ }
+
+ memmove(&buf->content[buf->use], str, len*sizeof(xmlChar));
+ buf->use += len;
+ buf->content[buf->use] = 0;
+ UPDATE_COMPAT(buf)
+ return 0;
+}
+
+/**
+ * xmlBufAddHead:
+ * @buf: the buffer
+ * @str: the #xmlChar string
+ * @len: the number of #xmlChar to add
+ *
+ * Add a string range to the beginning of an XML buffer.
+ * if len == -1, the length of @str is recomputed.
+ *
+ * Returns 0 successful, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+int
+xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len) {
+ unsigned int needSize;
+
+ if ((buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
+ if (str == NULL) {
+#ifdef DEBUG_BUFFER
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlBufAddHead: str == NULL\n");
+#endif
+ return -1;
+ }
+ if (len < -1) {
+#ifdef DEBUG_BUFFER
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlBufAddHead: len < 0\n");
+#endif
+ return -1;
+ }
+ if (len == 0) return 0;
+
+ if (len < 0)
+ len = xmlStrlen(str);
+
+ if (len <= 0) return -1;
+
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+
+ if (start_buf > (unsigned int) len) {
+ /*
+ * We can add it in the space previously shrinked
+ */
+ buf->content -= len;
+ memmove(&buf->content[0], str, len);
+ buf->use += len;
+ buf->size += len;
+ UPDATE_COMPAT(buf)
+ return(0);
+ }
+ }
+ needSize = buf->use + len + 2;
+ if (needSize > buf->size){
+ if (buf->alloc == XML_BUFFER_ALLOC_BOUNDED) {
+ /*
+ * Used to provide parsing limits
+ */
+ if (needSize >= XML_MAX_TEXT_LENGTH) {
+ xmlBufMemoryError(buf, "buffer error: text too long\n");
+ return(-1);
+ }
+ }
+ if (!xmlBufResize(buf, needSize)){
+ xmlBufMemoryError(buf, "growing buffer");
+ return XML_ERR_NO_MEMORY;
+ }
+ }
+
+ memmove(&buf->content[len], &buf->content[0], buf->use);
+ memmove(&buf->content[0], str, len);
+ buf->use += len;
+ buf->content[buf->use] = 0;
+ UPDATE_COMPAT(buf)
+ return 0;
+}
+
+/**
+ * xmlBufCat:
+ * @buf: the buffer to add to
+ * @str: the #xmlChar string
+ *
+ * Append a zero terminated string to an XML buffer.
+ *
+ * Returns 0 successful, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+int
+xmlBufCat(xmlBufPtr buf, const xmlChar *str) {
+ if ((buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
+ if (str == NULL) return -1;
+ return xmlBufAdd(buf, str, -1);
+}
+
+/**
+ * xmlBufCCat:
+ * @buf: the buffer to dump
+ * @str: the C char string
+ *
+ * Append a zero terminated C string to an XML buffer.
+ *
+ * Returns 0 successful, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+int
+xmlBufCCat(xmlBufPtr buf, const char *str) {
+ const char *cur;
+
+ if ((buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return -1;
+ if (str == NULL) {
+#ifdef DEBUG_BUFFER
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlBufCCat: str == NULL\n");
+#endif
+ return -1;
+ }
+ for (cur = str;*cur != 0;cur++) {
+ if (buf->use + 10 >= buf->size) {
+ if (!xmlBufResize(buf, buf->use+10)){
+ xmlBufMemoryError(buf, "growing buffer");
+ return XML_ERR_NO_MEMORY;
+ }
+ }
+ buf->content[buf->use++] = *cur;
+ }
+ buf->content[buf->use] = 0;
+ UPDATE_COMPAT(buf)
+ return 0;
+}
+
+/**
+ * xmlBufWriteCHAR:
+ * @buf: the XML buffer
+ * @string: the string to add
+ *
+ * routine which manages and grows an output buffer. This one adds
+ * xmlChars at the end of the buffer.
+ *
+ * Returns 0 if successful, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+int
+xmlBufWriteCHAR(xmlBufPtr buf, const xmlChar *string) {
+ if ((buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
+ return(-1);
+ return(xmlBufCat(buf, string));
+}
+
+/**
+ * xmlBufWriteChar:
+ * @buf: the XML buffer output
+ * @string: the string to add
+ *
+ * routine which manage and grows an output buffer. This one add
+ * C chars at the end of the array.
+ *
+ * Returns 0 if successful, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+int
+xmlBufWriteChar(xmlBufPtr buf, const char *string) {
+ if ((buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
+ return(-1);
+ return(xmlBufCCat(buf, string));
+}
+
+
+/**
+ * xmlBufWriteQuotedString:
+ * @buf: the XML buffer output
+ * @string: the string to add
+ *
+ * routine which manage and grows an output buffer. This one writes
+ * a quoted or double quoted #xmlChar string, checking first if it holds
+ * quote or double-quotes internally
+ *
+ * Returns 0 if successful, a positive error code number otherwise
+ * and -1 in case of internal or API error.
+ */
+int
+xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string) {
+ const xmlChar *cur, *base;
+ if ((buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
+ return(-1);
+ if (xmlStrchr(string, '\"')) {
+ if (xmlStrchr(string, '\'')) {
+#ifdef DEBUG_BUFFER
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlBufWriteQuotedString: string contains quote and double-quotes !\n");
+#endif
+ xmlBufCCat(buf, "\"");
+ base = cur = string;
+ while(*cur != 0){
+ if(*cur == '"'){
+ if (base != cur)
+ xmlBufAdd(buf, base, cur - base);
+ xmlBufAdd(buf, BAD_CAST "&quot;", 6);
+ cur++;
+ base = cur;
+ }
+ else {
+ cur++;
+ }
+ }
+ if (base != cur)
+ xmlBufAdd(buf, base, cur - base);
+ xmlBufCCat(buf, "\"");
+ }
+ else{
+ xmlBufCCat(buf, "\'");
+ xmlBufCat(buf, string);
+ xmlBufCCat(buf, "\'");
+ }
+ } else {
+ xmlBufCCat(buf, "\"");
+ xmlBufCat(buf, string);
+ xmlBufCCat(buf, "\"");
+ }
+ return(0);
+}
+
+/**
+ * xmlBufFromBuffer:
+ * @buffer: incoming old buffer to convert to a new one
+ *
+ * Helper routine to switch from the old buffer structures in use
+ * in various APIs. It creates a wrapper xmlBufPtr which will be
+ * used for internal processing until the xmlBufBackToBuffer() is
+ * issued.
+ *
+ * Returns a new xmlBufPtr unless the call failed and NULL is returned
+ */
+xmlBufPtr
+xmlBufFromBuffer(xmlBufferPtr buffer) {
+ xmlBufPtr ret;
+
+ if (buffer == NULL)
+ return(NULL);
+
+ ret = (xmlBufPtr) xmlMalloc(sizeof(xmlBuf));
+ if (ret == NULL) {
+ xmlBufMemoryError(NULL, "creating buffer");
+ return(NULL);
+ }
+ ret->use = buffer->use;
+ ret->size = buffer->size;
+ ret->compat_use = buffer->use;
+ ret->compat_size = buffer->size;
+ ret->error = 0;
+ ret->buffer = buffer;
+ ret->alloc = buffer->alloc;
+ ret->content = buffer->content;
+ ret->contentIO = buffer->contentIO;
+
+ return(ret);
+}
+
+/**
+ * xmlBufBackToBuffer:
+ * @buf: new buffer wrapping the old one
+ *
+ * Function to be called once internal processing had been done to
+ * update back the buffer provided by the user. This can lead to
+ * a failure in case the size accumulated in the xmlBuf is larger
+ * than what an xmlBuffer can support on 64 bits (INT_MAX)
+ * The xmlBufPtr @buf wrapper is deallocated by this call in any case.
+ *
+ * Returns the old xmlBufferPtr unless the call failed and NULL is returned
+ */
+xmlBufferPtr
+xmlBufBackToBuffer(xmlBufPtr buf) {
+ xmlBufferPtr ret;
+
+ if ((buf == NULL) || (buf->error))
+ return(NULL);
+ CHECK_COMPAT(buf)
+ if (buf->buffer == NULL) {
+ xmlBufFree(buf);
+ return(NULL);
+ }
+
+ ret = buf->buffer;
+ /*
+ * What to do in case of error in the buffer ???
+ */
+ if (buf->use > INT_MAX) {
+ /*
+ * Worse case, we really allocated and used more than the
+ * maximum allowed memory for an xmlBuffer on this architecture.
+ * Keep the buffer but provide a truncated size value.
+ */
+ xmlBufOverflowError(buf, "Used size too big for xmlBuffer");
+ ret->use = INT_MAX;
+ ret->size = INT_MAX;
+ } else if (buf->size > INT_MAX) {
+ /*
+ * milder case, we allocated more than the maximum allowed memory
+ * for an xmlBuffer on this architecture, but used less than the
+ * limit.
+ * Keep the buffer but provide a truncated size value.
+ */
+ xmlBufOverflowError(buf, "Allocated size too big for xmlBuffer");
+ ret->size = INT_MAX;
+ }
+ ret->use = (int) buf->use;
+ ret->size = (int) buf->size;
+ ret->alloc = buf->alloc;
+ ret->content = buf->content;
+ ret->contentIO = buf->contentIO;
+ xmlFree(buf);
+ return(ret);
+}
+
+/**
+ * xmlBufMergeBuffer:
+ * @buf: an xmlBufPtr
+ * @buffer: the buffer to consume into @buf
+ *
+ * The content of @buffer is appended to @buf and @buffer is freed
+ *
+ * Returns -1 in case of error, 0 otherwise, in any case @buffer is freed
+ */
+int
+xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer) {
+ int ret = 0;
+
+ if ((buf == NULL) || (buf->error)) {
+ xmlBufferFree(buffer);
+ return(-1);
+ }
+ CHECK_COMPAT(buf)
+ if ((buffer != NULL) && (buffer->content != NULL) &&
+ (buffer->use > 0)) {
+ ret = xmlBufAdd(buf, buffer->content, buffer->use);
+ }
+ xmlBufferFree(buffer);
+ return(ret);
+}
+
+/**
+ * xmlBufResetInput:
+ * @buf: an xmlBufPtr
+ * @input: an xmlParserInputPtr
+ *
+ * Update the input to use the current set of pointers from the buffer.
+ *
+ * Returns -1 in case of error, 0 otherwise
+ */
+int
+xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input) {
+ if ((input == NULL) || (buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ input->base = input->cur = buf->content;
+ input->end = &buf->content[buf->use];
+ return(0);
+}
+
+/**
+ * xmlBufGetInputBase:
+ * @buf: an xmlBufPtr
+ * @input: an xmlParserInputPtr
+ *
+ * Get the base of the @input relative to the beginning of the buffer
+ *
+ * Returns the size_t corresponding to the displacement
+ */
+size_t
+xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input) {
+ size_t base;
+
+ if ((input == NULL) || (buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ base = input->base - buf->content;
+ /*
+ * We could do some pointer arythmetic checks but that's probably
+ * sufficient.
+ */
+ if (base > buf->size) {
+ xmlBufOverflowError(buf, "Input reference outside of the buffer");
+ base = 0;
+ }
+ return(base);
+}
+
+/**
+ * xmlBufSetInputBaseCur:
+ * @buf: an xmlBufPtr
+ * @input: an xmlParserInputPtr
+ * @base: the base value relative to the beginning of the buffer
+ * @cur: the cur value relative to the beginning of the buffer
+ *
+ * Update the input to use the base and cur relative to the buffer
+ * after a possible reallocation of its content
+ *
+ * Returns -1 in case of error, 0 otherwise
+ */
+int
+xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
+ size_t base, size_t cur) {
+ if ((input == NULL) || (buf == NULL) || (buf->error))
+ return(-1);
+ CHECK_COMPAT(buf)
+ input->base = &buf->content[base];
+ input->cur = input->base + cur;
+ input->end = &buf->content[buf->use];
+ return(0);
+}
+
+#define bottom_buf
+#include "elfgcchack.h"
diff --git a/gnulib-local/lib/libxml/buf.h b/gnulib-local/lib/libxml/buf.h
new file mode 100644
index 0000000..ebdc978
--- /dev/null
+++ b/gnulib-local/lib/libxml/buf.h
@@ -0,0 +1,72 @@
+/*
+ * Summary: Internal Interfaces for memory buffers in libxml2
+ * Description: this module describes most of the new xmlBuf buffer
+ * entry points, those are private routines, with a
+ * few exceptions exported in tree.h. This was added
+ * in 2.9.0.
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_BUF_H__
+#define __XML_BUF_H__
+
+#include <libxml/tree.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+xmlBufPtr xmlBufCreate(void);
+xmlBufPtr xmlBufCreateSize(size_t size);
+xmlBufPtr xmlBufCreateStatic(void *mem, size_t size);
+
+int xmlBufSetAllocationScheme(xmlBufPtr buf,
+ xmlBufferAllocationScheme scheme);
+int xmlBufGetAllocationScheme(xmlBufPtr buf);
+
+void xmlBufFree(xmlBufPtr buf);
+void xmlBufEmpty(xmlBufPtr buf);
+
+/* size_t xmlBufShrink(xmlBufPtr buf, size_t len); */
+int xmlBufGrow(xmlBufPtr buf, int len);
+int xmlBufInflate(xmlBufPtr buf, size_t len);
+int xmlBufResize(xmlBufPtr buf, size_t len);
+
+int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len);
+int xmlBufAddHead(xmlBufPtr buf, const xmlChar *str, int len);
+int xmlBufCat(xmlBufPtr buf, const xmlChar *str);
+int xmlBufCCat(xmlBufPtr buf, const char *str);
+int xmlBufWriteCHAR(xmlBufPtr buf, const xmlChar *string);
+int xmlBufWriteChar(xmlBufPtr buf, const char *string);
+int xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string);
+
+size_t xmlBufAvail(const xmlBufPtr buf);
+size_t xmlBufLength(const xmlBufPtr buf);
+/* size_t xmlBufUse(const xmlBufPtr buf); */
+int xmlBufIsEmpty(const xmlBufPtr buf);
+int xmlBufAddLen(xmlBufPtr buf, size_t len);
+int xmlBufErase(xmlBufPtr buf, size_t len);
+
+/* const xmlChar * xmlBufContent(const xmlBuf *buf); */
+/* const xmlChar * xmlBufEnd(xmlBufPtr buf); */
+
+xmlChar * xmlBufDetach(xmlBufPtr buf);
+
+size_t xmlBufDump(FILE *file, xmlBufPtr buf);
+
+xmlBufPtr xmlBufFromBuffer(xmlBufferPtr buffer);
+xmlBufferPtr xmlBufBackToBuffer(xmlBufPtr buf);
+int xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer);
+
+int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input);
+size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input);
+int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input,
+ size_t base, size_t cur);
+#ifdef __cplusplus
+}
+#endif
+#endif /* __XML_BUF_H__ */
+
diff --git a/gnulib-local/lib/libxml/c14n.c b/gnulib-local/lib/libxml/c14n.c
index bb7c9ba..ca77f92 100644
--- a/gnulib-local/lib/libxml/c14n.c
+++ b/gnulib-local/lib/libxml/c14n.c
@@ -1,12 +1,12 @@
/*
- * "Canonical XML" implementation
+ * "Canonical XML" implementation
* http://www.w3.org/TR/xml-c14n
- *
+ *
* "Exclusive XML Canonicalization" implementation
* http://www.w3.org/TR/xml-exc-c14n
*
* See Copyright for the status of this software.
- *
+ *
* Author: Aleksey Sanin <aleksey@aleksey.com>
*/
#define IN_LIBXML
@@ -27,6 +27,8 @@
#include <libxml/xpathInternals.h>
#include <libxml/c14n.h>
+#include "buf.h"
+
/************************************************************************
* *
* Some declaration better left private ATM *
@@ -44,7 +46,7 @@ typedef struct _xmlC14NVisibleNsStack {
int nsPrevStart; /* the begginning of the stack for previous visible node */
int nsPrevEnd; /* the end of the stack for previous visible node */
int nsMax; /* size of the array as allocated */
- xmlNsPtr *nsTab; /* array of ns in no particular order */
+ xmlNsPtr *nsTab; /* array of ns in no particular order */
xmlNodePtr *nodeTab; /* array of nodes in no particular order */
} xmlC14NVisibleNsStack, *xmlC14NVisibleNsStackPtr;
@@ -52,7 +54,7 @@ typedef struct _xmlC14NCtx {
/* input parameters */
xmlDocPtr doc;
xmlC14NIsVisibleCallback is_visible_callback;
- void* user_data;
+ void* user_data;
int with_comments;
xmlOutputBufferPtr buf;
@@ -61,8 +63,10 @@ typedef struct _xmlC14NCtx {
int parent_is_doc;
xmlC14NVisibleNsStackPtr ns_rendered;
+ /* C14N mode */
+ xmlC14NMode mode;
+
/* exclusive canonicalization */
- int exclusive;
xmlChar **inclusive_ns_prefixes;
/* error number */
@@ -71,17 +75,17 @@ typedef struct _xmlC14NCtx {
static xmlC14NVisibleNsStackPtr xmlC14NVisibleNsStackCreate (void);
static void xmlC14NVisibleNsStackDestroy (xmlC14NVisibleNsStackPtr cur);
-static void xmlC14NVisibleNsStackAdd (xmlC14NVisibleNsStackPtr cur,
+static void xmlC14NVisibleNsStackAdd (xmlC14NVisibleNsStackPtr cur,
xmlNsPtr ns,
xmlNodePtr node);
-static void xmlC14NVisibleNsStackSave (xmlC14NVisibleNsStackPtr cur,
+static void xmlC14NVisibleNsStackSave (xmlC14NVisibleNsStackPtr cur,
xmlC14NVisibleNsStackPtr state);
-static void xmlC14NVisibleNsStackRestore (xmlC14NVisibleNsStackPtr cur,
+static void xmlC14NVisibleNsStackRestore (xmlC14NVisibleNsStackPtr cur,
xmlC14NVisibleNsStackPtr state);
-static void xmlC14NVisibleNsStackShift (xmlC14NVisibleNsStackPtr cur);
-static int xmlC14NVisibleNsStackFind (xmlC14NVisibleNsStackPtr cur,
+static void xmlC14NVisibleNsStackShift (xmlC14NVisibleNsStackPtr cur);
+static int xmlC14NVisibleNsStackFind (xmlC14NVisibleNsStackPtr cur,
xmlNsPtr ns);
-static int xmlExcC14NVisibleNsStackFind (xmlC14NVisibleNsStackPtr cur,
+static int xmlExcC14NVisibleNsStackFind (xmlC14NVisibleNsStackPtr cur,
xmlNsPtr ns,
xmlC14NCtxPtr ctx);
@@ -103,23 +107,26 @@ typedef enum {
static xmlChar *xmlC11NNormalizeString(const xmlChar * input,
xmlC14NNormalizationMode mode);
-#define xmlC11NNormalizeAttr( a ) \
+#define xmlC11NNormalizeAttr( a ) \
xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_ATTR)
-#define xmlC11NNormalizeComment( a ) \
+#define xmlC11NNormalizeComment( a ) \
xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_COMMENT)
-#define xmlC11NNormalizePI( a ) \
+#define xmlC11NNormalizePI( a ) \
xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_PI)
-#define xmlC11NNormalizeText( a ) \
+#define xmlC11NNormalizeText( a ) \
xmlC11NNormalizeString((a), XMLC14N_NORMALIZE_TEXT)
-#define xmlC14NIsVisible( ctx, node, parent ) \
+#define xmlC14NIsVisible( ctx, node, parent ) \
(((ctx)->is_visible_callback != NULL) ? \
(ctx)->is_visible_callback((ctx)->user_data, \
(xmlNodePtr)(node), (xmlNodePtr)(parent)) : 1)
+#define xmlC14NIsExclusive( ctx ) \
+ ( (ctx)->mode == XML_C14N_EXCLUSIVE_1_0 )
+
/************************************************************************
* *
- * Some factorized error routines *
+ * Some factorized error routines *
* *
************************************************************************/
@@ -234,7 +241,7 @@ xmlC14NErr(xmlC14NCtxPtr ctxt, xmlNodePtr node, int error,
__xmlRaiseError(NULL, NULL, NULL,
ctxt, node, XML_FROM_C14N, error,
XML_ERR_ERROR, NULL, 0,
- NULL, NULL, NULL, 0, 0, msg);
+ NULL, NULL, NULL, 0, 0, "%s", msg);
}
/************************************************************************
@@ -244,25 +251,25 @@ xmlC14NErr(xmlC14NCtxPtr ctxt, xmlNodePtr node, int error,
************************************************************************/
#define XML_NAMESPACES_DEFAULT 16
-static int
+static int
xmlC14NIsNodeInNodeset(xmlNodeSetPtr nodes, xmlNodePtr node, xmlNodePtr parent) {
if((nodes != NULL) && (node != NULL)) {
if(node->type != XML_NAMESPACE_DECL) {
return(xmlXPathNodeSetContains(nodes, node));
} else {
xmlNs ns;
-
- memcpy(&ns, node, sizeof(ns));
-
+
+ memcpy(&ns, node, sizeof(ns));
+
/* this is a libxml hack! check xpath.c for details */
if((parent != NULL) && (parent->type == XML_ATTRIBUTE_NODE)) {
ns.next = (xmlNsPtr)parent->parent;
} else {
- ns.next = (xmlNsPtr)parent;
+ ns.next = (xmlNsPtr)parent;
}
- /*
- * If the input is an XPath node-set, then the node-set must explicitly
+ /*
+ * If the input is an XPath node-set, then the node-set must explicitly
* contain every node to be rendered to the canonical form.
*/
return(xmlXPathNodeSetContains(nodes, (xmlNodePtr)&ns));
@@ -300,12 +307,12 @@ xmlC14NVisibleNsStackDestroy(xmlC14NVisibleNsStackPtr cur) {
}
memset(cur, 0, sizeof(xmlC14NVisibleNsStack));
xmlFree(cur);
-
+
}
-static void
+static void
xmlC14NVisibleNsStackAdd(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlNodePtr node) {
- if((cur == NULL) ||
+ if((cur == NULL) ||
((cur->nsTab == NULL) && (cur->nodeTab != NULL)) ||
((cur->nsTab != NULL) && (cur->nodeTab == NULL))) {
xmlC14NErrParam("adding namespace to stack");
@@ -323,9 +330,9 @@ xmlC14NVisibleNsStackAdd(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlNodePtr n
memset(cur->nodeTab, 0 , XML_NAMESPACES_DEFAULT * sizeof(xmlNodePtr));
cur->nsMax = XML_NAMESPACES_DEFAULT;
} else if(cur->nsMax == cur->nsCurEnd) {
- void *tmp;
+ void *tmp;
int tmpSize;
-
+
tmpSize = 2 * cur->nsMax;
tmp = xmlRealloc(cur->nsTab, tmpSize * sizeof(xmlNsPtr));
if (tmp == NULL) {
@@ -355,7 +362,7 @@ xmlC14NVisibleNsStackSave(xmlC14NVisibleNsStackPtr cur, xmlC14NVisibleNsStackPtr
xmlC14NErrParam("saving namespaces stack");
return;
}
-
+
state->nsCurEnd = cur->nsCurEnd;
state->nsPrevStart = cur->nsPrevStart;
state->nsPrevEnd = cur->nsPrevEnd;
@@ -372,7 +379,7 @@ xmlC14NVisibleNsStackRestore(xmlC14NVisibleNsStackPtr cur, xmlC14NVisibleNsStack
cur->nsPrevEnd = state->nsPrevEnd;
}
-static void
+static void
xmlC14NVisibleNsStackShift(xmlC14NVisibleNsStackPtr cur) {
if(cur == NULL) {
xmlC14NErrParam("shifting namespaces stack");
@@ -395,7 +402,7 @@ xmlC14NStrEqual(const xmlChar *str1, const xmlChar *str2) {
/**
* xmlC14NVisibleNsStackFind:
- * @ctx: the C14N context
+ * @ctx: the C14N context
* @ns: the namespace to check
*
* Checks whether the given namespace was already rendered or not
@@ -409,14 +416,14 @@ xmlC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns)
const xmlChar *prefix;
const xmlChar *href;
int has_empty_ns;
-
+
if(cur == NULL) {
xmlC14NErrParam("searching namespaces stack (c14n)");
return (0);
}
/*
- * if the default namespace xmlns="" is not defined yet then
+ * if the default namespace xmlns="" is not defined yet then
* we do not want to print it out
*/
prefix = ((ns == NULL) || (ns->prefix == NULL)) ? BAD_CAST "" : ns->prefix;
@@ -427,7 +434,7 @@ xmlC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns)
int start = (has_empty_ns) ? 0 : cur->nsPrevStart;
for (i = cur->nsCurEnd - 1; i >= start; --i) {
xmlNsPtr ns1 = cur->nsTab[i];
-
+
if(xmlC14NStrEqual(prefix, (ns1 != NULL) ? ns1->prefix : NULL)) {
return(xmlC14NStrEqual(href, (ns1 != NULL) ? ns1->href : NULL));
}
@@ -436,20 +443,20 @@ xmlC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns)
return(has_empty_ns);
}
-static int
+static int
xmlExcC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlC14NCtxPtr ctx) {
int i;
const xmlChar *prefix;
const xmlChar *href;
int has_empty_ns;
-
+
if(cur == NULL) {
xmlC14NErrParam("searching namespaces stack (exc c14n)");
return (0);
}
/*
- * if the default namespace xmlns="" is not defined yet then
+ * if the default namespace xmlns="" is not defined yet then
* we do not want to print it out
*/
prefix = ((ns == NULL) || (ns->prefix == NULL)) ? BAD_CAST "" : ns->prefix;
@@ -460,10 +467,10 @@ xmlExcC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlC14NC
int start = 0;
for (i = cur->nsCurEnd - 1; i >= start; --i) {
xmlNsPtr ns1 = cur->nsTab[i];
-
+
if(xmlC14NStrEqual(prefix, (ns1 != NULL) ? ns1->prefix : NULL)) {
if(xmlC14NStrEqual(href, (ns1 != NULL) ? ns1->href : NULL)) {
- return(xmlC14NIsVisible(ctx, ns1, cur->nodeTab[i]));
+ return(xmlC14NIsVisible(ctx, ns1, cur->nodeTab[i]));
} else {
return(0);
}
@@ -478,8 +485,8 @@ xmlExcC14NVisibleNsStackFind(xmlC14NVisibleNsStackPtr cur, xmlNsPtr ns, xmlC14NC
/**
* xmlC14NIsXmlNs:
- * @ns: the namespace to check
- *
+ * @ns: the namespace to check
+ *
* Checks whether the given namespace is a default "xml:" namespace
* with href="http://www.w3.org/XML/1998/namespace"
*
@@ -492,16 +499,14 @@ xmlC14NIsXmlNs(xmlNsPtr ns)
{
return ((ns != NULL) &&
(xmlStrEqual(ns->prefix, BAD_CAST "xml")) &&
- (xmlStrEqual(ns->href,
- BAD_CAST
- "http://www.w3.org/XML/1998/namespace")));
+ (xmlStrEqual(ns->href, XML_XML_NAMESPACE)));
}
/**
* xmlC14NNsCompare:
* @ns1: the pointer to first namespace
- * @ns2: the pointer to second namespace
+ * @ns2: the pointer to second namespace
*
* Compares the namespaces by names (prefixes).
*
@@ -524,7 +529,7 @@ xmlC14NNsCompare(xmlNsPtr ns1, xmlNsPtr ns2)
/**
* xmlC14NPrintNamespaces:
* @ns: the pointer to namespace
- * @ctx: the C14N context
+ * @ctx: the C14N context
*
* Prints the given namespace to the output buffer from C14N context.
*
@@ -542,52 +547,53 @@ xmlC14NPrintNamespaces(const xmlNsPtr ns, xmlC14NCtxPtr ctx)
if (ns->prefix != NULL) {
xmlOutputBufferWriteString(ctx->buf, " xmlns:");
xmlOutputBufferWriteString(ctx->buf, (const char *) ns->prefix);
- xmlOutputBufferWriteString(ctx->buf, "=\"");
+ xmlOutputBufferWriteString(ctx->buf, "=");
} else {
- xmlOutputBufferWriteString(ctx->buf, " xmlns=\"");
+ xmlOutputBufferWriteString(ctx->buf, " xmlns=");
}
if(ns->href != NULL) {
- xmlOutputBufferWriteString(ctx->buf, (const char *) ns->href);
+ xmlBufWriteQuotedString(ctx->buf->buffer, ns->href);
+ } else {
+ xmlOutputBufferWriteString(ctx->buf, "\"\"");
}
- xmlOutputBufferWriteString(ctx->buf, "\"");
return (1);
}
/**
* xmlC14NProcessNamespacesAxis:
- * @ctx: the C14N context
+ * @ctx: the C14N context
* @node: the current node
*
* Prints out canonical namespace axis of the current node to the
- * buffer from C14N context as follows
+ * buffer from C14N context as follows
*
* Canonical XML v 1.0 (http://www.w3.org/TR/xml-c14n)
*
* Namespace Axis
- * Consider a list L containing only namespace nodes in the
- * axis and in the node-set in lexicographic order (ascending). To begin
- * processing L, if the first node is not the default namespace node (a node
- * with no namespace URI and no local name), then generate a space followed
+ * Consider a list L containing only namespace nodes in the
+ * axis and in the node-set in lexicographic order (ascending). To begin
+ * processing L, if the first node is not the default namespace node (a node
+ * with no namespace URI and no local name), then generate a space followed
* by xmlns="" if and only if the following conditions are met:
* - the element E that owns the axis is in the node-set
- * - The nearest ancestor element of E in the node-set has a default
- * namespace node in the node-set (default namespace nodes always
+ * - The nearest ancestor element of E in the node-set has a default
+ * namespace node in the node-set (default namespace nodes always
* have non-empty values in XPath)
- * The latter condition eliminates unnecessary occurrences of xmlns="" in
- * the canonical form since an element only receives an xmlns="" if its
- * default namespace is empty and if it has an immediate parent in the
- * canonical form that has a non-empty default namespace. To finish
- * processing L, simply process every namespace node in L, except omit
- * namespace node with local name xml, which defines the xml prefix,
+ * The latter condition eliminates unnecessary occurrences of xmlns="" in
+ * the canonical form since an element only receives an xmlns="" if its
+ * default namespace is empty and if it has an immediate parent in the
+ * canonical form that has a non-empty default namespace. To finish
+ * processing L, simply process every namespace node in L, except omit
+ * namespace node with local name xml, which defines the xml prefix,
* if its string value is http://www.w3.org/XML/1998/namespace.
*
* Exclusive XML Canonicalization v 1.0 (http://www.w3.org/TR/xml-exc-c14n)
- * Canonical XML applied to a document subset requires the search of the
- * ancestor nodes of each orphan element node for attributes in the xml
- * namespace, such as xml:lang and xml:space. These are copied into the
- * element node except if a declaration of the same attribute is already
- * in the attribute axis of the element (whether or not it is included in
- * the document subset). This search and copying are omitted from the
+ * Canonical XML applied to a document subset requires the search of the
+ * ancestor nodes of each orphan element node for attributes in the xml
+ * namespace, such as xml:lang and xml:space. These are copied into the
+ * element node except if a declaration of the same attribute is already
+ * in the attribute axis of the element (whether or not it is included in
+ * the document subset). This search and copying are omitted from the
* Exclusive XML Canonicalization method.
*
* Returns 0 on success or -1 on fail.
@@ -600,7 +606,7 @@ xmlC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
xmlListPtr list;
int already_rendered;
int has_empty_ns = 0;
-
+
if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
xmlC14NErrParam("processing namespaces axis (c14n)");
return (-1);
@@ -619,29 +625,29 @@ xmlC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
for(n = cur; n != NULL; n = n->parent) {
for(ns = n->nsDef; ns != NULL; ns = ns->next) {
tmp = xmlSearchNs(cur->doc, cur, ns->prefix);
-
+
if((tmp == ns) && !xmlC14NIsXmlNs(ns) && xmlC14NIsVisible(ctx, ns, cur)) {
already_rendered = xmlC14NVisibleNsStackFind(ctx->ns_rendered, ns);
if(visible) {
- xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur);
+ xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur);
}
if(!already_rendered) {
- xmlListInsert(list, ns);
+ xmlListInsert(list, ns);
}
- if(xmlStrlen(ns->prefix) == 0) {
+ if(xmlStrlen(ns->prefix) == 0) {
has_empty_ns = 1;
}
}
}
}
-
+
/**
- * if the first node is not the default namespace node (a node with no
- * namespace URI and no local name), then generate a space followed by
+ * if the first node is not the default namespace node (a node with no
+ * namespace URI and no local name), then generate a space followed by
* xmlns="" if and only if the following conditions are met:
* - the element E that owns the axis is in the node-set
- * - the nearest ancestor element of E in the node-set has a default
- * namespace node in the node-set (default namespace nodes always
+ * - the nearest ancestor element of E in the node-set has a default
+ * namespace node in the node-set (default namespace nodes always
* have non-empty values in XPath)
*/
if(visible && !has_empty_ns) {
@@ -649,17 +655,17 @@ xmlC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
memset(&ns_default, 0, sizeof(ns_default));
if(!xmlC14NVisibleNsStackFind(ctx->ns_rendered, &ns_default)) {
- xmlC14NPrintNamespaces(&ns_default, ctx);
+ xmlC14NPrintNamespaces(&ns_default, ctx);
}
}
-
-
- /*
- * print out all elements from list
+
+
+ /*
+ * print out all elements from list
*/
xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx);
- /*
+ /*
* Cleanup
*/
xmlListDelete(list);
@@ -669,28 +675,28 @@ xmlC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
/**
* xmlExcC14NProcessNamespacesAxis:
- * @ctx: the C14N context
+ * @ctx: the C14N context
* @node: the current node
*
* Prints out exclusive canonical namespace axis of the current node to the
- * buffer from C14N context as follows
+ * buffer from C14N context as follows
*
* Exclusive XML Canonicalization
* http://www.w3.org/TR/xml-exc-c14n
*
- * If the element node is in the XPath subset then output the node in
- * accordance with Canonical XML except for namespace nodes which are
+ * If the element node is in the XPath subset then output the node in
+ * accordance with Canonical XML except for namespace nodes which are
* rendered as follows:
*
* 1. Render each namespace node iff:
- * * it is visibly utilized by the immediate parent element or one of
+ * * it is visibly utilized by the immediate parent element or one of
* its attributes, or is present in InclusiveNamespaces PrefixList, and
- * * its prefix and value do not appear in ns_rendered. ns_rendered is
- * obtained by popping the state stack in order to obtain a list of
- * prefixes and their values which have already been rendered by
+ * * its prefix and value do not appear in ns_rendered. ns_rendered is
+ * obtained by popping the state stack in order to obtain a list of
+ * prefixes and their values which have already been rendered by
* an output ancestor of the namespace node's parent element.
- * 2. Append the rendered namespace node to the list ns_rendered of namespace
- * nodes rendered by output ancestors. Push ns_rendered on state stack and
+ * 2. Append the rendered namespace node to the list ns_rendered of namespace
+ * nodes rendered by output ancestors. Push ns_rendered on state stack and
* recurse.
* 3. After the recursion returns, pop thestate stack.
*
@@ -707,13 +713,13 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
int has_empty_ns = 0;
int has_visibly_utilized_empty_ns = 0;
int has_empty_ns_in_inclusive_list = 0;
-
+
if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
xmlC14NErrParam("processing namespaces axis (exc c14n)");
return (-1);
}
- if(!ctx->exclusive) {
+ if(!xmlC14NIsExclusive(ctx)) {
xmlC14NErrParam("processing namespaces axis (exc c14n)");
return (-1);
@@ -728,15 +734,15 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
return (-1);
}
- /*
+ /*
* process inclusive namespaces:
- * All namespace nodes appearing on inclusive ns list are
+ * All namespace nodes appearing on inclusive ns list are
* handled as provided in Canonical XML
*/
if(ctx->inclusive_ns_prefixes != NULL) {
- xmlChar *prefix;
+ xmlChar *prefix;
int i;
-
+
for (i = 0; ctx->inclusive_ns_prefixes[i] != NULL; ++i) {
prefix = ctx->inclusive_ns_prefixes[i];
/*
@@ -747,23 +753,23 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
prefix = NULL;
has_empty_ns_in_inclusive_list = 1;
}
-
- ns = xmlSearchNs(cur->doc, cur, prefix);
+
+ ns = xmlSearchNs(cur->doc, cur, prefix);
if((ns != NULL) && !xmlC14NIsXmlNs(ns) && xmlC14NIsVisible(ctx, ns, cur)) {
already_rendered = xmlC14NVisibleNsStackFind(ctx->ns_rendered, ns);
if(visible) {
- xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur);
+ xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur);
}
if(!already_rendered) {
- xmlListInsert(list, ns);
+ xmlListInsert(list, ns);
}
- if(xmlStrlen(ns->prefix) == 0) {
+ if(xmlStrlen(ns->prefix) == 0) {
has_empty_ns = 1;
}
}
}
}
-
+
/* add node namespace */
if(cur->ns != NULL) {
ns = cur->ns;
@@ -772,32 +778,32 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
has_visibly_utilized_empty_ns = 1;
}
if((ns != NULL) && !xmlC14NIsXmlNs(ns)) {
- if(visible && xmlC14NIsVisible(ctx, ns, cur)) {
+ if(visible && xmlC14NIsVisible(ctx, ns, cur)) {
if(!xmlExcC14NVisibleNsStackFind(ctx->ns_rendered, ns, ctx)) {
xmlListInsert(list, ns);
}
}
if(visible) {
- xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur);
+ xmlC14NVisibleNsStackAdd(ctx->ns_rendered, ns, cur);
}
if(xmlStrlen(ns->prefix) == 0) {
has_empty_ns = 1;
}
}
-
-
+
+
/* add attributes */
for(attr = cur->properties; attr != NULL; attr = attr->next) {
- /*
+ /*
* we need to check that attribute is visible and has non
- * default namespace (XML Namespaces: "default namespaces
- * do not apply directly to attributes")
+ * default namespace (XML Namespaces: "default namespaces
+ * do not apply directly to attributes")
*/
if((attr->ns != NULL) && !xmlC14NIsXmlNs(attr->ns) && xmlC14NIsVisible(ctx, attr, cur)) {
already_rendered = xmlExcC14NVisibleNsStackFind(ctx->ns_rendered, attr->ns, ctx);
- xmlC14NVisibleNsStackAdd(ctx->ns_rendered, attr->ns, cur);
+ xmlC14NVisibleNsStackAdd(ctx->ns_rendered, attr->ns, cur);
if(!already_rendered && visible) {
- xmlListInsert(list, attr->ns);
+ xmlListInsert(list, attr->ns);
}
if(xmlStrlen(attr->ns->prefix) == 0) {
has_empty_ns = 1;
@@ -810,33 +816,33 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
/*
* Process xmlns=""
*/
- if(visible && has_visibly_utilized_empty_ns &&
+ if(visible && has_visibly_utilized_empty_ns &&
!has_empty_ns && !has_empty_ns_in_inclusive_list) {
static xmlNs ns_default;
memset(&ns_default, 0, sizeof(ns_default));
-
+
already_rendered = xmlExcC14NVisibleNsStackFind(ctx->ns_rendered, &ns_default, ctx);
if(!already_rendered) {
- xmlC14NPrintNamespaces(&ns_default, ctx);
+ xmlC14NPrintNamespaces(&ns_default, ctx);
}
} else if(visible && !has_empty_ns && has_empty_ns_in_inclusive_list) {
static xmlNs ns_default;
memset(&ns_default, 0, sizeof(ns_default));
if(!xmlC14NVisibleNsStackFind(ctx->ns_rendered, &ns_default)) {
- xmlC14NPrintNamespaces(&ns_default, ctx);
+ xmlC14NPrintNamespaces(&ns_default, ctx);
}
}
-
- /*
- * print out all elements from list
+
+ /*
+ * print out all elements from list
*/
xmlListWalk(list, (xmlListWalker) xmlC14NPrintNamespaces, (const void *) ctx);
- /*
+ /*
* Cleanup
*/
xmlListDelete(list);
@@ -845,9 +851,28 @@ xmlExcC14NProcessNamespacesAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
/**
+ * xmlC14NIsXmlAttr:
+ * @attr: the attr to check
+ *
+ * Checks whether the given attribute is a default "xml:" namespace
+ * with href="http://www.w3.org/XML/1998/namespace"
+ *
+ * Returns 1 if the node is default or 0 otherwise
+ */
+
+/* todo: make it a define? */
+static int
+xmlC14NIsXmlAttr(xmlAttrPtr attr)
+{
+ return ((attr->ns != NULL) &&
+ (xmlC14NIsXmlNs(attr->ns) != 0));
+}
+
+
+/**
* xmlC14NAttrsCompare:
* @attr1: the pointer tls o first attr
- * @attr2: the pointer to second attr
+ * @attr2: the pointer to second attr
*
* Prints the given attribute to the output buffer from C14N context.
*
@@ -871,7 +896,7 @@ xmlC14NAttrsCompare(xmlAttrPtr attr1, xmlAttrPtr attr2)
return (xmlStrcmp(attr1->name, attr2->name));
}
- /*
+ /*
* Attributes in the default namespace are first
* because the default namespace is not applied to
* unqualified attributes
@@ -896,10 +921,10 @@ xmlC14NAttrsCompare(xmlAttrPtr attr1, xmlAttrPtr attr2)
/**
* xmlC14NPrintAttrs:
* @attr: the pointer to attr
- * @ctx: the C14N context
+ * @ctx: the C14N context
*
* Prints out canonical attribute urrent node to the
- * buffer from C14N context as follows
+ * buffer from C14N context as follows
*
* Canonical XML v 1.0 (http://www.w3.org/TR/xml-c14n)
*
@@ -925,7 +950,7 @@ xmlC14NPrintAttrs(const xmlAttrPtr attr, xmlC14NCtxPtr ctx)
xmlOutputBufferWriteString(ctx->buf, (const char *) attr->name);
xmlOutputBufferWriteString(ctx->buf, "=\"");
- value = xmlNodeListGetString(attr->doc, attr->children, 1);
+ value = xmlNodeListGetString(ctx->doc, attr->children, 1);
/* todo: should we log an error if value==NULL ? */
if (value != NULL) {
buffer = xmlC11NNormalizeAttr(value);
@@ -943,33 +968,156 @@ xmlC14NPrintAttrs(const xmlAttrPtr attr, xmlC14NCtxPtr ctx)
}
/**
+ * xmlC14NFindHiddenParentAttr:
+ *
+ * Finds an attribute in a hidden parent node.
+ *
+ * Returns a pointer to the attribute node (if found) or NULL otherwise.
+ */
+static xmlAttrPtr
+xmlC14NFindHiddenParentAttr(xmlC14NCtxPtr ctx, xmlNodePtr cur, const xmlChar * name, const xmlChar * ns)
+{
+ xmlAttrPtr res;
+ while((cur != NULL) && (!xmlC14NIsVisible(ctx, cur, cur->parent))) {
+ res = xmlHasNsProp(cur, name, ns);
+ if(res != NULL) {
+ return res;
+ }
+
+ cur = cur->parent;
+ }
+
+ return NULL;
+}
+
+/**
+ * xmlC14NFixupBaseAttr:
+ *
+ * Fixes up the xml:base attribute
+ *
+ * Returns the newly created attribute or NULL
+ */
+static xmlAttrPtr
+xmlC14NFixupBaseAttr(xmlC14NCtxPtr ctx, xmlAttrPtr xml_base_attr)
+{
+ xmlChar * res = NULL;
+ xmlNodePtr cur;
+ xmlAttrPtr attr;
+ xmlChar * tmp_str;
+ xmlChar * tmp_str2;
+ int tmp_str_len;
+
+ if ((ctx == NULL) || (xml_base_attr == NULL) || (xml_base_attr->parent == NULL)) {
+ xmlC14NErrParam("processing xml:base attribute");
+ return (NULL);
+ }
+
+ /* start from current value */
+ res = xmlNodeListGetString(ctx->doc, xml_base_attr->children, 1);
+ if(res == NULL) {
+ xmlC14NErrInternal("processing xml:base attribute - can't get attr value");
+ return (NULL);
+ }
+
+ /* go up the stack until we find a node that we rendered already */
+ cur = xml_base_attr->parent->parent;
+ while((cur != NULL) && (!xmlC14NIsVisible(ctx, cur, cur->parent))) {
+ attr = xmlHasNsProp(cur, BAD_CAST "base", XML_XML_NAMESPACE);
+ if(attr != NULL) {
+ /* get attr value */
+ tmp_str = xmlNodeListGetString(ctx->doc, attr->children, 1);
+ if(tmp_str == NULL) {
+ xmlFree(res);
+
+ xmlC14NErrInternal("processing xml:base attribute - can't get attr value");
+ return (NULL);
+ }
+
+ /* we need to add '/' if our current base uri ends with '..' or '.'
+ to ensure that we are forced to go "up" all the time */
+ tmp_str_len = xmlStrlen(tmp_str);
+ if(tmp_str_len > 1 && tmp_str[tmp_str_len - 2] == '.') {
+ tmp_str2 = xmlStrcat(tmp_str, BAD_CAST "/");
+ if(tmp_str2 == NULL) {
+ xmlFree(tmp_str);
+ xmlFree(res);
+
+ xmlC14NErrInternal("processing xml:base attribute - can't modify uri");
+ return (NULL);
+ }
+
+ tmp_str = tmp_str2;
+ }
+
+ /* build uri */
+ tmp_str2 = xmlBuildURI(res, tmp_str);
+ if(tmp_str2 == NULL) {
+ xmlFree(tmp_str);
+ xmlFree(res);
+
+ xmlC14NErrInternal("processing xml:base attribute - can't construct uri");
+ return (NULL);
+ }
+
+ /* cleanup and set the new res */
+ xmlFree(tmp_str);
+ xmlFree(res);
+ res = tmp_str2;
+ }
+
+ /* next */
+ cur = cur->parent;
+ }
+
+ /* check if result uri is empty or not */
+ if((res == NULL) || xmlStrEqual(res, BAD_CAST "")) {
+ xmlFree(res);
+ return (NULL);
+ }
+
+ /* create and return the new attribute node */
+ attr = xmlNewNsProp(NULL, xml_base_attr->ns, BAD_CAST "base", res);
+ if(attr == NULL) {
+ xmlFree(res);
+
+ xmlC14NErrInternal("processing xml:base attribute - can't construct attribute");
+ return (NULL);
+ }
+
+ /* done */
+ xmlFree(res);
+ return (attr);
+}
+
+/**
* xmlC14NProcessAttrsAxis:
- * @ctx: the C14N context
+ * @ctx: the C14N context
* @cur: the current node
* @parent_visible: the visibility of parent node
+ * @all_parents_visible: the visibility of all parent nodes
*
* Prints out canonical attribute axis of the current node to the
- * buffer from C14N context as follows
+ * buffer from C14N context as follows
*
* Canonical XML v 1.0 (http://www.w3.org/TR/xml-c14n)
*
- * Attribute Axis
- * In lexicographic order (ascending), process each node that
+ * Attribute Axis
+ * In lexicographic order (ascending), process each node that
* is in the element's attribute axis and in the node-set.
- *
- * The processing of an element node E MUST be modified slightly
- * when an XPath node-set is given as input and the element's
+ *
+ * The processing of an element node E MUST be modified slightly
+ * when an XPath node-set is given as input and the element's
* parent is omitted from the node-set.
*
*
* Exclusive XML Canonicalization v 1.0 (http://www.w3.org/TR/xml-exc-c14n)
*
- * Canonical XML applied to a document subset requires the search of the
- * ancestor nodes of each orphan element node for attributes in the xml
- * namespace, such as xml:lang and xml:space. These are copied into the
- * element node except if a declaration of the same attribute is already
- * in the attribute axis of the element (whether or not it is included in
- * the document subset). This search and copying are omitted from the
+ * Canonical XML applied to a document subset requires the search of the
+ * ancestor nodes of each orphan element node for attributes in the xml
+ * namespace, such as xml:lang and xml:space. These are copied into the
+ * element node except if a declaration of the same attribute is already
+ * in the attribute axis of the element (whether or not it is included in
+ * the document subset). This search and copying are omitted from the
* Exclusive XML Canonicalization method.
*
* Returns 0 on success or -1 on fail.
@@ -979,6 +1127,12 @@ xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible)
{
xmlAttrPtr attr;
xmlListPtr list;
+ xmlAttrPtr attrs_to_delete = NULL;
+
+ /* special processing for 1.1 spec */
+ xmlAttrPtr xml_base_attr = NULL;
+ xmlAttrPtr xml_lang_attr = NULL;
+ xmlAttrPtr xml_space_attr = NULL;
if ((ctx == NULL) || (cur == NULL) || (cur->type != XML_ELEMENT_NODE)) {
xmlC14NErrParam("processing attributes axis");
@@ -994,57 +1148,200 @@ xmlC14NProcessAttrsAxis(xmlC14NCtxPtr ctx, xmlNodePtr cur, int parent_visible)
return (-1);
}
- /*
- * Add all visible attributes from current node.
- */
- attr = cur->properties;
- while (attr != NULL) {
- /* check that attribute is visible */
- if (xmlC14NIsVisible(ctx, attr, cur)) {
- xmlListInsert(list, attr);
+ switch(ctx->mode) {
+ case XML_C14N_1_0:
+ /* The processing of an element node E MUST be modified slightly when an XPath node-set is
+ * given as input and the element's parent is omitted from the node-set. The method for processing
+ * the attribute axis of an element E in the node-set is enhanced. All element nodes along E's
+ * ancestor axis are examined for nearest occurrences of attributes in the xml namespace, such
+ * as xml:lang and xml:space (whether or not they are in the node-set). From this list of attributes,
+ * remove any that are in E's attribute axis (whether or not they are in the node-set). Then,
+ * lexicographically merge this attribute list with the nodes of E's attribute axis that are in
+ * the node-set. The result of visiting the attribute axis is computed by processing the attribute
+ * nodes in this merged attribute list.
+ */
+
+ /*
+ * Add all visible attributes from current node.
+ */
+ attr = cur->properties;
+ while (attr != NULL) {
+ /* check that attribute is visible */
+ if (xmlC14NIsVisible(ctx, attr, cur)) {
+ xmlListInsert(list, attr);
+ }
+ attr = attr->next;
}
- attr = attr->next;
- }
- /*
- * include attributes in "xml" namespace defined in ancestors
- * (only for non-exclusive XML Canonicalization)
- */
- if (parent_visible && (!ctx->exclusive) && (cur->parent != NULL)
- && (!xmlC14NIsVisible(ctx, cur->parent, cur->parent->parent))) {
/*
- * If XPath node-set is not specified then the parent is always
- * visible!
+ * Handle xml attributes
*/
- cur = cur->parent;
- while (cur != NULL) {
- attr = cur->properties;
- while (attr != NULL) {
- if ((attr->ns != NULL)
- && (xmlStrEqual(attr->ns->prefix, BAD_CAST "xml"))) {
- if (xmlListSearch(list, attr) == NULL) {
- xmlListInsert(list, attr);
+ if (parent_visible && (cur->parent != NULL) &&
+ (!xmlC14NIsVisible(ctx, cur->parent, cur->parent->parent)))
+ {
+ xmlNodePtr tmp;
+
+ /*
+ * If XPath node-set is not specified then the parent is always
+ * visible!
+ */
+ tmp = cur->parent;
+ while (tmp != NULL) {
+ attr = tmp->properties;
+ while (attr != NULL) {
+ if (xmlC14NIsXmlAttr(attr) != 0) {
+ if (xmlListSearch(list, attr) == NULL) {
+ xmlListInsert(list, attr);
+ }
}
+ attr = attr->next;
+ }
+ tmp = tmp->parent;
+ }
+ }
+
+ /* done */
+ break;
+ case XML_C14N_EXCLUSIVE_1_0:
+ /* attributes in the XML namespace, such as xml:lang and xml:space
+ * are not imported into orphan nodes of the document subset
+ */
+
+ /*
+ * Add all visible attributes from current node.
+ */
+ attr = cur->properties;
+ while (attr != NULL) {
+ /* check that attribute is visible */
+ if (xmlC14NIsVisible(ctx, attr, cur)) {
+ xmlListInsert(list, attr);
+ }
+ attr = attr->next;
+ }
+
+ /* do nothing special for xml attributes */
+ break;
+ case XML_C14N_1_1:
+ /* The processing of an element node E MUST be modified slightly when an XPath node-set is
+ * given as input and some of the element's ancestors are omitted from the node-set.
+ *
+ * Simple inheritable attributes are attributes that have a value that requires at most a simple
+ * redeclaration. This redeclaration is done by supplying a new value in the child axis. The
+ * redeclaration of a simple inheritable attribute A contained in one of E's ancestors is done
+ * by supplying a value to an attribute Ae inside E with the same name. Simple inheritable attributes
+ * are xml:lang and xml:space.
+ *
+ * The method for processing the attribute axis of an element E in the node-set is hence enhanced.
+ * All element nodes along E's ancestor axis are examined for the nearest occurrences of simple
+ * inheritable attributes in the xml namespace, such as xml:lang and xml:space (whether or not they
+ * are in the node-set). From this list of attributes, any simple inheritable attributes that are
+ * already in E's attribute axis (whether or not they are in the node-set) are removed. Then,
+ * lexicographically merge this attribute list with the nodes of E's attribute axis that are in
+ * the node-set. The result of visiting the attribute axis is computed by processing the attribute
+ * nodes in this merged attribute list.
+ *
+ * The xml:id attribute is not a simple inheritable attribute and no processing of these attributes is
+ * performed.
+ *
+ * The xml:base attribute is not a simple inheritable attribute and requires special processing beyond
+ * a simple redeclaration.
+ *
+ * Attributes in the XML namespace other than xml:base, xml:id, xml:lang, and xml:space MUST be processed
+ * as ordinary attributes.
+ */
+
+ /*
+ * Add all visible attributes from current node.
+ */
+ attr = cur->properties;
+ while (attr != NULL) {
+ /* special processing for XML attribute kiks in only when we have invisible parents */
+ if ((!parent_visible) || (xmlC14NIsXmlAttr(attr) == 0)) {
+ /* check that attribute is visible */
+ if (xmlC14NIsVisible(ctx, attr, cur)) {
+ xmlListInsert(list, attr);
+ }
+ } else {
+ int matched = 0;
+
+ /* check for simple inheritance attributes */
+ if((!matched) && (xml_lang_attr == NULL) && xmlStrEqual(attr->name, BAD_CAST "lang")) {
+ xml_lang_attr = attr;
+ matched = 1;
+ }
+ if((!matched) && (xml_space_attr == NULL) && xmlStrEqual(attr->name, BAD_CAST "space")) {
+ xml_space_attr = attr;
+ matched = 1;
+ }
+
+ /* check for base attr */
+ if((!matched) && (xml_base_attr == NULL) && xmlStrEqual(attr->name, BAD_CAST "base")) {
+ xml_base_attr = attr;
+ matched = 1;
+ }
+
+ /* otherwise, it is a normal attribute, so just check if it is visible */
+ if((!matched) && xmlC14NIsVisible(ctx, attr, cur)) {
+ xmlListInsert(list, attr);
+ }
+ }
+
+ /* move to the next one */
+ attr = attr->next;
+ }
+
+ /* special processing for XML attribute kiks in only when we have invisible parents */
+ if ((parent_visible)) {
+
+ /* simple inheritance attributes - copy */
+ if(xml_lang_attr == NULL) {
+ xml_lang_attr = xmlC14NFindHiddenParentAttr(ctx, cur->parent, BAD_CAST "lang", XML_XML_NAMESPACE);
+ }
+ if(xml_lang_attr != NULL) {
+ xmlListInsert(list, xml_lang_attr);
+ }
+ if(xml_space_attr == NULL) {
+ xml_space_attr = xmlC14NFindHiddenParentAttr(ctx, cur->parent, BAD_CAST "space", XML_XML_NAMESPACE);
+ }
+ if(xml_space_attr != NULL) {
+ xmlListInsert(list, xml_space_attr);
+ }
+
+ /* base uri attribute - fix up */
+ if(xml_base_attr == NULL) {
+ /* if we don't have base uri attribute, check if we have a "hidden" one above */
+ xml_base_attr = xmlC14NFindHiddenParentAttr(ctx, cur->parent, BAD_CAST "base", XML_XML_NAMESPACE);
+ }
+ if(xml_base_attr != NULL) {
+ xml_base_attr = xmlC14NFixupBaseAttr(ctx, xml_base_attr);
+ if(xml_base_attr != NULL) {
+ xmlListInsert(list, xml_base_attr);
+
+ /* note that we MUST delete returned attr node ourselves! */
+ xml_base_attr->next = attrs_to_delete;
+ attrs_to_delete = xml_base_attr;
}
- attr = attr->next;
}
- cur = cur->parent;
}
+
+ /* done */
+ break;
}
- /*
- * print out all elements from list
+ /*
+ * print out all elements from list
*/
xmlListWalk(list, (xmlListWalker) xmlC14NPrintAttrs, (const void *) ctx);
- /*
+ /*
* Cleanup
*/
+ xmlFreePropList(attrs_to_delete);
xmlListDelete(list);
return (0);
}
-/**
+/**
* xmlC14NCheckForRelativeNamespaces:
* @ctx: the C14N context
* @cur: the current element node
@@ -1094,21 +1391,23 @@ xmlC14NCheckForRelativeNamespaces(xmlC14NCtxPtr ctx, xmlNodePtr cur)
/**
* xmlC14NProcessElementNode:
- * @ctx: the pointer to C14N context object
+ * @ctx: the pointer to C14N context object
* @cur: the node to process
- *
+ * @visible: this node is visible
+ * @all_parents_visible: whether all the parents of this node are visible
+ *
* Canonical XML v 1.0 (http://www.w3.org/TR/xml-c14n)
*
* Element Nodes
- * If the element is not in the node-set, then the result is obtained
- * by processing the namespace axis, then the attribute axis, then
- * processing the child nodes of the element that are in the node-set
- * (in document order). If the element is in the node-set, then the result
- * is an open angle bracket (<), the element QName, the result of
- * processing the namespace axis, the result of processing the attribute
- * axis, a close angle bracket (>), the result of processing the child
- * nodes of the element that are in the node-set (in document order), an
- * open angle bracket, a forward slash (/), the element QName, and a close
+ * If the element is not in the node-set, then the result is obtained
+ * by processing the namespace axis, then the attribute axis, then
+ * processing the child nodes of the element that are in the node-set
+ * (in document order). If the element is in the node-set, then the result
+ * is an open angle bracket (<), the element QName, the result of
+ * processing the namespace axis, the result of processing the attribute
+ * axis, a close angle bracket (>), the result of processing the child
+ * nodes of the element that are in the node-set (in document order), an
+ * open angle bracket, a forward slash (/), the element QName, and a close
* angle bracket.
*
* Returns non-negative value on success or negative value on fail
@@ -1125,7 +1424,7 @@ xmlC14NProcessElementNode(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
return (-1);
}
- /*
+ /*
* Check relative relative namespaces:
* implementations of XML canonicalization MUST report an operation
* failure on documents containing relative namespace URIs.
@@ -1136,13 +1435,13 @@ xmlC14NProcessElementNode(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
}
- /*
+ /*
* Save ns_rendered stack position
*/
memset(&state, 0, sizeof(state));
xmlC14NVisibleNsStackSave(ctx->ns_rendered, &state);
- if (visible) {
+ if (visible) {
if (ctx->parent_is_doc) {
/* save this flag into the stack */
parent_is_doc = ctx->parent_is_doc;
@@ -1159,7 +1458,7 @@ xmlC14NProcessElementNode(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
xmlOutputBufferWriteString(ctx->buf, (const char *) cur->name);
}
- if (!ctx->exclusive) {
+ if (!xmlC14NIsExclusive(ctx)) {
ret = xmlC14NProcessNamespacesAxis(ctx, cur, visible);
} else {
ret = xmlExcC14NProcessNamespacesAxis(ctx, cur, visible);
@@ -1172,14 +1471,14 @@ xmlC14NProcessElementNode(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
if(visible) {
xmlC14NVisibleNsStackShift(ctx->ns_rendered);
}
-
+
ret = xmlC14NProcessAttrsAxis(ctx, cur, visible);
if (ret < 0) {
xmlC14NErrInternal("processing attributes axis");
- return (-1);
+ return (-1);
}
- if (visible) {
+ if (visible) {
xmlOutputBufferWriteString(ctx->buf, ">");
}
if (cur->children != NULL) {
@@ -1205,7 +1504,7 @@ xmlC14NProcessElementNode(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
}
}
- /*
+ /*
* Restore ns_rendered stack position
*/
xmlC14NVisibleNsStackRestore(ctx->ns_rendered, &state);
@@ -1214,9 +1513,9 @@ xmlC14NProcessElementNode(xmlC14NCtxPtr ctx, xmlNodePtr cur, int visible)
/**
* xmlC14NProcessNode:
- * @ctx: the pointer to C14N context object
+ * @ctx: the pointer to C14N context object
* @cur: the node to process
- *
+ *
* Processes the given node
*
* Returns non-negative value on success or negative value on fail
@@ -1241,9 +1540,9 @@ xmlC14NProcessNode(xmlC14NCtxPtr ctx, xmlNodePtr cur)
case XML_TEXT_NODE:
/*
* Text Nodes
- * the string value, except all ampersands are replaced
- * by &amp;, all open angle brackets (<) are replaced by &lt;, all closing
- * angle brackets (>) are replaced by &gt;, and all #xD characters are
+ * the string value, except all ampersands are replaced
+ * by &amp;, all open angle brackets (<) are replaced by &lt;, all closing
+ * angle brackets (>) are replaced by &gt;, and all #xD characters are
* replaced by &#xD;.
*/
/* cdata sections are processed as text nodes */
@@ -1263,16 +1562,16 @@ xmlC14NProcessNode(xmlC14NCtxPtr ctx, xmlNodePtr cur)
}
break;
case XML_PI_NODE:
- /*
- * Processing Instruction (PI) Nodes-
- * The opening PI symbol (<?), the PI target name of the node,
- * a leading space and the string value if it is not empty, and
- * the closing PI symbol (?>). If the string value is empty,
- * then the leading space is not added. Also, a trailing #xA is
- * rendered after the closing PI symbol for PI children of the
- * root node with a lesser document order than the document
- * element, and a leading #xA is rendered before the opening PI
- * symbol of PI children of the root node with a greater document
+ /*
+ * Processing Instruction (PI) Nodes-
+ * The opening PI symbol (<?), the PI target name of the node,
+ * a leading space and the string value if it is not empty, and
+ * the closing PI symbol (?>). If the string value is empty,
+ * then the leading space is not added. Also, a trailing #xA is
+ * rendered after the closing PI symbol for PI children of the
+ * root node with a lesser document order than the document
+ * element, and a leading #xA is rendered before the opening PI
+ * symbol of PI children of the root node with a greater document
* order than the document element.
*/
if (visible) {
@@ -1311,17 +1610,17 @@ xmlC14NProcessNode(xmlC14NCtxPtr ctx, xmlNodePtr cur)
case XML_COMMENT_NODE:
/*
* Comment Nodes
- * Nothing if generating canonical XML without comments. For
- * canonical XML with comments, generate the opening comment
- * symbol (<!--), the string value of the node, and the
- * closing comment symbol (-->). Also, a trailing #xA is rendered
- * after the closing comment symbol for comment children of the
- * root node with a lesser document order than the document
- * element, and a leading #xA is rendered before the opening
- * comment symbol of comment children of the root node with a
- * greater document order than the document element. (Comment
- * children of the root node represent comments outside of the
- * top-level document element and outside of the document type
+ * Nothing if generating canonical XML without comments. For
+ * canonical XML with comments, generate the opening comment
+ * symbol (<!--), the string value of the node, and the
+ * closing comment symbol (-->). Also, a trailing #xA is rendered
+ * after the closing comment symbol for comment children of the
+ * root node with a lesser document order than the document
+ * element, and a leading #xA is rendered before the opening
+ * comment symbol of comment children of the root node with a
+ * greater document order than the document element. (Comment
+ * children of the root node represent comments outside of the
+ * top-level document element and outside of the document type
* declaration).
*/
if (visible && ctx->with_comments) {
@@ -1391,8 +1690,8 @@ xmlC14NProcessNode(xmlC14NCtxPtr ctx, xmlNodePtr cur)
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
#endif
- /*
- * should be ignored according to "W3C Canonical XML"
+ /*
+ * should be ignored according to "W3C Canonical XML"
*/
break;
default:
@@ -1405,9 +1704,9 @@ xmlC14NProcessNode(xmlC14NCtxPtr ctx, xmlNodePtr cur)
/**
* xmlC14NProcessNodeList:
- * @ctx: the pointer to C14N context object
+ * @ctx: the pointer to C14N context object
* @cur: the node to start from
- *
+ *
* Processes all nodes in the row starting from cur.
*
* Returns non-negative value on success or negative value on fail
@@ -1432,7 +1731,7 @@ xmlC14NProcessNodeList(xmlC14NCtxPtr ctx, xmlNodePtr cur)
/**
* xmlC14NFreeCtx:
* @ctx: the pointer to C14N context object
- *
+ *
* Cleanups the C14N context object.
*/
@@ -1452,28 +1751,29 @@ xmlC14NFreeCtx(xmlC14NCtxPtr ctx)
/**
* xmlC14NNewCtx:
- * @doc: the XML document for canonization
- * @is_visible_callback:the function to use to determine is node visible
+ * @doc: the XML document for canonization
+ * @is_visible_callback:the function to use to determine is node visible
* or not
- * @user_data: the first parameter for @is_visible_callback function
+ * @user_data: the first parameter for @is_visible_callback function
* (in most cases, it is nodes set)
- * @inclusive_ns_prefixe the list of inclusive namespace prefixes
+ * @mode: the c14n mode (see @xmlC14NMode)
+ * @inclusive_ns_prefixe the list of inclusive namespace prefixes
* ended with a NULL or NULL if there is no
- * inclusive namespaces (only for exclusive
+ * inclusive namespaces (only for `
* canonicalization)
- * @with_comments: include comments in the result (!=0) or not (==0)
- * @buf: the output buffer to store canonical XML; this
+ * @with_comments: include comments in the result (!=0) or not (==0)
+ * @buf: the output buffer to store canonical XML; this
* buffer MUST have encoder==NULL because C14N requires
* UTF-8 output
- *
+ *
* Creates new C14N context object to store C14N parameters.
*
* Returns pointer to newly created object (success) or NULL (fail)
*/
static xmlC14NCtxPtr
-xmlC14NNewCtx(xmlDocPtr doc,
+xmlC14NNewCtx(xmlDocPtr doc,
xmlC14NIsVisibleCallback is_visible_callback, void* user_data,
- int exclusive, xmlChar ** inclusive_ns_prefixes,
+ xmlC14NMode mode, xmlChar ** inclusive_ns_prefixes,
int with_comments, xmlOutputBufferPtr buf)
{
xmlC14NCtxPtr ctx = NULL;
@@ -1531,11 +1831,11 @@ xmlC14NNewCtx(xmlDocPtr doc,
}
/*
- * Set "exclusive" flag, create a nodes set for namespaces
- * stack and remember list of incluseve prefixes
+ * Set "mode" flag and remember list of incluseve prefixes
+ * for exclusive c14n
*/
- if (exclusive) {
- ctx->exclusive = 1;
+ ctx->mode = mode;
+ if(xmlC14NIsExclusive(ctx)) {
ctx->inclusive_ns_prefixes = inclusive_ns_prefixes;
}
return (ctx);
@@ -1543,34 +1843,34 @@ xmlC14NNewCtx(xmlDocPtr doc,
/**
* xmlC14NExecute:
- * @doc: the XML document for canonization
- * @is_visible_callback:the function to use to determine is node visible
+ * @doc: the XML document for canonization
+ * @is_visible_callback:the function to use to determine is node visible
* or not
- * @user_data: the first parameter for @is_visible_callback function
+ * @user_data: the first parameter for @is_visible_callback function
* (in most cases, it is nodes set)
- * @exclusive: the exclusive flag (0 - non-exclusive canonicalization;
- * otherwise - exclusive canonicalization)
- * @inclusive_ns_prefixes: the list of inclusive namespace prefixes
+ * @mode: the c14n mode (see @xmlC14NMode)
+ * @inclusive_ns_prefixes: the list of inclusive namespace prefixes
* ended with a NULL or NULL if there is no
- * inclusive namespaces (only for exclusive
+ * inclusive namespaces (only for exclusive
* canonicalization, ignored otherwise)
- * @with_comments: include comments in the result (!=0) or not (==0)
- * @buf: the output buffer to store canonical XML; this
+ * @with_comments: include comments in the result (!=0) or not (==0)
+ * @buf: the output buffer to store canonical XML; this
* buffer MUST have encoder==NULL because C14N requires
* UTF-8 output
- *
+ *
* Dumps the canonized image of given XML document into the provided buffer.
* For details see "Canonical XML" (http://www.w3.org/TR/xml-c14n) or
* "Exclusive XML Canonicalization" (http://www.w3.org/TR/xml-exc-c14n)
*
- * Returns non-negative value on success or a negative value on fail
+ * Returns non-negative value on success or a negative value on fail
*/
-int
+int
xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
- void* user_data, int exclusive, xmlChar **inclusive_ns_prefixes,
+ void* user_data, int mode, xmlChar **inclusive_ns_prefixes,
int with_comments, xmlOutputBufferPtr buf) {
xmlC14NCtxPtr ctx;
+ xmlC14NMode c14n_mode = XML_C14N_1_0;
int ret;
if ((buf == NULL) || (doc == NULL)) {
@@ -1578,6 +1878,19 @@ xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
return (-1);
}
+ /* for backward compatibility, we have to have "mode" as "int"
+ and here we check that user gives valid value */
+ switch(mode) {
+ case XML_C14N_1_0:
+ case XML_C14N_EXCLUSIVE_1_0:
+ case XML_C14N_1_1:
+ c14n_mode = (xmlC14NMode)mode;
+ break;
+ default:
+ xmlC14NErrParam("invalid mode for executing c14n");
+ return (-1);
+ }
+
/*
* Validate the encoding output buffer encoding
*/
@@ -1587,9 +1900,9 @@ xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
return (-1);
}
- ctx = xmlC14NNewCtx(doc, is_visible_callback, user_data,
- exclusive, inclusive_ns_prefixes,
- with_comments, buf);
+ ctx = xmlC14NNewCtx(doc, is_visible_callback, user_data,
+ c14n_mode, inclusive_ns_prefixes,
+ with_comments, buf);
if (ctx == NULL) {
xmlC14NErr(NULL, (xmlNodePtr) doc, XML_C14N_CREATE_CTXT,
"xmlC14NExecute: unable to create C14N context\n");
@@ -1598,12 +1911,12 @@ xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
- /*
+ /*
* Root Node
- * The root node is the parent of the top-level document element. The
- * result of processing each of its child nodes that is in the node-set
- * in document order. The root node does not generate a byte order mark,
- * XML declaration, nor anything from within the document type
+ * The root node is the parent of the top-level document element. The
+ * result of processing each of its child nodes that is in the node-set
+ * in document order. The root node does not generate a byte order mark,
+ * XML declaration, nor anything from within the document type
* declaration.
*/
if (doc->children != NULL) {
@@ -1625,7 +1938,7 @@ xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
return (-1);
}
- /*
+ /*
* Cleanup
*/
xmlC14NFreeCtx(ctx);
@@ -1634,34 +1947,33 @@ xmlC14NExecute(xmlDocPtr doc, xmlC14NIsVisibleCallback is_visible_callback,
/**
* xmlC14NDocSaveTo:
- * @doc: the XML document for canonization
- * @nodes: the nodes set to be included in the canonized image
- * or NULL if all document nodes should be included
- * @exclusive: the exclusive flag (0 - non-exclusive canonicalization;
- * otherwise - exclusive canonicalization)
- * @inclusive_ns_prefixes: the list of inclusive namespace prefixes
+ * @doc: the XML document for canonization
+ * @nodes: the nodes set to be included in the canonized image
+ * or NULL if all document nodes should be included
+ * @mode: the c14n mode (see @xmlC14NMode)
+ * @inclusive_ns_prefixes: the list of inclusive namespace prefixes
* ended with a NULL or NULL if there is no
- * inclusive namespaces (only for exclusive
+ * inclusive namespaces (only for exclusive
* canonicalization, ignored otherwise)
- * @with_comments: include comments in the result (!=0) or not (==0)
- * @buf: the output buffer to store canonical XML; this
+ * @with_comments: include comments in the result (!=0) or not (==0)
+ * @buf: the output buffer to store canonical XML; this
* buffer MUST have encoder==NULL because C14N requires
* UTF-8 output
- *
+ *
* Dumps the canonized image of given XML document into the provided buffer.
* For details see "Canonical XML" (http://www.w3.org/TR/xml-c14n) or
* "Exclusive XML Canonicalization" (http://www.w3.org/TR/xml-exc-c14n)
*
- * Returns non-negative value on success or a negative value on fail
+ * Returns non-negative value on success or a negative value on fail
*/
int
xmlC14NDocSaveTo(xmlDocPtr doc, xmlNodeSetPtr nodes,
- int exclusive, xmlChar ** inclusive_ns_prefixes,
+ int mode, xmlChar ** inclusive_ns_prefixes,
int with_comments, xmlOutputBufferPtr buf) {
- return(xmlC14NExecute(doc,
+ return(xmlC14NExecute(doc,
(xmlC14NIsVisibleCallback)xmlC14NIsNodeInNodeset,
nodes,
- exclusive,
+ mode,
inclusive_ns_prefixes,
with_comments,
buf));
@@ -1670,29 +1982,28 @@ xmlC14NDocSaveTo(xmlDocPtr doc, xmlNodeSetPtr nodes,
/**
* xmlC14NDocDumpMemory:
- * @doc: the XML document for canonization
- * @nodes: the nodes set to be included in the canonized image
- * or NULL if all document nodes should be included
- * @exclusive: the exclusive flag (0 - non-exclusive canonicalization;
- * otherwise - exclusive canonicalization)
- * @inclusive_ns_prefixes: the list of inclusive namespace prefixes
+ * @doc: the XML document for canonization
+ * @nodes: the nodes set to be included in the canonized image
+ * or NULL if all document nodes should be included
+ * @mode: the c14n mode (see @xmlC14NMode)
+ * @inclusive_ns_prefixes: the list of inclusive namespace prefixes
* ended with a NULL or NULL if there is no
- * inclusive namespaces (only for exclusive
+ * inclusive namespaces (only for exclusive
* canonicalization, ignored otherwise)
- * @with_comments: include comments in the result (!=0) or not (==0)
- * @doc_txt_ptr: the memory pointer for allocated canonical XML text;
+ * @with_comments: include comments in the result (!=0) or not (==0)
+ * @doc_txt_ptr: the memory pointer for allocated canonical XML text;
* the caller of this functions is responsible for calling
- * xmlFree() to free allocated memory
- *
+ * xmlFree() to free allocated memory
+ *
* Dumps the canonized image of given XML document into memory.
* For details see "Canonical XML" (http://www.w3.org/TR/xml-c14n) or
* "Exclusive XML Canonicalization" (http://www.w3.org/TR/xml-exc-c14n)
*
- * Returns the number of bytes written on success or a negative value on fail
+ * Returns the number of bytes written on success or a negative value on fail
*/
int
xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
- int exclusive, xmlChar ** inclusive_ns_prefixes,
+ int mode, xmlChar ** inclusive_ns_prefixes,
int with_comments, xmlChar ** doc_txt_ptr)
{
int ret;
@@ -1706,7 +2017,7 @@ xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
*doc_txt_ptr = NULL;
/*
- * create memory buffer with UTF8 (default) encoding
+ * create memory buffer with UTF8 (default) encoding
*/
buf = xmlAllocOutputBuffer(NULL);
if (buf == NULL) {
@@ -1717,7 +2028,7 @@ xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
/*
* canonize document and write to buffer
*/
- ret = xmlC14NDocSaveTo(doc, nodes, exclusive, inclusive_ns_prefixes,
+ ret = xmlC14NDocSaveTo(doc, nodes, mode, inclusive_ns_prefixes,
with_comments, buf);
if (ret < 0) {
xmlC14NErrInternal("saving doc to output buffer");
@@ -1725,9 +2036,9 @@ xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
return (-1);
}
- ret = buf->buffer->use;
+ ret = xmlBufUse(buf->buffer);
if (ret > 0) {
- *doc_txt_ptr = xmlStrndup(buf->buffer->content, ret);
+ *doc_txt_ptr = xmlStrndup(xmlBufContent(buf->buffer), ret);
}
(void) xmlOutputBufferClose(buf);
@@ -1740,31 +2051,30 @@ xmlC14NDocDumpMemory(xmlDocPtr doc, xmlNodeSetPtr nodes,
/**
* xmlC14NDocSave:
- * @doc: the XML document for canonization
- * @nodes: the nodes set to be included in the canonized image
- * or NULL if all document nodes should be included
- * @exclusive: the exclusive flag (0 - non-exclusive canonicalization;
- * otherwise - exclusive canonicalization)
- * @inclusive_ns_prefixes: the list of inclusive namespace prefixes
+ * @doc: the XML document for canonization
+ * @nodes: the nodes set to be included in the canonized image
+ * or NULL if all document nodes should be included
+ * @mode: the c14n mode (see @xmlC14NMode)
+ * @inclusive_ns_prefixes: the list of inclusive namespace prefixes
* ended with a NULL or NULL if there is no
- * inclusive namespaces (only for exclusive
+ * inclusive namespaces (only for exclusive
* canonicalization, ignored otherwise)
- * @with_comments: include comments in the result (!=0) or not (==0)
- * @filename: the filename to store canonical XML image
- * @compression: the compression level (zlib requred):
+ * @with_comments: include comments in the result (!=0) or not (==0)
+ * @filename: the filename to store canonical XML image
+ * @compression: the compression level (zlib requred):
* -1 - libxml default,
- * 0 - uncompressed,
+ * 0 - uncompressed,
* >0 - compression level
- *
+ *
* Dumps the canonized image of given XML document into the file.
* For details see "Canonical XML" (http://www.w3.org/TR/xml-c14n) or
* "Exclusive XML Canonicalization" (http://www.w3.org/TR/xml-exc-c14n)
*
- * Returns the number of bytes written success or a negative value on fail
+ * Returns the number of bytes written success or a negative value on fail
*/
int
xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
- int exclusive, xmlChar ** inclusive_ns_prefixes,
+ int mode, xmlChar ** inclusive_ns_prefixes,
int with_comments, const char *filename, int compression)
{
xmlOutputBufferPtr buf;
@@ -1779,7 +2089,7 @@ xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
compression = xmlGetCompressMode();
#endif
- /*
+ /*
* save the content to a temp buffer, use default UTF8 encoding.
*/
buf = xmlOutputBufferCreateFilename(filename, NULL, compression);
@@ -1791,7 +2101,7 @@ xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
/*
* canonize document and write to buffer
*/
- ret = xmlC14NDocSaveTo(doc, nodes, exclusive, inclusive_ns_prefixes,
+ ret = xmlC14NDocSaveTo(doc, nodes, mode, inclusive_ns_prefixes,
with_comments, buf);
if (ret < 0) {
xmlC14NErrInternal("cannicanize document to buffer");
@@ -1799,8 +2109,8 @@ xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
return (-1);
}
- /*
- * get the numbers of bytes written
+ /*
+ * get the numbers of bytes written
*/
ret = xmlOutputBufferClose(buf);
return (ret);
@@ -1814,14 +2124,14 @@ xmlC14NDocSave(xmlDocPtr doc, xmlNodeSetPtr nodes,
#define growBufferReentrant() { \
buffer_size *= 2; \
buffer = (xmlChar *) \
- xmlRealloc(buffer, buffer_size * sizeof(xmlChar)); \
+ xmlRealloc(buffer, buffer_size * sizeof(xmlChar)); \
if (buffer == NULL) { \
xmlC14NErrMemory("growing buffer"); \
return(NULL); \
} \
}
-/**
+/**
* xmlC11NNormalizeString:
* @input: the input string
* @mode: the normalization mode (attribute, comment, PI or text)
@@ -1919,7 +2229,7 @@ xmlC11NNormalizeString(const xmlChar * input,
}
cur++;
}
- *out++ = 0;
+ *out = 0;
return (buffer);
}
#endif /* LIBXML_OUTPUT_ENABLED */
diff --git a/gnulib-local/lib/libxml/c14n.in.h b/gnulib-local/lib/libxml/c14n.in.h
index 9f4c6c0..b8971d9 100644
--- a/gnulib-local/lib/libxml/c14n.in.h
+++ b/gnulib-local/lib/libxml/c14n.in.h
@@ -2,30 +2,30 @@
* Summary: Provide Canonical XML and Exclusive XML Canonicalization
* Description: the c14n modules provides a
*
- * "Canonical XML" implementation
+ * "Canonical XML" implementation
* http://www.w3.org/TR/xml-c14n
- *
+ *
* and an
*
* "Exclusive XML Canonicalization" implementation
* http://www.w3.org/TR/xml-exc-c14n
-
+
* Copy: See Copyright for the status of this software.
- *
+ *
* Author: Aleksey Sanin <aleksey@aleksey.com>
*/
#ifndef __XML_C14N_H__
-#define __XML_C14N_H__
+#define __XML_C14N_H__
#ifdef LIBXML_C14N_ENABLED
#ifdef LIBXML_OUTPUT_ENABLED
#ifdef __cplusplus
extern "C" {
-#endif /* __cplusplus */
+#endif /* __cplusplus */
#include <libxml/xmlversion.h>
#include <libxml/tree.h>
-#include <libxml/xpath.h>
+#include <libxml/xpath.h>
/*
* XML Canonicazation
@@ -37,44 +37,55 @@ extern "C" {
* Canonical form of an XML document could be created if and only if
* a) default attributes (if any) are added to all nodes
* b) all character and parsed entity references are resolved
- * In order to achive this in libxml2 the document MUST be loaded with
+ * In order to achive this in libxml2 the document MUST be loaded with
* following global setings:
- *
+ *
* xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
* xmlSubstituteEntitiesDefault(1);
*
* or corresponding parser context setting:
* xmlParserCtxtPtr ctxt;
- *
- * ...
+ *
+ * ...
* ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
* ctxt->replaceEntities = 1;
* ...
*/
+/*
+ * xmlC14NMode:
+ *
+ * Predefined values for C14N modes
+ *
+ */
+typedef enum {
+ XML_C14N_1_0 = 0, /* Origianal C14N 1.0 spec */
+ XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */
+ XML_C14N_1_1 = 2 /* C14N 1.1 spec */
+} xmlC14NMode;
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlC14NDocSaveTo (xmlDocPtr doc,
xmlNodeSetPtr nodes,
- int exclusive,
+ int mode, /* a xmlC14NMode */
xmlChar **inclusive_ns_prefixes,
- int with_comments,
+ int with_comments,
xmlOutputBufferPtr buf);
XMLPUBFUN int XMLCALL
xmlC14NDocDumpMemory (xmlDocPtr doc,
xmlNodeSetPtr nodes,
- int exclusive,
+ int mode, /* a xmlC14NMode */
xmlChar **inclusive_ns_prefixes,
- int with_comments,
+ int with_comments,
xmlChar **doc_txt_ptr);
XMLPUBFUN int XMLCALL
xmlC14NDocSave (xmlDocPtr doc,
xmlNodeSetPtr nodes,
- int exclusive,
+ int mode, /* a xmlC14NMode */
xmlChar **inclusive_ns_prefixes,
- int with_comments,
+ int with_comments,
const char* filename,
int compression);
@@ -82,17 +93,27 @@ XMLPUBFUN int XMLCALL
/**
* This is the core C14N function
*/
-typedef int (*xmlC14NIsVisibleCallback) (void* user_data,
+/**
+ * xmlC14NIsVisibleCallback:
+ * @user_data: user data
+ * @node: the curent node
+ * @parent: the parent node
+ *
+ * Signature for a C14N callback on visible nodes
+ *
+ * Returns 1 if the node should be included
+ */
+typedef int (*xmlC14NIsVisibleCallback) (void* user_data,
xmlNodePtr node,
xmlNodePtr parent);
XMLPUBFUN int XMLCALL
xmlC14NExecute (xmlDocPtr doc,
xmlC14NIsVisibleCallback is_visible_callback,
- void* user_data,
- int exclusive,
+ void* user_data,
+ int mode, /* a xmlC14NMode */
xmlChar **inclusive_ns_prefixes,
- int with_comments,
+ int with_comments,
xmlOutputBufferPtr buf);
#ifdef __cplusplus
diff --git a/gnulib-local/lib/libxml/catalog.c b/gnulib-local/lib/libxml/catalog.c
index 5456094..5773db3 100644
--- a/gnulib-local/lib/libxml/catalog.c
+++ b/gnulib-local/lib/libxml/catalog.c
@@ -1,5 +1,5 @@
/**
- * catalog.c: set of generic Catalog related routines
+ * catalog.c: set of generic Catalog related routines
*
* Reference: SGML Open Technical Resolution TR9401:1997.
* http://www.jclark.com/sp/catalog.htm
@@ -41,9 +41,17 @@
#include <libxml/threads.h>
#include <libxml/globals.h>
+#include "buf.h"
+
#define MAX_DELEGATE 50
#define MAX_CATAL_DEPTH 50
+#ifdef _WIN32
+# define PATH_SEAPARATOR ';'
+#else
+# define PATH_SEAPARATOR ':'
+#endif
+
/**
* TODO:
*
@@ -54,7 +62,7 @@
*> values "system" and "public". I have made the default be "system" to
*> match yours.
*/
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
@@ -71,9 +79,17 @@
#if defined(_WIN32) && defined(_MSC_VER)
#undef XML_XML_DEFAULT_CATALOG
static char XML_XML_DEFAULT_CATALOG[256] = "file:///etc/xml/catalog";
+#if defined(_WIN32_WCE)
+/* Windows CE don't have a A variant */
+#define GetModuleHandleA GetModuleHandle
+#define GetModuleFileNameA GetModuleFileName
+#else
+#if !defined(_WINDOWS_)
void* __stdcall GetModuleHandleA(const char*);
unsigned long __stdcall GetModuleFileNameA(void*, char*, unsigned long);
#endif
+#endif
+#endif
static xmlChar *xmlCatalogNormalizePublic(const xmlChar *pubID);
static int xmlExpandCatalog(xmlCatalogPtr catal, const char *filename);
@@ -194,7 +210,7 @@ static int xmlCatalogInitialized = 0;
/************************************************************************
* *
- * Catalog error handlers *
+ * Catalog error handlers *
* *
************************************************************************/
@@ -247,9 +263,9 @@ xmlCatalogErr(xmlCatalogEntryPtr catal, xmlNodePtr node, int error,
* @name: name of the entry
* @value: value of the entry
* @prefer: the PUBLIC vs. SYSTEM current preference value
- * @group: for members of a group, the group entry
+ * @group: for members of a group, the group entry
*
- * create a new Catalog entry, this type is shared both by XML and
+ * create a new Catalog entry, this type is shared both by XML and
* SGML catalogs, but the acceptable types values differs.
*
* Returns the xmlCatalogEntryPtr or NULL in case of error
@@ -387,7 +403,7 @@ xmlFreeCatalogHashEntryList(xmlCatalogEntryPtr catal) {
* @type: type of catalog
* @prefer: the PUBLIC vs. SYSTEM current preference value
*
- * create a new Catalog, this type is shared both by XML and
+ * create a new Catalog, this type is shared both by XML and
* SGML catalogs, but the acceptable types values differs.
*
* Returns the xmlCatalogPtr or NULL in case of error
@@ -555,7 +571,7 @@ static void xmlDumpXMLCatalogNode(xmlCatalogEntryPtr catal, xmlNodePtr catalog,
xns = xmlSearchNsByHref(doc, node, XML_XML_NAMESPACE);
if (xns != NULL)
xmlSetNsProp(node, xns, BAD_CAST "base",
- cur->value);
+ cur->value);
}
switch (cur->prefer) {
case XML_CATA_PREFER_NONE:
@@ -673,7 +689,7 @@ BAD_CAST "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd");
xmlAddChild((xmlNodePtr) doc, catalog);
xmlDumpXMLCatalogNode(catal, catalog, doc, ns, NULL);
-
+
/*
* reserialize it
*/
@@ -810,7 +826,7 @@ xmlCatalogUnWrapURN(const xmlChar *urn) {
if (xmlStrncmp(urn, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1))
return(NULL);
urn += sizeof(XML_URN_PUBID) - 1;
-
+
while (*urn != 0) {
if (i > sizeof(result) - 4)
break;
@@ -900,10 +916,7 @@ xmlParseCatalogFile(const char *filename) {
inputStream->filename = (char *) xmlCanonicPath((const xmlChar *)filename);
inputStream->buf = buf;
- inputStream->base = inputStream->buf->buffer->content;
- inputStream->cur = inputStream->buf->buffer->content;
- inputStream->end =
- &inputStream->buf->buffer->content[inputStream->buf->buffer->use];
+ xmlBufResetInput(buf->buffer, inputStream);
inputPush(ctxt, inputStream);
if ((ctxt->directory == NULL) && (directory == NULL))
@@ -926,7 +939,7 @@ xmlParseCatalogFile(const char *filename) {
ctxt->myDoc = NULL;
}
xmlFreeParserCtxt(ctxt);
-
+
return(ret);
}
@@ -978,25 +991,27 @@ xmlLoadFileContent(const char *filename)
return (NULL);
}
#endif
- content = xmlMallocAtomic(size + 10);
+ content = (xmlChar*)xmlMallocAtomic(size + 10);
if (content == NULL) {
xmlCatalogErrMemory("allocating catalog data");
+#ifdef HAVE_STAT
+ close(fd);
+#else
+ fclose(fd);
+#endif
return (NULL);
}
#ifdef HAVE_STAT
len = read(fd, content, size);
+ close(fd);
#else
len = fread(content, 1, size, fd);
+ fclose(fd);
#endif
if (len < 0) {
xmlFree(content);
return (NULL);
}
-#ifdef HAVE_STAT
- close(fd);
-#else
- fclose(fd);
-#endif
content[len] = 0;
return(content);
@@ -1319,7 +1334,7 @@ xmlParseXMLCatalogNodeList(xmlNodePtr cur, xmlCatalogPrefer prefer,
*
* Parses the catalog file to extract the XML tree and then analyze the
* tree to build a list of Catalog entries corresponding to this catalog
- *
+ *
* Returns the resulting Catalog entries list
*/
static xmlCatalogEntryPtr
@@ -1387,19 +1402,17 @@ xmlParseXMLCatalogFile(xmlCatalogPrefer prefer, const xmlChar *filename) {
* @catal: an existing but incomplete catalog entry
*
* Fetch and parse the subcatalog referenced by an entry
- *
+ *
* Returns 0 in case of success, -1 otherwise
*/
static int
xmlFetchXMLCatalogFile(xmlCatalogEntryPtr catal) {
xmlCatalogEntryPtr doc;
- if (catal == NULL)
+ if (catal == NULL)
return(-1);
if (catal->URL == NULL)
return(-1);
- if (catal->children != NULL)
- return(-1);
/*
* lock the whole catalog for modification
@@ -1488,7 +1501,7 @@ xmlAddXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *type,
xmlCatalogEntryType typ;
int doregister = 0;
- if ((catal == NULL) ||
+ if ((catal == NULL) ||
((catal->type != XML_CATA_CATALOG) &&
(catal->type != XML_CATA_BROKEN_CATALOG)))
return(-1);
@@ -1541,7 +1554,7 @@ xmlAddXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *type,
NULL, catal->prefer, NULL);
if (doregister) {
catal->type = XML_CATA_CATALOG;
- cur = xmlHashLookup(xmlCatalogXMLFiles, catal->URL);
+ cur = (xmlCatalogEntryPtr)xmlHashLookup(xmlCatalogXMLFiles, catal->URL);
if (cur != NULL)
cur->children = catal->children;
}
@@ -1564,7 +1577,7 @@ xmlDelXMLCatalog(xmlCatalogEntryPtr catal, const xmlChar *value) {
xmlCatalogEntryPtr cur;
int ret = 0;
- if ((catal == NULL) ||
+ if ((catal == NULL) ||
((catal->type != XML_CATA_CATALOG) &&
(catal->type != XML_CATA_BROKEN_CATALOG)))
return(-1);
@@ -1779,7 +1792,7 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
}
if (nbList < MAX_DELEGATE)
delegates[nbList++] = cur->URL;
-
+
if (cur->children == NULL) {
xmlFetchXMLCatalogFile(cur);
}
@@ -1816,6 +1829,8 @@ xmlCatalogXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
if (ret != NULL) {
catal->depth--;
return(ret);
+ } else if (catal->depth > MAX_CATAL_DEPTH) {
+ return(NULL);
}
}
}
@@ -1856,6 +1871,13 @@ xmlCatalogXMLResolveURI(xmlCatalogEntryPtr catal, const xmlChar *URI) {
if (URI == NULL)
return(NULL);
+ if (catal->depth > MAX_CATAL_DEPTH) {
+ xmlCatalogErr(catal, NULL, XML_CATALOG_RECURSION,
+ "Detected recursion in catalog %s\n",
+ catal->name, NULL, NULL);
+ return(NULL);
+ }
+
/*
* First tries steps 2/ 3/ 4/ if a system ID is provided.
*/
@@ -1983,7 +2005,7 @@ xmlCatalogListXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
xmlChar *ret = NULL;
xmlChar *urnID = NULL;
xmlChar *normid;
-
+
if (catal == NULL)
return(NULL);
if ((pubID == NULL) && (sysID == NULL))
@@ -1992,7 +2014,7 @@ xmlCatalogListXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
normid = xmlCatalogNormalizePublic(pubID);
if (normid != NULL)
pubID = (*normid != 0 ? normid : NULL);
-
+
if (!xmlStrncmp(pubID, BAD_CAST XML_URN_PUBID, sizeof(XML_URN_PUBID) - 1)) {
urnID = xmlCatalogUnWrapURN(pubID);
if (xmlDebugCatalogs) {
@@ -2041,16 +2063,18 @@ xmlCatalogListXMLResolve(xmlCatalogEntryPtr catal, const xmlChar *pubID,
if (catal->children != NULL) {
ret = xmlCatalogXMLResolve(catal->children, pubID, sysID);
if (ret != NULL) {
- if (normid != NULL)
- xmlFree(normid);
- return(ret);
- }
+ break;
+ } else if ((catal->children != NULL) &&
+ (catal->children->depth > MAX_CATAL_DEPTH)) {
+ ret = NULL;
+ break;
+ }
}
}
catal = catal->next;
}
- if (normid != NULL)
- xmlFree(normid);
+ if (normid != NULL)
+ xmlFree(normid);
return(ret);
}
@@ -2070,7 +2094,7 @@ static xmlChar *
xmlCatalogListXMLResolveURI(xmlCatalogEntryPtr catal, const xmlChar *URI) {
xmlChar *ret = NULL;
xmlChar *urnID = NULL;
-
+
if (catal == NULL)
return(NULL);
if (URI == NULL)
@@ -2130,7 +2154,7 @@ xmlCatalogListXMLResolveURI(xmlCatalogEntryPtr catal, const xmlChar *URI) {
*/
static const xmlChar *
xmlParseSGMLCatalogComment(const xmlChar *cur) {
- if ((cur[0] != '-') || (cur[1] != '-'))
+ if ((cur[0] != '-') || (cur[1] != '-'))
return(cur);
SKIP(2);
while ((cur[0] != 0) && ((cur[0] != '-') || ((cur[1] != '-'))))
@@ -2593,6 +2617,8 @@ xmlCatalogSGMLResolve(xmlCatalogPtr catal, const xmlChar *pubID,
return(ret);
if (sysID != NULL)
ret = xmlCatalogGetSGMLSystem(catal->sgml, sysID);
+ if (ret != NULL)
+ return(ret);
return(NULL);
}
@@ -2663,7 +2689,7 @@ xmlLoadACatalog(const char *filename)
first = content;
-
+
while ((*first != 0) && (*first != '-') && (*first != '<') &&
(!(((*first >= 'A') && (*first <= 'Z')) ||
((*first >= 'a') && (*first <= 'z')))))
@@ -2758,7 +2784,7 @@ xmlACatalogResolveSystem(xmlCatalogPtr catal, const xmlChar *sysID) {
if ((sysID == NULL) || (catal == NULL))
return(NULL);
-
+
if (xmlDebugCatalogs)
xmlGenericError(xmlGenericErrorContext,
"Resolve sysID %s\n", sysID);
@@ -2793,7 +2819,7 @@ xmlACatalogResolvePublic(xmlCatalogPtr catal, const xmlChar *pubID) {
if ((pubID == NULL) || (catal == NULL))
return(NULL);
-
+
if (xmlDebugCatalogs)
xmlGenericError(xmlGenericErrorContext,
"Resolve pubID %s\n", pubID);
@@ -2889,7 +2915,7 @@ xmlACatalogResolveURI(xmlCatalogPtr catal, const xmlChar *URI) {
sgml = xmlCatalogSGMLResolve(catal, NULL, URI);
if (sgml != NULL)
- sgml = xmlStrdup(sgml);
+ ret = xmlStrdup(sgml);
}
return(ret);
}
@@ -2912,7 +2938,7 @@ xmlACatalogDump(xmlCatalogPtr catal, FILE *out) {
} else {
xmlHashScan(catal->sgml,
(xmlHashScanner) xmlCatalogDumpEntry, out);
- }
+ }
}
#endif /* LIBXML_OUTPUT_ENABLED */
@@ -2920,7 +2946,7 @@ xmlACatalogDump(xmlCatalogPtr catal, FILE *out) {
* xmlACatalogAdd:
* @catal: a Catalog
* @type: the type of record to add to the catalog
- * @orig: the system, public or prefix to match
+ * @orig: the system, public or prefix to match
* @replace: the replacement value for the match
*
* Add an entry in the catalog, it may overwrite existing but
@@ -2979,7 +3005,7 @@ xmlACatalogRemove(xmlCatalogPtr catal, const xmlChar *value) {
(xmlHashDeallocator) xmlFreeCatalogEntry);
if (res == 0)
res = 1;
- }
+ }
return(res);
}
@@ -3038,7 +3064,7 @@ xmlCatalogIsEmpty(xmlCatalogPtr catal) {
return(1);
if (res < 0)
return(-1);
- }
+ }
return(0);
}
@@ -3061,7 +3087,7 @@ xmlInitializeCatalogData(void) {
if (xmlCatalogInitialized != 0)
return;
- if (getenv("XML_DEBUG_CATALOG"))
+ if (getenv("XML_DEBUG_CATALOG"))
xmlDebugCatalogs = 1;
xmlCatalogMutex = xmlNewRMutex();
@@ -3082,7 +3108,7 @@ xmlInitializeCatalog(void) {
xmlInitializeCatalogData();
xmlRMutexLock(xmlCatalogMutex);
- if (getenv("XML_DEBUG_CATALOG"))
+ if (getenv("XML_DEBUG_CATALOG"))
xmlDebugCatalogs = 1;
if (xmlDefaultCatalog == NULL) {
@@ -3105,12 +3131,12 @@ xmlInitializeCatalog(void) {
unsigned long len = GetModuleFileNameA(hmodule, buf, 255);
if (len != 0) {
char* p = &(buf[len]);
- while (*p != '\\' && p > buf)
+ while (*p != '\\' && p > buf)
p--;
if (p != buf) {
xmlChar* uri;
strncpy(p, "\\..\\etc\\catalog", 255 - (p - buf));
- uri = xmlCanonicPath(buf);
+ uri = xmlCanonicPath((const xmlChar*)buf);
if (uri != NULL) {
strncpy(XML_XML_DEFAULT_CATALOG, uri, 255);
xmlFree(uri);
@@ -3124,15 +3150,15 @@ xmlInitializeCatalog(void) {
catalogs = XML_XML_DEFAULT_CATALOG;
#endif
- catal = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE,
+ catal = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE,
xmlCatalogDefaultPrefer);
if (catal != NULL) {
- /* the XML_CATALOG_FILES envvar is allowed to contain a
+ /* the XML_CATALOG_FILES envvar is allowed to contain a
space-separated list of entries. */
cur = catalogs;
nextent = &catal->xml;
while (*cur != '\0') {
- while (xmlIsBlank_ch(*cur))
+ while (xmlIsBlank_ch(*cur))
cur++;
if (*cur != 0) {
paths = cur;
@@ -3209,6 +3235,9 @@ xmlLoadCatalogs(const char *pathss) {
const char *cur;
const char *paths;
xmlChar *path;
+#ifdef _WIN32
+ int i, iLen;
+#endif
if (pathss == NULL)
return;
@@ -3218,15 +3247,23 @@ xmlLoadCatalogs(const char *pathss) {
while (xmlIsBlank_ch(*cur)) cur++;
if (*cur != 0) {
paths = cur;
- while ((*cur != 0) && (*cur != ':') && (!xmlIsBlank_ch(*cur)))
+ while ((*cur != 0) && (*cur != PATH_SEAPARATOR) && (!xmlIsBlank_ch(*cur)))
cur++;
path = xmlStrndup((const xmlChar *)paths, cur - paths);
+#ifdef _WIN32
+ iLen = strlen((const char*)path);
+ for(i = 0; i < iLen; i++) {
+ if(path[i] == '\\') {
+ path[i] = '/';
+ }
+ }
+#endif
if (path != NULL) {
xmlLoadCatalog((const char *) path);
xmlFree(path);
}
}
- while (*cur == ':')
+ while (*cur == PATH_SEAPARATOR)
cur++;
}
}
@@ -3246,7 +3283,7 @@ xmlCatalogCleanup(void) {
xmlGenericError(xmlGenericErrorContext,
"Catalogs cleanup\n");
if (xmlCatalogXMLFiles != NULL)
- xmlHashFree(xmlCatalogXMLFiles,
+ xmlHashFree(xmlCatalogXMLFiles,
(xmlHashDeallocator)xmlFreeCatalogHashEntryList);
xmlCatalogXMLFiles = NULL;
if (xmlDefaultCatalog != NULL)
@@ -3361,7 +3398,7 @@ xmlCatalogDump(FILE *out) {
/**
* xmlCatalogAdd:
* @type: the type of record to add to the catalog
- * @orig: the system, public or prefix to match
+ * @orig: the system, public or prefix to match
* @replace: the replacement value for the match
*
* Add an entry in the catalog, it may overwrite existing but
@@ -3392,7 +3429,7 @@ xmlCatalogAdd(const xmlChar *type, const xmlChar *orig, const xmlChar *replace)
xmlRMutexUnlock(xmlCatalogMutex);
return(0);
- }
+ }
res = xmlACatalogAdd(xmlDefaultCatalog, type, orig, replace);
xmlRMutexUnlock(xmlCatalogMutex);
@@ -3518,8 +3555,8 @@ xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer) {
xmlGenericError(xmlGenericErrorContext,
"Setting catalog preference to SYSTEM\n");
break;
- case XML_CATA_PREFER_NONE:
- break;
+ default:
+ return(ret);
}
}
xmlCatalogDefaultPrefer = prefer;
@@ -3580,7 +3617,7 @@ xmlCatalogFreeLocal(void *catalogs) {
*
* Returns the updated list
*/
-void *
+void *
xmlCatalogAddLocal(void *catalogs, const xmlChar *URL) {
xmlCatalogEntryPtr catal, add;
@@ -3600,7 +3637,7 @@ xmlCatalogAddLocal(void *catalogs, const xmlChar *URL) {
return(catalogs);
catal = (xmlCatalogEntryPtr) catalogs;
- if (catal == NULL)
+ if (catal == NULL)
return((void *) add);
while (catal->next != NULL)
@@ -3615,7 +3652,7 @@ xmlCatalogAddLocal(void *catalogs, const xmlChar *URL) {
* @pubID: the public ID string
* @sysID: the system ID string
*
- * Do a complete resolution lookup of an External Identifier using a
+ * Do a complete resolution lookup of an External Identifier using a
* document's private catalog list
*
* Returns the URI of the resource or NULL if not found, it must be freed
@@ -3660,7 +3697,7 @@ xmlCatalogLocalResolve(void *catalogs, const xmlChar *pubID,
* @catalogs: a document's list of catalogs
* @URI: the URI
*
- * Do a complete resolution lookup of an URI using a
+ * Do a complete resolution lookup of an URI using a
* document's private catalog list
*
* Returns the URI of the resource or NULL if not found, it must be freed
@@ -3721,7 +3758,7 @@ xmlCatalogGetSystem(const xmlChar *sysID) {
if (sysID == NULL)
return(NULL);
-
+
/*
* Check first the XML catalogs
*/
@@ -3765,7 +3802,7 @@ xmlCatalogGetPublic(const xmlChar *pubID) {
if (pubID == NULL)
return(NULL);
-
+
/*
* Check first the XML catalogs
*/
diff --git a/gnulib-local/lib/libxml/catalog.in.h b/gnulib-local/lib/libxml/catalog.in.h
index b444137..5a13f51 100644
--- a/gnulib-local/lib/libxml/catalog.in.h
+++ b/gnulib-local/lib/libxml/catalog.in.h
@@ -68,111 +68,111 @@ typedef xmlCatalog *xmlCatalogPtr;
*/
XMLPUBFUN xmlCatalogPtr XMLCALL
xmlNewCatalog (int sgml);
-XMLPUBFUN xmlCatalogPtr XMLCALL
+XMLPUBFUN xmlCatalogPtr XMLCALL
xmlLoadACatalog (const char *filename);
-XMLPUBFUN xmlCatalogPtr XMLCALL
+XMLPUBFUN xmlCatalogPtr XMLCALL
xmlLoadSGMLSuperCatalog (const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlConvertSGMLCatalog (xmlCatalogPtr catal);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlACatalogAdd (xmlCatalogPtr catal,
const xmlChar *type,
const xmlChar *orig,
const xmlChar *replace);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlACatalogRemove (xmlCatalogPtr catal,
const xmlChar *value);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlACatalogResolve (xmlCatalogPtr catal,
const xmlChar *pubID,
const xmlChar *sysID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlACatalogResolveSystem(xmlCatalogPtr catal,
const xmlChar *sysID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlACatalogResolvePublic(xmlCatalogPtr catal,
const xmlChar *pubID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlACatalogResolveURI (xmlCatalogPtr catal,
const xmlChar *URI);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlACatalogDump (xmlCatalogPtr catal,
FILE *out);
#endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeCatalog (xmlCatalogPtr catal);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlCatalogIsEmpty (xmlCatalogPtr catal);
/*
* Global operations.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlInitializeCatalog (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlLoadCatalog (const char *filename);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlLoadCatalogs (const char *paths);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCatalogCleanup (void);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCatalogDump (FILE *out);
#endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlCatalogResolve (const xmlChar *pubID,
const xmlChar *sysID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlCatalogResolveSystem (const xmlChar *sysID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlCatalogResolvePublic (const xmlChar *pubID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlCatalogResolveURI (const xmlChar *URI);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlCatalogAdd (const xmlChar *type,
const xmlChar *orig,
const xmlChar *replace);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlCatalogRemove (const xmlChar *value);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlParseCatalogFile (const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlCatalogConvert (void);
/*
* Strictly minimal interfaces for per-document catalogs used
* by the parser.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCatalogFreeLocal (void *catalogs);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlCatalogAddLocal (void *catalogs,
const xmlChar *URL);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlCatalogLocalResolve (void *catalogs,
const xmlChar *pubID,
const xmlChar *sysID);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlCatalogLocalResolveURI(void *catalogs,
const xmlChar *URI);
/*
* Preference settings.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlCatalogSetDebug (int level);
-XMLPUBFUN xmlCatalogPrefer XMLCALL
+XMLPUBFUN xmlCatalogPrefer XMLCALL
xmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCatalogSetDefaults (xmlCatalogAllow allow);
-XMLPUBFUN xmlCatalogAllow XMLCALL
+XMLPUBFUN xmlCatalogAllow XMLCALL
xmlCatalogGetDefaults (void);
/* DEPRECATED interfaces */
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlCatalogGetSystem (const xmlChar *sysID);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlCatalogGetPublic (const xmlChar *pubID);
#ifdef __cplusplus
diff --git a/gnulib-local/lib/libxml/chvalid.c b/gnulib-local/lib/libxml/chvalid.c
index 00dd962..06e8db0 100644
--- a/gnulib-local/lib/libxml/chvalid.c
+++ b/gnulib-local/lib/libxml/chvalid.c
@@ -46,109 +46,109 @@ const unsigned char xmlIsPubidChar_tab[256] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00 };
-static const xmlChSRange xmlIsBaseChar_srng[] = { {0x100, 0x131},
- {0x134, 0x13e}, {0x141, 0x148}, {0x14a, 0x17e}, {0x180, 0x1c3},
- {0x1cd, 0x1f0}, {0x1f4, 0x1f5}, {0x1fa, 0x217}, {0x250, 0x2a8},
- {0x2bb, 0x2c1}, {0x386, 0x386}, {0x388, 0x38a}, {0x38c, 0x38c},
- {0x38e, 0x3a1}, {0x3a3, 0x3ce}, {0x3d0, 0x3d6}, {0x3da, 0x3da},
- {0x3dc, 0x3dc}, {0x3de, 0x3de}, {0x3e0, 0x3e0}, {0x3e2, 0x3f3},
- {0x401, 0x40c}, {0x40e, 0x44f}, {0x451, 0x45c}, {0x45e, 0x481},
- {0x490, 0x4c4}, {0x4c7, 0x4c8}, {0x4cb, 0x4cc}, {0x4d0, 0x4eb},
- {0x4ee, 0x4f5}, {0x4f8, 0x4f9}, {0x531, 0x556}, {0x559, 0x559},
- {0x561, 0x586}, {0x5d0, 0x5ea}, {0x5f0, 0x5f2}, {0x621, 0x63a},
- {0x641, 0x64a}, {0x671, 0x6b7}, {0x6ba, 0x6be}, {0x6c0, 0x6ce},
- {0x6d0, 0x6d3}, {0x6d5, 0x6d5}, {0x6e5, 0x6e6}, {0x905, 0x939},
- {0x93d, 0x93d}, {0x958, 0x961}, {0x985, 0x98c}, {0x98f, 0x990},
- {0x993, 0x9a8}, {0x9aa, 0x9b0}, {0x9b2, 0x9b2}, {0x9b6, 0x9b9},
- {0x9dc, 0x9dd}, {0x9df, 0x9e1}, {0x9f0, 0x9f1}, {0xa05, 0xa0a},
- {0xa0f, 0xa10}, {0xa13, 0xa28}, {0xa2a, 0xa30}, {0xa32, 0xa33},
- {0xa35, 0xa36}, {0xa38, 0xa39}, {0xa59, 0xa5c}, {0xa5e, 0xa5e},
- {0xa72, 0xa74}, {0xa85, 0xa8b}, {0xa8d, 0xa8d}, {0xa8f, 0xa91},
- {0xa93, 0xaa8}, {0xaaa, 0xab0}, {0xab2, 0xab3}, {0xab5, 0xab9},
- {0xabd, 0xabd}, {0xae0, 0xae0}, {0xb05, 0xb0c}, {0xb0f, 0xb10},
- {0xb13, 0xb28}, {0xb2a, 0xb30}, {0xb32, 0xb33}, {0xb36, 0xb39},
- {0xb3d, 0xb3d}, {0xb5c, 0xb5d}, {0xb5f, 0xb61}, {0xb85, 0xb8a},
- {0xb8e, 0xb90}, {0xb92, 0xb95}, {0xb99, 0xb9a}, {0xb9c, 0xb9c},
- {0xb9e, 0xb9f}, {0xba3, 0xba4}, {0xba8, 0xbaa}, {0xbae, 0xbb5},
- {0xbb7, 0xbb9}, {0xc05, 0xc0c}, {0xc0e, 0xc10}, {0xc12, 0xc28},
- {0xc2a, 0xc33}, {0xc35, 0xc39}, {0xc60, 0xc61}, {0xc85, 0xc8c},
- {0xc8e, 0xc90}, {0xc92, 0xca8}, {0xcaa, 0xcb3}, {0xcb5, 0xcb9},
- {0xcde, 0xcde}, {0xce0, 0xce1}, {0xd05, 0xd0c}, {0xd0e, 0xd10},
- {0xd12, 0xd28}, {0xd2a, 0xd39}, {0xd60, 0xd61}, {0xe01, 0xe2e},
- {0xe30, 0xe30}, {0xe32, 0xe33}, {0xe40, 0xe45}, {0xe81, 0xe82},
- {0xe84, 0xe84}, {0xe87, 0xe88}, {0xe8a, 0xe8a}, {0xe8d, 0xe8d},
- {0xe94, 0xe97}, {0xe99, 0xe9f}, {0xea1, 0xea3}, {0xea5, 0xea5},
- {0xea7, 0xea7}, {0xeaa, 0xeab}, {0xead, 0xeae}, {0xeb0, 0xeb0},
- {0xeb2, 0xeb3}, {0xebd, 0xebd}, {0xec0, 0xec4}, {0xf40, 0xf47},
- {0xf49, 0xf69}, {0x10a0, 0x10c5}, {0x10d0, 0x10f6}, {0x1100, 0x1100},
- {0x1102, 0x1103}, {0x1105, 0x1107}, {0x1109, 0x1109}, {0x110b, 0x110c},
- {0x110e, 0x1112}, {0x113c, 0x113c}, {0x113e, 0x113e}, {0x1140, 0x1140},
- {0x114c, 0x114c}, {0x114e, 0x114e}, {0x1150, 0x1150}, {0x1154, 0x1155},
- {0x1159, 0x1159}, {0x115f, 0x1161}, {0x1163, 0x1163}, {0x1165, 0x1165},
- {0x1167, 0x1167}, {0x1169, 0x1169}, {0x116d, 0x116e}, {0x1172, 0x1173},
- {0x1175, 0x1175}, {0x119e, 0x119e}, {0x11a8, 0x11a8}, {0x11ab, 0x11ab},
- {0x11ae, 0x11af}, {0x11b7, 0x11b8}, {0x11ba, 0x11ba}, {0x11bc, 0x11c2},
- {0x11eb, 0x11eb}, {0x11f0, 0x11f0}, {0x11f9, 0x11f9}, {0x1e00, 0x1e9b},
- {0x1ea0, 0x1ef9}, {0x1f00, 0x1f15}, {0x1f18, 0x1f1d}, {0x1f20, 0x1f45},
- {0x1f48, 0x1f4d}, {0x1f50, 0x1f57}, {0x1f59, 0x1f59}, {0x1f5b, 0x1f5b},
- {0x1f5d, 0x1f5d}, {0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4}, {0x1fb6, 0x1fbc},
- {0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4}, {0x1fc6, 0x1fcc}, {0x1fd0, 0x1fd3},
- {0x1fd6, 0x1fdb}, {0x1fe0, 0x1fec}, {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffc},
- {0x2126, 0x2126}, {0x212a, 0x212b}, {0x212e, 0x212e}, {0x2180, 0x2182},
+static const xmlChSRange xmlIsBaseChar_srng[] = { {0x100, 0x131},
+ {0x134, 0x13e}, {0x141, 0x148}, {0x14a, 0x17e}, {0x180, 0x1c3},
+ {0x1cd, 0x1f0}, {0x1f4, 0x1f5}, {0x1fa, 0x217}, {0x250, 0x2a8},
+ {0x2bb, 0x2c1}, {0x386, 0x386}, {0x388, 0x38a}, {0x38c, 0x38c},
+ {0x38e, 0x3a1}, {0x3a3, 0x3ce}, {0x3d0, 0x3d6}, {0x3da, 0x3da},
+ {0x3dc, 0x3dc}, {0x3de, 0x3de}, {0x3e0, 0x3e0}, {0x3e2, 0x3f3},
+ {0x401, 0x40c}, {0x40e, 0x44f}, {0x451, 0x45c}, {0x45e, 0x481},
+ {0x490, 0x4c4}, {0x4c7, 0x4c8}, {0x4cb, 0x4cc}, {0x4d0, 0x4eb},
+ {0x4ee, 0x4f5}, {0x4f8, 0x4f9}, {0x531, 0x556}, {0x559, 0x559},
+ {0x561, 0x586}, {0x5d0, 0x5ea}, {0x5f0, 0x5f2}, {0x621, 0x63a},
+ {0x641, 0x64a}, {0x671, 0x6b7}, {0x6ba, 0x6be}, {0x6c0, 0x6ce},
+ {0x6d0, 0x6d3}, {0x6d5, 0x6d5}, {0x6e5, 0x6e6}, {0x905, 0x939},
+ {0x93d, 0x93d}, {0x958, 0x961}, {0x985, 0x98c}, {0x98f, 0x990},
+ {0x993, 0x9a8}, {0x9aa, 0x9b0}, {0x9b2, 0x9b2}, {0x9b6, 0x9b9},
+ {0x9dc, 0x9dd}, {0x9df, 0x9e1}, {0x9f0, 0x9f1}, {0xa05, 0xa0a},
+ {0xa0f, 0xa10}, {0xa13, 0xa28}, {0xa2a, 0xa30}, {0xa32, 0xa33},
+ {0xa35, 0xa36}, {0xa38, 0xa39}, {0xa59, 0xa5c}, {0xa5e, 0xa5e},
+ {0xa72, 0xa74}, {0xa85, 0xa8b}, {0xa8d, 0xa8d}, {0xa8f, 0xa91},
+ {0xa93, 0xaa8}, {0xaaa, 0xab0}, {0xab2, 0xab3}, {0xab5, 0xab9},
+ {0xabd, 0xabd}, {0xae0, 0xae0}, {0xb05, 0xb0c}, {0xb0f, 0xb10},
+ {0xb13, 0xb28}, {0xb2a, 0xb30}, {0xb32, 0xb33}, {0xb36, 0xb39},
+ {0xb3d, 0xb3d}, {0xb5c, 0xb5d}, {0xb5f, 0xb61}, {0xb85, 0xb8a},
+ {0xb8e, 0xb90}, {0xb92, 0xb95}, {0xb99, 0xb9a}, {0xb9c, 0xb9c},
+ {0xb9e, 0xb9f}, {0xba3, 0xba4}, {0xba8, 0xbaa}, {0xbae, 0xbb5},
+ {0xbb7, 0xbb9}, {0xc05, 0xc0c}, {0xc0e, 0xc10}, {0xc12, 0xc28},
+ {0xc2a, 0xc33}, {0xc35, 0xc39}, {0xc60, 0xc61}, {0xc85, 0xc8c},
+ {0xc8e, 0xc90}, {0xc92, 0xca8}, {0xcaa, 0xcb3}, {0xcb5, 0xcb9},
+ {0xcde, 0xcde}, {0xce0, 0xce1}, {0xd05, 0xd0c}, {0xd0e, 0xd10},
+ {0xd12, 0xd28}, {0xd2a, 0xd39}, {0xd60, 0xd61}, {0xe01, 0xe2e},
+ {0xe30, 0xe30}, {0xe32, 0xe33}, {0xe40, 0xe45}, {0xe81, 0xe82},
+ {0xe84, 0xe84}, {0xe87, 0xe88}, {0xe8a, 0xe8a}, {0xe8d, 0xe8d},
+ {0xe94, 0xe97}, {0xe99, 0xe9f}, {0xea1, 0xea3}, {0xea5, 0xea5},
+ {0xea7, 0xea7}, {0xeaa, 0xeab}, {0xead, 0xeae}, {0xeb0, 0xeb0},
+ {0xeb2, 0xeb3}, {0xebd, 0xebd}, {0xec0, 0xec4}, {0xf40, 0xf47},
+ {0xf49, 0xf69}, {0x10a0, 0x10c5}, {0x10d0, 0x10f6}, {0x1100, 0x1100},
+ {0x1102, 0x1103}, {0x1105, 0x1107}, {0x1109, 0x1109}, {0x110b, 0x110c},
+ {0x110e, 0x1112}, {0x113c, 0x113c}, {0x113e, 0x113e}, {0x1140, 0x1140},
+ {0x114c, 0x114c}, {0x114e, 0x114e}, {0x1150, 0x1150}, {0x1154, 0x1155},
+ {0x1159, 0x1159}, {0x115f, 0x1161}, {0x1163, 0x1163}, {0x1165, 0x1165},
+ {0x1167, 0x1167}, {0x1169, 0x1169}, {0x116d, 0x116e}, {0x1172, 0x1173},
+ {0x1175, 0x1175}, {0x119e, 0x119e}, {0x11a8, 0x11a8}, {0x11ab, 0x11ab},
+ {0x11ae, 0x11af}, {0x11b7, 0x11b8}, {0x11ba, 0x11ba}, {0x11bc, 0x11c2},
+ {0x11eb, 0x11eb}, {0x11f0, 0x11f0}, {0x11f9, 0x11f9}, {0x1e00, 0x1e9b},
+ {0x1ea0, 0x1ef9}, {0x1f00, 0x1f15}, {0x1f18, 0x1f1d}, {0x1f20, 0x1f45},
+ {0x1f48, 0x1f4d}, {0x1f50, 0x1f57}, {0x1f59, 0x1f59}, {0x1f5b, 0x1f5b},
+ {0x1f5d, 0x1f5d}, {0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4}, {0x1fb6, 0x1fbc},
+ {0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4}, {0x1fc6, 0x1fcc}, {0x1fd0, 0x1fd3},
+ {0x1fd6, 0x1fdb}, {0x1fe0, 0x1fec}, {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffc},
+ {0x2126, 0x2126}, {0x212a, 0x212b}, {0x212e, 0x212e}, {0x2180, 0x2182},
{0x3041, 0x3094}, {0x30a1, 0x30fa}, {0x3105, 0x312c}, {0xac00, 0xd7a3}};
const xmlChRangeGroup xmlIsBaseCharGroup =
{197, 0, xmlIsBaseChar_srng, (xmlChLRangePtr)0};
-static const xmlChSRange xmlIsChar_srng[] = { {0x100, 0xd7ff},
+static const xmlChSRange xmlIsChar_srng[] = { {0x100, 0xd7ff},
{0xe000, 0xfffd}};
static const xmlChLRange xmlIsChar_lrng[] = { {0x10000, 0x10ffff}};
const xmlChRangeGroup xmlIsCharGroup =
{2, 1, xmlIsChar_srng, xmlIsChar_lrng};
-static const xmlChSRange xmlIsCombining_srng[] = { {0x300, 0x345},
- {0x360, 0x361}, {0x483, 0x486}, {0x591, 0x5a1}, {0x5a3, 0x5b9},
- {0x5bb, 0x5bd}, {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c4},
- {0x64b, 0x652}, {0x670, 0x670}, {0x6d6, 0x6dc}, {0x6dd, 0x6df},
- {0x6e0, 0x6e4}, {0x6e7, 0x6e8}, {0x6ea, 0x6ed}, {0x901, 0x903},
- {0x93c, 0x93c}, {0x93e, 0x94c}, {0x94d, 0x94d}, {0x951, 0x954},
- {0x962, 0x963}, {0x981, 0x983}, {0x9bc, 0x9bc}, {0x9be, 0x9be},
- {0x9bf, 0x9bf}, {0x9c0, 0x9c4}, {0x9c7, 0x9c8}, {0x9cb, 0x9cd},
- {0x9d7, 0x9d7}, {0x9e2, 0x9e3}, {0xa02, 0xa02}, {0xa3c, 0xa3c},
- {0xa3e, 0xa3e}, {0xa3f, 0xa3f}, {0xa40, 0xa42}, {0xa47, 0xa48},
- {0xa4b, 0xa4d}, {0xa70, 0xa71}, {0xa81, 0xa83}, {0xabc, 0xabc},
- {0xabe, 0xac5}, {0xac7, 0xac9}, {0xacb, 0xacd}, {0xb01, 0xb03},
- {0xb3c, 0xb3c}, {0xb3e, 0xb43}, {0xb47, 0xb48}, {0xb4b, 0xb4d},
- {0xb56, 0xb57}, {0xb82, 0xb83}, {0xbbe, 0xbc2}, {0xbc6, 0xbc8},
- {0xbca, 0xbcd}, {0xbd7, 0xbd7}, {0xc01, 0xc03}, {0xc3e, 0xc44},
- {0xc46, 0xc48}, {0xc4a, 0xc4d}, {0xc55, 0xc56}, {0xc82, 0xc83},
- {0xcbe, 0xcc4}, {0xcc6, 0xcc8}, {0xcca, 0xccd}, {0xcd5, 0xcd6},
- {0xd02, 0xd03}, {0xd3e, 0xd43}, {0xd46, 0xd48}, {0xd4a, 0xd4d},
- {0xd57, 0xd57}, {0xe31, 0xe31}, {0xe34, 0xe3a}, {0xe47, 0xe4e},
- {0xeb1, 0xeb1}, {0xeb4, 0xeb9}, {0xebb, 0xebc}, {0xec8, 0xecd},
- {0xf18, 0xf19}, {0xf35, 0xf35}, {0xf37, 0xf37}, {0xf39, 0xf39},
- {0xf3e, 0xf3e}, {0xf3f, 0xf3f}, {0xf71, 0xf84}, {0xf86, 0xf8b},
- {0xf90, 0xf95}, {0xf97, 0xf97}, {0xf99, 0xfad}, {0xfb1, 0xfb7},
- {0xfb9, 0xfb9}, {0x20d0, 0x20dc}, {0x20e1, 0x20e1}, {0x302a, 0x302f},
+static const xmlChSRange xmlIsCombining_srng[] = { {0x300, 0x345},
+ {0x360, 0x361}, {0x483, 0x486}, {0x591, 0x5a1}, {0x5a3, 0x5b9},
+ {0x5bb, 0x5bd}, {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c4},
+ {0x64b, 0x652}, {0x670, 0x670}, {0x6d6, 0x6dc}, {0x6dd, 0x6df},
+ {0x6e0, 0x6e4}, {0x6e7, 0x6e8}, {0x6ea, 0x6ed}, {0x901, 0x903},
+ {0x93c, 0x93c}, {0x93e, 0x94c}, {0x94d, 0x94d}, {0x951, 0x954},
+ {0x962, 0x963}, {0x981, 0x983}, {0x9bc, 0x9bc}, {0x9be, 0x9be},
+ {0x9bf, 0x9bf}, {0x9c0, 0x9c4}, {0x9c7, 0x9c8}, {0x9cb, 0x9cd},
+ {0x9d7, 0x9d7}, {0x9e2, 0x9e3}, {0xa02, 0xa02}, {0xa3c, 0xa3c},
+ {0xa3e, 0xa3e}, {0xa3f, 0xa3f}, {0xa40, 0xa42}, {0xa47, 0xa48},
+ {0xa4b, 0xa4d}, {0xa70, 0xa71}, {0xa81, 0xa83}, {0xabc, 0xabc},
+ {0xabe, 0xac5}, {0xac7, 0xac9}, {0xacb, 0xacd}, {0xb01, 0xb03},
+ {0xb3c, 0xb3c}, {0xb3e, 0xb43}, {0xb47, 0xb48}, {0xb4b, 0xb4d},
+ {0xb56, 0xb57}, {0xb82, 0xb83}, {0xbbe, 0xbc2}, {0xbc6, 0xbc8},
+ {0xbca, 0xbcd}, {0xbd7, 0xbd7}, {0xc01, 0xc03}, {0xc3e, 0xc44},
+ {0xc46, 0xc48}, {0xc4a, 0xc4d}, {0xc55, 0xc56}, {0xc82, 0xc83},
+ {0xcbe, 0xcc4}, {0xcc6, 0xcc8}, {0xcca, 0xccd}, {0xcd5, 0xcd6},
+ {0xd02, 0xd03}, {0xd3e, 0xd43}, {0xd46, 0xd48}, {0xd4a, 0xd4d},
+ {0xd57, 0xd57}, {0xe31, 0xe31}, {0xe34, 0xe3a}, {0xe47, 0xe4e},
+ {0xeb1, 0xeb1}, {0xeb4, 0xeb9}, {0xebb, 0xebc}, {0xec8, 0xecd},
+ {0xf18, 0xf19}, {0xf35, 0xf35}, {0xf37, 0xf37}, {0xf39, 0xf39},
+ {0xf3e, 0xf3e}, {0xf3f, 0xf3f}, {0xf71, 0xf84}, {0xf86, 0xf8b},
+ {0xf90, 0xf95}, {0xf97, 0xf97}, {0xf99, 0xfad}, {0xfb1, 0xfb7},
+ {0xfb9, 0xfb9}, {0x20d0, 0x20dc}, {0x20e1, 0x20e1}, {0x302a, 0x302f},
{0x3099, 0x3099}, {0x309a, 0x309a}};
const xmlChRangeGroup xmlIsCombiningGroup =
{95, 0, xmlIsCombining_srng, (xmlChLRangePtr)0};
-static const xmlChSRange xmlIsDigit_srng[] = { {0x660, 0x669},
- {0x6f0, 0x6f9}, {0x966, 0x96f}, {0x9e6, 0x9ef}, {0xa66, 0xa6f},
- {0xae6, 0xaef}, {0xb66, 0xb6f}, {0xbe7, 0xbef}, {0xc66, 0xc6f},
- {0xce6, 0xcef}, {0xd66, 0xd6f}, {0xe50, 0xe59}, {0xed0, 0xed9},
+static const xmlChSRange xmlIsDigit_srng[] = { {0x660, 0x669},
+ {0x6f0, 0x6f9}, {0x966, 0x96f}, {0x9e6, 0x9ef}, {0xa66, 0xa6f},
+ {0xae6, 0xaef}, {0xb66, 0xb6f}, {0xbe7, 0xbef}, {0xc66, 0xc6f},
+ {0xce6, 0xcef}, {0xd66, 0xd6f}, {0xe50, 0xe59}, {0xed0, 0xed9},
{0xf20, 0xf29}};
const xmlChRangeGroup xmlIsDigitGroup =
{14, 0, xmlIsDigit_srng, (xmlChLRangePtr)0};
-static const xmlChSRange xmlIsExtender_srng[] = { {0x2d0, 0x2d0},
- {0x2d1, 0x2d1}, {0x387, 0x387}, {0x640, 0x640}, {0xe46, 0xe46},
- {0xec6, 0xec6}, {0x3005, 0x3005}, {0x3031, 0x3035}, {0x309d, 0x309e},
+static const xmlChSRange xmlIsExtender_srng[] = { {0x2d0, 0x2d0},
+ {0x2d1, 0x2d1}, {0x387, 0x387}, {0x640, 0x640}, {0xe46, 0xe46},
+ {0xec6, 0xec6}, {0x3005, 0x3005}, {0x3031, 0x3035}, {0x309d, 0x309e},
{0x30fc, 0x30fe}};
const xmlChRangeGroup xmlIsExtenderGroup =
{10, 0, xmlIsExtender_srng, (xmlChLRangePtr)0};
-static const xmlChSRange xmlIsIdeographic_srng[] = { {0x3007, 0x3007},
+static const xmlChSRange xmlIsIdeographic_srng[] = { {0x3007, 0x3007},
{0x3021, 0x3029}, {0x4e00, 0x9fa5}};
const xmlChRangeGroup xmlIsIdeographicGroup =
{3, 0, xmlIsIdeographic_srng, (xmlChLRangePtr)0};
diff --git a/gnulib-local/lib/libxml/debugXML.c b/gnulib-local/lib/libxml/debugXML.c
index 3985ad3..b05fdff 100644
--- a/gnulib-local/lib/libxml/debugXML.c
+++ b/gnulib-local/lib/libxml/debugXML.c
@@ -85,7 +85,7 @@ xmlCtxtDumpCleanCtxt(xmlDebugCtxtPtr ctxt ATTRIBUTE_UNUSED)
*
* Check that a given namespace is in scope on a node.
*
- * Returns 1 if in scope, -1 in case of argument error,
+ * Returns 1 if in scope, -1 in case of argument error,
* -2 if the namespace is not in scope, and -3 if not on
* an ancestor node.
*/
@@ -141,9 +141,9 @@ xmlCtxtDumpSpaces(xmlDebugCtxtPtr ctxt)
return;
if ((ctxt->output != NULL) && (ctxt->depth > 0)) {
if (ctxt->depth < 50)
- fprintf(ctxt->output, &ctxt->shift[100 - 2 * ctxt->depth]);
+ fprintf(ctxt->output, "%s", &ctxt->shift[100 - 2 * ctxt->depth]);
else
- fprintf(ctxt->output, ctxt->shift);
+ fprintf(ctxt->output, "%s", ctxt->shift);
}
}
@@ -162,7 +162,7 @@ xmlDebugErr(xmlDebugCtxtPtr ctxt, int error, const char *msg)
NULL, ctxt->node, XML_FROM_CHECK,
error, XML_ERR_ERROR, NULL, 0,
NULL, NULL, NULL, 0, 0,
- msg);
+ "%s", msg);
}
static void
xmlDebugErr2(xmlDebugCtxtPtr ctxt, int error, const char *msg, int extra)
@@ -254,12 +254,16 @@ xmlCtxtCheckName(xmlDebugCtxtPtr ctxt, const xmlChar * name)
xmlDebugErr(ctxt, XML_CHECK_NO_NAME, "Name is NULL");
return;
}
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
if (xmlValidateName(name, 0)) {
xmlDebugErr3(ctxt, XML_CHECK_NOT_NCNAME,
"Name is not an NCName '%s'", (const char *) name);
}
+#endif
if ((ctxt->dict != NULL) &&
- (!xmlDictOwns(ctxt->dict, name))) {
+ (!xmlDictOwns(ctxt->dict, name)) &&
+ ((ctxt->doc == NULL) ||
+ ((ctxt->doc->parseFlags & (XML_PARSE_SAX1 | XML_PARSE_NODICT)) == 0))) {
xmlDebugErr3(ctxt, XML_CHECK_OUTSIDE_DICT,
"Name is not from the document dictionnary '%s'",
(const char *) name);
@@ -309,7 +313,7 @@ xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
(node != (xmlNodePtr) node->parent->properties))
xmlDebugErr(ctxt, XML_CHECK_NO_PREV,
"Attr has no prev and not first of attr list\n");
-
+
} else if ((node->parent != NULL) && (node->parent->children != node))
xmlDebugErr(ctxt, XML_CHECK_NO_PREV,
"Node has no prev and not first of parent list\n");
@@ -320,7 +324,8 @@ xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
}
if (node->next == NULL) {
if ((node->parent != NULL) && (node->type != XML_ATTRIBUTE_NODE) &&
- (node->parent->last != node))
+ (node->parent->last != node) &&
+ (node->parent->type == XML_ELEMENT_NODE))
xmlDebugErr(ctxt, XML_CHECK_NO_NEXT,
"Node has no next and not last of parent list\n");
} else {
@@ -351,7 +356,6 @@ xmlCtxtGenericNodeCheck(xmlDebugCtxtPtr ctxt, xmlNodePtr node) {
(node->type != XML_ELEMENT_DECL) &&
(node->type != XML_ATTRIBUTE_DECL) &&
(node->type != XML_DTD_NODE) &&
- (node->type != XML_ELEMENT_DECL) &&
(node->type != XML_HTML_DOCUMENT_NODE) &&
(node->type != XML_DOCUMENT_NODE)) {
if (node->content != NULL)
@@ -1065,7 +1069,7 @@ xmlCtxtDumpNode(xmlDebugCtxtPtr ctxt, xmlNodePtr node)
return;
}
xmlCtxtDumpOneNode(ctxt, node);
- if ((node->type != XML_NAMESPACE_DECL) &&
+ if ((node->type != XML_NAMESPACE_DECL) &&
(node->children != NULL) && (node->type != XML_ENTITY_REF_NODE)) {
ctxt->depth++;
xmlCtxtDumpNodeList(ctxt, node->children);
@@ -1600,7 +1604,7 @@ int
xmlLsCountNode(xmlNodePtr node) {
int ret = 0;
xmlNodePtr list = NULL;
-
+
if (node == NULL)
return(0);
@@ -1641,7 +1645,7 @@ xmlLsCountNode(xmlNodePtr node) {
ret = 1;
break;
}
- for (;list != NULL;ret++)
+ for (;list != NULL;ret++)
list = list->next;
return(ret);
}
@@ -1709,11 +1713,11 @@ xmlLsOneNode(FILE *output, xmlNodePtr node) {
if (node->type != XML_NAMESPACE_DECL) {
if (node->properties != NULL)
fprintf(output, "a");
- else
+ else
fprintf(output, "-");
- if (node->nsDef != NULL)
+ if (node->nsDef != NULL)
fprintf(output, "n");
- else
+ else
fprintf(output, "-");
}
@@ -1721,8 +1725,11 @@ xmlLsOneNode(FILE *output, xmlNodePtr node) {
switch (node->type) {
case XML_ELEMENT_NODE:
- if (node->name != NULL)
+ if (node->name != NULL) {
+ if ((node->ns != NULL) && (node->ns->prefix != NULL))
+ fprintf(output, "%s:", node->ns->prefix);
fprintf(output, "%s", (const char *) node->name);
+ }
break;
case XML_ATTRIBUTE_NODE:
if (node->name != NULL)
@@ -1780,7 +1787,7 @@ xmlLsOneNode(FILE *output, xmlNodePtr node) {
* xmlBoolToText:
* @boolval: a bool to turn into text
*
- * Convenient way to turn bool into text
+ * Convenient way to turn bool into text
*
* Returns a pointer to either "True" or "False"
*/
@@ -1796,7 +1803,7 @@ xmlBoolToText(int boolval)
#ifdef LIBXML_XPATH_ENABLED
/****************************************************************
* *
- * The XML shell related functions *
+ * The XML shell related functions *
* *
****************************************************************/
@@ -2047,7 +2054,7 @@ xmlShellBase(xmlShellCtxtPtr ctxt,
if (node == NULL) {
fprintf(ctxt->output, "NULL\n");
return (0);
- }
+ }
base = xmlNodeGetBase(node->doc, node);
@@ -2274,7 +2281,7 @@ xmlShellDir(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED,
if (node == NULL) {
fprintf(ctxt->output, "NULL\n");
return (0);
- }
+ }
if ((node->type == XML_DOCUMENT_NODE) ||
(node->type == XML_HTML_DOCUMENT_NODE)) {
xmlDebugDumpDocumentHead(ctxt->output, (xmlDocPtr) node);
@@ -2409,7 +2416,7 @@ xmlShellCat(xmlShellCtxtPtr ctxt, char *arg ATTRIBUTE_UNUSED,
if (node == NULL) {
fprintf(ctxt->output, "NULL\n");
return (0);
- }
+ }
if (ctxt->doc->type == XML_HTML_DOCUMENT_NODE) {
#ifdef LIBXML_HTML_ENABLED
if (node->type == XML_HTML_DOCUMENT_NODE)
@@ -2693,6 +2700,8 @@ xmlShellDu(xmlShellCtxtPtr ctxt,
} else if (node->type == XML_ELEMENT_NODE) {
for (i = 0; i < indent; i++)
fprintf(ctxt->output, " ");
+ if ((node->ns) && (node->ns->prefix))
+ fprintf(ctxt->output, "%s:", node->ns->prefix);
fprintf(ctxt->output, "%s\n", node->name);
} else {
}
@@ -2745,7 +2754,7 @@ xmlShellDu(xmlShellCtxtPtr ctxt,
* xmlShellPwd:
* @ctxt: the shell context
* @buffer: the output buffer
- * @node: a node
+ * @node: a node
* @node2: unused
*
* Implements the XML shell function "pwd"
@@ -2790,7 +2799,7 @@ xmlShellPwd(xmlShellCtxtPtr ctxt ATTRIBUTE_UNUSED, char *buffer,
* @input: the line reading function
* @output: the output FILE*, defaults to stdout if NULL
*
- * Implements the XML shell
+ * Implements the XML shell
* This allow to load, validate, view, modify and save a document
* using a environment similar to a UNIX commandline.
*/
@@ -2800,7 +2809,6 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
{
char prompt[500] = "/ > ";
char *cmdline = NULL, *cur;
- int nbargs;
char command[100];
char arg[400];
int i;
@@ -2835,6 +2843,10 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
while (1) {
if (ctxt->node == (xmlNodePtr) ctxt->doc)
snprintf(prompt, sizeof(prompt), "%s > ", "/");
+ else if ((ctxt->node != NULL) && (ctxt->node->name) &&
+ (ctxt->node->ns) && (ctxt->node->ns->prefix))
+ snprintf(prompt, sizeof(prompt), "%s:%s > ",
+ (ctxt->node->ns->prefix), ctxt->node->name);
else if ((ctxt->node != NULL) && (ctxt->node->name))
snprintf(prompt, sizeof(prompt), "%s > ", ctxt->node->name);
else
@@ -2852,7 +2864,6 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
* Parse the command itself
*/
cur = cmdline;
- nbargs = 0;
while ((*cur == ' ') || (*cur == '\t'))
cur++;
i = 0;
@@ -2865,7 +2876,6 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
command[i] = 0;
if (i == 0)
continue;
- nbargs++;
/*
* Parse the argument
@@ -2879,8 +2889,6 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
arg[i++] = *cur++;
}
arg[i] = 0;
- if (i != 0)
- nbargs++;
/*
* start interpreting the command
@@ -2913,6 +2921,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
fprintf(ctxt->output, "\t the default namespace if any uses 'defaultns' prefix\n");
#endif /* LIBXML_XPATH_ENABLED */
fprintf(ctxt->output, "\tpwd display current working directory\n");
+ fprintf(ctxt->output, "\twhereis display absolute path of [path] or current working directory\n");
fprintf(ctxt->output, "\tquit leave shell\n");
#ifdef LIBXML_OUTPUT_ENABLED
fprintf(ctxt->output, "\tsave [name] save this document to name or the original name\n");
@@ -2939,11 +2948,11 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
} else if (!strcmp(command, "save")) {
xmlShellSave(ctxt, arg, NULL, NULL);
} else if (!strcmp(command, "write")) {
- if ((arg == NULL) || (arg[0] == 0))
+ if (arg[0] == 0)
xmlGenericError(xmlGenericErrorContext,
"Write command requires a filename argument\n");
else
- xmlShellWrite(ctxt, arg, NULL, NULL);
+ xmlShellWrite(ctxt, arg, ctxt->node, NULL);
#endif /* LIBXML_OUTPUT_ENABLED */
} else if (!strcmp(command, "grep")) {
xmlShellGrep(ctxt, arg, ctxt->node, NULL);
@@ -2962,7 +2971,79 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
fprintf(ctxt->output, "%s\n", dir);
} else if (!strcmp(command, "du")) {
- xmlShellDu(ctxt, NULL, ctxt->node, NULL);
+ if (arg[0] == 0) {
+ xmlShellDu(ctxt, NULL, ctxt->node, NULL);
+ } else {
+ ctxt->pctxt->node = ctxt->node;
+#ifdef LIBXML_XPATH_ENABLED
+ ctxt->pctxt->node = ctxt->node;
+ list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
+#else
+ list = NULL;
+#endif /* LIBXML_XPATH_ENABLED */
+ if (list != NULL) {
+ switch (list->type) {
+ case XPATH_UNDEFINED:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s: no such node\n", arg);
+ break;
+ case XPATH_NODESET:{
+ int indx;
+
+ if (list->nodesetval == NULL)
+ break;
+
+ for (indx = 0;
+ indx < list->nodesetval->nodeNr;
+ indx++)
+ xmlShellDu(ctxt, NULL,
+ list->nodesetval->
+ nodeTab[indx], NULL);
+ break;
+ }
+ case XPATH_BOOLEAN:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a Boolean\n", arg);
+ break;
+ case XPATH_NUMBER:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a number\n", arg);
+ break;
+ case XPATH_STRING:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a string\n", arg);
+ break;
+ case XPATH_POINT:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a point\n", arg);
+ break;
+ case XPATH_RANGE:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a range\n", arg);
+ break;
+ case XPATH_LOCATIONSET:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a range\n", arg);
+ break;
+ case XPATH_USERS:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is user-defined\n", arg);
+ break;
+ case XPATH_XSLT_TREE:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is an XSLT value tree\n",
+ arg);
+ break;
+ }
+#ifdef LIBXML_XPATH_ENABLED
+ xmlXPathFreeObject(list);
+#endif
+ } else {
+ xmlGenericError(xmlGenericErrorContext,
+ "%s: no such node\n", arg);
+ }
+ ctxt->pctxt->node = NULL;
+ }
} else if (!strcmp(command, "base")) {
xmlShellBase(ctxt, NULL, ctxt->node, NULL);
} else if (!strcmp(command, "set")) {
@@ -3080,12 +3161,94 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
}
ctxt->pctxt->node = NULL;
}
+ } else if (!strcmp(command, "whereis")) {
+ char dir[500];
+
+ if (arg[0] == 0) {
+ if (!xmlShellPwd(ctxt, dir, ctxt->node, NULL))
+ fprintf(ctxt->output, "%s\n", dir);
+ } else {
+ ctxt->pctxt->node = ctxt->node;
+#ifdef LIBXML_XPATH_ENABLED
+ list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
+#else
+ list = NULL;
+#endif /* LIBXML_XPATH_ENABLED */
+ if (list != NULL) {
+ switch (list->type) {
+ case XPATH_UNDEFINED:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s: no such node\n", arg);
+ break;
+ case XPATH_NODESET:{
+ int indx;
+
+ if (list->nodesetval == NULL)
+ break;
+
+ for (indx = 0;
+ indx < list->nodesetval->nodeNr;
+ indx++) {
+ if (!xmlShellPwd(ctxt, dir, list->nodesetval->
+ nodeTab[indx], NULL))
+ fprintf(ctxt->output, "%s\n", dir);
+ }
+ break;
+ }
+ case XPATH_BOOLEAN:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a Boolean\n", arg);
+ break;
+ case XPATH_NUMBER:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a number\n", arg);
+ break;
+ case XPATH_STRING:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a string\n", arg);
+ break;
+ case XPATH_POINT:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a point\n", arg);
+ break;
+ case XPATH_RANGE:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a range\n", arg);
+ break;
+ case XPATH_LOCATIONSET:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is a range\n", arg);
+ break;
+ case XPATH_USERS:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is user-defined\n", arg);
+ break;
+ case XPATH_XSLT_TREE:
+ xmlGenericError(xmlGenericErrorContext,
+ "%s is an XSLT value tree\n",
+ arg);
+ break;
+ }
+#ifdef LIBXML_XPATH_ENABLED
+ xmlXPathFreeObject(list);
+#endif
+ } else {
+ xmlGenericError(xmlGenericErrorContext,
+ "%s: no such node\n", arg);
+ }
+ ctxt->pctxt->node = NULL;
+ }
} else if (!strcmp(command, "cd")) {
if (arg[0] == 0) {
ctxt->node = (xmlNodePtr) ctxt->doc;
} else {
#ifdef LIBXML_XPATH_ENABLED
+ int l;
+
ctxt->pctxt->node = ctxt->node;
+ l = strlen(arg);
+ if ((l >= 2) && (arg[l - 1] == '/'))
+ arg[l - 1] = 0;
list = xmlXPathEval((xmlChar *) arg, ctxt->pctxt);
#else
list = NULL;
@@ -3244,6 +3407,7 @@ xmlShell(xmlDocPtr doc, char *filename, xmlShellReadlineFunc input,
"Unknown command %s\n", command);
}
free(cmdline); /* not xmlFree here ! */
+ cmdline = NULL;
}
#ifdef LIBXML_XPATH_ENABLED
xmlXPathFreeContext(ctxt->pctxt);
diff --git a/gnulib-local/lib/libxml/debugXML.in.h b/gnulib-local/lib/libxml/debugXML.in.h
index 5a9d20b..5b3be13 100644
--- a/gnulib-local/lib/libxml/debugXML.in.h
+++ b/gnulib-local/lib/libxml/debugXML.in.h
@@ -25,18 +25,18 @@ extern "C" {
/*
* The standard Dump routines.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDebugDumpString (FILE *output,
const xmlChar *str);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDebugDumpAttr (FILE *output,
xmlAttrPtr attr,
int depth);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDebugDumpAttrList (FILE *output,
xmlAttrPtr attr,
int depth);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDebugDumpOneNode (FILE *output,
xmlNodePtr node,
int depth);
@@ -54,16 +54,16 @@ XMLPUBFUN void XMLCALL
XMLPUBFUN void XMLCALL
xmlDebugDumpDocument (FILE *output,
xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDebugDumpDTD (FILE *output,
xmlDtdPtr dtd);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDebugDumpEntities (FILE *output,
xmlDocPtr doc);
/****************************************************************
* *
- * Checking routines *
+ * Checking routines *
* *
****************************************************************/
@@ -73,16 +73,16 @@ XMLPUBFUN int XMLCALL
/****************************************************************
* *
- * XML shell helpers *
+ * XML shell helpers *
* *
****************************************************************/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlLsOneNode (FILE *output, xmlNodePtr node);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlLsCountNode (xmlNodePtr node);
-XMLPUBFUN const char * XMLCALL
+XMLPUBFUN const char * XMLCALL
xmlBoolToText (int boolval);
/****************************************************************
@@ -136,63 +136,63 @@ typedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt,
xmlNodePtr node,
xmlNodePtr node2);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlShellPrintXPathError (int errorType,
const char *arg);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlShellPrintXPathResult(xmlXPathObjectPtr list);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlShellList (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr node,
xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlShellBase (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr node,
xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlShellDir (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr node,
xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlShellLoad (xmlShellCtxtPtr ctxt,
char *filename,
xmlNodePtr node,
xmlNodePtr node2);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlShellPrintNode (xmlNodePtr node);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlShellCat (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr node,
xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlShellWrite (xmlShellCtxtPtr ctxt,
char *filename,
xmlNodePtr node,
xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlShellSave (xmlShellCtxtPtr ctxt,
char *filename,
xmlNodePtr node,
xmlNodePtr node2);
#endif /* LIBXML_OUTPUT_ENABLED */
#ifdef LIBXML_VALID_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlShellValidate (xmlShellCtxtPtr ctxt,
char *dtd,
xmlNodePtr node,
xmlNodePtr node2);
#endif /* LIBXML_VALID_ENABLED */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlShellDu (xmlShellCtxtPtr ctxt,
char *arg,
xmlNodePtr tree,
xmlNodePtr node2);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlShellPwd (xmlShellCtxtPtr ctxt,
char *buffer,
xmlNodePtr node,
@@ -201,12 +201,12 @@ XMLPUBFUN int XMLCALL
/*
* The Shell interface.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlShell (xmlDocPtr doc,
char *filename,
xmlShellReadlineFunc input,
FILE *output);
-
+
#endif /* LIBXML_XPATH_ENABLED */
#ifdef __cplusplus
diff --git a/gnulib-local/lib/libxml/dict.c b/gnulib-local/lib/libxml/dict.c
index 3b4054f..8c8f931 100644
--- a/gnulib-local/lib/libxml/dict.c
+++ b/gnulib-local/lib/libxml/dict.c
@@ -2,7 +2,7 @@
* dict.c: dictionary of reusable strings, just used to avoid allocation
* and freeing operations.
*
- * Copyright (C) 2003 Daniel Veillard.
+ * Copyright (C) 2003-2012 Daniel Veillard.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -19,19 +19,72 @@
#define IN_LIBXML
#include "libxml.h"
+#include <limits.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+
+/*
+ * Following http://www.ocert.org/advisories/ocert-2011-003.html
+ * it seems that having hash randomization might be a good idea
+ * when using XML with untrusted data
+ * Note1: that it works correctly only if compiled with WITH_BIG_KEY
+ * which is the default.
+ * Note2: the fast function used for a small dict won't protect very
+ * well but since the attack is based on growing a very big hash
+ * list we will use the BigKey algo as soon as the hash size grows
+ * over MIN_DICT_SIZE so this actually works
+ */
+#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME)
+#define DICT_RANDOMIZATION
+#endif
+
#include <string.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#else
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#elif defined(WIN32)
+typedef unsigned __int32 uint32_t;
+#endif
+#endif
#include <libxml/tree.h>
#include <libxml/dict.h>
#include <libxml/xmlmemory.h>
#include <libxml/xmlerror.h>
#include <libxml/globals.h>
-#define MAX_HASH_LEN 4
+/* #define DEBUG_GROW */
+/* #define DICT_DEBUG_PATTERNS */
+
+#define MAX_HASH_LEN 3
#define MIN_DICT_SIZE 128
#define MAX_DICT_HASH 8 * 2048
-
-/* #define ALLOW_REMOVAL */
-/* #define DEBUG_GROW */
+#define WITH_BIG_KEY
+
+#ifdef WITH_BIG_KEY
+#define xmlDictComputeKey(dict, name, len) \
+ (((dict)->size == MIN_DICT_SIZE) ? \
+ xmlDictComputeFastKey(name, len, (dict)->seed) : \
+ xmlDictComputeBigKey(name, len, (dict)->seed))
+
+#define xmlDictComputeQKey(dict, prefix, plen, name, len) \
+ (((prefix) == NULL) ? \
+ (xmlDictComputeKey(dict, name, len)) : \
+ (((dict)->size == MIN_DICT_SIZE) ? \
+ xmlDictComputeFastQKey(prefix, plen, name, len, (dict)->seed) : \
+ xmlDictComputeBigQKey(prefix, plen, name, len, (dict)->seed)))
+
+#else /* !WITH_BIG_KEY */
+#define xmlDictComputeKey(dict, name, len) \
+ xmlDictComputeFastKey(name, len, (dict)->seed)
+#define xmlDictComputeQKey(dict, prefix, plen, name, len) \
+ xmlDictComputeFastQKey(prefix, plen, name, len, (dict)->seed)
+#endif /* WITH_BIG_KEY */
/*
* An entry in the dictionnary
@@ -41,8 +94,9 @@ typedef xmlDictEntry *xmlDictEntryPtr;
struct _xmlDictEntry {
struct _xmlDictEntry *next;
const xmlChar *name;
- int len;
+ unsigned int len;
int valid;
+ unsigned long okey;
};
typedef struct _xmlDictStrings xmlDictStrings;
@@ -51,8 +105,8 @@ struct _xmlDictStrings {
xmlDictStringsPtr next;
xmlChar *free;
xmlChar *end;
- int size;
- int nbStrings;
+ size_t size;
+ size_t nbStrings;
xmlChar array[1];
};
/*
@@ -60,14 +114,17 @@ struct _xmlDictStrings {
*/
struct _xmlDict {
int ref_counter;
- xmlRMutexPtr mutex;
struct _xmlDictEntry *dict;
- int size;
- int nbElems;
+ size_t size;
+ unsigned int nbElems;
xmlDictStringsPtr strings;
struct _xmlDict *subdict;
+ /* used for randomization */
+ int seed;
+ /* used to impose a limit on size */
+ size_t limit;
};
/*
@@ -81,28 +138,84 @@ static xmlRMutexPtr xmlDictMutex = NULL;
*/
static int xmlDictInitialized = 0;
+#ifdef DICT_RANDOMIZATION
+#ifdef HAVE_RAND_R
+/*
+ * Internal data for random function, protected by xmlDictMutex
+ */
+static unsigned int rand_seed = 0;
+#endif
+#endif
+
/**
* xmlInitializeDict:
*
* Do the dictionary mutex initialization.
+ * this function is deprecated
+ *
+ * Returns 0 if initialization was already done, and 1 if that
+ * call led to the initialization
+ */
+int xmlInitializeDict(void) {
+ return(0);
+}
+
+/**
+ * __xmlInitializeDict:
+ *
+ * This function is not public
+ * Do the dictionary mutex initialization.
* this function is not thread safe, initialization should
- * preferably be done once at startup
+ * normally be done once at setup when called from xmlOnceInit()
+ * we may also land in this code if thread support is not compiled in
+ *
+ * Returns 0 if initialization was already done, and 1 if that
+ * call led to the initialization
*/
-static int xmlInitializeDict(void) {
+int __xmlInitializeDict(void) {
if (xmlDictInitialized)
return(1);
if ((xmlDictMutex = xmlNewRMutex()) == NULL)
return(0);
+ xmlRMutexLock(xmlDictMutex);
+#ifdef DICT_RANDOMIZATION
+#ifdef HAVE_RAND_R
+ rand_seed = time(NULL);
+ rand_r(& rand_seed);
+#else
+ srand(time(NULL));
+#endif
+#endif
xmlDictInitialized = 1;
+ xmlRMutexUnlock(xmlDictMutex);
return(1);
}
+#ifdef DICT_RANDOMIZATION
+int __xmlRandom(void) {
+ int ret;
+
+ if (xmlDictInitialized == 0)
+ __xmlInitializeDict();
+
+ xmlRMutexLock(xmlDictMutex);
+#ifdef HAVE_RAND_R
+ ret = rand_r(& rand_seed);
+#else
+ ret = rand();
+#endif
+ xmlRMutexUnlock(xmlDictMutex);
+ return(ret);
+}
+#endif
+
/**
* xmlDictCleanup:
*
- * Free the dictionary mutex.
+ * Free the dictionary mutex. Do not call unless sure the library
+ * is not in use anymore !
*/
void
xmlDictCleanup(void) {
@@ -118,32 +231,41 @@ xmlDictCleanup(void) {
* xmlDictAddString:
* @dict: the dictionnary
* @name: the name of the userdata
- * @len: the length of the name, if -1 it is recomputed
+ * @len: the length of the name
*
* Add the string to the array[s]
*
* Returns the pointer of the local string, or NULL in case of error.
*/
static const xmlChar *
-xmlDictAddString(xmlDictPtr dict, const xmlChar *name, int namelen) {
+xmlDictAddString(xmlDictPtr dict, const xmlChar *name, unsigned int namelen) {
xmlDictStringsPtr pool;
const xmlChar *ret;
- int size = 0; /* + sizeof(_xmlDictStrings) == 1024 */
+ size_t size = 0; /* + sizeof(_xmlDictStrings) == 1024 */
+ size_t limit = 0;
+#ifdef DICT_DEBUG_PATTERNS
+ fprintf(stderr, "-");
+#endif
pool = dict->strings;
while (pool != NULL) {
if (pool->end - pool->free > namelen)
goto found_pool;
if (pool->size > size) size = pool->size;
+ limit += pool->size;
pool = pool->next;
}
/*
* Not found, need to allocate
*/
if (pool == NULL) {
+ if ((dict->limit > 0) && (limit > dict->limit)) {
+ return(NULL);
+ }
+
if (size == 0) size = 1000;
else size *= 4; /* exponential growth */
- if (size < 4 * namelen)
+ if (size < 4 * namelen)
size = 4 * namelen; /* just in case ! */
pool = (xmlDictStringsPtr) xmlMalloc(sizeof(xmlDictStrings) + size);
if (pool == NULL)
@@ -154,12 +276,16 @@ xmlDictAddString(xmlDictPtr dict, const xmlChar *name, int namelen) {
pool->end = &pool->array[size];
pool->next = dict->strings;
dict->strings = pool;
+#ifdef DICT_DEBUG_PATTERNS
+ fprintf(stderr, "+");
+#endif
}
found_pool:
ret = pool->free;
memcpy(pool->free, name, namelen);
pool->free += namelen;
*(pool->free++) = 0;
+ pool->nbStrings++;
return(ret);
}
@@ -167,40 +293,48 @@ found_pool:
* xmlDictAddQString:
* @dict: the dictionnary
* @prefix: the prefix of the userdata
+ * @plen: the prefix length
* @name: the name of the userdata
- * @len: the length of the name, if -1 it is recomputed
+ * @len: the length of the name
*
* Add the QName to the array[s]
*
* Returns the pointer of the local string, or NULL in case of error.
*/
static const xmlChar *
-xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix,
- const xmlChar *name, int namelen)
+xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix, unsigned int plen,
+ const xmlChar *name, unsigned int namelen)
{
xmlDictStringsPtr pool;
const xmlChar *ret;
- int size = 0; /* + sizeof(_xmlDictStrings) == 1024 */
- int plen;
+ size_t size = 0; /* + sizeof(_xmlDictStrings) == 1024 */
+ size_t limit = 0;
if (prefix == NULL) return(xmlDictAddString(dict, name, namelen));
- plen = xmlStrlen(prefix);
+#ifdef DICT_DEBUG_PATTERNS
+ fprintf(stderr, "=");
+#endif
pool = dict->strings;
while (pool != NULL) {
- if (pool->end - pool->free > namelen)
+ if (pool->end - pool->free > namelen + plen + 1)
goto found_pool;
if (pool->size > size) size = pool->size;
+ limit += pool->size;
pool = pool->next;
}
/*
* Not found, need to allocate
*/
if (pool == NULL) {
+ if ((dict->limit > 0) && (limit > dict->limit)) {
+ return(NULL);
+ }
+
if (size == 0) size = 1000;
else size *= 4; /* exponential growth */
- if (size < 4 * namelen)
- size = 4 * namelen; /* just in case ! */
+ if (size < 4 * (namelen + plen + 1))
+ size = 4 * (namelen + plen + 1); /* just in case ! */
pool = (xmlDictStringsPtr) xmlMalloc(sizeof(xmlDictStrings) + size);
if (pool == NULL)
return(NULL);
@@ -210,27 +344,106 @@ xmlDictAddQString(xmlDictPtr dict, const xmlChar *prefix,
pool->end = &pool->array[size];
pool->next = dict->strings;
dict->strings = pool;
+#ifdef DICT_DEBUG_PATTERNS
+ fprintf(stderr, "+");
+#endif
}
found_pool:
ret = pool->free;
memcpy(pool->free, prefix, plen);
pool->free += plen;
*(pool->free++) = ':';
- namelen -= plen + 1;
memcpy(pool->free, name, namelen);
pool->free += namelen;
*(pool->free++) = 0;
+ pool->nbStrings++;
return(ret);
}
+#ifdef WITH_BIG_KEY
+/*
+ * xmlDictComputeBigKey:
+ *
+ * Calculate a hash key using a good hash function that works well for
+ * larger hash table sizes.
+ *
+ * Hash function by "One-at-a-Time Hash" see
+ * http://burtleburtle.net/bob/hash/doobs.html
+ */
+
+static uint32_t
+xmlDictComputeBigKey(const xmlChar* data, int namelen, int seed) {
+ uint32_t hash;
+ int i;
+
+ if (namelen <= 0 || data == NULL) return(0);
+
+ hash = seed;
+
+ for (i = 0;i < namelen; i++) {
+ hash += data[i];
+ hash += (hash << 10);
+ hash ^= (hash >> 6);
+ }
+ hash += (hash << 3);
+ hash ^= (hash >> 11);
+ hash += (hash << 15);
+
+ return hash;
+}
+
+/*
+ * xmlDictComputeBigQKey:
+ *
+ * Calculate a hash key for two strings using a good hash function
+ * that works well for larger hash table sizes.
+ *
+ * Hash function by "One-at-a-Time Hash" see
+ * http://burtleburtle.net/bob/hash/doobs.html
+ *
+ * Neither of the two strings must be NULL.
+ */
+static unsigned long
+xmlDictComputeBigQKey(const xmlChar *prefix, int plen,
+ const xmlChar *name, int len, int seed)
+{
+ uint32_t hash;
+ int i;
+
+ hash = seed;
+
+ for (i = 0;i < plen; i++) {
+ hash += prefix[i];
+ hash += (hash << 10);
+ hash ^= (hash >> 6);
+ }
+ hash += ':';
+ hash += (hash << 10);
+ hash ^= (hash >> 6);
+
+ for (i = 0;i < len; i++) {
+ hash += name[i];
+ hash += (hash << 10);
+ hash ^= (hash >> 6);
+ }
+ hash += (hash << 3);
+ hash ^= (hash >> 11);
+ hash += (hash << 15);
+
+ return hash;
+}
+#endif /* WITH_BIG_KEY */
+
/*
- * xmlDictComputeKey:
- * Calculate the hash key
+ * xmlDictComputeFastKey:
+ *
+ * Calculate a hash key using a fast hash function that works well
+ * for low hash table fill.
*/
static unsigned long
-xmlDictComputeKey(const xmlChar *name, int namelen) {
- unsigned long value = 0L;
-
+xmlDictComputeFastKey(const xmlChar *name, int namelen, int seed) {
+ unsigned long value = seed;
+
if (name == NULL) return(0);
value = *name;
value <<= 5;
@@ -254,26 +467,29 @@ xmlDictComputeKey(const xmlChar *name, int namelen) {
}
/*
- * xmlDictComputeQKey:
- * Calculate the hash key
+ * xmlDictComputeFastQKey:
+ *
+ * Calculate a hash key for two strings using a fast hash function
+ * that works well for low hash table fill.
+ *
+ * Neither of the two strings must be NULL.
*/
static unsigned long
-xmlDictComputeQKey(const xmlChar *prefix, const xmlChar *name, int len)
+xmlDictComputeFastQKey(const xmlChar *prefix, int plen,
+ const xmlChar *name, int len, int seed)
{
- unsigned long value = 0L;
- int plen;
-
- if (prefix == NULL)
- return(xmlDictComputeKey(name, len));
+ unsigned long value = (unsigned long) seed;
- plen = xmlStrlen(prefix);
if (plen == 0)
value += 30 * (unsigned long) ':';
else
value += 30 * (*prefix);
-
+
if (len > 10) {
- value += name[len - (plen + 1 + 1)];
+ int offset = len - (plen + 1 + 1);
+ if (offset < 0)
+ offset = len - (10 + 1);
+ value += name[offset];
len = 10;
if (plen > 10)
plen = 10;
@@ -324,12 +540,17 @@ xmlDictCreate(void) {
xmlDictPtr dict;
if (!xmlDictInitialized)
- if (!xmlInitializeDict())
+ if (!__xmlInitializeDict())
return(NULL);
-
+
+#ifdef DICT_DEBUG_PATTERNS
+ fprintf(stderr, "C");
+#endif
+
dict = xmlMalloc(sizeof(xmlDict));
if (dict) {
dict->ref_counter = 1;
+ dict->limit = 0;
dict->size = MIN_DICT_SIZE;
dict->nbElems = 0;
@@ -337,11 +558,13 @@ xmlDictCreate(void) {
dict->strings = NULL;
dict->subdict = NULL;
if (dict->dict) {
- if ((dict->mutex = xmlNewRMutex()) != NULL) {
- memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
- return(dict);
- }
- xmlFree(dict->dict);
+ memset(dict->dict, 0, MIN_DICT_SIZE * sizeof(xmlDictEntry));
+#ifdef DICT_RANDOMIZATION
+ dict->seed = __xmlRandom();
+#else
+ dict->seed = 0;
+#endif
+ return(dict);
}
xmlFree(dict);
}
@@ -362,8 +585,12 @@ xmlDictCreate(void) {
xmlDictPtr
xmlDictCreateSub(xmlDictPtr sub) {
xmlDictPtr dict = xmlDictCreate();
-
+
if ((dict != NULL) && (sub != NULL)) {
+#ifdef DICT_DEBUG_PATTERNS
+ fprintf(stderr, "R");
+#endif
+ dict->seed = sub->seed;
dict->subdict = sub;
xmlDictReference(dict->subdict);
}
@@ -381,7 +608,7 @@ xmlDictCreateSub(xmlDictPtr sub) {
int
xmlDictReference(xmlDictPtr dict) {
if (!xmlDictInitialized)
- if (!xmlInitializeDict())
+ if (!__xmlInitializeDict())
return(-1);
if (dict == NULL) return -1;
@@ -401,15 +628,17 @@ xmlDictReference(xmlDictPtr dict) {
* Returns 0 in case of success, -1 in case of failure
*/
static int
-xmlDictGrow(xmlDictPtr dict, int size) {
- unsigned long key;
- int oldsize, i;
+xmlDictGrow(xmlDictPtr dict, size_t size) {
+ unsigned long key, okey;
+ size_t oldsize, i;
xmlDictEntryPtr iter, next;
struct _xmlDictEntry *olddict;
#ifdef DEBUG_GROW
unsigned long nbElem = 0;
#endif
-
+ int ret = 0;
+ int keep_keys = 1;
+
if (dict == NULL)
return(-1);
if (size < 8)
@@ -417,11 +646,17 @@ xmlDictGrow(xmlDictPtr dict, int size) {
if (size > 8 * 2048)
return(-1);
+#ifdef DICT_DEBUG_PATTERNS
+ fprintf(stderr, "*");
+#endif
+
oldsize = dict->size;
olddict = dict->dict;
if (olddict == NULL)
return(-1);
-
+ if (oldsize == MIN_DICT_SIZE)
+ keep_keys = 0;
+
dict->dict = xmlMalloc(size * sizeof(xmlDictEntry));
if (dict->dict == NULL) {
dict->dict = olddict;
@@ -431,17 +666,44 @@ xmlDictGrow(xmlDictPtr dict, int size) {
dict->size = size;
/* If the two loops are merged, there would be situations where
- a new entry needs to allocated and data copied into it from
- the main dict. So instead, we run through the array twice, first
- copying all the elements in the main array (where we can't get
- conflicts) and then the rest, so we only free (and don't allocate)
+ a new entry needs to allocated and data copied into it from
+ the main dict. It is nicer to run through the array twice, first
+ copying all the elements in the main array (less probability of
+ allocate) and then the rest, so we only free in the second loop.
*/
for (i = 0; i < oldsize; i++) {
- if (olddict[i].valid == 0)
+ if (olddict[i].valid == 0)
continue;
- key = xmlDictComputeKey(olddict[i].name, olddict[i].len) % dict->size;
- memcpy(&(dict->dict[key]), &(olddict[i]), sizeof(xmlDictEntry));
- dict->dict[key].next = NULL;
+
+ if (keep_keys)
+ okey = olddict[i].okey;
+ else
+ okey = xmlDictComputeKey(dict, olddict[i].name, olddict[i].len);
+ key = okey % dict->size;
+
+ if (dict->dict[key].valid == 0) {
+ memcpy(&(dict->dict[key]), &(olddict[i]), sizeof(xmlDictEntry));
+ dict->dict[key].next = NULL;
+ dict->dict[key].okey = okey;
+ } else {
+ xmlDictEntryPtr entry;
+
+ entry = xmlMalloc(sizeof(xmlDictEntry));
+ if (entry != NULL) {
+ entry->name = olddict[i].name;
+ entry->len = olddict[i].len;
+ entry->okey = okey;
+ entry->next = dict->dict[key].next;
+ entry->valid = 1;
+ dict->dict[key].next = entry;
+ } else {
+ /*
+ * we don't have much ways to alert from herei
+ * result is loosing an entry and unicity garantee
+ */
+ ret = -1;
+ }
+ }
#ifdef DEBUG_GROW
nbElem++;
#endif
@@ -456,15 +718,21 @@ xmlDictGrow(xmlDictPtr dict, int size) {
* put back the entry in the new dict
*/
- key = xmlDictComputeKey(iter->name, iter->len) % dict->size;
+ if (keep_keys)
+ okey = iter->okey;
+ else
+ okey = xmlDictComputeKey(dict, iter->name, iter->len);
+ key = okey % dict->size;
if (dict->dict[key].valid == 0) {
memcpy(&(dict->dict[key]), iter, sizeof(xmlDictEntry));
dict->dict[key].next = NULL;
dict->dict[key].valid = 1;
+ dict->dict[key].okey = okey;
xmlFree(iter);
} else {
- iter->next = dict->dict[key].next;
- dict->dict[key].next = iter;
+ iter->next = dict->dict[key].next;
+ iter->okey = okey;
+ dict->dict[key].next = iter;
}
#ifdef DEBUG_GROW
@@ -479,10 +747,10 @@ xmlDictGrow(xmlDictPtr dict, int size) {
#ifdef DEBUG_GROW
xmlGenericError(xmlGenericErrorContext,
- "xmlDictGrow : from %d to %d, %d elems\n", oldsize, size, nbElem);
+ "xmlDictGrow : from %lu to %lu, %u elems\n", oldsize, size, nbElem);
#endif
- return(0);
+ return(ret);
}
/**
@@ -494,7 +762,7 @@ xmlDictGrow(xmlDictPtr dict, int size) {
*/
void
xmlDictFree(xmlDictPtr dict) {
- int i;
+ size_t i;
xmlDictEntryPtr iter;
xmlDictEntryPtr next;
int inside_dict = 0;
@@ -504,7 +772,7 @@ xmlDictFree(xmlDictPtr dict) {
return;
if (!xmlDictInitialized)
- if (!xmlInitializeDict())
+ if (!__xmlInitializeDict())
return;
/* decrement the counter, it may be shared by a parser and docs */
@@ -535,7 +803,6 @@ xmlDictFree(xmlDictPtr dict) {
inside_dict = 0;
iter = next;
}
- inside_dict = 0;
}
xmlFree(dict->dict);
}
@@ -545,7 +812,6 @@ xmlDictFree(xmlDictPtr dict) {
xmlFree(pool);
pool = nextp;
}
- xmlFreeRMutex(dict->mutex);
xmlFree(dict);
}
@@ -565,17 +831,24 @@ xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
xmlDictEntryPtr entry;
xmlDictEntryPtr insert;
const xmlChar *ret;
+ unsigned int l;
if ((dict == NULL) || (name == NULL))
return(NULL);
if (len < 0)
- len = xmlStrlen(name);
+ l = strlen((const char *) name);
+ else
+ l = len;
+
+ if (((dict->limit > 0) && (l >= dict->limit)) ||
+ (l > INT_MAX / 2))
+ return(NULL);
/*
* Check for duplicate and insertion location.
*/
- okey = xmlDictComputeKey(name, len);
+ okey = xmlDictComputeKey(dict, name, l);
key = okey % dict->size;
if (dict->dict[key].valid == 0) {
insert = NULL;
@@ -583,63 +856,74 @@ xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
for (insert = &(dict->dict[key]); insert->next != NULL;
insert = insert->next) {
#ifdef __GNUC__
- if (insert->len == len) {
- if (!memcmp(insert->name, name, len))
+ if ((insert->okey == okey) && (insert->len == l)) {
+ if (!memcmp(insert->name, name, l))
return(insert->name);
}
#else
- if ((insert->len == len) &&
- (!xmlStrncmp(insert->name, name, len)))
+ if ((insert->okey == okey) && (insert->len == l) &&
+ (!xmlStrncmp(insert->name, name, l)))
return(insert->name);
#endif
nbi++;
}
#ifdef __GNUC__
- if (insert->len == len) {
- if (!memcmp(insert->name, name, len))
+ if ((insert->okey == okey) && (insert->len == l)) {
+ if (!memcmp(insert->name, name, l))
return(insert->name);
}
#else
- if ((insert->len == len) &&
- (!xmlStrncmp(insert->name, name, len)))
+ if ((insert->okey == okey) && (insert->len == l) &&
+ (!xmlStrncmp(insert->name, name, l)))
return(insert->name);
#endif
}
if (dict->subdict) {
- key = okey % dict->subdict->size;
+ unsigned long skey;
+
+ /* we cannot always reuse the same okey for the subdict */
+ if (((dict->size == MIN_DICT_SIZE) &&
+ (dict->subdict->size != MIN_DICT_SIZE)) ||
+ ((dict->size != MIN_DICT_SIZE) &&
+ (dict->subdict->size == MIN_DICT_SIZE)))
+ skey = xmlDictComputeKey(dict->subdict, name, l);
+ else
+ skey = okey;
+
+ key = skey % dict->subdict->size;
if (dict->subdict->dict[key].valid != 0) {
xmlDictEntryPtr tmp;
for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
tmp = tmp->next) {
#ifdef __GNUC__
- if (tmp->len == len) {
- if (!memcmp(tmp->name, name, len))
+ if ((tmp->okey == skey) && (tmp->len == l)) {
+ if (!memcmp(tmp->name, name, l))
return(tmp->name);
}
#else
- if ((tmp->len == len) &&
- (!xmlStrncmp(tmp->name, name, len)))
+ if ((tmp->okey == skey) && (tmp->len == l) &&
+ (!xmlStrncmp(tmp->name, name, l)))
return(tmp->name);
#endif
nbi++;
}
#ifdef __GNUC__
- if (tmp->len == len) {
- if (!memcmp(tmp->name, name, len))
+ if ((tmp->okey == skey) && (tmp->len == l)) {
+ if (!memcmp(tmp->name, name, l))
return(tmp->name);
}
#else
- if ((tmp->len == len) &&
- (!xmlStrncmp(tmp->name, name, len)))
+ if ((tmp->okey == skey) && (tmp->len == l) &&
+ (!xmlStrncmp(tmp->name, name, l)))
return(tmp->name);
#endif
}
key = okey % dict->size;
}
- ret = xmlDictAddString(dict, name, len);
+ ret = xmlDictAddString(dict, name, l);
if (ret == NULL)
return(NULL);
if (insert == NULL) {
@@ -650,19 +934,22 @@ xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
return(NULL);
}
entry->name = ret;
- entry->len = len;
+ entry->len = l;
entry->next = NULL;
entry->valid = 1;
+ entry->okey = okey;
- if (insert != NULL)
+ if (insert != NULL)
insert->next = entry;
dict->nbElems++;
if ((nbi > MAX_HASH_LEN) &&
- (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN)))
- xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size);
+ (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN))) {
+ if (xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size) != 0)
+ return(NULL);
+ }
/* Note that entry may have been freed at this point by xmlDictGrow */
return(ret);
@@ -682,17 +969,23 @@ const xmlChar *
xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
unsigned long key, okey, nbi = 0;
xmlDictEntryPtr insert;
+ unsigned int l;
if ((dict == NULL) || (name == NULL))
return(NULL);
if (len < 0)
- len = xmlStrlen(name);
+ l = strlen((const char *) name);
+ else
+ l = len;
+ if (((dict->limit > 0) && (l >= dict->limit)) ||
+ (l > INT_MAX / 2))
+ return(NULL);
/*
* Check for duplicate and insertion location.
*/
- okey = xmlDictComputeKey(name, len);
+ okey = xmlDictComputeKey(dict, name, l);
key = okey % dict->size;
if (dict->dict[key].valid == 0) {
insert = NULL;
@@ -700,60 +993,70 @@ xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
for (insert = &(dict->dict[key]); insert->next != NULL;
insert = insert->next) {
#ifdef __GNUC__
- if (insert->len == len) {
- if (!memcmp(insert->name, name, len))
+ if ((insert->okey == okey) && (insert->len == l)) {
+ if (!memcmp(insert->name, name, l))
return(insert->name);
}
#else
- if ((insert->len == len) &&
- (!xmlStrncmp(insert->name, name, len)))
+ if ((insert->okey == okey) && (insert->len == l) &&
+ (!xmlStrncmp(insert->name, name, l)))
return(insert->name);
#endif
nbi++;
}
#ifdef __GNUC__
- if (insert->len == len) {
- if (!memcmp(insert->name, name, len))
+ if ((insert->okey == okey) && (insert->len == l)) {
+ if (!memcmp(insert->name, name, l))
return(insert->name);
}
#else
- if ((insert->len == len) &&
- (!xmlStrncmp(insert->name, name, len)))
+ if ((insert->okey == okey) && (insert->len == l) &&
+ (!xmlStrncmp(insert->name, name, l)))
return(insert->name);
#endif
}
if (dict->subdict) {
- key = okey % dict->subdict->size;
+ unsigned long skey;
+
+ /* we cannot always reuse the same okey for the subdict */
+ if (((dict->size == MIN_DICT_SIZE) &&
+ (dict->subdict->size != MIN_DICT_SIZE)) ||
+ ((dict->size != MIN_DICT_SIZE) &&
+ (dict->subdict->size == MIN_DICT_SIZE)))
+ skey = xmlDictComputeKey(dict->subdict, name, l);
+ else
+ skey = okey;
+
+ key = skey % dict->subdict->size;
if (dict->subdict->dict[key].valid != 0) {
xmlDictEntryPtr tmp;
for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
tmp = tmp->next) {
#ifdef __GNUC__
- if (tmp->len == len) {
- if (!memcmp(tmp->name, name, len))
+ if ((tmp->okey == skey) && (tmp->len == l)) {
+ if (!memcmp(tmp->name, name, l))
return(tmp->name);
}
#else
- if ((tmp->len == len) &&
- (!xmlStrncmp(tmp->name, name, len)))
+ if ((tmp->okey == skey) && (tmp->len == l) &&
+ (!xmlStrncmp(tmp->name, name, l)))
return(tmp->name);
#endif
nbi++;
}
#ifdef __GNUC__
- if (tmp->len == len) {
- if (!memcmp(tmp->name, name, len))
+ if ((tmp->okey == skey) && (tmp->len == l)) {
+ if (!memcmp(tmp->name, name, l))
return(tmp->name);
}
#else
- if ((tmp->len == len) &&
- (!xmlStrncmp(tmp->name, name, len)))
+ if ((tmp->okey == skey) && (tmp->len == l) &&
+ (!xmlStrncmp(tmp->name, name, l)))
return(tmp->name);
#endif
}
- key = okey % dict->size;
}
/* not found */
@@ -763,7 +1066,7 @@ xmlDictExists(xmlDictPtr dict, const xmlChar *name, int len) {
/**
* xmlDictQLookup:
* @dict: the dictionnary
- * @prefix: the prefix
+ * @prefix: the prefix
* @name: the name
*
* Add the QName @prefix:@name to the hash @dict if not present.
@@ -776,54 +1079,67 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
xmlDictEntryPtr entry;
xmlDictEntryPtr insert;
const xmlChar *ret;
- int len;
+ unsigned int len, plen, l;
if ((dict == NULL) || (name == NULL))
return(NULL);
+ if (prefix == NULL)
+ return(xmlDictLookup(dict, name, -1));
- len = xmlStrlen(name);
- if (prefix != NULL)
- len += 1 + xmlStrlen(prefix);
+ l = len = strlen((const char *) name);
+ plen = strlen((const char *) prefix);
+ len += 1 + plen;
/*
* Check for duplicate and insertion location.
*/
- okey = xmlDictComputeQKey(prefix, name, len);
+ okey = xmlDictComputeQKey(dict, prefix, plen, name, l);
key = okey % dict->size;
if (dict->dict[key].valid == 0) {
insert = NULL;
} else {
for (insert = &(dict->dict[key]); insert->next != NULL;
insert = insert->next) {
- if ((insert->len == len) &&
+ if ((insert->okey == okey) && (insert->len == len) &&
(xmlStrQEqual(prefix, name, insert->name)))
return(insert->name);
nbi++;
}
- if ((insert->len == len) &&
+ if ((insert->okey == okey) && (insert->len == len) &&
(xmlStrQEqual(prefix, name, insert->name)))
return(insert->name);
}
if (dict->subdict) {
- key = okey % dict->subdict->size;
+ unsigned long skey;
+
+ /* we cannot always reuse the same okey for the subdict */
+ if (((dict->size == MIN_DICT_SIZE) &&
+ (dict->subdict->size != MIN_DICT_SIZE)) ||
+ ((dict->size != MIN_DICT_SIZE) &&
+ (dict->subdict->size == MIN_DICT_SIZE)))
+ skey = xmlDictComputeQKey(dict->subdict, prefix, plen, name, l);
+ else
+ skey = okey;
+
+ key = skey % dict->subdict->size;
if (dict->subdict->dict[key].valid != 0) {
xmlDictEntryPtr tmp;
for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL;
tmp = tmp->next) {
- if ((tmp->len == len) &&
+ if ((tmp->okey == skey) && (tmp->len == len) &&
(xmlStrQEqual(prefix, name, tmp->name)))
return(tmp->name);
nbi++;
}
- if ((tmp->len == len) &&
+ if ((tmp->okey == skey) && (tmp->len == len) &&
(xmlStrQEqual(prefix, name, tmp->name)))
return(tmp->name);
}
key = okey % dict->size;
}
- ret = xmlDictAddQString(dict, prefix, name, len);
+ ret = xmlDictAddQString(dict, prefix, plen, name, l);
if (ret == NULL)
return(NULL);
if (insert == NULL) {
@@ -837,8 +1153,9 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
entry->len = len;
entry->next = NULL;
entry->valid = 1;
+ entry->okey = okey;
- if (insert != NULL)
+ if (insert != NULL)
insert->next = entry;
dict->nbElems++;
@@ -896,6 +1213,50 @@ xmlDictSize(xmlDictPtr dict) {
return(dict->nbElems);
}
+/**
+ * xmlDictSetLimit:
+ * @dict: the dictionnary
+ * @limit: the limit in bytes
+ *
+ * Set a size limit for the dictionary
+ * Added in 2.9.0
+ *
+ * Returns the previous limit of the dictionary or 0
+ */
+size_t
+xmlDictSetLimit(xmlDictPtr dict, size_t limit) {
+ size_t ret;
+
+ if (dict == NULL)
+ return(0);
+ ret = dict->limit;
+ dict->limit = limit;
+ return(ret);
+}
+
+/**
+ * xmlDictGetUsage:
+ * @dict: the dictionnary
+ *
+ * Get how much memory is used by a dictionary for strings
+ * Added in 2.9.0
+ *
+ * Returns the amount of strings allocated
+ */
+size_t
+xmlDictGetUsage(xmlDictPtr dict) {
+ xmlDictStringsPtr pool;
+ size_t limit = 0;
+
+ if (dict == NULL)
+ return(0);
+ pool = dict->strings;
+ while (pool != NULL) {
+ limit += pool->size;
+ pool = pool->next;
+ }
+ return(limit);
+}
#define bottom_dict
#include "elfgcchack.h"
diff --git a/gnulib-local/lib/libxml/dict.in.h b/gnulib-local/lib/libxml/dict.in.h
index abb8339..7022ec8 100644
--- a/gnulib-local/lib/libxml/dict.in.h
+++ b/gnulib-local/lib/libxml/dict.in.h
@@ -11,6 +11,7 @@
#ifndef __XML_DICT_H__
#define __XML_DICT_H__
+#include <limits.h>
#include <libxml/xmlversion.h>
#include <libxml/tree.h>
@@ -25,36 +26,46 @@ typedef struct _xmlDict xmlDict;
typedef xmlDict *xmlDictPtr;
/*
+ * Initializer
+ */
+XMLPUBFUN int XMLCALL xmlInitializeDict(void);
+
+/*
* Constructor and destructor.
*/
XMLPUBFUN xmlDictPtr XMLCALL
xmlDictCreate (void);
+XMLPUBFUN size_t XMLCALL
+ xmlDictSetLimit (xmlDictPtr dict,
+ size_t limit);
+XMLPUBFUN size_t XMLCALL
+ xmlDictGetUsage (xmlDictPtr dict);
XMLPUBFUN xmlDictPtr XMLCALL
xmlDictCreateSub(xmlDictPtr sub);
XMLPUBFUN int XMLCALL
xmlDictReference(xmlDictPtr dict);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDictFree (xmlDictPtr dict);
/*
* Lookup of entry in the dictionnary.
*/
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlDictLookup (xmlDictPtr dict,
const xmlChar *name,
int len);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlDictExists (xmlDictPtr dict,
const xmlChar *name,
int len);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlDictQLookup (xmlDictPtr dict,
const xmlChar *prefix,
const xmlChar *name);
XMLPUBFUN int XMLCALL
xmlDictOwns (xmlDictPtr dict,
const xmlChar *str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlDictSize (xmlDictPtr dict);
/*
diff --git a/gnulib-local/lib/libxml/elfgcchack.h b/gnulib-local/lib/libxml/elfgcchack.h
index e69de29..8c52884 100644
--- a/gnulib-local/lib/libxml/elfgcchack.h
+++ b/gnulib-local/lib/libxml/elfgcchack.h
@@ -0,0 +1,17808 @@
+/*
+ * elfgcchack.h: hack by Arjan van de Ven <arjanv@redhat.com> to speed
+ * up the code when using gcc for call within the library.
+ *
+ * Based on the analysis http://people.redhat.com/drepper/dsohowto.pdf
+ * from Ulrich drepper. Rewritten to be generated from the XML description
+ * file for libxml2 API
+ * autogenerated with xsltproc doc/elfgcchack.xsl doc/libxml2-api.xml
+ */
+
+#ifdef IN_LIBXML
+#ifdef __GNUC__
+#ifdef PIC
+#ifdef linux
+#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
+
+#include "libxml/c14n.h"
+#include "libxml/catalog.h"
+#include "libxml/chvalid.h"
+#include "libxml/debugXML.h"
+#include "libxml/dict.h"
+#include "libxml/DOCBparser.h"
+#include "libxml/encoding.h"
+#include "libxml/entities.h"
+#include "libxml/globals.h"
+#include "libxml/hash.h"
+#include "libxml/HTMLparser.h"
+#include "libxml/HTMLtree.h"
+#include "libxml/list.h"
+#include "libxml/nanoftp.h"
+#include "libxml/nanohttp.h"
+#include "libxml/parser.h"
+#include "libxml/parserInternals.h"
+#include "libxml/pattern.h"
+#include "libxml/relaxng.h"
+#include "libxml/SAX2.h"
+#include "libxml/SAX.h"
+#include "libxml/schemasInternals.h"
+#include "libxml/schematron.h"
+#include "libxml/threads.h"
+#include "libxml/tree.h"
+#include "libxml/uri.h"
+#include "libxml/valid.h"
+#include "libxml/xinclude.h"
+#include "libxml/xlink.h"
+#include "libxml/xmlautomata.h"
+#include "libxml/xmlerror.h"
+#include "libxml/xmlexports.h"
+#include "libxml/xmlIO.h"
+#include "libxml/xmlmemory.h"
+#include "libxml/xmlreader.h"
+#include "libxml/xmlregexp.h"
+#include "libxml/xmlsave.h"
+#include "libxml/xmlschemas.h"
+#include "libxml/xmlschemastypes.h"
+#include "libxml/xmlstring.h"
+#include "libxml/xmlunicode.h"
+#include "libxml/xmlversion.h"
+#include "libxml/xmlwriter.h"
+#include "libxml/xpath.h"
+#include "libxml/xpathInternals.h"
+#include "libxml/xpointer.h"
+#include "libxml/xmlmodule.h"
+
+/* special hot spot not exported ones */
+
+#ifdef bottom_globals
+#undef __xmlGenericError
+extern __typeof (__xmlGenericError) __xmlGenericError __attribute((alias("__xmlGenericError__internal_alias")));
+#else
+#ifndef __xmlGenericError
+extern __typeof (__xmlGenericError) __xmlGenericError__internal_alias __attribute((visibility("hidden")));
+#define __xmlGenericError __xmlGenericError__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef __xmlGenericErrorContext
+extern __typeof (__xmlGenericErrorContext) __xmlGenericErrorContext __attribute((alias("__xmlGenericErrorContext__internal_alias")));
+#else
+#ifndef __xmlGenericErrorContext
+extern __typeof (__xmlGenericErrorContext) __xmlGenericErrorContext__internal_alias __attribute((visibility("hidden")));
+#define __xmlGenericErrorContext __xmlGenericErrorContext__internal_alias
+#endif
+#endif
+
+/* list generated from libxml2-api.xml */
+#if defined(LIBXML_DOCB_ENABLED)
+#ifdef bottom_DOCBparser
+#undef docbCreatePushParserCtxt
+extern __typeof (docbCreatePushParserCtxt) docbCreatePushParserCtxt __attribute((alias("docbCreatePushParserCtxt__internal_alias")));
+#else
+#ifndef docbCreatePushParserCtxt
+extern __typeof (docbCreatePushParserCtxt) docbCreatePushParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define docbCreatePushParserCtxt docbCreatePushParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlAttrAllowed
+extern __typeof (htmlAttrAllowed) htmlAttrAllowed __attribute((alias("htmlAttrAllowed__internal_alias")));
+#else
+#ifndef htmlAttrAllowed
+extern __typeof (htmlAttrAllowed) htmlAttrAllowed__internal_alias __attribute((visibility("hidden")));
+#define htmlAttrAllowed htmlAttrAllowed__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlAutoCloseTag
+extern __typeof (htmlAutoCloseTag) htmlAutoCloseTag __attribute((alias("htmlAutoCloseTag__internal_alias")));
+#else
+#ifndef htmlAutoCloseTag
+extern __typeof (htmlAutoCloseTag) htmlAutoCloseTag__internal_alias __attribute((visibility("hidden")));
+#define htmlAutoCloseTag htmlAutoCloseTag__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlCreateFileParserCtxt
+extern __typeof (htmlCreateFileParserCtxt) htmlCreateFileParserCtxt __attribute((alias("htmlCreateFileParserCtxt__internal_alias")));
+#else
+#ifndef htmlCreateFileParserCtxt
+extern __typeof (htmlCreateFileParserCtxt) htmlCreateFileParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define htmlCreateFileParserCtxt htmlCreateFileParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlCreateMemoryParserCtxt
+extern __typeof (htmlCreateMemoryParserCtxt) htmlCreateMemoryParserCtxt __attribute((alias("htmlCreateMemoryParserCtxt__internal_alias")));
+#else
+#ifndef htmlCreateMemoryParserCtxt
+extern __typeof (htmlCreateMemoryParserCtxt) htmlCreateMemoryParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define htmlCreateMemoryParserCtxt htmlCreateMemoryParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_PUSH_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlCreatePushParserCtxt
+extern __typeof (htmlCreatePushParserCtxt) htmlCreatePushParserCtxt __attribute((alias("htmlCreatePushParserCtxt__internal_alias")));
+#else
+#ifndef htmlCreatePushParserCtxt
+extern __typeof (htmlCreatePushParserCtxt) htmlCreatePushParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define htmlCreatePushParserCtxt htmlCreatePushParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlCtxtReadDoc
+extern __typeof (htmlCtxtReadDoc) htmlCtxtReadDoc __attribute((alias("htmlCtxtReadDoc__internal_alias")));
+#else
+#ifndef htmlCtxtReadDoc
+extern __typeof (htmlCtxtReadDoc) htmlCtxtReadDoc__internal_alias __attribute((visibility("hidden")));
+#define htmlCtxtReadDoc htmlCtxtReadDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlCtxtReadFd
+extern __typeof (htmlCtxtReadFd) htmlCtxtReadFd __attribute((alias("htmlCtxtReadFd__internal_alias")));
+#else
+#ifndef htmlCtxtReadFd
+extern __typeof (htmlCtxtReadFd) htmlCtxtReadFd__internal_alias __attribute((visibility("hidden")));
+#define htmlCtxtReadFd htmlCtxtReadFd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlCtxtReadFile
+extern __typeof (htmlCtxtReadFile) htmlCtxtReadFile __attribute((alias("htmlCtxtReadFile__internal_alias")));
+#else
+#ifndef htmlCtxtReadFile
+extern __typeof (htmlCtxtReadFile) htmlCtxtReadFile__internal_alias __attribute((visibility("hidden")));
+#define htmlCtxtReadFile htmlCtxtReadFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlCtxtReadIO
+extern __typeof (htmlCtxtReadIO) htmlCtxtReadIO __attribute((alias("htmlCtxtReadIO__internal_alias")));
+#else
+#ifndef htmlCtxtReadIO
+extern __typeof (htmlCtxtReadIO) htmlCtxtReadIO__internal_alias __attribute((visibility("hidden")));
+#define htmlCtxtReadIO htmlCtxtReadIO__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlCtxtReadMemory
+extern __typeof (htmlCtxtReadMemory) htmlCtxtReadMemory __attribute((alias("htmlCtxtReadMemory__internal_alias")));
+#else
+#ifndef htmlCtxtReadMemory
+extern __typeof (htmlCtxtReadMemory) htmlCtxtReadMemory__internal_alias __attribute((visibility("hidden")));
+#define htmlCtxtReadMemory htmlCtxtReadMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlCtxtReset
+extern __typeof (htmlCtxtReset) htmlCtxtReset __attribute((alias("htmlCtxtReset__internal_alias")));
+#else
+#ifndef htmlCtxtReset
+extern __typeof (htmlCtxtReset) htmlCtxtReset__internal_alias __attribute((visibility("hidden")));
+#define htmlCtxtReset htmlCtxtReset__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlCtxtUseOptions
+extern __typeof (htmlCtxtUseOptions) htmlCtxtUseOptions __attribute((alias("htmlCtxtUseOptions__internal_alias")));
+#else
+#ifndef htmlCtxtUseOptions
+extern __typeof (htmlCtxtUseOptions) htmlCtxtUseOptions__internal_alias __attribute((visibility("hidden")));
+#define htmlCtxtUseOptions htmlCtxtUseOptions__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_SAX2
+#undef htmlDefaultSAXHandlerInit
+extern __typeof (htmlDefaultSAXHandlerInit) htmlDefaultSAXHandlerInit __attribute((alias("htmlDefaultSAXHandlerInit__internal_alias")));
+#else
+#ifndef htmlDefaultSAXHandlerInit
+extern __typeof (htmlDefaultSAXHandlerInit) htmlDefaultSAXHandlerInit__internal_alias __attribute((visibility("hidden")));
+#define htmlDefaultSAXHandlerInit htmlDefaultSAXHandlerInit__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlDocContentDumpFormatOutput
+extern __typeof (htmlDocContentDumpFormatOutput) htmlDocContentDumpFormatOutput __attribute((alias("htmlDocContentDumpFormatOutput__internal_alias")));
+#else
+#ifndef htmlDocContentDumpFormatOutput
+extern __typeof (htmlDocContentDumpFormatOutput) htmlDocContentDumpFormatOutput__internal_alias __attribute((visibility("hidden")));
+#define htmlDocContentDumpFormatOutput htmlDocContentDumpFormatOutput__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlDocContentDumpOutput
+extern __typeof (htmlDocContentDumpOutput) htmlDocContentDumpOutput __attribute((alias("htmlDocContentDumpOutput__internal_alias")));
+#else
+#ifndef htmlDocContentDumpOutput
+extern __typeof (htmlDocContentDumpOutput) htmlDocContentDumpOutput__internal_alias __attribute((visibility("hidden")));
+#define htmlDocContentDumpOutput htmlDocContentDumpOutput__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlDocDump
+extern __typeof (htmlDocDump) htmlDocDump __attribute((alias("htmlDocDump__internal_alias")));
+#else
+#ifndef htmlDocDump
+extern __typeof (htmlDocDump) htmlDocDump__internal_alias __attribute((visibility("hidden")));
+#define htmlDocDump htmlDocDump__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlDocDumpMemory
+extern __typeof (htmlDocDumpMemory) htmlDocDumpMemory __attribute((alias("htmlDocDumpMemory__internal_alias")));
+#else
+#ifndef htmlDocDumpMemory
+extern __typeof (htmlDocDumpMemory) htmlDocDumpMemory__internal_alias __attribute((visibility("hidden")));
+#define htmlDocDumpMemory htmlDocDumpMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlDocDumpMemoryFormat
+extern __typeof (htmlDocDumpMemoryFormat) htmlDocDumpMemoryFormat __attribute((alias("htmlDocDumpMemoryFormat__internal_alias")));
+#else
+#ifndef htmlDocDumpMemoryFormat
+extern __typeof (htmlDocDumpMemoryFormat) htmlDocDumpMemoryFormat__internal_alias __attribute((visibility("hidden")));
+#define htmlDocDumpMemoryFormat htmlDocDumpMemoryFormat__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlElementAllowedHere
+extern __typeof (htmlElementAllowedHere) htmlElementAllowedHere __attribute((alias("htmlElementAllowedHere__internal_alias")));
+#else
+#ifndef htmlElementAllowedHere
+extern __typeof (htmlElementAllowedHere) htmlElementAllowedHere__internal_alias __attribute((visibility("hidden")));
+#define htmlElementAllowedHere htmlElementAllowedHere__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlElementStatusHere
+extern __typeof (htmlElementStatusHere) htmlElementStatusHere __attribute((alias("htmlElementStatusHere__internal_alias")));
+#else
+#ifndef htmlElementStatusHere
+extern __typeof (htmlElementStatusHere) htmlElementStatusHere__internal_alias __attribute((visibility("hidden")));
+#define htmlElementStatusHere htmlElementStatusHere__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlEncodeEntities
+extern __typeof (htmlEncodeEntities) htmlEncodeEntities __attribute((alias("htmlEncodeEntities__internal_alias")));
+#else
+#ifndef htmlEncodeEntities
+extern __typeof (htmlEncodeEntities) htmlEncodeEntities__internal_alias __attribute((visibility("hidden")));
+#define htmlEncodeEntities htmlEncodeEntities__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlEntityLookup
+extern __typeof (htmlEntityLookup) htmlEntityLookup __attribute((alias("htmlEntityLookup__internal_alias")));
+#else
+#ifndef htmlEntityLookup
+extern __typeof (htmlEntityLookup) htmlEntityLookup__internal_alias __attribute((visibility("hidden")));
+#define htmlEntityLookup htmlEntityLookup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlEntityValueLookup
+extern __typeof (htmlEntityValueLookup) htmlEntityValueLookup __attribute((alias("htmlEntityValueLookup__internal_alias")));
+#else
+#ifndef htmlEntityValueLookup
+extern __typeof (htmlEntityValueLookup) htmlEntityValueLookup__internal_alias __attribute((visibility("hidden")));
+#define htmlEntityValueLookup htmlEntityValueLookup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlFreeParserCtxt
+extern __typeof (htmlFreeParserCtxt) htmlFreeParserCtxt __attribute((alias("htmlFreeParserCtxt__internal_alias")));
+#else
+#ifndef htmlFreeParserCtxt
+extern __typeof (htmlFreeParserCtxt) htmlFreeParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define htmlFreeParserCtxt htmlFreeParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlGetMetaEncoding
+extern __typeof (htmlGetMetaEncoding) htmlGetMetaEncoding __attribute((alias("htmlGetMetaEncoding__internal_alias")));
+#else
+#ifndef htmlGetMetaEncoding
+extern __typeof (htmlGetMetaEncoding) htmlGetMetaEncoding__internal_alias __attribute((visibility("hidden")));
+#define htmlGetMetaEncoding htmlGetMetaEncoding__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlHandleOmittedElem
+extern __typeof (htmlHandleOmittedElem) htmlHandleOmittedElem __attribute((alias("htmlHandleOmittedElem__internal_alias")));
+#else
+#ifndef htmlHandleOmittedElem
+extern __typeof (htmlHandleOmittedElem) htmlHandleOmittedElem__internal_alias __attribute((visibility("hidden")));
+#define htmlHandleOmittedElem htmlHandleOmittedElem__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlInitAutoClose
+extern __typeof (htmlInitAutoClose) htmlInitAutoClose __attribute((alias("htmlInitAutoClose__internal_alias")));
+#else
+#ifndef htmlInitAutoClose
+extern __typeof (htmlInitAutoClose) htmlInitAutoClose__internal_alias __attribute((visibility("hidden")));
+#define htmlInitAutoClose htmlInitAutoClose__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlIsAutoClosed
+extern __typeof (htmlIsAutoClosed) htmlIsAutoClosed __attribute((alias("htmlIsAutoClosed__internal_alias")));
+#else
+#ifndef htmlIsAutoClosed
+extern __typeof (htmlIsAutoClosed) htmlIsAutoClosed__internal_alias __attribute((visibility("hidden")));
+#define htmlIsAutoClosed htmlIsAutoClosed__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlIsBooleanAttr
+extern __typeof (htmlIsBooleanAttr) htmlIsBooleanAttr __attribute((alias("htmlIsBooleanAttr__internal_alias")));
+#else
+#ifndef htmlIsBooleanAttr
+extern __typeof (htmlIsBooleanAttr) htmlIsBooleanAttr__internal_alias __attribute((visibility("hidden")));
+#define htmlIsBooleanAttr htmlIsBooleanAttr__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlIsScriptAttribute
+extern __typeof (htmlIsScriptAttribute) htmlIsScriptAttribute __attribute((alias("htmlIsScriptAttribute__internal_alias")));
+#else
+#ifndef htmlIsScriptAttribute
+extern __typeof (htmlIsScriptAttribute) htmlIsScriptAttribute__internal_alias __attribute((visibility("hidden")));
+#define htmlIsScriptAttribute htmlIsScriptAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlNewDoc
+extern __typeof (htmlNewDoc) htmlNewDoc __attribute((alias("htmlNewDoc__internal_alias")));
+#else
+#ifndef htmlNewDoc
+extern __typeof (htmlNewDoc) htmlNewDoc__internal_alias __attribute((visibility("hidden")));
+#define htmlNewDoc htmlNewDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlNewDocNoDtD
+extern __typeof (htmlNewDocNoDtD) htmlNewDocNoDtD __attribute((alias("htmlNewDocNoDtD__internal_alias")));
+#else
+#ifndef htmlNewDocNoDtD
+extern __typeof (htmlNewDocNoDtD) htmlNewDocNoDtD__internal_alias __attribute((visibility("hidden")));
+#define htmlNewDocNoDtD htmlNewDocNoDtD__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlNewParserCtxt
+extern __typeof (htmlNewParserCtxt) htmlNewParserCtxt __attribute((alias("htmlNewParserCtxt__internal_alias")));
+#else
+#ifndef htmlNewParserCtxt
+extern __typeof (htmlNewParserCtxt) htmlNewParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define htmlNewParserCtxt htmlNewParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlNodeDump
+extern __typeof (htmlNodeDump) htmlNodeDump __attribute((alias("htmlNodeDump__internal_alias")));
+#else
+#ifndef htmlNodeDump
+extern __typeof (htmlNodeDump) htmlNodeDump__internal_alias __attribute((visibility("hidden")));
+#define htmlNodeDump htmlNodeDump__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlNodeDumpFile
+extern __typeof (htmlNodeDumpFile) htmlNodeDumpFile __attribute((alias("htmlNodeDumpFile__internal_alias")));
+#else
+#ifndef htmlNodeDumpFile
+extern __typeof (htmlNodeDumpFile) htmlNodeDumpFile__internal_alias __attribute((visibility("hidden")));
+#define htmlNodeDumpFile htmlNodeDumpFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlNodeDumpFileFormat
+extern __typeof (htmlNodeDumpFileFormat) htmlNodeDumpFileFormat __attribute((alias("htmlNodeDumpFileFormat__internal_alias")));
+#else
+#ifndef htmlNodeDumpFileFormat
+extern __typeof (htmlNodeDumpFileFormat) htmlNodeDumpFileFormat__internal_alias __attribute((visibility("hidden")));
+#define htmlNodeDumpFileFormat htmlNodeDumpFileFormat__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlNodeDumpFormatOutput
+extern __typeof (htmlNodeDumpFormatOutput) htmlNodeDumpFormatOutput __attribute((alias("htmlNodeDumpFormatOutput__internal_alias")));
+#else
+#ifndef htmlNodeDumpFormatOutput
+extern __typeof (htmlNodeDumpFormatOutput) htmlNodeDumpFormatOutput__internal_alias __attribute((visibility("hidden")));
+#define htmlNodeDumpFormatOutput htmlNodeDumpFormatOutput__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlNodeDumpOutput
+extern __typeof (htmlNodeDumpOutput) htmlNodeDumpOutput __attribute((alias("htmlNodeDumpOutput__internal_alias")));
+#else
+#ifndef htmlNodeDumpOutput
+extern __typeof (htmlNodeDumpOutput) htmlNodeDumpOutput__internal_alias __attribute((visibility("hidden")));
+#define htmlNodeDumpOutput htmlNodeDumpOutput__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlNodeStatus
+extern __typeof (htmlNodeStatus) htmlNodeStatus __attribute((alias("htmlNodeStatus__internal_alias")));
+#else
+#ifndef htmlNodeStatus
+extern __typeof (htmlNodeStatus) htmlNodeStatus__internal_alias __attribute((visibility("hidden")));
+#define htmlNodeStatus htmlNodeStatus__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlParseCharRef
+extern __typeof (htmlParseCharRef) htmlParseCharRef __attribute((alias("htmlParseCharRef__internal_alias")));
+#else
+#ifndef htmlParseCharRef
+extern __typeof (htmlParseCharRef) htmlParseCharRef__internal_alias __attribute((visibility("hidden")));
+#define htmlParseCharRef htmlParseCharRef__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_PUSH_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlParseChunk
+extern __typeof (htmlParseChunk) htmlParseChunk __attribute((alias("htmlParseChunk__internal_alias")));
+#else
+#ifndef htmlParseChunk
+extern __typeof (htmlParseChunk) htmlParseChunk__internal_alias __attribute((visibility("hidden")));
+#define htmlParseChunk htmlParseChunk__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlParseDoc
+extern __typeof (htmlParseDoc) htmlParseDoc __attribute((alias("htmlParseDoc__internal_alias")));
+#else
+#ifndef htmlParseDoc
+extern __typeof (htmlParseDoc) htmlParseDoc__internal_alias __attribute((visibility("hidden")));
+#define htmlParseDoc htmlParseDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlParseDocument
+extern __typeof (htmlParseDocument) htmlParseDocument __attribute((alias("htmlParseDocument__internal_alias")));
+#else
+#ifndef htmlParseDocument
+extern __typeof (htmlParseDocument) htmlParseDocument__internal_alias __attribute((visibility("hidden")));
+#define htmlParseDocument htmlParseDocument__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlParseElement
+extern __typeof (htmlParseElement) htmlParseElement __attribute((alias("htmlParseElement__internal_alias")));
+#else
+#ifndef htmlParseElement
+extern __typeof (htmlParseElement) htmlParseElement__internal_alias __attribute((visibility("hidden")));
+#define htmlParseElement htmlParseElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlParseEntityRef
+extern __typeof (htmlParseEntityRef) htmlParseEntityRef __attribute((alias("htmlParseEntityRef__internal_alias")));
+#else
+#ifndef htmlParseEntityRef
+extern __typeof (htmlParseEntityRef) htmlParseEntityRef__internal_alias __attribute((visibility("hidden")));
+#define htmlParseEntityRef htmlParseEntityRef__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlParseFile
+extern __typeof (htmlParseFile) htmlParseFile __attribute((alias("htmlParseFile__internal_alias")));
+#else
+#ifndef htmlParseFile
+extern __typeof (htmlParseFile) htmlParseFile__internal_alias __attribute((visibility("hidden")));
+#define htmlParseFile htmlParseFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlReadDoc
+extern __typeof (htmlReadDoc) htmlReadDoc __attribute((alias("htmlReadDoc__internal_alias")));
+#else
+#ifndef htmlReadDoc
+extern __typeof (htmlReadDoc) htmlReadDoc__internal_alias __attribute((visibility("hidden")));
+#define htmlReadDoc htmlReadDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlReadFd
+extern __typeof (htmlReadFd) htmlReadFd __attribute((alias("htmlReadFd__internal_alias")));
+#else
+#ifndef htmlReadFd
+extern __typeof (htmlReadFd) htmlReadFd__internal_alias __attribute((visibility("hidden")));
+#define htmlReadFd htmlReadFd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlReadFile
+extern __typeof (htmlReadFile) htmlReadFile __attribute((alias("htmlReadFile__internal_alias")));
+#else
+#ifndef htmlReadFile
+extern __typeof (htmlReadFile) htmlReadFile__internal_alias __attribute((visibility("hidden")));
+#define htmlReadFile htmlReadFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlReadIO
+extern __typeof (htmlReadIO) htmlReadIO __attribute((alias("htmlReadIO__internal_alias")));
+#else
+#ifndef htmlReadIO
+extern __typeof (htmlReadIO) htmlReadIO__internal_alias __attribute((visibility("hidden")));
+#define htmlReadIO htmlReadIO__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlReadMemory
+extern __typeof (htmlReadMemory) htmlReadMemory __attribute((alias("htmlReadMemory__internal_alias")));
+#else
+#ifndef htmlReadMemory
+extern __typeof (htmlReadMemory) htmlReadMemory__internal_alias __attribute((visibility("hidden")));
+#define htmlReadMemory htmlReadMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlSAXParseDoc
+extern __typeof (htmlSAXParseDoc) htmlSAXParseDoc __attribute((alias("htmlSAXParseDoc__internal_alias")));
+#else
+#ifndef htmlSAXParseDoc
+extern __typeof (htmlSAXParseDoc) htmlSAXParseDoc__internal_alias __attribute((visibility("hidden")));
+#define htmlSAXParseDoc htmlSAXParseDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlSAXParseFile
+extern __typeof (htmlSAXParseFile) htmlSAXParseFile __attribute((alias("htmlSAXParseFile__internal_alias")));
+#else
+#ifndef htmlSAXParseFile
+extern __typeof (htmlSAXParseFile) htmlSAXParseFile__internal_alias __attribute((visibility("hidden")));
+#define htmlSAXParseFile htmlSAXParseFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlSaveFile
+extern __typeof (htmlSaveFile) htmlSaveFile __attribute((alias("htmlSaveFile__internal_alias")));
+#else
+#ifndef htmlSaveFile
+extern __typeof (htmlSaveFile) htmlSaveFile__internal_alias __attribute((visibility("hidden")));
+#define htmlSaveFile htmlSaveFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlSaveFileEnc
+extern __typeof (htmlSaveFileEnc) htmlSaveFileEnc __attribute((alias("htmlSaveFileEnc__internal_alias")));
+#else
+#ifndef htmlSaveFileEnc
+extern __typeof (htmlSaveFileEnc) htmlSaveFileEnc__internal_alias __attribute((visibility("hidden")));
+#define htmlSaveFileEnc htmlSaveFileEnc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlSaveFileFormat
+extern __typeof (htmlSaveFileFormat) htmlSaveFileFormat __attribute((alias("htmlSaveFileFormat__internal_alias")));
+#else
+#ifndef htmlSaveFileFormat
+extern __typeof (htmlSaveFileFormat) htmlSaveFileFormat__internal_alias __attribute((visibility("hidden")));
+#define htmlSaveFileFormat htmlSaveFileFormat__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLtree
+#undef htmlSetMetaEncoding
+extern __typeof (htmlSetMetaEncoding) htmlSetMetaEncoding __attribute((alias("htmlSetMetaEncoding__internal_alias")));
+#else
+#ifndef htmlSetMetaEncoding
+extern __typeof (htmlSetMetaEncoding) htmlSetMetaEncoding__internal_alias __attribute((visibility("hidden")));
+#define htmlSetMetaEncoding htmlSetMetaEncoding__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_HTMLparser
+#undef htmlTagLookup
+extern __typeof (htmlTagLookup) htmlTagLookup __attribute((alias("htmlTagLookup__internal_alias")));
+#else
+#ifndef htmlTagLookup
+extern __typeof (htmlTagLookup) htmlTagLookup__internal_alias __attribute((visibility("hidden")));
+#define htmlTagLookup htmlTagLookup__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef inputPop
+extern __typeof (inputPop) inputPop __attribute((alias("inputPop__internal_alias")));
+#else
+#ifndef inputPop
+extern __typeof (inputPop) inputPop__internal_alias __attribute((visibility("hidden")));
+#define inputPop inputPop__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef inputPush
+extern __typeof (inputPush) inputPush __attribute((alias("inputPush__internal_alias")));
+#else
+#ifndef inputPush
+extern __typeof (inputPush) inputPush__internal_alias __attribute((visibility("hidden")));
+#define inputPush inputPush__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef namePop
+extern __typeof (namePop) namePop __attribute((alias("namePop__internal_alias")));
+#else
+#ifndef namePop
+extern __typeof (namePop) namePop__internal_alias __attribute((visibility("hidden")));
+#define namePop namePop__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef namePush
+extern __typeof (namePush) namePush __attribute((alias("namePush__internal_alias")));
+#else
+#ifndef namePush
+extern __typeof (namePush) namePush__internal_alias __attribute((visibility("hidden")));
+#define namePush namePush__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef nodePop
+extern __typeof (nodePop) nodePop __attribute((alias("nodePop__internal_alias")));
+#else
+#ifndef nodePop
+extern __typeof (nodePop) nodePop__internal_alias __attribute((visibility("hidden")));
+#define nodePop nodePop__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef nodePush
+extern __typeof (nodePush) nodePush __attribute((alias("nodePush__internal_alias")));
+#else
+#ifndef nodePush
+extern __typeof (nodePush) nodePush__internal_alias __attribute((visibility("hidden")));
+#define nodePush nodePush__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef valuePop
+extern __typeof (valuePop) valuePop __attribute((alias("valuePop__internal_alias")));
+#else
+#ifndef valuePop
+extern __typeof (valuePop) valuePop__internal_alias __attribute((visibility("hidden")));
+#define valuePop valuePop__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef valuePush
+extern __typeof (valuePush) valuePush __attribute((alias("valuePush__internal_alias")));
+#else
+#ifndef valuePush
+extern __typeof (valuePush) valuePush__internal_alias __attribute((visibility("hidden")));
+#define valuePush valuePush__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlACatalogAdd
+extern __typeof (xmlACatalogAdd) xmlACatalogAdd __attribute((alias("xmlACatalogAdd__internal_alias")));
+#else
+#ifndef xmlACatalogAdd
+extern __typeof (xmlACatalogAdd) xmlACatalogAdd__internal_alias __attribute((visibility("hidden")));
+#define xmlACatalogAdd xmlACatalogAdd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_catalog
+#undef xmlACatalogDump
+extern __typeof (xmlACatalogDump) xmlACatalogDump __attribute((alias("xmlACatalogDump__internal_alias")));
+#else
+#ifndef xmlACatalogDump
+extern __typeof (xmlACatalogDump) xmlACatalogDump__internal_alias __attribute((visibility("hidden")));
+#define xmlACatalogDump xmlACatalogDump__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlACatalogRemove
+extern __typeof (xmlACatalogRemove) xmlACatalogRemove __attribute((alias("xmlACatalogRemove__internal_alias")));
+#else
+#ifndef xmlACatalogRemove
+extern __typeof (xmlACatalogRemove) xmlACatalogRemove__internal_alias __attribute((visibility("hidden")));
+#define xmlACatalogRemove xmlACatalogRemove__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlACatalogResolve
+extern __typeof (xmlACatalogResolve) xmlACatalogResolve __attribute((alias("xmlACatalogResolve__internal_alias")));
+#else
+#ifndef xmlACatalogResolve
+extern __typeof (xmlACatalogResolve) xmlACatalogResolve__internal_alias __attribute((visibility("hidden")));
+#define xmlACatalogResolve xmlACatalogResolve__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlACatalogResolvePublic
+extern __typeof (xmlACatalogResolvePublic) xmlACatalogResolvePublic __attribute((alias("xmlACatalogResolvePublic__internal_alias")));
+#else
+#ifndef xmlACatalogResolvePublic
+extern __typeof (xmlACatalogResolvePublic) xmlACatalogResolvePublic__internal_alias __attribute((visibility("hidden")));
+#define xmlACatalogResolvePublic xmlACatalogResolvePublic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlACatalogResolveSystem
+extern __typeof (xmlACatalogResolveSystem) xmlACatalogResolveSystem __attribute((alias("xmlACatalogResolveSystem__internal_alias")));
+#else
+#ifndef xmlACatalogResolveSystem
+extern __typeof (xmlACatalogResolveSystem) xmlACatalogResolveSystem__internal_alias __attribute((visibility("hidden")));
+#define xmlACatalogResolveSystem xmlACatalogResolveSystem__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlACatalogResolveURI
+extern __typeof (xmlACatalogResolveURI) xmlACatalogResolveURI __attribute((alias("xmlACatalogResolveURI__internal_alias")));
+#else
+#ifndef xmlACatalogResolveURI
+extern __typeof (xmlACatalogResolveURI) xmlACatalogResolveURI__internal_alias __attribute((visibility("hidden")));
+#define xmlACatalogResolveURI xmlACatalogResolveURI__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlAddAttributeDecl
+extern __typeof (xmlAddAttributeDecl) xmlAddAttributeDecl __attribute((alias("xmlAddAttributeDecl__internal_alias")));
+#else
+#ifndef xmlAddAttributeDecl
+extern __typeof (xmlAddAttributeDecl) xmlAddAttributeDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlAddAttributeDecl xmlAddAttributeDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlAddChild
+extern __typeof (xmlAddChild) xmlAddChild __attribute((alias("xmlAddChild__internal_alias")));
+#else
+#ifndef xmlAddChild
+extern __typeof (xmlAddChild) xmlAddChild__internal_alias __attribute((visibility("hidden")));
+#define xmlAddChild xmlAddChild__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlAddChildList
+extern __typeof (xmlAddChildList) xmlAddChildList __attribute((alias("xmlAddChildList__internal_alias")));
+#else
+#ifndef xmlAddChildList
+extern __typeof (xmlAddChildList) xmlAddChildList__internal_alias __attribute((visibility("hidden")));
+#define xmlAddChildList xmlAddChildList__internal_alias
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlAddDocEntity
+extern __typeof (xmlAddDocEntity) xmlAddDocEntity __attribute((alias("xmlAddDocEntity__internal_alias")));
+#else
+#ifndef xmlAddDocEntity
+extern __typeof (xmlAddDocEntity) xmlAddDocEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlAddDocEntity xmlAddDocEntity__internal_alias
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlAddDtdEntity
+extern __typeof (xmlAddDtdEntity) xmlAddDtdEntity __attribute((alias("xmlAddDtdEntity__internal_alias")));
+#else
+#ifndef xmlAddDtdEntity
+extern __typeof (xmlAddDtdEntity) xmlAddDtdEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlAddDtdEntity xmlAddDtdEntity__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlAddElementDecl
+extern __typeof (xmlAddElementDecl) xmlAddElementDecl __attribute((alias("xmlAddElementDecl__internal_alias")));
+#else
+#ifndef xmlAddElementDecl
+extern __typeof (xmlAddElementDecl) xmlAddElementDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlAddElementDecl xmlAddElementDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlAddEncodingAlias
+extern __typeof (xmlAddEncodingAlias) xmlAddEncodingAlias __attribute((alias("xmlAddEncodingAlias__internal_alias")));
+#else
+#ifndef xmlAddEncodingAlias
+extern __typeof (xmlAddEncodingAlias) xmlAddEncodingAlias__internal_alias __attribute((visibility("hidden")));
+#define xmlAddEncodingAlias xmlAddEncodingAlias__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlAddID
+extern __typeof (xmlAddID) xmlAddID __attribute((alias("xmlAddID__internal_alias")));
+#else
+#ifndef xmlAddID
+extern __typeof (xmlAddID) xmlAddID__internal_alias __attribute((visibility("hidden")));
+#define xmlAddID xmlAddID__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlAddNextSibling
+extern __typeof (xmlAddNextSibling) xmlAddNextSibling __attribute((alias("xmlAddNextSibling__internal_alias")));
+#else
+#ifndef xmlAddNextSibling
+extern __typeof (xmlAddNextSibling) xmlAddNextSibling__internal_alias __attribute((visibility("hidden")));
+#define xmlAddNextSibling xmlAddNextSibling__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlAddNotationDecl
+extern __typeof (xmlAddNotationDecl) xmlAddNotationDecl __attribute((alias("xmlAddNotationDecl__internal_alias")));
+#else
+#ifndef xmlAddNotationDecl
+extern __typeof (xmlAddNotationDecl) xmlAddNotationDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlAddNotationDecl xmlAddNotationDecl__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_tree
+#undef xmlAddPrevSibling
+extern __typeof (xmlAddPrevSibling) xmlAddPrevSibling __attribute((alias("xmlAddPrevSibling__internal_alias")));
+#else
+#ifndef xmlAddPrevSibling
+extern __typeof (xmlAddPrevSibling) xmlAddPrevSibling__internal_alias __attribute((visibility("hidden")));
+#define xmlAddPrevSibling xmlAddPrevSibling__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlAddRef
+extern __typeof (xmlAddRef) xmlAddRef __attribute((alias("xmlAddRef__internal_alias")));
+#else
+#ifndef xmlAddRef
+extern __typeof (xmlAddRef) xmlAddRef__internal_alias __attribute((visibility("hidden")));
+#define xmlAddRef xmlAddRef__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlAddSibling
+extern __typeof (xmlAddSibling) xmlAddSibling __attribute((alias("xmlAddSibling__internal_alias")));
+#else
+#ifndef xmlAddSibling
+extern __typeof (xmlAddSibling) xmlAddSibling__internal_alias __attribute((visibility("hidden")));
+#define xmlAddSibling xmlAddSibling__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlAllocOutputBuffer
+extern __typeof (xmlAllocOutputBuffer) xmlAllocOutputBuffer __attribute((alias("xmlAllocOutputBuffer__internal_alias")));
+#else
+#ifndef xmlAllocOutputBuffer
+extern __typeof (xmlAllocOutputBuffer) xmlAllocOutputBuffer__internal_alias __attribute((visibility("hidden")));
+#define xmlAllocOutputBuffer xmlAllocOutputBuffer__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlAllocParserInputBuffer
+extern __typeof (xmlAllocParserInputBuffer) xmlAllocParserInputBuffer __attribute((alias("xmlAllocParserInputBuffer__internal_alias")));
+#else
+#ifndef xmlAllocParserInputBuffer
+extern __typeof (xmlAllocParserInputBuffer) xmlAllocParserInputBuffer__internal_alias __attribute((visibility("hidden")));
+#define xmlAllocParserInputBuffer xmlAllocParserInputBuffer__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlAttrSerializeTxtContent
+extern __typeof (xmlAttrSerializeTxtContent) xmlAttrSerializeTxtContent __attribute((alias("xmlAttrSerializeTxtContent__internal_alias")));
+#else
+#ifndef xmlAttrSerializeTxtContent
+extern __typeof (xmlAttrSerializeTxtContent) xmlAttrSerializeTxtContent__internal_alias __attribute((visibility("hidden")));
+#define xmlAttrSerializeTxtContent xmlAttrSerializeTxtContent__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataCompile
+extern __typeof (xmlAutomataCompile) xmlAutomataCompile __attribute((alias("xmlAutomataCompile__internal_alias")));
+#else
+#ifndef xmlAutomataCompile
+extern __typeof (xmlAutomataCompile) xmlAutomataCompile__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataCompile xmlAutomataCompile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataGetInitState
+extern __typeof (xmlAutomataGetInitState) xmlAutomataGetInitState __attribute((alias("xmlAutomataGetInitState__internal_alias")));
+#else
+#ifndef xmlAutomataGetInitState
+extern __typeof (xmlAutomataGetInitState) xmlAutomataGetInitState__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataGetInitState xmlAutomataGetInitState__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataIsDeterminist
+extern __typeof (xmlAutomataIsDeterminist) xmlAutomataIsDeterminist __attribute((alias("xmlAutomataIsDeterminist__internal_alias")));
+#else
+#ifndef xmlAutomataIsDeterminist
+extern __typeof (xmlAutomataIsDeterminist) xmlAutomataIsDeterminist__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataIsDeterminist xmlAutomataIsDeterminist__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewAllTrans
+extern __typeof (xmlAutomataNewAllTrans) xmlAutomataNewAllTrans __attribute((alias("xmlAutomataNewAllTrans__internal_alias")));
+#else
+#ifndef xmlAutomataNewAllTrans
+extern __typeof (xmlAutomataNewAllTrans) xmlAutomataNewAllTrans__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewAllTrans xmlAutomataNewAllTrans__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewCountTrans
+extern __typeof (xmlAutomataNewCountTrans) xmlAutomataNewCountTrans __attribute((alias("xmlAutomataNewCountTrans__internal_alias")));
+#else
+#ifndef xmlAutomataNewCountTrans
+extern __typeof (xmlAutomataNewCountTrans) xmlAutomataNewCountTrans__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewCountTrans xmlAutomataNewCountTrans__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewCountTrans2
+extern __typeof (xmlAutomataNewCountTrans2) xmlAutomataNewCountTrans2 __attribute((alias("xmlAutomataNewCountTrans2__internal_alias")));
+#else
+#ifndef xmlAutomataNewCountTrans2
+extern __typeof (xmlAutomataNewCountTrans2) xmlAutomataNewCountTrans2__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewCountTrans2 xmlAutomataNewCountTrans2__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewCountedTrans
+extern __typeof (xmlAutomataNewCountedTrans) xmlAutomataNewCountedTrans __attribute((alias("xmlAutomataNewCountedTrans__internal_alias")));
+#else
+#ifndef xmlAutomataNewCountedTrans
+extern __typeof (xmlAutomataNewCountedTrans) xmlAutomataNewCountedTrans__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewCountedTrans xmlAutomataNewCountedTrans__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewCounter
+extern __typeof (xmlAutomataNewCounter) xmlAutomataNewCounter __attribute((alias("xmlAutomataNewCounter__internal_alias")));
+#else
+#ifndef xmlAutomataNewCounter
+extern __typeof (xmlAutomataNewCounter) xmlAutomataNewCounter__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewCounter xmlAutomataNewCounter__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewCounterTrans
+extern __typeof (xmlAutomataNewCounterTrans) xmlAutomataNewCounterTrans __attribute((alias("xmlAutomataNewCounterTrans__internal_alias")));
+#else
+#ifndef xmlAutomataNewCounterTrans
+extern __typeof (xmlAutomataNewCounterTrans) xmlAutomataNewCounterTrans__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewCounterTrans xmlAutomataNewCounterTrans__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewEpsilon
+extern __typeof (xmlAutomataNewEpsilon) xmlAutomataNewEpsilon __attribute((alias("xmlAutomataNewEpsilon__internal_alias")));
+#else
+#ifndef xmlAutomataNewEpsilon
+extern __typeof (xmlAutomataNewEpsilon) xmlAutomataNewEpsilon__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewEpsilon xmlAutomataNewEpsilon__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewNegTrans
+extern __typeof (xmlAutomataNewNegTrans) xmlAutomataNewNegTrans __attribute((alias("xmlAutomataNewNegTrans__internal_alias")));
+#else
+#ifndef xmlAutomataNewNegTrans
+extern __typeof (xmlAutomataNewNegTrans) xmlAutomataNewNegTrans__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewNegTrans xmlAutomataNewNegTrans__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewOnceTrans
+extern __typeof (xmlAutomataNewOnceTrans) xmlAutomataNewOnceTrans __attribute((alias("xmlAutomataNewOnceTrans__internal_alias")));
+#else
+#ifndef xmlAutomataNewOnceTrans
+extern __typeof (xmlAutomataNewOnceTrans) xmlAutomataNewOnceTrans__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewOnceTrans xmlAutomataNewOnceTrans__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewOnceTrans2
+extern __typeof (xmlAutomataNewOnceTrans2) xmlAutomataNewOnceTrans2 __attribute((alias("xmlAutomataNewOnceTrans2__internal_alias")));
+#else
+#ifndef xmlAutomataNewOnceTrans2
+extern __typeof (xmlAutomataNewOnceTrans2) xmlAutomataNewOnceTrans2__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewOnceTrans2 xmlAutomataNewOnceTrans2__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewState
+extern __typeof (xmlAutomataNewState) xmlAutomataNewState __attribute((alias("xmlAutomataNewState__internal_alias")));
+#else
+#ifndef xmlAutomataNewState
+extern __typeof (xmlAutomataNewState) xmlAutomataNewState__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewState xmlAutomataNewState__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewTransition
+extern __typeof (xmlAutomataNewTransition) xmlAutomataNewTransition __attribute((alias("xmlAutomataNewTransition__internal_alias")));
+#else
+#ifndef xmlAutomataNewTransition
+extern __typeof (xmlAutomataNewTransition) xmlAutomataNewTransition__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewTransition xmlAutomataNewTransition__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataNewTransition2
+extern __typeof (xmlAutomataNewTransition2) xmlAutomataNewTransition2 __attribute((alias("xmlAutomataNewTransition2__internal_alias")));
+#else
+#ifndef xmlAutomataNewTransition2
+extern __typeof (xmlAutomataNewTransition2) xmlAutomataNewTransition2__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataNewTransition2 xmlAutomataNewTransition2__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlAutomataSetFinalState
+extern __typeof (xmlAutomataSetFinalState) xmlAutomataSetFinalState __attribute((alias("xmlAutomataSetFinalState__internal_alias")));
+#else
+#ifndef xmlAutomataSetFinalState
+extern __typeof (xmlAutomataSetFinalState) xmlAutomataSetFinalState__internal_alias __attribute((visibility("hidden")));
+#define xmlAutomataSetFinalState xmlAutomataSetFinalState__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlBoolToText
+extern __typeof (xmlBoolToText) xmlBoolToText __attribute((alias("xmlBoolToText__internal_alias")));
+#else
+#ifndef xmlBoolToText
+extern __typeof (xmlBoolToText) xmlBoolToText__internal_alias __attribute((visibility("hidden")));
+#define xmlBoolToText xmlBoolToText__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_buf
+#undef xmlBufContent
+extern __typeof (xmlBufContent) xmlBufContent __attribute((alias("xmlBufContent__internal_alias")));
+#else
+#ifndef xmlBufContent
+extern __typeof (xmlBufContent) xmlBufContent__internal_alias __attribute((visibility("hidden")));
+#define xmlBufContent xmlBufContent__internal_alias
+#endif
+#endif
+
+#ifdef bottom_buf
+#undef xmlBufEnd
+extern __typeof (xmlBufEnd) xmlBufEnd __attribute((alias("xmlBufEnd__internal_alias")));
+#else
+#ifndef xmlBufEnd
+extern __typeof (xmlBufEnd) xmlBufEnd__internal_alias __attribute((visibility("hidden")));
+#define xmlBufEnd xmlBufEnd__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufGetNodeContent
+extern __typeof (xmlBufGetNodeContent) xmlBufGetNodeContent __attribute((alias("xmlBufGetNodeContent__internal_alias")));
+#else
+#ifndef xmlBufGetNodeContent
+extern __typeof (xmlBufGetNodeContent) xmlBufGetNodeContent__internal_alias __attribute((visibility("hidden")));
+#define xmlBufGetNodeContent xmlBufGetNodeContent__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlBufNodeDump
+extern __typeof (xmlBufNodeDump) xmlBufNodeDump __attribute((alias("xmlBufNodeDump__internal_alias")));
+#else
+#ifndef xmlBufNodeDump
+extern __typeof (xmlBufNodeDump) xmlBufNodeDump__internal_alias __attribute((visibility("hidden")));
+#define xmlBufNodeDump xmlBufNodeDump__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_buf
+#undef xmlBufShrink
+extern __typeof (xmlBufShrink) xmlBufShrink __attribute((alias("xmlBufShrink__internal_alias")));
+#else
+#ifndef xmlBufShrink
+extern __typeof (xmlBufShrink) xmlBufShrink__internal_alias __attribute((visibility("hidden")));
+#define xmlBufShrink xmlBufShrink__internal_alias
+#endif
+#endif
+
+#ifdef bottom_buf
+#undef xmlBufUse
+extern __typeof (xmlBufUse) xmlBufUse __attribute((alias("xmlBufUse__internal_alias")));
+#else
+#ifndef xmlBufUse
+extern __typeof (xmlBufUse) xmlBufUse__internal_alias __attribute((visibility("hidden")));
+#define xmlBufUse xmlBufUse__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferAdd
+extern __typeof (xmlBufferAdd) xmlBufferAdd __attribute((alias("xmlBufferAdd__internal_alias")));
+#else
+#ifndef xmlBufferAdd
+extern __typeof (xmlBufferAdd) xmlBufferAdd__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferAdd xmlBufferAdd__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferAddHead
+extern __typeof (xmlBufferAddHead) xmlBufferAddHead __attribute((alias("xmlBufferAddHead__internal_alias")));
+#else
+#ifndef xmlBufferAddHead
+extern __typeof (xmlBufferAddHead) xmlBufferAddHead__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferAddHead xmlBufferAddHead__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferCCat
+extern __typeof (xmlBufferCCat) xmlBufferCCat __attribute((alias("xmlBufferCCat__internal_alias")));
+#else
+#ifndef xmlBufferCCat
+extern __typeof (xmlBufferCCat) xmlBufferCCat__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferCCat xmlBufferCCat__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferCat
+extern __typeof (xmlBufferCat) xmlBufferCat __attribute((alias("xmlBufferCat__internal_alias")));
+#else
+#ifndef xmlBufferCat
+extern __typeof (xmlBufferCat) xmlBufferCat__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferCat xmlBufferCat__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferContent
+extern __typeof (xmlBufferContent) xmlBufferContent __attribute((alias("xmlBufferContent__internal_alias")));
+#else
+#ifndef xmlBufferContent
+extern __typeof (xmlBufferContent) xmlBufferContent__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferContent xmlBufferContent__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferCreate
+extern __typeof (xmlBufferCreate) xmlBufferCreate __attribute((alias("xmlBufferCreate__internal_alias")));
+#else
+#ifndef xmlBufferCreate
+extern __typeof (xmlBufferCreate) xmlBufferCreate__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferCreate xmlBufferCreate__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferCreateSize
+extern __typeof (xmlBufferCreateSize) xmlBufferCreateSize __attribute((alias("xmlBufferCreateSize__internal_alias")));
+#else
+#ifndef xmlBufferCreateSize
+extern __typeof (xmlBufferCreateSize) xmlBufferCreateSize__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferCreateSize xmlBufferCreateSize__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferCreateStatic
+extern __typeof (xmlBufferCreateStatic) xmlBufferCreateStatic __attribute((alias("xmlBufferCreateStatic__internal_alias")));
+#else
+#ifndef xmlBufferCreateStatic
+extern __typeof (xmlBufferCreateStatic) xmlBufferCreateStatic__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferCreateStatic xmlBufferCreateStatic__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferDetach
+extern __typeof (xmlBufferDetach) xmlBufferDetach __attribute((alias("xmlBufferDetach__internal_alias")));
+#else
+#ifndef xmlBufferDetach
+extern __typeof (xmlBufferDetach) xmlBufferDetach__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferDetach xmlBufferDetach__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferDump
+extern __typeof (xmlBufferDump) xmlBufferDump __attribute((alias("xmlBufferDump__internal_alias")));
+#else
+#ifndef xmlBufferDump
+extern __typeof (xmlBufferDump) xmlBufferDump__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferDump xmlBufferDump__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferEmpty
+extern __typeof (xmlBufferEmpty) xmlBufferEmpty __attribute((alias("xmlBufferEmpty__internal_alias")));
+#else
+#ifndef xmlBufferEmpty
+extern __typeof (xmlBufferEmpty) xmlBufferEmpty__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferEmpty xmlBufferEmpty__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferFree
+extern __typeof (xmlBufferFree) xmlBufferFree __attribute((alias("xmlBufferFree__internal_alias")));
+#else
+#ifndef xmlBufferFree
+extern __typeof (xmlBufferFree) xmlBufferFree__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferFree xmlBufferFree__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferGrow
+extern __typeof (xmlBufferGrow) xmlBufferGrow __attribute((alias("xmlBufferGrow__internal_alias")));
+#else
+#ifndef xmlBufferGrow
+extern __typeof (xmlBufferGrow) xmlBufferGrow__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferGrow xmlBufferGrow__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferLength
+extern __typeof (xmlBufferLength) xmlBufferLength __attribute((alias("xmlBufferLength__internal_alias")));
+#else
+#ifndef xmlBufferLength
+extern __typeof (xmlBufferLength) xmlBufferLength__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferLength xmlBufferLength__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferResize
+extern __typeof (xmlBufferResize) xmlBufferResize __attribute((alias("xmlBufferResize__internal_alias")));
+#else
+#ifndef xmlBufferResize
+extern __typeof (xmlBufferResize) xmlBufferResize__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferResize xmlBufferResize__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferSetAllocationScheme
+extern __typeof (xmlBufferSetAllocationScheme) xmlBufferSetAllocationScheme __attribute((alias("xmlBufferSetAllocationScheme__internal_alias")));
+#else
+#ifndef xmlBufferSetAllocationScheme
+extern __typeof (xmlBufferSetAllocationScheme) xmlBufferSetAllocationScheme__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferSetAllocationScheme xmlBufferSetAllocationScheme__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferShrink
+extern __typeof (xmlBufferShrink) xmlBufferShrink __attribute((alias("xmlBufferShrink__internal_alias")));
+#else
+#ifndef xmlBufferShrink
+extern __typeof (xmlBufferShrink) xmlBufferShrink__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferShrink xmlBufferShrink__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferWriteCHAR
+extern __typeof (xmlBufferWriteCHAR) xmlBufferWriteCHAR __attribute((alias("xmlBufferWriteCHAR__internal_alias")));
+#else
+#ifndef xmlBufferWriteCHAR
+extern __typeof (xmlBufferWriteCHAR) xmlBufferWriteCHAR__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferWriteCHAR xmlBufferWriteCHAR__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferWriteChar
+extern __typeof (xmlBufferWriteChar) xmlBufferWriteChar __attribute((alias("xmlBufferWriteChar__internal_alias")));
+#else
+#ifndef xmlBufferWriteChar
+extern __typeof (xmlBufferWriteChar) xmlBufferWriteChar__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferWriteChar xmlBufferWriteChar__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBufferWriteQuotedString
+extern __typeof (xmlBufferWriteQuotedString) xmlBufferWriteQuotedString __attribute((alias("xmlBufferWriteQuotedString__internal_alias")));
+#else
+#ifndef xmlBufferWriteQuotedString
+extern __typeof (xmlBufferWriteQuotedString) xmlBufferWriteQuotedString__internal_alias __attribute((visibility("hidden")));
+#define xmlBufferWriteQuotedString xmlBufferWriteQuotedString__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlBuildQName
+extern __typeof (xmlBuildQName) xmlBuildQName __attribute((alias("xmlBuildQName__internal_alias")));
+#else
+#ifndef xmlBuildQName
+extern __typeof (xmlBuildQName) xmlBuildQName__internal_alias __attribute((visibility("hidden")));
+#define xmlBuildQName xmlBuildQName__internal_alias
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlBuildRelativeURI
+extern __typeof (xmlBuildRelativeURI) xmlBuildRelativeURI __attribute((alias("xmlBuildRelativeURI__internal_alias")));
+#else
+#ifndef xmlBuildRelativeURI
+extern __typeof (xmlBuildRelativeURI) xmlBuildRelativeURI__internal_alias __attribute((visibility("hidden")));
+#define xmlBuildRelativeURI xmlBuildRelativeURI__internal_alias
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlBuildURI
+extern __typeof (xmlBuildURI) xmlBuildURI __attribute((alias("xmlBuildURI__internal_alias")));
+#else
+#ifndef xmlBuildURI
+extern __typeof (xmlBuildURI) xmlBuildURI__internal_alias __attribute((visibility("hidden")));
+#define xmlBuildURI xmlBuildURI__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlByteConsumed
+extern __typeof (xmlByteConsumed) xmlByteConsumed __attribute((alias("xmlByteConsumed__internal_alias")));
+#else
+#ifndef xmlByteConsumed
+extern __typeof (xmlByteConsumed) xmlByteConsumed__internal_alias __attribute((visibility("hidden")));
+#define xmlByteConsumed xmlByteConsumed__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_c14n
+#undef xmlC14NDocDumpMemory
+extern __typeof (xmlC14NDocDumpMemory) xmlC14NDocDumpMemory __attribute((alias("xmlC14NDocDumpMemory__internal_alias")));
+#else
+#ifndef xmlC14NDocDumpMemory
+extern __typeof (xmlC14NDocDumpMemory) xmlC14NDocDumpMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlC14NDocDumpMemory xmlC14NDocDumpMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_c14n
+#undef xmlC14NDocSave
+extern __typeof (xmlC14NDocSave) xmlC14NDocSave __attribute((alias("xmlC14NDocSave__internal_alias")));
+#else
+#ifndef xmlC14NDocSave
+extern __typeof (xmlC14NDocSave) xmlC14NDocSave__internal_alias __attribute((visibility("hidden")));
+#define xmlC14NDocSave xmlC14NDocSave__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_c14n
+#undef xmlC14NDocSaveTo
+extern __typeof (xmlC14NDocSaveTo) xmlC14NDocSaveTo __attribute((alias("xmlC14NDocSaveTo__internal_alias")));
+#else
+#ifndef xmlC14NDocSaveTo
+extern __typeof (xmlC14NDocSaveTo) xmlC14NDocSaveTo__internal_alias __attribute((visibility("hidden")));
+#define xmlC14NDocSaveTo xmlC14NDocSaveTo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_C14N_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_c14n
+#undef xmlC14NExecute
+extern __typeof (xmlC14NExecute) xmlC14NExecute __attribute((alias("xmlC14NExecute__internal_alias")));
+#else
+#ifndef xmlC14NExecute
+extern __typeof (xmlC14NExecute) xmlC14NExecute__internal_alias __attribute((visibility("hidden")));
+#define xmlC14NExecute xmlC14NExecute__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlCanonicPath
+extern __typeof (xmlCanonicPath) xmlCanonicPath __attribute((alias("xmlCanonicPath__internal_alias")));
+#else
+#ifndef xmlCanonicPath
+extern __typeof (xmlCanonicPath) xmlCanonicPath__internal_alias __attribute((visibility("hidden")));
+#define xmlCanonicPath xmlCanonicPath__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogAdd
+extern __typeof (xmlCatalogAdd) xmlCatalogAdd __attribute((alias("xmlCatalogAdd__internal_alias")));
+#else
+#ifndef xmlCatalogAdd
+extern __typeof (xmlCatalogAdd) xmlCatalogAdd__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogAdd xmlCatalogAdd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogAddLocal
+extern __typeof (xmlCatalogAddLocal) xmlCatalogAddLocal __attribute((alias("xmlCatalogAddLocal__internal_alias")));
+#else
+#ifndef xmlCatalogAddLocal
+extern __typeof (xmlCatalogAddLocal) xmlCatalogAddLocal__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogAddLocal xmlCatalogAddLocal__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogCleanup
+extern __typeof (xmlCatalogCleanup) xmlCatalogCleanup __attribute((alias("xmlCatalogCleanup__internal_alias")));
+#else
+#ifndef xmlCatalogCleanup
+extern __typeof (xmlCatalogCleanup) xmlCatalogCleanup__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogCleanup xmlCatalogCleanup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogConvert
+extern __typeof (xmlCatalogConvert) xmlCatalogConvert __attribute((alias("xmlCatalogConvert__internal_alias")));
+#else
+#ifndef xmlCatalogConvert
+extern __typeof (xmlCatalogConvert) xmlCatalogConvert__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogConvert xmlCatalogConvert__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogDump
+extern __typeof (xmlCatalogDump) xmlCatalogDump __attribute((alias("xmlCatalogDump__internal_alias")));
+#else
+#ifndef xmlCatalogDump
+extern __typeof (xmlCatalogDump) xmlCatalogDump__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogDump xmlCatalogDump__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogFreeLocal
+extern __typeof (xmlCatalogFreeLocal) xmlCatalogFreeLocal __attribute((alias("xmlCatalogFreeLocal__internal_alias")));
+#else
+#ifndef xmlCatalogFreeLocal
+extern __typeof (xmlCatalogFreeLocal) xmlCatalogFreeLocal__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogFreeLocal xmlCatalogFreeLocal__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogGetDefaults
+extern __typeof (xmlCatalogGetDefaults) xmlCatalogGetDefaults __attribute((alias("xmlCatalogGetDefaults__internal_alias")));
+#else
+#ifndef xmlCatalogGetDefaults
+extern __typeof (xmlCatalogGetDefaults) xmlCatalogGetDefaults__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogGetDefaults xmlCatalogGetDefaults__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogGetPublic
+extern __typeof (xmlCatalogGetPublic) xmlCatalogGetPublic __attribute((alias("xmlCatalogGetPublic__internal_alias")));
+#else
+#ifndef xmlCatalogGetPublic
+extern __typeof (xmlCatalogGetPublic) xmlCatalogGetPublic__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogGetPublic xmlCatalogGetPublic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogGetSystem
+extern __typeof (xmlCatalogGetSystem) xmlCatalogGetSystem __attribute((alias("xmlCatalogGetSystem__internal_alias")));
+#else
+#ifndef xmlCatalogGetSystem
+extern __typeof (xmlCatalogGetSystem) xmlCatalogGetSystem__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogGetSystem xmlCatalogGetSystem__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogIsEmpty
+extern __typeof (xmlCatalogIsEmpty) xmlCatalogIsEmpty __attribute((alias("xmlCatalogIsEmpty__internal_alias")));
+#else
+#ifndef xmlCatalogIsEmpty
+extern __typeof (xmlCatalogIsEmpty) xmlCatalogIsEmpty__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogIsEmpty xmlCatalogIsEmpty__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogLocalResolve
+extern __typeof (xmlCatalogLocalResolve) xmlCatalogLocalResolve __attribute((alias("xmlCatalogLocalResolve__internal_alias")));
+#else
+#ifndef xmlCatalogLocalResolve
+extern __typeof (xmlCatalogLocalResolve) xmlCatalogLocalResolve__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogLocalResolve xmlCatalogLocalResolve__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogLocalResolveURI
+extern __typeof (xmlCatalogLocalResolveURI) xmlCatalogLocalResolveURI __attribute((alias("xmlCatalogLocalResolveURI__internal_alias")));
+#else
+#ifndef xmlCatalogLocalResolveURI
+extern __typeof (xmlCatalogLocalResolveURI) xmlCatalogLocalResolveURI__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogLocalResolveURI xmlCatalogLocalResolveURI__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogRemove
+extern __typeof (xmlCatalogRemove) xmlCatalogRemove __attribute((alias("xmlCatalogRemove__internal_alias")));
+#else
+#ifndef xmlCatalogRemove
+extern __typeof (xmlCatalogRemove) xmlCatalogRemove__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogRemove xmlCatalogRemove__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogResolve
+extern __typeof (xmlCatalogResolve) xmlCatalogResolve __attribute((alias("xmlCatalogResolve__internal_alias")));
+#else
+#ifndef xmlCatalogResolve
+extern __typeof (xmlCatalogResolve) xmlCatalogResolve__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogResolve xmlCatalogResolve__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogResolvePublic
+extern __typeof (xmlCatalogResolvePublic) xmlCatalogResolvePublic __attribute((alias("xmlCatalogResolvePublic__internal_alias")));
+#else
+#ifndef xmlCatalogResolvePublic
+extern __typeof (xmlCatalogResolvePublic) xmlCatalogResolvePublic__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogResolvePublic xmlCatalogResolvePublic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogResolveSystem
+extern __typeof (xmlCatalogResolveSystem) xmlCatalogResolveSystem __attribute((alias("xmlCatalogResolveSystem__internal_alias")));
+#else
+#ifndef xmlCatalogResolveSystem
+extern __typeof (xmlCatalogResolveSystem) xmlCatalogResolveSystem__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogResolveSystem xmlCatalogResolveSystem__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogResolveURI
+extern __typeof (xmlCatalogResolveURI) xmlCatalogResolveURI __attribute((alias("xmlCatalogResolveURI__internal_alias")));
+#else
+#ifndef xmlCatalogResolveURI
+extern __typeof (xmlCatalogResolveURI) xmlCatalogResolveURI__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogResolveURI xmlCatalogResolveURI__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogSetDebug
+extern __typeof (xmlCatalogSetDebug) xmlCatalogSetDebug __attribute((alias("xmlCatalogSetDebug__internal_alias")));
+#else
+#ifndef xmlCatalogSetDebug
+extern __typeof (xmlCatalogSetDebug) xmlCatalogSetDebug__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogSetDebug xmlCatalogSetDebug__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogSetDefaultPrefer
+extern __typeof (xmlCatalogSetDefaultPrefer) xmlCatalogSetDefaultPrefer __attribute((alias("xmlCatalogSetDefaultPrefer__internal_alias")));
+#else
+#ifndef xmlCatalogSetDefaultPrefer
+extern __typeof (xmlCatalogSetDefaultPrefer) xmlCatalogSetDefaultPrefer__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogSetDefaultPrefer xmlCatalogSetDefaultPrefer__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlCatalogSetDefaults
+extern __typeof (xmlCatalogSetDefaults) xmlCatalogSetDefaults __attribute((alias("xmlCatalogSetDefaults__internal_alias")));
+#else
+#ifndef xmlCatalogSetDefaults
+extern __typeof (xmlCatalogSetDefaults) xmlCatalogSetDefaults__internal_alias __attribute((visibility("hidden")));
+#define xmlCatalogSetDefaults xmlCatalogSetDefaults__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlCharEncCloseFunc
+extern __typeof (xmlCharEncCloseFunc) xmlCharEncCloseFunc __attribute((alias("xmlCharEncCloseFunc__internal_alias")));
+#else
+#ifndef xmlCharEncCloseFunc
+extern __typeof (xmlCharEncCloseFunc) xmlCharEncCloseFunc__internal_alias __attribute((visibility("hidden")));
+#define xmlCharEncCloseFunc xmlCharEncCloseFunc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlCharEncFirstLine
+extern __typeof (xmlCharEncFirstLine) xmlCharEncFirstLine __attribute((alias("xmlCharEncFirstLine__internal_alias")));
+#else
+#ifndef xmlCharEncFirstLine
+extern __typeof (xmlCharEncFirstLine) xmlCharEncFirstLine__internal_alias __attribute((visibility("hidden")));
+#define xmlCharEncFirstLine xmlCharEncFirstLine__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlCharEncInFunc
+extern __typeof (xmlCharEncInFunc) xmlCharEncInFunc __attribute((alias("xmlCharEncInFunc__internal_alias")));
+#else
+#ifndef xmlCharEncInFunc
+extern __typeof (xmlCharEncInFunc) xmlCharEncInFunc__internal_alias __attribute((visibility("hidden")));
+#define xmlCharEncInFunc xmlCharEncInFunc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlCharEncOutFunc
+extern __typeof (xmlCharEncOutFunc) xmlCharEncOutFunc __attribute((alias("xmlCharEncOutFunc__internal_alias")));
+#else
+#ifndef xmlCharEncOutFunc
+extern __typeof (xmlCharEncOutFunc) xmlCharEncOutFunc__internal_alias __attribute((visibility("hidden")));
+#define xmlCharEncOutFunc xmlCharEncOutFunc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_chvalid
+#undef xmlCharInRange
+extern __typeof (xmlCharInRange) xmlCharInRange __attribute((alias("xmlCharInRange__internal_alias")));
+#else
+#ifndef xmlCharInRange
+extern __typeof (xmlCharInRange) xmlCharInRange__internal_alias __attribute((visibility("hidden")));
+#define xmlCharInRange xmlCharInRange__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlCharStrdup
+extern __typeof (xmlCharStrdup) xmlCharStrdup __attribute((alias("xmlCharStrdup__internal_alias")));
+#else
+#ifndef xmlCharStrdup
+extern __typeof (xmlCharStrdup) xmlCharStrdup__internal_alias __attribute((visibility("hidden")));
+#define xmlCharStrdup xmlCharStrdup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlCharStrndup
+extern __typeof (xmlCharStrndup) xmlCharStrndup __attribute((alias("xmlCharStrndup__internal_alias")));
+#else
+#ifndef xmlCharStrndup
+extern __typeof (xmlCharStrndup) xmlCharStrndup__internal_alias __attribute((visibility("hidden")));
+#define xmlCharStrndup xmlCharStrndup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlCheckFilename
+extern __typeof (xmlCheckFilename) xmlCheckFilename __attribute((alias("xmlCheckFilename__internal_alias")));
+#else
+#ifndef xmlCheckFilename
+extern __typeof (xmlCheckFilename) xmlCheckFilename__internal_alias __attribute((visibility("hidden")));
+#define xmlCheckFilename xmlCheckFilename__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlCheckHTTPInput
+extern __typeof (xmlCheckHTTPInput) xmlCheckHTTPInput __attribute((alias("xmlCheckHTTPInput__internal_alias")));
+#else
+#ifndef xmlCheckHTTPInput
+extern __typeof (xmlCheckHTTPInput) xmlCheckHTTPInput__internal_alias __attribute((visibility("hidden")));
+#define xmlCheckHTTPInput xmlCheckHTTPInput__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCheckLanguageID
+extern __typeof (xmlCheckLanguageID) xmlCheckLanguageID __attribute((alias("xmlCheckLanguageID__internal_alias")));
+#else
+#ifndef xmlCheckLanguageID
+extern __typeof (xmlCheckLanguageID) xmlCheckLanguageID__internal_alias __attribute((visibility("hidden")));
+#define xmlCheckLanguageID xmlCheckLanguageID__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlCheckUTF8
+extern __typeof (xmlCheckUTF8) xmlCheckUTF8 __attribute((alias("xmlCheckUTF8__internal_alias")));
+#else
+#ifndef xmlCheckUTF8
+extern __typeof (xmlCheckUTF8) xmlCheckUTF8__internal_alias __attribute((visibility("hidden")));
+#define xmlCheckUTF8 xmlCheckUTF8__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlCheckVersion
+extern __typeof (xmlCheckVersion) xmlCheckVersion __attribute((alias("xmlCheckVersion__internal_alias")));
+#else
+#ifndef xmlCheckVersion
+extern __typeof (xmlCheckVersion) xmlCheckVersion__internal_alias __attribute((visibility("hidden")));
+#define xmlCheckVersion xmlCheckVersion__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlChildElementCount
+extern __typeof (xmlChildElementCount) xmlChildElementCount __attribute((alias("xmlChildElementCount__internal_alias")));
+#else
+#ifndef xmlChildElementCount
+extern __typeof (xmlChildElementCount) xmlChildElementCount__internal_alias __attribute((visibility("hidden")));
+#define xmlChildElementCount xmlChildElementCount__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlCleanupCharEncodingHandlers
+extern __typeof (xmlCleanupCharEncodingHandlers) xmlCleanupCharEncodingHandlers __attribute((alias("xmlCleanupCharEncodingHandlers__internal_alias")));
+#else
+#ifndef xmlCleanupCharEncodingHandlers
+extern __typeof (xmlCleanupCharEncodingHandlers) xmlCleanupCharEncodingHandlers__internal_alias __attribute((visibility("hidden")));
+#define xmlCleanupCharEncodingHandlers xmlCleanupCharEncodingHandlers__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlCleanupEncodingAliases
+extern __typeof (xmlCleanupEncodingAliases) xmlCleanupEncodingAliases __attribute((alias("xmlCleanupEncodingAliases__internal_alias")));
+#else
+#ifndef xmlCleanupEncodingAliases
+extern __typeof (xmlCleanupEncodingAliases) xmlCleanupEncodingAliases__internal_alias __attribute((visibility("hidden")));
+#define xmlCleanupEncodingAliases xmlCleanupEncodingAliases__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlCleanupGlobals
+extern __typeof (xmlCleanupGlobals) xmlCleanupGlobals __attribute((alias("xmlCleanupGlobals__internal_alias")));
+#else
+#ifndef xmlCleanupGlobals
+extern __typeof (xmlCleanupGlobals) xmlCleanupGlobals__internal_alias __attribute((visibility("hidden")));
+#define xmlCleanupGlobals xmlCleanupGlobals__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlCleanupInputCallbacks
+extern __typeof (xmlCleanupInputCallbacks) xmlCleanupInputCallbacks __attribute((alias("xmlCleanupInputCallbacks__internal_alias")));
+#else
+#ifndef xmlCleanupInputCallbacks
+extern __typeof (xmlCleanupInputCallbacks) xmlCleanupInputCallbacks__internal_alias __attribute((visibility("hidden")));
+#define xmlCleanupInputCallbacks xmlCleanupInputCallbacks__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlCleanupMemory
+extern __typeof (xmlCleanupMemory) xmlCleanupMemory __attribute((alias("xmlCleanupMemory__internal_alias")));
+#else
+#ifndef xmlCleanupMemory
+extern __typeof (xmlCleanupMemory) xmlCleanupMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlCleanupMemory xmlCleanupMemory__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlCleanupOutputCallbacks
+extern __typeof (xmlCleanupOutputCallbacks) xmlCleanupOutputCallbacks __attribute((alias("xmlCleanupOutputCallbacks__internal_alias")));
+#else
+#ifndef xmlCleanupOutputCallbacks
+extern __typeof (xmlCleanupOutputCallbacks) xmlCleanupOutputCallbacks__internal_alias __attribute((visibility("hidden")));
+#define xmlCleanupOutputCallbacks xmlCleanupOutputCallbacks__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCleanupParser
+extern __typeof (xmlCleanupParser) xmlCleanupParser __attribute((alias("xmlCleanupParser__internal_alias")));
+#else
+#ifndef xmlCleanupParser
+extern __typeof (xmlCleanupParser) xmlCleanupParser__internal_alias __attribute((visibility("hidden")));
+#define xmlCleanupParser xmlCleanupParser__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlCleanupPredefinedEntities
+extern __typeof (xmlCleanupPredefinedEntities) xmlCleanupPredefinedEntities __attribute((alias("xmlCleanupPredefinedEntities__internal_alias")));
+#else
+#ifndef xmlCleanupPredefinedEntities
+extern __typeof (xmlCleanupPredefinedEntities) xmlCleanupPredefinedEntities__internal_alias __attribute((visibility("hidden")));
+#define xmlCleanupPredefinedEntities xmlCleanupPredefinedEntities__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlCleanupThreads
+extern __typeof (xmlCleanupThreads) xmlCleanupThreads __attribute((alias("xmlCleanupThreads__internal_alias")));
+#else
+#ifndef xmlCleanupThreads
+extern __typeof (xmlCleanupThreads) xmlCleanupThreads__internal_alias __attribute((visibility("hidden")));
+#define xmlCleanupThreads xmlCleanupThreads__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlClearNodeInfoSeq
+extern __typeof (xmlClearNodeInfoSeq) xmlClearNodeInfoSeq __attribute((alias("xmlClearNodeInfoSeq__internal_alias")));
+#else
+#ifndef xmlClearNodeInfoSeq
+extern __typeof (xmlClearNodeInfoSeq) xmlClearNodeInfoSeq__internal_alias __attribute((visibility("hidden")));
+#define xmlClearNodeInfoSeq xmlClearNodeInfoSeq__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlClearParserCtxt
+extern __typeof (xmlClearParserCtxt) xmlClearParserCtxt __attribute((alias("xmlClearParserCtxt__internal_alias")));
+#else
+#ifndef xmlClearParserCtxt
+extern __typeof (xmlClearParserCtxt) xmlClearParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlClearParserCtxt xmlClearParserCtxt__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlConvertSGMLCatalog
+extern __typeof (xmlConvertSGMLCatalog) xmlConvertSGMLCatalog __attribute((alias("xmlConvertSGMLCatalog__internal_alias")));
+#else
+#ifndef xmlConvertSGMLCatalog
+extern __typeof (xmlConvertSGMLCatalog) xmlConvertSGMLCatalog__internal_alias __attribute((visibility("hidden")));
+#define xmlConvertSGMLCatalog xmlConvertSGMLCatalog__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_valid
+#undef xmlCopyAttributeTable
+extern __typeof (xmlCopyAttributeTable) xmlCopyAttributeTable __attribute((alias("xmlCopyAttributeTable__internal_alias")));
+#else
+#ifndef xmlCopyAttributeTable
+extern __typeof (xmlCopyAttributeTable) xmlCopyAttributeTable__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyAttributeTable xmlCopyAttributeTable__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlCopyChar
+extern __typeof (xmlCopyChar) xmlCopyChar __attribute((alias("xmlCopyChar__internal_alias")));
+#else
+#ifndef xmlCopyChar
+extern __typeof (xmlCopyChar) xmlCopyChar__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyChar xmlCopyChar__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlCopyCharMultiByte
+extern __typeof (xmlCopyCharMultiByte) xmlCopyCharMultiByte __attribute((alias("xmlCopyCharMultiByte__internal_alias")));
+#else
+#ifndef xmlCopyCharMultiByte
+extern __typeof (xmlCopyCharMultiByte) xmlCopyCharMultiByte__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyCharMultiByte xmlCopyCharMultiByte__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_tree
+#undef xmlCopyDoc
+extern __typeof (xmlCopyDoc) xmlCopyDoc __attribute((alias("xmlCopyDoc__internal_alias")));
+#else
+#ifndef xmlCopyDoc
+extern __typeof (xmlCopyDoc) xmlCopyDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyDoc xmlCopyDoc__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlCopyDocElementContent
+extern __typeof (xmlCopyDocElementContent) xmlCopyDocElementContent __attribute((alias("xmlCopyDocElementContent__internal_alias")));
+#else
+#ifndef xmlCopyDocElementContent
+extern __typeof (xmlCopyDocElementContent) xmlCopyDocElementContent__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyDocElementContent xmlCopyDocElementContent__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlCopyDtd
+extern __typeof (xmlCopyDtd) xmlCopyDtd __attribute((alias("xmlCopyDtd__internal_alias")));
+#else
+#ifndef xmlCopyDtd
+extern __typeof (xmlCopyDtd) xmlCopyDtd__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyDtd xmlCopyDtd__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlCopyElementContent
+extern __typeof (xmlCopyElementContent) xmlCopyElementContent __attribute((alias("xmlCopyElementContent__internal_alias")));
+#else
+#ifndef xmlCopyElementContent
+extern __typeof (xmlCopyElementContent) xmlCopyElementContent__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyElementContent xmlCopyElementContent__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_valid
+#undef xmlCopyElementTable
+extern __typeof (xmlCopyElementTable) xmlCopyElementTable __attribute((alias("xmlCopyElementTable__internal_alias")));
+#else
+#ifndef xmlCopyElementTable
+extern __typeof (xmlCopyElementTable) xmlCopyElementTable__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyElementTable xmlCopyElementTable__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_entities
+#undef xmlCopyEntitiesTable
+extern __typeof (xmlCopyEntitiesTable) xmlCopyEntitiesTable __attribute((alias("xmlCopyEntitiesTable__internal_alias")));
+#else
+#ifndef xmlCopyEntitiesTable
+extern __typeof (xmlCopyEntitiesTable) xmlCopyEntitiesTable__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyEntitiesTable xmlCopyEntitiesTable__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_valid
+#undef xmlCopyEnumeration
+extern __typeof (xmlCopyEnumeration) xmlCopyEnumeration __attribute((alias("xmlCopyEnumeration__internal_alias")));
+#else
+#ifndef xmlCopyEnumeration
+extern __typeof (xmlCopyEnumeration) xmlCopyEnumeration__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyEnumeration xmlCopyEnumeration__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlCopyError
+extern __typeof (xmlCopyError) xmlCopyError __attribute((alias("xmlCopyError__internal_alias")));
+#else
+#ifndef xmlCopyError
+extern __typeof (xmlCopyError) xmlCopyError__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyError xmlCopyError__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlCopyNamespace
+extern __typeof (xmlCopyNamespace) xmlCopyNamespace __attribute((alias("xmlCopyNamespace__internal_alias")));
+#else
+#ifndef xmlCopyNamespace
+extern __typeof (xmlCopyNamespace) xmlCopyNamespace__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyNamespace xmlCopyNamespace__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlCopyNamespaceList
+extern __typeof (xmlCopyNamespaceList) xmlCopyNamespaceList __attribute((alias("xmlCopyNamespaceList__internal_alias")));
+#else
+#ifndef xmlCopyNamespaceList
+extern __typeof (xmlCopyNamespaceList) xmlCopyNamespaceList__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyNamespaceList xmlCopyNamespaceList__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlCopyNode
+extern __typeof (xmlCopyNode) xmlCopyNode __attribute((alias("xmlCopyNode__internal_alias")));
+#else
+#ifndef xmlCopyNode
+extern __typeof (xmlCopyNode) xmlCopyNode__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyNode xmlCopyNode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlCopyNodeList
+extern __typeof (xmlCopyNodeList) xmlCopyNodeList __attribute((alias("xmlCopyNodeList__internal_alias")));
+#else
+#ifndef xmlCopyNodeList
+extern __typeof (xmlCopyNodeList) xmlCopyNodeList__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyNodeList xmlCopyNodeList__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_valid
+#undef xmlCopyNotationTable
+extern __typeof (xmlCopyNotationTable) xmlCopyNotationTable __attribute((alias("xmlCopyNotationTable__internal_alias")));
+#else
+#ifndef xmlCopyNotationTable
+extern __typeof (xmlCopyNotationTable) xmlCopyNotationTable__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyNotationTable xmlCopyNotationTable__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlCopyProp
+extern __typeof (xmlCopyProp) xmlCopyProp __attribute((alias("xmlCopyProp__internal_alias")));
+#else
+#ifndef xmlCopyProp
+extern __typeof (xmlCopyProp) xmlCopyProp__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyProp xmlCopyProp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlCopyPropList
+extern __typeof (xmlCopyPropList) xmlCopyPropList __attribute((alias("xmlCopyPropList__internal_alias")));
+#else
+#ifndef xmlCopyPropList
+extern __typeof (xmlCopyPropList) xmlCopyPropList__internal_alias __attribute((visibility("hidden")));
+#define xmlCopyPropList xmlCopyPropList__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCreateDocParserCtxt
+extern __typeof (xmlCreateDocParserCtxt) xmlCreateDocParserCtxt __attribute((alias("xmlCreateDocParserCtxt__internal_alias")));
+#else
+#ifndef xmlCreateDocParserCtxt
+extern __typeof (xmlCreateDocParserCtxt) xmlCreateDocParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlCreateDocParserCtxt xmlCreateDocParserCtxt__internal_alias
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlCreateEntitiesTable
+extern __typeof (xmlCreateEntitiesTable) xmlCreateEntitiesTable __attribute((alias("xmlCreateEntitiesTable__internal_alias")));
+#else
+#ifndef xmlCreateEntitiesTable
+extern __typeof (xmlCreateEntitiesTable) xmlCreateEntitiesTable__internal_alias __attribute((visibility("hidden")));
+#define xmlCreateEntitiesTable xmlCreateEntitiesTable__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCreateEntityParserCtxt
+extern __typeof (xmlCreateEntityParserCtxt) xmlCreateEntityParserCtxt __attribute((alias("xmlCreateEntityParserCtxt__internal_alias")));
+#else
+#ifndef xmlCreateEntityParserCtxt
+extern __typeof (xmlCreateEntityParserCtxt) xmlCreateEntityParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlCreateEntityParserCtxt xmlCreateEntityParserCtxt__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlCreateEnumeration
+extern __typeof (xmlCreateEnumeration) xmlCreateEnumeration __attribute((alias("xmlCreateEnumeration__internal_alias")));
+#else
+#ifndef xmlCreateEnumeration
+extern __typeof (xmlCreateEnumeration) xmlCreateEnumeration__internal_alias __attribute((visibility("hidden")));
+#define xmlCreateEnumeration xmlCreateEnumeration__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCreateFileParserCtxt
+extern __typeof (xmlCreateFileParserCtxt) xmlCreateFileParserCtxt __attribute((alias("xmlCreateFileParserCtxt__internal_alias")));
+#else
+#ifndef xmlCreateFileParserCtxt
+extern __typeof (xmlCreateFileParserCtxt) xmlCreateFileParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlCreateFileParserCtxt xmlCreateFileParserCtxt__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCreateIOParserCtxt
+extern __typeof (xmlCreateIOParserCtxt) xmlCreateIOParserCtxt __attribute((alias("xmlCreateIOParserCtxt__internal_alias")));
+#else
+#ifndef xmlCreateIOParserCtxt
+extern __typeof (xmlCreateIOParserCtxt) xmlCreateIOParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlCreateIOParserCtxt xmlCreateIOParserCtxt__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlCreateIntSubset
+extern __typeof (xmlCreateIntSubset) xmlCreateIntSubset __attribute((alias("xmlCreateIntSubset__internal_alias")));
+#else
+#ifndef xmlCreateIntSubset
+extern __typeof (xmlCreateIntSubset) xmlCreateIntSubset__internal_alias __attribute((visibility("hidden")));
+#define xmlCreateIntSubset xmlCreateIntSubset__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCreateMemoryParserCtxt
+extern __typeof (xmlCreateMemoryParserCtxt) xmlCreateMemoryParserCtxt __attribute((alias("xmlCreateMemoryParserCtxt__internal_alias")));
+#else
+#ifndef xmlCreateMemoryParserCtxt
+extern __typeof (xmlCreateMemoryParserCtxt) xmlCreateMemoryParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlCreateMemoryParserCtxt xmlCreateMemoryParserCtxt__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_PUSH_ENABLED)
+#ifdef bottom_parser
+#undef xmlCreatePushParserCtxt
+extern __typeof (xmlCreatePushParserCtxt) xmlCreatePushParserCtxt __attribute((alias("xmlCreatePushParserCtxt__internal_alias")));
+#else
+#ifndef xmlCreatePushParserCtxt
+extern __typeof (xmlCreatePushParserCtxt) xmlCreatePushParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlCreatePushParserCtxt xmlCreatePushParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlCreateURI
+extern __typeof (xmlCreateURI) xmlCreateURI __attribute((alias("xmlCreateURI__internal_alias")));
+#else
+#ifndef xmlCreateURI
+extern __typeof (xmlCreateURI) xmlCreateURI__internal_alias __attribute((visibility("hidden")));
+#define xmlCreateURI xmlCreateURI__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCreateURLParserCtxt
+extern __typeof (xmlCreateURLParserCtxt) xmlCreateURLParserCtxt __attribute((alias("xmlCreateURLParserCtxt__internal_alias")));
+#else
+#ifndef xmlCreateURLParserCtxt
+extern __typeof (xmlCreateURLParserCtxt) xmlCreateURLParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlCreateURLParserCtxt xmlCreateURLParserCtxt__internal_alias
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlCtxtGetLastError
+extern __typeof (xmlCtxtGetLastError) xmlCtxtGetLastError __attribute((alias("xmlCtxtGetLastError__internal_alias")));
+#else
+#ifndef xmlCtxtGetLastError
+extern __typeof (xmlCtxtGetLastError) xmlCtxtGetLastError__internal_alias __attribute((visibility("hidden")));
+#define xmlCtxtGetLastError xmlCtxtGetLastError__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCtxtReadDoc
+extern __typeof (xmlCtxtReadDoc) xmlCtxtReadDoc __attribute((alias("xmlCtxtReadDoc__internal_alias")));
+#else
+#ifndef xmlCtxtReadDoc
+extern __typeof (xmlCtxtReadDoc) xmlCtxtReadDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlCtxtReadDoc xmlCtxtReadDoc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCtxtReadFd
+extern __typeof (xmlCtxtReadFd) xmlCtxtReadFd __attribute((alias("xmlCtxtReadFd__internal_alias")));
+#else
+#ifndef xmlCtxtReadFd
+extern __typeof (xmlCtxtReadFd) xmlCtxtReadFd__internal_alias __attribute((visibility("hidden")));
+#define xmlCtxtReadFd xmlCtxtReadFd__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCtxtReadFile
+extern __typeof (xmlCtxtReadFile) xmlCtxtReadFile __attribute((alias("xmlCtxtReadFile__internal_alias")));
+#else
+#ifndef xmlCtxtReadFile
+extern __typeof (xmlCtxtReadFile) xmlCtxtReadFile__internal_alias __attribute((visibility("hidden")));
+#define xmlCtxtReadFile xmlCtxtReadFile__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCtxtReadIO
+extern __typeof (xmlCtxtReadIO) xmlCtxtReadIO __attribute((alias("xmlCtxtReadIO__internal_alias")));
+#else
+#ifndef xmlCtxtReadIO
+extern __typeof (xmlCtxtReadIO) xmlCtxtReadIO__internal_alias __attribute((visibility("hidden")));
+#define xmlCtxtReadIO xmlCtxtReadIO__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCtxtReadMemory
+extern __typeof (xmlCtxtReadMemory) xmlCtxtReadMemory __attribute((alias("xmlCtxtReadMemory__internal_alias")));
+#else
+#ifndef xmlCtxtReadMemory
+extern __typeof (xmlCtxtReadMemory) xmlCtxtReadMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlCtxtReadMemory xmlCtxtReadMemory__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCtxtReset
+extern __typeof (xmlCtxtReset) xmlCtxtReset __attribute((alias("xmlCtxtReset__internal_alias")));
+#else
+#ifndef xmlCtxtReset
+extern __typeof (xmlCtxtReset) xmlCtxtReset__internal_alias __attribute((visibility("hidden")));
+#define xmlCtxtReset xmlCtxtReset__internal_alias
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlCtxtResetLastError
+extern __typeof (xmlCtxtResetLastError) xmlCtxtResetLastError __attribute((alias("xmlCtxtResetLastError__internal_alias")));
+#else
+#ifndef xmlCtxtResetLastError
+extern __typeof (xmlCtxtResetLastError) xmlCtxtResetLastError__internal_alias __attribute((visibility("hidden")));
+#define xmlCtxtResetLastError xmlCtxtResetLastError__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCtxtResetPush
+extern __typeof (xmlCtxtResetPush) xmlCtxtResetPush __attribute((alias("xmlCtxtResetPush__internal_alias")));
+#else
+#ifndef xmlCtxtResetPush
+extern __typeof (xmlCtxtResetPush) xmlCtxtResetPush__internal_alias __attribute((visibility("hidden")));
+#define xmlCtxtResetPush xmlCtxtResetPush__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlCtxtUseOptions
+extern __typeof (xmlCtxtUseOptions) xmlCtxtUseOptions __attribute((alias("xmlCtxtUseOptions__internal_alias")));
+#else
+#ifndef xmlCtxtUseOptions
+extern __typeof (xmlCtxtUseOptions) xmlCtxtUseOptions__internal_alias __attribute((visibility("hidden")));
+#define xmlCtxtUseOptions xmlCtxtUseOptions__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlCurrentChar
+extern __typeof (xmlCurrentChar) xmlCurrentChar __attribute((alias("xmlCurrentChar__internal_alias")));
+#else
+#ifndef xmlCurrentChar
+extern __typeof (xmlCurrentChar) xmlCurrentChar__internal_alias __attribute((visibility("hidden")));
+#define xmlCurrentChar xmlCurrentChar__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlDOMWrapAdoptNode
+extern __typeof (xmlDOMWrapAdoptNode) xmlDOMWrapAdoptNode __attribute((alias("xmlDOMWrapAdoptNode__internal_alias")));
+#else
+#ifndef xmlDOMWrapAdoptNode
+extern __typeof (xmlDOMWrapAdoptNode) xmlDOMWrapAdoptNode__internal_alias __attribute((visibility("hidden")));
+#define xmlDOMWrapAdoptNode xmlDOMWrapAdoptNode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlDOMWrapCloneNode
+extern __typeof (xmlDOMWrapCloneNode) xmlDOMWrapCloneNode __attribute((alias("xmlDOMWrapCloneNode__internal_alias")));
+#else
+#ifndef xmlDOMWrapCloneNode
+extern __typeof (xmlDOMWrapCloneNode) xmlDOMWrapCloneNode__internal_alias __attribute((visibility("hidden")));
+#define xmlDOMWrapCloneNode xmlDOMWrapCloneNode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlDOMWrapFreeCtxt
+extern __typeof (xmlDOMWrapFreeCtxt) xmlDOMWrapFreeCtxt __attribute((alias("xmlDOMWrapFreeCtxt__internal_alias")));
+#else
+#ifndef xmlDOMWrapFreeCtxt
+extern __typeof (xmlDOMWrapFreeCtxt) xmlDOMWrapFreeCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlDOMWrapFreeCtxt xmlDOMWrapFreeCtxt__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlDOMWrapNewCtxt
+extern __typeof (xmlDOMWrapNewCtxt) xmlDOMWrapNewCtxt __attribute((alias("xmlDOMWrapNewCtxt__internal_alias")));
+#else
+#ifndef xmlDOMWrapNewCtxt
+extern __typeof (xmlDOMWrapNewCtxt) xmlDOMWrapNewCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlDOMWrapNewCtxt xmlDOMWrapNewCtxt__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlDOMWrapReconcileNamespaces
+extern __typeof (xmlDOMWrapReconcileNamespaces) xmlDOMWrapReconcileNamespaces __attribute((alias("xmlDOMWrapReconcileNamespaces__internal_alias")));
+#else
+#ifndef xmlDOMWrapReconcileNamespaces
+extern __typeof (xmlDOMWrapReconcileNamespaces) xmlDOMWrapReconcileNamespaces__internal_alias __attribute((visibility("hidden")));
+#define xmlDOMWrapReconcileNamespaces xmlDOMWrapReconcileNamespaces__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlDOMWrapRemoveNode
+extern __typeof (xmlDOMWrapRemoveNode) xmlDOMWrapRemoveNode __attribute((alias("xmlDOMWrapRemoveNode__internal_alias")));
+#else
+#ifndef xmlDOMWrapRemoveNode
+extern __typeof (xmlDOMWrapRemoveNode) xmlDOMWrapRemoveNode__internal_alias __attribute((visibility("hidden")));
+#define xmlDOMWrapRemoveNode xmlDOMWrapRemoveNode__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugCheckDocument
+extern __typeof (xmlDebugCheckDocument) xmlDebugCheckDocument __attribute((alias("xmlDebugCheckDocument__internal_alias")));
+#else
+#ifndef xmlDebugCheckDocument
+extern __typeof (xmlDebugCheckDocument) xmlDebugCheckDocument__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugCheckDocument xmlDebugCheckDocument__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugDumpAttr
+extern __typeof (xmlDebugDumpAttr) xmlDebugDumpAttr __attribute((alias("xmlDebugDumpAttr__internal_alias")));
+#else
+#ifndef xmlDebugDumpAttr
+extern __typeof (xmlDebugDumpAttr) xmlDebugDumpAttr__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugDumpAttr xmlDebugDumpAttr__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugDumpAttrList
+extern __typeof (xmlDebugDumpAttrList) xmlDebugDumpAttrList __attribute((alias("xmlDebugDumpAttrList__internal_alias")));
+#else
+#ifndef xmlDebugDumpAttrList
+extern __typeof (xmlDebugDumpAttrList) xmlDebugDumpAttrList__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugDumpAttrList xmlDebugDumpAttrList__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugDumpDTD
+extern __typeof (xmlDebugDumpDTD) xmlDebugDumpDTD __attribute((alias("xmlDebugDumpDTD__internal_alias")));
+#else
+#ifndef xmlDebugDumpDTD
+extern __typeof (xmlDebugDumpDTD) xmlDebugDumpDTD__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugDumpDTD xmlDebugDumpDTD__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugDumpDocument
+extern __typeof (xmlDebugDumpDocument) xmlDebugDumpDocument __attribute((alias("xmlDebugDumpDocument__internal_alias")));
+#else
+#ifndef xmlDebugDumpDocument
+extern __typeof (xmlDebugDumpDocument) xmlDebugDumpDocument__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugDumpDocument xmlDebugDumpDocument__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugDumpDocumentHead
+extern __typeof (xmlDebugDumpDocumentHead) xmlDebugDumpDocumentHead __attribute((alias("xmlDebugDumpDocumentHead__internal_alias")));
+#else
+#ifndef xmlDebugDumpDocumentHead
+extern __typeof (xmlDebugDumpDocumentHead) xmlDebugDumpDocumentHead__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugDumpDocumentHead xmlDebugDumpDocumentHead__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugDumpEntities
+extern __typeof (xmlDebugDumpEntities) xmlDebugDumpEntities __attribute((alias("xmlDebugDumpEntities__internal_alias")));
+#else
+#ifndef xmlDebugDumpEntities
+extern __typeof (xmlDebugDumpEntities) xmlDebugDumpEntities__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugDumpEntities xmlDebugDumpEntities__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugDumpNode
+extern __typeof (xmlDebugDumpNode) xmlDebugDumpNode __attribute((alias("xmlDebugDumpNode__internal_alias")));
+#else
+#ifndef xmlDebugDumpNode
+extern __typeof (xmlDebugDumpNode) xmlDebugDumpNode__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugDumpNode xmlDebugDumpNode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugDumpNodeList
+extern __typeof (xmlDebugDumpNodeList) xmlDebugDumpNodeList __attribute((alias("xmlDebugDumpNodeList__internal_alias")));
+#else
+#ifndef xmlDebugDumpNodeList
+extern __typeof (xmlDebugDumpNodeList) xmlDebugDumpNodeList__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugDumpNodeList xmlDebugDumpNodeList__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugDumpOneNode
+extern __typeof (xmlDebugDumpOneNode) xmlDebugDumpOneNode __attribute((alias("xmlDebugDumpOneNode__internal_alias")));
+#else
+#ifndef xmlDebugDumpOneNode
+extern __typeof (xmlDebugDumpOneNode) xmlDebugDumpOneNode__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugDumpOneNode xmlDebugDumpOneNode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlDebugDumpString
+extern __typeof (xmlDebugDumpString) xmlDebugDumpString __attribute((alias("xmlDebugDumpString__internal_alias")));
+#else
+#ifndef xmlDebugDumpString
+extern __typeof (xmlDebugDumpString) xmlDebugDumpString__internal_alias __attribute((visibility("hidden")));
+#define xmlDebugDumpString xmlDebugDumpString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlDecodeEntities
+extern __typeof (xmlDecodeEntities) xmlDecodeEntities __attribute((alias("xmlDecodeEntities__internal_alias")));
+#else
+#ifndef xmlDecodeEntities
+extern __typeof (xmlDecodeEntities) xmlDecodeEntities__internal_alias __attribute((visibility("hidden")));
+#define xmlDecodeEntities xmlDecodeEntities__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlDefaultSAXHandlerInit
+extern __typeof (xmlDefaultSAXHandlerInit) xmlDefaultSAXHandlerInit __attribute((alias("xmlDefaultSAXHandlerInit__internal_alias")));
+#else
+#ifndef xmlDefaultSAXHandlerInit
+extern __typeof (xmlDefaultSAXHandlerInit) xmlDefaultSAXHandlerInit__internal_alias __attribute((visibility("hidden")));
+#define xmlDefaultSAXHandlerInit xmlDefaultSAXHandlerInit__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlDelEncodingAlias
+extern __typeof (xmlDelEncodingAlias) xmlDelEncodingAlias __attribute((alias("xmlDelEncodingAlias__internal_alias")));
+#else
+#ifndef xmlDelEncodingAlias
+extern __typeof (xmlDelEncodingAlias) xmlDelEncodingAlias__internal_alias __attribute((visibility("hidden")));
+#define xmlDelEncodingAlias xmlDelEncodingAlias__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlDeregisterNodeDefault
+extern __typeof (xmlDeregisterNodeDefault) xmlDeregisterNodeDefault __attribute((alias("xmlDeregisterNodeDefault__internal_alias")));
+#else
+#ifndef xmlDeregisterNodeDefault
+extern __typeof (xmlDeregisterNodeDefault) xmlDeregisterNodeDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlDeregisterNodeDefault xmlDeregisterNodeDefault__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlDetectCharEncoding
+extern __typeof (xmlDetectCharEncoding) xmlDetectCharEncoding __attribute((alias("xmlDetectCharEncoding__internal_alias")));
+#else
+#ifndef xmlDetectCharEncoding
+extern __typeof (xmlDetectCharEncoding) xmlDetectCharEncoding__internal_alias __attribute((visibility("hidden")));
+#define xmlDetectCharEncoding xmlDetectCharEncoding__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictCleanup
+extern __typeof (xmlDictCleanup) xmlDictCleanup __attribute((alias("xmlDictCleanup__internal_alias")));
+#else
+#ifndef xmlDictCleanup
+extern __typeof (xmlDictCleanup) xmlDictCleanup__internal_alias __attribute((visibility("hidden")));
+#define xmlDictCleanup xmlDictCleanup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictCreate
+extern __typeof (xmlDictCreate) xmlDictCreate __attribute((alias("xmlDictCreate__internal_alias")));
+#else
+#ifndef xmlDictCreate
+extern __typeof (xmlDictCreate) xmlDictCreate__internal_alias __attribute((visibility("hidden")));
+#define xmlDictCreate xmlDictCreate__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictCreateSub
+extern __typeof (xmlDictCreateSub) xmlDictCreateSub __attribute((alias("xmlDictCreateSub__internal_alias")));
+#else
+#ifndef xmlDictCreateSub
+extern __typeof (xmlDictCreateSub) xmlDictCreateSub__internal_alias __attribute((visibility("hidden")));
+#define xmlDictCreateSub xmlDictCreateSub__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictExists
+extern __typeof (xmlDictExists) xmlDictExists __attribute((alias("xmlDictExists__internal_alias")));
+#else
+#ifndef xmlDictExists
+extern __typeof (xmlDictExists) xmlDictExists__internal_alias __attribute((visibility("hidden")));
+#define xmlDictExists xmlDictExists__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictFree
+extern __typeof (xmlDictFree) xmlDictFree __attribute((alias("xmlDictFree__internal_alias")));
+#else
+#ifndef xmlDictFree
+extern __typeof (xmlDictFree) xmlDictFree__internal_alias __attribute((visibility("hidden")));
+#define xmlDictFree xmlDictFree__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictGetUsage
+extern __typeof (xmlDictGetUsage) xmlDictGetUsage __attribute((alias("xmlDictGetUsage__internal_alias")));
+#else
+#ifndef xmlDictGetUsage
+extern __typeof (xmlDictGetUsage) xmlDictGetUsage__internal_alias __attribute((visibility("hidden")));
+#define xmlDictGetUsage xmlDictGetUsage__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictLookup
+extern __typeof (xmlDictLookup) xmlDictLookup __attribute((alias("xmlDictLookup__internal_alias")));
+#else
+#ifndef xmlDictLookup
+extern __typeof (xmlDictLookup) xmlDictLookup__internal_alias __attribute((visibility("hidden")));
+#define xmlDictLookup xmlDictLookup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictOwns
+extern __typeof (xmlDictOwns) xmlDictOwns __attribute((alias("xmlDictOwns__internal_alias")));
+#else
+#ifndef xmlDictOwns
+extern __typeof (xmlDictOwns) xmlDictOwns__internal_alias __attribute((visibility("hidden")));
+#define xmlDictOwns xmlDictOwns__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictQLookup
+extern __typeof (xmlDictQLookup) xmlDictQLookup __attribute((alias("xmlDictQLookup__internal_alias")));
+#else
+#ifndef xmlDictQLookup
+extern __typeof (xmlDictQLookup) xmlDictQLookup__internal_alias __attribute((visibility("hidden")));
+#define xmlDictQLookup xmlDictQLookup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictReference
+extern __typeof (xmlDictReference) xmlDictReference __attribute((alias("xmlDictReference__internal_alias")));
+#else
+#ifndef xmlDictReference
+extern __typeof (xmlDictReference) xmlDictReference__internal_alias __attribute((visibility("hidden")));
+#define xmlDictReference xmlDictReference__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictSetLimit
+extern __typeof (xmlDictSetLimit) xmlDictSetLimit __attribute((alias("xmlDictSetLimit__internal_alias")));
+#else
+#ifndef xmlDictSetLimit
+extern __typeof (xmlDictSetLimit) xmlDictSetLimit__internal_alias __attribute((visibility("hidden")));
+#define xmlDictSetLimit xmlDictSetLimit__internal_alias
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlDictSize
+extern __typeof (xmlDictSize) xmlDictSize __attribute((alias("xmlDictSize__internal_alias")));
+#else
+#ifndef xmlDictSize
+extern __typeof (xmlDictSize) xmlDictSize__internal_alias __attribute((visibility("hidden")));
+#define xmlDictSize xmlDictSize__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlDocCopyNode
+extern __typeof (xmlDocCopyNode) xmlDocCopyNode __attribute((alias("xmlDocCopyNode__internal_alias")));
+#else
+#ifndef xmlDocCopyNode
+extern __typeof (xmlDocCopyNode) xmlDocCopyNode__internal_alias __attribute((visibility("hidden")));
+#define xmlDocCopyNode xmlDocCopyNode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlDocCopyNodeList
+extern __typeof (xmlDocCopyNodeList) xmlDocCopyNodeList __attribute((alias("xmlDocCopyNodeList__internal_alias")));
+#else
+#ifndef xmlDocCopyNodeList
+extern __typeof (xmlDocCopyNodeList) xmlDocCopyNodeList__internal_alias __attribute((visibility("hidden")));
+#define xmlDocCopyNodeList xmlDocCopyNodeList__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlDocDump
+extern __typeof (xmlDocDump) xmlDocDump __attribute((alias("xmlDocDump__internal_alias")));
+#else
+#ifndef xmlDocDump
+extern __typeof (xmlDocDump) xmlDocDump__internal_alias __attribute((visibility("hidden")));
+#define xmlDocDump xmlDocDump__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlDocDumpFormatMemory
+extern __typeof (xmlDocDumpFormatMemory) xmlDocDumpFormatMemory __attribute((alias("xmlDocDumpFormatMemory__internal_alias")));
+#else
+#ifndef xmlDocDumpFormatMemory
+extern __typeof (xmlDocDumpFormatMemory) xmlDocDumpFormatMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlDocDumpFormatMemory xmlDocDumpFormatMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlDocDumpFormatMemoryEnc
+extern __typeof (xmlDocDumpFormatMemoryEnc) xmlDocDumpFormatMemoryEnc __attribute((alias("xmlDocDumpFormatMemoryEnc__internal_alias")));
+#else
+#ifndef xmlDocDumpFormatMemoryEnc
+extern __typeof (xmlDocDumpFormatMemoryEnc) xmlDocDumpFormatMemoryEnc__internal_alias __attribute((visibility("hidden")));
+#define xmlDocDumpFormatMemoryEnc xmlDocDumpFormatMemoryEnc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlDocDumpMemory
+extern __typeof (xmlDocDumpMemory) xmlDocDumpMemory __attribute((alias("xmlDocDumpMemory__internal_alias")));
+#else
+#ifndef xmlDocDumpMemory
+extern __typeof (xmlDocDumpMemory) xmlDocDumpMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlDocDumpMemory xmlDocDumpMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlDocDumpMemoryEnc
+extern __typeof (xmlDocDumpMemoryEnc) xmlDocDumpMemoryEnc __attribute((alias("xmlDocDumpMemoryEnc__internal_alias")));
+#else
+#ifndef xmlDocDumpMemoryEnc
+extern __typeof (xmlDocDumpMemoryEnc) xmlDocDumpMemoryEnc__internal_alias __attribute((visibility("hidden")));
+#define xmlDocDumpMemoryEnc xmlDocDumpMemoryEnc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlDocFormatDump
+extern __typeof (xmlDocFormatDump) xmlDocFormatDump __attribute((alias("xmlDocFormatDump__internal_alias")));
+#else
+#ifndef xmlDocFormatDump
+extern __typeof (xmlDocFormatDump) xmlDocFormatDump__internal_alias __attribute((visibility("hidden")));
+#define xmlDocFormatDump xmlDocFormatDump__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlDocGetRootElement
+extern __typeof (xmlDocGetRootElement) xmlDocGetRootElement __attribute((alias("xmlDocGetRootElement__internal_alias")));
+#else
+#ifndef xmlDocGetRootElement
+extern __typeof (xmlDocGetRootElement) xmlDocGetRootElement__internal_alias __attribute((visibility("hidden")));
+#define xmlDocGetRootElement xmlDocGetRootElement__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_tree
+#undef xmlDocSetRootElement
+extern __typeof (xmlDocSetRootElement) xmlDocSetRootElement __attribute((alias("xmlDocSetRootElement__internal_alias")));
+#else
+#ifndef xmlDocSetRootElement
+extern __typeof (xmlDocSetRootElement) xmlDocSetRootElement__internal_alias __attribute((visibility("hidden")));
+#define xmlDocSetRootElement xmlDocSetRootElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_valid
+#undef xmlDumpAttributeDecl
+extern __typeof (xmlDumpAttributeDecl) xmlDumpAttributeDecl __attribute((alias("xmlDumpAttributeDecl__internal_alias")));
+#else
+#ifndef xmlDumpAttributeDecl
+extern __typeof (xmlDumpAttributeDecl) xmlDumpAttributeDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlDumpAttributeDecl xmlDumpAttributeDecl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_valid
+#undef xmlDumpAttributeTable
+extern __typeof (xmlDumpAttributeTable) xmlDumpAttributeTable __attribute((alias("xmlDumpAttributeTable__internal_alias")));
+#else
+#ifndef xmlDumpAttributeTable
+extern __typeof (xmlDumpAttributeTable) xmlDumpAttributeTable__internal_alias __attribute((visibility("hidden")));
+#define xmlDumpAttributeTable xmlDumpAttributeTable__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_valid
+#undef xmlDumpElementDecl
+extern __typeof (xmlDumpElementDecl) xmlDumpElementDecl __attribute((alias("xmlDumpElementDecl__internal_alias")));
+#else
+#ifndef xmlDumpElementDecl
+extern __typeof (xmlDumpElementDecl) xmlDumpElementDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlDumpElementDecl xmlDumpElementDecl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_valid
+#undef xmlDumpElementTable
+extern __typeof (xmlDumpElementTable) xmlDumpElementTable __attribute((alias("xmlDumpElementTable__internal_alias")));
+#else
+#ifndef xmlDumpElementTable
+extern __typeof (xmlDumpElementTable) xmlDumpElementTable__internal_alias __attribute((visibility("hidden")));
+#define xmlDumpElementTable xmlDumpElementTable__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_entities
+#undef xmlDumpEntitiesTable
+extern __typeof (xmlDumpEntitiesTable) xmlDumpEntitiesTable __attribute((alias("xmlDumpEntitiesTable__internal_alias")));
+#else
+#ifndef xmlDumpEntitiesTable
+extern __typeof (xmlDumpEntitiesTable) xmlDumpEntitiesTable__internal_alias __attribute((visibility("hidden")));
+#define xmlDumpEntitiesTable xmlDumpEntitiesTable__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_entities
+#undef xmlDumpEntityDecl
+extern __typeof (xmlDumpEntityDecl) xmlDumpEntityDecl __attribute((alias("xmlDumpEntityDecl__internal_alias")));
+#else
+#ifndef xmlDumpEntityDecl
+extern __typeof (xmlDumpEntityDecl) xmlDumpEntityDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlDumpEntityDecl xmlDumpEntityDecl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_valid
+#undef xmlDumpNotationDecl
+extern __typeof (xmlDumpNotationDecl) xmlDumpNotationDecl __attribute((alias("xmlDumpNotationDecl__internal_alias")));
+#else
+#ifndef xmlDumpNotationDecl
+extern __typeof (xmlDumpNotationDecl) xmlDumpNotationDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlDumpNotationDecl xmlDumpNotationDecl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_valid
+#undef xmlDumpNotationTable
+extern __typeof (xmlDumpNotationTable) xmlDumpNotationTable __attribute((alias("xmlDumpNotationTable__internal_alias")));
+#else
+#ifndef xmlDumpNotationTable
+extern __typeof (xmlDumpNotationTable) xmlDumpNotationTable__internal_alias __attribute((visibility("hidden")));
+#define xmlDumpNotationTable xmlDumpNotationTable__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlElemDump
+extern __typeof (xmlElemDump) xmlElemDump __attribute((alias("xmlElemDump__internal_alias")));
+#else
+#ifndef xmlElemDump
+extern __typeof (xmlElemDump) xmlElemDump__internal_alias __attribute((visibility("hidden")));
+#define xmlElemDump xmlElemDump__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlEncodeEntities
+extern __typeof (xmlEncodeEntities) xmlEncodeEntities __attribute((alias("xmlEncodeEntities__internal_alias")));
+#else
+#ifndef xmlEncodeEntities
+extern __typeof (xmlEncodeEntities) xmlEncodeEntities__internal_alias __attribute((visibility("hidden")));
+#define xmlEncodeEntities xmlEncodeEntities__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlEncodeEntitiesReentrant
+extern __typeof (xmlEncodeEntitiesReentrant) xmlEncodeEntitiesReentrant __attribute((alias("xmlEncodeEntitiesReentrant__internal_alias")));
+#else
+#ifndef xmlEncodeEntitiesReentrant
+extern __typeof (xmlEncodeEntitiesReentrant) xmlEncodeEntitiesReentrant__internal_alias __attribute((visibility("hidden")));
+#define xmlEncodeEntitiesReentrant xmlEncodeEntitiesReentrant__internal_alias
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlEncodeSpecialChars
+extern __typeof (xmlEncodeSpecialChars) xmlEncodeSpecialChars __attribute((alias("xmlEncodeSpecialChars__internal_alias")));
+#else
+#ifndef xmlEncodeSpecialChars
+extern __typeof (xmlEncodeSpecialChars) xmlEncodeSpecialChars__internal_alias __attribute((visibility("hidden")));
+#define xmlEncodeSpecialChars xmlEncodeSpecialChars__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlErrMemory
+extern __typeof (xmlErrMemory) xmlErrMemory __attribute((alias("xmlErrMemory__internal_alias")));
+#else
+#ifndef xmlErrMemory
+extern __typeof (xmlErrMemory) xmlErrMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlErrMemory xmlErrMemory__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpCtxtNbCons
+extern __typeof (xmlExpCtxtNbCons) xmlExpCtxtNbCons __attribute((alias("xmlExpCtxtNbCons__internal_alias")));
+#else
+#ifndef xmlExpCtxtNbCons
+extern __typeof (xmlExpCtxtNbCons) xmlExpCtxtNbCons__internal_alias __attribute((visibility("hidden")));
+#define xmlExpCtxtNbCons xmlExpCtxtNbCons__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpCtxtNbNodes
+extern __typeof (xmlExpCtxtNbNodes) xmlExpCtxtNbNodes __attribute((alias("xmlExpCtxtNbNodes__internal_alias")));
+#else
+#ifndef xmlExpCtxtNbNodes
+extern __typeof (xmlExpCtxtNbNodes) xmlExpCtxtNbNodes__internal_alias __attribute((visibility("hidden")));
+#define xmlExpCtxtNbNodes xmlExpCtxtNbNodes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpDump
+extern __typeof (xmlExpDump) xmlExpDump __attribute((alias("xmlExpDump__internal_alias")));
+#else
+#ifndef xmlExpDump
+extern __typeof (xmlExpDump) xmlExpDump__internal_alias __attribute((visibility("hidden")));
+#define xmlExpDump xmlExpDump__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpExpDerive
+extern __typeof (xmlExpExpDerive) xmlExpExpDerive __attribute((alias("xmlExpExpDerive__internal_alias")));
+#else
+#ifndef xmlExpExpDerive
+extern __typeof (xmlExpExpDerive) xmlExpExpDerive__internal_alias __attribute((visibility("hidden")));
+#define xmlExpExpDerive xmlExpExpDerive__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpFree
+extern __typeof (xmlExpFree) xmlExpFree __attribute((alias("xmlExpFree__internal_alias")));
+#else
+#ifndef xmlExpFree
+extern __typeof (xmlExpFree) xmlExpFree__internal_alias __attribute((visibility("hidden")));
+#define xmlExpFree xmlExpFree__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpFreeCtxt
+extern __typeof (xmlExpFreeCtxt) xmlExpFreeCtxt __attribute((alias("xmlExpFreeCtxt__internal_alias")));
+#else
+#ifndef xmlExpFreeCtxt
+extern __typeof (xmlExpFreeCtxt) xmlExpFreeCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlExpFreeCtxt xmlExpFreeCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpGetLanguage
+extern __typeof (xmlExpGetLanguage) xmlExpGetLanguage __attribute((alias("xmlExpGetLanguage__internal_alias")));
+#else
+#ifndef xmlExpGetLanguage
+extern __typeof (xmlExpGetLanguage) xmlExpGetLanguage__internal_alias __attribute((visibility("hidden")));
+#define xmlExpGetLanguage xmlExpGetLanguage__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpGetStart
+extern __typeof (xmlExpGetStart) xmlExpGetStart __attribute((alias("xmlExpGetStart__internal_alias")));
+#else
+#ifndef xmlExpGetStart
+extern __typeof (xmlExpGetStart) xmlExpGetStart__internal_alias __attribute((visibility("hidden")));
+#define xmlExpGetStart xmlExpGetStart__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpIsNillable
+extern __typeof (xmlExpIsNillable) xmlExpIsNillable __attribute((alias("xmlExpIsNillable__internal_alias")));
+#else
+#ifndef xmlExpIsNillable
+extern __typeof (xmlExpIsNillable) xmlExpIsNillable__internal_alias __attribute((visibility("hidden")));
+#define xmlExpIsNillable xmlExpIsNillable__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpMaxToken
+extern __typeof (xmlExpMaxToken) xmlExpMaxToken __attribute((alias("xmlExpMaxToken__internal_alias")));
+#else
+#ifndef xmlExpMaxToken
+extern __typeof (xmlExpMaxToken) xmlExpMaxToken__internal_alias __attribute((visibility("hidden")));
+#define xmlExpMaxToken xmlExpMaxToken__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpNewAtom
+extern __typeof (xmlExpNewAtom) xmlExpNewAtom __attribute((alias("xmlExpNewAtom__internal_alias")));
+#else
+#ifndef xmlExpNewAtom
+extern __typeof (xmlExpNewAtom) xmlExpNewAtom__internal_alias __attribute((visibility("hidden")));
+#define xmlExpNewAtom xmlExpNewAtom__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpNewCtxt
+extern __typeof (xmlExpNewCtxt) xmlExpNewCtxt __attribute((alias("xmlExpNewCtxt__internal_alias")));
+#else
+#ifndef xmlExpNewCtxt
+extern __typeof (xmlExpNewCtxt) xmlExpNewCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlExpNewCtxt xmlExpNewCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpNewOr
+extern __typeof (xmlExpNewOr) xmlExpNewOr __attribute((alias("xmlExpNewOr__internal_alias")));
+#else
+#ifndef xmlExpNewOr
+extern __typeof (xmlExpNewOr) xmlExpNewOr__internal_alias __attribute((visibility("hidden")));
+#define xmlExpNewOr xmlExpNewOr__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpNewRange
+extern __typeof (xmlExpNewRange) xmlExpNewRange __attribute((alias("xmlExpNewRange__internal_alias")));
+#else
+#ifndef xmlExpNewRange
+extern __typeof (xmlExpNewRange) xmlExpNewRange__internal_alias __attribute((visibility("hidden")));
+#define xmlExpNewRange xmlExpNewRange__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpNewSeq
+extern __typeof (xmlExpNewSeq) xmlExpNewSeq __attribute((alias("xmlExpNewSeq__internal_alias")));
+#else
+#ifndef xmlExpNewSeq
+extern __typeof (xmlExpNewSeq) xmlExpNewSeq__internal_alias __attribute((visibility("hidden")));
+#define xmlExpNewSeq xmlExpNewSeq__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpParse
+extern __typeof (xmlExpParse) xmlExpParse __attribute((alias("xmlExpParse__internal_alias")));
+#else
+#ifndef xmlExpParse
+extern __typeof (xmlExpParse) xmlExpParse__internal_alias __attribute((visibility("hidden")));
+#define xmlExpParse xmlExpParse__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpRef
+extern __typeof (xmlExpRef) xmlExpRef __attribute((alias("xmlExpRef__internal_alias")));
+#else
+#ifndef xmlExpRef
+extern __typeof (xmlExpRef) xmlExpRef__internal_alias __attribute((visibility("hidden")));
+#define xmlExpRef xmlExpRef__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpStringDerive
+extern __typeof (xmlExpStringDerive) xmlExpStringDerive __attribute((alias("xmlExpStringDerive__internal_alias")));
+#else
+#ifndef xmlExpStringDerive
+extern __typeof (xmlExpStringDerive) xmlExpStringDerive__internal_alias __attribute((visibility("hidden")));
+#define xmlExpStringDerive xmlExpStringDerive__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_EXPR_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlExpSubsume
+extern __typeof (xmlExpSubsume) xmlExpSubsume __attribute((alias("xmlExpSubsume__internal_alias")));
+#else
+#ifndef xmlExpSubsume
+extern __typeof (xmlExpSubsume) xmlExpSubsume__internal_alias __attribute((visibility("hidden")));
+#define xmlExpSubsume xmlExpSubsume__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlFileClose
+extern __typeof (xmlFileClose) xmlFileClose __attribute((alias("xmlFileClose__internal_alias")));
+#else
+#ifndef xmlFileClose
+extern __typeof (xmlFileClose) xmlFileClose__internal_alias __attribute((visibility("hidden")));
+#define xmlFileClose xmlFileClose__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlFileMatch
+extern __typeof (xmlFileMatch) xmlFileMatch __attribute((alias("xmlFileMatch__internal_alias")));
+#else
+#ifndef xmlFileMatch
+extern __typeof (xmlFileMatch) xmlFileMatch__internal_alias __attribute((visibility("hidden")));
+#define xmlFileMatch xmlFileMatch__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlFileOpen
+extern __typeof (xmlFileOpen) xmlFileOpen __attribute((alias("xmlFileOpen__internal_alias")));
+#else
+#ifndef xmlFileOpen
+extern __typeof (xmlFileOpen) xmlFileOpen__internal_alias __attribute((visibility("hidden")));
+#define xmlFileOpen xmlFileOpen__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlFileRead
+extern __typeof (xmlFileRead) xmlFileRead __attribute((alias("xmlFileRead__internal_alias")));
+#else
+#ifndef xmlFileRead
+extern __typeof (xmlFileRead) xmlFileRead__internal_alias __attribute((visibility("hidden")));
+#define xmlFileRead xmlFileRead__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlFindCharEncodingHandler
+extern __typeof (xmlFindCharEncodingHandler) xmlFindCharEncodingHandler __attribute((alias("xmlFindCharEncodingHandler__internal_alias")));
+#else
+#ifndef xmlFindCharEncodingHandler
+extern __typeof (xmlFindCharEncodingHandler) xmlFindCharEncodingHandler__internal_alias __attribute((visibility("hidden")));
+#define xmlFindCharEncodingHandler xmlFindCharEncodingHandler__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlFirstElementChild
+extern __typeof (xmlFirstElementChild) xmlFirstElementChild __attribute((alias("xmlFirstElementChild__internal_alias")));
+#else
+#ifndef xmlFirstElementChild
+extern __typeof (xmlFirstElementChild) xmlFirstElementChild__internal_alias __attribute((visibility("hidden")));
+#define xmlFirstElementChild xmlFirstElementChild__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlFreeAttributeTable
+extern __typeof (xmlFreeAttributeTable) xmlFreeAttributeTable __attribute((alias("xmlFreeAttributeTable__internal_alias")));
+#else
+#ifndef xmlFreeAttributeTable
+extern __typeof (xmlFreeAttributeTable) xmlFreeAttributeTable__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeAttributeTable xmlFreeAttributeTable__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlFreeAutomata
+extern __typeof (xmlFreeAutomata) xmlFreeAutomata __attribute((alias("xmlFreeAutomata__internal_alias")));
+#else
+#ifndef xmlFreeAutomata
+extern __typeof (xmlFreeAutomata) xmlFreeAutomata__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeAutomata xmlFreeAutomata__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlFreeCatalog
+extern __typeof (xmlFreeCatalog) xmlFreeCatalog __attribute((alias("xmlFreeCatalog__internal_alias")));
+#else
+#ifndef xmlFreeCatalog
+extern __typeof (xmlFreeCatalog) xmlFreeCatalog__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeCatalog xmlFreeCatalog__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlFreeDoc
+extern __typeof (xmlFreeDoc) xmlFreeDoc __attribute((alias("xmlFreeDoc__internal_alias")));
+#else
+#ifndef xmlFreeDoc
+extern __typeof (xmlFreeDoc) xmlFreeDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeDoc xmlFreeDoc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlFreeDocElementContent
+extern __typeof (xmlFreeDocElementContent) xmlFreeDocElementContent __attribute((alias("xmlFreeDocElementContent__internal_alias")));
+#else
+#ifndef xmlFreeDocElementContent
+extern __typeof (xmlFreeDocElementContent) xmlFreeDocElementContent__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeDocElementContent xmlFreeDocElementContent__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlFreeDtd
+extern __typeof (xmlFreeDtd) xmlFreeDtd __attribute((alias("xmlFreeDtd__internal_alias")));
+#else
+#ifndef xmlFreeDtd
+extern __typeof (xmlFreeDtd) xmlFreeDtd__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeDtd xmlFreeDtd__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlFreeElementContent
+extern __typeof (xmlFreeElementContent) xmlFreeElementContent __attribute((alias("xmlFreeElementContent__internal_alias")));
+#else
+#ifndef xmlFreeElementContent
+extern __typeof (xmlFreeElementContent) xmlFreeElementContent__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeElementContent xmlFreeElementContent__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlFreeElementTable
+extern __typeof (xmlFreeElementTable) xmlFreeElementTable __attribute((alias("xmlFreeElementTable__internal_alias")));
+#else
+#ifndef xmlFreeElementTable
+extern __typeof (xmlFreeElementTable) xmlFreeElementTable__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeElementTable xmlFreeElementTable__internal_alias
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlFreeEntitiesTable
+extern __typeof (xmlFreeEntitiesTable) xmlFreeEntitiesTable __attribute((alias("xmlFreeEntitiesTable__internal_alias")));
+#else
+#ifndef xmlFreeEntitiesTable
+extern __typeof (xmlFreeEntitiesTable) xmlFreeEntitiesTable__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeEntitiesTable xmlFreeEntitiesTable__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlFreeEnumeration
+extern __typeof (xmlFreeEnumeration) xmlFreeEnumeration __attribute((alias("xmlFreeEnumeration__internal_alias")));
+#else
+#ifndef xmlFreeEnumeration
+extern __typeof (xmlFreeEnumeration) xmlFreeEnumeration__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeEnumeration xmlFreeEnumeration__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlFreeIDTable
+extern __typeof (xmlFreeIDTable) xmlFreeIDTable __attribute((alias("xmlFreeIDTable__internal_alias")));
+#else
+#ifndef xmlFreeIDTable
+extern __typeof (xmlFreeIDTable) xmlFreeIDTable__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeIDTable xmlFreeIDTable__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlFreeInputStream
+extern __typeof (xmlFreeInputStream) xmlFreeInputStream __attribute((alias("xmlFreeInputStream__internal_alias")));
+#else
+#ifndef xmlFreeInputStream
+extern __typeof (xmlFreeInputStream) xmlFreeInputStream__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeInputStream xmlFreeInputStream__internal_alias
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlFreeMutex
+extern __typeof (xmlFreeMutex) xmlFreeMutex __attribute((alias("xmlFreeMutex__internal_alias")));
+#else
+#ifndef xmlFreeMutex
+extern __typeof (xmlFreeMutex) xmlFreeMutex__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeMutex xmlFreeMutex__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlFreeNode
+extern __typeof (xmlFreeNode) xmlFreeNode __attribute((alias("xmlFreeNode__internal_alias")));
+#else
+#ifndef xmlFreeNode
+extern __typeof (xmlFreeNode) xmlFreeNode__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeNode xmlFreeNode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlFreeNodeList
+extern __typeof (xmlFreeNodeList) xmlFreeNodeList __attribute((alias("xmlFreeNodeList__internal_alias")));
+#else
+#ifndef xmlFreeNodeList
+extern __typeof (xmlFreeNodeList) xmlFreeNodeList__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeNodeList xmlFreeNodeList__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlFreeNotationTable
+extern __typeof (xmlFreeNotationTable) xmlFreeNotationTable __attribute((alias("xmlFreeNotationTable__internal_alias")));
+#else
+#ifndef xmlFreeNotationTable
+extern __typeof (xmlFreeNotationTable) xmlFreeNotationTable__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeNotationTable xmlFreeNotationTable__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlFreeNs
+extern __typeof (xmlFreeNs) xmlFreeNs __attribute((alias("xmlFreeNs__internal_alias")));
+#else
+#ifndef xmlFreeNs
+extern __typeof (xmlFreeNs) xmlFreeNs__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeNs xmlFreeNs__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlFreeNsList
+extern __typeof (xmlFreeNsList) xmlFreeNsList __attribute((alias("xmlFreeNsList__internal_alias")));
+#else
+#ifndef xmlFreeNsList
+extern __typeof (xmlFreeNsList) xmlFreeNsList__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeNsList xmlFreeNsList__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlFreeParserCtxt
+extern __typeof (xmlFreeParserCtxt) xmlFreeParserCtxt __attribute((alias("xmlFreeParserCtxt__internal_alias")));
+#else
+#ifndef xmlFreeParserCtxt
+extern __typeof (xmlFreeParserCtxt) xmlFreeParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeParserCtxt xmlFreeParserCtxt__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlFreeParserInputBuffer
+extern __typeof (xmlFreeParserInputBuffer) xmlFreeParserInputBuffer __attribute((alias("xmlFreeParserInputBuffer__internal_alias")));
+#else
+#ifndef xmlFreeParserInputBuffer
+extern __typeof (xmlFreeParserInputBuffer) xmlFreeParserInputBuffer__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeParserInputBuffer xmlFreeParserInputBuffer__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlFreePattern
+extern __typeof (xmlFreePattern) xmlFreePattern __attribute((alias("xmlFreePattern__internal_alias")));
+#else
+#ifndef xmlFreePattern
+extern __typeof (xmlFreePattern) xmlFreePattern__internal_alias __attribute((visibility("hidden")));
+#define xmlFreePattern xmlFreePattern__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlFreePatternList
+extern __typeof (xmlFreePatternList) xmlFreePatternList __attribute((alias("xmlFreePatternList__internal_alias")));
+#else
+#ifndef xmlFreePatternList
+extern __typeof (xmlFreePatternList) xmlFreePatternList__internal_alias __attribute((visibility("hidden")));
+#define xmlFreePatternList xmlFreePatternList__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlFreeProp
+extern __typeof (xmlFreeProp) xmlFreeProp __attribute((alias("xmlFreeProp__internal_alias")));
+#else
+#ifndef xmlFreeProp
+extern __typeof (xmlFreeProp) xmlFreeProp__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeProp xmlFreeProp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlFreePropList
+extern __typeof (xmlFreePropList) xmlFreePropList __attribute((alias("xmlFreePropList__internal_alias")));
+#else
+#ifndef xmlFreePropList
+extern __typeof (xmlFreePropList) xmlFreePropList__internal_alias __attribute((visibility("hidden")));
+#define xmlFreePropList xmlFreePropList__internal_alias
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlFreeRMutex
+extern __typeof (xmlFreeRMutex) xmlFreeRMutex __attribute((alias("xmlFreeRMutex__internal_alias")));
+#else
+#ifndef xmlFreeRMutex
+extern __typeof (xmlFreeRMutex) xmlFreeRMutex__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeRMutex xmlFreeRMutex__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlFreeRefTable
+extern __typeof (xmlFreeRefTable) xmlFreeRefTable __attribute((alias("xmlFreeRefTable__internal_alias")));
+#else
+#ifndef xmlFreeRefTable
+extern __typeof (xmlFreeRefTable) xmlFreeRefTable__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeRefTable xmlFreeRefTable__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlFreeStreamCtxt
+extern __typeof (xmlFreeStreamCtxt) xmlFreeStreamCtxt __attribute((alias("xmlFreeStreamCtxt__internal_alias")));
+#else
+#ifndef xmlFreeStreamCtxt
+extern __typeof (xmlFreeStreamCtxt) xmlFreeStreamCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeStreamCtxt xmlFreeStreamCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlFreeTextReader
+extern __typeof (xmlFreeTextReader) xmlFreeTextReader __attribute((alias("xmlFreeTextReader__internal_alias")));
+#else
+#ifndef xmlFreeTextReader
+extern __typeof (xmlFreeTextReader) xmlFreeTextReader__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeTextReader xmlFreeTextReader__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlFreeTextWriter
+extern __typeof (xmlFreeTextWriter) xmlFreeTextWriter __attribute((alias("xmlFreeTextWriter__internal_alias")));
+#else
+#ifndef xmlFreeTextWriter
+extern __typeof (xmlFreeTextWriter) xmlFreeTextWriter__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeTextWriter xmlFreeTextWriter__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlFreeURI
+extern __typeof (xmlFreeURI) xmlFreeURI __attribute((alias("xmlFreeURI__internal_alias")));
+#else
+#ifndef xmlFreeURI
+extern __typeof (xmlFreeURI) xmlFreeURI__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeURI xmlFreeURI__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlFreeValidCtxt
+extern __typeof (xmlFreeValidCtxt) xmlFreeValidCtxt __attribute((alias("xmlFreeValidCtxt__internal_alias")));
+#else
+#ifndef xmlFreeValidCtxt
+extern __typeof (xmlFreeValidCtxt) xmlFreeValidCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlFreeValidCtxt xmlFreeValidCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlGcMemGet
+extern __typeof (xmlGcMemGet) xmlGcMemGet __attribute((alias("xmlGcMemGet__internal_alias")));
+#else
+#ifndef xmlGcMemGet
+extern __typeof (xmlGcMemGet) xmlGcMemGet__internal_alias __attribute((visibility("hidden")));
+#define xmlGcMemGet xmlGcMemGet__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlGcMemSetup
+extern __typeof (xmlGcMemSetup) xmlGcMemSetup __attribute((alias("xmlGcMemSetup__internal_alias")));
+#else
+#ifndef xmlGcMemSetup
+extern __typeof (xmlGcMemSetup) xmlGcMemSetup__internal_alias __attribute((visibility("hidden")));
+#define xmlGcMemSetup xmlGcMemSetup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlGetBufferAllocationScheme
+extern __typeof (xmlGetBufferAllocationScheme) xmlGetBufferAllocationScheme __attribute((alias("xmlGetBufferAllocationScheme__internal_alias")));
+#else
+#ifndef xmlGetBufferAllocationScheme
+extern __typeof (xmlGetBufferAllocationScheme) xmlGetBufferAllocationScheme__internal_alias __attribute((visibility("hidden")));
+#define xmlGetBufferAllocationScheme xmlGetBufferAllocationScheme__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlGetCharEncodingHandler
+extern __typeof (xmlGetCharEncodingHandler) xmlGetCharEncodingHandler __attribute((alias("xmlGetCharEncodingHandler__internal_alias")));
+#else
+#ifndef xmlGetCharEncodingHandler
+extern __typeof (xmlGetCharEncodingHandler) xmlGetCharEncodingHandler__internal_alias __attribute((visibility("hidden")));
+#define xmlGetCharEncodingHandler xmlGetCharEncodingHandler__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlGetCharEncodingName
+extern __typeof (xmlGetCharEncodingName) xmlGetCharEncodingName __attribute((alias("xmlGetCharEncodingName__internal_alias")));
+#else
+#ifndef xmlGetCharEncodingName
+extern __typeof (xmlGetCharEncodingName) xmlGetCharEncodingName__internal_alias __attribute((visibility("hidden")));
+#define xmlGetCharEncodingName xmlGetCharEncodingName__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlGetCompressMode
+extern __typeof (xmlGetCompressMode) xmlGetCompressMode __attribute((alias("xmlGetCompressMode__internal_alias")));
+#else
+#ifndef xmlGetCompressMode
+extern __typeof (xmlGetCompressMode) xmlGetCompressMode__internal_alias __attribute((visibility("hidden")));
+#define xmlGetCompressMode xmlGetCompressMode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlGetDocCompressMode
+extern __typeof (xmlGetDocCompressMode) xmlGetDocCompressMode __attribute((alias("xmlGetDocCompressMode__internal_alias")));
+#else
+#ifndef xmlGetDocCompressMode
+extern __typeof (xmlGetDocCompressMode) xmlGetDocCompressMode__internal_alias __attribute((visibility("hidden")));
+#define xmlGetDocCompressMode xmlGetDocCompressMode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlGetDocEntity
+extern __typeof (xmlGetDocEntity) xmlGetDocEntity __attribute((alias("xmlGetDocEntity__internal_alias")));
+#else
+#ifndef xmlGetDocEntity
+extern __typeof (xmlGetDocEntity) xmlGetDocEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlGetDocEntity xmlGetDocEntity__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlGetDtdAttrDesc
+extern __typeof (xmlGetDtdAttrDesc) xmlGetDtdAttrDesc __attribute((alias("xmlGetDtdAttrDesc__internal_alias")));
+#else
+#ifndef xmlGetDtdAttrDesc
+extern __typeof (xmlGetDtdAttrDesc) xmlGetDtdAttrDesc__internal_alias __attribute((visibility("hidden")));
+#define xmlGetDtdAttrDesc xmlGetDtdAttrDesc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlGetDtdElementDesc
+extern __typeof (xmlGetDtdElementDesc) xmlGetDtdElementDesc __attribute((alias("xmlGetDtdElementDesc__internal_alias")));
+#else
+#ifndef xmlGetDtdElementDesc
+extern __typeof (xmlGetDtdElementDesc) xmlGetDtdElementDesc__internal_alias __attribute((visibility("hidden")));
+#define xmlGetDtdElementDesc xmlGetDtdElementDesc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlGetDtdEntity
+extern __typeof (xmlGetDtdEntity) xmlGetDtdEntity __attribute((alias("xmlGetDtdEntity__internal_alias")));
+#else
+#ifndef xmlGetDtdEntity
+extern __typeof (xmlGetDtdEntity) xmlGetDtdEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlGetDtdEntity xmlGetDtdEntity__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlGetDtdNotationDesc
+extern __typeof (xmlGetDtdNotationDesc) xmlGetDtdNotationDesc __attribute((alias("xmlGetDtdNotationDesc__internal_alias")));
+#else
+#ifndef xmlGetDtdNotationDesc
+extern __typeof (xmlGetDtdNotationDesc) xmlGetDtdNotationDesc__internal_alias __attribute((visibility("hidden")));
+#define xmlGetDtdNotationDesc xmlGetDtdNotationDesc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlGetDtdQAttrDesc
+extern __typeof (xmlGetDtdQAttrDesc) xmlGetDtdQAttrDesc __attribute((alias("xmlGetDtdQAttrDesc__internal_alias")));
+#else
+#ifndef xmlGetDtdQAttrDesc
+extern __typeof (xmlGetDtdQAttrDesc) xmlGetDtdQAttrDesc__internal_alias __attribute((visibility("hidden")));
+#define xmlGetDtdQAttrDesc xmlGetDtdQAttrDesc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlGetDtdQElementDesc
+extern __typeof (xmlGetDtdQElementDesc) xmlGetDtdQElementDesc __attribute((alias("xmlGetDtdQElementDesc__internal_alias")));
+#else
+#ifndef xmlGetDtdQElementDesc
+extern __typeof (xmlGetDtdQElementDesc) xmlGetDtdQElementDesc__internal_alias __attribute((visibility("hidden")));
+#define xmlGetDtdQElementDesc xmlGetDtdQElementDesc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlGetEncodingAlias
+extern __typeof (xmlGetEncodingAlias) xmlGetEncodingAlias __attribute((alias("xmlGetEncodingAlias__internal_alias")));
+#else
+#ifndef xmlGetEncodingAlias
+extern __typeof (xmlGetEncodingAlias) xmlGetEncodingAlias__internal_alias __attribute((visibility("hidden")));
+#define xmlGetEncodingAlias xmlGetEncodingAlias__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlGetExternalEntityLoader
+extern __typeof (xmlGetExternalEntityLoader) xmlGetExternalEntityLoader __attribute((alias("xmlGetExternalEntityLoader__internal_alias")));
+#else
+#ifndef xmlGetExternalEntityLoader
+extern __typeof (xmlGetExternalEntityLoader) xmlGetExternalEntityLoader__internal_alias __attribute((visibility("hidden")));
+#define xmlGetExternalEntityLoader xmlGetExternalEntityLoader__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlGetFeature
+extern __typeof (xmlGetFeature) xmlGetFeature __attribute((alias("xmlGetFeature__internal_alias")));
+#else
+#ifndef xmlGetFeature
+extern __typeof (xmlGetFeature) xmlGetFeature__internal_alias __attribute((visibility("hidden")));
+#define xmlGetFeature xmlGetFeature__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlGetFeaturesList
+extern __typeof (xmlGetFeaturesList) xmlGetFeaturesList __attribute((alias("xmlGetFeaturesList__internal_alias")));
+#else
+#ifndef xmlGetFeaturesList
+extern __typeof (xmlGetFeaturesList) xmlGetFeaturesList__internal_alias __attribute((visibility("hidden")));
+#define xmlGetFeaturesList xmlGetFeaturesList__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlGetGlobalState
+extern __typeof (xmlGetGlobalState) xmlGetGlobalState __attribute((alias("xmlGetGlobalState__internal_alias")));
+#else
+#ifndef xmlGetGlobalState
+extern __typeof (xmlGetGlobalState) xmlGetGlobalState__internal_alias __attribute((visibility("hidden")));
+#define xmlGetGlobalState xmlGetGlobalState__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlGetID
+extern __typeof (xmlGetID) xmlGetID __attribute((alias("xmlGetID__internal_alias")));
+#else
+#ifndef xmlGetID
+extern __typeof (xmlGetID) xmlGetID__internal_alias __attribute((visibility("hidden")));
+#define xmlGetID xmlGetID__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlGetIntSubset
+extern __typeof (xmlGetIntSubset) xmlGetIntSubset __attribute((alias("xmlGetIntSubset__internal_alias")));
+#else
+#ifndef xmlGetIntSubset
+extern __typeof (xmlGetIntSubset) xmlGetIntSubset__internal_alias __attribute((visibility("hidden")));
+#define xmlGetIntSubset xmlGetIntSubset__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlGetLastChild
+extern __typeof (xmlGetLastChild) xmlGetLastChild __attribute((alias("xmlGetLastChild__internal_alias")));
+#else
+#ifndef xmlGetLastChild
+extern __typeof (xmlGetLastChild) xmlGetLastChild__internal_alias __attribute((visibility("hidden")));
+#define xmlGetLastChild xmlGetLastChild__internal_alias
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlGetLastError
+extern __typeof (xmlGetLastError) xmlGetLastError __attribute((alias("xmlGetLastError__internal_alias")));
+#else
+#ifndef xmlGetLastError
+extern __typeof (xmlGetLastError) xmlGetLastError__internal_alias __attribute((visibility("hidden")));
+#define xmlGetLastError xmlGetLastError__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlGetLineNo
+extern __typeof (xmlGetLineNo) xmlGetLineNo __attribute((alias("xmlGetLineNo__internal_alias")));
+#else
+#ifndef xmlGetLineNo
+extern __typeof (xmlGetLineNo) xmlGetLineNo__internal_alias __attribute((visibility("hidden")));
+#define xmlGetLineNo xmlGetLineNo__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlGetNoNsProp
+extern __typeof (xmlGetNoNsProp) xmlGetNoNsProp __attribute((alias("xmlGetNoNsProp__internal_alias")));
+#else
+#ifndef xmlGetNoNsProp
+extern __typeof (xmlGetNoNsProp) xmlGetNoNsProp__internal_alias __attribute((visibility("hidden")));
+#define xmlGetNoNsProp xmlGetNoNsProp__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_tree
+#undef xmlGetNodePath
+extern __typeof (xmlGetNodePath) xmlGetNodePath __attribute((alias("xmlGetNodePath__internal_alias")));
+#else
+#ifndef xmlGetNodePath
+extern __typeof (xmlGetNodePath) xmlGetNodePath__internal_alias __attribute((visibility("hidden")));
+#define xmlGetNodePath xmlGetNodePath__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_tree
+#undef xmlGetNsList
+extern __typeof (xmlGetNsList) xmlGetNsList __attribute((alias("xmlGetNsList__internal_alias")));
+#else
+#ifndef xmlGetNsList
+extern __typeof (xmlGetNsList) xmlGetNsList__internal_alias __attribute((visibility("hidden")));
+#define xmlGetNsList xmlGetNsList__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlGetNsProp
+extern __typeof (xmlGetNsProp) xmlGetNsProp __attribute((alias("xmlGetNsProp__internal_alias")));
+#else
+#ifndef xmlGetNsProp
+extern __typeof (xmlGetNsProp) xmlGetNsProp__internal_alias __attribute((visibility("hidden")));
+#define xmlGetNsProp xmlGetNsProp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlGetParameterEntity
+extern __typeof (xmlGetParameterEntity) xmlGetParameterEntity __attribute((alias("xmlGetParameterEntity__internal_alias")));
+#else
+#ifndef xmlGetParameterEntity
+extern __typeof (xmlGetParameterEntity) xmlGetParameterEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlGetParameterEntity xmlGetParameterEntity__internal_alias
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlGetPredefinedEntity
+extern __typeof (xmlGetPredefinedEntity) xmlGetPredefinedEntity __attribute((alias("xmlGetPredefinedEntity__internal_alias")));
+#else
+#ifndef xmlGetPredefinedEntity
+extern __typeof (xmlGetPredefinedEntity) xmlGetPredefinedEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlGetPredefinedEntity xmlGetPredefinedEntity__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlGetProp
+extern __typeof (xmlGetProp) xmlGetProp __attribute((alias("xmlGetProp__internal_alias")));
+#else
+#ifndef xmlGetProp
+extern __typeof (xmlGetProp) xmlGetProp__internal_alias __attribute((visibility("hidden")));
+#define xmlGetProp xmlGetProp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlGetRefs
+extern __typeof (xmlGetRefs) xmlGetRefs __attribute((alias("xmlGetRefs__internal_alias")));
+#else
+#ifndef xmlGetRefs
+extern __typeof (xmlGetRefs) xmlGetRefs__internal_alias __attribute((visibility("hidden")));
+#define xmlGetRefs xmlGetRefs__internal_alias
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlGetThreadId
+extern __typeof (xmlGetThreadId) xmlGetThreadId __attribute((alias("xmlGetThreadId__internal_alias")));
+#else
+#ifndef xmlGetThreadId
+extern __typeof (xmlGetThreadId) xmlGetThreadId__internal_alias __attribute((visibility("hidden")));
+#define xmlGetThreadId xmlGetThreadId__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlGetUTF8Char
+extern __typeof (xmlGetUTF8Char) xmlGetUTF8Char __attribute((alias("xmlGetUTF8Char__internal_alias")));
+#else
+#ifndef xmlGetUTF8Char
+extern __typeof (xmlGetUTF8Char) xmlGetUTF8Char__internal_alias __attribute((visibility("hidden")));
+#define xmlGetUTF8Char xmlGetUTF8Char__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlHandleEntity
+extern __typeof (xmlHandleEntity) xmlHandleEntity __attribute((alias("xmlHandleEntity__internal_alias")));
+#else
+#ifndef xmlHandleEntity
+extern __typeof (xmlHandleEntity) xmlHandleEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlHandleEntity xmlHandleEntity__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlHasFeature
+extern __typeof (xmlHasFeature) xmlHasFeature __attribute((alias("xmlHasFeature__internal_alias")));
+#else
+#ifndef xmlHasFeature
+extern __typeof (xmlHasFeature) xmlHasFeature__internal_alias __attribute((visibility("hidden")));
+#define xmlHasFeature xmlHasFeature__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlHasNsProp
+extern __typeof (xmlHasNsProp) xmlHasNsProp __attribute((alias("xmlHasNsProp__internal_alias")));
+#else
+#ifndef xmlHasNsProp
+extern __typeof (xmlHasNsProp) xmlHasNsProp__internal_alias __attribute((visibility("hidden")));
+#define xmlHasNsProp xmlHasNsProp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlHasProp
+extern __typeof (xmlHasProp) xmlHasProp __attribute((alias("xmlHasProp__internal_alias")));
+#else
+#ifndef xmlHasProp
+extern __typeof (xmlHasProp) xmlHasProp__internal_alias __attribute((visibility("hidden")));
+#define xmlHasProp xmlHasProp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashAddEntry
+extern __typeof (xmlHashAddEntry) xmlHashAddEntry __attribute((alias("xmlHashAddEntry__internal_alias")));
+#else
+#ifndef xmlHashAddEntry
+extern __typeof (xmlHashAddEntry) xmlHashAddEntry__internal_alias __attribute((visibility("hidden")));
+#define xmlHashAddEntry xmlHashAddEntry__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashAddEntry2
+extern __typeof (xmlHashAddEntry2) xmlHashAddEntry2 __attribute((alias("xmlHashAddEntry2__internal_alias")));
+#else
+#ifndef xmlHashAddEntry2
+extern __typeof (xmlHashAddEntry2) xmlHashAddEntry2__internal_alias __attribute((visibility("hidden")));
+#define xmlHashAddEntry2 xmlHashAddEntry2__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashAddEntry3
+extern __typeof (xmlHashAddEntry3) xmlHashAddEntry3 __attribute((alias("xmlHashAddEntry3__internal_alias")));
+#else
+#ifndef xmlHashAddEntry3
+extern __typeof (xmlHashAddEntry3) xmlHashAddEntry3__internal_alias __attribute((visibility("hidden")));
+#define xmlHashAddEntry3 xmlHashAddEntry3__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashCopy
+extern __typeof (xmlHashCopy) xmlHashCopy __attribute((alias("xmlHashCopy__internal_alias")));
+#else
+#ifndef xmlHashCopy
+extern __typeof (xmlHashCopy) xmlHashCopy__internal_alias __attribute((visibility("hidden")));
+#define xmlHashCopy xmlHashCopy__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashCreate
+extern __typeof (xmlHashCreate) xmlHashCreate __attribute((alias("xmlHashCreate__internal_alias")));
+#else
+#ifndef xmlHashCreate
+extern __typeof (xmlHashCreate) xmlHashCreate__internal_alias __attribute((visibility("hidden")));
+#define xmlHashCreate xmlHashCreate__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashCreateDict
+extern __typeof (xmlHashCreateDict) xmlHashCreateDict __attribute((alias("xmlHashCreateDict__internal_alias")));
+#else
+#ifndef xmlHashCreateDict
+extern __typeof (xmlHashCreateDict) xmlHashCreateDict__internal_alias __attribute((visibility("hidden")));
+#define xmlHashCreateDict xmlHashCreateDict__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashFree
+extern __typeof (xmlHashFree) xmlHashFree __attribute((alias("xmlHashFree__internal_alias")));
+#else
+#ifndef xmlHashFree
+extern __typeof (xmlHashFree) xmlHashFree__internal_alias __attribute((visibility("hidden")));
+#define xmlHashFree xmlHashFree__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashLookup
+extern __typeof (xmlHashLookup) xmlHashLookup __attribute((alias("xmlHashLookup__internal_alias")));
+#else
+#ifndef xmlHashLookup
+extern __typeof (xmlHashLookup) xmlHashLookup__internal_alias __attribute((visibility("hidden")));
+#define xmlHashLookup xmlHashLookup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashLookup2
+extern __typeof (xmlHashLookup2) xmlHashLookup2 __attribute((alias("xmlHashLookup2__internal_alias")));
+#else
+#ifndef xmlHashLookup2
+extern __typeof (xmlHashLookup2) xmlHashLookup2__internal_alias __attribute((visibility("hidden")));
+#define xmlHashLookup2 xmlHashLookup2__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashLookup3
+extern __typeof (xmlHashLookup3) xmlHashLookup3 __attribute((alias("xmlHashLookup3__internal_alias")));
+#else
+#ifndef xmlHashLookup3
+extern __typeof (xmlHashLookup3) xmlHashLookup3__internal_alias __attribute((visibility("hidden")));
+#define xmlHashLookup3 xmlHashLookup3__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashQLookup
+extern __typeof (xmlHashQLookup) xmlHashQLookup __attribute((alias("xmlHashQLookup__internal_alias")));
+#else
+#ifndef xmlHashQLookup
+extern __typeof (xmlHashQLookup) xmlHashQLookup__internal_alias __attribute((visibility("hidden")));
+#define xmlHashQLookup xmlHashQLookup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashQLookup2
+extern __typeof (xmlHashQLookup2) xmlHashQLookup2 __attribute((alias("xmlHashQLookup2__internal_alias")));
+#else
+#ifndef xmlHashQLookup2
+extern __typeof (xmlHashQLookup2) xmlHashQLookup2__internal_alias __attribute((visibility("hidden")));
+#define xmlHashQLookup2 xmlHashQLookup2__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashQLookup3
+extern __typeof (xmlHashQLookup3) xmlHashQLookup3 __attribute((alias("xmlHashQLookup3__internal_alias")));
+#else
+#ifndef xmlHashQLookup3
+extern __typeof (xmlHashQLookup3) xmlHashQLookup3__internal_alias __attribute((visibility("hidden")));
+#define xmlHashQLookup3 xmlHashQLookup3__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashRemoveEntry
+extern __typeof (xmlHashRemoveEntry) xmlHashRemoveEntry __attribute((alias("xmlHashRemoveEntry__internal_alias")));
+#else
+#ifndef xmlHashRemoveEntry
+extern __typeof (xmlHashRemoveEntry) xmlHashRemoveEntry__internal_alias __attribute((visibility("hidden")));
+#define xmlHashRemoveEntry xmlHashRemoveEntry__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashRemoveEntry2
+extern __typeof (xmlHashRemoveEntry2) xmlHashRemoveEntry2 __attribute((alias("xmlHashRemoveEntry2__internal_alias")));
+#else
+#ifndef xmlHashRemoveEntry2
+extern __typeof (xmlHashRemoveEntry2) xmlHashRemoveEntry2__internal_alias __attribute((visibility("hidden")));
+#define xmlHashRemoveEntry2 xmlHashRemoveEntry2__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashRemoveEntry3
+extern __typeof (xmlHashRemoveEntry3) xmlHashRemoveEntry3 __attribute((alias("xmlHashRemoveEntry3__internal_alias")));
+#else
+#ifndef xmlHashRemoveEntry3
+extern __typeof (xmlHashRemoveEntry3) xmlHashRemoveEntry3__internal_alias __attribute((visibility("hidden")));
+#define xmlHashRemoveEntry3 xmlHashRemoveEntry3__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashScan
+extern __typeof (xmlHashScan) xmlHashScan __attribute((alias("xmlHashScan__internal_alias")));
+#else
+#ifndef xmlHashScan
+extern __typeof (xmlHashScan) xmlHashScan__internal_alias __attribute((visibility("hidden")));
+#define xmlHashScan xmlHashScan__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashScan3
+extern __typeof (xmlHashScan3) xmlHashScan3 __attribute((alias("xmlHashScan3__internal_alias")));
+#else
+#ifndef xmlHashScan3
+extern __typeof (xmlHashScan3) xmlHashScan3__internal_alias __attribute((visibility("hidden")));
+#define xmlHashScan3 xmlHashScan3__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashScanFull
+extern __typeof (xmlHashScanFull) xmlHashScanFull __attribute((alias("xmlHashScanFull__internal_alias")));
+#else
+#ifndef xmlHashScanFull
+extern __typeof (xmlHashScanFull) xmlHashScanFull__internal_alias __attribute((visibility("hidden")));
+#define xmlHashScanFull xmlHashScanFull__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashScanFull3
+extern __typeof (xmlHashScanFull3) xmlHashScanFull3 __attribute((alias("xmlHashScanFull3__internal_alias")));
+#else
+#ifndef xmlHashScanFull3
+extern __typeof (xmlHashScanFull3) xmlHashScanFull3__internal_alias __attribute((visibility("hidden")));
+#define xmlHashScanFull3 xmlHashScanFull3__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashSize
+extern __typeof (xmlHashSize) xmlHashSize __attribute((alias("xmlHashSize__internal_alias")));
+#else
+#ifndef xmlHashSize
+extern __typeof (xmlHashSize) xmlHashSize__internal_alias __attribute((visibility("hidden")));
+#define xmlHashSize xmlHashSize__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashUpdateEntry
+extern __typeof (xmlHashUpdateEntry) xmlHashUpdateEntry __attribute((alias("xmlHashUpdateEntry__internal_alias")));
+#else
+#ifndef xmlHashUpdateEntry
+extern __typeof (xmlHashUpdateEntry) xmlHashUpdateEntry__internal_alias __attribute((visibility("hidden")));
+#define xmlHashUpdateEntry xmlHashUpdateEntry__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashUpdateEntry2
+extern __typeof (xmlHashUpdateEntry2) xmlHashUpdateEntry2 __attribute((alias("xmlHashUpdateEntry2__internal_alias")));
+#else
+#ifndef xmlHashUpdateEntry2
+extern __typeof (xmlHashUpdateEntry2) xmlHashUpdateEntry2__internal_alias __attribute((visibility("hidden")));
+#define xmlHashUpdateEntry2 xmlHashUpdateEntry2__internal_alias
+#endif
+#endif
+
+#ifdef bottom_hash
+#undef xmlHashUpdateEntry3
+extern __typeof (xmlHashUpdateEntry3) xmlHashUpdateEntry3 __attribute((alias("xmlHashUpdateEntry3__internal_alias")));
+#else
+#ifndef xmlHashUpdateEntry3
+extern __typeof (xmlHashUpdateEntry3) xmlHashUpdateEntry3__internal_alias __attribute((visibility("hidden")));
+#define xmlHashUpdateEntry3 xmlHashUpdateEntry3__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlIOFTPClose
+extern __typeof (xmlIOFTPClose) xmlIOFTPClose __attribute((alias("xmlIOFTPClose__internal_alias")));
+#else
+#ifndef xmlIOFTPClose
+extern __typeof (xmlIOFTPClose) xmlIOFTPClose__internal_alias __attribute((visibility("hidden")));
+#define xmlIOFTPClose xmlIOFTPClose__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlIOFTPMatch
+extern __typeof (xmlIOFTPMatch) xmlIOFTPMatch __attribute((alias("xmlIOFTPMatch__internal_alias")));
+#else
+#ifndef xmlIOFTPMatch
+extern __typeof (xmlIOFTPMatch) xmlIOFTPMatch__internal_alias __attribute((visibility("hidden")));
+#define xmlIOFTPMatch xmlIOFTPMatch__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlIOFTPOpen
+extern __typeof (xmlIOFTPOpen) xmlIOFTPOpen __attribute((alias("xmlIOFTPOpen__internal_alias")));
+#else
+#ifndef xmlIOFTPOpen
+extern __typeof (xmlIOFTPOpen) xmlIOFTPOpen__internal_alias __attribute((visibility("hidden")));
+#define xmlIOFTPOpen xmlIOFTPOpen__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlIOFTPRead
+extern __typeof (xmlIOFTPRead) xmlIOFTPRead __attribute((alias("xmlIOFTPRead__internal_alias")));
+#else
+#ifndef xmlIOFTPRead
+extern __typeof (xmlIOFTPRead) xmlIOFTPRead__internal_alias __attribute((visibility("hidden")));
+#define xmlIOFTPRead xmlIOFTPRead__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlIOHTTPClose
+extern __typeof (xmlIOHTTPClose) xmlIOHTTPClose __attribute((alias("xmlIOHTTPClose__internal_alias")));
+#else
+#ifndef xmlIOHTTPClose
+extern __typeof (xmlIOHTTPClose) xmlIOHTTPClose__internal_alias __attribute((visibility("hidden")));
+#define xmlIOHTTPClose xmlIOHTTPClose__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlIOHTTPMatch
+extern __typeof (xmlIOHTTPMatch) xmlIOHTTPMatch __attribute((alias("xmlIOHTTPMatch__internal_alias")));
+#else
+#ifndef xmlIOHTTPMatch
+extern __typeof (xmlIOHTTPMatch) xmlIOHTTPMatch__internal_alias __attribute((visibility("hidden")));
+#define xmlIOHTTPMatch xmlIOHTTPMatch__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlIOHTTPOpen
+extern __typeof (xmlIOHTTPOpen) xmlIOHTTPOpen __attribute((alias("xmlIOHTTPOpen__internal_alias")));
+#else
+#ifndef xmlIOHTTPOpen
+extern __typeof (xmlIOHTTPOpen) xmlIOHTTPOpen__internal_alias __attribute((visibility("hidden")));
+#define xmlIOHTTPOpen xmlIOHTTPOpen__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlIOHTTPOpenW
+extern __typeof (xmlIOHTTPOpenW) xmlIOHTTPOpenW __attribute((alias("xmlIOHTTPOpenW__internal_alias")));
+#else
+#ifndef xmlIOHTTPOpenW
+extern __typeof (xmlIOHTTPOpenW) xmlIOHTTPOpenW__internal_alias __attribute((visibility("hidden")));
+#define xmlIOHTTPOpenW xmlIOHTTPOpenW__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlIOHTTPRead
+extern __typeof (xmlIOHTTPRead) xmlIOHTTPRead __attribute((alias("xmlIOHTTPRead__internal_alias")));
+#else
+#ifndef xmlIOHTTPRead
+extern __typeof (xmlIOHTTPRead) xmlIOHTTPRead__internal_alias __attribute((visibility("hidden")));
+#define xmlIOHTTPRead xmlIOHTTPRead__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_parser
+#undef xmlIOParseDTD
+extern __typeof (xmlIOParseDTD) xmlIOParseDTD __attribute((alias("xmlIOParseDTD__internal_alias")));
+#else
+#ifndef xmlIOParseDTD
+extern __typeof (xmlIOParseDTD) xmlIOParseDTD__internal_alias __attribute((visibility("hidden")));
+#define xmlIOParseDTD xmlIOParseDTD__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlInitCharEncodingHandlers
+extern __typeof (xmlInitCharEncodingHandlers) xmlInitCharEncodingHandlers __attribute((alias("xmlInitCharEncodingHandlers__internal_alias")));
+#else
+#ifndef xmlInitCharEncodingHandlers
+extern __typeof (xmlInitCharEncodingHandlers) xmlInitCharEncodingHandlers__internal_alias __attribute((visibility("hidden")));
+#define xmlInitCharEncodingHandlers xmlInitCharEncodingHandlers__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlInitGlobals
+extern __typeof (xmlInitGlobals) xmlInitGlobals __attribute((alias("xmlInitGlobals__internal_alias")));
+#else
+#ifndef xmlInitGlobals
+extern __typeof (xmlInitGlobals) xmlInitGlobals__internal_alias __attribute((visibility("hidden")));
+#define xmlInitGlobals xmlInitGlobals__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlInitMemory
+extern __typeof (xmlInitMemory) xmlInitMemory __attribute((alias("xmlInitMemory__internal_alias")));
+#else
+#ifndef xmlInitMemory
+extern __typeof (xmlInitMemory) xmlInitMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlInitMemory xmlInitMemory__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlInitNodeInfoSeq
+extern __typeof (xmlInitNodeInfoSeq) xmlInitNodeInfoSeq __attribute((alias("xmlInitNodeInfoSeq__internal_alias")));
+#else
+#ifndef xmlInitNodeInfoSeq
+extern __typeof (xmlInitNodeInfoSeq) xmlInitNodeInfoSeq__internal_alias __attribute((visibility("hidden")));
+#define xmlInitNodeInfoSeq xmlInitNodeInfoSeq__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlInitParser
+extern __typeof (xmlInitParser) xmlInitParser __attribute((alias("xmlInitParser__internal_alias")));
+#else
+#ifndef xmlInitParser
+extern __typeof (xmlInitParser) xmlInitParser__internal_alias __attribute((visibility("hidden")));
+#define xmlInitParser xmlInitParser__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlInitParserCtxt
+extern __typeof (xmlInitParserCtxt) xmlInitParserCtxt __attribute((alias("xmlInitParserCtxt__internal_alias")));
+#else
+#ifndef xmlInitParserCtxt
+extern __typeof (xmlInitParserCtxt) xmlInitParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlInitParserCtxt xmlInitParserCtxt__internal_alias
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlInitThreads
+extern __typeof (xmlInitThreads) xmlInitThreads __attribute((alias("xmlInitThreads__internal_alias")));
+#else
+#ifndef xmlInitThreads
+extern __typeof (xmlInitThreads) xmlInitThreads__internal_alias __attribute((visibility("hidden")));
+#define xmlInitThreads xmlInitThreads__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlInitializeCatalog
+extern __typeof (xmlInitializeCatalog) xmlInitializeCatalog __attribute((alias("xmlInitializeCatalog__internal_alias")));
+#else
+#ifndef xmlInitializeCatalog
+extern __typeof (xmlInitializeCatalog) xmlInitializeCatalog__internal_alias __attribute((visibility("hidden")));
+#define xmlInitializeCatalog xmlInitializeCatalog__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_dict
+#undef xmlInitializeDict
+extern __typeof (xmlInitializeDict) xmlInitializeDict __attribute((alias("xmlInitializeDict__internal_alias")));
+#else
+#ifndef xmlInitializeDict
+extern __typeof (xmlInitializeDict) xmlInitializeDict__internal_alias __attribute((visibility("hidden")));
+#define xmlInitializeDict xmlInitializeDict__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlInitializeGlobalState
+extern __typeof (xmlInitializeGlobalState) xmlInitializeGlobalState __attribute((alias("xmlInitializeGlobalState__internal_alias")));
+#else
+#ifndef xmlInitializeGlobalState
+extern __typeof (xmlInitializeGlobalState) xmlInitializeGlobalState__internal_alias __attribute((visibility("hidden")));
+#define xmlInitializeGlobalState xmlInitializeGlobalState__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlInitializePredefinedEntities
+extern __typeof (xmlInitializePredefinedEntities) xmlInitializePredefinedEntities __attribute((alias("xmlInitializePredefinedEntities__internal_alias")));
+#else
+#ifndef xmlInitializePredefinedEntities
+extern __typeof (xmlInitializePredefinedEntities) xmlInitializePredefinedEntities__internal_alias __attribute((visibility("hidden")));
+#define xmlInitializePredefinedEntities xmlInitializePredefinedEntities__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_chvalid
+#undef xmlIsBaseChar
+extern __typeof (xmlIsBaseChar) xmlIsBaseChar __attribute((alias("xmlIsBaseChar__internal_alias")));
+#else
+#ifndef xmlIsBaseChar
+extern __typeof (xmlIsBaseChar) xmlIsBaseChar__internal_alias __attribute((visibility("hidden")));
+#define xmlIsBaseChar xmlIsBaseChar__internal_alias
+#endif
+#endif
+
+#ifdef bottom_chvalid
+#undef xmlIsBlank
+extern __typeof (xmlIsBlank) xmlIsBlank __attribute((alias("xmlIsBlank__internal_alias")));
+#else
+#ifndef xmlIsBlank
+extern __typeof (xmlIsBlank) xmlIsBlank__internal_alias __attribute((visibility("hidden")));
+#define xmlIsBlank xmlIsBlank__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlIsBlankNode
+extern __typeof (xmlIsBlankNode) xmlIsBlankNode __attribute((alias("xmlIsBlankNode__internal_alias")));
+#else
+#ifndef xmlIsBlankNode
+extern __typeof (xmlIsBlankNode) xmlIsBlankNode__internal_alias __attribute((visibility("hidden")));
+#define xmlIsBlankNode xmlIsBlankNode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_chvalid
+#undef xmlIsChar
+extern __typeof (xmlIsChar) xmlIsChar __attribute((alias("xmlIsChar__internal_alias")));
+#else
+#ifndef xmlIsChar
+extern __typeof (xmlIsChar) xmlIsChar__internal_alias __attribute((visibility("hidden")));
+#define xmlIsChar xmlIsChar__internal_alias
+#endif
+#endif
+
+#ifdef bottom_chvalid
+#undef xmlIsCombining
+extern __typeof (xmlIsCombining) xmlIsCombining __attribute((alias("xmlIsCombining__internal_alias")));
+#else
+#ifndef xmlIsCombining
+extern __typeof (xmlIsCombining) xmlIsCombining__internal_alias __attribute((visibility("hidden")));
+#define xmlIsCombining xmlIsCombining__internal_alias
+#endif
+#endif
+
+#ifdef bottom_chvalid
+#undef xmlIsDigit
+extern __typeof (xmlIsDigit) xmlIsDigit __attribute((alias("xmlIsDigit__internal_alias")));
+#else
+#ifndef xmlIsDigit
+extern __typeof (xmlIsDigit) xmlIsDigit__internal_alias __attribute((visibility("hidden")));
+#define xmlIsDigit xmlIsDigit__internal_alias
+#endif
+#endif
+
+#ifdef bottom_chvalid
+#undef xmlIsExtender
+extern __typeof (xmlIsExtender) xmlIsExtender __attribute((alias("xmlIsExtender__internal_alias")));
+#else
+#ifndef xmlIsExtender
+extern __typeof (xmlIsExtender) xmlIsExtender__internal_alias __attribute((visibility("hidden")));
+#define xmlIsExtender xmlIsExtender__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlIsID
+extern __typeof (xmlIsID) xmlIsID __attribute((alias("xmlIsID__internal_alias")));
+#else
+#ifndef xmlIsID
+extern __typeof (xmlIsID) xmlIsID__internal_alias __attribute((visibility("hidden")));
+#define xmlIsID xmlIsID__internal_alias
+#endif
+#endif
+
+#ifdef bottom_chvalid
+#undef xmlIsIdeographic
+extern __typeof (xmlIsIdeographic) xmlIsIdeographic __attribute((alias("xmlIsIdeographic__internal_alias")));
+#else
+#ifndef xmlIsIdeographic
+extern __typeof (xmlIsIdeographic) xmlIsIdeographic__internal_alias __attribute((visibility("hidden")));
+#define xmlIsIdeographic xmlIsIdeographic__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlIsLetter
+extern __typeof (xmlIsLetter) xmlIsLetter __attribute((alias("xmlIsLetter__internal_alias")));
+#else
+#ifndef xmlIsLetter
+extern __typeof (xmlIsLetter) xmlIsLetter__internal_alias __attribute((visibility("hidden")));
+#define xmlIsLetter xmlIsLetter__internal_alias
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlIsMainThread
+extern __typeof (xmlIsMainThread) xmlIsMainThread __attribute((alias("xmlIsMainThread__internal_alias")));
+#else
+#ifndef xmlIsMainThread
+extern __typeof (xmlIsMainThread) xmlIsMainThread__internal_alias __attribute((visibility("hidden")));
+#define xmlIsMainThread xmlIsMainThread__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlIsMixedElement
+extern __typeof (xmlIsMixedElement) xmlIsMixedElement __attribute((alias("xmlIsMixedElement__internal_alias")));
+#else
+#ifndef xmlIsMixedElement
+extern __typeof (xmlIsMixedElement) xmlIsMixedElement__internal_alias __attribute((visibility("hidden")));
+#define xmlIsMixedElement xmlIsMixedElement__internal_alias
+#endif
+#endif
+
+#ifdef bottom_chvalid
+#undef xmlIsPubidChar
+extern __typeof (xmlIsPubidChar) xmlIsPubidChar __attribute((alias("xmlIsPubidChar__internal_alias")));
+#else
+#ifndef xmlIsPubidChar
+extern __typeof (xmlIsPubidChar) xmlIsPubidChar__internal_alias __attribute((visibility("hidden")));
+#define xmlIsPubidChar xmlIsPubidChar__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlIsRef
+extern __typeof (xmlIsRef) xmlIsRef __attribute((alias("xmlIsRef__internal_alias")));
+#else
+#ifndef xmlIsRef
+extern __typeof (xmlIsRef) xmlIsRef__internal_alias __attribute((visibility("hidden")));
+#define xmlIsRef xmlIsRef__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlsave
+#undef xmlIsXHTML
+extern __typeof (xmlIsXHTML) xmlIsXHTML __attribute((alias("xmlIsXHTML__internal_alias")));
+#else
+#ifndef xmlIsXHTML
+extern __typeof (xmlIsXHTML) xmlIsXHTML__internal_alias __attribute((visibility("hidden")));
+#define xmlIsXHTML xmlIsXHTML__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlKeepBlanksDefault
+extern __typeof (xmlKeepBlanksDefault) xmlKeepBlanksDefault __attribute((alias("xmlKeepBlanksDefault__internal_alias")));
+#else
+#ifndef xmlKeepBlanksDefault
+extern __typeof (xmlKeepBlanksDefault) xmlKeepBlanksDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlKeepBlanksDefault xmlKeepBlanksDefault__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlLastElementChild
+extern __typeof (xmlLastElementChild) xmlLastElementChild __attribute((alias("xmlLastElementChild__internal_alias")));
+#else
+#ifndef xmlLastElementChild
+extern __typeof (xmlLastElementChild) xmlLastElementChild__internal_alias __attribute((visibility("hidden")));
+#define xmlLastElementChild xmlLastElementChild__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlLineNumbersDefault
+extern __typeof (xmlLineNumbersDefault) xmlLineNumbersDefault __attribute((alias("xmlLineNumbersDefault__internal_alias")));
+#else
+#ifndef xmlLineNumbersDefault
+extern __typeof (xmlLineNumbersDefault) xmlLineNumbersDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlLineNumbersDefault xmlLineNumbersDefault__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlLinkGetData
+extern __typeof (xmlLinkGetData) xmlLinkGetData __attribute((alias("xmlLinkGetData__internal_alias")));
+#else
+#ifndef xmlLinkGetData
+extern __typeof (xmlLinkGetData) xmlLinkGetData__internal_alias __attribute((visibility("hidden")));
+#define xmlLinkGetData xmlLinkGetData__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListAppend
+extern __typeof (xmlListAppend) xmlListAppend __attribute((alias("xmlListAppend__internal_alias")));
+#else
+#ifndef xmlListAppend
+extern __typeof (xmlListAppend) xmlListAppend__internal_alias __attribute((visibility("hidden")));
+#define xmlListAppend xmlListAppend__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListClear
+extern __typeof (xmlListClear) xmlListClear __attribute((alias("xmlListClear__internal_alias")));
+#else
+#ifndef xmlListClear
+extern __typeof (xmlListClear) xmlListClear__internal_alias __attribute((visibility("hidden")));
+#define xmlListClear xmlListClear__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListCopy
+extern __typeof (xmlListCopy) xmlListCopy __attribute((alias("xmlListCopy__internal_alias")));
+#else
+#ifndef xmlListCopy
+extern __typeof (xmlListCopy) xmlListCopy__internal_alias __attribute((visibility("hidden")));
+#define xmlListCopy xmlListCopy__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListCreate
+extern __typeof (xmlListCreate) xmlListCreate __attribute((alias("xmlListCreate__internal_alias")));
+#else
+#ifndef xmlListCreate
+extern __typeof (xmlListCreate) xmlListCreate__internal_alias __attribute((visibility("hidden")));
+#define xmlListCreate xmlListCreate__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListDelete
+extern __typeof (xmlListDelete) xmlListDelete __attribute((alias("xmlListDelete__internal_alias")));
+#else
+#ifndef xmlListDelete
+extern __typeof (xmlListDelete) xmlListDelete__internal_alias __attribute((visibility("hidden")));
+#define xmlListDelete xmlListDelete__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListDup
+extern __typeof (xmlListDup) xmlListDup __attribute((alias("xmlListDup__internal_alias")));
+#else
+#ifndef xmlListDup
+extern __typeof (xmlListDup) xmlListDup__internal_alias __attribute((visibility("hidden")));
+#define xmlListDup xmlListDup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListEmpty
+extern __typeof (xmlListEmpty) xmlListEmpty __attribute((alias("xmlListEmpty__internal_alias")));
+#else
+#ifndef xmlListEmpty
+extern __typeof (xmlListEmpty) xmlListEmpty__internal_alias __attribute((visibility("hidden")));
+#define xmlListEmpty xmlListEmpty__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListEnd
+extern __typeof (xmlListEnd) xmlListEnd __attribute((alias("xmlListEnd__internal_alias")));
+#else
+#ifndef xmlListEnd
+extern __typeof (xmlListEnd) xmlListEnd__internal_alias __attribute((visibility("hidden")));
+#define xmlListEnd xmlListEnd__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListFront
+extern __typeof (xmlListFront) xmlListFront __attribute((alias("xmlListFront__internal_alias")));
+#else
+#ifndef xmlListFront
+extern __typeof (xmlListFront) xmlListFront__internal_alias __attribute((visibility("hidden")));
+#define xmlListFront xmlListFront__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListInsert
+extern __typeof (xmlListInsert) xmlListInsert __attribute((alias("xmlListInsert__internal_alias")));
+#else
+#ifndef xmlListInsert
+extern __typeof (xmlListInsert) xmlListInsert__internal_alias __attribute((visibility("hidden")));
+#define xmlListInsert xmlListInsert__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListMerge
+extern __typeof (xmlListMerge) xmlListMerge __attribute((alias("xmlListMerge__internal_alias")));
+#else
+#ifndef xmlListMerge
+extern __typeof (xmlListMerge) xmlListMerge__internal_alias __attribute((visibility("hidden")));
+#define xmlListMerge xmlListMerge__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListPopBack
+extern __typeof (xmlListPopBack) xmlListPopBack __attribute((alias("xmlListPopBack__internal_alias")));
+#else
+#ifndef xmlListPopBack
+extern __typeof (xmlListPopBack) xmlListPopBack__internal_alias __attribute((visibility("hidden")));
+#define xmlListPopBack xmlListPopBack__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListPopFront
+extern __typeof (xmlListPopFront) xmlListPopFront __attribute((alias("xmlListPopFront__internal_alias")));
+#else
+#ifndef xmlListPopFront
+extern __typeof (xmlListPopFront) xmlListPopFront__internal_alias __attribute((visibility("hidden")));
+#define xmlListPopFront xmlListPopFront__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListPushBack
+extern __typeof (xmlListPushBack) xmlListPushBack __attribute((alias("xmlListPushBack__internal_alias")));
+#else
+#ifndef xmlListPushBack
+extern __typeof (xmlListPushBack) xmlListPushBack__internal_alias __attribute((visibility("hidden")));
+#define xmlListPushBack xmlListPushBack__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListPushFront
+extern __typeof (xmlListPushFront) xmlListPushFront __attribute((alias("xmlListPushFront__internal_alias")));
+#else
+#ifndef xmlListPushFront
+extern __typeof (xmlListPushFront) xmlListPushFront__internal_alias __attribute((visibility("hidden")));
+#define xmlListPushFront xmlListPushFront__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListRemoveAll
+extern __typeof (xmlListRemoveAll) xmlListRemoveAll __attribute((alias("xmlListRemoveAll__internal_alias")));
+#else
+#ifndef xmlListRemoveAll
+extern __typeof (xmlListRemoveAll) xmlListRemoveAll__internal_alias __attribute((visibility("hidden")));
+#define xmlListRemoveAll xmlListRemoveAll__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListRemoveFirst
+extern __typeof (xmlListRemoveFirst) xmlListRemoveFirst __attribute((alias("xmlListRemoveFirst__internal_alias")));
+#else
+#ifndef xmlListRemoveFirst
+extern __typeof (xmlListRemoveFirst) xmlListRemoveFirst__internal_alias __attribute((visibility("hidden")));
+#define xmlListRemoveFirst xmlListRemoveFirst__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListRemoveLast
+extern __typeof (xmlListRemoveLast) xmlListRemoveLast __attribute((alias("xmlListRemoveLast__internal_alias")));
+#else
+#ifndef xmlListRemoveLast
+extern __typeof (xmlListRemoveLast) xmlListRemoveLast__internal_alias __attribute((visibility("hidden")));
+#define xmlListRemoveLast xmlListRemoveLast__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListReverse
+extern __typeof (xmlListReverse) xmlListReverse __attribute((alias("xmlListReverse__internal_alias")));
+#else
+#ifndef xmlListReverse
+extern __typeof (xmlListReverse) xmlListReverse__internal_alias __attribute((visibility("hidden")));
+#define xmlListReverse xmlListReverse__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListReverseSearch
+extern __typeof (xmlListReverseSearch) xmlListReverseSearch __attribute((alias("xmlListReverseSearch__internal_alias")));
+#else
+#ifndef xmlListReverseSearch
+extern __typeof (xmlListReverseSearch) xmlListReverseSearch__internal_alias __attribute((visibility("hidden")));
+#define xmlListReverseSearch xmlListReverseSearch__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListReverseWalk
+extern __typeof (xmlListReverseWalk) xmlListReverseWalk __attribute((alias("xmlListReverseWalk__internal_alias")));
+#else
+#ifndef xmlListReverseWalk
+extern __typeof (xmlListReverseWalk) xmlListReverseWalk__internal_alias __attribute((visibility("hidden")));
+#define xmlListReverseWalk xmlListReverseWalk__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListSearch
+extern __typeof (xmlListSearch) xmlListSearch __attribute((alias("xmlListSearch__internal_alias")));
+#else
+#ifndef xmlListSearch
+extern __typeof (xmlListSearch) xmlListSearch__internal_alias __attribute((visibility("hidden")));
+#define xmlListSearch xmlListSearch__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListSize
+extern __typeof (xmlListSize) xmlListSize __attribute((alias("xmlListSize__internal_alias")));
+#else
+#ifndef xmlListSize
+extern __typeof (xmlListSize) xmlListSize__internal_alias __attribute((visibility("hidden")));
+#define xmlListSize xmlListSize__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListSort
+extern __typeof (xmlListSort) xmlListSort __attribute((alias("xmlListSort__internal_alias")));
+#else
+#ifndef xmlListSort
+extern __typeof (xmlListSort) xmlListSort__internal_alias __attribute((visibility("hidden")));
+#define xmlListSort xmlListSort__internal_alias
+#endif
+#endif
+
+#ifdef bottom_list
+#undef xmlListWalk
+extern __typeof (xmlListWalk) xmlListWalk __attribute((alias("xmlListWalk__internal_alias")));
+#else
+#ifndef xmlListWalk
+extern __typeof (xmlListWalk) xmlListWalk__internal_alias __attribute((visibility("hidden")));
+#define xmlListWalk xmlListWalk__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlLoadACatalog
+extern __typeof (xmlLoadACatalog) xmlLoadACatalog __attribute((alias("xmlLoadACatalog__internal_alias")));
+#else
+#ifndef xmlLoadACatalog
+extern __typeof (xmlLoadACatalog) xmlLoadACatalog__internal_alias __attribute((visibility("hidden")));
+#define xmlLoadACatalog xmlLoadACatalog__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlLoadCatalog
+extern __typeof (xmlLoadCatalog) xmlLoadCatalog __attribute((alias("xmlLoadCatalog__internal_alias")));
+#else
+#ifndef xmlLoadCatalog
+extern __typeof (xmlLoadCatalog) xmlLoadCatalog__internal_alias __attribute((visibility("hidden")));
+#define xmlLoadCatalog xmlLoadCatalog__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlLoadCatalogs
+extern __typeof (xmlLoadCatalogs) xmlLoadCatalogs __attribute((alias("xmlLoadCatalogs__internal_alias")));
+#else
+#ifndef xmlLoadCatalogs
+extern __typeof (xmlLoadCatalogs) xmlLoadCatalogs__internal_alias __attribute((visibility("hidden")));
+#define xmlLoadCatalogs xmlLoadCatalogs__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlLoadExternalEntity
+extern __typeof (xmlLoadExternalEntity) xmlLoadExternalEntity __attribute((alias("xmlLoadExternalEntity__internal_alias")));
+#else
+#ifndef xmlLoadExternalEntity
+extern __typeof (xmlLoadExternalEntity) xmlLoadExternalEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlLoadExternalEntity xmlLoadExternalEntity__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlLoadSGMLSuperCatalog
+extern __typeof (xmlLoadSGMLSuperCatalog) xmlLoadSGMLSuperCatalog __attribute((alias("xmlLoadSGMLSuperCatalog__internal_alias")));
+#else
+#ifndef xmlLoadSGMLSuperCatalog
+extern __typeof (xmlLoadSGMLSuperCatalog) xmlLoadSGMLSuperCatalog__internal_alias __attribute((visibility("hidden")));
+#define xmlLoadSGMLSuperCatalog xmlLoadSGMLSuperCatalog__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlLockLibrary
+extern __typeof (xmlLockLibrary) xmlLockLibrary __attribute((alias("xmlLockLibrary__internal_alias")));
+#else
+#ifndef xmlLockLibrary
+extern __typeof (xmlLockLibrary) xmlLockLibrary__internal_alias __attribute((visibility("hidden")));
+#define xmlLockLibrary xmlLockLibrary__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlLsCountNode
+extern __typeof (xmlLsCountNode) xmlLsCountNode __attribute((alias("xmlLsCountNode__internal_alias")));
+#else
+#ifndef xmlLsCountNode
+extern __typeof (xmlLsCountNode) xmlLsCountNode__internal_alias __attribute((visibility("hidden")));
+#define xmlLsCountNode xmlLsCountNode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlLsOneNode
+extern __typeof (xmlLsOneNode) xmlLsOneNode __attribute((alias("xmlLsOneNode__internal_alias")));
+#else
+#ifndef xmlLsOneNode
+extern __typeof (xmlLsOneNode) xmlLsOneNode__internal_alias __attribute((visibility("hidden")));
+#define xmlLsOneNode xmlLsOneNode__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMallocAtomicLoc
+extern __typeof (xmlMallocAtomicLoc) xmlMallocAtomicLoc __attribute((alias("xmlMallocAtomicLoc__internal_alias")));
+#else
+#ifndef xmlMallocAtomicLoc
+extern __typeof (xmlMallocAtomicLoc) xmlMallocAtomicLoc__internal_alias __attribute((visibility("hidden")));
+#define xmlMallocAtomicLoc xmlMallocAtomicLoc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMallocLoc
+extern __typeof (xmlMallocLoc) xmlMallocLoc __attribute((alias("xmlMallocLoc__internal_alias")));
+#else
+#ifndef xmlMallocLoc
+extern __typeof (xmlMallocLoc) xmlMallocLoc__internal_alias __attribute((visibility("hidden")));
+#define xmlMallocLoc xmlMallocLoc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemBlocks
+extern __typeof (xmlMemBlocks) xmlMemBlocks __attribute((alias("xmlMemBlocks__internal_alias")));
+#else
+#ifndef xmlMemBlocks
+extern __typeof (xmlMemBlocks) xmlMemBlocks__internal_alias __attribute((visibility("hidden")));
+#define xmlMemBlocks xmlMemBlocks__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemDisplay
+extern __typeof (xmlMemDisplay) xmlMemDisplay __attribute((alias("xmlMemDisplay__internal_alias")));
+#else
+#ifndef xmlMemDisplay
+extern __typeof (xmlMemDisplay) xmlMemDisplay__internal_alias __attribute((visibility("hidden")));
+#define xmlMemDisplay xmlMemDisplay__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemDisplayLast
+extern __typeof (xmlMemDisplayLast) xmlMemDisplayLast __attribute((alias("xmlMemDisplayLast__internal_alias")));
+#else
+#ifndef xmlMemDisplayLast
+extern __typeof (xmlMemDisplayLast) xmlMemDisplayLast__internal_alias __attribute((visibility("hidden")));
+#define xmlMemDisplayLast xmlMemDisplayLast__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemFree
+extern __typeof (xmlMemFree) xmlMemFree __attribute((alias("xmlMemFree__internal_alias")));
+#else
+#ifndef xmlMemFree
+extern __typeof (xmlMemFree) xmlMemFree__internal_alias __attribute((visibility("hidden")));
+#define xmlMemFree xmlMemFree__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemGet
+extern __typeof (xmlMemGet) xmlMemGet __attribute((alias("xmlMemGet__internal_alias")));
+#else
+#ifndef xmlMemGet
+extern __typeof (xmlMemGet) xmlMemGet__internal_alias __attribute((visibility("hidden")));
+#define xmlMemGet xmlMemGet__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemMalloc
+extern __typeof (xmlMemMalloc) xmlMemMalloc __attribute((alias("xmlMemMalloc__internal_alias")));
+#else
+#ifndef xmlMemMalloc
+extern __typeof (xmlMemMalloc) xmlMemMalloc__internal_alias __attribute((visibility("hidden")));
+#define xmlMemMalloc xmlMemMalloc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemRealloc
+extern __typeof (xmlMemRealloc) xmlMemRealloc __attribute((alias("xmlMemRealloc__internal_alias")));
+#else
+#ifndef xmlMemRealloc
+extern __typeof (xmlMemRealloc) xmlMemRealloc__internal_alias __attribute((visibility("hidden")));
+#define xmlMemRealloc xmlMemRealloc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemSetup
+extern __typeof (xmlMemSetup) xmlMemSetup __attribute((alias("xmlMemSetup__internal_alias")));
+#else
+#ifndef xmlMemSetup
+extern __typeof (xmlMemSetup) xmlMemSetup__internal_alias __attribute((visibility("hidden")));
+#define xmlMemSetup xmlMemSetup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemShow
+extern __typeof (xmlMemShow) xmlMemShow __attribute((alias("xmlMemShow__internal_alias")));
+#else
+#ifndef xmlMemShow
+extern __typeof (xmlMemShow) xmlMemShow__internal_alias __attribute((visibility("hidden")));
+#define xmlMemShow xmlMemShow__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemStrdupLoc
+extern __typeof (xmlMemStrdupLoc) xmlMemStrdupLoc __attribute((alias("xmlMemStrdupLoc__internal_alias")));
+#else
+#ifndef xmlMemStrdupLoc
+extern __typeof (xmlMemStrdupLoc) xmlMemStrdupLoc__internal_alias __attribute((visibility("hidden")));
+#define xmlMemStrdupLoc xmlMemStrdupLoc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemUsed
+extern __typeof (xmlMemUsed) xmlMemUsed __attribute((alias("xmlMemUsed__internal_alias")));
+#else
+#ifndef xmlMemUsed
+extern __typeof (xmlMemUsed) xmlMemUsed__internal_alias __attribute((visibility("hidden")));
+#define xmlMemUsed xmlMemUsed__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemoryDump
+extern __typeof (xmlMemoryDump) xmlMemoryDump __attribute((alias("xmlMemoryDump__internal_alias")));
+#else
+#ifndef xmlMemoryDump
+extern __typeof (xmlMemoryDump) xmlMemoryDump__internal_alias __attribute((visibility("hidden")));
+#define xmlMemoryDump xmlMemoryDump__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlMemoryStrdup
+extern __typeof (xmlMemoryStrdup) xmlMemoryStrdup __attribute((alias("xmlMemoryStrdup__internal_alias")));
+#else
+#ifndef xmlMemoryStrdup
+extern __typeof (xmlMemoryStrdup) xmlMemoryStrdup__internal_alias __attribute((visibility("hidden")));
+#define xmlMemoryStrdup xmlMemoryStrdup__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_MODULES_ENABLED)
+#ifdef bottom_xmlmodule
+#undef xmlModuleClose
+extern __typeof (xmlModuleClose) xmlModuleClose __attribute((alias("xmlModuleClose__internal_alias")));
+#else
+#ifndef xmlModuleClose
+extern __typeof (xmlModuleClose) xmlModuleClose__internal_alias __attribute((visibility("hidden")));
+#define xmlModuleClose xmlModuleClose__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_MODULES_ENABLED)
+#ifdef bottom_xmlmodule
+#undef xmlModuleFree
+extern __typeof (xmlModuleFree) xmlModuleFree __attribute((alias("xmlModuleFree__internal_alias")));
+#else
+#ifndef xmlModuleFree
+extern __typeof (xmlModuleFree) xmlModuleFree__internal_alias __attribute((visibility("hidden")));
+#define xmlModuleFree xmlModuleFree__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_MODULES_ENABLED)
+#ifdef bottom_xmlmodule
+#undef xmlModuleOpen
+extern __typeof (xmlModuleOpen) xmlModuleOpen __attribute((alias("xmlModuleOpen__internal_alias")));
+#else
+#ifndef xmlModuleOpen
+extern __typeof (xmlModuleOpen) xmlModuleOpen__internal_alias __attribute((visibility("hidden")));
+#define xmlModuleOpen xmlModuleOpen__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_MODULES_ENABLED)
+#ifdef bottom_xmlmodule
+#undef xmlModuleSymbol
+extern __typeof (xmlModuleSymbol) xmlModuleSymbol __attribute((alias("xmlModuleSymbol__internal_alias")));
+#else
+#ifndef xmlModuleSymbol
+extern __typeof (xmlModuleSymbol) xmlModuleSymbol__internal_alias __attribute((visibility("hidden")));
+#define xmlModuleSymbol xmlModuleSymbol__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlMutexLock
+extern __typeof (xmlMutexLock) xmlMutexLock __attribute((alias("xmlMutexLock__internal_alias")));
+#else
+#ifndef xmlMutexLock
+extern __typeof (xmlMutexLock) xmlMutexLock__internal_alias __attribute((visibility("hidden")));
+#define xmlMutexLock xmlMutexLock__internal_alias
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlMutexUnlock
+extern __typeof (xmlMutexUnlock) xmlMutexUnlock __attribute((alias("xmlMutexUnlock__internal_alias")));
+#else
+#ifndef xmlMutexUnlock
+extern __typeof (xmlMutexUnlock) xmlMutexUnlock__internal_alias __attribute((visibility("hidden")));
+#define xmlMutexUnlock xmlMutexUnlock__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlNamespaceParseNCName
+extern __typeof (xmlNamespaceParseNCName) xmlNamespaceParseNCName __attribute((alias("xmlNamespaceParseNCName__internal_alias")));
+#else
+#ifndef xmlNamespaceParseNCName
+extern __typeof (xmlNamespaceParseNCName) xmlNamespaceParseNCName__internal_alias __attribute((visibility("hidden")));
+#define xmlNamespaceParseNCName xmlNamespaceParseNCName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlNamespaceParseNSDef
+extern __typeof (xmlNamespaceParseNSDef) xmlNamespaceParseNSDef __attribute((alias("xmlNamespaceParseNSDef__internal_alias")));
+#else
+#ifndef xmlNamespaceParseNSDef
+extern __typeof (xmlNamespaceParseNSDef) xmlNamespaceParseNSDef__internal_alias __attribute((visibility("hidden")));
+#define xmlNamespaceParseNSDef xmlNamespaceParseNSDef__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlNamespaceParseQName
+extern __typeof (xmlNamespaceParseQName) xmlNamespaceParseQName __attribute((alias("xmlNamespaceParseQName__internal_alias")));
+#else
+#ifndef xmlNamespaceParseQName
+extern __typeof (xmlNamespaceParseQName) xmlNamespaceParseQName__internal_alias __attribute((visibility("hidden")));
+#define xmlNamespaceParseQName xmlNamespaceParseQName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPCheckResponse
+extern __typeof (xmlNanoFTPCheckResponse) xmlNanoFTPCheckResponse __attribute((alias("xmlNanoFTPCheckResponse__internal_alias")));
+#else
+#ifndef xmlNanoFTPCheckResponse
+extern __typeof (xmlNanoFTPCheckResponse) xmlNanoFTPCheckResponse__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPCheckResponse xmlNanoFTPCheckResponse__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPCleanup
+extern __typeof (xmlNanoFTPCleanup) xmlNanoFTPCleanup __attribute((alias("xmlNanoFTPCleanup__internal_alias")));
+#else
+#ifndef xmlNanoFTPCleanup
+extern __typeof (xmlNanoFTPCleanup) xmlNanoFTPCleanup__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPCleanup xmlNanoFTPCleanup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPClose
+extern __typeof (xmlNanoFTPClose) xmlNanoFTPClose __attribute((alias("xmlNanoFTPClose__internal_alias")));
+#else
+#ifndef xmlNanoFTPClose
+extern __typeof (xmlNanoFTPClose) xmlNanoFTPClose__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPClose xmlNanoFTPClose__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPCloseConnection
+extern __typeof (xmlNanoFTPCloseConnection) xmlNanoFTPCloseConnection __attribute((alias("xmlNanoFTPCloseConnection__internal_alias")));
+#else
+#ifndef xmlNanoFTPCloseConnection
+extern __typeof (xmlNanoFTPCloseConnection) xmlNanoFTPCloseConnection__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPCloseConnection xmlNanoFTPCloseConnection__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPConnect
+extern __typeof (xmlNanoFTPConnect) xmlNanoFTPConnect __attribute((alias("xmlNanoFTPConnect__internal_alias")));
+#else
+#ifndef xmlNanoFTPConnect
+extern __typeof (xmlNanoFTPConnect) xmlNanoFTPConnect__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPConnect xmlNanoFTPConnect__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPConnectTo
+extern __typeof (xmlNanoFTPConnectTo) xmlNanoFTPConnectTo __attribute((alias("xmlNanoFTPConnectTo__internal_alias")));
+#else
+#ifndef xmlNanoFTPConnectTo
+extern __typeof (xmlNanoFTPConnectTo) xmlNanoFTPConnectTo__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPConnectTo xmlNanoFTPConnectTo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPCwd
+extern __typeof (xmlNanoFTPCwd) xmlNanoFTPCwd __attribute((alias("xmlNanoFTPCwd__internal_alias")));
+#else
+#ifndef xmlNanoFTPCwd
+extern __typeof (xmlNanoFTPCwd) xmlNanoFTPCwd__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPCwd xmlNanoFTPCwd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPDele
+extern __typeof (xmlNanoFTPDele) xmlNanoFTPDele __attribute((alias("xmlNanoFTPDele__internal_alias")));
+#else
+#ifndef xmlNanoFTPDele
+extern __typeof (xmlNanoFTPDele) xmlNanoFTPDele__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPDele xmlNanoFTPDele__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPFreeCtxt
+extern __typeof (xmlNanoFTPFreeCtxt) xmlNanoFTPFreeCtxt __attribute((alias("xmlNanoFTPFreeCtxt__internal_alias")));
+#else
+#ifndef xmlNanoFTPFreeCtxt
+extern __typeof (xmlNanoFTPFreeCtxt) xmlNanoFTPFreeCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPFreeCtxt xmlNanoFTPFreeCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPGet
+extern __typeof (xmlNanoFTPGet) xmlNanoFTPGet __attribute((alias("xmlNanoFTPGet__internal_alias")));
+#else
+#ifndef xmlNanoFTPGet
+extern __typeof (xmlNanoFTPGet) xmlNanoFTPGet__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPGet xmlNanoFTPGet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPGetConnection
+extern __typeof (xmlNanoFTPGetConnection) xmlNanoFTPGetConnection __attribute((alias("xmlNanoFTPGetConnection__internal_alias")));
+#else
+#ifndef xmlNanoFTPGetConnection
+extern __typeof (xmlNanoFTPGetConnection) xmlNanoFTPGetConnection__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPGetConnection xmlNanoFTPGetConnection__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPGetResponse
+extern __typeof (xmlNanoFTPGetResponse) xmlNanoFTPGetResponse __attribute((alias("xmlNanoFTPGetResponse__internal_alias")));
+#else
+#ifndef xmlNanoFTPGetResponse
+extern __typeof (xmlNanoFTPGetResponse) xmlNanoFTPGetResponse__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPGetResponse xmlNanoFTPGetResponse__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPGetSocket
+extern __typeof (xmlNanoFTPGetSocket) xmlNanoFTPGetSocket __attribute((alias("xmlNanoFTPGetSocket__internal_alias")));
+#else
+#ifndef xmlNanoFTPGetSocket
+extern __typeof (xmlNanoFTPGetSocket) xmlNanoFTPGetSocket__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPGetSocket xmlNanoFTPGetSocket__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPInit
+extern __typeof (xmlNanoFTPInit) xmlNanoFTPInit __attribute((alias("xmlNanoFTPInit__internal_alias")));
+#else
+#ifndef xmlNanoFTPInit
+extern __typeof (xmlNanoFTPInit) xmlNanoFTPInit__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPInit xmlNanoFTPInit__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPList
+extern __typeof (xmlNanoFTPList) xmlNanoFTPList __attribute((alias("xmlNanoFTPList__internal_alias")));
+#else
+#ifndef xmlNanoFTPList
+extern __typeof (xmlNanoFTPList) xmlNanoFTPList__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPList xmlNanoFTPList__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPNewCtxt
+extern __typeof (xmlNanoFTPNewCtxt) xmlNanoFTPNewCtxt __attribute((alias("xmlNanoFTPNewCtxt__internal_alias")));
+#else
+#ifndef xmlNanoFTPNewCtxt
+extern __typeof (xmlNanoFTPNewCtxt) xmlNanoFTPNewCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPNewCtxt xmlNanoFTPNewCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPOpen
+extern __typeof (xmlNanoFTPOpen) xmlNanoFTPOpen __attribute((alias("xmlNanoFTPOpen__internal_alias")));
+#else
+#ifndef xmlNanoFTPOpen
+extern __typeof (xmlNanoFTPOpen) xmlNanoFTPOpen__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPOpen xmlNanoFTPOpen__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPProxy
+extern __typeof (xmlNanoFTPProxy) xmlNanoFTPProxy __attribute((alias("xmlNanoFTPProxy__internal_alias")));
+#else
+#ifndef xmlNanoFTPProxy
+extern __typeof (xmlNanoFTPProxy) xmlNanoFTPProxy__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPProxy xmlNanoFTPProxy__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPQuit
+extern __typeof (xmlNanoFTPQuit) xmlNanoFTPQuit __attribute((alias("xmlNanoFTPQuit__internal_alias")));
+#else
+#ifndef xmlNanoFTPQuit
+extern __typeof (xmlNanoFTPQuit) xmlNanoFTPQuit__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPQuit xmlNanoFTPQuit__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPRead
+extern __typeof (xmlNanoFTPRead) xmlNanoFTPRead __attribute((alias("xmlNanoFTPRead__internal_alias")));
+#else
+#ifndef xmlNanoFTPRead
+extern __typeof (xmlNanoFTPRead) xmlNanoFTPRead__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPRead xmlNanoFTPRead__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPScanProxy
+extern __typeof (xmlNanoFTPScanProxy) xmlNanoFTPScanProxy __attribute((alias("xmlNanoFTPScanProxy__internal_alias")));
+#else
+#ifndef xmlNanoFTPScanProxy
+extern __typeof (xmlNanoFTPScanProxy) xmlNanoFTPScanProxy__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPScanProxy xmlNanoFTPScanProxy__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_FTP_ENABLED)
+#ifdef bottom_nanoftp
+#undef xmlNanoFTPUpdateURL
+extern __typeof (xmlNanoFTPUpdateURL) xmlNanoFTPUpdateURL __attribute((alias("xmlNanoFTPUpdateURL__internal_alias")));
+#else
+#ifndef xmlNanoFTPUpdateURL
+extern __typeof (xmlNanoFTPUpdateURL) xmlNanoFTPUpdateURL__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoFTPUpdateURL xmlNanoFTPUpdateURL__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPAuthHeader
+extern __typeof (xmlNanoHTTPAuthHeader) xmlNanoHTTPAuthHeader __attribute((alias("xmlNanoHTTPAuthHeader__internal_alias")));
+#else
+#ifndef xmlNanoHTTPAuthHeader
+extern __typeof (xmlNanoHTTPAuthHeader) xmlNanoHTTPAuthHeader__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPAuthHeader xmlNanoHTTPAuthHeader__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPCleanup
+extern __typeof (xmlNanoHTTPCleanup) xmlNanoHTTPCleanup __attribute((alias("xmlNanoHTTPCleanup__internal_alias")));
+#else
+#ifndef xmlNanoHTTPCleanup
+extern __typeof (xmlNanoHTTPCleanup) xmlNanoHTTPCleanup__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPCleanup xmlNanoHTTPCleanup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPClose
+extern __typeof (xmlNanoHTTPClose) xmlNanoHTTPClose __attribute((alias("xmlNanoHTTPClose__internal_alias")));
+#else
+#ifndef xmlNanoHTTPClose
+extern __typeof (xmlNanoHTTPClose) xmlNanoHTTPClose__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPClose xmlNanoHTTPClose__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPContentLength
+extern __typeof (xmlNanoHTTPContentLength) xmlNanoHTTPContentLength __attribute((alias("xmlNanoHTTPContentLength__internal_alias")));
+#else
+#ifndef xmlNanoHTTPContentLength
+extern __typeof (xmlNanoHTTPContentLength) xmlNanoHTTPContentLength__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPContentLength xmlNanoHTTPContentLength__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPEncoding
+extern __typeof (xmlNanoHTTPEncoding) xmlNanoHTTPEncoding __attribute((alias("xmlNanoHTTPEncoding__internal_alias")));
+#else
+#ifndef xmlNanoHTTPEncoding
+extern __typeof (xmlNanoHTTPEncoding) xmlNanoHTTPEncoding__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPEncoding xmlNanoHTTPEncoding__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPFetch
+extern __typeof (xmlNanoHTTPFetch) xmlNanoHTTPFetch __attribute((alias("xmlNanoHTTPFetch__internal_alias")));
+#else
+#ifndef xmlNanoHTTPFetch
+extern __typeof (xmlNanoHTTPFetch) xmlNanoHTTPFetch__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPFetch xmlNanoHTTPFetch__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPInit
+extern __typeof (xmlNanoHTTPInit) xmlNanoHTTPInit __attribute((alias("xmlNanoHTTPInit__internal_alias")));
+#else
+#ifndef xmlNanoHTTPInit
+extern __typeof (xmlNanoHTTPInit) xmlNanoHTTPInit__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPInit xmlNanoHTTPInit__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPMethod
+extern __typeof (xmlNanoHTTPMethod) xmlNanoHTTPMethod __attribute((alias("xmlNanoHTTPMethod__internal_alias")));
+#else
+#ifndef xmlNanoHTTPMethod
+extern __typeof (xmlNanoHTTPMethod) xmlNanoHTTPMethod__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPMethod xmlNanoHTTPMethod__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPMethodRedir
+extern __typeof (xmlNanoHTTPMethodRedir) xmlNanoHTTPMethodRedir __attribute((alias("xmlNanoHTTPMethodRedir__internal_alias")));
+#else
+#ifndef xmlNanoHTTPMethodRedir
+extern __typeof (xmlNanoHTTPMethodRedir) xmlNanoHTTPMethodRedir__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPMethodRedir xmlNanoHTTPMethodRedir__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPMimeType
+extern __typeof (xmlNanoHTTPMimeType) xmlNanoHTTPMimeType __attribute((alias("xmlNanoHTTPMimeType__internal_alias")));
+#else
+#ifndef xmlNanoHTTPMimeType
+extern __typeof (xmlNanoHTTPMimeType) xmlNanoHTTPMimeType__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPMimeType xmlNanoHTTPMimeType__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPOpen
+extern __typeof (xmlNanoHTTPOpen) xmlNanoHTTPOpen __attribute((alias("xmlNanoHTTPOpen__internal_alias")));
+#else
+#ifndef xmlNanoHTTPOpen
+extern __typeof (xmlNanoHTTPOpen) xmlNanoHTTPOpen__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPOpen xmlNanoHTTPOpen__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPOpenRedir
+extern __typeof (xmlNanoHTTPOpenRedir) xmlNanoHTTPOpenRedir __attribute((alias("xmlNanoHTTPOpenRedir__internal_alias")));
+#else
+#ifndef xmlNanoHTTPOpenRedir
+extern __typeof (xmlNanoHTTPOpenRedir) xmlNanoHTTPOpenRedir__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPOpenRedir xmlNanoHTTPOpenRedir__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPRead
+extern __typeof (xmlNanoHTTPRead) xmlNanoHTTPRead __attribute((alias("xmlNanoHTTPRead__internal_alias")));
+#else
+#ifndef xmlNanoHTTPRead
+extern __typeof (xmlNanoHTTPRead) xmlNanoHTTPRead__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPRead xmlNanoHTTPRead__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPRedir
+extern __typeof (xmlNanoHTTPRedir) xmlNanoHTTPRedir __attribute((alias("xmlNanoHTTPRedir__internal_alias")));
+#else
+#ifndef xmlNanoHTTPRedir
+extern __typeof (xmlNanoHTTPRedir) xmlNanoHTTPRedir__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPRedir xmlNanoHTTPRedir__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPReturnCode
+extern __typeof (xmlNanoHTTPReturnCode) xmlNanoHTTPReturnCode __attribute((alias("xmlNanoHTTPReturnCode__internal_alias")));
+#else
+#ifndef xmlNanoHTTPReturnCode
+extern __typeof (xmlNanoHTTPReturnCode) xmlNanoHTTPReturnCode__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPReturnCode xmlNanoHTTPReturnCode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPSave
+extern __typeof (xmlNanoHTTPSave) xmlNanoHTTPSave __attribute((alias("xmlNanoHTTPSave__internal_alias")));
+#else
+#ifndef xmlNanoHTTPSave
+extern __typeof (xmlNanoHTTPSave) xmlNanoHTTPSave__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPSave xmlNanoHTTPSave__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_nanohttp
+#undef xmlNanoHTTPScanProxy
+extern __typeof (xmlNanoHTTPScanProxy) xmlNanoHTTPScanProxy __attribute((alias("xmlNanoHTTPScanProxy__internal_alias")));
+#else
+#ifndef xmlNanoHTTPScanProxy
+extern __typeof (xmlNanoHTTPScanProxy) xmlNanoHTTPScanProxy__internal_alias __attribute((visibility("hidden")));
+#define xmlNanoHTTPScanProxy xmlNanoHTTPScanProxy__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED) && defined(LIBXML_AUTOMATA_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlNewAutomata
+extern __typeof (xmlNewAutomata) xmlNewAutomata __attribute((alias("xmlNewAutomata__internal_alias")));
+#else
+#ifndef xmlNewAutomata
+extern __typeof (xmlNewAutomata) xmlNewAutomata__internal_alias __attribute((visibility("hidden")));
+#define xmlNewAutomata xmlNewAutomata__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewCDataBlock
+extern __typeof (xmlNewCDataBlock) xmlNewCDataBlock __attribute((alias("xmlNewCDataBlock__internal_alias")));
+#else
+#ifndef xmlNewCDataBlock
+extern __typeof (xmlNewCDataBlock) xmlNewCDataBlock__internal_alias __attribute((visibility("hidden")));
+#define xmlNewCDataBlock xmlNewCDataBlock__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlNewCatalog
+extern __typeof (xmlNewCatalog) xmlNewCatalog __attribute((alias("xmlNewCatalog__internal_alias")));
+#else
+#ifndef xmlNewCatalog
+extern __typeof (xmlNewCatalog) xmlNewCatalog__internal_alias __attribute((visibility("hidden")));
+#define xmlNewCatalog xmlNewCatalog__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlNewCharEncodingHandler
+extern __typeof (xmlNewCharEncodingHandler) xmlNewCharEncodingHandler __attribute((alias("xmlNewCharEncodingHandler__internal_alias")));
+#else
+#ifndef xmlNewCharEncodingHandler
+extern __typeof (xmlNewCharEncodingHandler) xmlNewCharEncodingHandler__internal_alias __attribute((visibility("hidden")));
+#define xmlNewCharEncodingHandler xmlNewCharEncodingHandler__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewCharRef
+extern __typeof (xmlNewCharRef) xmlNewCharRef __attribute((alias("xmlNewCharRef__internal_alias")));
+#else
+#ifndef xmlNewCharRef
+extern __typeof (xmlNewCharRef) xmlNewCharRef__internal_alias __attribute((visibility("hidden")));
+#define xmlNewCharRef xmlNewCharRef__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_tree
+#undef xmlNewChild
+extern __typeof (xmlNewChild) xmlNewChild __attribute((alias("xmlNewChild__internal_alias")));
+#else
+#ifndef xmlNewChild
+extern __typeof (xmlNewChild) xmlNewChild__internal_alias __attribute((visibility("hidden")));
+#define xmlNewChild xmlNewChild__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewComment
+extern __typeof (xmlNewComment) xmlNewComment __attribute((alias("xmlNewComment__internal_alias")));
+#else
+#ifndef xmlNewComment
+extern __typeof (xmlNewComment) xmlNewComment__internal_alias __attribute((visibility("hidden")));
+#define xmlNewComment xmlNewComment__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewDoc
+extern __typeof (xmlNewDoc) xmlNewDoc __attribute((alias("xmlNewDoc__internal_alias")));
+#else
+#ifndef xmlNewDoc
+extern __typeof (xmlNewDoc) xmlNewDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDoc xmlNewDoc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewDocComment
+extern __typeof (xmlNewDocComment) xmlNewDocComment __attribute((alias("xmlNewDocComment__internal_alias")));
+#else
+#ifndef xmlNewDocComment
+extern __typeof (xmlNewDocComment) xmlNewDocComment__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDocComment xmlNewDocComment__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlNewDocElementContent
+extern __typeof (xmlNewDocElementContent) xmlNewDocElementContent __attribute((alias("xmlNewDocElementContent__internal_alias")));
+#else
+#ifndef xmlNewDocElementContent
+extern __typeof (xmlNewDocElementContent) xmlNewDocElementContent__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDocElementContent xmlNewDocElementContent__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNewDocFragment
+extern __typeof (xmlNewDocFragment) xmlNewDocFragment __attribute((alias("xmlNewDocFragment__internal_alias")));
+#else
+#ifndef xmlNewDocFragment
+extern __typeof (xmlNewDocFragment) xmlNewDocFragment__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDocFragment xmlNewDocFragment__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewDocNode
+extern __typeof (xmlNewDocNode) xmlNewDocNode __attribute((alias("xmlNewDocNode__internal_alias")));
+#else
+#ifndef xmlNewDocNode
+extern __typeof (xmlNewDocNode) xmlNewDocNode__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDocNode xmlNewDocNode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewDocNodeEatName
+extern __typeof (xmlNewDocNodeEatName) xmlNewDocNodeEatName __attribute((alias("xmlNewDocNodeEatName__internal_alias")));
+#else
+#ifndef xmlNewDocNodeEatName
+extern __typeof (xmlNewDocNodeEatName) xmlNewDocNodeEatName__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDocNodeEatName xmlNewDocNodeEatName__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewDocPI
+extern __typeof (xmlNewDocPI) xmlNewDocPI __attribute((alias("xmlNewDocPI__internal_alias")));
+#else
+#ifndef xmlNewDocPI
+extern __typeof (xmlNewDocPI) xmlNewDocPI__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDocPI xmlNewDocPI__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewDocProp
+extern __typeof (xmlNewDocProp) xmlNewDocProp __attribute((alias("xmlNewDocProp__internal_alias")));
+#else
+#ifndef xmlNewDocProp
+extern __typeof (xmlNewDocProp) xmlNewDocProp__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDocProp xmlNewDocProp__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNewDocRawNode
+extern __typeof (xmlNewDocRawNode) xmlNewDocRawNode __attribute((alias("xmlNewDocRawNode__internal_alias")));
+#else
+#ifndef xmlNewDocRawNode
+extern __typeof (xmlNewDocRawNode) xmlNewDocRawNode__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDocRawNode xmlNewDocRawNode__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewDocText
+extern __typeof (xmlNewDocText) xmlNewDocText __attribute((alias("xmlNewDocText__internal_alias")));
+#else
+#ifndef xmlNewDocText
+extern __typeof (xmlNewDocText) xmlNewDocText__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDocText xmlNewDocText__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewDocTextLen
+extern __typeof (xmlNewDocTextLen) xmlNewDocTextLen __attribute((alias("xmlNewDocTextLen__internal_alias")));
+#else
+#ifndef xmlNewDocTextLen
+extern __typeof (xmlNewDocTextLen) xmlNewDocTextLen__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDocTextLen xmlNewDocTextLen__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewDtd
+extern __typeof (xmlNewDtd) xmlNewDtd __attribute((alias("xmlNewDtd__internal_alias")));
+#else
+#ifndef xmlNewDtd
+extern __typeof (xmlNewDtd) xmlNewDtd__internal_alias __attribute((visibility("hidden")));
+#define xmlNewDtd xmlNewDtd__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlNewElementContent
+extern __typeof (xmlNewElementContent) xmlNewElementContent __attribute((alias("xmlNewElementContent__internal_alias")));
+#else
+#ifndef xmlNewElementContent
+extern __typeof (xmlNewElementContent) xmlNewElementContent__internal_alias __attribute((visibility("hidden")));
+#define xmlNewElementContent xmlNewElementContent__internal_alias
+#endif
+#endif
+
+#ifdef bottom_entities
+#undef xmlNewEntity
+extern __typeof (xmlNewEntity) xmlNewEntity __attribute((alias("xmlNewEntity__internal_alias")));
+#else
+#ifndef xmlNewEntity
+extern __typeof (xmlNewEntity) xmlNewEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlNewEntity xmlNewEntity__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlNewEntityInputStream
+extern __typeof (xmlNewEntityInputStream) xmlNewEntityInputStream __attribute((alias("xmlNewEntityInputStream__internal_alias")));
+#else
+#ifndef xmlNewEntityInputStream
+extern __typeof (xmlNewEntityInputStream) xmlNewEntityInputStream__internal_alias __attribute((visibility("hidden")));
+#define xmlNewEntityInputStream xmlNewEntityInputStream__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlNewGlobalNs
+extern __typeof (xmlNewGlobalNs) xmlNewGlobalNs __attribute((alias("xmlNewGlobalNs__internal_alias")));
+#else
+#ifndef xmlNewGlobalNs
+extern __typeof (xmlNewGlobalNs) xmlNewGlobalNs__internal_alias __attribute((visibility("hidden")));
+#define xmlNewGlobalNs xmlNewGlobalNs__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlNewIOInputStream
+extern __typeof (xmlNewIOInputStream) xmlNewIOInputStream __attribute((alias("xmlNewIOInputStream__internal_alias")));
+#else
+#ifndef xmlNewIOInputStream
+extern __typeof (xmlNewIOInputStream) xmlNewIOInputStream__internal_alias __attribute((visibility("hidden")));
+#define xmlNewIOInputStream xmlNewIOInputStream__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlNewInputFromFile
+extern __typeof (xmlNewInputFromFile) xmlNewInputFromFile __attribute((alias("xmlNewInputFromFile__internal_alias")));
+#else
+#ifndef xmlNewInputFromFile
+extern __typeof (xmlNewInputFromFile) xmlNewInputFromFile__internal_alias __attribute((visibility("hidden")));
+#define xmlNewInputFromFile xmlNewInputFromFile__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlNewInputStream
+extern __typeof (xmlNewInputStream) xmlNewInputStream __attribute((alias("xmlNewInputStream__internal_alias")));
+#else
+#ifndef xmlNewInputStream
+extern __typeof (xmlNewInputStream) xmlNewInputStream__internal_alias __attribute((visibility("hidden")));
+#define xmlNewInputStream xmlNewInputStream__internal_alias
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlNewMutex
+extern __typeof (xmlNewMutex) xmlNewMutex __attribute((alias("xmlNewMutex__internal_alias")));
+#else
+#ifndef xmlNewMutex
+extern __typeof (xmlNewMutex) xmlNewMutex__internal_alias __attribute((visibility("hidden")));
+#define xmlNewMutex xmlNewMutex__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewNode
+extern __typeof (xmlNewNode) xmlNewNode __attribute((alias("xmlNewNode__internal_alias")));
+#else
+#ifndef xmlNewNode
+extern __typeof (xmlNewNode) xmlNewNode__internal_alias __attribute((visibility("hidden")));
+#define xmlNewNode xmlNewNode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewNodeEatName
+extern __typeof (xmlNewNodeEatName) xmlNewNodeEatName __attribute((alias("xmlNewNodeEatName__internal_alias")));
+#else
+#ifndef xmlNewNodeEatName
+extern __typeof (xmlNewNodeEatName) xmlNewNodeEatName__internal_alias __attribute((visibility("hidden")));
+#define xmlNewNodeEatName xmlNewNodeEatName__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewNs
+extern __typeof (xmlNewNs) xmlNewNs __attribute((alias("xmlNewNs__internal_alias")));
+#else
+#ifndef xmlNewNs
+extern __typeof (xmlNewNs) xmlNewNs__internal_alias __attribute((visibility("hidden")));
+#define xmlNewNs xmlNewNs__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewNsProp
+extern __typeof (xmlNewNsProp) xmlNewNsProp __attribute((alias("xmlNewNsProp__internal_alias")));
+#else
+#ifndef xmlNewNsProp
+extern __typeof (xmlNewNsProp) xmlNewNsProp__internal_alias __attribute((visibility("hidden")));
+#define xmlNewNsProp xmlNewNsProp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewNsPropEatName
+extern __typeof (xmlNewNsPropEatName) xmlNewNsPropEatName __attribute((alias("xmlNewNsPropEatName__internal_alias")));
+#else
+#ifndef xmlNewNsPropEatName
+extern __typeof (xmlNewNsPropEatName) xmlNewNsPropEatName__internal_alias __attribute((visibility("hidden")));
+#define xmlNewNsPropEatName xmlNewNsPropEatName__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewPI
+extern __typeof (xmlNewPI) xmlNewPI __attribute((alias("xmlNewPI__internal_alias")));
+#else
+#ifndef xmlNewPI
+extern __typeof (xmlNewPI) xmlNewPI__internal_alias __attribute((visibility("hidden")));
+#define xmlNewPI xmlNewPI__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlNewParserCtxt
+extern __typeof (xmlNewParserCtxt) xmlNewParserCtxt __attribute((alias("xmlNewParserCtxt__internal_alias")));
+#else
+#ifndef xmlNewParserCtxt
+extern __typeof (xmlNewParserCtxt) xmlNewParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlNewParserCtxt xmlNewParserCtxt__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_tree
+#undef xmlNewProp
+extern __typeof (xmlNewProp) xmlNewProp __attribute((alias("xmlNewProp__internal_alias")));
+#else
+#ifndef xmlNewProp
+extern __typeof (xmlNewProp) xmlNewProp__internal_alias __attribute((visibility("hidden")));
+#define xmlNewProp xmlNewProp__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlNewRMutex
+extern __typeof (xmlNewRMutex) xmlNewRMutex __attribute((alias("xmlNewRMutex__internal_alias")));
+#else
+#ifndef xmlNewRMutex
+extern __typeof (xmlNewRMutex) xmlNewRMutex__internal_alias __attribute((visibility("hidden")));
+#define xmlNewRMutex xmlNewRMutex__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewReference
+extern __typeof (xmlNewReference) xmlNewReference __attribute((alias("xmlNewReference__internal_alias")));
+#else
+#ifndef xmlNewReference
+extern __typeof (xmlNewReference) xmlNewReference__internal_alias __attribute((visibility("hidden")));
+#define xmlNewReference xmlNewReference__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlNewStringInputStream
+extern __typeof (xmlNewStringInputStream) xmlNewStringInputStream __attribute((alias("xmlNewStringInputStream__internal_alias")));
+#else
+#ifndef xmlNewStringInputStream
+extern __typeof (xmlNewStringInputStream) xmlNewStringInputStream__internal_alias __attribute((visibility("hidden")));
+#define xmlNewStringInputStream xmlNewStringInputStream__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewText
+extern __typeof (xmlNewText) xmlNewText __attribute((alias("xmlNewText__internal_alias")));
+#else
+#ifndef xmlNewText
+extern __typeof (xmlNewText) xmlNewText__internal_alias __attribute((visibility("hidden")));
+#define xmlNewText xmlNewText__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNewTextChild
+extern __typeof (xmlNewTextChild) xmlNewTextChild __attribute((alias("xmlNewTextChild__internal_alias")));
+#else
+#ifndef xmlNewTextChild
+extern __typeof (xmlNewTextChild) xmlNewTextChild__internal_alias __attribute((visibility("hidden")));
+#define xmlNewTextChild xmlNewTextChild__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNewTextLen
+extern __typeof (xmlNewTextLen) xmlNewTextLen __attribute((alias("xmlNewTextLen__internal_alias")));
+#else
+#ifndef xmlNewTextLen
+extern __typeof (xmlNewTextLen) xmlNewTextLen__internal_alias __attribute((visibility("hidden")));
+#define xmlNewTextLen xmlNewTextLen__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlNewTextReader
+extern __typeof (xmlNewTextReader) xmlNewTextReader __attribute((alias("xmlNewTextReader__internal_alias")));
+#else
+#ifndef xmlNewTextReader
+extern __typeof (xmlNewTextReader) xmlNewTextReader__internal_alias __attribute((visibility("hidden")));
+#define xmlNewTextReader xmlNewTextReader__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlNewTextReaderFilename
+extern __typeof (xmlNewTextReaderFilename) xmlNewTextReaderFilename __attribute((alias("xmlNewTextReaderFilename__internal_alias")));
+#else
+#ifndef xmlNewTextReaderFilename
+extern __typeof (xmlNewTextReaderFilename) xmlNewTextReaderFilename__internal_alias __attribute((visibility("hidden")));
+#define xmlNewTextReaderFilename xmlNewTextReaderFilename__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlNewTextWriter
+extern __typeof (xmlNewTextWriter) xmlNewTextWriter __attribute((alias("xmlNewTextWriter__internal_alias")));
+#else
+#ifndef xmlNewTextWriter
+extern __typeof (xmlNewTextWriter) xmlNewTextWriter__internal_alias __attribute((visibility("hidden")));
+#define xmlNewTextWriter xmlNewTextWriter__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlNewTextWriterDoc
+extern __typeof (xmlNewTextWriterDoc) xmlNewTextWriterDoc __attribute((alias("xmlNewTextWriterDoc__internal_alias")));
+#else
+#ifndef xmlNewTextWriterDoc
+extern __typeof (xmlNewTextWriterDoc) xmlNewTextWriterDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlNewTextWriterDoc xmlNewTextWriterDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlNewTextWriterFilename
+extern __typeof (xmlNewTextWriterFilename) xmlNewTextWriterFilename __attribute((alias("xmlNewTextWriterFilename__internal_alias")));
+#else
+#ifndef xmlNewTextWriterFilename
+extern __typeof (xmlNewTextWriterFilename) xmlNewTextWriterFilename__internal_alias __attribute((visibility("hidden")));
+#define xmlNewTextWriterFilename xmlNewTextWriterFilename__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlNewTextWriterMemory
+extern __typeof (xmlNewTextWriterMemory) xmlNewTextWriterMemory __attribute((alias("xmlNewTextWriterMemory__internal_alias")));
+#else
+#ifndef xmlNewTextWriterMemory
+extern __typeof (xmlNewTextWriterMemory) xmlNewTextWriterMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlNewTextWriterMemory xmlNewTextWriterMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlNewTextWriterPushParser
+extern __typeof (xmlNewTextWriterPushParser) xmlNewTextWriterPushParser __attribute((alias("xmlNewTextWriterPushParser__internal_alias")));
+#else
+#ifndef xmlNewTextWriterPushParser
+extern __typeof (xmlNewTextWriterPushParser) xmlNewTextWriterPushParser__internal_alias __attribute((visibility("hidden")));
+#define xmlNewTextWriterPushParser xmlNewTextWriterPushParser__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlNewTextWriterTree
+extern __typeof (xmlNewTextWriterTree) xmlNewTextWriterTree __attribute((alias("xmlNewTextWriterTree__internal_alias")));
+#else
+#ifndef xmlNewTextWriterTree
+extern __typeof (xmlNewTextWriterTree) xmlNewTextWriterTree__internal_alias __attribute((visibility("hidden")));
+#define xmlNewTextWriterTree xmlNewTextWriterTree__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlNewValidCtxt
+extern __typeof (xmlNewValidCtxt) xmlNewValidCtxt __attribute((alias("xmlNewValidCtxt__internal_alias")));
+#else
+#ifndef xmlNewValidCtxt
+extern __typeof (xmlNewValidCtxt) xmlNewValidCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlNewValidCtxt xmlNewValidCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlNextChar
+extern __typeof (xmlNextChar) xmlNextChar __attribute((alias("xmlNextChar__internal_alias")));
+#else
+#ifndef xmlNextChar
+extern __typeof (xmlNextChar) xmlNextChar__internal_alias __attribute((visibility("hidden")));
+#define xmlNextChar xmlNextChar__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNextElementSibling
+extern __typeof (xmlNextElementSibling) xmlNextElementSibling __attribute((alias("xmlNextElementSibling__internal_alias")));
+#else
+#ifndef xmlNextElementSibling
+extern __typeof (xmlNextElementSibling) xmlNextElementSibling__internal_alias __attribute((visibility("hidden")));
+#define xmlNextElementSibling xmlNextElementSibling__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlNoNetExternalEntityLoader
+extern __typeof (xmlNoNetExternalEntityLoader) xmlNoNetExternalEntityLoader __attribute((alias("xmlNoNetExternalEntityLoader__internal_alias")));
+#else
+#ifndef xmlNoNetExternalEntityLoader
+extern __typeof (xmlNoNetExternalEntityLoader) xmlNoNetExternalEntityLoader__internal_alias __attribute((visibility("hidden")));
+#define xmlNoNetExternalEntityLoader xmlNoNetExternalEntityLoader__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNodeAddContent
+extern __typeof (xmlNodeAddContent) xmlNodeAddContent __attribute((alias("xmlNodeAddContent__internal_alias")));
+#else
+#ifndef xmlNodeAddContent
+extern __typeof (xmlNodeAddContent) xmlNodeAddContent__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeAddContent xmlNodeAddContent__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNodeAddContentLen
+extern __typeof (xmlNodeAddContentLen) xmlNodeAddContentLen __attribute((alias("xmlNodeAddContentLen__internal_alias")));
+#else
+#ifndef xmlNodeAddContentLen
+extern __typeof (xmlNodeAddContentLen) xmlNodeAddContentLen__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeAddContentLen xmlNodeAddContentLen__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNodeBufGetContent
+extern __typeof (xmlNodeBufGetContent) xmlNodeBufGetContent __attribute((alias("xmlNodeBufGetContent__internal_alias")));
+#else
+#ifndef xmlNodeBufGetContent
+extern __typeof (xmlNodeBufGetContent) xmlNodeBufGetContent__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeBufGetContent xmlNodeBufGetContent__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlNodeDump
+extern __typeof (xmlNodeDump) xmlNodeDump __attribute((alias("xmlNodeDump__internal_alias")));
+#else
+#ifndef xmlNodeDump
+extern __typeof (xmlNodeDump) xmlNodeDump__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeDump xmlNodeDump__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlNodeDumpOutput
+extern __typeof (xmlNodeDumpOutput) xmlNodeDumpOutput __attribute((alias("xmlNodeDumpOutput__internal_alias")));
+#else
+#ifndef xmlNodeDumpOutput
+extern __typeof (xmlNodeDumpOutput) xmlNodeDumpOutput__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeDumpOutput xmlNodeDumpOutput__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNodeGetBase
+extern __typeof (xmlNodeGetBase) xmlNodeGetBase __attribute((alias("xmlNodeGetBase__internal_alias")));
+#else
+#ifndef xmlNodeGetBase
+extern __typeof (xmlNodeGetBase) xmlNodeGetBase__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeGetBase xmlNodeGetBase__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNodeGetContent
+extern __typeof (xmlNodeGetContent) xmlNodeGetContent __attribute((alias("xmlNodeGetContent__internal_alias")));
+#else
+#ifndef xmlNodeGetContent
+extern __typeof (xmlNodeGetContent) xmlNodeGetContent__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeGetContent xmlNodeGetContent__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNodeGetLang
+extern __typeof (xmlNodeGetLang) xmlNodeGetLang __attribute((alias("xmlNodeGetLang__internal_alias")));
+#else
+#ifndef xmlNodeGetLang
+extern __typeof (xmlNodeGetLang) xmlNodeGetLang__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeGetLang xmlNodeGetLang__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNodeGetSpacePreserve
+extern __typeof (xmlNodeGetSpacePreserve) xmlNodeGetSpacePreserve __attribute((alias("xmlNodeGetSpacePreserve__internal_alias")));
+#else
+#ifndef xmlNodeGetSpacePreserve
+extern __typeof (xmlNodeGetSpacePreserve) xmlNodeGetSpacePreserve__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeGetSpacePreserve xmlNodeGetSpacePreserve__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNodeIsText
+extern __typeof (xmlNodeIsText) xmlNodeIsText __attribute((alias("xmlNodeIsText__internal_alias")));
+#else
+#ifndef xmlNodeIsText
+extern __typeof (xmlNodeIsText) xmlNodeIsText__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeIsText xmlNodeIsText__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNodeListGetRawString
+extern __typeof (xmlNodeListGetRawString) xmlNodeListGetRawString __attribute((alias("xmlNodeListGetRawString__internal_alias")));
+#else
+#ifndef xmlNodeListGetRawString
+extern __typeof (xmlNodeListGetRawString) xmlNodeListGetRawString__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeListGetRawString xmlNodeListGetRawString__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNodeListGetString
+extern __typeof (xmlNodeListGetString) xmlNodeListGetString __attribute((alias("xmlNodeListGetString__internal_alias")));
+#else
+#ifndef xmlNodeListGetString
+extern __typeof (xmlNodeListGetString) xmlNodeListGetString__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeListGetString xmlNodeListGetString__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNodeSetBase
+extern __typeof (xmlNodeSetBase) xmlNodeSetBase __attribute((alias("xmlNodeSetBase__internal_alias")));
+#else
+#ifndef xmlNodeSetBase
+extern __typeof (xmlNodeSetBase) xmlNodeSetBase__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeSetBase xmlNodeSetBase__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlNodeSetContent
+extern __typeof (xmlNodeSetContent) xmlNodeSetContent __attribute((alias("xmlNodeSetContent__internal_alias")));
+#else
+#ifndef xmlNodeSetContent
+extern __typeof (xmlNodeSetContent) xmlNodeSetContent__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeSetContent xmlNodeSetContent__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNodeSetContentLen
+extern __typeof (xmlNodeSetContentLen) xmlNodeSetContentLen __attribute((alias("xmlNodeSetContentLen__internal_alias")));
+#else
+#ifndef xmlNodeSetContentLen
+extern __typeof (xmlNodeSetContentLen) xmlNodeSetContentLen__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeSetContentLen xmlNodeSetContentLen__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNodeSetLang
+extern __typeof (xmlNodeSetLang) xmlNodeSetLang __attribute((alias("xmlNodeSetLang__internal_alias")));
+#else
+#ifndef xmlNodeSetLang
+extern __typeof (xmlNodeSetLang) xmlNodeSetLang__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeSetLang xmlNodeSetLang__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNodeSetName
+extern __typeof (xmlNodeSetName) xmlNodeSetName __attribute((alias("xmlNodeSetName__internal_alias")));
+#else
+#ifndef xmlNodeSetName
+extern __typeof (xmlNodeSetName) xmlNodeSetName__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeSetName xmlNodeSetName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlNodeSetSpacePreserve
+extern __typeof (xmlNodeSetSpacePreserve) xmlNodeSetSpacePreserve __attribute((alias("xmlNodeSetSpacePreserve__internal_alias")));
+#else
+#ifndef xmlNodeSetSpacePreserve
+extern __typeof (xmlNodeSetSpacePreserve) xmlNodeSetSpacePreserve__internal_alias __attribute((visibility("hidden")));
+#define xmlNodeSetSpacePreserve xmlNodeSetSpacePreserve__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlNormalizeURIPath
+extern __typeof (xmlNormalizeURIPath) xmlNormalizeURIPath __attribute((alias("xmlNormalizeURIPath__internal_alias")));
+#else
+#ifndef xmlNormalizeURIPath
+extern __typeof (xmlNormalizeURIPath) xmlNormalizeURIPath__internal_alias __attribute((visibility("hidden")));
+#define xmlNormalizeURIPath xmlNormalizeURIPath__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlNormalizeWindowsPath
+extern __typeof (xmlNormalizeWindowsPath) xmlNormalizeWindowsPath __attribute((alias("xmlNormalizeWindowsPath__internal_alias")));
+#else
+#ifndef xmlNormalizeWindowsPath
+extern __typeof (xmlNormalizeWindowsPath) xmlNormalizeWindowsPath__internal_alias __attribute((visibility("hidden")));
+#define xmlNormalizeWindowsPath xmlNormalizeWindowsPath__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferClose
+extern __typeof (xmlOutputBufferClose) xmlOutputBufferClose __attribute((alias("xmlOutputBufferClose__internal_alias")));
+#else
+#ifndef xmlOutputBufferClose
+extern __typeof (xmlOutputBufferClose) xmlOutputBufferClose__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferClose xmlOutputBufferClose__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferCreateBuffer
+extern __typeof (xmlOutputBufferCreateBuffer) xmlOutputBufferCreateBuffer __attribute((alias("xmlOutputBufferCreateBuffer__internal_alias")));
+#else
+#ifndef xmlOutputBufferCreateBuffer
+extern __typeof (xmlOutputBufferCreateBuffer) xmlOutputBufferCreateBuffer__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferCreateBuffer xmlOutputBufferCreateBuffer__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferCreateFd
+extern __typeof (xmlOutputBufferCreateFd) xmlOutputBufferCreateFd __attribute((alias("xmlOutputBufferCreateFd__internal_alias")));
+#else
+#ifndef xmlOutputBufferCreateFd
+extern __typeof (xmlOutputBufferCreateFd) xmlOutputBufferCreateFd__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferCreateFd xmlOutputBufferCreateFd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferCreateFile
+extern __typeof (xmlOutputBufferCreateFile) xmlOutputBufferCreateFile __attribute((alias("xmlOutputBufferCreateFile__internal_alias")));
+#else
+#ifndef xmlOutputBufferCreateFile
+extern __typeof (xmlOutputBufferCreateFile) xmlOutputBufferCreateFile__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferCreateFile xmlOutputBufferCreateFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferCreateFilename
+extern __typeof (xmlOutputBufferCreateFilename) xmlOutputBufferCreateFilename __attribute((alias("xmlOutputBufferCreateFilename__internal_alias")));
+#else
+#ifndef xmlOutputBufferCreateFilename
+extern __typeof (xmlOutputBufferCreateFilename) xmlOutputBufferCreateFilename__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferCreateFilename xmlOutputBufferCreateFilename__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferCreateFilenameDefault
+extern __typeof (xmlOutputBufferCreateFilenameDefault) xmlOutputBufferCreateFilenameDefault __attribute((alias("xmlOutputBufferCreateFilenameDefault__internal_alias")));
+#else
+#ifndef xmlOutputBufferCreateFilenameDefault
+extern __typeof (xmlOutputBufferCreateFilenameDefault) xmlOutputBufferCreateFilenameDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferCreateFilenameDefault xmlOutputBufferCreateFilenameDefault__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferCreateIO
+extern __typeof (xmlOutputBufferCreateIO) xmlOutputBufferCreateIO __attribute((alias("xmlOutputBufferCreateIO__internal_alias")));
+#else
+#ifndef xmlOutputBufferCreateIO
+extern __typeof (xmlOutputBufferCreateIO) xmlOutputBufferCreateIO__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferCreateIO xmlOutputBufferCreateIO__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferFlush
+extern __typeof (xmlOutputBufferFlush) xmlOutputBufferFlush __attribute((alias("xmlOutputBufferFlush__internal_alias")));
+#else
+#ifndef xmlOutputBufferFlush
+extern __typeof (xmlOutputBufferFlush) xmlOutputBufferFlush__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferFlush xmlOutputBufferFlush__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferGetContent
+extern __typeof (xmlOutputBufferGetContent) xmlOutputBufferGetContent __attribute((alias("xmlOutputBufferGetContent__internal_alias")));
+#else
+#ifndef xmlOutputBufferGetContent
+extern __typeof (xmlOutputBufferGetContent) xmlOutputBufferGetContent__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferGetContent xmlOutputBufferGetContent__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferGetSize
+extern __typeof (xmlOutputBufferGetSize) xmlOutputBufferGetSize __attribute((alias("xmlOutputBufferGetSize__internal_alias")));
+#else
+#ifndef xmlOutputBufferGetSize
+extern __typeof (xmlOutputBufferGetSize) xmlOutputBufferGetSize__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferGetSize xmlOutputBufferGetSize__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferWrite
+extern __typeof (xmlOutputBufferWrite) xmlOutputBufferWrite __attribute((alias("xmlOutputBufferWrite__internal_alias")));
+#else
+#ifndef xmlOutputBufferWrite
+extern __typeof (xmlOutputBufferWrite) xmlOutputBufferWrite__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferWrite xmlOutputBufferWrite__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferWriteEscape
+extern __typeof (xmlOutputBufferWriteEscape) xmlOutputBufferWriteEscape __attribute((alias("xmlOutputBufferWriteEscape__internal_alias")));
+#else
+#ifndef xmlOutputBufferWriteEscape
+extern __typeof (xmlOutputBufferWriteEscape) xmlOutputBufferWriteEscape__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferWriteEscape xmlOutputBufferWriteEscape__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlOutputBufferWriteString
+extern __typeof (xmlOutputBufferWriteString) xmlOutputBufferWriteString __attribute((alias("xmlOutputBufferWriteString__internal_alias")));
+#else
+#ifndef xmlOutputBufferWriteString
+extern __typeof (xmlOutputBufferWriteString) xmlOutputBufferWriteString__internal_alias __attribute((visibility("hidden")));
+#define xmlOutputBufferWriteString xmlOutputBufferWriteString__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseAttValue
+extern __typeof (xmlParseAttValue) xmlParseAttValue __attribute((alias("xmlParseAttValue__internal_alias")));
+#else
+#ifndef xmlParseAttValue
+extern __typeof (xmlParseAttValue) xmlParseAttValue__internal_alias __attribute((visibility("hidden")));
+#define xmlParseAttValue xmlParseAttValue__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseAttribute
+extern __typeof (xmlParseAttribute) xmlParseAttribute __attribute((alias("xmlParseAttribute__internal_alias")));
+#else
+#ifndef xmlParseAttribute
+extern __typeof (xmlParseAttribute) xmlParseAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlParseAttribute xmlParseAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseAttributeListDecl
+extern __typeof (xmlParseAttributeListDecl) xmlParseAttributeListDecl __attribute((alias("xmlParseAttributeListDecl__internal_alias")));
+#else
+#ifndef xmlParseAttributeListDecl
+extern __typeof (xmlParseAttributeListDecl) xmlParseAttributeListDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseAttributeListDecl xmlParseAttributeListDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseAttributeType
+extern __typeof (xmlParseAttributeType) xmlParseAttributeType __attribute((alias("xmlParseAttributeType__internal_alias")));
+#else
+#ifndef xmlParseAttributeType
+extern __typeof (xmlParseAttributeType) xmlParseAttributeType__internal_alias __attribute((visibility("hidden")));
+#define xmlParseAttributeType xmlParseAttributeType__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseBalancedChunkMemory
+extern __typeof (xmlParseBalancedChunkMemory) xmlParseBalancedChunkMemory __attribute((alias("xmlParseBalancedChunkMemory__internal_alias")));
+#else
+#ifndef xmlParseBalancedChunkMemory
+extern __typeof (xmlParseBalancedChunkMemory) xmlParseBalancedChunkMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlParseBalancedChunkMemory xmlParseBalancedChunkMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseBalancedChunkMemoryRecover
+extern __typeof (xmlParseBalancedChunkMemoryRecover) xmlParseBalancedChunkMemoryRecover __attribute((alias("xmlParseBalancedChunkMemoryRecover__internal_alias")));
+#else
+#ifndef xmlParseBalancedChunkMemoryRecover
+extern __typeof (xmlParseBalancedChunkMemoryRecover) xmlParseBalancedChunkMemoryRecover__internal_alias __attribute((visibility("hidden")));
+#define xmlParseBalancedChunkMemoryRecover xmlParseBalancedChunkMemoryRecover__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseCDSect
+extern __typeof (xmlParseCDSect) xmlParseCDSect __attribute((alias("xmlParseCDSect__internal_alias")));
+#else
+#ifndef xmlParseCDSect
+extern __typeof (xmlParseCDSect) xmlParseCDSect__internal_alias __attribute((visibility("hidden")));
+#define xmlParseCDSect xmlParseCDSect__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_CATALOG_ENABLED)
+#ifdef bottom_catalog
+#undef xmlParseCatalogFile
+extern __typeof (xmlParseCatalogFile) xmlParseCatalogFile __attribute((alias("xmlParseCatalogFile__internal_alias")));
+#else
+#ifndef xmlParseCatalogFile
+extern __typeof (xmlParseCatalogFile) xmlParseCatalogFile__internal_alias __attribute((visibility("hidden")));
+#define xmlParseCatalogFile xmlParseCatalogFile__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseCharData
+extern __typeof (xmlParseCharData) xmlParseCharData __attribute((alias("xmlParseCharData__internal_alias")));
+#else
+#ifndef xmlParseCharData
+extern __typeof (xmlParseCharData) xmlParseCharData__internal_alias __attribute((visibility("hidden")));
+#define xmlParseCharData xmlParseCharData__internal_alias
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlParseCharEncoding
+extern __typeof (xmlParseCharEncoding) xmlParseCharEncoding __attribute((alias("xmlParseCharEncoding__internal_alias")));
+#else
+#ifndef xmlParseCharEncoding
+extern __typeof (xmlParseCharEncoding) xmlParseCharEncoding__internal_alias __attribute((visibility("hidden")));
+#define xmlParseCharEncoding xmlParseCharEncoding__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseCharRef
+extern __typeof (xmlParseCharRef) xmlParseCharRef __attribute((alias("xmlParseCharRef__internal_alias")));
+#else
+#ifndef xmlParseCharRef
+extern __typeof (xmlParseCharRef) xmlParseCharRef__internal_alias __attribute((visibility("hidden")));
+#define xmlParseCharRef xmlParseCharRef__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_PUSH_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseChunk
+extern __typeof (xmlParseChunk) xmlParseChunk __attribute((alias("xmlParseChunk__internal_alias")));
+#else
+#ifndef xmlParseChunk
+extern __typeof (xmlParseChunk) xmlParseChunk__internal_alias __attribute((visibility("hidden")));
+#define xmlParseChunk xmlParseChunk__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseComment
+extern __typeof (xmlParseComment) xmlParseComment __attribute((alias("xmlParseComment__internal_alias")));
+#else
+#ifndef xmlParseComment
+extern __typeof (xmlParseComment) xmlParseComment__internal_alias __attribute((visibility("hidden")));
+#define xmlParseComment xmlParseComment__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseContent
+extern __typeof (xmlParseContent) xmlParseContent __attribute((alias("xmlParseContent__internal_alias")));
+#else
+#ifndef xmlParseContent
+extern __typeof (xmlParseContent) xmlParseContent__internal_alias __attribute((visibility("hidden")));
+#define xmlParseContent xmlParseContent__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseCtxtExternalEntity
+extern __typeof (xmlParseCtxtExternalEntity) xmlParseCtxtExternalEntity __attribute((alias("xmlParseCtxtExternalEntity__internal_alias")));
+#else
+#ifndef xmlParseCtxtExternalEntity
+extern __typeof (xmlParseCtxtExternalEntity) xmlParseCtxtExternalEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlParseCtxtExternalEntity xmlParseCtxtExternalEntity__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseDTD
+extern __typeof (xmlParseDTD) xmlParseDTD __attribute((alias("xmlParseDTD__internal_alias")));
+#else
+#ifndef xmlParseDTD
+extern __typeof (xmlParseDTD) xmlParseDTD__internal_alias __attribute((visibility("hidden")));
+#define xmlParseDTD xmlParseDTD__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseDefaultDecl
+extern __typeof (xmlParseDefaultDecl) xmlParseDefaultDecl __attribute((alias("xmlParseDefaultDecl__internal_alias")));
+#else
+#ifndef xmlParseDefaultDecl
+extern __typeof (xmlParseDefaultDecl) xmlParseDefaultDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseDefaultDecl xmlParseDefaultDecl__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseDoc
+extern __typeof (xmlParseDoc) xmlParseDoc __attribute((alias("xmlParseDoc__internal_alias")));
+#else
+#ifndef xmlParseDoc
+extern __typeof (xmlParseDoc) xmlParseDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlParseDoc xmlParseDoc__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseDocTypeDecl
+extern __typeof (xmlParseDocTypeDecl) xmlParseDocTypeDecl __attribute((alias("xmlParseDocTypeDecl__internal_alias")));
+#else
+#ifndef xmlParseDocTypeDecl
+extern __typeof (xmlParseDocTypeDecl) xmlParseDocTypeDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseDocTypeDecl xmlParseDocTypeDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseDocument
+extern __typeof (xmlParseDocument) xmlParseDocument __attribute((alias("xmlParseDocument__internal_alias")));
+#else
+#ifndef xmlParseDocument
+extern __typeof (xmlParseDocument) xmlParseDocument__internal_alias __attribute((visibility("hidden")));
+#define xmlParseDocument xmlParseDocument__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseElement
+extern __typeof (xmlParseElement) xmlParseElement __attribute((alias("xmlParseElement__internal_alias")));
+#else
+#ifndef xmlParseElement
+extern __typeof (xmlParseElement) xmlParseElement__internal_alias __attribute((visibility("hidden")));
+#define xmlParseElement xmlParseElement__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseElementChildrenContentDecl
+extern __typeof (xmlParseElementChildrenContentDecl) xmlParseElementChildrenContentDecl __attribute((alias("xmlParseElementChildrenContentDecl__internal_alias")));
+#else
+#ifndef xmlParseElementChildrenContentDecl
+extern __typeof (xmlParseElementChildrenContentDecl) xmlParseElementChildrenContentDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseElementChildrenContentDecl xmlParseElementChildrenContentDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseElementContentDecl
+extern __typeof (xmlParseElementContentDecl) xmlParseElementContentDecl __attribute((alias("xmlParseElementContentDecl__internal_alias")));
+#else
+#ifndef xmlParseElementContentDecl
+extern __typeof (xmlParseElementContentDecl) xmlParseElementContentDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseElementContentDecl xmlParseElementContentDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseElementDecl
+extern __typeof (xmlParseElementDecl) xmlParseElementDecl __attribute((alias("xmlParseElementDecl__internal_alias")));
+#else
+#ifndef xmlParseElementDecl
+extern __typeof (xmlParseElementDecl) xmlParseElementDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseElementDecl xmlParseElementDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseElementMixedContentDecl
+extern __typeof (xmlParseElementMixedContentDecl) xmlParseElementMixedContentDecl __attribute((alias("xmlParseElementMixedContentDecl__internal_alias")));
+#else
+#ifndef xmlParseElementMixedContentDecl
+extern __typeof (xmlParseElementMixedContentDecl) xmlParseElementMixedContentDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseElementMixedContentDecl xmlParseElementMixedContentDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseEncName
+extern __typeof (xmlParseEncName) xmlParseEncName __attribute((alias("xmlParseEncName__internal_alias")));
+#else
+#ifndef xmlParseEncName
+extern __typeof (xmlParseEncName) xmlParseEncName__internal_alias __attribute((visibility("hidden")));
+#define xmlParseEncName xmlParseEncName__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseEncodingDecl
+extern __typeof (xmlParseEncodingDecl) xmlParseEncodingDecl __attribute((alias("xmlParseEncodingDecl__internal_alias")));
+#else
+#ifndef xmlParseEncodingDecl
+extern __typeof (xmlParseEncodingDecl) xmlParseEncodingDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseEncodingDecl xmlParseEncodingDecl__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseEndTag
+extern __typeof (xmlParseEndTag) xmlParseEndTag __attribute((alias("xmlParseEndTag__internal_alias")));
+#else
+#ifndef xmlParseEndTag
+extern __typeof (xmlParseEndTag) xmlParseEndTag__internal_alias __attribute((visibility("hidden")));
+#define xmlParseEndTag xmlParseEndTag__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseEntity
+extern __typeof (xmlParseEntity) xmlParseEntity __attribute((alias("xmlParseEntity__internal_alias")));
+#else
+#ifndef xmlParseEntity
+extern __typeof (xmlParseEntity) xmlParseEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlParseEntity xmlParseEntity__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseEntityDecl
+extern __typeof (xmlParseEntityDecl) xmlParseEntityDecl __attribute((alias("xmlParseEntityDecl__internal_alias")));
+#else
+#ifndef xmlParseEntityDecl
+extern __typeof (xmlParseEntityDecl) xmlParseEntityDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseEntityDecl xmlParseEntityDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseEntityRef
+extern __typeof (xmlParseEntityRef) xmlParseEntityRef __attribute((alias("xmlParseEntityRef__internal_alias")));
+#else
+#ifndef xmlParseEntityRef
+extern __typeof (xmlParseEntityRef) xmlParseEntityRef__internal_alias __attribute((visibility("hidden")));
+#define xmlParseEntityRef xmlParseEntityRef__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseEntityValue
+extern __typeof (xmlParseEntityValue) xmlParseEntityValue __attribute((alias("xmlParseEntityValue__internal_alias")));
+#else
+#ifndef xmlParseEntityValue
+extern __typeof (xmlParseEntityValue) xmlParseEntityValue__internal_alias __attribute((visibility("hidden")));
+#define xmlParseEntityValue xmlParseEntityValue__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseEnumeratedType
+extern __typeof (xmlParseEnumeratedType) xmlParseEnumeratedType __attribute((alias("xmlParseEnumeratedType__internal_alias")));
+#else
+#ifndef xmlParseEnumeratedType
+extern __typeof (xmlParseEnumeratedType) xmlParseEnumeratedType__internal_alias __attribute((visibility("hidden")));
+#define xmlParseEnumeratedType xmlParseEnumeratedType__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseEnumerationType
+extern __typeof (xmlParseEnumerationType) xmlParseEnumerationType __attribute((alias("xmlParseEnumerationType__internal_alias")));
+#else
+#ifndef xmlParseEnumerationType
+extern __typeof (xmlParseEnumerationType) xmlParseEnumerationType__internal_alias __attribute((visibility("hidden")));
+#define xmlParseEnumerationType xmlParseEnumerationType__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseExtParsedEnt
+extern __typeof (xmlParseExtParsedEnt) xmlParseExtParsedEnt __attribute((alias("xmlParseExtParsedEnt__internal_alias")));
+#else
+#ifndef xmlParseExtParsedEnt
+extern __typeof (xmlParseExtParsedEnt) xmlParseExtParsedEnt__internal_alias __attribute((visibility("hidden")));
+#define xmlParseExtParsedEnt xmlParseExtParsedEnt__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseExternalEntity
+extern __typeof (xmlParseExternalEntity) xmlParseExternalEntity __attribute((alias("xmlParseExternalEntity__internal_alias")));
+#else
+#ifndef xmlParseExternalEntity
+extern __typeof (xmlParseExternalEntity) xmlParseExternalEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlParseExternalEntity xmlParseExternalEntity__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseExternalID
+extern __typeof (xmlParseExternalID) xmlParseExternalID __attribute((alias("xmlParseExternalID__internal_alias")));
+#else
+#ifndef xmlParseExternalID
+extern __typeof (xmlParseExternalID) xmlParseExternalID__internal_alias __attribute((visibility("hidden")));
+#define xmlParseExternalID xmlParseExternalID__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseExternalSubset
+extern __typeof (xmlParseExternalSubset) xmlParseExternalSubset __attribute((alias("xmlParseExternalSubset__internal_alias")));
+#else
+#ifndef xmlParseExternalSubset
+extern __typeof (xmlParseExternalSubset) xmlParseExternalSubset__internal_alias __attribute((visibility("hidden")));
+#define xmlParseExternalSubset xmlParseExternalSubset__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseFile
+extern __typeof (xmlParseFile) xmlParseFile __attribute((alias("xmlParseFile__internal_alias")));
+#else
+#ifndef xmlParseFile
+extern __typeof (xmlParseFile) xmlParseFile__internal_alias __attribute((visibility("hidden")));
+#define xmlParseFile xmlParseFile__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseInNodeContext
+extern __typeof (xmlParseInNodeContext) xmlParseInNodeContext __attribute((alias("xmlParseInNodeContext__internal_alias")));
+#else
+#ifndef xmlParseInNodeContext
+extern __typeof (xmlParseInNodeContext) xmlParseInNodeContext__internal_alias __attribute((visibility("hidden")));
+#define xmlParseInNodeContext xmlParseInNodeContext__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseMarkupDecl
+extern __typeof (xmlParseMarkupDecl) xmlParseMarkupDecl __attribute((alias("xmlParseMarkupDecl__internal_alias")));
+#else
+#ifndef xmlParseMarkupDecl
+extern __typeof (xmlParseMarkupDecl) xmlParseMarkupDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseMarkupDecl xmlParseMarkupDecl__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseMemory
+extern __typeof (xmlParseMemory) xmlParseMemory __attribute((alias("xmlParseMemory__internal_alias")));
+#else
+#ifndef xmlParseMemory
+extern __typeof (xmlParseMemory) xmlParseMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlParseMemory xmlParseMemory__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseMisc
+extern __typeof (xmlParseMisc) xmlParseMisc __attribute((alias("xmlParseMisc__internal_alias")));
+#else
+#ifndef xmlParseMisc
+extern __typeof (xmlParseMisc) xmlParseMisc__internal_alias __attribute((visibility("hidden")));
+#define xmlParseMisc xmlParseMisc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseName
+extern __typeof (xmlParseName) xmlParseName __attribute((alias("xmlParseName__internal_alias")));
+#else
+#ifndef xmlParseName
+extern __typeof (xmlParseName) xmlParseName__internal_alias __attribute((visibility("hidden")));
+#define xmlParseName xmlParseName__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlParseNamespace
+extern __typeof (xmlParseNamespace) xmlParseNamespace __attribute((alias("xmlParseNamespace__internal_alias")));
+#else
+#ifndef xmlParseNamespace
+extern __typeof (xmlParseNamespace) xmlParseNamespace__internal_alias __attribute((visibility("hidden")));
+#define xmlParseNamespace xmlParseNamespace__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseNmtoken
+extern __typeof (xmlParseNmtoken) xmlParseNmtoken __attribute((alias("xmlParseNmtoken__internal_alias")));
+#else
+#ifndef xmlParseNmtoken
+extern __typeof (xmlParseNmtoken) xmlParseNmtoken__internal_alias __attribute((visibility("hidden")));
+#define xmlParseNmtoken xmlParseNmtoken__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseNotationDecl
+extern __typeof (xmlParseNotationDecl) xmlParseNotationDecl __attribute((alias("xmlParseNotationDecl__internal_alias")));
+#else
+#ifndef xmlParseNotationDecl
+extern __typeof (xmlParseNotationDecl) xmlParseNotationDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseNotationDecl xmlParseNotationDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseNotationType
+extern __typeof (xmlParseNotationType) xmlParseNotationType __attribute((alias("xmlParseNotationType__internal_alias")));
+#else
+#ifndef xmlParseNotationType
+extern __typeof (xmlParseNotationType) xmlParseNotationType__internal_alias __attribute((visibility("hidden")));
+#define xmlParseNotationType xmlParseNotationType__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParsePEReference
+extern __typeof (xmlParsePEReference) xmlParsePEReference __attribute((alias("xmlParsePEReference__internal_alias")));
+#else
+#ifndef xmlParsePEReference
+extern __typeof (xmlParsePEReference) xmlParsePEReference__internal_alias __attribute((visibility("hidden")));
+#define xmlParsePEReference xmlParsePEReference__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParsePI
+extern __typeof (xmlParsePI) xmlParsePI __attribute((alias("xmlParsePI__internal_alias")));
+#else
+#ifndef xmlParsePI
+extern __typeof (xmlParsePI) xmlParsePI__internal_alias __attribute((visibility("hidden")));
+#define xmlParsePI xmlParsePI__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParsePITarget
+extern __typeof (xmlParsePITarget) xmlParsePITarget __attribute((alias("xmlParsePITarget__internal_alias")));
+#else
+#ifndef xmlParsePITarget
+extern __typeof (xmlParsePITarget) xmlParsePITarget__internal_alias __attribute((visibility("hidden")));
+#define xmlParsePITarget xmlParsePITarget__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParsePubidLiteral
+extern __typeof (xmlParsePubidLiteral) xmlParsePubidLiteral __attribute((alias("xmlParsePubidLiteral__internal_alias")));
+#else
+#ifndef xmlParsePubidLiteral
+extern __typeof (xmlParsePubidLiteral) xmlParsePubidLiteral__internal_alias __attribute((visibility("hidden")));
+#define xmlParsePubidLiteral xmlParsePubidLiteral__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlParseQuotedString
+extern __typeof (xmlParseQuotedString) xmlParseQuotedString __attribute((alias("xmlParseQuotedString__internal_alias")));
+#else
+#ifndef xmlParseQuotedString
+extern __typeof (xmlParseQuotedString) xmlParseQuotedString__internal_alias __attribute((visibility("hidden")));
+#define xmlParseQuotedString xmlParseQuotedString__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseReference
+extern __typeof (xmlParseReference) xmlParseReference __attribute((alias("xmlParseReference__internal_alias")));
+#else
+#ifndef xmlParseReference
+extern __typeof (xmlParseReference) xmlParseReference__internal_alias __attribute((visibility("hidden")));
+#define xmlParseReference xmlParseReference__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseSDDecl
+extern __typeof (xmlParseSDDecl) xmlParseSDDecl __attribute((alias("xmlParseSDDecl__internal_alias")));
+#else
+#ifndef xmlParseSDDecl
+extern __typeof (xmlParseSDDecl) xmlParseSDDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseSDDecl xmlParseSDDecl__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlParseStartTag
+extern __typeof (xmlParseStartTag) xmlParseStartTag __attribute((alias("xmlParseStartTag__internal_alias")));
+#else
+#ifndef xmlParseStartTag
+extern __typeof (xmlParseStartTag) xmlParseStartTag__internal_alias __attribute((visibility("hidden")));
+#define xmlParseStartTag xmlParseStartTag__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseSystemLiteral
+extern __typeof (xmlParseSystemLiteral) xmlParseSystemLiteral __attribute((alias("xmlParseSystemLiteral__internal_alias")));
+#else
+#ifndef xmlParseSystemLiteral
+extern __typeof (xmlParseSystemLiteral) xmlParseSystemLiteral__internal_alias __attribute((visibility("hidden")));
+#define xmlParseSystemLiteral xmlParseSystemLiteral__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseTextDecl
+extern __typeof (xmlParseTextDecl) xmlParseTextDecl __attribute((alias("xmlParseTextDecl__internal_alias")));
+#else
+#ifndef xmlParseTextDecl
+extern __typeof (xmlParseTextDecl) xmlParseTextDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseTextDecl xmlParseTextDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlParseURI
+extern __typeof (xmlParseURI) xmlParseURI __attribute((alias("xmlParseURI__internal_alias")));
+#else
+#ifndef xmlParseURI
+extern __typeof (xmlParseURI) xmlParseURI__internal_alias __attribute((visibility("hidden")));
+#define xmlParseURI xmlParseURI__internal_alias
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlParseURIRaw
+extern __typeof (xmlParseURIRaw) xmlParseURIRaw __attribute((alias("xmlParseURIRaw__internal_alias")));
+#else
+#ifndef xmlParseURIRaw
+extern __typeof (xmlParseURIRaw) xmlParseURIRaw__internal_alias __attribute((visibility("hidden")));
+#define xmlParseURIRaw xmlParseURIRaw__internal_alias
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlParseURIReference
+extern __typeof (xmlParseURIReference) xmlParseURIReference __attribute((alias("xmlParseURIReference__internal_alias")));
+#else
+#ifndef xmlParseURIReference
+extern __typeof (xmlParseURIReference) xmlParseURIReference__internal_alias __attribute((visibility("hidden")));
+#define xmlParseURIReference xmlParseURIReference__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseVersionInfo
+extern __typeof (xmlParseVersionInfo) xmlParseVersionInfo __attribute((alias("xmlParseVersionInfo__internal_alias")));
+#else
+#ifndef xmlParseVersionInfo
+extern __typeof (xmlParseVersionInfo) xmlParseVersionInfo__internal_alias __attribute((visibility("hidden")));
+#define xmlParseVersionInfo xmlParseVersionInfo__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseVersionNum
+extern __typeof (xmlParseVersionNum) xmlParseVersionNum __attribute((alias("xmlParseVersionNum__internal_alias")));
+#else
+#ifndef xmlParseVersionNum
+extern __typeof (xmlParseVersionNum) xmlParseVersionNum__internal_alias __attribute((visibility("hidden")));
+#define xmlParseVersionNum xmlParseVersionNum__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParseXMLDecl
+extern __typeof (xmlParseXMLDecl) xmlParseXMLDecl __attribute((alias("xmlParseXMLDecl__internal_alias")));
+#else
+#ifndef xmlParseXMLDecl
+extern __typeof (xmlParseXMLDecl) xmlParseXMLDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlParseXMLDecl xmlParseXMLDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlParserAddNodeInfo
+extern __typeof (xmlParserAddNodeInfo) xmlParserAddNodeInfo __attribute((alias("xmlParserAddNodeInfo__internal_alias")));
+#else
+#ifndef xmlParserAddNodeInfo
+extern __typeof (xmlParserAddNodeInfo) xmlParserAddNodeInfo__internal_alias __attribute((visibility("hidden")));
+#define xmlParserAddNodeInfo xmlParserAddNodeInfo__internal_alias
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlParserError
+extern __typeof (xmlParserError) xmlParserError __attribute((alias("xmlParserError__internal_alias")));
+#else
+#ifndef xmlParserError
+extern __typeof (xmlParserError) xmlParserError__internal_alias __attribute((visibility("hidden")));
+#define xmlParserError xmlParserError__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlParserFindNodeInfo
+extern __typeof (xmlParserFindNodeInfo) xmlParserFindNodeInfo __attribute((alias("xmlParserFindNodeInfo__internal_alias")));
+#else
+#ifndef xmlParserFindNodeInfo
+extern __typeof (xmlParserFindNodeInfo) xmlParserFindNodeInfo__internal_alias __attribute((visibility("hidden")));
+#define xmlParserFindNodeInfo xmlParserFindNodeInfo__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlParserFindNodeInfoIndex
+extern __typeof (xmlParserFindNodeInfoIndex) xmlParserFindNodeInfoIndex __attribute((alias("xmlParserFindNodeInfoIndex__internal_alias")));
+#else
+#ifndef xmlParserFindNodeInfoIndex
+extern __typeof (xmlParserFindNodeInfoIndex) xmlParserFindNodeInfoIndex__internal_alias __attribute((visibility("hidden")));
+#define xmlParserFindNodeInfoIndex xmlParserFindNodeInfoIndex__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserGetDirectory
+extern __typeof (xmlParserGetDirectory) xmlParserGetDirectory __attribute((alias("xmlParserGetDirectory__internal_alias")));
+#else
+#ifndef xmlParserGetDirectory
+extern __typeof (xmlParserGetDirectory) xmlParserGetDirectory__internal_alias __attribute((visibility("hidden")));
+#define xmlParserGetDirectory xmlParserGetDirectory__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlParserHandlePEReference
+extern __typeof (xmlParserHandlePEReference) xmlParserHandlePEReference __attribute((alias("xmlParserHandlePEReference__internal_alias")));
+#else
+#ifndef xmlParserHandlePEReference
+extern __typeof (xmlParserHandlePEReference) xmlParserHandlePEReference__internal_alias __attribute((visibility("hidden")));
+#define xmlParserHandlePEReference xmlParserHandlePEReference__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlParserHandleReference
+extern __typeof (xmlParserHandleReference) xmlParserHandleReference __attribute((alias("xmlParserHandleReference__internal_alias")));
+#else
+#ifndef xmlParserHandleReference
+extern __typeof (xmlParserHandleReference) xmlParserHandleReference__internal_alias __attribute((visibility("hidden")));
+#define xmlParserHandleReference xmlParserHandleReference__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserInputBufferCreateFd
+extern __typeof (xmlParserInputBufferCreateFd) xmlParserInputBufferCreateFd __attribute((alias("xmlParserInputBufferCreateFd__internal_alias")));
+#else
+#ifndef xmlParserInputBufferCreateFd
+extern __typeof (xmlParserInputBufferCreateFd) xmlParserInputBufferCreateFd__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputBufferCreateFd xmlParserInputBufferCreateFd__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserInputBufferCreateFile
+extern __typeof (xmlParserInputBufferCreateFile) xmlParserInputBufferCreateFile __attribute((alias("xmlParserInputBufferCreateFile__internal_alias")));
+#else
+#ifndef xmlParserInputBufferCreateFile
+extern __typeof (xmlParserInputBufferCreateFile) xmlParserInputBufferCreateFile__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputBufferCreateFile xmlParserInputBufferCreateFile__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserInputBufferCreateFilename
+extern __typeof (xmlParserInputBufferCreateFilename) xmlParserInputBufferCreateFilename __attribute((alias("xmlParserInputBufferCreateFilename__internal_alias")));
+#else
+#ifndef xmlParserInputBufferCreateFilename
+extern __typeof (xmlParserInputBufferCreateFilename) xmlParserInputBufferCreateFilename__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputBufferCreateFilename xmlParserInputBufferCreateFilename__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserInputBufferCreateFilenameDefault
+extern __typeof (xmlParserInputBufferCreateFilenameDefault) xmlParserInputBufferCreateFilenameDefault __attribute((alias("xmlParserInputBufferCreateFilenameDefault__internal_alias")));
+#else
+#ifndef xmlParserInputBufferCreateFilenameDefault
+extern __typeof (xmlParserInputBufferCreateFilenameDefault) xmlParserInputBufferCreateFilenameDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputBufferCreateFilenameDefault xmlParserInputBufferCreateFilenameDefault__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserInputBufferCreateIO
+extern __typeof (xmlParserInputBufferCreateIO) xmlParserInputBufferCreateIO __attribute((alias("xmlParserInputBufferCreateIO__internal_alias")));
+#else
+#ifndef xmlParserInputBufferCreateIO
+extern __typeof (xmlParserInputBufferCreateIO) xmlParserInputBufferCreateIO__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputBufferCreateIO xmlParserInputBufferCreateIO__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserInputBufferCreateMem
+extern __typeof (xmlParserInputBufferCreateMem) xmlParserInputBufferCreateMem __attribute((alias("xmlParserInputBufferCreateMem__internal_alias")));
+#else
+#ifndef xmlParserInputBufferCreateMem
+extern __typeof (xmlParserInputBufferCreateMem) xmlParserInputBufferCreateMem__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputBufferCreateMem xmlParserInputBufferCreateMem__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserInputBufferCreateStatic
+extern __typeof (xmlParserInputBufferCreateStatic) xmlParserInputBufferCreateStatic __attribute((alias("xmlParserInputBufferCreateStatic__internal_alias")));
+#else
+#ifndef xmlParserInputBufferCreateStatic
+extern __typeof (xmlParserInputBufferCreateStatic) xmlParserInputBufferCreateStatic__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputBufferCreateStatic xmlParserInputBufferCreateStatic__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserInputBufferGrow
+extern __typeof (xmlParserInputBufferGrow) xmlParserInputBufferGrow __attribute((alias("xmlParserInputBufferGrow__internal_alias")));
+#else
+#ifndef xmlParserInputBufferGrow
+extern __typeof (xmlParserInputBufferGrow) xmlParserInputBufferGrow__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputBufferGrow xmlParserInputBufferGrow__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserInputBufferPush
+extern __typeof (xmlParserInputBufferPush) xmlParserInputBufferPush __attribute((alias("xmlParserInputBufferPush__internal_alias")));
+#else
+#ifndef xmlParserInputBufferPush
+extern __typeof (xmlParserInputBufferPush) xmlParserInputBufferPush__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputBufferPush xmlParserInputBufferPush__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlParserInputBufferRead
+extern __typeof (xmlParserInputBufferRead) xmlParserInputBufferRead __attribute((alias("xmlParserInputBufferRead__internal_alias")));
+#else
+#ifndef xmlParserInputBufferRead
+extern __typeof (xmlParserInputBufferRead) xmlParserInputBufferRead__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputBufferRead xmlParserInputBufferRead__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlParserInputGrow
+extern __typeof (xmlParserInputGrow) xmlParserInputGrow __attribute((alias("xmlParserInputGrow__internal_alias")));
+#else
+#ifndef xmlParserInputGrow
+extern __typeof (xmlParserInputGrow) xmlParserInputGrow__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputGrow xmlParserInputGrow__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlParserInputRead
+extern __typeof (xmlParserInputRead) xmlParserInputRead __attribute((alias("xmlParserInputRead__internal_alias")));
+#else
+#ifndef xmlParserInputRead
+extern __typeof (xmlParserInputRead) xmlParserInputRead__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputRead xmlParserInputRead__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlParserInputShrink
+extern __typeof (xmlParserInputShrink) xmlParserInputShrink __attribute((alias("xmlParserInputShrink__internal_alias")));
+#else
+#ifndef xmlParserInputShrink
+extern __typeof (xmlParserInputShrink) xmlParserInputShrink__internal_alias __attribute((visibility("hidden")));
+#define xmlParserInputShrink xmlParserInputShrink__internal_alias
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlParserPrintFileContext
+extern __typeof (xmlParserPrintFileContext) xmlParserPrintFileContext __attribute((alias("xmlParserPrintFileContext__internal_alias")));
+#else
+#ifndef xmlParserPrintFileContext
+extern __typeof (xmlParserPrintFileContext) xmlParserPrintFileContext__internal_alias __attribute((visibility("hidden")));
+#define xmlParserPrintFileContext xmlParserPrintFileContext__internal_alias
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlParserPrintFileInfo
+extern __typeof (xmlParserPrintFileInfo) xmlParserPrintFileInfo __attribute((alias("xmlParserPrintFileInfo__internal_alias")));
+#else
+#ifndef xmlParserPrintFileInfo
+extern __typeof (xmlParserPrintFileInfo) xmlParserPrintFileInfo__internal_alias __attribute((visibility("hidden")));
+#define xmlParserPrintFileInfo xmlParserPrintFileInfo__internal_alias
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlParserValidityError
+extern __typeof (xmlParserValidityError) xmlParserValidityError __attribute((alias("xmlParserValidityError__internal_alias")));
+#else
+#ifndef xmlParserValidityError
+extern __typeof (xmlParserValidityError) xmlParserValidityError__internal_alias __attribute((visibility("hidden")));
+#define xmlParserValidityError xmlParserValidityError__internal_alias
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlParserValidityWarning
+extern __typeof (xmlParserValidityWarning) xmlParserValidityWarning __attribute((alias("xmlParserValidityWarning__internal_alias")));
+#else
+#ifndef xmlParserValidityWarning
+extern __typeof (xmlParserValidityWarning) xmlParserValidityWarning__internal_alias __attribute((visibility("hidden")));
+#define xmlParserValidityWarning xmlParserValidityWarning__internal_alias
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlParserWarning
+extern __typeof (xmlParserWarning) xmlParserWarning __attribute((alias("xmlParserWarning__internal_alias")));
+#else
+#ifndef xmlParserWarning
+extern __typeof (xmlParserWarning) xmlParserWarning__internal_alias __attribute((visibility("hidden")));
+#define xmlParserWarning xmlParserWarning__internal_alias
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlPathToURI
+extern __typeof (xmlPathToURI) xmlPathToURI __attribute((alias("xmlPathToURI__internal_alias")));
+#else
+#ifndef xmlPathToURI
+extern __typeof (xmlPathToURI) xmlPathToURI__internal_alias __attribute((visibility("hidden")));
+#define xmlPathToURI xmlPathToURI__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlPatternFromRoot
+extern __typeof (xmlPatternFromRoot) xmlPatternFromRoot __attribute((alias("xmlPatternFromRoot__internal_alias")));
+#else
+#ifndef xmlPatternFromRoot
+extern __typeof (xmlPatternFromRoot) xmlPatternFromRoot__internal_alias __attribute((visibility("hidden")));
+#define xmlPatternFromRoot xmlPatternFromRoot__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlPatternGetStreamCtxt
+extern __typeof (xmlPatternGetStreamCtxt) xmlPatternGetStreamCtxt __attribute((alias("xmlPatternGetStreamCtxt__internal_alias")));
+#else
+#ifndef xmlPatternGetStreamCtxt
+extern __typeof (xmlPatternGetStreamCtxt) xmlPatternGetStreamCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlPatternGetStreamCtxt xmlPatternGetStreamCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlPatternMatch
+extern __typeof (xmlPatternMatch) xmlPatternMatch __attribute((alias("xmlPatternMatch__internal_alias")));
+#else
+#ifndef xmlPatternMatch
+extern __typeof (xmlPatternMatch) xmlPatternMatch__internal_alias __attribute((visibility("hidden")));
+#define xmlPatternMatch xmlPatternMatch__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlPatternMaxDepth
+extern __typeof (xmlPatternMaxDepth) xmlPatternMaxDepth __attribute((alias("xmlPatternMaxDepth__internal_alias")));
+#else
+#ifndef xmlPatternMaxDepth
+extern __typeof (xmlPatternMaxDepth) xmlPatternMaxDepth__internal_alias __attribute((visibility("hidden")));
+#define xmlPatternMaxDepth xmlPatternMaxDepth__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlPatternMinDepth
+extern __typeof (xmlPatternMinDepth) xmlPatternMinDepth __attribute((alias("xmlPatternMinDepth__internal_alias")));
+#else
+#ifndef xmlPatternMinDepth
+extern __typeof (xmlPatternMinDepth) xmlPatternMinDepth__internal_alias __attribute((visibility("hidden")));
+#define xmlPatternMinDepth xmlPatternMinDepth__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlPatternStreamable
+extern __typeof (xmlPatternStreamable) xmlPatternStreamable __attribute((alias("xmlPatternStreamable__internal_alias")));
+#else
+#ifndef xmlPatternStreamable
+extern __typeof (xmlPatternStreamable) xmlPatternStreamable__internal_alias __attribute((visibility("hidden")));
+#define xmlPatternStreamable xmlPatternStreamable__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlPatterncompile
+extern __typeof (xmlPatterncompile) xmlPatterncompile __attribute((alias("xmlPatterncompile__internal_alias")));
+#else
+#ifndef xmlPatterncompile
+extern __typeof (xmlPatterncompile) xmlPatterncompile__internal_alias __attribute((visibility("hidden")));
+#define xmlPatterncompile xmlPatterncompile__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlPedanticParserDefault
+extern __typeof (xmlPedanticParserDefault) xmlPedanticParserDefault __attribute((alias("xmlPedanticParserDefault__internal_alias")));
+#else
+#ifndef xmlPedanticParserDefault
+extern __typeof (xmlPedanticParserDefault) xmlPedanticParserDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlPedanticParserDefault xmlPedanticParserDefault__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlPopInput
+extern __typeof (xmlPopInput) xmlPopInput __attribute((alias("xmlPopInput__internal_alias")));
+#else
+#ifndef xmlPopInput
+extern __typeof (xmlPopInput) xmlPopInput__internal_alias __attribute((visibility("hidden")));
+#define xmlPopInput xmlPopInput__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlPopInputCallbacks
+extern __typeof (xmlPopInputCallbacks) xmlPopInputCallbacks __attribute((alias("xmlPopInputCallbacks__internal_alias")));
+#else
+#ifndef xmlPopInputCallbacks
+extern __typeof (xmlPopInputCallbacks) xmlPopInputCallbacks__internal_alias __attribute((visibility("hidden")));
+#define xmlPopInputCallbacks xmlPopInputCallbacks__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlPreviousElementSibling
+extern __typeof (xmlPreviousElementSibling) xmlPreviousElementSibling __attribute((alias("xmlPreviousElementSibling__internal_alias")));
+#else
+#ifndef xmlPreviousElementSibling
+extern __typeof (xmlPreviousElementSibling) xmlPreviousElementSibling__internal_alias __attribute((visibility("hidden")));
+#define xmlPreviousElementSibling xmlPreviousElementSibling__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlPrintURI
+extern __typeof (xmlPrintURI) xmlPrintURI __attribute((alias("xmlPrintURI__internal_alias")));
+#else
+#ifndef xmlPrintURI
+extern __typeof (xmlPrintURI) xmlPrintURI__internal_alias __attribute((visibility("hidden")));
+#define xmlPrintURI xmlPrintURI__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlPushInput
+extern __typeof (xmlPushInput) xmlPushInput __attribute((alias("xmlPushInput__internal_alias")));
+#else
+#ifndef xmlPushInput
+extern __typeof (xmlPushInput) xmlPushInput__internal_alias __attribute((visibility("hidden")));
+#define xmlPushInput xmlPushInput__internal_alias
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlRMutexLock
+extern __typeof (xmlRMutexLock) xmlRMutexLock __attribute((alias("xmlRMutexLock__internal_alias")));
+#else
+#ifndef xmlRMutexLock
+extern __typeof (xmlRMutexLock) xmlRMutexLock__internal_alias __attribute((visibility("hidden")));
+#define xmlRMutexLock xmlRMutexLock__internal_alias
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlRMutexUnlock
+extern __typeof (xmlRMutexUnlock) xmlRMutexUnlock __attribute((alias("xmlRMutexUnlock__internal_alias")));
+#else
+#ifndef xmlRMutexUnlock
+extern __typeof (xmlRMutexUnlock) xmlRMutexUnlock__internal_alias __attribute((visibility("hidden")));
+#define xmlRMutexUnlock xmlRMutexUnlock__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlReadDoc
+extern __typeof (xmlReadDoc) xmlReadDoc __attribute((alias("xmlReadDoc__internal_alias")));
+#else
+#ifndef xmlReadDoc
+extern __typeof (xmlReadDoc) xmlReadDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlReadDoc xmlReadDoc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlReadFd
+extern __typeof (xmlReadFd) xmlReadFd __attribute((alias("xmlReadFd__internal_alias")));
+#else
+#ifndef xmlReadFd
+extern __typeof (xmlReadFd) xmlReadFd__internal_alias __attribute((visibility("hidden")));
+#define xmlReadFd xmlReadFd__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlReadFile
+extern __typeof (xmlReadFile) xmlReadFile __attribute((alias("xmlReadFile__internal_alias")));
+#else
+#ifndef xmlReadFile
+extern __typeof (xmlReadFile) xmlReadFile__internal_alias __attribute((visibility("hidden")));
+#define xmlReadFile xmlReadFile__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlReadIO
+extern __typeof (xmlReadIO) xmlReadIO __attribute((alias("xmlReadIO__internal_alias")));
+#else
+#ifndef xmlReadIO
+extern __typeof (xmlReadIO) xmlReadIO__internal_alias __attribute((visibility("hidden")));
+#define xmlReadIO xmlReadIO__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlReadMemory
+extern __typeof (xmlReadMemory) xmlReadMemory __attribute((alias("xmlReadMemory__internal_alias")));
+#else
+#ifndef xmlReadMemory
+extern __typeof (xmlReadMemory) xmlReadMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlReadMemory xmlReadMemory__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderForDoc
+extern __typeof (xmlReaderForDoc) xmlReaderForDoc __attribute((alias("xmlReaderForDoc__internal_alias")));
+#else
+#ifndef xmlReaderForDoc
+extern __typeof (xmlReaderForDoc) xmlReaderForDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderForDoc xmlReaderForDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderForFd
+extern __typeof (xmlReaderForFd) xmlReaderForFd __attribute((alias("xmlReaderForFd__internal_alias")));
+#else
+#ifndef xmlReaderForFd
+extern __typeof (xmlReaderForFd) xmlReaderForFd__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderForFd xmlReaderForFd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderForFile
+extern __typeof (xmlReaderForFile) xmlReaderForFile __attribute((alias("xmlReaderForFile__internal_alias")));
+#else
+#ifndef xmlReaderForFile
+extern __typeof (xmlReaderForFile) xmlReaderForFile__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderForFile xmlReaderForFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderForIO
+extern __typeof (xmlReaderForIO) xmlReaderForIO __attribute((alias("xmlReaderForIO__internal_alias")));
+#else
+#ifndef xmlReaderForIO
+extern __typeof (xmlReaderForIO) xmlReaderForIO__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderForIO xmlReaderForIO__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderForMemory
+extern __typeof (xmlReaderForMemory) xmlReaderForMemory __attribute((alias("xmlReaderForMemory__internal_alias")));
+#else
+#ifndef xmlReaderForMemory
+extern __typeof (xmlReaderForMemory) xmlReaderForMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderForMemory xmlReaderForMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderNewDoc
+extern __typeof (xmlReaderNewDoc) xmlReaderNewDoc __attribute((alias("xmlReaderNewDoc__internal_alias")));
+#else
+#ifndef xmlReaderNewDoc
+extern __typeof (xmlReaderNewDoc) xmlReaderNewDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderNewDoc xmlReaderNewDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderNewFd
+extern __typeof (xmlReaderNewFd) xmlReaderNewFd __attribute((alias("xmlReaderNewFd__internal_alias")));
+#else
+#ifndef xmlReaderNewFd
+extern __typeof (xmlReaderNewFd) xmlReaderNewFd__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderNewFd xmlReaderNewFd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderNewFile
+extern __typeof (xmlReaderNewFile) xmlReaderNewFile __attribute((alias("xmlReaderNewFile__internal_alias")));
+#else
+#ifndef xmlReaderNewFile
+extern __typeof (xmlReaderNewFile) xmlReaderNewFile__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderNewFile xmlReaderNewFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderNewIO
+extern __typeof (xmlReaderNewIO) xmlReaderNewIO __attribute((alias("xmlReaderNewIO__internal_alias")));
+#else
+#ifndef xmlReaderNewIO
+extern __typeof (xmlReaderNewIO) xmlReaderNewIO__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderNewIO xmlReaderNewIO__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderNewMemory
+extern __typeof (xmlReaderNewMemory) xmlReaderNewMemory __attribute((alias("xmlReaderNewMemory__internal_alias")));
+#else
+#ifndef xmlReaderNewMemory
+extern __typeof (xmlReaderNewMemory) xmlReaderNewMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderNewMemory xmlReaderNewMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderNewWalker
+extern __typeof (xmlReaderNewWalker) xmlReaderNewWalker __attribute((alias("xmlReaderNewWalker__internal_alias")));
+#else
+#ifndef xmlReaderNewWalker
+extern __typeof (xmlReaderNewWalker) xmlReaderNewWalker__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderNewWalker xmlReaderNewWalker__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlReaderWalker
+extern __typeof (xmlReaderWalker) xmlReaderWalker __attribute((alias("xmlReaderWalker__internal_alias")));
+#else
+#ifndef xmlReaderWalker
+extern __typeof (xmlReaderWalker) xmlReaderWalker__internal_alias __attribute((visibility("hidden")));
+#define xmlReaderWalker xmlReaderWalker__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlmemory
+#undef xmlReallocLoc
+extern __typeof (xmlReallocLoc) xmlReallocLoc __attribute((alias("xmlReallocLoc__internal_alias")));
+#else
+#ifndef xmlReallocLoc
+extern __typeof (xmlReallocLoc) xmlReallocLoc__internal_alias __attribute((visibility("hidden")));
+#define xmlReallocLoc xmlReallocLoc__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED)
+#ifdef bottom_tree
+#undef xmlReconciliateNs
+extern __typeof (xmlReconciliateNs) xmlReconciliateNs __attribute((alias("xmlReconciliateNs__internal_alias")));
+#else
+#ifndef xmlReconciliateNs
+extern __typeof (xmlReconciliateNs) xmlReconciliateNs__internal_alias __attribute((visibility("hidden")));
+#define xmlReconciliateNs xmlReconciliateNs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlRecoverDoc
+extern __typeof (xmlRecoverDoc) xmlRecoverDoc __attribute((alias("xmlRecoverDoc__internal_alias")));
+#else
+#ifndef xmlRecoverDoc
+extern __typeof (xmlRecoverDoc) xmlRecoverDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlRecoverDoc xmlRecoverDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlRecoverFile
+extern __typeof (xmlRecoverFile) xmlRecoverFile __attribute((alias("xmlRecoverFile__internal_alias")));
+#else
+#ifndef xmlRecoverFile
+extern __typeof (xmlRecoverFile) xmlRecoverFile__internal_alias __attribute((visibility("hidden")));
+#define xmlRecoverFile xmlRecoverFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlRecoverMemory
+extern __typeof (xmlRecoverMemory) xmlRecoverMemory __attribute((alias("xmlRecoverMemory__internal_alias")));
+#else
+#ifndef xmlRecoverMemory
+extern __typeof (xmlRecoverMemory) xmlRecoverMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlRecoverMemory xmlRecoverMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegExecErrInfo
+extern __typeof (xmlRegExecErrInfo) xmlRegExecErrInfo __attribute((alias("xmlRegExecErrInfo__internal_alias")));
+#else
+#ifndef xmlRegExecErrInfo
+extern __typeof (xmlRegExecErrInfo) xmlRegExecErrInfo__internal_alias __attribute((visibility("hidden")));
+#define xmlRegExecErrInfo xmlRegExecErrInfo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegExecNextValues
+extern __typeof (xmlRegExecNextValues) xmlRegExecNextValues __attribute((alias("xmlRegExecNextValues__internal_alias")));
+#else
+#ifndef xmlRegExecNextValues
+extern __typeof (xmlRegExecNextValues) xmlRegExecNextValues__internal_alias __attribute((visibility("hidden")));
+#define xmlRegExecNextValues xmlRegExecNextValues__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegExecPushString
+extern __typeof (xmlRegExecPushString) xmlRegExecPushString __attribute((alias("xmlRegExecPushString__internal_alias")));
+#else
+#ifndef xmlRegExecPushString
+extern __typeof (xmlRegExecPushString) xmlRegExecPushString__internal_alias __attribute((visibility("hidden")));
+#define xmlRegExecPushString xmlRegExecPushString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegExecPushString2
+extern __typeof (xmlRegExecPushString2) xmlRegExecPushString2 __attribute((alias("xmlRegExecPushString2__internal_alias")));
+#else
+#ifndef xmlRegExecPushString2
+extern __typeof (xmlRegExecPushString2) xmlRegExecPushString2__internal_alias __attribute((visibility("hidden")));
+#define xmlRegExecPushString2 xmlRegExecPushString2__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegFreeExecCtxt
+extern __typeof (xmlRegFreeExecCtxt) xmlRegFreeExecCtxt __attribute((alias("xmlRegFreeExecCtxt__internal_alias")));
+#else
+#ifndef xmlRegFreeExecCtxt
+extern __typeof (xmlRegFreeExecCtxt) xmlRegFreeExecCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlRegFreeExecCtxt xmlRegFreeExecCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegFreeRegexp
+extern __typeof (xmlRegFreeRegexp) xmlRegFreeRegexp __attribute((alias("xmlRegFreeRegexp__internal_alias")));
+#else
+#ifndef xmlRegFreeRegexp
+extern __typeof (xmlRegFreeRegexp) xmlRegFreeRegexp__internal_alias __attribute((visibility("hidden")));
+#define xmlRegFreeRegexp xmlRegFreeRegexp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegNewExecCtxt
+extern __typeof (xmlRegNewExecCtxt) xmlRegNewExecCtxt __attribute((alias("xmlRegNewExecCtxt__internal_alias")));
+#else
+#ifndef xmlRegNewExecCtxt
+extern __typeof (xmlRegNewExecCtxt) xmlRegNewExecCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlRegNewExecCtxt xmlRegNewExecCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegexpCompile
+extern __typeof (xmlRegexpCompile) xmlRegexpCompile __attribute((alias("xmlRegexpCompile__internal_alias")));
+#else
+#ifndef xmlRegexpCompile
+extern __typeof (xmlRegexpCompile) xmlRegexpCompile__internal_alias __attribute((visibility("hidden")));
+#define xmlRegexpCompile xmlRegexpCompile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegexpExec
+extern __typeof (xmlRegexpExec) xmlRegexpExec __attribute((alias("xmlRegexpExec__internal_alias")));
+#else
+#ifndef xmlRegexpExec
+extern __typeof (xmlRegexpExec) xmlRegexpExec__internal_alias __attribute((visibility("hidden")));
+#define xmlRegexpExec xmlRegexpExec__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegexpIsDeterminist
+extern __typeof (xmlRegexpIsDeterminist) xmlRegexpIsDeterminist __attribute((alias("xmlRegexpIsDeterminist__internal_alias")));
+#else
+#ifndef xmlRegexpIsDeterminist
+extern __typeof (xmlRegexpIsDeterminist) xmlRegexpIsDeterminist__internal_alias __attribute((visibility("hidden")));
+#define xmlRegexpIsDeterminist xmlRegexpIsDeterminist__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_xmlregexp
+#undef xmlRegexpPrint
+extern __typeof (xmlRegexpPrint) xmlRegexpPrint __attribute((alias("xmlRegexpPrint__internal_alias")));
+#else
+#ifndef xmlRegexpPrint
+extern __typeof (xmlRegexpPrint) xmlRegexpPrint__internal_alias __attribute((visibility("hidden")));
+#define xmlRegexpPrint xmlRegexpPrint__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_encoding
+#undef xmlRegisterCharEncodingHandler
+extern __typeof (xmlRegisterCharEncodingHandler) xmlRegisterCharEncodingHandler __attribute((alias("xmlRegisterCharEncodingHandler__internal_alias")));
+#else
+#ifndef xmlRegisterCharEncodingHandler
+extern __typeof (xmlRegisterCharEncodingHandler) xmlRegisterCharEncodingHandler__internal_alias __attribute((visibility("hidden")));
+#define xmlRegisterCharEncodingHandler xmlRegisterCharEncodingHandler__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlRegisterDefaultInputCallbacks
+extern __typeof (xmlRegisterDefaultInputCallbacks) xmlRegisterDefaultInputCallbacks __attribute((alias("xmlRegisterDefaultInputCallbacks__internal_alias")));
+#else
+#ifndef xmlRegisterDefaultInputCallbacks
+extern __typeof (xmlRegisterDefaultInputCallbacks) xmlRegisterDefaultInputCallbacks__internal_alias __attribute((visibility("hidden")));
+#define xmlRegisterDefaultInputCallbacks xmlRegisterDefaultInputCallbacks__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlRegisterDefaultOutputCallbacks
+extern __typeof (xmlRegisterDefaultOutputCallbacks) xmlRegisterDefaultOutputCallbacks __attribute((alias("xmlRegisterDefaultOutputCallbacks__internal_alias")));
+#else
+#ifndef xmlRegisterDefaultOutputCallbacks
+extern __typeof (xmlRegisterDefaultOutputCallbacks) xmlRegisterDefaultOutputCallbacks__internal_alias __attribute((visibility("hidden")));
+#define xmlRegisterDefaultOutputCallbacks xmlRegisterDefaultOutputCallbacks__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED) && defined(LIBXML_HTTP_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlRegisterHTTPPostCallbacks
+extern __typeof (xmlRegisterHTTPPostCallbacks) xmlRegisterHTTPPostCallbacks __attribute((alias("xmlRegisterHTTPPostCallbacks__internal_alias")));
+#else
+#ifndef xmlRegisterHTTPPostCallbacks
+extern __typeof (xmlRegisterHTTPPostCallbacks) xmlRegisterHTTPPostCallbacks__internal_alias __attribute((visibility("hidden")));
+#define xmlRegisterHTTPPostCallbacks xmlRegisterHTTPPostCallbacks__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlRegisterInputCallbacks
+extern __typeof (xmlRegisterInputCallbacks) xmlRegisterInputCallbacks __attribute((alias("xmlRegisterInputCallbacks__internal_alias")));
+#else
+#ifndef xmlRegisterInputCallbacks
+extern __typeof (xmlRegisterInputCallbacks) xmlRegisterInputCallbacks__internal_alias __attribute((visibility("hidden")));
+#define xmlRegisterInputCallbacks xmlRegisterInputCallbacks__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlRegisterNodeDefault
+extern __typeof (xmlRegisterNodeDefault) xmlRegisterNodeDefault __attribute((alias("xmlRegisterNodeDefault__internal_alias")));
+#else
+#ifndef xmlRegisterNodeDefault
+extern __typeof (xmlRegisterNodeDefault) xmlRegisterNodeDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlRegisterNodeDefault xmlRegisterNodeDefault__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlIO
+#undef xmlRegisterOutputCallbacks
+extern __typeof (xmlRegisterOutputCallbacks) xmlRegisterOutputCallbacks __attribute((alias("xmlRegisterOutputCallbacks__internal_alias")));
+#else
+#ifndef xmlRegisterOutputCallbacks
+extern __typeof (xmlRegisterOutputCallbacks) xmlRegisterOutputCallbacks__internal_alias __attribute((visibility("hidden")));
+#define xmlRegisterOutputCallbacks xmlRegisterOutputCallbacks__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGCleanupTypes
+extern __typeof (xmlRelaxNGCleanupTypes) xmlRelaxNGCleanupTypes __attribute((alias("xmlRelaxNGCleanupTypes__internal_alias")));
+#else
+#ifndef xmlRelaxNGCleanupTypes
+extern __typeof (xmlRelaxNGCleanupTypes) xmlRelaxNGCleanupTypes__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGCleanupTypes xmlRelaxNGCleanupTypes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGDump
+extern __typeof (xmlRelaxNGDump) xmlRelaxNGDump __attribute((alias("xmlRelaxNGDump__internal_alias")));
+#else
+#ifndef xmlRelaxNGDump
+extern __typeof (xmlRelaxNGDump) xmlRelaxNGDump__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGDump xmlRelaxNGDump__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGDumpTree
+extern __typeof (xmlRelaxNGDumpTree) xmlRelaxNGDumpTree __attribute((alias("xmlRelaxNGDumpTree__internal_alias")));
+#else
+#ifndef xmlRelaxNGDumpTree
+extern __typeof (xmlRelaxNGDumpTree) xmlRelaxNGDumpTree__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGDumpTree xmlRelaxNGDumpTree__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGFree
+extern __typeof (xmlRelaxNGFree) xmlRelaxNGFree __attribute((alias("xmlRelaxNGFree__internal_alias")));
+#else
+#ifndef xmlRelaxNGFree
+extern __typeof (xmlRelaxNGFree) xmlRelaxNGFree__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGFree xmlRelaxNGFree__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGFreeParserCtxt
+extern __typeof (xmlRelaxNGFreeParserCtxt) xmlRelaxNGFreeParserCtxt __attribute((alias("xmlRelaxNGFreeParserCtxt__internal_alias")));
+#else
+#ifndef xmlRelaxNGFreeParserCtxt
+extern __typeof (xmlRelaxNGFreeParserCtxt) xmlRelaxNGFreeParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGFreeParserCtxt xmlRelaxNGFreeParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGFreeValidCtxt
+extern __typeof (xmlRelaxNGFreeValidCtxt) xmlRelaxNGFreeValidCtxt __attribute((alias("xmlRelaxNGFreeValidCtxt__internal_alias")));
+#else
+#ifndef xmlRelaxNGFreeValidCtxt
+extern __typeof (xmlRelaxNGFreeValidCtxt) xmlRelaxNGFreeValidCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGFreeValidCtxt xmlRelaxNGFreeValidCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGGetParserErrors
+extern __typeof (xmlRelaxNGGetParserErrors) xmlRelaxNGGetParserErrors __attribute((alias("xmlRelaxNGGetParserErrors__internal_alias")));
+#else
+#ifndef xmlRelaxNGGetParserErrors
+extern __typeof (xmlRelaxNGGetParserErrors) xmlRelaxNGGetParserErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGGetParserErrors xmlRelaxNGGetParserErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGGetValidErrors
+extern __typeof (xmlRelaxNGGetValidErrors) xmlRelaxNGGetValidErrors __attribute((alias("xmlRelaxNGGetValidErrors__internal_alias")));
+#else
+#ifndef xmlRelaxNGGetValidErrors
+extern __typeof (xmlRelaxNGGetValidErrors) xmlRelaxNGGetValidErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGGetValidErrors xmlRelaxNGGetValidErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGInitTypes
+extern __typeof (xmlRelaxNGInitTypes) xmlRelaxNGInitTypes __attribute((alias("xmlRelaxNGInitTypes__internal_alias")));
+#else
+#ifndef xmlRelaxNGInitTypes
+extern __typeof (xmlRelaxNGInitTypes) xmlRelaxNGInitTypes__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGInitTypes xmlRelaxNGInitTypes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGNewDocParserCtxt
+extern __typeof (xmlRelaxNGNewDocParserCtxt) xmlRelaxNGNewDocParserCtxt __attribute((alias("xmlRelaxNGNewDocParserCtxt__internal_alias")));
+#else
+#ifndef xmlRelaxNGNewDocParserCtxt
+extern __typeof (xmlRelaxNGNewDocParserCtxt) xmlRelaxNGNewDocParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGNewDocParserCtxt xmlRelaxNGNewDocParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGNewMemParserCtxt
+extern __typeof (xmlRelaxNGNewMemParserCtxt) xmlRelaxNGNewMemParserCtxt __attribute((alias("xmlRelaxNGNewMemParserCtxt__internal_alias")));
+#else
+#ifndef xmlRelaxNGNewMemParserCtxt
+extern __typeof (xmlRelaxNGNewMemParserCtxt) xmlRelaxNGNewMemParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGNewMemParserCtxt xmlRelaxNGNewMemParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGNewParserCtxt
+extern __typeof (xmlRelaxNGNewParserCtxt) xmlRelaxNGNewParserCtxt __attribute((alias("xmlRelaxNGNewParserCtxt__internal_alias")));
+#else
+#ifndef xmlRelaxNGNewParserCtxt
+extern __typeof (xmlRelaxNGNewParserCtxt) xmlRelaxNGNewParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGNewParserCtxt xmlRelaxNGNewParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGNewValidCtxt
+extern __typeof (xmlRelaxNGNewValidCtxt) xmlRelaxNGNewValidCtxt __attribute((alias("xmlRelaxNGNewValidCtxt__internal_alias")));
+#else
+#ifndef xmlRelaxNGNewValidCtxt
+extern __typeof (xmlRelaxNGNewValidCtxt) xmlRelaxNGNewValidCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGNewValidCtxt xmlRelaxNGNewValidCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGParse
+extern __typeof (xmlRelaxNGParse) xmlRelaxNGParse __attribute((alias("xmlRelaxNGParse__internal_alias")));
+#else
+#ifndef xmlRelaxNGParse
+extern __typeof (xmlRelaxNGParse) xmlRelaxNGParse__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGParse xmlRelaxNGParse__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGSetParserErrors
+extern __typeof (xmlRelaxNGSetParserErrors) xmlRelaxNGSetParserErrors __attribute((alias("xmlRelaxNGSetParserErrors__internal_alias")));
+#else
+#ifndef xmlRelaxNGSetParserErrors
+extern __typeof (xmlRelaxNGSetParserErrors) xmlRelaxNGSetParserErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGSetParserErrors xmlRelaxNGSetParserErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGSetParserStructuredErrors
+extern __typeof (xmlRelaxNGSetParserStructuredErrors) xmlRelaxNGSetParserStructuredErrors __attribute((alias("xmlRelaxNGSetParserStructuredErrors__internal_alias")));
+#else
+#ifndef xmlRelaxNGSetParserStructuredErrors
+extern __typeof (xmlRelaxNGSetParserStructuredErrors) xmlRelaxNGSetParserStructuredErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGSetParserStructuredErrors xmlRelaxNGSetParserStructuredErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGSetValidErrors
+extern __typeof (xmlRelaxNGSetValidErrors) xmlRelaxNGSetValidErrors __attribute((alias("xmlRelaxNGSetValidErrors__internal_alias")));
+#else
+#ifndef xmlRelaxNGSetValidErrors
+extern __typeof (xmlRelaxNGSetValidErrors) xmlRelaxNGSetValidErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGSetValidErrors xmlRelaxNGSetValidErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGSetValidStructuredErrors
+extern __typeof (xmlRelaxNGSetValidStructuredErrors) xmlRelaxNGSetValidStructuredErrors __attribute((alias("xmlRelaxNGSetValidStructuredErrors__internal_alias")));
+#else
+#ifndef xmlRelaxNGSetValidStructuredErrors
+extern __typeof (xmlRelaxNGSetValidStructuredErrors) xmlRelaxNGSetValidStructuredErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGSetValidStructuredErrors xmlRelaxNGSetValidStructuredErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGValidateDoc
+extern __typeof (xmlRelaxNGValidateDoc) xmlRelaxNGValidateDoc __attribute((alias("xmlRelaxNGValidateDoc__internal_alias")));
+#else
+#ifndef xmlRelaxNGValidateDoc
+extern __typeof (xmlRelaxNGValidateDoc) xmlRelaxNGValidateDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGValidateDoc xmlRelaxNGValidateDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGValidateFullElement
+extern __typeof (xmlRelaxNGValidateFullElement) xmlRelaxNGValidateFullElement __attribute((alias("xmlRelaxNGValidateFullElement__internal_alias")));
+#else
+#ifndef xmlRelaxNGValidateFullElement
+extern __typeof (xmlRelaxNGValidateFullElement) xmlRelaxNGValidateFullElement__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGValidateFullElement xmlRelaxNGValidateFullElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGValidatePopElement
+extern __typeof (xmlRelaxNGValidatePopElement) xmlRelaxNGValidatePopElement __attribute((alias("xmlRelaxNGValidatePopElement__internal_alias")));
+#else
+#ifndef xmlRelaxNGValidatePopElement
+extern __typeof (xmlRelaxNGValidatePopElement) xmlRelaxNGValidatePopElement__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGValidatePopElement xmlRelaxNGValidatePopElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGValidatePushCData
+extern __typeof (xmlRelaxNGValidatePushCData) xmlRelaxNGValidatePushCData __attribute((alias("xmlRelaxNGValidatePushCData__internal_alias")));
+#else
+#ifndef xmlRelaxNGValidatePushCData
+extern __typeof (xmlRelaxNGValidatePushCData) xmlRelaxNGValidatePushCData__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGValidatePushCData xmlRelaxNGValidatePushCData__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxNGValidatePushElement
+extern __typeof (xmlRelaxNGValidatePushElement) xmlRelaxNGValidatePushElement __attribute((alias("xmlRelaxNGValidatePushElement__internal_alias")));
+#else
+#ifndef xmlRelaxNGValidatePushElement
+extern __typeof (xmlRelaxNGValidatePushElement) xmlRelaxNGValidatePushElement__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxNGValidatePushElement xmlRelaxNGValidatePushElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_relaxng
+#undef xmlRelaxParserSetFlag
+extern __typeof (xmlRelaxParserSetFlag) xmlRelaxParserSetFlag __attribute((alias("xmlRelaxParserSetFlag__internal_alias")));
+#else
+#ifndef xmlRelaxParserSetFlag
+extern __typeof (xmlRelaxParserSetFlag) xmlRelaxParserSetFlag__internal_alias __attribute((visibility("hidden")));
+#define xmlRelaxParserSetFlag xmlRelaxParserSetFlag__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlRemoveID
+extern __typeof (xmlRemoveID) xmlRemoveID __attribute((alias("xmlRemoveID__internal_alias")));
+#else
+#ifndef xmlRemoveID
+extern __typeof (xmlRemoveID) xmlRemoveID__internal_alias __attribute((visibility("hidden")));
+#define xmlRemoveID xmlRemoveID__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlRemoveProp
+extern __typeof (xmlRemoveProp) xmlRemoveProp __attribute((alias("xmlRemoveProp__internal_alias")));
+#else
+#ifndef xmlRemoveProp
+extern __typeof (xmlRemoveProp) xmlRemoveProp__internal_alias __attribute((visibility("hidden")));
+#define xmlRemoveProp xmlRemoveProp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlRemoveRef
+extern __typeof (xmlRemoveRef) xmlRemoveRef __attribute((alias("xmlRemoveRef__internal_alias")));
+#else
+#ifndef xmlRemoveRef
+extern __typeof (xmlRemoveRef) xmlRemoveRef__internal_alias __attribute((visibility("hidden")));
+#define xmlRemoveRef xmlRemoveRef__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_tree
+#undef xmlReplaceNode
+extern __typeof (xmlReplaceNode) xmlReplaceNode __attribute((alias("xmlReplaceNode__internal_alias")));
+#else
+#ifndef xmlReplaceNode
+extern __typeof (xmlReplaceNode) xmlReplaceNode__internal_alias __attribute((visibility("hidden")));
+#define xmlReplaceNode xmlReplaceNode__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlResetError
+extern __typeof (xmlResetError) xmlResetError __attribute((alias("xmlResetError__internal_alias")));
+#else
+#ifndef xmlResetError
+extern __typeof (xmlResetError) xmlResetError__internal_alias __attribute((visibility("hidden")));
+#define xmlResetError xmlResetError__internal_alias
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlResetLastError
+extern __typeof (xmlResetLastError) xmlResetLastError __attribute((alias("xmlResetLastError__internal_alias")));
+#else
+#ifndef xmlResetLastError
+extern __typeof (xmlResetLastError) xmlResetLastError__internal_alias __attribute((visibility("hidden")));
+#define xmlResetLastError xmlResetLastError__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2AttributeDecl
+extern __typeof (xmlSAX2AttributeDecl) xmlSAX2AttributeDecl __attribute((alias("xmlSAX2AttributeDecl__internal_alias")));
+#else
+#ifndef xmlSAX2AttributeDecl
+extern __typeof (xmlSAX2AttributeDecl) xmlSAX2AttributeDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2AttributeDecl xmlSAX2AttributeDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2CDataBlock
+extern __typeof (xmlSAX2CDataBlock) xmlSAX2CDataBlock __attribute((alias("xmlSAX2CDataBlock__internal_alias")));
+#else
+#ifndef xmlSAX2CDataBlock
+extern __typeof (xmlSAX2CDataBlock) xmlSAX2CDataBlock__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2CDataBlock xmlSAX2CDataBlock__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2Characters
+extern __typeof (xmlSAX2Characters) xmlSAX2Characters __attribute((alias("xmlSAX2Characters__internal_alias")));
+#else
+#ifndef xmlSAX2Characters
+extern __typeof (xmlSAX2Characters) xmlSAX2Characters__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2Characters xmlSAX2Characters__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2Comment
+extern __typeof (xmlSAX2Comment) xmlSAX2Comment __attribute((alias("xmlSAX2Comment__internal_alias")));
+#else
+#ifndef xmlSAX2Comment
+extern __typeof (xmlSAX2Comment) xmlSAX2Comment__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2Comment xmlSAX2Comment__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2ElementDecl
+extern __typeof (xmlSAX2ElementDecl) xmlSAX2ElementDecl __attribute((alias("xmlSAX2ElementDecl__internal_alias")));
+#else
+#ifndef xmlSAX2ElementDecl
+extern __typeof (xmlSAX2ElementDecl) xmlSAX2ElementDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2ElementDecl xmlSAX2ElementDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2EndDocument
+extern __typeof (xmlSAX2EndDocument) xmlSAX2EndDocument __attribute((alias("xmlSAX2EndDocument__internal_alias")));
+#else
+#ifndef xmlSAX2EndDocument
+extern __typeof (xmlSAX2EndDocument) xmlSAX2EndDocument__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2EndDocument xmlSAX2EndDocument__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_SAX2
+#undef xmlSAX2EndElement
+extern __typeof (xmlSAX2EndElement) xmlSAX2EndElement __attribute((alias("xmlSAX2EndElement__internal_alias")));
+#else
+#ifndef xmlSAX2EndElement
+extern __typeof (xmlSAX2EndElement) xmlSAX2EndElement__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2EndElement xmlSAX2EndElement__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2EndElementNs
+extern __typeof (xmlSAX2EndElementNs) xmlSAX2EndElementNs __attribute((alias("xmlSAX2EndElementNs__internal_alias")));
+#else
+#ifndef xmlSAX2EndElementNs
+extern __typeof (xmlSAX2EndElementNs) xmlSAX2EndElementNs__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2EndElementNs xmlSAX2EndElementNs__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2EntityDecl
+extern __typeof (xmlSAX2EntityDecl) xmlSAX2EntityDecl __attribute((alias("xmlSAX2EntityDecl__internal_alias")));
+#else
+#ifndef xmlSAX2EntityDecl
+extern __typeof (xmlSAX2EntityDecl) xmlSAX2EntityDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2EntityDecl xmlSAX2EntityDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2ExternalSubset
+extern __typeof (xmlSAX2ExternalSubset) xmlSAX2ExternalSubset __attribute((alias("xmlSAX2ExternalSubset__internal_alias")));
+#else
+#ifndef xmlSAX2ExternalSubset
+extern __typeof (xmlSAX2ExternalSubset) xmlSAX2ExternalSubset__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2ExternalSubset xmlSAX2ExternalSubset__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2GetColumnNumber
+extern __typeof (xmlSAX2GetColumnNumber) xmlSAX2GetColumnNumber __attribute((alias("xmlSAX2GetColumnNumber__internal_alias")));
+#else
+#ifndef xmlSAX2GetColumnNumber
+extern __typeof (xmlSAX2GetColumnNumber) xmlSAX2GetColumnNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2GetColumnNumber xmlSAX2GetColumnNumber__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2GetEntity
+extern __typeof (xmlSAX2GetEntity) xmlSAX2GetEntity __attribute((alias("xmlSAX2GetEntity__internal_alias")));
+#else
+#ifndef xmlSAX2GetEntity
+extern __typeof (xmlSAX2GetEntity) xmlSAX2GetEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2GetEntity xmlSAX2GetEntity__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2GetLineNumber
+extern __typeof (xmlSAX2GetLineNumber) xmlSAX2GetLineNumber __attribute((alias("xmlSAX2GetLineNumber__internal_alias")));
+#else
+#ifndef xmlSAX2GetLineNumber
+extern __typeof (xmlSAX2GetLineNumber) xmlSAX2GetLineNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2GetLineNumber xmlSAX2GetLineNumber__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2GetParameterEntity
+extern __typeof (xmlSAX2GetParameterEntity) xmlSAX2GetParameterEntity __attribute((alias("xmlSAX2GetParameterEntity__internal_alias")));
+#else
+#ifndef xmlSAX2GetParameterEntity
+extern __typeof (xmlSAX2GetParameterEntity) xmlSAX2GetParameterEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2GetParameterEntity xmlSAX2GetParameterEntity__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2GetPublicId
+extern __typeof (xmlSAX2GetPublicId) xmlSAX2GetPublicId __attribute((alias("xmlSAX2GetPublicId__internal_alias")));
+#else
+#ifndef xmlSAX2GetPublicId
+extern __typeof (xmlSAX2GetPublicId) xmlSAX2GetPublicId__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2GetPublicId xmlSAX2GetPublicId__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2GetSystemId
+extern __typeof (xmlSAX2GetSystemId) xmlSAX2GetSystemId __attribute((alias("xmlSAX2GetSystemId__internal_alias")));
+#else
+#ifndef xmlSAX2GetSystemId
+extern __typeof (xmlSAX2GetSystemId) xmlSAX2GetSystemId__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2GetSystemId xmlSAX2GetSystemId__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2HasExternalSubset
+extern __typeof (xmlSAX2HasExternalSubset) xmlSAX2HasExternalSubset __attribute((alias("xmlSAX2HasExternalSubset__internal_alias")));
+#else
+#ifndef xmlSAX2HasExternalSubset
+extern __typeof (xmlSAX2HasExternalSubset) xmlSAX2HasExternalSubset__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2HasExternalSubset xmlSAX2HasExternalSubset__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2HasInternalSubset
+extern __typeof (xmlSAX2HasInternalSubset) xmlSAX2HasInternalSubset __attribute((alias("xmlSAX2HasInternalSubset__internal_alias")));
+#else
+#ifndef xmlSAX2HasInternalSubset
+extern __typeof (xmlSAX2HasInternalSubset) xmlSAX2HasInternalSubset__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2HasInternalSubset xmlSAX2HasInternalSubset__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2IgnorableWhitespace
+extern __typeof (xmlSAX2IgnorableWhitespace) xmlSAX2IgnorableWhitespace __attribute((alias("xmlSAX2IgnorableWhitespace__internal_alias")));
+#else
+#ifndef xmlSAX2IgnorableWhitespace
+extern __typeof (xmlSAX2IgnorableWhitespace) xmlSAX2IgnorableWhitespace__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2IgnorableWhitespace xmlSAX2IgnorableWhitespace__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2InitDefaultSAXHandler
+extern __typeof (xmlSAX2InitDefaultSAXHandler) xmlSAX2InitDefaultSAXHandler __attribute((alias("xmlSAX2InitDefaultSAXHandler__internal_alias")));
+#else
+#ifndef xmlSAX2InitDefaultSAXHandler
+extern __typeof (xmlSAX2InitDefaultSAXHandler) xmlSAX2InitDefaultSAXHandler__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2InitDefaultSAXHandler xmlSAX2InitDefaultSAXHandler__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_DOCB_ENABLED)
+#ifdef bottom_SAX2
+#undef xmlSAX2InitDocbDefaultSAXHandler
+extern __typeof (xmlSAX2InitDocbDefaultSAXHandler) xmlSAX2InitDocbDefaultSAXHandler __attribute((alias("xmlSAX2InitDocbDefaultSAXHandler__internal_alias")));
+#else
+#ifndef xmlSAX2InitDocbDefaultSAXHandler
+extern __typeof (xmlSAX2InitDocbDefaultSAXHandler) xmlSAX2InitDocbDefaultSAXHandler__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2InitDocbDefaultSAXHandler xmlSAX2InitDocbDefaultSAXHandler__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_SAX2
+#undef xmlSAX2InitHtmlDefaultSAXHandler
+extern __typeof (xmlSAX2InitHtmlDefaultSAXHandler) xmlSAX2InitHtmlDefaultSAXHandler __attribute((alias("xmlSAX2InitHtmlDefaultSAXHandler__internal_alias")));
+#else
+#ifndef xmlSAX2InitHtmlDefaultSAXHandler
+extern __typeof (xmlSAX2InitHtmlDefaultSAXHandler) xmlSAX2InitHtmlDefaultSAXHandler__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2InitHtmlDefaultSAXHandler xmlSAX2InitHtmlDefaultSAXHandler__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2InternalSubset
+extern __typeof (xmlSAX2InternalSubset) xmlSAX2InternalSubset __attribute((alias("xmlSAX2InternalSubset__internal_alias")));
+#else
+#ifndef xmlSAX2InternalSubset
+extern __typeof (xmlSAX2InternalSubset) xmlSAX2InternalSubset__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2InternalSubset xmlSAX2InternalSubset__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2IsStandalone
+extern __typeof (xmlSAX2IsStandalone) xmlSAX2IsStandalone __attribute((alias("xmlSAX2IsStandalone__internal_alias")));
+#else
+#ifndef xmlSAX2IsStandalone
+extern __typeof (xmlSAX2IsStandalone) xmlSAX2IsStandalone__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2IsStandalone xmlSAX2IsStandalone__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2NotationDecl
+extern __typeof (xmlSAX2NotationDecl) xmlSAX2NotationDecl __attribute((alias("xmlSAX2NotationDecl__internal_alias")));
+#else
+#ifndef xmlSAX2NotationDecl
+extern __typeof (xmlSAX2NotationDecl) xmlSAX2NotationDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2NotationDecl xmlSAX2NotationDecl__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2ProcessingInstruction
+extern __typeof (xmlSAX2ProcessingInstruction) xmlSAX2ProcessingInstruction __attribute((alias("xmlSAX2ProcessingInstruction__internal_alias")));
+#else
+#ifndef xmlSAX2ProcessingInstruction
+extern __typeof (xmlSAX2ProcessingInstruction) xmlSAX2ProcessingInstruction__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2ProcessingInstruction xmlSAX2ProcessingInstruction__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2Reference
+extern __typeof (xmlSAX2Reference) xmlSAX2Reference __attribute((alias("xmlSAX2Reference__internal_alias")));
+#else
+#ifndef xmlSAX2Reference
+extern __typeof (xmlSAX2Reference) xmlSAX2Reference__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2Reference xmlSAX2Reference__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2ResolveEntity
+extern __typeof (xmlSAX2ResolveEntity) xmlSAX2ResolveEntity __attribute((alias("xmlSAX2ResolveEntity__internal_alias")));
+#else
+#ifndef xmlSAX2ResolveEntity
+extern __typeof (xmlSAX2ResolveEntity) xmlSAX2ResolveEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2ResolveEntity xmlSAX2ResolveEntity__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2SetDocumentLocator
+extern __typeof (xmlSAX2SetDocumentLocator) xmlSAX2SetDocumentLocator __attribute((alias("xmlSAX2SetDocumentLocator__internal_alias")));
+#else
+#ifndef xmlSAX2SetDocumentLocator
+extern __typeof (xmlSAX2SetDocumentLocator) xmlSAX2SetDocumentLocator__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2SetDocumentLocator xmlSAX2SetDocumentLocator__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2StartDocument
+extern __typeof (xmlSAX2StartDocument) xmlSAX2StartDocument __attribute((alias("xmlSAX2StartDocument__internal_alias")));
+#else
+#ifndef xmlSAX2StartDocument
+extern __typeof (xmlSAX2StartDocument) xmlSAX2StartDocument__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2StartDocument xmlSAX2StartDocument__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_SAX2
+#undef xmlSAX2StartElement
+extern __typeof (xmlSAX2StartElement) xmlSAX2StartElement __attribute((alias("xmlSAX2StartElement__internal_alias")));
+#else
+#ifndef xmlSAX2StartElement
+extern __typeof (xmlSAX2StartElement) xmlSAX2StartElement__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2StartElement xmlSAX2StartElement__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2StartElementNs
+extern __typeof (xmlSAX2StartElementNs) xmlSAX2StartElementNs __attribute((alias("xmlSAX2StartElementNs__internal_alias")));
+#else
+#ifndef xmlSAX2StartElementNs
+extern __typeof (xmlSAX2StartElementNs) xmlSAX2StartElementNs__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2StartElementNs xmlSAX2StartElementNs__internal_alias
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAX2UnparsedEntityDecl
+extern __typeof (xmlSAX2UnparsedEntityDecl) xmlSAX2UnparsedEntityDecl __attribute((alias("xmlSAX2UnparsedEntityDecl__internal_alias")));
+#else
+#ifndef xmlSAX2UnparsedEntityDecl
+extern __typeof (xmlSAX2UnparsedEntityDecl) xmlSAX2UnparsedEntityDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlSAX2UnparsedEntityDecl xmlSAX2UnparsedEntityDecl__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_SAX2
+#undef xmlSAXDefaultVersion
+extern __typeof (xmlSAXDefaultVersion) xmlSAXDefaultVersion __attribute((alias("xmlSAXDefaultVersion__internal_alias")));
+#else
+#ifndef xmlSAXDefaultVersion
+extern __typeof (xmlSAXDefaultVersion) xmlSAXDefaultVersion__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXDefaultVersion xmlSAXDefaultVersion__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_parser
+#undef xmlSAXParseDTD
+extern __typeof (xmlSAXParseDTD) xmlSAXParseDTD __attribute((alias("xmlSAXParseDTD__internal_alias")));
+#else
+#ifndef xmlSAXParseDTD
+extern __typeof (xmlSAXParseDTD) xmlSAXParseDTD__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXParseDTD xmlSAXParseDTD__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlSAXParseDoc
+extern __typeof (xmlSAXParseDoc) xmlSAXParseDoc __attribute((alias("xmlSAXParseDoc__internal_alias")));
+#else
+#ifndef xmlSAXParseDoc
+extern __typeof (xmlSAXParseDoc) xmlSAXParseDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXParseDoc xmlSAXParseDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlSAXParseEntity
+extern __typeof (xmlSAXParseEntity) xmlSAXParseEntity __attribute((alias("xmlSAXParseEntity__internal_alias")));
+#else
+#ifndef xmlSAXParseEntity
+extern __typeof (xmlSAXParseEntity) xmlSAXParseEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXParseEntity xmlSAXParseEntity__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlSAXParseFile
+extern __typeof (xmlSAXParseFile) xmlSAXParseFile __attribute((alias("xmlSAXParseFile__internal_alias")));
+#else
+#ifndef xmlSAXParseFile
+extern __typeof (xmlSAXParseFile) xmlSAXParseFile__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXParseFile xmlSAXParseFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlSAXParseFileWithData
+extern __typeof (xmlSAXParseFileWithData) xmlSAXParseFileWithData __attribute((alias("xmlSAXParseFileWithData__internal_alias")));
+#else
+#ifndef xmlSAXParseFileWithData
+extern __typeof (xmlSAXParseFileWithData) xmlSAXParseFileWithData__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXParseFileWithData xmlSAXParseFileWithData__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlSAXParseMemory
+extern __typeof (xmlSAXParseMemory) xmlSAXParseMemory __attribute((alias("xmlSAXParseMemory__internal_alias")));
+#else
+#ifndef xmlSAXParseMemory
+extern __typeof (xmlSAXParseMemory) xmlSAXParseMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXParseMemory xmlSAXParseMemory__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlSAXParseMemoryWithData
+extern __typeof (xmlSAXParseMemoryWithData) xmlSAXParseMemoryWithData __attribute((alias("xmlSAXParseMemoryWithData__internal_alias")));
+#else
+#ifndef xmlSAXParseMemoryWithData
+extern __typeof (xmlSAXParseMemoryWithData) xmlSAXParseMemoryWithData__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXParseMemoryWithData xmlSAXParseMemoryWithData__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlSAXUserParseFile
+extern __typeof (xmlSAXUserParseFile) xmlSAXUserParseFile __attribute((alias("xmlSAXUserParseFile__internal_alias")));
+#else
+#ifndef xmlSAXUserParseFile
+extern __typeof (xmlSAXUserParseFile) xmlSAXUserParseFile__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXUserParseFile xmlSAXUserParseFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlSAXUserParseMemory
+extern __typeof (xmlSAXUserParseMemory) xmlSAXUserParseMemory __attribute((alias("xmlSAXUserParseMemory__internal_alias")));
+#else
+#ifndef xmlSAXUserParseMemory
+extern __typeof (xmlSAXUserParseMemory) xmlSAXUserParseMemory__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXUserParseMemory xmlSAXUserParseMemory__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_SAX2
+#undef xmlSAXVersion
+extern __typeof (xmlSAXVersion) xmlSAXVersion __attribute((alias("xmlSAXVersion__internal_alias")));
+#else
+#ifndef xmlSAXVersion
+extern __typeof (xmlSAXVersion) xmlSAXVersion__internal_alias __attribute((visibility("hidden")));
+#define xmlSAXVersion xmlSAXVersion__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveClose
+extern __typeof (xmlSaveClose) xmlSaveClose __attribute((alias("xmlSaveClose__internal_alias")));
+#else
+#ifndef xmlSaveClose
+extern __typeof (xmlSaveClose) xmlSaveClose__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveClose xmlSaveClose__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveDoc
+extern __typeof (xmlSaveDoc) xmlSaveDoc __attribute((alias("xmlSaveDoc__internal_alias")));
+#else
+#ifndef xmlSaveDoc
+extern __typeof (xmlSaveDoc) xmlSaveDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveDoc xmlSaveDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveFile
+extern __typeof (xmlSaveFile) xmlSaveFile __attribute((alias("xmlSaveFile__internal_alias")));
+#else
+#ifndef xmlSaveFile
+extern __typeof (xmlSaveFile) xmlSaveFile__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveFile xmlSaveFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveFileEnc
+extern __typeof (xmlSaveFileEnc) xmlSaveFileEnc __attribute((alias("xmlSaveFileEnc__internal_alias")));
+#else
+#ifndef xmlSaveFileEnc
+extern __typeof (xmlSaveFileEnc) xmlSaveFileEnc__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveFileEnc xmlSaveFileEnc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveFileTo
+extern __typeof (xmlSaveFileTo) xmlSaveFileTo __attribute((alias("xmlSaveFileTo__internal_alias")));
+#else
+#ifndef xmlSaveFileTo
+extern __typeof (xmlSaveFileTo) xmlSaveFileTo__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveFileTo xmlSaveFileTo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveFlush
+extern __typeof (xmlSaveFlush) xmlSaveFlush __attribute((alias("xmlSaveFlush__internal_alias")));
+#else
+#ifndef xmlSaveFlush
+extern __typeof (xmlSaveFlush) xmlSaveFlush__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveFlush xmlSaveFlush__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveFormatFile
+extern __typeof (xmlSaveFormatFile) xmlSaveFormatFile __attribute((alias("xmlSaveFormatFile__internal_alias")));
+#else
+#ifndef xmlSaveFormatFile
+extern __typeof (xmlSaveFormatFile) xmlSaveFormatFile__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveFormatFile xmlSaveFormatFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveFormatFileEnc
+extern __typeof (xmlSaveFormatFileEnc) xmlSaveFormatFileEnc __attribute((alias("xmlSaveFormatFileEnc__internal_alias")));
+#else
+#ifndef xmlSaveFormatFileEnc
+extern __typeof (xmlSaveFormatFileEnc) xmlSaveFormatFileEnc__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveFormatFileEnc xmlSaveFormatFileEnc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveFormatFileTo
+extern __typeof (xmlSaveFormatFileTo) xmlSaveFormatFileTo __attribute((alias("xmlSaveFormatFileTo__internal_alias")));
+#else
+#ifndef xmlSaveFormatFileTo
+extern __typeof (xmlSaveFormatFileTo) xmlSaveFormatFileTo__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveFormatFileTo xmlSaveFormatFileTo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveSetAttrEscape
+extern __typeof (xmlSaveSetAttrEscape) xmlSaveSetAttrEscape __attribute((alias("xmlSaveSetAttrEscape__internal_alias")));
+#else
+#ifndef xmlSaveSetAttrEscape
+extern __typeof (xmlSaveSetAttrEscape) xmlSaveSetAttrEscape__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveSetAttrEscape xmlSaveSetAttrEscape__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveSetEscape
+extern __typeof (xmlSaveSetEscape) xmlSaveSetEscape __attribute((alias("xmlSaveSetEscape__internal_alias")));
+#else
+#ifndef xmlSaveSetEscape
+extern __typeof (xmlSaveSetEscape) xmlSaveSetEscape__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveSetEscape xmlSaveSetEscape__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveToBuffer
+extern __typeof (xmlSaveToBuffer) xmlSaveToBuffer __attribute((alias("xmlSaveToBuffer__internal_alias")));
+#else
+#ifndef xmlSaveToBuffer
+extern __typeof (xmlSaveToBuffer) xmlSaveToBuffer__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveToBuffer xmlSaveToBuffer__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveToFd
+extern __typeof (xmlSaveToFd) xmlSaveToFd __attribute((alias("xmlSaveToFd__internal_alias")));
+#else
+#ifndef xmlSaveToFd
+extern __typeof (xmlSaveToFd) xmlSaveToFd__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveToFd xmlSaveToFd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveToFilename
+extern __typeof (xmlSaveToFilename) xmlSaveToFilename __attribute((alias("xmlSaveToFilename__internal_alias")));
+#else
+#ifndef xmlSaveToFilename
+extern __typeof (xmlSaveToFilename) xmlSaveToFilename__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveToFilename xmlSaveToFilename__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveToIO
+extern __typeof (xmlSaveToIO) xmlSaveToIO __attribute((alias("xmlSaveToIO__internal_alias")));
+#else
+#ifndef xmlSaveToIO
+extern __typeof (xmlSaveToIO) xmlSaveToIO__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveToIO xmlSaveToIO__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlsave
+#undef xmlSaveTree
+extern __typeof (xmlSaveTree) xmlSaveTree __attribute((alias("xmlSaveTree__internal_alias")));
+#else
+#ifndef xmlSaveTree
+extern __typeof (xmlSaveTree) xmlSaveTree__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveTree xmlSaveTree__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlSaveUri
+extern __typeof (xmlSaveUri) xmlSaveUri __attribute((alias("xmlSaveUri__internal_alias")));
+#else
+#ifndef xmlSaveUri
+extern __typeof (xmlSaveUri) xmlSaveUri__internal_alias __attribute((visibility("hidden")));
+#define xmlSaveUri xmlSaveUri__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlScanName
+extern __typeof (xmlScanName) xmlScanName __attribute((alias("xmlScanName__internal_alias")));
+#else
+#ifndef xmlScanName
+extern __typeof (xmlScanName) xmlScanName__internal_alias __attribute((visibility("hidden")));
+#define xmlScanName xmlScanName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaCheckFacet
+extern __typeof (xmlSchemaCheckFacet) xmlSchemaCheckFacet __attribute((alias("xmlSchemaCheckFacet__internal_alias")));
+#else
+#ifndef xmlSchemaCheckFacet
+extern __typeof (xmlSchemaCheckFacet) xmlSchemaCheckFacet__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaCheckFacet xmlSchemaCheckFacet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaCleanupTypes
+extern __typeof (xmlSchemaCleanupTypes) xmlSchemaCleanupTypes __attribute((alias("xmlSchemaCleanupTypes__internal_alias")));
+#else
+#ifndef xmlSchemaCleanupTypes
+extern __typeof (xmlSchemaCleanupTypes) xmlSchemaCleanupTypes__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaCleanupTypes xmlSchemaCleanupTypes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaCollapseString
+extern __typeof (xmlSchemaCollapseString) xmlSchemaCollapseString __attribute((alias("xmlSchemaCollapseString__internal_alias")));
+#else
+#ifndef xmlSchemaCollapseString
+extern __typeof (xmlSchemaCollapseString) xmlSchemaCollapseString__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaCollapseString xmlSchemaCollapseString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaCompareValues
+extern __typeof (xmlSchemaCompareValues) xmlSchemaCompareValues __attribute((alias("xmlSchemaCompareValues__internal_alias")));
+#else
+#ifndef xmlSchemaCompareValues
+extern __typeof (xmlSchemaCompareValues) xmlSchemaCompareValues__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaCompareValues xmlSchemaCompareValues__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaCompareValuesWhtsp
+extern __typeof (xmlSchemaCompareValuesWhtsp) xmlSchemaCompareValuesWhtsp __attribute((alias("xmlSchemaCompareValuesWhtsp__internal_alias")));
+#else
+#ifndef xmlSchemaCompareValuesWhtsp
+extern __typeof (xmlSchemaCompareValuesWhtsp) xmlSchemaCompareValuesWhtsp__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaCompareValuesWhtsp xmlSchemaCompareValuesWhtsp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaCopyValue
+extern __typeof (xmlSchemaCopyValue) xmlSchemaCopyValue __attribute((alias("xmlSchemaCopyValue__internal_alias")));
+#else
+#ifndef xmlSchemaCopyValue
+extern __typeof (xmlSchemaCopyValue) xmlSchemaCopyValue__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaCopyValue xmlSchemaCopyValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaDump
+extern __typeof (xmlSchemaDump) xmlSchemaDump __attribute((alias("xmlSchemaDump__internal_alias")));
+#else
+#ifndef xmlSchemaDump
+extern __typeof (xmlSchemaDump) xmlSchemaDump__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaDump xmlSchemaDump__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaFree
+extern __typeof (xmlSchemaFree) xmlSchemaFree __attribute((alias("xmlSchemaFree__internal_alias")));
+#else
+#ifndef xmlSchemaFree
+extern __typeof (xmlSchemaFree) xmlSchemaFree__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaFree xmlSchemaFree__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaFreeFacet
+extern __typeof (xmlSchemaFreeFacet) xmlSchemaFreeFacet __attribute((alias("xmlSchemaFreeFacet__internal_alias")));
+#else
+#ifndef xmlSchemaFreeFacet
+extern __typeof (xmlSchemaFreeFacet) xmlSchemaFreeFacet__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaFreeFacet xmlSchemaFreeFacet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaFreeParserCtxt
+extern __typeof (xmlSchemaFreeParserCtxt) xmlSchemaFreeParserCtxt __attribute((alias("xmlSchemaFreeParserCtxt__internal_alias")));
+#else
+#ifndef xmlSchemaFreeParserCtxt
+extern __typeof (xmlSchemaFreeParserCtxt) xmlSchemaFreeParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaFreeParserCtxt xmlSchemaFreeParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaFreeType
+extern __typeof (xmlSchemaFreeType) xmlSchemaFreeType __attribute((alias("xmlSchemaFreeType__internal_alias")));
+#else
+#ifndef xmlSchemaFreeType
+extern __typeof (xmlSchemaFreeType) xmlSchemaFreeType__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaFreeType xmlSchemaFreeType__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaFreeValidCtxt
+extern __typeof (xmlSchemaFreeValidCtxt) xmlSchemaFreeValidCtxt __attribute((alias("xmlSchemaFreeValidCtxt__internal_alias")));
+#else
+#ifndef xmlSchemaFreeValidCtxt
+extern __typeof (xmlSchemaFreeValidCtxt) xmlSchemaFreeValidCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaFreeValidCtxt xmlSchemaFreeValidCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaFreeValue
+extern __typeof (xmlSchemaFreeValue) xmlSchemaFreeValue __attribute((alias("xmlSchemaFreeValue__internal_alias")));
+#else
+#ifndef xmlSchemaFreeValue
+extern __typeof (xmlSchemaFreeValue) xmlSchemaFreeValue__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaFreeValue xmlSchemaFreeValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaFreeWildcard
+extern __typeof (xmlSchemaFreeWildcard) xmlSchemaFreeWildcard __attribute((alias("xmlSchemaFreeWildcard__internal_alias")));
+#else
+#ifndef xmlSchemaFreeWildcard
+extern __typeof (xmlSchemaFreeWildcard) xmlSchemaFreeWildcard__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaFreeWildcard xmlSchemaFreeWildcard__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaGetBuiltInListSimpleTypeItemType
+extern __typeof (xmlSchemaGetBuiltInListSimpleTypeItemType) xmlSchemaGetBuiltInListSimpleTypeItemType __attribute((alias("xmlSchemaGetBuiltInListSimpleTypeItemType__internal_alias")));
+#else
+#ifndef xmlSchemaGetBuiltInListSimpleTypeItemType
+extern __typeof (xmlSchemaGetBuiltInListSimpleTypeItemType) xmlSchemaGetBuiltInListSimpleTypeItemType__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaGetBuiltInListSimpleTypeItemType xmlSchemaGetBuiltInListSimpleTypeItemType__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaGetBuiltInType
+extern __typeof (xmlSchemaGetBuiltInType) xmlSchemaGetBuiltInType __attribute((alias("xmlSchemaGetBuiltInType__internal_alias")));
+#else
+#ifndef xmlSchemaGetBuiltInType
+extern __typeof (xmlSchemaGetBuiltInType) xmlSchemaGetBuiltInType__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaGetBuiltInType xmlSchemaGetBuiltInType__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaGetCanonValue
+extern __typeof (xmlSchemaGetCanonValue) xmlSchemaGetCanonValue __attribute((alias("xmlSchemaGetCanonValue__internal_alias")));
+#else
+#ifndef xmlSchemaGetCanonValue
+extern __typeof (xmlSchemaGetCanonValue) xmlSchemaGetCanonValue__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaGetCanonValue xmlSchemaGetCanonValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaGetCanonValueWhtsp
+extern __typeof (xmlSchemaGetCanonValueWhtsp) xmlSchemaGetCanonValueWhtsp __attribute((alias("xmlSchemaGetCanonValueWhtsp__internal_alias")));
+#else
+#ifndef xmlSchemaGetCanonValueWhtsp
+extern __typeof (xmlSchemaGetCanonValueWhtsp) xmlSchemaGetCanonValueWhtsp__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaGetCanonValueWhtsp xmlSchemaGetCanonValueWhtsp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaGetFacetValueAsULong
+extern __typeof (xmlSchemaGetFacetValueAsULong) xmlSchemaGetFacetValueAsULong __attribute((alias("xmlSchemaGetFacetValueAsULong__internal_alias")));
+#else
+#ifndef xmlSchemaGetFacetValueAsULong
+extern __typeof (xmlSchemaGetFacetValueAsULong) xmlSchemaGetFacetValueAsULong__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaGetFacetValueAsULong xmlSchemaGetFacetValueAsULong__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaGetParserErrors
+extern __typeof (xmlSchemaGetParserErrors) xmlSchemaGetParserErrors __attribute((alias("xmlSchemaGetParserErrors__internal_alias")));
+#else
+#ifndef xmlSchemaGetParserErrors
+extern __typeof (xmlSchemaGetParserErrors) xmlSchemaGetParserErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaGetParserErrors xmlSchemaGetParserErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaGetPredefinedType
+extern __typeof (xmlSchemaGetPredefinedType) xmlSchemaGetPredefinedType __attribute((alias("xmlSchemaGetPredefinedType__internal_alias")));
+#else
+#ifndef xmlSchemaGetPredefinedType
+extern __typeof (xmlSchemaGetPredefinedType) xmlSchemaGetPredefinedType__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaGetPredefinedType xmlSchemaGetPredefinedType__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaGetValType
+extern __typeof (xmlSchemaGetValType) xmlSchemaGetValType __attribute((alias("xmlSchemaGetValType__internal_alias")));
+#else
+#ifndef xmlSchemaGetValType
+extern __typeof (xmlSchemaGetValType) xmlSchemaGetValType__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaGetValType xmlSchemaGetValType__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaGetValidErrors
+extern __typeof (xmlSchemaGetValidErrors) xmlSchemaGetValidErrors __attribute((alias("xmlSchemaGetValidErrors__internal_alias")));
+#else
+#ifndef xmlSchemaGetValidErrors
+extern __typeof (xmlSchemaGetValidErrors) xmlSchemaGetValidErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaGetValidErrors xmlSchemaGetValidErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaInitTypes
+extern __typeof (xmlSchemaInitTypes) xmlSchemaInitTypes __attribute((alias("xmlSchemaInitTypes__internal_alias")));
+#else
+#ifndef xmlSchemaInitTypes
+extern __typeof (xmlSchemaInitTypes) xmlSchemaInitTypes__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaInitTypes xmlSchemaInitTypes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaIsBuiltInTypeFacet
+extern __typeof (xmlSchemaIsBuiltInTypeFacet) xmlSchemaIsBuiltInTypeFacet __attribute((alias("xmlSchemaIsBuiltInTypeFacet__internal_alias")));
+#else
+#ifndef xmlSchemaIsBuiltInTypeFacet
+extern __typeof (xmlSchemaIsBuiltInTypeFacet) xmlSchemaIsBuiltInTypeFacet__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaIsBuiltInTypeFacet xmlSchemaIsBuiltInTypeFacet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaIsValid
+extern __typeof (xmlSchemaIsValid) xmlSchemaIsValid __attribute((alias("xmlSchemaIsValid__internal_alias")));
+#else
+#ifndef xmlSchemaIsValid
+extern __typeof (xmlSchemaIsValid) xmlSchemaIsValid__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaIsValid xmlSchemaIsValid__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaNewDocParserCtxt
+extern __typeof (xmlSchemaNewDocParserCtxt) xmlSchemaNewDocParserCtxt __attribute((alias("xmlSchemaNewDocParserCtxt__internal_alias")));
+#else
+#ifndef xmlSchemaNewDocParserCtxt
+extern __typeof (xmlSchemaNewDocParserCtxt) xmlSchemaNewDocParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaNewDocParserCtxt xmlSchemaNewDocParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaNewFacet
+extern __typeof (xmlSchemaNewFacet) xmlSchemaNewFacet __attribute((alias("xmlSchemaNewFacet__internal_alias")));
+#else
+#ifndef xmlSchemaNewFacet
+extern __typeof (xmlSchemaNewFacet) xmlSchemaNewFacet__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaNewFacet xmlSchemaNewFacet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaNewMemParserCtxt
+extern __typeof (xmlSchemaNewMemParserCtxt) xmlSchemaNewMemParserCtxt __attribute((alias("xmlSchemaNewMemParserCtxt__internal_alias")));
+#else
+#ifndef xmlSchemaNewMemParserCtxt
+extern __typeof (xmlSchemaNewMemParserCtxt) xmlSchemaNewMemParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaNewMemParserCtxt xmlSchemaNewMemParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaNewNOTATIONValue
+extern __typeof (xmlSchemaNewNOTATIONValue) xmlSchemaNewNOTATIONValue __attribute((alias("xmlSchemaNewNOTATIONValue__internal_alias")));
+#else
+#ifndef xmlSchemaNewNOTATIONValue
+extern __typeof (xmlSchemaNewNOTATIONValue) xmlSchemaNewNOTATIONValue__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaNewNOTATIONValue xmlSchemaNewNOTATIONValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaNewParserCtxt
+extern __typeof (xmlSchemaNewParserCtxt) xmlSchemaNewParserCtxt __attribute((alias("xmlSchemaNewParserCtxt__internal_alias")));
+#else
+#ifndef xmlSchemaNewParserCtxt
+extern __typeof (xmlSchemaNewParserCtxt) xmlSchemaNewParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaNewParserCtxt xmlSchemaNewParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaNewQNameValue
+extern __typeof (xmlSchemaNewQNameValue) xmlSchemaNewQNameValue __attribute((alias("xmlSchemaNewQNameValue__internal_alias")));
+#else
+#ifndef xmlSchemaNewQNameValue
+extern __typeof (xmlSchemaNewQNameValue) xmlSchemaNewQNameValue__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaNewQNameValue xmlSchemaNewQNameValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaNewStringValue
+extern __typeof (xmlSchemaNewStringValue) xmlSchemaNewStringValue __attribute((alias("xmlSchemaNewStringValue__internal_alias")));
+#else
+#ifndef xmlSchemaNewStringValue
+extern __typeof (xmlSchemaNewStringValue) xmlSchemaNewStringValue__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaNewStringValue xmlSchemaNewStringValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaNewValidCtxt
+extern __typeof (xmlSchemaNewValidCtxt) xmlSchemaNewValidCtxt __attribute((alias("xmlSchemaNewValidCtxt__internal_alias")));
+#else
+#ifndef xmlSchemaNewValidCtxt
+extern __typeof (xmlSchemaNewValidCtxt) xmlSchemaNewValidCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaNewValidCtxt xmlSchemaNewValidCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaParse
+extern __typeof (xmlSchemaParse) xmlSchemaParse __attribute((alias("xmlSchemaParse__internal_alias")));
+#else
+#ifndef xmlSchemaParse
+extern __typeof (xmlSchemaParse) xmlSchemaParse__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaParse xmlSchemaParse__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaSAXPlug
+extern __typeof (xmlSchemaSAXPlug) xmlSchemaSAXPlug __attribute((alias("xmlSchemaSAXPlug__internal_alias")));
+#else
+#ifndef xmlSchemaSAXPlug
+extern __typeof (xmlSchemaSAXPlug) xmlSchemaSAXPlug__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaSAXPlug xmlSchemaSAXPlug__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaSAXUnplug
+extern __typeof (xmlSchemaSAXUnplug) xmlSchemaSAXUnplug __attribute((alias("xmlSchemaSAXUnplug__internal_alias")));
+#else
+#ifndef xmlSchemaSAXUnplug
+extern __typeof (xmlSchemaSAXUnplug) xmlSchemaSAXUnplug__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaSAXUnplug xmlSchemaSAXUnplug__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaSetParserErrors
+extern __typeof (xmlSchemaSetParserErrors) xmlSchemaSetParserErrors __attribute((alias("xmlSchemaSetParserErrors__internal_alias")));
+#else
+#ifndef xmlSchemaSetParserErrors
+extern __typeof (xmlSchemaSetParserErrors) xmlSchemaSetParserErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaSetParserErrors xmlSchemaSetParserErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaSetParserStructuredErrors
+extern __typeof (xmlSchemaSetParserStructuredErrors) xmlSchemaSetParserStructuredErrors __attribute((alias("xmlSchemaSetParserStructuredErrors__internal_alias")));
+#else
+#ifndef xmlSchemaSetParserStructuredErrors
+extern __typeof (xmlSchemaSetParserStructuredErrors) xmlSchemaSetParserStructuredErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaSetParserStructuredErrors xmlSchemaSetParserStructuredErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaSetValidErrors
+extern __typeof (xmlSchemaSetValidErrors) xmlSchemaSetValidErrors __attribute((alias("xmlSchemaSetValidErrors__internal_alias")));
+#else
+#ifndef xmlSchemaSetValidErrors
+extern __typeof (xmlSchemaSetValidErrors) xmlSchemaSetValidErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaSetValidErrors xmlSchemaSetValidErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaSetValidOptions
+extern __typeof (xmlSchemaSetValidOptions) xmlSchemaSetValidOptions __attribute((alias("xmlSchemaSetValidOptions__internal_alias")));
+#else
+#ifndef xmlSchemaSetValidOptions
+extern __typeof (xmlSchemaSetValidOptions) xmlSchemaSetValidOptions__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaSetValidOptions xmlSchemaSetValidOptions__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaSetValidStructuredErrors
+extern __typeof (xmlSchemaSetValidStructuredErrors) xmlSchemaSetValidStructuredErrors __attribute((alias("xmlSchemaSetValidStructuredErrors__internal_alias")));
+#else
+#ifndef xmlSchemaSetValidStructuredErrors
+extern __typeof (xmlSchemaSetValidStructuredErrors) xmlSchemaSetValidStructuredErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaSetValidStructuredErrors xmlSchemaSetValidStructuredErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValPredefTypeNode
+extern __typeof (xmlSchemaValPredefTypeNode) xmlSchemaValPredefTypeNode __attribute((alias("xmlSchemaValPredefTypeNode__internal_alias")));
+#else
+#ifndef xmlSchemaValPredefTypeNode
+extern __typeof (xmlSchemaValPredefTypeNode) xmlSchemaValPredefTypeNode__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValPredefTypeNode xmlSchemaValPredefTypeNode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValPredefTypeNodeNoNorm
+extern __typeof (xmlSchemaValPredefTypeNodeNoNorm) xmlSchemaValPredefTypeNodeNoNorm __attribute((alias("xmlSchemaValPredefTypeNodeNoNorm__internal_alias")));
+#else
+#ifndef xmlSchemaValPredefTypeNodeNoNorm
+extern __typeof (xmlSchemaValPredefTypeNodeNoNorm) xmlSchemaValPredefTypeNodeNoNorm__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValPredefTypeNodeNoNorm xmlSchemaValPredefTypeNodeNoNorm__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaValidCtxtGetOptions
+extern __typeof (xmlSchemaValidCtxtGetOptions) xmlSchemaValidCtxtGetOptions __attribute((alias("xmlSchemaValidCtxtGetOptions__internal_alias")));
+#else
+#ifndef xmlSchemaValidCtxtGetOptions
+extern __typeof (xmlSchemaValidCtxtGetOptions) xmlSchemaValidCtxtGetOptions__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidCtxtGetOptions xmlSchemaValidCtxtGetOptions__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaValidCtxtGetParserCtxt
+extern __typeof (xmlSchemaValidCtxtGetParserCtxt) xmlSchemaValidCtxtGetParserCtxt __attribute((alias("xmlSchemaValidCtxtGetParserCtxt__internal_alias")));
+#else
+#ifndef xmlSchemaValidCtxtGetParserCtxt
+extern __typeof (xmlSchemaValidCtxtGetParserCtxt) xmlSchemaValidCtxtGetParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidCtxtGetParserCtxt xmlSchemaValidCtxtGetParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaValidateDoc
+extern __typeof (xmlSchemaValidateDoc) xmlSchemaValidateDoc __attribute((alias("xmlSchemaValidateDoc__internal_alias")));
+#else
+#ifndef xmlSchemaValidateDoc
+extern __typeof (xmlSchemaValidateDoc) xmlSchemaValidateDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateDoc xmlSchemaValidateDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValidateFacet
+extern __typeof (xmlSchemaValidateFacet) xmlSchemaValidateFacet __attribute((alias("xmlSchemaValidateFacet__internal_alias")));
+#else
+#ifndef xmlSchemaValidateFacet
+extern __typeof (xmlSchemaValidateFacet) xmlSchemaValidateFacet__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateFacet xmlSchemaValidateFacet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValidateFacetWhtsp
+extern __typeof (xmlSchemaValidateFacetWhtsp) xmlSchemaValidateFacetWhtsp __attribute((alias("xmlSchemaValidateFacetWhtsp__internal_alias")));
+#else
+#ifndef xmlSchemaValidateFacetWhtsp
+extern __typeof (xmlSchemaValidateFacetWhtsp) xmlSchemaValidateFacetWhtsp__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateFacetWhtsp xmlSchemaValidateFacetWhtsp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaValidateFile
+extern __typeof (xmlSchemaValidateFile) xmlSchemaValidateFile __attribute((alias("xmlSchemaValidateFile__internal_alias")));
+#else
+#ifndef xmlSchemaValidateFile
+extern __typeof (xmlSchemaValidateFile) xmlSchemaValidateFile__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateFile xmlSchemaValidateFile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValidateLengthFacet
+extern __typeof (xmlSchemaValidateLengthFacet) xmlSchemaValidateLengthFacet __attribute((alias("xmlSchemaValidateLengthFacet__internal_alias")));
+#else
+#ifndef xmlSchemaValidateLengthFacet
+extern __typeof (xmlSchemaValidateLengthFacet) xmlSchemaValidateLengthFacet__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateLengthFacet xmlSchemaValidateLengthFacet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValidateLengthFacetWhtsp
+extern __typeof (xmlSchemaValidateLengthFacetWhtsp) xmlSchemaValidateLengthFacetWhtsp __attribute((alias("xmlSchemaValidateLengthFacetWhtsp__internal_alias")));
+#else
+#ifndef xmlSchemaValidateLengthFacetWhtsp
+extern __typeof (xmlSchemaValidateLengthFacetWhtsp) xmlSchemaValidateLengthFacetWhtsp__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateLengthFacetWhtsp xmlSchemaValidateLengthFacetWhtsp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValidateListSimpleTypeFacet
+extern __typeof (xmlSchemaValidateListSimpleTypeFacet) xmlSchemaValidateListSimpleTypeFacet __attribute((alias("xmlSchemaValidateListSimpleTypeFacet__internal_alias")));
+#else
+#ifndef xmlSchemaValidateListSimpleTypeFacet
+extern __typeof (xmlSchemaValidateListSimpleTypeFacet) xmlSchemaValidateListSimpleTypeFacet__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateListSimpleTypeFacet xmlSchemaValidateListSimpleTypeFacet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaValidateOneElement
+extern __typeof (xmlSchemaValidateOneElement) xmlSchemaValidateOneElement __attribute((alias("xmlSchemaValidateOneElement__internal_alias")));
+#else
+#ifndef xmlSchemaValidateOneElement
+extern __typeof (xmlSchemaValidateOneElement) xmlSchemaValidateOneElement__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateOneElement xmlSchemaValidateOneElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValidatePredefinedType
+extern __typeof (xmlSchemaValidatePredefinedType) xmlSchemaValidatePredefinedType __attribute((alias("xmlSchemaValidatePredefinedType__internal_alias")));
+#else
+#ifndef xmlSchemaValidatePredefinedType
+extern __typeof (xmlSchemaValidatePredefinedType) xmlSchemaValidatePredefinedType__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidatePredefinedType xmlSchemaValidatePredefinedType__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaValidateSetFilename
+extern __typeof (xmlSchemaValidateSetFilename) xmlSchemaValidateSetFilename __attribute((alias("xmlSchemaValidateSetFilename__internal_alias")));
+#else
+#ifndef xmlSchemaValidateSetFilename
+extern __typeof (xmlSchemaValidateSetFilename) xmlSchemaValidateSetFilename__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateSetFilename xmlSchemaValidateSetFilename__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaValidateSetLocator
+extern __typeof (xmlSchemaValidateSetLocator) xmlSchemaValidateSetLocator __attribute((alias("xmlSchemaValidateSetLocator__internal_alias")));
+#else
+#ifndef xmlSchemaValidateSetLocator
+extern __typeof (xmlSchemaValidateSetLocator) xmlSchemaValidateSetLocator__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateSetLocator xmlSchemaValidateSetLocator__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemas
+#undef xmlSchemaValidateStream
+extern __typeof (xmlSchemaValidateStream) xmlSchemaValidateStream __attribute((alias("xmlSchemaValidateStream__internal_alias")));
+#else
+#ifndef xmlSchemaValidateStream
+extern __typeof (xmlSchemaValidateStream) xmlSchemaValidateStream__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValidateStream xmlSchemaValidateStream__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValueAppend
+extern __typeof (xmlSchemaValueAppend) xmlSchemaValueAppend __attribute((alias("xmlSchemaValueAppend__internal_alias")));
+#else
+#ifndef xmlSchemaValueAppend
+extern __typeof (xmlSchemaValueAppend) xmlSchemaValueAppend__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValueAppend xmlSchemaValueAppend__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValueGetAsBoolean
+extern __typeof (xmlSchemaValueGetAsBoolean) xmlSchemaValueGetAsBoolean __attribute((alias("xmlSchemaValueGetAsBoolean__internal_alias")));
+#else
+#ifndef xmlSchemaValueGetAsBoolean
+extern __typeof (xmlSchemaValueGetAsBoolean) xmlSchemaValueGetAsBoolean__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValueGetAsBoolean xmlSchemaValueGetAsBoolean__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValueGetAsString
+extern __typeof (xmlSchemaValueGetAsString) xmlSchemaValueGetAsString __attribute((alias("xmlSchemaValueGetAsString__internal_alias")));
+#else
+#ifndef xmlSchemaValueGetAsString
+extern __typeof (xmlSchemaValueGetAsString) xmlSchemaValueGetAsString__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValueGetAsString xmlSchemaValueGetAsString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaValueGetNext
+extern __typeof (xmlSchemaValueGetNext) xmlSchemaValueGetNext __attribute((alias("xmlSchemaValueGetNext__internal_alias")));
+#else
+#ifndef xmlSchemaValueGetNext
+extern __typeof (xmlSchemaValueGetNext) xmlSchemaValueGetNext__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaValueGetNext xmlSchemaValueGetNext__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlschemastypes
+#undef xmlSchemaWhiteSpaceReplace
+extern __typeof (xmlSchemaWhiteSpaceReplace) xmlSchemaWhiteSpaceReplace __attribute((alias("xmlSchemaWhiteSpaceReplace__internal_alias")));
+#else
+#ifndef xmlSchemaWhiteSpaceReplace
+extern __typeof (xmlSchemaWhiteSpaceReplace) xmlSchemaWhiteSpaceReplace__internal_alias __attribute((visibility("hidden")));
+#define xmlSchemaWhiteSpaceReplace xmlSchemaWhiteSpaceReplace__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
+#undef xmlSchematronFree
+extern __typeof (xmlSchematronFree) xmlSchematronFree __attribute((alias("xmlSchematronFree__internal_alias")));
+#else
+#ifndef xmlSchematronFree
+extern __typeof (xmlSchematronFree) xmlSchematronFree__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronFree xmlSchematronFree__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
+#undef xmlSchematronFreeParserCtxt
+extern __typeof (xmlSchematronFreeParserCtxt) xmlSchematronFreeParserCtxt __attribute((alias("xmlSchematronFreeParserCtxt__internal_alias")));
+#else
+#ifndef xmlSchematronFreeParserCtxt
+extern __typeof (xmlSchematronFreeParserCtxt) xmlSchematronFreeParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronFreeParserCtxt xmlSchematronFreeParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
+#undef xmlSchematronFreeValidCtxt
+extern __typeof (xmlSchematronFreeValidCtxt) xmlSchematronFreeValidCtxt __attribute((alias("xmlSchematronFreeValidCtxt__internal_alias")));
+#else
+#ifndef xmlSchematronFreeValidCtxt
+extern __typeof (xmlSchematronFreeValidCtxt) xmlSchematronFreeValidCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronFreeValidCtxt xmlSchematronFreeValidCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
+#undef xmlSchematronNewDocParserCtxt
+extern __typeof (xmlSchematronNewDocParserCtxt) xmlSchematronNewDocParserCtxt __attribute((alias("xmlSchematronNewDocParserCtxt__internal_alias")));
+#else
+#ifndef xmlSchematronNewDocParserCtxt
+extern __typeof (xmlSchematronNewDocParserCtxt) xmlSchematronNewDocParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronNewDocParserCtxt xmlSchematronNewDocParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
+#undef xmlSchematronNewMemParserCtxt
+extern __typeof (xmlSchematronNewMemParserCtxt) xmlSchematronNewMemParserCtxt __attribute((alias("xmlSchematronNewMemParserCtxt__internal_alias")));
+#else
+#ifndef xmlSchematronNewMemParserCtxt
+extern __typeof (xmlSchematronNewMemParserCtxt) xmlSchematronNewMemParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronNewMemParserCtxt xmlSchematronNewMemParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
+#undef xmlSchematronNewParserCtxt
+extern __typeof (xmlSchematronNewParserCtxt) xmlSchematronNewParserCtxt __attribute((alias("xmlSchematronNewParserCtxt__internal_alias")));
+#else
+#ifndef xmlSchematronNewParserCtxt
+extern __typeof (xmlSchematronNewParserCtxt) xmlSchematronNewParserCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronNewParserCtxt xmlSchematronNewParserCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
+#undef xmlSchematronNewValidCtxt
+extern __typeof (xmlSchematronNewValidCtxt) xmlSchematronNewValidCtxt __attribute((alias("xmlSchematronNewValidCtxt__internal_alias")));
+#else
+#ifndef xmlSchematronNewValidCtxt
+extern __typeof (xmlSchematronNewValidCtxt) xmlSchematronNewValidCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronNewValidCtxt xmlSchematronNewValidCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
+#undef xmlSchematronParse
+extern __typeof (xmlSchematronParse) xmlSchematronParse __attribute((alias("xmlSchematronParse__internal_alias")));
+#else
+#ifndef xmlSchematronParse
+extern __typeof (xmlSchematronParse) xmlSchematronParse__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronParse xmlSchematronParse__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
+#undef xmlSchematronSetValidStructuredErrors
+extern __typeof (xmlSchematronSetValidStructuredErrors) xmlSchematronSetValidStructuredErrors __attribute((alias("xmlSchematronSetValidStructuredErrors__internal_alias")));
+#else
+#ifndef xmlSchematronSetValidStructuredErrors
+extern __typeof (xmlSchematronSetValidStructuredErrors) xmlSchematronSetValidStructuredErrors__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronSetValidStructuredErrors xmlSchematronSetValidStructuredErrors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_SCHEMATRON_ENABLED)
+#ifdef bottom_schematron
+#undef xmlSchematronValidateDoc
+extern __typeof (xmlSchematronValidateDoc) xmlSchematronValidateDoc __attribute((alias("xmlSchematronValidateDoc__internal_alias")));
+#else
+#ifndef xmlSchematronValidateDoc
+extern __typeof (xmlSchematronValidateDoc) xmlSchematronValidateDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlSchematronValidateDoc xmlSchematronValidateDoc__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlSearchNs
+extern __typeof (xmlSearchNs) xmlSearchNs __attribute((alias("xmlSearchNs__internal_alias")));
+#else
+#ifndef xmlSearchNs
+extern __typeof (xmlSearchNs) xmlSearchNs__internal_alias __attribute((visibility("hidden")));
+#define xmlSearchNs xmlSearchNs__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlSearchNsByHref
+extern __typeof (xmlSearchNsByHref) xmlSearchNsByHref __attribute((alias("xmlSearchNsByHref__internal_alias")));
+#else
+#ifndef xmlSearchNsByHref
+extern __typeof (xmlSearchNsByHref) xmlSearchNsByHref__internal_alias __attribute((visibility("hidden")));
+#define xmlSearchNsByHref xmlSearchNsByHref__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlSetBufferAllocationScheme
+extern __typeof (xmlSetBufferAllocationScheme) xmlSetBufferAllocationScheme __attribute((alias("xmlSetBufferAllocationScheme__internal_alias")));
+#else
+#ifndef xmlSetBufferAllocationScheme
+extern __typeof (xmlSetBufferAllocationScheme) xmlSetBufferAllocationScheme__internal_alias __attribute((visibility("hidden")));
+#define xmlSetBufferAllocationScheme xmlSetBufferAllocationScheme__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlSetCompressMode
+extern __typeof (xmlSetCompressMode) xmlSetCompressMode __attribute((alias("xmlSetCompressMode__internal_alias")));
+#else
+#ifndef xmlSetCompressMode
+extern __typeof (xmlSetCompressMode) xmlSetCompressMode__internal_alias __attribute((visibility("hidden")));
+#define xmlSetCompressMode xmlSetCompressMode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlSetDocCompressMode
+extern __typeof (xmlSetDocCompressMode) xmlSetDocCompressMode __attribute((alias("xmlSetDocCompressMode__internal_alias")));
+#else
+#ifndef xmlSetDocCompressMode
+extern __typeof (xmlSetDocCompressMode) xmlSetDocCompressMode__internal_alias __attribute((visibility("hidden")));
+#define xmlSetDocCompressMode xmlSetDocCompressMode__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_parser
+#undef xmlSetEntityReferenceFunc
+extern __typeof (xmlSetEntityReferenceFunc) xmlSetEntityReferenceFunc __attribute((alias("xmlSetEntityReferenceFunc__internal_alias")));
+#else
+#ifndef xmlSetEntityReferenceFunc
+extern __typeof (xmlSetEntityReferenceFunc) xmlSetEntityReferenceFunc__internal_alias __attribute((visibility("hidden")));
+#define xmlSetEntityReferenceFunc xmlSetEntityReferenceFunc__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_xmlIO
+#undef xmlSetExternalEntityLoader
+extern __typeof (xmlSetExternalEntityLoader) xmlSetExternalEntityLoader __attribute((alias("xmlSetExternalEntityLoader__internal_alias")));
+#else
+#ifndef xmlSetExternalEntityLoader
+extern __typeof (xmlSetExternalEntityLoader) xmlSetExternalEntityLoader__internal_alias __attribute((visibility("hidden")));
+#define xmlSetExternalEntityLoader xmlSetExternalEntityLoader__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_legacy
+#undef xmlSetFeature
+extern __typeof (xmlSetFeature) xmlSetFeature __attribute((alias("xmlSetFeature__internal_alias")));
+#else
+#ifndef xmlSetFeature
+extern __typeof (xmlSetFeature) xmlSetFeature__internal_alias __attribute((visibility("hidden")));
+#define xmlSetFeature xmlSetFeature__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlSetGenericErrorFunc
+extern __typeof (xmlSetGenericErrorFunc) xmlSetGenericErrorFunc __attribute((alias("xmlSetGenericErrorFunc__internal_alias")));
+#else
+#ifndef xmlSetGenericErrorFunc
+extern __typeof (xmlSetGenericErrorFunc) xmlSetGenericErrorFunc__internal_alias __attribute((visibility("hidden")));
+#define xmlSetGenericErrorFunc xmlSetGenericErrorFunc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlSetListDoc
+extern __typeof (xmlSetListDoc) xmlSetListDoc __attribute((alias("xmlSetListDoc__internal_alias")));
+#else
+#ifndef xmlSetListDoc
+extern __typeof (xmlSetListDoc) xmlSetListDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlSetListDoc xmlSetListDoc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlSetNs
+extern __typeof (xmlSetNs) xmlSetNs __attribute((alias("xmlSetNs__internal_alias")));
+#else
+#ifndef xmlSetNs
+extern __typeof (xmlSetNs) xmlSetNs__internal_alias __attribute((visibility("hidden")));
+#define xmlSetNs xmlSetNs__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_tree
+#undef xmlSetNsProp
+extern __typeof (xmlSetNsProp) xmlSetNsProp __attribute((alias("xmlSetNsProp__internal_alias")));
+#else
+#ifndef xmlSetNsProp
+extern __typeof (xmlSetNsProp) xmlSetNsProp__internal_alias __attribute((visibility("hidden")));
+#define xmlSetNsProp xmlSetNsProp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
+#ifdef bottom_tree
+#undef xmlSetProp
+extern __typeof (xmlSetProp) xmlSetProp __attribute((alias("xmlSetProp__internal_alias")));
+#else
+#ifndef xmlSetProp
+extern __typeof (xmlSetProp) xmlSetProp__internal_alias __attribute((visibility("hidden")));
+#define xmlSetProp xmlSetProp__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_error
+#undef xmlSetStructuredErrorFunc
+extern __typeof (xmlSetStructuredErrorFunc) xmlSetStructuredErrorFunc __attribute((alias("xmlSetStructuredErrorFunc__internal_alias")));
+#else
+#ifndef xmlSetStructuredErrorFunc
+extern __typeof (xmlSetStructuredErrorFunc) xmlSetStructuredErrorFunc__internal_alias __attribute((visibility("hidden")));
+#define xmlSetStructuredErrorFunc xmlSetStructuredErrorFunc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlSetTreeDoc
+extern __typeof (xmlSetTreeDoc) xmlSetTreeDoc __attribute((alias("xmlSetTreeDoc__internal_alias")));
+#else
+#ifndef xmlSetTreeDoc
+extern __typeof (xmlSetTreeDoc) xmlSetTreeDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlSetTreeDoc xmlSetTreeDoc__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_SAX1_ENABLED)
+#ifdef bottom_parser
+#undef xmlSetupParserForBuffer
+extern __typeof (xmlSetupParserForBuffer) xmlSetupParserForBuffer __attribute((alias("xmlSetupParserForBuffer__internal_alias")));
+#else
+#ifndef xmlSetupParserForBuffer
+extern __typeof (xmlSetupParserForBuffer) xmlSetupParserForBuffer__internal_alias __attribute((visibility("hidden")));
+#define xmlSetupParserForBuffer xmlSetupParserForBuffer__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShell
+extern __typeof (xmlShell) xmlShell __attribute((alias("xmlShell__internal_alias")));
+#else
+#ifndef xmlShell
+extern __typeof (xmlShell) xmlShell__internal_alias __attribute((visibility("hidden")));
+#define xmlShell xmlShell__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellBase
+extern __typeof (xmlShellBase) xmlShellBase __attribute((alias("xmlShellBase__internal_alias")));
+#else
+#ifndef xmlShellBase
+extern __typeof (xmlShellBase) xmlShellBase__internal_alias __attribute((visibility("hidden")));
+#define xmlShellBase xmlShellBase__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellCat
+extern __typeof (xmlShellCat) xmlShellCat __attribute((alias("xmlShellCat__internal_alias")));
+#else
+#ifndef xmlShellCat
+extern __typeof (xmlShellCat) xmlShellCat__internal_alias __attribute((visibility("hidden")));
+#define xmlShellCat xmlShellCat__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellDir
+extern __typeof (xmlShellDir) xmlShellDir __attribute((alias("xmlShellDir__internal_alias")));
+#else
+#ifndef xmlShellDir
+extern __typeof (xmlShellDir) xmlShellDir__internal_alias __attribute((visibility("hidden")));
+#define xmlShellDir xmlShellDir__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellDu
+extern __typeof (xmlShellDu) xmlShellDu __attribute((alias("xmlShellDu__internal_alias")));
+#else
+#ifndef xmlShellDu
+extern __typeof (xmlShellDu) xmlShellDu__internal_alias __attribute((visibility("hidden")));
+#define xmlShellDu xmlShellDu__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellList
+extern __typeof (xmlShellList) xmlShellList __attribute((alias("xmlShellList__internal_alias")));
+#else
+#ifndef xmlShellList
+extern __typeof (xmlShellList) xmlShellList__internal_alias __attribute((visibility("hidden")));
+#define xmlShellList xmlShellList__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellLoad
+extern __typeof (xmlShellLoad) xmlShellLoad __attribute((alias("xmlShellLoad__internal_alias")));
+#else
+#ifndef xmlShellLoad
+extern __typeof (xmlShellLoad) xmlShellLoad__internal_alias __attribute((visibility("hidden")));
+#define xmlShellLoad xmlShellLoad__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellPrintNode
+extern __typeof (xmlShellPrintNode) xmlShellPrintNode __attribute((alias("xmlShellPrintNode__internal_alias")));
+#else
+#ifndef xmlShellPrintNode
+extern __typeof (xmlShellPrintNode) xmlShellPrintNode__internal_alias __attribute((visibility("hidden")));
+#define xmlShellPrintNode xmlShellPrintNode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellPrintXPathError
+extern __typeof (xmlShellPrintXPathError) xmlShellPrintXPathError __attribute((alias("xmlShellPrintXPathError__internal_alias")));
+#else
+#ifndef xmlShellPrintXPathError
+extern __typeof (xmlShellPrintXPathError) xmlShellPrintXPathError__internal_alias __attribute((visibility("hidden")));
+#define xmlShellPrintXPathError xmlShellPrintXPathError__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellPrintXPathResult
+extern __typeof (xmlShellPrintXPathResult) xmlShellPrintXPathResult __attribute((alias("xmlShellPrintXPathResult__internal_alias")));
+#else
+#ifndef xmlShellPrintXPathResult
+extern __typeof (xmlShellPrintXPathResult) xmlShellPrintXPathResult__internal_alias __attribute((visibility("hidden")));
+#define xmlShellPrintXPathResult xmlShellPrintXPathResult__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellPwd
+extern __typeof (xmlShellPwd) xmlShellPwd __attribute((alias("xmlShellPwd__internal_alias")));
+#else
+#ifndef xmlShellPwd
+extern __typeof (xmlShellPwd) xmlShellPwd__internal_alias __attribute((visibility("hidden")));
+#define xmlShellPwd xmlShellPwd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellSave
+extern __typeof (xmlShellSave) xmlShellSave __attribute((alias("xmlShellSave__internal_alias")));
+#else
+#ifndef xmlShellSave
+extern __typeof (xmlShellSave) xmlShellSave__internal_alias __attribute((visibility("hidden")));
+#define xmlShellSave xmlShellSave__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellValidate
+extern __typeof (xmlShellValidate) xmlShellValidate __attribute((alias("xmlShellValidate__internal_alias")));
+#else
+#ifndef xmlShellValidate
+extern __typeof (xmlShellValidate) xmlShellValidate__internal_alias __attribute((visibility("hidden")));
+#define xmlShellValidate xmlShellValidate__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_DEBUG_ENABLED) && defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_debugXML
+#undef xmlShellWrite
+extern __typeof (xmlShellWrite) xmlShellWrite __attribute((alias("xmlShellWrite__internal_alias")));
+#else
+#ifndef xmlShellWrite
+extern __typeof (xmlShellWrite) xmlShellWrite__internal_alias __attribute((visibility("hidden")));
+#define xmlShellWrite xmlShellWrite__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlSkipBlankChars
+extern __typeof (xmlSkipBlankChars) xmlSkipBlankChars __attribute((alias("xmlSkipBlankChars__internal_alias")));
+#else
+#ifndef xmlSkipBlankChars
+extern __typeof (xmlSkipBlankChars) xmlSkipBlankChars__internal_alias __attribute((visibility("hidden")));
+#define xmlSkipBlankChars xmlSkipBlankChars__internal_alias
+#endif
+#endif
+
+#ifdef bottom_valid
+#undef xmlSnprintfElementContent
+extern __typeof (xmlSnprintfElementContent) xmlSnprintfElementContent __attribute((alias("xmlSnprintfElementContent__internal_alias")));
+#else
+#ifndef xmlSnprintfElementContent
+extern __typeof (xmlSnprintfElementContent) xmlSnprintfElementContent__internal_alias __attribute((visibility("hidden")));
+#define xmlSnprintfElementContent xmlSnprintfElementContent__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlSplitQName
+extern __typeof (xmlSplitQName) xmlSplitQName __attribute((alias("xmlSplitQName__internal_alias")));
+#else
+#ifndef xmlSplitQName
+extern __typeof (xmlSplitQName) xmlSplitQName__internal_alias __attribute((visibility("hidden")));
+#define xmlSplitQName xmlSplitQName__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlSplitQName2
+extern __typeof (xmlSplitQName2) xmlSplitQName2 __attribute((alias("xmlSplitQName2__internal_alias")));
+#else
+#ifndef xmlSplitQName2
+extern __typeof (xmlSplitQName2) xmlSplitQName2__internal_alias __attribute((visibility("hidden")));
+#define xmlSplitQName2 xmlSplitQName2__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlSplitQName3
+extern __typeof (xmlSplitQName3) xmlSplitQName3 __attribute((alias("xmlSplitQName3__internal_alias")));
+#else
+#ifndef xmlSplitQName3
+extern __typeof (xmlSplitQName3) xmlSplitQName3__internal_alias __attribute((visibility("hidden")));
+#define xmlSplitQName3 xmlSplitQName3__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_OUTPUT_ENABLED)
+#ifdef bottom_valid
+#undef xmlSprintfElementContent
+extern __typeof (xmlSprintfElementContent) xmlSprintfElementContent __attribute((alias("xmlSprintfElementContent__internal_alias")));
+#else
+#ifndef xmlSprintfElementContent
+extern __typeof (xmlSprintfElementContent) xmlSprintfElementContent__internal_alias __attribute((visibility("hidden")));
+#define xmlSprintfElementContent xmlSprintfElementContent__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlStopParser
+extern __typeof (xmlStopParser) xmlStopParser __attribute((alias("xmlStopParser__internal_alias")));
+#else
+#ifndef xmlStopParser
+extern __typeof (xmlStopParser) xmlStopParser__internal_alias __attribute((visibility("hidden")));
+#define xmlStopParser xmlStopParser__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrEqual
+extern __typeof (xmlStrEqual) xmlStrEqual __attribute((alias("xmlStrEqual__internal_alias")));
+#else
+#ifndef xmlStrEqual
+extern __typeof (xmlStrEqual) xmlStrEqual__internal_alias __attribute((visibility("hidden")));
+#define xmlStrEqual xmlStrEqual__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrPrintf
+extern __typeof (xmlStrPrintf) xmlStrPrintf __attribute((alias("xmlStrPrintf__internal_alias")));
+#else
+#ifndef xmlStrPrintf
+extern __typeof (xmlStrPrintf) xmlStrPrintf__internal_alias __attribute((visibility("hidden")));
+#define xmlStrPrintf xmlStrPrintf__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrQEqual
+extern __typeof (xmlStrQEqual) xmlStrQEqual __attribute((alias("xmlStrQEqual__internal_alias")));
+#else
+#ifndef xmlStrQEqual
+extern __typeof (xmlStrQEqual) xmlStrQEqual__internal_alias __attribute((visibility("hidden")));
+#define xmlStrQEqual xmlStrQEqual__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrVPrintf
+extern __typeof (xmlStrVPrintf) xmlStrVPrintf __attribute((alias("xmlStrVPrintf__internal_alias")));
+#else
+#ifndef xmlStrVPrintf
+extern __typeof (xmlStrVPrintf) xmlStrVPrintf__internal_alias __attribute((visibility("hidden")));
+#define xmlStrVPrintf xmlStrVPrintf__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrcasecmp
+extern __typeof (xmlStrcasecmp) xmlStrcasecmp __attribute((alias("xmlStrcasecmp__internal_alias")));
+#else
+#ifndef xmlStrcasecmp
+extern __typeof (xmlStrcasecmp) xmlStrcasecmp__internal_alias __attribute((visibility("hidden")));
+#define xmlStrcasecmp xmlStrcasecmp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrcasestr
+extern __typeof (xmlStrcasestr) xmlStrcasestr __attribute((alias("xmlStrcasestr__internal_alias")));
+#else
+#ifndef xmlStrcasestr
+extern __typeof (xmlStrcasestr) xmlStrcasestr__internal_alias __attribute((visibility("hidden")));
+#define xmlStrcasestr xmlStrcasestr__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrcat
+extern __typeof (xmlStrcat) xmlStrcat __attribute((alias("xmlStrcat__internal_alias")));
+#else
+#ifndef xmlStrcat
+extern __typeof (xmlStrcat) xmlStrcat__internal_alias __attribute((visibility("hidden")));
+#define xmlStrcat xmlStrcat__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrchr
+extern __typeof (xmlStrchr) xmlStrchr __attribute((alias("xmlStrchr__internal_alias")));
+#else
+#ifndef xmlStrchr
+extern __typeof (xmlStrchr) xmlStrchr__internal_alias __attribute((visibility("hidden")));
+#define xmlStrchr xmlStrchr__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrcmp
+extern __typeof (xmlStrcmp) xmlStrcmp __attribute((alias("xmlStrcmp__internal_alias")));
+#else
+#ifndef xmlStrcmp
+extern __typeof (xmlStrcmp) xmlStrcmp__internal_alias __attribute((visibility("hidden")));
+#define xmlStrcmp xmlStrcmp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrdup
+extern __typeof (xmlStrdup) xmlStrdup __attribute((alias("xmlStrdup__internal_alias")));
+#else
+#ifndef xmlStrdup
+extern __typeof (xmlStrdup) xmlStrdup__internal_alias __attribute((visibility("hidden")));
+#define xmlStrdup xmlStrdup__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlStreamPop
+extern __typeof (xmlStreamPop) xmlStreamPop __attribute((alias("xmlStreamPop__internal_alias")));
+#else
+#ifndef xmlStreamPop
+extern __typeof (xmlStreamPop) xmlStreamPop__internal_alias __attribute((visibility("hidden")));
+#define xmlStreamPop xmlStreamPop__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlStreamPush
+extern __typeof (xmlStreamPush) xmlStreamPush __attribute((alias("xmlStreamPush__internal_alias")));
+#else
+#ifndef xmlStreamPush
+extern __typeof (xmlStreamPush) xmlStreamPush__internal_alias __attribute((visibility("hidden")));
+#define xmlStreamPush xmlStreamPush__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlStreamPushAttr
+extern __typeof (xmlStreamPushAttr) xmlStreamPushAttr __attribute((alias("xmlStreamPushAttr__internal_alias")));
+#else
+#ifndef xmlStreamPushAttr
+extern __typeof (xmlStreamPushAttr) xmlStreamPushAttr__internal_alias __attribute((visibility("hidden")));
+#define xmlStreamPushAttr xmlStreamPushAttr__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlStreamPushNode
+extern __typeof (xmlStreamPushNode) xmlStreamPushNode __attribute((alias("xmlStreamPushNode__internal_alias")));
+#else
+#ifndef xmlStreamPushNode
+extern __typeof (xmlStreamPushNode) xmlStreamPushNode__internal_alias __attribute((visibility("hidden")));
+#define xmlStreamPushNode xmlStreamPushNode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_pattern
+#undef xmlStreamWantsAnyNode
+extern __typeof (xmlStreamWantsAnyNode) xmlStreamWantsAnyNode __attribute((alias("xmlStreamWantsAnyNode__internal_alias")));
+#else
+#ifndef xmlStreamWantsAnyNode
+extern __typeof (xmlStreamWantsAnyNode) xmlStreamWantsAnyNode__internal_alias __attribute((visibility("hidden")));
+#define xmlStreamWantsAnyNode xmlStreamWantsAnyNode__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlStringCurrentChar
+extern __typeof (xmlStringCurrentChar) xmlStringCurrentChar __attribute((alias("xmlStringCurrentChar__internal_alias")));
+#else
+#ifndef xmlStringCurrentChar
+extern __typeof (xmlStringCurrentChar) xmlStringCurrentChar__internal_alias __attribute((visibility("hidden")));
+#define xmlStringCurrentChar xmlStringCurrentChar__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlStringDecodeEntities
+extern __typeof (xmlStringDecodeEntities) xmlStringDecodeEntities __attribute((alias("xmlStringDecodeEntities__internal_alias")));
+#else
+#ifndef xmlStringDecodeEntities
+extern __typeof (xmlStringDecodeEntities) xmlStringDecodeEntities__internal_alias __attribute((visibility("hidden")));
+#define xmlStringDecodeEntities xmlStringDecodeEntities__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlStringGetNodeList
+extern __typeof (xmlStringGetNodeList) xmlStringGetNodeList __attribute((alias("xmlStringGetNodeList__internal_alias")));
+#else
+#ifndef xmlStringGetNodeList
+extern __typeof (xmlStringGetNodeList) xmlStringGetNodeList__internal_alias __attribute((visibility("hidden")));
+#define xmlStringGetNodeList xmlStringGetNodeList__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parser
+#undef xmlStringLenDecodeEntities
+extern __typeof (xmlStringLenDecodeEntities) xmlStringLenDecodeEntities __attribute((alias("xmlStringLenDecodeEntities__internal_alias")));
+#else
+#ifndef xmlStringLenDecodeEntities
+extern __typeof (xmlStringLenDecodeEntities) xmlStringLenDecodeEntities__internal_alias __attribute((visibility("hidden")));
+#define xmlStringLenDecodeEntities xmlStringLenDecodeEntities__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlStringLenGetNodeList
+extern __typeof (xmlStringLenGetNodeList) xmlStringLenGetNodeList __attribute((alias("xmlStringLenGetNodeList__internal_alias")));
+#else
+#ifndef xmlStringLenGetNodeList
+extern __typeof (xmlStringLenGetNodeList) xmlStringLenGetNodeList__internal_alias __attribute((visibility("hidden")));
+#define xmlStringLenGetNodeList xmlStringLenGetNodeList__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrlen
+extern __typeof (xmlStrlen) xmlStrlen __attribute((alias("xmlStrlen__internal_alias")));
+#else
+#ifndef xmlStrlen
+extern __typeof (xmlStrlen) xmlStrlen__internal_alias __attribute((visibility("hidden")));
+#define xmlStrlen xmlStrlen__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrncasecmp
+extern __typeof (xmlStrncasecmp) xmlStrncasecmp __attribute((alias("xmlStrncasecmp__internal_alias")));
+#else
+#ifndef xmlStrncasecmp
+extern __typeof (xmlStrncasecmp) xmlStrncasecmp__internal_alias __attribute((visibility("hidden")));
+#define xmlStrncasecmp xmlStrncasecmp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrncat
+extern __typeof (xmlStrncat) xmlStrncat __attribute((alias("xmlStrncat__internal_alias")));
+#else
+#ifndef xmlStrncat
+extern __typeof (xmlStrncat) xmlStrncat__internal_alias __attribute((visibility("hidden")));
+#define xmlStrncat xmlStrncat__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrncatNew
+extern __typeof (xmlStrncatNew) xmlStrncatNew __attribute((alias("xmlStrncatNew__internal_alias")));
+#else
+#ifndef xmlStrncatNew
+extern __typeof (xmlStrncatNew) xmlStrncatNew__internal_alias __attribute((visibility("hidden")));
+#define xmlStrncatNew xmlStrncatNew__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrncmp
+extern __typeof (xmlStrncmp) xmlStrncmp __attribute((alias("xmlStrncmp__internal_alias")));
+#else
+#ifndef xmlStrncmp
+extern __typeof (xmlStrncmp) xmlStrncmp__internal_alias __attribute((visibility("hidden")));
+#define xmlStrncmp xmlStrncmp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrndup
+extern __typeof (xmlStrndup) xmlStrndup __attribute((alias("xmlStrndup__internal_alias")));
+#else
+#ifndef xmlStrndup
+extern __typeof (xmlStrndup) xmlStrndup__internal_alias __attribute((visibility("hidden")));
+#define xmlStrndup xmlStrndup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrstr
+extern __typeof (xmlStrstr) xmlStrstr __attribute((alias("xmlStrstr__internal_alias")));
+#else
+#ifndef xmlStrstr
+extern __typeof (xmlStrstr) xmlStrstr__internal_alias __attribute((visibility("hidden")));
+#define xmlStrstr xmlStrstr__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlStrsub
+extern __typeof (xmlStrsub) xmlStrsub __attribute((alias("xmlStrsub__internal_alias")));
+#else
+#ifndef xmlStrsub
+extern __typeof (xmlStrsub) xmlStrsub__internal_alias __attribute((visibility("hidden")));
+#define xmlStrsub xmlStrsub__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlSubstituteEntitiesDefault
+extern __typeof (xmlSubstituteEntitiesDefault) xmlSubstituteEntitiesDefault __attribute((alias("xmlSubstituteEntitiesDefault__internal_alias")));
+#else
+#ifndef xmlSubstituteEntitiesDefault
+extern __typeof (xmlSubstituteEntitiesDefault) xmlSubstituteEntitiesDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlSubstituteEntitiesDefault xmlSubstituteEntitiesDefault__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlSwitchEncoding
+extern __typeof (xmlSwitchEncoding) xmlSwitchEncoding __attribute((alias("xmlSwitchEncoding__internal_alias")));
+#else
+#ifndef xmlSwitchEncoding
+extern __typeof (xmlSwitchEncoding) xmlSwitchEncoding__internal_alias __attribute((visibility("hidden")));
+#define xmlSwitchEncoding xmlSwitchEncoding__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlSwitchInputEncoding
+extern __typeof (xmlSwitchInputEncoding) xmlSwitchInputEncoding __attribute((alias("xmlSwitchInputEncoding__internal_alias")));
+#else
+#ifndef xmlSwitchInputEncoding
+extern __typeof (xmlSwitchInputEncoding) xmlSwitchInputEncoding__internal_alias __attribute((visibility("hidden")));
+#define xmlSwitchInputEncoding xmlSwitchInputEncoding__internal_alias
+#endif
+#endif
+
+#ifdef bottom_parserInternals
+#undef xmlSwitchToEncoding
+extern __typeof (xmlSwitchToEncoding) xmlSwitchToEncoding __attribute((alias("xmlSwitchToEncoding__internal_alias")));
+#else
+#ifndef xmlSwitchToEncoding
+extern __typeof (xmlSwitchToEncoding) xmlSwitchToEncoding__internal_alias __attribute((visibility("hidden")));
+#define xmlSwitchToEncoding xmlSwitchToEncoding__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlTextConcat
+extern __typeof (xmlTextConcat) xmlTextConcat __attribute((alias("xmlTextConcat__internal_alias")));
+#else
+#ifndef xmlTextConcat
+extern __typeof (xmlTextConcat) xmlTextConcat__internal_alias __attribute((visibility("hidden")));
+#define xmlTextConcat xmlTextConcat__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlTextMerge
+extern __typeof (xmlTextMerge) xmlTextMerge __attribute((alias("xmlTextMerge__internal_alias")));
+#else
+#ifndef xmlTextMerge
+extern __typeof (xmlTextMerge) xmlTextMerge__internal_alias __attribute((visibility("hidden")));
+#define xmlTextMerge xmlTextMerge__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderAttributeCount
+extern __typeof (xmlTextReaderAttributeCount) xmlTextReaderAttributeCount __attribute((alias("xmlTextReaderAttributeCount__internal_alias")));
+#else
+#ifndef xmlTextReaderAttributeCount
+extern __typeof (xmlTextReaderAttributeCount) xmlTextReaderAttributeCount__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderAttributeCount xmlTextReaderAttributeCount__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderBaseUri
+extern __typeof (xmlTextReaderBaseUri) xmlTextReaderBaseUri __attribute((alias("xmlTextReaderBaseUri__internal_alias")));
+#else
+#ifndef xmlTextReaderBaseUri
+extern __typeof (xmlTextReaderBaseUri) xmlTextReaderBaseUri__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderBaseUri xmlTextReaderBaseUri__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderByteConsumed
+extern __typeof (xmlTextReaderByteConsumed) xmlTextReaderByteConsumed __attribute((alias("xmlTextReaderByteConsumed__internal_alias")));
+#else
+#ifndef xmlTextReaderByteConsumed
+extern __typeof (xmlTextReaderByteConsumed) xmlTextReaderByteConsumed__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderByteConsumed xmlTextReaderByteConsumed__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderClose
+extern __typeof (xmlTextReaderClose) xmlTextReaderClose __attribute((alias("xmlTextReaderClose__internal_alias")));
+#else
+#ifndef xmlTextReaderClose
+extern __typeof (xmlTextReaderClose) xmlTextReaderClose__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderClose xmlTextReaderClose__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderConstBaseUri
+extern __typeof (xmlTextReaderConstBaseUri) xmlTextReaderConstBaseUri __attribute((alias("xmlTextReaderConstBaseUri__internal_alias")));
+#else
+#ifndef xmlTextReaderConstBaseUri
+extern __typeof (xmlTextReaderConstBaseUri) xmlTextReaderConstBaseUri__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderConstBaseUri xmlTextReaderConstBaseUri__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderConstEncoding
+extern __typeof (xmlTextReaderConstEncoding) xmlTextReaderConstEncoding __attribute((alias("xmlTextReaderConstEncoding__internal_alias")));
+#else
+#ifndef xmlTextReaderConstEncoding
+extern __typeof (xmlTextReaderConstEncoding) xmlTextReaderConstEncoding__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderConstEncoding xmlTextReaderConstEncoding__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderConstLocalName
+extern __typeof (xmlTextReaderConstLocalName) xmlTextReaderConstLocalName __attribute((alias("xmlTextReaderConstLocalName__internal_alias")));
+#else
+#ifndef xmlTextReaderConstLocalName
+extern __typeof (xmlTextReaderConstLocalName) xmlTextReaderConstLocalName__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderConstLocalName xmlTextReaderConstLocalName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderConstName
+extern __typeof (xmlTextReaderConstName) xmlTextReaderConstName __attribute((alias("xmlTextReaderConstName__internal_alias")));
+#else
+#ifndef xmlTextReaderConstName
+extern __typeof (xmlTextReaderConstName) xmlTextReaderConstName__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderConstName xmlTextReaderConstName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderConstNamespaceUri
+extern __typeof (xmlTextReaderConstNamespaceUri) xmlTextReaderConstNamespaceUri __attribute((alias("xmlTextReaderConstNamespaceUri__internal_alias")));
+#else
+#ifndef xmlTextReaderConstNamespaceUri
+extern __typeof (xmlTextReaderConstNamespaceUri) xmlTextReaderConstNamespaceUri__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderConstNamespaceUri xmlTextReaderConstNamespaceUri__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderConstPrefix
+extern __typeof (xmlTextReaderConstPrefix) xmlTextReaderConstPrefix __attribute((alias("xmlTextReaderConstPrefix__internal_alias")));
+#else
+#ifndef xmlTextReaderConstPrefix
+extern __typeof (xmlTextReaderConstPrefix) xmlTextReaderConstPrefix__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderConstPrefix xmlTextReaderConstPrefix__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderConstString
+extern __typeof (xmlTextReaderConstString) xmlTextReaderConstString __attribute((alias("xmlTextReaderConstString__internal_alias")));
+#else
+#ifndef xmlTextReaderConstString
+extern __typeof (xmlTextReaderConstString) xmlTextReaderConstString__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderConstString xmlTextReaderConstString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderConstValue
+extern __typeof (xmlTextReaderConstValue) xmlTextReaderConstValue __attribute((alias("xmlTextReaderConstValue__internal_alias")));
+#else
+#ifndef xmlTextReaderConstValue
+extern __typeof (xmlTextReaderConstValue) xmlTextReaderConstValue__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderConstValue xmlTextReaderConstValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderConstXmlLang
+extern __typeof (xmlTextReaderConstXmlLang) xmlTextReaderConstXmlLang __attribute((alias("xmlTextReaderConstXmlLang__internal_alias")));
+#else
+#ifndef xmlTextReaderConstXmlLang
+extern __typeof (xmlTextReaderConstXmlLang) xmlTextReaderConstXmlLang__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderConstXmlLang xmlTextReaderConstXmlLang__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderConstXmlVersion
+extern __typeof (xmlTextReaderConstXmlVersion) xmlTextReaderConstXmlVersion __attribute((alias("xmlTextReaderConstXmlVersion__internal_alias")));
+#else
+#ifndef xmlTextReaderConstXmlVersion
+extern __typeof (xmlTextReaderConstXmlVersion) xmlTextReaderConstXmlVersion__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderConstXmlVersion xmlTextReaderConstXmlVersion__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderCurrentDoc
+extern __typeof (xmlTextReaderCurrentDoc) xmlTextReaderCurrentDoc __attribute((alias("xmlTextReaderCurrentDoc__internal_alias")));
+#else
+#ifndef xmlTextReaderCurrentDoc
+extern __typeof (xmlTextReaderCurrentDoc) xmlTextReaderCurrentDoc__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderCurrentDoc xmlTextReaderCurrentDoc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderCurrentNode
+extern __typeof (xmlTextReaderCurrentNode) xmlTextReaderCurrentNode __attribute((alias("xmlTextReaderCurrentNode__internal_alias")));
+#else
+#ifndef xmlTextReaderCurrentNode
+extern __typeof (xmlTextReaderCurrentNode) xmlTextReaderCurrentNode__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderCurrentNode xmlTextReaderCurrentNode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderDepth
+extern __typeof (xmlTextReaderDepth) xmlTextReaderDepth __attribute((alias("xmlTextReaderDepth__internal_alias")));
+#else
+#ifndef xmlTextReaderDepth
+extern __typeof (xmlTextReaderDepth) xmlTextReaderDepth__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderDepth xmlTextReaderDepth__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderExpand
+extern __typeof (xmlTextReaderExpand) xmlTextReaderExpand __attribute((alias("xmlTextReaderExpand__internal_alias")));
+#else
+#ifndef xmlTextReaderExpand
+extern __typeof (xmlTextReaderExpand) xmlTextReaderExpand__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderExpand xmlTextReaderExpand__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderGetAttribute
+extern __typeof (xmlTextReaderGetAttribute) xmlTextReaderGetAttribute __attribute((alias("xmlTextReaderGetAttribute__internal_alias")));
+#else
+#ifndef xmlTextReaderGetAttribute
+extern __typeof (xmlTextReaderGetAttribute) xmlTextReaderGetAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderGetAttribute xmlTextReaderGetAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderGetAttributeNo
+extern __typeof (xmlTextReaderGetAttributeNo) xmlTextReaderGetAttributeNo __attribute((alias("xmlTextReaderGetAttributeNo__internal_alias")));
+#else
+#ifndef xmlTextReaderGetAttributeNo
+extern __typeof (xmlTextReaderGetAttributeNo) xmlTextReaderGetAttributeNo__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderGetAttributeNo xmlTextReaderGetAttributeNo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderGetAttributeNs
+extern __typeof (xmlTextReaderGetAttributeNs) xmlTextReaderGetAttributeNs __attribute((alias("xmlTextReaderGetAttributeNs__internal_alias")));
+#else
+#ifndef xmlTextReaderGetAttributeNs
+extern __typeof (xmlTextReaderGetAttributeNs) xmlTextReaderGetAttributeNs__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderGetAttributeNs xmlTextReaderGetAttributeNs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderGetErrorHandler
+extern __typeof (xmlTextReaderGetErrorHandler) xmlTextReaderGetErrorHandler __attribute((alias("xmlTextReaderGetErrorHandler__internal_alias")));
+#else
+#ifndef xmlTextReaderGetErrorHandler
+extern __typeof (xmlTextReaderGetErrorHandler) xmlTextReaderGetErrorHandler__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderGetErrorHandler xmlTextReaderGetErrorHandler__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderGetParserColumnNumber
+extern __typeof (xmlTextReaderGetParserColumnNumber) xmlTextReaderGetParserColumnNumber __attribute((alias("xmlTextReaderGetParserColumnNumber__internal_alias")));
+#else
+#ifndef xmlTextReaderGetParserColumnNumber
+extern __typeof (xmlTextReaderGetParserColumnNumber) xmlTextReaderGetParserColumnNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderGetParserColumnNumber xmlTextReaderGetParserColumnNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderGetParserLineNumber
+extern __typeof (xmlTextReaderGetParserLineNumber) xmlTextReaderGetParserLineNumber __attribute((alias("xmlTextReaderGetParserLineNumber__internal_alias")));
+#else
+#ifndef xmlTextReaderGetParserLineNumber
+extern __typeof (xmlTextReaderGetParserLineNumber) xmlTextReaderGetParserLineNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderGetParserLineNumber xmlTextReaderGetParserLineNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderGetParserProp
+extern __typeof (xmlTextReaderGetParserProp) xmlTextReaderGetParserProp __attribute((alias("xmlTextReaderGetParserProp__internal_alias")));
+#else
+#ifndef xmlTextReaderGetParserProp
+extern __typeof (xmlTextReaderGetParserProp) xmlTextReaderGetParserProp__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderGetParserProp xmlTextReaderGetParserProp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderGetRemainder
+extern __typeof (xmlTextReaderGetRemainder) xmlTextReaderGetRemainder __attribute((alias("xmlTextReaderGetRemainder__internal_alias")));
+#else
+#ifndef xmlTextReaderGetRemainder
+extern __typeof (xmlTextReaderGetRemainder) xmlTextReaderGetRemainder__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderGetRemainder xmlTextReaderGetRemainder__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderHasAttributes
+extern __typeof (xmlTextReaderHasAttributes) xmlTextReaderHasAttributes __attribute((alias("xmlTextReaderHasAttributes__internal_alias")));
+#else
+#ifndef xmlTextReaderHasAttributes
+extern __typeof (xmlTextReaderHasAttributes) xmlTextReaderHasAttributes__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderHasAttributes xmlTextReaderHasAttributes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderHasValue
+extern __typeof (xmlTextReaderHasValue) xmlTextReaderHasValue __attribute((alias("xmlTextReaderHasValue__internal_alias")));
+#else
+#ifndef xmlTextReaderHasValue
+extern __typeof (xmlTextReaderHasValue) xmlTextReaderHasValue__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderHasValue xmlTextReaderHasValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderIsDefault
+extern __typeof (xmlTextReaderIsDefault) xmlTextReaderIsDefault __attribute((alias("xmlTextReaderIsDefault__internal_alias")));
+#else
+#ifndef xmlTextReaderIsDefault
+extern __typeof (xmlTextReaderIsDefault) xmlTextReaderIsDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderIsDefault xmlTextReaderIsDefault__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderIsEmptyElement
+extern __typeof (xmlTextReaderIsEmptyElement) xmlTextReaderIsEmptyElement __attribute((alias("xmlTextReaderIsEmptyElement__internal_alias")));
+#else
+#ifndef xmlTextReaderIsEmptyElement
+extern __typeof (xmlTextReaderIsEmptyElement) xmlTextReaderIsEmptyElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderIsEmptyElement xmlTextReaderIsEmptyElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderIsNamespaceDecl
+extern __typeof (xmlTextReaderIsNamespaceDecl) xmlTextReaderIsNamespaceDecl __attribute((alias("xmlTextReaderIsNamespaceDecl__internal_alias")));
+#else
+#ifndef xmlTextReaderIsNamespaceDecl
+extern __typeof (xmlTextReaderIsNamespaceDecl) xmlTextReaderIsNamespaceDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderIsNamespaceDecl xmlTextReaderIsNamespaceDecl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderIsValid
+extern __typeof (xmlTextReaderIsValid) xmlTextReaderIsValid __attribute((alias("xmlTextReaderIsValid__internal_alias")));
+#else
+#ifndef xmlTextReaderIsValid
+extern __typeof (xmlTextReaderIsValid) xmlTextReaderIsValid__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderIsValid xmlTextReaderIsValid__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderLocalName
+extern __typeof (xmlTextReaderLocalName) xmlTextReaderLocalName __attribute((alias("xmlTextReaderLocalName__internal_alias")));
+#else
+#ifndef xmlTextReaderLocalName
+extern __typeof (xmlTextReaderLocalName) xmlTextReaderLocalName__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderLocalName xmlTextReaderLocalName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderLocatorBaseURI
+extern __typeof (xmlTextReaderLocatorBaseURI) xmlTextReaderLocatorBaseURI __attribute((alias("xmlTextReaderLocatorBaseURI__internal_alias")));
+#else
+#ifndef xmlTextReaderLocatorBaseURI
+extern __typeof (xmlTextReaderLocatorBaseURI) xmlTextReaderLocatorBaseURI__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderLocatorBaseURI xmlTextReaderLocatorBaseURI__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderLocatorLineNumber
+extern __typeof (xmlTextReaderLocatorLineNumber) xmlTextReaderLocatorLineNumber __attribute((alias("xmlTextReaderLocatorLineNumber__internal_alias")));
+#else
+#ifndef xmlTextReaderLocatorLineNumber
+extern __typeof (xmlTextReaderLocatorLineNumber) xmlTextReaderLocatorLineNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderLocatorLineNumber xmlTextReaderLocatorLineNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderLookupNamespace
+extern __typeof (xmlTextReaderLookupNamespace) xmlTextReaderLookupNamespace __attribute((alias("xmlTextReaderLookupNamespace__internal_alias")));
+#else
+#ifndef xmlTextReaderLookupNamespace
+extern __typeof (xmlTextReaderLookupNamespace) xmlTextReaderLookupNamespace__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderLookupNamespace xmlTextReaderLookupNamespace__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderMoveToAttribute
+extern __typeof (xmlTextReaderMoveToAttribute) xmlTextReaderMoveToAttribute __attribute((alias("xmlTextReaderMoveToAttribute__internal_alias")));
+#else
+#ifndef xmlTextReaderMoveToAttribute
+extern __typeof (xmlTextReaderMoveToAttribute) xmlTextReaderMoveToAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderMoveToAttribute xmlTextReaderMoveToAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderMoveToAttributeNo
+extern __typeof (xmlTextReaderMoveToAttributeNo) xmlTextReaderMoveToAttributeNo __attribute((alias("xmlTextReaderMoveToAttributeNo__internal_alias")));
+#else
+#ifndef xmlTextReaderMoveToAttributeNo
+extern __typeof (xmlTextReaderMoveToAttributeNo) xmlTextReaderMoveToAttributeNo__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderMoveToAttributeNo xmlTextReaderMoveToAttributeNo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderMoveToAttributeNs
+extern __typeof (xmlTextReaderMoveToAttributeNs) xmlTextReaderMoveToAttributeNs __attribute((alias("xmlTextReaderMoveToAttributeNs__internal_alias")));
+#else
+#ifndef xmlTextReaderMoveToAttributeNs
+extern __typeof (xmlTextReaderMoveToAttributeNs) xmlTextReaderMoveToAttributeNs__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderMoveToAttributeNs xmlTextReaderMoveToAttributeNs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderMoveToElement
+extern __typeof (xmlTextReaderMoveToElement) xmlTextReaderMoveToElement __attribute((alias("xmlTextReaderMoveToElement__internal_alias")));
+#else
+#ifndef xmlTextReaderMoveToElement
+extern __typeof (xmlTextReaderMoveToElement) xmlTextReaderMoveToElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderMoveToElement xmlTextReaderMoveToElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderMoveToFirstAttribute
+extern __typeof (xmlTextReaderMoveToFirstAttribute) xmlTextReaderMoveToFirstAttribute __attribute((alias("xmlTextReaderMoveToFirstAttribute__internal_alias")));
+#else
+#ifndef xmlTextReaderMoveToFirstAttribute
+extern __typeof (xmlTextReaderMoveToFirstAttribute) xmlTextReaderMoveToFirstAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderMoveToFirstAttribute xmlTextReaderMoveToFirstAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderMoveToNextAttribute
+extern __typeof (xmlTextReaderMoveToNextAttribute) xmlTextReaderMoveToNextAttribute __attribute((alias("xmlTextReaderMoveToNextAttribute__internal_alias")));
+#else
+#ifndef xmlTextReaderMoveToNextAttribute
+extern __typeof (xmlTextReaderMoveToNextAttribute) xmlTextReaderMoveToNextAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderMoveToNextAttribute xmlTextReaderMoveToNextAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderName
+extern __typeof (xmlTextReaderName) xmlTextReaderName __attribute((alias("xmlTextReaderName__internal_alias")));
+#else
+#ifndef xmlTextReaderName
+extern __typeof (xmlTextReaderName) xmlTextReaderName__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderName xmlTextReaderName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderNamespaceUri
+extern __typeof (xmlTextReaderNamespaceUri) xmlTextReaderNamespaceUri __attribute((alias("xmlTextReaderNamespaceUri__internal_alias")));
+#else
+#ifndef xmlTextReaderNamespaceUri
+extern __typeof (xmlTextReaderNamespaceUri) xmlTextReaderNamespaceUri__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderNamespaceUri xmlTextReaderNamespaceUri__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderNext
+extern __typeof (xmlTextReaderNext) xmlTextReaderNext __attribute((alias("xmlTextReaderNext__internal_alias")));
+#else
+#ifndef xmlTextReaderNext
+extern __typeof (xmlTextReaderNext) xmlTextReaderNext__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderNext xmlTextReaderNext__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderNextSibling
+extern __typeof (xmlTextReaderNextSibling) xmlTextReaderNextSibling __attribute((alias("xmlTextReaderNextSibling__internal_alias")));
+#else
+#ifndef xmlTextReaderNextSibling
+extern __typeof (xmlTextReaderNextSibling) xmlTextReaderNextSibling__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderNextSibling xmlTextReaderNextSibling__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderNodeType
+extern __typeof (xmlTextReaderNodeType) xmlTextReaderNodeType __attribute((alias("xmlTextReaderNodeType__internal_alias")));
+#else
+#ifndef xmlTextReaderNodeType
+extern __typeof (xmlTextReaderNodeType) xmlTextReaderNodeType__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderNodeType xmlTextReaderNodeType__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderNormalization
+extern __typeof (xmlTextReaderNormalization) xmlTextReaderNormalization __attribute((alias("xmlTextReaderNormalization__internal_alias")));
+#else
+#ifndef xmlTextReaderNormalization
+extern __typeof (xmlTextReaderNormalization) xmlTextReaderNormalization__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderNormalization xmlTextReaderNormalization__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderPrefix
+extern __typeof (xmlTextReaderPrefix) xmlTextReaderPrefix __attribute((alias("xmlTextReaderPrefix__internal_alias")));
+#else
+#ifndef xmlTextReaderPrefix
+extern __typeof (xmlTextReaderPrefix) xmlTextReaderPrefix__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderPrefix xmlTextReaderPrefix__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderPreserve
+extern __typeof (xmlTextReaderPreserve) xmlTextReaderPreserve __attribute((alias("xmlTextReaderPreserve__internal_alias")));
+#else
+#ifndef xmlTextReaderPreserve
+extern __typeof (xmlTextReaderPreserve) xmlTextReaderPreserve__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderPreserve xmlTextReaderPreserve__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderPreservePattern
+extern __typeof (xmlTextReaderPreservePattern) xmlTextReaderPreservePattern __attribute((alias("xmlTextReaderPreservePattern__internal_alias")));
+#else
+#ifndef xmlTextReaderPreservePattern
+extern __typeof (xmlTextReaderPreservePattern) xmlTextReaderPreservePattern__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderPreservePattern xmlTextReaderPreservePattern__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderQuoteChar
+extern __typeof (xmlTextReaderQuoteChar) xmlTextReaderQuoteChar __attribute((alias("xmlTextReaderQuoteChar__internal_alias")));
+#else
+#ifndef xmlTextReaderQuoteChar
+extern __typeof (xmlTextReaderQuoteChar) xmlTextReaderQuoteChar__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderQuoteChar xmlTextReaderQuoteChar__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderRead
+extern __typeof (xmlTextReaderRead) xmlTextReaderRead __attribute((alias("xmlTextReaderRead__internal_alias")));
+#else
+#ifndef xmlTextReaderRead
+extern __typeof (xmlTextReaderRead) xmlTextReaderRead__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderRead xmlTextReaderRead__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderReadAttributeValue
+extern __typeof (xmlTextReaderReadAttributeValue) xmlTextReaderReadAttributeValue __attribute((alias("xmlTextReaderReadAttributeValue__internal_alias")));
+#else
+#ifndef xmlTextReaderReadAttributeValue
+extern __typeof (xmlTextReaderReadAttributeValue) xmlTextReaderReadAttributeValue__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderReadAttributeValue xmlTextReaderReadAttributeValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderReadInnerXml
+extern __typeof (xmlTextReaderReadInnerXml) xmlTextReaderReadInnerXml __attribute((alias("xmlTextReaderReadInnerXml__internal_alias")));
+#else
+#ifndef xmlTextReaderReadInnerXml
+extern __typeof (xmlTextReaderReadInnerXml) xmlTextReaderReadInnerXml__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderReadInnerXml xmlTextReaderReadInnerXml__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderReadOuterXml
+extern __typeof (xmlTextReaderReadOuterXml) xmlTextReaderReadOuterXml __attribute((alias("xmlTextReaderReadOuterXml__internal_alias")));
+#else
+#ifndef xmlTextReaderReadOuterXml
+extern __typeof (xmlTextReaderReadOuterXml) xmlTextReaderReadOuterXml__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderReadOuterXml xmlTextReaderReadOuterXml__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderReadState
+extern __typeof (xmlTextReaderReadState) xmlTextReaderReadState __attribute((alias("xmlTextReaderReadState__internal_alias")));
+#else
+#ifndef xmlTextReaderReadState
+extern __typeof (xmlTextReaderReadState) xmlTextReaderReadState__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderReadState xmlTextReaderReadState__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderReadString
+extern __typeof (xmlTextReaderReadString) xmlTextReaderReadString __attribute((alias("xmlTextReaderReadString__internal_alias")));
+#else
+#ifndef xmlTextReaderReadString
+extern __typeof (xmlTextReaderReadString) xmlTextReaderReadString__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderReadString xmlTextReaderReadString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderRelaxNGSetSchema
+extern __typeof (xmlTextReaderRelaxNGSetSchema) xmlTextReaderRelaxNGSetSchema __attribute((alias("xmlTextReaderRelaxNGSetSchema__internal_alias")));
+#else
+#ifndef xmlTextReaderRelaxNGSetSchema
+extern __typeof (xmlTextReaderRelaxNGSetSchema) xmlTextReaderRelaxNGSetSchema__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderRelaxNGSetSchema xmlTextReaderRelaxNGSetSchema__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderRelaxNGValidate
+extern __typeof (xmlTextReaderRelaxNGValidate) xmlTextReaderRelaxNGValidate __attribute((alias("xmlTextReaderRelaxNGValidate__internal_alias")));
+#else
+#ifndef xmlTextReaderRelaxNGValidate
+extern __typeof (xmlTextReaderRelaxNGValidate) xmlTextReaderRelaxNGValidate__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderRelaxNGValidate xmlTextReaderRelaxNGValidate__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderRelaxNGValidateCtxt
+extern __typeof (xmlTextReaderRelaxNGValidateCtxt) xmlTextReaderRelaxNGValidateCtxt __attribute((alias("xmlTextReaderRelaxNGValidateCtxt__internal_alias")));
+#else
+#ifndef xmlTextReaderRelaxNGValidateCtxt
+extern __typeof (xmlTextReaderRelaxNGValidateCtxt) xmlTextReaderRelaxNGValidateCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderRelaxNGValidateCtxt xmlTextReaderRelaxNGValidateCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderSchemaValidate
+extern __typeof (xmlTextReaderSchemaValidate) xmlTextReaderSchemaValidate __attribute((alias("xmlTextReaderSchemaValidate__internal_alias")));
+#else
+#ifndef xmlTextReaderSchemaValidate
+extern __typeof (xmlTextReaderSchemaValidate) xmlTextReaderSchemaValidate__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderSchemaValidate xmlTextReaderSchemaValidate__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderSchemaValidateCtxt
+extern __typeof (xmlTextReaderSchemaValidateCtxt) xmlTextReaderSchemaValidateCtxt __attribute((alias("xmlTextReaderSchemaValidateCtxt__internal_alias")));
+#else
+#ifndef xmlTextReaderSchemaValidateCtxt
+extern __typeof (xmlTextReaderSchemaValidateCtxt) xmlTextReaderSchemaValidateCtxt__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderSchemaValidateCtxt xmlTextReaderSchemaValidateCtxt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderSetErrorHandler
+extern __typeof (xmlTextReaderSetErrorHandler) xmlTextReaderSetErrorHandler __attribute((alias("xmlTextReaderSetErrorHandler__internal_alias")));
+#else
+#ifndef xmlTextReaderSetErrorHandler
+extern __typeof (xmlTextReaderSetErrorHandler) xmlTextReaderSetErrorHandler__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderSetErrorHandler xmlTextReaderSetErrorHandler__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderSetParserProp
+extern __typeof (xmlTextReaderSetParserProp) xmlTextReaderSetParserProp __attribute((alias("xmlTextReaderSetParserProp__internal_alias")));
+#else
+#ifndef xmlTextReaderSetParserProp
+extern __typeof (xmlTextReaderSetParserProp) xmlTextReaderSetParserProp__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderSetParserProp xmlTextReaderSetParserProp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderSetSchema
+extern __typeof (xmlTextReaderSetSchema) xmlTextReaderSetSchema __attribute((alias("xmlTextReaderSetSchema__internal_alias")));
+#else
+#ifndef xmlTextReaderSetSchema
+extern __typeof (xmlTextReaderSetSchema) xmlTextReaderSetSchema__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderSetSchema xmlTextReaderSetSchema__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderSetStructuredErrorHandler
+extern __typeof (xmlTextReaderSetStructuredErrorHandler) xmlTextReaderSetStructuredErrorHandler __attribute((alias("xmlTextReaderSetStructuredErrorHandler__internal_alias")));
+#else
+#ifndef xmlTextReaderSetStructuredErrorHandler
+extern __typeof (xmlTextReaderSetStructuredErrorHandler) xmlTextReaderSetStructuredErrorHandler__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderSetStructuredErrorHandler xmlTextReaderSetStructuredErrorHandler__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderSetup
+extern __typeof (xmlTextReaderSetup) xmlTextReaderSetup __attribute((alias("xmlTextReaderSetup__internal_alias")));
+#else
+#ifndef xmlTextReaderSetup
+extern __typeof (xmlTextReaderSetup) xmlTextReaderSetup__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderSetup xmlTextReaderSetup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderStandalone
+extern __typeof (xmlTextReaderStandalone) xmlTextReaderStandalone __attribute((alias("xmlTextReaderStandalone__internal_alias")));
+#else
+#ifndef xmlTextReaderStandalone
+extern __typeof (xmlTextReaderStandalone) xmlTextReaderStandalone__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderStandalone xmlTextReaderStandalone__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderValue
+extern __typeof (xmlTextReaderValue) xmlTextReaderValue __attribute((alias("xmlTextReaderValue__internal_alias")));
+#else
+#ifndef xmlTextReaderValue
+extern __typeof (xmlTextReaderValue) xmlTextReaderValue__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderValue xmlTextReaderValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_READER_ENABLED)
+#ifdef bottom_xmlreader
+#undef xmlTextReaderXmlLang
+extern __typeof (xmlTextReaderXmlLang) xmlTextReaderXmlLang __attribute((alias("xmlTextReaderXmlLang__internal_alias")));
+#else
+#ifndef xmlTextReaderXmlLang
+extern __typeof (xmlTextReaderXmlLang) xmlTextReaderXmlLang__internal_alias __attribute((visibility("hidden")));
+#define xmlTextReaderXmlLang xmlTextReaderXmlLang__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterEndAttribute
+extern __typeof (xmlTextWriterEndAttribute) xmlTextWriterEndAttribute __attribute((alias("xmlTextWriterEndAttribute__internal_alias")));
+#else
+#ifndef xmlTextWriterEndAttribute
+extern __typeof (xmlTextWriterEndAttribute) xmlTextWriterEndAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterEndAttribute xmlTextWriterEndAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterEndCDATA
+extern __typeof (xmlTextWriterEndCDATA) xmlTextWriterEndCDATA __attribute((alias("xmlTextWriterEndCDATA__internal_alias")));
+#else
+#ifndef xmlTextWriterEndCDATA
+extern __typeof (xmlTextWriterEndCDATA) xmlTextWriterEndCDATA__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterEndCDATA xmlTextWriterEndCDATA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterEndComment
+extern __typeof (xmlTextWriterEndComment) xmlTextWriterEndComment __attribute((alias("xmlTextWriterEndComment__internal_alias")));
+#else
+#ifndef xmlTextWriterEndComment
+extern __typeof (xmlTextWriterEndComment) xmlTextWriterEndComment__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterEndComment xmlTextWriterEndComment__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterEndDTD
+extern __typeof (xmlTextWriterEndDTD) xmlTextWriterEndDTD __attribute((alias("xmlTextWriterEndDTD__internal_alias")));
+#else
+#ifndef xmlTextWriterEndDTD
+extern __typeof (xmlTextWriterEndDTD) xmlTextWriterEndDTD__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterEndDTD xmlTextWriterEndDTD__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterEndDTDAttlist
+extern __typeof (xmlTextWriterEndDTDAttlist) xmlTextWriterEndDTDAttlist __attribute((alias("xmlTextWriterEndDTDAttlist__internal_alias")));
+#else
+#ifndef xmlTextWriterEndDTDAttlist
+extern __typeof (xmlTextWriterEndDTDAttlist) xmlTextWriterEndDTDAttlist__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterEndDTDAttlist xmlTextWriterEndDTDAttlist__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterEndDTDElement
+extern __typeof (xmlTextWriterEndDTDElement) xmlTextWriterEndDTDElement __attribute((alias("xmlTextWriterEndDTDElement__internal_alias")));
+#else
+#ifndef xmlTextWriterEndDTDElement
+extern __typeof (xmlTextWriterEndDTDElement) xmlTextWriterEndDTDElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterEndDTDElement xmlTextWriterEndDTDElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterEndDTDEntity
+extern __typeof (xmlTextWriterEndDTDEntity) xmlTextWriterEndDTDEntity __attribute((alias("xmlTextWriterEndDTDEntity__internal_alias")));
+#else
+#ifndef xmlTextWriterEndDTDEntity
+extern __typeof (xmlTextWriterEndDTDEntity) xmlTextWriterEndDTDEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterEndDTDEntity xmlTextWriterEndDTDEntity__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterEndDocument
+extern __typeof (xmlTextWriterEndDocument) xmlTextWriterEndDocument __attribute((alias("xmlTextWriterEndDocument__internal_alias")));
+#else
+#ifndef xmlTextWriterEndDocument
+extern __typeof (xmlTextWriterEndDocument) xmlTextWriterEndDocument__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterEndDocument xmlTextWriterEndDocument__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterEndElement
+extern __typeof (xmlTextWriterEndElement) xmlTextWriterEndElement __attribute((alias("xmlTextWriterEndElement__internal_alias")));
+#else
+#ifndef xmlTextWriterEndElement
+extern __typeof (xmlTextWriterEndElement) xmlTextWriterEndElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterEndElement xmlTextWriterEndElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterEndPI
+extern __typeof (xmlTextWriterEndPI) xmlTextWriterEndPI __attribute((alias("xmlTextWriterEndPI__internal_alias")));
+#else
+#ifndef xmlTextWriterEndPI
+extern __typeof (xmlTextWriterEndPI) xmlTextWriterEndPI__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterEndPI xmlTextWriterEndPI__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterFlush
+extern __typeof (xmlTextWriterFlush) xmlTextWriterFlush __attribute((alias("xmlTextWriterFlush__internal_alias")));
+#else
+#ifndef xmlTextWriterFlush
+extern __typeof (xmlTextWriterFlush) xmlTextWriterFlush__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterFlush xmlTextWriterFlush__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterFullEndElement
+extern __typeof (xmlTextWriterFullEndElement) xmlTextWriterFullEndElement __attribute((alias("xmlTextWriterFullEndElement__internal_alias")));
+#else
+#ifndef xmlTextWriterFullEndElement
+extern __typeof (xmlTextWriterFullEndElement) xmlTextWriterFullEndElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterFullEndElement xmlTextWriterFullEndElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterSetIndent
+extern __typeof (xmlTextWriterSetIndent) xmlTextWriterSetIndent __attribute((alias("xmlTextWriterSetIndent__internal_alias")));
+#else
+#ifndef xmlTextWriterSetIndent
+extern __typeof (xmlTextWriterSetIndent) xmlTextWriterSetIndent__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterSetIndent xmlTextWriterSetIndent__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterSetIndentString
+extern __typeof (xmlTextWriterSetIndentString) xmlTextWriterSetIndentString __attribute((alias("xmlTextWriterSetIndentString__internal_alias")));
+#else
+#ifndef xmlTextWriterSetIndentString
+extern __typeof (xmlTextWriterSetIndentString) xmlTextWriterSetIndentString__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterSetIndentString xmlTextWriterSetIndentString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterSetQuoteChar
+extern __typeof (xmlTextWriterSetQuoteChar) xmlTextWriterSetQuoteChar __attribute((alias("xmlTextWriterSetQuoteChar__internal_alias")));
+#else
+#ifndef xmlTextWriterSetQuoteChar
+extern __typeof (xmlTextWriterSetQuoteChar) xmlTextWriterSetQuoteChar__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterSetQuoteChar xmlTextWriterSetQuoteChar__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartAttribute
+extern __typeof (xmlTextWriterStartAttribute) xmlTextWriterStartAttribute __attribute((alias("xmlTextWriterStartAttribute__internal_alias")));
+#else
+#ifndef xmlTextWriterStartAttribute
+extern __typeof (xmlTextWriterStartAttribute) xmlTextWriterStartAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartAttribute xmlTextWriterStartAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartAttributeNS
+extern __typeof (xmlTextWriterStartAttributeNS) xmlTextWriterStartAttributeNS __attribute((alias("xmlTextWriterStartAttributeNS__internal_alias")));
+#else
+#ifndef xmlTextWriterStartAttributeNS
+extern __typeof (xmlTextWriterStartAttributeNS) xmlTextWriterStartAttributeNS__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartAttributeNS xmlTextWriterStartAttributeNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartCDATA
+extern __typeof (xmlTextWriterStartCDATA) xmlTextWriterStartCDATA __attribute((alias("xmlTextWriterStartCDATA__internal_alias")));
+#else
+#ifndef xmlTextWriterStartCDATA
+extern __typeof (xmlTextWriterStartCDATA) xmlTextWriterStartCDATA__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartCDATA xmlTextWriterStartCDATA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartComment
+extern __typeof (xmlTextWriterStartComment) xmlTextWriterStartComment __attribute((alias("xmlTextWriterStartComment__internal_alias")));
+#else
+#ifndef xmlTextWriterStartComment
+extern __typeof (xmlTextWriterStartComment) xmlTextWriterStartComment__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartComment xmlTextWriterStartComment__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartDTD
+extern __typeof (xmlTextWriterStartDTD) xmlTextWriterStartDTD __attribute((alias("xmlTextWriterStartDTD__internal_alias")));
+#else
+#ifndef xmlTextWriterStartDTD
+extern __typeof (xmlTextWriterStartDTD) xmlTextWriterStartDTD__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartDTD xmlTextWriterStartDTD__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartDTDAttlist
+extern __typeof (xmlTextWriterStartDTDAttlist) xmlTextWriterStartDTDAttlist __attribute((alias("xmlTextWriterStartDTDAttlist__internal_alias")));
+#else
+#ifndef xmlTextWriterStartDTDAttlist
+extern __typeof (xmlTextWriterStartDTDAttlist) xmlTextWriterStartDTDAttlist__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartDTDAttlist xmlTextWriterStartDTDAttlist__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartDTDElement
+extern __typeof (xmlTextWriterStartDTDElement) xmlTextWriterStartDTDElement __attribute((alias("xmlTextWriterStartDTDElement__internal_alias")));
+#else
+#ifndef xmlTextWriterStartDTDElement
+extern __typeof (xmlTextWriterStartDTDElement) xmlTextWriterStartDTDElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartDTDElement xmlTextWriterStartDTDElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartDTDEntity
+extern __typeof (xmlTextWriterStartDTDEntity) xmlTextWriterStartDTDEntity __attribute((alias("xmlTextWriterStartDTDEntity__internal_alias")));
+#else
+#ifndef xmlTextWriterStartDTDEntity
+extern __typeof (xmlTextWriterStartDTDEntity) xmlTextWriterStartDTDEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartDTDEntity xmlTextWriterStartDTDEntity__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartDocument
+extern __typeof (xmlTextWriterStartDocument) xmlTextWriterStartDocument __attribute((alias("xmlTextWriterStartDocument__internal_alias")));
+#else
+#ifndef xmlTextWriterStartDocument
+extern __typeof (xmlTextWriterStartDocument) xmlTextWriterStartDocument__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartDocument xmlTextWriterStartDocument__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartElement
+extern __typeof (xmlTextWriterStartElement) xmlTextWriterStartElement __attribute((alias("xmlTextWriterStartElement__internal_alias")));
+#else
+#ifndef xmlTextWriterStartElement
+extern __typeof (xmlTextWriterStartElement) xmlTextWriterStartElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartElement xmlTextWriterStartElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartElementNS
+extern __typeof (xmlTextWriterStartElementNS) xmlTextWriterStartElementNS __attribute((alias("xmlTextWriterStartElementNS__internal_alias")));
+#else
+#ifndef xmlTextWriterStartElementNS
+extern __typeof (xmlTextWriterStartElementNS) xmlTextWriterStartElementNS__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartElementNS xmlTextWriterStartElementNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterStartPI
+extern __typeof (xmlTextWriterStartPI) xmlTextWriterStartPI __attribute((alias("xmlTextWriterStartPI__internal_alias")));
+#else
+#ifndef xmlTextWriterStartPI
+extern __typeof (xmlTextWriterStartPI) xmlTextWriterStartPI__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterStartPI xmlTextWriterStartPI__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteAttribute
+extern __typeof (xmlTextWriterWriteAttribute) xmlTextWriterWriteAttribute __attribute((alias("xmlTextWriterWriteAttribute__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteAttribute
+extern __typeof (xmlTextWriterWriteAttribute) xmlTextWriterWriteAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteAttribute xmlTextWriterWriteAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteAttributeNS
+extern __typeof (xmlTextWriterWriteAttributeNS) xmlTextWriterWriteAttributeNS __attribute((alias("xmlTextWriterWriteAttributeNS__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteAttributeNS
+extern __typeof (xmlTextWriterWriteAttributeNS) xmlTextWriterWriteAttributeNS__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteAttributeNS xmlTextWriterWriteAttributeNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteBase64
+extern __typeof (xmlTextWriterWriteBase64) xmlTextWriterWriteBase64 __attribute((alias("xmlTextWriterWriteBase64__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteBase64
+extern __typeof (xmlTextWriterWriteBase64) xmlTextWriterWriteBase64__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteBase64 xmlTextWriterWriteBase64__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteBinHex
+extern __typeof (xmlTextWriterWriteBinHex) xmlTextWriterWriteBinHex __attribute((alias("xmlTextWriterWriteBinHex__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteBinHex
+extern __typeof (xmlTextWriterWriteBinHex) xmlTextWriterWriteBinHex__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteBinHex xmlTextWriterWriteBinHex__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteCDATA
+extern __typeof (xmlTextWriterWriteCDATA) xmlTextWriterWriteCDATA __attribute((alias("xmlTextWriterWriteCDATA__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteCDATA
+extern __typeof (xmlTextWriterWriteCDATA) xmlTextWriterWriteCDATA__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteCDATA xmlTextWriterWriteCDATA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteComment
+extern __typeof (xmlTextWriterWriteComment) xmlTextWriterWriteComment __attribute((alias("xmlTextWriterWriteComment__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteComment
+extern __typeof (xmlTextWriterWriteComment) xmlTextWriterWriteComment__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteComment xmlTextWriterWriteComment__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteDTD
+extern __typeof (xmlTextWriterWriteDTD) xmlTextWriterWriteDTD __attribute((alias("xmlTextWriterWriteDTD__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteDTD
+extern __typeof (xmlTextWriterWriteDTD) xmlTextWriterWriteDTD__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteDTD xmlTextWriterWriteDTD__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteDTDAttlist
+extern __typeof (xmlTextWriterWriteDTDAttlist) xmlTextWriterWriteDTDAttlist __attribute((alias("xmlTextWriterWriteDTDAttlist__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteDTDAttlist
+extern __typeof (xmlTextWriterWriteDTDAttlist) xmlTextWriterWriteDTDAttlist__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteDTDAttlist xmlTextWriterWriteDTDAttlist__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteDTDElement
+extern __typeof (xmlTextWriterWriteDTDElement) xmlTextWriterWriteDTDElement __attribute((alias("xmlTextWriterWriteDTDElement__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteDTDElement
+extern __typeof (xmlTextWriterWriteDTDElement) xmlTextWriterWriteDTDElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteDTDElement xmlTextWriterWriteDTDElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteDTDEntity
+extern __typeof (xmlTextWriterWriteDTDEntity) xmlTextWriterWriteDTDEntity __attribute((alias("xmlTextWriterWriteDTDEntity__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteDTDEntity
+extern __typeof (xmlTextWriterWriteDTDEntity) xmlTextWriterWriteDTDEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteDTDEntity xmlTextWriterWriteDTDEntity__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteDTDExternalEntity
+extern __typeof (xmlTextWriterWriteDTDExternalEntity) xmlTextWriterWriteDTDExternalEntity __attribute((alias("xmlTextWriterWriteDTDExternalEntity__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteDTDExternalEntity
+extern __typeof (xmlTextWriterWriteDTDExternalEntity) xmlTextWriterWriteDTDExternalEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteDTDExternalEntity xmlTextWriterWriteDTDExternalEntity__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteDTDExternalEntityContents
+extern __typeof (xmlTextWriterWriteDTDExternalEntityContents) xmlTextWriterWriteDTDExternalEntityContents __attribute((alias("xmlTextWriterWriteDTDExternalEntityContents__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteDTDExternalEntityContents
+extern __typeof (xmlTextWriterWriteDTDExternalEntityContents) xmlTextWriterWriteDTDExternalEntityContents__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteDTDExternalEntityContents xmlTextWriterWriteDTDExternalEntityContents__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteDTDInternalEntity
+extern __typeof (xmlTextWriterWriteDTDInternalEntity) xmlTextWriterWriteDTDInternalEntity __attribute((alias("xmlTextWriterWriteDTDInternalEntity__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteDTDInternalEntity
+extern __typeof (xmlTextWriterWriteDTDInternalEntity) xmlTextWriterWriteDTDInternalEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteDTDInternalEntity xmlTextWriterWriteDTDInternalEntity__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteDTDNotation
+extern __typeof (xmlTextWriterWriteDTDNotation) xmlTextWriterWriteDTDNotation __attribute((alias("xmlTextWriterWriteDTDNotation__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteDTDNotation
+extern __typeof (xmlTextWriterWriteDTDNotation) xmlTextWriterWriteDTDNotation__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteDTDNotation xmlTextWriterWriteDTDNotation__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteElement
+extern __typeof (xmlTextWriterWriteElement) xmlTextWriterWriteElement __attribute((alias("xmlTextWriterWriteElement__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteElement
+extern __typeof (xmlTextWriterWriteElement) xmlTextWriterWriteElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteElement xmlTextWriterWriteElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteElementNS
+extern __typeof (xmlTextWriterWriteElementNS) xmlTextWriterWriteElementNS __attribute((alias("xmlTextWriterWriteElementNS__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteElementNS
+extern __typeof (xmlTextWriterWriteElementNS) xmlTextWriterWriteElementNS__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteElementNS xmlTextWriterWriteElementNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatAttribute
+extern __typeof (xmlTextWriterWriteFormatAttribute) xmlTextWriterWriteFormatAttribute __attribute((alias("xmlTextWriterWriteFormatAttribute__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatAttribute
+extern __typeof (xmlTextWriterWriteFormatAttribute) xmlTextWriterWriteFormatAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatAttribute xmlTextWriterWriteFormatAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatAttributeNS
+extern __typeof (xmlTextWriterWriteFormatAttributeNS) xmlTextWriterWriteFormatAttributeNS __attribute((alias("xmlTextWriterWriteFormatAttributeNS__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatAttributeNS
+extern __typeof (xmlTextWriterWriteFormatAttributeNS) xmlTextWriterWriteFormatAttributeNS__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatAttributeNS xmlTextWriterWriteFormatAttributeNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatCDATA
+extern __typeof (xmlTextWriterWriteFormatCDATA) xmlTextWriterWriteFormatCDATA __attribute((alias("xmlTextWriterWriteFormatCDATA__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatCDATA
+extern __typeof (xmlTextWriterWriteFormatCDATA) xmlTextWriterWriteFormatCDATA__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatCDATA xmlTextWriterWriteFormatCDATA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatComment
+extern __typeof (xmlTextWriterWriteFormatComment) xmlTextWriterWriteFormatComment __attribute((alias("xmlTextWriterWriteFormatComment__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatComment
+extern __typeof (xmlTextWriterWriteFormatComment) xmlTextWriterWriteFormatComment__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatComment xmlTextWriterWriteFormatComment__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatDTD
+extern __typeof (xmlTextWriterWriteFormatDTD) xmlTextWriterWriteFormatDTD __attribute((alias("xmlTextWriterWriteFormatDTD__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatDTD
+extern __typeof (xmlTextWriterWriteFormatDTD) xmlTextWriterWriteFormatDTD__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatDTD xmlTextWriterWriteFormatDTD__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatDTDAttlist
+extern __typeof (xmlTextWriterWriteFormatDTDAttlist) xmlTextWriterWriteFormatDTDAttlist __attribute((alias("xmlTextWriterWriteFormatDTDAttlist__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatDTDAttlist
+extern __typeof (xmlTextWriterWriteFormatDTDAttlist) xmlTextWriterWriteFormatDTDAttlist__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatDTDAttlist xmlTextWriterWriteFormatDTDAttlist__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatDTDElement
+extern __typeof (xmlTextWriterWriteFormatDTDElement) xmlTextWriterWriteFormatDTDElement __attribute((alias("xmlTextWriterWriteFormatDTDElement__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatDTDElement
+extern __typeof (xmlTextWriterWriteFormatDTDElement) xmlTextWriterWriteFormatDTDElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatDTDElement xmlTextWriterWriteFormatDTDElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatDTDInternalEntity
+extern __typeof (xmlTextWriterWriteFormatDTDInternalEntity) xmlTextWriterWriteFormatDTDInternalEntity __attribute((alias("xmlTextWriterWriteFormatDTDInternalEntity__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatDTDInternalEntity
+extern __typeof (xmlTextWriterWriteFormatDTDInternalEntity) xmlTextWriterWriteFormatDTDInternalEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatDTDInternalEntity xmlTextWriterWriteFormatDTDInternalEntity__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatElement
+extern __typeof (xmlTextWriterWriteFormatElement) xmlTextWriterWriteFormatElement __attribute((alias("xmlTextWriterWriteFormatElement__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatElement
+extern __typeof (xmlTextWriterWriteFormatElement) xmlTextWriterWriteFormatElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatElement xmlTextWriterWriteFormatElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatElementNS
+extern __typeof (xmlTextWriterWriteFormatElementNS) xmlTextWriterWriteFormatElementNS __attribute((alias("xmlTextWriterWriteFormatElementNS__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatElementNS
+extern __typeof (xmlTextWriterWriteFormatElementNS) xmlTextWriterWriteFormatElementNS__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatElementNS xmlTextWriterWriteFormatElementNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatPI
+extern __typeof (xmlTextWriterWriteFormatPI) xmlTextWriterWriteFormatPI __attribute((alias("xmlTextWriterWriteFormatPI__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatPI
+extern __typeof (xmlTextWriterWriteFormatPI) xmlTextWriterWriteFormatPI__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatPI xmlTextWriterWriteFormatPI__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatRaw
+extern __typeof (xmlTextWriterWriteFormatRaw) xmlTextWriterWriteFormatRaw __attribute((alias("xmlTextWriterWriteFormatRaw__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatRaw
+extern __typeof (xmlTextWriterWriteFormatRaw) xmlTextWriterWriteFormatRaw__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatRaw xmlTextWriterWriteFormatRaw__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteFormatString
+extern __typeof (xmlTextWriterWriteFormatString) xmlTextWriterWriteFormatString __attribute((alias("xmlTextWriterWriteFormatString__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteFormatString
+extern __typeof (xmlTextWriterWriteFormatString) xmlTextWriterWriteFormatString__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteFormatString xmlTextWriterWriteFormatString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWritePI
+extern __typeof (xmlTextWriterWritePI) xmlTextWriterWritePI __attribute((alias("xmlTextWriterWritePI__internal_alias")));
+#else
+#ifndef xmlTextWriterWritePI
+extern __typeof (xmlTextWriterWritePI) xmlTextWriterWritePI__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWritePI xmlTextWriterWritePI__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteRaw
+extern __typeof (xmlTextWriterWriteRaw) xmlTextWriterWriteRaw __attribute((alias("xmlTextWriterWriteRaw__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteRaw
+extern __typeof (xmlTextWriterWriteRaw) xmlTextWriterWriteRaw__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteRaw xmlTextWriterWriteRaw__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteRawLen
+extern __typeof (xmlTextWriterWriteRawLen) xmlTextWriterWriteRawLen __attribute((alias("xmlTextWriterWriteRawLen__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteRawLen
+extern __typeof (xmlTextWriterWriteRawLen) xmlTextWriterWriteRawLen__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteRawLen xmlTextWriterWriteRawLen__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteString
+extern __typeof (xmlTextWriterWriteString) xmlTextWriterWriteString __attribute((alias("xmlTextWriterWriteString__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteString
+extern __typeof (xmlTextWriterWriteString) xmlTextWriterWriteString__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteString xmlTextWriterWriteString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatAttribute
+extern __typeof (xmlTextWriterWriteVFormatAttribute) xmlTextWriterWriteVFormatAttribute __attribute((alias("xmlTextWriterWriteVFormatAttribute__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatAttribute
+extern __typeof (xmlTextWriterWriteVFormatAttribute) xmlTextWriterWriteVFormatAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatAttribute xmlTextWriterWriteVFormatAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatAttributeNS
+extern __typeof (xmlTextWriterWriteVFormatAttributeNS) xmlTextWriterWriteVFormatAttributeNS __attribute((alias("xmlTextWriterWriteVFormatAttributeNS__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatAttributeNS
+extern __typeof (xmlTextWriterWriteVFormatAttributeNS) xmlTextWriterWriteVFormatAttributeNS__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatAttributeNS xmlTextWriterWriteVFormatAttributeNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatCDATA
+extern __typeof (xmlTextWriterWriteVFormatCDATA) xmlTextWriterWriteVFormatCDATA __attribute((alias("xmlTextWriterWriteVFormatCDATA__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatCDATA
+extern __typeof (xmlTextWriterWriteVFormatCDATA) xmlTextWriterWriteVFormatCDATA__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatCDATA xmlTextWriterWriteVFormatCDATA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatComment
+extern __typeof (xmlTextWriterWriteVFormatComment) xmlTextWriterWriteVFormatComment __attribute((alias("xmlTextWriterWriteVFormatComment__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatComment
+extern __typeof (xmlTextWriterWriteVFormatComment) xmlTextWriterWriteVFormatComment__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatComment xmlTextWriterWriteVFormatComment__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatDTD
+extern __typeof (xmlTextWriterWriteVFormatDTD) xmlTextWriterWriteVFormatDTD __attribute((alias("xmlTextWriterWriteVFormatDTD__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatDTD
+extern __typeof (xmlTextWriterWriteVFormatDTD) xmlTextWriterWriteVFormatDTD__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatDTD xmlTextWriterWriteVFormatDTD__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatDTDAttlist
+extern __typeof (xmlTextWriterWriteVFormatDTDAttlist) xmlTextWriterWriteVFormatDTDAttlist __attribute((alias("xmlTextWriterWriteVFormatDTDAttlist__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatDTDAttlist
+extern __typeof (xmlTextWriterWriteVFormatDTDAttlist) xmlTextWriterWriteVFormatDTDAttlist__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatDTDAttlist xmlTextWriterWriteVFormatDTDAttlist__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatDTDElement
+extern __typeof (xmlTextWriterWriteVFormatDTDElement) xmlTextWriterWriteVFormatDTDElement __attribute((alias("xmlTextWriterWriteVFormatDTDElement__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatDTDElement
+extern __typeof (xmlTextWriterWriteVFormatDTDElement) xmlTextWriterWriteVFormatDTDElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatDTDElement xmlTextWriterWriteVFormatDTDElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatDTDInternalEntity
+extern __typeof (xmlTextWriterWriteVFormatDTDInternalEntity) xmlTextWriterWriteVFormatDTDInternalEntity __attribute((alias("xmlTextWriterWriteVFormatDTDInternalEntity__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatDTDInternalEntity
+extern __typeof (xmlTextWriterWriteVFormatDTDInternalEntity) xmlTextWriterWriteVFormatDTDInternalEntity__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatDTDInternalEntity xmlTextWriterWriteVFormatDTDInternalEntity__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatElement
+extern __typeof (xmlTextWriterWriteVFormatElement) xmlTextWriterWriteVFormatElement __attribute((alias("xmlTextWriterWriteVFormatElement__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatElement
+extern __typeof (xmlTextWriterWriteVFormatElement) xmlTextWriterWriteVFormatElement__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatElement xmlTextWriterWriteVFormatElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatElementNS
+extern __typeof (xmlTextWriterWriteVFormatElementNS) xmlTextWriterWriteVFormatElementNS __attribute((alias("xmlTextWriterWriteVFormatElementNS__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatElementNS
+extern __typeof (xmlTextWriterWriteVFormatElementNS) xmlTextWriterWriteVFormatElementNS__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatElementNS xmlTextWriterWriteVFormatElementNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatPI
+extern __typeof (xmlTextWriterWriteVFormatPI) xmlTextWriterWriteVFormatPI __attribute((alias("xmlTextWriterWriteVFormatPI__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatPI
+extern __typeof (xmlTextWriterWriteVFormatPI) xmlTextWriterWriteVFormatPI__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatPI xmlTextWriterWriteVFormatPI__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatRaw
+extern __typeof (xmlTextWriterWriteVFormatRaw) xmlTextWriterWriteVFormatRaw __attribute((alias("xmlTextWriterWriteVFormatRaw__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatRaw
+extern __typeof (xmlTextWriterWriteVFormatRaw) xmlTextWriterWriteVFormatRaw__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatRaw xmlTextWriterWriteVFormatRaw__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_WRITER_ENABLED)
+#ifdef bottom_xmlwriter
+#undef xmlTextWriterWriteVFormatString
+extern __typeof (xmlTextWriterWriteVFormatString) xmlTextWriterWriteVFormatString __attribute((alias("xmlTextWriterWriteVFormatString__internal_alias")));
+#else
+#ifndef xmlTextWriterWriteVFormatString
+extern __typeof (xmlTextWriterWriteVFormatString) xmlTextWriterWriteVFormatString__internal_alias __attribute((visibility("hidden")));
+#define xmlTextWriterWriteVFormatString xmlTextWriterWriteVFormatString__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefBufferAllocScheme
+extern __typeof (xmlThrDefBufferAllocScheme) xmlThrDefBufferAllocScheme __attribute((alias("xmlThrDefBufferAllocScheme__internal_alias")));
+#else
+#ifndef xmlThrDefBufferAllocScheme
+extern __typeof (xmlThrDefBufferAllocScheme) xmlThrDefBufferAllocScheme__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefBufferAllocScheme xmlThrDefBufferAllocScheme__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefDefaultBufferSize
+extern __typeof (xmlThrDefDefaultBufferSize) xmlThrDefDefaultBufferSize __attribute((alias("xmlThrDefDefaultBufferSize__internal_alias")));
+#else
+#ifndef xmlThrDefDefaultBufferSize
+extern __typeof (xmlThrDefDefaultBufferSize) xmlThrDefDefaultBufferSize__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefDefaultBufferSize xmlThrDefDefaultBufferSize__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefDeregisterNodeDefault
+extern __typeof (xmlThrDefDeregisterNodeDefault) xmlThrDefDeregisterNodeDefault __attribute((alias("xmlThrDefDeregisterNodeDefault__internal_alias")));
+#else
+#ifndef xmlThrDefDeregisterNodeDefault
+extern __typeof (xmlThrDefDeregisterNodeDefault) xmlThrDefDeregisterNodeDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefDeregisterNodeDefault xmlThrDefDeregisterNodeDefault__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefDoValidityCheckingDefaultValue
+extern __typeof (xmlThrDefDoValidityCheckingDefaultValue) xmlThrDefDoValidityCheckingDefaultValue __attribute((alias("xmlThrDefDoValidityCheckingDefaultValue__internal_alias")));
+#else
+#ifndef xmlThrDefDoValidityCheckingDefaultValue
+extern __typeof (xmlThrDefDoValidityCheckingDefaultValue) xmlThrDefDoValidityCheckingDefaultValue__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefDoValidityCheckingDefaultValue xmlThrDefDoValidityCheckingDefaultValue__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefGetWarningsDefaultValue
+extern __typeof (xmlThrDefGetWarningsDefaultValue) xmlThrDefGetWarningsDefaultValue __attribute((alias("xmlThrDefGetWarningsDefaultValue__internal_alias")));
+#else
+#ifndef xmlThrDefGetWarningsDefaultValue
+extern __typeof (xmlThrDefGetWarningsDefaultValue) xmlThrDefGetWarningsDefaultValue__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefGetWarningsDefaultValue xmlThrDefGetWarningsDefaultValue__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefIndentTreeOutput
+extern __typeof (xmlThrDefIndentTreeOutput) xmlThrDefIndentTreeOutput __attribute((alias("xmlThrDefIndentTreeOutput__internal_alias")));
+#else
+#ifndef xmlThrDefIndentTreeOutput
+extern __typeof (xmlThrDefIndentTreeOutput) xmlThrDefIndentTreeOutput__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefIndentTreeOutput xmlThrDefIndentTreeOutput__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefKeepBlanksDefaultValue
+extern __typeof (xmlThrDefKeepBlanksDefaultValue) xmlThrDefKeepBlanksDefaultValue __attribute((alias("xmlThrDefKeepBlanksDefaultValue__internal_alias")));
+#else
+#ifndef xmlThrDefKeepBlanksDefaultValue
+extern __typeof (xmlThrDefKeepBlanksDefaultValue) xmlThrDefKeepBlanksDefaultValue__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefKeepBlanksDefaultValue xmlThrDefKeepBlanksDefaultValue__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefLineNumbersDefaultValue
+extern __typeof (xmlThrDefLineNumbersDefaultValue) xmlThrDefLineNumbersDefaultValue __attribute((alias("xmlThrDefLineNumbersDefaultValue__internal_alias")));
+#else
+#ifndef xmlThrDefLineNumbersDefaultValue
+extern __typeof (xmlThrDefLineNumbersDefaultValue) xmlThrDefLineNumbersDefaultValue__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefLineNumbersDefaultValue xmlThrDefLineNumbersDefaultValue__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefLoadExtDtdDefaultValue
+extern __typeof (xmlThrDefLoadExtDtdDefaultValue) xmlThrDefLoadExtDtdDefaultValue __attribute((alias("xmlThrDefLoadExtDtdDefaultValue__internal_alias")));
+#else
+#ifndef xmlThrDefLoadExtDtdDefaultValue
+extern __typeof (xmlThrDefLoadExtDtdDefaultValue) xmlThrDefLoadExtDtdDefaultValue__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefLoadExtDtdDefaultValue xmlThrDefLoadExtDtdDefaultValue__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefOutputBufferCreateFilenameDefault
+extern __typeof (xmlThrDefOutputBufferCreateFilenameDefault) xmlThrDefOutputBufferCreateFilenameDefault __attribute((alias("xmlThrDefOutputBufferCreateFilenameDefault__internal_alias")));
+#else
+#ifndef xmlThrDefOutputBufferCreateFilenameDefault
+extern __typeof (xmlThrDefOutputBufferCreateFilenameDefault) xmlThrDefOutputBufferCreateFilenameDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefOutputBufferCreateFilenameDefault xmlThrDefOutputBufferCreateFilenameDefault__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefParserDebugEntities
+extern __typeof (xmlThrDefParserDebugEntities) xmlThrDefParserDebugEntities __attribute((alias("xmlThrDefParserDebugEntities__internal_alias")));
+#else
+#ifndef xmlThrDefParserDebugEntities
+extern __typeof (xmlThrDefParserDebugEntities) xmlThrDefParserDebugEntities__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefParserDebugEntities xmlThrDefParserDebugEntities__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefParserInputBufferCreateFilenameDefault
+extern __typeof (xmlThrDefParserInputBufferCreateFilenameDefault) xmlThrDefParserInputBufferCreateFilenameDefault __attribute((alias("xmlThrDefParserInputBufferCreateFilenameDefault__internal_alias")));
+#else
+#ifndef xmlThrDefParserInputBufferCreateFilenameDefault
+extern __typeof (xmlThrDefParserInputBufferCreateFilenameDefault) xmlThrDefParserInputBufferCreateFilenameDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefParserInputBufferCreateFilenameDefault xmlThrDefParserInputBufferCreateFilenameDefault__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefPedanticParserDefaultValue
+extern __typeof (xmlThrDefPedanticParserDefaultValue) xmlThrDefPedanticParserDefaultValue __attribute((alias("xmlThrDefPedanticParserDefaultValue__internal_alias")));
+#else
+#ifndef xmlThrDefPedanticParserDefaultValue
+extern __typeof (xmlThrDefPedanticParserDefaultValue) xmlThrDefPedanticParserDefaultValue__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefPedanticParserDefaultValue xmlThrDefPedanticParserDefaultValue__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefRegisterNodeDefault
+extern __typeof (xmlThrDefRegisterNodeDefault) xmlThrDefRegisterNodeDefault __attribute((alias("xmlThrDefRegisterNodeDefault__internal_alias")));
+#else
+#ifndef xmlThrDefRegisterNodeDefault
+extern __typeof (xmlThrDefRegisterNodeDefault) xmlThrDefRegisterNodeDefault__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefRegisterNodeDefault xmlThrDefRegisterNodeDefault__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefSaveNoEmptyTags
+extern __typeof (xmlThrDefSaveNoEmptyTags) xmlThrDefSaveNoEmptyTags __attribute((alias("xmlThrDefSaveNoEmptyTags__internal_alias")));
+#else
+#ifndef xmlThrDefSaveNoEmptyTags
+extern __typeof (xmlThrDefSaveNoEmptyTags) xmlThrDefSaveNoEmptyTags__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefSaveNoEmptyTags xmlThrDefSaveNoEmptyTags__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefSetGenericErrorFunc
+extern __typeof (xmlThrDefSetGenericErrorFunc) xmlThrDefSetGenericErrorFunc __attribute((alias("xmlThrDefSetGenericErrorFunc__internal_alias")));
+#else
+#ifndef xmlThrDefSetGenericErrorFunc
+extern __typeof (xmlThrDefSetGenericErrorFunc) xmlThrDefSetGenericErrorFunc__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefSetGenericErrorFunc xmlThrDefSetGenericErrorFunc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefSetStructuredErrorFunc
+extern __typeof (xmlThrDefSetStructuredErrorFunc) xmlThrDefSetStructuredErrorFunc __attribute((alias("xmlThrDefSetStructuredErrorFunc__internal_alias")));
+#else
+#ifndef xmlThrDefSetStructuredErrorFunc
+extern __typeof (xmlThrDefSetStructuredErrorFunc) xmlThrDefSetStructuredErrorFunc__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefSetStructuredErrorFunc xmlThrDefSetStructuredErrorFunc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefSubstituteEntitiesDefaultValue
+extern __typeof (xmlThrDefSubstituteEntitiesDefaultValue) xmlThrDefSubstituteEntitiesDefaultValue __attribute((alias("xmlThrDefSubstituteEntitiesDefaultValue__internal_alias")));
+#else
+#ifndef xmlThrDefSubstituteEntitiesDefaultValue
+extern __typeof (xmlThrDefSubstituteEntitiesDefaultValue) xmlThrDefSubstituteEntitiesDefaultValue__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefSubstituteEntitiesDefaultValue xmlThrDefSubstituteEntitiesDefaultValue__internal_alias
+#endif
+#endif
+
+#ifdef bottom_globals
+#undef xmlThrDefTreeIndentString
+extern __typeof (xmlThrDefTreeIndentString) xmlThrDefTreeIndentString __attribute((alias("xmlThrDefTreeIndentString__internal_alias")));
+#else
+#ifndef xmlThrDefTreeIndentString
+extern __typeof (xmlThrDefTreeIndentString) xmlThrDefTreeIndentString__internal_alias __attribute((visibility("hidden")));
+#define xmlThrDefTreeIndentString xmlThrDefTreeIndentString__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsAegeanNumbers
+extern __typeof (xmlUCSIsAegeanNumbers) xmlUCSIsAegeanNumbers __attribute((alias("xmlUCSIsAegeanNumbers__internal_alias")));
+#else
+#ifndef xmlUCSIsAegeanNumbers
+extern __typeof (xmlUCSIsAegeanNumbers) xmlUCSIsAegeanNumbers__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsAegeanNumbers xmlUCSIsAegeanNumbers__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsAlphabeticPresentationForms
+extern __typeof (xmlUCSIsAlphabeticPresentationForms) xmlUCSIsAlphabeticPresentationForms __attribute((alias("xmlUCSIsAlphabeticPresentationForms__internal_alias")));
+#else
+#ifndef xmlUCSIsAlphabeticPresentationForms
+extern __typeof (xmlUCSIsAlphabeticPresentationForms) xmlUCSIsAlphabeticPresentationForms__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsAlphabeticPresentationForms xmlUCSIsAlphabeticPresentationForms__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsArabic
+extern __typeof (xmlUCSIsArabic) xmlUCSIsArabic __attribute((alias("xmlUCSIsArabic__internal_alias")));
+#else
+#ifndef xmlUCSIsArabic
+extern __typeof (xmlUCSIsArabic) xmlUCSIsArabic__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsArabic xmlUCSIsArabic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsArabicPresentationFormsA
+extern __typeof (xmlUCSIsArabicPresentationFormsA) xmlUCSIsArabicPresentationFormsA __attribute((alias("xmlUCSIsArabicPresentationFormsA__internal_alias")));
+#else
+#ifndef xmlUCSIsArabicPresentationFormsA
+extern __typeof (xmlUCSIsArabicPresentationFormsA) xmlUCSIsArabicPresentationFormsA__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsArabicPresentationFormsA xmlUCSIsArabicPresentationFormsA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsArabicPresentationFormsB
+extern __typeof (xmlUCSIsArabicPresentationFormsB) xmlUCSIsArabicPresentationFormsB __attribute((alias("xmlUCSIsArabicPresentationFormsB__internal_alias")));
+#else
+#ifndef xmlUCSIsArabicPresentationFormsB
+extern __typeof (xmlUCSIsArabicPresentationFormsB) xmlUCSIsArabicPresentationFormsB__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsArabicPresentationFormsB xmlUCSIsArabicPresentationFormsB__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsArmenian
+extern __typeof (xmlUCSIsArmenian) xmlUCSIsArmenian __attribute((alias("xmlUCSIsArmenian__internal_alias")));
+#else
+#ifndef xmlUCSIsArmenian
+extern __typeof (xmlUCSIsArmenian) xmlUCSIsArmenian__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsArmenian xmlUCSIsArmenian__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsArrows
+extern __typeof (xmlUCSIsArrows) xmlUCSIsArrows __attribute((alias("xmlUCSIsArrows__internal_alias")));
+#else
+#ifndef xmlUCSIsArrows
+extern __typeof (xmlUCSIsArrows) xmlUCSIsArrows__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsArrows xmlUCSIsArrows__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsBasicLatin
+extern __typeof (xmlUCSIsBasicLatin) xmlUCSIsBasicLatin __attribute((alias("xmlUCSIsBasicLatin__internal_alias")));
+#else
+#ifndef xmlUCSIsBasicLatin
+extern __typeof (xmlUCSIsBasicLatin) xmlUCSIsBasicLatin__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsBasicLatin xmlUCSIsBasicLatin__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsBengali
+extern __typeof (xmlUCSIsBengali) xmlUCSIsBengali __attribute((alias("xmlUCSIsBengali__internal_alias")));
+#else
+#ifndef xmlUCSIsBengali
+extern __typeof (xmlUCSIsBengali) xmlUCSIsBengali__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsBengali xmlUCSIsBengali__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsBlock
+extern __typeof (xmlUCSIsBlock) xmlUCSIsBlock __attribute((alias("xmlUCSIsBlock__internal_alias")));
+#else
+#ifndef xmlUCSIsBlock
+extern __typeof (xmlUCSIsBlock) xmlUCSIsBlock__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsBlock xmlUCSIsBlock__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsBlockElements
+extern __typeof (xmlUCSIsBlockElements) xmlUCSIsBlockElements __attribute((alias("xmlUCSIsBlockElements__internal_alias")));
+#else
+#ifndef xmlUCSIsBlockElements
+extern __typeof (xmlUCSIsBlockElements) xmlUCSIsBlockElements__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsBlockElements xmlUCSIsBlockElements__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsBopomofo
+extern __typeof (xmlUCSIsBopomofo) xmlUCSIsBopomofo __attribute((alias("xmlUCSIsBopomofo__internal_alias")));
+#else
+#ifndef xmlUCSIsBopomofo
+extern __typeof (xmlUCSIsBopomofo) xmlUCSIsBopomofo__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsBopomofo xmlUCSIsBopomofo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsBopomofoExtended
+extern __typeof (xmlUCSIsBopomofoExtended) xmlUCSIsBopomofoExtended __attribute((alias("xmlUCSIsBopomofoExtended__internal_alias")));
+#else
+#ifndef xmlUCSIsBopomofoExtended
+extern __typeof (xmlUCSIsBopomofoExtended) xmlUCSIsBopomofoExtended__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsBopomofoExtended xmlUCSIsBopomofoExtended__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsBoxDrawing
+extern __typeof (xmlUCSIsBoxDrawing) xmlUCSIsBoxDrawing __attribute((alias("xmlUCSIsBoxDrawing__internal_alias")));
+#else
+#ifndef xmlUCSIsBoxDrawing
+extern __typeof (xmlUCSIsBoxDrawing) xmlUCSIsBoxDrawing__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsBoxDrawing xmlUCSIsBoxDrawing__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsBraillePatterns
+extern __typeof (xmlUCSIsBraillePatterns) xmlUCSIsBraillePatterns __attribute((alias("xmlUCSIsBraillePatterns__internal_alias")));
+#else
+#ifndef xmlUCSIsBraillePatterns
+extern __typeof (xmlUCSIsBraillePatterns) xmlUCSIsBraillePatterns__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsBraillePatterns xmlUCSIsBraillePatterns__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsBuhid
+extern __typeof (xmlUCSIsBuhid) xmlUCSIsBuhid __attribute((alias("xmlUCSIsBuhid__internal_alias")));
+#else
+#ifndef xmlUCSIsBuhid
+extern __typeof (xmlUCSIsBuhid) xmlUCSIsBuhid__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsBuhid xmlUCSIsBuhid__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsByzantineMusicalSymbols
+extern __typeof (xmlUCSIsByzantineMusicalSymbols) xmlUCSIsByzantineMusicalSymbols __attribute((alias("xmlUCSIsByzantineMusicalSymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsByzantineMusicalSymbols
+extern __typeof (xmlUCSIsByzantineMusicalSymbols) xmlUCSIsByzantineMusicalSymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsByzantineMusicalSymbols xmlUCSIsByzantineMusicalSymbols__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCJKCompatibility
+extern __typeof (xmlUCSIsCJKCompatibility) xmlUCSIsCJKCompatibility __attribute((alias("xmlUCSIsCJKCompatibility__internal_alias")));
+#else
+#ifndef xmlUCSIsCJKCompatibility
+extern __typeof (xmlUCSIsCJKCompatibility) xmlUCSIsCJKCompatibility__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCJKCompatibility xmlUCSIsCJKCompatibility__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCJKCompatibilityForms
+extern __typeof (xmlUCSIsCJKCompatibilityForms) xmlUCSIsCJKCompatibilityForms __attribute((alias("xmlUCSIsCJKCompatibilityForms__internal_alias")));
+#else
+#ifndef xmlUCSIsCJKCompatibilityForms
+extern __typeof (xmlUCSIsCJKCompatibilityForms) xmlUCSIsCJKCompatibilityForms__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCJKCompatibilityForms xmlUCSIsCJKCompatibilityForms__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCJKCompatibilityIdeographs
+extern __typeof (xmlUCSIsCJKCompatibilityIdeographs) xmlUCSIsCJKCompatibilityIdeographs __attribute((alias("xmlUCSIsCJKCompatibilityIdeographs__internal_alias")));
+#else
+#ifndef xmlUCSIsCJKCompatibilityIdeographs
+extern __typeof (xmlUCSIsCJKCompatibilityIdeographs) xmlUCSIsCJKCompatibilityIdeographs__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCJKCompatibilityIdeographs xmlUCSIsCJKCompatibilityIdeographs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCJKCompatibilityIdeographsSupplement
+extern __typeof (xmlUCSIsCJKCompatibilityIdeographsSupplement) xmlUCSIsCJKCompatibilityIdeographsSupplement __attribute((alias("xmlUCSIsCJKCompatibilityIdeographsSupplement__internal_alias")));
+#else
+#ifndef xmlUCSIsCJKCompatibilityIdeographsSupplement
+extern __typeof (xmlUCSIsCJKCompatibilityIdeographsSupplement) xmlUCSIsCJKCompatibilityIdeographsSupplement__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCJKCompatibilityIdeographsSupplement xmlUCSIsCJKCompatibilityIdeographsSupplement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCJKRadicalsSupplement
+extern __typeof (xmlUCSIsCJKRadicalsSupplement) xmlUCSIsCJKRadicalsSupplement __attribute((alias("xmlUCSIsCJKRadicalsSupplement__internal_alias")));
+#else
+#ifndef xmlUCSIsCJKRadicalsSupplement
+extern __typeof (xmlUCSIsCJKRadicalsSupplement) xmlUCSIsCJKRadicalsSupplement__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCJKRadicalsSupplement xmlUCSIsCJKRadicalsSupplement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCJKSymbolsandPunctuation
+extern __typeof (xmlUCSIsCJKSymbolsandPunctuation) xmlUCSIsCJKSymbolsandPunctuation __attribute((alias("xmlUCSIsCJKSymbolsandPunctuation__internal_alias")));
+#else
+#ifndef xmlUCSIsCJKSymbolsandPunctuation
+extern __typeof (xmlUCSIsCJKSymbolsandPunctuation) xmlUCSIsCJKSymbolsandPunctuation__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCJKSymbolsandPunctuation xmlUCSIsCJKSymbolsandPunctuation__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCJKUnifiedIdeographs
+extern __typeof (xmlUCSIsCJKUnifiedIdeographs) xmlUCSIsCJKUnifiedIdeographs __attribute((alias("xmlUCSIsCJKUnifiedIdeographs__internal_alias")));
+#else
+#ifndef xmlUCSIsCJKUnifiedIdeographs
+extern __typeof (xmlUCSIsCJKUnifiedIdeographs) xmlUCSIsCJKUnifiedIdeographs__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCJKUnifiedIdeographs xmlUCSIsCJKUnifiedIdeographs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCJKUnifiedIdeographsExtensionA
+extern __typeof (xmlUCSIsCJKUnifiedIdeographsExtensionA) xmlUCSIsCJKUnifiedIdeographsExtensionA __attribute((alias("xmlUCSIsCJKUnifiedIdeographsExtensionA__internal_alias")));
+#else
+#ifndef xmlUCSIsCJKUnifiedIdeographsExtensionA
+extern __typeof (xmlUCSIsCJKUnifiedIdeographsExtensionA) xmlUCSIsCJKUnifiedIdeographsExtensionA__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCJKUnifiedIdeographsExtensionA xmlUCSIsCJKUnifiedIdeographsExtensionA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCJKUnifiedIdeographsExtensionB
+extern __typeof (xmlUCSIsCJKUnifiedIdeographsExtensionB) xmlUCSIsCJKUnifiedIdeographsExtensionB __attribute((alias("xmlUCSIsCJKUnifiedIdeographsExtensionB__internal_alias")));
+#else
+#ifndef xmlUCSIsCJKUnifiedIdeographsExtensionB
+extern __typeof (xmlUCSIsCJKUnifiedIdeographsExtensionB) xmlUCSIsCJKUnifiedIdeographsExtensionB__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCJKUnifiedIdeographsExtensionB xmlUCSIsCJKUnifiedIdeographsExtensionB__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCat
+extern __typeof (xmlUCSIsCat) xmlUCSIsCat __attribute((alias("xmlUCSIsCat__internal_alias")));
+#else
+#ifndef xmlUCSIsCat
+extern __typeof (xmlUCSIsCat) xmlUCSIsCat__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCat xmlUCSIsCat__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatC
+extern __typeof (xmlUCSIsCatC) xmlUCSIsCatC __attribute((alias("xmlUCSIsCatC__internal_alias")));
+#else
+#ifndef xmlUCSIsCatC
+extern __typeof (xmlUCSIsCatC) xmlUCSIsCatC__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatC xmlUCSIsCatC__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatCc
+extern __typeof (xmlUCSIsCatCc) xmlUCSIsCatCc __attribute((alias("xmlUCSIsCatCc__internal_alias")));
+#else
+#ifndef xmlUCSIsCatCc
+extern __typeof (xmlUCSIsCatCc) xmlUCSIsCatCc__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatCc xmlUCSIsCatCc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatCf
+extern __typeof (xmlUCSIsCatCf) xmlUCSIsCatCf __attribute((alias("xmlUCSIsCatCf__internal_alias")));
+#else
+#ifndef xmlUCSIsCatCf
+extern __typeof (xmlUCSIsCatCf) xmlUCSIsCatCf__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatCf xmlUCSIsCatCf__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatCo
+extern __typeof (xmlUCSIsCatCo) xmlUCSIsCatCo __attribute((alias("xmlUCSIsCatCo__internal_alias")));
+#else
+#ifndef xmlUCSIsCatCo
+extern __typeof (xmlUCSIsCatCo) xmlUCSIsCatCo__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatCo xmlUCSIsCatCo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatCs
+extern __typeof (xmlUCSIsCatCs) xmlUCSIsCatCs __attribute((alias("xmlUCSIsCatCs__internal_alias")));
+#else
+#ifndef xmlUCSIsCatCs
+extern __typeof (xmlUCSIsCatCs) xmlUCSIsCatCs__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatCs xmlUCSIsCatCs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatL
+extern __typeof (xmlUCSIsCatL) xmlUCSIsCatL __attribute((alias("xmlUCSIsCatL__internal_alias")));
+#else
+#ifndef xmlUCSIsCatL
+extern __typeof (xmlUCSIsCatL) xmlUCSIsCatL__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatL xmlUCSIsCatL__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatLl
+extern __typeof (xmlUCSIsCatLl) xmlUCSIsCatLl __attribute((alias("xmlUCSIsCatLl__internal_alias")));
+#else
+#ifndef xmlUCSIsCatLl
+extern __typeof (xmlUCSIsCatLl) xmlUCSIsCatLl__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatLl xmlUCSIsCatLl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatLm
+extern __typeof (xmlUCSIsCatLm) xmlUCSIsCatLm __attribute((alias("xmlUCSIsCatLm__internal_alias")));
+#else
+#ifndef xmlUCSIsCatLm
+extern __typeof (xmlUCSIsCatLm) xmlUCSIsCatLm__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatLm xmlUCSIsCatLm__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatLo
+extern __typeof (xmlUCSIsCatLo) xmlUCSIsCatLo __attribute((alias("xmlUCSIsCatLo__internal_alias")));
+#else
+#ifndef xmlUCSIsCatLo
+extern __typeof (xmlUCSIsCatLo) xmlUCSIsCatLo__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatLo xmlUCSIsCatLo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatLt
+extern __typeof (xmlUCSIsCatLt) xmlUCSIsCatLt __attribute((alias("xmlUCSIsCatLt__internal_alias")));
+#else
+#ifndef xmlUCSIsCatLt
+extern __typeof (xmlUCSIsCatLt) xmlUCSIsCatLt__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatLt xmlUCSIsCatLt__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatLu
+extern __typeof (xmlUCSIsCatLu) xmlUCSIsCatLu __attribute((alias("xmlUCSIsCatLu__internal_alias")));
+#else
+#ifndef xmlUCSIsCatLu
+extern __typeof (xmlUCSIsCatLu) xmlUCSIsCatLu__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatLu xmlUCSIsCatLu__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatM
+extern __typeof (xmlUCSIsCatM) xmlUCSIsCatM __attribute((alias("xmlUCSIsCatM__internal_alias")));
+#else
+#ifndef xmlUCSIsCatM
+extern __typeof (xmlUCSIsCatM) xmlUCSIsCatM__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatM xmlUCSIsCatM__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatMc
+extern __typeof (xmlUCSIsCatMc) xmlUCSIsCatMc __attribute((alias("xmlUCSIsCatMc__internal_alias")));
+#else
+#ifndef xmlUCSIsCatMc
+extern __typeof (xmlUCSIsCatMc) xmlUCSIsCatMc__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatMc xmlUCSIsCatMc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatMe
+extern __typeof (xmlUCSIsCatMe) xmlUCSIsCatMe __attribute((alias("xmlUCSIsCatMe__internal_alias")));
+#else
+#ifndef xmlUCSIsCatMe
+extern __typeof (xmlUCSIsCatMe) xmlUCSIsCatMe__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatMe xmlUCSIsCatMe__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatMn
+extern __typeof (xmlUCSIsCatMn) xmlUCSIsCatMn __attribute((alias("xmlUCSIsCatMn__internal_alias")));
+#else
+#ifndef xmlUCSIsCatMn
+extern __typeof (xmlUCSIsCatMn) xmlUCSIsCatMn__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatMn xmlUCSIsCatMn__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatN
+extern __typeof (xmlUCSIsCatN) xmlUCSIsCatN __attribute((alias("xmlUCSIsCatN__internal_alias")));
+#else
+#ifndef xmlUCSIsCatN
+extern __typeof (xmlUCSIsCatN) xmlUCSIsCatN__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatN xmlUCSIsCatN__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatNd
+extern __typeof (xmlUCSIsCatNd) xmlUCSIsCatNd __attribute((alias("xmlUCSIsCatNd__internal_alias")));
+#else
+#ifndef xmlUCSIsCatNd
+extern __typeof (xmlUCSIsCatNd) xmlUCSIsCatNd__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatNd xmlUCSIsCatNd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatNl
+extern __typeof (xmlUCSIsCatNl) xmlUCSIsCatNl __attribute((alias("xmlUCSIsCatNl__internal_alias")));
+#else
+#ifndef xmlUCSIsCatNl
+extern __typeof (xmlUCSIsCatNl) xmlUCSIsCatNl__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatNl xmlUCSIsCatNl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatNo
+extern __typeof (xmlUCSIsCatNo) xmlUCSIsCatNo __attribute((alias("xmlUCSIsCatNo__internal_alias")));
+#else
+#ifndef xmlUCSIsCatNo
+extern __typeof (xmlUCSIsCatNo) xmlUCSIsCatNo__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatNo xmlUCSIsCatNo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatP
+extern __typeof (xmlUCSIsCatP) xmlUCSIsCatP __attribute((alias("xmlUCSIsCatP__internal_alias")));
+#else
+#ifndef xmlUCSIsCatP
+extern __typeof (xmlUCSIsCatP) xmlUCSIsCatP__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatP xmlUCSIsCatP__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatPc
+extern __typeof (xmlUCSIsCatPc) xmlUCSIsCatPc __attribute((alias("xmlUCSIsCatPc__internal_alias")));
+#else
+#ifndef xmlUCSIsCatPc
+extern __typeof (xmlUCSIsCatPc) xmlUCSIsCatPc__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatPc xmlUCSIsCatPc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatPd
+extern __typeof (xmlUCSIsCatPd) xmlUCSIsCatPd __attribute((alias("xmlUCSIsCatPd__internal_alias")));
+#else
+#ifndef xmlUCSIsCatPd
+extern __typeof (xmlUCSIsCatPd) xmlUCSIsCatPd__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatPd xmlUCSIsCatPd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatPe
+extern __typeof (xmlUCSIsCatPe) xmlUCSIsCatPe __attribute((alias("xmlUCSIsCatPe__internal_alias")));
+#else
+#ifndef xmlUCSIsCatPe
+extern __typeof (xmlUCSIsCatPe) xmlUCSIsCatPe__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatPe xmlUCSIsCatPe__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatPf
+extern __typeof (xmlUCSIsCatPf) xmlUCSIsCatPf __attribute((alias("xmlUCSIsCatPf__internal_alias")));
+#else
+#ifndef xmlUCSIsCatPf
+extern __typeof (xmlUCSIsCatPf) xmlUCSIsCatPf__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatPf xmlUCSIsCatPf__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatPi
+extern __typeof (xmlUCSIsCatPi) xmlUCSIsCatPi __attribute((alias("xmlUCSIsCatPi__internal_alias")));
+#else
+#ifndef xmlUCSIsCatPi
+extern __typeof (xmlUCSIsCatPi) xmlUCSIsCatPi__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatPi xmlUCSIsCatPi__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatPo
+extern __typeof (xmlUCSIsCatPo) xmlUCSIsCatPo __attribute((alias("xmlUCSIsCatPo__internal_alias")));
+#else
+#ifndef xmlUCSIsCatPo
+extern __typeof (xmlUCSIsCatPo) xmlUCSIsCatPo__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatPo xmlUCSIsCatPo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatPs
+extern __typeof (xmlUCSIsCatPs) xmlUCSIsCatPs __attribute((alias("xmlUCSIsCatPs__internal_alias")));
+#else
+#ifndef xmlUCSIsCatPs
+extern __typeof (xmlUCSIsCatPs) xmlUCSIsCatPs__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatPs xmlUCSIsCatPs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatS
+extern __typeof (xmlUCSIsCatS) xmlUCSIsCatS __attribute((alias("xmlUCSIsCatS__internal_alias")));
+#else
+#ifndef xmlUCSIsCatS
+extern __typeof (xmlUCSIsCatS) xmlUCSIsCatS__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatS xmlUCSIsCatS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatSc
+extern __typeof (xmlUCSIsCatSc) xmlUCSIsCatSc __attribute((alias("xmlUCSIsCatSc__internal_alias")));
+#else
+#ifndef xmlUCSIsCatSc
+extern __typeof (xmlUCSIsCatSc) xmlUCSIsCatSc__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatSc xmlUCSIsCatSc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatSk
+extern __typeof (xmlUCSIsCatSk) xmlUCSIsCatSk __attribute((alias("xmlUCSIsCatSk__internal_alias")));
+#else
+#ifndef xmlUCSIsCatSk
+extern __typeof (xmlUCSIsCatSk) xmlUCSIsCatSk__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatSk xmlUCSIsCatSk__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatSm
+extern __typeof (xmlUCSIsCatSm) xmlUCSIsCatSm __attribute((alias("xmlUCSIsCatSm__internal_alias")));
+#else
+#ifndef xmlUCSIsCatSm
+extern __typeof (xmlUCSIsCatSm) xmlUCSIsCatSm__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatSm xmlUCSIsCatSm__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatSo
+extern __typeof (xmlUCSIsCatSo) xmlUCSIsCatSo __attribute((alias("xmlUCSIsCatSo__internal_alias")));
+#else
+#ifndef xmlUCSIsCatSo
+extern __typeof (xmlUCSIsCatSo) xmlUCSIsCatSo__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatSo xmlUCSIsCatSo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatZ
+extern __typeof (xmlUCSIsCatZ) xmlUCSIsCatZ __attribute((alias("xmlUCSIsCatZ__internal_alias")));
+#else
+#ifndef xmlUCSIsCatZ
+extern __typeof (xmlUCSIsCatZ) xmlUCSIsCatZ__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatZ xmlUCSIsCatZ__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatZl
+extern __typeof (xmlUCSIsCatZl) xmlUCSIsCatZl __attribute((alias("xmlUCSIsCatZl__internal_alias")));
+#else
+#ifndef xmlUCSIsCatZl
+extern __typeof (xmlUCSIsCatZl) xmlUCSIsCatZl__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatZl xmlUCSIsCatZl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatZp
+extern __typeof (xmlUCSIsCatZp) xmlUCSIsCatZp __attribute((alias("xmlUCSIsCatZp__internal_alias")));
+#else
+#ifndef xmlUCSIsCatZp
+extern __typeof (xmlUCSIsCatZp) xmlUCSIsCatZp__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatZp xmlUCSIsCatZp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCatZs
+extern __typeof (xmlUCSIsCatZs) xmlUCSIsCatZs __attribute((alias("xmlUCSIsCatZs__internal_alias")));
+#else
+#ifndef xmlUCSIsCatZs
+extern __typeof (xmlUCSIsCatZs) xmlUCSIsCatZs__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCatZs xmlUCSIsCatZs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCherokee
+extern __typeof (xmlUCSIsCherokee) xmlUCSIsCherokee __attribute((alias("xmlUCSIsCherokee__internal_alias")));
+#else
+#ifndef xmlUCSIsCherokee
+extern __typeof (xmlUCSIsCherokee) xmlUCSIsCherokee__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCherokee xmlUCSIsCherokee__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCombiningDiacriticalMarks
+extern __typeof (xmlUCSIsCombiningDiacriticalMarks) xmlUCSIsCombiningDiacriticalMarks __attribute((alias("xmlUCSIsCombiningDiacriticalMarks__internal_alias")));
+#else
+#ifndef xmlUCSIsCombiningDiacriticalMarks
+extern __typeof (xmlUCSIsCombiningDiacriticalMarks) xmlUCSIsCombiningDiacriticalMarks__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCombiningDiacriticalMarks xmlUCSIsCombiningDiacriticalMarks__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCombiningDiacriticalMarksforSymbols
+extern __typeof (xmlUCSIsCombiningDiacriticalMarksforSymbols) xmlUCSIsCombiningDiacriticalMarksforSymbols __attribute((alias("xmlUCSIsCombiningDiacriticalMarksforSymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsCombiningDiacriticalMarksforSymbols
+extern __typeof (xmlUCSIsCombiningDiacriticalMarksforSymbols) xmlUCSIsCombiningDiacriticalMarksforSymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCombiningDiacriticalMarksforSymbols xmlUCSIsCombiningDiacriticalMarksforSymbols__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCombiningHalfMarks
+extern __typeof (xmlUCSIsCombiningHalfMarks) xmlUCSIsCombiningHalfMarks __attribute((alias("xmlUCSIsCombiningHalfMarks__internal_alias")));
+#else
+#ifndef xmlUCSIsCombiningHalfMarks
+extern __typeof (xmlUCSIsCombiningHalfMarks) xmlUCSIsCombiningHalfMarks__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCombiningHalfMarks xmlUCSIsCombiningHalfMarks__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCombiningMarksforSymbols
+extern __typeof (xmlUCSIsCombiningMarksforSymbols) xmlUCSIsCombiningMarksforSymbols __attribute((alias("xmlUCSIsCombiningMarksforSymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsCombiningMarksforSymbols
+extern __typeof (xmlUCSIsCombiningMarksforSymbols) xmlUCSIsCombiningMarksforSymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCombiningMarksforSymbols xmlUCSIsCombiningMarksforSymbols__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsControlPictures
+extern __typeof (xmlUCSIsControlPictures) xmlUCSIsControlPictures __attribute((alias("xmlUCSIsControlPictures__internal_alias")));
+#else
+#ifndef xmlUCSIsControlPictures
+extern __typeof (xmlUCSIsControlPictures) xmlUCSIsControlPictures__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsControlPictures xmlUCSIsControlPictures__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCurrencySymbols
+extern __typeof (xmlUCSIsCurrencySymbols) xmlUCSIsCurrencySymbols __attribute((alias("xmlUCSIsCurrencySymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsCurrencySymbols
+extern __typeof (xmlUCSIsCurrencySymbols) xmlUCSIsCurrencySymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCurrencySymbols xmlUCSIsCurrencySymbols__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCypriotSyllabary
+extern __typeof (xmlUCSIsCypriotSyllabary) xmlUCSIsCypriotSyllabary __attribute((alias("xmlUCSIsCypriotSyllabary__internal_alias")));
+#else
+#ifndef xmlUCSIsCypriotSyllabary
+extern __typeof (xmlUCSIsCypriotSyllabary) xmlUCSIsCypriotSyllabary__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCypriotSyllabary xmlUCSIsCypriotSyllabary__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCyrillic
+extern __typeof (xmlUCSIsCyrillic) xmlUCSIsCyrillic __attribute((alias("xmlUCSIsCyrillic__internal_alias")));
+#else
+#ifndef xmlUCSIsCyrillic
+extern __typeof (xmlUCSIsCyrillic) xmlUCSIsCyrillic__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCyrillic xmlUCSIsCyrillic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsCyrillicSupplement
+extern __typeof (xmlUCSIsCyrillicSupplement) xmlUCSIsCyrillicSupplement __attribute((alias("xmlUCSIsCyrillicSupplement__internal_alias")));
+#else
+#ifndef xmlUCSIsCyrillicSupplement
+extern __typeof (xmlUCSIsCyrillicSupplement) xmlUCSIsCyrillicSupplement__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsCyrillicSupplement xmlUCSIsCyrillicSupplement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsDeseret
+extern __typeof (xmlUCSIsDeseret) xmlUCSIsDeseret __attribute((alias("xmlUCSIsDeseret__internal_alias")));
+#else
+#ifndef xmlUCSIsDeseret
+extern __typeof (xmlUCSIsDeseret) xmlUCSIsDeseret__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsDeseret xmlUCSIsDeseret__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsDevanagari
+extern __typeof (xmlUCSIsDevanagari) xmlUCSIsDevanagari __attribute((alias("xmlUCSIsDevanagari__internal_alias")));
+#else
+#ifndef xmlUCSIsDevanagari
+extern __typeof (xmlUCSIsDevanagari) xmlUCSIsDevanagari__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsDevanagari xmlUCSIsDevanagari__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsDingbats
+extern __typeof (xmlUCSIsDingbats) xmlUCSIsDingbats __attribute((alias("xmlUCSIsDingbats__internal_alias")));
+#else
+#ifndef xmlUCSIsDingbats
+extern __typeof (xmlUCSIsDingbats) xmlUCSIsDingbats__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsDingbats xmlUCSIsDingbats__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsEnclosedAlphanumerics
+extern __typeof (xmlUCSIsEnclosedAlphanumerics) xmlUCSIsEnclosedAlphanumerics __attribute((alias("xmlUCSIsEnclosedAlphanumerics__internal_alias")));
+#else
+#ifndef xmlUCSIsEnclosedAlphanumerics
+extern __typeof (xmlUCSIsEnclosedAlphanumerics) xmlUCSIsEnclosedAlphanumerics__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsEnclosedAlphanumerics xmlUCSIsEnclosedAlphanumerics__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsEnclosedCJKLettersandMonths
+extern __typeof (xmlUCSIsEnclosedCJKLettersandMonths) xmlUCSIsEnclosedCJKLettersandMonths __attribute((alias("xmlUCSIsEnclosedCJKLettersandMonths__internal_alias")));
+#else
+#ifndef xmlUCSIsEnclosedCJKLettersandMonths
+extern __typeof (xmlUCSIsEnclosedCJKLettersandMonths) xmlUCSIsEnclosedCJKLettersandMonths__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsEnclosedCJKLettersandMonths xmlUCSIsEnclosedCJKLettersandMonths__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsEthiopic
+extern __typeof (xmlUCSIsEthiopic) xmlUCSIsEthiopic __attribute((alias("xmlUCSIsEthiopic__internal_alias")));
+#else
+#ifndef xmlUCSIsEthiopic
+extern __typeof (xmlUCSIsEthiopic) xmlUCSIsEthiopic__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsEthiopic xmlUCSIsEthiopic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsGeneralPunctuation
+extern __typeof (xmlUCSIsGeneralPunctuation) xmlUCSIsGeneralPunctuation __attribute((alias("xmlUCSIsGeneralPunctuation__internal_alias")));
+#else
+#ifndef xmlUCSIsGeneralPunctuation
+extern __typeof (xmlUCSIsGeneralPunctuation) xmlUCSIsGeneralPunctuation__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsGeneralPunctuation xmlUCSIsGeneralPunctuation__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsGeometricShapes
+extern __typeof (xmlUCSIsGeometricShapes) xmlUCSIsGeometricShapes __attribute((alias("xmlUCSIsGeometricShapes__internal_alias")));
+#else
+#ifndef xmlUCSIsGeometricShapes
+extern __typeof (xmlUCSIsGeometricShapes) xmlUCSIsGeometricShapes__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsGeometricShapes xmlUCSIsGeometricShapes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsGeorgian
+extern __typeof (xmlUCSIsGeorgian) xmlUCSIsGeorgian __attribute((alias("xmlUCSIsGeorgian__internal_alias")));
+#else
+#ifndef xmlUCSIsGeorgian
+extern __typeof (xmlUCSIsGeorgian) xmlUCSIsGeorgian__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsGeorgian xmlUCSIsGeorgian__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsGothic
+extern __typeof (xmlUCSIsGothic) xmlUCSIsGothic __attribute((alias("xmlUCSIsGothic__internal_alias")));
+#else
+#ifndef xmlUCSIsGothic
+extern __typeof (xmlUCSIsGothic) xmlUCSIsGothic__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsGothic xmlUCSIsGothic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsGreek
+extern __typeof (xmlUCSIsGreek) xmlUCSIsGreek __attribute((alias("xmlUCSIsGreek__internal_alias")));
+#else
+#ifndef xmlUCSIsGreek
+extern __typeof (xmlUCSIsGreek) xmlUCSIsGreek__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsGreek xmlUCSIsGreek__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsGreekExtended
+extern __typeof (xmlUCSIsGreekExtended) xmlUCSIsGreekExtended __attribute((alias("xmlUCSIsGreekExtended__internal_alias")));
+#else
+#ifndef xmlUCSIsGreekExtended
+extern __typeof (xmlUCSIsGreekExtended) xmlUCSIsGreekExtended__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsGreekExtended xmlUCSIsGreekExtended__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsGreekandCoptic
+extern __typeof (xmlUCSIsGreekandCoptic) xmlUCSIsGreekandCoptic __attribute((alias("xmlUCSIsGreekandCoptic__internal_alias")));
+#else
+#ifndef xmlUCSIsGreekandCoptic
+extern __typeof (xmlUCSIsGreekandCoptic) xmlUCSIsGreekandCoptic__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsGreekandCoptic xmlUCSIsGreekandCoptic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsGujarati
+extern __typeof (xmlUCSIsGujarati) xmlUCSIsGujarati __attribute((alias("xmlUCSIsGujarati__internal_alias")));
+#else
+#ifndef xmlUCSIsGujarati
+extern __typeof (xmlUCSIsGujarati) xmlUCSIsGujarati__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsGujarati xmlUCSIsGujarati__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsGurmukhi
+extern __typeof (xmlUCSIsGurmukhi) xmlUCSIsGurmukhi __attribute((alias("xmlUCSIsGurmukhi__internal_alias")));
+#else
+#ifndef xmlUCSIsGurmukhi
+extern __typeof (xmlUCSIsGurmukhi) xmlUCSIsGurmukhi__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsGurmukhi xmlUCSIsGurmukhi__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsHalfwidthandFullwidthForms
+extern __typeof (xmlUCSIsHalfwidthandFullwidthForms) xmlUCSIsHalfwidthandFullwidthForms __attribute((alias("xmlUCSIsHalfwidthandFullwidthForms__internal_alias")));
+#else
+#ifndef xmlUCSIsHalfwidthandFullwidthForms
+extern __typeof (xmlUCSIsHalfwidthandFullwidthForms) xmlUCSIsHalfwidthandFullwidthForms__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsHalfwidthandFullwidthForms xmlUCSIsHalfwidthandFullwidthForms__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsHangulCompatibilityJamo
+extern __typeof (xmlUCSIsHangulCompatibilityJamo) xmlUCSIsHangulCompatibilityJamo __attribute((alias("xmlUCSIsHangulCompatibilityJamo__internal_alias")));
+#else
+#ifndef xmlUCSIsHangulCompatibilityJamo
+extern __typeof (xmlUCSIsHangulCompatibilityJamo) xmlUCSIsHangulCompatibilityJamo__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsHangulCompatibilityJamo xmlUCSIsHangulCompatibilityJamo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsHangulJamo
+extern __typeof (xmlUCSIsHangulJamo) xmlUCSIsHangulJamo __attribute((alias("xmlUCSIsHangulJamo__internal_alias")));
+#else
+#ifndef xmlUCSIsHangulJamo
+extern __typeof (xmlUCSIsHangulJamo) xmlUCSIsHangulJamo__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsHangulJamo xmlUCSIsHangulJamo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsHangulSyllables
+extern __typeof (xmlUCSIsHangulSyllables) xmlUCSIsHangulSyllables __attribute((alias("xmlUCSIsHangulSyllables__internal_alias")));
+#else
+#ifndef xmlUCSIsHangulSyllables
+extern __typeof (xmlUCSIsHangulSyllables) xmlUCSIsHangulSyllables__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsHangulSyllables xmlUCSIsHangulSyllables__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsHanunoo
+extern __typeof (xmlUCSIsHanunoo) xmlUCSIsHanunoo __attribute((alias("xmlUCSIsHanunoo__internal_alias")));
+#else
+#ifndef xmlUCSIsHanunoo
+extern __typeof (xmlUCSIsHanunoo) xmlUCSIsHanunoo__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsHanunoo xmlUCSIsHanunoo__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsHebrew
+extern __typeof (xmlUCSIsHebrew) xmlUCSIsHebrew __attribute((alias("xmlUCSIsHebrew__internal_alias")));
+#else
+#ifndef xmlUCSIsHebrew
+extern __typeof (xmlUCSIsHebrew) xmlUCSIsHebrew__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsHebrew xmlUCSIsHebrew__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsHighPrivateUseSurrogates
+extern __typeof (xmlUCSIsHighPrivateUseSurrogates) xmlUCSIsHighPrivateUseSurrogates __attribute((alias("xmlUCSIsHighPrivateUseSurrogates__internal_alias")));
+#else
+#ifndef xmlUCSIsHighPrivateUseSurrogates
+extern __typeof (xmlUCSIsHighPrivateUseSurrogates) xmlUCSIsHighPrivateUseSurrogates__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsHighPrivateUseSurrogates xmlUCSIsHighPrivateUseSurrogates__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsHighSurrogates
+extern __typeof (xmlUCSIsHighSurrogates) xmlUCSIsHighSurrogates __attribute((alias("xmlUCSIsHighSurrogates__internal_alias")));
+#else
+#ifndef xmlUCSIsHighSurrogates
+extern __typeof (xmlUCSIsHighSurrogates) xmlUCSIsHighSurrogates__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsHighSurrogates xmlUCSIsHighSurrogates__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsHiragana
+extern __typeof (xmlUCSIsHiragana) xmlUCSIsHiragana __attribute((alias("xmlUCSIsHiragana__internal_alias")));
+#else
+#ifndef xmlUCSIsHiragana
+extern __typeof (xmlUCSIsHiragana) xmlUCSIsHiragana__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsHiragana xmlUCSIsHiragana__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsIPAExtensions
+extern __typeof (xmlUCSIsIPAExtensions) xmlUCSIsIPAExtensions __attribute((alias("xmlUCSIsIPAExtensions__internal_alias")));
+#else
+#ifndef xmlUCSIsIPAExtensions
+extern __typeof (xmlUCSIsIPAExtensions) xmlUCSIsIPAExtensions__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsIPAExtensions xmlUCSIsIPAExtensions__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsIdeographicDescriptionCharacters
+extern __typeof (xmlUCSIsIdeographicDescriptionCharacters) xmlUCSIsIdeographicDescriptionCharacters __attribute((alias("xmlUCSIsIdeographicDescriptionCharacters__internal_alias")));
+#else
+#ifndef xmlUCSIsIdeographicDescriptionCharacters
+extern __typeof (xmlUCSIsIdeographicDescriptionCharacters) xmlUCSIsIdeographicDescriptionCharacters__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsIdeographicDescriptionCharacters xmlUCSIsIdeographicDescriptionCharacters__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsKanbun
+extern __typeof (xmlUCSIsKanbun) xmlUCSIsKanbun __attribute((alias("xmlUCSIsKanbun__internal_alias")));
+#else
+#ifndef xmlUCSIsKanbun
+extern __typeof (xmlUCSIsKanbun) xmlUCSIsKanbun__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsKanbun xmlUCSIsKanbun__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsKangxiRadicals
+extern __typeof (xmlUCSIsKangxiRadicals) xmlUCSIsKangxiRadicals __attribute((alias("xmlUCSIsKangxiRadicals__internal_alias")));
+#else
+#ifndef xmlUCSIsKangxiRadicals
+extern __typeof (xmlUCSIsKangxiRadicals) xmlUCSIsKangxiRadicals__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsKangxiRadicals xmlUCSIsKangxiRadicals__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsKannada
+extern __typeof (xmlUCSIsKannada) xmlUCSIsKannada __attribute((alias("xmlUCSIsKannada__internal_alias")));
+#else
+#ifndef xmlUCSIsKannada
+extern __typeof (xmlUCSIsKannada) xmlUCSIsKannada__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsKannada xmlUCSIsKannada__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsKatakana
+extern __typeof (xmlUCSIsKatakana) xmlUCSIsKatakana __attribute((alias("xmlUCSIsKatakana__internal_alias")));
+#else
+#ifndef xmlUCSIsKatakana
+extern __typeof (xmlUCSIsKatakana) xmlUCSIsKatakana__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsKatakana xmlUCSIsKatakana__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsKatakanaPhoneticExtensions
+extern __typeof (xmlUCSIsKatakanaPhoneticExtensions) xmlUCSIsKatakanaPhoneticExtensions __attribute((alias("xmlUCSIsKatakanaPhoneticExtensions__internal_alias")));
+#else
+#ifndef xmlUCSIsKatakanaPhoneticExtensions
+extern __typeof (xmlUCSIsKatakanaPhoneticExtensions) xmlUCSIsKatakanaPhoneticExtensions__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsKatakanaPhoneticExtensions xmlUCSIsKatakanaPhoneticExtensions__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsKhmer
+extern __typeof (xmlUCSIsKhmer) xmlUCSIsKhmer __attribute((alias("xmlUCSIsKhmer__internal_alias")));
+#else
+#ifndef xmlUCSIsKhmer
+extern __typeof (xmlUCSIsKhmer) xmlUCSIsKhmer__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsKhmer xmlUCSIsKhmer__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsKhmerSymbols
+extern __typeof (xmlUCSIsKhmerSymbols) xmlUCSIsKhmerSymbols __attribute((alias("xmlUCSIsKhmerSymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsKhmerSymbols
+extern __typeof (xmlUCSIsKhmerSymbols) xmlUCSIsKhmerSymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsKhmerSymbols xmlUCSIsKhmerSymbols__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsLao
+extern __typeof (xmlUCSIsLao) xmlUCSIsLao __attribute((alias("xmlUCSIsLao__internal_alias")));
+#else
+#ifndef xmlUCSIsLao
+extern __typeof (xmlUCSIsLao) xmlUCSIsLao__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsLao xmlUCSIsLao__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsLatin1Supplement
+extern __typeof (xmlUCSIsLatin1Supplement) xmlUCSIsLatin1Supplement __attribute((alias("xmlUCSIsLatin1Supplement__internal_alias")));
+#else
+#ifndef xmlUCSIsLatin1Supplement
+extern __typeof (xmlUCSIsLatin1Supplement) xmlUCSIsLatin1Supplement__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsLatin1Supplement xmlUCSIsLatin1Supplement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsLatinExtendedA
+extern __typeof (xmlUCSIsLatinExtendedA) xmlUCSIsLatinExtendedA __attribute((alias("xmlUCSIsLatinExtendedA__internal_alias")));
+#else
+#ifndef xmlUCSIsLatinExtendedA
+extern __typeof (xmlUCSIsLatinExtendedA) xmlUCSIsLatinExtendedA__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsLatinExtendedA xmlUCSIsLatinExtendedA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsLatinExtendedAdditional
+extern __typeof (xmlUCSIsLatinExtendedAdditional) xmlUCSIsLatinExtendedAdditional __attribute((alias("xmlUCSIsLatinExtendedAdditional__internal_alias")));
+#else
+#ifndef xmlUCSIsLatinExtendedAdditional
+extern __typeof (xmlUCSIsLatinExtendedAdditional) xmlUCSIsLatinExtendedAdditional__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsLatinExtendedAdditional xmlUCSIsLatinExtendedAdditional__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsLatinExtendedB
+extern __typeof (xmlUCSIsLatinExtendedB) xmlUCSIsLatinExtendedB __attribute((alias("xmlUCSIsLatinExtendedB__internal_alias")));
+#else
+#ifndef xmlUCSIsLatinExtendedB
+extern __typeof (xmlUCSIsLatinExtendedB) xmlUCSIsLatinExtendedB__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsLatinExtendedB xmlUCSIsLatinExtendedB__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsLetterlikeSymbols
+extern __typeof (xmlUCSIsLetterlikeSymbols) xmlUCSIsLetterlikeSymbols __attribute((alias("xmlUCSIsLetterlikeSymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsLetterlikeSymbols
+extern __typeof (xmlUCSIsLetterlikeSymbols) xmlUCSIsLetterlikeSymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsLetterlikeSymbols xmlUCSIsLetterlikeSymbols__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsLimbu
+extern __typeof (xmlUCSIsLimbu) xmlUCSIsLimbu __attribute((alias("xmlUCSIsLimbu__internal_alias")));
+#else
+#ifndef xmlUCSIsLimbu
+extern __typeof (xmlUCSIsLimbu) xmlUCSIsLimbu__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsLimbu xmlUCSIsLimbu__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsLinearBIdeograms
+extern __typeof (xmlUCSIsLinearBIdeograms) xmlUCSIsLinearBIdeograms __attribute((alias("xmlUCSIsLinearBIdeograms__internal_alias")));
+#else
+#ifndef xmlUCSIsLinearBIdeograms
+extern __typeof (xmlUCSIsLinearBIdeograms) xmlUCSIsLinearBIdeograms__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsLinearBIdeograms xmlUCSIsLinearBIdeograms__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsLinearBSyllabary
+extern __typeof (xmlUCSIsLinearBSyllabary) xmlUCSIsLinearBSyllabary __attribute((alias("xmlUCSIsLinearBSyllabary__internal_alias")));
+#else
+#ifndef xmlUCSIsLinearBSyllabary
+extern __typeof (xmlUCSIsLinearBSyllabary) xmlUCSIsLinearBSyllabary__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsLinearBSyllabary xmlUCSIsLinearBSyllabary__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsLowSurrogates
+extern __typeof (xmlUCSIsLowSurrogates) xmlUCSIsLowSurrogates __attribute((alias("xmlUCSIsLowSurrogates__internal_alias")));
+#else
+#ifndef xmlUCSIsLowSurrogates
+extern __typeof (xmlUCSIsLowSurrogates) xmlUCSIsLowSurrogates__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsLowSurrogates xmlUCSIsLowSurrogates__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMalayalam
+extern __typeof (xmlUCSIsMalayalam) xmlUCSIsMalayalam __attribute((alias("xmlUCSIsMalayalam__internal_alias")));
+#else
+#ifndef xmlUCSIsMalayalam
+extern __typeof (xmlUCSIsMalayalam) xmlUCSIsMalayalam__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMalayalam xmlUCSIsMalayalam__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMathematicalAlphanumericSymbols
+extern __typeof (xmlUCSIsMathematicalAlphanumericSymbols) xmlUCSIsMathematicalAlphanumericSymbols __attribute((alias("xmlUCSIsMathematicalAlphanumericSymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsMathematicalAlphanumericSymbols
+extern __typeof (xmlUCSIsMathematicalAlphanumericSymbols) xmlUCSIsMathematicalAlphanumericSymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMathematicalAlphanumericSymbols xmlUCSIsMathematicalAlphanumericSymbols__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMathematicalOperators
+extern __typeof (xmlUCSIsMathematicalOperators) xmlUCSIsMathematicalOperators __attribute((alias("xmlUCSIsMathematicalOperators__internal_alias")));
+#else
+#ifndef xmlUCSIsMathematicalOperators
+extern __typeof (xmlUCSIsMathematicalOperators) xmlUCSIsMathematicalOperators__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMathematicalOperators xmlUCSIsMathematicalOperators__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMiscellaneousMathematicalSymbolsA
+extern __typeof (xmlUCSIsMiscellaneousMathematicalSymbolsA) xmlUCSIsMiscellaneousMathematicalSymbolsA __attribute((alias("xmlUCSIsMiscellaneousMathematicalSymbolsA__internal_alias")));
+#else
+#ifndef xmlUCSIsMiscellaneousMathematicalSymbolsA
+extern __typeof (xmlUCSIsMiscellaneousMathematicalSymbolsA) xmlUCSIsMiscellaneousMathematicalSymbolsA__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMiscellaneousMathematicalSymbolsA xmlUCSIsMiscellaneousMathematicalSymbolsA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMiscellaneousMathematicalSymbolsB
+extern __typeof (xmlUCSIsMiscellaneousMathematicalSymbolsB) xmlUCSIsMiscellaneousMathematicalSymbolsB __attribute((alias("xmlUCSIsMiscellaneousMathematicalSymbolsB__internal_alias")));
+#else
+#ifndef xmlUCSIsMiscellaneousMathematicalSymbolsB
+extern __typeof (xmlUCSIsMiscellaneousMathematicalSymbolsB) xmlUCSIsMiscellaneousMathematicalSymbolsB__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMiscellaneousMathematicalSymbolsB xmlUCSIsMiscellaneousMathematicalSymbolsB__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMiscellaneousSymbols
+extern __typeof (xmlUCSIsMiscellaneousSymbols) xmlUCSIsMiscellaneousSymbols __attribute((alias("xmlUCSIsMiscellaneousSymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsMiscellaneousSymbols
+extern __typeof (xmlUCSIsMiscellaneousSymbols) xmlUCSIsMiscellaneousSymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMiscellaneousSymbols xmlUCSIsMiscellaneousSymbols__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMiscellaneousSymbolsandArrows
+extern __typeof (xmlUCSIsMiscellaneousSymbolsandArrows) xmlUCSIsMiscellaneousSymbolsandArrows __attribute((alias("xmlUCSIsMiscellaneousSymbolsandArrows__internal_alias")));
+#else
+#ifndef xmlUCSIsMiscellaneousSymbolsandArrows
+extern __typeof (xmlUCSIsMiscellaneousSymbolsandArrows) xmlUCSIsMiscellaneousSymbolsandArrows__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMiscellaneousSymbolsandArrows xmlUCSIsMiscellaneousSymbolsandArrows__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMiscellaneousTechnical
+extern __typeof (xmlUCSIsMiscellaneousTechnical) xmlUCSIsMiscellaneousTechnical __attribute((alias("xmlUCSIsMiscellaneousTechnical__internal_alias")));
+#else
+#ifndef xmlUCSIsMiscellaneousTechnical
+extern __typeof (xmlUCSIsMiscellaneousTechnical) xmlUCSIsMiscellaneousTechnical__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMiscellaneousTechnical xmlUCSIsMiscellaneousTechnical__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMongolian
+extern __typeof (xmlUCSIsMongolian) xmlUCSIsMongolian __attribute((alias("xmlUCSIsMongolian__internal_alias")));
+#else
+#ifndef xmlUCSIsMongolian
+extern __typeof (xmlUCSIsMongolian) xmlUCSIsMongolian__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMongolian xmlUCSIsMongolian__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMusicalSymbols
+extern __typeof (xmlUCSIsMusicalSymbols) xmlUCSIsMusicalSymbols __attribute((alias("xmlUCSIsMusicalSymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsMusicalSymbols
+extern __typeof (xmlUCSIsMusicalSymbols) xmlUCSIsMusicalSymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMusicalSymbols xmlUCSIsMusicalSymbols__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsMyanmar
+extern __typeof (xmlUCSIsMyanmar) xmlUCSIsMyanmar __attribute((alias("xmlUCSIsMyanmar__internal_alias")));
+#else
+#ifndef xmlUCSIsMyanmar
+extern __typeof (xmlUCSIsMyanmar) xmlUCSIsMyanmar__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsMyanmar xmlUCSIsMyanmar__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsNumberForms
+extern __typeof (xmlUCSIsNumberForms) xmlUCSIsNumberForms __attribute((alias("xmlUCSIsNumberForms__internal_alias")));
+#else
+#ifndef xmlUCSIsNumberForms
+extern __typeof (xmlUCSIsNumberForms) xmlUCSIsNumberForms__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsNumberForms xmlUCSIsNumberForms__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsOgham
+extern __typeof (xmlUCSIsOgham) xmlUCSIsOgham __attribute((alias("xmlUCSIsOgham__internal_alias")));
+#else
+#ifndef xmlUCSIsOgham
+extern __typeof (xmlUCSIsOgham) xmlUCSIsOgham__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsOgham xmlUCSIsOgham__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsOldItalic
+extern __typeof (xmlUCSIsOldItalic) xmlUCSIsOldItalic __attribute((alias("xmlUCSIsOldItalic__internal_alias")));
+#else
+#ifndef xmlUCSIsOldItalic
+extern __typeof (xmlUCSIsOldItalic) xmlUCSIsOldItalic__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsOldItalic xmlUCSIsOldItalic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsOpticalCharacterRecognition
+extern __typeof (xmlUCSIsOpticalCharacterRecognition) xmlUCSIsOpticalCharacterRecognition __attribute((alias("xmlUCSIsOpticalCharacterRecognition__internal_alias")));
+#else
+#ifndef xmlUCSIsOpticalCharacterRecognition
+extern __typeof (xmlUCSIsOpticalCharacterRecognition) xmlUCSIsOpticalCharacterRecognition__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsOpticalCharacterRecognition xmlUCSIsOpticalCharacterRecognition__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsOriya
+extern __typeof (xmlUCSIsOriya) xmlUCSIsOriya __attribute((alias("xmlUCSIsOriya__internal_alias")));
+#else
+#ifndef xmlUCSIsOriya
+extern __typeof (xmlUCSIsOriya) xmlUCSIsOriya__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsOriya xmlUCSIsOriya__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsOsmanya
+extern __typeof (xmlUCSIsOsmanya) xmlUCSIsOsmanya __attribute((alias("xmlUCSIsOsmanya__internal_alias")));
+#else
+#ifndef xmlUCSIsOsmanya
+extern __typeof (xmlUCSIsOsmanya) xmlUCSIsOsmanya__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsOsmanya xmlUCSIsOsmanya__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsPhoneticExtensions
+extern __typeof (xmlUCSIsPhoneticExtensions) xmlUCSIsPhoneticExtensions __attribute((alias("xmlUCSIsPhoneticExtensions__internal_alias")));
+#else
+#ifndef xmlUCSIsPhoneticExtensions
+extern __typeof (xmlUCSIsPhoneticExtensions) xmlUCSIsPhoneticExtensions__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsPhoneticExtensions xmlUCSIsPhoneticExtensions__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsPrivateUse
+extern __typeof (xmlUCSIsPrivateUse) xmlUCSIsPrivateUse __attribute((alias("xmlUCSIsPrivateUse__internal_alias")));
+#else
+#ifndef xmlUCSIsPrivateUse
+extern __typeof (xmlUCSIsPrivateUse) xmlUCSIsPrivateUse__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsPrivateUse xmlUCSIsPrivateUse__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsPrivateUseArea
+extern __typeof (xmlUCSIsPrivateUseArea) xmlUCSIsPrivateUseArea __attribute((alias("xmlUCSIsPrivateUseArea__internal_alias")));
+#else
+#ifndef xmlUCSIsPrivateUseArea
+extern __typeof (xmlUCSIsPrivateUseArea) xmlUCSIsPrivateUseArea__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsPrivateUseArea xmlUCSIsPrivateUseArea__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsRunic
+extern __typeof (xmlUCSIsRunic) xmlUCSIsRunic __attribute((alias("xmlUCSIsRunic__internal_alias")));
+#else
+#ifndef xmlUCSIsRunic
+extern __typeof (xmlUCSIsRunic) xmlUCSIsRunic__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsRunic xmlUCSIsRunic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsShavian
+extern __typeof (xmlUCSIsShavian) xmlUCSIsShavian __attribute((alias("xmlUCSIsShavian__internal_alias")));
+#else
+#ifndef xmlUCSIsShavian
+extern __typeof (xmlUCSIsShavian) xmlUCSIsShavian__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsShavian xmlUCSIsShavian__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSinhala
+extern __typeof (xmlUCSIsSinhala) xmlUCSIsSinhala __attribute((alias("xmlUCSIsSinhala__internal_alias")));
+#else
+#ifndef xmlUCSIsSinhala
+extern __typeof (xmlUCSIsSinhala) xmlUCSIsSinhala__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSinhala xmlUCSIsSinhala__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSmallFormVariants
+extern __typeof (xmlUCSIsSmallFormVariants) xmlUCSIsSmallFormVariants __attribute((alias("xmlUCSIsSmallFormVariants__internal_alias")));
+#else
+#ifndef xmlUCSIsSmallFormVariants
+extern __typeof (xmlUCSIsSmallFormVariants) xmlUCSIsSmallFormVariants__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSmallFormVariants xmlUCSIsSmallFormVariants__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSpacingModifierLetters
+extern __typeof (xmlUCSIsSpacingModifierLetters) xmlUCSIsSpacingModifierLetters __attribute((alias("xmlUCSIsSpacingModifierLetters__internal_alias")));
+#else
+#ifndef xmlUCSIsSpacingModifierLetters
+extern __typeof (xmlUCSIsSpacingModifierLetters) xmlUCSIsSpacingModifierLetters__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSpacingModifierLetters xmlUCSIsSpacingModifierLetters__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSpecials
+extern __typeof (xmlUCSIsSpecials) xmlUCSIsSpecials __attribute((alias("xmlUCSIsSpecials__internal_alias")));
+#else
+#ifndef xmlUCSIsSpecials
+extern __typeof (xmlUCSIsSpecials) xmlUCSIsSpecials__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSpecials xmlUCSIsSpecials__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSuperscriptsandSubscripts
+extern __typeof (xmlUCSIsSuperscriptsandSubscripts) xmlUCSIsSuperscriptsandSubscripts __attribute((alias("xmlUCSIsSuperscriptsandSubscripts__internal_alias")));
+#else
+#ifndef xmlUCSIsSuperscriptsandSubscripts
+extern __typeof (xmlUCSIsSuperscriptsandSubscripts) xmlUCSIsSuperscriptsandSubscripts__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSuperscriptsandSubscripts xmlUCSIsSuperscriptsandSubscripts__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSupplementalArrowsA
+extern __typeof (xmlUCSIsSupplementalArrowsA) xmlUCSIsSupplementalArrowsA __attribute((alias("xmlUCSIsSupplementalArrowsA__internal_alias")));
+#else
+#ifndef xmlUCSIsSupplementalArrowsA
+extern __typeof (xmlUCSIsSupplementalArrowsA) xmlUCSIsSupplementalArrowsA__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSupplementalArrowsA xmlUCSIsSupplementalArrowsA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSupplementalArrowsB
+extern __typeof (xmlUCSIsSupplementalArrowsB) xmlUCSIsSupplementalArrowsB __attribute((alias("xmlUCSIsSupplementalArrowsB__internal_alias")));
+#else
+#ifndef xmlUCSIsSupplementalArrowsB
+extern __typeof (xmlUCSIsSupplementalArrowsB) xmlUCSIsSupplementalArrowsB__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSupplementalArrowsB xmlUCSIsSupplementalArrowsB__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSupplementalMathematicalOperators
+extern __typeof (xmlUCSIsSupplementalMathematicalOperators) xmlUCSIsSupplementalMathematicalOperators __attribute((alias("xmlUCSIsSupplementalMathematicalOperators__internal_alias")));
+#else
+#ifndef xmlUCSIsSupplementalMathematicalOperators
+extern __typeof (xmlUCSIsSupplementalMathematicalOperators) xmlUCSIsSupplementalMathematicalOperators__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSupplementalMathematicalOperators xmlUCSIsSupplementalMathematicalOperators__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSupplementaryPrivateUseAreaA
+extern __typeof (xmlUCSIsSupplementaryPrivateUseAreaA) xmlUCSIsSupplementaryPrivateUseAreaA __attribute((alias("xmlUCSIsSupplementaryPrivateUseAreaA__internal_alias")));
+#else
+#ifndef xmlUCSIsSupplementaryPrivateUseAreaA
+extern __typeof (xmlUCSIsSupplementaryPrivateUseAreaA) xmlUCSIsSupplementaryPrivateUseAreaA__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSupplementaryPrivateUseAreaA xmlUCSIsSupplementaryPrivateUseAreaA__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSupplementaryPrivateUseAreaB
+extern __typeof (xmlUCSIsSupplementaryPrivateUseAreaB) xmlUCSIsSupplementaryPrivateUseAreaB __attribute((alias("xmlUCSIsSupplementaryPrivateUseAreaB__internal_alias")));
+#else
+#ifndef xmlUCSIsSupplementaryPrivateUseAreaB
+extern __typeof (xmlUCSIsSupplementaryPrivateUseAreaB) xmlUCSIsSupplementaryPrivateUseAreaB__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSupplementaryPrivateUseAreaB xmlUCSIsSupplementaryPrivateUseAreaB__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsSyriac
+extern __typeof (xmlUCSIsSyriac) xmlUCSIsSyriac __attribute((alias("xmlUCSIsSyriac__internal_alias")));
+#else
+#ifndef xmlUCSIsSyriac
+extern __typeof (xmlUCSIsSyriac) xmlUCSIsSyriac__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsSyriac xmlUCSIsSyriac__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsTagalog
+extern __typeof (xmlUCSIsTagalog) xmlUCSIsTagalog __attribute((alias("xmlUCSIsTagalog__internal_alias")));
+#else
+#ifndef xmlUCSIsTagalog
+extern __typeof (xmlUCSIsTagalog) xmlUCSIsTagalog__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsTagalog xmlUCSIsTagalog__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsTagbanwa
+extern __typeof (xmlUCSIsTagbanwa) xmlUCSIsTagbanwa __attribute((alias("xmlUCSIsTagbanwa__internal_alias")));
+#else
+#ifndef xmlUCSIsTagbanwa
+extern __typeof (xmlUCSIsTagbanwa) xmlUCSIsTagbanwa__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsTagbanwa xmlUCSIsTagbanwa__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsTags
+extern __typeof (xmlUCSIsTags) xmlUCSIsTags __attribute((alias("xmlUCSIsTags__internal_alias")));
+#else
+#ifndef xmlUCSIsTags
+extern __typeof (xmlUCSIsTags) xmlUCSIsTags__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsTags xmlUCSIsTags__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsTaiLe
+extern __typeof (xmlUCSIsTaiLe) xmlUCSIsTaiLe __attribute((alias("xmlUCSIsTaiLe__internal_alias")));
+#else
+#ifndef xmlUCSIsTaiLe
+extern __typeof (xmlUCSIsTaiLe) xmlUCSIsTaiLe__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsTaiLe xmlUCSIsTaiLe__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsTaiXuanJingSymbols
+extern __typeof (xmlUCSIsTaiXuanJingSymbols) xmlUCSIsTaiXuanJingSymbols __attribute((alias("xmlUCSIsTaiXuanJingSymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsTaiXuanJingSymbols
+extern __typeof (xmlUCSIsTaiXuanJingSymbols) xmlUCSIsTaiXuanJingSymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsTaiXuanJingSymbols xmlUCSIsTaiXuanJingSymbols__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsTamil
+extern __typeof (xmlUCSIsTamil) xmlUCSIsTamil __attribute((alias("xmlUCSIsTamil__internal_alias")));
+#else
+#ifndef xmlUCSIsTamil
+extern __typeof (xmlUCSIsTamil) xmlUCSIsTamil__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsTamil xmlUCSIsTamil__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsTelugu
+extern __typeof (xmlUCSIsTelugu) xmlUCSIsTelugu __attribute((alias("xmlUCSIsTelugu__internal_alias")));
+#else
+#ifndef xmlUCSIsTelugu
+extern __typeof (xmlUCSIsTelugu) xmlUCSIsTelugu__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsTelugu xmlUCSIsTelugu__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsThaana
+extern __typeof (xmlUCSIsThaana) xmlUCSIsThaana __attribute((alias("xmlUCSIsThaana__internal_alias")));
+#else
+#ifndef xmlUCSIsThaana
+extern __typeof (xmlUCSIsThaana) xmlUCSIsThaana__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsThaana xmlUCSIsThaana__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsThai
+extern __typeof (xmlUCSIsThai) xmlUCSIsThai __attribute((alias("xmlUCSIsThai__internal_alias")));
+#else
+#ifndef xmlUCSIsThai
+extern __typeof (xmlUCSIsThai) xmlUCSIsThai__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsThai xmlUCSIsThai__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsTibetan
+extern __typeof (xmlUCSIsTibetan) xmlUCSIsTibetan __attribute((alias("xmlUCSIsTibetan__internal_alias")));
+#else
+#ifndef xmlUCSIsTibetan
+extern __typeof (xmlUCSIsTibetan) xmlUCSIsTibetan__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsTibetan xmlUCSIsTibetan__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsUgaritic
+extern __typeof (xmlUCSIsUgaritic) xmlUCSIsUgaritic __attribute((alias("xmlUCSIsUgaritic__internal_alias")));
+#else
+#ifndef xmlUCSIsUgaritic
+extern __typeof (xmlUCSIsUgaritic) xmlUCSIsUgaritic__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsUgaritic xmlUCSIsUgaritic__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsUnifiedCanadianAboriginalSyllabics
+extern __typeof (xmlUCSIsUnifiedCanadianAboriginalSyllabics) xmlUCSIsUnifiedCanadianAboriginalSyllabics __attribute((alias("xmlUCSIsUnifiedCanadianAboriginalSyllabics__internal_alias")));
+#else
+#ifndef xmlUCSIsUnifiedCanadianAboriginalSyllabics
+extern __typeof (xmlUCSIsUnifiedCanadianAboriginalSyllabics) xmlUCSIsUnifiedCanadianAboriginalSyllabics__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsUnifiedCanadianAboriginalSyllabics xmlUCSIsUnifiedCanadianAboriginalSyllabics__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsVariationSelectors
+extern __typeof (xmlUCSIsVariationSelectors) xmlUCSIsVariationSelectors __attribute((alias("xmlUCSIsVariationSelectors__internal_alias")));
+#else
+#ifndef xmlUCSIsVariationSelectors
+extern __typeof (xmlUCSIsVariationSelectors) xmlUCSIsVariationSelectors__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsVariationSelectors xmlUCSIsVariationSelectors__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsVariationSelectorsSupplement
+extern __typeof (xmlUCSIsVariationSelectorsSupplement) xmlUCSIsVariationSelectorsSupplement __attribute((alias("xmlUCSIsVariationSelectorsSupplement__internal_alias")));
+#else
+#ifndef xmlUCSIsVariationSelectorsSupplement
+extern __typeof (xmlUCSIsVariationSelectorsSupplement) xmlUCSIsVariationSelectorsSupplement__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsVariationSelectorsSupplement xmlUCSIsVariationSelectorsSupplement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsYiRadicals
+extern __typeof (xmlUCSIsYiRadicals) xmlUCSIsYiRadicals __attribute((alias("xmlUCSIsYiRadicals__internal_alias")));
+#else
+#ifndef xmlUCSIsYiRadicals
+extern __typeof (xmlUCSIsYiRadicals) xmlUCSIsYiRadicals__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsYiRadicals xmlUCSIsYiRadicals__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsYiSyllables
+extern __typeof (xmlUCSIsYiSyllables) xmlUCSIsYiSyllables __attribute((alias("xmlUCSIsYiSyllables__internal_alias")));
+#else
+#ifndef xmlUCSIsYiSyllables
+extern __typeof (xmlUCSIsYiSyllables) xmlUCSIsYiSyllables__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsYiSyllables xmlUCSIsYiSyllables__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_UNICODE_ENABLED)
+#ifdef bottom_xmlunicode
+#undef xmlUCSIsYijingHexagramSymbols
+extern __typeof (xmlUCSIsYijingHexagramSymbols) xmlUCSIsYijingHexagramSymbols __attribute((alias("xmlUCSIsYijingHexagramSymbols__internal_alias")));
+#else
+#ifndef xmlUCSIsYijingHexagramSymbols
+extern __typeof (xmlUCSIsYijingHexagramSymbols) xmlUCSIsYijingHexagramSymbols__internal_alias __attribute((visibility("hidden")));
+#define xmlUCSIsYijingHexagramSymbols xmlUCSIsYijingHexagramSymbols__internal_alias
+#endif
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlURIEscape
+extern __typeof (xmlURIEscape) xmlURIEscape __attribute((alias("xmlURIEscape__internal_alias")));
+#else
+#ifndef xmlURIEscape
+extern __typeof (xmlURIEscape) xmlURIEscape__internal_alias __attribute((visibility("hidden")));
+#define xmlURIEscape xmlURIEscape__internal_alias
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlURIEscapeStr
+extern __typeof (xmlURIEscapeStr) xmlURIEscapeStr __attribute((alias("xmlURIEscapeStr__internal_alias")));
+#else
+#ifndef xmlURIEscapeStr
+extern __typeof (xmlURIEscapeStr) xmlURIEscapeStr__internal_alias __attribute((visibility("hidden")));
+#define xmlURIEscapeStr xmlURIEscapeStr__internal_alias
+#endif
+#endif
+
+#ifdef bottom_uri
+#undef xmlURIUnescapeString
+extern __typeof (xmlURIUnescapeString) xmlURIUnescapeString __attribute((alias("xmlURIUnescapeString__internal_alias")));
+#else
+#ifndef xmlURIUnescapeString
+extern __typeof (xmlURIUnescapeString) xmlURIUnescapeString__internal_alias __attribute((visibility("hidden")));
+#define xmlURIUnescapeString xmlURIUnescapeString__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlUTF8Charcmp
+extern __typeof (xmlUTF8Charcmp) xmlUTF8Charcmp __attribute((alias("xmlUTF8Charcmp__internal_alias")));
+#else
+#ifndef xmlUTF8Charcmp
+extern __typeof (xmlUTF8Charcmp) xmlUTF8Charcmp__internal_alias __attribute((visibility("hidden")));
+#define xmlUTF8Charcmp xmlUTF8Charcmp__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlUTF8Size
+extern __typeof (xmlUTF8Size) xmlUTF8Size __attribute((alias("xmlUTF8Size__internal_alias")));
+#else
+#ifndef xmlUTF8Size
+extern __typeof (xmlUTF8Size) xmlUTF8Size__internal_alias __attribute((visibility("hidden")));
+#define xmlUTF8Size xmlUTF8Size__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlUTF8Strlen
+extern __typeof (xmlUTF8Strlen) xmlUTF8Strlen __attribute((alias("xmlUTF8Strlen__internal_alias")));
+#else
+#ifndef xmlUTF8Strlen
+extern __typeof (xmlUTF8Strlen) xmlUTF8Strlen__internal_alias __attribute((visibility("hidden")));
+#define xmlUTF8Strlen xmlUTF8Strlen__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlUTF8Strloc
+extern __typeof (xmlUTF8Strloc) xmlUTF8Strloc __attribute((alias("xmlUTF8Strloc__internal_alias")));
+#else
+#ifndef xmlUTF8Strloc
+extern __typeof (xmlUTF8Strloc) xmlUTF8Strloc__internal_alias __attribute((visibility("hidden")));
+#define xmlUTF8Strloc xmlUTF8Strloc__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlUTF8Strndup
+extern __typeof (xmlUTF8Strndup) xmlUTF8Strndup __attribute((alias("xmlUTF8Strndup__internal_alias")));
+#else
+#ifndef xmlUTF8Strndup
+extern __typeof (xmlUTF8Strndup) xmlUTF8Strndup__internal_alias __attribute((visibility("hidden")));
+#define xmlUTF8Strndup xmlUTF8Strndup__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlUTF8Strpos
+extern __typeof (xmlUTF8Strpos) xmlUTF8Strpos __attribute((alias("xmlUTF8Strpos__internal_alias")));
+#else
+#ifndef xmlUTF8Strpos
+extern __typeof (xmlUTF8Strpos) xmlUTF8Strpos__internal_alias __attribute((visibility("hidden")));
+#define xmlUTF8Strpos xmlUTF8Strpos__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlUTF8Strsize
+extern __typeof (xmlUTF8Strsize) xmlUTF8Strsize __attribute((alias("xmlUTF8Strsize__internal_alias")));
+#else
+#ifndef xmlUTF8Strsize
+extern __typeof (xmlUTF8Strsize) xmlUTF8Strsize__internal_alias __attribute((visibility("hidden")));
+#define xmlUTF8Strsize xmlUTF8Strsize__internal_alias
+#endif
+#endif
+
+#ifdef bottom_xmlstring
+#undef xmlUTF8Strsub
+extern __typeof (xmlUTF8Strsub) xmlUTF8Strsub __attribute((alias("xmlUTF8Strsub__internal_alias")));
+#else
+#ifndef xmlUTF8Strsub
+extern __typeof (xmlUTF8Strsub) xmlUTF8Strsub__internal_alias __attribute((visibility("hidden")));
+#define xmlUTF8Strsub xmlUTF8Strsub__internal_alias
+#endif
+#endif
+
+#ifdef bottom_tree
+#undef xmlUnlinkNode
+extern __typeof (xmlUnlinkNode) xmlUnlinkNode __attribute((alias("xmlUnlinkNode__internal_alias")));
+#else
+#ifndef xmlUnlinkNode
+extern __typeof (xmlUnlinkNode) xmlUnlinkNode__internal_alias __attribute((visibility("hidden")));
+#define xmlUnlinkNode xmlUnlinkNode__internal_alias
+#endif
+#endif
+
+#ifdef bottom_threads
+#undef xmlUnlockLibrary
+extern __typeof (xmlUnlockLibrary) xmlUnlockLibrary __attribute((alias("xmlUnlockLibrary__internal_alias")));
+#else
+#ifndef xmlUnlockLibrary
+extern __typeof (xmlUnlockLibrary) xmlUnlockLibrary__internal_alias __attribute((visibility("hidden")));
+#define xmlUnlockLibrary xmlUnlockLibrary__internal_alias
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_tree
+#undef xmlUnsetNsProp
+extern __typeof (xmlUnsetNsProp) xmlUnsetNsProp __attribute((alias("xmlUnsetNsProp__internal_alias")));
+#else
+#ifndef xmlUnsetNsProp
+extern __typeof (xmlUnsetNsProp) xmlUnsetNsProp__internal_alias __attribute((visibility("hidden")));
+#define xmlUnsetNsProp xmlUnsetNsProp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_tree
+#undef xmlUnsetProp
+extern __typeof (xmlUnsetProp) xmlUnsetProp __attribute((alias("xmlUnsetProp__internal_alias")));
+#else
+#ifndef xmlUnsetProp
+extern __typeof (xmlUnsetProp) xmlUnsetProp__internal_alias __attribute((visibility("hidden")));
+#define xmlUnsetProp xmlUnsetProp__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidBuildContentModel
+extern __typeof (xmlValidBuildContentModel) xmlValidBuildContentModel __attribute((alias("xmlValidBuildContentModel__internal_alias")));
+#else
+#ifndef xmlValidBuildContentModel
+extern __typeof (xmlValidBuildContentModel) xmlValidBuildContentModel__internal_alias __attribute((visibility("hidden")));
+#define xmlValidBuildContentModel xmlValidBuildContentModel__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidCtxtNormalizeAttributeValue
+extern __typeof (xmlValidCtxtNormalizeAttributeValue) xmlValidCtxtNormalizeAttributeValue __attribute((alias("xmlValidCtxtNormalizeAttributeValue__internal_alias")));
+#else
+#ifndef xmlValidCtxtNormalizeAttributeValue
+extern __typeof (xmlValidCtxtNormalizeAttributeValue) xmlValidCtxtNormalizeAttributeValue__internal_alias __attribute((visibility("hidden")));
+#define xmlValidCtxtNormalizeAttributeValue xmlValidCtxtNormalizeAttributeValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidGetPotentialChildren
+extern __typeof (xmlValidGetPotentialChildren) xmlValidGetPotentialChildren __attribute((alias("xmlValidGetPotentialChildren__internal_alias")));
+#else
+#ifndef xmlValidGetPotentialChildren
+extern __typeof (xmlValidGetPotentialChildren) xmlValidGetPotentialChildren__internal_alias __attribute((visibility("hidden")));
+#define xmlValidGetPotentialChildren xmlValidGetPotentialChildren__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidGetValidElements
+extern __typeof (xmlValidGetValidElements) xmlValidGetValidElements __attribute((alias("xmlValidGetValidElements__internal_alias")));
+#else
+#ifndef xmlValidGetValidElements
+extern __typeof (xmlValidGetValidElements) xmlValidGetValidElements__internal_alias __attribute((visibility("hidden")));
+#define xmlValidGetValidElements xmlValidGetValidElements__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidNormalizeAttributeValue
+extern __typeof (xmlValidNormalizeAttributeValue) xmlValidNormalizeAttributeValue __attribute((alias("xmlValidNormalizeAttributeValue__internal_alias")));
+#else
+#ifndef xmlValidNormalizeAttributeValue
+extern __typeof (xmlValidNormalizeAttributeValue) xmlValidNormalizeAttributeValue__internal_alias __attribute((visibility("hidden")));
+#define xmlValidNormalizeAttributeValue xmlValidNormalizeAttributeValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateAttributeDecl
+extern __typeof (xmlValidateAttributeDecl) xmlValidateAttributeDecl __attribute((alias("xmlValidateAttributeDecl__internal_alias")));
+#else
+#ifndef xmlValidateAttributeDecl
+extern __typeof (xmlValidateAttributeDecl) xmlValidateAttributeDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateAttributeDecl xmlValidateAttributeDecl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateAttributeValue
+extern __typeof (xmlValidateAttributeValue) xmlValidateAttributeValue __attribute((alias("xmlValidateAttributeValue__internal_alias")));
+#else
+#ifndef xmlValidateAttributeValue
+extern __typeof (xmlValidateAttributeValue) xmlValidateAttributeValue__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateAttributeValue xmlValidateAttributeValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateDocument
+extern __typeof (xmlValidateDocument) xmlValidateDocument __attribute((alias("xmlValidateDocument__internal_alias")));
+#else
+#ifndef xmlValidateDocument
+extern __typeof (xmlValidateDocument) xmlValidateDocument__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateDocument xmlValidateDocument__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateDocumentFinal
+extern __typeof (xmlValidateDocumentFinal) xmlValidateDocumentFinal __attribute((alias("xmlValidateDocumentFinal__internal_alias")));
+#else
+#ifndef xmlValidateDocumentFinal
+extern __typeof (xmlValidateDocumentFinal) xmlValidateDocumentFinal__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateDocumentFinal xmlValidateDocumentFinal__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateDtd
+extern __typeof (xmlValidateDtd) xmlValidateDtd __attribute((alias("xmlValidateDtd__internal_alias")));
+#else
+#ifndef xmlValidateDtd
+extern __typeof (xmlValidateDtd) xmlValidateDtd__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateDtd xmlValidateDtd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateDtdFinal
+extern __typeof (xmlValidateDtdFinal) xmlValidateDtdFinal __attribute((alias("xmlValidateDtdFinal__internal_alias")));
+#else
+#ifndef xmlValidateDtdFinal
+extern __typeof (xmlValidateDtdFinal) xmlValidateDtdFinal__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateDtdFinal xmlValidateDtdFinal__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateElement
+extern __typeof (xmlValidateElement) xmlValidateElement __attribute((alias("xmlValidateElement__internal_alias")));
+#else
+#ifndef xmlValidateElement
+extern __typeof (xmlValidateElement) xmlValidateElement__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateElement xmlValidateElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateElementDecl
+extern __typeof (xmlValidateElementDecl) xmlValidateElementDecl __attribute((alias("xmlValidateElementDecl__internal_alias")));
+#else
+#ifndef xmlValidateElementDecl
+extern __typeof (xmlValidateElementDecl) xmlValidateElementDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateElementDecl xmlValidateElementDecl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
+#ifdef bottom_tree
+#undef xmlValidateNCName
+extern __typeof (xmlValidateNCName) xmlValidateNCName __attribute((alias("xmlValidateNCName__internal_alias")));
+#else
+#ifndef xmlValidateNCName
+extern __typeof (xmlValidateNCName) xmlValidateNCName__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateNCName xmlValidateNCName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_tree
+#undef xmlValidateNMToken
+extern __typeof (xmlValidateNMToken) xmlValidateNMToken __attribute((alias("xmlValidateNMToken__internal_alias")));
+#else
+#ifndef xmlValidateNMToken
+extern __typeof (xmlValidateNMToken) xmlValidateNMToken__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateNMToken xmlValidateNMToken__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_tree
+#undef xmlValidateName
+extern __typeof (xmlValidateName) xmlValidateName __attribute((alias("xmlValidateName__internal_alias")));
+#else
+#ifndef xmlValidateName
+extern __typeof (xmlValidateName) xmlValidateName__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateName xmlValidateName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateNameValue
+extern __typeof (xmlValidateNameValue) xmlValidateNameValue __attribute((alias("xmlValidateNameValue__internal_alias")));
+#else
+#ifndef xmlValidateNameValue
+extern __typeof (xmlValidateNameValue) xmlValidateNameValue__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateNameValue xmlValidateNameValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateNamesValue
+extern __typeof (xmlValidateNamesValue) xmlValidateNamesValue __attribute((alias("xmlValidateNamesValue__internal_alias")));
+#else
+#ifndef xmlValidateNamesValue
+extern __typeof (xmlValidateNamesValue) xmlValidateNamesValue__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateNamesValue xmlValidateNamesValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateNmtokenValue
+extern __typeof (xmlValidateNmtokenValue) xmlValidateNmtokenValue __attribute((alias("xmlValidateNmtokenValue__internal_alias")));
+#else
+#ifndef xmlValidateNmtokenValue
+extern __typeof (xmlValidateNmtokenValue) xmlValidateNmtokenValue__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateNmtokenValue xmlValidateNmtokenValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateNmtokensValue
+extern __typeof (xmlValidateNmtokensValue) xmlValidateNmtokensValue __attribute((alias("xmlValidateNmtokensValue__internal_alias")));
+#else
+#ifndef xmlValidateNmtokensValue
+extern __typeof (xmlValidateNmtokensValue) xmlValidateNmtokensValue__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateNmtokensValue xmlValidateNmtokensValue__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateNotationDecl
+extern __typeof (xmlValidateNotationDecl) xmlValidateNotationDecl __attribute((alias("xmlValidateNotationDecl__internal_alias")));
+#else
+#ifndef xmlValidateNotationDecl
+extern __typeof (xmlValidateNotationDecl) xmlValidateNotationDecl__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateNotationDecl xmlValidateNotationDecl__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateNotationUse
+extern __typeof (xmlValidateNotationUse) xmlValidateNotationUse __attribute((alias("xmlValidateNotationUse__internal_alias")));
+#else
+#ifndef xmlValidateNotationUse
+extern __typeof (xmlValidateNotationUse) xmlValidateNotationUse__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateNotationUse xmlValidateNotationUse__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateOneAttribute
+extern __typeof (xmlValidateOneAttribute) xmlValidateOneAttribute __attribute((alias("xmlValidateOneAttribute__internal_alias")));
+#else
+#ifndef xmlValidateOneAttribute
+extern __typeof (xmlValidateOneAttribute) xmlValidateOneAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateOneAttribute xmlValidateOneAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateOneElement
+extern __typeof (xmlValidateOneElement) xmlValidateOneElement __attribute((alias("xmlValidateOneElement__internal_alias")));
+#else
+#ifndef xmlValidateOneElement
+extern __typeof (xmlValidateOneElement) xmlValidateOneElement__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateOneElement xmlValidateOneElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateOneNamespace
+extern __typeof (xmlValidateOneNamespace) xmlValidateOneNamespace __attribute((alias("xmlValidateOneNamespace__internal_alias")));
+#else
+#ifndef xmlValidateOneNamespace
+extern __typeof (xmlValidateOneNamespace) xmlValidateOneNamespace__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateOneNamespace xmlValidateOneNamespace__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidatePopElement
+extern __typeof (xmlValidatePopElement) xmlValidatePopElement __attribute((alias("xmlValidatePopElement__internal_alias")));
+#else
+#ifndef xmlValidatePopElement
+extern __typeof (xmlValidatePopElement) xmlValidatePopElement__internal_alias __attribute((visibility("hidden")));
+#define xmlValidatePopElement xmlValidatePopElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidatePushCData
+extern __typeof (xmlValidatePushCData) xmlValidatePushCData __attribute((alias("xmlValidatePushCData__internal_alias")));
+#else
+#ifndef xmlValidatePushCData
+extern __typeof (xmlValidatePushCData) xmlValidatePushCData__internal_alias __attribute((visibility("hidden")));
+#define xmlValidatePushCData xmlValidatePushCData__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED) && defined(LIBXML_REGEXP_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidatePushElement
+extern __typeof (xmlValidatePushElement) xmlValidatePushElement __attribute((alias("xmlValidatePushElement__internal_alias")));
+#else
+#ifndef xmlValidatePushElement
+extern __typeof (xmlValidatePushElement) xmlValidatePushElement__internal_alias __attribute((visibility("hidden")));
+#define xmlValidatePushElement xmlValidatePushElement__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_tree
+#undef xmlValidateQName
+extern __typeof (xmlValidateQName) xmlValidateQName __attribute((alias("xmlValidateQName__internal_alias")));
+#else
+#ifndef xmlValidateQName
+extern __typeof (xmlValidateQName) xmlValidateQName__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateQName xmlValidateQName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_VALID_ENABLED)
+#ifdef bottom_valid
+#undef xmlValidateRoot
+extern __typeof (xmlValidateRoot) xmlValidateRoot __attribute((alias("xmlValidateRoot__internal_alias")));
+#else
+#ifndef xmlValidateRoot
+extern __typeof (xmlValidateRoot) xmlValidateRoot__internal_alias __attribute((visibility("hidden")));
+#define xmlValidateRoot xmlValidateRoot__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_xinclude
+#undef xmlXIncludeFreeContext
+extern __typeof (xmlXIncludeFreeContext) xmlXIncludeFreeContext __attribute((alias("xmlXIncludeFreeContext__internal_alias")));
+#else
+#ifndef xmlXIncludeFreeContext
+extern __typeof (xmlXIncludeFreeContext) xmlXIncludeFreeContext__internal_alias __attribute((visibility("hidden")));
+#define xmlXIncludeFreeContext xmlXIncludeFreeContext__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_xinclude
+#undef xmlXIncludeNewContext
+extern __typeof (xmlXIncludeNewContext) xmlXIncludeNewContext __attribute((alias("xmlXIncludeNewContext__internal_alias")));
+#else
+#ifndef xmlXIncludeNewContext
+extern __typeof (xmlXIncludeNewContext) xmlXIncludeNewContext__internal_alias __attribute((visibility("hidden")));
+#define xmlXIncludeNewContext xmlXIncludeNewContext__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_xinclude
+#undef xmlXIncludeProcess
+extern __typeof (xmlXIncludeProcess) xmlXIncludeProcess __attribute((alias("xmlXIncludeProcess__internal_alias")));
+#else
+#ifndef xmlXIncludeProcess
+extern __typeof (xmlXIncludeProcess) xmlXIncludeProcess__internal_alias __attribute((visibility("hidden")));
+#define xmlXIncludeProcess xmlXIncludeProcess__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_xinclude
+#undef xmlXIncludeProcessFlags
+extern __typeof (xmlXIncludeProcessFlags) xmlXIncludeProcessFlags __attribute((alias("xmlXIncludeProcessFlags__internal_alias")));
+#else
+#ifndef xmlXIncludeProcessFlags
+extern __typeof (xmlXIncludeProcessFlags) xmlXIncludeProcessFlags__internal_alias __attribute((visibility("hidden")));
+#define xmlXIncludeProcessFlags xmlXIncludeProcessFlags__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_xinclude
+#undef xmlXIncludeProcessFlagsData
+extern __typeof (xmlXIncludeProcessFlagsData) xmlXIncludeProcessFlagsData __attribute((alias("xmlXIncludeProcessFlagsData__internal_alias")));
+#else
+#ifndef xmlXIncludeProcessFlagsData
+extern __typeof (xmlXIncludeProcessFlagsData) xmlXIncludeProcessFlagsData__internal_alias __attribute((visibility("hidden")));
+#define xmlXIncludeProcessFlagsData xmlXIncludeProcessFlagsData__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_xinclude
+#undef xmlXIncludeProcessNode
+extern __typeof (xmlXIncludeProcessNode) xmlXIncludeProcessNode __attribute((alias("xmlXIncludeProcessNode__internal_alias")));
+#else
+#ifndef xmlXIncludeProcessNode
+extern __typeof (xmlXIncludeProcessNode) xmlXIncludeProcessNode__internal_alias __attribute((visibility("hidden")));
+#define xmlXIncludeProcessNode xmlXIncludeProcessNode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_xinclude
+#undef xmlXIncludeProcessTree
+extern __typeof (xmlXIncludeProcessTree) xmlXIncludeProcessTree __attribute((alias("xmlXIncludeProcessTree__internal_alias")));
+#else
+#ifndef xmlXIncludeProcessTree
+extern __typeof (xmlXIncludeProcessTree) xmlXIncludeProcessTree__internal_alias __attribute((visibility("hidden")));
+#define xmlXIncludeProcessTree xmlXIncludeProcessTree__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_xinclude
+#undef xmlXIncludeProcessTreeFlags
+extern __typeof (xmlXIncludeProcessTreeFlags) xmlXIncludeProcessTreeFlags __attribute((alias("xmlXIncludeProcessTreeFlags__internal_alias")));
+#else
+#ifndef xmlXIncludeProcessTreeFlags
+extern __typeof (xmlXIncludeProcessTreeFlags) xmlXIncludeProcessTreeFlags__internal_alias __attribute((visibility("hidden")));
+#define xmlXIncludeProcessTreeFlags xmlXIncludeProcessTreeFlags__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_xinclude
+#undef xmlXIncludeProcessTreeFlagsData
+extern __typeof (xmlXIncludeProcessTreeFlagsData) xmlXIncludeProcessTreeFlagsData __attribute((alias("xmlXIncludeProcessTreeFlagsData__internal_alias")));
+#else
+#ifndef xmlXIncludeProcessTreeFlagsData
+extern __typeof (xmlXIncludeProcessTreeFlagsData) xmlXIncludeProcessTreeFlagsData__internal_alias __attribute((visibility("hidden")));
+#define xmlXIncludeProcessTreeFlagsData xmlXIncludeProcessTreeFlagsData__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XINCLUDE_ENABLED)
+#ifdef bottom_xinclude
+#undef xmlXIncludeSetFlags
+extern __typeof (xmlXIncludeSetFlags) xmlXIncludeSetFlags __attribute((alias("xmlXIncludeSetFlags__internal_alias")));
+#else
+#ifndef xmlXIncludeSetFlags
+extern __typeof (xmlXIncludeSetFlags) xmlXIncludeSetFlags__internal_alias __attribute((visibility("hidden")));
+#define xmlXIncludeSetFlags xmlXIncludeSetFlags__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathAddValues
+extern __typeof (xmlXPathAddValues) xmlXPathAddValues __attribute((alias("xmlXPathAddValues__internal_alias")));
+#else
+#ifndef xmlXPathAddValues
+extern __typeof (xmlXPathAddValues) xmlXPathAddValues__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathAddValues xmlXPathAddValues__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathBooleanFunction
+extern __typeof (xmlXPathBooleanFunction) xmlXPathBooleanFunction __attribute((alias("xmlXPathBooleanFunction__internal_alias")));
+#else
+#ifndef xmlXPathBooleanFunction
+extern __typeof (xmlXPathBooleanFunction) xmlXPathBooleanFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathBooleanFunction xmlXPathBooleanFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastBooleanToNumber
+extern __typeof (xmlXPathCastBooleanToNumber) xmlXPathCastBooleanToNumber __attribute((alias("xmlXPathCastBooleanToNumber__internal_alias")));
+#else
+#ifndef xmlXPathCastBooleanToNumber
+extern __typeof (xmlXPathCastBooleanToNumber) xmlXPathCastBooleanToNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastBooleanToNumber xmlXPathCastBooleanToNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastBooleanToString
+extern __typeof (xmlXPathCastBooleanToString) xmlXPathCastBooleanToString __attribute((alias("xmlXPathCastBooleanToString__internal_alias")));
+#else
+#ifndef xmlXPathCastBooleanToString
+extern __typeof (xmlXPathCastBooleanToString) xmlXPathCastBooleanToString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastBooleanToString xmlXPathCastBooleanToString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastNodeSetToBoolean
+extern __typeof (xmlXPathCastNodeSetToBoolean) xmlXPathCastNodeSetToBoolean __attribute((alias("xmlXPathCastNodeSetToBoolean__internal_alias")));
+#else
+#ifndef xmlXPathCastNodeSetToBoolean
+extern __typeof (xmlXPathCastNodeSetToBoolean) xmlXPathCastNodeSetToBoolean__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastNodeSetToBoolean xmlXPathCastNodeSetToBoolean__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastNodeSetToNumber
+extern __typeof (xmlXPathCastNodeSetToNumber) xmlXPathCastNodeSetToNumber __attribute((alias("xmlXPathCastNodeSetToNumber__internal_alias")));
+#else
+#ifndef xmlXPathCastNodeSetToNumber
+extern __typeof (xmlXPathCastNodeSetToNumber) xmlXPathCastNodeSetToNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastNodeSetToNumber xmlXPathCastNodeSetToNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastNodeSetToString
+extern __typeof (xmlXPathCastNodeSetToString) xmlXPathCastNodeSetToString __attribute((alias("xmlXPathCastNodeSetToString__internal_alias")));
+#else
+#ifndef xmlXPathCastNodeSetToString
+extern __typeof (xmlXPathCastNodeSetToString) xmlXPathCastNodeSetToString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastNodeSetToString xmlXPathCastNodeSetToString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastNodeToNumber
+extern __typeof (xmlXPathCastNodeToNumber) xmlXPathCastNodeToNumber __attribute((alias("xmlXPathCastNodeToNumber__internal_alias")));
+#else
+#ifndef xmlXPathCastNodeToNumber
+extern __typeof (xmlXPathCastNodeToNumber) xmlXPathCastNodeToNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastNodeToNumber xmlXPathCastNodeToNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastNodeToString
+extern __typeof (xmlXPathCastNodeToString) xmlXPathCastNodeToString __attribute((alias("xmlXPathCastNodeToString__internal_alias")));
+#else
+#ifndef xmlXPathCastNodeToString
+extern __typeof (xmlXPathCastNodeToString) xmlXPathCastNodeToString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastNodeToString xmlXPathCastNodeToString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastNumberToBoolean
+extern __typeof (xmlXPathCastNumberToBoolean) xmlXPathCastNumberToBoolean __attribute((alias("xmlXPathCastNumberToBoolean__internal_alias")));
+#else
+#ifndef xmlXPathCastNumberToBoolean
+extern __typeof (xmlXPathCastNumberToBoolean) xmlXPathCastNumberToBoolean__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastNumberToBoolean xmlXPathCastNumberToBoolean__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastNumberToString
+extern __typeof (xmlXPathCastNumberToString) xmlXPathCastNumberToString __attribute((alias("xmlXPathCastNumberToString__internal_alias")));
+#else
+#ifndef xmlXPathCastNumberToString
+extern __typeof (xmlXPathCastNumberToString) xmlXPathCastNumberToString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastNumberToString xmlXPathCastNumberToString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastStringToBoolean
+extern __typeof (xmlXPathCastStringToBoolean) xmlXPathCastStringToBoolean __attribute((alias("xmlXPathCastStringToBoolean__internal_alias")));
+#else
+#ifndef xmlXPathCastStringToBoolean
+extern __typeof (xmlXPathCastStringToBoolean) xmlXPathCastStringToBoolean__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastStringToBoolean xmlXPathCastStringToBoolean__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastStringToNumber
+extern __typeof (xmlXPathCastStringToNumber) xmlXPathCastStringToNumber __attribute((alias("xmlXPathCastStringToNumber__internal_alias")));
+#else
+#ifndef xmlXPathCastStringToNumber
+extern __typeof (xmlXPathCastStringToNumber) xmlXPathCastStringToNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastStringToNumber xmlXPathCastStringToNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastToBoolean
+extern __typeof (xmlXPathCastToBoolean) xmlXPathCastToBoolean __attribute((alias("xmlXPathCastToBoolean__internal_alias")));
+#else
+#ifndef xmlXPathCastToBoolean
+extern __typeof (xmlXPathCastToBoolean) xmlXPathCastToBoolean__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastToBoolean xmlXPathCastToBoolean__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastToNumber
+extern __typeof (xmlXPathCastToNumber) xmlXPathCastToNumber __attribute((alias("xmlXPathCastToNumber__internal_alias")));
+#else
+#ifndef xmlXPathCastToNumber
+extern __typeof (xmlXPathCastToNumber) xmlXPathCastToNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastToNumber xmlXPathCastToNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCastToString
+extern __typeof (xmlXPathCastToString) xmlXPathCastToString __attribute((alias("xmlXPathCastToString__internal_alias")));
+#else
+#ifndef xmlXPathCastToString
+extern __typeof (xmlXPathCastToString) xmlXPathCastToString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCastToString xmlXPathCastToString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCeilingFunction
+extern __typeof (xmlXPathCeilingFunction) xmlXPathCeilingFunction __attribute((alias("xmlXPathCeilingFunction__internal_alias")));
+#else
+#ifndef xmlXPathCeilingFunction
+extern __typeof (xmlXPathCeilingFunction) xmlXPathCeilingFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCeilingFunction xmlXPathCeilingFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCmpNodes
+extern __typeof (xmlXPathCmpNodes) xmlXPathCmpNodes __attribute((alias("xmlXPathCmpNodes__internal_alias")));
+#else
+#ifndef xmlXPathCmpNodes
+extern __typeof (xmlXPathCmpNodes) xmlXPathCmpNodes__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCmpNodes xmlXPathCmpNodes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCompareValues
+extern __typeof (xmlXPathCompareValues) xmlXPathCompareValues __attribute((alias("xmlXPathCompareValues__internal_alias")));
+#else
+#ifndef xmlXPathCompareValues
+extern __typeof (xmlXPathCompareValues) xmlXPathCompareValues__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCompareValues xmlXPathCompareValues__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCompile
+extern __typeof (xmlXPathCompile) xmlXPathCompile __attribute((alias("xmlXPathCompile__internal_alias")));
+#else
+#ifndef xmlXPathCompile
+extern __typeof (xmlXPathCompile) xmlXPathCompile__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCompile xmlXPathCompile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCompiledEval
+extern __typeof (xmlXPathCompiledEval) xmlXPathCompiledEval __attribute((alias("xmlXPathCompiledEval__internal_alias")));
+#else
+#ifndef xmlXPathCompiledEval
+extern __typeof (xmlXPathCompiledEval) xmlXPathCompiledEval__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCompiledEval xmlXPathCompiledEval__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCompiledEvalToBoolean
+extern __typeof (xmlXPathCompiledEvalToBoolean) xmlXPathCompiledEvalToBoolean __attribute((alias("xmlXPathCompiledEvalToBoolean__internal_alias")));
+#else
+#ifndef xmlXPathCompiledEvalToBoolean
+extern __typeof (xmlXPathCompiledEvalToBoolean) xmlXPathCompiledEvalToBoolean__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCompiledEvalToBoolean xmlXPathCompiledEvalToBoolean__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathConcatFunction
+extern __typeof (xmlXPathConcatFunction) xmlXPathConcatFunction __attribute((alias("xmlXPathConcatFunction__internal_alias")));
+#else
+#ifndef xmlXPathConcatFunction
+extern __typeof (xmlXPathConcatFunction) xmlXPathConcatFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathConcatFunction xmlXPathConcatFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathContainsFunction
+extern __typeof (xmlXPathContainsFunction) xmlXPathContainsFunction __attribute((alias("xmlXPathContainsFunction__internal_alias")));
+#else
+#ifndef xmlXPathContainsFunction
+extern __typeof (xmlXPathContainsFunction) xmlXPathContainsFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathContainsFunction xmlXPathContainsFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathContextSetCache
+extern __typeof (xmlXPathContextSetCache) xmlXPathContextSetCache __attribute((alias("xmlXPathContextSetCache__internal_alias")));
+#else
+#ifndef xmlXPathContextSetCache
+extern __typeof (xmlXPathContextSetCache) xmlXPathContextSetCache__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathContextSetCache xmlXPathContextSetCache__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathConvertBoolean
+extern __typeof (xmlXPathConvertBoolean) xmlXPathConvertBoolean __attribute((alias("xmlXPathConvertBoolean__internal_alias")));
+#else
+#ifndef xmlXPathConvertBoolean
+extern __typeof (xmlXPathConvertBoolean) xmlXPathConvertBoolean__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathConvertBoolean xmlXPathConvertBoolean__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathConvertNumber
+extern __typeof (xmlXPathConvertNumber) xmlXPathConvertNumber __attribute((alias("xmlXPathConvertNumber__internal_alias")));
+#else
+#ifndef xmlXPathConvertNumber
+extern __typeof (xmlXPathConvertNumber) xmlXPathConvertNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathConvertNumber xmlXPathConvertNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathConvertString
+extern __typeof (xmlXPathConvertString) xmlXPathConvertString __attribute((alias("xmlXPathConvertString__internal_alias")));
+#else
+#ifndef xmlXPathConvertString
+extern __typeof (xmlXPathConvertString) xmlXPathConvertString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathConvertString xmlXPathConvertString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCountFunction
+extern __typeof (xmlXPathCountFunction) xmlXPathCountFunction __attribute((alias("xmlXPathCountFunction__internal_alias")));
+#else
+#ifndef xmlXPathCountFunction
+extern __typeof (xmlXPathCountFunction) xmlXPathCountFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCountFunction xmlXPathCountFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathCtxtCompile
+extern __typeof (xmlXPathCtxtCompile) xmlXPathCtxtCompile __attribute((alias("xmlXPathCtxtCompile__internal_alias")));
+#else
+#ifndef xmlXPathCtxtCompile
+extern __typeof (xmlXPathCtxtCompile) xmlXPathCtxtCompile__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathCtxtCompile xmlXPathCtxtCompile__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathDebugDumpCompExpr
+extern __typeof (xmlXPathDebugDumpCompExpr) xmlXPathDebugDumpCompExpr __attribute((alias("xmlXPathDebugDumpCompExpr__internal_alias")));
+#else
+#ifndef xmlXPathDebugDumpCompExpr
+extern __typeof (xmlXPathDebugDumpCompExpr) xmlXPathDebugDumpCompExpr__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathDebugDumpCompExpr xmlXPathDebugDumpCompExpr__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED) && defined(LIBXML_DEBUG_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathDebugDumpObject
+extern __typeof (xmlXPathDebugDumpObject) xmlXPathDebugDumpObject __attribute((alias("xmlXPathDebugDumpObject__internal_alias")));
+#else
+#ifndef xmlXPathDebugDumpObject
+extern __typeof (xmlXPathDebugDumpObject) xmlXPathDebugDumpObject__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathDebugDumpObject xmlXPathDebugDumpObject__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathDifference
+extern __typeof (xmlXPathDifference) xmlXPathDifference __attribute((alias("xmlXPathDifference__internal_alias")));
+#else
+#ifndef xmlXPathDifference
+extern __typeof (xmlXPathDifference) xmlXPathDifference__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathDifference xmlXPathDifference__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathDistinct
+extern __typeof (xmlXPathDistinct) xmlXPathDistinct __attribute((alias("xmlXPathDistinct__internal_alias")));
+#else
+#ifndef xmlXPathDistinct
+extern __typeof (xmlXPathDistinct) xmlXPathDistinct__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathDistinct xmlXPathDistinct__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathDistinctSorted
+extern __typeof (xmlXPathDistinctSorted) xmlXPathDistinctSorted __attribute((alias("xmlXPathDistinctSorted__internal_alias")));
+#else
+#ifndef xmlXPathDistinctSorted
+extern __typeof (xmlXPathDistinctSorted) xmlXPathDistinctSorted__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathDistinctSorted xmlXPathDistinctSorted__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathDivValues
+extern __typeof (xmlXPathDivValues) xmlXPathDivValues __attribute((alias("xmlXPathDivValues__internal_alias")));
+#else
+#ifndef xmlXPathDivValues
+extern __typeof (xmlXPathDivValues) xmlXPathDivValues__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathDivValues xmlXPathDivValues__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathEqualValues
+extern __typeof (xmlXPathEqualValues) xmlXPathEqualValues __attribute((alias("xmlXPathEqualValues__internal_alias")));
+#else
+#ifndef xmlXPathEqualValues
+extern __typeof (xmlXPathEqualValues) xmlXPathEqualValues__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathEqualValues xmlXPathEqualValues__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathErr
+extern __typeof (xmlXPathErr) xmlXPathErr __attribute((alias("xmlXPathErr__internal_alias")));
+#else
+#ifndef xmlXPathErr
+extern __typeof (xmlXPathErr) xmlXPathErr__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathErr xmlXPathErr__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathEval
+extern __typeof (xmlXPathEval) xmlXPathEval __attribute((alias("xmlXPathEval__internal_alias")));
+#else
+#ifndef xmlXPathEval
+extern __typeof (xmlXPathEval) xmlXPathEval__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathEval xmlXPathEval__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathEvalExpr
+extern __typeof (xmlXPathEvalExpr) xmlXPathEvalExpr __attribute((alias("xmlXPathEvalExpr__internal_alias")));
+#else
+#ifndef xmlXPathEvalExpr
+extern __typeof (xmlXPathEvalExpr) xmlXPathEvalExpr__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathEvalExpr xmlXPathEvalExpr__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathEvalExpression
+extern __typeof (xmlXPathEvalExpression) xmlXPathEvalExpression __attribute((alias("xmlXPathEvalExpression__internal_alias")));
+#else
+#ifndef xmlXPathEvalExpression
+extern __typeof (xmlXPathEvalExpression) xmlXPathEvalExpression__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathEvalExpression xmlXPathEvalExpression__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathEvalPredicate
+extern __typeof (xmlXPathEvalPredicate) xmlXPathEvalPredicate __attribute((alias("xmlXPathEvalPredicate__internal_alias")));
+#else
+#ifndef xmlXPathEvalPredicate
+extern __typeof (xmlXPathEvalPredicate) xmlXPathEvalPredicate__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathEvalPredicate xmlXPathEvalPredicate__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathEvaluatePredicateResult
+extern __typeof (xmlXPathEvaluatePredicateResult) xmlXPathEvaluatePredicateResult __attribute((alias("xmlXPathEvaluatePredicateResult__internal_alias")));
+#else
+#ifndef xmlXPathEvaluatePredicateResult
+extern __typeof (xmlXPathEvaluatePredicateResult) xmlXPathEvaluatePredicateResult__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathEvaluatePredicateResult xmlXPathEvaluatePredicateResult__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathFalseFunction
+extern __typeof (xmlXPathFalseFunction) xmlXPathFalseFunction __attribute((alias("xmlXPathFalseFunction__internal_alias")));
+#else
+#ifndef xmlXPathFalseFunction
+extern __typeof (xmlXPathFalseFunction) xmlXPathFalseFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathFalseFunction xmlXPathFalseFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathFloorFunction
+extern __typeof (xmlXPathFloorFunction) xmlXPathFloorFunction __attribute((alias("xmlXPathFloorFunction__internal_alias")));
+#else
+#ifndef xmlXPathFloorFunction
+extern __typeof (xmlXPathFloorFunction) xmlXPathFloorFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathFloorFunction xmlXPathFloorFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathFreeCompExpr
+extern __typeof (xmlXPathFreeCompExpr) xmlXPathFreeCompExpr __attribute((alias("xmlXPathFreeCompExpr__internal_alias")));
+#else
+#ifndef xmlXPathFreeCompExpr
+extern __typeof (xmlXPathFreeCompExpr) xmlXPathFreeCompExpr__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathFreeCompExpr xmlXPathFreeCompExpr__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathFreeContext
+extern __typeof (xmlXPathFreeContext) xmlXPathFreeContext __attribute((alias("xmlXPathFreeContext__internal_alias")));
+#else
+#ifndef xmlXPathFreeContext
+extern __typeof (xmlXPathFreeContext) xmlXPathFreeContext__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathFreeContext xmlXPathFreeContext__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathFreeNodeSet
+extern __typeof (xmlXPathFreeNodeSet) xmlXPathFreeNodeSet __attribute((alias("xmlXPathFreeNodeSet__internal_alias")));
+#else
+#ifndef xmlXPathFreeNodeSet
+extern __typeof (xmlXPathFreeNodeSet) xmlXPathFreeNodeSet__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathFreeNodeSet xmlXPathFreeNodeSet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathFreeNodeSetList
+extern __typeof (xmlXPathFreeNodeSetList) xmlXPathFreeNodeSetList __attribute((alias("xmlXPathFreeNodeSetList__internal_alias")));
+#else
+#ifndef xmlXPathFreeNodeSetList
+extern __typeof (xmlXPathFreeNodeSetList) xmlXPathFreeNodeSetList__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathFreeNodeSetList xmlXPathFreeNodeSetList__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathFreeObject
+extern __typeof (xmlXPathFreeObject) xmlXPathFreeObject __attribute((alias("xmlXPathFreeObject__internal_alias")));
+#else
+#ifndef xmlXPathFreeObject
+extern __typeof (xmlXPathFreeObject) xmlXPathFreeObject__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathFreeObject xmlXPathFreeObject__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathFreeParserContext
+extern __typeof (xmlXPathFreeParserContext) xmlXPathFreeParserContext __attribute((alias("xmlXPathFreeParserContext__internal_alias")));
+#else
+#ifndef xmlXPathFreeParserContext
+extern __typeof (xmlXPathFreeParserContext) xmlXPathFreeParserContext__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathFreeParserContext xmlXPathFreeParserContext__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathFunctionLookup
+extern __typeof (xmlXPathFunctionLookup) xmlXPathFunctionLookup __attribute((alias("xmlXPathFunctionLookup__internal_alias")));
+#else
+#ifndef xmlXPathFunctionLookup
+extern __typeof (xmlXPathFunctionLookup) xmlXPathFunctionLookup__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathFunctionLookup xmlXPathFunctionLookup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathFunctionLookupNS
+extern __typeof (xmlXPathFunctionLookupNS) xmlXPathFunctionLookupNS __attribute((alias("xmlXPathFunctionLookupNS__internal_alias")));
+#else
+#ifndef xmlXPathFunctionLookupNS
+extern __typeof (xmlXPathFunctionLookupNS) xmlXPathFunctionLookupNS__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathFunctionLookupNS xmlXPathFunctionLookupNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathHasSameNodes
+extern __typeof (xmlXPathHasSameNodes) xmlXPathHasSameNodes __attribute((alias("xmlXPathHasSameNodes__internal_alias")));
+#else
+#ifndef xmlXPathHasSameNodes
+extern __typeof (xmlXPathHasSameNodes) xmlXPathHasSameNodes__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathHasSameNodes xmlXPathHasSameNodes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathIdFunction
+extern __typeof (xmlXPathIdFunction) xmlXPathIdFunction __attribute((alias("xmlXPathIdFunction__internal_alias")));
+#else
+#ifndef xmlXPathIdFunction
+extern __typeof (xmlXPathIdFunction) xmlXPathIdFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathIdFunction xmlXPathIdFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathInit
+extern __typeof (xmlXPathInit) xmlXPathInit __attribute((alias("xmlXPathInit__internal_alias")));
+#else
+#ifndef xmlXPathInit
+extern __typeof (xmlXPathInit) xmlXPathInit__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathInit xmlXPathInit__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathIntersection
+extern __typeof (xmlXPathIntersection) xmlXPathIntersection __attribute((alias("xmlXPathIntersection__internal_alias")));
+#else
+#ifndef xmlXPathIntersection
+extern __typeof (xmlXPathIntersection) xmlXPathIntersection__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathIntersection xmlXPathIntersection__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathIsInf
+extern __typeof (xmlXPathIsInf) xmlXPathIsInf __attribute((alias("xmlXPathIsInf__internal_alias")));
+#else
+#ifndef xmlXPathIsInf
+extern __typeof (xmlXPathIsInf) xmlXPathIsInf__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathIsInf xmlXPathIsInf__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathIsNaN
+extern __typeof (xmlXPathIsNaN) xmlXPathIsNaN __attribute((alias("xmlXPathIsNaN__internal_alias")));
+#else
+#ifndef xmlXPathIsNaN
+extern __typeof (xmlXPathIsNaN) xmlXPathIsNaN__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathIsNaN xmlXPathIsNaN__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathIsNodeType
+extern __typeof (xmlXPathIsNodeType) xmlXPathIsNodeType __attribute((alias("xmlXPathIsNodeType__internal_alias")));
+#else
+#ifndef xmlXPathIsNodeType
+extern __typeof (xmlXPathIsNodeType) xmlXPathIsNodeType__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathIsNodeType xmlXPathIsNodeType__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathLangFunction
+extern __typeof (xmlXPathLangFunction) xmlXPathLangFunction __attribute((alias("xmlXPathLangFunction__internal_alias")));
+#else
+#ifndef xmlXPathLangFunction
+extern __typeof (xmlXPathLangFunction) xmlXPathLangFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathLangFunction xmlXPathLangFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathLastFunction
+extern __typeof (xmlXPathLastFunction) xmlXPathLastFunction __attribute((alias("xmlXPathLastFunction__internal_alias")));
+#else
+#ifndef xmlXPathLastFunction
+extern __typeof (xmlXPathLastFunction) xmlXPathLastFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathLastFunction xmlXPathLastFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathLeading
+extern __typeof (xmlXPathLeading) xmlXPathLeading __attribute((alias("xmlXPathLeading__internal_alias")));
+#else
+#ifndef xmlXPathLeading
+extern __typeof (xmlXPathLeading) xmlXPathLeading__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathLeading xmlXPathLeading__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathLeadingSorted
+extern __typeof (xmlXPathLeadingSorted) xmlXPathLeadingSorted __attribute((alias("xmlXPathLeadingSorted__internal_alias")));
+#else
+#ifndef xmlXPathLeadingSorted
+extern __typeof (xmlXPathLeadingSorted) xmlXPathLeadingSorted__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathLeadingSorted xmlXPathLeadingSorted__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathLocalNameFunction
+extern __typeof (xmlXPathLocalNameFunction) xmlXPathLocalNameFunction __attribute((alias("xmlXPathLocalNameFunction__internal_alias")));
+#else
+#ifndef xmlXPathLocalNameFunction
+extern __typeof (xmlXPathLocalNameFunction) xmlXPathLocalNameFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathLocalNameFunction xmlXPathLocalNameFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathModValues
+extern __typeof (xmlXPathModValues) xmlXPathModValues __attribute((alias("xmlXPathModValues__internal_alias")));
+#else
+#ifndef xmlXPathModValues
+extern __typeof (xmlXPathModValues) xmlXPathModValues__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathModValues xmlXPathModValues__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathMultValues
+extern __typeof (xmlXPathMultValues) xmlXPathMultValues __attribute((alias("xmlXPathMultValues__internal_alias")));
+#else
+#ifndef xmlXPathMultValues
+extern __typeof (xmlXPathMultValues) xmlXPathMultValues__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathMultValues xmlXPathMultValues__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNamespaceURIFunction
+extern __typeof (xmlXPathNamespaceURIFunction) xmlXPathNamespaceURIFunction __attribute((alias("xmlXPathNamespaceURIFunction__internal_alias")));
+#else
+#ifndef xmlXPathNamespaceURIFunction
+extern __typeof (xmlXPathNamespaceURIFunction) xmlXPathNamespaceURIFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNamespaceURIFunction xmlXPathNamespaceURIFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNewBoolean
+extern __typeof (xmlXPathNewBoolean) xmlXPathNewBoolean __attribute((alias("xmlXPathNewBoolean__internal_alias")));
+#else
+#ifndef xmlXPathNewBoolean
+extern __typeof (xmlXPathNewBoolean) xmlXPathNewBoolean__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNewBoolean xmlXPathNewBoolean__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNewCString
+extern __typeof (xmlXPathNewCString) xmlXPathNewCString __attribute((alias("xmlXPathNewCString__internal_alias")));
+#else
+#ifndef xmlXPathNewCString
+extern __typeof (xmlXPathNewCString) xmlXPathNewCString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNewCString xmlXPathNewCString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNewContext
+extern __typeof (xmlXPathNewContext) xmlXPathNewContext __attribute((alias("xmlXPathNewContext__internal_alias")));
+#else
+#ifndef xmlXPathNewContext
+extern __typeof (xmlXPathNewContext) xmlXPathNewContext__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNewContext xmlXPathNewContext__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNewFloat
+extern __typeof (xmlXPathNewFloat) xmlXPathNewFloat __attribute((alias("xmlXPathNewFloat__internal_alias")));
+#else
+#ifndef xmlXPathNewFloat
+extern __typeof (xmlXPathNewFloat) xmlXPathNewFloat__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNewFloat xmlXPathNewFloat__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNewNodeSet
+extern __typeof (xmlXPathNewNodeSet) xmlXPathNewNodeSet __attribute((alias("xmlXPathNewNodeSet__internal_alias")));
+#else
+#ifndef xmlXPathNewNodeSet
+extern __typeof (xmlXPathNewNodeSet) xmlXPathNewNodeSet__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNewNodeSet xmlXPathNewNodeSet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNewNodeSetList
+extern __typeof (xmlXPathNewNodeSetList) xmlXPathNewNodeSetList __attribute((alias("xmlXPathNewNodeSetList__internal_alias")));
+#else
+#ifndef xmlXPathNewNodeSetList
+extern __typeof (xmlXPathNewNodeSetList) xmlXPathNewNodeSetList__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNewNodeSetList xmlXPathNewNodeSetList__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNewParserContext
+extern __typeof (xmlXPathNewParserContext) xmlXPathNewParserContext __attribute((alias("xmlXPathNewParserContext__internal_alias")));
+#else
+#ifndef xmlXPathNewParserContext
+extern __typeof (xmlXPathNewParserContext) xmlXPathNewParserContext__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNewParserContext xmlXPathNewParserContext__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNewString
+extern __typeof (xmlXPathNewString) xmlXPathNewString __attribute((alias("xmlXPathNewString__internal_alias")));
+#else
+#ifndef xmlXPathNewString
+extern __typeof (xmlXPathNewString) xmlXPathNewString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNewString xmlXPathNewString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNewValueTree
+extern __typeof (xmlXPathNewValueTree) xmlXPathNewValueTree __attribute((alias("xmlXPathNewValueTree__internal_alias")));
+#else
+#ifndef xmlXPathNewValueTree
+extern __typeof (xmlXPathNewValueTree) xmlXPathNewValueTree__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNewValueTree xmlXPathNewValueTree__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextAncestor
+extern __typeof (xmlXPathNextAncestor) xmlXPathNextAncestor __attribute((alias("xmlXPathNextAncestor__internal_alias")));
+#else
+#ifndef xmlXPathNextAncestor
+extern __typeof (xmlXPathNextAncestor) xmlXPathNextAncestor__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextAncestor xmlXPathNextAncestor__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextAncestorOrSelf
+extern __typeof (xmlXPathNextAncestorOrSelf) xmlXPathNextAncestorOrSelf __attribute((alias("xmlXPathNextAncestorOrSelf__internal_alias")));
+#else
+#ifndef xmlXPathNextAncestorOrSelf
+extern __typeof (xmlXPathNextAncestorOrSelf) xmlXPathNextAncestorOrSelf__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextAncestorOrSelf xmlXPathNextAncestorOrSelf__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextAttribute
+extern __typeof (xmlXPathNextAttribute) xmlXPathNextAttribute __attribute((alias("xmlXPathNextAttribute__internal_alias")));
+#else
+#ifndef xmlXPathNextAttribute
+extern __typeof (xmlXPathNextAttribute) xmlXPathNextAttribute__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextAttribute xmlXPathNextAttribute__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextChild
+extern __typeof (xmlXPathNextChild) xmlXPathNextChild __attribute((alias("xmlXPathNextChild__internal_alias")));
+#else
+#ifndef xmlXPathNextChild
+extern __typeof (xmlXPathNextChild) xmlXPathNextChild__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextChild xmlXPathNextChild__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextDescendant
+extern __typeof (xmlXPathNextDescendant) xmlXPathNextDescendant __attribute((alias("xmlXPathNextDescendant__internal_alias")));
+#else
+#ifndef xmlXPathNextDescendant
+extern __typeof (xmlXPathNextDescendant) xmlXPathNextDescendant__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextDescendant xmlXPathNextDescendant__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextDescendantOrSelf
+extern __typeof (xmlXPathNextDescendantOrSelf) xmlXPathNextDescendantOrSelf __attribute((alias("xmlXPathNextDescendantOrSelf__internal_alias")));
+#else
+#ifndef xmlXPathNextDescendantOrSelf
+extern __typeof (xmlXPathNextDescendantOrSelf) xmlXPathNextDescendantOrSelf__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextDescendantOrSelf xmlXPathNextDescendantOrSelf__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextFollowing
+extern __typeof (xmlXPathNextFollowing) xmlXPathNextFollowing __attribute((alias("xmlXPathNextFollowing__internal_alias")));
+#else
+#ifndef xmlXPathNextFollowing
+extern __typeof (xmlXPathNextFollowing) xmlXPathNextFollowing__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextFollowing xmlXPathNextFollowing__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextFollowingSibling
+extern __typeof (xmlXPathNextFollowingSibling) xmlXPathNextFollowingSibling __attribute((alias("xmlXPathNextFollowingSibling__internal_alias")));
+#else
+#ifndef xmlXPathNextFollowingSibling
+extern __typeof (xmlXPathNextFollowingSibling) xmlXPathNextFollowingSibling__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextFollowingSibling xmlXPathNextFollowingSibling__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextNamespace
+extern __typeof (xmlXPathNextNamespace) xmlXPathNextNamespace __attribute((alias("xmlXPathNextNamespace__internal_alias")));
+#else
+#ifndef xmlXPathNextNamespace
+extern __typeof (xmlXPathNextNamespace) xmlXPathNextNamespace__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextNamespace xmlXPathNextNamespace__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextParent
+extern __typeof (xmlXPathNextParent) xmlXPathNextParent __attribute((alias("xmlXPathNextParent__internal_alias")));
+#else
+#ifndef xmlXPathNextParent
+extern __typeof (xmlXPathNextParent) xmlXPathNextParent__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextParent xmlXPathNextParent__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextPreceding
+extern __typeof (xmlXPathNextPreceding) xmlXPathNextPreceding __attribute((alias("xmlXPathNextPreceding__internal_alias")));
+#else
+#ifndef xmlXPathNextPreceding
+extern __typeof (xmlXPathNextPreceding) xmlXPathNextPreceding__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextPreceding xmlXPathNextPreceding__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextPrecedingSibling
+extern __typeof (xmlXPathNextPrecedingSibling) xmlXPathNextPrecedingSibling __attribute((alias("xmlXPathNextPrecedingSibling__internal_alias")));
+#else
+#ifndef xmlXPathNextPrecedingSibling
+extern __typeof (xmlXPathNextPrecedingSibling) xmlXPathNextPrecedingSibling__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextPrecedingSibling xmlXPathNextPrecedingSibling__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNextSelf
+extern __typeof (xmlXPathNextSelf) xmlXPathNextSelf __attribute((alias("xmlXPathNextSelf__internal_alias")));
+#else
+#ifndef xmlXPathNextSelf
+extern __typeof (xmlXPathNextSelf) xmlXPathNextSelf__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNextSelf xmlXPathNextSelf__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeEval
+extern __typeof (xmlXPathNodeEval) xmlXPathNodeEval __attribute((alias("xmlXPathNodeEval__internal_alias")));
+#else
+#ifndef xmlXPathNodeEval
+extern __typeof (xmlXPathNodeEval) xmlXPathNodeEval__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeEval xmlXPathNodeEval__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeLeading
+extern __typeof (xmlXPathNodeLeading) xmlXPathNodeLeading __attribute((alias("xmlXPathNodeLeading__internal_alias")));
+#else
+#ifndef xmlXPathNodeLeading
+extern __typeof (xmlXPathNodeLeading) xmlXPathNodeLeading__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeLeading xmlXPathNodeLeading__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeLeadingSorted
+extern __typeof (xmlXPathNodeLeadingSorted) xmlXPathNodeLeadingSorted __attribute((alias("xmlXPathNodeLeadingSorted__internal_alias")));
+#else
+#ifndef xmlXPathNodeLeadingSorted
+extern __typeof (xmlXPathNodeLeadingSorted) xmlXPathNodeLeadingSorted__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeLeadingSorted xmlXPathNodeLeadingSorted__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeSetAdd
+extern __typeof (xmlXPathNodeSetAdd) xmlXPathNodeSetAdd __attribute((alias("xmlXPathNodeSetAdd__internal_alias")));
+#else
+#ifndef xmlXPathNodeSetAdd
+extern __typeof (xmlXPathNodeSetAdd) xmlXPathNodeSetAdd__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeSetAdd xmlXPathNodeSetAdd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeSetAddNs
+extern __typeof (xmlXPathNodeSetAddNs) xmlXPathNodeSetAddNs __attribute((alias("xmlXPathNodeSetAddNs__internal_alias")));
+#else
+#ifndef xmlXPathNodeSetAddNs
+extern __typeof (xmlXPathNodeSetAddNs) xmlXPathNodeSetAddNs__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeSetAddNs xmlXPathNodeSetAddNs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeSetAddUnique
+extern __typeof (xmlXPathNodeSetAddUnique) xmlXPathNodeSetAddUnique __attribute((alias("xmlXPathNodeSetAddUnique__internal_alias")));
+#else
+#ifndef xmlXPathNodeSetAddUnique
+extern __typeof (xmlXPathNodeSetAddUnique) xmlXPathNodeSetAddUnique__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeSetAddUnique xmlXPathNodeSetAddUnique__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeSetContains
+extern __typeof (xmlXPathNodeSetContains) xmlXPathNodeSetContains __attribute((alias("xmlXPathNodeSetContains__internal_alias")));
+#else
+#ifndef xmlXPathNodeSetContains
+extern __typeof (xmlXPathNodeSetContains) xmlXPathNodeSetContains__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeSetContains xmlXPathNodeSetContains__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeSetCreate
+extern __typeof (xmlXPathNodeSetCreate) xmlXPathNodeSetCreate __attribute((alias("xmlXPathNodeSetCreate__internal_alias")));
+#else
+#ifndef xmlXPathNodeSetCreate
+extern __typeof (xmlXPathNodeSetCreate) xmlXPathNodeSetCreate__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeSetCreate xmlXPathNodeSetCreate__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeSetDel
+extern __typeof (xmlXPathNodeSetDel) xmlXPathNodeSetDel __attribute((alias("xmlXPathNodeSetDel__internal_alias")));
+#else
+#ifndef xmlXPathNodeSetDel
+extern __typeof (xmlXPathNodeSetDel) xmlXPathNodeSetDel__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeSetDel xmlXPathNodeSetDel__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeSetFreeNs
+extern __typeof (xmlXPathNodeSetFreeNs) xmlXPathNodeSetFreeNs __attribute((alias("xmlXPathNodeSetFreeNs__internal_alias")));
+#else
+#ifndef xmlXPathNodeSetFreeNs
+extern __typeof (xmlXPathNodeSetFreeNs) xmlXPathNodeSetFreeNs__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeSetFreeNs xmlXPathNodeSetFreeNs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeSetMerge
+extern __typeof (xmlXPathNodeSetMerge) xmlXPathNodeSetMerge __attribute((alias("xmlXPathNodeSetMerge__internal_alias")));
+#else
+#ifndef xmlXPathNodeSetMerge
+extern __typeof (xmlXPathNodeSetMerge) xmlXPathNodeSetMerge__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeSetMerge xmlXPathNodeSetMerge__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeSetRemove
+extern __typeof (xmlXPathNodeSetRemove) xmlXPathNodeSetRemove __attribute((alias("xmlXPathNodeSetRemove__internal_alias")));
+#else
+#ifndef xmlXPathNodeSetRemove
+extern __typeof (xmlXPathNodeSetRemove) xmlXPathNodeSetRemove__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeSetRemove xmlXPathNodeSetRemove__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeSetSort
+extern __typeof (xmlXPathNodeSetSort) xmlXPathNodeSetSort __attribute((alias("xmlXPathNodeSetSort__internal_alias")));
+#else
+#ifndef xmlXPathNodeSetSort
+extern __typeof (xmlXPathNodeSetSort) xmlXPathNodeSetSort__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeSetSort xmlXPathNodeSetSort__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeTrailing
+extern __typeof (xmlXPathNodeTrailing) xmlXPathNodeTrailing __attribute((alias("xmlXPathNodeTrailing__internal_alias")));
+#else
+#ifndef xmlXPathNodeTrailing
+extern __typeof (xmlXPathNodeTrailing) xmlXPathNodeTrailing__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeTrailing xmlXPathNodeTrailing__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNodeTrailingSorted
+extern __typeof (xmlXPathNodeTrailingSorted) xmlXPathNodeTrailingSorted __attribute((alias("xmlXPathNodeTrailingSorted__internal_alias")));
+#else
+#ifndef xmlXPathNodeTrailingSorted
+extern __typeof (xmlXPathNodeTrailingSorted) xmlXPathNodeTrailingSorted__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNodeTrailingSorted xmlXPathNodeTrailingSorted__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNormalizeFunction
+extern __typeof (xmlXPathNormalizeFunction) xmlXPathNormalizeFunction __attribute((alias("xmlXPathNormalizeFunction__internal_alias")));
+#else
+#ifndef xmlXPathNormalizeFunction
+extern __typeof (xmlXPathNormalizeFunction) xmlXPathNormalizeFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNormalizeFunction xmlXPathNormalizeFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNotEqualValues
+extern __typeof (xmlXPathNotEqualValues) xmlXPathNotEqualValues __attribute((alias("xmlXPathNotEqualValues__internal_alias")));
+#else
+#ifndef xmlXPathNotEqualValues
+extern __typeof (xmlXPathNotEqualValues) xmlXPathNotEqualValues__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNotEqualValues xmlXPathNotEqualValues__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNotFunction
+extern __typeof (xmlXPathNotFunction) xmlXPathNotFunction __attribute((alias("xmlXPathNotFunction__internal_alias")));
+#else
+#ifndef xmlXPathNotFunction
+extern __typeof (xmlXPathNotFunction) xmlXPathNotFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNotFunction xmlXPathNotFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNsLookup
+extern __typeof (xmlXPathNsLookup) xmlXPathNsLookup __attribute((alias("xmlXPathNsLookup__internal_alias")));
+#else
+#ifndef xmlXPathNsLookup
+extern __typeof (xmlXPathNsLookup) xmlXPathNsLookup__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNsLookup xmlXPathNsLookup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathNumberFunction
+extern __typeof (xmlXPathNumberFunction) xmlXPathNumberFunction __attribute((alias("xmlXPathNumberFunction__internal_alias")));
+#else
+#ifndef xmlXPathNumberFunction
+extern __typeof (xmlXPathNumberFunction) xmlXPathNumberFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathNumberFunction xmlXPathNumberFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathObjectCopy
+extern __typeof (xmlXPathObjectCopy) xmlXPathObjectCopy __attribute((alias("xmlXPathObjectCopy__internal_alias")));
+#else
+#ifndef xmlXPathObjectCopy
+extern __typeof (xmlXPathObjectCopy) xmlXPathObjectCopy__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathObjectCopy xmlXPathObjectCopy__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathOrderDocElems
+extern __typeof (xmlXPathOrderDocElems) xmlXPathOrderDocElems __attribute((alias("xmlXPathOrderDocElems__internal_alias")));
+#else
+#ifndef xmlXPathOrderDocElems
+extern __typeof (xmlXPathOrderDocElems) xmlXPathOrderDocElems__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathOrderDocElems xmlXPathOrderDocElems__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathParseNCName
+extern __typeof (xmlXPathParseNCName) xmlXPathParseNCName __attribute((alias("xmlXPathParseNCName__internal_alias")));
+#else
+#ifndef xmlXPathParseNCName
+extern __typeof (xmlXPathParseNCName) xmlXPathParseNCName__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathParseNCName xmlXPathParseNCName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathParseName
+extern __typeof (xmlXPathParseName) xmlXPathParseName __attribute((alias("xmlXPathParseName__internal_alias")));
+#else
+#ifndef xmlXPathParseName
+extern __typeof (xmlXPathParseName) xmlXPathParseName__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathParseName xmlXPathParseName__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathPopBoolean
+extern __typeof (xmlXPathPopBoolean) xmlXPathPopBoolean __attribute((alias("xmlXPathPopBoolean__internal_alias")));
+#else
+#ifndef xmlXPathPopBoolean
+extern __typeof (xmlXPathPopBoolean) xmlXPathPopBoolean__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathPopBoolean xmlXPathPopBoolean__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathPopExternal
+extern __typeof (xmlXPathPopExternal) xmlXPathPopExternal __attribute((alias("xmlXPathPopExternal__internal_alias")));
+#else
+#ifndef xmlXPathPopExternal
+extern __typeof (xmlXPathPopExternal) xmlXPathPopExternal__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathPopExternal xmlXPathPopExternal__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathPopNodeSet
+extern __typeof (xmlXPathPopNodeSet) xmlXPathPopNodeSet __attribute((alias("xmlXPathPopNodeSet__internal_alias")));
+#else
+#ifndef xmlXPathPopNodeSet
+extern __typeof (xmlXPathPopNodeSet) xmlXPathPopNodeSet__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathPopNodeSet xmlXPathPopNodeSet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathPopNumber
+extern __typeof (xmlXPathPopNumber) xmlXPathPopNumber __attribute((alias("xmlXPathPopNumber__internal_alias")));
+#else
+#ifndef xmlXPathPopNumber
+extern __typeof (xmlXPathPopNumber) xmlXPathPopNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathPopNumber xmlXPathPopNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathPopString
+extern __typeof (xmlXPathPopString) xmlXPathPopString __attribute((alias("xmlXPathPopString__internal_alias")));
+#else
+#ifndef xmlXPathPopString
+extern __typeof (xmlXPathPopString) xmlXPathPopString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathPopString xmlXPathPopString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathPositionFunction
+extern __typeof (xmlXPathPositionFunction) xmlXPathPositionFunction __attribute((alias("xmlXPathPositionFunction__internal_alias")));
+#else
+#ifndef xmlXPathPositionFunction
+extern __typeof (xmlXPathPositionFunction) xmlXPathPositionFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathPositionFunction xmlXPathPositionFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisterAllFunctions
+extern __typeof (xmlXPathRegisterAllFunctions) xmlXPathRegisterAllFunctions __attribute((alias("xmlXPathRegisterAllFunctions__internal_alias")));
+#else
+#ifndef xmlXPathRegisterAllFunctions
+extern __typeof (xmlXPathRegisterAllFunctions) xmlXPathRegisterAllFunctions__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisterAllFunctions xmlXPathRegisterAllFunctions__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisterFunc
+extern __typeof (xmlXPathRegisterFunc) xmlXPathRegisterFunc __attribute((alias("xmlXPathRegisterFunc__internal_alias")));
+#else
+#ifndef xmlXPathRegisterFunc
+extern __typeof (xmlXPathRegisterFunc) xmlXPathRegisterFunc__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisterFunc xmlXPathRegisterFunc__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisterFuncLookup
+extern __typeof (xmlXPathRegisterFuncLookup) xmlXPathRegisterFuncLookup __attribute((alias("xmlXPathRegisterFuncLookup__internal_alias")));
+#else
+#ifndef xmlXPathRegisterFuncLookup
+extern __typeof (xmlXPathRegisterFuncLookup) xmlXPathRegisterFuncLookup__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisterFuncLookup xmlXPathRegisterFuncLookup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisterFuncNS
+extern __typeof (xmlXPathRegisterFuncNS) xmlXPathRegisterFuncNS __attribute((alias("xmlXPathRegisterFuncNS__internal_alias")));
+#else
+#ifndef xmlXPathRegisterFuncNS
+extern __typeof (xmlXPathRegisterFuncNS) xmlXPathRegisterFuncNS__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisterFuncNS xmlXPathRegisterFuncNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisterNs
+extern __typeof (xmlXPathRegisterNs) xmlXPathRegisterNs __attribute((alias("xmlXPathRegisterNs__internal_alias")));
+#else
+#ifndef xmlXPathRegisterNs
+extern __typeof (xmlXPathRegisterNs) xmlXPathRegisterNs__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisterNs xmlXPathRegisterNs__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisterVariable
+extern __typeof (xmlXPathRegisterVariable) xmlXPathRegisterVariable __attribute((alias("xmlXPathRegisterVariable__internal_alias")));
+#else
+#ifndef xmlXPathRegisterVariable
+extern __typeof (xmlXPathRegisterVariable) xmlXPathRegisterVariable__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisterVariable xmlXPathRegisterVariable__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisterVariableLookup
+extern __typeof (xmlXPathRegisterVariableLookup) xmlXPathRegisterVariableLookup __attribute((alias("xmlXPathRegisterVariableLookup__internal_alias")));
+#else
+#ifndef xmlXPathRegisterVariableLookup
+extern __typeof (xmlXPathRegisterVariableLookup) xmlXPathRegisterVariableLookup__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisterVariableLookup xmlXPathRegisterVariableLookup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisterVariableNS
+extern __typeof (xmlXPathRegisterVariableNS) xmlXPathRegisterVariableNS __attribute((alias("xmlXPathRegisterVariableNS__internal_alias")));
+#else
+#ifndef xmlXPathRegisterVariableNS
+extern __typeof (xmlXPathRegisterVariableNS) xmlXPathRegisterVariableNS__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisterVariableNS xmlXPathRegisterVariableNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisteredFuncsCleanup
+extern __typeof (xmlXPathRegisteredFuncsCleanup) xmlXPathRegisteredFuncsCleanup __attribute((alias("xmlXPathRegisteredFuncsCleanup__internal_alias")));
+#else
+#ifndef xmlXPathRegisteredFuncsCleanup
+extern __typeof (xmlXPathRegisteredFuncsCleanup) xmlXPathRegisteredFuncsCleanup__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisteredFuncsCleanup xmlXPathRegisteredFuncsCleanup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisteredNsCleanup
+extern __typeof (xmlXPathRegisteredNsCleanup) xmlXPathRegisteredNsCleanup __attribute((alias("xmlXPathRegisteredNsCleanup__internal_alias")));
+#else
+#ifndef xmlXPathRegisteredNsCleanup
+extern __typeof (xmlXPathRegisteredNsCleanup) xmlXPathRegisteredNsCleanup__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisteredNsCleanup xmlXPathRegisteredNsCleanup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRegisteredVariablesCleanup
+extern __typeof (xmlXPathRegisteredVariablesCleanup) xmlXPathRegisteredVariablesCleanup __attribute((alias("xmlXPathRegisteredVariablesCleanup__internal_alias")));
+#else
+#ifndef xmlXPathRegisteredVariablesCleanup
+extern __typeof (xmlXPathRegisteredVariablesCleanup) xmlXPathRegisteredVariablesCleanup__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRegisteredVariablesCleanup xmlXPathRegisteredVariablesCleanup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRoot
+extern __typeof (xmlXPathRoot) xmlXPathRoot __attribute((alias("xmlXPathRoot__internal_alias")));
+#else
+#ifndef xmlXPathRoot
+extern __typeof (xmlXPathRoot) xmlXPathRoot__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRoot xmlXPathRoot__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathRoundFunction
+extern __typeof (xmlXPathRoundFunction) xmlXPathRoundFunction __attribute((alias("xmlXPathRoundFunction__internal_alias")));
+#else
+#ifndef xmlXPathRoundFunction
+extern __typeof (xmlXPathRoundFunction) xmlXPathRoundFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathRoundFunction xmlXPathRoundFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathSetContextNode
+extern __typeof (xmlXPathSetContextNode) xmlXPathSetContextNode __attribute((alias("xmlXPathSetContextNode__internal_alias")));
+#else
+#ifndef xmlXPathSetContextNode
+extern __typeof (xmlXPathSetContextNode) xmlXPathSetContextNode__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathSetContextNode xmlXPathSetContextNode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathStartsWithFunction
+extern __typeof (xmlXPathStartsWithFunction) xmlXPathStartsWithFunction __attribute((alias("xmlXPathStartsWithFunction__internal_alias")));
+#else
+#ifndef xmlXPathStartsWithFunction
+extern __typeof (xmlXPathStartsWithFunction) xmlXPathStartsWithFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathStartsWithFunction xmlXPathStartsWithFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathStringEvalNumber
+extern __typeof (xmlXPathStringEvalNumber) xmlXPathStringEvalNumber __attribute((alias("xmlXPathStringEvalNumber__internal_alias")));
+#else
+#ifndef xmlXPathStringEvalNumber
+extern __typeof (xmlXPathStringEvalNumber) xmlXPathStringEvalNumber__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathStringEvalNumber xmlXPathStringEvalNumber__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathStringFunction
+extern __typeof (xmlXPathStringFunction) xmlXPathStringFunction __attribute((alias("xmlXPathStringFunction__internal_alias")));
+#else
+#ifndef xmlXPathStringFunction
+extern __typeof (xmlXPathStringFunction) xmlXPathStringFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathStringFunction xmlXPathStringFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathStringLengthFunction
+extern __typeof (xmlXPathStringLengthFunction) xmlXPathStringLengthFunction __attribute((alias("xmlXPathStringLengthFunction__internal_alias")));
+#else
+#ifndef xmlXPathStringLengthFunction
+extern __typeof (xmlXPathStringLengthFunction) xmlXPathStringLengthFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathStringLengthFunction xmlXPathStringLengthFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathSubValues
+extern __typeof (xmlXPathSubValues) xmlXPathSubValues __attribute((alias("xmlXPathSubValues__internal_alias")));
+#else
+#ifndef xmlXPathSubValues
+extern __typeof (xmlXPathSubValues) xmlXPathSubValues__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathSubValues xmlXPathSubValues__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathSubstringAfterFunction
+extern __typeof (xmlXPathSubstringAfterFunction) xmlXPathSubstringAfterFunction __attribute((alias("xmlXPathSubstringAfterFunction__internal_alias")));
+#else
+#ifndef xmlXPathSubstringAfterFunction
+extern __typeof (xmlXPathSubstringAfterFunction) xmlXPathSubstringAfterFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathSubstringAfterFunction xmlXPathSubstringAfterFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathSubstringBeforeFunction
+extern __typeof (xmlXPathSubstringBeforeFunction) xmlXPathSubstringBeforeFunction __attribute((alias("xmlXPathSubstringBeforeFunction__internal_alias")));
+#else
+#ifndef xmlXPathSubstringBeforeFunction
+extern __typeof (xmlXPathSubstringBeforeFunction) xmlXPathSubstringBeforeFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathSubstringBeforeFunction xmlXPathSubstringBeforeFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathSubstringFunction
+extern __typeof (xmlXPathSubstringFunction) xmlXPathSubstringFunction __attribute((alias("xmlXPathSubstringFunction__internal_alias")));
+#else
+#ifndef xmlXPathSubstringFunction
+extern __typeof (xmlXPathSubstringFunction) xmlXPathSubstringFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathSubstringFunction xmlXPathSubstringFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathSumFunction
+extern __typeof (xmlXPathSumFunction) xmlXPathSumFunction __attribute((alias("xmlXPathSumFunction__internal_alias")));
+#else
+#ifndef xmlXPathSumFunction
+extern __typeof (xmlXPathSumFunction) xmlXPathSumFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathSumFunction xmlXPathSumFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathTrailing
+extern __typeof (xmlXPathTrailing) xmlXPathTrailing __attribute((alias("xmlXPathTrailing__internal_alias")));
+#else
+#ifndef xmlXPathTrailing
+extern __typeof (xmlXPathTrailing) xmlXPathTrailing__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathTrailing xmlXPathTrailing__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathTrailingSorted
+extern __typeof (xmlXPathTrailingSorted) xmlXPathTrailingSorted __attribute((alias("xmlXPathTrailingSorted__internal_alias")));
+#else
+#ifndef xmlXPathTrailingSorted
+extern __typeof (xmlXPathTrailingSorted) xmlXPathTrailingSorted__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathTrailingSorted xmlXPathTrailingSorted__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathTranslateFunction
+extern __typeof (xmlXPathTranslateFunction) xmlXPathTranslateFunction __attribute((alias("xmlXPathTranslateFunction__internal_alias")));
+#else
+#ifndef xmlXPathTranslateFunction
+extern __typeof (xmlXPathTranslateFunction) xmlXPathTranslateFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathTranslateFunction xmlXPathTranslateFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathTrueFunction
+extern __typeof (xmlXPathTrueFunction) xmlXPathTrueFunction __attribute((alias("xmlXPathTrueFunction__internal_alias")));
+#else
+#ifndef xmlXPathTrueFunction
+extern __typeof (xmlXPathTrueFunction) xmlXPathTrueFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathTrueFunction xmlXPathTrueFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathValueFlipSign
+extern __typeof (xmlXPathValueFlipSign) xmlXPathValueFlipSign __attribute((alias("xmlXPathValueFlipSign__internal_alias")));
+#else
+#ifndef xmlXPathValueFlipSign
+extern __typeof (xmlXPathValueFlipSign) xmlXPathValueFlipSign__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathValueFlipSign xmlXPathValueFlipSign__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathVariableLookup
+extern __typeof (xmlXPathVariableLookup) xmlXPathVariableLookup __attribute((alias("xmlXPathVariableLookup__internal_alias")));
+#else
+#ifndef xmlXPathVariableLookup
+extern __typeof (xmlXPathVariableLookup) xmlXPathVariableLookup__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathVariableLookup xmlXPathVariableLookup__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathVariableLookupNS
+extern __typeof (xmlXPathVariableLookupNS) xmlXPathVariableLookupNS __attribute((alias("xmlXPathVariableLookupNS__internal_alias")));
+#else
+#ifndef xmlXPathVariableLookupNS
+extern __typeof (xmlXPathVariableLookupNS) xmlXPathVariableLookupNS__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathVariableLookupNS xmlXPathVariableLookupNS__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathWrapCString
+extern __typeof (xmlXPathWrapCString) xmlXPathWrapCString __attribute((alias("xmlXPathWrapCString__internal_alias")));
+#else
+#ifndef xmlXPathWrapCString
+extern __typeof (xmlXPathWrapCString) xmlXPathWrapCString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathWrapCString xmlXPathWrapCString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathWrapExternal
+extern __typeof (xmlXPathWrapExternal) xmlXPathWrapExternal __attribute((alias("xmlXPathWrapExternal__internal_alias")));
+#else
+#ifndef xmlXPathWrapExternal
+extern __typeof (xmlXPathWrapExternal) xmlXPathWrapExternal__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathWrapExternal xmlXPathWrapExternal__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathWrapNodeSet
+extern __typeof (xmlXPathWrapNodeSet) xmlXPathWrapNodeSet __attribute((alias("xmlXPathWrapNodeSet__internal_alias")));
+#else
+#ifndef xmlXPathWrapNodeSet
+extern __typeof (xmlXPathWrapNodeSet) xmlXPathWrapNodeSet__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathWrapNodeSet xmlXPathWrapNodeSet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPathWrapString
+extern __typeof (xmlXPathWrapString) xmlXPathWrapString __attribute((alias("xmlXPathWrapString__internal_alias")));
+#else
+#ifndef xmlXPathWrapString
+extern __typeof (xmlXPathWrapString) xmlXPathWrapString__internal_alias __attribute((visibility("hidden")));
+#define xmlXPathWrapString xmlXPathWrapString__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPATH_ENABLED)
+#ifdef bottom_xpath
+#undef xmlXPatherror
+extern __typeof (xmlXPatherror) xmlXPatherror __attribute((alias("xmlXPatherror__internal_alias")));
+#else
+#ifndef xmlXPatherror
+extern __typeof (xmlXPatherror) xmlXPatherror__internal_alias __attribute((visibility("hidden")));
+#define xmlXPatherror xmlXPatherror__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrBuildNodeList
+extern __typeof (xmlXPtrBuildNodeList) xmlXPtrBuildNodeList __attribute((alias("xmlXPtrBuildNodeList__internal_alias")));
+#else
+#ifndef xmlXPtrBuildNodeList
+extern __typeof (xmlXPtrBuildNodeList) xmlXPtrBuildNodeList__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrBuildNodeList xmlXPtrBuildNodeList__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrEval
+extern __typeof (xmlXPtrEval) xmlXPtrEval __attribute((alias("xmlXPtrEval__internal_alias")));
+#else
+#ifndef xmlXPtrEval
+extern __typeof (xmlXPtrEval) xmlXPtrEval__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrEval xmlXPtrEval__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrEvalRangePredicate
+extern __typeof (xmlXPtrEvalRangePredicate) xmlXPtrEvalRangePredicate __attribute((alias("xmlXPtrEvalRangePredicate__internal_alias")));
+#else
+#ifndef xmlXPtrEvalRangePredicate
+extern __typeof (xmlXPtrEvalRangePredicate) xmlXPtrEvalRangePredicate__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrEvalRangePredicate xmlXPtrEvalRangePredicate__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrFreeLocationSet
+extern __typeof (xmlXPtrFreeLocationSet) xmlXPtrFreeLocationSet __attribute((alias("xmlXPtrFreeLocationSet__internal_alias")));
+#else
+#ifndef xmlXPtrFreeLocationSet
+extern __typeof (xmlXPtrFreeLocationSet) xmlXPtrFreeLocationSet__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrFreeLocationSet xmlXPtrFreeLocationSet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrLocationSetAdd
+extern __typeof (xmlXPtrLocationSetAdd) xmlXPtrLocationSetAdd __attribute((alias("xmlXPtrLocationSetAdd__internal_alias")));
+#else
+#ifndef xmlXPtrLocationSetAdd
+extern __typeof (xmlXPtrLocationSetAdd) xmlXPtrLocationSetAdd__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrLocationSetAdd xmlXPtrLocationSetAdd__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrLocationSetCreate
+extern __typeof (xmlXPtrLocationSetCreate) xmlXPtrLocationSetCreate __attribute((alias("xmlXPtrLocationSetCreate__internal_alias")));
+#else
+#ifndef xmlXPtrLocationSetCreate
+extern __typeof (xmlXPtrLocationSetCreate) xmlXPtrLocationSetCreate__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrLocationSetCreate xmlXPtrLocationSetCreate__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrLocationSetDel
+extern __typeof (xmlXPtrLocationSetDel) xmlXPtrLocationSetDel __attribute((alias("xmlXPtrLocationSetDel__internal_alias")));
+#else
+#ifndef xmlXPtrLocationSetDel
+extern __typeof (xmlXPtrLocationSetDel) xmlXPtrLocationSetDel__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrLocationSetDel xmlXPtrLocationSetDel__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrLocationSetMerge
+extern __typeof (xmlXPtrLocationSetMerge) xmlXPtrLocationSetMerge __attribute((alias("xmlXPtrLocationSetMerge__internal_alias")));
+#else
+#ifndef xmlXPtrLocationSetMerge
+extern __typeof (xmlXPtrLocationSetMerge) xmlXPtrLocationSetMerge__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrLocationSetMerge xmlXPtrLocationSetMerge__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrLocationSetRemove
+extern __typeof (xmlXPtrLocationSetRemove) xmlXPtrLocationSetRemove __attribute((alias("xmlXPtrLocationSetRemove__internal_alias")));
+#else
+#ifndef xmlXPtrLocationSetRemove
+extern __typeof (xmlXPtrLocationSetRemove) xmlXPtrLocationSetRemove__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrLocationSetRemove xmlXPtrLocationSetRemove__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrNewCollapsedRange
+extern __typeof (xmlXPtrNewCollapsedRange) xmlXPtrNewCollapsedRange __attribute((alias("xmlXPtrNewCollapsedRange__internal_alias")));
+#else
+#ifndef xmlXPtrNewCollapsedRange
+extern __typeof (xmlXPtrNewCollapsedRange) xmlXPtrNewCollapsedRange__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrNewCollapsedRange xmlXPtrNewCollapsedRange__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrNewContext
+extern __typeof (xmlXPtrNewContext) xmlXPtrNewContext __attribute((alias("xmlXPtrNewContext__internal_alias")));
+#else
+#ifndef xmlXPtrNewContext
+extern __typeof (xmlXPtrNewContext) xmlXPtrNewContext__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrNewContext xmlXPtrNewContext__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrNewLocationSetNodeSet
+extern __typeof (xmlXPtrNewLocationSetNodeSet) xmlXPtrNewLocationSetNodeSet __attribute((alias("xmlXPtrNewLocationSetNodeSet__internal_alias")));
+#else
+#ifndef xmlXPtrNewLocationSetNodeSet
+extern __typeof (xmlXPtrNewLocationSetNodeSet) xmlXPtrNewLocationSetNodeSet__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrNewLocationSetNodeSet xmlXPtrNewLocationSetNodeSet__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrNewLocationSetNodes
+extern __typeof (xmlXPtrNewLocationSetNodes) xmlXPtrNewLocationSetNodes __attribute((alias("xmlXPtrNewLocationSetNodes__internal_alias")));
+#else
+#ifndef xmlXPtrNewLocationSetNodes
+extern __typeof (xmlXPtrNewLocationSetNodes) xmlXPtrNewLocationSetNodes__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrNewLocationSetNodes xmlXPtrNewLocationSetNodes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrNewRange
+extern __typeof (xmlXPtrNewRange) xmlXPtrNewRange __attribute((alias("xmlXPtrNewRange__internal_alias")));
+#else
+#ifndef xmlXPtrNewRange
+extern __typeof (xmlXPtrNewRange) xmlXPtrNewRange__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrNewRange xmlXPtrNewRange__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrNewRangeNodeObject
+extern __typeof (xmlXPtrNewRangeNodeObject) xmlXPtrNewRangeNodeObject __attribute((alias("xmlXPtrNewRangeNodeObject__internal_alias")));
+#else
+#ifndef xmlXPtrNewRangeNodeObject
+extern __typeof (xmlXPtrNewRangeNodeObject) xmlXPtrNewRangeNodeObject__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrNewRangeNodeObject xmlXPtrNewRangeNodeObject__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrNewRangeNodePoint
+extern __typeof (xmlXPtrNewRangeNodePoint) xmlXPtrNewRangeNodePoint __attribute((alias("xmlXPtrNewRangeNodePoint__internal_alias")));
+#else
+#ifndef xmlXPtrNewRangeNodePoint
+extern __typeof (xmlXPtrNewRangeNodePoint) xmlXPtrNewRangeNodePoint__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrNewRangeNodePoint xmlXPtrNewRangeNodePoint__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrNewRangeNodes
+extern __typeof (xmlXPtrNewRangeNodes) xmlXPtrNewRangeNodes __attribute((alias("xmlXPtrNewRangeNodes__internal_alias")));
+#else
+#ifndef xmlXPtrNewRangeNodes
+extern __typeof (xmlXPtrNewRangeNodes) xmlXPtrNewRangeNodes__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrNewRangeNodes xmlXPtrNewRangeNodes__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrNewRangePointNode
+extern __typeof (xmlXPtrNewRangePointNode) xmlXPtrNewRangePointNode __attribute((alias("xmlXPtrNewRangePointNode__internal_alias")));
+#else
+#ifndef xmlXPtrNewRangePointNode
+extern __typeof (xmlXPtrNewRangePointNode) xmlXPtrNewRangePointNode__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrNewRangePointNode xmlXPtrNewRangePointNode__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrNewRangePoints
+extern __typeof (xmlXPtrNewRangePoints) xmlXPtrNewRangePoints __attribute((alias("xmlXPtrNewRangePoints__internal_alias")));
+#else
+#ifndef xmlXPtrNewRangePoints
+extern __typeof (xmlXPtrNewRangePoints) xmlXPtrNewRangePoints__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrNewRangePoints xmlXPtrNewRangePoints__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrRangeToFunction
+extern __typeof (xmlXPtrRangeToFunction) xmlXPtrRangeToFunction __attribute((alias("xmlXPtrRangeToFunction__internal_alias")));
+#else
+#ifndef xmlXPtrRangeToFunction
+extern __typeof (xmlXPtrRangeToFunction) xmlXPtrRangeToFunction__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrRangeToFunction xmlXPtrRangeToFunction__internal_alias
+#endif
+#endif
+#endif
+
+#if defined(LIBXML_XPTR_ENABLED)
+#ifdef bottom_xpointer
+#undef xmlXPtrWrapLocationSet
+extern __typeof (xmlXPtrWrapLocationSet) xmlXPtrWrapLocationSet __attribute((alias("xmlXPtrWrapLocationSet__internal_alias")));
+#else
+#ifndef xmlXPtrWrapLocationSet
+extern __typeof (xmlXPtrWrapLocationSet) xmlXPtrWrapLocationSet__internal_alias __attribute((visibility("hidden")));
+#define xmlXPtrWrapLocationSet xmlXPtrWrapLocationSet__internal_alias
+#endif
+#endif
+#endif
+
+
+#endif
+#endif
+#endif
+#endif
+#endif
+
diff --git a/gnulib-local/lib/libxml/enc.h b/gnulib-local/lib/libxml/enc.h
new file mode 100644
index 0000000..057d206
--- /dev/null
+++ b/gnulib-local/lib/libxml/enc.h
@@ -0,0 +1,32 @@
+/*
+ * Summary: Internal Interfaces for encoding in libxml2
+ * Description: this module describes a few interfaces which were
+ * addded along with the API changes in 2.9.0
+ * those are private routines at this point
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_ENC_H__
+#define __XML_ENC_H__
+
+#include <libxml/tree.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
+ xmlBufferPtr in, int len);
+int xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len);
+int xmlCharEncInput(xmlParserInputBufferPtr input, int flush);
+int xmlCharEncOutput(xmlOutputBufferPtr output, int init);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __XML_ENC_H__ */
+
+
diff --git a/gnulib-local/lib/libxml/encoding.c b/gnulib-local/lib/libxml/encoding.c
index ee33df1..574e1ae 100644
--- a/gnulib-local/lib/libxml/encoding.c
+++ b/gnulib-local/lib/libxml/encoding.c
@@ -1,7 +1,7 @@
/*
* encoding.c : implements the encoding conversion functions needed for XML
*
- * Related specs:
+ * Related specs:
* rfc2044 (UTF-8 and UTF-16) F. Yergeau Alis Technologies
* rfc2781 UTF-16, an encoding of ISO 10646, P. Hoffman, F. Yergeau
* [ISO-10646] UTF-8 and UTF-16 in Annexes
@@ -24,6 +24,7 @@
#include "libxml.h"
#include <string.h>
+#include <limits.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
@@ -44,6 +45,9 @@
#include <libxml/globals.h>
#include <libxml/xmlerror.h>
+#include "buf.h"
+#include "enc.h"
+
static xmlCharEncodingHandlerPtr xmlUTF16LEHandler = NULL;
static xmlCharEncodingHandlerPtr xmlUTF16BEHandler = NULL;
@@ -58,7 +62,7 @@ static xmlCharEncodingAliasPtr xmlCharEncodingAliases = NULL;
static int xmlCharEncodingAliasesNb = 0;
static int xmlCharEncodingAliasesMax = 0;
-#ifdef LIBXML_ICONV_ENABLED
+#if defined(LIBXML_ICONV_ENABLED) || defined(LIBXML_ICU_ENABLED)
#if 0
#define DEBUG_ENCODING /* Define this to get encoding traces */
#endif
@@ -97,6 +101,54 @@ xmlEncodingErr(xmlParserErrors error, const char *msg, const char *val)
NULL, 0, val, NULL, NULL, 0, 0, msg, val);
}
+#ifdef LIBXML_ICU_ENABLED
+static uconv_t*
+openIcuConverter(const char* name, int toUnicode)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ uconv_t *conv = (uconv_t *) xmlMalloc(sizeof(uconv_t));
+ if (conv == NULL)
+ return NULL;
+
+ conv->uconv = ucnv_open(name, &status);
+ if (U_FAILURE(status))
+ goto error;
+
+ status = U_ZERO_ERROR;
+ if (toUnicode) {
+ ucnv_setToUCallBack(conv->uconv, UCNV_TO_U_CALLBACK_STOP,
+ NULL, NULL, NULL, &status);
+ }
+ else {
+ ucnv_setFromUCallBack(conv->uconv, UCNV_FROM_U_CALLBACK_STOP,
+ NULL, NULL, NULL, &status);
+ }
+ if (U_FAILURE(status))
+ goto error;
+
+ status = U_ZERO_ERROR;
+ conv->utf8 = ucnv_open("UTF-8", &status);
+ if (U_SUCCESS(status))
+ return conv;
+
+error:
+ if (conv->uconv)
+ ucnv_close(conv->uconv);
+ xmlFree(conv);
+ return NULL;
+}
+
+static void
+closeIcuConverter(uconv_t *conv)
+{
+ if (conv != NULL) {
+ ucnv_close(conv->uconv);
+ ucnv_close(conv->utf8);
+ xmlFree(conv);
+ }
+}
+#endif /* LIBXML_ICU_ENABLED */
+
/************************************************************************
* *
* Conversions To/From UTF8 encoding *
@@ -135,12 +187,12 @@ asciiToUTF8(unsigned char* out, int *outlen,
break;
if (c < 0x80) {
*out++ = c;
- } else {
+ } else {
*outlen = out - outstart;
*inlen = processed - base;
return(-1);
}
-
+
processed = (const unsigned char*) in;
}
*outlen = out - outstart;
@@ -206,7 +258,7 @@ UTF8Toascii(unsigned char* out, int *outlen,
if (inend - in < trailing) {
break;
- }
+ }
for ( ; trailing; trailing--) {
if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))
@@ -263,19 +315,19 @@ isolat1ToUTF8(unsigned char* out, int *outlen,
outend = out + *outlen;
inend = in + (*inlen);
instop = inend;
-
- while (in < inend && out < outend - 1) {
- if (*in >= 0x80) {
+
+ while ((in < inend) && (out < outend - 1)) {
+ if (*in >= 0x80) {
*out++ = (((*in) >> 6) & 0x1F) | 0xC0;
- *out++ = ((*in) & 0x3F) | 0x80;
+ *out++ = ((*in) & 0x3F) | 0x80;
++in;
}
- if (instop - in > outend - out) instop = in + (outend - out);
- while (in < instop && *in < 0x80) {
+ if ((instop - in) > (outend - out)) instop = in + (outend - out);
+ while ((in < instop) && (*in < 0x80)) {
*out++ = *in++;
}
- }
- if (in < inend && out < outend && *in < 0x80) {
+ }
+ if ((in < inend) && (out < outend) && (*in < 0x80)) {
*out++ = *in++;
}
*outlen = out - outstart;
@@ -379,7 +431,7 @@ UTF8Toisolat1(unsigned char* out, int *outlen,
if (inend - in < trailing) {
break;
- }
+ }
for ( ; trailing; trailing--) {
if (in >= inend)
@@ -487,7 +539,7 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
else if (c < 0x800) { *out++= ((c >> 6) & 0x1F) | 0xC0; bits= 0; }
else if (c < 0x10000) { *out++= ((c >> 12) & 0x0F) | 0xE0; bits= 6; }
else { *out++= ((c >> 18) & 0x07) | 0xF0; bits= 12; }
-
+
for ( ; bits >= 0; bits-= 6) {
if (out >= outend)
break;
@@ -512,7 +564,7 @@ UTF16LEToUTF8(unsigned char* out, int *outlen,
* block of chars out.
*
* Returns the number of bytes written, or -1 if lack of space, or -2
- * if the transcoding failed.
+ * if the transcoding failed.
*/
static int
UTF8ToUTF16LE(unsigned char* outb, int *outlen,
@@ -558,7 +610,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
if (inend - in < trailing) {
break;
- }
+ }
for ( ; trailing; trailing--) {
if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80))
@@ -621,7 +673,7 @@ UTF8ToUTF16LE(unsigned char* outb, int *outlen,
* block of chars out.
*
* Returns the number of bytes written, or -1 if lack of space, or -2
- * if the transcoding failed.
+ * if the transcoding failed.
*/
static int
UTF8ToUTF16(unsigned char* outb, int *outlen,
@@ -693,7 +745,7 @@ UTF16BEToUTF8(unsigned char* out, int *outlen,
in++;
} else {
c= *in++;
- }
+ }
if ((c & 0xFC00) == 0xD800) { /* surrogates */
if (in >= inend) { /* (in > inend) shouldn't happens */
*outlen = out - outstart;
@@ -723,15 +775,15 @@ UTF16BEToUTF8(unsigned char* out, int *outlen,
}
/* assertion: c is a single UTF-4 value */
- if (out >= outend)
+ if (out >= outend)
break;
if (c < 0x80) { *out++= c; bits= -6; }
else if (c < 0x800) { *out++= ((c >> 6) & 0x1F) | 0xC0; bits= 0; }
else if (c < 0x10000) { *out++= ((c >> 12) & 0x0F) | 0xE0; bits= 6; }
else { *out++= ((c >> 18) & 0x07) | 0xF0; bits= 12; }
-
+
for ( ; bits >= 0; bits-= 6) {
- if (out >= outend)
+ if (out >= outend)
break;
*out++= ((c >> bits) & 0x3F) | 0x80;
}
@@ -754,7 +806,7 @@ UTF16BEToUTF8(unsigned char* out, int *outlen,
* block of chars out.
*
* Returns the number of byte written, or -1 by lack of space, or -2
- * if the transcoding failed.
+ * if the transcoding failed.
*/
static int
UTF8ToUTF16BE(unsigned char* outb, int *outlen,
@@ -800,7 +852,7 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
if (inend - in < trailing) {
break;
- }
+ }
for ( ; trailing; trailing--) {
if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80)) break;
@@ -864,13 +916,13 @@ UTF8ToUTF16BE(unsigned char* outb, int *outlen,
*
* Guess the encoding of the entity using the first bytes of the entity content
* according to the non-normative appendix F of the XML-1.0 recommendation.
- *
+ *
* Returns one of the XML_CHAR_ENCODING_... values.
*/
xmlCharEncoding
xmlDetectCharEncoding(const unsigned char* in, int len)
{
- if (in == NULL)
+ if (in == NULL)
return(XML_CHAR_ENCODING_NONE);
if (len >= 4) {
if ((in[0] == 0x00) && (in[1] == 0x00) &&
@@ -951,7 +1003,7 @@ xmlCleanupEncodingAliases(void) {
* @alias: the alias name as parsed, in UTF-8 format (ASCII actually)
*
* Lookup an encoding name for the given alias.
- *
+ *
* Returns NULL if not found, otherwise the original name
*/
const char *
@@ -989,7 +1041,7 @@ xmlGetEncodingAlias(const char *alias) {
*
* Registers an alias @alias for an encoding named @name. Existing alias
* will be overwritten.
- *
+ *
* Returns 0 in case of success, -1 in case of error
*/
int
@@ -1009,13 +1061,13 @@ xmlAddEncodingAlias(const char *name, const char *alias) {
if (xmlCharEncodingAliases == NULL) {
xmlCharEncodingAliasesNb = 0;
xmlCharEncodingAliasesMax = 20;
- xmlCharEncodingAliases = (xmlCharEncodingAliasPtr)
+ xmlCharEncodingAliases = (xmlCharEncodingAliasPtr)
xmlMalloc(xmlCharEncodingAliasesMax * sizeof(xmlCharEncodingAlias));
if (xmlCharEncodingAliases == NULL)
return(-1);
} else if (xmlCharEncodingAliasesNb >= xmlCharEncodingAliasesMax) {
xmlCharEncodingAliasesMax *= 2;
- xmlCharEncodingAliases = (xmlCharEncodingAliasPtr)
+ xmlCharEncodingAliases = (xmlCharEncodingAliasPtr)
xmlRealloc(xmlCharEncodingAliases,
xmlCharEncodingAliasesMax * sizeof(xmlCharEncodingAlias));
}
@@ -1046,7 +1098,7 @@ xmlAddEncodingAlias(const char *name, const char *alias) {
* @alias: the alias name as parsed, in UTF-8 format (ASCII actually)
*
* Unregisters an encoding alias @alias
- *
+ *
* Returns 0 in case of success, -1 in case of error
*/
int
@@ -1081,7 +1133,7 @@ xmlDelEncodingAlias(const char *alias) {
* Compare the string to the encoding schemes already known. Note
* that the comparison is case insensitive accordingly to the section
* [XML] 4.3.3 Character Encoding in Entities.
- *
+ *
* Returns one of the XML_CHAR_ENCODING_... values or XML_CHAR_ENCODING_NONE
* if not recognized.
*/
@@ -1118,7 +1170,7 @@ xmlParseCharEncoding(const char* name)
*/
if (!strcmp(upper, "UTF-16")) return(XML_CHAR_ENCODING_UTF16LE);
if (!strcmp(upper, "UTF16")) return(XML_CHAR_ENCODING_UTF16LE);
-
+
if (!strcmp(upper, "ISO-10646-UCS-2")) return(XML_CHAR_ENCODING_UCS2);
if (!strcmp(upper, "UCS-2")) return(XML_CHAR_ENCODING_UCS2);
if (!strcmp(upper, "UCS2")) return(XML_CHAR_ENCODING_UCS2);
@@ -1131,7 +1183,7 @@ xmlParseCharEncoding(const char* name)
if (!strcmp(upper, "UCS-4")) return(XML_CHAR_ENCODING_UCS4LE);
if (!strcmp(upper, "UCS4")) return(XML_CHAR_ENCODING_UCS4LE);
-
+
if (!strcmp(upper, "ISO-8859-1")) return(XML_CHAR_ENCODING_8859_1);
if (!strcmp(upper, "ISO-LATIN-1")) return(XML_CHAR_ENCODING_8859_1);
if (!strcmp(upper, "ISO LATIN 1")) return(XML_CHAR_ENCODING_8859_1);
@@ -1254,7 +1306,7 @@ static xmlCharEncodingHandlerPtr xmlDefaultCharEncodingHandler = NULL;
* Returns the xmlCharEncodingHandlerPtr created (or NULL in case of error).
*/
xmlCharEncodingHandlerPtr
-xmlNewCharEncodingHandler(const char *name,
+xmlNewCharEncodingHandler(const char *name,
xmlCharEncodingInputFunc input,
xmlCharEncodingOutputFunc output) {
xmlCharEncodingHandlerPtr handler;
@@ -1299,6 +1351,7 @@ xmlNewCharEncodingHandler(const char *name,
xmlEncodingErrMemory("xmlNewCharEncodingHandler : out of memory !\n");
return(NULL);
}
+ memset(handler, 0, sizeof(xmlCharEncodingHandler));
handler->input = input;
handler->output = output;
handler->name = up;
@@ -1306,7 +1359,11 @@ xmlNewCharEncodingHandler(const char *name,
#ifdef LIBXML_ICONV_ENABLED
handler->iconv_in = NULL;
handler->iconv_out = NULL;
-#endif /* LIBXML_ICONV_ENABLED */
+#endif
+#ifdef LIBXML_ICU_ENABLED
+ handler->uconv_in = NULL;
+ handler->uconv_out = NULL;
+#endif
/*
* registers and returns the handler.
@@ -1330,7 +1387,7 @@ xmlNewCharEncodingHandler(const char *name,
void
xmlInitCharEncodingHandlers(void) {
unsigned short int tst = 0x1234;
- unsigned char *ptr = (unsigned char *) &tst;
+ unsigned char *ptr = (unsigned char *) &tst;
if (handlers != NULL) return;
@@ -1350,9 +1407,9 @@ xmlInitCharEncodingHandlers(void) {
}
xmlNewCharEncodingHandler("UTF-8", UTF8ToUTF8, UTF8ToUTF8);
#ifdef LIBXML_OUTPUT_ENABLED
- xmlUTF16LEHandler =
+ xmlUTF16LEHandler =
xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, UTF8ToUTF16LE);
- xmlUTF16BEHandler =
+ xmlUTF16BEHandler =
xmlNewCharEncodingHandler("UTF-16BE", UTF16BEToUTF8, UTF8ToUTF16BE);
xmlNewCharEncodingHandler("UTF-16", UTF16LEToUTF8, UTF8ToUTF16);
xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, UTF8Toisolat1);
@@ -1362,16 +1419,16 @@ xmlInitCharEncodingHandlers(void) {
xmlNewCharEncodingHandler("HTML", NULL, UTF8ToHtml);
#endif
#else
- xmlUTF16LEHandler =
+ xmlUTF16LEHandler =
xmlNewCharEncodingHandler("UTF-16LE", UTF16LEToUTF8, NULL);
- xmlUTF16BEHandler =
+ xmlUTF16BEHandler =
xmlNewCharEncodingHandler("UTF-16BE", UTF16BEToUTF8, NULL);
xmlNewCharEncodingHandler("UTF-16", UTF16LEToUTF8, NULL);
xmlNewCharEncodingHandler("ISO-8859-1", isolat1ToUTF8, NULL);
xmlNewCharEncodingHandler("ASCII", asciiToUTF8, NULL);
xmlNewCharEncodingHandler("US-ASCII", asciiToUTF8, NULL);
#endif /* LIBXML_OUTPUT_ENABLED */
-#ifndef LIBXML_ICONV_ENABLED
+#if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED)
#ifdef LIBXML_ISO8859X_ENABLED
xmlRegisterCharEncodingHandlersISO8859x ();
#endif
@@ -1414,7 +1471,7 @@ xmlCleanupCharEncodingHandlers(void) {
void
xmlRegisterCharEncodingHandler(xmlCharEncodingHandlerPtr handler) {
if (handlers == NULL) xmlInitCharEncodingHandlers();
- if (handler == NULL) {
+ if ((handler == NULL) || (handlers == NULL)) {
xmlEncodingErr(XML_I18N_NO_HANDLER,
"xmlRegisterCharEncodingHandler: NULL handler !\n", NULL);
return;
@@ -1458,6 +1515,10 @@ xmlGetCharEncodingHandler(xmlCharEncoding enc) {
if (handler != NULL) return(handler);
handler = xmlFindCharEncodingHandler("ebcdic");
if (handler != NULL) return(handler);
+ handler = xmlFindCharEncodingHandler("EBCDIC-US");
+ if (handler != NULL) return(handler);
+ handler = xmlFindCharEncodingHandler("IBM-037");
+ if (handler != NULL) return(handler);
break;
case XML_CHAR_ENCODING_UCS4BE:
handler = xmlFindCharEncodingHandler("ISO-10646-UCS-4");
@@ -1548,10 +1609,10 @@ xmlGetCharEncodingHandler(xmlCharEncoding enc) {
handler = xmlFindCharEncodingHandler("EUC-JP");
if (handler != NULL) return(handler);
break;
- default:
+ default:
break;
}
-
+
#ifdef DEBUG_ENCODING
xmlGenericError(xmlGenericErrorContext,
"No handler found for encoding %d\n", enc);
@@ -1576,6 +1637,10 @@ xmlFindCharEncodingHandler(const char *name) {
xmlCharEncodingHandlerPtr enc;
iconv_t icv_in, icv_out;
#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ xmlCharEncodingHandlerPtr encu;
+ uconv_t *ucv_in, *ucv_out;
+#endif /* LIBXML_ICU_ENABLED */
char upper[100];
int i;
@@ -1600,14 +1665,17 @@ xmlFindCharEncodingHandler(const char *name) {
}
upper[i] = 0;
- for (i = 0;i < nbCharEncodingHandler; i++)
- if (!strcmp(upper, handlers[i]->name)) {
+ if (handlers != NULL) {
+ for (i = 0;i < nbCharEncodingHandler; i++) {
+ if (!strcmp(upper, handlers[i]->name)) {
#ifdef DEBUG_ENCODING
- xmlGenericError(xmlGenericErrorContext,
- "Found registered handler for encoding %s\n", name);
+ xmlGenericError(xmlGenericErrorContext,
+ "Found registered handler for encoding %s\n", name);
#endif
- return(handlers[i]);
- }
+ return(handlers[i]);
+ }
+ }
+ }
#ifdef LIBXML_ICONV_ENABLED
/* check whether iconv can handle this */
@@ -1627,6 +1695,7 @@ xmlFindCharEncodingHandler(const char *name) {
iconv_close(icv_out);
return(NULL);
}
+ memset(enc, 0, sizeof(xmlCharEncodingHandler));
enc->name = xmlMemStrdup(name);
enc->input = NULL;
enc->output = NULL;
@@ -1642,6 +1711,36 @@ xmlFindCharEncodingHandler(const char *name) {
"iconv : problems with filters for '%s'\n", name);
}
#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ /* check whether icu can handle this */
+ ucv_in = openIcuConverter(name, 1);
+ ucv_out = openIcuConverter(name, 0);
+ if (ucv_in != NULL && ucv_out != NULL) {
+ encu = (xmlCharEncodingHandlerPtr)
+ xmlMalloc(sizeof(xmlCharEncodingHandler));
+ if (encu == NULL) {
+ closeIcuConverter(ucv_in);
+ closeIcuConverter(ucv_out);
+ return(NULL);
+ }
+ memset(encu, 0, sizeof(xmlCharEncodingHandler));
+ encu->name = xmlMemStrdup(name);
+ encu->input = NULL;
+ encu->output = NULL;
+ encu->uconv_in = ucv_in;
+ encu->uconv_out = ucv_out;
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "Found ICU converter handler for encoding %s\n", name);
+#endif
+ return encu;
+ } else if (ucv_in != NULL || ucv_out != NULL) {
+ closeIcuConverter(ucv_in);
+ closeIcuConverter(ucv_out);
+ xmlEncodingErr(XML_ERR_INTERNAL_ERROR,
+ "ICU converter : problems with filters for '%s'\n", name);
+ }
+#endif /* LIBXML_ICU_ENABLED */
#ifdef DEBUG_ENCODING
xmlGenericError(xmlGenericErrorContext,
@@ -1679,12 +1778,12 @@ xmlFindCharEncodingHandler(const char *name) {
* @in: a pointer to an array of ISO Latin 1 chars
* @inlen: the length of @in
*
- * Returns 0 if success, or
+ * Returns 0 if success, or
* -1 by lack of space, or
* -2 if the transcoding fails (for *in is not valid utf8 string or
* the result of transformation can't fit into the encoding we want), or
* -3 if there the last byte can't form a single output char.
- *
+ *
* The value of @inlen after return is the number of octets consumed
* as the return value is positive, else unpredictable.
* The value of @outlen after return is the number of ocetes consumed.
@@ -1703,7 +1802,7 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
}
icv_inlen = *inlen;
icv_outlen = *outlen;
- ret = iconv(cd, (char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
+ ret = iconv(cd, (ICONV_CONST char **) &icv_in, &icv_inlen, &icv_out, &icv_outlen);
*inlen -= icv_inlen;
*outlen -= icv_outlen;
if ((icv_inlen != 0) || (ret == -1)) {
@@ -1732,27 +1831,97 @@ xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
/************************************************************************
* *
+ * ICU based generic conversion functions *
+ * *
+ ************************************************************************/
+
+#ifdef LIBXML_ICU_ENABLED
+/**
+ * xmlUconvWrapper:
+ * @cd: ICU uconverter data structure
+ * @toUnicode : non-zero if toUnicode. 0 otherwise.
+ * @out: a pointer to an array of bytes to store the result
+ * @outlen: the length of @out
+ * @in: a pointer to an array of ISO Latin 1 chars
+ * @inlen: the length of @in
+ *
+ * Returns 0 if success, or
+ * -1 by lack of space, or
+ * -2 if the transcoding fails (for *in is not valid utf8 string or
+ * the result of transformation can't fit into the encoding we want), or
+ * -3 if there the last byte can't form a single output char.
+ *
+ * The value of @inlen after return is the number of octets consumed
+ * as the return value is positive, else unpredictable.
+ * The value of @outlen after return is the number of ocetes consumed.
+ */
+static int
+xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
+ const unsigned char *in, int *inlen) {
+ const char *ucv_in = (const char *) in;
+ char *ucv_out = (char *) out;
+ UErrorCode err = U_ZERO_ERROR;
+
+ if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) {
+ if (outlen != NULL) *outlen = 0;
+ return(-1);
+ }
+
+ /*
+ * TODO(jungshik)
+ * 1. is ucnv_convert(To|From)Algorithmic better?
+ * 2. had we better use an explicit pivot buffer?
+ * 3. error returned comes from 'fromUnicode' only even
+ * when toUnicode is true !
+ */
+ if (toUnicode) {
+ /* encoding => UTF-16 => UTF-8 */
+ ucnv_convertEx(cd->utf8, cd->uconv, &ucv_out, ucv_out + *outlen,
+ &ucv_in, ucv_in + *inlen, NULL, NULL, NULL, NULL,
+ 0, TRUE, &err);
+ } else {
+ /* UTF-8 => UTF-16 => encoding */
+ ucnv_convertEx(cd->uconv, cd->utf8, &ucv_out, ucv_out + *outlen,
+ &ucv_in, ucv_in + *inlen, NULL, NULL, NULL, NULL,
+ 0, TRUE, &err);
+ }
+ *inlen = ucv_in - (const char*) in;
+ *outlen = ucv_out - (char *) out;
+ if (U_SUCCESS(err))
+ return 0;
+ if (err == U_BUFFER_OVERFLOW_ERROR)
+ return -1;
+ if (err == U_INVALID_CHAR_FOUND || err == U_ILLEGAL_CHAR_FOUND)
+ return -2;
+ /* if (err == U_TRUNCATED_CHAR_FOUND) */
+ return -3;
+}
+#endif /* LIBXML_ICU_ENABLED */
+
+/************************************************************************
+ * *
* The real API used by libxml for on-the-fly conversion *
* *
************************************************************************/
/**
- * xmlCharEncFirstLine:
+ * xmlCharEncFirstLineInt:
* @handler: char enconding transformation data structure
* @out: an xmlBuffer for the output.
* @in: an xmlBuffer for the input
- *
+ * @len: number of bytes to convert for the first line, or -1
+ *
* Front-end for the encoding handler input function, but handle only
* the very first line, i.e. limit itself to 45 chars.
- *
- * Returns the number of byte written if success, or
+ *
+ * Returns the number of byte written if success, or
* -1 general error
* -2 if the transcoding fails (for *in is not valid utf8 string or
* the result of transformation can't fit into the encoding we want), or
*/
int
-xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
- xmlBufferPtr in) {
+xmlCharEncFirstLineInt(xmlCharEncodingHandler *handler, xmlBufferPtr out,
+ xmlBufferPtr in, int len) {
int ret = -2;
int written;
int toconv;
@@ -1761,19 +1930,28 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
if (out == NULL) return(-1);
if (in == NULL) return(-1);
- written = out->size - out->use;
+ /* calculate space available */
+ written = out->size - out->use - 1; /* count '\0' */
toconv = in->use;
- if (toconv * 2 >= written) {
- xmlBufferGrow(out, toconv);
- written = out->size - out->use - 1;
- }
-
/*
* echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
* 45 chars should be sufficient to reach the end of the encoding
* declaration without going too far inside the document content.
+ * on UTF-16 this means 90bytes, on UCS4 this means 180
+ * The actual value depending on guessed encoding is passed as @len
+ * if provided
*/
- written = 45;
+ if (len >= 0) {
+ if (toconv > len)
+ toconv = len;
+ } else {
+ if (toconv > 180)
+ toconv = 180;
+ }
+ if (toconv * 2 >= written) {
+ xmlBufferGrow(out, toconv * 2);
+ written = out->size - out->use - 1;
+ }
if (handler->input != NULL) {
ret = handler->input(&out->content[out->use], &written,
@@ -1792,6 +1970,16 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
if (ret == -1) ret = -3;
}
#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ else if (handler->uconv_in != NULL) {
+ ret = xmlUconvWrapper(handler->uconv_in, 1, &out->content[out->use],
+ &written, in->content, &toconv);
+ xmlBufferShrink(in, toconv);
+ out->use += written;
+ out->content[out->use] = 0;
+ if (ret == -1) ret = -3;
+ }
+#endif /* LIBXML_ICU_ENABLED */
#ifdef DEBUG_ENCODING
switch (ret) {
case 0:
@@ -1824,14 +2012,280 @@ xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
}
/**
+ * xmlCharEncFirstLine:
+ * @handler: char enconding transformation data structure
+ * @out: an xmlBuffer for the output.
+ * @in: an xmlBuffer for the input
+ *
+ * Front-end for the encoding handler input function, but handle only
+ * the very first line, i.e. limit itself to 45 chars.
+ *
+ * Returns the number of byte written if success, or
+ * -1 general error
+ * -2 if the transcoding fails (for *in is not valid utf8 string or
+ * the result of transformation can't fit into the encoding we want), or
+ */
+int
+xmlCharEncFirstLine(xmlCharEncodingHandler *handler, xmlBufferPtr out,
+ xmlBufferPtr in) {
+ return(xmlCharEncFirstLineInt(handler, out, in, -1));
+}
+
+/**
+ * xmlCharEncFirstLineInput:
+ * @input: a parser input buffer
+ * @len: number of bytes to convert for the first line, or -1
+ *
+ * Front-end for the encoding handler input function, but handle only
+ * the very first line. Point is that this is based on autodetection
+ * of the encoding and once that first line is converted we may find
+ * out that a different decoder is needed to process the input.
+ *
+ * Returns the number of byte written if success, or
+ * -1 general error
+ * -2 if the transcoding fails (for *in is not valid utf8 string or
+ * the result of transformation can't fit into the encoding we want), or
+ */
+int
+xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len)
+{
+ int ret = -2;
+ size_t written;
+ size_t toconv;
+ int c_in;
+ int c_out;
+ xmlBufPtr in;
+ xmlBufPtr out;
+
+ if ((input == NULL) || (input->encoder == NULL) ||
+ (input->buffer == NULL) || (input->raw == NULL))
+ return (-1);
+ out = input->buffer;
+ in = input->raw;
+
+ toconv = xmlBufUse(in);
+ if (toconv == 0)
+ return (0);
+ written = xmlBufAvail(out) - 1; /* count '\0' */
+ /*
+ * echo '<?xml version="1.0" encoding="UCS4"?>' | wc -c => 38
+ * 45 chars should be sufficient to reach the end of the encoding
+ * declaration without going too far inside the document content.
+ * on UTF-16 this means 90bytes, on UCS4 this means 180
+ * The actual value depending on guessed encoding is passed as @len
+ * if provided
+ */
+ if (len >= 0) {
+ if (toconv > (unsigned int) len)
+ toconv = len;
+ } else {
+ if (toconv > 180)
+ toconv = 180;
+ }
+ if (toconv * 2 >= written) {
+ xmlBufGrow(out, toconv * 2);
+ written = xmlBufAvail(out) - 1;
+ }
+ if (written > 360)
+ written = 360;
+
+ c_in = toconv;
+ c_out = written;
+ if (input->encoder->input != NULL) {
+ ret = input->encoder->input(xmlBufEnd(out), &c_out,
+ xmlBufContent(in), &c_in);
+ xmlBufShrink(in, c_in);
+ xmlBufAddLen(out, c_out);
+ }
+#ifdef LIBXML_ICONV_ENABLED
+ else if (input->encoder->iconv_in != NULL) {
+ ret = xmlIconvWrapper(input->encoder->iconv_in, xmlBufEnd(out),
+ &c_out, xmlBufContent(in), &c_in);
+ xmlBufShrink(in, c_in);
+ xmlBufAddLen(out, c_out);
+ if (ret == -1)
+ ret = -3;
+ }
+#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ else if (input->encoder->uconv_in != NULL) {
+ ret = xmlUconvWrapper(input->encoder->uconv_in, 1, xmlBufEnd(out),
+ &c_out, xmlBufContent(in), &c_in);
+ xmlBufShrink(in, c_in);
+ xmlBufAddLen(out, c_out);
+ if (ret == -1)
+ ret = -3;
+ }
+#endif /* LIBXML_ICU_ENABLED */
+ switch (ret) {
+ case 0:
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "converted %d bytes to %d bytes of input\n",
+ c_in, c_out);
+#endif
+ break;
+ case -1:
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "converted %d bytes to %d bytes of input, %d left\n",
+ c_in, c_out, (int)xmlBufUse(in));
+#endif
+ break;
+ case -3:
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "converted %d bytes to %d bytes of input, %d left\n",
+ c_in, c_out, (int)xmlBufUse(in));
+#endif
+ break;
+ case -2: {
+ char buf[50];
+ const xmlChar *content = xmlBufContent(in);
+
+ snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
+ content[0], content[1],
+ content[2], content[3]);
+ buf[49] = 0;
+ xmlEncodingErr(XML_I18N_CONV_FAILED,
+ "input conversion failed due to input error, bytes %s\n",
+ buf);
+ }
+ }
+ /*
+ * Ignore when input buffer is not on a boundary
+ */
+ if (ret == -3) ret = 0;
+ if (ret == -1) ret = 0;
+ return(ret);
+}
+
+/**
+ * xmlCharEncInput:
+ * @input: a parser input buffer
+ * @flush: try to flush all the raw buffer
+ *
+ * Generic front-end for the encoding handler on parser input
+ *
+ * Returns the number of byte written if success, or
+ * -1 general error
+ * -2 if the transcoding fails (for *in is not valid utf8 string or
+ * the result of transformation can't fit into the encoding we want), or
+ */
+int
+xmlCharEncInput(xmlParserInputBufferPtr input, int flush)
+{
+ int ret = -2;
+ size_t written;
+ size_t toconv;
+ int c_in;
+ int c_out;
+ xmlBufPtr in;
+ xmlBufPtr out;
+
+ if ((input == NULL) || (input->encoder == NULL) ||
+ (input->buffer == NULL) || (input->raw == NULL))
+ return (-1);
+ out = input->buffer;
+ in = input->raw;
+
+ toconv = xmlBufUse(in);
+ if (toconv == 0)
+ return (0);
+ if ((toconv > 64 * 1024) && (flush == 0))
+ toconv = 64 * 1024;
+ written = xmlBufAvail(out);
+ if (written > 0)
+ written--; /* count '\0' */
+ if (toconv * 2 >= written) {
+ xmlBufGrow(out, toconv * 2);
+ written = xmlBufAvail(out);
+ if (written > 0)
+ written--; /* count '\0' */
+ }
+ if ((written > 128 * 1024) && (flush == 0))
+ written = 128 * 1024;
+
+ c_in = toconv;
+ c_out = written;
+ if (input->encoder->input != NULL) {
+ ret = input->encoder->input(xmlBufEnd(out), &c_out,
+ xmlBufContent(in), &c_in);
+ xmlBufShrink(in, c_in);
+ xmlBufAddLen(out, c_out);
+ }
+#ifdef LIBXML_ICONV_ENABLED
+ else if (input->encoder->iconv_in != NULL) {
+ ret = xmlIconvWrapper(input->encoder->iconv_in, xmlBufEnd(out),
+ &c_out, xmlBufContent(in), &c_in);
+ xmlBufShrink(in, c_in);
+ xmlBufAddLen(out, c_out);
+ if (ret == -1)
+ ret = -3;
+ }
+#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ else if (input->encoder->uconv_in != NULL) {
+ ret = xmlUconvWrapper(input->encoder->uconv_in, 1, xmlBufEnd(out),
+ &c_out, xmlBufContent(in), &c_in);
+ xmlBufShrink(in, c_in);
+ xmlBufAddLen(out, c_out);
+ if (ret == -1)
+ ret = -3;
+ }
+#endif /* LIBXML_ICU_ENABLED */
+ switch (ret) {
+ case 0:
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "converted %d bytes to %d bytes of input\n",
+ c_in, c_out);
+#endif
+ break;
+ case -1:
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "converted %d bytes to %d bytes of input, %d left\n",
+ c_in, c_out, (int)xmlBufUse(in));
+#endif
+ break;
+ case -3:
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "converted %d bytes to %d bytes of input, %d left\n",
+ c_in, c_out, (int)xmlBufUse(in));
+#endif
+ break;
+ case -2: {
+ char buf[50];
+ const xmlChar *content = xmlBufContent(in);
+
+ snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
+ content[0], content[1],
+ content[2], content[3]);
+ buf[49] = 0;
+ xmlEncodingErr(XML_I18N_CONV_FAILED,
+ "input conversion failed due to input error, bytes %s\n",
+ buf);
+ }
+ }
+ /*
+ * Ignore when input buffer is not on a boundary
+ */
+ if (ret == -3)
+ ret = 0;
+ return (c_out? c_out : ret);
+}
+
+/**
* xmlCharEncInFunc:
* @handler: char encoding transformation data structure
* @out: an xmlBuffer for the output.
* @in: an xmlBuffer for the input
- *
+ *
* Generic front-end for the encoding handler input function
- *
- * Returns the number of byte written if success, or
+ *
+ * Returns the number of byte written if success, or
* -1 general error
* -2 if the transcoding fails (for *in is not valid utf8 string or
* the result of transformation can't fit into the encoding we want), or
@@ -1854,7 +2308,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
toconv = in->use;
if (toconv == 0)
return (0);
- written = out->size - out->use;
+ written = out->size - out->use -1; /* count '\0' */
if (toconv * 2 >= written) {
xmlBufferGrow(out, out->size + toconv * 2);
written = out->size - out->use - 1;
@@ -1877,6 +2331,17 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
ret = -3;
}
#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ else if (handler->uconv_in != NULL) {
+ ret = xmlUconvWrapper(handler->uconv_in, 1, &out->content[out->use],
+ &written, in->content, &toconv);
+ xmlBufferShrink(in, toconv);
+ out->use += written;
+ out->content[out->use] = 0;
+ if (ret == -1)
+ ret = -3;
+ }
+#endif /* LIBXML_ICU_ENABLED */
switch (ret) {
case 0:
#ifdef DEBUG_ENCODING
@@ -1902,7 +2367,7 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
case -2: {
char buf[50];
- snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
+ snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
in->content[0], in->content[1],
in->content[2], in->content[3]);
buf[49] = 0;
@@ -1919,20 +2384,251 @@ xmlCharEncInFunc(xmlCharEncodingHandler * handler, xmlBufferPtr out,
return (written? written : ret);
}
+#ifdef LIBXML_OUTPUT_ENABLED
+/**
+ * xmlCharEncOutput:
+ * @output: a parser output buffer
+ * @init: is this an initialization call without data
+ *
+ * Generic front-end for the encoding handler on parser output
+ * a first call with @init == 1 has to be made first to initiate the
+ * output in case of non-stateless encoding needing to initiate their
+ * state or the output (like the BOM in UTF16).
+ * In case of UTF8 sequence conversion errors for the given encoder,
+ * the content will be automatically remapped to a CharRef sequence.
+ *
+ * Returns the number of byte written if success, or
+ * -1 general error
+ * -2 if the transcoding fails (for *in is not valid utf8 string or
+ * the result of transformation can't fit into the encoding we want), or
+ */
+int
+xmlCharEncOutput(xmlOutputBufferPtr output, int init)
+{
+ int ret = -2;
+ size_t written;
+ size_t writtentot = 0;
+ size_t toconv;
+ int c_in;
+ int c_out;
+ xmlBufPtr in;
+ xmlBufPtr out;
+ int charref_len = 0;
+
+ if ((output == NULL) || (output->encoder == NULL) ||
+ (output->buffer == NULL) || (output->conv == NULL))
+ return (-1);
+ out = output->conv;
+ in = output->buffer;
+
+retry:
+
+ written = xmlBufAvail(out);
+ if (written > 0)
+ written--; /* count '\0' */
+
+ /*
+ * First specific handling of the initialization call
+ */
+ if (init) {
+ c_in = 0;
+ c_out = written;
+ if (output->encoder->output != NULL) {
+ ret = output->encoder->output(xmlBufEnd(out), &c_out,
+ NULL, &c_in);
+ if (ret > 0) /* Gennady: check return value */
+ xmlBufAddLen(out, c_out);
+ }
+#ifdef LIBXML_ICONV_ENABLED
+ else if (output->encoder->iconv_out != NULL) {
+ ret = xmlIconvWrapper(output->encoder->iconv_out, xmlBufEnd(out),
+ &c_out, NULL, &c_in);
+ xmlBufAddLen(out, c_out);
+ }
+#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ else if (output->encoder->uconv_out != NULL) {
+ ret = xmlUconvWrapper(output->encoder->uconv_out, 0, xmlBufEnd(out),
+ &c_out, NULL, &c_in);
+ xmlBufAddLen(out, c_out);
+ }
+#endif /* LIBXML_ICU_ENABLED */
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "initialized encoder\n");
+#endif
+ return(0);
+ }
+
+ /*
+ * Conversion itself.
+ */
+ toconv = xmlBufUse(in);
+ if (toconv == 0)
+ return (0);
+ if (toconv > 64 * 1024)
+ toconv = 64 * 1024;
+ if (toconv * 4 >= written) {
+ xmlBufGrow(out, toconv * 4);
+ written = xmlBufAvail(out) - 1;
+ }
+ if (written > 256 * 1024)
+ written = 256 * 1024;
+
+ c_in = toconv;
+ c_out = written;
+ if (output->encoder->output != NULL) {
+ ret = output->encoder->output(xmlBufEnd(out), &c_out,
+ xmlBufContent(in), &c_in);
+ if (c_out > 0) {
+ xmlBufShrink(in, c_in);
+ xmlBufAddLen(out, c_out);
+ writtentot += c_out;
+ }
+ }
+#ifdef LIBXML_ICONV_ENABLED
+ else if (output->encoder->iconv_out != NULL) {
+ ret = xmlIconvWrapper(output->encoder->iconv_out, xmlBufEnd(out),
+ &c_out, xmlBufContent(in), &c_in);
+ xmlBufShrink(in, c_in);
+ xmlBufAddLen(out, c_out);
+ writtentot += c_out;
+ if (ret == -1) {
+ if (c_out > 0) {
+ /*
+ * Can be a limitation of iconv
+ */
+ charref_len = 0;
+ goto retry;
+ }
+ ret = -3;
+ }
+ }
+#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ else if (output->encoder->uconv_out != NULL) {
+ ret = xmlUconvWrapper(output->encoder->uconv_out, 0, xmlBufEnd(out),
+ &c_out, xmlBufContent(in), &c_in);
+ xmlBufShrink(in, c_in);
+ xmlBufAddLen(out, c_out);
+ writtentot += c_out;
+ if (ret == -1) {
+ if (c_out > 0) {
+ /*
+ * Can be a limitation of uconv
+ */
+ charref_len = 0;
+ goto retry;
+ }
+ ret = -3;
+ }
+ }
+#endif /* LIBXML_ICU_ENABLED */
+ else {
+ xmlEncodingErr(XML_I18N_NO_OUTPUT,
+ "xmlCharEncOutFunc: no output function !\n", NULL);
+ return(-1);
+ }
+
+ if (ret >= 0) output += ret;
+
+ /*
+ * Attempt to handle error cases
+ */
+ switch (ret) {
+ case 0:
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "converted %d bytes to %d bytes of output\n",
+ c_in, c_out);
+#endif
+ break;
+ case -1:
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "output conversion failed by lack of space\n");
+#endif
+ break;
+ case -3:
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,"converted %d bytes to %d bytes of output %d left\n",
+ c_in, c_out, (int) xmlBufUse(in));
+#endif
+ break;
+ case -2: {
+ int len = (int) xmlBufUse(in);
+ xmlChar *content = xmlBufContent(in);
+ int cur;
+
+ cur = xmlGetUTF8Char(content, &len);
+ if ((charref_len != 0) && (c_out < charref_len)) {
+ /*
+ * We attempted to insert a character reference and failed.
+ * Undo what was written and skip the remaining charref.
+ */
+ xmlBufErase(out, c_out);
+ writtentot -= c_out;
+ xmlBufShrink(in, charref_len - c_out);
+ charref_len = 0;
+
+ ret = -1;
+ break;
+ } else if (cur > 0) {
+ xmlChar charref[20];
+
+#ifdef DEBUG_ENCODING
+ xmlGenericError(xmlGenericErrorContext,
+ "handling output conversion error\n");
+ xmlGenericError(xmlGenericErrorContext,
+ "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n",
+ content[0], content[1],
+ content[2], content[3]);
+#endif
+ /*
+ * Removes the UTF8 sequence, and replace it by a charref
+ * and continue the transcoding phase, hoping the error
+ * did not mangle the encoder state.
+ */
+ charref_len = snprintf((char *) &charref[0], sizeof(charref),
+ "&#%d;", cur);
+ xmlBufShrink(in, len);
+ xmlBufAddHead(in, charref, -1);
+
+ goto retry;
+ } else {
+ char buf[50];
+
+ snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
+ content[0], content[1],
+ content[2], content[3]);
+ buf[49] = 0;
+ xmlEncodingErr(XML_I18N_CONV_FAILED,
+ "output conversion failed due to conv error, bytes %s\n",
+ buf);
+ if (xmlBufGetAllocationScheme(in) != XML_BUFFER_ALLOC_IMMUTABLE)
+ content[0] = ' ';
+ }
+ break;
+ }
+ }
+ return(ret);
+}
+#endif
+
/**
* xmlCharEncOutFunc:
* @handler: char enconding transformation data structure
* @out: an xmlBuffer for the output.
* @in: an xmlBuffer for the input
- *
+ *
* Generic front-end for the encoding handler output function
- * a first call with @in == NULL has to be made firs to initiate the
+ * a first call with @in == NULL has to be made firs to initiate the
* output in case of non-stateless encoding needing to initiate their
* state or the output (like the BOM in UTF16).
* In case of UTF8 sequence conversion errors for the given encoder,
* the content will be automatically remapped to a CharRef sequence.
- *
- * Returns the number of byte written if success, or
+ *
+ * Returns the number of byte written if success, or
* -1 general error
* -2 if the transcoding fails (for *in is not valid utf8 string or
* the result of transformation can't fit into the encoding we want), or
@@ -1945,12 +2641,13 @@ xmlCharEncOutFunc(xmlCharEncodingHandler *handler, xmlBufferPtr out,
int writtentot = 0;
int toconv;
int output = 0;
+ int charref_len = 0;
if (handler == NULL) return(-1);
if (out == NULL) return(-1);
retry:
-
+
written = out->size - out->use;
if (written > 0)
@@ -1977,6 +2674,15 @@ retry:
out->content[out->use] = 0;
}
#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ else if (handler->uconv_out != NULL) {
+ ret = xmlUconvWrapper(handler->uconv_out, 0,
+ &out->content[out->use],
+ &written, NULL, &toconv);
+ out->use += written;
+ out->content[out->use] = 0;
+ }
+#endif /* LIBXML_ICU_ENABLED */
#ifdef DEBUG_ENCODING
xmlGenericError(xmlGenericErrorContext,
"initialized encoder\n");
@@ -1990,16 +2696,18 @@ retry:
toconv = in->use;
if (toconv == 0)
return(0);
- if (toconv * 2 >= written) {
- xmlBufferGrow(out, toconv * 2);
+ if (toconv * 4 >= written) {
+ xmlBufferGrow(out, toconv * 4);
written = out->size - out->use - 1;
}
if (handler->output != NULL) {
ret = handler->output(&out->content[out->use], &written,
in->content, &toconv);
- xmlBufferShrink(in, toconv);
- out->use += written;
- writtentot += written;
+ if (written > 0) {
+ xmlBufferShrink(in, toconv);
+ out->use += written;
+ writtentot += written;
+ }
out->content[out->use] = 0;
}
#ifdef LIBXML_ICONV_ENABLED
@@ -2015,12 +2723,34 @@ retry:
/*
* Can be a limitation of iconv
*/
+ charref_len = 0;
goto retry;
}
ret = -3;
}
}
#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ else if (handler->uconv_out != NULL) {
+ ret = xmlUconvWrapper(handler->uconv_out, 0,
+ &out->content[out->use],
+ &written, in->content, &toconv);
+ xmlBufferShrink(in, toconv);
+ out->use += written;
+ writtentot += written;
+ out->content[out->use] = 0;
+ if (ret == -1) {
+ if (written > 0) {
+ /*
+ * Can be a limitation of iconv
+ */
+ charref_len = 0;
+ goto retry;
+ }
+ ret = -3;
+ }
+ }
+#endif /* LIBXML_ICU_ENABLED */
else {
xmlEncodingErr(XML_I18N_NO_OUTPUT,
"xmlCharEncOutFunc: no output function !\n", NULL);
@@ -2058,7 +2788,19 @@ retry:
int cur;
cur = xmlGetUTF8Char(utf, &len);
- if (cur > 0) {
+ if ((charref_len != 0) && (written < charref_len)) {
+ /*
+ * We attempted to insert a character reference and failed.
+ * Undo what was written and skip the remaining charref.
+ */
+ out->use -= written;
+ writtentot -= written;
+ xmlBufferShrink(in, charref_len - written);
+ charref_len = 0;
+
+ ret = -1;
+ break;
+ } else if (cur > 0) {
xmlChar charref[20];
#ifdef DEBUG_ENCODING
@@ -2074,7 +2816,8 @@ retry:
* and continue the transcoding phase, hoping the error
* did not mangle the encoder state.
*/
- snprintf((char *) &charref[0], sizeof(charref), "&#%d;", cur);
+ charref_len = snprintf((char *) &charref[0], sizeof(charref),
+ "&#%d;", cur);
xmlBufferShrink(in, len);
xmlBufferAddHead(in, charref, -1);
@@ -2082,7 +2825,7 @@ retry:
} else {
char buf[50];
- snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
+ snprintf(&buf[0], 49, "0x%02X 0x%02X 0x%02X 0x%02X",
in->content[0], in->content[1],
in->content[2], in->content[3]);
buf[49] = 0;
@@ -2101,7 +2844,7 @@ retry:
/**
* xmlCharEncCloseFunc:
* @handler: char enconding transformation data structure
- *
+ *
* Generic front-end for encoding handler close function
*
* Returns 0 if success, or -1 in case of error
@@ -2109,17 +2852,27 @@ retry:
int
xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
int ret = 0;
+ int tofree = 0;
+ int i, handler_in_list = 0;
+
if (handler == NULL) return(-1);
if (handler->name == NULL) return(-1);
+ if (handlers != NULL) {
+ for (i = 0;i < nbCharEncodingHandler; i++) {
+ if (handler == handlers[i]) {
+ handler_in_list = 1;
+ break;
+ }
+ }
+ }
#ifdef LIBXML_ICONV_ENABLED
/*
* Iconv handlers can be used only once, free the whole block.
* and the associated icon resources.
*/
- if ((handler->iconv_out != NULL) || (handler->iconv_in != NULL)) {
- if (handler->name != NULL)
- xmlFree(handler->name);
- handler->name = NULL;
+ if ((handler_in_list == 0) &&
+ ((handler->iconv_out != NULL) || (handler->iconv_in != NULL))) {
+ tofree = 1;
if (handler->iconv_out != NULL) {
if (iconv_close(handler->iconv_out))
ret = -1;
@@ -2130,9 +2883,29 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
ret = -1;
handler->iconv_in = NULL;
}
- xmlFree(handler);
}
#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ if ((handler_in_list == 0) &&
+ ((handler->uconv_out != NULL) || (handler->uconv_in != NULL))) {
+ tofree = 1;
+ if (handler->uconv_out != NULL) {
+ closeIcuConverter(handler->uconv_out);
+ handler->uconv_out = NULL;
+ }
+ if (handler->uconv_in != NULL) {
+ closeIcuConverter(handler->uconv_in);
+ handler->uconv_in = NULL;
+ }
+ }
+#endif
+ if (tofree) {
+ /* free up only dynamic handlers iconv/uconv */
+ if (handler->name != NULL)
+ xmlFree(handler->name);
+ handler->name = NULL;
+ xmlFree(handler);
+ }
#ifdef DEBUG_ENCODING
if (ret)
xmlGenericError(xmlGenericErrorContext,
@@ -2162,7 +2935,7 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
long
xmlByteConsumed(xmlParserCtxtPtr ctxt) {
xmlParserInputPtr in;
-
+
if (ctxt == NULL) return(-1);
in = ctxt->input;
if (in == NULL) return(-1);
@@ -2208,6 +2981,23 @@ xmlByteConsumed(xmlParserCtxtPtr ctxt) {
cur += toconv;
} while (ret == -2);
#endif
+#ifdef LIBXML_ICU_ENABLED
+ } else if (handler->uconv_out != NULL) {
+ do {
+ toconv = in->end - cur;
+ written = 32000;
+ ret = xmlUconvWrapper(handler->uconv_out, 0, &convbuf[0],
+ &written, cur, &toconv);
+ if (ret < 0) {
+ if (written > 0)
+ ret = -2;
+ else
+ return(-1);
+ }
+ unused += written;
+ cur += toconv;
+ } while (ret == -2);
+#endif
} else {
/* could not find a converter */
return(-1);
@@ -2220,7 +3010,7 @@ xmlByteConsumed(xmlParserCtxtPtr ctxt) {
return(in->consumed + (in->cur - in->base));
}
-#ifndef LIBXML_ICONV_ENABLED
+#if !defined(LIBXML_ICONV_ENABLED) && !defined(LIBXML_ICU_ENABLED)
#ifdef LIBXML_ISO8859X_ENABLED
/**
@@ -2246,6 +3036,7 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
const unsigned char* outstart = out;
const unsigned char* inend;
const unsigned char* instart = in;
+ const unsigned char* processed = in;
if ((out == NULL) || (outlen == NULL) || (inlen == NULL) ||
(xlattable == NULL))
@@ -2262,81 +3053,82 @@ UTF8ToISO8859x(unsigned char* out, int *outlen,
while (in < inend) {
unsigned char d = *in++;
if (d < 0x80) {
- *out++ = d;
+ *out++ = d;
} else if (d < 0xC0) {
/* trailing byte in leading position */
*outlen = out - outstart;
- *inlen = in - instart - 1;
+ *inlen = processed - instart;
return(-2);
} else if (d < 0xE0) {
unsigned char c;
if (!(in < inend)) {
/* trailing byte not in input buffer */
*outlen = out - outstart;
- *inlen = in - instart - 1;
- return(-2);
+ *inlen = processed - instart;
+ return(-3);
}
c = *in++;
if ((c & 0xC0) != 0x80) {
/* not a trailing byte */
*outlen = out - outstart;
- *inlen = in - instart - 2;
+ *inlen = processed - instart;
return(-2);
}
- c = c & 0x3F;
+ c = c & 0x3F;
d = d & 0x1F;
d = xlattable [48 + c + xlattable [d] * 64];
if (d == 0) {
/* not in character set */
*outlen = out - outstart;
- *inlen = in - instart - 2;
+ *inlen = processed - instart;
return(-2);
}
- *out++ = d;
+ *out++ = d;
} else if (d < 0xF0) {
unsigned char c1;
unsigned char c2;
if (!(in < inend - 1)) {
/* trailing bytes not in input buffer */
*outlen = out - outstart;
- *inlen = in - instart - 1;
- return(-2);
+ *inlen = processed - instart;
+ return(-3);
}
c1 = *in++;
if ((c1 & 0xC0) != 0x80) {
/* not a trailing byte (c1) */
*outlen = out - outstart;
- *inlen = in - instart - 2;
+ *inlen = processed - instart;
return(-2);
}
c2 = *in++;
if ((c2 & 0xC0) != 0x80) {
/* not a trailing byte (c2) */
*outlen = out - outstart;
- *inlen = in - instart - 2;
+ *inlen = processed - instart;
return(-2);
}
- c1 = c1 & 0x3F;
- c2 = c2 & 0x3F;
+ c1 = c1 & 0x3F;
+ c2 = c2 & 0x3F;
d = d & 0x0F;
- d = xlattable [48 + c2 + xlattable [48 + c1 +
- xlattable [32 + d] * 64] * 64];
+ d = xlattable [48 + c2 + xlattable [48 + c1 +
+ xlattable [32 + d] * 64] * 64];
if (d == 0) {
/* not in character set */
*outlen = out - outstart;
- *inlen = in - instart - 3;
+ *inlen = processed - instart;
return(-2);
}
- *out++ = d;
+ *out++ = d;
} else {
/* cannot transcode >= U+010000 */
*outlen = out - outstart;
- *inlen = in - instart - 1;
+ *inlen = processed - instart;
return(-2);
}
+ processed = in;
}
*outlen = out - outstart;
- *inlen = in - instart;
+ *inlen = processed - instart;
return(*outlen);
}
@@ -2370,16 +3162,16 @@ ISO8859xToUTF8(unsigned char* out, int *outlen,
outend = out + *outlen;
inend = in + *inlen;
instop = inend;
- c = *in;
- while (in < inend && out < outend - 1) {
- if (c >= 0x80) {
- c = unicodetable [c - 0x80];
+
+ while ((in < inend) && (out < outend - 2)) {
+ if (*in >= 0x80) {
+ c = unicodetable [*in - 0x80];
if (c == 0) {
/* undefined code point */
*outlen = out - outstart;
*inlen = in - instart;
return (-1);
- }
+ }
if (c < 0x800) {
*out++ = ((c >> 6) & 0x1F) | 0xC0;
*out++ = (c & 0x3F) | 0x80;
@@ -2387,48 +3179,47 @@ ISO8859xToUTF8(unsigned char* out, int *outlen,
*out++ = ((c >> 12) & 0x0F) | 0xE0;
*out++ = ((c >> 6) & 0x3F) | 0x80;
*out++ = (c & 0x3F) | 0x80;
- }
+ }
++in;
- c = *in;
}
- if (instop - in > outend - out) instop = in + (outend - out);
- while (c < 0x80 && in < instop) {
- *out++ = c;
- ++in;
- c = *in;
+ if (instop - in > outend - out) instop = in + (outend - out);
+ while ((*in < 0x80) && (in < instop)) {
+ *out++ = *in++;
}
- }
- if (in < inend && out < outend && c < 0x80) {
- *out++ = c;
- ++in;
+ }
+ if ((in < inend) && (out < outend) && (*in < 0x80)) {
+ *out++ = *in++;
+ }
+ if ((in < inend) && (out < outend) && (*in < 0x80)) {
+ *out++ = *in++;
}
*outlen = out - outstart;
*inlen = in - instart;
return (*outlen);
}
-
+
/************************************************************************
* Lookup tables for ISO-8859-2..ISO-8859-16 transcoding *
************************************************************************/
static unsigned short const xmlunicodetable_ISO8859_2 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7,
- 0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b,
- 0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7,
- 0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c,
- 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7,
- 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
- 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7,
- 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
- 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7,
- 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
- 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7,
- 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7,
+ 0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b,
+ 0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7,
+ 0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c,
+ 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7,
+ 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e,
+ 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7,
+ 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df,
+ 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7,
+ 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f,
+ 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7,
+ 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9,
};
static unsigned char const xmltranscodetable_ISO8859_2 [48 + 6 * 64] = {
@@ -2462,22 +3253,22 @@ static unsigned char const xmltranscodetable_ISO8859_2 [48 + 6 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_3 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0x0000, 0x0124, 0x00a7,
- 0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0x0000, 0x017b,
- 0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7,
- 0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0x0000, 0x017c,
- 0x00c0, 0x00c1, 0x00c2, 0x0000, 0x00c4, 0x010a, 0x0108, 0x00c7,
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
- 0x0000, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7,
- 0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df,
- 0x00e0, 0x00e1, 0x00e2, 0x0000, 0x00e4, 0x010b, 0x0109, 0x00e7,
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
- 0x0000, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7,
- 0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0x0000, 0x0124, 0x00a7,
+ 0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0x0000, 0x017b,
+ 0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7,
+ 0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0x0000, 0x017c,
+ 0x00c0, 0x00c1, 0x00c2, 0x0000, 0x00c4, 0x010a, 0x0108, 0x00c7,
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+ 0x0000, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7,
+ 0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df,
+ 0x00e0, 0x00e1, 0x00e2, 0x0000, 0x00e4, 0x010b, 0x0109, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ 0x0000, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7,
+ 0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9,
};
static unsigned char const xmltranscodetable_ISO8859_3 [48 + 7 * 64] = {
@@ -2515,22 +3306,22 @@ static unsigned char const xmltranscodetable_ISO8859_3 [48 + 7 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_4 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x0128, 0x013b, 0x00a7,
- 0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af,
- 0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7,
- 0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b,
- 0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
- 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a,
- 0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
- 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df,
- 0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
- 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b,
- 0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
- 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x0128, 0x013b, 0x00a7,
+ 0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af,
+ 0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7,
+ 0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b,
+ 0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
+ 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a,
+ 0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
+ 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df,
+ 0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
+ 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b,
+ 0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
+ 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9,
};
static unsigned char const xmltranscodetable_ISO8859_4 [48 + 6 * 64] = {
@@ -2564,22 +3355,22 @@ static unsigned char const xmltranscodetable_ISO8859_4 [48 + 6 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_5 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
- 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f,
- 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
- 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
- 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
- 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
- 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
- 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
- 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
- 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
- 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
- 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
+ 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f,
+ 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
+ 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
+ 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
+ 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
+ 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
+ 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
+ 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
+ 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
+ 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
+ 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f,
};
static unsigned char const xmltranscodetable_ISO8859_5 [48 + 6 * 64] = {
@@ -2613,22 +3404,22 @@ static unsigned char const xmltranscodetable_ISO8859_5 [48 + 6 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_6 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x0000, 0x0000, 0x0000, 0x00a4, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x060c, 0x00ad, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f,
- 0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
- 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
- 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637,
- 0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647,
- 0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f,
- 0x0650, 0x0651, 0x0652, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x0000, 0x0000, 0x0000, 0x00a4, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x060c, 0x00ad, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f,
+ 0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
+ 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f,
+ 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637,
+ 0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647,
+ 0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f,
+ 0x0650, 0x0651, 0x0652, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
};
static unsigned char const xmltranscodetable_ISO8859_6 [48 + 5 * 64] = {
@@ -2658,22 +3449,22 @@ static unsigned char const xmltranscodetable_ISO8859_6 [48 + 5 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_7 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x2018, 0x2019, 0x00a3, 0x0000, 0x0000, 0x00a6, 0x00a7,
- 0x00a8, 0x00a9, 0x0000, 0x00ab, 0x00ac, 0x00ad, 0x0000, 0x2015,
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0384, 0x0385, 0x0386, 0x00b7,
- 0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f,
- 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
- 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
- 0x03a0, 0x03a1, 0x0000, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
- 0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af,
- 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
- 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
- 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7,
- 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0000,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x2018, 0x2019, 0x00a3, 0x0000, 0x0000, 0x00a6, 0x00a7,
+ 0x00a8, 0x00a9, 0x0000, 0x00ab, 0x00ac, 0x00ad, 0x0000, 0x2015,
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0384, 0x0385, 0x0386, 0x00b7,
+ 0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f,
+ 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
+ 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f,
+ 0x03a0, 0x03a1, 0x0000, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7,
+ 0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af,
+ 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7,
+ 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf,
+ 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7,
+ 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0000,
};
static unsigned char const xmltranscodetable_ISO8859_7 [48 + 7 * 64] = {
@@ -2711,22 +3502,22 @@ static unsigned char const xmltranscodetable_ISO8859_7 [48 + 7 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_8 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x0000, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
- 0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
- 0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
- 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2017,
- 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
- 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
- 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
- 0x05e8, 0x05e9, 0x05ea, 0x0000, 0x0000, 0x200e, 0x200f, 0x0000,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x0000, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
+ 0x00a8, 0x00a9, 0x00d7, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+ 0x00b8, 0x00b9, 0x00f7, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2017,
+ 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7,
+ 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df,
+ 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7,
+ 0x05e8, 0x05e9, 0x05ea, 0x0000, 0x0000, 0x200e, 0x200f, 0x0000,
};
static unsigned char const xmltranscodetable_ISO8859_8 [48 + 7 * 64] = {
@@ -2764,22 +3555,22 @@ static unsigned char const xmltranscodetable_ISO8859_8 [48 + 7 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_9 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
- 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
- 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
- 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
- 0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
- 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df,
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
- 0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
- 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7,
+ 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7,
+ 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf,
+ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+ 0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
+ 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df,
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ 0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
+ 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff,
};
static unsigned char const xmltranscodetable_ISO8859_9 [48 + 5 * 64] = {
@@ -2809,22 +3600,22 @@ static unsigned char const xmltranscodetable_ISO8859_9 [48 + 5 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_10 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x0104, 0x0112, 0x0122, 0x012a, 0x0128, 0x0136, 0x00a7,
- 0x013b, 0x0110, 0x0160, 0x0166, 0x017d, 0x00ad, 0x016a, 0x014a,
- 0x00b0, 0x0105, 0x0113, 0x0123, 0x012b, 0x0129, 0x0137, 0x00b7,
- 0x013c, 0x0111, 0x0161, 0x0167, 0x017e, 0x2015, 0x016b, 0x014b,
- 0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
- 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x00cf,
- 0x00d0, 0x0145, 0x014c, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x0168,
- 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
- 0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
- 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x00ef,
- 0x00f0, 0x0146, 0x014d, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x0169,
- 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x0138,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x0104, 0x0112, 0x0122, 0x012a, 0x0128, 0x0136, 0x00a7,
+ 0x013b, 0x0110, 0x0160, 0x0166, 0x017d, 0x00ad, 0x016a, 0x014a,
+ 0x00b0, 0x0105, 0x0113, 0x0123, 0x012b, 0x0129, 0x0137, 0x00b7,
+ 0x013c, 0x0111, 0x0161, 0x0167, 0x017e, 0x2015, 0x016b, 0x014b,
+ 0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e,
+ 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x00cf,
+ 0x00d0, 0x0145, 0x014c, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x0168,
+ 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
+ 0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f,
+ 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x00ef,
+ 0x00f0, 0x0146, 0x014d, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x0169,
+ 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x0138,
};
static unsigned char const xmltranscodetable_ISO8859_10 [48 + 7 * 64] = {
@@ -2862,22 +3653,22 @@ static unsigned char const xmltranscodetable_ISO8859_10 [48 + 7 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_11 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07,
- 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
- 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17,
- 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
- 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27,
- 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
- 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
- 0x0e38, 0x0e39, 0x0e3a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0e3f,
- 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
- 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f,
- 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57,
- 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0x0000, 0x0000, 0x0000, 0x0000,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07,
+ 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f,
+ 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17,
+ 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f,
+ 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27,
+ 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f,
+ 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37,
+ 0x0e38, 0x0e39, 0x0e3a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0e3f,
+ 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47,
+ 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0e4e, 0x0e4f,
+ 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57,
+ 0x0e58, 0x0e59, 0x0e5a, 0x0e5b, 0x0000, 0x0000, 0x0000, 0x0000,
};
static unsigned char const xmltranscodetable_ISO8859_11 [48 + 6 * 64] = {
@@ -2911,22 +3702,22 @@ static unsigned char const xmltranscodetable_ISO8859_11 [48 + 6 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_13 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x201d, 0x00a2, 0x00a3, 0x00a4, 0x201e, 0x00a6, 0x00a7,
- 0x00d8, 0x00a9, 0x0156, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00c6,
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x201c, 0x00b5, 0x00b6, 0x00b7,
- 0x00f8, 0x00b9, 0x0157, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00e6,
- 0x0104, 0x012e, 0x0100, 0x0106, 0x00c4, 0x00c5, 0x0118, 0x0112,
- 0x010c, 0x00c9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012a, 0x013b,
- 0x0160, 0x0143, 0x0145, 0x00d3, 0x014c, 0x00d5, 0x00d6, 0x00d7,
- 0x0172, 0x0141, 0x015a, 0x016a, 0x00dc, 0x017b, 0x017d, 0x00df,
- 0x0105, 0x012f, 0x0101, 0x0107, 0x00e4, 0x00e5, 0x0119, 0x0113,
- 0x010d, 0x00e9, 0x017a, 0x0117, 0x0123, 0x0137, 0x012b, 0x013c,
- 0x0161, 0x0144, 0x0146, 0x00f3, 0x014d, 0x00f5, 0x00f6, 0x00f7,
- 0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x2019,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x201d, 0x00a2, 0x00a3, 0x00a4, 0x201e, 0x00a6, 0x00a7,
+ 0x00d8, 0x00a9, 0x0156, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00c6,
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x201c, 0x00b5, 0x00b6, 0x00b7,
+ 0x00f8, 0x00b9, 0x0157, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00e6,
+ 0x0104, 0x012e, 0x0100, 0x0106, 0x00c4, 0x00c5, 0x0118, 0x0112,
+ 0x010c, 0x00c9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012a, 0x013b,
+ 0x0160, 0x0143, 0x0145, 0x00d3, 0x014c, 0x00d5, 0x00d6, 0x00d7,
+ 0x0172, 0x0141, 0x015a, 0x016a, 0x00dc, 0x017b, 0x017d, 0x00df,
+ 0x0105, 0x012f, 0x0101, 0x0107, 0x00e4, 0x00e5, 0x0119, 0x0113,
+ 0x010d, 0x00e9, 0x017a, 0x0117, 0x0123, 0x0137, 0x012b, 0x013c,
+ 0x0161, 0x0144, 0x0146, 0x00f3, 0x014d, 0x00f5, 0x00f6, 0x00f7,
+ 0x0173, 0x0142, 0x015b, 0x016b, 0x00fc, 0x017c, 0x017e, 0x2019,
};
static unsigned char const xmltranscodetable_ISO8859_13 [48 + 7 * 64] = {
@@ -2964,22 +3755,22 @@ static unsigned char const xmltranscodetable_ISO8859_13 [48 + 7 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_14 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x1e02, 0x1e03, 0x00a3, 0x010a, 0x010b, 0x1e0a, 0x00a7,
- 0x1e80, 0x00a9, 0x1e82, 0x1e0b, 0x1ef2, 0x00ad, 0x00ae, 0x0178,
- 0x1e1e, 0x1e1f, 0x0120, 0x0121, 0x1e40, 0x1e41, 0x00b6, 0x1e56,
- 0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61,
- 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
- 0x0174, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x1e6a,
- 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x0176, 0x00df,
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
- 0x0175, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x1e6b,
- 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x1e02, 0x1e03, 0x00a3, 0x010a, 0x010b, 0x1e0a, 0x00a7,
+ 0x1e80, 0x00a9, 0x1e82, 0x1e0b, 0x1ef2, 0x00ad, 0x00ae, 0x0178,
+ 0x1e1e, 0x1e1f, 0x0120, 0x0121, 0x1e40, 0x1e41, 0x00b6, 0x1e56,
+ 0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61,
+ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+ 0x0174, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x1e6a,
+ 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x0176, 0x00df,
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ 0x0175, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x1e6b,
+ 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff,
};
static unsigned char const xmltranscodetable_ISO8859_14 [48 + 10 * 64] = {
@@ -3029,22 +3820,22 @@ static unsigned char const xmltranscodetable_ISO8859_14 [48 + 10 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_15 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7,
- 0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7,
- 0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
- 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
- 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
- 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
- 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
- 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x20ac, 0x00a5, 0x0160, 0x00a7,
+ 0x0161, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af,
+ 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x017d, 0x00b5, 0x00b6, 0x00b7,
+ 0x017e, 0x00b9, 0x00ba, 0x00bb, 0x0152, 0x0153, 0x0178, 0x00bf,
+ 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7,
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+ 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7,
+ 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df,
+ 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7,
+ 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff,
};
static unsigned char const xmltranscodetable_ISO8859_15 [48 + 6 * 64] = {
@@ -3078,22 +3869,22 @@ static unsigned char const xmltranscodetable_ISO8859_15 [48 + 6 * 64] = {
};
static unsigned short const xmlunicodetable_ISO8859_16 [128] = {
- 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
- 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
- 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
- 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
- 0x00a0, 0x0104, 0x0105, 0x0141, 0x20ac, 0x201e, 0x0160, 0x00a7,
- 0x0161, 0x00a9, 0x0218, 0x00ab, 0x0179, 0x00ad, 0x017a, 0x017b,
- 0x00b0, 0x00b1, 0x010c, 0x0142, 0x017d, 0x201d, 0x00b6, 0x00b7,
- 0x017e, 0x010d, 0x0219, 0x00bb, 0x0152, 0x0153, 0x0178, 0x017c,
- 0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0106, 0x00c6, 0x00c7,
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
- 0x0110, 0x0143, 0x00d2, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x015a,
- 0x0170, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0118, 0x021a, 0x00df,
- 0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x0107, 0x00e6, 0x00e7,
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
- 0x0111, 0x0144, 0x00f2, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x015b,
- 0x0171, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0119, 0x021b, 0x00ff,
+ 0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
+ 0x0088, 0x0089, 0x008a, 0x008b, 0x008c, 0x008d, 0x008e, 0x008f,
+ 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
+ 0x0098, 0x0099, 0x009a, 0x009b, 0x009c, 0x009d, 0x009e, 0x009f,
+ 0x00a0, 0x0104, 0x0105, 0x0141, 0x20ac, 0x201e, 0x0160, 0x00a7,
+ 0x0161, 0x00a9, 0x0218, 0x00ab, 0x0179, 0x00ad, 0x017a, 0x017b,
+ 0x00b0, 0x00b1, 0x010c, 0x0142, 0x017d, 0x201d, 0x00b6, 0x00b7,
+ 0x017e, 0x010d, 0x0219, 0x00bb, 0x0152, 0x0153, 0x0178, 0x017c,
+ 0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0106, 0x00c6, 0x00c7,
+ 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf,
+ 0x0110, 0x0143, 0x00d2, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x015a,
+ 0x0170, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0118, 0x021a, 0x00df,
+ 0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x0107, 0x00e6, 0x00e7,
+ 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef,
+ 0x0111, 0x0144, 0x00f2, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x015b,
+ 0x0171, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0119, 0x021b, 0x00ff,
};
static unsigned char const xmltranscodetable_ISO8859_16 [48 + 9 * 64] = {
@@ -3292,4 +4083,3 @@ xmlRegisterCharEncodingHandlersISO8859x (void) {
#define bottom_encoding
#include "elfgcchack.h"
-
diff --git a/gnulib-local/lib/libxml/encoding.in.h b/gnulib-local/lib/libxml/encoding.in.h
index c74b25f..7967cc6 100644
--- a/gnulib-local/lib/libxml/encoding.in.h
+++ b/gnulib-local/lib/libxml/encoding.in.h
@@ -27,6 +27,9 @@
#ifdef LIBXML_ICONV_ENABLED
#include <iconv.h>
#endif
+#ifdef LIBXML_ICU_ENABLED
+#include <unicode/ucnv.h>
+#endif
#ifdef __cplusplus
extern "C" {
#endif
@@ -125,6 +128,13 @@ typedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,
* Block defining the handlers for non UTF-8 encodings.
* If iconv is supported, there are two extra fields.
*/
+#ifdef LIBXML_ICU_ENABLED
+struct _uconv_t {
+ UConverter *uconv; /* for conversion between an encoding and UTF-16 */
+ UConverter *utf8; /* for conversion between UTF-8 and UTF-16 */
+};
+typedef struct _uconv_t uconv_t;
+#endif
typedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;
typedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;
@@ -136,6 +146,10 @@ struct _xmlCharEncodingHandler {
iconv_t iconv_in;
iconv_t iconv_out;
#endif /* LIBXML_ICONV_ENABLED */
+#ifdef LIBXML_ICU_ENABLED
+ uconv_t *uconv_in;
+ uconv_t *uconv_out;
+#endif /* LIBXML_ICU_ENABLED */
};
#ifdef __cplusplus
@@ -149,32 +163,32 @@ extern "C" {
/*
* Interfaces for encoding handlers.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlInitCharEncodingHandlers (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCleanupCharEncodingHandlers (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRegisterCharEncodingHandler (xmlCharEncodingHandlerPtr handler);
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
xmlGetCharEncodingHandler (xmlCharEncoding enc);
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
xmlFindCharEncodingHandler (const char *name);
XMLPUBFUN xmlCharEncodingHandlerPtr XMLCALL
- xmlNewCharEncodingHandler (const char *name,
- xmlCharEncodingInputFunc input,
- xmlCharEncodingOutputFunc output);
+ xmlNewCharEncodingHandler (const char *name,
+ xmlCharEncodingInputFunc input,
+ xmlCharEncodingOutputFunc output);
/*
* Interfaces for encoding names and aliases.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlAddEncodingAlias (const char *name,
const char *alias);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlDelEncodingAlias (const char *alias);
XMLPUBFUN const char * XMLCALL
xmlGetEncodingAlias (const char *alias);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCleanupEncodingAliases (void);
XMLPUBFUN xmlCharEncoding XMLCALL
xmlParseCharEncoding (const char *name);
@@ -188,12 +202,12 @@ XMLPUBFUN xmlCharEncoding XMLCALL
xmlDetectCharEncoding (const unsigned char *in,
int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlCharEncOutFunc (xmlCharEncodingHandler *handler,
xmlBufferPtr out,
xmlBufferPtr in);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlCharEncInFunc (xmlCharEncodingHandler *handler,
xmlBufferPtr out,
xmlBufferPtr in);
@@ -201,20 +215,20 @@ XMLPUBFUN int XMLCALL
xmlCharEncFirstLine (xmlCharEncodingHandler *handler,
xmlBufferPtr out,
xmlBufferPtr in);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlCharEncCloseFunc (xmlCharEncodingHandler *handler);
/*
* Export a few useful functions
*/
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
UTF8Toisolat1 (unsigned char *out,
int *outlen,
const unsigned char *in,
int *inlen);
#endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
isolat1ToUTF8 (unsigned char *out,
int *outlen,
const unsigned char *in,
diff --git a/gnulib-local/lib/libxml/entities.c b/gnulib-local/lib/libxml/entities.c
index 91a3978..a72afb3 100644
--- a/gnulib-local/lib/libxml/entities.c
+++ b/gnulib-local/lib/libxml/entities.c
@@ -22,41 +22,43 @@
#include <libxml/globals.h>
#include <libxml/dict.h>
+#include "save.h"
+
/*
* The XML predefined entities.
*/
static xmlEntity xmlEntityLt = {
NULL, XML_ENTITY_DECL, BAD_CAST "lt",
- NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
BAD_CAST "<", BAD_CAST "<", 1,
XML_INTERNAL_PREDEFINED_ENTITY,
NULL, NULL, NULL, NULL, 0, 1
};
static xmlEntity xmlEntityGt = {
NULL, XML_ENTITY_DECL, BAD_CAST "gt",
- NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
BAD_CAST ">", BAD_CAST ">", 1,
XML_INTERNAL_PREDEFINED_ENTITY,
NULL, NULL, NULL, NULL, 0, 1
};
static xmlEntity xmlEntityAmp = {
NULL, XML_ENTITY_DECL, BAD_CAST "amp",
- NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
BAD_CAST "&", BAD_CAST "&", 1,
XML_INTERNAL_PREDEFINED_ENTITY,
NULL, NULL, NULL, NULL, 0, 1
};
static xmlEntity xmlEntityQuot = {
NULL, XML_ENTITY_DECL, BAD_CAST "quot",
- NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
BAD_CAST "\"", BAD_CAST "\"", 1,
XML_INTERNAL_PREDEFINED_ENTITY,
NULL, NULL, NULL, NULL, 0, 1
};
static xmlEntity xmlEntityApos = {
NULL, XML_ENTITY_DECL, BAD_CAST "apos",
- NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL,
BAD_CAST "'", BAD_CAST "'", 1,
XML_INTERNAL_PREDEFINED_ENTITY,
NULL, NULL, NULL, NULL, 0, 1
@@ -139,45 +141,19 @@ xmlFreeEntity(xmlEntityPtr entity)
}
/*
- * xmlAddEntity : register a new entity for an entities table.
+ * xmlCreateEntity:
+ *
+ * internal routine doing the entity node strutures allocations
*/
static xmlEntityPtr
-xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
- const xmlChar *ExternalID, const xmlChar *SystemID,
- const xmlChar *content) {
- xmlDictPtr dict = NULL;
- xmlEntitiesTablePtr table = NULL;
+xmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type,
+ const xmlChar *ExternalID, const xmlChar *SystemID,
+ const xmlChar *content) {
xmlEntityPtr ret;
- if (name == NULL)
- return(NULL);
- if (dtd == NULL)
- return(NULL);
- if (dtd->doc != NULL)
- dict = dtd->doc->dict;
-
- switch (type) {
- case XML_INTERNAL_GENERAL_ENTITY:
- case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
- case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
- if (dtd->entities == NULL)
- dtd->entities = xmlHashCreateDict(0, dict);
- table = dtd->entities;
- break;
- case XML_INTERNAL_PARAMETER_ENTITY:
- case XML_EXTERNAL_PARAMETER_ENTITY:
- if (dtd->pentities == NULL)
- dtd->pentities = xmlHashCreateDict(0, dict);
- table = dtd->pentities;
- break;
- case XML_INTERNAL_PREDEFINED_ENTITY:
- return(NULL);
- }
- if (table == NULL)
- return(NULL);
ret = (xmlEntityPtr) xmlMalloc(sizeof(xmlEntity));
if (ret == NULL) {
- xmlEntitiesErrMemory("xmlAddEntity:: malloc failed");
+ xmlEntitiesErrMemory("xmlCreateEntity: malloc failed");
return(NULL);
}
memset(ret, 0, sizeof(xmlEntity));
@@ -216,6 +192,50 @@ xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
the defining entity */
ret->orig = NULL;
ret->owner = 0;
+
+ return(ret);
+}
+
+/*
+ * xmlAddEntity : register a new entity for an entities table.
+ */
+static xmlEntityPtr
+xmlAddEntity(xmlDtdPtr dtd, const xmlChar *name, int type,
+ const xmlChar *ExternalID, const xmlChar *SystemID,
+ const xmlChar *content) {
+ xmlDictPtr dict = NULL;
+ xmlEntitiesTablePtr table = NULL;
+ xmlEntityPtr ret;
+
+ if (name == NULL)
+ return(NULL);
+ if (dtd == NULL)
+ return(NULL);
+ if (dtd->doc != NULL)
+ dict = dtd->doc->dict;
+
+ switch (type) {
+ case XML_INTERNAL_GENERAL_ENTITY:
+ case XML_EXTERNAL_GENERAL_PARSED_ENTITY:
+ case XML_EXTERNAL_GENERAL_UNPARSED_ENTITY:
+ if (dtd->entities == NULL)
+ dtd->entities = xmlHashCreateDict(0, dict);
+ table = dtd->entities;
+ break;
+ case XML_INTERNAL_PARAMETER_ENTITY:
+ case XML_EXTERNAL_PARAMETER_ENTITY:
+ if (dtd->pentities == NULL)
+ dtd->pentities = xmlHashCreateDict(0, dict);
+ table = dtd->pentities;
+ break;
+ case XML_INTERNAL_PREDEFINED_ENTITY:
+ return(NULL);
+ }
+ if (table == NULL)
+ return(NULL);
+ ret = xmlCreateEntity(dict, name, type, ExternalID, SystemID, content);
+ if (ret == NULL)
+ return(NULL);
ret->doc = dtd->doc;
if (xmlHashAddEntry(table, name, ret)) {
@@ -363,6 +383,44 @@ xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type,
}
/**
+ * xmlNewEntity:
+ * @doc: the document
+ * @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
+ *
+ * Create a new entity, this differs from xmlAddDocEntity() that if
+ * the document is NULL or has no internal subset defined, then an
+ * unlinked entity structure will be returned, it is then the responsability
+ * of the caller to link it to the document later or free it when not needed
+ * anymore.
+ *
+ * Returns a pointer to the entity or NULL in case of error
+ */
+xmlEntityPtr
+xmlNewEntity(xmlDocPtr doc, const xmlChar *name, int type,
+ const xmlChar *ExternalID, const xmlChar *SystemID,
+ const xmlChar *content) {
+ xmlEntityPtr ret;
+ xmlDictPtr dict;
+
+ if ((doc != NULL) && (doc->intSubset != NULL)) {
+ return(xmlAddDocEntity(doc, name, type, ExternalID, SystemID, content));
+ }
+ if (doc != NULL)
+ dict = doc->dict;
+ else
+ dict = NULL;
+ ret = xmlCreateEntity(dict, name, type, ExternalID, SystemID, content);
+ if (ret == NULL)
+ return(NULL);
+ ret->doc = doc;
+ return(ret);
+}
+
+/**
* xmlGetEntityFromTable:
* @table: an entity table
* @name: the entity name
@@ -370,7 +428,7 @@ xmlAddDocEntity(xmlDocPtr doc, const xmlChar *name, int type,
*
* Do an entity lookup in the table.
* returns the corresponding parameter entity, if found.
- *
+ *
* Returns A pointer to the entity structure or NULL if not found.
*/
static xmlEntityPtr
@@ -385,7 +443,7 @@ xmlGetEntityFromTable(xmlEntitiesTablePtr table, const xmlChar *name) {
*
* Do an entity lookup in the internal and external subsets and
* returns the corresponding parameter entity, if found.
- *
+ *
* Returns A pointer to the entity structure or NULL if not found.
*/
xmlEntityPtr
@@ -416,7 +474,7 @@ xmlGetParameterEntity(xmlDocPtr doc, const xmlChar *name) {
* Do an entity lookup in the DTD entity hash table and
* returns the corresponding entity, if found.
* Note: the first argument is the document node, not the DTD node.
- *
+ *
* Returns A pointer to the entity structure or NULL if not found.
*/
xmlEntityPtr
@@ -440,11 +498,11 @@ xmlGetDtdEntity(xmlDocPtr doc, const xmlChar *name) {
* Do an entity lookup in the document entity hash table and
* returns the corresponding entity, otherwise a lookup is done
* in the predefined entities too.
- *
+ *
* Returns A pointer to the entity structure or NULL if not found.
*/
xmlEntityPtr
-xmlGetDocEntity(xmlDocPtr doc, const xmlChar *name) {
+xmlGetDocEntity(const xmlDoc *doc, const xmlChar *name) {
xmlEntityPtr cur;
xmlEntitiesTablePtr table;
@@ -472,20 +530,20 @@ xmlGetDocEntity(xmlDocPtr doc, const xmlChar *name) {
* Macro used to grow the current buffer.
*/
#define growBufferReentrant() { \
- buffer_size *= 2; \
- buffer = (xmlChar *) \
- xmlRealloc(buffer, buffer_size * sizeof(xmlChar)); \
- if (buffer == NULL) { \
- xmlEntitiesErrMemory("xmlEncodeEntitiesReentrant: realloc failed");\
- return(NULL); \
- } \
+ xmlChar *tmp; \
+ size_t new_size = buffer_size * 2; \
+ if (new_size < buffer_size) goto mem_error; \
+ tmp = (xmlChar *) xmlRealloc(buffer, new_size); \
+ if (tmp == NULL) goto mem_error; \
+ buffer = tmp; \
+ buffer_size = new_size; \
}
-
/**
- * xmlEncodeEntitiesReentrant:
+ * xmlEncodeEntitiesInternal:
* @doc: the document containing the string
* @input: A string to convert to XML.
+ * @attr: are we handling an atrbute value
*
* Do a global encoding of a string, replacing the predefined entities
* and non ASCII values with their entities and CharRef counterparts.
@@ -494,12 +552,12 @@ xmlGetDocEntity(xmlDocPtr doc, const xmlChar *name) {
*
* Returns A newly allocated string with the substitution done.
*/
-xmlChar *
-xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
+static xmlChar *
+xmlEncodeEntitiesInternal(xmlDocPtr doc, const xmlChar *input, int attr) {
const xmlChar *cur = input;
xmlChar *buffer = NULL;
xmlChar *out = NULL;
- int buffer_size = 0;
+ size_t buffer_size = 0;
int html = 0;
if (input == NULL) return(NULL);
@@ -512,14 +570,14 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
buffer_size = 1000;
buffer = (xmlChar *) xmlMalloc(buffer_size * sizeof(xmlChar));
if (buffer == NULL) {
- xmlEntitiesErrMemory("xmlEncodeEntitiesReentrant: malloc failed");
+ xmlEntitiesErrMemory("xmlEncodeEntities: malloc failed");
return(NULL);
}
out = buffer;
while (*cur != '\0') {
- if (out - buffer > buffer_size - 100) {
- int indx = out - buffer;
+ size_t indx = out - buffer;
+ if (indx + 100 > buffer_size) {
growBufferReentrant();
out = &buffer[indx];
@@ -529,6 +587,27 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
* By default one have to encode at least '<', '>', '"' and '&' !
*/
if (*cur == '<') {
+ const xmlChar *end;
+
+ /*
+ * Special handling of server side include in HTML attributes
+ */
+ if (html && attr &&
+ (cur[1] == '!') && (cur[2] == '-') && (cur[3] == '-') &&
+ ((end = xmlStrstr(cur, BAD_CAST "-->")) != NULL)) {
+ while (cur != end) {
+ *out++ = *cur++;
+ indx = out - buffer;
+ if (indx + 100 > buffer_size) {
+ growBufferReentrant();
+ out = &buffer[indx];
+ }
+ }
+ *out++ = *cur++;
+ *out++ = *cur++;
+ *out++ = *cur++;
+ continue;
+ }
*out++ = '&';
*out++ = 'l';
*out++ = 't';
@@ -539,6 +618,23 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
*out++ = 't';
*out++ = ';';
} else if (*cur == '&') {
+ /*
+ * Special handling of &{...} construct from HTML 4, see
+ * http://www.w3.org/TR/html401/appendix/notes.html#h-B.7.1
+ */
+ if (html && attr && (cur[1] == '{') &&
+ (strchr((const char *) cur, '}'))) {
+ while (*cur != '}') {
+ *out++ = *cur++;
+ indx = out - buffer;
+ if (indx + 100 > buffer_size) {
+ growBufferReentrant();
+ out = &buffer[indx];
+ }
+ }
+ *out++ = *cur++;
+ continue;
+ }
*out++ = '&';
*out++ = 'a';
*out++ = 'm';
@@ -553,7 +649,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
} else if (*cur >= 0x80) {
if (((doc != NULL) && (doc->encoding != NULL)) || (html)) {
/*
- * Bjørn Reese <br@sseusa.com> provided the patch
+ * Bjørn Reese <br@sseusa.com> provided the patch
xmlChar xc;
xc = (*cur & 0x3F) << 6;
if (cur[1] != 0) {
@@ -571,7 +667,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
if (*cur < 0xC0) {
xmlEntitiesErr(XML_CHECK_NOT_UTF8,
- "xmlEncodeEntitiesReentrant : input not UTF-8");
+ "xmlEncodeEntities: input not UTF-8");
if (doc != NULL)
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
snprintf(buf, sizeof(buf), "&#%d;", *cur);
@@ -604,7 +700,7 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
}
if ((l == 1) || (!IS_CHAR(val))) {
xmlEntitiesErr(XML_ERR_INVALID_CHAR,
- "xmlEncodeEntitiesReentrant : char out of range\n");
+ "xmlEncodeEntities: char out of range\n");
if (doc != NULL)
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
snprintf(buf, sizeof(buf), "&#%d;", *cur);
@@ -634,8 +730,46 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
}
cur++;
}
- *out++ = 0;
+ *out = 0;
return(buffer);
+
+mem_error:
+ xmlEntitiesErrMemory("xmlEncodeEntities: realloc failed");
+ xmlFree(buffer);
+ return(NULL);
+}
+
+/**
+ * xmlEncodeAttributeEntities:
+ * @doc: the document containing the string
+ * @input: A string to convert to XML.
+ *
+ * Do a global encoding of a string, replacing the predefined entities
+ * and non ASCII values with their entities and CharRef counterparts for
+ * attribute values.
+ *
+ * Returns A newly allocated string with the substitution done.
+ */
+xmlChar *
+xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input) {
+ return xmlEncodeEntitiesInternal(doc, input, 1);
+}
+
+/**
+ * xmlEncodeEntitiesReentrant:
+ * @doc: the document containing the string
+ * @input: A string to convert to XML.
+ *
+ * Do a global encoding of a string, replacing the predefined entities
+ * and non ASCII values with their entities and CharRef counterparts.
+ * Contrary to xmlEncodeEntities, this routine is reentrant, and result
+ * must be deallocated.
+ *
+ * Returns A newly allocated string with the substitution done.
+ */
+xmlChar *
+xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
+ return xmlEncodeEntitiesInternal(doc, input, 0);
}
/**
@@ -649,11 +783,11 @@ xmlEncodeEntitiesReentrant(xmlDocPtr doc, const xmlChar *input) {
* Returns A newly allocated string with the substitution done.
*/
xmlChar *
-xmlEncodeSpecialChars(xmlDocPtr doc ATTRIBUTE_UNUSED, const xmlChar *input) {
+xmlEncodeSpecialChars(const xmlDoc *doc ATTRIBUTE_UNUSED, const xmlChar *input) {
const xmlChar *cur = input;
xmlChar *buffer = NULL;
xmlChar *out = NULL;
- int buffer_size = 0;
+ size_t buffer_size = 0;
if (input == NULL) return(NULL);
/*
@@ -668,8 +802,8 @@ xmlEncodeSpecialChars(xmlDocPtr doc ATTRIBUTE_UNUSED, const xmlChar *input) {
out = buffer;
while (*cur != '\0') {
- if (out - buffer > buffer_size - 10) {
- int indx = out - buffer;
+ size_t indx = out - buffer;
+ if (indx + 10 > buffer_size) {
growBufferReentrant();
out = &buffer[indx];
@@ -716,8 +850,13 @@ xmlEncodeSpecialChars(xmlDocPtr doc ATTRIBUTE_UNUSED, const xmlChar *input) {
}
cur++;
}
- *out++ = 0;
+ *out = 0;
return(buffer);
+
+mem_error:
+ xmlEntitiesErrMemory("xmlEncodeSpecialChars: realloc failed");
+ xmlFree(buffer);
+ return(NULL);
}
/**
@@ -764,7 +903,7 @@ xmlFreeEntitiesTable(xmlEntitiesTablePtr table) {
* @ent: An entity
*
* Build a copy of an entity
- *
+ *
* Returns the new xmlEntitiesPtr or NULL in case of error.
*/
static xmlEntityPtr
@@ -800,7 +939,7 @@ xmlCopyEntity(xmlEntityPtr ent) {
* @table: An entity table
*
* Build a copy of an entity table.
- *
+ *
* Returns the new xmlEntitiesTablePtr or NULL in case of error.
*/
xmlEntitiesTablePtr
@@ -949,7 +1088,7 @@ static void
xmlDumpEntityDeclScan(xmlEntityPtr ent, xmlBufferPtr buf) {
xmlDumpEntityDecl(buf, ent);
}
-
+
/**
* xmlDumpEntitiesTable:
* @buf: An XML buffer.
diff --git a/gnulib-local/lib/libxml/entities.in.h b/gnulib-local/lib/libxml/entities.in.h
index fdd7222..47b4573 100644
--- a/gnulib-local/lib/libxml/entities.in.h
+++ b/gnulib-local/lib/libxml/entities.in.h
@@ -57,6 +57,9 @@ struct _xmlEntity {
const xmlChar *URI; /* the full URI as computed */
int owner; /* does the entity own the childrens */
int checked; /* was the entity content checked */
+ /* this is also used to count entities
+ * references done from that entity
+ * and if it contains '<' */
};
/*
@@ -72,9 +75,17 @@ typedef xmlEntitiesTable *xmlEntitiesTablePtr;
*/
#ifdef LIBXML_LEGACY_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlInitializePredefinedEntities (void);
#endif /* LIBXML_LEGACY_ENABLED */
+
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlNewEntity (xmlDocPtr doc,
+ const xmlChar *name,
+ int type,
+ const xmlChar *ExternalID,
+ const xmlChar *SystemID,
+ const xmlChar *content);
XMLPUBFUN xmlEntityPtr XMLCALL
xmlAddDocEntity (xmlDocPtr doc,
const xmlChar *name,
@@ -82,53 +93,53 @@ XMLPUBFUN xmlEntityPtr XMLCALL
const xmlChar *ExternalID,
const xmlChar *SystemID,
const xmlChar *content);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr XMLCALL
xmlAddDtdEntity (xmlDocPtr doc,
const xmlChar *name,
int type,
const xmlChar *ExternalID,
const xmlChar *SystemID,
const xmlChar *content);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr XMLCALL
xmlGetPredefinedEntity (const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
- xmlGetDocEntity (xmlDocPtr doc,
+XMLPUBFUN xmlEntityPtr XMLCALL
+ xmlGetDocEntity (const xmlDoc *doc,
const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr XMLCALL
xmlGetDtdEntity (xmlDocPtr doc,
const xmlChar *name);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr XMLCALL
xmlGetParameterEntity (xmlDocPtr doc,
const xmlChar *name);
#ifdef LIBXML_LEGACY_ENABLED
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlEncodeEntities (xmlDocPtr doc,
const xmlChar *input);
#endif /* LIBXML_LEGACY_ENABLED */
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlEncodeEntitiesReentrant(xmlDocPtr doc,
const xmlChar *input);
-XMLPUBFUN xmlChar * XMLCALL
- xmlEncodeSpecialChars (xmlDocPtr doc,
+XMLPUBFUN xmlChar * XMLCALL
+ xmlEncodeSpecialChars (const xmlDoc *doc,
const xmlChar *input);
-XMLPUBFUN xmlEntitiesTablePtr XMLCALL
+XMLPUBFUN xmlEntitiesTablePtr XMLCALL
xmlCreateEntitiesTable (void);
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlEntitiesTablePtr XMLCALL
+XMLPUBFUN xmlEntitiesTablePtr XMLCALL
xmlCopyEntitiesTable (xmlEntitiesTablePtr table);
#endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeEntitiesTable (xmlEntitiesTablePtr table);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDumpEntitiesTable (xmlBufferPtr buf,
xmlEntitiesTablePtr table);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDumpEntityDecl (xmlBufferPtr buf,
xmlEntityPtr ent);
#endif /* LIBXML_OUTPUT_ENABLED */
#ifdef LIBXML_LEGACY_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCleanupPredefinedEntities(void);
#endif /* LIBXML_LEGACY_ENABLED */
diff --git a/gnulib-local/lib/libxml/error.c b/gnulib-local/lib/libxml/error.c
index 722ffbb..9c45040 100644
--- a/gnulib-local/lib/libxml/error.c
+++ b/gnulib-local/lib/libxml/error.c
@@ -31,9 +31,9 @@ void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
\
size = 150; \
\
- while (1) { \
+ while (size < 64000) { \
va_start(ap, msg); \
- chars = vsnprintf(str, size, msg, ap); \
+ chars = vsnprintf(str, size, msg, ap); \
va_end(ap); \
if ((chars > -1) && (chars < size)) { \
if (prev_size == chars) { \
@@ -54,9 +54,9 @@ void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
}
/************************************************************************
- * *
- * Handling of out of context errors *
- * *
+ * *
+ * Handling of out of context errors *
+ * *
************************************************************************/
/**
@@ -64,7 +64,7 @@ void XMLCDECL xmlGenericErrorDefaultFunc (void *ctx ATTRIBUTE_UNUSED,
* @ctx: an error context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Default handler for out of context error messages.
*/
void XMLCDECL
@@ -82,7 +82,7 @@ xmlGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
/**
* initGenericErrorDefaultFunc:
* @handler: the handler
- *
+ *
* Set or reset (if NULL) the default handler for generic errors
* to the builtin error function.
*/
@@ -132,20 +132,20 @@ xmlSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
*/
void
xmlSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
- xmlGenericErrorContext = ctx;
+ xmlStructuredErrorContext = ctx;
xmlStructuredError = handler;
}
/************************************************************************
- * *
- * Handling of parsing errors *
- * *
+ * *
+ * Handling of parsing errors *
+ * *
************************************************************************/
/**
* xmlParserPrintFileInfo:
* @input: an xmlParserInputPtr input
- *
+ *
* Displays the associated file and line informations for the current input
*/
@@ -165,19 +165,21 @@ xmlParserPrintFileInfo(xmlParserInputPtr input) {
/**
* xmlParserPrintFileContext:
* @input: an xmlParserInputPtr input
- *
+ *
* Displays current context within the input content for error tracking
*/
static void
-xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
+xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
xmlGenericErrorFunc channel, void *data ) {
const xmlChar *cur, *base;
unsigned int n, col; /* GCC warns if signed, because compared with sizeof() */
xmlChar content[81]; /* space for 80 chars + line terminator */
xmlChar *ctnt;
- if (input == NULL) return;
+ if ((input == NULL) || (input->cur == NULL) ||
+ (*input->cur == 0)) return;
+
cur = input->cur;
base = input->base;
/* skip backwards over any end-of-lines */
@@ -186,8 +188,8 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
}
n = 0;
/* search backwards for beginning-of-line (to max buff size) */
- while ((n++ < (sizeof(content)-1)) && (cur > base) &&
- (*(cur) != '\n') && (*(cur) != '\r'))
+ while ((n++ < (sizeof(content)-1)) && (cur > base) &&
+ (*(cur) != '\n') && (*(cur) != '\r'))
cur--;
if ((*(cur) == '\n') || (*(cur) == '\r')) cur++;
/* calculate the error position in terms of the current position */
@@ -196,8 +198,8 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
n = 0;
ctnt = content;
/* copy selected text to our buffer */
- while ((*cur != 0) && (*(cur) != '\n') &&
- (*(cur) != '\r') && (n < sizeof(content)-1)) {
+ while ((*cur != 0) && (*(cur) != '\n') &&
+ (*(cur) != '\r') && (n < sizeof(content)-1)) {
*ctnt++ = *cur++;
n++;
}
@@ -221,7 +223,7 @@ xmlParserPrintFileContextInternal(xmlParserInputPtr input ,
/**
* xmlParserPrintFileContext:
* @input: an xmlParserInputPtr input
- *
+ *
* Displays current context within the input content for error tracking
*/
void
@@ -292,7 +294,10 @@ xmlReportError(xmlErrorPtr err, xmlParserCtxtPtr ctxt, const char *str,
} else {
if (file != NULL)
channel(data, "%s:%d: ", file, line);
- else if ((line != 0) && (domain == XML_FROM_PARSER))
+ else if ((line != 0) &&
+ ((domain == XML_FROM_PARSER) || (domain == XML_FROM_SCHEMASV)||
+ (domain == XML_FROM_SCHEMASP)||(domain == XML_FROM_DTD) ||
+ (domain == XML_FROM_RELAXNGP)||(domain == XML_FROM_RELAXNGV)))
channel(data, "Entity: line %d: ", line);
}
if (name != NULL) {
@@ -360,6 +365,15 @@ xmlReportError(xmlErrorPtr err, xmlParserCtxtPtr ctxt, const char *str,
case XML_FROM_I18N:
channel(data, "encoding ");
break;
+ case XML_FROM_SCHEMATRONV:
+ channel(data, "schematron ");
+ break;
+ case XML_FROM_BUFFER:
+ channel(data, "internal buffer ");
+ break;
+ case XML_FROM_URI:
+ channel(data, "URI ");
+ break;
default:
break;
}
@@ -429,7 +443,7 @@ xmlReportError(xmlErrorPtr err, xmlParserCtxtPtr ctxt, const char *str,
* @str2: extra string info
* @str3: extra string info
* @int1: extra int info
- * @col: column number of the error or 0 if N/A
+ * @col: column number of the error or 0 if N/A
* @msg: the message to display/transmit
* @...: extra parameters for the message display
*
@@ -452,6 +466,8 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
xmlErrorPtr to = &xmlLastError;
xmlNodePtr baseptr = NULL;
+ if (code == XML_ERR_OK)
+ return;
if ((xmlGetWarningsDefaultValue == 0) && (level == XML_ERR_WARNING))
return;
if ((domain == XML_FROM_PARSER) || (domain == XML_FROM_HTML) ||
@@ -459,8 +475,11 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
(domain == XML_FROM_IO) || (domain == XML_FROM_VALID)) {
ctxt = (xmlParserCtxtPtr) ctx;
if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
- (ctxt->sax->initialized == XML_SAX2_MAGIC))
+ (ctxt->sax->initialized == XML_SAX2_MAGIC) &&
+ (ctxt->sax->serror != NULL)) {
schannel = ctxt->sax->serror;
+ data = ctxt->userData;
+ }
}
/*
* Check if structured error handler set
@@ -471,18 +490,8 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
* if user has defined handler, change data ptr to user's choice
*/
if (schannel != NULL)
- data = xmlGenericErrorContext;
+ data = xmlStructuredErrorContext;
}
- if ((domain == XML_FROM_VALID) &&
- ((channel == xmlParserValidityError) ||
- (channel == xmlParserValidityWarning))) {
- ctxt = (xmlParserCtxtPtr) ctx;
- if ((schannel == NULL) && (ctxt != NULL) && (ctxt->sax != NULL) &&
- (ctxt->sax->initialized == XML_SAX2_MAGIC))
- schannel = ctxt->sax->serror;
- }
- if (code == XML_ERR_OK)
- return;
/*
* Formatting the message
*/
@@ -526,6 +535,8 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
if ((node != NULL) && (node->type == XML_ELEMENT_NODE))
line = node->line;
+ if ((line == 0) || (line == 65535))
+ line = xmlGetLineNo(node);
}
/*
@@ -573,7 +584,6 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
if ((to->file == NULL) && (node != NULL) && (node->doc != NULL)) {
to->file = (char *) xmlStrdup(node->doc->URL);
}
- file = to->file;
}
to->line = line;
if (str1 != NULL)
@@ -590,27 +600,28 @@ __xmlRaiseError(xmlStructuredErrorFunc schannel,
if (to != &xmlLastError)
xmlCopyError(to,&xmlLastError);
+ if (schannel != NULL) {
+ schannel(data, to);
+ return;
+ }
+
/*
* Find the callback channel if channel param is NULL
*/
- if ((ctxt != NULL) && (channel == NULL) && (xmlStructuredError == NULL) && (ctxt->sax != NULL)) {
+ if ((ctxt != NULL) && (channel == NULL) &&
+ (xmlStructuredError == NULL) && (ctxt->sax != NULL)) {
if (level == XML_ERR_WARNING)
channel = ctxt->sax->warning;
else
channel = ctxt->sax->error;
data = ctxt->userData;
} else if (channel == NULL) {
- if (xmlStructuredError != NULL)
- schannel = xmlStructuredError;
- else
- channel = xmlGenericError;
- if (!data) {
- data = xmlGenericErrorContext;
- }
- }
- if (schannel != NULL) {
- schannel(data, to);
- return;
+ channel = xmlGenericError;
+ if (ctxt != NULL) {
+ data = ctxt;
+ } else {
+ data = xmlGenericErrorContext;
+ }
}
if (channel == NULL)
return;
@@ -662,7 +673,7 @@ __xmlSimpleError(int domain, int code, xmlNodePtr node,
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format an error messages, gives file, line, position and
* extra parameters.
*/
@@ -705,7 +716,7 @@ xmlParserError(void *ctx, const char *msg, ...)
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format a warning messages, gives file, line, position and
* extra parameters.
*/
@@ -726,7 +737,7 @@ xmlParserWarning(void *ctx, const char *msg, ...)
}
xmlParserPrintFileInfo(input);
}
-
+
xmlGenericError(xmlGenericErrorContext, "warning: ");
XML_GET_VAR_STR(msg, str);
xmlGenericError(xmlGenericErrorContext, "%s", str);
@@ -744,9 +755,9 @@ xmlParserWarning(void *ctx, const char *msg, ...)
}
/************************************************************************
- * *
- * Handling of validation errors *
- * *
+ * *
+ * Handling of validation errors *
+ * *
************************************************************************/
/**
@@ -754,7 +765,7 @@ xmlParserWarning(void *ctx, const char *msg, ...)
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format an validity error messages, gives file,
* line, position and extra parameters.
*/
@@ -772,7 +783,7 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
input = ctxt->input;
if ((input->filename == NULL) && (ctxt->inputNr > 1))
input = ctxt->inputTab[ctxt->inputNr - 2];
-
+
if (had_info == 0) {
xmlParserPrintFileInfo(input);
}
@@ -798,7 +809,7 @@ xmlParserValidityError(void *ctx, const char *msg, ...)
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format a validity warning messages, gives file, line,
* position and extra parameters.
*/
@@ -817,7 +828,7 @@ xmlParserValidityWarning(void *ctx, const char *msg, ...)
xmlParserPrintFileInfo(input);
}
-
+
xmlGenericError(xmlGenericErrorContext, "validity warning: ");
XML_GET_VAR_STR(msg, str);
xmlGenericError(xmlGenericErrorContext, "%s", str);
@@ -927,6 +938,7 @@ xmlCtxtResetLastError(void *ctx)
if (ctxt == NULL)
return;
+ ctxt->errNo = XML_ERR_OK;
if (ctxt->lastError.code == XML_ERR_OK)
return;
xmlResetError(&ctxt->lastError);
diff --git a/gnulib-local/lib/libxml/globals.c b/gnulib-local/lib/libxml/globals.c
index c104a1a..e351b03 100644
--- a/gnulib-local/lib/libxml/globals.c
+++ b/gnulib-local/lib/libxml/globals.c
@@ -46,7 +46,8 @@ static xmlMutexPtr xmlThrDefMutex = NULL;
*/
void xmlInitGlobals(void)
{
- xmlThrDefMutex = xmlNewMutex();
+ if (xmlThrDefMutex == NULL)
+ xmlThrDefMutex = xmlNewMutex();
}
/**
@@ -60,12 +61,13 @@ void xmlCleanupGlobals(void)
xmlFreeMutex(xmlThrDefMutex);
xmlThrDefMutex = NULL;
}
+ __xmlGlobalInitMutexDestroy();
}
/************************************************************************
- * *
+ * *
* All the user accessible global variables of the library *
- * *
+ * *
************************************************************************/
/*
@@ -147,6 +149,7 @@ xmlStrdupFunc xmlMemStrdup = (xmlStrdupFunc) xmlStrdup;
#undef xmlGenericError
#undef xmlStructuredError
#undef xmlGenericErrorContext
+#undef xmlStructuredErrorContext
#undef xmlGetWarningsDefaultValue
#undef xmlIndentTreeOutput
#undef xmlTreeIndentString
@@ -243,7 +246,7 @@ static int xmlPedanticParserDefaultValueThrDef = 0;
* xmlLineNumbersDefaultValue:
*
* Global setting, indicate that the parser should store the line number
- * in the content field of elements in the DOM tree.
+ * in the content field of elements in the DOM tree.
* Disabled by default since this may not be safe for old classes of
* applicaton.
*/
@@ -313,6 +316,13 @@ static xmlStructuredErrorFunc xmlStructuredErrorThrDef = NULL;
*/
void *xmlGenericErrorContext = NULL;
static void *xmlGenericErrorContextThrDef = NULL;
+/**
+ * xmlStructuredErrorContext:
+ *
+ * Global setting passed to structured error callbacks
+ */
+void *xmlStructuredErrorContext = NULL;
+static void *xmlStructuredErrorContextThrDef = NULL;
xmlError xmlLastError;
/*
@@ -499,7 +509,7 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
#if defined(LIBXML_DOCB_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
initdocbDefaultSAXHandler(&gs->docbDefaultSAXHandler);
#endif
-#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED)
+#if defined(LIBXML_HTML_ENABLED) && defined(LIBXML_LEGACY_ENABLED) && defined(LIBXML_SAX1_ENABLED)
inithtmlDefaultSAXHandler(&gs->htmlDefaultSAXHandler);
#endif
@@ -513,7 +523,7 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
gs->xmlDefaultSAXLocator.getSystemId = xmlSAX2GetSystemId;
gs->xmlDefaultSAXLocator.getLineNumber = xmlSAX2GetLineNumber;
gs->xmlDefaultSAXLocator.getColumnNumber = xmlSAX2GetColumnNumber;
- gs->xmlDoValidityCheckingDefaultValue =
+ gs->xmlDoValidityCheckingDefaultValue =
xmlDoValidityCheckingDefaultValueThrDef;
#if defined(DEBUG_MEMORY_LOCATION) | defined(DEBUG_MEMORY)
gs->xmlFree = (xmlFreeFunc) xmlMemFree;
@@ -538,12 +548,13 @@ xmlInitializeGlobalState(xmlGlobalStatePtr gs)
gs->xmlParserVersion = LIBXML_VERSION_STRING;
gs->xmlPedanticParserDefaultValue = xmlPedanticParserDefaultValueThrDef;
gs->xmlSaveNoEmptyTags = xmlSaveNoEmptyTagsThrDef;
- gs->xmlSubstituteEntitiesDefaultValue =
+ gs->xmlSubstituteEntitiesDefaultValue =
xmlSubstituteEntitiesDefaultValueThrDef;
gs->xmlGenericError = xmlGenericErrorThrDef;
gs->xmlStructuredError = xmlStructuredErrorThrDef;
gs->xmlGenericErrorContext = xmlGenericErrorContextThrDef;
+ gs->xmlStructuredErrorContext = xmlStructuredErrorContextThrDef;
gs->xmlRegisterNodeDefaultValue = xmlRegisterNodeDefaultValueThrDef;
gs->xmlDeregisterNodeDefaultValue = xmlDeregisterNodeDefaultValueThrDef;
@@ -572,7 +583,7 @@ xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
void
xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler) {
xmlMutexLock(xmlThrDefMutex);
- xmlGenericErrorContextThrDef = ctx;
+ xmlStructuredErrorContextThrDef = ctx;
xmlStructuredErrorThrDef = handler;
xmlMutexUnlock(xmlThrDefMutex);
}
@@ -589,7 +600,7 @@ xmlRegisterNodeFunc
xmlRegisterNodeDefault(xmlRegisterNodeFunc func)
{
xmlRegisterNodeFunc old = xmlRegisterNodeDefaultValue;
-
+
__xmlRegisterCallbacks = 1;
xmlRegisterNodeDefaultValue = func;
return(old);
@@ -599,10 +610,10 @@ xmlRegisterNodeFunc
xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func)
{
xmlRegisterNodeFunc old;
-
+
xmlMutexLock(xmlThrDefMutex);
old = xmlRegisterNodeDefaultValueThrDef;
-
+
__xmlRegisterCallbacks = 1;
xmlRegisterNodeDefaultValueThrDef = func;
xmlMutexUnlock(xmlThrDefMutex);
@@ -622,7 +633,7 @@ xmlDeregisterNodeFunc
xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func)
{
xmlDeregisterNodeFunc old = xmlDeregisterNodeDefaultValue;
-
+
__xmlRegisterCallbacks = 1;
xmlDeregisterNodeDefaultValue = func;
return(old);
@@ -635,7 +646,7 @@ xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func)
xmlMutexLock(xmlThrDefMutex);
old = xmlDeregisterNodeDefaultValueThrDef;
-
+
__xmlRegisterCallbacks = 1;
xmlDeregisterNodeDefaultValueThrDef = func;
xmlMutexUnlock(xmlThrDefMutex);
@@ -647,7 +658,7 @@ xmlParserInputBufferCreateFilenameFunc
xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func)
{
xmlParserInputBufferCreateFilenameFunc old;
-
+
xmlMutexLock(xmlThrDefMutex);
old = xmlParserInputBufferCreateFilenameValueThrDef;
if (old == NULL) {
@@ -664,7 +675,7 @@ xmlOutputBufferCreateFilenameFunc
xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func)
{
xmlOutputBufferCreateFilenameFunc old;
-
+
xmlMutexLock(xmlThrDefMutex);
old = xmlOutputBufferCreateFilenameValueThrDef;
#ifdef LIBXML_OUTPUT_ENABLED
@@ -721,7 +732,7 @@ __xmlMalloc(void){
if (IS_MAIN_THREAD)
return (&xmlMalloc);
else
- return (&xmlGetGlobalState()->xmlMalloc);
+ return (&xmlGetGlobalState()->xmlMalloc);
}
#undef xmlMallocAtomic
@@ -875,6 +886,15 @@ __xmlGenericErrorContext(void) {
return (&xmlGetGlobalState()->xmlGenericErrorContext);
}
+#undef xmlStructuredErrorContext
+void * *
+__xmlStructuredErrorContext(void) {
+ if (IS_MAIN_THREAD)
+ return (&xmlStructuredErrorContext);
+ else
+ return (&xmlGetGlobalState()->xmlStructuredErrorContext);
+}
+
#undef xmlGetWarningsDefaultValue
int *
__xmlGetWarningsDefaultValue(void) {
@@ -909,7 +929,7 @@ int xmlThrDefIndentTreeOutput(int v) {
return ret;
}
-#undef xmlTreeIndentString
+#undef xmlTreeIndentString
const char * *
__xmlTreeIndentString(void) {
if (IS_MAIN_THREAD)
diff --git a/gnulib-local/lib/libxml/globals.in.h b/gnulib-local/lib/libxml/globals.in.h
index 1173a8f..a9305aa 100644
--- a/gnulib-local/lib/libxml/globals.in.h
+++ b/gnulib-local/lib/libxml/globals.in.h
@@ -28,8 +28,36 @@ extern "C" {
XMLPUBFUN void XMLCALL xmlInitGlobals(void);
XMLPUBFUN void XMLCALL xmlCleanupGlobals(void);
-typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI, xmlCharEncoding enc);
-typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI, xmlCharEncodingHandlerPtr encoder, int compression);
+/**
+ * xmlParserInputBufferCreateFilenameFunc:
+ * @URI: the URI to read from
+ * @enc: the requested source encoding
+ *
+ * Signature for the function doing the lookup for a suitable input method
+ * corresponding to an URI.
+ *
+ * Returns the new xmlParserInputBufferPtr in case of success or NULL if no
+ * method was found.
+ */
+typedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI,
+ xmlCharEncoding enc);
+
+
+/**
+ * xmlOutputBufferCreateFilenameFunc:
+ * @URI: the URI to write to
+ * @enc: the requested target encoding
+ *
+ * Signature for the function doing the lookup for a suitable output method
+ * corresponding to an URI.
+ *
+ * Returns the new xmlOutputBufferPtr in case of success or NULL if no
+ * method was found.
+ */
+typedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI,
+ xmlCharEncodingHandlerPtr encoder,
+ int compression);
+
XMLPUBFUN xmlParserInputBufferCreateFilenameFunc
XMLCALL xmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func);
XMLPUBFUN xmlOutputBufferCreateFilenameFunc
@@ -52,6 +80,7 @@ XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc
#undef xmlGenericError
#undef xmlStructuredError
#undef xmlGenericErrorContext
+#undef xmlStructuredErrorContext
#undef xmlGetWarningsDefaultValue
#undef xmlIndentTreeOutput
#undef xmlTreeIndentString
@@ -73,12 +102,24 @@ XMLCALL xmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc
#undef xmlParserInputBufferCreateFilenameValue
#undef xmlOutputBufferCreateFilenameValue
+/**
+ * xmlRegisterNodeFunc:
+ * @node: the current node
+ *
+ * Signature for the registration callback of a created node
+ */
typedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);
+/**
+ * xmlDeregisterNodeFunc:
+ * @node: the current node
+ *
+ * Signature for the deregistration callback of a discarded node
+ */
typedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);
typedef struct _xmlGlobalState xmlGlobalState;
typedef xmlGlobalState *xmlGlobalStatePtr;
-struct _xmlGlobalState
+struct _xmlGlobalState
{
const char *xmlParserVersion;
@@ -114,14 +155,16 @@ struct _xmlGlobalState
int xmlIndentTreeOutput;
const char *xmlTreeIndentString;
- xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
- xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
+ xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;
+ xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
xmlMallocFunc xmlMallocAtomic;
xmlError xmlLastError;
xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;
xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;
+
+ void *xmlStructuredErrorContext;
};
#ifdef __cplusplus
@@ -143,10 +186,11 @@ XMLPUBFUN xmlRegisterNodeFunc XMLCALL xmlThrDefRegisterNodeDefault(xmlRegisterNo
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);
XMLPUBFUN xmlDeregisterNodeFunc XMLCALL xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);
-XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL
+XMLPUBFUN xmlOutputBufferCreateFilenameFunc XMLCALL
xmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);
-XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL
- xmlThrDefParserInputBufferCreateFilenameDefault(xmlParserInputBufferCreateFilenameFunc func);
+XMLPUBFUN xmlParserInputBufferCreateFilenameFunc XMLCALL
+ xmlThrDefParserInputBufferCreateFilenameDefault(
+ xmlParserInputBufferCreateFilenameFunc func);
/** DOC_DISABLE */
/*
@@ -258,7 +302,8 @@ XMLPUBFUN xmlBufferAllocationScheme * XMLCALL __xmlBufferAllocScheme(void);
#else
XMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme;
#endif
-XMLPUBFUN xmlBufferAllocationScheme XMLCALL xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
+XMLPUBFUN xmlBufferAllocationScheme XMLCALL
+ xmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);
XMLPUBFUN int * XMLCALL __xmlDefaultBufferSize(void);
#ifdef LIBXML_THREAD_ENABLED
@@ -318,6 +363,14 @@ XMLPUBFUN void * * XMLCALL __xmlGenericErrorContext(void);
XMLPUBVAR void * xmlGenericErrorContext;
#endif
+XMLPUBFUN void * * XMLCALL __xmlStructuredErrorContext(void);
+#ifdef LIBXML_THREAD_ENABLED
+#define xmlStructuredErrorContext \
+(*(__xmlStructuredErrorContext()))
+#else
+XMLPUBVAR void * xmlStructuredErrorContext;
+#endif
+
XMLPUBFUN int * XMLCALL __xmlGetWarningsDefaultValue(void);
#ifdef LIBXML_THREAD_ENABLED
#define xmlGetWarningsDefaultValue \
@@ -432,7 +485,8 @@ XMLPUBFUN xmlDeregisterNodeFunc * XMLCALL __xmlDeregisterNodeDefaultValue(void);
XMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;
#endif
-XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL __xmlParserInputBufferCreateFilenameValue(void);
+XMLPUBFUN xmlParserInputBufferCreateFilenameFunc * XMLCALL \
+ __xmlParserInputBufferCreateFilenameValue(void);
#ifdef LIBXML_THREAD_ENABLED
#define xmlParserInputBufferCreateFilenameValue \
(*(__xmlParserInputBufferCreateFilenameValue()))
diff --git a/gnulib-local/lib/libxml/hash.c b/gnulib-local/lib/libxml/hash.c
index e92a5a0..f9a2017 100644
--- a/gnulib-local/lib/libxml/hash.c
+++ b/gnulib-local/lib/libxml/hash.c
@@ -3,7 +3,7 @@
*
* Reference: Your favorite introductory book on algorithms
*
- * Copyright (C) 2000 Bjorn Reese and Daniel Veillard.
+ * Copyright (C) 2000,2012 Bjorn Reese and Daniel Veillard.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -21,6 +21,22 @@
#include "libxml.h"
#include <string.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+
+/*
+ * Following http://www.ocert.org/advisories/ocert-2011-003.html
+ * it seems that having hash randomization might be a good idea
+ * when using XML with untrusted data
+ */
+#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME)
+#define HASH_RANDOMIZATION
+#endif
+
#include <libxml/parser.h>
#include <libxml/hash.h>
#include <libxml/xmlmemory.h>
@@ -53,6 +69,9 @@ struct _xmlHashTable {
int size;
int nbElems;
xmlDictPtr dict;
+#ifdef HASH_RANDOMIZATION
+ int random_seed;
+#endif
};
/*
@@ -64,18 +83,23 @@ xmlHashComputeKey(xmlHashTablePtr table, const xmlChar *name,
const xmlChar *name2, const xmlChar *name3) {
unsigned long value = 0L;
char ch;
-
+
+#ifdef HASH_RANDOMIZATION
+ value = table->random_seed;
+#endif
if (name != NULL) {
value += 30 * (*name);
while ((ch = *name++) != 0) {
value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
}
}
+ value = value ^ ((value << 5) + (value >> 3));
if (name2 != NULL) {
while ((ch = *name2++) != 0) {
value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
}
}
+ value = value ^ ((value << 5) + (value >> 3));
if (name3 != NULL) {
while ((ch = *name3++) != 0) {
value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
@@ -91,7 +115,10 @@ xmlHashComputeQKey(xmlHashTablePtr table,
const xmlChar *prefix3, const xmlChar *name3) {
unsigned long value = 0L;
char ch;
-
+
+#ifdef HASH_RANDOMIZATION
+ value = table->random_seed;
+#endif
if (prefix != NULL)
value += 30 * (*prefix);
else
@@ -108,6 +135,7 @@ xmlHashComputeQKey(xmlHashTablePtr table,
value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
}
}
+ value = value ^ ((value << 5) + (value >> 3));
if (prefix2 != NULL) {
while ((ch = *prefix2++) != 0) {
value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
@@ -119,6 +147,7 @@ xmlHashComputeQKey(xmlHashTablePtr table,
value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
}
}
+ value = value ^ ((value << 5) + (value >> 3));
if (prefix3 != NULL) {
while ((ch = *prefix3++) != 0) {
value = value ^ ((value << 5) + (value >> 3) + (unsigned long)ch);
@@ -144,10 +173,10 @@ xmlHashComputeQKey(xmlHashTablePtr table,
xmlHashTablePtr
xmlHashCreate(int size) {
xmlHashTablePtr table;
-
+
if (size <= 0)
size = 256;
-
+
table = xmlMalloc(sizeof(xmlHashTable));
if (table) {
table->dict = NULL;
@@ -155,8 +184,11 @@ xmlHashCreate(int size) {
table->nbElems = 0;
table->table = xmlMalloc(size * sizeof(xmlHashEntry));
if (table->table) {
- memset(table->table, 0, size * sizeof(xmlHashEntry));
- return(table);
+ memset(table->table, 0, size * sizeof(xmlHashEntry));
+#ifdef HASH_RANDOMIZATION
+ table->random_seed = __xmlRandom();
+#endif
+ return(table);
}
xmlFree(table);
}
@@ -202,7 +234,7 @@ xmlHashGrow(xmlHashTablePtr table, int size) {
#ifdef DEBUG_GROW
unsigned long nbElem = 0;
#endif
-
+
if (table == NULL)
return(-1);
if (size < 8)
@@ -214,7 +246,7 @@ xmlHashGrow(xmlHashTablePtr table, int size) {
oldtable = table->table;
if (oldtable == NULL)
return(-1);
-
+
table->table = xmlMalloc(size * sizeof(xmlHashEntry));
if (table->table == NULL) {
table->table = oldtable;
@@ -224,13 +256,13 @@ xmlHashGrow(xmlHashTablePtr table, int size) {
table->size = size;
/* If the two loops are merged, there would be situations where
- a new entry needs to allocated and data copied into it from
+ a new entry needs to allocated and data copied into it from
the main table. So instead, we run through the array twice, first
copying all the elements in the main array (where we can't get
conflicts) and then the rest, so we only free (and don't allocate)
*/
for (i = 0; i < oldsize; i++) {
- if (oldtable[i].valid == 0)
+ if (oldtable[i].valid == 0)
continue;
key = xmlHashComputeKey(table, oldtable[i].name, oldtable[i].name2,
oldtable[i].name3);
@@ -254,8 +286,8 @@ xmlHashGrow(xmlHashTablePtr table, int size) {
table->table[key].next = NULL;
xmlFree(iter);
} else {
- iter->next = table->table[key].next;
- table->table[key].next = iter;
+ iter->next = table->table[key].next;
+ table->table[key].next = iter;
}
#ifdef DEBUG_GROW
@@ -320,7 +352,6 @@ xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f) {
inside_table = 0;
iter = next;
}
- inside_table = 0;
}
xmlFree(table->table);
}
@@ -572,7 +603,7 @@ xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name,
entry->valid = 1;
- if (insert != NULL)
+ if (insert != NULL)
insert->next = entry;
table->nbElems++;
@@ -721,7 +752,7 @@ xmlHashUpdateEntry3(xmlHashTablePtr table, const xmlChar *name,
* Returns the a pointer to the userdata
*/
void *
-xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name,
+xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name,
const xmlChar *name2, const xmlChar *name3) {
unsigned long key;
xmlHashEntryPtr entry;
@@ -794,14 +825,14 @@ typedef struct {
void *data;
} stubData;
-static void
-stubHashScannerFull (void *payload, void *data, const xmlChar *name,
+static void
+stubHashScannerFull (void *payload, void *data, const xmlChar *name,
const xmlChar *name2 ATTRIBUTE_UNUSED,
const xmlChar *name3 ATTRIBUTE_UNUSED) {
stubData *stubdata = (stubData *) data;
stubdata->hashscanner (payload, stubdata->data, (xmlChar *) name);
-}
-
+}
+
/**
* xmlHashScan:
* @table: the hash table
@@ -814,7 +845,7 @@ void
xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data) {
stubData stubdata;
stubdata.data = data;
- stubdata.hashscanner = f;
+ stubdata.hashscanner = f;
xmlHashScanFull (table, stubHashScannerFull, &stubdata);
}
@@ -828,7 +859,7 @@ xmlHashScan(xmlHashTablePtr table, xmlHashScanner f, void *data) {
*/
void
xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerFull f, void *data) {
- int i;
+ int i, nb;
xmlHashEntryPtr iter;
xmlHashEntryPtr next;
@@ -839,15 +870,26 @@ xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerFull f, void *data) {
if (table->table) {
for(i = 0; i < table->size; i++) {
- if (table->table[i].valid == 0)
+ if (table->table[i].valid == 0)
continue;
iter = &(table->table[i]);
while (iter) {
next = iter->next;
+ nb = table->nbElems;
if ((f != NULL) && (iter->payload != NULL))
f(iter->payload, data, iter->name,
iter->name2, iter->name3);
- iter = next;
+ if (nb != table->nbElems) {
+ /* table was modified by the callback, be careful */
+ if (iter == &(table->table[i])) {
+ if (table->table[i].valid == 0)
+ iter = NULL;
+ if (table->table[i].next != next)
+ iter = &(table->table[i]);
+ } else
+ iter = next;
+ } else
+ iter = next;
}
}
}
@@ -867,7 +909,7 @@ xmlHashScanFull(xmlHashTablePtr table, xmlHashScannerFull f, void *data) {
* the comparison is considered to match.
*/
void
-xmlHashScan3(xmlHashTablePtr table, const xmlChar *name,
+xmlHashScan3(xmlHashTablePtr table, const xmlChar *name,
const xmlChar *name2, const xmlChar *name3,
xmlHashScanner f, void *data) {
xmlHashScanFull3 (table, name, name2, name3,
@@ -888,7 +930,7 @@ xmlHashScan3(xmlHashTablePtr table, const xmlChar *name,
* the comparison is considered to match.
*/
void
-xmlHashScanFull3(xmlHashTablePtr table, const xmlChar *name,
+xmlHashScanFull3(xmlHashTablePtr table, const xmlChar *name,
const xmlChar *name2, const xmlChar *name3,
xmlHashScannerFull f, void *data) {
int i;
@@ -942,6 +984,9 @@ xmlHashCopy(xmlHashTablePtr table, xmlHashCopier f) {
return(NULL);
ret = xmlHashCreate(table->size);
+ if (ret == NULL)
+ return(NULL);
+
if (table->table) {
for(i = 0; i < table->size; i++) {
if (table->table[i].valid == 0)
diff --git a/gnulib-local/lib/libxml/hash.in.h b/gnulib-local/lib/libxml/hash.in.h
index 7fe4be7..dc8ab7e 100644
--- a/gnulib-local/lib/libxml/hash.in.h
+++ b/gnulib-local/lib/libxml/hash.in.h
@@ -1,7 +1,7 @@
/*
* Summary: Chained hash tables
- * Description: This module implements the hash table support used in
- * various places in the library.
+ * Description: This module implements the hash table support used in
+ * various places in the library.
*
* Copy: See Copyright for the status of this software.
*
@@ -108,40 +108,40 @@ XMLPUBFUN xmlHashTablePtr XMLCALL
XMLPUBFUN xmlHashTablePtr XMLCALL
xmlHashCreateDict(int size,
xmlDictPtr dict);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlHashFree (xmlHashTablePtr table,
xmlHashDeallocator f);
/*
* Add a new entry to the hash table.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlHashAddEntry (xmlHashTablePtr table,
const xmlChar *name,
void *userdata);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlHashUpdateEntry(xmlHashTablePtr table,
const xmlChar *name,
void *userdata,
xmlHashDeallocator f);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlHashAddEntry2(xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *name2,
void *userdata);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlHashUpdateEntry2(xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *name2,
void *userdata,
xmlHashDeallocator f);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlHashAddEntry3(xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *name2,
const xmlChar *name3,
void *userdata);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlHashUpdateEntry3(xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *name2,
@@ -152,13 +152,13 @@ XMLPUBFUN int XMLCALL
/*
* Remove an entry from the hash table.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,
xmlHashDeallocator f);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,
const xmlChar *name2, xmlHashDeallocator f);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,
const xmlChar *name2, const xmlChar *name3,
xmlHashDeallocator f);
@@ -166,29 +166,29 @@ XMLPUBFUN int XMLCALL
/*
* Retrieve the userdata.
*/
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlHashLookup (xmlHashTablePtr table,
const xmlChar *name);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlHashLookup2 (xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *name2);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlHashLookup3 (xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *name2,
const xmlChar *name3);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlHashQLookup (xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *prefix);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlHashQLookup2 (xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *prefix,
const xmlChar *name2,
const xmlChar *prefix2);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlHashQLookup3 (xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *prefix,
@@ -200,27 +200,27 @@ XMLPUBFUN void * XMLCALL
/*
* Helpers.
*/
-XMLPUBFUN xmlHashTablePtr XMLCALL
+XMLPUBFUN xmlHashTablePtr XMLCALL
xmlHashCopy (xmlHashTablePtr table,
xmlHashCopier f);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlHashSize (xmlHashTablePtr table);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlHashScan (xmlHashTablePtr table,
xmlHashScanner f,
void *data);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlHashScan3 (xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *name2,
const xmlChar *name3,
xmlHashScanner f,
void *data);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlHashScanFull (xmlHashTablePtr table,
xmlHashScannerFull f,
void *data);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlHashScanFull3(xmlHashTablePtr table,
const xmlChar *name,
const xmlChar *name2,
diff --git a/gnulib-local/lib/libxml/legacy.c b/gnulib-local/lib/libxml/legacy.c
index e75178a..86362bf 100644
--- a/gnulib-local/lib/libxml/legacy.c
+++ b/gnulib-local/lib/libxml/legacy.c
@@ -393,7 +393,7 @@ xmlSetFeature(xmlParserCtxtPtr ctxt, const char *name, void *value)
* @end: an end marker xmlChar, 0 if none
* @end2: an end marker xmlChar, 0 if none
* @end3: an end marker xmlChar, 0 if none
- *
+ *
* This function is deprecated, we now always process entities content
* through xmlStringDecodeEntities
*
@@ -456,7 +456,7 @@ xmlNamespaceParseNCName(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
/**
* xmlNamespaceParseQName:
* @ctxt: an XML parser context
- * @prefix: a xmlChar **
+ * @prefix: a xmlChar **
*
* TODO: this seems not in use anymore, the namespace handling is done on
* top of the SAX interfaces, i.e. not on raw input.
@@ -603,7 +603,7 @@ xmlScanName(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
/**
* xmlParserHandleReference:
* @ctxt: the parser context
- *
+ *
* TODO: Remove, now deprecated ... the test is done directly in the
* content parsing
* routines.
@@ -615,7 +615,7 @@ xmlScanName(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
* [ WFC: Entity Declared ]
* 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.
+ * of the following entities: amp, lt, gt, apos, quot.
*
* [ WFC: Parsed Entity ]
* An entity reference must not contain the name of an unparsed entity
@@ -624,7 +624,7 @@ xmlScanName(xmlParserCtxtPtr ctxt ATTRIBUTE_UNUSED)
* '&#x' [0-9a-fA-F]+ ';'
*
* A PEReference may have been detected in the current input stream
- * the handling is done accordingly to
+ * the handling is done accordingly to
* http://www.w3.org/TR/REC-xml#entproc
*/
void
@@ -693,7 +693,7 @@ xmlNewGlobalNs(xmlDocPtr doc ATTRIBUTE_UNUSED,
/**
* xmlUpgradeOldNs:
* @doc: a document pointer
- *
+ *
* Upgrade old style Namespaces (PI) and move them to the root of the document.
* DEPRECATED
*/
@@ -719,7 +719,7 @@ xmlUpgradeOldNs(xmlDocPtr doc ATTRIBUTE_UNUSED)
*
* People must migrate their code to xmlEncodeEntitiesReentrant !
* This routine will issue a warning when encountered.
- *
+ *
* Returns NULL
*/
const xmlChar *
@@ -740,7 +740,7 @@ xmlEncodeEntities(xmlDocPtr doc ATTRIBUTE_UNUSED,
/************************************************************************
* *
- * Old set of SAXv1 functions *
+ * Old set of SAXv1 functions *
* *
************************************************************************/
static int deprecated_v1_msg = 0;
@@ -961,8 +961,8 @@ getParameterEntity(void *ctx, const xmlChar * name)
/**
* entityDecl:
* @ctx: the user data (XML parser context)
- * @name: the entity name
- * @type: the entity type
+ * @name: the entity name
+ * @type: the entity type
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
* @content: the entity value (without processing).
@@ -983,8 +983,8 @@ entityDecl(void *ctx, const xmlChar * name, int type,
* attributeDecl:
* @ctx: the user data (XML parser context)
* @elem: the name of the element
- * @fullname: the attribute name
- * @type: the attribute type
+ * @fullname: the attribute name
+ * @type: the attribute type
* @def: the type of default value
* @defaultValue: the attribute default value
* @tree: the tree of enumerated value set
@@ -1005,8 +1005,8 @@ attributeDecl(void *ctx, const xmlChar * elem, const xmlChar * fullname,
/**
* elementDecl:
* @ctx: the user data (XML parser context)
- * @name: the element name
- * @type: the element type
+ * @name: the element name
+ * @type: the element type
* @content: the element value tree
*
* An element definition has been parsed
@@ -1151,7 +1151,7 @@ void
endElement(void *ctx, const xmlChar * name ATTRIBUTE_UNUSED)
{
DEPRECATED("endElement")
- xmlSAX2EndElement(ctx, name);
+ xmlSAX2EndElement(ctx, name);
}
/**
@@ -1159,7 +1159,7 @@ endElement(void *ctx, const xmlChar * name ATTRIBUTE_UNUSED)
* @ctx: the user data (XML parser context)
* @name: The entity name
*
- * called when an entity reference is detected.
+ * called when an entity reference is detected.
* DEPRECATED: use xmlSAX2Reference()
*/
void
diff --git a/gnulib-local/lib/libxml/libxml.h b/gnulib-local/lib/libxml/libxml.h
index 696be62..2da9044 100644
--- a/gnulib-local/lib/libxml/libxml.h
+++ b/gnulib-local/lib/libxml/libxml.h
@@ -20,7 +20,20 @@
#if defined(macintosh)
#include "config-mac.h"
+#elif defined(_WIN32_WCE)
+/*
+ * Windows CE compatibility definitions and functions
+ * This is needed to compile libxml2 for Windows CE.
+ * At least I tested it with WinCE 5.0 for Emulator and WinCE 4.2/SH4 target
+ */
+#include <win32config.h>
+#include <libxml/xmlversion.h>
#else
+/*
+ * Currently supported platforms use either autoconf or
+ * copy to config.h own "preset" configuration file.
+ * As result ifdef HAVE_CONFIG_H is omited here.
+ */
#include "config.h"
#include <libxml/xmlversion.h>
#endif
@@ -64,6 +77,23 @@ void __xmlLoaderErr(void *ctx, const char *msg, const char *filename);
void __htmlParseContent(void *ctx);
#endif
+/*
+ * internal global initialization critical section routines.
+ */
+void __xmlGlobalInitMutexLock(void);
+void __xmlGlobalInitMutexUnlock(void);
+void __xmlGlobalInitMutexDestroy(void);
+
+int __xmlInitializeDict(void);
+
+#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME)
+/*
+ * internal thread safe random function
+ */
+int __xmlRandom(void);
+#endif
+
+int xmlNop(void);
#ifdef IN_LIBXML
#ifdef __GNUC__
@@ -76,4 +106,7 @@ void __htmlParseContent(void *ctx);
#endif
#endif
#endif
+#if !defined(PIC) && !defined(NOLIBTOOL)
+# define LIBXML_STATIC
+#endif
#endif /* ! __XML_LIBXML_H__ */
diff --git a/gnulib-local/lib/libxml/list.c b/gnulib-local/lib/libxml/list.c
index 2dc6d96..d33d928 100644
--- a/gnulib-local/lib/libxml/list.c
+++ b/gnulib-local/lib/libxml/list.c
@@ -94,15 +94,15 @@ xmlLinkCompare(const void *data0, const void *data1)
*
* Returns the link containing the data or NULL
*/
-static xmlLinkPtr
-xmlListLowerSearch(xmlListPtr l, void *data)
+static xmlLinkPtr
+xmlListLowerSearch(xmlListPtr l, void *data)
{
xmlLinkPtr lk;
if (l == NULL)
return(NULL);
for(lk = l->sentinel->next;lk != l->sentinel && l->linkCompare(lk->data, data) <0 ;lk = lk->next);
- return lk;
+ return lk;
}
/**
@@ -114,15 +114,15 @@ xmlListLowerSearch(xmlListPtr l, void *data)
*
* Returns the link containing the data or NULL
*/
-static xmlLinkPtr
-xmlListHigherSearch(xmlListPtr l, void *data)
+static xmlLinkPtr
+xmlListHigherSearch(xmlListPtr l, void *data)
{
xmlLinkPtr lk;
if (l == NULL)
return(NULL);
for(lk = l->sentinel->prev;lk != l->sentinel && l->linkCompare(lk->data, data) >0 ;lk = lk->prev);
- return lk;
+ return lk;
}
/**
@@ -134,8 +134,8 @@ xmlListHigherSearch(xmlListPtr l, void *data)
*
* Returns the link containing the data or NULL
*/
-static xmlLinkPtr
-xmlListLinkSearch(xmlListPtr l, void *data)
+static xmlLinkPtr
+xmlListLinkSearch(xmlListPtr l, void *data)
{
xmlLinkPtr lk;
if (l == NULL)
@@ -159,8 +159,8 @@ xmlListLinkSearch(xmlListPtr l, void *data)
*
* Returns the link containing the data or NULL
*/
-static xmlLinkPtr
-xmlListLinkReverseSearch(xmlListPtr l, void *data)
+static xmlLinkPtr
+xmlListLinkReverseSearch(xmlListPtr l, void *data)
{
xmlLinkPtr lk;
if (l == NULL)
@@ -189,16 +189,16 @@ xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare)
{
xmlListPtr l;
if (NULL == (l = (xmlListPtr )xmlMalloc( sizeof(xmlList)))) {
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"Cannot initialize memory for list");
return (NULL);
}
/* Initialize the list to NULL */
memset(l, 0, sizeof(xmlList));
-
+
/* Add the sentinel */
if (NULL ==(l->sentinel = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) {
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"Cannot initialize memory for sentinel");
xmlFree(l);
return (NULL);
@@ -206,7 +206,7 @@ xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare)
l->sentinel->next = l->sentinel;
l->sentinel->prev = l->sentinel;
l->sentinel->data = NULL;
-
+
/* If there is a link deallocator, use it */
if (deallocator != NULL)
l->linkDeallocator = deallocator;
@@ -217,7 +217,7 @@ xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare)
l->linkCompare = xmlLinkCompare;
return l;
}
-
+
/**
* xmlListSearch:
* @l: a list
@@ -228,7 +228,7 @@ xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare)
* Returns the value associated to @data or NULL in case of error
*/
void *
-xmlListSearch(xmlListPtr l, void *data)
+xmlListSearch(xmlListPtr l, void *data)
{
xmlLinkPtr lk;
if (l == NULL)
@@ -249,7 +249,7 @@ xmlListSearch(xmlListPtr l, void *data)
* Returns the value associated to @data or NULL in case of error
*/
void *
-xmlListReverseSearch(xmlListPtr l, void *data)
+xmlListReverseSearch(xmlListPtr l, void *data)
{
xmlLinkPtr lk;
if (l == NULL)
@@ -270,7 +270,7 @@ xmlListReverseSearch(xmlListPtr l, void *data)
* Returns 0 in case of success, 1 in case of failure
*/
int
-xmlListInsert(xmlListPtr l, void *data)
+xmlListInsert(xmlListPtr l, void *data)
{
xmlLinkPtr lkPlace, lkNew;
@@ -280,7 +280,7 @@ xmlListInsert(xmlListPtr l, void *data)
/* Add the new link */
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
if (lkNew == NULL) {
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"Cannot initialize memory for new link");
return (1);
}
@@ -302,7 +302,7 @@ xmlListInsert(xmlListPtr l, void *data)
*
* Returns 0 in case of success, 1 in case of failure
*/
-int xmlListAppend(xmlListPtr l, void *data)
+int xmlListAppend(xmlListPtr l, void *data)
{
xmlLinkPtr lkPlace, lkNew;
@@ -312,16 +312,16 @@ int xmlListAppend(xmlListPtr l, void *data)
/* Add the new link */
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
if (lkNew == NULL) {
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"Cannot initialize memory for new link");
- return (0);
+ return (1);
}
lkNew->data = data;
lkNew->next = lkPlace->next;
(lkPlace->next)->prev = lkNew;
lkPlace->next = lkNew;
lkNew->prev = lkPlace;
- return 1;
+ return 0;
}
/**
@@ -353,7 +353,7 @@ int
xmlListRemoveFirst(xmlListPtr l, void *data)
{
xmlLinkPtr lk;
-
+
if (l == NULL)
return(0);
/*Find the first instance of this data */
@@ -378,7 +378,7 @@ int
xmlListRemoveLast(xmlListPtr l, void *data)
{
xmlLinkPtr lk;
-
+
if (l == NULL)
return(0);
/*Find the last instance of this data */
@@ -403,7 +403,7 @@ int
xmlListRemoveAll(xmlListPtr l, void *data)
{
int count=0;
-
+
if (l == NULL)
return(0);
@@ -422,7 +422,7 @@ void
xmlListClear(xmlListPtr l)
{
xmlLinkPtr lk;
-
+
if (l == NULL)
return;
lk = l->sentinel->next;
@@ -458,14 +458,14 @@ xmlListEmpty(xmlListPtr l)
*
* Returns the first element in the list, or NULL
*/
-xmlLinkPtr
+xmlLinkPtr
xmlListFront(xmlListPtr l)
{
if (l == NULL)
return(NULL);
return (l->sentinel->next);
}
-
+
/**
* xmlListEnd:
* @l: a list
@@ -474,14 +474,14 @@ xmlListFront(xmlListPtr l)
*
* Returns the last element in the list, or NULL
*/
-xmlLinkPtr
+xmlLinkPtr
xmlListEnd(xmlListPtr l)
{
if (l == NULL)
return(NULL);
return (l->sentinel->prev);
}
-
+
/**
* xmlListSize:
* @l: a list
@@ -539,7 +539,7 @@ xmlListPopBack(xmlListPtr l)
* Returns 1 if successful, 0 otherwise
*/
int
-xmlListPushFront(xmlListPtr l, void *data)
+xmlListPushFront(xmlListPtr l, void *data)
{
xmlLinkPtr lkPlace, lkNew;
@@ -549,7 +549,7 @@ xmlListPushFront(xmlListPtr l, void *data)
/* Add the new link */
lkNew = (xmlLinkPtr) xmlMalloc(sizeof(xmlLink));
if (lkNew == NULL) {
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"Cannot initialize memory for new link");
return (0);
}
@@ -571,7 +571,7 @@ xmlListPushFront(xmlListPtr l, void *data)
* Returns 1 if successful, 0 otherwise
*/
int
-xmlListPushBack(xmlListPtr l, void *data)
+xmlListPushBack(xmlListPtr l, void *data)
{
xmlLinkPtr lkPlace, lkNew;
@@ -580,7 +580,7 @@ xmlListPushBack(xmlListPtr l, void *data)
lkPlace = l->sentinel->prev;
/* Add the new link */
if (NULL ==(lkNew = (xmlLinkPtr )xmlMalloc(sizeof(xmlLink)))) {
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"Cannot initialize memory for new link");
return (0);
}
@@ -643,7 +643,7 @@ void
xmlListSort(xmlListPtr l)
{
xmlListPtr lTemp;
-
+
if (l == NULL)
return;
if(xmlListEmpty(l))
@@ -725,10 +725,10 @@ xmlListMerge(xmlListPtr l1, xmlListPtr l2)
* @old: the list
*
* Duplicate the list
- *
+ *
* Returns a new copy of the list or NULL in case of error
*/
-xmlListPtr
+xmlListPtr
xmlListDup(const xmlListPtr old)
{
xmlListPtr cur;
@@ -754,7 +754,7 @@ xmlListDup(const xmlListPtr old)
* @old: the old list
*
* Move all the element from the old list in the new list
- *
+ *
* Returns 0 in case of success 1 in case of error
*/
int
@@ -771,7 +771,7 @@ xmlListCopy(xmlListPtr cur, const xmlListPtr old)
return (1);
}
}
- return (0);
+ return (0);
}
/* xmlListUnique() */
/* xmlListSwap */
diff --git a/gnulib-local/lib/libxml/list.in.h b/gnulib-local/lib/libxml/list.in.h
index 1d83482..0504e0c 100644
--- a/gnulib-local/lib/libxml/list.in.h
+++ b/gnulib-local/lib/libxml/list.in.h
@@ -1,6 +1,6 @@
/*
* Summary: lists interfaces
- * Description: this module implement the list support used in
+ * Description: this module implement the list support used in
* various place in the library.
*
* Copy: See Copyright for the status of this software.
@@ -55,76 +55,76 @@ typedef int (*xmlListWalker) (const void *data, const void *user);
XMLPUBFUN xmlListPtr XMLCALL
xmlListCreate (xmlListDeallocator deallocator,
xmlListDataCompare compare);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlListDelete (xmlListPtr l);
/* Basic Operators */
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlListSearch (xmlListPtr l,
void *data);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlListReverseSearch (xmlListPtr l,
void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlListInsert (xmlListPtr l,
void *data) ;
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlListAppend (xmlListPtr l,
void *data) ;
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlListRemoveFirst (xmlListPtr l,
void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlListRemoveLast (xmlListPtr l,
void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlListRemoveAll (xmlListPtr l,
void *data);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlListClear (xmlListPtr l);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlListEmpty (xmlListPtr l);
-XMLPUBFUN xmlLinkPtr XMLCALL
+XMLPUBFUN xmlLinkPtr XMLCALL
xmlListFront (xmlListPtr l);
-XMLPUBFUN xmlLinkPtr XMLCALL
+XMLPUBFUN xmlLinkPtr XMLCALL
xmlListEnd (xmlListPtr l);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlListSize (xmlListPtr l);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlListPopFront (xmlListPtr l);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlListPopBack (xmlListPtr l);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlListPushFront (xmlListPtr l,
void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlListPushBack (xmlListPtr l,
void *data);
/* Advanced Operators */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlListReverse (xmlListPtr l);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlListSort (xmlListPtr l);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlListWalk (xmlListPtr l,
xmlListWalker walker,
const void *user);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlListReverseWalk (xmlListPtr l,
xmlListWalker walker,
const void *user);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlListMerge (xmlListPtr l1,
xmlListPtr l2);
-XMLPUBFUN xmlListPtr XMLCALL
+XMLPUBFUN xmlListPtr XMLCALL
xmlListDup (const xmlListPtr old);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlListCopy (xmlListPtr cur,
const xmlListPtr old);
/* Link operators */
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlLinkGetData (xmlLinkPtr lk);
/* xmlListUnique() */
diff --git a/gnulib-local/lib/libxml/nanoftp.c b/gnulib-local/lib/libxml/nanoftp.c
index c78503b..2135ab9 100644
--- a/gnulib-local/lib/libxml/nanoftp.c
+++ b/gnulib-local/lib/libxml/nanoftp.c
@@ -41,7 +41,7 @@
#include <netdb.h>
#endif
#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
+#include <fcntl.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -77,8 +77,10 @@
#endif
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_WIN32_WCE)
+#ifndef _WINSOCKAPI_
#define _WINSOCKAPI_
+#endif
#include <wsockcompat.h>
#include <winsock2.h>
#undef XML_SOCKLEN_T
@@ -89,10 +91,9 @@
* A couple portability macros
*/
#ifndef _WINSOCKAPI_
-#ifndef __BEOS__
+#if !defined(__BEOS__) || defined(__HAIKU__)
#define closesocket(s) close(s)
#endif
-#define SOCKET int
#endif
#ifdef __BEOS__
@@ -102,8 +103,10 @@
#endif
#ifdef _AIX
+#ifdef HAVE_BROKEN_SS_FAMILY
#define ss_family __ss_family
#endif
+#endif
#ifndef XML_SOCKLEN_T
#define XML_SOCKLEN_T unsigned int
@@ -185,7 +188,7 @@ void
xmlNanoFTPInit(void) {
const char *env;
#ifdef _WINSOCKAPI_
- WSADATA wsaData;
+ WSADATA wsaData;
#endif
if (initialized)
@@ -302,15 +305,15 @@ xmlNanoFTPScanURL(void *ctx, const char *URL) {
/*
* Clear any existing data from the context
*/
- if (ctxt->protocol != NULL) {
+ if (ctxt->protocol != NULL) {
xmlFree(ctxt->protocol);
ctxt->protocol = NULL;
}
- if (ctxt->hostname != NULL) {
+ if (ctxt->hostname != NULL) {
xmlFree(ctxt->hostname);
ctxt->hostname = NULL;
}
- if (ctxt->path != NULL) {
+ if (ctxt->path != NULL) {
xmlFree(ctxt->path);
ctxt->path = NULL;
}
@@ -324,7 +327,7 @@ xmlNanoFTPScanURL(void *ctx, const char *URL) {
xmlFreeURI(uri);
return;
}
-
+
ctxt->protocol = xmlMemStrdup(uri->scheme);
ctxt->hostname = xmlMemStrdup(uri->server);
if (uri->path != NULL)
@@ -355,7 +358,7 @@ xmlNanoFTPScanURL(void *ctx, const char *URL) {
* @URL: The URL used to update the context
*
* Update an FTP context by parsing the URL and finding
- * new path it indicates. If there is an error in the
+ * new path it indicates. If there is an error in the
* protocol, hostname, port or other information, the
* error is raised. It indicates a new connection has to
* be established.
@@ -400,7 +403,7 @@ xmlNanoFTPUpdateURL(void *ctx, const char *URL) {
ctxt->path = NULL;
}
- if (uri->path == NULL)
+ if (uri->path == NULL)
ctxt->path = xmlMemStrdup("/");
else
ctxt->path = xmlMemStrdup(uri->path);
@@ -424,7 +427,7 @@ void
xmlNanoFTPScanProxy(const char *URL) {
xmlURIPtr uri;
- if (proxy != NULL) {
+ if (proxy != NULL) {
xmlFree(proxy);
proxy = NULL;
}
@@ -448,7 +451,7 @@ xmlNanoFTPScanProxy(const char *URL) {
xmlFreeURI(uri);
return;
}
-
+
proxy = xmlMemStrdup(uri->server);
if (uri->port != 0)
proxyPort = uri->port;
@@ -482,7 +485,7 @@ xmlNanoFTPNewCtxt(const char *URL) {
ret->returnValue = 0;
ret->controlBufIndex = 0;
ret->controlBufUsed = 0;
- ret->controlFd = -1;
+ ret->controlFd = INVALID_SOCKET;
unescaped = xmlURIUnescapeString(URL, 0, NULL);
if (unescaped != NULL) {
@@ -509,8 +512,8 @@ xmlNanoFTPFreeCtxt(void * ctx) {
if (ctxt->protocol != NULL) xmlFree(ctxt->protocol);
if (ctxt->path != NULL) xmlFree(ctxt->path);
ctxt->passive = 1;
- if (ctxt->controlFd >= 0) closesocket(ctxt->controlFd);
- ctxt->controlFd = -1;
+ if (ctxt->controlFd != INVALID_SOCKET) closesocket(ctxt->controlFd);
+ ctxt->controlFd = INVALID_SOCKET;
ctxt->controlBufIndex = -1;
ctxt->controlBufUsed = -1;
xmlFree(ctxt);
@@ -520,7 +523,7 @@ xmlNanoFTPFreeCtxt(void * ctx) {
* xmlNanoFTPParseResponse:
* @buf: the buffer containing the response
* @len: the buffer length
- *
+ *
* Parsing of the server answer, we just extract the code.
*
* returns 0 for errors
@@ -532,22 +535,22 @@ xmlNanoFTPParseResponse(char *buf, int len) {
int val = 0;
if (len < 3) return(-1);
- if ((*buf >= '0') && (*buf <= '9'))
+ if ((*buf >= '0') && (*buf <= '9'))
val = val * 10 + (*buf - '0');
else
return(0);
buf++;
- if ((*buf >= '0') && (*buf <= '9'))
+ if ((*buf >= '0') && (*buf <= '9'))
val = val * 10 + (*buf - '0');
else
return(0);
buf++;
- if ((*buf >= '0') && (*buf <= '9'))
+ if ((*buf >= '0') && (*buf <= '9'))
val = val * 10 + (*buf - '0');
else
return(0);
buf++;
- if (*buf == '-')
+ if (*buf == '-')
return(-val);
return(val);
}
@@ -565,7 +568,7 @@ xmlNanoFTPGetMore(void *ctx) {
int len;
int size;
- if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1);
+ if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1);
if ((ctxt->controlBufIndex < 0) || (ctxt->controlBufIndex > FTP_BUF_SIZE)) {
#ifdef DEBUG_FTP
@@ -617,8 +620,8 @@ xmlNanoFTPGetMore(void *ctx) {
if ((len = recv(ctxt->controlFd, &ctxt->controlBuf[ctxt->controlBufIndex],
size, 0)) < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "recv failed");
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
#ifdef DEBUG_FTP
@@ -646,7 +649,7 @@ xmlNanoFTPReadResponse(void *ctx) {
int len;
int res = -1, cur = -1;
- if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1);
+ if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1);
get_more:
/*
@@ -735,7 +738,7 @@ xmlNanoFTPCheckResponse(void *ctx) {
fd_set rfd;
struct timeval tv;
- if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1);
+ if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1);
tv.tv_sec = 0;
tv.tv_usec = 0;
FD_ZERO(&rfd);
@@ -746,7 +749,7 @@ xmlNanoFTPCheckResponse(void *ctx) {
case -1:
__xmlIOErr(XML_FROM_FTP, 0, "select");
return(-1);
-
+
}
return(xmlNanoFTPReadResponse(ctx));
@@ -772,7 +775,7 @@ xmlNanoFTPSendUser(void *ctx) {
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
return(res);
@@ -800,7 +803,7 @@ xmlNanoFTPSendPasswd(void *ctx) {
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
return(res);
@@ -824,14 +827,14 @@ xmlNanoFTPQuit(void *ctx) {
char buf[200];
int len, res;
- if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1);
+ if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1);
snprintf(buf, sizeof(buf), "QUIT\r\n");
len = strlen(buf);
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf); /* Just to be consistent, even though we know it can't have a % in it */
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
return(res);
@@ -905,6 +908,8 @@ xmlNanoFTPConnect(void *ctx) {
return (-1);
}
if (tmp->ai_addrlen > sizeof(ctxt->ftpAddr)) {
+ if (result)
+ freeaddrinfo (result);
__xmlIOErr(XML_FROM_FTP, 0, "gethostbyname address mismatch");
return (-1);
}
@@ -925,9 +930,9 @@ xmlNanoFTPConnect(void *ctx) {
#endif
{
if (proxy)
- hp = gethostbyname (proxy);
+ hp = gethostbyname (GETHOSTBYNAME_ARG_CAST proxy);
else
- hp = gethostbyname (ctxt->hostname);
+ hp = gethostbyname (GETHOSTBYNAME_ARG_CAST ctxt->hostname);
if (hp == NULL) {
__xmlIOErr(XML_FROM_FTP, 0, "gethostbyname failed");
return (-1);
@@ -944,12 +949,13 @@ xmlNanoFTPConnect(void *ctx) {
((struct sockaddr_in *)&ctxt->ftpAddr)->sin_family = AF_INET;
memcpy (&((struct sockaddr_in *)&ctxt->ftpAddr)->sin_addr,
hp->h_addr_list[0], hp->h_length);
- ((struct sockaddr_in *)&ctxt->ftpAddr)->sin_port = (u_short)htons ((unsigned short)port);
+ ((struct sockaddr_in *)&ctxt->ftpAddr)->sin_port =
+ (unsigned short)htons ((unsigned short)port);
ctxt->controlFd = socket (AF_INET, SOCK_STREAM, 0);
addrlen = sizeof (struct sockaddr_in);
}
- if (ctxt->controlFd < 0) {
+ if (ctxt->controlFd == INVALID_SOCKET) {
__xmlIOErr(XML_FROM_FTP, 0, "socket failed");
return(-1);
}
@@ -960,8 +966,8 @@ xmlNanoFTPConnect(void *ctx) {
if (connect(ctxt->controlFd, (struct sockaddr *) &ctxt->ftpAddr,
addrlen) < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "Failed to create a connection");
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
@@ -970,8 +976,8 @@ xmlNanoFTPConnect(void *ctx) {
*/
res = xmlNanoFTPGetResponse(ctxt);
if (res != 2) {
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
@@ -1024,11 +1030,11 @@ xmlNanoFTPConnect(void *ctx) {
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
closesocket(ctxt->controlFd);
- ctxt->controlFd = -1;
+ ctxt->controlFd = INVALID_SOCKET;
return(res);
}
res = xmlNanoFTPGetResponse(ctxt);
@@ -1046,17 +1052,17 @@ xmlNanoFTPConnect(void *ctx) {
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
closesocket(ctxt->controlFd);
- ctxt->controlFd = -1;
+ ctxt->controlFd = INVALID_SOCKET;
return(res);
}
res = xmlNanoFTPGetResponse(ctxt);
if (res > 3) {
closesocket(ctxt->controlFd);
- ctxt->controlFd = -1;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
break;
@@ -1067,7 +1073,7 @@ xmlNanoFTPConnect(void *ctx) {
case -1:
default:
closesocket(ctxt->controlFd);
- ctxt->controlFd = -1;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
}
@@ -1087,11 +1093,11 @@ xmlNanoFTPConnect(void *ctx) {
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(res);
}
res = xmlNanoFTPGetResponse(ctxt);
@@ -1099,10 +1105,10 @@ xmlNanoFTPConnect(void *ctx) {
/* we assume it worked :-\ 1 is error for SITE command */
proxyType = 1;
break;
- }
+ }
if (proxyType == 1) {
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
case 2:
@@ -1118,11 +1124,11 @@ xmlNanoFTPConnect(void *ctx) {
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(res);
}
res = xmlNanoFTPGetResponse(ctxt);
@@ -1130,7 +1136,7 @@ xmlNanoFTPConnect(void *ctx) {
/* we assume it worked :-\ */
proxyType = 2;
return(0);
- }
+ }
if (ctxt->passwd == NULL)
snprintf(buf, sizeof(buf), "PASS anonymous@\r\n");
else
@@ -1140,11 +1146,11 @@ xmlNanoFTPConnect(void *ctx) {
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(res);
}
res = xmlNanoFTPGetResponse(ctxt);
@@ -1154,8 +1160,8 @@ xmlNanoFTPConnect(void *ctx) {
return(0);
}
if (proxyType == 2) {
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
case 3:
@@ -1164,8 +1170,8 @@ xmlNanoFTPConnect(void *ctx) {
* send the code or at least the sequence in use.
*/
default:
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
}
@@ -1174,8 +1180,8 @@ xmlNanoFTPConnect(void *ctx) {
*/
res = xmlNanoFTPSendUser(ctxt);
if (res < 0) {
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
res = xmlNanoFTPGetResponse(ctxt);
@@ -1189,14 +1195,14 @@ xmlNanoFTPConnect(void *ctx) {
case 5:
case -1:
default:
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
res = xmlNanoFTPSendPasswd(ctxt);
if (res < 0) {
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
res = xmlNanoFTPGetResponse(ctxt);
@@ -1211,8 +1217,8 @@ xmlNanoFTPConnect(void *ctx) {
case 5:
case -1:
default:
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
- ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
+ ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
@@ -1235,12 +1241,18 @@ xmlNanoFTPConnectTo(const char *server, int port) {
int res;
xmlNanoFTPInit();
- if (server == NULL)
+ if (server == NULL)
return(NULL);
if (port <= 0)
return(NULL);
ctxt = (xmlNanoFTPCtxtPtr) xmlNanoFTPNewCtxt(NULL);
+ if (ctxt == NULL)
+ return(NULL);
ctxt->hostname = xmlMemStrdup(server);
+ if (ctxt->hostname == NULL) {
+ xmlNanoFTPFreeCtxt(ctxt);
+ return(NULL);
+ }
if (port != 0)
ctxt->port = port;
res = xmlNanoFTPConnect(ctxt);
@@ -1268,7 +1280,7 @@ xmlNanoFTPCwd(void *ctx, const char *directory) {
int len;
int res;
- if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1);
+ if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1);
if (directory == NULL) return 0;
/*
@@ -1284,7 +1296,7 @@ xmlNanoFTPCwd(void *ctx, const char *directory) {
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
return(res);
@@ -1317,8 +1329,8 @@ xmlNanoFTPDele(void *ctx, const char *file) {
int len;
int res;
- if ((ctxt == NULL) || (ctxt->controlFd < 0) || (file == NULL)) return(-1);
- if (file == NULL) return (0);
+ if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET) ||
+ (file == NULL)) return(-1);
/*
* Expected response code for DELE:
@@ -1328,14 +1340,14 @@ xmlNanoFTPDele(void *ctx, const char *file) {
* 450, 550
* 500, 501, 502, 421, 530
*/
-
+
snprintf(buf, sizeof(buf), "DELE %s\r\n", file);
buf[sizeof(buf) - 1] = 0;
len = strlen(buf);
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
return(res);
@@ -1360,7 +1372,7 @@ xmlNanoFTPDele(void *ctx, const char *file) {
* Returns -1 incase of error, 0 otherwise
*/
-int
+SOCKET
xmlNanoFTPGetConnection(void *ctx) {
xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx;
char buf[200], *cur;
@@ -1375,7 +1387,7 @@ xmlNanoFTPGetConnection(void *ctx) {
#endif
XML_SOCKLEN_T dataAddrLen;
- if (ctxt == NULL) return(-1);
+ if (ctxt == NULL) return INVALID_SOCKET;
memset (&dataAddr, 0, sizeof(dataAddr));
#ifdef SUPPORT_IP6
@@ -1391,9 +1403,9 @@ xmlNanoFTPGetConnection(void *ctx) {
dataAddrLen = sizeof (struct sockaddr_in);
}
- if (ctxt->dataFd < 0) {
+ if (ctxt->dataFd == INVALID_SOCKET) {
__xmlIOErr(XML_FROM_FTP, 0, "socket failed");
- return (-1);
+ return INVALID_SOCKET;
}
if (ctxt->passive) {
@@ -1407,36 +1419,36 @@ xmlNanoFTPGetConnection(void *ctx) {
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return(res);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
}
res = xmlNanoFTPReadResponse(ctx);
if (res != 2) {
if (res == 5) {
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return(-1);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
} else {
/*
* retry with an active connection
*/
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
ctxt->passive = 0;
}
}
- cur = &ctxt->controlBuf[ctxt->controlBufAnswer];
+ cur = &ctxt->controlBuf[ctxt->controlBufAnswer];
while (((*cur < '0') || (*cur > '9')) && *cur != '\0') cur++;
#ifdef SUPPORT_IP6
if ((ctxt->ftpAddr).ss_family == AF_INET6) {
if (sscanf (cur, "%u", &temp[0]) != 1) {
__xmlIOErr(XML_FROM_FTP, XML_FTP_EPSV_ANSWER,
"Invalid answer to EPSV\n");
- if (ctxt->dataFd != -1) {
- closesocket (ctxt->dataFd); ctxt->dataFd = -1;
+ if (ctxt->dataFd != INVALID_SOCKET) {
+ closesocket (ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
}
- return (-1);
+ return INVALID_SOCKET;
}
memcpy (&((struct sockaddr_in6 *)&dataAddr)->sin6_addr, &((struct sockaddr_in6 *)&ctxt->ftpAddr)->sin6_addr, sizeof(struct in6_addr));
((struct sockaddr_in6 *)&dataAddr)->sin6_port = htons (temp[0]);
@@ -1448,10 +1460,10 @@ xmlNanoFTPGetConnection(void *ctx) {
&temp[3], &temp[4], &temp[5]) != 6) {
__xmlIOErr(XML_FROM_FTP, XML_FTP_PASV_ANSWER,
"Invalid answer to PASV\n");
- if (ctxt->dataFd != -1) {
- closesocket (ctxt->dataFd); ctxt->dataFd = -1;
+ if (ctxt->dataFd != INVALID_SOCKET) {
+ closesocket (ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
}
- return (-1);
+ return INVALID_SOCKET;
}
for (i=0; i<6; i++) ad[i] = (unsigned char) (temp[i] & 0xff);
memcpy (&((struct sockaddr_in *)&dataAddr)->sin_addr, &ad[0], 4);
@@ -1460,8 +1472,8 @@ xmlNanoFTPGetConnection(void *ctx) {
if (connect(ctxt->dataFd, (struct sockaddr *) &dataAddr, dataAddrLen) < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "Failed to create a data connection");
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return (-1);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
}
} else {
getsockname(ctxt->dataFd, (struct sockaddr *) &dataAddr, &dataAddrLen);
@@ -1474,15 +1486,15 @@ xmlNanoFTPGetConnection(void *ctx) {
if (bind(ctxt->dataFd, (struct sockaddr *) &dataAddr, dataAddrLen) < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "bind failed");
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return (-1);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
}
getsockname(ctxt->dataFd, (struct sockaddr *) &dataAddr, &dataAddrLen);
if (listen(ctxt->dataFd, 1) < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "listen failed");
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return (-1);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
}
#ifdef SUPPORT_IP6
if ((ctxt->ftpAddr).ss_family == AF_INET6) {
@@ -1508,20 +1520,20 @@ xmlNanoFTPGetConnection(void *ctx) {
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return(res);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
}
res = xmlNanoFTPGetResponse(ctxt);
if (res != 2) {
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return(-1);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
}
}
return(ctxt->dataFd);
-
+
}
/**
@@ -1540,9 +1552,9 @@ xmlNanoFTPCloseConnection(void *ctx) {
fd_set rfd, efd;
struct timeval tv;
- if ((ctxt == NULL) || (ctxt->controlFd < 0)) return(-1);
+ if ((ctxt == NULL) || (ctxt->controlFd == INVALID_SOCKET)) return(-1);
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
tv.tv_sec = 15;
tv.tv_usec = 0;
FD_ZERO(&rfd);
@@ -1554,7 +1566,7 @@ xmlNanoFTPCloseConnection(void *ctx) {
#ifdef DEBUG_FTP
perror("select");
#endif
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
if (res == 0) {
@@ -1562,11 +1574,11 @@ xmlNanoFTPCloseConnection(void *ctx) {
xmlGenericError(xmlGenericErrorContext,
"xmlNanoFTPCloseConnection: timeout\n");
#endif
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
} else {
res = xmlNanoFTPGetResponse(ctxt);
if (res != 2) {
- closesocket(ctxt->controlFd); ctxt->controlFd = -1;
+ closesocket(ctxt->controlFd); ctxt->controlFd = INVALID_SOCKET;
return(-1);
}
}
@@ -1579,7 +1591,7 @@ xmlNanoFTPCloseConnection(void *ctx) {
* @callback: the user callback
* @userData: the user callback data
*
- * Parse at most one entry from the listing.
+ * Parse at most one entry from the listing.
*
* Returns -1 incase of error, the length of data parsed otherwise
*/
@@ -1616,7 +1628,7 @@ xmlNanoFTPParseList(const char *list, ftpListCallback callback, void *userData)
if (*cur == 0) return(0);
i = 0;
while (*cur != ' ') {
- if (i < 10)
+ if (i < 10)
attrib[i++] = *cur;
cur++;
if (*cur == 0) return(0);
@@ -1630,7 +1642,7 @@ xmlNanoFTPParseList(const char *list, ftpListCallback callback, void *userData)
if (*cur == 0) return(0);
i = 0;
while (*cur != ' ') {
- if (i < 10)
+ if (i < 10)
owner[i++] = *cur;
cur++;
if (*cur == 0) return(0);
@@ -1640,7 +1652,7 @@ xmlNanoFTPParseList(const char *list, ftpListCallback callback, void *userData)
if (*cur == 0) return(0);
i = 0;
while (*cur != ' ') {
- if (i < 10)
+ if (i < 10)
group[i++] = *cur;
cur++;
if (*cur == 0) return(0);
@@ -1727,7 +1739,7 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
if (xmlNanoFTPCwd(ctxt, ctxt->path) < 1)
return(-1);
ctxt->dataFd = xmlNanoFTPGetConnection(ctxt);
- if (ctxt->dataFd == -1)
+ if (ctxt->dataFd == INVALID_SOCKET)
return(-1);
snprintf(buf, sizeof(buf), "LIST -L\r\n");
} else {
@@ -1736,7 +1748,7 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
return(-1);
}
ctxt->dataFd = xmlNanoFTPGetConnection(ctxt);
- if (ctxt->dataFd == -1)
+ if (ctxt->dataFd == INVALID_SOCKET)
return(-1);
snprintf(buf, sizeof(buf), "LIST -L %s\r\n", filename);
}
@@ -1745,15 +1757,15 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
return(res);
}
res = xmlNanoFTPReadResponse(ctxt);
if (res != 1) {
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
return(-res);
}
@@ -1769,18 +1781,18 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
#ifdef DEBUG_FTP
perror("select");
#endif
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
return(-1);
}
if (res == 0) {
res = xmlNanoFTPCheckResponse(ctxt);
if (res < 0) {
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ ctxt->dataFd = INVALID_SOCKET;
return(-1);
}
if (res == 2) {
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
return(0);
}
@@ -1789,8 +1801,8 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
if ((len = recv(ctxt->dataFd, &buf[indx], sizeof(buf) - (indx + 1), 0)) < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "recv");
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ ctxt->dataFd = INVALID_SOCKET;
return(-1);
}
#ifdef DEBUG_FTP
@@ -1822,34 +1834,34 @@ xmlNanoFTPList(void *ctx, ftpListCallback callback, void *userData,
*/
-int
+SOCKET
xmlNanoFTPGetSocket(void *ctx, const char *filename) {
xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx;
char buf[300];
int res, len;
if (ctx == NULL)
- return(-1);
+ return INVALID_SOCKET;
if ((filename == NULL) && (ctxt->path == NULL))
- return(-1);
+ return INVALID_SOCKET;
ctxt->dataFd = xmlNanoFTPGetConnection(ctxt);
- if (ctxt->dataFd == -1)
- return(-1);
+ if (ctxt->dataFd == INVALID_SOCKET)
+ return INVALID_SOCKET;
snprintf(buf, sizeof(buf), "TYPE I\r\n");
len = strlen(buf);
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return(res);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
}
res = xmlNanoFTPReadResponse(ctxt);
if (res != 2) {
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return(-res);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
}
if (filename == NULL)
snprintf(buf, sizeof(buf), "RETR %s\r\n", ctxt->path);
@@ -1860,16 +1872,16 @@ xmlNanoFTPGetSocket(void *ctx, const char *filename) {
#ifdef DEBUG_FTP
xmlGenericError(xmlGenericErrorContext, "%s", buf);
#endif
- res = send(ctxt->controlFd, buf, len, 0);
+ res = send(ctxt->controlFd, SEND_ARG2_CAST buf, len, 0);
if (res < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "send failed");
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return(res);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
}
res = xmlNanoFTPReadResponse(ctxt);
if (res != 1) {
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- return(-res);
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ return INVALID_SOCKET;
}
return(ctxt->dataFd);
}
@@ -1901,7 +1913,7 @@ xmlNanoFTPGet(void *ctx, ftpDataCallback callback, void *userData,
return(-1);
if (callback == NULL)
return(-1);
- if (xmlNanoFTPGetSocket(ctxt, filename) < 0)
+ if (xmlNanoFTPGetSocket(ctxt, filename) == INVALID_SOCKET)
return(-1);
do {
@@ -1914,18 +1926,18 @@ xmlNanoFTPGet(void *ctx, ftpDataCallback callback, void *userData,
#ifdef DEBUG_FTP
perror("select");
#endif
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
return(-1);
}
if (res == 0) {
res = xmlNanoFTPCheckResponse(ctxt);
if (res < 0) {
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
- ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
+ ctxt->dataFd = INVALID_SOCKET;
return(-1);
}
if (res == 2) {
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
return(0);
}
@@ -1934,7 +1946,7 @@ xmlNanoFTPGet(void *ctx, ftpDataCallback callback, void *userData,
if ((len = recv(ctxt->dataFd, buf, sizeof(buf), 0)) < 0) {
__xmlIOErr(XML_FROM_FTP, 0, "recv failed");
callback(userData, buf, len);
- closesocket(ctxt->dataFd); ctxt->dataFd = -1;
+ closesocket(ctxt->dataFd); ctxt->dataFd = INVALID_SOCKET;
return(-1);
}
callback(userData, buf, len);
@@ -1960,7 +1972,7 @@ xmlNanoFTPRead(void *ctx, void *dest, int len) {
xmlNanoFTPCtxtPtr ctxt = (xmlNanoFTPCtxtPtr) ctx;
if (ctx == NULL) return(-1);
- if (ctxt->dataFd < 0) return(0);
+ if (ctxt->dataFd == INVALID_SOCKET) return(0);
if (dest == NULL) return(-1);
if (len <= 0) return(0);
@@ -1982,13 +1994,13 @@ xmlNanoFTPRead(void *ctx, void *dest, int len) {
*
* Start to fetch the given ftp:// resource
*
- * Returns an FTP context, or NULL
+ * Returns an FTP context, or NULL
*/
void*
xmlNanoFTPOpen(const char *URL) {
xmlNanoFTPCtxtPtr ctxt;
- int sock;
+ SOCKET sock;
xmlNanoFTPInit();
if (URL == NULL) return(NULL);
@@ -2001,7 +2013,7 @@ xmlNanoFTPOpen(const char *URL) {
return(NULL);
}
sock = xmlNanoFTPGetSocket(ctxt, ctxt->path);
- if (sock < 0) {
+ if (sock == INVALID_SOCKET) {
xmlNanoFTPFreeCtxt(ctxt);
return(NULL);
}
@@ -2024,14 +2036,14 @@ xmlNanoFTPClose(void *ctx) {
if (ctxt == NULL)
return(-1);
- if (ctxt->dataFd >= 0) {
+ if (ctxt->dataFd != INVALID_SOCKET) {
closesocket(ctxt->dataFd);
- ctxt->dataFd = -1;
+ ctxt->dataFd = INVALID_SOCKET;
}
- if (ctxt->controlFd >= 0) {
+ if (ctxt->controlFd != INVALID_SOCKET) {
xmlNanoFTPQuit(ctxt);
closesocket(ctxt->controlFd);
- ctxt->controlFd = -1;
+ ctxt->controlFd = INVALID_SOCKET;
}
xmlNanoFTPFreeCtxt(ctxt);
return(0);
@@ -2039,9 +2051,9 @@ xmlNanoFTPClose(void *ctx) {
#ifdef STANDALONE
/************************************************************************
- * *
- * Basic test in Standalone mode *
- * *
+ * *
+ * Basic test in Standalone mode *
+ * *
************************************************************************/
static
void ftpList(void *userData, const char *filename, const char* attrib,
@@ -2056,7 +2068,7 @@ void ftpData(void *userData, const char *data, int len) {
if (len <= 0) {
fclose((FILE*)userData);
return;
- }
+ }
fwrite(data, len, 1, (FILE*)userData);
}
@@ -2088,7 +2100,7 @@ int main(int argc, char **argv) {
if (xmlNanoFTPGet(ctxt, ftpData, (void *) output, tstfile) < 0)
xmlGenericError(xmlGenericErrorContext,
"Failed to get file\n");
-
+
}
xmlNanoFTPClose(ctxt);
xmlMemoryDump();
diff --git a/gnulib-local/lib/libxml/nanoftp.in.h b/gnulib-local/lib/libxml/nanoftp.in.h
index e3c28a0..abb4bf7 100644
--- a/gnulib-local/lib/libxml/nanoftp.in.h
+++ b/gnulib-local/lib/libxml/nanoftp.in.h
@@ -7,7 +7,7 @@
*
* Author: Daniel Veillard
*/
-
+
#ifndef __NANO_FTP_H__
#define __NANO_FTP_H__
@@ -15,12 +15,32 @@
#ifdef LIBXML_FTP_ENABLED
+/* Needed for portability to Windows 64 bits */
+#if defined(__MINGW32__) || defined(_WIN32_WCE)
+#include <winsock2.h>
+#else
+/**
+ * SOCKET:
+ *
+ * macro used to provide portability of code to windows sockets
+ */
+#define SOCKET int
+/**
+ * INVALID_SOCKET:
+ *
+ * macro used to provide portability of code to windows sockets
+ * the value to be used when the socket is not valid
+ */
+#undef INVALID_SOCKET
+#define INVALID_SOCKET (-1)
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
/**
- * ftpListCallback:
+ * ftpListCallback:
* @userData: user provided data for the callback
* @filename: the file name (including "->" when links are shown)
* @attrib: the attribute string
@@ -44,7 +64,7 @@ typedef void (*ftpListCallback) (void *userData,
const char *month, int day, int hour,
int minute);
/**
- * ftpDataCallback:
+ * ftpDataCallback:
* @userData: the user provided context
* @data: the data received
* @len: its size in bytes
@@ -60,78 +80,78 @@ typedef void (*ftpDataCallback) (void *userData,
*/
XMLPUBFUN void XMLCALL
xmlNanoFTPInit (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNanoFTPCleanup (void);
/*
* Creating/freeing contexts.
*/
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlNanoFTPNewCtxt (const char *URL);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNanoFTPFreeCtxt (void * ctx);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlNanoFTPConnectTo (const char *server,
int port);
/*
* Opening/closing session connections.
*/
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlNanoFTPOpen (const char *URL);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPConnect (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPClose (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPQuit (void *ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNanoFTPScanProxy (const char *URL);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNanoFTPProxy (const char *host,
int port,
const char *user,
const char *passwd,
int type);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPUpdateURL (void *ctx,
const char *URL);
/*
* Rather internal commands.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPGetResponse (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPCheckResponse (void *ctx);
/*
* CD/DIR/GET handlers.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPCwd (void *ctx,
const char *directory);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPDele (void *ctx,
const char *file);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN SOCKET XMLCALL
xmlNanoFTPGetConnection (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPCloseConnection(void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPList (void *ctx,
ftpListCallback callback,
void *userData,
const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN SOCKET XMLCALL
xmlNanoFTPGetSocket (void *ctx,
const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPGet (void *ctx,
ftpDataCallback callback,
void *userData,
const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoFTPRead (void *ctx,
void *dest,
int len);
diff --git a/gnulib-local/lib/libxml/nanohttp.c b/gnulib-local/lib/libxml/nanohttp.c
index ae7923f..e109ad7 100644
--- a/gnulib-local/lib/libxml/nanohttp.c
+++ b/gnulib-local/lib/libxml/nanohttp.c
@@ -10,7 +10,7 @@
*
* daniel@veillard.com
*/
-
+
#define NEED_SOCKETS
#define IN_LIBXML
#include "libxml.h"
@@ -46,7 +46,7 @@
#include <resolv.h>
#endif
#ifdef HAVE_FCNTL_H
-#include <fcntl.h>
+#include <fcntl.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
@@ -54,15 +54,16 @@
#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
+#ifndef HAVE_POLL_H
#ifdef HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
+#else
+#include <poll.h>
+#endif
#ifdef HAVE_STRINGS_H
#include <strings.h>
#endif
-#ifdef SUPPORT_IP6
-#include <resolv.h>
-#endif
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
@@ -71,19 +72,18 @@
#ifdef VMS
#include <stropts>
#define XML_SOCKLEN_T unsigned int
-#define SOCKET int
#endif
-
-#ifdef __MINGW32__
+#if defined(__MINGW32__) || defined(_WIN32_WCE)
+#ifndef _WINSOCKAPI_
#define _WINSOCKAPI_
+#endif
#include <wsockcompat.h>
#include <winsock2.h>
#undef XML_SOCKLEN_T
#define XML_SOCKLEN_T unsigned int
#endif
-
#include <libxml/globals.h>
#include <libxml/xmlerror.h>
#include <libxml/xmlmemory.h>
@@ -96,10 +96,11 @@
* A couple portability macros
*/
#ifndef _WINSOCKAPI_
-#ifndef __BEOS__
+#if !defined(__BEOS__) || defined(__HAIKU__)
#define closesocket(s) close(s)
#endif
#define SOCKET int
+#define INVALID_SOCKET (-1)
#endif
#ifdef __BEOS__
@@ -111,9 +112,6 @@
#ifndef XML_SOCKLEN_T
#define XML_SOCKLEN_T unsigned int
#endif
-#ifndef SOCKET
-#define SOCKET int
-#endif
#ifdef STANDALONE
#define DEBUG_HTTP
@@ -147,6 +145,7 @@ typedef struct xmlNanoHTTPCtxt {
int inlen; /* len of the input buffer */
int last; /* return code for last operation */
int returnValue; /* the protocol return value */
+ int version; /* the protocol version */
int ContentLength; /* specified content length from HTTP header */
char *contentType; /* the MIME type for the input */
char *location; /* the new URL in case of redirect */
@@ -192,10 +191,10 @@ static int socket_errno(void) {
#ifdef SUPPORT_IP6
static
int have_ipv6(void) {
- int s;
+ SOCKET s;
s = socket (AF_INET6, SOCK_STREAM, 0);
- if (s != -1) {
+ if (s != INVALID_SOCKET) {
close (s);
return (1);
}
@@ -214,7 +213,7 @@ void
xmlNanoHTTPInit(void) {
const char *env;
#ifdef _WINSOCKAPI_
- WSADATA wsaData;
+ WSADATA wsaData;
#endif
if (initialized)
@@ -277,22 +276,24 @@ xmlNanoHTTPCleanup(void) {
static void
xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
xmlURIPtr uri;
+ int len;
+
/*
* Clear any existing data from the context
*/
- if (ctxt->protocol != NULL) {
+ if (ctxt->protocol != NULL) {
xmlFree(ctxt->protocol);
ctxt->protocol = NULL;
}
- if (ctxt->hostname != NULL) {
+ if (ctxt->hostname != NULL) {
xmlFree(ctxt->hostname);
ctxt->hostname = NULL;
}
- if (ctxt->path != NULL) {
+ if (ctxt->path != NULL) {
xmlFree(ctxt->path);
ctxt->path = NULL;
}
- if (ctxt->query != NULL) {
+ if (ctxt->query != NULL) {
xmlFree(ctxt->query);
ctxt->query = NULL;
}
@@ -306,9 +307,17 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
xmlFreeURI(uri);
return;
}
-
+
ctxt->protocol = xmlMemStrdup(uri->scheme);
- ctxt->hostname = xmlMemStrdup(uri->server);
+ /* special case of IPv6 addresses, the [] need to be removed */
+ if ((uri->server != NULL) && (*uri->server == '[')) {
+ len = strlen(uri->server);
+ if ((len > 2) && (uri->server[len - 1] == ']')) {
+ ctxt->hostname = (char *) xmlCharStrndup(uri->server + 1, len -2);
+ } else
+ ctxt->hostname = xmlMemStrdup(uri->server);
+ } else
+ ctxt->hostname = xmlMemStrdup(uri->server);
if (uri->path != NULL)
ctxt->path = xmlMemStrdup(uri->path);
else
@@ -335,7 +344,7 @@ void
xmlNanoHTTPScanProxy(const char *URL) {
xmlURIPtr uri;
- if (proxy != NULL) {
+ if (proxy != NULL) {
xmlFree(proxy);
proxy = NULL;
}
@@ -359,7 +368,7 @@ xmlNanoHTTPScanProxy(const char *URL) {
xmlFreeURI(uri);
return;
}
-
+
proxy = xmlMemStrdup(uri->server);
if (uri->port != 0)
proxyPort = uri->port;
@@ -389,7 +398,7 @@ xmlNanoHTTPNewCtxt(const char *URL) {
memset(ret, 0, sizeof(xmlNanoHTTPCtxt));
ret->port = 80;
ret->returnValue = 0;
- ret->fd = -1;
+ ret->fd = INVALID_SOCKET;
ret->ContentLength = -1;
xmlNanoHTTPScanURL(ret, URL);
@@ -426,8 +435,8 @@ xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) {
#endif
ctxt->state = XML_NANO_HTTP_NONE;
- if (ctxt->fd >= 0) closesocket(ctxt->fd);
- ctxt->fd = -1;
+ if (ctxt->fd != INVALID_SOCKET) closesocket(ctxt->fd);
+ ctxt->fd = INVALID_SOCKET;
xmlFree(ctxt);
}
@@ -440,51 +449,64 @@ xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) {
*/
static int
-xmlNanoHTTPSend(xmlNanoHTTPCtxtPtr ctxt, const char * xmt_ptr, int outlen) {
-
- int total_sent = 0;
+xmlNanoHTTPSend(xmlNanoHTTPCtxtPtr ctxt, const char *xmt_ptr, int outlen)
+{
+ int total_sent = 0;
+#ifdef HAVE_POLL_H
+ struct pollfd p;
+#else
+ struct timeval tv;
+ fd_set wfd;
+#endif
- if ( (ctxt->state & XML_NANO_HTTP_WRITE) && (xmt_ptr != NULL ) ) {
+ if ((ctxt->state & XML_NANO_HTTP_WRITE) && (xmt_ptr != NULL)) {
while (total_sent < outlen) {
- int nsent = send(ctxt->fd, xmt_ptr + total_sent,
- outlen - total_sent, 0);
- if (nsent>0)
+ int nsent = send(ctxt->fd, SEND_ARG2_CAST (xmt_ptr + total_sent),
+ outlen - total_sent, 0);
+
+ if (nsent > 0)
total_sent += nsent;
- else if ( ( nsent == -1 ) &&
+ else if ((nsent == -1) &&
#if defined(EAGAIN) && EAGAIN != EWOULDBLOCK
- ( socket_errno( ) != EAGAIN ) &&
+ (socket_errno() != EAGAIN) &&
+#endif
+ (socket_errno() != EWOULDBLOCK)) {
+ __xmlIOErr(XML_FROM_HTTP, 0, "send failed\n");
+ if (total_sent == 0)
+ total_sent = -1;
+ break;
+ } else {
+ /*
+ * No data sent
+ * Since non-blocking sockets are used, wait for
+ * socket to be writable or default timeout prior
+ * to retrying.
+ */
+#ifndef HAVE_POLL_H
+#ifndef _WINSOCKAPI_
+ if (ctxt->fd > FD_SETSIZE)
+ return -1;
#endif
- ( socket_errno( ) != EWOULDBLOCK ) ) {
- __xmlIOErr(XML_FROM_HTTP, 0, "send failed\n");
- if ( total_sent == 0 )
- total_sent = -1;
- break;
- }
- else {
- /*
- ** No data sent
- ** Since non-blocking sockets are used, wait for
- ** socket to be writable or default timeout prior
- ** to retrying.
- */
-
- struct timeval tv;
- fd_set wfd;
-
- tv.tv_sec = timeout;
- tv.tv_usec = 0;
- FD_ZERO( &wfd );
+
+ tv.tv_sec = timeout;
+ tv.tv_usec = 0;
+ FD_ZERO(&wfd);
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4018)
#endif
- FD_SET( ctxt->fd, &wfd );
+ FD_SET(ctxt->fd, &wfd);
#ifdef _MSC_VER
#pragma warning(pop)
#endif
- (void)select( ctxt->fd + 1, NULL, &wfd, NULL, &tv );
- }
- }
+ (void) select(ctxt->fd + 1, NULL, &wfd, NULL, &tv);
+#else
+ p.fd = ctxt->fd;
+ p.events = POLLOUT;
+ (void) poll(&p, 1, timeout * 1000);
+#endif /* !HAVE_POLL_H */
+ }
+ }
}
return total_sent;
@@ -501,96 +523,119 @@ xmlNanoHTTPSend(xmlNanoHTTPCtxtPtr ctxt, const char * xmt_ptr, int outlen) {
*/
static int
-xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt) {
+xmlNanoHTTPRecv(xmlNanoHTTPCtxtPtr ctxt)
+{
+#ifdef HAVE_POLL_H
+ struct pollfd p;
+#else
fd_set rfd;
struct timeval tv;
+#endif
while (ctxt->state & XML_NANO_HTTP_READ) {
- if (ctxt->in == NULL) {
- ctxt->in = (char *) xmlMallocAtomic(65000 * sizeof(char));
- if (ctxt->in == NULL) {
- xmlHTTPErrMemory("allocating input");
- ctxt->last = -1;
- return(-1);
- }
- ctxt->inlen = 65000;
- ctxt->inptr = ctxt->content = ctxt->inrptr = ctxt->in;
- }
- if (ctxt->inrptr > ctxt->in + XML_NANO_HTTP_CHUNK) {
- int delta = ctxt->inrptr - ctxt->in;
- int len = ctxt->inptr - ctxt->inrptr;
-
- memmove(ctxt->in, ctxt->inrptr, len);
- ctxt->inrptr -= delta;
- ctxt->content -= delta;
- ctxt->inptr -= delta;
- }
+ if (ctxt->in == NULL) {
+ ctxt->in = (char *) xmlMallocAtomic(65000 * sizeof(char));
+ if (ctxt->in == NULL) {
+ xmlHTTPErrMemory("allocating input");
+ ctxt->last = -1;
+ return (-1);
+ }
+ ctxt->inlen = 65000;
+ ctxt->inptr = ctxt->content = ctxt->inrptr = ctxt->in;
+ }
+ if (ctxt->inrptr > ctxt->in + XML_NANO_HTTP_CHUNK) {
+ int delta = ctxt->inrptr - ctxt->in;
+ int len = ctxt->inptr - ctxt->inrptr;
+
+ memmove(ctxt->in, ctxt->inrptr, len);
+ ctxt->inrptr -= delta;
+ ctxt->content -= delta;
+ ctxt->inptr -= delta;
+ }
if ((ctxt->in + ctxt->inlen) < (ctxt->inptr + XML_NANO_HTTP_CHUNK)) {
- int d_inptr = ctxt->inptr - ctxt->in;
- int d_content = ctxt->content - ctxt->in;
- int d_inrptr = ctxt->inrptr - ctxt->in;
- char * tmp_ptr = ctxt->in;
+ int d_inptr = ctxt->inptr - ctxt->in;
+ int d_content = ctxt->content - ctxt->in;
+ int d_inrptr = ctxt->inrptr - ctxt->in;
+ char *tmp_ptr = ctxt->in;
- ctxt->inlen *= 2;
+ ctxt->inlen *= 2;
ctxt->in = (char *) xmlRealloc(tmp_ptr, ctxt->inlen);
- if (ctxt->in == NULL) {
- xmlHTTPErrMemory("allocating input buffer");
- xmlFree( tmp_ptr );
- ctxt->last = -1;
- return(-1);
- }
+ if (ctxt->in == NULL) {
+ xmlHTTPErrMemory("allocating input buffer");
+ xmlFree(tmp_ptr);
+ ctxt->last = -1;
+ return (-1);
+ }
ctxt->inptr = ctxt->in + d_inptr;
ctxt->content = ctxt->in + d_content;
ctxt->inrptr = ctxt->in + d_inrptr;
- }
- ctxt->last = recv(ctxt->fd, ctxt->inptr, XML_NANO_HTTP_CHUNK, 0);
- if (ctxt->last > 0) {
- ctxt->inptr += ctxt->last;
- return(ctxt->last);
- }
- if (ctxt->last == 0) {
- return(0);
- }
- if (ctxt->last == -1) {
- switch (socket_errno()) {
- case EINPROGRESS:
- case EWOULDBLOCK:
+ }
+ ctxt->last = recv(ctxt->fd, ctxt->inptr, XML_NANO_HTTP_CHUNK, 0);
+ if (ctxt->last > 0) {
+ ctxt->inptr += ctxt->last;
+ return (ctxt->last);
+ }
+ if (ctxt->last == 0) {
+ return (0);
+ }
+ if (ctxt->last == -1) {
+ switch (socket_errno()) {
+ case EINPROGRESS:
+ case EWOULDBLOCK:
#if defined(EAGAIN) && EAGAIN != EWOULDBLOCK
- case EAGAIN:
+ case EAGAIN:
+#endif
+ break;
+
+ case ECONNRESET:
+ case ESHUTDOWN:
+ return (0);
+
+ default:
+ __xmlIOErr(XML_FROM_HTTP, 0, "recv failed\n");
+ return (-1);
+ }
+ }
+#ifdef HAVE_POLL_H
+ p.fd = ctxt->fd;
+ p.events = POLLIN;
+ if ((poll(&p, 1, timeout * 1000) < 1)
+#if defined(EINTR)
+ && (errno != EINTR)
+#endif
+ )
+ return (0);
+#else /* !HAVE_POLL_H */
+#ifndef _WINSOCKAPI_
+ if (ctxt->fd > FD_SETSIZE)
+ return 0;
#endif
- break;
- case ECONNRESET:
- case ESHUTDOWN:
- return ( 0 );
+ tv.tv_sec = timeout;
+ tv.tv_usec = 0;
+ FD_ZERO(&rfd);
- default:
- __xmlIOErr(XML_FROM_HTTP, 0, "recv failed\n");
- return(-1);
- }
- }
-
- tv.tv_sec = timeout;
- tv.tv_usec = 0;
- FD_ZERO(&rfd);
#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable: 4018)
#endif
- FD_SET(ctxt->fd, &rfd);
+
+ FD_SET(ctxt->fd, &rfd);
+
#ifdef _MSC_VER
#pragma warning(pop)
#endif
-
- if ( (select(ctxt->fd+1, &rfd, NULL, NULL, &tv)<1)
+
+ if ((select(ctxt->fd + 1, &rfd, NULL, NULL, &tv) < 1)
#if defined(EINTR)
- && (errno != EINTR)
+ && (errno != EINTR)
#endif
- )
- return(0);
+ )
+ return (0);
+#endif /* !HAVE_POLL_H */
}
- return(0);
+ return (0);
}
/**
@@ -609,7 +654,7 @@ xmlNanoHTTPReadLine(xmlNanoHTTPCtxtPtr ctxt) {
char buf[4096];
char *bp = buf;
int rc;
-
+
while (bp - buf < 4095) {
if (ctxt->inrptr == ctxt->inptr) {
if ( (rc = xmlNanoHTTPRecv(ctxt)) == 0) {
@@ -687,6 +732,7 @@ xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) {
}
if ((*cur != 0) && (*cur != ' ') && (*cur != '\t')) return;
ctxt->returnValue = ret;
+ ctxt->version = version;
} else if (!xmlStrncasecmp(BAD_CAST line, BAD_CAST"Content-Type:", 13)) {
const xmlChar *charset, *last, *mime;
cur += 13;
@@ -745,9 +791,9 @@ xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) {
xmlFree(ctxt->location);
if (*cur == '/') {
xmlChar *tmp_http = xmlStrdup(BAD_CAST "http://");
- xmlChar *tmp_loc =
+ xmlChar *tmp_loc =
xmlStrcat(tmp_http, (const xmlChar *) ctxt->hostname);
- ctxt->location =
+ ctxt->location =
(char *) xmlStrcat (tmp_loc, (const xmlChar *) cur);
} else {
ctxt->location = xmlMemStrdup(cur);
@@ -801,90 +847,99 @@ xmlNanoHTTPScanAnswer(xmlNanoHTTPCtxtPtr ctxt, const char *line) {
* Returns -1 in case of failure, the file descriptor number otherwise
*/
-static int
+static SOCKET
xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
{
+#ifndef HAVE_POLL_H
fd_set wfd;
#ifdef _WINSOCKAPI_
fd_set xfd;
#endif
struct timeval tv;
+#else /* !HAVE_POLL_H */
+ struct pollfd p;
+#endif /* !HAVE_POLL_H */
int status;
+
int addrlen;
+
SOCKET s;
-
+
#ifdef SUPPORT_IP6
if (addr->sa_family == AF_INET6) {
- s = socket (PF_INET6, SOCK_STREAM, IPPROTO_TCP);
- addrlen = sizeof (struct sockaddr_in6);
- }
- else
+ s = socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP);
+ addrlen = sizeof(struct sockaddr_in6);
+ } else
#endif
{
- s = socket (PF_INET, SOCK_STREAM, IPPROTO_TCP);
- addrlen = sizeof (struct sockaddr_in);
+ s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ addrlen = sizeof(struct sockaddr_in);
}
- if (s==-1) {
+ if (s == INVALID_SOCKET) {
#ifdef DEBUG_HTTP
- perror("socket");
+ perror("socket");
#endif
- __xmlIOErr(XML_FROM_HTTP, 0, "socket failed\n");
- return(-1);
+ __xmlIOErr(XML_FROM_HTTP, 0, "socket failed\n");
+ return INVALID_SOCKET;
}
-
#ifdef _WINSOCKAPI_
{
- u_long one = 1;
+ u_long one = 1;
- status = ioctlsocket(s, FIONBIO, &one) == SOCKET_ERROR ? -1 : 0;
+ status = ioctlsocket(s, FIONBIO, &one) == SOCKET_ERROR ? -1 : 0;
}
#else /* _WINSOCKAPI_ */
#if defined(VMS)
{
- int enable = 1;
- status = ioctl(s, FIONBIO, &enable);
+ int enable = 1;
+
+ status = ioctl(s, FIONBIO, &enable);
}
#else /* VMS */
-#if defined(__BEOS__)
- {
- bool noblock = true;
- status = setsockopt(s, SOL_SOCKET, SO_NONBLOCK, &noblock, sizeof(noblock));
- }
+#if defined(__BEOS__) && !defined(__HAIKU__)
+ {
+ bool noblock = true;
+
+ status =
+ setsockopt(s, SOL_SOCKET, SO_NONBLOCK, &noblock,
+ sizeof(noblock));
+ }
#else /* __BEOS__ */
if ((status = fcntl(s, F_GETFL, 0)) != -1) {
#ifdef O_NONBLOCK
- status |= O_NONBLOCK;
+ status |= O_NONBLOCK;
#else /* O_NONBLOCK */
#ifdef F_NDELAY
- status |= F_NDELAY;
+ status |= F_NDELAY;
#endif /* F_NDELAY */
#endif /* !O_NONBLOCK */
- status = fcntl(s, F_SETFL, status);
+ status = fcntl(s, F_SETFL, status);
}
if (status < 0) {
#ifdef DEBUG_HTTP
- perror("nonblocking");
+ perror("nonblocking");
#endif
- __xmlIOErr(XML_FROM_HTTP, 0, "error setting non-blocking IO\n");
- closesocket(s);
- return(-1);
+ __xmlIOErr(XML_FROM_HTTP, 0, "error setting non-blocking IO\n");
+ closesocket(s);
+ return INVALID_SOCKET;
}
#endif /* !__BEOS__ */
#endif /* !VMS */
#endif /* !_WINSOCKAPI_ */
- if (connect (s, addr, addrlen) == -1) {
- switch (socket_errno()) {
- case EINPROGRESS:
- case EWOULDBLOCK:
- break;
- default:
- __xmlIOErr(XML_FROM_HTTP, 0, "error connecting to HTTP server");
- closesocket(s);
- return(-1);
- }
- }
-
+ if (connect(s, addr, addrlen) == -1) {
+ switch (socket_errno()) {
+ case EINPROGRESS:
+ case EWOULDBLOCK:
+ break;
+ default:
+ __xmlIOErr(XML_FROM_HTTP, 0,
+ "error connecting to HTTP server");
+ closesocket(s);
+ return INVALID_SOCKET;
+ }
+ }
+#ifndef HAVE_POLL_H
tv.tv_sec = timeout;
tv.tv_usec = 0;
@@ -892,63 +947,83 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
#pragma warning(push)
#pragma warning(disable: 4018)
#endif
+#ifndef _WINSOCKAPI_
+ if (s > FD_SETSIZE)
+ return INVALID_SOCKET;
+#endif
FD_ZERO(&wfd);
FD_SET(s, &wfd);
-#ifdef _WINSOCKAPI_
+#ifdef _WINSOCKAPI_
FD_ZERO(&xfd);
FD_SET(s, &xfd);
-
- switch(select(s+1, NULL, &wfd, &xfd, &tv))
+
+ switch (select(s + 1, NULL, &wfd, &xfd, &tv))
#else
- switch(select(s+1, NULL, &wfd, NULL, &tv))
+ switch (select(s + 1, NULL, &wfd, NULL, &tv))
#endif
#ifdef _MSC_VER
#pragma warning(pop)
#endif
+
+#else /* !HAVE_POLL_H */
+ p.fd = s;
+ p.events = POLLOUT;
+ switch (poll(&p, 1, timeout * 1000))
+#endif /* !HAVE_POLL_H */
+
{
- case 0:
- /* Time out */
- __xmlIOErr(XML_FROM_HTTP, 0, "Connect attempt timed out");
- closesocket(s);
- return(-1);
- case -1:
- /* Ermm.. ?? */
- __xmlIOErr(XML_FROM_HTTP, 0, "Connect failed");
- closesocket(s);
- return(-1);
+ case 0:
+ /* Time out */
+ __xmlIOErr(XML_FROM_HTTP, 0, "Connect attempt timed out");
+ closesocket(s);
+ return INVALID_SOCKET;
+ case -1:
+ /* Ermm.. ?? */
+ __xmlIOErr(XML_FROM_HTTP, 0, "Connect failed");
+ closesocket(s);
+ return INVALID_SOCKET;
}
- if ( FD_ISSET(s, &wfd)
+#ifndef HAVE_POLL_H
+ if (FD_ISSET(s, &wfd)
#ifdef _WINSOCKAPI_
- || FD_ISSET(s, &xfd)
+ || FD_ISSET(s, &xfd)
#endif
- ) {
- XML_SOCKLEN_T len;
- len = sizeof(status);
+ )
+#else /* !HAVE_POLL_H */
+ if (p.revents == POLLOUT)
+#endif /* !HAVE_POLL_H */
+ {
+ XML_SOCKLEN_T len;
+
+ len = sizeof(status);
#ifdef SO_ERROR
- if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char*)&status, &len) < 0 ) {
- /* Solaris error code */
- __xmlIOErr(XML_FROM_HTTP, 0, "getsockopt failed\n");
- return (-1);
- }
-#endif
- if ( status ) {
- __xmlIOErr(XML_FROM_HTTP, 0, "Error connecting to remote host");
- closesocket(s);
- errno = status;
- return (-1);
- }
+ if (getsockopt(s, SOL_SOCKET, SO_ERROR, (char *) &status, &len) <
+ 0) {
+ /* Solaris error code */
+ __xmlIOErr(XML_FROM_HTTP, 0, "getsockopt failed\n");
+ closesocket(s);
+ return INVALID_SOCKET;
+ }
+#endif
+ if (status) {
+ __xmlIOErr(XML_FROM_HTTP, 0,
+ "Error connecting to remote host");
+ closesocket(s);
+ errno = status;
+ return INVALID_SOCKET;
+ }
} else {
- /* pbm */
- __xmlIOErr(XML_FROM_HTTP, 0, "select failed\n");
- closesocket(s);
- return (-1);
+ /* pbm */
+ __xmlIOErr(XML_FROM_HTTP, 0, "select failed\n");
+ closesocket(s);
+ return INVALID_SOCKET;
}
-
- return(s);
+
+ return (s);
}
-
+
/**
* xmlNanoHTTPConnectHost:
* @host: the host name
@@ -960,7 +1035,7 @@ xmlNanoHTTPConnectAttempt(struct sockaddr *addr)
* Returns -1 in case of failure, the file descriptor number otherwise
*/
-static int
+static SOCKET
xmlNanoHTTPConnectHost(const char *host, int port)
{
struct hostent *h;
@@ -973,7 +1048,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
struct sockaddr_in6 sockin6;
#endif
int i;
- int s;
+ SOCKET s;
memset (&sockin, 0, sizeof(sockin));
#ifdef SUPPORT_IP6
@@ -1004,7 +1079,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
status = getaddrinfo (host, NULL, &hints, &result);
if (status) {
__xmlIOErr(XML_FROM_HTTP, 0, "getaddrinfo failed\n");
- return (-1);
+ return INVALID_SOCKET;
}
for (res = result; res; res = res->ai_next) {
@@ -1012,7 +1087,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
if (res->ai_addrlen > sizeof(sockin)) {
__xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
freeaddrinfo (result);
- return (-1);
+ return INVALID_SOCKET;
}
memcpy (&sockin, res->ai_addr, res->ai_addrlen);
sockin.sin_port = htons (port);
@@ -1022,7 +1097,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
if (res->ai_addrlen > sizeof(sockin6)) {
__xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
freeaddrinfo (result);
- return (-1);
+ return INVALID_SOCKET;
}
memcpy (&sockin6, res->ai_addr, res->ai_addrlen);
sockin6.sin6_port = htons (port);
@@ -1032,7 +1107,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
continue; /* for */
s = xmlNanoHTTPConnectAttempt (addr);
- if (s != -1) {
+ if (s != INVALID_SOCKET) {
freeaddrinfo (result);
return (s);
}
@@ -1047,7 +1122,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
#endif
#if !defined(HAVE_GETADDRINFO) || !defined(_WIN32)
{
- h = gethostbyname (host);
+ h = gethostbyname (GETHOSTBYNAME_ARG_CAST host);
if (h == NULL) {
/*
@@ -1073,10 +1148,12 @@ xmlNanoHTTPConnectHost(const char *host, int port)
"Non-recoverable errors: FORMERR, REFUSED, or NOTIMP.";
break;
+#ifdef NO_ADDRESS
case NO_ADDRESS:
h_err_txt =
"Valid name, no data record of requested type.";
break;
+#endif
default:
h_err_txt = "No error text defined.";
@@ -1086,7 +1163,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
#else
__xmlIOErr(XML_FROM_HTTP, 0, "Failed to resolve host");
#endif
- return (-1);
+ return INVALID_SOCKET;
}
for (i = 0; h->h_addr_list[i]; i++) {
@@ -1094,19 +1171,19 @@ xmlNanoHTTPConnectHost(const char *host, int port)
/* A records (IPv4) */
if ((unsigned int) h->h_length > sizeof(ia)) {
__xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
- return (-1);
+ return INVALID_SOCKET;
}
memcpy (&ia, h->h_addr_list[i], h->h_length);
sockin.sin_family = h->h_addrtype;
sockin.sin_addr = ia;
- sockin.sin_port = (u_short)htons ((unsigned short)port);
+ sockin.sin_port = (unsigned short)htons ((unsigned short)port);
addr = (struct sockaddr *) &sockin;
#ifdef SUPPORT_IP6
} else if (have_ipv6 () && (h->h_addrtype == AF_INET6)) {
/* AAAA records (IPv6) */
if ((unsigned int) h->h_length > sizeof(ia6)) {
__xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
- return (-1);
+ return INVALID_SOCKET;
}
memcpy (&ia6, h->h_addr_list[i], h->h_length);
sockin6.sin6_family = h->h_addrtype;
@@ -1118,7 +1195,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
break; /* for */
s = xmlNanoHTTPConnectAttempt (addr);
- if (s != -1)
+ if (s != INVALID_SOCKET)
return (s);
}
}
@@ -1129,7 +1206,7 @@ xmlNanoHTTPConnectHost(const char *host, int port)
"xmlNanoHTTPConnectHost: unable to connect to '%s'.\n",
host);
#endif
- return (-1);
+ return INVALID_SOCKET;
}
@@ -1201,19 +1278,22 @@ xmlNanoHTTPRead(void *ctx, void *dest, int len) {
#ifdef HAVE_ZLIB_H
if (ctxt->usesGzip == 1) {
if (ctxt->strm == NULL) return(0);
-
+
ctxt->strm->next_out = dest;
ctxt->strm->avail_out = len;
+ ctxt->strm->avail_in = ctxt->inptr - ctxt->inrptr;
- do {
- orig_avail_in = ctxt->strm->avail_in = ctxt->inptr - ctxt->inrptr - bytes_read;
+ while (ctxt->strm->avail_out > 0 &&
+ (ctxt->strm->avail_in > 0 || xmlNanoHTTPRecv(ctxt) > 0)) {
+ orig_avail_in = ctxt->strm->avail_in =
+ ctxt->inptr - ctxt->inrptr - bytes_read;
ctxt->strm->next_in = BAD_CAST (ctxt->inrptr + bytes_read);
z_ret = inflate(ctxt->strm, Z_NO_FLUSH);
bytes_read += orig_avail_in - ctxt->strm->avail_in;
if (z_ret != Z_OK) break;
- } while (ctxt->strm->avail_out > 0 && xmlNanoHTTPRecv(ctxt) > 0);
+ }
ctxt->inrptr += bytes_read;
return(len - ctxt->strm->avail_out);
@@ -1270,30 +1350,30 @@ xmlNanoHTTPMethodRedir(const char *URL, const char *method, const char *input,
const char *headers, int ilen ) {
xmlNanoHTTPCtxtPtr ctxt;
char *bp, *p;
- int blen, ret;
- int head;
+ int blen;
+ SOCKET ret;
int nbRedirects = 0;
char *redirURL = NULL;
#ifdef DEBUG_HTTP
int xmt_bytes;
#endif
-
+
if (URL == NULL) return(NULL);
if (method == NULL) method = "GET";
xmlNanoHTTPInit();
retry:
- if (redirURL == NULL)
+ if (redirURL == NULL) {
ctxt = xmlNanoHTTPNewCtxt(URL);
- else {
+ if (ctxt == NULL)
+ return(NULL);
+ } else {
ctxt = xmlNanoHTTPNewCtxt(redirURL);
+ if (ctxt == NULL)
+ return(NULL);
ctxt->location = xmlMemStrdup(redirURL);
}
- if ( ctxt == NULL ) {
- return ( NULL );
- }
-
if ((ctxt->protocol == NULL) || (strcmp(ctxt->protocol, "http"))) {
__xmlIOErr(XML_FROM_HTTP, XML_HTTP_URL_SYNTAX, "Not a valid HTTP URI");
xmlNanoHTTPFreeCtxt(ctxt);
@@ -1315,7 +1395,7 @@ retry:
blen = strlen(ctxt->hostname);
ret = xmlNanoHTTPConnectHost(ctxt->hostname, ctxt->port);
}
- if (ret < 0) {
+ if (ret == INVALID_SOCKET) {
xmlNanoHTTPFreeCtxt(ctxt);
if (redirURL != NULL) xmlFree(redirURL);
return(NULL);
@@ -1330,13 +1410,23 @@ retry:
if (headers != NULL)
blen += strlen(headers) + 2;
if (contentType && *contentType)
+ /* reserve for string plus 'Content-Type: \r\n" */
blen += strlen(*contentType) + 16;
if (ctxt->query != NULL)
+ /* 1 for '?' */
blen += strlen(ctxt->query) + 1;
blen += strlen(method) + strlen(ctxt->path) + 24;
#ifdef HAVE_ZLIB_H
+ /* reserve for possible 'Accept-Encoding: gzip' string */
blen += 23;
#endif
+ if (ctxt->port != 80) {
+ /* reserve space for ':xxxxx', incl. potential proxy */
+ if (proxy)
+ blen += 12;
+ else
+ blen += 6;
+ }
bp = (char*)xmlMallocAtomic(blen);
if ( bp == NULL ) {
xmlNanoHTTPFreeCtxt( ctxt );
@@ -1348,13 +1438,13 @@ retry:
if (proxy) {
if (ctxt->port != 80) {
- p += snprintf( p, blen - (p - bp), "%s http://%s:%d%s",
+ p += snprintf( p, blen - (p - bp), "%s http://%s:%d%s",
method, ctxt->hostname,
- ctxt->port, ctxt->path );
+ ctxt->port, ctxt->path );
}
- else
+ else
p += snprintf( p, blen - (p - bp), "%s http://%s%s", method,
- ctxt->hostname, ctxt->path);
+ ctxt->hostname, ctxt->path);
}
else
p += snprintf( p, blen - (p - bp), "%s %s", method, ctxt->path);
@@ -1362,14 +1452,19 @@ retry:
if (ctxt->query != NULL)
p += snprintf( p, blen - (p - bp), "?%s", ctxt->query);
- p += snprintf( p, blen - (p - bp), " HTTP/1.0\r\nHost: %s\r\n",
+ if (ctxt->port == 80) {
+ p += snprintf( p, blen - (p - bp), " HTTP/1.0\r\nHost: %s\r\n",
ctxt->hostname);
+ } else {
+ p += snprintf( p, blen - (p - bp), " HTTP/1.0\r\nHost: %s:%d\r\n",
+ ctxt->hostname, ctxt->port);
+ }
#ifdef HAVE_ZLIB_H
p += snprintf(p, blen - (p - bp), "Accept-Encoding: gzip\r\n");
#endif
- if (contentType != NULL && *contentType)
+ if (contentType != NULL && *contentType)
p += snprintf(p, blen - (p - bp), "Content-Type: %s\r\n", *contentType);
if (headers != NULL)
@@ -1408,7 +1503,7 @@ retry:
if ( xmt_bytes != ilen )
xmlGenericError( xmlGenericErrorContext,
- "xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n",
+ "xmlNanoHTTPMethodRedir: Only %d of %d %s %s\n",
xmt_bytes, ilen,
"bytes of HTTP content sent to host",
ctxt->hostname );
@@ -1418,11 +1513,9 @@ retry:
}
ctxt->state = XML_NANO_HTTP_READ;
- head = 1;
while ((p = xmlNanoHTTPReadLine(ctxt)) != NULL) {
- if (head && (*p == 0)) {
- head = 0;
+ if (*p == 0) {
ctxt->content = ctxt->inrptr;
xmlFree(p);
break;
@@ -1532,12 +1625,13 @@ xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) {
char *buf = NULL;
int fd;
int len;
-
+ int ret = 0;
+
if (filename == NULL) return(-1);
ctxt = xmlNanoHTTPOpen(URL, contentType);
if (ctxt == NULL) return(-1);
- if (!strcmp(filename, "-"))
+ if (!strcmp(filename, "-"))
fd = 0;
else {
fd = open(filename, O_CREAT | O_WRONLY, 00644);
@@ -1553,12 +1647,14 @@ xmlNanoHTTPFetch(const char *URL, const char *filename, char **contentType) {
xmlNanoHTTPFetchContent( ctxt, &buf, &len );
if ( len > 0 ) {
- write(fd, buf, len);
+ if (write(fd, buf, len) == -1) {
+ ret = -1;
+ }
}
xmlNanoHTTPClose(ctxt);
close(fd);
- return(0);
+ return(ret);
}
#ifdef LIBXML_OUTPUT_ENABLED
@@ -1577,13 +1673,14 @@ xmlNanoHTTPSave(void *ctxt, const char *filename) {
char *buf = NULL;
int fd;
int len;
-
+ int ret = 0;
+
if ((ctxt == NULL) || (filename == NULL)) return(-1);
- if (!strcmp(filename, "-"))
+ if (!strcmp(filename, "-"))
fd = 0;
else {
- fd = open(filename, O_CREAT | O_WRONLY);
+ fd = open(filename, O_CREAT | O_WRONLY, 0666);
if (fd < 0) {
xmlNanoHTTPClose(ctxt);
return(-1);
@@ -1592,12 +1689,14 @@ xmlNanoHTTPSave(void *ctxt, const char *filename) {
xmlNanoHTTPFetchContent( ctxt, &buf, &len );
if ( len > 0 ) {
- write(fd, buf, len);
+ if (write(fd, buf, len) == -1) {
+ ret = -1;
+ }
}
xmlNanoHTTPClose(ctxt);
close(fd);
- return(0);
+ return(ret);
}
#endif /* LIBXML_OUTPUT_ENABLED */
@@ -1707,7 +1806,7 @@ xmlNanoHTTPMimeType( void * ctx ) {
* Check if all the content was read
*
* Returns 0 if all the content was read and available, returns
- * -1 if received content length was less than specified or an error
+ * -1 if received content length was less than specified or an error
* occurred.
*/
static int
@@ -1761,7 +1860,7 @@ int main(int argc, char **argv) {
char *contentType = NULL;
if (argv[1] != NULL) {
- if (argv[2] != NULL)
+ if (argv[2] != NULL)
xmlNanoHTTPFetch(argv[1], argv[2], &contentType);
else
xmlNanoHTTPFetch(argv[1], "-", &contentType);
diff --git a/gnulib-local/lib/libxml/nanohttp.in.h b/gnulib-local/lib/libxml/nanohttp.in.h
index 1d8ac24..22b8fb4 100644
--- a/gnulib-local/lib/libxml/nanohttp.in.h
+++ b/gnulib-local/lib/libxml/nanohttp.in.h
@@ -7,7 +7,7 @@
*
* Author: Daniel Veillard
*/
-
+
#ifndef __NANO_HTTP_H__
#define __NANO_HTTP_H__
@@ -20,22 +20,22 @@ extern "C" {
#endif
XMLPUBFUN void XMLCALL
xmlNanoHTTPInit (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNanoHTTPCleanup (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNanoHTTPScanProxy (const char *URL);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoHTTPFetch (const char *URL,
const char *filename,
char **contentType);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlNanoHTTPMethod (const char *URL,
const char *method,
const char *input,
char **contentType,
const char *headers,
int ilen);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlNanoHTTPMethodRedir (const char *URL,
const char *method,
const char *input,
@@ -43,16 +43,16 @@ XMLPUBFUN void * XMLCALL
char **redir,
const char *headers,
int ilen);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlNanoHTTPOpen (const char *URL,
char **contentType);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlNanoHTTPOpenRedir (const char *URL,
char **contentType,
char **redir);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoHTTPReturnCode (void *ctx);
-XMLPUBFUN const char * XMLCALL
+XMLPUBFUN const char * XMLCALL
xmlNanoHTTPAuthHeader (void *ctx);
XMLPUBFUN const char * XMLCALL
xmlNanoHTTPRedir (void *ctx);
@@ -62,16 +62,16 @@ XMLPUBFUN const char * XMLCALL
xmlNanoHTTPEncoding (void *ctx);
XMLPUBFUN const char * XMLCALL
xmlNanoHTTPMimeType (void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoHTTPRead (void *ctx,
void *dest,
int len);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNanoHTTPSave (void *ctxt,
const char *filename);
#endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNanoHTTPClose (void *ctx);
#ifdef __cplusplus
}
diff --git a/gnulib-local/lib/libxml/parser.c b/gnulib-local/lib/libxml/parser.c
index bd44585..c5741e3 100644
--- a/gnulib-local/lib/libxml/parser.c
+++ b/gnulib-local/lib/libxml/parser.c
@@ -17,7 +17,7 @@
* parserInternals.c to reduce this file size.
* As much as possible the functions are associated with their relative
* production in the XML specification. A few productions defining the
- * different ranges of character are actually implanted either in
+ * different ranges of character are actually implanted either in
* parserInternals.h or parserInternals.c
* The DOM tree build is realized from the default SAX callbacks in
* the module SAX.c.
@@ -40,6 +40,7 @@
#endif
#include <stdlib.h>
+#include <limits.h>
#include <string.h>
#include <stdarg.h>
#include <libxml/xmlmemory.h>
@@ -79,36 +80,193 @@
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
+#ifdef HAVE_LZMA_H
+#include <lzma.h>
+#endif
+
+#include "buf.h"
+#include "enc.h"
+
+static void
+xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info);
+
+static xmlParserCtxtPtr
+xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID,
+ const xmlChar *base, xmlParserCtxtPtr pctx);
+
+static void xmlHaltParser(xmlParserCtxtPtr ctxt);
+
+/************************************************************************
+ * *
+ * Arbitrary limits set in the parser. See XML_PARSE_HUGE *
+ * *
+ ************************************************************************/
+
+#define XML_PARSER_BIG_ENTITY 1000
+#define XML_PARSER_LOT_ENTITY 5000
+
+/*
+ * XML_PARSER_NON_LINEAR is the threshold where the ratio of parsed entity
+ * replacement over the size in byte of the input indicates that you have
+ * and eponential behaviour. A value of 10 correspond to at least 3 entity
+ * replacement per byte of input.
+ */
+#define XML_PARSER_NON_LINEAR 10
+
+/*
+ * xmlParserEntityCheck
+ *
+ * Function to check non-linear entity expansion behaviour
+ * This is here to detect and stop exponential linear entity expansion
+ * This is not a limitation of the parser but a safety
+ * boundary feature. It can be disabled with the XML_PARSE_HUGE
+ * parser option.
+ */
+static int
+xmlParserEntityCheck(xmlParserCtxtPtr ctxt, size_t size,
+ xmlEntityPtr ent, size_t replacement)
+{
+ size_t consumed = 0;
+
+ if ((ctxt == NULL) || (ctxt->options & XML_PARSE_HUGE))
+ return (0);
+ if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)
+ return (1);
+
+ /*
+ * This may look absurd but is needed to detect
+ * entities problems
+ */
+ if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
+ (ent->content != NULL) && (ent->checked == 0)) {
+ unsigned long oldnbent = ctxt->nbentities;
+ xmlChar *rep;
+
+ ent->checked = 1;
+
+ rep = xmlStringDecodeEntities(ctxt, ent->content,
+ XML_SUBSTITUTE_REF, 0, 0, 0);
+
+ ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
+ if (rep != NULL) {
+ if (xmlStrchr(rep, '<'))
+ ent->checked |= 1;
+ xmlFree(rep);
+ rep = NULL;
+ }
+ }
+ if (replacement != 0) {
+ if (replacement < XML_MAX_TEXT_LENGTH)
+ return(0);
+
+ /*
+ * If the volume of entity copy reaches 10 times the
+ * amount of parsed data and over the large text threshold
+ * then that's very likely to be an abuse.
+ */
+ if (ctxt->input != NULL) {
+ consumed = ctxt->input->consumed +
+ (ctxt->input->cur - ctxt->input->base);
+ }
+ consumed += ctxt->sizeentities;
+
+ if (replacement < XML_PARSER_NON_LINEAR * consumed)
+ return(0);
+ } else if (size != 0) {
+ /*
+ * Do the check based on the replacement size of the entity
+ */
+ if (size < XML_PARSER_BIG_ENTITY)
+ return(0);
+
+ /*
+ * A limit on the amount of text data reasonably used
+ */
+ if (ctxt->input != NULL) {
+ consumed = ctxt->input->consumed +
+ (ctxt->input->cur - ctxt->input->base);
+ }
+ consumed += ctxt->sizeentities;
+
+ if ((size < XML_PARSER_NON_LINEAR * consumed) &&
+ (ctxt->nbentities * 3 < XML_PARSER_NON_LINEAR * consumed))
+ return (0);
+ } else if (ent != NULL) {
+ /*
+ * use the number of parsed entities in the replacement
+ */
+ size = ent->checked / 2;
+
+ /*
+ * The amount of data parsed counting entities size only once
+ */
+ if (ctxt->input != NULL) {
+ consumed = ctxt->input->consumed +
+ (ctxt->input->cur - ctxt->input->base);
+ }
+ consumed += ctxt->sizeentities;
+
+ /*
+ * Check the density of entities for the amount of data
+ * knowing an entity reference will take at least 3 bytes
+ */
+ if (size * 3 < consumed * XML_PARSER_NON_LINEAR)
+ return (0);
+ } else {
+ /*
+ * strange we got no data for checking
+ */
+ if (((ctxt->lastError.code != XML_ERR_UNDECLARED_ENTITY) &&
+ (ctxt->lastError.code != XML_WAR_UNDECLARED_ENTITY)) ||
+ (ctxt->nbentities <= 10000))
+ return (0);
+ }
+ xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
+ return (1);
+}
/**
* 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.
+ * 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.
*/
-unsigned int xmlParserMaxDepth = 1024;
+unsigned int xmlParserMaxDepth = 256;
-#define SAX2 1
+
+#define SAX2 1
#define XML_PARSER_BIG_BUFFER_SIZE 300
#define XML_PARSER_BUFFER_SIZE 100
-
#define SAX_COMPAT_MODE BAD_CAST "SAX compatibility mode document"
+/**
+ * XML_PARSER_CHUNK_SIZE
+ *
+ * When calling GROW that's the minimal amount of data
+ * the parser expected to have received. It is not a hard
+ * limit but an optimization when reading strings like Names
+ * It is not strictly needed as long as inputs available characters
+ * are followed by 0, which should be provided by the I/O level
+ */
+#define XML_PARSER_CHUNK_SIZE 100
+
/*
* List of XML prefixed PI allowed by W3C specs
*/
static const char *xmlW3CPIs[] = {
"xml-stylesheet",
+ "xml-model",
NULL
};
/* DEPR void xmlParserHandleReference(xmlParserCtxtPtr ctxt); */
-xmlEntityPtr xmlParseStringPEReference(xmlParserCtxtPtr ctxt,
- const xmlChar **str);
+static xmlEntityPtr xmlParseStringPEReference(xmlParserCtxtPtr ctxt,
+ const xmlChar **str);
static xmlParserErrors
xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
@@ -116,6 +274,9 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
void *user_data, int depth, const xmlChar *URL,
const xmlChar *ID, xmlNodePtr *list);
+static int
+xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options,
+ const char *encoding);
#ifdef LIBXML_LEGACY_ENABLED
static void
xmlAddEntityReference(xmlEntityPtr ent, xmlNodePtr firstNode,
@@ -126,9 +287,12 @@ static xmlParserErrors
xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
const xmlChar *string, void *user_data, xmlNodePtr *lst);
+static int
+xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity);
+
/************************************************************************
* *
- * Some factorized error routines *
+ * Some factorized error routines *
* *
************************************************************************/
@@ -149,14 +313,15 @@ xmlErrAttributeDup(xmlParserCtxtPtr ctxt, const xmlChar * prefix,
return;
if (ctxt != NULL)
ctxt->errNo = XML_ERR_ATTRIBUTE_REDEFINED;
+
if (prefix == NULL)
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
- ctxt->errNo, XML_ERR_FATAL, NULL, 0,
+ XML_ERR_ATTRIBUTE_REDEFINED, XML_ERR_FATAL, NULL, 0,
(const char *) localname, NULL, NULL, 0, 0,
"Attribute %s redefined\n", localname);
else
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
- ctxt->errNo, XML_ERR_FATAL, NULL, 0,
+ XML_ERR_ATTRIBUTE_REDEFINED, XML_ERR_FATAL, NULL, 0,
(const char *) prefix, (const char *) localname,
NULL, 0, 0, "Attribute %s:%s redefined\n", prefix,
localname);
@@ -179,193 +344,201 @@ static void
xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
{
const char *errmsg;
+ char errstr[129] = "";
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
(ctxt->instate == XML_PARSER_EOF))
return;
switch (error) {
case XML_ERR_INVALID_HEX_CHARREF:
- errmsg = "CharRef: invalid hexadecimal value\n";
+ errmsg = "CharRef: invalid hexadecimal value";
break;
case XML_ERR_INVALID_DEC_CHARREF:
- errmsg = "CharRef: invalid decimal value\n";
+ errmsg = "CharRef: invalid decimal value";
break;
case XML_ERR_INVALID_CHARREF:
- errmsg = "CharRef: invalid value\n";
+ errmsg = "CharRef: invalid value";
break;
case XML_ERR_INTERNAL_ERROR:
errmsg = "internal error";
break;
case XML_ERR_PEREF_AT_EOF:
- errmsg = "PEReference at end of document\n";
+ errmsg = "PEReference at end of document";
break;
case XML_ERR_PEREF_IN_PROLOG:
- errmsg = "PEReference in prolog\n";
+ errmsg = "PEReference in prolog";
break;
case XML_ERR_PEREF_IN_EPILOG:
- errmsg = "PEReference in epilog\n";
+ errmsg = "PEReference in epilog";
break;
case XML_ERR_PEREF_NO_NAME:
- errmsg = "PEReference: no name\n";
+ errmsg = "PEReference: no name";
break;
case XML_ERR_PEREF_SEMICOL_MISSING:
- errmsg = "PEReference: expecting ';'\n";
+ errmsg = "PEReference: expecting ';'";
break;
case XML_ERR_ENTITY_LOOP:
- errmsg = "Detected an entity reference loop\n";
+ errmsg = "Detected an entity reference loop";
break;
case XML_ERR_ENTITY_NOT_STARTED:
- errmsg = "EntityValue: \" or ' expected\n";
+ errmsg = "EntityValue: \" or ' expected";
break;
case XML_ERR_ENTITY_PE_INTERNAL:
- errmsg = "PEReferences forbidden in internal subset\n";
+ errmsg = "PEReferences forbidden in internal subset";
break;
case XML_ERR_ENTITY_NOT_FINISHED:
- errmsg = "EntityValue: \" or ' expected\n";
+ errmsg = "EntityValue: \" or ' expected";
break;
case XML_ERR_ATTRIBUTE_NOT_STARTED:
- errmsg = "AttValue: \" or ' expected\n";
+ errmsg = "AttValue: \" or ' expected";
break;
case XML_ERR_LT_IN_ATTRIBUTE:
- errmsg = "Unescaped '<' not allowed in attributes values\n";
+ errmsg = "Unescaped '<' not allowed in attributes values";
break;
case XML_ERR_LITERAL_NOT_STARTED:
- errmsg = "SystemLiteral \" or ' expected\n";
+ errmsg = "SystemLiteral \" or ' expected";
break;
case XML_ERR_LITERAL_NOT_FINISHED:
- errmsg = "Unfinished System or Public ID \" or ' expected\n";
+ errmsg = "Unfinished System or Public ID \" or ' expected";
break;
case XML_ERR_MISPLACED_CDATA_END:
- errmsg = "Sequence ']]>' not allowed in content\n";
+ errmsg = "Sequence ']]>' not allowed in content";
break;
case XML_ERR_URI_REQUIRED:
- errmsg = "SYSTEM or PUBLIC, the URI is missing\n";
+ errmsg = "SYSTEM or PUBLIC, the URI is missing";
break;
case XML_ERR_PUBID_REQUIRED:
- errmsg = "PUBLIC, the Public Identifier is missing\n";
+ errmsg = "PUBLIC, the Public Identifier is missing";
break;
case XML_ERR_HYPHEN_IN_COMMENT:
- errmsg = "Comment must not contain '--' (double-hyphen)\n";
+ errmsg = "Comment must not contain '--' (double-hyphen)";
break;
case XML_ERR_PI_NOT_STARTED:
- errmsg = "xmlParsePI : no target name\n";
+ errmsg = "xmlParsePI : no target name";
break;
case XML_ERR_RESERVED_XML_NAME:
- errmsg = "Invalid PI name\n";
+ errmsg = "Invalid PI name";
break;
case XML_ERR_NOTATION_NOT_STARTED:
- errmsg = "NOTATION: Name expected here\n";
+ errmsg = "NOTATION: Name expected here";
break;
case XML_ERR_NOTATION_NOT_FINISHED:
- errmsg = "'>' required to close NOTATION declaration\n";
+ errmsg = "'>' required to close NOTATION declaration";
break;
case XML_ERR_VALUE_REQUIRED:
- errmsg = "Entity value required\n";
+ errmsg = "Entity value required";
break;
case XML_ERR_URI_FRAGMENT:
errmsg = "Fragment not allowed";
break;
case XML_ERR_ATTLIST_NOT_STARTED:
- errmsg = "'(' required to start ATTLIST enumeration\n";
+ errmsg = "'(' required to start ATTLIST enumeration";
break;
case XML_ERR_NMTOKEN_REQUIRED:
- errmsg = "NmToken expected in ATTLIST enumeration\n";
+ errmsg = "NmToken expected in ATTLIST enumeration";
break;
case XML_ERR_ATTLIST_NOT_FINISHED:
- errmsg = "')' required to finish ATTLIST enumeration\n";
+ errmsg = "')' required to finish ATTLIST enumeration";
break;
case XML_ERR_MIXED_NOT_STARTED:
- errmsg = "MixedContentDecl : '|' or ')*' expected\n";
+ errmsg = "MixedContentDecl : '|' or ')*' expected";
break;
case XML_ERR_PCDATA_REQUIRED:
- errmsg = "MixedContentDecl : '#PCDATA' expected\n";
+ errmsg = "MixedContentDecl : '#PCDATA' expected";
break;
case XML_ERR_ELEMCONTENT_NOT_STARTED:
- errmsg = "ContentDecl : Name or '(' expected\n";
+ errmsg = "ContentDecl : Name or '(' expected";
break;
case XML_ERR_ELEMCONTENT_NOT_FINISHED:
- errmsg = "ContentDecl : ',' '|' or ')' expected\n";
+ errmsg = "ContentDecl : ',' '|' or ')' expected";
break;
case XML_ERR_PEREF_IN_INT_SUBSET:
errmsg =
- "PEReference: forbidden within markup decl in internal subset\n";
+ "PEReference: forbidden within markup decl in internal subset";
break;
case XML_ERR_GT_REQUIRED:
- errmsg = "expected '>'\n";
+ errmsg = "expected '>'";
break;
case XML_ERR_CONDSEC_INVALID:
- errmsg = "XML conditional section '[' expected\n";
+ errmsg = "XML conditional section '[' expected";
break;
case XML_ERR_EXT_SUBSET_NOT_FINISHED:
- errmsg = "Content error in the external subset\n";
+ errmsg = "Content error in the external subset";
break;
case XML_ERR_CONDSEC_INVALID_KEYWORD:
errmsg =
- "conditional section INCLUDE or IGNORE keyword expected\n";
+ "conditional section INCLUDE or IGNORE keyword expected";
break;
case XML_ERR_CONDSEC_NOT_FINISHED:
- errmsg = "XML conditional section not closed\n";
+ errmsg = "XML conditional section not closed";
break;
case XML_ERR_XMLDECL_NOT_STARTED:
- errmsg = "Text declaration '<?xml' required\n";
+ errmsg = "Text declaration '<?xml' required";
break;
case XML_ERR_XMLDECL_NOT_FINISHED:
- errmsg = "parsing XML declaration: '?>' expected\n";
+ errmsg = "parsing XML declaration: '?>' expected";
break;
case XML_ERR_EXT_ENTITY_STANDALONE:
- errmsg = "external parsed entities cannot be standalone\n";
+ errmsg = "external parsed entities cannot be standalone";
break;
case XML_ERR_ENTITYREF_SEMICOL_MISSING:
- errmsg = "EntityRef: expecting ';'\n";
+ errmsg = "EntityRef: expecting ';'";
break;
case XML_ERR_DOCTYPE_NOT_FINISHED:
- errmsg = "DOCTYPE improperly terminated\n";
+ errmsg = "DOCTYPE improperly terminated";
break;
case XML_ERR_LTSLASH_REQUIRED:
- errmsg = "EndTag: '</' not found\n";
+ errmsg = "EndTag: '</' not found";
break;
case XML_ERR_EQUAL_REQUIRED:
- errmsg = "expected '='\n";
+ errmsg = "expected '='";
break;
case XML_ERR_STRING_NOT_CLOSED:
- errmsg = "String not closed expecting \" or '\n";
+ errmsg = "String not closed expecting \" or '";
break;
case XML_ERR_STRING_NOT_STARTED:
- errmsg = "String not started expecting ' or \"\n";
+ errmsg = "String not started expecting ' or \"";
break;
case XML_ERR_ENCODING_NAME:
- errmsg = "Invalid XML encoding name\n";
+ errmsg = "Invalid XML encoding name";
break;
case XML_ERR_STANDALONE_VALUE:
- errmsg = "standalone accepts only 'yes' or 'no'\n";
+ errmsg = "standalone accepts only 'yes' or 'no'";
break;
case XML_ERR_DOCUMENT_EMPTY:
- errmsg = "Document is empty\n";
+ errmsg = "Document is empty";
break;
case XML_ERR_DOCUMENT_END:
- errmsg = "Extra content at the end of the document\n";
+ errmsg = "Extra content at the end of the document";
break;
case XML_ERR_NOT_WELL_BALANCED:
- errmsg = "chunk is not well balanced\n";
+ errmsg = "chunk is not well balanced";
break;
case XML_ERR_EXTRA_CONTENT:
- errmsg = "extra content at the end of well balanced chunk\n";
+ errmsg = "extra content at the end of well balanced chunk";
break;
case XML_ERR_VERSION_MISSING:
- errmsg = "Malformed declaration expecting version\n";
+ errmsg = "Malformed declaration expecting version";
+ break;
+ case XML_ERR_NAME_TOO_LONG:
+ errmsg = "Name too long use XML_PARSE_HUGE option";
break;
#if 0
case:
- errmsg = "\n";
+ errmsg = "";
break;
#endif
default:
- errmsg = "Unregistered error message\n";
+ errmsg = "Unregistered error message";
}
+ if (info == NULL)
+ snprintf(errstr, 128, "%s\n", errmsg);
+ else
+ snprintf(errstr, 128, "%s: %%s\n", errmsg);
if (ctxt != NULL)
ctxt->errNo = error;
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
- XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, errmsg,
+ XML_ERR_FATAL, NULL, 0, info, NULL, NULL, 0, 0, &errstr[0],
info);
if (ctxt != NULL) {
ctxt->wellFormed = 0;
@@ -392,7 +565,7 @@ xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
if (ctxt != NULL)
ctxt->errNo = error;
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
- XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, msg);
+ XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg);
if (ctxt != NULL) {
ctxt->wellFormed = 0;
if (ctxt->recovery == 0)
@@ -415,20 +588,28 @@ xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
const char *msg, const xmlChar *str1, const xmlChar *str2)
{
xmlStructuredErrorFunc schannel = NULL;
-
+
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
(ctxt->instate == XML_PARSER_EOF))
return;
if ((ctxt != NULL) && (ctxt->sax != NULL) &&
(ctxt->sax->initialized == XML_SAX2_MAGIC))
schannel = ctxt->sax->serror;
- __xmlRaiseError(schannel,
+ if (ctxt != NULL) {
+ __xmlRaiseError(schannel,
(ctxt->sax) ? ctxt->sax->warning : NULL,
ctxt->userData,
ctxt, NULL, XML_FROM_PARSER, error,
XML_ERR_WARNING, NULL, 0,
(const char *) str1, (const char *) str2, NULL, 0, 0,
msg, (const char *) str1, (const char *) str2);
+ } else {
+ __xmlRaiseError(schannel, NULL, NULL,
+ ctxt, NULL, XML_FROM_PARSER, error,
+ XML_ERR_WARNING, NULL, 0,
+ (const char *) str1, (const char *) str2, NULL, 0, 0,
+ msg, (const char *) str1, (const char *) str2);
+ }
}
/**
@@ -442,7 +623,7 @@ xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
*/
static void
xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error,
- const char *msg, const xmlChar *str1)
+ const char *msg, const xmlChar *str1, const xmlChar *str2)
{
xmlStructuredErrorFunc schannel = NULL;
@@ -454,14 +635,20 @@ xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error,
if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
schannel = ctxt->sax->serror;
}
- __xmlRaiseError(schannel,
+ if (ctxt != NULL) {
+ __xmlRaiseError(schannel,
ctxt->vctxt.error, ctxt->vctxt.userData,
ctxt, NULL, XML_FROM_DTD, error,
XML_ERR_ERROR, NULL, 0, (const char *) str1,
- NULL, NULL, 0, 0,
- msg, (const char *) str1);
- if (ctxt != NULL) {
+ (const char *) str2, NULL, 0, 0,
+ msg, (const char *) str1, (const char *) str2);
ctxt->valid = 0;
+ } else {
+ __xmlRaiseError(schannel, NULL, NULL,
+ ctxt, NULL, XML_FROM_DTD, error,
+ XML_ERR_ERROR, NULL, 0, (const char *) str1,
+ (const char *) str2, NULL, 0, 0,
+ msg, (const char *) str1, (const char *) str2);
}
}
@@ -506,7 +693,7 @@ xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
*/
static void
xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
- const char *msg, const xmlChar *str1, int val,
+ const char *msg, const xmlChar *str1, int val,
const xmlChar *str2)
{
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
@@ -607,9 +794,34 @@ xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
ctxt->nsWellFormed = 0;
}
+/**
+ * xmlNsWarn
+ * @ctxt: an XML parser context
+ * @error: the error number
+ * @msg: the message
+ * @info1: extra information string
+ * @info2: extra information string
+ *
+ * Handle a namespace warning error
+ */
+static void
+xmlNsWarn(xmlParserCtxtPtr ctxt, xmlParserErrors error,
+ const char *msg,
+ const xmlChar * info1, const xmlChar * info2,
+ const xmlChar * info3)
+{
+ if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
+ (ctxt->instate == XML_PARSER_EOF))
+ return;
+ __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
+ XML_ERR_WARNING, NULL, 0, (const char *) info1,
+ (const char *) info2, (const char *) info3, 0, 0, msg,
+ info1, info2, info3);
+}
+
/************************************************************************
* *
- * Library wide options *
+ * Library wide options *
* *
************************************************************************/
@@ -806,13 +1018,25 @@ xmlHasFeature(xmlFeature feature)
return(1);
#else
return(0);
-#endif
+#endif
case XML_WITH_ZLIB:
#ifdef LIBXML_ZLIB_ENABLED
return(1);
#else
return(0);
#endif
+ case XML_WITH_LZMA:
+#ifdef LIBXML_LZMA_ENABLED
+ return(1);
+#else
+ return(0);
+#endif
+ case XML_WITH_ICU:
+#ifdef LIBXML_ICU_ENABLED
+ return(1);
+#else
+ return(0);
+#endif
default:
break;
}
@@ -821,7 +1045,7 @@ xmlHasFeature(xmlFeature feature)
/************************************************************************
* *
- * SAX2 defaulted attributes handling *
+ * SAX2 defaulted attributes handling *
* *
************************************************************************/
@@ -845,8 +1069,8 @@ xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
ctxt->str_xml = xmlDictLookup(ctxt->dict, BAD_CAST "xml", 3);
ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
- if ((ctxt->str_xml==NULL) || (ctxt->str_xmlns==NULL) ||
- (ctxt->str_xml_ns == NULL)) {
+ if ((ctxt->str_xml==NULL) || (ctxt->str_xmlns==NULL) ||
+ (ctxt->str_xml_ns == NULL)) {
xmlErrMemory(ctxt, NULL);
}
}
@@ -856,10 +1080,108 @@ typedef xmlDefAttrs *xmlDefAttrsPtr;
struct _xmlDefAttrs {
int nbAttrs; /* number of defaulted attributes on that element */
int maxAttrs; /* the size of the array */
- const xmlChar *values[4]; /* array of localname/prefix/values */
+ const xmlChar *values[5]; /* array of localname/prefix/values/external */
};
/**
+ * xmlAttrNormalizeSpace:
+ * @src: the source string
+ * @dst: the target string
+ *
+ * Normalize the space in non CDATA attribute values:
+ * If the attribute type 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 a single space (#x20) character.
+ * Note that the size of dst need to be at least src, and if one doesn't need
+ * to preserve dst (and it doesn't come from a dictionary or read-only) then
+ * passing src as dst is just fine.
+ *
+ * Returns a pointer to the normalized value (dst) or NULL if no conversion
+ * is needed.
+ */
+static xmlChar *
+xmlAttrNormalizeSpace(const xmlChar *src, xmlChar *dst)
+{
+ if ((src == NULL) || (dst == NULL))
+ return(NULL);
+
+ while (*src == 0x20) src++;
+ while (*src != 0) {
+ if (*src == 0x20) {
+ while (*src == 0x20) src++;
+ if (*src != 0)
+ *dst++ = 0x20;
+ } else {
+ *dst++ = *src++;
+ }
+ }
+ *dst = 0;
+ if (dst == src)
+ return(NULL);
+ return(dst);
+}
+
+/**
+ * xmlAttrNormalizeSpace2:
+ * @src: the source string
+ *
+ * Normalize the space in non CDATA attribute values, a slightly more complex
+ * front end to avoid allocation problems when running on attribute values
+ * coming from the input.
+ *
+ * Returns a pointer to the normalized value (dst) or NULL if no conversion
+ * is needed.
+ */
+static const xmlChar *
+xmlAttrNormalizeSpace2(xmlParserCtxtPtr ctxt, xmlChar *src, int *len)
+{
+ int i;
+ int remove_head = 0;
+ int need_realloc = 0;
+ const xmlChar *cur;
+
+ if ((ctxt == NULL) || (src == NULL) || (len == NULL))
+ return(NULL);
+ i = *len;
+ if (i <= 0)
+ return(NULL);
+
+ cur = src;
+ while (*cur == 0x20) {
+ cur++;
+ remove_head++;
+ }
+ while (*cur != 0) {
+ if (*cur == 0x20) {
+ cur++;
+ if ((*cur == 0x20) || (*cur == 0)) {
+ need_realloc = 1;
+ break;
+ }
+ } else
+ cur++;
+ }
+ if (need_realloc) {
+ xmlChar *ret;
+
+ ret = xmlStrndup(src + remove_head, i - remove_head + 1);
+ if (ret == NULL) {
+ xmlErrMemory(ctxt, NULL);
+ return(NULL);
+ }
+ xmlAttrNormalizeSpace(ret, ret);
+ *len = (int) strlen((const char *)ret);
+ return(ret);
+ } else if (remove_head) {
+ *len -= remove_head;
+ memmove(src, src + remove_head, 1 + *len);
+ return(src);
+ }
+ return(NULL);
+}
+
+/**
* xmlAddDefAttrs:
* @ctxt: an XML parser context
* @fullname: the element fullname
@@ -878,6 +1200,14 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
const xmlChar *name;
const xmlChar *prefix;
+ /*
+ * Allows to detect attribute redefinitions
+ */
+ if (ctxt->attsSpecial != NULL) {
+ if (xmlHashLookup2(ctxt->attsSpecial, fullname, fullattr) != NULL)
+ return;
+ }
+
if (ctxt->attsDefault == NULL) {
ctxt->attsDefault = xmlHashCreateDict(10, ctxt->dict);
if (ctxt->attsDefault == NULL)
@@ -903,22 +1233,30 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
defaults = xmlHashLookup2(ctxt->attsDefault, name, prefix);
if (defaults == NULL) {
defaults = (xmlDefAttrsPtr) xmlMalloc(sizeof(xmlDefAttrs) +
- (4 * 4) * sizeof(const xmlChar *));
+ (4 * 5) * sizeof(const xmlChar *));
if (defaults == NULL)
goto mem_error;
defaults->nbAttrs = 0;
defaults->maxAttrs = 4;
- xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix, defaults, NULL);
+ if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix,
+ defaults, NULL) < 0) {
+ xmlFree(defaults);
+ goto mem_error;
+ }
} else if (defaults->nbAttrs >= defaults->maxAttrs) {
xmlDefAttrsPtr temp;
temp = (xmlDefAttrsPtr) xmlRealloc(defaults, sizeof(xmlDefAttrs) +
- (2 * defaults->maxAttrs * 4) * sizeof(const xmlChar *));
+ (2 * defaults->maxAttrs * 5) * sizeof(const xmlChar *));
if (temp == NULL)
goto mem_error;
defaults = temp;
defaults->maxAttrs *= 2;
- xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix, defaults, NULL);
+ if (xmlHashUpdateEntry2(ctxt->attsDefault, name, prefix,
+ defaults, NULL) < 0) {
+ xmlFree(defaults);
+ goto mem_error;
+ }
}
/*
@@ -934,13 +1272,17 @@ xmlAddDefAttrs(xmlParserCtxtPtr ctxt,
prefix = xmlDictLookup(ctxt->dict, fullattr, len);
}
- defaults->values[4 * defaults->nbAttrs] = name;
- defaults->values[4 * defaults->nbAttrs + 1] = prefix;
+ defaults->values[5 * defaults->nbAttrs] = name;
+ defaults->values[5 * defaults->nbAttrs + 1] = prefix;
/* intern the string and precompute the end */
len = xmlStrlen(value);
value = xmlDictLookup(ctxt->dict, value, len);
- defaults->values[4 * defaults->nbAttrs + 2] = value;
- defaults->values[4 * defaults->nbAttrs + 3] = value + len;
+ defaults->values[5 * defaults->nbAttrs + 2] = value;
+ defaults->values[5 * defaults->nbAttrs + 3] = value + len;
+ if (ctxt->external)
+ defaults->values[5 * defaults->nbAttrs + 4] = BAD_CAST "external";
+ else
+ defaults->values[5 * defaults->nbAttrs + 4] = NULL;
defaults->nbAttrs++;
return;
@@ -957,7 +1299,7 @@ mem_error:
* @fullattr: the attribute fullname
* @type: the attribute type
*
- * Register that this attribute is not CDATA
+ * Register this attribute type
*/
static void
xmlAddSpecialAttr(xmlParserCtxtPtr ctxt,
@@ -971,6 +1313,9 @@ xmlAddSpecialAttr(xmlParserCtxtPtr ctxt,
goto mem_error;
}
+ if (xmlHashLookup2(ctxt->attsSpecial, fullname, fullattr) != NULL)
+ return;
+
xmlHashAddEntry2(ctxt->attsSpecial, fullname, fullattr,
(void *) (long) type);
return;
@@ -981,6 +1326,45 @@ mem_error:
}
/**
+ * xmlCleanSpecialAttrCallback:
+ *
+ * Removes CDATA attributes from the special attribute table
+ */
+static void
+xmlCleanSpecialAttrCallback(void *payload, void *data,
+ const xmlChar *fullname, const xmlChar *fullattr,
+ const xmlChar *unused ATTRIBUTE_UNUSED) {
+ xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) data;
+
+ if (((long) payload) == XML_ATTRIBUTE_CDATA) {
+ xmlHashRemoveEntry2(ctxt->attsSpecial, fullname, fullattr, NULL);
+ }
+}
+
+/**
+ * xmlCleanSpecialAttr:
+ * @ctxt: an XML parser context
+ *
+ * Trim the list of attributes defined to remove all those of type
+ * CDATA as they are not special. This call should be done when finishing
+ * to parse the DTD and before starting to parse the document root.
+ */
+static void
+xmlCleanSpecialAttr(xmlParserCtxtPtr ctxt)
+{
+ if (ctxt->attsSpecial == NULL)
+ return;
+
+ xmlHashScanFull(ctxt->attsSpecial, xmlCleanSpecialAttrCallback, ctxt);
+
+ if (xmlHashSize(ctxt->attsSpecial) == 0) {
+ xmlHashFree(ctxt->attsSpecial, NULL);
+ ctxt->attsSpecial = NULL;
+ }
+ return;
+}
+
+/**
* xmlCheckLanguageID:
* @lang: pointer to the string value
*
@@ -996,70 +1380,192 @@ mem_error:
* [37] UserCode ::= ('x' | 'X') '-' ([a-z] | [A-Z])+
* [38] Subcode ::= ([a-z] | [A-Z])+
*
+ * The current REC reference the sucessors of RFC 1766, currently 5646
+ *
+ * http://www.rfc-editor.org/rfc/rfc5646.txt
+ * langtag = language
+ * ["-" script]
+ * ["-" region]
+ * *("-" variant)
+ * *("-" extension)
+ * ["-" privateuse]
+ * language = 2*3ALPHA ; shortest ISO 639 code
+ * ["-" extlang] ; sometimes followed by
+ * ; extended language subtags
+ * / 4ALPHA ; or reserved for future use
+ * / 5*8ALPHA ; or registered language subtag
+ *
+ * extlang = 3ALPHA ; selected ISO 639 codes
+ * *2("-" 3ALPHA) ; permanently reserved
+ *
+ * script = 4ALPHA ; ISO 15924 code
+ *
+ * region = 2ALPHA ; ISO 3166-1 code
+ * / 3DIGIT ; UN M.49 code
+ *
+ * variant = 5*8alphanum ; registered variants
+ * / (DIGIT 3alphanum)
+ *
+ * extension = singleton 1*("-" (2*8alphanum))
+ *
+ * ; Single alphanumerics
+ * ; "x" reserved for private use
+ * singleton = DIGIT ; 0 - 9
+ * / %x41-57 ; A - W
+ * / %x59-5A ; Y - Z
+ * / %x61-77 ; a - w
+ * / %x79-7A ; y - z
+ *
+ * it sounds right to still allow Irregular i-xxx IANA and user codes too
+ * The parser below doesn't try to cope with extension or privateuse
+ * that could be added but that's not interoperable anyway
+ *
* Returns 1 if correct 0 otherwise
**/
int
xmlCheckLanguageID(const xmlChar * lang)
{
- const xmlChar *cur = lang;
+ const xmlChar *cur = lang, *nxt;
if (cur == NULL)
return (0);
if (((cur[0] == 'i') && (cur[1] == '-')) ||
- ((cur[0] == 'I') && (cur[1] == '-'))) {
+ ((cur[0] == 'I') && (cur[1] == '-')) ||
+ ((cur[0] == 'x') && (cur[1] == '-')) ||
+ ((cur[0] == 'X') && (cur[1] == '-'))) {
/*
- * IANA code
+ * Still allow IANA code and user code which were coming
+ * from the previous version of the XML-1.0 specification
+ * it's deprecated but we should not fail
*/
cur += 2;
- while (((cur[0] >= 'A') && (cur[0] <= 'Z')) || /* non input consuming */
+ while (((cur[0] >= 'A') && (cur[0] <= 'Z')) ||
((cur[0] >= 'a') && (cur[0] <= 'z')))
cur++;
- } else if (((cur[0] == 'x') && (cur[1] == '-')) ||
- ((cur[0] == 'X') && (cur[1] == '-'))) {
- /*
- * User code
- */
- cur += 2;
- while (((cur[0] >= 'A') && (cur[0] <= 'Z')) || /* non input consuming */
- ((cur[0] >= 'a') && (cur[0] <= 'z')))
- cur++;
- } else if (((cur[0] >= 'A') && (cur[0] <= 'Z')) ||
- ((cur[0] >= 'a') && (cur[0] <= 'z'))) {
+ return(cur[0] == 0);
+ }
+ nxt = cur;
+ while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
+ ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
+ nxt++;
+ if (nxt - cur >= 4) {
/*
- * ISO639
+ * Reserved
*/
- cur++;
- if (((cur[0] >= 'A') && (cur[0] <= 'Z')) ||
- ((cur[0] >= 'a') && (cur[0] <= 'z')))
- cur++;
- else
- return (0);
- } else
- return (0);
- while (cur[0] != 0) { /* non input consuming */
- if (cur[0] != '-')
- return (0);
- cur++;
- if (((cur[0] >= 'A') && (cur[0] <= 'Z')) ||
- ((cur[0] >= 'a') && (cur[0] <= 'z')))
- cur++;
- else
- return (0);
- while (((cur[0] >= 'A') && (cur[0] <= 'Z')) || /* non input consuming */
- ((cur[0] >= 'a') && (cur[0] <= 'z')))
- cur++;
+ if ((nxt - cur > 8) || (nxt[0] != 0))
+ return(0);
+ return(1);
}
+ if (nxt - cur < 2)
+ return(0);
+ /* we got an ISO 639 code */
+ if (nxt[0] == 0)
+ return(1);
+ if (nxt[0] != '-')
+ return(0);
+
+ nxt++;
+ cur = nxt;
+ /* now we can have extlang or script or region or variant */
+ if ((nxt[0] >= '0') && (nxt[0] <= '9'))
+ goto region_m49;
+
+ while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
+ ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
+ nxt++;
+ if (nxt - cur == 4)
+ goto script;
+ if (nxt - cur == 2)
+ goto region;
+ if ((nxt - cur >= 5) && (nxt - cur <= 8))
+ goto variant;
+ if (nxt - cur != 3)
+ return(0);
+ /* we parsed an extlang */
+ if (nxt[0] == 0)
+ return(1);
+ if (nxt[0] != '-')
+ return(0);
+
+ nxt++;
+ cur = nxt;
+ /* now we can have script or region or variant */
+ if ((nxt[0] >= '0') && (nxt[0] <= '9'))
+ goto region_m49;
+
+ while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
+ ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
+ nxt++;
+ if (nxt - cur == 2)
+ goto region;
+ if ((nxt - cur >= 5) && (nxt - cur <= 8))
+ goto variant;
+ if (nxt - cur != 4)
+ return(0);
+ /* we parsed a script */
+script:
+ if (nxt[0] == 0)
+ return(1);
+ if (nxt[0] != '-')
+ return(0);
+
+ nxt++;
+ cur = nxt;
+ /* now we can have region or variant */
+ if ((nxt[0] >= '0') && (nxt[0] <= '9'))
+ goto region_m49;
+
+ while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
+ ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
+ nxt++;
+
+ if ((nxt - cur >= 5) && (nxt - cur <= 8))
+ goto variant;
+ if (nxt - cur != 2)
+ return(0);
+ /* we parsed a region */
+region:
+ if (nxt[0] == 0)
+ return(1);
+ if (nxt[0] != '-')
+ return(0);
+
+ nxt++;
+ cur = nxt;
+ /* now we can just have a variant */
+ while (((nxt[0] >= 'A') && (nxt[0] <= 'Z')) ||
+ ((nxt[0] >= 'a') && (nxt[0] <= 'z')))
+ nxt++;
+
+ if ((nxt - cur < 5) || (nxt - cur > 8))
+ return(0);
+
+ /* we parsed a variant */
+variant:
+ if (nxt[0] == 0)
+ return(1);
+ if (nxt[0] != '-')
+ return(0);
+ /* extensions and private use subtags not checked */
return (1);
+
+region_m49:
+ if (((nxt[1] >= '0') && (nxt[1] <= '9')) &&
+ ((nxt[2] >= '0') && (nxt[2] <= '9'))) {
+ nxt += 3;
+ goto region;
+ }
+ return(0);
}
/************************************************************************
* *
- * Parser stacks related functions and macros *
+ * Parser stacks related functions and macros *
* *
************************************************************************/
-xmlEntityPtr xmlParseStringEntityRef(xmlParserCtxtPtr ctxt,
- const xmlChar ** str);
+static xmlEntityPtr xmlParseStringEntityRef(xmlParserCtxtPtr ctxt,
+ const xmlChar ** str);
#ifdef SAX2
/**
@@ -1078,7 +1584,7 @@ nsPush(xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URL)
{
if (ctxt->options & XML_PARSE_NSCLEAN) {
int i;
- for (i = 0;i < ctxt->nsNr;i += 2) {
+ for (i = ctxt->nsNr - 2;i >= 0;i -= 2) {
if (ctxt->nsTab[i] == prefix) {
/* in scope */
if (ctxt->nsTab[i + 1] == URL)
@@ -1099,15 +1605,16 @@ nsPush(xmlParserCtxtPtr ctxt, const xmlChar *prefix, const xmlChar *URL)
return (-1);
}
} else if (ctxt->nsNr >= ctxt->nsMax) {
+ const xmlChar ** tmp;
ctxt->nsMax *= 2;
- ctxt->nsTab = (const xmlChar **)
- xmlRealloc((char *) ctxt->nsTab,
- ctxt->nsMax * sizeof(ctxt->nsTab[0]));
- if (ctxt->nsTab == NULL) {
+ tmp = (const xmlChar **) xmlRealloc((char *) ctxt->nsTab,
+ ctxt->nsMax * sizeof(ctxt->nsTab[0]));
+ if (tmp == NULL) {
xmlErrMemory(ctxt, NULL);
ctxt->nsMax /= 2;
return (-1);
}
+ ctxt->nsTab = tmp;
}
ctxt->nsTab[ctxt->nsNr++] = prefix;
ctxt->nsTab[ctxt->nsNr++] = URL;
@@ -1134,7 +1641,7 @@ nsPop(xmlParserCtxtPtr ctxt, int nr)
}
if (ctxt->nsNr <= 0)
return (0);
-
+
for (i = 0;i < nr;i++) {
ctxt->nsNr--;
ctxt->nsTab[ctxt->nsNr] = NULL;
@@ -1184,13 +1691,13 @@ mem_error:
*
* Pushes a new parser input on top of the input stack
*
- * Returns 0 in case of error, the index in the stack otherwise
+ * Returns -1 in case of error, the index in the stack otherwise
*/
int
inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
{
if ((ctxt == NULL) || (value == NULL))
- return(0);
+ return(-1);
if (ctxt->inputNr >= ctxt->inputMax) {
ctxt->inputMax *= 2;
ctxt->inputTab =
@@ -1199,7 +1706,10 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
sizeof(ctxt->inputTab[0]));
if (ctxt->inputTab == NULL) {
xmlErrMemory(ctxt, NULL);
- return (0);
+ xmlFreeInputStream(value);
+ ctxt->inputMax /= 2;
+ value = NULL;
+ return (-1);
}
}
ctxt->inputTab[ctxt->inputNr] = value;
@@ -1239,7 +1749,7 @@ inputPop(xmlParserCtxtPtr ctxt)
*
* Pushes a new element node on top of the node stack
*
- * Returns 0 in case of error, the index in the stack otherwise
+ * Returns -1 in case of error, the index in the stack otherwise
*/
int
nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
@@ -1253,22 +1763,24 @@ nodePush(xmlParserCtxtPtr ctxt, xmlNodePtr value)
sizeof(ctxt->nodeTab[0]));
if (tmp == NULL) {
xmlErrMemory(ctxt, NULL);
- return (0);
+ return (-1);
}
ctxt->nodeTab = tmp;
ctxt->nodeMax *= 2;
}
- if (((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) {
+ if ((((unsigned int) ctxt->nodeNr) > xmlParserMaxDepth) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
- "Excessive depth in document: change xmlParserMaxDepth = %d\n",
+ "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
xmlParserMaxDepth);
- ctxt->instate = XML_PARSER_EOF;
- return(0);
+ xmlHaltParser(ctxt);
+ return(-1);
}
ctxt->nodeTab[ctxt->nodeNr] = value;
ctxt->node = value;
return (ctxt->nodeNr++);
}
+
/**
* nodePop:
* @ctxt: an XML parser context
@@ -1384,15 +1896,14 @@ namePush(xmlParserCtxtPtr ctxt, const xmlChar * value)
if (ctxt->nameNr >= ctxt->nameMax) {
const xmlChar * *tmp;
- ctxt->nameMax *= 2;
tmp = (const xmlChar * *) xmlRealloc((xmlChar * *)ctxt->nameTab,
- ctxt->nameMax *
+ ctxt->nameMax * 2 *
sizeof(ctxt->nameTab[0]));
if (tmp == NULL) {
- ctxt->nameMax /= 2;
goto mem_error;
}
ctxt->nameTab = tmp;
+ ctxt->nameMax *= 2;
}
ctxt->nameTab[ctxt->nameNr] = value;
ctxt->name = value;
@@ -1428,13 +1939,17 @@ namePop(xmlParserCtxtPtr ctxt)
static int spacePush(xmlParserCtxtPtr ctxt, int val) {
if (ctxt->spaceNr >= ctxt->spaceMax) {
+ int *tmp;
+
ctxt->spaceMax *= 2;
- ctxt->spaceTab = (int *) xmlRealloc(ctxt->spaceTab,
- ctxt->spaceMax * sizeof(ctxt->spaceTab[0]));
- if (ctxt->spaceTab == NULL) {
+ tmp = (int *) xmlRealloc(ctxt->spaceTab,
+ ctxt->spaceMax * sizeof(ctxt->spaceTab[0]));
+ if (tmp == NULL) {
xmlErrMemory(ctxt, NULL);
- return(0);
+ ctxt->spaceMax /=2;
+ return(-1);
}
+ ctxt->spaceTab = tmp;
}
ctxt->spaceTab[ctxt->spaceNr] = val;
ctxt->space = &ctxt->spaceTab[ctxt->spaceNr];
@@ -1474,7 +1989,7 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
* to compare on ASCII based substring.
* SKIP(n) Skip n xmlChar, and must also be used only to skip ASCII defined
* strings without newlines within the parser.
- * NEXT1(l) Skip 1 xmlChar, and must also be used only to skip 1 non-newline ASCII
+ * NEXT1(l) Skip 1 xmlChar, and must also be used only to skip 1 non-newline ASCII
* defined char within the parser.
* Clean macros, not dependent of an ASCII context, expect UTF-8 encoding
*
@@ -1523,10 +2038,10 @@ static int spacePop(xmlParserCtxtPtr ctxt) {
#define SKIPL(val) do { \
int skipl; \
for(skipl=0; skipl<val; skipl++) { \
- if (*(ctxt->input->cur) == '\n') { \
+ if (*(ctxt->input->cur) == '\n') { \
ctxt->input->line++; ctxt->input->col = 1; \
- } else ctxt->input->col++; \
- ctxt->nbChars++; \
+ } else ctxt->input->col++; \
+ ctxt->nbChars++; \
ctxt->input->cur++; \
} \
if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt); \
@@ -1552,8 +2067,25 @@ static void xmlSHRINK (xmlParserCtxtPtr ctxt) {
xmlGROW (ctxt);
static void xmlGROW (xmlParserCtxtPtr ctxt) {
+ unsigned long curEnd = ctxt->input->end - ctxt->input->cur;
+ unsigned long curBase = ctxt->input->cur - ctxt->input->base;
+
+ if (((curEnd > (unsigned long) XML_MAX_LOOKUP_LIMIT) ||
+ (curBase > (unsigned long) XML_MAX_LOOKUP_LIMIT)) &&
+ ((ctxt->input->buf) && (ctxt->input->buf->readcallback != (xmlInputReadCallback) xmlNop)) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
+ xmlHaltParser(ctxt);
+ return;
+ }
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
- if ((*ctxt->input->cur == 0) &&
+ if ((ctxt->input->cur > ctxt->input->end) ||
+ (ctxt->input->cur < ctxt->input->base)) {
+ xmlHaltParser(ctxt);
+ xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "cur index out of bound");
+ return;
+ }
+ if ((ctxt->input->cur != NULL) && (*ctxt->input->cur == 0) &&
(xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0))
xmlPopInput(ctxt);
}
@@ -1612,6 +2144,8 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
while (IS_BLANK_CH(*cur)) {
if (*cur == '\n') {
ctxt->input->line++; ctxt->input->col = 1;
+ } else {
+ ctxt->input->col++;
}
cur++;
res++;
@@ -1626,7 +2160,8 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
int cur;
do {
cur = CUR;
- while (IS_BLANK_CH(cur)) { /* CHECKED tstblanks.xml */
+ while ((IS_BLANK_CH(cur) && /* CHECKED tstblanks.xml */
+ (ctxt->instate != XML_PARSER_EOF))) {
NEXT;
cur = CUR;
res++;
@@ -1640,7 +2175,8 @@ xmlSkipBlankChars(xmlParserCtxtPtr ctxt) {
* Need to handle support of entities branching here
*/
if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt);
- } while (IS_BLANK(cur)); /* CHECKED tstblanks.xml */
+ } while ((IS_BLANK(cur)) && /* CHECKED tstblanks.xml */
+ (ctxt->instate != XML_PARSER_EOF));
}
return(res);
}
@@ -1680,10 +2216,12 @@ xmlPopInput(xmlParserCtxtPtr ctxt) {
*
* xmlPushInput: switch to a new input stream which is stacked on top
* of the previous one(s).
+ * Returns -1 in case of error or the index in the input stack
*/
-void
+int
xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
- if (input == NULL) return;
+ int ret;
+ if (input == NULL) return(-1);
if (xmlParserDebugEntities) {
if ((ctxt->input != NULL) && (ctxt->input->filename))
@@ -1693,8 +2231,11 @@ xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
xmlGenericError(xmlGenericErrorContext,
"Pushing input %d : %.30s\n", ctxt->inputNr+1, input->cur);
}
- inputPush(ctxt, input);
+ ret = inputPush(ctxt, input);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(-1);
GROW;
+ return(ret);
}
/**
@@ -1708,7 +2249,7 @@ xmlPushInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr input) {
*
* [ WFC: Legal Character ]
* Characters referred to using character references must match the
- * production for Char.
+ * production for Char.
*
* Returns the value parsed (as an int), 0 in case of error
*/
@@ -1729,8 +2270,10 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
if (count++ > 20) {
count = 0;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(0);
}
- if ((RAW >= '0') && (RAW <= '9'))
+ if ((RAW >= '0') && (RAW <= '9'))
val = val * 16 + (CUR - '0');
else if ((RAW >= 'a') && (RAW <= 'f') && (count < 20))
val = val * 16 + (CUR - 'a') + 10;
@@ -1760,8 +2303,10 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
if (count++ > 20) {
count = 0;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(0);
}
- if ((RAW >= '0') && (RAW <= '9'))
+ if ((RAW >= '0') && (RAW <= '9'))
val = val * 10 + (CUR - '0');
else {
xmlFatalErr(ctxt, XML_ERR_INVALID_DEC_CHARREF, NULL);
@@ -1787,7 +2332,7 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
/*
* [ WFC: Legal Character ]
* Characters referred to using character references must match the
- * production for Char.
+ * production for Char.
*/
if ((IS_CHAR(val) && (outofrange == 0))) {
return(val);
@@ -1812,7 +2357,7 @@ xmlParseCharRef(xmlParserCtxtPtr ctxt) {
*
* [ WFC: Legal Character ]
* Characters referred to using character references must match the
- * production for Char.
+ * production for Char.
*
* Returns the value parsed (as an int), 0 in case of error, str will be
* updated to the current value of the index
@@ -1831,7 +2376,7 @@ xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
ptr += 3;
cur = *ptr;
while (cur != ';') { /* Non input consuming loop */
- if ((cur >= '0') && (cur <= '9'))
+ if ((cur >= '0') && (cur <= '9'))
val = val * 16 + (cur - '0');
else if ((cur >= 'a') && (cur <= 'f'))
val = val * 16 + (cur - 'a') + 10;
@@ -1854,7 +2399,7 @@ xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
ptr += 2;
cur = *ptr;
while (cur != ';') { /* Non input consuming loops */
- if ((cur >= '0') && (cur <= '9'))
+ if ((cur >= '0') && (cur <= '9'))
val = val * 10 + (cur - '0');
else {
xmlFatalErr(ctxt, XML_ERR_INVALID_DEC_CHARREF, NULL);
@@ -1878,7 +2423,7 @@ xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
/*
* [ WFC: Legal Character ]
* Characters referred to using character references must match the
- * production for Char.
+ * production for Char.
*/
if ((IS_CHAR(val) && (outofrange == 0))) {
return(val);
@@ -1900,9 +2445,9 @@ xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
*
* Returns the new input stream or NULL
*/
-
+
static void deallocblankswrapper (xmlChar *str) {xmlFree(str);}
-
+
static xmlParserInputPtr
xmlNewBlanksWrapperInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
xmlParserInputPtr input;
@@ -1924,7 +2469,8 @@ xmlNewBlanksWrapperInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
buffer = xmlMallocAtomic(length);
if (buffer == NULL) {
xmlErrMemory(ctxt, NULL);
- return(NULL);
+ xmlFree(input);
+ return(NULL);
}
buffer [0] = ' ';
buffer [1] = '%';
@@ -1943,12 +2489,12 @@ xmlNewBlanksWrapperInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
/**
* xmlParserHandlePEReference:
* @ctxt: the parser context
- *
+ *
* [69] PEReference ::= '%' Name ';'
*
* [ WFC: No Recursion ]
* A parsed entity must not contain a recursive
- * reference to itself, either directly or indirectly.
+ * reference to itself, either directly or indirectly.
*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an internal DTD
@@ -1966,9 +2512,9 @@ xmlNewBlanksWrapperInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
* NOTE: misleading but this is handled.
*
* A PEReference may have been detected in the current input stream
- * the handling is done accordingly to
+ * the handling is done accordingly to
* http://www.w3.org/TR/REC-xml#entproc
- * i.e.
+ * i.e.
* - Included in literal in entity values
* - Included as Parameter Entity reference within DTDs
*/
@@ -2045,8 +2591,10 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
NEXT;
if ((ctxt->sax != NULL) && (ctxt->sax->getParameterEntity != NULL))
entity = ctxt->sax->getParameterEntity(ctxt->userData, name);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
if (entity == NULL) {
-
+
/*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an
@@ -2071,16 +2619,18 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
if ((ctxt->validate) && (ctxt->vctxt.error != NULL)) {
xmlValidityError(ctxt, XML_WAR_UNDECLARED_ENTITY,
"PEReference: %%%s; not found\n",
- name);
- } else
+ name, NULL);
+ } else
xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
"PEReference: %%%s; not found\n",
name, NULL);
ctxt->valid = 0;
}
+ xmlParserEntityCheck(ctxt, 0, NULL, 0);
} else if (ctxt->input->free != deallocblankswrapper) {
input = xmlNewBlanksWrapperInputStream(ctxt, entity);
- xmlPushInput(ctxt, input);
+ if (xmlPushInput(ctxt, input) < 0)
+ return;
} else {
if ((entity->etype == XML_INTERNAL_PARAMETER_ENTITY) ||
(entity->etype == XML_EXTERNAL_PARAMETER_ENTITY)) {
@@ -2088,14 +2638,32 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
xmlCharEncoding enc;
/*
+ * Note: external parameter entities will not be loaded, it
+ * is not required for a non-validating parser, unless the
+ * option of validating, or substituting entities were
+ * given. Doing so is far more secure as the parser will
+ * only process data coming from the document entity by
+ * default.
+ */
+ if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
+ ((ctxt->options & XML_PARSE_NOENT) == 0) &&
+ ((ctxt->options & XML_PARSE_DTDVALID) == 0) &&
+ ((ctxt->options & XML_PARSE_DTDLOAD) == 0) &&
+ ((ctxt->options & XML_PARSE_DTDATTR) == 0) &&
+ (ctxt->replaceEntities == 0) &&
+ (ctxt->validate == 0))
+ return;
+
+ /*
* handle the extra spaces added before and after
* c.f. http://www.w3.org/TR/REC-xml#as-PE
* this is done independently.
*/
input = xmlNewEntityInputStream(ctxt, entity);
- xmlPushInput(ctxt, input);
+ if (xmlPushInput(ctxt, input) < 0)
+ return;
- /*
+ /*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
@@ -2105,6 +2673,8 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
* the amount of data in the buffer.
*/
GROW
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
if ((ctxt->input->end - ctxt->input->cur)>=4) {
start[0] = RAW;
start[1] = NXT(1);
@@ -2135,14 +2705,17 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
/*
* Macro used to grow the current buffer.
+ * buffer##_size is expected to be a size_t
+ * mem_error: is expected to handle memory allocation failures
*/
-#define growBuffer(buffer) { \
+#define growBuffer(buffer, n) { \
xmlChar *tmp; \
- buffer##_size *= 2; \
- tmp = (xmlChar *) \
- xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \
+ size_t new_size = buffer##_size * 2 + n; \
+ if (new_size < buffer##_size) goto mem_error; \
+ tmp = (xmlChar *) xmlRealloc(buffer, new_size); \
if (tmp == NULL) goto mem_error; \
buffer = tmp; \
+ buffer##_size = new_size; \
}
/**
@@ -2154,7 +2727,7 @@ xmlParserHandlePEReference(xmlParserCtxtPtr ctxt) {
* @end: an end marker xmlChar, 0 if none
* @end2: an end marker xmlChar, 0 if none
* @end3: an end marker xmlChar, 0 if none
- *
+ *
* Takes a entity string content and process to do the adequate substitutions.
*
* [67] Reference ::= EntityRef | CharRef
@@ -2168,19 +2741,22 @@ xmlChar *
xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
int what, xmlChar end, xmlChar end2, xmlChar end3) {
xmlChar *buffer = NULL;
- int buffer_size = 0;
+ size_t buffer_size = 0;
+ size_t nbchars = 0;
xmlChar *current = NULL;
+ xmlChar *rep = NULL;
const xmlChar *last;
xmlEntityPtr ent;
int c,l;
- int nbchars = 0;
if ((ctxt == NULL) || (str == NULL) || (len < 0))
return(NULL);
last = str + len;
- if (ctxt->depth > 40) {
+ if (((ctxt->depth > 40) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) ||
+ (ctxt->depth > 1024)) {
xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
return(NULL);
}
@@ -2189,7 +2765,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
* allocate a translation buffer.
*/
buffer_size = XML_PARSER_BIG_BUFFER_SIZE;
- buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar));
+ buffer = (xmlChar *) xmlMallocAtomic(buffer_size);
if (buffer == NULL) goto mem_error;
/*
@@ -2209,8 +2785,8 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
if (val != 0) {
COPY_BUF(0,buffer,nbchars,val);
}
- if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) {
- growBuffer(buffer);
+ if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
+ growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
}
} else if ((c == '&') && (what & XML_SUBSTITUTE_REF)) {
if (xmlParserDebugEntities)
@@ -2218,42 +2794,53 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
"String decoding Entity Reference: %.30s\n",
str);
ent = xmlParseStringEntityRef(ctxt, &str);
+ if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) ||
+ (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR))
+ goto int_error;
+ xmlParserEntityCheck(ctxt, 0, ent, 0);
+ if (ent != NULL)
+ ctxt->nbentities += ent->checked / 2;
if ((ent != NULL) &&
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
if (ent->content != NULL) {
COPY_BUF(0,buffer,nbchars,ent->content[0]);
- if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) {
- growBuffer(buffer);
+ if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
+ growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
}
} else {
xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
"predefined entity has no content\n");
}
} else if ((ent != NULL) && (ent->content != NULL)) {
- xmlChar *rep;
-
ctxt->depth++;
rep = xmlStringDecodeEntities(ctxt, ent->content, what,
0, 0, 0);
ctxt->depth--;
+
+ if ((ctxt->lastError.code == XML_ERR_ENTITY_LOOP) ||
+ (ctxt->lastError.code == XML_ERR_INTERNAL_ERROR))
+ goto int_error;
+
if (rep != NULL) {
current = rep;
while (*current != 0) { /* non input consuming loop */
buffer[nbchars++] = *current++;
- if (nbchars >
- buffer_size - XML_PARSER_BUFFER_SIZE) {
- growBuffer(buffer);
+ if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
+ if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))
+ goto int_error;
+ growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
}
}
xmlFree(rep);
+ rep = NULL;
}
} else if (ent != NULL) {
int i = xmlStrlen(ent->name);
const xmlChar *cur = ent->name;
buffer[nbchars++] = '&';
- if (nbchars > buffer_size - i - XML_PARSER_BUFFER_SIZE) {
- growBuffer(buffer);
+ if (nbchars + i + XML_PARSER_BUFFER_SIZE > buffer_size) {
+ growBuffer(buffer, i + XML_PARSER_BUFFER_SIZE);
}
for (;i > 0;i--)
buffer[nbchars++] = *cur++;
@@ -2264,9 +2851,15 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
xmlGenericError(xmlGenericErrorContext,
"String decoding PE Reference: %.30s\n", str);
ent = xmlParseStringPEReference(ctxt, &str);
+ if (ctxt->lastError.code == XML_ERR_ENTITY_LOOP)
+ goto int_error;
+ xmlParserEntityCheck(ctxt, 0, ent, 0);
+ if (ent != NULL)
+ ctxt->nbentities += ent->checked / 2;
if (ent != NULL) {
- xmlChar *rep;
-
+ if (ent->content == NULL) {
+ xmlLoadEntityContent(ctxt, ent);
+ }
ctxt->depth++;
rep = xmlStringDecodeEntities(ctxt, ent->content, what,
0, 0, 0);
@@ -2275,19 +2868,21 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
current = rep;
while (*current != 0) { /* non input consuming loop */
buffer[nbchars++] = *current++;
- if (nbchars >
- buffer_size - XML_PARSER_BUFFER_SIZE) {
- growBuffer(buffer);
+ if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
+ if (xmlParserEntityCheck(ctxt, nbchars, ent, 0))
+ goto int_error;
+ growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
}
}
xmlFree(rep);
+ rep = NULL;
}
}
} else {
COPY_BUF(l,buffer,nbchars,c);
str += l;
- if (nbchars > buffer_size - XML_PARSER_BUFFER_SIZE) {
- growBuffer(buffer);
+ if (nbchars + XML_PARSER_BUFFER_SIZE > buffer_size) {
+ growBuffer(buffer, XML_PARSER_BUFFER_SIZE);
}
}
if (str < last)
@@ -2295,11 +2890,16 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
else
c = 0;
}
- buffer[nbchars++] = 0;
+ buffer[nbchars] = 0;
return(buffer);
mem_error:
xmlErrMemory(ctxt, NULL);
+int_error:
+ if (rep != NULL)
+ xmlFree(rep);
+ if (buffer != NULL)
+ xmlFree(buffer);
return(NULL);
}
@@ -2311,7 +2911,7 @@ mem_error:
* @end: an end marker xmlChar, 0 if none
* @end2: an end marker xmlChar, 0 if none
* @end3: an end marker xmlChar, 0 if none
- *
+ *
* Takes a entity string content and process to do the adequate substitutions.
*
* [67] Reference ::= EntityRef | CharRef
@@ -2414,7 +3014,7 @@ static int areBlanks(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
* xmlSplitQName:
* @ctxt: an XML parser context
* @name: an XML parser context
- * @prefix: a xmlChar **
+ * @prefix: a xmlChar **
*
* parse an UTF8 encoded XML qualified name string
*
@@ -2465,7 +3065,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
* for the processing speed.
*/
max = len * 2;
-
+
buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
if (buffer == NULL) {
xmlErrMemory(ctxt, NULL);
@@ -2480,7 +3080,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
tmp = (xmlChar *) xmlRealloc(buffer,
max * sizeof(xmlChar));
if (tmp == NULL) {
- xmlFree(tmp);
+ xmlFree(buffer);
xmlErrMemory(ctxt, NULL);
return(NULL);
}
@@ -2491,7 +3091,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
}
buffer[len] = 0;
}
-
+
if ((c == ':') && (*cur == 0)) {
if (buffer != NULL)
xmlFree(buffer);
@@ -2544,7 +3144,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
* for the processing speed.
*/
max = len * 2;
-
+
buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
if (buffer == NULL) {
xmlErrMemory(ctxt, NULL);
@@ -2570,7 +3170,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
}
buffer[len] = 0;
}
-
+
if (buffer == NULL)
ret = xmlStrndup(buf, len);
else {
@@ -2588,10 +3188,221 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
* *
************************************************************************/
-static const xmlChar * xmlParseNameComplex(xmlParserCtxtPtr ctxt);
+/************************************************************************
+ * *
+ * Routines to parse Name, NCName and NmToken *
+ * *
+ ************************************************************************/
+#ifdef DEBUG
+static unsigned long nbParseName = 0;
+static unsigned long nbParseNmToken = 0;
+static unsigned long nbParseNCName = 0;
+static unsigned long nbParseNCNameComplex = 0;
+static unsigned long nbParseNameComplex = 0;
+static unsigned long nbParseStringName = 0;
+#endif
+
+/*
+ * The two following functions are related to the change of accepted
+ * characters for Name and NmToken in the Revision 5 of XML-1.0
+ * They correspond to the modified production [4] and the new production [4a]
+ * changes in that revision. Also note that the macros used for the
+ * productions Letter, Digit, CombiningChar and Extender are not needed
+ * anymore.
+ * We still keep compatibility to pre-revision5 parsing semantic if the
+ * new XML_PARSE_OLD10 option is given to the parser.
+ */
+static int
+xmlIsNameStartChar(xmlParserCtxtPtr ctxt, int c) {
+ if ((ctxt->options & XML_PARSE_OLD10) == 0) {
+ /*
+ * Use the new checks of production [4] [4a] amd [5] of the
+ * Update 5 of XML-1.0
+ */
+ if ((c != ' ') && (c != '>') && (c != '/') && /* accelerators */
+ (((c >= 'a') && (c <= 'z')) ||
+ ((c >= 'A') && (c <= 'Z')) ||
+ (c == '_') || (c == ':') ||
+ ((c >= 0xC0) && (c <= 0xD6)) ||
+ ((c >= 0xD8) && (c <= 0xF6)) ||
+ ((c >= 0xF8) && (c <= 0x2FF)) ||
+ ((c >= 0x370) && (c <= 0x37D)) ||
+ ((c >= 0x37F) && (c <= 0x1FFF)) ||
+ ((c >= 0x200C) && (c <= 0x200D)) ||
+ ((c >= 0x2070) && (c <= 0x218F)) ||
+ ((c >= 0x2C00) && (c <= 0x2FEF)) ||
+ ((c >= 0x3001) && (c <= 0xD7FF)) ||
+ ((c >= 0xF900) && (c <= 0xFDCF)) ||
+ ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
+ ((c >= 0x10000) && (c <= 0xEFFFF))))
+ return(1);
+ } else {
+ if (IS_LETTER(c) || (c == '_') || (c == ':'))
+ return(1);
+ }
+ return(0);
+}
+
+static int
+xmlIsNameChar(xmlParserCtxtPtr ctxt, int c) {
+ if ((ctxt->options & XML_PARSE_OLD10) == 0) {
+ /*
+ * Use the new checks of production [4] [4a] amd [5] of the
+ * Update 5 of XML-1.0
+ */
+ if ((c != ' ') && (c != '>') && (c != '/') && /* accelerators */
+ (((c >= 'a') && (c <= 'z')) ||
+ ((c >= 'A') && (c <= 'Z')) ||
+ ((c >= '0') && (c <= '9')) || /* !start */
+ (c == '_') || (c == ':') ||
+ (c == '-') || (c == '.') || (c == 0xB7) || /* !start */
+ ((c >= 0xC0) && (c <= 0xD6)) ||
+ ((c >= 0xD8) && (c <= 0xF6)) ||
+ ((c >= 0xF8) && (c <= 0x2FF)) ||
+ ((c >= 0x300) && (c <= 0x36F)) || /* !start */
+ ((c >= 0x370) && (c <= 0x37D)) ||
+ ((c >= 0x37F) && (c <= 0x1FFF)) ||
+ ((c >= 0x200C) && (c <= 0x200D)) ||
+ ((c >= 0x203F) && (c <= 0x2040)) || /* !start */
+ ((c >= 0x2070) && (c <= 0x218F)) ||
+ ((c >= 0x2C00) && (c <= 0x2FEF)) ||
+ ((c >= 0x3001) && (c <= 0xD7FF)) ||
+ ((c >= 0xF900) && (c <= 0xFDCF)) ||
+ ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
+ ((c >= 0x10000) && (c <= 0xEFFFF))))
+ return(1);
+ } else {
+ if ((IS_LETTER(c)) || (IS_DIGIT(c)) ||
+ (c == '.') || (c == '-') ||
+ (c == '_') || (c == ':') ||
+ (IS_COMBINING(c)) ||
+ (IS_EXTENDER(c)))
+ return(1);
+ }
+ return(0);
+}
+
static xmlChar * xmlParseAttValueInternal(xmlParserCtxtPtr ctxt,
int *len, int *alloc, int normalize);
+static const xmlChar *
+xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
+ int len = 0, l;
+ int c;
+ int count = 0;
+
+#ifdef DEBUG
+ nbParseNameComplex++;
+#endif
+
+ /*
+ * Handler for more complex cases
+ */
+ GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
+ c = CUR_CHAR(l);
+ if ((ctxt->options & XML_PARSE_OLD10) == 0) {
+ /*
+ * Use the new checks of production [4] [4a] amd [5] of the
+ * Update 5 of XML-1.0
+ */
+ if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
+ (!(((c >= 'a') && (c <= 'z')) ||
+ ((c >= 'A') && (c <= 'Z')) ||
+ (c == '_') || (c == ':') ||
+ ((c >= 0xC0) && (c <= 0xD6)) ||
+ ((c >= 0xD8) && (c <= 0xF6)) ||
+ ((c >= 0xF8) && (c <= 0x2FF)) ||
+ ((c >= 0x370) && (c <= 0x37D)) ||
+ ((c >= 0x37F) && (c <= 0x1FFF)) ||
+ ((c >= 0x200C) && (c <= 0x200D)) ||
+ ((c >= 0x2070) && (c <= 0x218F)) ||
+ ((c >= 0x2C00) && (c <= 0x2FEF)) ||
+ ((c >= 0x3001) && (c <= 0xD7FF)) ||
+ ((c >= 0xF900) && (c <= 0xFDCF)) ||
+ ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
+ ((c >= 0x10000) && (c <= 0xEFFFF))))) {
+ return(NULL);
+ }
+ len += l;
+ NEXTL(l);
+ c = CUR_CHAR(l);
+ while ((c != ' ') && (c != '>') && (c != '/') && /* accelerators */
+ (((c >= 'a') && (c <= 'z')) ||
+ ((c >= 'A') && (c <= 'Z')) ||
+ ((c >= '0') && (c <= '9')) || /* !start */
+ (c == '_') || (c == ':') ||
+ (c == '-') || (c == '.') || (c == 0xB7) || /* !start */
+ ((c >= 0xC0) && (c <= 0xD6)) ||
+ ((c >= 0xD8) && (c <= 0xF6)) ||
+ ((c >= 0xF8) && (c <= 0x2FF)) ||
+ ((c >= 0x300) && (c <= 0x36F)) || /* !start */
+ ((c >= 0x370) && (c <= 0x37D)) ||
+ ((c >= 0x37F) && (c <= 0x1FFF)) ||
+ ((c >= 0x200C) && (c <= 0x200D)) ||
+ ((c >= 0x203F) && (c <= 0x2040)) || /* !start */
+ ((c >= 0x2070) && (c <= 0x218F)) ||
+ ((c >= 0x2C00) && (c <= 0x2FEF)) ||
+ ((c >= 0x3001) && (c <= 0xD7FF)) ||
+ ((c >= 0xF900) && (c <= 0xFDCF)) ||
+ ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
+ ((c >= 0x10000) && (c <= 0xEFFFF))
+ )) {
+ if (count++ > XML_PARSER_CHUNK_SIZE) {
+ count = 0;
+ GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
+ }
+ len += l;
+ NEXTL(l);
+ c = CUR_CHAR(l);
+ }
+ } else {
+ if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
+ (!IS_LETTER(c) && (c != '_') &&
+ (c != ':'))) {
+ return(NULL);
+ }
+ len += l;
+ NEXTL(l);
+ c = CUR_CHAR(l);
+
+ while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
+ ((IS_LETTER(c)) || (IS_DIGIT(c)) ||
+ (c == '.') || (c == '-') ||
+ (c == '_') || (c == ':') ||
+ (IS_COMBINING(c)) ||
+ (IS_EXTENDER(c)))) {
+ if (count++ > XML_PARSER_CHUNK_SIZE) {
+ count = 0;
+ GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
+ }
+ len += l;
+ NEXTL(l);
+ c = CUR_CHAR(l);
+ if (c == 0) {
+ count = 0;
+ GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
+ c = CUR_CHAR(l);
+ }
+ }
+ }
+ if ((len > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name");
+ return(NULL);
+ }
+ if ((*ctxt->input->cur == '\n') && (ctxt->input->cur[-1] == '\r'))
+ return(xmlDictLookup(ctxt->dict, ctxt->input->cur - (len + 1), len));
+ return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len));
+}
+
/**
* xmlParseName:
* @ctxt: an XML parser context
@@ -2616,6 +3427,10 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
GROW;
+#ifdef DEBUG
+ nbParseName++;
+#endif
+
/*
* Accelerator for simple ASCII names
*/
@@ -2632,6 +3447,11 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
in++;
if ((*in > 0) && (*in < 0x80)) {
count = in - ctxt->input->cur;
+ if ((count > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Name");
+ return(NULL);
+ }
ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
ctxt->input->cur = in;
ctxt->nbChars += count;
@@ -2641,9 +3461,136 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
return(ret);
}
}
+ /* accelerator for special cases */
return(xmlParseNameComplex(ctxt));
}
+static const xmlChar *
+xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
+ int len = 0, l;
+ int c;
+ int count = 0;
+ const xmlChar *end; /* needed because CUR_CHAR() can move cur on \r\n */
+
+#ifdef DEBUG
+ nbParseNCNameComplex++;
+#endif
+
+ /*
+ * Handler for more complex cases
+ */
+ GROW;
+ end = ctxt->input->cur;
+ c = CUR_CHAR(l);
+ if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
+ (!xmlIsNameStartChar(ctxt, c) || (c == ':'))) {
+ return(NULL);
+ }
+
+ while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
+ (xmlIsNameChar(ctxt, c) && (c != ':'))) {
+ if (count++ > XML_PARSER_CHUNK_SIZE) {
+ if ((len > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
+ return(NULL);
+ }
+ count = 0;
+ GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
+ }
+ len += l;
+ NEXTL(l);
+ end = ctxt->input->cur;
+ c = CUR_CHAR(l);
+ if (c == 0) {
+ count = 0;
+ /*
+ * when shrinking to extend the buffer we really need to preserve
+ * the part of the name we already parsed. Hence rolling back
+ * by current lenght.
+ */
+ ctxt->input->cur -= l;
+ GROW;
+ ctxt->input->cur += l;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
+ end = ctxt->input->cur;
+ c = CUR_CHAR(l);
+ }
+ }
+ if ((len > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
+ return(NULL);
+ }
+ return(xmlDictLookup(ctxt->dict, end - len, len));
+}
+
+/**
+ * xmlParseNCName:
+ * @ctxt: an XML parser context
+ * @len: length of the string parsed
+ *
+ * parse an XML name.
+ *
+ * [4NS] NCNameChar ::= Letter | Digit | '.' | '-' | '_' |
+ * CombiningChar | Extender
+ *
+ * [5NS] NCName ::= (Letter | '_') (NCNameChar)*
+ *
+ * Returns the Name parsed or NULL
+ */
+
+static const xmlChar *
+xmlParseNCName(xmlParserCtxtPtr ctxt) {
+ const xmlChar *in, *e;
+ const xmlChar *ret;
+ int count = 0;
+
+#ifdef DEBUG
+ nbParseNCName++;
+#endif
+
+ /*
+ * Accelerator for simple ASCII names
+ */
+ in = ctxt->input->cur;
+ e = ctxt->input->end;
+ if ((((*in >= 0x61) && (*in <= 0x7A)) ||
+ ((*in >= 0x41) && (*in <= 0x5A)) ||
+ (*in == '_')) && (in < e)) {
+ in++;
+ while ((((*in >= 0x61) && (*in <= 0x7A)) ||
+ ((*in >= 0x41) && (*in <= 0x5A)) ||
+ ((*in >= 0x30) && (*in <= 0x39)) ||
+ (*in == '_') || (*in == '-') ||
+ (*in == '.')) && (in < e))
+ in++;
+ if (in >= e)
+ goto complex;
+ if ((*in > 0) && (*in < 0x80)) {
+ count = in - ctxt->input->cur;
+ if ((count > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
+ return(NULL);
+ }
+ ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
+ ctxt->input->cur = in;
+ ctxt->nbChars += count;
+ ctxt->input->col += count;
+ if (ret == NULL) {
+ xmlErrMemory(ctxt, NULL);
+ }
+ return(ret);
+ }
+ }
+complex:
+ return(xmlParseNCNameComplex(ctxt));
+}
+
/**
* xmlParseNameAndCompare:
* @ctxt: an XML parser context
@@ -2662,15 +3609,17 @@ xmlParseNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *other) {
const xmlChar *ret;
GROW;
-
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
+
in = ctxt->input->cur;
while (*in != 0 && *in == *cmp) {
- ++in;
+ ++in;
++cmp;
ctxt->input->col++;
}
if (*cmp == 0 && (*in == '>' || IS_BLANK_CH (*in))) {
- /* success */
+ /* success */
ctxt->input->cur = in;
return (const xmlChar*) 1;
}
@@ -2683,42 +3632,6 @@ xmlParseNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *other) {
return ret;
}
-static const xmlChar *
-xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
- int len = 0, l;
- int c;
- int count = 0;
-
- /*
- * Handler for more complex cases
- */
- GROW;
- c = CUR_CHAR(l);
- if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
- (!IS_LETTER(c) && (c != '_') &&
- (c != ':'))) {
- return(NULL);
- }
-
- while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
- ((IS_LETTER(c)) || (IS_DIGIT(c)) ||
- (c == '.') || (c == '-') ||
- (c == '_') || (c == ':') ||
- (IS_COMBINING(c)) ||
- (IS_EXTENDER(c)))) {
- if (count++ > 100) {
- count = 0;
- GROW;
- }
- len += l;
- NEXTL(l);
- c = CUR_CHAR(l);
- }
- if ((*ctxt->input->cur == '\n') && (ctxt->input->cur[-1] == '\r'))
- return(xmlDictLookup(ctxt->dict, ctxt->input->cur - (len + 1), len));
- return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len));
-}
-
/**
* xmlParseStringName:
* @ctxt: an XML parser context
@@ -2733,7 +3646,7 @@ xmlParseNameComplex(xmlParserCtxtPtr ctxt) {
*
* [6] Names ::= Name (#x20 Name)*
*
- * Returns the Name parsed or NULL. The @str pointer
+ * Returns the Name parsed or NULL. The @str pointer
* is updated to the current location in the string.
*/
@@ -2744,17 +3657,19 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
int len = 0, l;
int c;
+#ifdef DEBUG
+ nbParseStringName++;
+#endif
+
c = CUR_SCHAR(cur, l);
- if (!IS_LETTER(c) && (c != '_') &&
- (c != ':')) {
+ if (!xmlIsNameStartChar(ctxt, c)) {
return(NULL);
}
- while ((IS_LETTER(c)) || (IS_DIGIT(c)) || /* test bigentname.xml */
- (c == '.') || (c == '-') ||
- (c == '_') || (c == ':') ||
- (IS_COMBINING(c)) ||
- (IS_EXTENDER(c))) {
+ COPY_BUF(l,buf,len,c);
+ cur += l;
+ c = CUR_SCHAR(cur, l);
+ while (xmlIsNameChar(ctxt, c)) {
COPY_BUF(l,buf,len,c);
cur += l;
c = CUR_SCHAR(cur, l);
@@ -2765,21 +3680,23 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
*/
xmlChar *buffer;
int max = len * 2;
-
+
buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
if (buffer == NULL) {
xmlErrMemory(ctxt, NULL);
return(NULL);
}
memcpy(buffer, buf, len);
- while ((IS_LETTER(c)) || (IS_DIGIT(c)) ||
- /* test bigentname.xml */
- (c == '.') || (c == '-') ||
- (c == '_') || (c == ':') ||
- (IS_COMBINING(c)) ||
- (IS_EXTENDER(c))) {
+ while (xmlIsNameChar(ctxt, c)) {
if (len + 10 > max) {
xmlChar *tmp;
+
+ if ((len > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
+ xmlFree(buffer);
+ return(NULL);
+ }
max *= 2;
tmp = (xmlChar *) xmlRealloc(buffer,
max * sizeof(xmlChar));
@@ -2799,6 +3716,11 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
return(buffer);
}
}
+ if ((len > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NCName");
+ return(NULL);
+ }
*str = cur;
return(xmlStrndup(buf, len));
}
@@ -2806,7 +3728,7 @@ xmlParseStringName(xmlParserCtxtPtr ctxt, const xmlChar** str) {
/**
* xmlParseNmtoken:
* @ctxt: an XML parser context
- *
+ *
* parse an XML Nmtoken.
*
* [7] Nmtoken ::= (NameChar)+
@@ -2823,21 +3745,30 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
int c;
int count = 0;
+#ifdef DEBUG
+ nbParseNmToken++;
+#endif
+
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
c = CUR_CHAR(l);
- while ((IS_LETTER(c)) || (IS_DIGIT(c)) || /* test bigtoken.xml */
- (c == '.') || (c == '-') ||
- (c == '_') || (c == ':') ||
- (IS_COMBINING(c)) ||
- (IS_EXTENDER(c))) {
- if (count++ > 100) {
+ while (xmlIsNameChar(ctxt, c)) {
+ if (count++ > XML_PARSER_CHUNK_SIZE) {
count = 0;
GROW;
}
COPY_BUF(l,buf,len,c);
NEXTL(l);
c = CUR_CHAR(l);
+ if (c == 0) {
+ count = 0;
+ GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
+ c = CUR_CHAR(l);
+ }
if (len >= XML_MAX_NAMELEN) {
/*
* Okay someone managed to make a huge token, so he's ready to pay
@@ -2845,25 +3776,31 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
*/
xmlChar *buffer;
int max = len * 2;
-
+
buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
if (buffer == NULL) {
xmlErrMemory(ctxt, NULL);
return(NULL);
}
memcpy(buffer, buf, len);
- while ((IS_LETTER(c)) || (IS_DIGIT(c)) || /* test bigtoken.xml */
- (c == '.') || (c == '-') ||
- (c == '_') || (c == ':') ||
- (IS_COMBINING(c)) ||
- (IS_EXTENDER(c))) {
- if (count++ > 100) {
+ while (xmlIsNameChar(ctxt, c)) {
+ if (count++ > XML_PARSER_CHUNK_SIZE) {
count = 0;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(buffer);
+ return(NULL);
+ }
}
if (len + 10 > max) {
xmlChar *tmp;
+ if ((max > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken");
+ xmlFree(buffer);
+ return(NULL);
+ }
max *= 2;
tmp = (xmlChar *) xmlRealloc(buffer,
max * sizeof(xmlChar));
@@ -2884,6 +3821,11 @@ xmlParseNmtoken(xmlParserCtxtPtr ctxt) {
}
if (len == 0)
return(NULL);
+ if ((len > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "NmToken");
+ return(NULL);
+ }
return(xmlStrndup(buf, len));
}
@@ -2930,6 +3872,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
ctxt->instate = XML_PARSER_ENTITY_VALUE;
input = ctxt->input;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(buf);
+ return(NULL);
+ }
NEXT;
c = CUR_CHAR(l);
/*
@@ -2937,12 +3883,12 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
* When a parameter entity reference appears in a literal entity
* value, ... a single or double quote character in the replacement
* text is always treated as a normal data character and will not
- * terminate the literal.
+ * terminate the literal.
* In practice it means we stop the loop only when back at parsing
* the initial entity and the quote is found
*/
- while ((IS_CHAR(c)) && ((c != stop) || /* checked */
- (ctxt->input != input))) {
+ while (((IS_CHAR(c)) && ((c != stop) || /* checked */
+ (ctxt->input != input))) && (ctxt->instate != XML_PARSER_EOF)) {
if (len + 5 >= size) {
xmlChar *tmp;
@@ -2971,6 +3917,10 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
}
}
buf[len] = 0;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(buf);
+ return(NULL);
+ }
/*
* Raise problem w.r.t. '&' and '%' being used in non-entities
@@ -3018,12 +3968,12 @@ xmlParseEntityValue(xmlParserCtxtPtr ctxt, xmlChar **orig) {
*/
ret = xmlStringDecodeEntities(ctxt, buf, XML_SUBSTITUTE_PEREF,
0, 0, 0);
- if (orig != NULL)
+ if (orig != NULL)
*orig = buf;
else
xmlFree(buf);
}
-
+
return(ret);
}
@@ -3043,8 +3993,9 @@ static xmlChar *
xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
xmlChar limit = 0;
xmlChar *buf = NULL;
- int len = 0;
- int buf_size = 0;
+ xmlChar *rep = NULL;
+ size_t len = 0;
+ size_t buf_size = 0;
int c, l, in_space = 0;
xmlChar *current = NULL;
xmlEntityPtr ent;
@@ -3061,20 +4012,31 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL);
return(NULL);
}
-
+
/*
* allocate a translation buffer.
*/
buf_size = XML_PARSER_BUFFER_SIZE;
- buf = (xmlChar *) xmlMallocAtomic(buf_size * sizeof(xmlChar));
+ buf = (xmlChar *) xmlMallocAtomic(buf_size);
if (buf == NULL) goto mem_error;
/*
* OK loop until we reach one of the ending char or a size limit.
*/
c = CUR_CHAR(l);
- while ((NXT(0) != limit) && /* checked */
- (c != '<')) {
+ while (((NXT(0) != limit) && /* checked */
+ (IS_CHAR(c)) && (c != '<')) &&
+ (ctxt->instate != XML_PARSER_EOF)) {
+ /*
+ * Impose a reasonable limit on attribute size, unless XML_PARSE_HUGE
+ * special option is given
+ */
+ if ((len > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+ "AttValue length too long\n");
+ goto mem_error;
+ }
if (c == 0) break;
if (c == '&') {
in_space = 0;
@@ -3083,8 +4045,8 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
if (val == '&') {
if (ctxt->replaceEntities) {
- if (len > buf_size - 10) {
- growBuffer(buf);
+ if (len + 10 > buf_size) {
+ growBuffer(buf, 10);
}
buf[len++] = '&';
} else {
@@ -3092,8 +4054,8 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
* The reparsing will be done in xmlStringGetNodeList()
* called by the attribute() function in SAX.c
*/
- if (len > buf_size - 10) {
- growBuffer(buf);
+ if (len + 10 > buf_size) {
+ growBuffer(buf, 10);
}
buf[len++] = '&';
buf[len++] = '#';
@@ -3101,18 +4063,21 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
buf[len++] = '8';
buf[len++] = ';';
}
- } else {
- if (len > buf_size - 10) {
- growBuffer(buf);
+ } else if (val != 0) {
+ if (len + 10 > buf_size) {
+ growBuffer(buf, 10);
}
len += xmlCopyChar(0, &buf[len], val);
}
} else {
ent = xmlParseEntityRef(ctxt);
+ ctxt->nbentities++;
+ if (ent != NULL)
+ ctxt->nbentities += ent->owner;
if ((ent != NULL) &&
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
- if (len > buf_size - 10) {
- growBuffer(buf);
+ if (len + 10 > buf_size) {
+ growBuffer(buf, 10);
}
if ((ctxt->replaceEntities == 0) &&
(ent->content[0] == '&')) {
@@ -3124,10 +4089,8 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
} else {
buf[len++] = ent->content[0];
}
- } else if ((ent != NULL) &&
+ } else if ((ent != NULL) &&
(ctxt->replaceEntities != 0)) {
- xmlChar *rep;
-
if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {
rep = xmlStringDecodeEntities(ctxt, ent->content,
XML_SUBSTITUTE_REF,
@@ -3135,16 +4098,22 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
if (rep != NULL) {
current = rep;
while (*current != 0) { /* non input consuming */
- buf[len++] = *current++;
- if (len > buf_size - 10) {
- growBuffer(buf);
+ if ((*current == 0xD) || (*current == 0xA) ||
+ (*current == 0x9)) {
+ buf[len++] = 0x20;
+ current++;
+ } else
+ buf[len++] = *current++;
+ if (len + 10 > buf_size) {
+ growBuffer(buf, 10);
}
}
xmlFree(rep);
+ rep = NULL;
}
} else {
- if (len > buf_size - 10) {
- growBuffer(buf);
+ if (len + 10 > buf_size) {
+ growBuffer(buf, 10);
}
if (ent->content != NULL)
buf[len++] = ent->content[0];
@@ -3158,20 +4127,27 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
* entities problems
*/
if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
- (ent->content != NULL)) {
- xmlChar *rep;
+ (ent->content != NULL) && (ent->checked == 0)) {
+ unsigned long oldnbent = ctxt->nbentities;
+
rep = xmlStringDecodeEntities(ctxt, ent->content,
- XML_SUBSTITUTE_REF, 0, 0, 0);
- if (rep != NULL)
+ XML_SUBSTITUTE_REF, 0, 0, 0);
+
+ ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
+ if (rep != NULL) {
+ if (xmlStrchr(rep, '<'))
+ ent->checked |= 1;
xmlFree(rep);
+ rep = NULL;
+ }
}
/*
* Just output the reference
*/
buf[len++] = '&';
- if (len > buf_size - i - 10) {
- growBuffer(buf);
+ while (len + i + 10 > buf_size) {
+ growBuffer(buf, i + 10);
}
for (;i > 0;i--)
buf[len++] = *cur++;
@@ -3183,8 +4159,8 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
if ((len != 0) || (!normalize)) {
if ((!normalize) || (!in_space)) {
COPY_BUF(l,buf,len,0x20);
- if (len > buf_size - 10) {
- growBuffer(buf);
+ while (len + 10 > buf_size) {
+ growBuffer(buf, 10);
}
}
in_space = 1;
@@ -3192,8 +4168,8 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
} else {
in_space = 0;
COPY_BUF(l,buf,len,c);
- if (len > buf_size - 10) {
- growBuffer(buf);
+ if (len + 10 > buf_size) {
+ growBuffer(buf, 10);
}
}
NEXTL(l);
@@ -3201,22 +4177,46 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
GROW;
c = CUR_CHAR(l);
}
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto error;
+
if ((in_space) && (normalize)) {
- while (buf[len - 1] == 0x20) len--;
+ while ((len > 0) && (buf[len - 1] == 0x20)) len--;
}
buf[len] = 0;
if (RAW == '<') {
xmlFatalErr(ctxt, XML_ERR_LT_IN_ATTRIBUTE, NULL);
} else if (RAW != limit) {
- xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
- "AttValue: ' expected\n");
+ if ((c != 0) && (!IS_CHAR(c))) {
+ xmlFatalErrMsg(ctxt, XML_ERR_INVALID_CHAR,
+ "invalid character in attribute value\n");
+ } else {
+ xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+ "AttValue: ' expected\n");
+ }
} else
NEXT;
- if (attlen != NULL) *attlen = len;
+
+ /*
+ * There we potentially risk an overflow, don't allow attribute value of
+ * length more than INT_MAX it is a very reasonnable assumption !
+ */
+ if (len >= INT_MAX) {
+ xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+ "AttValue length too long\n");
+ goto mem_error;
+ }
+
+ if (attlen != NULL) *attlen = (int) len;
return(buf);
mem_error:
xmlErrMemory(ctxt, NULL);
+error:
+ if (buf != NULL)
+ xmlFree(buf);
+ if (rep != NULL)
+ xmlFree(rep);
return(NULL);
}
@@ -3233,20 +4233,20 @@ mem_error:
*
* 3.3.3 Attribute-Value Normalization:
* Before the value of an attribute is passed to the application or
- * checked for validity, the XML processor must normalize it as follows:
+ * checked for validity, the XML processor must normalize it as follows:
* - a character reference is processed by appending the referenced
* character to the attribute value
* - an entity reference is processed by recursively processing the
- * replacement text of the entity
+ * replacement text of the entity
* - a whitespace character (#x20, #xD, #xA, #x9) is processed by
* appending #x20 to the normalized value, except that only a single
* #x20 is appended for a "#xD#xA" sequence that is part of an external
- * parsed entity or the literal entity value of an internal parsed entity
- * - other characters are processed by appending them to the normalized value
+ * parsed entity or the literal entity value of an internal parsed entity
+ * - other characters are processed by appending them to the normalized value
* 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 a single space (#x20) character.
+ * (#x20) characters by a single space (#x20) character.
* All attributes for which no declaration has been read should be treated
* by a non-validating parser as if declared CDATA.
*
@@ -3263,7 +4263,7 @@ xmlParseAttValue(xmlParserCtxtPtr ctxt) {
/**
* xmlParseSystemLiteral:
* @ctxt: an XML parser context
- *
+ *
* parse an XML Literal
*
* [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'")
@@ -3292,7 +4292,7 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
xmlFatalErr(ctxt, XML_ERR_LITERAL_NOT_STARTED, NULL);
return(NULL);
}
-
+
buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
if (buf == NULL) {
xmlErrMemory(ctxt, NULL);
@@ -3304,6 +4304,13 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
if (len + 5 >= size) {
xmlChar *tmp;
+ if ((size > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "SystemLiteral");
+ xmlFree(buf);
+ ctxt->instate = (xmlParserInputState) state;
+ return(NULL);
+ }
size *= 2;
tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
if (tmp == NULL) {
@@ -3318,6 +4325,10 @@ xmlParseSystemLiteral(xmlParserCtxtPtr ctxt) {
if (count > 50) {
GROW;
count = 0;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(buf);
+ return(NULL);
+ }
}
COPY_BUF(l,buf,len,cur);
NEXTL(l);
@@ -3381,6 +4392,12 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
if (len + 1 >= size) {
xmlChar *tmp;
+ if ((size > XML_MAX_NAME_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_NAME_TOO_LONG, "Public ID");
+ xmlFree(buf);
+ return(NULL);
+ }
size *= 2;
tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
if (tmp == NULL) {
@@ -3395,6 +4412,10 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
if (count > 50) {
GROW;
count = 0;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(buf);
+ return(NULL);
+ }
}
NEXT;
cur = CUR;
@@ -3414,7 +4435,7 @@ xmlParsePubidLiteral(xmlParserCtxtPtr ctxt) {
return(buf);
}
-void xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata);
+static void xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata);
/*
* used for the test in the inner loop of the char data testing
@@ -3465,7 +4486,7 @@ static const unsigned char test_char_data[256] = {
* The right angle bracket (>) may be represented using the string "&gt;",
* and must, for compatibility, be escaped using "&gt;" or a character
* reference when it appears in the string "]]>" in content, when that
- * string is not marking the end of a CDATA section.
+ * string is not marking the end of a CDATA section.
*
* [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*)
*/
@@ -3488,7 +4509,7 @@ xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata) {
in = ctxt->input->cur;
do {
get_more_space:
- while (*in == 0x20) in++;
+ while (*in == 0x20) { in++; ctxt->input->col++; }
if (*in == 0xA) {
do {
ctxt->input->line++; ctxt->input->col = 1;
@@ -3578,6 +4599,9 @@ get_more:
line = ctxt->input->line;
col = ctxt->input->col;
}
+ /* something really bad happened in the SAX callback */
+ if (ctxt->instate != XML_PARSER_CONTENT)
+ return;
}
ctxt->input->cur = in;
if (*in == 0xD) {
@@ -3598,6 +4622,8 @@ get_more:
}
SHRINK;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
in = ctxt->input->cur;
} while (((*in >= 0x20) && (*in <= 0x7F)) || (*in == 0x09));
nbchar = 0;
@@ -3616,7 +4642,7 @@ get_more:
* of xmlParseCharData() when the parsing requires handling
* of non-ASCII characters.
*/
-void
+static void
xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
xmlChar buf[XML_PARSER_BIG_BUFFER_SIZE + 5];
int nbchar = 0;
@@ -3627,7 +4653,7 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
GROW;
cur = CUR_CHAR(l);
while ((cur != '<') && /* checked */
- (cur != '&') &&
+ (cur != '&') &&
(IS_CHAR(cur))) /* test also done in xmlCurrentChar() */ {
if ((cur == ']') && (NXT(1) == ']') &&
(NXT(2) == '>')) {
@@ -3658,11 +4684,16 @@ xmlParseCharDataComplex(xmlParserCtxtPtr ctxt, int cdata) {
}
}
nbchar = 0;
+ /* something really bad happened in the SAX callback */
+ if (ctxt->instate != XML_PARSER_CONTENT)
+ return;
}
count++;
if (count > 50) {
GROW;
count = 0;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
}
NEXTL(l);
cur = CUR_CHAR(l);
@@ -3755,7 +4786,7 @@ xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict) {
}
} else {
/*
- * We handle [83] so we return immediately, if
+ * We handle [83] so we return immediately, if
* "S SystemLiteral" is not detected. From a purely parsing
* point of view that's a nice mess.
*/
@@ -3764,7 +4795,7 @@ xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict) {
ptr = CUR_PTR;
if (!IS_BLANK_CH(*ptr)) return(NULL);
-
+
while (IS_BLANK_CH(*ptr)) ptr++; /* TODO: dangerous, fix ! */
if ((*ptr != '\'') && (*ptr != '"')) return(NULL);
}
@@ -3792,12 +4823,15 @@ xmlParseExternalID(xmlParserCtxtPtr ctxt, xmlChar **publicID, int strict) {
* [15] Comment ::= '<!--' ((Char - '-') | ('-' (Char - '-')))* '-->'
*/
static void
-xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, int len, int size) {
+xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf,
+ size_t len, size_t size) {
int q, ql;
int r, rl;
int cur, l;
- xmlParserInputPtr input = ctxt->input;
- int count = 0;
+ size_t count = 0;
+ int inputid;
+
+ inputid = ctxt->input->id;
if (buf == NULL) {
len = 0;
@@ -3808,13 +4842,28 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, int len, int size) {
return;
}
}
+ GROW; /* Assure there's enough input data */
q = CUR_CHAR(ql);
if (q == 0)
goto not_terminated;
+ if (!IS_CHAR(q)) {
+ xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
+ "xmlParseComment: invalid xmlChar value %d\n",
+ q);
+ xmlFree (buf);
+ return;
+ }
NEXTL(ql);
r = CUR_CHAR(rl);
if (r == 0)
goto not_terminated;
+ if (!IS_CHAR(r)) {
+ xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
+ "xmlParseComment: invalid xmlChar value %d\n",
+ q);
+ xmlFree (buf);
+ return;
+ }
NEXTL(rl);
cur = CUR_CHAR(l);
if (cur == 0)
@@ -3825,16 +4874,26 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, int len, int size) {
if ((r == '-') && (q == '-')) {
xmlFatalErr(ctxt, XML_ERR_HYPHEN_IN_COMMENT, NULL);
}
+ if ((len > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
+ "Comment too big found", NULL);
+ xmlFree (buf);
+ return;
+ }
if (len + 5 >= size) {
xmlChar *new_buf;
- size *= 2;
- new_buf = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+ size_t new_size;
+
+ new_size = size * 2;
+ new_buf = (xmlChar *) xmlRealloc(buf, new_size);
if (new_buf == NULL) {
xmlFree (buf);
xmlErrMemory(ctxt, NULL);
return;
}
buf = new_buf;
+ size = new_size;
}
COPY_BUF(ql,buf,len,q);
q = r;
@@ -3846,6 +4905,10 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, int len, int size) {
if (count > 50) {
GROW;
count = 0;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(buf);
+ return;
+ }
}
NEXTL(l);
cur = CUR_CHAR(l);
@@ -3856,12 +4919,15 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, int len, int size) {
}
}
buf[len] = 0;
- if (!IS_CHAR(cur)) {
+ if (cur == 0) {
xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
"Comment not terminated \n<!--%.50s\n", buf);
- xmlFree(buf);
+ } else if (!IS_CHAR(cur)) {
+ xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
+ "xmlParseComment: invalid xmlChar value %d\n",
+ cur);
} else {
- if (input != ctxt->input) {
+ if (inputid != ctxt->input->id) {
xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
"Comment doesn't start and stop in the same entity\n");
}
@@ -3869,14 +4935,16 @@ xmlParseCommentComplex(xmlParserCtxtPtr ctxt, xmlChar *buf, int len, int size) {
if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
(!ctxt->disableSAX))
ctxt->sax->comment(ctxt->userData, buf);
- xmlFree(buf);
}
+ xmlFree(buf);
return;
not_terminated:
xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
"Comment not terminated\n", NULL);
xmlFree(buf);
+ return;
}
+
/**
* xmlParseComment:
* @ctxt: an XML parser context
@@ -3890,20 +4958,22 @@ not_terminated:
void
xmlParseComment(xmlParserCtxtPtr ctxt) {
xmlChar *buf = NULL;
- int size = XML_PARSER_BUFFER_SIZE;
- int len = 0;
+ size_t size = XML_PARSER_BUFFER_SIZE;
+ size_t len = 0;
xmlParserInputState state;
const xmlChar *in;
- int nbchar = 0, ccol;
+ size_t nbchar = 0;
+ int ccol;
+ int inputid;
/*
* Check that there is a comment right here.
*/
if ((RAW != '<') || (NXT(1) != '!') ||
(NXT(2) != '-') || (NXT(3) != '-')) return;
-
state = ctxt->instate;
ctxt->instate = XML_PARSER_COMMENT;
+ inputid = ctxt->input->id;
SKIP(4);
SHRINK;
GROW;
@@ -3973,6 +5043,13 @@ get_more:
buf[len] = 0;
}
}
+ if ((len > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
+ "Comment too big found", NULL);
+ xmlFree (buf);
+ return;
+ }
ctxt->input->cur = in;
if (*in == 0xA) {
in++;
@@ -3990,10 +5067,18 @@ get_more:
}
SHRINK;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(buf);
+ return;
+ }
in = ctxt->input->cur;
if (*in == '-') {
if (in[1] == '-') {
if (in[2] == '>') {
+ if (ctxt->input->id != inputid) {
+ xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+ "comment doesn't start and stop in the same entity\n");
+ }
SKIP(3);
if ((ctxt->sax != NULL) && (ctxt->sax->comment != NULL) &&
(!ctxt->disableSAX)) {
@@ -4004,16 +5089,18 @@ get_more:
}
if (buf != NULL)
xmlFree(buf);
- ctxt->instate = state;
+ if (ctxt->instate != XML_PARSER_EOF)
+ ctxt->instate = state;
return;
}
- if (buf != NULL)
- xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
- "Comment not terminated \n<!--%.50s\n",
+ if (buf != NULL) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
+ "Double hyphen within comment: "
+ "<!--%.50s\n",
buf);
- else
- xmlFatalErrMsgStr(ctxt, XML_ERR_COMMENT_NOT_FINISHED,
- "Comment not terminated \n", NULL);
+ } else
+ xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
+ "Double hyphen within comment\n", NULL);
in++;
ctxt->input->col++;
}
@@ -4031,7 +5118,7 @@ get_more:
/**
* xmlParsePITarget:
* @ctxt: an XML parser context
- *
+ *
* parse the name of a PI
*
* [17] PITarget ::= Name - (('X' | 'x') ('M' | 'm') ('L' | 'l'))
@@ -4067,6 +5154,10 @@ xmlParsePITarget(xmlParserCtxtPtr ctxt) {
"xmlParsePITarget: invalid name prefix 'xml'\n",
NULL, NULL);
}
+ if ((name != NULL) && (xmlStrchr(name, ':') != NULL)) {
+ xmlNsErr(ctxt, XML_NS_ERR_COLON,
+ "colons are forbidden from PI names '%s'\n", name, NULL, NULL);
+ }
return(name);
}
@@ -4075,7 +5166,7 @@ xmlParsePITarget(xmlParserCtxtPtr ctxt) {
* xmlParseCatalogPI:
* @ctxt: an XML parser context
* @catalog: the PI value string
- *
+ *
* parse an XML Catalog Processing Instruction.
*
* <?oasis-xml-catalog catalog="http://example.com/catalog.xml"?>
@@ -4135,7 +5226,7 @@ error:
/**
* xmlParsePI:
* @ctxt: an XML parser context
- *
+ *
* parse an XML Processing Instruction.
*
* [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
@@ -4146,8 +5237,8 @@ error:
void
xmlParsePI(xmlParserCtxtPtr ctxt) {
xmlChar *buf = NULL;
- int len = 0;
- int size = XML_PARSER_BUFFER_SIZE;
+ size_t len = 0;
+ size_t size = XML_PARSER_BUFFER_SIZE;
int cur, l;
const xmlChar *target;
xmlParserInputState state;
@@ -4183,7 +5274,8 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
(ctxt->sax->processingInstruction != NULL))
ctxt->sax->processingInstruction(ctxt->userData,
target, NULL);
- ctxt->instate = state;
+ if (ctxt->instate != XML_PARSER_EOF)
+ ctxt->instate = state;
return;
}
buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar));
@@ -4203,9 +5295,8 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
((cur != '?') || (NXT(1) != '>'))) {
if (len + 5 >= size) {
xmlChar *tmp;
-
- size *= 2;
- tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+ size_t new_size = size * 2;
+ tmp = (xmlChar *) xmlRealloc(buf, new_size);
if (tmp == NULL) {
xmlErrMemory(ctxt, NULL);
xmlFree(buf);
@@ -4213,11 +5304,24 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
return;
}
buf = tmp;
+ size = new_size;
}
count++;
if (count > 50) {
GROW;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(buf);
+ return;
+ }
count = 0;
+ if ((len > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
+ "PI %s too big found", target);
+ xmlFree(buf);
+ ctxt->instate = state;
+ return;
+ }
}
COPY_BUF(l,buf,len,cur);
NEXTL(l);
@@ -4228,6 +5332,14 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
cur = CUR_CHAR(l);
}
}
+ if ((len > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
+ "PI %s too big found", target);
+ xmlFree(buf);
+ ctxt->instate = state;
+ return;
+ }
buf[len] = 0;
if (cur != '?') {
xmlFatalErrMsgStr(ctxt, XML_ERR_PI_NOT_FINISHED,
@@ -4263,7 +5375,8 @@ xmlParsePI(xmlParserCtxtPtr ctxt) {
} else {
xmlFatalErr(ctxt, XML_ERR_PI_NOT_STARTED, NULL);
}
- ctxt->instate = state;
+ if (ctxt->instate != XML_PARSER_EOF)
+ ctxt->instate = state;
}
}
@@ -4288,7 +5401,7 @@ xmlParseNotationDecl(xmlParserCtxtPtr ctxt) {
const xmlChar *name;
xmlChar *Pubid;
xmlChar *Systemid;
-
+
if (CMP10(CUR_PTR, '<', '!', 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N')) {
xmlParserInputPtr input = ctxt->input;
SHRINK;
@@ -4310,6 +5423,11 @@ xmlParseNotationDecl(xmlParserCtxtPtr ctxt) {
"Space required after the NOTATION name'\n");
return;
}
+ if (xmlStrchr(name, ':') != NULL) {
+ xmlNsErr(ctxt, XML_NS_ERR_COLON,
+ "colons are forbidden from notation names '%s'\n",
+ name, NULL, NULL);
+ }
SKIP_BLANKS;
/*
@@ -4366,7 +5484,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
int isParameter = 0;
xmlChar *orig = NULL;
int skipped;
-
+
/* GROW; done in the caller */
if (CMP8(CUR_PTR, '<', '!', 'E', 'N', 'T', 'I', 'T', 'Y')) {
xmlParserInputPtr input = ctxt->input;
@@ -4394,6 +5512,11 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
"xmlParseEntityDecl: no name\n");
return;
}
+ if (xmlStrchr(name, ':') != NULL) {
+ xmlNsErr(ctxt, XML_NS_ERR_COLON,
+ "colons are forbidden from entities names '%s'\n",
+ name, NULL, NULL);
+ }
skipped = SKIP_BLANKS;
if (skipped == 0) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
@@ -4465,6 +5588,11 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
(xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE))) {
if (ctxt->myDoc == NULL) {
ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
+ if (ctxt->myDoc == NULL) {
+ xmlErrMemory(ctxt, "New Doc failed");
+ return;
+ }
+ ctxt->myDoc->properties = XML_DOC_INTERNAL;
}
if (ctxt->myDoc->intSubset == NULL)
ctxt->myDoc->intSubset = xmlNewDtd(ctxt->myDoc,
@@ -4533,6 +5661,11 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
(xmlStrEqual(ctxt->myDoc->version, SAX_COMPAT_MODE)))) {
if (ctxt->myDoc == NULL) {
ctxt->myDoc = xmlNewDoc(SAX_COMPAT_MODE);
+ if (ctxt->myDoc == NULL) {
+ xmlErrMemory(ctxt, "New Doc failed");
+ return;
+ }
+ ctxt->myDoc->properties = XML_DOC_INTERNAL;
}
if (ctxt->myDoc->intSubset == NULL)
@@ -4545,10 +5678,13 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
}
}
}
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
SKIP_BLANKS;
if (RAW != '>') {
xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_NOT_FINISHED,
"xmlParseEntityDecl: entity %s not terminated\n", name);
+ xmlHaltParser(ctxt);
} else {
if (input != ctxt->input) {
xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
@@ -4608,13 +5744,13 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
*
* [ VC: Fixed Attribute Default ]
* if an attribute has a default value declared with the #FIXED
- * keyword, instances of that attribute must match the default value.
+ * keyword, instances of that attribute must match the default value.
*
* [ WFC: No < in Attribute Values ]
* handled in xmlParseAttValue()
*
* returns: XML_ATTRIBUTE_NONE, XML_ATTRIBUTE_REQUIRED, XML_ATTRIBUTE_IMPLIED
- * or XML_ATTRIBUTE_FIXED.
+ * or XML_ATTRIBUTE_FIXED.
*/
int
@@ -4663,7 +5799,7 @@ xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, xmlChar **value) {
*
* [ VC: Notation Attributes ]
* Values of this type must match one of the notation names included
- * in the declaration; all notation names in the declaration must be declared.
+ * in the declaration; all notation names in the declaration must be declared.
*
* Returns: the notation attribute tree built while parsing
*/
@@ -4671,7 +5807,7 @@ xmlParseDefaultDecl(xmlParserCtxtPtr ctxt, xmlChar **value) {
xmlEnumerationPtr
xmlParseNotationType(xmlParserCtxtPtr ctxt) {
const xmlChar *name;
- xmlEnumerationPtr ret = NULL, last = NULL, cur;
+ xmlEnumerationPtr ret = NULL, last = NULL, cur, tmp;
if (RAW != '(') {
xmlFatalErr(ctxt, XML_ERR_NOTATION_NOT_STARTED, NULL);
@@ -4685,22 +5821,39 @@ xmlParseNotationType(xmlParserCtxtPtr ctxt) {
if (name == NULL) {
xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
"Name expected in NOTATION declaration\n");
- return(ret);
+ xmlFreeEnumeration(ret);
+ return(NULL);
}
- cur = xmlCreateEnumeration(name);
- if (cur == NULL) return(ret);
- if (last == NULL) ret = last = cur;
- else {
- last->next = cur;
- last = cur;
+ tmp = ret;
+ while (tmp != NULL) {
+ if (xmlStrEqual(name, tmp->name)) {
+ xmlValidityError(ctxt, XML_DTD_DUP_TOKEN,
+ "standalone: attribute notation value token %s duplicated\n",
+ name, NULL);
+ if (!xmlDictOwns(ctxt->dict, name))
+ xmlFree((xmlChar *) name);
+ break;
+ }
+ tmp = tmp->next;
+ }
+ if (tmp == NULL) {
+ cur = xmlCreateEnumeration(name);
+ if (cur == NULL) {
+ xmlFreeEnumeration(ret);
+ return(NULL);
+ }
+ if (last == NULL) ret = last = cur;
+ else {
+ last->next = cur;
+ last = cur;
+ }
}
SKIP_BLANKS;
} while (RAW == '|');
if (RAW != ')') {
xmlFatalErr(ctxt, XML_ERR_NOTATION_NOT_FINISHED, NULL);
- if ((last != NULL) && (last != ret))
- xmlFreeEnumeration(last);
- return(ret);
+ xmlFreeEnumeration(ret);
+ return(NULL);
}
NEXT;
return(ret);
@@ -4724,7 +5877,7 @@ xmlParseNotationType(xmlParserCtxtPtr ctxt) {
xmlEnumerationPtr
xmlParseEnumerationType(xmlParserCtxtPtr ctxt) {
xmlChar *name;
- xmlEnumerationPtr ret = NULL, last = NULL, cur;
+ xmlEnumerationPtr ret = NULL, last = NULL, cur, tmp;
if (RAW != '(') {
xmlFatalErr(ctxt, XML_ERR_ATTLIST_NOT_STARTED, NULL);
@@ -4739,13 +5892,31 @@ xmlParseEnumerationType(xmlParserCtxtPtr ctxt) {
xmlFatalErr(ctxt, XML_ERR_NMTOKEN_REQUIRED, NULL);
return(ret);
}
- cur = xmlCreateEnumeration(name);
- xmlFree(name);
- if (cur == NULL) return(ret);
- if (last == NULL) ret = last = cur;
- else {
- last->next = cur;
- last = cur;
+ tmp = ret;
+ while (tmp != NULL) {
+ if (xmlStrEqual(name, tmp->name)) {
+ xmlValidityError(ctxt, XML_DTD_DUP_TOKEN,
+ "standalone: attribute enumeration value token %s duplicated\n",
+ name, NULL);
+ if (!xmlDictOwns(ctxt->dict, name))
+ xmlFree(name);
+ break;
+ }
+ tmp = tmp->next;
+ }
+ if (tmp == NULL) {
+ cur = xmlCreateEnumeration(name);
+ if (!xmlDictOwns(ctxt->dict, name))
+ xmlFree(name);
+ if (cur == NULL) {
+ xmlFreeEnumeration(ret);
+ return(NULL);
+ }
+ if (last == NULL) ret = last = cur;
+ else {
+ last->next = cur;
+ last = cur;
+ }
}
SKIP_BLANKS;
} while (RAW == '|');
@@ -4828,15 +5999,15 @@ xmlParseEnumeratedType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) {
* [ VC: Entity Name ]
* Values of type ENTITY must match the Name production, values
* of type ENTITIES must match Names; each Entity Name must match the
- * name of an unparsed entity declared in the DTD.
+ * name of an unparsed entity declared in the DTD.
*
* [ VC: Name Token ]
* Values of type NMTOKEN must match the Nmtoken production; values
- * of type NMTOKENS must match Nmtokens.
+ * of type NMTOKENS must match Nmtokens.
*
* Returns the attribute type
*/
-int
+int
xmlParseAttributeType(xmlParserCtxtPtr ctxt, xmlEnumerationPtr *tree) {
SHRINK;
if (CMP5(CUR_PTR, 'C', 'D', 'A', 'T', 'A')) {
@@ -4901,7 +6072,7 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) {
}
SKIP_BLANKS;
GROW;
- while (RAW != '>') {
+ while ((RAW != '>') && (ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *check = CUR_PTR;
int type;
int def;
@@ -4946,6 +6117,8 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) {
xmlFreeEnumeration(tree);
break;
}
+ if ((type != XML_ATTRIBUTE_CDATA) && (defaultValue != NULL))
+ xmlAttrNormalizeSpace(defaultValue, defaultValue);
GROW;
if (RAW != '>') {
@@ -4977,11 +6150,11 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) {
xmlFreeEnumeration(tree);
if ((ctxt->sax2) && (defaultValue != NULL) &&
- (def != XML_ATTRIBUTE_IMPLIED) &&
+ (def != XML_ATTRIBUTE_IMPLIED) &&
(def != XML_ATTRIBUTE_REQUIRED)) {
xmlAddDefAttrs(ctxt, elemName, attrName, defaultValue);
}
- if ((ctxt->sax2) && (type != XML_ATTRIBUTE_CDATA)) {
+ if (ctxt->sax2) {
xmlAddSpecialAttr(ctxt, elemName, attrName, type);
}
if (defaultValue != NULL)
@@ -4990,8 +6163,9 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) {
}
if (RAW == '>') {
if (input != ctxt->input) {
- xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
- "Attribute list declaration doesn't start and stop in the same entity\n");
+ xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
+ "Attribute list declaration doesn't start and stop in the same entity\n",
+ NULL, NULL);
}
NEXT;
}
@@ -5005,7 +6179,7 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) {
*
* parse the declaration for a Mixed Element content
* The leading '(' and spaces have been skipped in xmlParseElementContentDecl
- *
+ *
* [51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' |
* '(' S? '#PCDATA' S? ')'
*
@@ -5013,7 +6187,7 @@ xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt) {
*
* [ VC: No Duplicate Types ]
* The same name must not appear more than once in a single
- * mixed-content declaration.
+ * mixed-content declaration.
*
* returns: the list of the xmlElementContentPtr describing the element choices
*/
@@ -5031,10 +6205,12 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
if ((ctxt->validate) && (ctxt->input->id != inputchk)) {
xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
"Element content declaration doesn't start and stop in the same entity\n",
- NULL);
+ NULL, NULL);
}
NEXT;
ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA);
+ if (ret == NULL)
+ return(NULL);
if (RAW == '*') {
ret->ocur = XML_ELEMENT_CONTENT_MULT;
NEXT;
@@ -5045,7 +6221,7 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
ret = cur = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_PCDATA);
if (ret == NULL) return(NULL);
}
- while (RAW == '|') {
+ while ((RAW == '|') && (ctxt->instate != XML_PARSER_EOF)) {
NEXT;
if (elem == NULL) {
ret = xmlNewDocElementContent(ctxt->myDoc, NULL, XML_ELEMENT_CONTENT_OR);
@@ -5083,11 +6259,12 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
if (cur->c2 != NULL)
cur->c2->parent = cur;
}
- ret->ocur = XML_ELEMENT_CONTENT_MULT;
+ if (ret != NULL)
+ ret->ocur = XML_ELEMENT_CONTENT_MULT;
if ((ctxt->validate) && (ctxt->input->id != inputchk)) {
xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
"Element content declaration doesn't start and stop in the same entity\n",
- NULL);
+ NULL, NULL);
}
SKIP(2);
} else {
@@ -5103,13 +6280,14 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
}
/**
- * xmlParseElementChildrenContentDecl:
+ * xmlParseElementChildrenContentDeclPriv:
* @ctxt: an XML parser context
* @inputchk: the input used for the current entity, needed for boundary checks
+ * @depth: the level of recursion
*
* parse the declaration for a Mixed Element content
* The leading '(' and spaces have been skipped in xmlParseElementContentDecl
- *
+ *
*
* [47] children ::= (choice | seq) ('?' | '*' | '+')?
*
@@ -5130,15 +6308,23 @@ xmlParseElementMixedContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
* be empty, and neither the first nor last non-blank character of
* the replacement text should be a connector (| or ,).
*
- * Returns the tree of xmlElementContentPtr describing the element
+ * Returns the tree of xmlElementContentPtr describing the element
* hierarchy.
*/
-xmlElementContentPtr
-xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
+static xmlElementContentPtr
+xmlParseElementChildrenContentDeclPriv(xmlParserCtxtPtr ctxt, int inputchk,
+ int depth) {
xmlElementContentPtr ret = NULL, cur = NULL, last = NULL, op = NULL;
const xmlChar *elem;
xmlChar type = 0;
+ if (((depth > 128) && ((ctxt->options & XML_PARSE_HUGE) == 0)) ||
+ (depth > 2048)) {
+ xmlFatalErrMsgInt(ctxt, XML_ERR_ELEMCONTENT_NOT_FINISHED,
+"xmlParseElementChildrenContentDecl : depth %d too deep, use XML_PARSE_HUGE\n",
+ depth);
+ return(NULL);
+ }
SKIP_BLANKS;
GROW;
if (RAW == '(') {
@@ -5147,7 +6333,8 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
/* Recurse on first child */
NEXT;
SKIP_BLANKS;
- cur = ret = xmlParseElementChildrenContentDecl(ctxt, inputid);
+ cur = ret = xmlParseElementChildrenContentDeclPriv(ctxt, inputid,
+ depth + 1);
SKIP_BLANKS;
GROW;
} else {
@@ -5178,7 +6365,7 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
}
SKIP_BLANKS;
SHRINK;
- while (RAW != ')') {
+ while ((RAW != ')') && (ctxt->instate != XML_PARSER_EOF)) {
/*
* Each loop we parse one separator and one element.
*/
@@ -5265,6 +6452,8 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
}
} else {
xmlFatalErr(ctxt, XML_ERR_ELEMCONTENT_NOT_FINISHED, NULL);
+ if ((last != NULL) && (last != ret))
+ xmlFreeDocElementContent(ctxt->myDoc, last);
if (ret != NULL)
xmlFreeDocElementContent(ctxt->myDoc, ret);
return(NULL);
@@ -5277,7 +6466,8 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
/* Recurse on second child */
NEXT;
SKIP_BLANKS;
- last = xmlParseElementChildrenContentDecl(ctxt, inputid);
+ last = xmlParseElementChildrenContentDeclPriv(ctxt, inputid,
+ depth + 1);
SKIP_BLANKS;
} else {
elem = xmlParseName(ctxt);
@@ -5288,6 +6478,11 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
return(NULL);
}
last = xmlNewDocElementContent(ctxt->myDoc, elem, XML_ELEMENT_CONTENT_ELEMENT);
+ if (last == NULL) {
+ if (ret != NULL)
+ xmlFreeDocElementContent(ctxt->myDoc, ret);
+ return(NULL);
+ }
if (RAW == '?') {
last->ocur = XML_ELEMENT_CONTENT_OPT;
NEXT;
@@ -5312,7 +6507,7 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
if ((ctxt->validate) && (ctxt->input->id != inputchk)) {
xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
"Element content declaration doesn't start and stop in the same entity\n",
- NULL);
+ NULL, NULL);
}
NEXT;
if (RAW == '?') {
@@ -5383,6 +6578,42 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
}
/**
+ * xmlParseElementChildrenContentDecl:
+ * @ctxt: an XML parser context
+ * @inputchk: the input used for the current entity, needed for boundary checks
+ *
+ * parse the declaration for a Mixed Element content
+ * The leading '(' and spaces have been skipped in xmlParseElementContentDecl
+ *
+ * [47] children ::= (choice | seq) ('?' | '*' | '+')?
+ *
+ * [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')?
+ *
+ * [49] choice ::= '(' S? cp ( S? '|' S? cp )* S? ')'
+ *
+ * [50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')'
+ *
+ * [ VC: Proper Group/PE Nesting ] applies to [49] and [50]
+ * TODO Parameter-entity replacement text must be properly nested
+ * with parenthesized groups. That is to say, if either of the
+ * opening or closing parentheses in a choice, seq, or Mixed
+ * construct is contained in the replacement text for a parameter
+ * entity, both must be contained in the same replacement text. For
+ * interoperability, if a parameter-entity reference appears in a
+ * choice, seq, or Mixed construct, its replacement text should not
+ * be empty, and neither the first nor last non-blank character of
+ * the replacement text should be a connector (| or ,).
+ *
+ * Returns the tree of xmlElementContentPtr describing the element
+ * hierarchy.
+ */
+xmlElementContentPtr
+xmlParseElementChildrenContentDecl(xmlParserCtxtPtr ctxt, int inputchk) {
+ /* stub left for API/ABI compat */
+ return(xmlParseElementChildrenContentDeclPriv(ctxt, inputchk, 1));
+}
+
+/**
* xmlParseElementContentDecl:
* @ctxt: an XML parser context
* @name: the name of the element being defined.
@@ -5390,7 +6621,7 @@ xmlParseElementChildrenContentDecl (xmlParserCtxtPtr ctxt, int inputchk) {
*
* parse the declaration for an Element content either Mixed or Children,
* the cases EMPTY and ANY are handled directly in xmlParseElementDecl
- *
+ *
* [46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children
*
* returns: the type of element content XML_ELEMENT_TYPE_xxx
@@ -5413,12 +6644,14 @@ xmlParseElementContentDecl(xmlParserCtxtPtr ctxt, const xmlChar *name,
}
NEXT;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(-1);
SKIP_BLANKS;
if (CMP7(CUR_PTR, '#', 'P', 'C', 'D', 'A', 'T', 'A')) {
tree = xmlParseElementMixedContentDecl(ctxt, inputid);
res = XML_ELEMENT_TYPE_MIXED;
} else {
- tree = xmlParseElementChildrenContentDecl(ctxt, inputid);
+ tree = xmlParseElementChildrenContentDeclPriv(ctxt, inputid, 1);
res = XML_ELEMENT_TYPE_ELEMENT;
}
SKIP_BLANKS;
@@ -5516,7 +6749,7 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) {
xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
"Element declaration doesn't start and stop in the same entity\n");
}
-
+
NEXT;
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
(ctxt->sax->elementDecl != NULL)) {
@@ -5528,7 +6761,7 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) {
/*
* this is a trick: if xmlAddElementDecl is called,
* instead of copying the full tree it is plugged directly
- * if called from the parser. Avoid duplicating the
+ * if called from the parser. Avoid duplicating the
* interfaces or change the API/ABI
*/
xmlFreeDocElementContent(ctxt->myDoc, content);
@@ -5545,8 +6778,8 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) {
* xmlParseConditionalSections
* @ctxt: an XML parser context
*
- * [61] conditionalSect ::= includeSect | ignoreSect
- * [62] includeSect ::= '<![' S? 'INCLUDE' S? '[' extSubsetDecl ']]>'
+ * [61] conditionalSect ::= includeSect | ignoreSect
+ * [62] includeSect ::= '<![' S? 'INCLUDE' S? '[' extSubsetDecl ']]>'
* [63] ignoreSect ::= '<![' S? 'IGNORE' S? '[' ignoreSectContents* ']]>'
* [64] ignoreSectContents ::= Ignore ('<![' ignoreSectContents ']]>' Ignore)*
* [65] Ignore ::= Char* - (Char* ('<![' | ']]>') Char*)
@@ -5554,6 +6787,8 @@ xmlParseElementDecl(xmlParserCtxtPtr ctxt) {
static void
xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
+ int id = ctxt->input->id;
+
SKIP(3);
SKIP_BLANKS;
if (CMP7(CUR_PTR, 'I', 'N', 'C', 'L', 'U', 'D', 'E')) {
@@ -5561,7 +6796,14 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
SKIP_BLANKS;
if (RAW != '[') {
xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
+ xmlHaltParser(ctxt);
+ return;
} else {
+ if (ctxt->input->id != id) {
+ xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
+ "All markup of the conditional section is not in the same entity\n",
+ NULL, NULL);
+ }
NEXT;
}
if (xmlParserDebugEntities) {
@@ -5573,8 +6815,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
"Entering INCLUDE Conditional Section\n");
}
- while ((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') ||
- (NXT(2) != '>'))) {
+ while (((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') ||
+ (NXT(2) != '>'))) && (ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *check = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
@@ -5616,7 +6858,14 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
SKIP_BLANKS;
if (RAW != '[') {
xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
+ xmlHaltParser(ctxt);
+ return;
} else {
+ if (ctxt->input->id != id) {
+ xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
+ "All markup of the conditional section is not in the same entity\n",
+ NULL, NULL);
+ }
NEXT;
}
if (xmlParserDebugEntities) {
@@ -5637,7 +6886,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
if (ctxt->recovery == 0) ctxt->disableSAX = 1;
ctxt->instate = XML_PARSER_IGNORE;
- while ((depth >= 0) && (RAW != 0)) {
+ while (((depth >= 0) && (RAW != 0)) &&
+ (ctxt->instate != XML_PARSER_EOF)) {
if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
depth++;
SKIP(3);
@@ -5665,6 +6915,8 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
} else {
xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL);
+ xmlHaltParser(ctxt);
+ return;
}
if (RAW == 0)
@@ -5673,14 +6925,21 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
if (RAW == 0) {
xmlFatalErr(ctxt, XML_ERR_CONDSEC_NOT_FINISHED, NULL);
} else {
- SKIP(3);
+ if (ctxt->input->id != id) {
+ xmlValidityError(ctxt, XML_ERR_ENTITY_BOUNDARY,
+ "All markup of the conditional section is not in the same entity\n",
+ NULL, NULL);
+ }
+ if ((ctxt-> instate != XML_PARSER_EOF) &&
+ ((ctxt->input->cur + 3) <= ctxt->input->end))
+ SKIP(3);
}
}
/**
* xmlParseMarkupDecl:
* @ctxt: an XML parser context
- *
+ *
* parse Markup declarations
*
* [29] markupdecl ::= elementdecl | AttlistDecl | EntityDecl |
@@ -5697,7 +6956,7 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
* In the internal DTD subset, parameter-entity references can occur
* only where markup declarations can occur, not within markup declarations.
* (This does not apply to references that occur in external parameter
- * entities or to the external subset.)
+ * entities or to the external subset.)
*/
void
xmlParseMarkupDecl(xmlParserCtxtPtr ctxt) {
@@ -5728,6 +6987,14 @@ xmlParseMarkupDecl(xmlParserCtxtPtr ctxt) {
xmlParsePI(ctxt);
}
}
+
+ /*
+ * detect requirement to exit there and act accordingly
+ * and avoid having instate overriden later on
+ */
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
+
/*
* This is only for internal subset. On external entities,
* the replacement is done before parsing stage
@@ -5751,12 +7018,10 @@ xmlParseMarkupDecl(xmlParserCtxtPtr ctxt) {
/**
* xmlParseTextDecl:
* @ctxt: an XML parser context
- *
+ *
* parse an XML declaration header for external entities
*
* [77] TextDecl ::= '<?xml' VersionInfo? EncodingDecl S? '?>'
- *
- * Question: Seems that EncodingDecl is mandatory ? Is that a typo ?
*/
void
@@ -5828,7 +7093,7 @@ xmlParseTextDecl(xmlParserCtxtPtr ctxt) {
* @ctxt: an XML parser context
* @ExternalID: the external identifier
* @SystemID: the system identifier (or URL)
- *
+ *
* parse Markup declarations from an external subset
*
* [30] extSubset ::= textDecl? extSubsetDecl
@@ -5840,18 +7105,38 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
const xmlChar *SystemID) {
xmlDetectSAX2(ctxt);
GROW;
+
+ if ((ctxt->encoding == NULL) &&
+ (ctxt->input->end - ctxt->input->cur >= 4)) {
+ xmlChar start[4];
+ xmlCharEncoding enc;
+
+ start[0] = RAW;
+ start[1] = NXT(1);
+ start[2] = NXT(2);
+ start[3] = NXT(3);
+ enc = xmlDetectCharEncoding(start, 4);
+ if (enc != XML_CHAR_ENCODING_NONE)
+ xmlSwitchEncoding(ctxt, enc);
+ }
+
if (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) {
xmlParseTextDecl(ctxt);
if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
/*
* The XML REC instructs us to stop parsing right here
*/
- ctxt->instate = XML_PARSER_EOF;
+ xmlHaltParser(ctxt);
return;
}
}
if (ctxt->myDoc == NULL) {
ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
+ if (ctxt->myDoc == NULL) {
+ xmlErrMemory(ctxt, "New Doc failed");
+ return;
+ }
+ ctxt->myDoc->properties = XML_DOC_INTERNAL;
}
if ((ctxt->myDoc != NULL) && (ctxt->myDoc->intSubset == NULL))
xmlCreateIntSubset(ctxt->myDoc, NULL, ExternalID, SystemID);
@@ -5885,7 +7170,7 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
break;
}
}
-
+
if (RAW != 0) {
xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
}
@@ -5895,7 +7180,7 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
/**
* xmlParseReference:
* @ctxt: an XML parser context
- *
+ *
* parse and handle entity references in content, depending on the SAX
* interface, this may end-up in a call to character() if this is a
* CharRef, a predefined entity, if there is no reference() callback.
@@ -5907,14 +7192,25 @@ void
xmlParseReference(xmlParserCtxtPtr ctxt) {
xmlEntityPtr ent;
xmlChar *val;
- if (RAW != '&') return;
+ int was_checked;
+ xmlNodePtr list = NULL;
+ xmlParserErrors ret = XML_ERR_OK;
+
+
+ if (RAW != '&')
+ return;
+ /*
+ * Simple case of a CharRef
+ */
if (NXT(1) == '#') {
int i = 0;
xmlChar out[10];
int hex = NXT(2);
int value = xmlParseCharRef(ctxt);
-
+
+ if (value == 0)
+ return;
if (ctxt->charset != XML_CHAR_ENCODING_UTF8) {
/*
* So we are using non-UTF-8 buffers
@@ -5946,359 +7242,367 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
(!ctxt->disableSAX))
ctxt->sax->characters(ctxt->userData, out, i);
}
- } else {
- int was_checked;
+ return;
+ }
- ent = xmlParseEntityRef(ctxt);
- if (ent == NULL) return;
- if (!ctxt->wellFormed)
- return;
- was_checked = ent->checked;
- if ((ent->name != NULL) &&
- (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY)) {
- xmlNodePtr list = NULL;
- xmlParserErrors ret = XML_ERR_OK;
+ /*
+ * We are seeing an entity reference
+ */
+ ent = xmlParseEntityRef(ctxt);
+ if (ent == NULL) return;
+ if (!ctxt->wellFormed)
+ return;
+ was_checked = ent->checked;
+
+ /* special case of predefined entities */
+ if ((ent->name == NULL) ||
+ (ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
+ val = ent->content;
+ if (val == NULL) return;
+ /*
+ * inline the entity.
+ */
+ if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
+ (!ctxt->disableSAX))
+ ctxt->sax->characters(ctxt->userData, val, xmlStrlen(val));
+ return;
+ }
+ /*
+ * The first reference to the entity trigger a parsing phase
+ * where the ent->children is filled with the result from
+ * the parsing.
+ * Note: external parsed entities will not be loaded, it is not
+ * required for a non-validating parser, unless the parsing option
+ * of validating, or substituting entities were given. Doing so is
+ * far more secure as the parser will only process data coming from
+ * the document entity by default.
+ */
+ if (((ent->checked == 0) ||
+ ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) &&
+ ((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) ||
+ (ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) {
+ unsigned long oldnbent = ctxt->nbentities;
- /*
- * The first reference to the entity trigger a parsing phase
- * where the ent->children is filled with the result from
- * the parsing.
- */
- if (ent->checked == 0) {
- xmlChar *value;
+ /*
+ * This is a bit hackish but this seems the best
+ * way to make sure both SAX and DOM entity support
+ * behaves okay.
+ */
+ void *user_data;
+ if (ctxt->userData == ctxt)
+ user_data = NULL;
+ else
+ user_data = ctxt->userData;
- value = ent->content;
+ /*
+ * Check that this entity is well formed
+ * 4.3.2: An internal general parsed entity is well-formed
+ * if its replacement text matches the production labeled
+ * content.
+ */
+ if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) {
+ ctxt->depth++;
+ ret = xmlParseBalancedChunkMemoryInternal(ctxt, ent->content,
+ user_data, &list);
+ ctxt->depth--;
+
+ } else if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) {
+ ctxt->depth++;
+ ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt, ctxt->sax,
+ user_data, ctxt->depth, ent->URI,
+ ent->ExternalID, &list);
+ ctxt->depth--;
+ } else {
+ ret = XML_ERR_ENTITY_PE_INTERNAL;
+ xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
+ "invalid entity type found\n", NULL);
+ }
- /*
- * Check that this entity is well formed
- */
- if ((value != NULL) && (value[0] != 0) &&
- (value[1] == 0) && (value[0] == '<') &&
- (xmlStrEqual(ent->name, BAD_CAST "lt"))) {
- /*
- * DONE: get definite answer on this !!!
- * Lots of entity decls are used to declare a single
- * char
- * <!ENTITY lt "<">
- * Which seems to be valid since
- * 2.4: The ampersand character (&) and the left angle
- * bracket (<) may appear in their literal form only
- * when used ... They are also legal within the literal
- * entity value of an internal entity declaration;i
- * see "4.3.2 Well-Formed Parsed Entities".
- * IMHO 2.4 and 4.3.2 are directly in contradiction.
- * Looking at the OASIS test suite and James Clark
- * tests, this is broken. However the XML REC uses
- * it. Is the XML REC not well-formed ????
- * This is a hack to avoid this problem
- *
- * ANSWER: since lt gt amp .. are already defined,
- * this is a redefinition and hence the fact that the
- * content is not well balanced is not a Wf error, this
- * is lousy but acceptable.
- */
- list = xmlNewDocText(ctxt->myDoc, value);
- if (list != NULL) {
- if ((ent->etype == XML_INTERNAL_GENERAL_ENTITY) &&
- (ent->children == NULL)) {
- ent->children = list;
- ent->last = list;
- ent->owner = 1;
- list->parent = (xmlNodePtr) ent;
- } else {
- xmlFreeNodeList(list);
- }
- } else if (list != NULL) {
- xmlFreeNodeList(list);
- }
- } else {
- /*
- * 4.3.2: An internal general parsed entity is well-formed
- * if its replacement text matches the production labeled
- * content.
- */
+ /*
+ * Store the number of entities needing parsing for this entity
+ * content and do checkings
+ */
+ ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
+ if ((ent->content != NULL) && (xmlStrchr(ent->content, '<')))
+ ent->checked |= 1;
+ if (ret == XML_ERR_ENTITY_LOOP) {
+ xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
+ xmlFreeNodeList(list);
+ return;
+ }
+ if (xmlParserEntityCheck(ctxt, 0, ent, 0)) {
+ xmlFreeNodeList(list);
+ return;
+ }
- void *user_data;
+ if ((ret == XML_ERR_OK) && (list != NULL)) {
+ if (((ent->etype == XML_INTERNAL_GENERAL_ENTITY) ||
+ (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY))&&
+ (ent->children == NULL)) {
+ ent->children = list;
+ if (ctxt->replaceEntities) {
/*
- * This is a bit hackish but this seems the best
- * way to make sure both SAX and DOM entity support
- * behaves okay.
+ * Prune it directly in the generated document
+ * except for single text nodes.
*/
- if (ctxt->userData == ctxt)
- user_data = NULL;
- else
- user_data = ctxt->userData;
-
- if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) {
- ctxt->depth++;
- ret = xmlParseBalancedChunkMemoryInternal(ctxt,
- value, user_data, &list);
- ctxt->depth--;
- } else if (ent->etype ==
- XML_EXTERNAL_GENERAL_PARSED_ENTITY) {
- ctxt->depth++;
- ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt,
- ctxt->sax, user_data, ctxt->depth,
- ent->URI, ent->ExternalID, &list);
- ctxt->depth--;
+ if (((list->type == XML_TEXT_NODE) &&
+ (list->next == NULL)) ||
+ (ctxt->parseMode == XML_PARSE_READER)) {
+ list->parent = (xmlNodePtr) ent;
+ list = NULL;
+ ent->owner = 1;
} else {
- ret = XML_ERR_ENTITY_PE_INTERNAL;
- xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
- "invalid entity type found\n", NULL);
- }
- if (ret == XML_ERR_ENTITY_LOOP) {
- xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
- return;
- } else if ((ret == XML_ERR_OK) && (list != NULL)) {
- if (((ent->etype == XML_INTERNAL_GENERAL_ENTITY) ||
- (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY))&&
- (ent->children == NULL)) {
- ent->children = list;
- if (ctxt->replaceEntities) {
- /*
- * Prune it directly in the generated document
- * except for single text nodes.
- */
- if (((list->type == XML_TEXT_NODE) &&
- (list->next == NULL)) ||
- (ctxt->parseMode == XML_PARSE_READER)) {
- list->parent = (xmlNodePtr) ent;
- list = NULL;
- ent->owner = 1;
- } else {
- ent->owner = 0;
- while (list != NULL) {
- list->parent = (xmlNodePtr) ctxt->node;
- list->doc = ctxt->myDoc;
- if (list->next == NULL)
- ent->last = list;
- list = list->next;
- }
- list = ent->children;
+ ent->owner = 0;
+ while (list != NULL) {
+ list->parent = (xmlNodePtr) ctxt->node;
+ list->doc = ctxt->myDoc;
+ if (list->next == NULL)
+ ent->last = list;
+ list = list->next;
+ }
+ list = ent->children;
#ifdef LIBXML_LEGACY_ENABLED
- if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
- xmlAddEntityReference(ent, list, NULL);
+ if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
+ xmlAddEntityReference(ent, list, NULL);
#endif /* LIBXML_LEGACY_ENABLED */
- }
- } else {
- ent->owner = 1;
- while (list != NULL) {
- list->parent = (xmlNodePtr) ent;
- if (list->next == NULL)
- ent->last = list;
- list = list->next;
- }
- }
- } else {
- xmlFreeNodeList(list);
- list = NULL;
- }
- } else if ((ret != XML_ERR_OK) &&
- (ret != XML_WAR_UNDECLARED_ENTITY)) {
- xmlFatalErr(ctxt, ret, NULL);
- } else if (list != NULL) {
- xmlFreeNodeList(list);
- list = NULL;
+ }
+ } else {
+ ent->owner = 1;
+ while (list != NULL) {
+ list->parent = (xmlNodePtr) ent;
+ xmlSetTreeDoc(list, ent->doc);
+ if (list->next == NULL)
+ ent->last = list;
+ list = list->next;
}
}
- ent->checked = 1;
+ } else {
+ xmlFreeNodeList(list);
+ list = NULL;
}
+ } else if ((ret != XML_ERR_OK) &&
+ (ret != XML_WAR_UNDECLARED_ENTITY)) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
+ "Entity '%s' failed to parse\n", ent->name);
+ xmlParserEntityCheck(ctxt, 0, ent, 0);
+ } else if (list != NULL) {
+ xmlFreeNodeList(list);
+ list = NULL;
+ }
+ if (ent->checked == 0)
+ ent->checked = 2;
+ } else if (ent->checked != 1) {
+ ctxt->nbentities += ent->checked / 2;
+ }
- if (ent->children == NULL) {
- /*
- * Probably running in SAX mode and the callbacks don't
- * build the entity content. So unless we already went
- * though parsing for first checking go though the entity
- * content to generate callbacks associated to the entity
- */
- if (was_checked == 1) {
- void *user_data;
- /*
- * This is a bit hackish but this seems the best
- * way to make sure both SAX and DOM entity support
- * behaves okay.
- */
- if (ctxt->userData == ctxt)
- user_data = NULL;
- else
- user_data = ctxt->userData;
-
- if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) {
- ctxt->depth++;
- ret = xmlParseBalancedChunkMemoryInternal(ctxt,
- ent->content, user_data, NULL);
- ctxt->depth--;
- } else if (ent->etype ==
- XML_EXTERNAL_GENERAL_PARSED_ENTITY) {
- ctxt->depth++;
- ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt,
- ctxt->sax, user_data, ctxt->depth,
- ent->URI, ent->ExternalID, NULL);
- ctxt->depth--;
- } else {
- ret = XML_ERR_ENTITY_PE_INTERNAL;
- xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
- "invalid entity type found\n", NULL);
- }
- if (ret == XML_ERR_ENTITY_LOOP) {
- xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
- return;
- }
- }
- if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
- (ctxt->replaceEntities == 0) && (!ctxt->disableSAX)) {
- /*
- * Entity reference callback comes second, it's somewhat
- * superfluous but a compatibility to historical behaviour
- */
- ctxt->sax->reference(ctxt->userData, ent->name);
- }
+ /*
+ * Now that the entity content has been gathered
+ * provide it to the application, this can take different forms based
+ * on the parsing modes.
+ */
+ if (ent->children == NULL) {
+ /*
+ * Probably running in SAX mode and the callbacks don't
+ * build the entity content. So unless we already went
+ * though parsing for first checking go though the entity
+ * content to generate callbacks associated to the entity
+ */
+ if (was_checked != 0) {
+ void *user_data;
+ /*
+ * This is a bit hackish but this seems the best
+ * way to make sure both SAX and DOM entity support
+ * behaves okay.
+ */
+ if (ctxt->userData == ctxt)
+ user_data = NULL;
+ else
+ user_data = ctxt->userData;
+
+ if (ent->etype == XML_INTERNAL_GENERAL_ENTITY) {
+ ctxt->depth++;
+ ret = xmlParseBalancedChunkMemoryInternal(ctxt,
+ ent->content, user_data, NULL);
+ ctxt->depth--;
+ } else if (ent->etype ==
+ XML_EXTERNAL_GENERAL_PARSED_ENTITY) {
+ ctxt->depth++;
+ ret = xmlParseExternalEntityPrivate(ctxt->myDoc, ctxt,
+ ctxt->sax, user_data, ctxt->depth,
+ ent->URI, ent->ExternalID, NULL);
+ ctxt->depth--;
+ } else {
+ ret = XML_ERR_ENTITY_PE_INTERNAL;
+ xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
+ "invalid entity type found\n", NULL);
+ }
+ if (ret == XML_ERR_ENTITY_LOOP) {
+ xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
return;
}
- if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
- (ctxt->replaceEntities == 0) && (!ctxt->disableSAX)) {
+ }
+ if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
+ (ctxt->replaceEntities == 0) && (!ctxt->disableSAX)) {
+ /*
+ * Entity reference callback comes second, it's somewhat
+ * superfluous but a compatibility to historical behaviour
+ */
+ ctxt->sax->reference(ctxt->userData, ent->name);
+ }
+ return;
+ }
+
+ /*
+ * If we didn't get any children for the entity being built
+ */
+ if ((ctxt->sax != NULL) && (ctxt->sax->reference != NULL) &&
+ (ctxt->replaceEntities == 0) && (!ctxt->disableSAX)) {
+ /*
+ * Create a node.
+ */
+ ctxt->sax->reference(ctxt->userData, ent->name);
+ return;
+ }
+
+ if ((ctxt->replaceEntities) || (ent->children == NULL)) {
+ /*
+ * There is a problem on the handling of _private for entities
+ * (bug 155816): Should we copy the content of the field from
+ * the entity (possibly overwriting some value set by the user
+ * when a copy is created), should we leave it alone, or should
+ * we try to take care of different situations? The problem
+ * is exacerbated by the usage of this field by the xmlReader.
+ * To fix this bug, we look at _private on the created node
+ * and, if it's NULL, we copy in whatever was in the entity.
+ * If it's not NULL we leave it alone. This is somewhat of a
+ * hack - maybe we should have further tests to determine
+ * what to do.
+ */
+ if ((ctxt->node != NULL) && (ent->children != NULL)) {
+ /*
+ * Seems we are generating the DOM content, do
+ * a simple tree copy for all references except the first
+ * In the first occurrence list contains the replacement.
+ */
+ if (((list == NULL) && (ent->owner == 0)) ||
+ (ctxt->parseMode == XML_PARSE_READER)) {
+ xmlNodePtr nw = NULL, cur, firstChild = NULL;
+
/*
- * Create a node.
+ * We are copying here, make sure there is no abuse
*/
- ctxt->sax->reference(ctxt->userData, ent->name);
- return;
- }
- if ((ctxt->replaceEntities) || (ent->children == NULL)) {
+ ctxt->sizeentcopy += ent->length + 5;
+ if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy))
+ return;
+
/*
- * There is a problem on the handling of _private for entities
- * (bug 155816): Should we copy the content of the field from
- * the entity (possibly overwriting some value set by the user
- * when a copy is created), should we leave it alone, or should
- * we try to take care of different situations? The problem
- * is exacerbated by the usage of this field by the xmlReader.
- * To fix this bug, we look at _private on the created node
- * and, if it's NULL, we copy in whatever was in the entity.
- * If it's not NULL we leave it alone. This is somewhat of a
- * hack - maybe we should have further tests to determine
- * what to do.
+ * when operating on a reader, the entities definitions
+ * are always owning the entities subtree.
+ if (ctxt->parseMode == XML_PARSE_READER)
+ ent->owner = 1;
*/
- if ((ctxt->node != NULL) && (ent->children != NULL)) {
- /*
- * Seems we are generating the DOM content, do
- * a simple tree copy for all references except the first
- * In the first occurrence list contains the replacement.
- * progressive == 2 means we are operating on the Reader
- * and since nodes are discarded we must copy all the time.
- */
- if (((list == NULL) && (ent->owner == 0)) ||
- (ctxt->parseMode == XML_PARSE_READER)) {
- xmlNodePtr nw = NULL, cur, firstChild = NULL;
+ cur = ent->children;
+ while (cur != NULL) {
+ nw = xmlDocCopyNode(cur, ctxt->myDoc, 1);
+ if (nw != NULL) {
+ if (nw->_private == NULL)
+ nw->_private = cur->_private;
+ if (firstChild == NULL){
+ firstChild = nw;
+ }
+ nw = xmlAddChild(ctxt->node, nw);
+ }
+ if (cur == ent->last) {
/*
- * when operating on a reader, the entities definitions
- * are always owning the entities subtree.
- if (ctxt->parseMode == XML_PARSE_READER)
- ent->owner = 1;
+ * needed to detect some strange empty
+ * node cases in the reader tests
*/
+ if ((ctxt->parseMode == XML_PARSE_READER) &&
+ (nw != NULL) &&
+ (nw->type == XML_ELEMENT_NODE) &&
+ (nw->children == NULL))
+ nw->extra = 1;
- cur = ent->children;
- while (cur != NULL) {
- nw = xmlDocCopyNode(cur, ctxt->myDoc, 1);
- if (nw != NULL) {
- if (nw->_private == NULL)
- nw->_private = cur->_private;
- if (firstChild == NULL){
- firstChild = nw;
- }
- nw = xmlAddChild(ctxt->node, nw);
- }
- if (cur == ent->last) {
- /*
- * needed to detect some strange empty
- * node cases in the reader tests
- */
- if ((ctxt->parseMode == XML_PARSE_READER) &&
- (nw != NULL) &&
- (nw->type == XML_ELEMENT_NODE) &&
- (nw->children == NULL))
- nw->extra = 1;
-
- break;
- }
- cur = cur->next;
- }
+ break;
+ }
+ cur = cur->next;
+ }
#ifdef LIBXML_LEGACY_ENABLED
- if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
- xmlAddEntityReference(ent, firstChild, nw);
+ if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
+ xmlAddEntityReference(ent, firstChild, nw);
#endif /* LIBXML_LEGACY_ENABLED */
- } else if (list == NULL) {
- xmlNodePtr nw = NULL, cur, next, last,
- firstChild = NULL;
- /*
- * Copy the entity child list and make it the new
- * entity child list. The goal is to make sure any
- * ID or REF referenced will be the one from the
- * document content and not the entity copy.
- */
- cur = ent->children;
- ent->children = NULL;
- last = ent->last;
- ent->last = NULL;
- while (cur != NULL) {
- next = cur->next;
- cur->next = NULL;
- cur->parent = NULL;
- nw = xmlDocCopyNode(cur, ctxt->myDoc, 1);
- if (nw != NULL) {
- if (nw->_private == NULL)
- nw->_private = cur->_private;
- if (firstChild == NULL){
- firstChild = cur;
- }
- xmlAddChild((xmlNodePtr) ent, nw);
- xmlAddChild(ctxt->node, cur);
- }
- if (cur == last)
- break;
- cur = next;
+ } else if ((list == NULL) || (ctxt->inputNr > 0)) {
+ xmlNodePtr nw = NULL, cur, next, last,
+ firstChild = NULL;
+
+ /*
+ * We are copying here, make sure there is no abuse
+ */
+ ctxt->sizeentcopy += ent->length + 5;
+ if (xmlParserEntityCheck(ctxt, 0, ent, ctxt->sizeentcopy))
+ return;
+
+ /*
+ * Copy the entity child list and make it the new
+ * entity child list. The goal is to make sure any
+ * ID or REF referenced will be the one from the
+ * document content and not the entity copy.
+ */
+ cur = ent->children;
+ ent->children = NULL;
+ last = ent->last;
+ ent->last = NULL;
+ while (cur != NULL) {
+ next = cur->next;
+ cur->next = NULL;
+ cur->parent = NULL;
+ nw = xmlDocCopyNode(cur, ctxt->myDoc, 1);
+ if (nw != NULL) {
+ if (nw->_private == NULL)
+ nw->_private = cur->_private;
+ if (firstChild == NULL){
+ firstChild = cur;
}
- ent->owner = 1;
+ xmlAddChild((xmlNodePtr) ent, nw);
+ xmlAddChild(ctxt->node, cur);
+ }
+ if (cur == last)
+ break;
+ cur = next;
+ }
+ if (ent->owner == 0)
+ ent->owner = 1;
#ifdef LIBXML_LEGACY_ENABLED
- if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
- xmlAddEntityReference(ent, firstChild, nw);
+ if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)
+ xmlAddEntityReference(ent, firstChild, nw);
#endif /* LIBXML_LEGACY_ENABLED */
- } else {
- const xmlChar *nbktext;
-
- /*
- * the name change is to avoid coalescing of the
- * node with a possible previous text one which
- * would make ent->children a dangling pointer
- */
- nbktext = xmlDictLookup(ctxt->dict, BAD_CAST "nbktext",
- -1);
- if (ent->children->type == XML_TEXT_NODE)
- ent->children->name = nbktext;
- if ((ent->last != ent->children) &&
- (ent->last->type == XML_TEXT_NODE))
- ent->last->name = nbktext;
- xmlAddChildList(ctxt->node, ent->children);
- }
+ } else {
+ const xmlChar *nbktext;
- /*
- * This is to avoid a nasty side effect, see
- * characters() in SAX.c
- */
- ctxt->nodemem = 0;
- ctxt->nodelen = 0;
- return;
- }
+ /*
+ * the name change is to avoid coalescing of the
+ * node with a possible previous text one which
+ * would make ent->children a dangling pointer
+ */
+ nbktext = xmlDictLookup(ctxt->dict, BAD_CAST "nbktext",
+ -1);
+ if (ent->children->type == XML_TEXT_NODE)
+ ent->children->name = nbktext;
+ if ((ent->last != ent->children) &&
+ (ent->last->type == XML_TEXT_NODE))
+ ent->last->name = nbktext;
+ xmlAddChildList(ctxt->node, ent->children);
}
- } else {
- val = ent->content;
- if (val == NULL) return;
+
/*
- * inline the entity.
+ * This is to avoid a nasty side effect, see
+ * characters() in SAX.c
*/
- if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL) &&
- (!ctxt->disableSAX))
- ctxt->sax->characters(ctxt->userData, val, xmlStrlen(val));
+ ctxt->nodemem = 0;
+ ctxt->nodelen = 0;
+ return;
}
}
}
@@ -6337,132 +7641,153 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
xmlEntityPtr ent = NULL;
GROW;
-
- if (RAW == '&') {
- NEXT;
- name = xmlParseName(ctxt);
- if (name == NULL) {
- xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
- "xmlParseEntityRef: no name\n");
- } else {
- if (RAW == ';') {
- NEXT;
- /*
- * Ask first SAX for entity resolution, otherwise try the
- * predefined set.
- */
- if (ctxt->sax != NULL) {
- if (ctxt->sax->getEntity != NULL)
- ent = ctxt->sax->getEntity(ctxt->userData, name);
- if ((ctxt->wellFormed == 1 ) && (ent == NULL))
- ent = xmlGetPredefinedEntity(name);
- if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
- (ctxt->userData==ctxt)) {
- 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->standalone == 1) ||
- ((ctxt->hasExternalSubset == 0) &&
- (ctxt->hasPErefs == 0))) {
- xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
- "Entity '%s' not defined\n", name);
- } else {
- xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY,
- "Entity '%s' not defined\n", name);
- if ((ctxt->inSubset == 0) &&
- (ctxt->sax != NULL) &&
- (ctxt->sax->reference != NULL)) {
- ctxt->sax->reference(ctxt->userData, name);
- }
- }
- ctxt->valid = 0;
- }
-
- /*
- * [ WFC: Parsed Entity ]
- * An entity reference must not contain the name of an
- * unparsed entity
- */
- else if (ent->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
- xmlFatalErrMsgStr(ctxt, XML_ERR_UNPARSED_ENTITY,
- "Entity reference to unparsed entity %s\n", name);
- }
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
- /*
- * [ WFC: No External Entity References ]
- * Attribute values cannot contain direct or indirect
- * entity references to external entities.
- */
- else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
- (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
- xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_EXTERNAL,
- "Attribute references external entity '%s'\n", name);
- }
- /*
- * [ WFC: No < in Attribute Values ]
- * The replacement text of any entity referred to directly or
- * indirectly in an attribute value (other than "&lt;") must
- * not contain a <.
- */
- else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
- (ent != NULL) &&
- (!xmlStrEqual(ent->name, BAD_CAST "lt")) &&
- (ent->content != NULL) &&
- (xmlStrchr(ent->content, '<'))) {
- xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
- "'<' in entity '%s' is not allowed in attributes values\n", name);
- }
+ if (RAW != '&')
+ return(NULL);
+ NEXT;
+ name = xmlParseName(ctxt);
+ if (name == NULL) {
+ xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
+ "xmlParseEntityRef: no name\n");
+ return(NULL);
+ }
+ if (RAW != ';') {
+ xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);
+ return(NULL);
+ }
+ NEXT;
- /*
- * Internal check, no parameter entities here ...
- */
- else {
- switch (ent->etype) {
- case XML_INTERNAL_PARAMETER_ENTITY:
- case XML_EXTERNAL_PARAMETER_ENTITY:
- xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_PARAMETER,
- "Attempt to reference the parameter entity '%s'\n",
- name);
- break;
- default:
- break;
- }
- }
+ /*
+ * Predefined entities override any extra definition
+ */
+ if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
+ ent = xmlGetPredefinedEntity(name);
+ if (ent != NULL)
+ return(ent);
+ }
- /*
- * [ WFC: No Recursion ]
- * A parsed entity must not contain a recursive reference
- * to itself, either directly or indirectly.
- * Done somewhere else
- */
+ /*
+ * Increase the number of entity references parsed
+ */
+ ctxt->nbentities++;
- } else {
- xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);
+ /*
+ * Ask first SAX for entity resolution, otherwise try the
+ * entities which may have stored in the parser context.
+ */
+ if (ctxt->sax != NULL) {
+ if (ctxt->sax->getEntity != NULL)
+ ent = ctxt->sax->getEntity(ctxt->userData, name);
+ if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
+ (ctxt->options & XML_PARSE_OLDSAX))
+ ent = xmlGetPredefinedEntity(name);
+ if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
+ (ctxt->userData==ctxt)) {
+ ent = xmlSAX2GetEntity(ctxt, name);
+ }
+ }
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(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
+ * 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->standalone == 1) ||
+ ((ctxt->hasExternalSubset == 0) &&
+ (ctxt->hasPErefs == 0))) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
+ "Entity '%s' not defined\n", name);
+ } else {
+ xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY,
+ "Entity '%s' not defined\n", name);
+ if ((ctxt->inSubset == 0) &&
+ (ctxt->sax != NULL) &&
+ (ctxt->sax->reference != NULL)) {
+ ctxt->sax->reference(ctxt->userData, name);
}
}
+ xmlParserEntityCheck(ctxt, 0, ent, 0);
+ ctxt->valid = 0;
+ }
+
+ /*
+ * [ WFC: Parsed Entity ]
+ * An entity reference must not contain the name of an
+ * unparsed entity
+ */
+ else if (ent->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_UNPARSED_ENTITY,
+ "Entity reference to unparsed entity %s\n", name);
}
+
+ /*
+ * [ WFC: No External Entity References ]
+ * Attribute values cannot contain direct or indirect
+ * entity references to external entities.
+ */
+ else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
+ (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_EXTERNAL,
+ "Attribute references external entity '%s'\n", name);
+ }
+ /*
+ * [ WFC: No < in Attribute Values ]
+ * The replacement text of any entity referred to directly or
+ * indirectly in an attribute value (other than "&lt;") must
+ * not contain a <.
+ */
+ else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
+ (ent != NULL) &&
+ (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY)) {
+ if (((ent->checked & 1) || (ent->checked == 0)) &&
+ (ent->content != NULL) && (xmlStrchr(ent->content, '<'))) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
+ "'<' in entity '%s' is not allowed in attributes values\n", name);
+ }
+ }
+
+ /*
+ * Internal check, no parameter entities here ...
+ */
+ else {
+ switch (ent->etype) {
+ case XML_INTERNAL_PARAMETER_ENTITY:
+ case XML_EXTERNAL_PARAMETER_ENTITY:
+ xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_PARAMETER,
+ "Attempt to reference the parameter entity '%s'\n",
+ name);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /*
+ * [ WFC: No Recursion ]
+ * A parsed entity must not contain a recursive reference
+ * to itself, either directly or indirectly.
+ * Done somewhere else
+ */
return(ent);
}
@@ -6497,7 +7822,7 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
* Returns the xmlEntityPtr if found, or NULL otherwise. The str pointer
* is updated to the current location in the string.
*/
-xmlEntityPtr
+static xmlEntityPtr
xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
xmlChar *name;
const xmlChar *ptr;
@@ -6508,129 +7833,156 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
return(NULL);
ptr = *str;
cur = *ptr;
- if (cur == '&') {
- ptr++;
- cur = *ptr;
- name = xmlParseStringName(ctxt, &ptr);
- if (name == NULL) {
- xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
- "xmlParseStringEntityRef: no name\n");
- } else {
- if (*ptr == ';') {
- ptr++;
- /*
- * Ask first SAX for entity resolution, otherwise try the
- * predefined set.
- */
- if (ctxt->sax != NULL) {
- if (ctxt->sax->getEntity != NULL)
- ent = ctxt->sax->getEntity(ctxt->userData, name);
- if (ent == NULL)
- ent = xmlGetPredefinedEntity(name);
- if ((ent == NULL) && (ctxt->userData==ctxt)) {
- 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->standalone == 1) ||
- ((ctxt->hasExternalSubset == 0) &&
- (ctxt->hasPErefs == 0))) {
- xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
- "Entity '%s' not defined\n", name);
- } else {
- xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY,
- "Entity '%s' not defined\n",
- name);
- }
- /* TODO ? check regressions ctxt->valid = 0; */
- }
+ if (cur != '&')
+ return(NULL);
- /*
- * [ WFC: Parsed Entity ]
- * An entity reference must not contain the name of an
- * unparsed entity
- */
- else if (ent->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
- xmlFatalErrMsgStr(ctxt, XML_ERR_UNPARSED_ENTITY,
- "Entity reference to unparsed entity %s\n", name);
- }
+ ptr++;
+ name = xmlParseStringName(ctxt, &ptr);
+ if (name == NULL) {
+ xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
+ "xmlParseStringEntityRef: no name\n");
+ *str = ptr;
+ return(NULL);
+ }
+ if (*ptr != ';') {
+ xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);
+ xmlFree(name);
+ *str = ptr;
+ return(NULL);
+ }
+ ptr++;
- /*
- * [ WFC: No External Entity References ]
- * Attribute values cannot contain direct or indirect
- * entity references to external entities.
- */
- else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
- (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
- xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_EXTERNAL,
- "Attribute references external entity '%s'\n", name);
- }
- /*
- * [ WFC: No < in Attribute Values ]
- * The replacement text of any entity referred to directly or
- * indirectly in an attribute value (other than "&lt;") must
- * not contain a <.
- */
- else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
- (ent != NULL) &&
- (!xmlStrEqual(ent->name, BAD_CAST "lt")) &&
- (ent->content != NULL) &&
- (xmlStrchr(ent->content, '<'))) {
- xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
- "'<' in entity '%s' is not allowed in attributes values\n",
- name);
- }
- /*
- * Internal check, no parameter entities here ...
- */
- else {
- switch (ent->etype) {
- case XML_INTERNAL_PARAMETER_ENTITY:
- case XML_EXTERNAL_PARAMETER_ENTITY:
- xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_PARAMETER,
- "Attempt to reference the parameter entity '%s'\n",
- name);
- break;
- default:
- break;
- }
- }
+ /*
+ * Predefined entities override any extra definition
+ */
+ if ((ctxt->options & XML_PARSE_OLDSAX) == 0) {
+ ent = xmlGetPredefinedEntity(name);
+ if (ent != NULL) {
+ xmlFree(name);
+ *str = ptr;
+ return(ent);
+ }
+ }
- /*
- * [ WFC: No Recursion ]
- * A parsed entity must not contain a recursive reference
- * to itself, either directly or indirectly.
- * Done somewhere else
- */
+ /*
+ * Increate the number of entity references parsed
+ */
+ ctxt->nbentities++;
- } else {
- xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);
- }
- xmlFree(name);
+ /*
+ * Ask first SAX for entity resolution, otherwise try the
+ * entities which may have stored in the parser context.
+ */
+ if (ctxt->sax != NULL) {
+ if (ctxt->sax->getEntity != NULL)
+ ent = ctxt->sax->getEntity(ctxt->userData, name);
+ if ((ent == NULL) && (ctxt->options & XML_PARSE_OLDSAX))
+ ent = xmlGetPredefinedEntity(name);
+ if ((ent == NULL) && (ctxt->userData==ctxt)) {
+ ent = xmlSAX2GetEntity(ctxt, name);
+ }
+ }
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(name);
+ return(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
+ * 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->standalone == 1) ||
+ ((ctxt->hasExternalSubset == 0) &&
+ (ctxt->hasPErefs == 0))) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
+ "Entity '%s' not defined\n", name);
+ } else {
+ xmlErrMsgStr(ctxt, XML_WAR_UNDECLARED_ENTITY,
+ "Entity '%s' not defined\n",
+ name);
+ }
+ xmlParserEntityCheck(ctxt, 0, ent, 0);
+ /* TODO ? check regressions ctxt->valid = 0; */
+ }
+
+ /*
+ * [ WFC: Parsed Entity ]
+ * An entity reference must not contain the name of an
+ * unparsed entity
+ */
+ else if (ent->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_UNPARSED_ENTITY,
+ "Entity reference to unparsed entity %s\n", name);
+ }
+
+ /*
+ * [ WFC: No External Entity References ]
+ * Attribute values cannot contain direct or indirect
+ * entity references to external entities.
+ */
+ else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
+ (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_EXTERNAL,
+ "Attribute references external entity '%s'\n", name);
+ }
+ /*
+ * [ WFC: No < in Attribute Values ]
+ * The replacement text of any entity referred to directly or
+ * indirectly in an attribute value (other than "&lt;") must
+ * not contain a <.
+ */
+ else if ((ctxt->instate == XML_PARSER_ATTRIBUTE_VALUE) &&
+ (ent != NULL) && (ent->content != NULL) &&
+ (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
+ (xmlStrchr(ent->content, '<'))) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_LT_IN_ATTRIBUTE,
+ "'<' in entity '%s' is not allowed in attributes values\n",
+ name);
+ }
+
+ /*
+ * Internal check, no parameter entities here ...
+ */
+ else {
+ switch (ent->etype) {
+ case XML_INTERNAL_PARAMETER_ENTITY:
+ case XML_EXTERNAL_PARAMETER_ENTITY:
+ xmlFatalErrMsgStr(ctxt, XML_ERR_ENTITY_IS_PARAMETER,
+ "Attempt to reference the parameter entity '%s'\n",
+ name);
+ break;
+ default:
+ break;
}
}
+
+ /*
+ * [ WFC: No Recursion ]
+ * A parsed entity must not contain a recursive reference
+ * to itself, either directly or indirectly.
+ * Done somewhere else
+ */
+
+ xmlFree(name);
*str = ptr;
return(ent);
}
@@ -6647,7 +7999,7 @@ xmlParseStringEntityRef(xmlParserCtxtPtr ctxt, const xmlChar ** str) {
*
* [ WFC: No Recursion ]
* A parsed entity must not contain a recursive
- * reference to itself, either directly or indirectly.
+ * reference to itself, either directly or indirectly.
*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an internal DTD
@@ -6671,90 +8023,200 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
xmlEntityPtr entity = NULL;
xmlParserInputPtr input;
- if (RAW == '%') {
- NEXT;
- name = xmlParseName(ctxt);
- if (name == NULL) {
- xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
- "xmlParsePEReference: no name\n");
- } else {
- if (RAW == ';') {
- NEXT;
- if ((ctxt->sax != NULL) &&
- (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))) {
- 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...
- */
- xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
- "PEReference: %%%s; not found\n",
- name, NULL);
- ctxt->valid = 0;
- }
- } else {
- /*
- * Internal checking in case the entity quest barfed
- */
- if ((entity->etype != XML_INTERNAL_PARAMETER_ENTITY) &&
- (entity->etype != XML_EXTERNAL_PARAMETER_ENTITY)) {
- xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
- "Internal: %%%s; is not a parameter entity\n",
- name, NULL);
- } else if (ctxt->input->free != deallocblankswrapper) {
- input =
- xmlNewBlanksWrapperInputStream(ctxt, entity);
- xmlPushInput(ctxt, input);
- } else {
- /*
- * TODO !!!
- * handle the extra spaces added before and after
- * c.f. http://www.w3.org/TR/REC-xml#as-PE
- */
- input = xmlNewEntityInputStream(ctxt, entity);
- xmlPushInput(ctxt, input);
- if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
- (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) &&
- (IS_BLANK_CH(NXT(5)))) {
- xmlParseTextDecl(ctxt);
- if (ctxt->errNo ==
- XML_ERR_UNSUPPORTED_ENCODING) {
- /*
- * The XML REC instructs us to stop parsing
- * right here
- */
- ctxt->instate = XML_PARSER_EOF;
- return;
- }
- }
- }
- }
- ctxt->hasPErefs = 1;
- } else {
- xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);
+ if (RAW != '%')
+ return;
+ NEXT;
+ name = xmlParseName(ctxt);
+ if (name == NULL) {
+ xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
+ "xmlParsePEReference: no name\n");
+ return;
+ }
+ if (RAW != ';') {
+ xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);
+ return;
+ }
+
+ NEXT;
+
+ /*
+ * Increate the number of entity references parsed
+ */
+ ctxt->nbentities++;
+
+ /*
+ * Request the entity from SAX
+ */
+ if ((ctxt->sax != NULL) &&
+ (ctxt->sax->getParameterEntity != NULL))
+ entity = ctxt->sax->getParameterEntity(ctxt->userData, name);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
+ 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))) {
+ 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...
+ */
+ xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
+ "PEReference: %%%s; not found\n",
+ name, NULL);
+ ctxt->valid = 0;
+ }
+ xmlParserEntityCheck(ctxt, 0, NULL, 0);
+ } else {
+ /*
+ * Internal checking in case the entity quest barfed
+ */
+ if ((entity->etype != XML_INTERNAL_PARAMETER_ENTITY) &&
+ (entity->etype != XML_EXTERNAL_PARAMETER_ENTITY)) {
+ xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
+ "Internal: %%%s; is not a parameter entity\n",
+ name, NULL);
+ } else if (ctxt->input->free != deallocblankswrapper) {
+ input = xmlNewBlanksWrapperInputStream(ctxt, entity);
+ if (xmlPushInput(ctxt, input) < 0)
+ return;
+ } else {
+ /*
+ * TODO !!!
+ * handle the extra spaces added before and after
+ * c.f. http://www.w3.org/TR/REC-xml#as-PE
+ */
+ input = xmlNewEntityInputStream(ctxt, entity);
+ if (xmlPushInput(ctxt, input) < 0)
+ return;
+ if ((entity->etype == XML_EXTERNAL_PARAMETER_ENTITY) &&
+ (CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) &&
+ (IS_BLANK_CH(NXT(5)))) {
+ xmlParseTextDecl(ctxt);
+ if (ctxt->errNo ==
+ XML_ERR_UNSUPPORTED_ENCODING) {
+ /*
+ * The XML REC instructs us to stop parsing
+ * right here
+ */
+ xmlHaltParser(ctxt);
+ return;
+ }
+ }
+ }
+ }
+ ctxt->hasPErefs = 1;
+}
+
+/**
+ * xmlLoadEntityContent:
+ * @ctxt: an XML parser context
+ * @entity: an unloaded system entity
+ *
+ * Load the original content of the given system entity from the
+ * ExternalID/SystemID given. This is to be used for Included in Literal
+ * http://www.w3.org/TR/REC-xml/#inliteral processing of entities references
+ *
+ * Returns 0 in case of success and -1 in case of failure
+ */
+static int
+xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
+ xmlParserInputPtr input;
+ xmlBufferPtr buf;
+ int l, c;
+ int count = 0;
+
+ if ((ctxt == NULL) || (entity == NULL) ||
+ ((entity->etype != XML_EXTERNAL_PARAMETER_ENTITY) &&
+ (entity->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY)) ||
+ (entity->content != NULL)) {
+ xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
+ "xmlLoadEntityContent parameter error");
+ return(-1);
+ }
+
+ if (xmlParserDebugEntities)
+ xmlGenericError(xmlGenericErrorContext,
+ "Reading %s entity content input\n", entity->name);
+
+ buf = xmlBufferCreate();
+ if (buf == NULL) {
+ xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
+ "xmlLoadEntityContent parameter error");
+ return(-1);
+ }
+
+ input = xmlNewEntityInputStream(ctxt, entity);
+ if (input == NULL) {
+ xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
+ "xmlLoadEntityContent input error");
+ xmlBufferFree(buf);
+ return(-1);
+ }
+
+ /*
+ * Push the entity as the current input, read char by char
+ * saving to the buffer until the end of the entity or an error
+ */
+ if (xmlPushInput(ctxt, input) < 0) {
+ xmlBufferFree(buf);
+ return(-1);
+ }
+
+ GROW;
+ c = CUR_CHAR(l);
+ while ((ctxt->input == input) && (ctxt->input->cur < ctxt->input->end) &&
+ (IS_CHAR(c))) {
+ xmlBufferAdd(buf, ctxt->input->cur, l);
+ if (count++ > XML_PARSER_CHUNK_SIZE) {
+ count = 0;
+ GROW;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlBufferFree(buf);
+ return(-1);
}
- }
+ }
+ NEXTL(l);
+ c = CUR_CHAR(l);
+ if (c == 0) {
+ count = 0;
+ GROW;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlBufferFree(buf);
+ return(-1);
+ }
+ c = CUR_CHAR(l);
+ }
}
+
+ if ((ctxt->input == input) && (ctxt->input->cur >= ctxt->input->end)) {
+ xmlPopInput(ctxt);
+ } else if (!IS_CHAR(c)) {
+ xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
+ "xmlLoadEntityContent: invalid char value %d\n",
+ c);
+ xmlBufferFree(buf);
+ return(-1);
+ }
+ entity->content = buf->content;
+ buf->content = NULL;
+ xmlBufferFree(buf);
+
+ return(0);
}
/**
@@ -6768,7 +8230,7 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
*
* [ WFC: No Recursion ]
* A parsed entity must not contain a recursive
- * reference to itself, either directly or indirectly.
+ * reference to itself, either directly or indirectly.
*
* [ WFC: Entity Declared ]
* In a document without any DTD, a document with only an internal DTD
@@ -6788,7 +8250,7 @@ xmlParsePEReference(xmlParserCtxtPtr ctxt)
* Returns the string of the entity content.
* str is updated to the current value of the index
*/
-xmlEntityPtr
+static xmlEntityPtr
xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) {
const xmlChar *ptr;
xmlChar cur;
@@ -6798,67 +8260,80 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) {
if ((str == NULL) || (*str == NULL)) return(NULL);
ptr = *str;
cur = *ptr;
- if (cur == '%') {
- ptr++;
- cur = *ptr;
- name = xmlParseStringName(ctxt, &ptr);
- if (name == NULL) {
- xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
- "xmlParseStringPEReference: no name\n");
+ if (cur != '%')
+ return(NULL);
+ ptr++;
+ name = xmlParseStringName(ctxt, &ptr);
+ if (name == NULL) {
+ xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
+ "xmlParseStringPEReference: no name\n");
+ *str = ptr;
+ return(NULL);
+ }
+ cur = *ptr;
+ if (cur != ';') {
+ xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);
+ xmlFree(name);
+ *str = ptr;
+ return(NULL);
+ }
+ ptr++;
+
+ /*
+ * Increate the number of entity references parsed
+ */
+ ctxt->nbentities++;
+
+ /*
+ * Request the entity from SAX
+ */
+ if ((ctxt->sax != NULL) &&
+ (ctxt->sax->getParameterEntity != NULL))
+ entity = ctxt->sax->getParameterEntity(ctxt->userData, name);
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(name);
+ return(NULL);
+ }
+ 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))) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY,
+ "PEReference: %%%s; not found\n", name);
} else {
- cur = *ptr;
- if (cur == ';') {
- ptr++;
- cur = *ptr;
- if ((ctxt->sax != NULL) &&
- (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))) {
- 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...
- */
- xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
- "PEReference: %%%s; not found\n",
- name, NULL);
- ctxt->valid = 0;
- }
- } else {
- /*
- * Internal checking in case the entity quest barfed
- */
- if ((entity->etype != XML_INTERNAL_PARAMETER_ENTITY) &&
- (entity->etype != XML_EXTERNAL_PARAMETER_ENTITY)) {
- xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
- "%%%s; is not a parameter entity\n",
- name, NULL);
- }
- }
- ctxt->hasPErefs = 1;
- } else {
- xmlFatalErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, NULL);
- }
- xmlFree(name);
+ /*
+ * [ 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...
+ */
+ xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
+ "PEReference: %%%s; not found\n",
+ name, NULL);
+ ctxt->valid = 0;
+ }
+ xmlParserEntityCheck(ctxt, 0, NULL, 0);
+ } else {
+ /*
+ * Internal checking in case the entity quest barfed
+ */
+ if ((entity->etype != XML_INTERNAL_PARAMETER_ENTITY) &&
+ (entity->etype != XML_EXTERNAL_PARAMETER_ENTITY)) {
+ xmlWarningMsg(ctxt, XML_WAR_UNDECLARED_ENTITY,
+ "%%%s; is not a parameter entity\n",
+ name, NULL);
}
}
+ ctxt->hasPErefs = 1;
+ xmlFree(name);
*str = ptr;
return(entity);
}
@@ -6869,12 +8344,12 @@ xmlParseStringPEReference(xmlParserCtxtPtr ctxt, const xmlChar **str) {
*
* parse a DOCTYPE declaration
*
- * [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S?
+ * [28] doctypedecl ::= '<!DOCTYPE' S Name (S ExternalID)? S?
* ('[' (markupdecl | PEReference | S)* ']' S?)? '>'
*
* [ VC: Root Element Type ]
* The Name in the document type declaration must match the element
- * type of the root element.
+ * type of the root element.
*/
void
@@ -6921,6 +8396,8 @@ xmlParseDocTypeDecl(xmlParserCtxtPtr ctxt) {
if ((ctxt->sax != NULL) && (ctxt->sax->internalSubset != NULL) &&
(!ctxt->disableSAX))
ctxt->sax->internalSubset(ctxt->userData, name, ExternalID, URI);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
/*
* Is there any internal subset declarations ?
@@ -6956,11 +8433,11 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
ctxt->instate = XML_PARSER_DTD;
NEXT;
/*
- * Parse the succession of Markup declarations and
+ * Parse the succession of Markup declarations and
* PEReferences.
* Subsequence (markupdecl | PEReference | S)*
*/
- while (RAW != ']') {
+ while ((RAW != ']') && (ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *check = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
@@ -6980,7 +8457,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
break;
}
}
- if (RAW == ']') {
+ if (RAW == ']') {
NEXT;
SKIP_BLANKS;
}
@@ -7011,8 +8488,8 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
*
* [ WFC: No < in Attribute Values ]
* The replacement text of any entity referred to directly or indirectly in
- * an attribute value (other than "&lt;") must not contain a <.
- *
+ * an attribute value (other than "&lt;") must not contain a <.
+ *
* [ VC: Attribute Value Type ]
* The attribute must have been declared; the value must be of the type
* declared for it.
@@ -7093,7 +8570,7 @@ xmlParseAttribute(xmlParserCtxtPtr ctxt, xmlChar **value) {
/**
* xmlParseStartTag:
* @ctxt: an XML parser context
- *
+ *
* parse a start of tag either for rule element or
* EmptyElement. In both case we don't parse the tag closing chars.
*
@@ -7101,13 +8578,13 @@ xmlParseAttribute(xmlParserCtxtPtr ctxt, xmlChar **value) {
*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same start-tag or
- * empty-element tag.
+ * empty-element tag.
*
* [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same start-tag or
- * empty-element tag.
+ * empty-element tag.
*
* With namespace:
*
@@ -7146,9 +8623,9 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
SKIP_BLANKS;
GROW;
- while ((RAW != '>') &&
+ while (((RAW != '>') &&
((RAW != '/') || (NXT(1) != '>')) &&
- (IS_BYTE_CHAR(RAW))) {
+ (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *q = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
@@ -7157,7 +8634,7 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
/*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same
- * start-tag or empty-element tag.
+ * start-tag or empty-element tag.
*/
for (i = 0; i < nbatts;i += 2) {
if (xmlStrEqual(atts[i], attname)) {
@@ -7206,7 +8683,7 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
xmlFree(attvalue);
}
-failed:
+failed:
GROW
if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
@@ -7288,7 +8765,7 @@ xmlParseEndTag1(xmlParserCtxtPtr ctxt, int line) {
/*
* [ WFC: Element Type Match ]
* The Name in an element's end-tag must match the element type in the
- * start-tag.
+ * start-tag.
*
*/
if (name != (xmlChar*)1) {
@@ -7335,38 +8812,6 @@ xmlParseEndTag(xmlParserCtxtPtr ctxt) {
* *
************************************************************************/
-static const xmlChar *
-xmlParseNCNameComplex(xmlParserCtxtPtr ctxt) {
- int len = 0, l;
- int c;
- int count = 0;
-
- /*
- * Handler for more complex cases
- */
- GROW;
- c = CUR_CHAR(l);
- if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
- (!IS_LETTER(c) && (c != '_'))) {
- return(NULL);
- }
-
- while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
- ((IS_LETTER(c)) || (IS_DIGIT(c)) ||
- (c == '.') || (c == '-') || (c == '_') ||
- (IS_COMBINING(c)) ||
- (IS_EXTENDER(c)))) {
- if (count++ > 100) {
- count = 0;
- GROW;
- }
- len += l;
- NEXTL(l);
- c = CUR_CHAR(l);
- }
- return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len));
-}
-
/*
* xmlGetNamespace:
* @ctxt: an XML parser context
@@ -7392,56 +8837,6 @@ xmlGetNamespace(xmlParserCtxtPtr ctxt, const xmlChar *prefix) {
}
/**
- * xmlParseNCName:
- * @ctxt: an XML parser context
- * @len: lenght of the string parsed
- *
- * parse an XML name.
- *
- * [4NS] NCNameChar ::= Letter | Digit | '.' | '-' | '_' |
- * CombiningChar | Extender
- *
- * [5NS] NCName ::= (Letter | '_') (NCNameChar)*
- *
- * Returns the Name parsed or NULL
- */
-
-static const xmlChar *
-xmlParseNCName(xmlParserCtxtPtr ctxt) {
- const xmlChar *in;
- const xmlChar *ret;
- int count = 0;
-
- /*
- * Accelerator for simple ASCII names
- */
- in = ctxt->input->cur;
- if (((*in >= 0x61) && (*in <= 0x7A)) ||
- ((*in >= 0x41) && (*in <= 0x5A)) ||
- (*in == '_')) {
- in++;
- while (((*in >= 0x61) && (*in <= 0x7A)) ||
- ((*in >= 0x41) && (*in <= 0x5A)) ||
- ((*in >= 0x30) && (*in <= 0x39)) ||
- (*in == '_') || (*in == '-') ||
- (*in == '.'))
- in++;
- if ((*in > 0) && (*in < 0x80)) {
- count = in - ctxt->input->cur;
- ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count);
- ctxt->input->cur = in;
- ctxt->nbChars += count;
- ctxt->input->col += count;
- if (ret == NULL) {
- xmlErrMemory(ctxt, NULL);
- }
- return(ret);
- }
- }
- return(xmlParseNCNameComplex(ctxt));
-}
-
-/**
* xmlParseQName:
* @ctxt: an XML parser context
* @prefix: pointer to store the prefix part
@@ -7466,7 +8861,7 @@ xmlParseQName(xmlParserCtxtPtr ctxt, const xmlChar **prefix) {
if (CUR == ':') {
l = xmlParseName(ctxt);
if (l != NULL) {
- xmlNsErr(ctxt, XML_NS_ERR_QNAME,
+ xmlNsErr(ctxt, XML_NS_ERR_QNAME,
"Failed to parse QName '%s'\n", l, NULL, NULL);
*prefix = NULL;
return(l);
@@ -7483,7 +8878,13 @@ xmlParseQName(xmlParserCtxtPtr ctxt, const xmlChar **prefix) {
xmlNsErr(ctxt, XML_NS_ERR_QNAME,
"Failed to parse QName '%s:'\n", p, NULL, NULL);
- tmp = xmlBuildQName(BAD_CAST "", p, NULL, 0);
+ l = xmlParseNmtoken(ctxt);
+ if (l == NULL)
+ tmp = xmlBuildQName(BAD_CAST "", p, NULL, 0);
+ else {
+ tmp = xmlBuildQName(l, p, NULL, 0);
+ xmlFree((char *)l);
+ }
p = xmlDictLookup(ctxt->dict, tmp, -1);
if (tmp != NULL) xmlFree(tmp);
*prefix = NULL;
@@ -7531,7 +8932,7 @@ xmlParseQName(xmlParserCtxtPtr ctxt, const xmlChar **prefix) {
static const xmlChar *
xmlParseQNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *name,
xmlChar const *prefix) {
- const xmlChar *cmp = name;
+ const xmlChar *cmp;
const xmlChar *in;
const xmlChar *ret;
const xmlChar *prefix2;
@@ -7540,10 +8941,10 @@ xmlParseQNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *name,
GROW;
in = ctxt->input->cur;
-
+
cmp = prefix;
while (*in != 0 && *in == *cmp) {
- ++in;
+ ++in;
++cmp;
}
if ((*cmp == 0) && (*in == ':')) {
@@ -7581,20 +8982,20 @@ xmlParseQNameAndCompare(xmlParserCtxtPtr ctxt, xmlChar const *name,
*
* 3.3.3 Attribute-Value Normalization:
* Before the value of an attribute is passed to the application or
- * checked for validity, the XML processor must normalize it as follows:
+ * checked for validity, the XML processor must normalize it as follows:
* - a character reference is processed by appending the referenced
* character to the attribute value
* - an entity reference is processed by recursively processing the
- * replacement text of the entity
+ * replacement text of the entity
* - a whitespace character (#x20, #xD, #xA, #x9) is processed by
* appending #x20 to the normalized value, except that only a single
* #x20 is appended for a "#xD#xA" sequence that is part of an external
- * parsed entity or the literal entity value of an internal parsed entity
- * - other characters are processed by appending them to the normalized value
+ * parsed entity or the literal entity value of an internal parsed entity
+ * - other characters are processed by appending them to the normalized value
* 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 a single space (#x20) character.
+ * (#x20) characters by a single space (#x20) character.
* All attributes for which no declaration has been read should be treated
* by a non-validating parser as if declared CDATA.
*
@@ -7609,9 +9010,12 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
xmlChar limit = 0;
const xmlChar *in = NULL, *start, *end, *last;
xmlChar *ret = NULL;
+ int line, col;
GROW;
in = (xmlChar *) CUR_PTR;
+ line = ctxt->input->line;
+ col = ctxt->input->col;
if (*in != '"' && *in != '\'') {
xmlFatalErr(ctxt, XML_ERR_ATTRIBUTE_NOT_STARTED, NULL);
return (NULL);
@@ -7624,6 +9028,7 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
* pure ASCII.
*/
limit = *in++;
+ col++;
end = ctxt->input->end;
start = in;
if (in >= end) {
@@ -7640,34 +9045,56 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
/*
* Skip any leading spaces
*/
- while ((in < end) && (*in != limit) &&
+ while ((in < end) && (*in != limit) &&
((*in == 0x20) || (*in == 0x9) ||
(*in == 0xA) || (*in == 0xD))) {
+ if (*in == 0xA) {
+ line++; col = 1;
+ } else {
+ col++;
+ }
in++;
start = in;
if (in >= end) {
const xmlChar *oldbase = ctxt->input->base;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
if (oldbase != ctxt->input->base) {
long delta = ctxt->input->base - oldbase;
start = start + delta;
in = in + delta;
}
end = ctxt->input->end;
+ if (((in - start) > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+ "AttValue length too long\n");
+ return(NULL);
+ }
}
}
while ((in < end) && (*in != limit) && (*in >= 0x20) &&
(*in <= 0x7f) && (*in != '&') && (*in != '<')) {
+ col++;
if ((*in++ == 0x20) && (*in == 0x20)) break;
if (in >= end) {
const xmlChar *oldbase = ctxt->input->base;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
if (oldbase != ctxt->input->base) {
long delta = ctxt->input->base - oldbase;
start = start + delta;
in = in + delta;
}
end = ctxt->input->end;
+ if (((in - start) > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+ "AttValue length too long\n");
+ return(NULL);
+ }
}
}
last = in;
@@ -7675,13 +9102,20 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
* skip the trailing blanks
*/
while ((last[-1] == 0x20) && (last > start)) last--;
- while ((in < end) && (*in != limit) &&
+ while ((in < end) && (*in != limit) &&
((*in == 0x20) || (*in == 0x9) ||
(*in == 0xA) || (*in == 0xD))) {
+ if (*in == 0xA) {
+ line++, col = 1;
+ } else {
+ col++;
+ }
in++;
if (in >= end) {
const xmlChar *oldbase = ctxt->input->base;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
if (oldbase != ctxt->input->base) {
long delta = ctxt->input->base - oldbase;
start = start + delta;
@@ -7689,28 +9123,56 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
last = last + delta;
}
end = ctxt->input->end;
+ if (((in - start) > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+ "AttValue length too long\n");
+ return(NULL);
+ }
}
}
+ if (((in - start) > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+ "AttValue length too long\n");
+ return(NULL);
+ }
if (*in != limit) goto need_complex;
} else {
while ((in < end) && (*in != limit) && (*in >= 0x20) &&
(*in <= 0x7f) && (*in != '&') && (*in != '<')) {
in++;
+ col++;
if (in >= end) {
const xmlChar *oldbase = ctxt->input->base;
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(NULL);
if (oldbase != ctxt->input->base) {
long delta = ctxt->input->base - oldbase;
start = start + delta;
in = in + delta;
}
end = ctxt->input->end;
+ if (((in - start) > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+ "AttValue length too long\n");
+ return(NULL);
+ }
}
}
last = in;
+ if (((in - start) > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
+ "AttValue length too long\n");
+ return(NULL);
+ }
if (*in != limit) goto need_complex;
}
in++;
+ col++;
if (len != NULL) {
*len = last - start;
ret = (xmlChar *) start;
@@ -7719,6 +9181,8 @@ xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
ret = xmlStrndup(start, last - start);
}
CUR_PTR = in;
+ ctxt->input->line = line;
+ ctxt->input->col = col;
if (alloc) *alloc = 0;
return ret;
need_complex:
@@ -7743,9 +9207,10 @@ need_complex:
static const xmlChar *
xmlParseAttribute2(xmlParserCtxtPtr ctxt,
- const xmlChar *pref, const xmlChar *elem,
- const xmlChar **prefix, xmlChar **value,
- int *len, int *alloc) {
+ const xmlChar * pref, const xmlChar * elem,
+ const xmlChar ** prefix, xmlChar ** value,
+ int *len, int *alloc)
+{
const xmlChar *name;
xmlChar *val, *internal_val = NULL;
int normalize = 0;
@@ -7754,9 +9219,9 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
GROW;
name = xmlParseQName(ctxt, prefix);
if (name == NULL) {
- xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
- "error parsing attribute name\n");
- return(NULL);
+ xmlFatalErrMsg(ctxt, XML_ERR_NAME_REQUIRED,
+ "error parsing attribute name\n");
+ return (NULL);
}
/*
@@ -7766,8 +9231,9 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
int type;
type = (int) (long) xmlHashQLookup2(ctxt->attsSpecial,
- pref, elem, *prefix, name);
- if (type != 0) normalize = 1;
+ pref, elem, *prefix, name);
+ if (type != 0)
+ normalize = 1;
}
/*
@@ -7776,58 +9242,75 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
SKIP_BLANKS;
if (RAW == '=') {
NEXT;
- SKIP_BLANKS;
- val = xmlParseAttValueInternal(ctxt, len, alloc, normalize);
- ctxt->instate = XML_PARSER_CONTENT;
+ SKIP_BLANKS;
+ val = xmlParseAttValueInternal(ctxt, len, alloc, normalize);
+ if (normalize) {
+ /*
+ * Sometimes a second normalisation pass for spaces is needed
+ * but that only happens if charrefs or entities refernces
+ * have been used in the attribute value, i.e. the attribute
+ * value have been extracted in an allocated string already.
+ */
+ if (*alloc) {
+ const xmlChar *val2;
+
+ val2 = xmlAttrNormalizeSpace2(ctxt, val, len);
+ if ((val2 != NULL) && (val2 != val)) {
+ xmlFree(val);
+ val = (xmlChar *) val2;
+ }
+ }
+ }
+ ctxt->instate = XML_PARSER_CONTENT;
} else {
- xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
- "Specification mandate value for attribute %s\n", name);
- return(NULL);
+ xmlFatalErrMsgStr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE,
+ "Specification mandate value for attribute %s\n",
+ name);
+ return (NULL);
}
- if (*prefix == ctxt->str_xml) {
- /*
- * Check that xml:lang conforms to the specification
- * No more registered as an error, just generate a warning now
- * since this was deprecated in XML second edition
- */
- if ((ctxt->pedantic) && (xmlStrEqual(name, BAD_CAST "lang"))) {
- internal_val = xmlStrndup(val, *len);
- if (!xmlCheckLanguageID(internal_val)) {
- xmlWarningMsg(ctxt, XML_WAR_LANG_VALUE,
- "Malformed value for xml:lang : %s\n",
- internal_val, NULL);
- }
- }
+ if (*prefix == ctxt->str_xml) {
+ /*
+ * Check that xml:lang conforms to the specification
+ * No more registered as an error, just generate a warning now
+ * since this was deprecated in XML second edition
+ */
+ if ((ctxt->pedantic) && (xmlStrEqual(name, BAD_CAST "lang"))) {
+ internal_val = xmlStrndup(val, *len);
+ if (!xmlCheckLanguageID(internal_val)) {
+ xmlWarningMsg(ctxt, XML_WAR_LANG_VALUE,
+ "Malformed value for xml:lang : %s\n",
+ internal_val, NULL);
+ }
+ }
- /*
- * Check that xml:space conforms to the specification
- */
- if (xmlStrEqual(name, BAD_CAST "space")) {
- internal_val = xmlStrndup(val, *len);
- if (xmlStrEqual(internal_val, BAD_CAST "default"))
- *(ctxt->space) = 0;
- else if (xmlStrEqual(internal_val, BAD_CAST "preserve"))
- *(ctxt->space) = 1;
- else {
- xmlWarningMsg(ctxt, XML_WAR_SPACE_VALUE,
-"Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
- internal_val, NULL);
- }
- }
- if (internal_val) {
- xmlFree(internal_val);
- }
- }
+ /*
+ * Check that xml:space conforms to the specification
+ */
+ if (xmlStrEqual(name, BAD_CAST "space")) {
+ internal_val = xmlStrndup(val, *len);
+ if (xmlStrEqual(internal_val, BAD_CAST "default"))
+ *(ctxt->space) = 0;
+ else if (xmlStrEqual(internal_val, BAD_CAST "preserve"))
+ *(ctxt->space) = 1;
+ else {
+ xmlWarningMsg(ctxt, XML_WAR_SPACE_VALUE,
+ "Invalid value \"%s\" for xml:space : \"default\" or \"preserve\" expected\n",
+ internal_val, NULL);
+ }
+ }
+ if (internal_val) {
+ xmlFree(internal_val);
+ }
+ }
*value = val;
- return(name);
+ return (name);
}
-
/**
* xmlParseStartTag2:
* @ctxt: an XML parser context
- *
+ *
* parse a start of tag either for rule element or
* EmptyElement. In both case we don't parse the tag closing chars.
* This routine is called when running SAX2 parsing
@@ -7836,13 +9319,13 @@ xmlParseAttribute2(xmlParserCtxtPtr ctxt,
*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same start-tag or
- * empty-element tag.
+ * empty-element tag.
*
* [44] EmptyElemTag ::= '<' Name (S Attribute)* S? '/>'
*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same start-tag or
- * empty-element tag.
+ * empty-element tag.
*
* With namespace:
*
@@ -7865,7 +9348,7 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
const xmlChar **atts = ctxt->atts;
int maxatts = ctxt->maxatts;
int nratts, nbatts, nbdef;
- int i, j, nbNs, attval, oldline, oldcol;
+ int i, j, nbNs, attval, oldline, oldcol, inputNr;
const xmlChar *base;
unsigned long cur;
int nsNr = ctxt->nsNr;
@@ -7884,6 +9367,7 @@ reparse:
SHRINK;
base = ctxt->input->base;
cur = ctxt->input->cur - ctxt->input->base;
+ inputNr = ctxt->inputNr;
oldline = ctxt->input->line;
oldcol = ctxt->input->col;
nbatts = 0;
@@ -7909,18 +9393,19 @@ reparse:
*/
SKIP_BLANKS;
GROW;
- if (ctxt->input->base != base) goto base_changed;
+ if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
+ goto base_changed;
- while ((RAW != '>') &&
+ while (((RAW != '>') &&
((RAW != '/') || (NXT(1) != '>')) &&
- (IS_BYTE_CHAR(RAW))) {
+ (IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *q = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int len = -1, alloc = 0;
attname = xmlParseAttribute2(ctxt, prefix, localname,
&aprefix, &attvalue, &len, &alloc);
- if (ctxt->input->base != base) {
+ if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr)) {
if ((attvalue != NULL) && (alloc != 0))
xmlFree(attvalue);
attvalue = NULL;
@@ -7932,20 +9417,42 @@ reparse:
const xmlChar *URL = xmlDictLookup(ctxt->dict, attvalue, len);
xmlURIPtr uri;
+ if (URL == NULL) {
+ xmlErrMemory(ctxt, "dictionary allocation failure");
+ if ((attvalue != NULL) && (alloc != 0))
+ xmlFree(attvalue);
+ return(NULL);
+ }
if (*URL != 0) {
uri = xmlParseURI((const char *) URL);
if (uri == NULL) {
- xmlWarningMsg(ctxt, XML_WAR_NS_URI,
- "xmlns: %s not a valid URI\n",
- URL, NULL);
+ xmlNsErr(ctxt, XML_WAR_NS_URI,
+ "xmlns: '%s' is not a valid URI\n",
+ URL, NULL, NULL);
} else {
if (uri->scheme == NULL) {
- xmlWarningMsg(ctxt, XML_WAR_NS_URI_RELATIVE,
- "xmlns: URI %s is not absolute\n",
- URL, NULL);
+ xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,
+ "xmlns: URI %s is not absolute\n",
+ URL, NULL, NULL);
}
xmlFreeURI(uri);
}
+ if (URL == ctxt->str_xml_ns) {
+ if (attname != ctxt->str_xml) {
+ xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+ "xml namespace URI cannot be the default namespace\n",
+ NULL, NULL, NULL);
+ }
+ goto skip_default_ns;
+ }
+ if ((len == 29) &&
+ (xmlStrEqual(URL,
+ BAD_CAST "http://www.w3.org/2000/xmlns/"))) {
+ xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+ "reuse of the xmlns namespace name is forbidden\n",
+ NULL, NULL, NULL);
+ goto skip_default_ns;
+ }
}
/*
* check that it's not a defined namespace
@@ -7957,7 +9464,15 @@ reparse:
xmlErrAttributeDup(ctxt, NULL, attname);
else
if (nsPush(ctxt, NULL, URL) > 0) nbNs++;
+skip_default_ns:
if (alloc != 0) xmlFree(attvalue);
+ if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
+ break;
+ if (!IS_BLANK_CH(RAW)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
+ "attributes construct error\n");
+ break;
+ }
SKIP_BLANKS;
continue;
}
@@ -7974,22 +9489,49 @@ reparse:
/*
* Do not keep a namespace definition node
*/
- if (alloc != 0) xmlFree(attvalue);
- SKIP_BLANKS;
- continue;
+ goto skip_ns;
+ }
+ if (URL == ctxt->str_xml_ns) {
+ if (attname != ctxt->str_xml) {
+ xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+ "xml namespace URI mapped to wrong prefix\n",
+ NULL, NULL, NULL);
+ }
+ goto skip_ns;
+ }
+ if (attname == ctxt->str_xmlns) {
+ xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+ "redefinition of the xmlns prefix is forbidden\n",
+ NULL, NULL, NULL);
+ goto skip_ns;
}
- uri = xmlParseURI((const char *) URL);
- if (uri == NULL) {
- xmlWarningMsg(ctxt, XML_WAR_NS_URI,
- "xmlns:%s: '%s' is not a valid URI\n",
- attname, URL);
+ if ((len == 29) &&
+ (xmlStrEqual(URL,
+ BAD_CAST "http://www.w3.org/2000/xmlns/"))) {
+ xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+ "reuse of the xmlns namespace name is forbidden\n",
+ NULL, NULL, NULL);
+ goto skip_ns;
+ }
+ if ((URL == NULL) || (URL[0] == 0)) {
+ xmlNsErr(ctxt, XML_NS_ERR_XML_NAMESPACE,
+ "xmlns:%s: Empty XML namespace is not allowed\n",
+ attname, NULL, NULL);
+ goto skip_ns;
} else {
- if ((ctxt->pedantic) && (uri->scheme == NULL)) {
- xmlWarningMsg(ctxt, XML_WAR_NS_URI_RELATIVE,
+ uri = xmlParseURI((const char *) URL);
+ if (uri == NULL) {
+ xmlNsErr(ctxt, XML_WAR_NS_URI,
+ "xmlns:%s: '%s' is not a valid URI\n",
+ attname, URL, NULL);
+ } else {
+ if ((ctxt->pedantic) && (uri->scheme == NULL)) {
+ xmlNsWarn(ctxt, XML_WAR_NS_URI_RELATIVE,
"xmlns:%s: URI %s is not absolute\n",
- attname, URL);
+ attname, URL, NULL);
+ }
+ xmlFreeURI(uri);
}
- xmlFreeURI(uri);
}
/*
@@ -8002,9 +9544,18 @@ reparse:
xmlErrAttributeDup(ctxt, aprefix, attname);
else
if (nsPush(ctxt, attname, URL) > 0) nbNs++;
+skip_ns:
if (alloc != 0) xmlFree(attvalue);
+ if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
+ break;
+ if (!IS_BLANK_CH(RAW)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
+ "attributes construct error\n");
+ break;
+ }
SKIP_BLANKS;
- if (ctxt->input->base != base) goto base_changed;
+ if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
+ goto base_changed;
continue;
}
@@ -8036,10 +9587,13 @@ reparse:
xmlFree(attvalue);
}
-failed:
+failed:
GROW
- if (ctxt->input->base != base) goto base_changed;
+ if (ctxt->instate == XML_PARSER_EOF)
+ break;
+ if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
+ goto base_changed;
if ((RAW == '>') || (((RAW == '/') && (NXT(1) == '>'))))
break;
if (!IS_BLANK_CH(RAW)) {
@@ -8055,7 +9609,8 @@ failed:
break;
}
GROW;
- if (ctxt->input->base != base) goto base_changed;
+ if ((ctxt->input->base != base) || (inputNr != ctxt->inputNr))
+ goto base_changed;
}
/*
@@ -8067,8 +9622,8 @@ failed:
defaults = xmlHashLookup2(ctxt->attsDefault, localname, prefix);
if (defaults != NULL) {
for (i = 0;i < defaults->nbAttrs;i++) {
- attname = defaults->values[4 * i];
- aprefix = defaults->values[4 * i + 1];
+ attname = defaults->values[5 * i];
+ aprefix = defaults->values[5 * i + 1];
/*
* special work for namespaces defaulted defs
@@ -8083,9 +9638,9 @@ failed:
if (j <= nbNs) continue;
nsname = xmlGetNamespace(ctxt, NULL);
- if (nsname != defaults->values[4 * i + 2]) {
+ if (nsname != defaults->values[5 * i + 2]) {
if (nsPush(ctxt, NULL,
- defaults->values[4 * i + 2]) > 0)
+ defaults->values[5 * i + 2]) > 0)
nbNs++;
}
} else if (aprefix == ctxt->str_xmlns) {
@@ -8100,7 +9655,7 @@ failed:
nsname = xmlGetNamespace(ctxt, attname);
if (nsname != defaults->values[2]) {
if (nsPush(ctxt, attname,
- defaults->values[4 * i + 2]) > 0)
+ defaults->values[5 * i + 2]) > 0)
nbNs++;
}
} else {
@@ -8126,8 +9681,14 @@ failed:
atts[nbatts++] = NULL;
else
atts[nbatts++] = xmlGetNamespace(ctxt, aprefix);
- atts[nbatts++] = defaults->values[4 * i + 2];
- atts[nbatts++] = defaults->values[4 * i + 3];
+ atts[nbatts++] = defaults->values[5 * i + 2];
+ atts[nbatts++] = defaults->values[5 * i + 3];
+ if ((ctxt->standalone == 1) &&
+ (defaults->values[5 * i + 4] != NULL)) {
+ xmlValidityError(ctxt, XML_DTD_STANDALONE_DEFAULTED,
+ "standalone: attribute %s on %s defaulted from external subset\n",
+ attname, localname);
+ }
nbdef++;
}
}
@@ -8154,7 +9715,7 @@ failed:
/*
* [ WFC: Unique Att Spec ]
* No attribute name may appear more than once in the same
- * start-tag or empty-element tag.
+ * start-tag or empty-element tag.
* As extended by the Namespace in XML REC.
*/
for (j = 0; j < i;j += 5) {
@@ -8216,6 +9777,17 @@ base_changed:
if ((ctxt->attallocs[j] != 0) && (atts[i] != NULL))
xmlFree((xmlChar *) atts[i]);
}
+
+ /*
+ * We can't switch from one entity to another in the middle
+ * of a start tag
+ */
+ if (inputNr != ctxt->inputNr) {
+ xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
+ "Start tag doesn't start and stop in the same entity\n");
+ return(NULL);
+ }
+
ctxt->input->cur = ctxt->input->base + cur;
ctxt->input->line = oldline;
ctxt->input->col = oldcol;
@@ -8255,9 +9827,11 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
if ((tlen > 0) && (xmlStrncmp(ctxt->input->cur, ctxt->name, tlen) == 0)) {
if (ctxt->input->cur[tlen] == '>') {
ctxt->input->cur += tlen + 1;
+ ctxt->input->col += tlen + 1;
goto done;
}
ctxt->input->cur += tlen;
+ ctxt->input->col += tlen;
name = (xmlChar*)1;
} else {
if (prefix == NULL)
@@ -8270,6 +9844,8 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
* We should definitely be at the ending "S? '>'" part
*/
GROW;
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
SKIP_BLANKS;
if ((!IS_BYTE_CHAR(RAW)) || (RAW != '>')) {
xmlFatalErr(ctxt, XML_ERR_GT_REQUIRED, NULL);
@@ -8279,11 +9855,13 @@ xmlParseEndTag2(xmlParserCtxtPtr ctxt, const xmlChar *prefix,
/*
* [ WFC: Element Type Match ]
* The Name in an element's end-tag must match the element type in the
- * start-tag.
+ * start-tag.
*
*/
if (name != (xmlChar*)1) {
if (name == NULL) name = BAD_CAST "unparseable";
+ if ((line == 0) && (ctxt->node != NULL))
+ line = ctxt->node->line;
xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NAME_MISMATCH,
"Opening and ending tag mismatch: %s line %d and %s\n",
ctxt->name, line, name);
@@ -8306,7 +9884,7 @@ done:
/**
* xmlParseCDSect:
* @ctxt: an XML parser context
- *
+ *
* Parse escaped pure raw content.
*
* [18] CDSect ::= CDStart CData CDEnd
@@ -8359,14 +9937,21 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
if (len + 5 >= size) {
xmlChar *tmp;
- size *= 2;
- tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
+ if ((size > XML_MAX_TEXT_LENGTH) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_CDATA_NOT_FINISHED,
+ "CData section too big found", NULL);
+ xmlFree (buf);
+ return;
+ }
+ tmp = (xmlChar *) xmlRealloc(buf, size * 2 * sizeof(xmlChar));
if (tmp == NULL) {
xmlFree(buf);
xmlErrMemory(ctxt, NULL);
return;
}
buf = tmp;
+ size *= 2;
}
COPY_BUF(rl,buf,len,r);
r = s;
@@ -8376,6 +9961,10 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
count++;
if (count > 50) {
GROW;
+ if (ctxt->instate == XML_PARSER_EOF) {
+ xmlFree(buf);
+ return;
+ }
count = 0;
}
NEXTL(l);
@@ -8455,7 +10044,7 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
/*
* Fifth case : a reference. If if has not been resolved,
- * parsing returns it's Name, create the node
+ * parsing returns it's Name, create the node
*/
else if (*cur == '&') {
@@ -8480,7 +10069,7 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"detected an error in element content\n");
- ctxt->instate = XML_PARSER_EOF;
+ xmlHaltParser(ctxt);
break;
}
}
@@ -8496,25 +10085,26 @@ xmlParseContent(xmlParserCtxtPtr ctxt) {
*
* [ WFC: Element Type Match ]
* The Name in an element's end-tag must match the element type in the
- * start-tag.
+ * start-tag.
*
*/
void
xmlParseElement(xmlParserCtxtPtr ctxt) {
const xmlChar *name;
- const xmlChar *prefix;
- const xmlChar *URI;
+ const xmlChar *prefix = NULL;
+ const xmlChar *URI = NULL;
xmlParserNodeInfo node_info;
- int line, tlen;
+ int line, tlen = 0;
xmlNodePtr ret;
int nsNr = ctxt->nsNr;
- if ((unsigned int) ctxt->nameNr > xmlParserMaxDepth) {
- xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
- "Excessive depth in document: change xmlParserMaxDepth = %d\n",
- xmlParserMaxDepth);
- ctxt->instate = XML_PARSER_EOF;
+ if (((unsigned int) ctxt->nameNr > xmlParserMaxDepth) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErrMsgInt(ctxt, XML_ERR_INTERNAL_ERROR,
+ "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
+ xmlParserMaxDepth);
+ xmlHaltParser(ctxt);
return;
}
@@ -8541,6 +10131,8 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
else
name = xmlParseStartTag(ctxt);
#endif /* LIBXML_SAX1_ENABLED */
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
if (name == NULL) {
spacePop(ctxt);
return;
@@ -8552,7 +10144,7 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
/*
* [ VC: Root Element Type ]
* The Name in the document type declaration must match the element
- * type of the root element.
+ * type of the root element.
*/
if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc &&
ctxt->node && (ctxt->node == ctxt->myDoc->children))
@@ -8621,6 +10213,8 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
* Parse the content of the element:
*/
xmlParseContent(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return;
if (!IS_BYTE_CHAR(RAW)) {
xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
"Premature end of data in tag %s line %d\n",
@@ -8667,7 +10261,9 @@ xmlParseElement(xmlParserCtxtPtr ctxt) {
*
* parse the XML version value.
*
- * [26] VersionNum ::= ([a-zA-Z0-9_.:] | '-')+
+ * [26] VersionNum ::= '1.' [0-9]+
+ *
+ * In practice allow [0-9].[0-9]+ at that level
*
* Returns the string giving the XML version number, or NULL
*/
@@ -8684,17 +10280,28 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
return(NULL);
}
cur = CUR;
- while (((cur >= 'a') && (cur <= 'z')) ||
- ((cur >= 'A') && (cur <= 'Z')) ||
- ((cur >= '0') && (cur <= '9')) ||
- (cur == '_') || (cur == '.') ||
- (cur == ':') || (cur == '-')) {
+ if (!((cur >= '0') && (cur <= '9'))) {
+ xmlFree(buf);
+ return(NULL);
+ }
+ buf[len++] = cur;
+ NEXT;
+ cur=CUR;
+ if (cur != '.') {
+ xmlFree(buf);
+ return(NULL);
+ }
+ buf[len++] = cur;
+ NEXT;
+ cur=CUR;
+ while ((cur >= '0') && (cur <= '9')) {
if (len + 1 >= size) {
xmlChar *tmp;
size *= 2;
tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar));
if (tmp == NULL) {
+ xmlFree(buf);
xmlErrMemory(ctxt, NULL);
return(NULL);
}
@@ -8711,11 +10318,11 @@ xmlParseVersionNum(xmlParserCtxtPtr ctxt) {
/**
* xmlParseVersionInfo:
* @ctxt: an XML parser context
- *
+ *
* parse the XML version.
*
* [24] VersionInfo ::= S 'version' Eq (' VersionNum ' | " VersionNum ")
- *
+ *
* [25] Eq ::= S? '=' S?
*
* Returns the version string, e.g. "1.0"
@@ -8780,7 +10387,7 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
xmlErrMemory(ctxt, NULL);
return(NULL);
}
-
+
buf[len++] = cur;
NEXT;
cur = CUR;
@@ -8820,7 +10427,7 @@ xmlParseEncName(xmlParserCtxtPtr ctxt) {
/**
* xmlParseEncodingDecl:
* @ctxt: an XML parser context
- *
+ *
* parse the XML encoding declaration
*
* [80] EncodingDecl ::= S 'encoding' Eq ('"' EncName '"' | "'" EncName "'")
@@ -8849,6 +10456,8 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
encoding = xmlParseEncName(ctxt);
if (RAW != '"') {
xmlFatalErr(ctxt, XML_ERR_STRING_NOT_CLOSED, NULL);
+ xmlFree((xmlChar *) encoding);
+ return(NULL);
} else
NEXT;
} else if (RAW == '\''){
@@ -8856,11 +10465,22 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
encoding = xmlParseEncName(ctxt);
if (RAW != '\'') {
xmlFatalErr(ctxt, XML_ERR_STRING_NOT_CLOSED, NULL);
+ xmlFree((xmlChar *) encoding);
+ return(NULL);
} else
NEXT;
} else {
xmlFatalErr(ctxt, XML_ERR_STRING_NOT_STARTED, NULL);
}
+
+ /*
+ * Non standard parsing, allowing the user to ignore encoding
+ */
+ if (ctxt->options & XML_PARSE_IGNORE_ENC) {
+ xmlFree((xmlChar *) encoding);
+ return(NULL);
+ }
+
/*
* UTF-16 encoding stwich has already taken place at this stage,
* more over the little-endian/big-endian selection is already done
@@ -8868,6 +10488,18 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
if ((encoding != NULL) &&
((!xmlStrcasecmp(encoding, BAD_CAST "UTF-16")) ||
(!xmlStrcasecmp(encoding, BAD_CAST "UTF16")))) {
+ /*
+ * If no encoding was passed to the parser, that we are
+ * using UTF-16 and no decoder is present i.e. the
+ * document is apparently UTF-8 compatible, then raise an
+ * encoding mismatch fatal error
+ */
+ if ((ctxt->encoding == NULL) &&
+ (ctxt->input->buf != NULL) &&
+ (ctxt->input->buf->encoder == NULL)) {
+ xmlFatalErrMsg(ctxt, XML_ERR_INVALID_ENCODING,
+ "Document labelled UTF-16 but has UTF-8 content\n");
+ }
if (ctxt->encoding != NULL)
xmlFree((xmlChar *) ctxt->encoding);
ctxt->encoding = encoding;
@@ -8891,7 +10523,11 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
handler = xmlFindCharEncodingHandler((const char *) encoding);
if (handler != NULL) {
- xmlSwitchToEncoding(ctxt, handler);
+ if (xmlSwitchToEncoding(ctxt, handler) < 0) {
+ /* failed to convert */
+ ctxt->errNo = XML_ERR_UNSUPPORTED_ENCODING;
+ return(NULL);
+ }
} else {
xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
"Unsupported encoding %s\n", encoding);
@@ -8909,7 +10545,7 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
* parse the XML standalone declaration
*
* [32] SDDecl ::= S 'standalone' Eq
- * (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no')'"'))
+ * (("'" ('yes' | 'no') "'") | ('"' ('yes' | 'no')'"'))
*
* [ VC: Standalone Document Declaration ]
* TODO The standalone document declaration must have the value "no"
@@ -8925,12 +10561,17 @@ xmlParseEncodingDecl(xmlParserCtxtPtr ctxt) {
* - element types with element content, if white space occurs directly
* within any instance of those types.
*
- * Returns 1 if standalone, 0 otherwise
+ * Returns:
+ * 1 if standalone="yes"
+ * 0 if standalone="no"
+ * -2 if standalone attribute is missing or invalid
+ * (A standalone value of -2 means that the XML declaration was found,
+ * but no value was specified for the standalone attribute).
*/
int
xmlParseSDDecl(xmlParserCtxtPtr ctxt) {
- int standalone = -1;
+ int standalone = -2;
SKIP_BLANKS;
if (CMP10(CUR_PTR, 's', 't', 'a', 'n', 'd', 'a', 'l', 'o', 'n', 'e')) {
@@ -8984,7 +10625,7 @@ xmlParseSDDecl(xmlParserCtxtPtr ctxt) {
/**
* xmlParseXMLDecl:
* @ctxt: an XML parser context
- *
+ *
* parse an XML declaration header
*
* [23] XMLDecl ::= '<?xml' VersionInfo EncodingDecl? SDDecl? S? '?>'
@@ -9021,11 +10662,23 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
} else {
if (!xmlStrEqual(version, (const xmlChar *) XML_DEFAULT_VERSION)) {
/*
- * TODO: Blueberry should be detected here
+ * Changed here for XML-1.0 5th edition
*/
- xmlWarningMsg(ctxt, XML_WAR_UNKNOWN_VERSION,
- "Unsupported version '%s'\n",
- version, NULL);
+ if (ctxt->options & XML_PARSE_OLD10) {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_UNKNOWN_VERSION,
+ "Unsupported version '%s'\n",
+ version);
+ } else {
+ if ((version[0] == '1') && ((version[1] == '.'))) {
+ xmlWarningMsg(ctxt, XML_WAR_UNKNOWN_VERSION,
+ "Unsupported version '%s'\n",
+ version, NULL);
+ } else {
+ xmlFatalErrMsgStr(ctxt, XML_ERR_UNKNOWN_VERSION,
+ "Unsupported version '%s'\n",
+ version);
+ }
+ }
}
if (ctxt->version != NULL)
xmlFree((void *) ctxt->version);
@@ -9043,7 +10696,8 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "Blank needed here\n");
}
xmlParseEncodingDecl(ctxt);
- if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
+ if ((ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) ||
+ (ctxt->instate == XML_PARSER_EOF)) {
/*
* The XML REC instructs us to stop parsing right here
*/
@@ -9060,6 +10714,12 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
}
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED, "Blank needed here\n");
}
+
+ /*
+ * We can grow the input buffer freely at that point
+ */
+ GROW;
+
SKIP_BLANKS;
ctxt->input->standalone = xmlParseSDDecl(ctxt);
@@ -9080,7 +10740,7 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
/**
* xmlParseMisc:
* @ctxt: an XML parser context
- *
+ *
* parse an XML Misc* optional field.
*
* [27] Misc ::= Comment | PI | S
@@ -9088,9 +10748,10 @@ xmlParseXMLDecl(xmlParserCtxtPtr ctxt) {
void
xmlParseMisc(xmlParserCtxtPtr ctxt) {
- while (((RAW == '<') && (NXT(1) == '?')) ||
- (CMP4(CUR_PTR, '<', '!', '-', '-')) ||
- IS_BLANK_CH(CUR)) {
+ while ((ctxt->instate != XML_PARSER_EOF) &&
+ (((RAW == '<') && (NXT(1) == '?')) ||
+ (CMP4(CUR_PTR, '<', '!', '-', '-')) ||
+ IS_BLANK_CH(CUR))) {
if ((RAW == '<') && (NXT(1) == '?')) {
xmlParsePI(ctxt);
} else if (IS_BLANK_CH(CUR)) {
@@ -9103,7 +10764,7 @@ xmlParseMisc(xmlParserCtxtPtr ctxt) {
/**
* xmlParseDocument:
* @ctxt: an XML parser context
- *
+ *
* parse an XML document (and build a tree if using the standard SAX
* interface).
*
@@ -9137,10 +10798,12 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
*/
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(-1);
- if ((ctxt->encoding == (const xmlChar *)XML_CHAR_ENCODING_NONE) &&
+ if ((ctxt->encoding == NULL) &&
((ctxt->input->end - ctxt->input->cur) >= 4)) {
- /*
+ /*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
@@ -9158,19 +10821,26 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
if (CUR == 0) {
xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
+ return(-1);
}
/*
* Check for the XMLDecl in the Prolog.
+ * do not GROW here to avoid the detected encoder to decode more
+ * than just the first line, unless the amount of data is really
+ * too small to hold "<?xml version="1.0" encoding="foo"
*/
- GROW;
+ if ((ctxt->input->end - ctxt->input->cur) < 35) {
+ GROW;
+ }
if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
/*
* Note that we will switch encoding on the fly.
*/
xmlParseXMLDecl(ctxt);
- if (ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) {
+ if ((ctxt->errNo == XML_ERR_UNSUPPORTED_ENCODING) ||
+ (ctxt->instate == XML_PARSER_EOF)) {
/*
* The XML REC instructs us to stop parsing right here
*/
@@ -9183,6 +10853,12 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
}
if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX))
ctxt->sax->startDocument(ctxt->userData);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(-1);
+ if ((ctxt->myDoc != NULL) && (ctxt->input != NULL) &&
+ (ctxt->input->buf != NULL) && (ctxt->input->buf->compressed >= 0)) {
+ ctxt->myDoc->compression = ctxt->input->buf->compressed;
+ }
/*
* The Misc part of the Prolog
@@ -9202,6 +10878,8 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
if (RAW == '[') {
ctxt->instate = XML_PARSER_DTD;
xmlParseInternalSubset(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(-1);
}
/*
@@ -9212,8 +10890,11 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
(!ctxt->disableSAX))
ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName,
ctxt->extSubSystem, ctxt->extSubURI);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(-1);
ctxt->inSubset = 0;
+ xmlCleanSpecialAttr(ctxt);
ctxt->instate = XML_PARSER_PROLOG;
xmlParseMisc(ctxt);
@@ -9258,6 +10939,15 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
ctxt->myDoc = NULL;
}
+ if ((ctxt->wellFormed) && (ctxt->myDoc != NULL)) {
+ ctxt->myDoc->properties |= XML_DOC_WELLFORMED;
+ if (ctxt->valid)
+ ctxt->myDoc->properties |= XML_DOC_DTDVALID;
+ if (ctxt->nsWellFormed)
+ ctxt->myDoc->properties |= XML_DOC_NSVALID;
+ if (ctxt->options & XML_PARSE_OLD10)
+ ctxt->myDoc->properties |= XML_DOC_OLD10;
+ }
if (! ctxt->wellFormed) {
ctxt->valid = 0;
return(-1);
@@ -9268,7 +10958,7 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
/**
* xmlParseExtParsedEnt:
* @ctxt: an XML parser context
- *
+ *
* parse a general parsed entity
* An external general parsed entity is well-formed if it matches the
* production labeled extParsedEnt.
@@ -9299,7 +10989,7 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator))
ctxt->sax->setDocumentLocator(ctxt->userData, &xmlDefaultSAXLocator);
- /*
+ /*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
@@ -9342,6 +11032,8 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
}
if ((ctxt->sax) && (ctxt->sax->startDocument) && (!ctxt->disableSAX))
ctxt->sax->startDocument(ctxt->userData);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(-1);
/*
* Doing validity checking on chunk doesn't make sense
@@ -9352,7 +11044,9 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
ctxt->depth = 0;
xmlParseContent(ctxt);
-
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(-1);
+
if ((RAW == '<') && (NXT(1) == '/')) {
xmlFatalErr(ctxt, XML_ERR_NOT_WELL_BALANCED, NULL);
} else if (RAW != 0) {
@@ -9372,7 +11066,7 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
#ifdef LIBXML_PUSH_ENABLED
/************************************************************************
* *
- * Progressive parsing interfaces *
+ * Progressive parsing interfaces *
* *
************************************************************************/
@@ -9409,8 +11103,8 @@ xmlParseLookupSequence(xmlParserCtxtPtr ctxt, xmlChar first,
buf = in->base;
len = in->length;
} else {
- buf = in->buf->buffer->content;
- len = in->buf->buffer->use;
+ buf = xmlBufContent(in->buf->buffer);
+ len = xmlBufUse(in->buf->buffer);
}
/* take into account the sequence length */
if (third) len -= 2;
@@ -9433,7 +11127,7 @@ xmlParseLookupSequence(xmlParserCtxtPtr ctxt, xmlChar first,
xmlGenericError(xmlGenericErrorContext,
"PP: lookup '%c%c' found at %d\n",
first, next, base);
- else
+ else
xmlGenericError(xmlGenericErrorContext,
"PP: lookup '%c%c%c' found at %d\n",
first, next, third, base);
@@ -9449,7 +11143,7 @@ xmlParseLookupSequence(xmlParserCtxtPtr ctxt, xmlChar first,
else if (third == 0)
xmlGenericError(xmlGenericErrorContext,
"PP: lookup '%c%c' failed\n", first, next);
- else
+ else
xmlGenericError(xmlGenericErrorContext,
"PP: lookup '%c%c%c' failed\n", first, next, third);
#endif
@@ -9531,7 +11225,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) {
if ((utf == NULL) || (len <= 0))
return(0);
-
+
for (ix = 0; ix < len;) { /* string is 0-terminated */
c = utf[ix];
if ((c & 0x80) == 0x00) { /* 1-byte code, starts with 10 */
@@ -9542,7 +11236,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) {
else
return(-ix);
} else if ((c & 0xe0) == 0xc0) {/* 2-byte code, starts with 110 */
- if (ix + 2 > len) return(ix);
+ if (ix + 2 > len) return(-ix);
if ((utf[ix+1] & 0xc0 ) != 0x80)
return(-ix);
codepoint = (utf[ix] & 0x1f) << 6;
@@ -9551,7 +11245,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) {
return(-ix);
ix += 2;
} else if ((c & 0xf0) == 0xe0) {/* 3-byte code, starts with 1110 */
- if (ix + 3 > len) return(ix);
+ if (ix + 3 > len) return(-ix);
if (((utf[ix+1] & 0xc0) != 0x80) ||
((utf[ix+2] & 0xc0) != 0x80))
return(-ix);
@@ -9562,7 +11256,7 @@ xmlCheckCdataPush(const xmlChar *utf, int len) {
return(-ix);
ix += 3;
} else if ((c & 0xf8) == 0xf0) {/* 4-byte code, starts with 11110 */
- if (ix + 4 > len) return(ix);
+ if (ix + 4 > len) return(-ix);
if (((utf[ix+1] & 0xc0) != 0x80) ||
((utf[ix+2] & 0xc0) != 0x80) ||
((utf[ix+3] & 0xc0) != 0x80))
@@ -9659,11 +11353,11 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
}
xmlParseGetLasts(ctxt, &lastlt, &lastgt);
- while (1) {
+ while (ctxt->instate != XML_PARSER_EOF) {
if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
return(0);
-
+
/*
* Pop-up of finished entities.
*/
@@ -9678,22 +11372,22 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
/*
* If we are operating on converted input, try to flush
* remainng chars to avoid them stalling in the non-converted
- * buffer.
+ * buffer. But do not do this in document start where
+ * encoding="..." may not have been read and we work on a
+ * guessed encoding.
*/
- if ((ctxt->input->buf->raw != NULL) &&
- (ctxt->input->buf->raw->use > 0)) {
- int base = ctxt->input->base -
- ctxt->input->buf->buffer->content;
- int current = ctxt->input->cur - ctxt->input->base;
+ if ((ctxt->instate != XML_PARSER_START) &&
+ (ctxt->input->buf->raw != NULL) &&
+ (xmlBufIsEmpty(ctxt->input->buf->raw) == 0)) {
+ size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer,
+ ctxt->input);
+ size_t current = ctxt->input->cur - ctxt->input->base;
xmlParserInputBufferPush(ctxt->input->buf, 0, "");
- ctxt->input->base = ctxt->input->buf->buffer->content + base;
- ctxt->input->cur = ctxt->input->base + current;
- ctxt->input->end =
- &ctxt->input->buf->buffer->content[
- ctxt->input->buf->buffer->use];
+ xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input,
+ base, current);
}
- avail = ctxt->input->buf->buffer->use -
+ avail = xmlBufUse(ctxt->input->buf->buffer) -
(ctxt->input->cur - ctxt->input->base);
}
if (avail < 1)
@@ -9715,7 +11409,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
if (avail < 4)
goto done;
- /*
+ /*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines,
@@ -9740,7 +11434,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
ctxt->sax->setDocumentLocator(ctxt->userData,
&xmlDefaultSAXLocator);
xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
- ctxt->instate = XML_PARSER_EOF;
+ xmlHaltParser(ctxt);
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: entering EOF\n");
@@ -9773,7 +11467,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
* The XML REC instructs us to stop parsing right
* here
*/
- ctxt->instate = XML_PARSER_EOF;
+ xmlHaltParser(ctxt);
return(0);
}
ctxt->standalone = ctxt->input->standalone;
@@ -9820,8 +11514,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
break;
case XML_PARSER_START_TAG: {
const xmlChar *name;
- const xmlChar *prefix;
- const xmlChar *URI;
+ const xmlChar *prefix = NULL;
+ const xmlChar *URI = NULL;
int nsNr = ctxt->nsNr;
if ((avail < 2) && (ctxt->inputNr == 1))
@@ -9829,7 +11523,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
cur = ctxt->input->cur[0];
if (cur != '<') {
xmlFatalErr(ctxt, XML_ERR_DOCUMENT_EMPTY, NULL);
- ctxt->instate = XML_PARSER_EOF;
+ xmlHaltParser(ctxt);
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
ctxt->sax->endDocument(ctxt->userData);
goto done;
@@ -9857,9 +11551,11 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
else
name = xmlParseStartTag(ctxt);
#endif /* LIBXML_SAX1_ENABLED */
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
if (name == NULL) {
spacePop(ctxt);
- ctxt->instate = XML_PARSER_EOF;
+ xmlHaltParser(ctxt);
if ((ctxt->sax) && (ctxt->sax->endDocument != NULL))
ctxt->sax->endDocument(ctxt->userData);
goto done;
@@ -9868,7 +11564,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
/*
* [ VC: Root Element Type ]
* The Name in the document type declaration must match
- * the element type of the root element.
+ * the element type of the root element.
*/
if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc &&
ctxt->node && (ctxt->node == ctxt->myDoc->children))
@@ -9897,12 +11593,15 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
ctxt->sax->endElement(ctxt->userData, name);
#endif /* LIBXML_SAX1_ENABLED */
}
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
spacePop(ctxt);
if (ctxt->nameNr == 0) {
ctxt->instate = XML_PARSER_EPILOG;
} else {
ctxt->instate = XML_PARSER_CONTENT;
}
+ ctxt->progressive = 1;
break;
}
if (RAW == '>') {
@@ -9922,6 +11621,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
#endif /* LIBXML_SAX1_ENABLED */
ctxt->instate = XML_PARSER_CONTENT;
+ ctxt->progressive = 1;
break;
}
case XML_PARSER_CONTENT: {
@@ -9939,9 +11639,13 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
break;
} else if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
+ (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
+ ctxt->progressive = XML_PARSER_PI;
goto done;
+ }
xmlParsePI(ctxt);
+ ctxt->instate = XML_PARSER_CONTENT;
+ ctxt->progressive = 1;
} else if ((cur == '<') && (next != '!')) {
ctxt->instate = XML_PARSER_START_TAG;
break;
@@ -9955,10 +11659,13 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
ctxt->input->cur += 4;
term = xmlParseLookupSequence(ctxt, '-', '-', '>');
ctxt->input->cur -= 4;
- if ((!terminate) && (term < 0))
+ if ((!terminate) && (term < 0)) {
+ ctxt->progressive = XML_PARSER_COMMENT;
goto done;
+ }
xmlParseComment(ctxt);
ctxt->instate = XML_PARSER_CONTENT;
+ ctxt->progressive = 1;
} else if ((cur == '<') && (ctxt->input->cur[1] == '!') &&
(ctxt->input->cur[2] == '[') &&
(ctxt->input->cur[3] == 'C') &&
@@ -10015,7 +11722,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"detected an error in element content\n");
- ctxt->instate = XML_PARSER_EOF;
+ xmlHaltParser(ctxt);
break;
}
break;
@@ -10043,7 +11750,9 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
else
xmlParseEndTag1(ctxt, 0);
#endif /* LIBXML_SAX1_ENABLED */
- if (ctxt->nameNr == 0) {
+ if (ctxt->instate == XML_PARSER_EOF) {
+ /* Nothing */
+ } else if (ctxt->nameNr == 0) {
ctxt->instate = XML_PARSER_EPILOG;
} else {
ctxt->instate = XML_PARSER_CONTENT;
@@ -10051,7 +11760,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
break;
case XML_PARSER_CDATA_SECTION: {
/*
- * The Push mode need to have the SAX callback for
+ * The Push mode need to have the SAX callback for
* cdataBlock merge back contiguous callbacks.
*/
int base;
@@ -10061,7 +11770,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
if (avail >= XML_PARSER_BIG_BUFFER_SIZE + 2) {
int tmp;
- tmp = xmlCheckCdataPush(ctxt->input->cur,
+ tmp = xmlCheckCdataPush(ctxt->input->cur,
XML_PARSER_BIG_BUFFER_SIZE);
if (tmp < 0) {
tmp = -tmp;
@@ -10076,6 +11785,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
ctxt->sax->characters(ctxt->userData,
ctxt->input->cur, tmp);
}
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
SKIPL(tmp);
ctxt->checkIndex = 0;
}
@@ -10089,7 +11800,20 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
ctxt->input->cur += tmp;
goto encoding_error;
}
- if ((ctxt->sax != NULL) && (base > 0) &&
+ if ((ctxt->sax != NULL) && (base == 0) &&
+ (ctxt->sax->cdataBlock != NULL) &&
+ (!ctxt->disableSAX)) {
+ /*
+ * Special case to provide identical behaviour
+ * between pull and push parsers on enpty CDATA
+ * sections
+ */
+ if ((ctxt->input->cur - ctxt->input->base >= 9) &&
+ (!strncmp((const char *)&ctxt->input->cur[-9],
+ "<![CDATA[", 9)))
+ ctxt->sax->cdataBlock(ctxt->userData,
+ BAD_CAST "", 0);
+ } else if ((ctxt->sax != NULL) && (base > 0) &&
(!ctxt->disableSAX)) {
if (ctxt->sax->cdataBlock != NULL)
ctxt->sax->cdataBlock(ctxt->userData,
@@ -10098,6 +11822,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
ctxt->sax->characters(ctxt->userData,
ctxt->input->cur, base);
}
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
SKIPL(base + 3);
ctxt->checkIndex = 0;
ctxt->instate = XML_PARSER_CONTENT;
@@ -10114,7 +11840,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
avail = ctxt->input->length -
(ctxt->input->cur - ctxt->input->base);
else
- avail = ctxt->input->buf->buffer->use -
+ avail = xmlBufUse(ctxt->input->buf->buffer) -
(ctxt->input->cur - ctxt->input->base);
if (avail < 2)
goto done;
@@ -10122,25 +11848,38 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
next = ctxt->input->cur[1];
if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
+ (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
+ ctxt->progressive = XML_PARSER_PI;
goto done;
+ }
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: Parsing PI\n");
#endif
xmlParsePI(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
+ ctxt->instate = XML_PARSER_MISC;
+ ctxt->progressive = 1;
+ ctxt->checkIndex = 0;
} else if ((cur == '<') && (next == '!') &&
(ctxt->input->cur[2] == '-') &&
(ctxt->input->cur[3] == '-')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
+ (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0)) {
+ ctxt->progressive = XML_PARSER_COMMENT;
goto done;
+ }
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: Parsing Comment\n");
#endif
xmlParseComment(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
ctxt->instate = XML_PARSER_MISC;
+ ctxt->progressive = 1;
+ ctxt->checkIndex = 0;
} else if ((cur == '<') && (next == '!') &&
(ctxt->input->cur[2] == 'D') &&
(ctxt->input->cur[3] == 'O') &&
@@ -10150,14 +11889,20 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
(ctxt->input->cur[7] == 'P') &&
(ctxt->input->cur[8] == 'E')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0))
+ (xmlParseLookupSequence(ctxt, '>', 0, 0) < 0)) {
+ ctxt->progressive = XML_PARSER_DTD;
goto done;
+ }
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: Parsing internal subset\n");
#endif
ctxt->inSubset = 1;
+ ctxt->progressive = 0;
+ ctxt->checkIndex = 0;
xmlParseDocTypeDecl(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
if (RAW == '[') {
ctxt->instate = XML_PARSER_DTD;
#ifdef DEBUG_PUSH
@@ -10175,6 +11920,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
ctxt->intSubName, ctxt->extSubSystem,
ctxt->extSubURI);
ctxt->inSubset = 0;
+ xmlCleanSpecialAttr(ctxt);
ctxt->instate = XML_PARSER_PROLOG;
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -10186,7 +11932,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
goto done;
} else {
ctxt->instate = XML_PARSER_START_TAG;
- ctxt->progressive = 1;
+ ctxt->progressive = XML_PARSER_START_TAG;
xmlParseGetLasts(ctxt, &lastlt, &lastgt);
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -10199,38 +11945,50 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
if (ctxt->input->buf == NULL)
avail = ctxt->input->length - (ctxt->input->cur - ctxt->input->base);
else
- avail = ctxt->input->buf->buffer->use - (ctxt->input->cur - ctxt->input->base);
- if (avail < 2)
+ avail = xmlBufUse(ctxt->input->buf->buffer) -
+ (ctxt->input->cur - ctxt->input->base);
+ if (avail < 2)
goto done;
cur = ctxt->input->cur[0];
next = ctxt->input->cur[1];
if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
+ (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
+ ctxt->progressive = XML_PARSER_PI;
goto done;
+ }
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: Parsing PI\n");
#endif
xmlParsePI(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
+ ctxt->instate = XML_PARSER_PROLOG;
+ ctxt->progressive = 1;
} else if ((cur == '<') && (next == '!') &&
(ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
+ (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0)) {
+ ctxt->progressive = XML_PARSER_COMMENT;
goto done;
+ }
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: Parsing Comment\n");
#endif
xmlParseComment(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
ctxt->instate = XML_PARSER_PROLOG;
+ ctxt->progressive = 1;
} else if ((cur == '<') && (next == '!') &&
(avail < 4)) {
goto done;
} else {
ctxt->instate = XML_PARSER_START_TAG;
if (ctxt->progressive == 0)
- ctxt->progressive = 1;
+ ctxt->progressive = XML_PARSER_START_TAG;
xmlParseGetLasts(ctxt, &lastlt, &lastgt);
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
@@ -10243,38 +12001,49 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
if (ctxt->input->buf == NULL)
avail = ctxt->input->length - (ctxt->input->cur - ctxt->input->base);
else
- avail = ctxt->input->buf->buffer->use - (ctxt->input->cur - ctxt->input->base);
+ avail = xmlBufUse(ctxt->input->buf->buffer) -
+ (ctxt->input->cur - ctxt->input->base);
if (avail < 2)
goto done;
cur = ctxt->input->cur[0];
next = ctxt->input->cur[1];
if ((cur == '<') && (next == '?')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0))
+ (xmlParseLookupSequence(ctxt, '?', '>', 0) < 0)) {
+ ctxt->progressive = XML_PARSER_PI;
goto done;
+ }
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: Parsing PI\n");
#endif
xmlParsePI(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
ctxt->instate = XML_PARSER_EPILOG;
+ ctxt->progressive = 1;
} else if ((cur == '<') && (next == '!') &&
(ctxt->input->cur[2] == '-') && (ctxt->input->cur[3] == '-')) {
if ((!terminate) &&
- (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0))
+ (xmlParseLookupSequence(ctxt, '-', '-', '>') < 0)) {
+ ctxt->progressive = XML_PARSER_COMMENT;
goto done;
+ }
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: Parsing Comment\n");
#endif
xmlParseComment(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
ctxt->instate = XML_PARSER_EPILOG;
+ ctxt->progressive = 1;
} else if ((cur == '<') && (next == '!') &&
(avail < 4)) {
goto done;
} else {
xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
- ctxt->instate = XML_PARSER_EOF;
+ xmlHaltParser(ctxt);
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext,
"PP: entering EOF\n");
@@ -10298,29 +12067,28 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
int base, i;
xmlChar *buf;
xmlChar quote = 0;
+ size_t use;
base = ctxt->input->cur - ctxt->input->base;
if (base < 0) return(0);
if (ctxt->checkIndex > base)
base = ctxt->checkIndex;
- buf = ctxt->input->buf->buffer->content;
- for (;(unsigned int) base < ctxt->input->buf->buffer->use;
- base++) {
+ buf = xmlBufContent(ctxt->input->buf->buffer);
+ use = xmlBufUse(ctxt->input->buf->buffer);
+ for (;(unsigned int) base < use; base++) {
if (quote != 0) {
if (buf[base] == quote)
quote = 0;
- continue;
+ continue;
}
if ((quote == 0) && (buf[base] == '<')) {
int found = 0;
/* special handling of comments */
- if (((unsigned int) base + 4 <
- ctxt->input->buf->buffer->use) &&
+ if (((unsigned int) base + 4 < use) &&
(buf[base + 1] == '!') &&
(buf[base + 2] == '-') &&
(buf[base + 3] == '-')) {
- for (;(unsigned int) base + 3 <
- ctxt->input->buf->buffer->use; base++) {
+ for (;(unsigned int) base + 3 < use; base++) {
if ((buf[base] == '-') &&
(buf[base + 1] == '-') &&
(buf[base + 2] == '>')) {
@@ -10351,17 +12119,14 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
fprintf(stderr, "%c%c%c%c: ", buf[base],
buf[base + 1], buf[base + 2], buf[base + 3]);
#endif
- if ((unsigned int) base +1 >=
- ctxt->input->buf->buffer->use)
+ if ((unsigned int) base +1 >= use)
break;
if (buf[base + 1] == ']') {
/* conditional crap, skip both ']' ! */
base++;
continue;
}
- for (i = 1;
- (unsigned int) base + i < ctxt->input->buf->buffer->use;
- i++) {
+ for (i = 1; (unsigned int) base + i < use; i++) {
if (buf[base + i] == '>') {
#if 0
fprintf(stderr, "found\n");
@@ -10379,7 +12144,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
fprintf(stderr, "end of stream\n");
#endif
break;
-
+
}
not_end_of_int_subset:
continue; /* for */
@@ -10387,6 +12152,10 @@ not_end_of_int_subset:
/*
* We didn't found the end of the Internal subset
*/
+ if (quote == 0)
+ ctxt->checkIndex = base;
+ else
+ ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
if (next == 0)
xmlGenericError(xmlGenericErrorContext,
@@ -10395,13 +12164,19 @@ not_end_of_int_subset:
goto done;
found_end_int_subset:
+ ctxt->checkIndex = 0;
xmlParseInternalSubset(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
ctxt->inSubset = 2;
if ((ctxt->sax != NULL) && (!ctxt->disableSAX) &&
(ctxt->sax->externalSubset != NULL))
ctxt->sax->externalSubset(ctxt->userData, ctxt->intSubName,
ctxt->extSubSystem, ctxt->extSubURI);
ctxt->inSubset = 0;
+ xmlCleanSpecialAttr(ctxt);
+ if (ctxt->instate == XML_PARSER_EOF)
+ goto done;
ctxt->instate = XML_PARSER_PROLOG;
ctxt->checkIndex = 0;
#ifdef DEBUG_PUSH
@@ -10484,7 +12259,7 @@ found_end_int_subset:
break;
}
}
-done:
+done:
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext, "PP: done %d\n", ret);
#endif
@@ -10504,6 +12279,55 @@ encoding_error:
}
/**
+ * xmlParseCheckTransition:
+ * @ctxt: an XML parser context
+ * @chunk: a char array
+ * @size: the size in byte of the chunk
+ *
+ * Check depending on the current parser state if the chunk given must be
+ * processed immediately or one need more data to advance on parsing.
+ *
+ * Returns -1 in case of error, 0 if the push is not needed and 1 if needed
+ */
+static int
+xmlParseCheckTransition(xmlParserCtxtPtr ctxt, const char *chunk, int size) {
+ if ((ctxt == NULL) || (chunk == NULL) || (size < 0))
+ return(-1);
+ if (ctxt->instate == XML_PARSER_START_TAG) {
+ if (memchr(chunk, '>', size) != NULL)
+ return(1);
+ return(0);
+ }
+ if (ctxt->progressive == XML_PARSER_COMMENT) {
+ if (memchr(chunk, '>', size) != NULL)
+ return(1);
+ return(0);
+ }
+ if (ctxt->instate == XML_PARSER_CDATA_SECTION) {
+ if (memchr(chunk, '>', size) != NULL)
+ return(1);
+ return(0);
+ }
+ if (ctxt->progressive == XML_PARSER_PI) {
+ if (memchr(chunk, '>', size) != NULL)
+ return(1);
+ return(0);
+ }
+ if (ctxt->instate == XML_PARSER_END_TAG) {
+ if (memchr(chunk, '>', size) != NULL)
+ return(1);
+ return(0);
+ }
+ if ((ctxt->progressive == XML_PARSER_DTD) ||
+ (ctxt->instate == XML_PARSER_DTD)) {
+ if (memchr(chunk, '>', size) != NULL)
+ return(1);
+ return(0);
+ }
+ return(1);
+}
+
+/**
* xmlParseChunk:
* @ctxt: an XML parser context
* @chunk: an char array
@@ -10518,11 +12342,16 @@ int
xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
int terminate) {
int end_in_lf = 0;
+ int remain = 0;
+ size_t old_avail = 0;
+ size_t avail = 0;
if (ctxt == NULL)
return(XML_ERR_INTERNAL_ERROR);
if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
return(ctxt->errNo);
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(-1);
if (ctxt->instate == XML_PARSER_START)
xmlDetectSAX2(ctxt);
if ((size > 0) && (chunk != NULL) && (!terminate) &&
@@ -10530,22 +12359,58 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
end_in_lf = 1;
size--;
}
+
+xmldecl_done:
+
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
(ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF)) {
- int base = ctxt->input->base - ctxt->input->buf->buffer->content;
- int cur = ctxt->input->cur - ctxt->input->base;
+ size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
+ size_t cur = ctxt->input->cur - ctxt->input->base;
int res;
-
- res =xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+
+ old_avail = xmlBufUse(ctxt->input->buf->buffer);
+ /*
+ * Specific handling if we autodetected an encoding, we should not
+ * push more than the first line ... which depend on the encoding
+ * And only push the rest once the final encoding was detected
+ */
+ if ((ctxt->instate == XML_PARSER_START) && (ctxt->input != NULL) &&
+ (ctxt->input->buf != NULL) && (ctxt->input->buf->encoder != NULL)) {
+ unsigned int len = 45;
+
+ if ((xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name,
+ BAD_CAST "UTF-16")) ||
+ (xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name,
+ BAD_CAST "UTF16")))
+ len = 90;
+ else if ((xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name,
+ BAD_CAST "UCS-4")) ||
+ (xmlStrcasestr(BAD_CAST ctxt->input->buf->encoder->name,
+ BAD_CAST "UCS4")))
+ len = 180;
+
+ if (ctxt->input->buf->rawconsumed < len)
+ len -= ctxt->input->buf->rawconsumed;
+
+ /*
+ * Change size for reading the initial declaration only
+ * if size is greater than len. Otherwise, memmove in xmlBufferAdd
+ * will blindly copy extra bytes from memory.
+ */
+ if ((unsigned int) size > len) {
+ remain = size - len;
+ size = len;
+ } else {
+ remain = 0;
+ }
+ }
+ res = xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
if (res < 0) {
ctxt->errNo = XML_PARSER_EOF;
- ctxt->disableSAX = 1;
+ xmlHaltParser(ctxt);
return (XML_PARSER_EOF);
}
- ctxt->input->base = ctxt->input->buf->buffer->content + base;
- ctxt->input->cur = ctxt->input->base + cur;
- ctxt->input->end =
- &ctxt->input->buf->buffer->content[ctxt->input->buf->buffer->use];
+ xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
#endif
@@ -10556,44 +12421,88 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
if ((in->encoder != NULL) && (in->buffer != NULL) &&
(in->raw != NULL)) {
int nbchars;
-
- nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
+ size_t base = xmlBufGetInputBase(in->buffer, ctxt->input);
+ size_t current = ctxt->input->cur - ctxt->input->base;
+
+ nbchars = xmlCharEncInput(in, terminate);
if (nbchars < 0) {
/* TODO 2.6.0 */
xmlGenericError(xmlGenericErrorContext,
"xmlParseChunk: encoder error\n");
return(XML_ERR_INVALID_ENCODING);
}
+ xmlBufSetInputBaseCur(in->buffer, ctxt->input, base, current);
}
}
}
- xmlParseTryOrFinish(ctxt, terminate);
+ if (remain != 0) {
+ xmlParseTryOrFinish(ctxt, 0);
+ } else {
+ if ((ctxt->input != NULL) && (ctxt->input->buf != NULL))
+ avail = xmlBufUse(ctxt->input->buf->buffer);
+ /*
+ * Depending on the current state it may not be such
+ * a good idea to try parsing if there is nothing in the chunk
+ * which would be worth doing a parser state transition and we
+ * need to wait for more data
+ */
+ if ((terminate) || (avail > XML_MAX_TEXT_LENGTH) ||
+ (old_avail == 0) || (avail == 0) ||
+ (xmlParseCheckTransition(ctxt,
+ (const char *)&ctxt->input->base[old_avail],
+ avail - old_avail)))
+ xmlParseTryOrFinish(ctxt, terminate);
+ }
+ if (ctxt->instate == XML_PARSER_EOF)
+ return(ctxt->errNo);
+
+ if ((ctxt->input != NULL) &&
+ (((ctxt->input->end - ctxt->input->cur) > XML_MAX_LOOKUP_LIMIT) ||
+ ((ctxt->input->cur - ctxt->input->base) > XML_MAX_LOOKUP_LIMIT)) &&
+ ((ctxt->options & XML_PARSE_HUGE) == 0)) {
+ xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR, "Huge input lookup");
+ xmlHaltParser(ctxt);
+ }
+ if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
+ return(ctxt->errNo);
+
+ if (remain != 0) {
+ chunk += size;
+ size = remain;
+ remain = 0;
+ goto xmldecl_done;
+ }
if ((end_in_lf == 1) && (ctxt->input != NULL) &&
(ctxt->input->buf != NULL)) {
+ size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer,
+ ctxt->input);
+ size_t current = ctxt->input->cur - ctxt->input->base;
+
xmlParserInputBufferPush(ctxt->input->buf, 1, "\r");
+
+ xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input,
+ base, current);
}
- if ((ctxt->errNo != XML_ERR_OK) && (ctxt->disableSAX == 1))
- return(ctxt->errNo);
if (terminate) {
/*
* Check for termination
*/
- int avail = 0;
+ int cur_avail = 0;
if (ctxt->input != NULL) {
if (ctxt->input->buf == NULL)
- avail = ctxt->input->length -
- (ctxt->input->cur - ctxt->input->base);
+ cur_avail = ctxt->input->length -
+ (ctxt->input->cur - ctxt->input->base);
else
- avail = ctxt->input->buf->buffer->use -
- (ctxt->input->cur - ctxt->input->base);
+ cur_avail = xmlBufUse(ctxt->input->buf->buffer) -
+ (ctxt->input->cur - ctxt->input->base);
}
-
+
if ((ctxt->instate != XML_PARSER_EOF) &&
(ctxt->instate != XML_PARSER_EPILOG)) {
xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
- }
- if ((ctxt->instate == XML_PARSER_EPILOG) && (avail > 0)) {
+ }
+ if ((ctxt->instate == XML_PARSER_EPILOG) && (cur_avail > 0)) {
xmlFatalErr(ctxt, XML_ERR_DOCUMENT_END, NULL);
}
if (ctxt->instate != XML_PARSER_EOF) {
@@ -10602,12 +12511,15 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
}
ctxt->instate = XML_PARSER_EOF;
}
- return((xmlParserErrors) ctxt->errNo);
+ if (ctxt->wellFormed == 0)
+ return((xmlParserErrors) ctxt->errNo);
+ else
+ return(0);
}
/************************************************************************
* *
- * I/O front end functions to the parser *
+ * I/O front end functions to the parser *
* *
************************************************************************/
@@ -10631,7 +12543,7 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
*/
xmlParserCtxtPtr
-xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
+xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
const char *chunk, int size, const char *filename) {
xmlParserCtxtPtr ctxt;
xmlParserInputPtr inputStream;
@@ -10680,7 +12592,7 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
if (user_data != NULL)
ctxt->userData = user_data;
- }
+ }
if (filename == NULL) {
ctxt->directory = NULL;
} else {
@@ -10706,11 +12618,7 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
}
}
inputStream->buf = buf;
- inputStream->base = inputStream->buf->buffer->content;
- inputStream->cur = inputStream->buf->buffer->content;
- inputStream->end =
- &inputStream->buf->buffer->content[inputStream->buf->buffer->use];
-
+ xmlBufResetInput(inputStream->buf->buffer, inputStream);
inputPush(ctxt, inputStream);
/*
@@ -10721,15 +12629,12 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
if ((size == 0) || (chunk == NULL)) {
ctxt->charset = XML_CHAR_ENCODING_NONE;
} else if ((ctxt->input != NULL) && (ctxt->input->buf != NULL)) {
- int base = ctxt->input->base - ctxt->input->buf->buffer->content;
- int cur = ctxt->input->cur - ctxt->input->base;
+ size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
+ size_t cur = ctxt->input->cur - ctxt->input->base;
- xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
+ xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
- ctxt->input->base = ctxt->input->buf->buffer->content + base;
- ctxt->input->cur = ctxt->input->base + cur;
- ctxt->input->end =
- &ctxt->input->buf->buffer->content[ctxt->input->buf->buffer->use];
+ xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
#endif
@@ -10744,24 +12649,47 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
#endif /* LIBXML_PUSH_ENABLED */
/**
- * xmlStopParser:
+ * xmlHaltParser:
* @ctxt: an XML parser context
*
- * Blocks further parser processing
+ * Blocks further parser processing don't override error
+ * for internal use
*/
-void
-xmlStopParser(xmlParserCtxtPtr ctxt) {
+static void
+xmlHaltParser(xmlParserCtxtPtr ctxt) {
if (ctxt == NULL)
return;
ctxt->instate = XML_PARSER_EOF;
ctxt->disableSAX = 1;
if (ctxt->input != NULL) {
+ /*
+ * in case there was a specific allocation deallocate before
+ * overriding base
+ */
+ if (ctxt->input->free != NULL) {
+ ctxt->input->free((xmlChar *) ctxt->input->base);
+ ctxt->input->free = NULL;
+ }
ctxt->input->cur = BAD_CAST"";
ctxt->input->base = ctxt->input->cur;
}
}
/**
+ * xmlStopParser:
+ * @ctxt: an XML parser context
+ *
+ * Blocks further parser processing
+ */
+void
+xmlStopParser(xmlParserCtxtPtr ctxt) {
+ if (ctxt == NULL)
+ return;
+ xmlHaltParser(ctxt);
+ ctxt->errNo = XML_ERR_USER_STOP;
+}
+
+/**
* xmlCreateIOParserCtxt:
* @sax: a SAX handler
* @user_data: The user data returned on SAX callbacks
@@ -10782,11 +12710,15 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
xmlParserCtxtPtr ctxt;
xmlParserInputPtr inputStream;
xmlParserInputBufferPtr buf;
-
+
if (ioread == NULL) return(NULL);
buf = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, enc);
- if (buf == NULL) return(NULL);
+ if (buf == NULL) {
+ if (ioclose != NULL)
+ ioclose(ioctx);
+ return (NULL);
+ }
ctxt = xmlNewParserCtxt();
if (ctxt == NULL) {
@@ -10811,7 +12743,7 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
memcpy(ctxt->sax, sax, sizeof(xmlSAXHandlerV1));
if (user_data != NULL)
ctxt->userData = user_data;
- }
+ }
inputStream = xmlNewIOInputStream(ctxt, buf, enc);
if (inputStream == NULL) {
@@ -10826,7 +12758,7 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
#ifdef LIBXML_VALID_ENABLED
/************************************************************************
* *
- * Front ends when parsing a DTD *
+ * Front ends when parsing a DTD *
* *
************************************************************************/
@@ -10837,7 +12769,7 @@ xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
* @enc: the charset encoding if known
*
* Load and parse a DTD
- *
+ *
* Returns the resulting xmlDtdPtr or NULL in case of error.
* @input will be freed by the function in any case.
*/
@@ -10859,10 +12791,13 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
return(NULL);
}
+ /* We are loading a DTD */
+ ctxt->options |= XML_PARSE_DTDLOAD;
+
/*
* Set-up the SAX context
*/
- if (sax != NULL) {
+ if (sax != NULL) {
if (ctxt->sax != NULL)
xmlFree(ctxt->sax);
ctxt->sax = sax;
@@ -10885,7 +12820,11 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
/*
* plug some encoding conversion routines here.
*/
- xmlPushInput(ctxt, pinput);
+ if (xmlPushInput(ctxt, pinput) < 0) {
+ if (sax != NULL) ctxt->sax = NULL;
+ xmlFreeParserCtxt(ctxt);
+ return(NULL);
+ }
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
@@ -10902,12 +12841,17 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
*/
ctxt->inSubset = 2;
ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
+ if (ctxt->myDoc == NULL) {
+ xmlErrMemory(ctxt, "New Doc failed");
+ return(NULL);
+ }
+ ctxt->myDoc->properties = XML_DOC_INTERNAL;
ctxt->myDoc->extSubset = xmlNewDtd(ctxt->myDoc, BAD_CAST "none",
BAD_CAST "none", BAD_CAST "none");
if ((enc == XML_CHAR_ENCODING_NONE) &&
((ctxt->input->end - ctxt->input->cur) >= 4)) {
- /*
+ /*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
@@ -10946,7 +12890,7 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
}
if (sax != NULL) ctxt->sax = NULL;
xmlFreeParserCtxt(ctxt);
-
+
return(ret);
}
@@ -10957,7 +12901,7 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
* @SystemID: a NAME* containing the URL to the DTD
*
* Load and parse an external subset.
- *
+ *
* Returns the resulting xmlDtdPtr or NULL in case of error.
*/
@@ -10977,16 +12921,19 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
return(NULL);
}
+ /* We are loading a DTD */
+ ctxt->options |= XML_PARSE_DTDLOAD;
+
/*
* Set-up the SAX context
*/
- if (sax != NULL) {
+ if (sax != NULL) {
if (ctxt->sax != NULL)
xmlFree(ctxt->sax);
ctxt->sax = sax;
ctxt->userData = ctxt;
}
-
+
/*
* Canonicalise the system ID
*/
@@ -11014,7 +12961,13 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
/*
* plug some encoding conversion routines here.
*/
- xmlPushInput(ctxt, input);
+ if (xmlPushInput(ctxt, input) < 0) {
+ if (sax != NULL) ctxt->sax = NULL;
+ xmlFreeParserCtxt(ctxt);
+ if (systemIdCanonic != NULL)
+ xmlFree(systemIdCanonic);
+ return(NULL);
+ }
if ((ctxt->input->end - ctxt->input->cur) >= 4) {
enc = xmlDetectCharEncoding(ctxt->input->cur, 4);
xmlSwitchEncoding(ctxt, enc);
@@ -11035,6 +12988,13 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
*/
ctxt->inSubset = 2;
ctxt->myDoc = xmlNewDoc(BAD_CAST "1.0");
+ if (ctxt->myDoc == NULL) {
+ xmlErrMemory(ctxt, "New Doc failed");
+ if (sax != NULL) ctxt->sax = NULL;
+ xmlFreeParserCtxt(ctxt);
+ return(NULL);
+ }
+ ctxt->myDoc->properties = XML_DOC_INTERNAL;
ctxt->myDoc->extSubset = xmlNewDtd(ctxt->myDoc, BAD_CAST "none",
ExternalID, SystemID);
xmlParseExternalSubset(ctxt, ExternalID, SystemID);
@@ -11061,7 +13021,7 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
}
if (sax != NULL) ctxt->sax = NULL;
xmlFreeParserCtxt(ctxt);
-
+
return(ret);
}
@@ -11072,7 +13032,7 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
* @SystemID: a NAME* containing the URL to the DTD
*
* Load and parse an external subset.
- *
+ *
* Returns the resulting xmlDtdPtr or NULL in case of error.
*/
@@ -11084,7 +13044,7 @@ xmlParseDTD(const xmlChar *ExternalID, const xmlChar *SystemID) {
/************************************************************************
* *
- * Front ends when parsing an Entity *
+ * Front ends when parsing an Entity *
* *
************************************************************************/
@@ -11115,12 +13075,11 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
int ret = 0;
xmlChar start[4];
xmlCharEncoding enc;
- xmlParserInputPtr inputStream;
- char *directory = NULL;
if (ctx == NULL) return(-1);
- if (ctx->depth > 40) {
+ if (((ctx->depth > 40) && ((ctx->options & XML_PARSE_HUGE) == 0)) ||
+ (ctx->depth > 1024)) {
return(XML_ERR_ENTITY_LOOP);
}
@@ -11131,27 +13090,11 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
if (ctx->myDoc == NULL) /* @@ relax but check for dereferences */
return(-1);
- ctxt = xmlNewParserCtxt();
+ ctxt = xmlCreateEntityParserCtxtInternal(URL, ID, NULL, ctx);
if (ctxt == NULL) {
return(-1);
}
-
- ctxt->userData = ctxt;
- ctxt->_private = ctx->_private;
-
- inputStream = xmlLoadExternalEntity((char *)URL, (char *)ID, ctxt);
- if (inputStream == NULL) {
- xmlFreeParserCtxt(ctxt);
- return(-1);
- }
-
- inputPush(ctxt, inputStream);
- if ((ctxt->directory == NULL) && (directory == NULL))
- directory = xmlParserGetDirectory((char *)URL);
- if ((ctxt->directory == NULL) && (directory != NULL))
- ctxt->directory = directory;
-
oldsax = ctxt->sax;
ctxt->sax = ctx->sax;
xmlDetectSAX2(ctxt);
@@ -11160,6 +13103,7 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
xmlFreeParserCtxt(ctxt);
return(-1);
}
+ newDoc->properties = XML_DOC_INTERNAL;
if (ctx->myDoc->dict) {
newDoc->dict = ctx->myDoc->dict;
xmlDictReference(newDoc->dict);
@@ -11189,7 +13133,7 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
newDoc->children->doc = ctx->myDoc;
}
- /*
+ /*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
@@ -11211,9 +13155,27 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
*/
if ((CMP5(CUR_PTR, '<', '?', 'x', 'm', 'l')) && (IS_BLANK_CH(NXT(5)))) {
xmlParseTextDecl(ctxt);
+ /*
+ * An XML-1.0 document can't reference an entity not XML-1.0
+ */
+ if ((xmlStrEqual(ctx->version, BAD_CAST "1.0")) &&
+ (!xmlStrEqual(ctxt->input->version, BAD_CAST "1.0"))) {
+ xmlFatalErrMsg(ctxt, XML_ERR_VERSION_MISMATCH,
+ "Version mismatch between document and entity\n");
+ }
}
/*
+ * If the user provided its own SAX callbacks then reuse the
+ * useData callback field, otherwise the expected setup in a
+ * DOM builder is to have userData == ctxt
+ */
+ if (ctx->userData == ctx)
+ ctxt->userData = ctxt;
+ else
+ ctxt->userData = ctx->userData;
+
+ /*
* Doing validity checking on chunk doesn't make sense
*/
ctxt->instate = XML_PARSER_CONTENT;
@@ -11244,7 +13206,7 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
ctxt->linenumbers = ctx->linenumbers;
xmlParseContent(ctxt);
-
+
ctx->validate = ctxt->validate;
ctx->valid = ctxt->valid;
if ((RAW == '<') && (NXT(1) == '/')) {
@@ -11287,7 +13249,7 @@ xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx, const xmlChar *URL,
newDoc->intSubset = NULL;
newDoc->extSubset = NULL;
xmlFreeDoc(newDoc);
-
+
return(ret);
}
@@ -11321,12 +13283,12 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
xmlChar start[4];
xmlCharEncoding enc;
- if (depth > 40) {
+ if (((depth > 40) &&
+ ((oldctxt == NULL) || (oldctxt->options & XML_PARSE_HUGE) == 0)) ||
+ (depth > 1024)) {
return(XML_ERR_ENTITY_LOOP);
}
-
-
if (list != NULL)
*list = NULL;
if ((URL == NULL) && (ID == NULL))
@@ -11335,7 +13297,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
return(XML_ERR_INTERNAL_ERROR);
- ctxt = xmlCreateEntityParserCtxt(URL, ID, NULL);
+ ctxt = xmlCreateEntityParserCtxtInternal(URL, ID, NULL, oldctxt);
if (ctxt == NULL) return(XML_WAR_UNDECLARED_ENTITY);
ctxt->userData = ctxt;
if (oldctxt != NULL) {
@@ -11372,6 +13334,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
xmlFreeParserCtxt(ctxt);
return(XML_ERR_INTERNAL_ERROR);
}
+ newDoc->properties = XML_DOC_INTERNAL;
newDoc->intSubset = doc->intSubset;
newDoc->extSubset = doc->extSubset;
newDoc->dict = doc->dict;
@@ -11398,7 +13361,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
ctxt->myDoc = doc;
newRoot->doc = doc;
- /*
+ /*
* Get the 4 first bytes and decode the charset
* if enc != XML_CHAR_ENCODING_NONE
* plug some encoding conversion routines.
@@ -11426,7 +13389,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
ctxt->depth = depth;
xmlParseContent(ctxt);
-
+
if ((RAW == '<') && (NXT(1) == '/')) {
xmlFatalErr(ctxt, XML_ERR_NOT_WELL_BALANCED, NULL);
} else if (RAW != 0) {
@@ -11459,11 +13422,34 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
}
ret = XML_ERR_OK;
}
- if (sax != NULL)
+
+ /*
+ * Record in the parent context the number of entities replacement
+ * done when parsing that reference.
+ */
+ if (oldctxt != NULL)
+ oldctxt->nbentities += ctxt->nbentities;
+
+ /*
+ * Also record the size of the entity parsed
+ */
+ if (ctxt->input != NULL && oldctxt != NULL) {
+ oldctxt->sizeentities += ctxt->input->consumed;
+ oldctxt->sizeentities += (ctxt->input->cur - ctxt->input->base);
+ }
+ /*
+ * And record the last error if any
+ */
+ if (ctxt->lastError.code != XML_ERR_OK)
+ xmlCopyError(&ctxt->lastError, &oldctxt->lastError);
+
+ if (sax != NULL)
ctxt->sax = oldsax;
- oldctxt->node_seq.maximum = ctxt->node_seq.maximum;
- oldctxt->node_seq.length = ctxt->node_seq.length;
- oldctxt->node_seq.buffer = ctxt->node_seq.buffer;
+ if (oldctxt != NULL) {
+ oldctxt->node_seq.maximum = ctxt->node_seq.maximum;
+ oldctxt->node_seq.length = ctxt->node_seq.length;
+ oldctxt->node_seq.buffer = ctxt->node_seq.buffer;
+ }
ctxt->node_seq.maximum = 0;
ctxt->node_seq.length = 0;
ctxt->node_seq.buffer = NULL;
@@ -11471,7 +13457,7 @@ xmlParseExternalEntityPrivate(xmlDocPtr doc, xmlParserCtxtPtr oldctxt,
newDoc->intSubset = NULL;
newDoc->extSubset = NULL;
xmlFreeDoc(newDoc);
-
+
return(ret);
}
@@ -11548,9 +13534,9 @@ xmlParseBalancedChunkMemory(xmlDocPtr doc, xmlSAXHandlerPtr sax,
*
* Returns XML_ERR_OK if the chunk is well balanced, 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.
+ * the parsed chunk is not well balanced.
*/
static xmlParserErrors
xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
@@ -11563,8 +13549,12 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
xmlNodePtr last = NULL;
int size;
xmlParserErrors ret = XML_ERR_OK;
+#ifdef SAX2
+ int i;
+#endif
- if (oldctxt->depth > 40) {
+ if (((oldctxt->depth > 40) && ((oldctxt->options & XML_PARSE_HUGE) == 0)) ||
+ (oldctxt->depth > 1024)) {
return(XML_ERR_ENTITY_LOOP);
}
@@ -11588,12 +13578,19 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
ctxt->str_xmlns = xmlDictLookup(ctxt->dict, BAD_CAST "xmlns", 5);
ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
+#ifdef SAX2
+ /* propagate namespaces down the entity */
+ for (i = 0;i < oldctxt->nsNr;i += 2) {
+ nsPush(ctxt, oldctxt->nsTab[i], oldctxt->nsTab[i+1]);
+ }
+#endif
+
oldsax = ctxt->sax;
ctxt->sax = oldctxt->sax;
xmlDetectSAX2(ctxt);
ctxt->replaceEntities = oldctxt->replaceEntities;
ctxt->options = oldctxt->options;
-
+
ctxt->_private = oldctxt->_private;
if (oldctxt->myDoc == NULL) {
newDoc = xmlNewDoc(BAD_CAST "1.0");
@@ -11603,6 +13600,7 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
xmlFreeParserCtxt(ctxt);
return(XML_ERR_INTERNAL_ERROR);
}
+ newDoc->properties = XML_DOC_INTERNAL;
newDoc->dict = ctxt->dict;
xmlDictReference(newDoc->dict);
ctxt->myDoc = newDoc;
@@ -11658,7 +13656,7 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
} else {
ret = XML_ERR_OK;
}
-
+
if ((lst != NULL) && (ret == XML_ERR_OK)) {
xmlNodePtr cur;
@@ -11687,7 +13685,20 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
ctxt->myDoc->children = content;
ctxt->myDoc->last = last;
}
-
+
+ /*
+ * Record in the parent context the number of entities replacement
+ * done when parsing that reference.
+ */
+ if (oldctxt != NULL)
+ oldctxt->nbentities += ctxt->nbentities;
+
+ /*
+ * Also record the last error if any
+ */
+ if (ctxt->lastError.code != XML_ERR_OK)
+ xmlCopyError(&ctxt->lastError, &oldctxt->lastError);
+
ctxt->sax = oldsax;
ctxt->dict = NULL;
ctxt->attsDefault = NULL;
@@ -11696,7 +13707,7 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt,
if (newDoc != NULL) {
xmlFreeDoc(newDoc);
}
-
+
return(ret);
}
@@ -11770,22 +13781,22 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
if (doc->type == XML_DOCUMENT_NODE)
ctxt = xmlCreateMemoryParserCtxt((char *) data, datalen);
#ifdef LIBXML_HTML_ENABLED
- else if (doc->type == XML_HTML_DOCUMENT_NODE)
+ else if (doc->type == XML_HTML_DOCUMENT_NODE) {
ctxt = htmlCreateMemoryParserCtxt((char *) data, datalen);
+ /*
+ * When parsing in context, it makes no sense to add implied
+ * elements like html/body/etc...
+ */
+ options |= HTML_PARSE_NOIMPLIED;
+ }
#endif
else
return(XML_ERR_INTERNAL_ERROR);
if (ctxt == NULL)
return(XML_ERR_NO_MEMORY);
- fake = xmlNewComment(NULL);
- if (fake == NULL) {
- xmlFreeParserCtxt(ctxt);
- return(XML_ERR_NO_MEMORY);
- }
- xmlAddChild(node, fake);
- /*
+ /*
* Use input doc's dict if present, else assure XML_PARSE_NODICT is set.
* We need a dictionary for xmlDetectSAX2, so if there's no doc dict
* we must wait until the last moment to free the original one.
@@ -11797,9 +13808,33 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
} else
options |= XML_PARSE_NODICT;
- xmlCtxtUseOptions(ctxt, options);
+ if (doc->encoding != NULL) {
+ xmlCharEncodingHandlerPtr hdlr;
+
+ if (ctxt->encoding != NULL)
+ xmlFree((xmlChar *) ctxt->encoding);
+ ctxt->encoding = xmlStrdup((const xmlChar *) doc->encoding);
+
+ hdlr = xmlFindCharEncodingHandler((const char *) doc->encoding);
+ if (hdlr != NULL) {
+ xmlSwitchToEncoding(ctxt, hdlr);
+ } else {
+ return(XML_ERR_UNSUPPORTED_ENCODING);
+ }
+ }
+
+ xmlCtxtUseOptionsInternal(ctxt, options, NULL);
xmlDetectSAX2(ctxt);
ctxt->myDoc = doc;
+ /* parsing in context, i.e. as within existing content */
+ ctxt->instate = XML_PARSER_CONTENT;
+
+ fake = xmlNewComment(NULL);
+ if (fake == NULL) {
+ xmlFreeParserCtxt(ctxt);
+ return(XML_ERR_NO_MEMORY);
+ }
+ xmlAddChild(node, fake);
if (node->type == XML_ELEMENT_NODE) {
nodePush(ctxt, node);
@@ -11828,8 +13863,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
}
cur = cur->parent;
}
- ctxt->instate = XML_PARSER_CONTENT;
- }
+ }
if ((ctxt->validate) || (ctxt->replaceEntities != 0)) {
/*
@@ -11864,12 +13898,12 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
} else {
ret = XML_ERR_OK;
}
-
+
/*
* Return the newly created nodeset after unlinking it from
* the pseudo sibling.
*/
-
+
cur = fake->next;
fake->next = NULL;
node->last = fake;
@@ -11897,7 +13931,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
if (doc->dict != NULL)
ctxt->dict = NULL;
xmlFreeParserCtxt(ctxt);
-
+
return(ret);
#else /* !SAX2 */
return(XML_ERR_INTERNAL_ERROR);
@@ -11925,13 +13959,14 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
*
* 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.
+ * the parsed chunk is not well balanced, assuming the parsing succeeded to
+ * some extent.
*/
int
xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
- void *user_data, int depth, const xmlChar *string, xmlNodePtr *lst,
+ void *user_data, int depth, const xmlChar *string, xmlNodePtr *lst,
int recover) {
xmlParserCtxtPtr ctxt;
xmlDocPtr newDoc;
@@ -11966,6 +14001,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
xmlFreeParserCtxt(ctxt);
return(-1);
}
+ newDoc->properties = XML_DOC_INTERNAL;
if ((doc != NULL) && (doc->dict != NULL)) {
xmlDictFree(ctxt->dict);
ctxt->dict = doc->dict;
@@ -11975,7 +14011,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
ctxt->str_xml_ns = xmlDictLookup(ctxt->dict, XML_XML_NAMESPACE, 36);
ctxt->dictNames = 1;
} else {
- xmlCtxtUseOptions(ctxt, XML_PARSE_NODICT);
+ xmlCtxtUseOptionsInternal(ctxt, XML_PARSE_NODICT, NULL);
}
if (doc != NULL) {
newDoc->intSubset = doc->intSubset;
@@ -12038,7 +14074,7 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
} else {
ret = 0;
}
-
+
if ((lst != NULL) && ((ret == 0) || (recover == 1))) {
xmlNodePtr cur;
@@ -12055,15 +14091,15 @@ xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc, xmlSAXHandlerPtr sax,
}
newDoc->children->children = NULL;
}
-
- if (sax != NULL)
+
+ if (sax != NULL)
ctxt->sax = oldsax;
xmlFreeParserCtxt(ctxt);
newDoc->intSubset = NULL;
newDoc->extSubset = NULL;
newDoc->oldNs = NULL;
xmlFreeDoc(newDoc);
-
+
return(ret);
}
@@ -12111,7 +14147,7 @@ xmlSAXParseEntity(xmlSAXHandlerPtr sax, const char *filename) {
if (sax != NULL)
ctxt->sax = NULL;
xmlFreeParserCtxt(ctxt);
-
+
return(ret);
}
@@ -12135,10 +14171,11 @@ xmlParseEntity(const char *filename) {
#endif /* LIBXML_SAX1_ENABLED */
/**
- * xmlCreateEntityParserCtxt:
+ * xmlCreateEntityParserCtxtInternal:
* @URL: the entity URL
* @ID: the entity PUBLIC ID
* @base: a possible base for the target URI
+ * @pctx: parser context used to set options on new context
*
* Create a parser context for an external entity
* Automatic support for ZLIB/Compress compressed document is provided
@@ -12146,19 +14183,24 @@ xmlParseEntity(const char *filename) {
*
* Returns the new parser context or NULL
*/
-xmlParserCtxtPtr
-xmlCreateEntityParserCtxt(const xmlChar *URL, const xmlChar *ID,
- const xmlChar *base) {
+static xmlParserCtxtPtr
+xmlCreateEntityParserCtxtInternal(const xmlChar *URL, const xmlChar *ID,
+ const xmlChar *base, xmlParserCtxtPtr pctx) {
xmlParserCtxtPtr ctxt;
xmlParserInputPtr inputStream;
char *directory = NULL;
xmlChar *uri;
-
+
ctxt = xmlNewParserCtxt();
if (ctxt == NULL) {
return(NULL);
}
+ if (pctx != NULL) {
+ ctxt->options = pctx->options;
+ ctxt->_private = pctx->_private;
+ }
+
uri = xmlBuildURI(URL, base);
if (uri == NULL) {
@@ -12193,9 +14235,28 @@ xmlCreateEntityParserCtxt(const xmlChar *URL, const xmlChar *ID,
return(ctxt);
}
+/**
+ * xmlCreateEntityParserCtxt:
+ * @URL: the entity URL
+ * @ID: the entity PUBLIC ID
+ * @base: a possible base for the target URI
+ *
+ * Create a parser context for an external entity
+ * Automatic support for ZLIB/Compress compressed document is provided
+ * by default if found at compile-time.
+ *
+ * Returns the new parser context or NULL
+ */
+xmlParserCtxtPtr
+xmlCreateEntityParserCtxt(const xmlChar *URL, const xmlChar *ID,
+ const xmlChar *base) {
+ return xmlCreateEntityParserCtxtInternal(URL, ID, base, NULL);
+
+}
+
/************************************************************************
* *
- * Front ends when parsing from a file *
+ * Front ends when parsing from a file *
* *
************************************************************************/
@@ -12204,7 +14265,7 @@ xmlCreateEntityParserCtxt(const xmlChar *URL, const xmlChar *ID,
* @filename: the filename or URL
* @options: a combination of xmlParserOption
*
- * Create a parser context for a file or URL content.
+ * 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
*
@@ -12224,9 +14285,9 @@ xmlCreateURLParserCtxt(const char *filename, int options)
}
if (options)
- xmlCtxtUseOptions(ctxt, options);
+ xmlCtxtUseOptionsInternal(ctxt, options, NULL);
ctxt->linenumbers = 1;
-
+
inputStream = xmlLoadExternalEntity(filename, NULL, ctxt);
if (inputStream == NULL) {
xmlFreeParserCtxt(ctxt);
@@ -12246,7 +14307,7 @@ xmlCreateURLParserCtxt(const char *filename, int options)
* xmlCreateFileParserCtxt:
* @filename: the filename
*
- * Create a parser context for a file content.
+ * Create a parser context for a file content.
* Automatic support for ZLIB/Compress compressed document is provided
* by default if found at compile-time.
*
@@ -12283,7 +14344,6 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename,
int recovery, void *data) {
xmlDocPtr ret;
xmlParserCtxtPtr ctxt;
- char *directory = NULL;
xmlInitParser();
@@ -12301,10 +14361,8 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename,
ctxt->_private = data;
}
- if ((ctxt->directory == NULL) && (directory == NULL))
- directory = xmlParserGetDirectory(filename);
- if ((ctxt->directory == NULL) && (directory != NULL))
- ctxt->directory = (char *) xmlStrdup((xmlChar *) directory);
+ if (ctxt->directory == NULL)
+ ctxt->directory = xmlParserGetDirectory(filename);
ctxt->recovery = recovery;
@@ -12327,7 +14385,7 @@ xmlSAXParseFileWithData(xmlSAXHandlerPtr sax, const char *filename,
if (sax != NULL)
ctxt->sax = NULL;
xmlFreeParserCtxt(ctxt);
-
+
return(ret);
}
@@ -12357,13 +14415,14 @@ xmlSAXParseFile(xmlSAXHandlerPtr sax, const char *filename,
* @cur: a pointer to an array of xmlChar
*
* parse an XML in-memory document and build a tree.
- * In the case the document is not Well Formed, a tree is built anyway
- *
- * Returns the resulting document tree
+ * In the case the document is not Well Formed, a attempt to build a
+ * tree is tried anyway
+ *
+ * Returns the resulting document tree or NULL in case of failure
*/
xmlDocPtr
-xmlRecoverDoc(xmlChar *cur) {
+xmlRecoverDoc(const xmlChar *cur) {
return(xmlSAXParseDoc(NULL, cur, 1));
}
@@ -12389,9 +14448,10 @@ xmlParseFile(const char *filename) {
*
* parse an XML file and build a tree. Automatic support for ZLIB/Compress
* compressed document is provided by default if found at compile-time.
- * In the case the document is not Well Formed, a tree is built anyway
+ * In the case the document is not Well Formed, it attempts to build
+ * a tree anyway
*
- * Returns the resulting document tree
+ * Returns the resulting document tree or NULL in case of failure
*/
xmlDocPtr
@@ -12425,7 +14485,7 @@ xmlSetupParserForBuffer(xmlParserCtxtPtr ctxt, const xmlChar* buffer,
xmlClearParserCtxt(ctxt);
return;
}
-
+
xmlClearParserCtxt(ctxt);
if (filename != NULL)
input->filename = (char *) xmlCanonicPath((const xmlChar *)filename);
@@ -12443,7 +14503,7 @@ xmlSetupParserForBuffer(xmlParserCtxtPtr ctxt, const xmlChar* buffer,
*
* parse an XML file and call the given SAX handler routines.
* Automatic support for ZLIB/Compress compressed document is provided
- *
+ *
* Returns 0 in case of success or a error number otherwise
*/
int
@@ -12451,21 +14511,19 @@ xmlSAXUserParseFile(xmlSAXHandlerPtr sax, void *user_data,
const char *filename) {
int ret = 0;
xmlParserCtxtPtr ctxt;
-
+
ctxt = xmlCreateFileParserCtxt(filename);
if (ctxt == NULL) return -1;
-#ifdef LIBXML_SAX1_ENABLED
if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
-#endif /* LIBXML_SAX1_ENABLED */
xmlFree(ctxt->sax);
ctxt->sax = sax;
xmlDetectSAX2(ctxt);
if (user_data != NULL)
ctxt->userData = user_data;
-
+
xmlParseDocument(ctxt);
-
+
if (ctxt->wellFormed)
ret = 0;
else {
@@ -12481,14 +14539,14 @@ xmlSAXUserParseFile(xmlSAXHandlerPtr sax, void *user_data,
ctxt->myDoc = NULL;
}
xmlFreeParserCtxt(ctxt);
-
+
return ret;
}
#endif /* LIBXML_SAX1_ENABLED */
/************************************************************************
* *
- * Front ends when parsing from memory *
+ * Front ends when parsing from memory *
* *
************************************************************************/
@@ -12532,9 +14590,7 @@ xmlCreateMemoryParserCtxt(const char *buffer, int size) {
input->filename = NULL;
input->buf = buf;
- input->base = input->buf->buffer->content;
- input->cur = input->buf->buffer->content;
- input->end = &input->buf->buffer->content[input->buf->buffer->use];
+ xmlBufResetInput(input->buf->buffer, input);
inputPush(ctxt, input);
return(ctxt);
@@ -12566,6 +14622,8 @@ xmlSAXParseMemoryWithData(xmlSAXHandlerPtr sax, const char *buffer,
xmlDocPtr ret;
xmlParserCtxtPtr ctxt;
+ xmlInitParser();
+
ctxt = xmlCreateMemoryParserCtxt(buffer, size);
if (ctxt == NULL) return(NULL);
if (sax != NULL) {
@@ -12588,10 +14646,10 @@ xmlSAXParseMemoryWithData(xmlSAXHandlerPtr sax, const char *buffer,
xmlFreeDoc(ctxt->myDoc);
ctxt->myDoc = NULL;
}
- if (sax != NULL)
+ if (sax != NULL)
ctxt->sax = NULL;
xmlFreeParserCtxt(ctxt);
-
+
return(ret);
}
@@ -12606,7 +14664,7 @@ xmlSAXParseMemoryWithData(xmlSAXHandlerPtr sax, const char *buffer,
* parse an XML in-memory block and use the given SAX function block
* to handle the parsing callback. If sax is NULL, fallback to the default
* DOM tree building routines.
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -12621,7 +14679,7 @@ xmlSAXParseMemory(xmlSAXHandlerPtr sax, const char *buffer,
* @size: the size of the array
*
* parse an XML in-memory block and build a tree.
- *
+ *
* Returns the resulting document tree
*/
@@ -12635,9 +14693,10 @@ xmlDocPtr xmlParseMemory(const char *buffer, int size) {
* @size: the size of the array
*
* parse an XML in-memory block and build a tree.
- * In the case the document is not Well Formed, a tree is built anyway
- *
- * Returns the resulting document tree
+ * In the case the document is not Well Formed, an attempt to
+ * build a tree is tried anyway
+ *
+ * Returns the resulting document tree or NULL in case of error
*/
xmlDocPtr xmlRecoverMemory(const char *buffer, int size) {
@@ -12653,26 +14712,28 @@ xmlDocPtr xmlRecoverMemory(const char *buffer, int size) {
*
* A better SAX parsing routine.
* parse an XML in-memory buffer and call the given SAX handler routines.
- *
+ *
* Returns 0 in case of success or a error number otherwise
*/
int xmlSAXUserParseMemory(xmlSAXHandlerPtr sax, void *user_data,
const char *buffer, int size) {
int ret = 0;
xmlParserCtxtPtr ctxt;
- xmlSAXHandlerPtr oldsax = NULL;
-
- if (sax == NULL) return -1;
+
+ xmlInitParser();
+
ctxt = xmlCreateMemoryParserCtxt(buffer, size);
if (ctxt == NULL) return -1;
- oldsax = ctxt->sax;
+ if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
+ xmlFree(ctxt->sax);
ctxt->sax = sax;
xmlDetectSAX2(ctxt);
+
if (user_data != NULL)
ctxt->userData = user_data;
-
+
xmlParseDocument(ctxt);
-
+
if (ctxt->wellFormed)
ret = 0;
else {
@@ -12681,13 +14742,14 @@ int xmlSAXUserParseMemory(xmlSAXHandlerPtr sax, void *user_data,
else
ret = -1;
}
- ctxt->sax = oldsax;
+ if (sax != NULL)
+ ctxt->sax = NULL;
if (ctxt->myDoc != NULL) {
xmlFreeDoc(ctxt->myDoc);
ctxt->myDoc = NULL;
}
xmlFreeParserCtxt(ctxt);
-
+
return ret;
}
#endif /* LIBXML_SAX1_ENABLED */
@@ -12721,7 +14783,7 @@ xmlCreateDocParserCtxt(const xmlChar *cur) {
* parse an XML in-memory document and build a tree.
* It use the given SAX function block to handle the parsing callback.
* If sax is NULL, fallback to the default DOM tree building routines.
- *
+ *
* Returns the resulting document tree
*/
@@ -12736,7 +14798,7 @@ xmlSAXParseDoc(xmlSAXHandlerPtr sax, const xmlChar *cur, int recovery) {
ctxt = xmlCreateDocParserCtxt(cur);
if (ctxt == NULL) return(NULL);
- if (sax != NULL) {
+ if (sax != NULL) {
oldsax = ctxt->sax;
ctxt->sax = sax;
ctxt->userData = NULL;
@@ -12753,7 +14815,7 @@ xmlSAXParseDoc(xmlSAXHandlerPtr sax, const xmlChar *cur, int recovery) {
if (sax != NULL)
ctxt->sax = oldsax;
xmlFreeParserCtxt(ctxt);
-
+
return(ret);
}
@@ -12762,7 +14824,7 @@ xmlSAXParseDoc(xmlSAXHandlerPtr sax, const xmlChar *cur, int recovery) {
* @cur: a pointer to an array of xmlChar
*
* parse an XML in-memory document and build a tree.
- *
+ *
* Returns the resulting document tree
*/
@@ -12775,8 +14837,8 @@ xmlParseDoc(const xmlChar *cur) {
#ifdef LIBXML_LEGACY_ENABLED
/************************************************************************
* *
- * Specific function to keep track of entities references *
- * and used by the XSLT debugger *
+ * Specific function to keep track of entities references *
+ * and used by the XSLT debugger *
* *
************************************************************************/
@@ -12786,7 +14848,7 @@ static xmlEntityReferenceFunc xmlEntityRefFunc = NULL;
* xmlAddEntityReference:
* @ent : A valid entity
* @firstNode : A valid first node for children of entity
- * @lastNode : A valid last node of children entity
+ * @lastNode : A valid last node of children entity
*
* Notify of a reference to an entity of type XML_EXTERNAL_GENERAL_PARSED_ENTITY
*/
@@ -12815,7 +14877,7 @@ xmlSetEntityReferenceFunc(xmlEntityReferenceFunc func)
/************************************************************************
* *
- * Miscellaneous *
+ * Miscellaneous *
* *
************************************************************************/
@@ -12839,37 +14901,57 @@ xmlInitParser(void) {
if (xmlParserInitialized != 0)
return;
- if ((xmlGenericError == xmlGenericErrorDefaultFunc) ||
- (xmlGenericError == NULL))
- initGenericErrorDefaultFunc(NULL);
- xmlInitGlobals();
- xmlInitThreads();
- xmlInitMemory();
- xmlInitCharEncodingHandlers();
- xmlDefaultSAXHandlerInit();
- xmlRegisterDefaultInputCallbacks();
+#ifdef LIBXML_THREAD_ENABLED
+ __xmlGlobalInitMutexLock();
+ if (xmlParserInitialized == 0) {
+#endif
+ xmlInitThreads();
+ xmlInitGlobals();
+ if ((xmlGenericError == xmlGenericErrorDefaultFunc) ||
+ (xmlGenericError == NULL))
+ initGenericErrorDefaultFunc(NULL);
+ xmlInitMemory();
+ xmlInitializeDict();
+ xmlInitCharEncodingHandlers();
+ xmlDefaultSAXHandlerInit();
+ xmlRegisterDefaultInputCallbacks();
#ifdef LIBXML_OUTPUT_ENABLED
- xmlRegisterDefaultOutputCallbacks();
+ xmlRegisterDefaultOutputCallbacks();
#endif /* LIBXML_OUTPUT_ENABLED */
#ifdef LIBXML_HTML_ENABLED
- htmlInitAutoClose();
- htmlDefaultSAXHandlerInit();
+ htmlInitAutoClose();
+ htmlDefaultSAXHandlerInit();
#endif
#ifdef LIBXML_XPATH_ENABLED
- xmlXPathInit();
+ xmlXPathInit();
+#endif
+ xmlParserInitialized = 1;
+#ifdef LIBXML_THREAD_ENABLED
+ }
+ __xmlGlobalInitMutexUnlock();
#endif
- xmlParserInitialized = 1;
}
/**
* xmlCleanupParser:
*
- * Cleanup function for the XML library. It tries to reclaim all
- * parsing related global memory allocated for the library processing.
- * It doesn't deallocate any document related memory. Calling this
- * function should not prevent reusing the library but one should
- * call xmlCleanupParser() only when the process has
- * finished using the library or XML document built with it.
+ * This function name is somewhat misleading. It does not clean up
+ * parser state, it cleans up memory allocated by the library itself.
+ * It is a cleanup function for the XML library. It tries to reclaim all
+ * related global memory allocated for the library processing.
+ * It doesn't deallocate any document related memory. One should
+ * call xmlCleanupParser() only when the process has finished using
+ * the library and all XML/HTML documents built with it.
+ * See also xmlInitParser() which has the opposite function of preparing
+ * the library for operations.
+ *
+ * WARNING: if your application is multithreaded or has plugin support
+ * calling this may crash the application if another thread or
+ * a plugin is still using libxml2. It's sometimes very hard to
+ * guess if libxml2 is in use in the application, some libraries
+ * or plugins may use it without notice. In case of doubt abstain
+ * from calling this function or do it just before calling exit()
+ * to avoid leak reports from valgrind !
*/
void
@@ -12890,8 +14972,8 @@ xmlCleanupParser(void) {
xmlSchemaCleanupTypes();
xmlRelaxNGCleanupTypes();
#endif
- xmlCleanupGlobals();
xmlResetLastError();
+ xmlCleanupGlobals();
xmlCleanupThreads(); /* must be last if called not from the main thread */
xmlCleanupMemory();
xmlParserInitialized = 0;
@@ -12911,7 +14993,7 @@ xmlCleanupParser(void) {
* current scope
*/
#define DICT_FREE(str) \
- if ((str) && ((!dict) || \
+ if ((str) && ((!dict) || \
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
xmlFree((char *)(str));
@@ -12926,7 +15008,7 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
{
xmlParserInputPtr input;
xmlDictPtr dict;
-
+
if (ctxt == NULL)
return;
@@ -12939,8 +15021,12 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
ctxt->input = NULL;
ctxt->spaceNr = 0;
- ctxt->spaceTab[0] = -1;
- ctxt->space = &ctxt->spaceTab[0];
+ if (ctxt->spaceTab != NULL) {
+ ctxt->spaceTab[0] = -1;
+ ctxt->space = &ctxt->spaceTab[0];
+ } else {
+ ctxt->space = NULL;
+ }
ctxt->nodeNr = 0;
@@ -12988,6 +15074,9 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
ctxt->depth = 0;
ctxt->charset = XML_CHAR_ENCODING_UTF8;
ctxt->catalogs = NULL;
+ ctxt->nbentities = 0;
+ ctxt->sizeentities = 0;
+ ctxt->sizeentcopy = 0;
xmlInitNodeInfoSeq(&ctxt->node_seq);
if (ctxt->attsDefault != NULL) {
@@ -13072,25 +15161,18 @@ xmlCtxtResetPush(xmlParserCtxtPtr ctxt, const char *chunk,
inputStream->filename = (char *)
xmlCanonicPath((const xmlChar *) filename);
inputStream->buf = buf;
- inputStream->base = inputStream->buf->buffer->content;
- inputStream->cur = inputStream->buf->buffer->content;
- inputStream->end =
- &inputStream->buf->buffer->content[inputStream->buf->buffer->use];
+ xmlBufResetInput(buf->buffer, inputStream);
inputPush(ctxt, inputStream);
if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) &&
(ctxt->input->buf != NULL)) {
- int base = ctxt->input->base - ctxt->input->buf->buffer->content;
- int cur = ctxt->input->cur - ctxt->input->base;
+ size_t base = xmlBufGetInputBase(ctxt->input->buf->buffer, ctxt->input);
+ size_t cur = ctxt->input->cur - ctxt->input->base;
xmlParserInputBufferPush(ctxt->input->buf, size, chunk);
- ctxt->input->base = ctxt->input->buf->buffer->content + base;
- ctxt->input->cur = ctxt->input->base + cur;
- ctxt->input->end =
- &ctxt->input->buf->buffer->content[ctxt->input->buf->buffer->
- use];
+ xmlBufSetInputBaseCur(ctxt->input->buf->buffer, ctxt->input, base, cur);
#ifdef DEBUG_PUSH
xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
#endif
@@ -13099,6 +15181,10 @@ xmlCtxtResetPush(xmlParserCtxtPtr ctxt, const char *chunk,
if (encoding != NULL) {
xmlCharEncodingHandlerPtr hdlr;
+ if (ctxt->encoding != NULL)
+ xmlFree((xmlChar *) ctxt->encoding);
+ ctxt->encoding = xmlStrdup((const xmlChar *) encoding);
+
hdlr = xmlFindCharEncodingHandler(encoding);
if (hdlr != NULL) {
xmlSwitchToEncoding(ctxt, hdlr);
@@ -13113,50 +15199,63 @@ xmlCtxtResetPush(xmlParserCtxtPtr ctxt, const char *chunk,
return(0);
}
+
/**
- * xmlCtxtUseOptions:
+ * xmlCtxtUseOptionsInternal:
* @ctxt: an XML parser context
* @options: a combination of xmlParserOption
+ * @encoding: the user provided encoding to use
*
* Applies the options to the parser context
*
* Returns 0 in case of success, the set of unknown or unimplemented options
* in case of error.
*/
-int
-xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
+static int
+xmlCtxtUseOptionsInternal(xmlParserCtxtPtr ctxt, int options, const char *encoding)
{
if (ctxt == NULL)
return(-1);
+ if (encoding != NULL) {
+ if (ctxt->encoding != NULL)
+ xmlFree((xmlChar *) ctxt->encoding);
+ ctxt->encoding = xmlStrdup((const xmlChar *) encoding);
+ }
if (options & XML_PARSE_RECOVER) {
ctxt->recovery = 1;
options -= XML_PARSE_RECOVER;
+ ctxt->options |= XML_PARSE_RECOVER;
} else
ctxt->recovery = 0;
if (options & XML_PARSE_DTDLOAD) {
ctxt->loadsubset = XML_DETECT_IDS;
options -= XML_PARSE_DTDLOAD;
+ ctxt->options |= XML_PARSE_DTDLOAD;
} else
ctxt->loadsubset = 0;
if (options & XML_PARSE_DTDATTR) {
ctxt->loadsubset |= XML_COMPLETE_ATTRS;
options -= XML_PARSE_DTDATTR;
+ ctxt->options |= XML_PARSE_DTDATTR;
}
if (options & XML_PARSE_NOENT) {
ctxt->replaceEntities = 1;
/* ctxt->loadsubset |= XML_DETECT_IDS; */
options -= XML_PARSE_NOENT;
+ ctxt->options |= XML_PARSE_NOENT;
} else
ctxt->replaceEntities = 0;
if (options & XML_PARSE_PEDANTIC) {
ctxt->pedantic = 1;
options -= XML_PARSE_PEDANTIC;
+ ctxt->options |= XML_PARSE_PEDANTIC;
} else
ctxt->pedantic = 0;
if (options & XML_PARSE_NOBLANKS) {
ctxt->keepBlanks = 0;
ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
options -= XML_PARSE_NOBLANKS;
+ ctxt->options |= XML_PARSE_NOBLANKS;
} else
ctxt->keepBlanks = 1;
if (options & XML_PARSE_DTDVALID) {
@@ -13166,6 +15265,7 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
if (options & XML_PARSE_NOERROR)
ctxt->vctxt.error = NULL;
options -= XML_PARSE_DTDVALID;
+ ctxt->options |= XML_PARSE_DTDVALID;
} else
ctxt->validate = 0;
if (options & XML_PARSE_NOWARNING) {
@@ -13185,17 +15285,20 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
ctxt->sax->endElementNs = NULL;
ctxt->sax->initialized = 1;
options -= XML_PARSE_SAX1;
+ ctxt->options |= XML_PARSE_SAX1;
}
#endif /* LIBXML_SAX1_ENABLED */
if (options & XML_PARSE_NODICT) {
ctxt->dictNames = 0;
options -= XML_PARSE_NODICT;
+ ctxt->options |= XML_PARSE_NODICT;
} else {
ctxt->dictNames = 1;
}
if (options & XML_PARSE_NOCDATA) {
ctxt->sax->cdataBlock = NULL;
options -= XML_PARSE_NOCDATA;
+ ctxt->options |= XML_PARSE_NOCDATA;
}
if (options & XML_PARSE_NSCLEAN) {
ctxt->options |= XML_PARSE_NSCLEAN;
@@ -13209,11 +15312,53 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
ctxt->options |= XML_PARSE_COMPACT;
options -= XML_PARSE_COMPACT;
}
+ if (options & XML_PARSE_OLD10) {
+ ctxt->options |= XML_PARSE_OLD10;
+ options -= XML_PARSE_OLD10;
+ }
+ if (options & XML_PARSE_NOBASEFIX) {
+ ctxt->options |= XML_PARSE_NOBASEFIX;
+ options -= XML_PARSE_NOBASEFIX;
+ }
+ if (options & XML_PARSE_HUGE) {
+ ctxt->options |= XML_PARSE_HUGE;
+ options -= XML_PARSE_HUGE;
+ if (ctxt->dict != NULL)
+ xmlDictSetLimit(ctxt->dict, 0);
+ }
+ if (options & XML_PARSE_OLDSAX) {
+ ctxt->options |= XML_PARSE_OLDSAX;
+ options -= XML_PARSE_OLDSAX;
+ }
+ if (options & XML_PARSE_IGNORE_ENC) {
+ ctxt->options |= XML_PARSE_IGNORE_ENC;
+ options -= XML_PARSE_IGNORE_ENC;
+ }
+ if (options & XML_PARSE_BIG_LINES) {
+ ctxt->options |= XML_PARSE_BIG_LINES;
+ options -= XML_PARSE_BIG_LINES;
+ }
ctxt->linenumbers = 1;
return (options);
}
/**
+ * xmlCtxtUseOptions:
+ * @ctxt: an XML parser context
+ * @options: a combination of xmlParserOption
+ *
+ * Applies the options to the parser context
+ *
+ * Returns 0 in case of success, the set of unknown or unimplemented options
+ * in case of error.
+ */
+int
+xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
+{
+ return(xmlCtxtUseOptionsInternal(ctxt, options, NULL));
+}
+
+/**
* xmlDoRead:
* @ctxt: an XML parser context
* @URL: the base URL to use for the document
@@ -13222,7 +15367,7 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
* @reuse: keep the context for reuse
*
* Common front-end for the xmlRead functions
- *
+ *
* Returns the resulting document tree or NULL
*/
static xmlDocPtr
@@ -13230,8 +15375,8 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding,
int options, int reuse)
{
xmlDocPtr ret;
-
- xmlCtxtUseOptions(ctxt, options);
+
+ xmlCtxtUseOptionsInternal(ctxt, options, encoding);
if (encoding != NULL) {
xmlCharEncodingHandlerPtr hdlr;
@@ -13267,7 +15412,7 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *URL, const char *encoding,
* @options: a combination of xmlParserOption
*
* parse an XML in-memory document and build a tree.
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -13277,6 +15422,7 @@ xmlReadDoc(const xmlChar * cur, const char *URL, const char *encoding, int optio
if (cur == NULL)
return (NULL);
+ xmlInitParser();
ctxt = xmlCreateDocParserCtxt(cur);
if (ctxt == NULL)
@@ -13291,7 +15437,7 @@ xmlReadDoc(const xmlChar * cur, const char *URL, const char *encoding, int optio
* @options: a combination of xmlParserOption
*
* parse an XML file from the filesystem or the network.
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -13299,6 +15445,7 @@ xmlReadFile(const char *filename, const char *encoding, int options)
{
xmlParserCtxtPtr ctxt;
+ xmlInitParser();
ctxt = xmlCreateURLParserCtxt(filename, options);
if (ctxt == NULL)
return (NULL);
@@ -13314,7 +15461,7 @@ xmlReadFile(const char *filename, const char *encoding, int options)
* @options: a combination of xmlParserOption
*
* parse an XML in-memory document and build a tree.
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -13322,6 +15469,7 @@ xmlReadMemory(const char *buffer, int size, const char *URL, const char *encodin
{
xmlParserCtxtPtr ctxt;
+ xmlInitParser();
ctxt = xmlCreateMemoryParserCtxt(buffer, size);
if (ctxt == NULL)
return (NULL);
@@ -13338,7 +15486,7 @@ xmlReadMemory(const char *buffer, int size, const char *URL, const char *encodin
* 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.
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -13350,6 +15498,7 @@ xmlReadFd(int fd, const char *URL, const char *encoding, int options)
if (fd < 0)
return (NULL);
+ xmlInitParser();
input = xmlParserInputBufferCreateFd(fd, XML_CHAR_ENCODING_NONE);
if (input == NULL)
@@ -13380,7 +15529,7 @@ xmlReadFd(int fd, const char *URL, const char *encoding, int options)
* @options: a combination of xmlParserOption
*
* parse an XML document from I/O functions and source and build a tree.
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -13393,11 +15542,15 @@ xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
if (ioread == NULL)
return (NULL);
+ xmlInitParser();
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
XML_CHAR_ENCODING_NONE);
- if (input == NULL)
+ if (input == NULL) {
+ if (ioclose != NULL)
+ ioclose(ioctx);
return (NULL);
+ }
ctxt = xmlNewParserCtxt();
if (ctxt == NULL) {
xmlFreeParserInputBuffer(input);
@@ -13423,7 +15576,7 @@ xmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
*
* parse an XML in-memory document and build a tree.
* This reuses the existing @ctxt parser context
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -13436,6 +15589,7 @@ xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
return (NULL);
if (ctxt == NULL)
return (NULL);
+ xmlInitParser();
xmlCtxtReset(ctxt);
@@ -13456,7 +15610,7 @@ xmlCtxtReadDoc(xmlParserCtxtPtr ctxt, const xmlChar * cur,
*
* parse an XML file from the filesystem or the network.
* This reuses the existing @ctxt parser context
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -13469,6 +15623,7 @@ xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename,
return (NULL);
if (ctxt == NULL)
return (NULL);
+ xmlInitParser();
xmlCtxtReset(ctxt);
@@ -13491,7 +15646,7 @@ xmlCtxtReadFile(xmlParserCtxtPtr ctxt, const char *filename,
*
* parse an XML in-memory document and build a tree.
* This reuses the existing @ctxt parser context
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -13505,6 +15660,7 @@ xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size,
return (NULL);
if (buffer == NULL)
return (NULL);
+ xmlInitParser();
xmlCtxtReset(ctxt);
@@ -13535,7 +15691,7 @@ xmlCtxtReadMemory(xmlParserCtxtPtr ctxt, const char *buffer, int size,
* This reuses the existing @ctxt parser context
* NOTE that the file descriptor will not be closed when the
* reader is closed or reset.
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -13549,6 +15705,7 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd,
return (NULL);
if (ctxt == NULL)
return (NULL);
+ xmlInitParser();
xmlCtxtReset(ctxt);
@@ -13578,7 +15735,7 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd,
*
* parse an XML document from I/O functions and source and build a tree.
* This reuses the existing @ctxt parser context
- *
+ *
* Returns the resulting document tree
*/
xmlDocPtr
@@ -13594,13 +15751,17 @@ xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
return (NULL);
if (ctxt == NULL)
return (NULL);
+ xmlInitParser();
xmlCtxtReset(ctxt);
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
XML_CHAR_ENCODING_NONE);
- if (input == NULL)
+ if (input == NULL) {
+ if (ioclose != NULL)
+ ioclose(ioctx);
return (NULL);
+ }
stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE);
if (stream == NULL) {
xmlFreeParserInputBuffer(input);
diff --git a/gnulib-local/lib/libxml/parser.in.h b/gnulib-local/lib/libxml/parser.in.h
index fe63bda..3f5730d 100644
--- a/gnulib-local/lib/libxml/parser.in.h
+++ b/gnulib-local/lib/libxml/parser.in.h
@@ -80,7 +80,7 @@ struct _xmlParserInput {
* xmlParserNodeInfo:
*
* The parser can be asked to collect Node informations, i.e. at what
- * place in the file they were detected.
+ * place in the file they were detected.
* NOTE: This is off by default and not very well tested.
*/
typedef struct _xmlParserNodeInfo xmlParserNodeInfo;
@@ -125,9 +125,9 @@ typedef enum {
XML_PARSER_ENTITY_VALUE, /* within an entity value in a decl */
XML_PARSER_ATTRIBUTE_VALUE, /* within an attribute value */
XML_PARSER_SYSTEM_LITERAL, /* within a SYSTEM value */
- XML_PARSER_EPILOG, /* the Misc* after the last end tag */
+ XML_PARSER_EPILOG, /* the Misc* after the last end tag */
XML_PARSER_IGNORE, /* within an IGNORED section */
- XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
+ XML_PARSER_PUBLIC_LITERAL /* within a PUBLIC value */
} xmlParserInputState;
/**
@@ -190,7 +190,10 @@ struct _xmlParserCtxt {
const xmlChar *version; /* the XML version string */
const xmlChar *encoding; /* the declared encoding, if any */
int standalone; /* standalone document */
- int html; /* an HTML(1)/Docbook(2) document */
+ int html; /* an HTML(1)/Docbook(2) document
+ * 3 is HTML after <head>
+ * 10 is HTML after <body>
+ */
/* Input stream stack */
xmlParserInputPtr input; /* Current input stream */
@@ -218,7 +221,7 @@ struct _xmlParserCtxt {
xmlValidCtxt vctxt; /* The validity context */
xmlParserInputState instate; /* current type of input */
- int token; /* next char look-ahead */
+ int token; /* next char look-ahead */
char *directory; /* the data directory */
@@ -297,6 +300,17 @@ struct _xmlParserCtxt {
*/
xmlError lastError;
xmlParserMode parseMode; /* the parser mode */
+ unsigned long nbentities; /* number of entities references */
+ unsigned long sizeentities; /* size of parsed 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 */
+ xmlParserNodeInfo *nodeInfoTab; /* array of nodeInfos */
+
+ int input_id; /* we need to label inputs */
+ unsigned long sizeentcopy; /* volume of entity copy */
};
/**
@@ -387,8 +401,8 @@ typedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,
/**
* entityDeclSAXFunc:
* @ctx: the user data (XML parser context)
- * @name: the entity name
- * @type: the entity type
+ * @name: the entity name
+ * @type: the entity type
* @publicId: The public ID of the entity
* @systemId: The system ID of the entity
* @content: the entity value (without processing).
@@ -418,8 +432,8 @@ typedef void (*notationDeclSAXFunc)(void *ctx,
* attributeDeclSAXFunc:
* @ctx: the user data (XML parser context)
* @elem: the name of the element
- * @fullname: the attribute name
- * @type: the attribute type
+ * @fullname: the attribute name
+ * @type: the attribute type
* @def: the type of default value
* @defaultValue: the attribute default value
* @tree: the tree of enumerated value set
@@ -436,8 +450,8 @@ typedef void (*attributeDeclSAXFunc)(void *ctx,
/**
* elementDeclSAXFunc:
* @ctx: the user data (XML parser context)
- * @name: the element name
- * @type: the element type
+ * @name: the element name
+ * @type: the element type
* @content: the element value tree
*
* An element definition has been parsed.
@@ -524,7 +538,7 @@ typedef void (*attributeSAXFunc) (void *ctx,
* @ctx: the user data (XML parser context)
* @name: The entity name
*
- * Called when an entity reference is detected.
+ * Called when an entity reference is detected.
*/
typedef void (*referenceSAXFunc) (void *ctx,
const xmlChar *name);
@@ -588,33 +602,33 @@ typedef void (*cdataBlockSAXFunc) (
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format a warning messages, callback.
*/
typedef void (XMLCDECL *warningSAXFunc) (void *ctx,
- const char *msg, ...);
+ const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
/**
* errorSAXFunc:
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format an error messages, callback.
*/
typedef void (XMLCDECL *errorSAXFunc) (void *ctx,
- const char *msg, ...);
+ const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
/**
* fatalErrorSAXFunc:
* @ctx: an XML parser context
* @msg: the message to display/transmit
* @...: extra parameters for the message display
- *
+ *
* Display and format fatal error messages, callback.
* Note: so far fatalError() SAX callbacks are not used, error()
* get all the callbacks for errors.
*/
typedef void (XMLCDECL *fatalErrorSAXFunc) (void *ctx,
- const char *msg, ...);
+ const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
/**
* isStandaloneSAXFunc:
* @ctx: the user data (XML parser context)
@@ -684,7 +698,7 @@ typedef void (*startElementNsSAX2Func) (void *ctx,
int nb_attributes,
int nb_defaulted,
const xmlChar **attributes);
-
+
/**
* endElementNsSAX2Func:
* @ctx: the user data (XML parser context)
@@ -779,7 +793,7 @@ struct _xmlSAXHandlerV1 {
* xmlExternalEntityLoader:
* @URL: The System ID of the resource requested
* @ID: The Public ID of the resource requested
- * @context: the XML parser context
+ * @context: the XML parser context
*
* External entity loaders types.
*
@@ -805,18 +819,18 @@ extern "C" {
/*
* Init/Cleanup
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlInitParser (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCleanupParser (void);
/*
* Input functions
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParserInputRead (xmlParserInputPtr in,
int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParserInputGrow (xmlParserInputPtr in,
int len);
@@ -824,101 +838,101 @@ XMLPUBFUN int XMLCALL
* Basic parsing Interfaces
*/
#ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlParseDoc (const xmlChar *cur);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlParseFile (const char *filename);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlParseMemory (const char *buffer,
int size);
#endif /* LIBXML_SAX1_ENABLED */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSubstituteEntitiesDefault(int val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlKeepBlanksDefault (int val);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlStopParser (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlPedanticParserDefault(int val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlLineNumbersDefault (int val);
#ifdef LIBXML_SAX1_ENABLED
/*
- * Recovery mode
+ * Recovery mode
*/
-XMLPUBFUN xmlDocPtr XMLCALL
- xmlRecoverDoc (xmlChar *cur);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
+ xmlRecoverDoc (const xmlChar *cur);
+XMLPUBFUN xmlDocPtr XMLCALL
xmlRecoverMemory (const char *buffer,
int size);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlRecoverFile (const char *filename);
#endif /* LIBXML_SAX1_ENABLED */
/*
* Less common routines and SAX interfaces
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseDocument (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseExtParsedEnt (xmlParserCtxtPtr ctxt);
#ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSAXUserParseFile (xmlSAXHandlerPtr sax,
void *user_data,
const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSAXUserParseMemory (xmlSAXHandlerPtr sax,
void *user_data,
const char *buffer,
int size);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseDoc (xmlSAXHandlerPtr sax,
const xmlChar *cur,
int recovery);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseMemory (xmlSAXHandlerPtr sax,
const char *buffer,
- int size,
+ int size,
int recovery);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,
const char *buffer,
- int size,
+ int size,
int recovery,
void *data);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseFile (xmlSAXHandlerPtr sax,
const char *filename,
int recovery);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseFileWithData (xmlSAXHandlerPtr sax,
const char *filename,
int recovery,
void *data);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlSAXParseEntity (xmlSAXHandlerPtr sax,
const char *filename);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlParseEntity (const char *filename);
#endif /* LIBXML_SAX1_ENABLED */
#ifdef LIBXML_VALID_ENABLED
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr XMLCALL
xmlSAXParseDTD (xmlSAXHandlerPtr sax,
const xmlChar *ExternalID,
const xmlChar *SystemID);
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr XMLCALL
xmlParseDTD (const xmlChar *ExternalID,
const xmlChar *SystemID);
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr XMLCALL
xmlIOParseDTD (xmlSAXHandlerPtr sax,
xmlParserInputBufferPtr input,
xmlCharEncoding enc);
#endif /* LIBXML_VALID_ENABLE */
#ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseBalancedChunkMemory(xmlDocPtr doc,
xmlSAXHandlerPtr sax,
void *user_data,
@@ -933,7 +947,7 @@ XMLPUBFUN xmlParserErrors XMLCALL
int options,
xmlNodePtr *lst);
#ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,
xmlSAXHandlerPtr sax,
void *user_data,
@@ -941,7 +955,7 @@ XMLPUBFUN int XMLCALL
const xmlChar *string,
xmlNodePtr *lst,
int recover);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseExternalEntity (xmlDocPtr doc,
xmlSAXHandlerPtr sax,
void *user_data,
@@ -950,7 +964,7 @@ XMLPUBFUN int XMLCALL
const xmlChar *ID,
xmlNodePtr *lst);
#endif /* LIBXML_SAX1_ENABLED */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,
const xmlChar *URL,
const xmlChar *ID,
@@ -959,35 +973,35 @@ XMLPUBFUN int XMLCALL
/*
* Parser contexts handling.
*/
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlNewParserCtxt (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlInitParserCtxt (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlClearParserCtxt (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeParserCtxt (xmlParserCtxtPtr ctxt);
#ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSetupParserForBuffer (xmlParserCtxtPtr ctxt,
const xmlChar* buffer,
const char *filename);
#endif /* LIBXML_SAX1_ENABLED */
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlCreateDocParserCtxt (const xmlChar *cur);
#ifdef LIBXML_LEGACY_ENABLED
/*
* Reading/setting optional parsing features.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlGetFeaturesList (int *len,
const char **result);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlGetFeature (xmlParserCtxtPtr ctxt,
const char *name,
void *result);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSetFeature (xmlParserCtxtPtr ctxt,
const char *name,
void *value);
@@ -997,13 +1011,13 @@ XMLPUBFUN int XMLCALL
/*
* Interfaces for the Push mode.
*/
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,
void *user_data,
const char *chunk,
int size,
const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseChunk (xmlParserCtxtPtr ctxt,
const char *chunk,
int size,
@@ -1014,7 +1028,7 @@ XMLPUBFUN int XMLCALL
* Special I/O mode.
*/
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
void *user_data,
xmlInputReadCallback ioread,
@@ -1022,7 +1036,7 @@ XMLPUBFUN xmlParserCtxtPtr XMLCALL
void *ioctx,
xmlCharEncoding enc);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr XMLCALL
xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
xmlParserInputBufferPtr input,
xmlCharEncoding enc);
@@ -1033,14 +1047,14 @@ XMLPUBFUN xmlParserInputPtr XMLCALL
XMLPUBFUN const xmlParserNodeInfo* XMLCALL
xmlParserFindNodeInfo (const xmlParserCtxtPtr ctxt,
const xmlNodePtr node);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlInitNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlClearNodeInfoSeq (xmlParserNodeInfoSeqPtr seq);
-XMLPUBFUN unsigned long XMLCALL
+XMLPUBFUN unsigned long XMLCALL
xmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,
const xmlNodePtr node);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParserAddNodeInfo (xmlParserCtxtPtr ctxt,
const xmlParserNodeInfoPtr info);
@@ -1048,7 +1062,7 @@ XMLPUBFUN void XMLCALL
* External entities handling actually implemented in xmlIO.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSetExternalEntityLoader(xmlExternalEntityLoader f);
XMLPUBFUN xmlExternalEntityLoader XMLCALL
xmlGetExternalEntityLoader(void);
@@ -1089,9 +1103,15 @@ typedef enum {
XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
XML_PARSE_NOCDATA = 1<<14,/* merge CDATA as text nodes */
XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */
- XML_PARSE_COMPACT = 1<<16 /* compact small text nodes; no modification of
+ XML_PARSE_COMPACT = 1<<16,/* compact small text nodes; no modification of
the tree allowed afterwards (will possibly
crash if you try to modify the tree) */
+ XML_PARSE_OLD10 = 1<<17,/* parse using XML-1.0 before update 5 */
+ XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */
+ XML_PARSE_HUGE = 1<<19,/* relax any hardcoded limit from the parser */
+ XML_PARSE_OLDSAX = 1<<20,/* parse using SAX2 interface before 2.7.0 */
+ XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */
+ XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */
} xmlParserOption;
XMLPUBFUN void XMLCALL
@@ -1207,6 +1227,8 @@ typedef enum {
XML_WITH_DEBUG_MEM = 29,
XML_WITH_DEBUG_RUN = 30,
XML_WITH_ZLIB = 31,
+ XML_WITH_ICU = 32,
+ XML_WITH_LZMA = 33,
XML_WITH_NONE = 99999 /* just to be sure of allocation size */
} xmlFeature;
@@ -1217,4 +1239,3 @@ XMLPUBFUN int XMLCALL
}
#endif
#endif /* __XML_PARSER_H__ */
-
diff --git a/gnulib-local/lib/libxml/parserInternals.c b/gnulib-local/lib/libxml/parserInternals.c
index f4da58d..2b8646c 100644
--- a/gnulib-local/lib/libxml/parserInternals.c
+++ b/gnulib-local/lib/libxml/parserInternals.c
@@ -55,6 +55,9 @@
#include <libxml/globals.h>
#include <libxml/chvalid.h>
+#include "buf.h"
+#include "enc.h"
+
/*
* Various global defaults for parsing
*/
@@ -73,15 +76,15 @@ xmlCheckVersion(int version) {
xmlInitParser();
if ((myversion / 10000) != (version / 10000)) {
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"Fatal: program compiled against libxml %d using libxml %d\n",
(version / 10000), (myversion / 10000));
- fprintf(stderr,
+ fprintf(stderr,
"Fatal: program compiled against libxml %d using libxml %d\n",
(version / 10000), (myversion / 10000));
}
if ((myversion / 100) < (version / 100)) {
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"Warning: program compiled against libxml %d using older %d\n",
(version / 100), (myversion / 100));
}
@@ -90,7 +93,7 @@ xmlCheckVersion(int version) {
/************************************************************************
* *
- * Some factorized error routines *
+ * Some factorized error routines *
* *
************************************************************************/
@@ -225,7 +228,7 @@ xmlIsLetter(int c) {
/************************************************************************
* *
- * Input handling functions for progressive parsing *
+ * Input handling functions for progressive parsing *
* *
************************************************************************/
@@ -242,7 +245,7 @@ xmlIsLetter(int c) {
static
void check_buffer(xmlParserInputPtr in) {
- if (in->base != in->buf->buffer->content) {
+ if (in->base != xmlBufContent(in->buf->buffer)) {
xmlGenericError(xmlGenericErrorContext,
"xmlParserInput: base mismatch problem\n");
}
@@ -250,17 +253,17 @@ void check_buffer(xmlParserInputPtr in) {
xmlGenericError(xmlGenericErrorContext,
"xmlParserInput: cur < base problem\n");
}
- if (in->cur > in->base + in->buf->buffer->use) {
+ if (in->cur > in->base + xmlBufUse(in->buf->buffer)) {
xmlGenericError(xmlGenericErrorContext,
"xmlParserInput: cur > base + use problem\n");
}
- xmlGenericError(xmlGenericErrorContext,"buffer %x : content %x, cur %d, use %d, size %d\n",
- (int) in, (int) in->buf->buffer->content, in->cur - in->base,
- in->buf->buffer->use, in->buf->buffer->size);
+ xmlGenericError(xmlGenericErrorContext,"buffer %x : content %x, cur %d, use %d\n",
+ (int) in, (int) xmlBufContent(in->buf->buffer), in->cur - in->base,
+ xmlBufUse(in->buf->buffer));
}
#else
-#define CHECK_BUFFER(in)
+#define CHECK_BUFFER(in)
#endif
@@ -269,50 +272,13 @@ void check_buffer(xmlParserInputPtr in) {
* @in: an XML parser input
* @len: an indicative size for the lookahead
*
- * This function refresh the input for the parser. It doesn't try to
- * preserve pointers to the input buffer, and discard already read data
+ * This function was internal and is deprecated.
*
- * Returns the number of xmlChars read, or -1 in case of error, 0 indicate the
- * end of this entity
+ * Returns -1 as this is an error to use it.
*/
int
-xmlParserInputRead(xmlParserInputPtr in, int len) {
- int ret;
- int used;
- int indx;
-
- if (in == NULL) return(-1);
-#ifdef DEBUG_INPUT
- xmlGenericError(xmlGenericErrorContext, "Read\n");
-#endif
- if (in->buf == NULL) return(-1);
- if (in->base == NULL) return(-1);
- if (in->cur == NULL) return(-1);
- if (in->buf->buffer == NULL) return(-1);
- if (in->buf->readcallback == NULL) return(-1);
-
- CHECK_BUFFER(in);
-
- used = in->cur - in->buf->buffer->content;
- ret = xmlBufferShrink(in->buf->buffer, used);
- if (ret > 0) {
- in->cur -= ret;
- in->consumed += ret;
- }
- ret = xmlParserInputBufferRead(in->buf, len);
- if (in->base != in->buf->buffer->content) {
- /*
- * the buffer has been reallocated
- */
- indx = in->cur - in->base;
- in->base = in->buf->buffer->content;
- in->cur = &in->buf->buffer->content[indx];
- }
- in->end = &in->buf->buffer->content[in->buf->buffer->use];
-
- CHECK_BUFFER(in);
-
- return(ret);
+xmlParserInputRead(xmlParserInputPtr in ATTRIBUTE_UNUSED, int len ATTRIBUTE_UNUSED) {
+ return(-1);
}
/**
@@ -323,15 +289,16 @@ xmlParserInputRead(xmlParserInputPtr in, int len) {
* This function increase the input for the parser. It tries to
* preserve pointers to the input buffer, and keep already read data
*
- * Returns the number of xmlChars read, or -1 in case of error, 0 indicate the
+ * Returns the amount of char read, or -1 in case of error, 0 indicate the
* end of this entity
*/
int
xmlParserInputGrow(xmlParserInputPtr in, int len) {
- int ret;
- int indx;
+ size_t ret;
+ size_t indx;
+ const xmlChar *content;
- if (in == NULL) return(-1);
+ if ((in == NULL) || (len < 0)) return(-1);
#ifdef DEBUG_INPUT
xmlGenericError(xmlGenericErrorContext, "Grow\n");
#endif
@@ -343,15 +310,15 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
CHECK_BUFFER(in);
indx = in->cur - in->base;
- if (in->buf->buffer->use > (unsigned int) indx + INPUT_CHUNK) {
+ if (xmlBufUse(in->buf->buffer) > (unsigned int) indx + INPUT_CHUNK) {
CHECK_BUFFER(in);
return(0);
}
- if (in->buf->readcallback != NULL)
+ if (in->buf->readcallback != NULL) {
ret = xmlParserInputBufferGrow(in->buf, len);
- else
+ } else
return(0);
/*
@@ -360,15 +327,17 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
* pointer arithmetic. Insure will raise it as a bug but in
* that specific case, that's not !
*/
- if (in->base != in->buf->buffer->content) {
+
+ content = xmlBufContent(in->buf->buffer);
+ if (in->base != content) {
/*
* the buffer has been reallocated
*/
indx = in->cur - in->base;
- in->base = in->buf->buffer->content;
- in->cur = &in->buf->buffer->content[indx];
+ in->base = content;
+ in->cur = &content[indx];
}
- in->end = &in->buf->buffer->content[in->buf->buffer->use];
+ in->end = xmlBufEnd(in->buf->buffer);
CHECK_BUFFER(in);
@@ -383,9 +352,10 @@ xmlParserInputGrow(xmlParserInputPtr in, int len) {
*/
void
xmlParserInputShrink(xmlParserInputPtr in) {
- int used;
- int ret;
- int indx;
+ size_t used;
+ size_t ret;
+ size_t indx;
+ const xmlChar *content;
#ifdef DEBUG_INPUT
xmlGenericError(xmlGenericErrorContext, "Shrink\n");
@@ -398,42 +368,43 @@ xmlParserInputShrink(xmlParserInputPtr in) {
CHECK_BUFFER(in);
- used = in->cur - in->buf->buffer->content;
+ used = in->cur - xmlBufContent(in->buf->buffer);
/*
* Do not shrink on large buffers whose only a tiny fraction
* was consumed
*/
if (used > INPUT_CHUNK) {
- ret = xmlBufferShrink(in->buf->buffer, used - LINE_LEN);
+ ret = xmlBufShrink(in->buf->buffer, used - LINE_LEN);
if (ret > 0) {
in->cur -= ret;
in->consumed += ret;
}
- in->end = &in->buf->buffer->content[in->buf->buffer->use];
+ in->end = xmlBufEnd(in->buf->buffer);
}
CHECK_BUFFER(in);
- if (in->buf->buffer->use > INPUT_CHUNK) {
+ if (xmlBufUse(in->buf->buffer) > INPUT_CHUNK) {
return;
}
xmlParserInputBufferRead(in->buf, 2 * INPUT_CHUNK);
- if (in->base != in->buf->buffer->content) {
+ content = xmlBufContent(in->buf->buffer);
+ if (in->base != content) {
/*
* the buffer has been reallocated
*/
indx = in->cur - in->base;
- in->base = in->buf->buffer->content;
- in->cur = &in->buf->buffer->content[indx];
+ in->base = content;
+ in->cur = &content[indx];
}
- in->end = &in->buf->buffer->content[in->buf->buffer->use];
+ in->end = xmlBufEnd(in->buf->buffer);
CHECK_BUFFER(in);
}
/************************************************************************
* *
- * UTF8 character input and related functions *
+ * UTF8 character input and related functions *
* *
************************************************************************/
@@ -484,7 +455,7 @@ xmlNextChar(xmlParserCtxtPtr ctxt)
* UCS-4 range (hex.) UTF-8 octet sequence (binary)
* 0000 0000-0000 007F 0xxxxxxx
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx
- * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
+ * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
*
* Check for the 0x110000 limit too
*/
@@ -494,20 +465,26 @@ xmlNextChar(xmlParserCtxtPtr ctxt)
if (c & 0x80) {
if (c == 0xC0)
goto encoding_error;
- if (cur[1] == 0)
+ if (cur[1] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+ cur = ctxt->input->cur;
+ }
if ((cur[1] & 0xc0) != 0x80)
goto encoding_error;
if ((c & 0xe0) == 0xe0) {
unsigned int val;
- if (cur[2] == 0)
+ if (cur[2] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+ cur = ctxt->input->cur;
+ }
if ((cur[2] & 0xc0) != 0x80)
goto encoding_error;
if ((c & 0xf0) == 0xf0) {
- if (cur[3] == 0)
+ if (cur[3] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+ cur = ctxt->input->cur;
+ }
if (((c & 0xf8) != 0xf0) ||
((cur[3] & 0xc0) != 0x80))
goto encoding_error;
@@ -628,7 +605,7 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
* UCS-4 range (hex.) UTF-8 octet sequence (binary)
* 0000 0000-0000 007F 0xxxxxxx
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx
- * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
+ * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
*
* Check for the 0x110000 limit too
*/
@@ -638,21 +615,26 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
c = *cur;
if (c & 0x80) {
- if (c == 0xC0)
+ if (((c & 0x40) == 0) || (c == 0xC0))
goto encoding_error;
- if (cur[1] == 0)
+ if (cur[1] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+ cur = ctxt->input->cur;
+ }
if ((cur[1] & 0xc0) != 0x80)
goto encoding_error;
if ((c & 0xe0) == 0xe0) {
-
- if (cur[2] == 0)
+ if (cur[2] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+ cur = ctxt->input->cur;
+ }
if ((cur[2] & 0xc0) != 0x80)
goto encoding_error;
if ((c & 0xf0) == 0xf0) {
- if (cur[3] == 0)
+ if (cur[3] == 0) {
xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+ cur = ctxt->input->cur;
+ }
if (((c & 0xf8) != 0xf0) ||
((cur[3] & 0xc0) != 0x80))
goto encoding_error;
@@ -662,27 +644,40 @@ xmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) {
val |= (cur[1] & 0x3f) << 12;
val |= (cur[2] & 0x3f) << 6;
val |= cur[3] & 0x3f;
+ if (val < 0x10000)
+ goto encoding_error;
} else {
/* 3-byte code */
*len = 3;
val = (cur[0] & 0xf) << 12;
val |= (cur[1] & 0x3f) << 6;
val |= cur[2] & 0x3f;
+ if (val < 0x800)
+ goto encoding_error;
}
} else {
/* 2-byte code */
*len = 2;
val = (cur[0] & 0x1f) << 6;
val |= cur[1] & 0x3f;
+ if (val < 0x80)
+ goto encoding_error;
}
if (!IS_CHAR(val)) {
xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
"Char 0x%X out of allowed range\n", val);
- }
+ }
return(val);
} else {
/* 1-byte code */
*len = 1;
+ if (*ctxt->input->cur == 0)
+ xmlParserInputGrow(ctxt->input, INPUT_CHUNK);
+ if ((*ctxt->input->cur == 0) &&
+ (ctxt->input->end > ctxt->input->cur)) {
+ xmlErrEncodingInt(ctxt, XML_ERR_INVALID_CHAR,
+ "Char 0x0 out of allowed range\n", 0);
+ }
if (*ctxt->input->cur == 0xD) {
if (ctxt->input->cur[1] == 0xA) {
ctxt->nbChars++;
@@ -735,7 +730,7 @@ encoding_error:
"Input is not proper UTF-8, indicate encoding !\n%s",
BAD_CAST buffer, NULL);
}
- ctxt->charset = XML_CHAR_ENCODING_8859_1;
+ ctxt->charset = XML_CHAR_ENCODING_8859_1;
*len = 1;
return((int) *ctxt->input->cur);
}
@@ -764,7 +759,7 @@ xmlStringCurrentChar(xmlParserCtxtPtr ctxt, const xmlChar * cur, int *len)
* UCS-4 range (hex.) UTF-8 octet sequence (binary)
* 0000 0000-0000 007F 0xxxxxxx
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx
- * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
+ * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
*
* Check for the 0x110000 limit too
*/
@@ -857,7 +852,7 @@ encoding_error:
* @out: pointer to an array of xmlChar
* @val: the char value
*
- * append the char value in the array
+ * append the char value in the array
*
* Returns the number of xmlChar written
*/
@@ -871,7 +866,7 @@ xmlCopyCharMultiByte(xmlChar *out, int val) {
* UCS-4 range (hex.) UTF-8 octet sequence (binary)
* 0000 0000-0000 007F 0xxxxxxx
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx
- * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
+ * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
*/
if (val >= 0x80) {
xmlChar *savedout = out;
@@ -899,7 +894,7 @@ xmlCopyCharMultiByte(xmlChar *out, int val) {
* @out: pointer to an array of xmlChar
* @val: the char value
*
- * append the char value in the array
+ * append the char value in the array
*
* Returns the number of xmlChar written
*/
@@ -921,6 +916,12 @@ xmlCopyChar(int len ATTRIBUTE_UNUSED, xmlChar *out, int val) {
* *
************************************************************************/
+static int
+xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
+ xmlCharEncodingHandlerPtr handler, int len);
+static int
+xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
+ xmlCharEncodingHandlerPtr handler, int len);
/**
* xmlSwitchEncoding:
* @ctxt: the parser context
@@ -935,6 +936,8 @@ int
xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
{
xmlCharEncodingHandlerPtr handler;
+ int len = -1;
+ int ret;
if (ctxt == NULL) return(-1);
switch (enc) {
@@ -978,9 +981,33 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
(ctxt->input->cur[2] == 0xBF)) {
ctxt->input->cur += 3;
}
- break ;
- default:
- break;
+ len = 90;
+ break;
+ case XML_CHAR_ENCODING_UCS2:
+ len = 90;
+ break;
+ case XML_CHAR_ENCODING_UCS4BE:
+ case XML_CHAR_ENCODING_UCS4LE:
+ case XML_CHAR_ENCODING_UCS4_2143:
+ case XML_CHAR_ENCODING_UCS4_3412:
+ len = 180;
+ break;
+ case XML_CHAR_ENCODING_EBCDIC:
+ case XML_CHAR_ENCODING_8859_1:
+ case XML_CHAR_ENCODING_8859_2:
+ case XML_CHAR_ENCODING_8859_3:
+ case XML_CHAR_ENCODING_8859_4:
+ case XML_CHAR_ENCODING_8859_5:
+ case XML_CHAR_ENCODING_8859_6:
+ case XML_CHAR_ENCODING_8859_7:
+ case XML_CHAR_ENCODING_8859_8:
+ case XML_CHAR_ENCODING_8859_9:
+ case XML_CHAR_ENCODING_ASCII:
+ case XML_CHAR_ENCODING_2022_JP:
+ case XML_CHAR_ENCODING_SHIFT_JIS:
+ case XML_CHAR_ENCODING_EUC_JP:
+ len = 45;
+ break;
}
handler = xmlGetCharEncodingHandler(enc);
if (handler == NULL) {
@@ -1071,7 +1098,15 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
if (handler == NULL)
return(-1);
ctxt->charset = XML_CHAR_ENCODING_UTF8;
- return(xmlSwitchToEncoding(ctxt, handler));
+ ret = xmlSwitchToEncodingInt(ctxt, handler, len);
+ if ((ret < 0) || (ctxt->errNo == XML_I18N_CONV_FAILED)) {
+ /*
+ * on encoding conversion errors, stop the parser
+ */
+ xmlStopParser(ctxt);
+ ctxt->errNo = XML_I18N_CONV_FAILED;
+ }
+ return(ret);
}
/**
@@ -1079,15 +1114,16 @@ xmlSwitchEncoding(xmlParserCtxtPtr ctxt, xmlCharEncoding enc)
* @ctxt: the parser context
* @input: the input stream
* @handler: the encoding handler
+ * @len: the number of bytes to convert for the first line or -1
*
* change the input functions when discovering the character encoding
* of a given entity.
*
* Returns 0 in case of success, -1 otherwise
*/
-int
-xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
- xmlCharEncodingHandlerPtr handler)
+static int
+xmlSwitchInputEncodingInt(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
+ xmlCharEncodingHandlerPtr handler, int len)
{
int nbchars;
@@ -1128,12 +1164,12 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
/*
* Is there already some content down the pipe to convert ?
*/
- if ((input->buf->buffer != NULL) && (input->buf->buffer->use > 0)) {
+ if (xmlBufIsEmpty(input->buf->buffer) == 0) {
int processed;
unsigned int use;
/*
- * Specific handling of the Byte Order Mark for
+ * Specific handling of the Byte Order Mark for
* UTF-16
*/
if ((handler->name != NULL) &&
@@ -1164,19 +1200,17 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
* Move it as the raw buffer and create a new input buffer
*/
processed = input->cur - input->base;
- xmlBufferShrink(input->buf->buffer, processed);
+ xmlBufShrink(input->buf->buffer, processed);
input->buf->raw = input->buf->buffer;
- input->buf->buffer = xmlBufferCreate();
+ input->buf->buffer = xmlBufCreate();
input->buf->rawconsumed = processed;
- use = input->buf->raw->use;
+ use = xmlBufUse(input->buf->raw);
if (ctxt->html) {
/*
* convert as much as possible of the buffer
*/
- nbchars = xmlCharEncInFunc(input->buf->encoder,
- input->buf->buffer,
- input->buf->raw);
+ nbchars = xmlCharEncInput(input->buf, 1);
} else {
/*
* convert just enough to get
@@ -1184,9 +1218,7 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
* parsed with the autodetected encoding
* into the parser reading buffer.
*/
- nbchars = xmlCharEncFirstLine(input->buf->encoder,
- input->buf->buffer,
- input->buf->raw);
+ nbchars = xmlCharEncFirstLineInput(input->buf, len);
}
if (nbchars < 0) {
xmlErrInternal(ctxt,
@@ -1194,10 +1226,8 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
NULL);
return (-1);
}
- input->buf->rawconsumed += use - input->buf->raw->use;
- input->base = input->cur = input->buf->buffer->content;
- input->end = &input->base[input->buf->buffer->use];
-
+ input->buf->rawconsumed += use - xmlBufUse(input->buf->raw);
+ xmlBufResetInput(input->buf->buffer, input);
}
return (0);
} else if (input->length == 0) {
@@ -1212,8 +1242,9 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
}
/**
- * xmlSwitchToEncoding:
+ * xmlSwitchInputEncoding:
* @ctxt: the parser context
+ * @input: the input stream
* @handler: the encoding handler
*
* change the input functions when discovering the character encoding
@@ -1222,13 +1253,32 @@ xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
* Returns 0 in case of success, -1 otherwise
*/
int
-xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
-{
+xmlSwitchInputEncoding(xmlParserCtxtPtr ctxt, xmlParserInputPtr input,
+ xmlCharEncodingHandlerPtr handler) {
+ return(xmlSwitchInputEncodingInt(ctxt, input, handler, -1));
+}
+
+/**
+ * xmlSwitchToEncodingInt:
+ * @ctxt: the parser context
+ * @handler: the encoding handler
+ * @len: the length to convert or -1
+ *
+ * change the input functions when discovering the character encoding
+ * of a given entity, and convert only @len bytes of the output, this
+ * is needed on auto detect to allows any declared encoding later to
+ * convert the actual content after the xmlDecl
+ *
+ * Returns 0 in case of success, -1 otherwise
+ */
+static int
+xmlSwitchToEncodingInt(xmlParserCtxtPtr ctxt,
+ xmlCharEncodingHandlerPtr handler, int len) {
int ret = 0;
if (handler != NULL) {
if (ctxt->input != NULL) {
- ret = xmlSwitchInputEncoding(ctxt, ctxt->input, handler);
+ ret = xmlSwitchInputEncodingInt(ctxt, ctxt->input, handler, len);
} else {
xmlErrInternal(ctxt, "xmlSwitchToEncoding : no input\n",
NULL);
@@ -1238,11 +1288,27 @@ xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
* The parsing is now done in UTF8 natively
*/
ctxt->charset = XML_CHAR_ENCODING_UTF8;
- } else
+ } else
return(-1);
return(ret);
}
+/**
+ * xmlSwitchToEncoding:
+ * @ctxt: the parser context
+ * @handler: the encoding handler
+ *
+ * change the input functions when discovering the character encoding
+ * of a given entity.
+ *
+ * Returns 0 in case of success, -1 otherwise
+ */
+int
+xmlSwitchToEncoding(xmlParserCtxtPtr ctxt, xmlCharEncodingHandlerPtr handler)
+{
+ return (xmlSwitchToEncodingInt(ctxt, handler, -1));
+}
+
/************************************************************************
* *
* Commodity functions to handle entities processing *
@@ -1265,7 +1331,7 @@ xmlFreeInputStream(xmlParserInputPtr input) {
if (input->version != NULL) xmlFree((char *) input->version);
if ((input->free != NULL) && (input->base != NULL))
input->free((xmlChar *) input->base);
- if (input->buf != NULL)
+ if (input->buf != NULL)
xmlFreeParserInputBuffer(input->buf);
xmlFree(input);
}
@@ -1274,13 +1340,13 @@ xmlFreeInputStream(xmlParserInputPtr input) {
* xmlNewInputStream:
* @ctxt: an XML parser context
*
- * Create a new input stream structure
+ * Create a new input stream structure.
+ *
* Returns the new input stream or NULL
*/
xmlParserInputPtr
xmlNewInputStream(xmlParserCtxtPtr ctxt) {
xmlParserInputPtr input;
- static int id = 0;
input = (xmlParserInputPtr) xmlMalloc(sizeof(xmlParserInput));
if (input == NULL) {
@@ -1291,11 +1357,15 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) {
input->line = 1;
input->col = 1;
input->standalone = -1;
+
/*
- * we don't care about thread reentrancy unicity for a single
- * parser context (and hence thread) is sufficient.
+ * If the context is NULL the id cannot be initialized, but that
+ * should not happen while parsing which is the situation where
+ * the id is actually needed.
*/
- input->id = id++;
+ if (ctxt != NULL)
+ input->id = ctxt->input_id++;
+
return(input);
}
@@ -1324,9 +1394,8 @@ xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input,
}
inputStream->filename = NULL;
inputStream->buf = input;
- inputStream->base = inputStream->buf->buffer->content;
- inputStream->cur = inputStream->buf->buffer->content;
- inputStream->end = &inputStream->base[inputStream->buf->buffer->use];
+ xmlBufResetInput(inputStream->buf->buffer, inputStream);
+
if (enc != XML_CHAR_ENCODING_NONE) {
xmlSwitchEncoding(ctxt, enc);
}
@@ -1387,8 +1456,11 @@ xmlNewEntityInputStream(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
if (input == NULL) {
return(NULL);
}
- input->filename = (char *) entity->URI;
+ if (entity->URI != NULL)
+ input->filename = (char *) xmlStrdup((xmlChar *) entity->URI);
input->base = entity->content;
+ if (entity->length == 0)
+ entity->length = xmlStrlen(entity->content);
input->cur = entity->content;
input->length = entity->length;
input->end = &entity->content[input->length];
@@ -1467,7 +1539,7 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
inputStream = xmlCheckHTTPInput(ctxt, inputStream);
if (inputStream == NULL)
return(NULL);
-
+
if (inputStream->filename == NULL)
URI = xmlStrdup((xmlChar *) filename);
else
@@ -1478,9 +1550,7 @@ xmlNewInputFromFile(xmlParserCtxtPtr ctxt, const char *filename) {
if (URI != NULL) xmlFree((char *) URI);
inputStream->directory = directory;
- inputStream->base = inputStream->buf->buffer->content;
- inputStream->cur = inputStream->buf->buffer->content;
- inputStream->end = &inputStream->base[inputStream->buf->buffer->use];
+ xmlBufResetInput(inputStream->buf->buffer, inputStream);
if ((ctxt->directory == NULL) && (directory != NULL))
ctxt->directory = (char *) xmlStrdup((const xmlChar *) directory);
return(inputStream);
@@ -1519,6 +1589,8 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
xmlErrMemory(NULL, "cannot initialize parser context\n");
return(-1);
}
+ xmlDictSetLimit(ctxt->dict, XML_MAX_DICTIONARY_LIMIT);
+
if (ctxt->sax == NULL)
ctxt->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
if (ctxt->sax == NULL) {
@@ -1630,12 +1702,20 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
ctxt->nsWellFormed = 1;
ctxt->valid = 1;
ctxt->loadsubset = xmlLoadExtDtdDefaultValue;
+ if (ctxt->loadsubset) {
+ ctxt->options |= XML_PARSE_DTDLOAD;
+ }
ctxt->validate = xmlDoValidityCheckingDefaultValue;
ctxt->pedantic = xmlPedanticParserDefaultValue;
+ if (ctxt->pedantic) {
+ ctxt->options |= XML_PARSE_PEDANTIC;
+ }
ctxt->linenumbers = xmlLineNumbersDefaultValue;
ctxt->keepBlanks = xmlKeepBlanksDefaultValue;
- if (ctxt->keepBlanks == 0)
+ if (ctxt->keepBlanks == 0) {
ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace;
+ ctxt->options |= XML_PARSE_NOBLANKS;
+ }
ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_0;
ctxt->vctxt.userData = ctxt;
@@ -1647,8 +1727,12 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
else
ctxt->vctxt.warning = xmlParserValidityWarning;
ctxt->vctxt.nodeMax = 0;
+ ctxt->options |= XML_PARSE_DTDVALID;
}
ctxt->replaceEntities = xmlSubstituteEntitiesDefaultValue;
+ if (ctxt->replaceEntities) {
+ ctxt->options |= XML_PARSE_NOENT;
+ }
ctxt->record_info = 0;
ctxt->nbChars = 0;
ctxt->checkIndex = 0;
@@ -1657,6 +1741,10 @@ xmlInitParserCtxt(xmlParserCtxtPtr ctxt)
ctxt->depth = 0;
ctxt->charset = XML_CHAR_ENCODING_UTF8;
ctxt->catalogs = NULL;
+ ctxt->nbentities = 0;
+ ctxt->sizeentities = 0;
+ ctxt->sizeentcopy = 0;
+ ctxt->input_id = 1;
xmlInitNodeInfoSeq(&ctxt->node_seq);
return(0);
}
@@ -1682,6 +1770,7 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
if (ctxt->spaceTab != NULL) xmlFree(ctxt->spaceTab);
if (ctxt->nameTab != NULL) xmlFree((xmlChar * *)ctxt->nameTab);
if (ctxt->nodeTab != NULL) xmlFree(ctxt->nodeTab);
+ if (ctxt->nodeInfoTab != NULL) xmlFree(ctxt->nodeInfoTab);
if (ctxt->inputTab != NULL) xmlFree(ctxt->inputTab);
if (ctxt->version != NULL) xmlFree((char *) ctxt->version);
if (ctxt->encoding != NULL) xmlFree((char *) ctxt->encoding);
@@ -1701,7 +1790,7 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
if (ctxt->nsTab != NULL) xmlFree((char *) ctxt->nsTab);
if (ctxt->pushTab != NULL) xmlFree(ctxt->pushTab);
if (ctxt->attallocs != NULL) xmlFree(ctxt->attallocs);
- if (ctxt->attsDefault != NULL)
+ if (ctxt->attsDefault != NULL)
xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree);
if (ctxt->attsSpecial != NULL)
xmlHashFree(ctxt->attsSpecial, NULL);
@@ -1801,7 +1890,7 @@ xmlClearParserCtxt(xmlParserCtxtPtr ctxt)
* @node: an XML node within the tree
*
* Find the parser node info struct for a given node
- *
+ *
* Returns an xmlParserNodeInfo block pointer or NULL
*/
const xmlParserNodeInfo *
@@ -1859,7 +1948,7 @@ xmlClearNodeInfoSeq(xmlParserNodeInfoSeqPtr seq)
* @seq: a node info sequence pointer
* @node: an XML node pointer
*
- *
+ *
* xmlParserFindNodeInfoIndex : Find the index that the info record for
* the given node is or should be at in a sorted sequence
*
@@ -1916,7 +2005,7 @@ xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
pos = xmlParserFindNodeInfoIndex(&ctxt->node_seq, (xmlNodePtr)
info->node);
- if ((pos < ctxt->node_seq.length) &&
+ if ((pos < ctxt->node_seq.length) &&
(ctxt->node_seq.buffer != NULL) &&
(ctxt->node_seq.buffer[pos].node == info->node)) {
ctxt->node_seq.buffer[pos] = *info;
@@ -1924,7 +2013,8 @@ xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
/* Otherwise, we need to add new node to buffer */
else {
- if (ctxt->node_seq.length + 1 > ctxt->node_seq.maximum) {
+ if ((ctxt->node_seq.length + 1 > ctxt->node_seq.maximum) ||
+ (ctxt->node_seq.buffer == NULL)) {
xmlParserNodeInfo *tmp_buffer;
unsigned int byte_size;
@@ -1969,7 +2059,7 @@ xmlParserAddNodeInfo(xmlParserCtxtPtr ctxt,
************************************************************************/
/**
* xmlPedanticParserDefault:
- * @val: int 0 or 1
+ * @val: int 0 or 1
*
* Set and return the previous value for enabling pedantic warnings.
*
@@ -1986,7 +2076,7 @@ xmlPedanticParserDefault(int val) {
/**
* xmlLineNumbersDefault:
- * @val: int 0 or 1
+ * @val: int 0 or 1
*
* Set and return the previous value for enabling line numbers in elements
* contents. This may break on old application and is turned off by default.
@@ -2004,7 +2094,7 @@ xmlLineNumbersDefault(int val) {
/**
* xmlSubstituteEntitiesDefault:
- * @val: int 0 or 1
+ * @val: int 0 or 1
*
* Set and return the previous value for default entity support.
* Initially the parser always keep entity references instead of substituting
@@ -2026,7 +2116,7 @@ xmlSubstituteEntitiesDefault(int val) {
/**
* xmlKeepBlanksDefault:
- * @val: int 0 or 1
+ * @val: int 0 or 1
*
* Set and return the previous value for default blanks text nodes support.
* The 1.x version of the parser used an heuristic to try to detect
@@ -2037,7 +2127,7 @@ xmlSubstituteEntitiesDefault(int val) {
* ignorableWhitespace() are only generated when running the parser in
* validating mode and when the current element doesn't allow CDATA or
* mixed content.
- * This function is provided as a way to force the standard behavior
+ * This function is provided as a way to force the standard behavior
* on 1.X libs and to switch back to the old mode for compatibility when
* running 1.X client code on 2.X . Upgrade of 1.X code should be done
* by using xmlIsBlankNode() commodity function to detect the "empty"
@@ -2053,7 +2143,7 @@ xmlKeepBlanksDefault(int val) {
int old = xmlKeepBlanksDefaultValue;
xmlKeepBlanksDefaultValue = val;
- xmlIndentTreeOutput = !val;
+ if (!val) xmlIndentTreeOutput = 1;
return(old);
}
diff --git a/gnulib-local/lib/libxml/parserInternals.in.h b/gnulib-local/lib/libxml/parserInternals.in.h
index 7ac0ce6..6065320 100644
--- a/gnulib-local/lib/libxml/parserInternals.in.h
+++ b/gnulib-local/lib/libxml/parserInternals.in.h
@@ -1,5 +1,5 @@
/*
- * Summary: internals routines exported by the parser.
+ * Summary: internals routines and limits exported by the parser.
* Description: this module exports a number of internal parsing routines
* they are not really all intended for applications but
* can prove useful doing low level processing.
@@ -24,18 +24,60 @@ extern "C" {
/**
* 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.
+ * 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, use XML_PARSE_HUGE option to override it.
*/
XMLPUBVAR unsigned int xmlParserMaxDepth;
- /**
- * XML_MAX_NAMELEN:
- *
- * Identifiers can be longer, but this will be more costly
- * at runtime.
- */
+/**
+ * XML_MAX_TEXT_LENGTH:
+ *
+ * Maximum size allowed for a single text node when building a tree.
+ * This is not a limitation of the parser but a safety boundary feature,
+ * use XML_PARSE_HUGE option to override it.
+ * Introduced in 2.9.0
+ */
+#define XML_MAX_TEXT_LENGTH 10000000
+
+/**
+ * XML_MAX_NAME_LENGTH:
+ *
+ * Maximum size allowed for a markup identitier
+ * This is not a limitation of the parser but a safety boundary feature,
+ * use XML_PARSE_HUGE option to override it.
+ * Note that with the use of parsing dictionaries overriding the limit
+ * may result in more runtime memory usage in face of "unfriendly' content
+ * Introduced in 2.9.0
+ */
+#define XML_MAX_NAME_LENGTH 50000
+
+/**
+ * XML_MAX_DICTIONARY_LIMIT:
+ *
+ * Maximum size allowed by the parser for a dictionary by default
+ * This is not a limitation of the parser but a safety boundary feature,
+ * use XML_PARSE_HUGE option to override it.
+ * Introduced in 2.9.0
+ */
+#define XML_MAX_DICTIONARY_LIMIT 10000000
+
+/**
+ * XML_MAX_LOOKUP_LIMIT:
+ *
+ * Maximum size allowed by the parser for ahead lookup
+ * This is an upper boundary enforced by the parser to avoid bad
+ * behaviour on "unfriendly' content
+ * Introduced in 2.9.0
+ */
+#define XML_MAX_LOOKUP_LIMIT 10000000
+
+/**
+ * XML_MAX_NAMELEN:
+ *
+ * Identifiers can be longer, but this will be more costly
+ * at runtime.
+ */
#define XML_MAX_NAMELEN 100
/**
@@ -48,7 +90,7 @@ XMLPUBVAR unsigned int xmlParserMaxDepth;
/************************************************************************
* *
- * UNICODE version of the macros. *
+ * UNICODE version of the macros. *
* *
************************************************************************/
/**
@@ -144,7 +186,7 @@ XMLPUBVAR unsigned int xmlParserMaxDepth;
*
* Always false (all combining chars > 0xff)
*/
-#define IS_COMBINING_CH(c) 0
+#define IS_COMBINING_CH(c) 0
/**
* IS_EXTENDER:
@@ -185,7 +227,7 @@ XMLPUBVAR unsigned int xmlParserMaxDepth;
* Macro to check the following production in the XML spec:
*
*
- * [84] Letter ::= BaseChar | Ideographic
+ * [84] Letter ::= BaseChar | Ideographic
*/
#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))
@@ -242,7 +284,7 @@ XMLPUBVAR unsigned int xmlParserMaxDepth;
*
* Skips the end of line chars.
*/
-#define SKIP_EOL(p) \
+#define SKIP_EOL(p) \
if (*(p) == 0x13) { p++ ; if (*(p) == 0x10) p++; } \
if (*(p) == 0x10) { p++ ; if (*(p) == 0x13) p++; }
@@ -279,25 +321,25 @@ XMLPUBFUN int XMLCALL xmlIsLetter (int c);
/**
* Parser context.
*/
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlCreateFileParserCtxt (const char *filename);
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlCreateURLParserCtxt (const char *filename,
int options);
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlCreateMemoryParserCtxt(const char *buffer,
int size);
-XMLPUBFUN xmlParserCtxtPtr XMLCALL
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
xmlCreateEntityParserCtxt(const xmlChar *URL,
const xmlChar *ID,
const xmlChar *base);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSwitchEncoding (xmlParserCtxtPtr ctxt,
xmlCharEncoding enc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSwitchToEncoding (xmlParserCtxtPtr ctxt,
xmlCharEncodingHandlerPtr handler);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSwitchInputEncoding (xmlParserCtxtPtr ctxt,
xmlParserInputPtr input,
xmlCharEncodingHandlerPtr handler);
@@ -315,29 +357,29 @@ XMLPUBFUN void XMLCALL
/**
* Input Streams.
*/
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr XMLCALL
xmlNewStringInputStream (xmlParserCtxtPtr ctxt,
const xmlChar *buffer);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr XMLCALL
xmlNewEntityInputStream (xmlParserCtxtPtr ctxt,
xmlEntityPtr entity);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN int XMLCALL
xmlPushInput (xmlParserCtxtPtr ctxt,
xmlParserInputPtr input);
-XMLPUBFUN xmlChar XMLCALL
+XMLPUBFUN xmlChar XMLCALL
xmlPopInput (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeInputStream (xmlParserInputPtr input);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr XMLCALL
xmlNewInputFromFile (xmlParserCtxtPtr ctxt,
const char *filename);
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr XMLCALL
xmlNewInputStream (xmlParserCtxtPtr ctxt);
/**
* Namespaces.
*/
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlSplitQName (xmlParserCtxtPtr ctxt,
const xmlChar *name,
xmlChar **prefix);
@@ -345,112 +387,112 @@ XMLPUBFUN xmlChar * XMLCALL
/**
* Generic production rules.
*/
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlParseName (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlParseNmtoken (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlParseEntityValue (xmlParserCtxtPtr ctxt,
xmlChar **orig);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlParseAttValue (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlParseSystemLiteral (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlParsePubidLiteral (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseCharData (xmlParserCtxtPtr ctxt,
int cdata);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlParseExternalID (xmlParserCtxtPtr ctxt,
xmlChar **publicID,
int strict);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseComment (xmlParserCtxtPtr ctxt);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlParsePITarget (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParsePI (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseNotationDecl (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseEntityDecl (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseDefaultDecl (xmlParserCtxtPtr ctxt,
xmlChar **value);
-XMLPUBFUN xmlEnumerationPtr XMLCALL
+XMLPUBFUN xmlEnumerationPtr XMLCALL
xmlParseNotationType (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlEnumerationPtr XMLCALL
+XMLPUBFUN xmlEnumerationPtr XMLCALL
xmlParseEnumerationType (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseEnumeratedType (xmlParserCtxtPtr ctxt,
xmlEnumerationPtr *tree);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseAttributeType (xmlParserCtxtPtr ctxt,
xmlEnumerationPtr *tree);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XMLPUBFUN xmlElementContentPtr XMLCALL
xmlParseElementMixedContentDecl
(xmlParserCtxtPtr ctxt,
int inputchk);
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XMLPUBFUN xmlElementContentPtr XMLCALL
xmlParseElementChildrenContentDecl
(xmlParserCtxtPtr ctxt,
int inputchk);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseElementContentDecl(xmlParserCtxtPtr ctxt,
const xmlChar *name,
xmlElementContentPtr *result);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseElementDecl (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseMarkupDecl (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseCharRef (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlEntityPtr XMLCALL
+XMLPUBFUN xmlEntityPtr XMLCALL
xmlParseEntityRef (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseReference (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParsePEReference (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseDocTypeDecl (xmlParserCtxtPtr ctxt);
#ifdef LIBXML_SAX1_ENABLED
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlParseAttribute (xmlParserCtxtPtr ctxt,
xmlChar **value);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlParseStartTag (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseEndTag (xmlParserCtxtPtr ctxt);
#endif /* LIBXML_SAX1_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseCDSect (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseContent (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseElement (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlParseVersionNum (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlParseVersionInfo (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlParseEncName (xmlParserCtxtPtr ctxt);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlParseEncodingDecl (xmlParserCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseSDDecl (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseXMLDecl (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseTextDecl (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseMisc (xmlParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParseExternalSubset (xmlParserCtxtPtr ctxt,
const xmlChar *ExternalID,
- const xmlChar *SystemID);
+ const xmlChar *SystemID);
/**
* XML_SUBSTITUTE_NONE:
*
@@ -474,7 +516,7 @@ XMLPUBFUN void XMLCALL
*
* Both general and parameter entities need to be substituted.
*/
-#define XML_SUBSTITUTE_BOTH 3
+#define XML_SUBSTITUTE_BOTH 3
XMLPUBFUN xmlChar * XMLCALL
xmlStringDecodeEntities (xmlParserCtxtPtr ctxt,
@@ -554,21 +596,21 @@ XMLPUBFUN htmlParserCtxtPtr XMLCALL htmlCreateFileParserCtxt(const char *filenam
typedef void (*xmlEntityReferenceFunc) (xmlEntityPtr ent,
xmlNodePtr firstNode,
xmlNodePtr lastNode);
-
+
XMLPUBFUN void XMLCALL xmlSetEntityReferenceFunc (xmlEntityReferenceFunc func);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlParseQuotedString (xmlParserCtxtPtr ctxt);
XMLPUBFUN void XMLCALL
xmlParseNamespace (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlNamespaceParseNSDef (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlScanName (xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlNamespaceParseNCName (xmlParserCtxtPtr ctxt);
XMLPUBFUN void XMLCALL xmlParserHandleReference(xmlParserCtxtPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlNamespaceParseQName (xmlParserCtxtPtr ctxt,
xmlChar **prefix);
/**
@@ -581,7 +623,7 @@ XMLPUBFUN xmlChar * XMLCALL
xmlChar end,
xmlChar end2,
xmlChar end3);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlHandleEntity (xmlParserCtxtPtr ctxt,
xmlEntityPtr entity);
diff --git a/gnulib-local/lib/libxml/pattern.c b/gnulib-local/lib/libxml/pattern.c
index cf41606..33dee3a 100644
--- a/gnulib-local/lib/libxml/pattern.c
+++ b/gnulib-local/lib/libxml/pattern.c
@@ -3,7 +3,7 @@
*
* Reference:
* http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/
- * to some extent
+ * to some extent
* http://www.w3.org/TR/1999/REC-xml-19991116
*
* See Copyright for the status of this software.
@@ -39,6 +39,9 @@
/* #define DEBUG_STREAMING */
+#ifdef ERROR
+#undef ERROR
+#endif
#define ERROR(a, b, c, d)
#define ERROR5(a, b, c, d, e)
@@ -53,7 +56,7 @@
* NOTE: Those private flags (XML_STREAM_xxx) are used
* in _xmlStreamCtxt->flag. They extend the public
* xmlPatternFlags, so be carefull not to interfere with the
-* reserved values for xmlPatternFlags.
+* reserved values for xmlPatternFlags.
*/
#define XML_STREAM_FINAL_IS_ANY_NODE 1<<14
#define XML_STREAM_FROM_ROOT 1<<15
@@ -159,7 +162,7 @@ struct _xmlStepOp {
#define PAT_FROM_CUR (1<<9)
struct _xmlPattern {
- void *data; /* the associated template */
+ void *data; /* the associated template */
xmlDictPtr dict; /* the optional dictionary */
struct _xmlPattern *next; /* next pattern if | is used */
const xmlChar *pattern; /* the pattern */
@@ -178,15 +181,15 @@ struct _xmlPatParserContext {
int error; /* error code */
xmlDictPtr dict; /* the dictionary if any */
xmlPatternPtr comp; /* the result */
- xmlNodePtr elem; /* the current node if any */
+ xmlNodePtr elem; /* the current node if any */
const xmlChar **namespaces; /* the namespaces definitions */
int nb_namespaces; /* the number of namespaces */
};
/************************************************************************
- * *
- * Type functions *
- * *
+ * *
+ * Type functions *
+ * *
************************************************************************/
/**
@@ -305,7 +308,8 @@ xmlNewPatParserContext(const xmlChar *pattern, xmlDictPtr dict,
cur->base = pattern;
if (namespaces != NULL) {
int i;
- for (i = 0;namespaces[2 * i] != NULL;i++);
+ for (i = 0;namespaces[2 * i] != NULL;i++)
+ ;
cur->nb_namespaces = i;
} else {
cur->nb_namespaces = 0;
@@ -323,7 +327,7 @@ xmlNewPatParserContext(const xmlChar *pattern, xmlDictPtr dict,
static void
xmlFreePatParserContext(xmlPatParserContextPtr ctxt) {
if (ctxt == NULL)
- return;
+ return;
memset(ctxt, -1, sizeof(xmlPatParserContext));
xmlFree(ctxt);
}
@@ -451,9 +455,9 @@ xmlReversePattern(xmlPatternPtr comp) {
}
/************************************************************************
- * *
- * The interpreter for the precompiled patterns *
- * *
+ * *
+ * The interpreter for the precompiled patterns *
+ * *
************************************************************************/
static int
@@ -705,7 +709,7 @@ rollback:
* *
************************************************************************/
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
@@ -715,14 +719,14 @@ rollback:
#define PEEKPREV(val) ctxt->cur[-(val)]
#define CUR_PTR ctxt->cur
-#define SKIP_BLANKS \
+#define SKIP_BLANKS \
while (IS_BLANK_CH(CUR)) NEXT
#define CURRENT (*ctxt->cur)
#define NEXT ((*ctxt->cur) ? ctxt->cur++: ctxt->cur)
-#define PUSH(op, val, val2) \
+#define PUSH(op, val, val2) \
if (xmlPatternAdd(ctxt, ctxt->comp, (op), (val), (val2))) goto error;
#define XSLT_ERROR(X) \
@@ -768,7 +772,7 @@ xmlPatScanLiteral(xmlPatParserContextPtr ctxt) {
if (ctxt->dict)
ret = (xmlChar *) xmlDictLookup(ctxt->dict, q, cur - q);
else
- ret = xmlStrndup(q, cur - q);
+ ret = xmlStrndup(q, cur - q);
}
cur += len;
CUR_PTR = cur;
@@ -787,7 +791,7 @@ xmlPatScanLiteral(xmlPatParserContextPtr ctxt) {
if (ctxt->dict)
ret = (xmlChar *) xmlDictLookup(ctxt->dict, q, cur - q);
else
- ret = xmlStrndup(q, cur - q);
+ ret = xmlStrndup(q, cur - q);
}
cur += len;
CUR_PTR = cur;
@@ -804,7 +808,7 @@ xmlPatScanLiteral(xmlPatParserContextPtr ctxt) {
* xmlPatScanName:
* @ctxt: the XPath Parser context
*
- * [4] NameChar ::= Letter | Digit | '.' | '-' | '_' |
+ * [4] NameChar ::= Letter | Digit | '.' | '-' | '_' |
* CombiningChar | Extender
*
* [5] Name ::= (Letter | '_' | ':') (NameChar)*
@@ -829,7 +833,7 @@ xmlPatScanName(xmlPatParserContextPtr ctxt) {
while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
(val == '.') || (val == '-') ||
- (val == '_') ||
+ (val == '_') ||
(IS_COMBINING(val)) ||
(IS_EXTENDER(val))) {
cur += len;
@@ -838,7 +842,7 @@ xmlPatScanName(xmlPatParserContextPtr ctxt) {
if (ctxt->dict)
ret = (xmlChar *) xmlDictLookup(ctxt->dict, q, cur - q);
else
- ret = xmlStrndup(q, cur - q);
+ ret = xmlStrndup(q, cur - q);
CUR_PTR = cur;
return(ret);
}
@@ -918,7 +922,7 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
xmlChar *token = NULL;
xmlChar *name = NULL;
xmlChar *URL = NULL;
-
+
SKIP_BLANKS;
name = xmlPatScanNCName(ctxt);
if (name == NULL) {
@@ -935,10 +939,10 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
if (CUR == ':') {
int i;
xmlChar *prefix = name;
-
+
NEXT;
- if (IS_BLANK_CH(CUR)) {
+ if (IS_BLANK_CH(CUR)) {
ERROR5(NULL, NULL, NULL, "Invalid QName.\n", NULL);
XML_PAT_FREE_STRING(ctxt, prefix);
ctxt->error = 1;
@@ -953,11 +957,11 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
(prefix[2] == 'l') &&
(prefix[3] == 0))
{
- XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE);
+ XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE);
} else {
for (i = 0;i < ctxt->nb_namespaces;i++) {
if (xmlStrEqual(ctxt->namespaces[2 * i + 1], prefix)) {
- XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i])
+ XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i])
break;
}
}
@@ -965,7 +969,7 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
ERROR5(NULL, NULL, NULL,
"xmlCompileAttributeTest : no namespace bound to prefix %s\n",
prefix);
- ctxt->error = 1;
+ ctxt->error = 1;
goto error;
}
}
@@ -979,7 +983,7 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
"xmlCompileAttributeTest : Name expected\n");
ctxt->error = 1;
goto error;
- }
+ }
} else {
PUSH(XML_OP_ATTR, token, URL);
}
@@ -989,7 +993,7 @@ xmlCompileAttributeTest(xmlPatParserContextPtr ctxt) {
return;
error:
if (URL != NULL)
- XML_PAT_FREE_STRING(ctxt, URL)
+ XML_PAT_FREE_STRING(ctxt, URL)
if (token != NULL)
XML_PAT_FREE_STRING(ctxt, token);
}
@@ -1002,7 +1006,7 @@ error:
* form suitable for fast matching.
*
* [3] Step ::= '.' | NameTest
- * [4] NameTest ::= QName | '*' | NCName ':' '*'
+ * [4] NameTest ::= QName | '*' | NCName ':' '*'
*/
static void
@@ -1033,7 +1037,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
}
NEXT;
xmlCompileAttributeTest(ctxt);
- if (ctxt->error != 0)
+ if (ctxt->error != 0)
goto error;
return;
}
@@ -1058,7 +1062,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
NEXT;
if (CUR != ':') {
xmlChar *prefix = name;
- int i;
+ int i;
if (hasBlanks || IS_BLANK_CH(CUR)) {
ERROR5(NULL, NULL, NULL, "Invalid QName.\n", NULL);
@@ -1091,6 +1095,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
}
}
XML_PAT_FREE_STRING(ctxt, prefix);
+ name = NULL;
if (token == NULL) {
if (CUR == '*') {
NEXT;
@@ -1106,7 +1111,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
}
} else {
NEXT;
- if (xmlStrEqual(name, (const xmlChar *) "child")) {
+ if (xmlStrEqual(name, (const xmlChar *) "child")) {
XML_PAT_FREE_STRING(ctxt, name);
name = xmlPatScanName(ctxt);
if (name == NULL) {
@@ -1124,7 +1129,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
if (CUR == ':') {
xmlChar *prefix = name;
int i;
-
+
NEXT;
if (IS_BLANK_CH(CUR)) {
ERROR5(NULL, NULL, NULL, "Invalid QName.\n", NULL);
@@ -1140,11 +1145,11 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
(prefix[2] == 'l') &&
(prefix[3] == 0))
{
- XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE)
+ XML_PAT_COPY_NSNAME(ctxt, URL, XML_XML_NAMESPACE)
} else {
for (i = 0;i < ctxt->nb_namespaces;i++) {
if (xmlStrEqual(ctxt->namespaces[2 * i + 1], prefix)) {
- XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i])
+ XML_PAT_COPY_NSNAME(ctxt, URL, ctxt->namespaces[2 * i])
break;
}
}
@@ -1157,6 +1162,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
}
}
XML_PAT_FREE_STRING(ctxt, prefix);
+ name = NULL;
if (token == NULL) {
if (CUR == '*') {
NEXT;
@@ -1191,7 +1197,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
"The 'element' or 'attribute' axis is expected.\n", NULL);
ctxt->error = 1;
goto error;
- }
+ }
}
} else if (CUR == '*') {
if (name != NULL) {
@@ -1206,7 +1212,7 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
return;
error:
if (URL != NULL)
- XML_PAT_FREE_STRING(ctxt, URL)
+ XML_PAT_FREE_STRING(ctxt, URL)
if (token != NULL)
XML_PAT_FREE_STRING(ctxt, token)
if (name != NULL)
@@ -1220,7 +1226,7 @@ error:
* Compile the Path Pattern and generates a precompiled
* form suitable for fast matching.
*
- * [5] Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest )
+ * [5] Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest )
*/
static void
xmlCompilePathPattern(xmlPatParserContextPtr ctxt) {
@@ -1230,7 +1236,7 @@ xmlCompilePathPattern(xmlPatParserContextPtr ctxt) {
} else if ((CUR == '.') || (ctxt->comp->flags & XML_PATTERN_NOTPATTERN)) {
ctxt->comp->flags |= PAT_FROM_CUR;
}
-
+
if ((CUR == '/') && (NXT(1) == '/')) {
PUSH(XML_OP_ANCESTOR, NULL, NULL);
NEXT;
@@ -1293,7 +1299,7 @@ xmlCompilePathPattern(xmlPatParserContextPtr ctxt) {
ERROR5(NULL, NULL, NULL,
"Incomplete expression '%s'.\n", ctxt->base);
ctxt->error = 1;
- goto error;
+ goto error;
}
xmlCompileStepPattern(ctxt);
if (ctxt->error != 0)
@@ -1317,7 +1323,7 @@ error:
* Compile the Path Pattern and generates a precompiled
* form suitable for fast matching.
*
- * [5] Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest )
+ * [5] Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest )
*/
static void
xmlCompileIDCXPathPath(xmlPatParserContextPtr ctxt) {
@@ -1372,7 +1378,7 @@ xmlCompileIDCXPathPath(xmlPatParserContextPtr ctxt) {
*/
do {
xmlCompileStepPattern(ctxt);
- if (ctxt->error != 0)
+ if (ctxt->error != 0)
goto error;
SKIP_BLANKS;
if (CUR != '/')
@@ -1391,7 +1397,7 @@ xmlCompileIDCXPathPath(xmlPatParserContextPtr ctxt) {
}
if (CUR == 0)
goto error_unfinished;
-
+
} while (CUR != 0);
if (CUR != 0) {
@@ -1407,7 +1413,7 @@ error:
error_unfinished:
ctxt->error = 1;
ERROR5(NULL, NULL, NULL,
- "Unfinished expression '%s'.\n", ctxt->base);
+ "Unfinished expression '%s'.\n", ctxt->base);
return;
}
@@ -1562,7 +1568,7 @@ xmlStreamCompAddStep(xmlStreamCompPtr comp, const xmlChar *name,
/**
* xmlStreamCompile:
* @comp: the precompiled pattern
- *
+ *
* Tries to stream compile a pattern
*
* Returns -1 in case of failure and 0 in case of success.
@@ -1599,7 +1605,7 @@ xmlStreamCompile(xmlPatternPtr comp) {
xmlDictReference(stream->dict);
}
- i = 0;
+ i = 0;
if (comp->flags & PAT_FROM_ROOT)
stream->flags |= XML_STREAM_FROM_ROOT;
@@ -1615,12 +1621,12 @@ xmlStreamCompile(xmlPatternPtr comp) {
break;
case XML_OP_NS:
s = xmlStreamCompAddStep(stream, NULL, step.value,
- XML_ELEMENT_NODE, flags);
+ XML_ELEMENT_NODE, flags);
if (s < 0)
goto error;
prevs = s;
- flags = 0;
- break;
+ flags = 0;
+ break;
case XML_OP_ATTR:
flags |= XML_STREAM_STEP_ATTR;
prevs = -1;
@@ -1630,7 +1636,7 @@ xmlStreamCompile(xmlPatternPtr comp) {
if (s < 0)
goto error;
break;
- case XML_OP_ELEM:
+ case XML_OP_ELEM:
if ((step.value == NULL) && (step.value2 == NULL)) {
/*
* We have a "." or "self::node()" here.
@@ -1649,7 +1655,7 @@ xmlStreamCompile(xmlPatternPtr comp) {
if (comp->nbStep == i + 1) {
stream->flags |= XML_STREAM_FINAL_IS_ANY_NODE;
}
- flags |= XML_STREAM_STEP_NODE;
+ flags |= XML_STREAM_STEP_NODE;
s = xmlStreamCompAddStep(stream, NULL, NULL,
XML_STREAM_ANY_NODE, flags);
if (s < 0)
@@ -1665,39 +1671,39 @@ xmlStreamCompile(xmlPatternPtr comp) {
stream->steps[prevs].flags |= XML_STREAM_STEP_IN_SET;
prevs = -1;
}
- break;
+ break;
} else {
/* Just skip this one. */
continue;
}
}
- /* An element node. */
+ /* An element node. */
s = xmlStreamCompAddStep(stream, step.value, step.value2,
- XML_ELEMENT_NODE, flags);
+ XML_ELEMENT_NODE, flags);
if (s < 0)
goto error;
prevs = s;
- flags = 0;
- break;
+ flags = 0;
+ break;
case XML_OP_CHILD:
/* An element node child. */
s = xmlStreamCompAddStep(stream, step.value, step.value2,
- XML_ELEMENT_NODE, flags);
+ XML_ELEMENT_NODE, flags);
if (s < 0)
goto error;
prevs = s;
flags = 0;
- break;
+ break;
case XML_OP_ALL:
s = xmlStreamCompAddStep(stream, NULL, NULL,
- XML_ELEMENT_NODE, flags);
+ XML_ELEMENT_NODE, flags);
if (s < 0)
goto error;
prevs = s;
flags = 0;
break;
- case XML_OP_PARENT:
+ case XML_OP_PARENT:
break;
case XML_OP_ANCESTOR:
/* Skip redundant continuations. */
@@ -1711,7 +1717,7 @@ xmlStreamCompile(xmlPatternPtr comp) {
stream->flags |= XML_STREAM_DESC;
break;
}
- }
+ }
if ((! root) && (comp->flags & XML_PATTERN_NOTPATTERN) == 0) {
/*
* If this should behave like a real pattern, we will mark
@@ -1723,7 +1729,7 @@ xmlStreamCompile(xmlPatternPtr comp) {
if (stream->nbStep > 0) {
if ((stream->steps[0].flags & XML_STREAM_STEP_DESC) == 0)
- stream->steps[0].flags |= XML_STREAM_STEP_DESC;
+ stream->steps[0].flags |= XML_STREAM_STEP_DESC;
}
}
if (stream->nbStep <= s)
@@ -1916,7 +1922,7 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
if ((nodeType != XML_ATTRIBUTE_NODE) &&
(((stream->flags & XML_PATTERN_NOTPATTERN) == 0) ||
(stream->level == 0))) {
- ret = 1;
+ ret = 1;
}
stream->level++;
goto stream_next;
@@ -1925,7 +1931,7 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
/*
* Skip blocked expressions.
*/
- stream->level++;
+ stream->level++;
goto stream_next;
}
@@ -1968,7 +1974,7 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
* If there are "//", then we need to process every "//"
* occuring in the states, plus any other state for this
* level.
- */
+ */
stepNr = stream->states[2 * i];
/* TODO: should not happen anymore: dead states */
@@ -1986,7 +1992,7 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
if ((tmp < stream->level) && (!desc))
goto next_state;
}
- /*
+ /*
* Check for correct node-type.
*/
step = comp->steps[stepNr];
@@ -2000,7 +2006,7 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
goto next_state;
} else if (step.nodeType != XML_STREAM_ANY_NODE)
goto next_state;
- }
+ }
/*
* Compare local/namespace-name.
*/
@@ -2021,9 +2027,9 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
xmlStrEqual(step.name, name) &&
((step.ns == ns) || xmlStrEqual(step.ns, ns)))
{
- match = 1;
- }
-#if 0
+ match = 1;
+ }
+#if 0
/*
* TODO: Pointer comparison won't work, since not guaranteed that the given
* values are in the same dict; especially if it's the namespace name,
@@ -2038,8 +2044,8 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
} else {
match = ((step.name == name) && (step.ns == ns));
}
-#endif /* if 0 ------------------------------------------------------- */
- if (match) {
+#endif /* if 0 ------------------------------------------------------- */
+ if (match) {
final = step.flags & XML_STREAM_STEP_FINAL;
if (desc) {
if (final) {
@@ -2064,7 +2070,7 @@ xmlStreamPushInternal(xmlStreamCtxtPtr stream,
*/
ret = 1;
}
- }
+ }
if (((comp->flags & XML_STREAM_DESC) == 0) &&
((! match) || final)) {
/*
@@ -2095,7 +2101,7 @@ next_state:
* Re/enter the expression if it is a "descendant" one,
* or if we are at the 1st level of evaluation.
*/
-
+
if (stream->level == 1) {
if (XML_STREAM_XS_IDC(stream)) {
/*
@@ -2105,7 +2111,7 @@ next_state:
goto stream_next;
} else
goto compare;
- }
+ }
/*
* A "//" is always reentrant.
*/
@@ -2115,14 +2121,14 @@ next_state:
/*
* XS-IDC: Process the 2nd level, since the missing
* "self::node()" is responsible for the 2nd level being
- * the real start level.
- */
+ * the real start level.
+ */
if ((stream->level == 2) && XML_STREAM_XS_IDC(stream))
goto compare;
goto stream_next;
}
-
+
compare:
/*
* Check expected node-type.
@@ -2131,7 +2137,7 @@ compare:
if (nodeType == XML_ATTRIBUTE_NODE)
goto stream_next;
else if (step.nodeType != XML_STREAM_ANY_NODE)
- goto stream_next;
+ goto stream_next;
}
/*
* Compare local/namespace-name.
@@ -2153,10 +2159,10 @@ compare:
xmlStrEqual(step.name, name) &&
((step.ns == ns) || xmlStrEqual(step.ns, ns)))
{
- match = 1;
- }
+ match = 1;
+ }
final = step.flags & XML_STREAM_STEP_FINAL;
- if (match) {
+ if (match) {
if (final)
ret = 1;
else
@@ -2181,7 +2187,7 @@ compare:
stream_next:
stream = stream->next;
} /* while stream != NULL */
-
+
if (err > 0)
ret = -1;
#ifdef DEBUG_STREAMING
@@ -2273,7 +2279,7 @@ xmlStreamPushAttr(xmlStreamCtxtPtr stream,
int
xmlStreamPop(xmlStreamCtxtPtr stream) {
int i, lev;
-
+
if (stream == NULL)
return(-1);
while (stream != NULL) {
@@ -2283,12 +2289,16 @@ xmlStreamPop(xmlStreamCtxtPtr stream) {
if (stream->blockLevel == stream->level)
stream->blockLevel = -1;
- stream->level--;
- if (stream->level < 0)
- return(-1);
+ /*
+ * stream->level can be zero when XML_FINAL_IS_ANY_NODE is set
+ * (see the thread at
+ * http://mail.gnome.org/archives/xslt/2008-July/msg00027.html)
+ */
+ if (stream->level)
+ stream->level--;
/*
* Check evolution of existing states
- */
+ */
for (i = stream->nbState -1; i >= 0; i--) {
/* discard obsoleted states */
lev = stream->states[(2 * i) + 1];
@@ -2316,11 +2326,11 @@ xmlStreamPop(xmlStreamCtxtPtr stream) {
*/
int
xmlStreamWantsAnyNode(xmlStreamCtxtPtr streamCtxt)
-{
+{
if (streamCtxt == NULL)
return(-1);
while (streamCtxt != NULL) {
- if (streamCtxt->comp->flags & XML_STREAM_FINAL_IS_ANY_NODE)
+ if (streamCtxt->comp->flags & XML_STREAM_FINAL_IS_ANY_NODE)
return(1);
streamCtxt = streamCtxt->next;
}
@@ -2371,13 +2381,13 @@ xmlPatterncompile(const xmlChar *pattern, xmlDict *dict, int flags,
}
or++;
}
- if (ctxt == NULL) goto error;
+ if (ctxt == NULL) goto error;
cur = xmlNewPattern();
if (cur == NULL) goto error;
/*
* Assign string dict.
*/
- if (dict) {
+ if (dict) {
cur->dict = dict;
xmlDictReference(dict);
}
@@ -2560,7 +2570,7 @@ xmlPatternMaxDepth(xmlPatternPtr comp) {
* part of the set.
*
* Returns -1 in case of error otherwise the depth,
- *
+ *
*/
int
xmlPatternMinDepth(xmlPatternPtr comp) {
diff --git a/gnulib-local/lib/libxml/relaxng.c b/gnulib-local/lib/libxml/relaxng.c
index 16527cc..5779e7f 100644
--- a/gnulib-local/lib/libxml/relaxng.c
+++ b/gnulib-local/lib/libxml/relaxng.c
@@ -39,9 +39,10 @@
static const xmlChar *xmlRelaxNGNs = (const xmlChar *)
"http://relaxng.org/ns/structure/1.0";
-#define IS_RELAXNG(node, type) \
+#define IS_RELAXNG(node, typ) \
((node != NULL) && (node->ns != NULL) && \
- (xmlStrEqual(node->name, (const xmlChar *) type)) && \
+ (node->type == XML_ELEMENT_NODE) && \
+ (xmlStrEqual(node->name, (const xmlChar *) typ)) && \
(xmlStrEqual(node->ns->href, xmlRelaxNGNs)))
@@ -60,7 +61,7 @@ static const xmlChar *xmlRelaxNGNs = (const xmlChar *)
#define DEBUG_LIST 1
-#define DEBUG_INCLUDE 1
+#define DEBUG_INCLUDE 1
#define DEBUG_ERROR 1
@@ -71,7 +72,7 @@ static const xmlChar *xmlRelaxNGNs = (const xmlChar *)
#define MAX_ERROR 5
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
@@ -149,6 +150,7 @@ typedef enum {
#define IS_PROCESSED (1 << 5)
#define IS_COMPILABLE (1 << 6)
#define IS_NOT_COMPILABLE (1 << 7)
+#define IS_EXTERNAL_REF (1 << 8)
struct _xmlRelaxNGDefine {
xmlRelaxNGType type; /* the type of definition */
@@ -414,12 +416,13 @@ struct _xmlRelaxNGDocument {
xmlDocPtr doc; /* the associated XML document */
xmlRelaxNGDefinePtr content; /* the definitions */
xmlRelaxNGPtr schema; /* the schema */
+ int externalRef; /* 1 if an external ref */
};
/************************************************************************
* *
- * Some factorized error routines *
+ * Some factorized error routines *
* *
************************************************************************/
@@ -562,9 +565,9 @@ xmlRngVErr(xmlRelaxNGValidCtxtPtr ctxt, xmlNodePtr node, int error,
}
/************************************************************************
- * *
- * Preliminary type checking interfaces *
- * *
+ * *
+ * Preliminary type checking interfaces *
+ * *
************************************************************************/
/**
@@ -652,9 +655,9 @@ struct _xmlRelaxNGTypeLibrary {
};
/************************************************************************
- * *
- * Allocation functions *
- * *
+ * *
+ * Allocation functions *
+ * *
************************************************************************/
static void xmlRelaxNGFreeGrammar(xmlRelaxNGGrammarPtr grammar);
static void xmlRelaxNGFreeDefine(xmlRelaxNGDefinePtr define);
@@ -1006,7 +1009,7 @@ xmlRelaxNGNewStates(xmlRelaxNGValidCtxtPtr ctxt, int size)
xmlRelaxNGStatesPtr ret;
if ((ctxt != NULL) &&
- (ctxt->freeState != NULL) && (ctxt->freeStatesNr > 0)) {
+ (ctxt->freeStates != NULL) && (ctxt->freeStatesNr > 0)) {
ctxt->freeStatesNr--;
ret = ctxt->freeStates[ctxt->freeStatesNr];
ret->nbState = 0;
@@ -1092,7 +1095,7 @@ xmlRelaxNGAddStates(xmlRelaxNGValidCtxtPtr ctxt,
{
int i;
- if (state == NULL) {
+ if (state == NULL || states == NULL) {
return (-1);
}
if (states->nbState >= states->maxState) {
@@ -1395,9 +1398,9 @@ xmlRelaxNGFreeValidState(xmlRelaxNGValidCtxtPtr ctxt,
}
/************************************************************************
- * *
- * Semi internal functions *
- * *
+ * *
+ * Semi internal functions *
+ * *
************************************************************************/
/**
@@ -1427,9 +1430,9 @@ xmlRelaxParserSetFlag(xmlRelaxNGParserCtxtPtr ctxt, int flags)
}
/************************************************************************
- * *
- * Document functions *
- * *
+ * *
+ * Document functions *
+ * *
************************************************************************/
static xmlDocPtr xmlRelaxNGCleanupDoc(xmlRelaxNGParserCtxtPtr ctxt,
xmlDocPtr doc);
@@ -1559,8 +1562,8 @@ xmlRelaxNGRemoveRedefine(xmlRelaxNGParserCtxtPtr ctxt,
href = xmlGetProp(tmp, BAD_CAST "href");
#endif
if (xmlRelaxNGRemoveRedefine(ctxt, href,
- inc->doc->children->
- children, name) == 1) {
+ xmlDocGetRootElement(inc->doc)->children,
+ name) == 1) {
found = 1;
}
#ifdef DEBUG_INCLUDE
@@ -1970,6 +1973,7 @@ xmlRelaxNGLoadExternalRef(xmlRelaxNGParserCtxtPtr ctxt,
ret->doc = doc;
ret->href = xmlStrdup(URL);
ret->next = ctxt->documents;
+ ret->externalRef = 1;
ctxt->documents = ret;
/*
@@ -2004,9 +2008,9 @@ xmlRelaxNGLoadExternalRef(xmlRelaxNGParserCtxtPtr ctxt,
}
/************************************************************************
- * *
- * Error functions *
- * *
+ * *
+ * Error functions *
+ * *
************************************************************************/
#define VALID_ERR(a) xmlRelaxNGAddValidError(ctxt, a, NULL, NULL, 0);
@@ -2357,7 +2361,7 @@ xmlRelaxNGAddValidError(xmlRelaxNGValidCtxtPtr ctxt,
* generate the error directly
*/
if (((ctxt->flags & FLAGS_IGNORABLE) == 0) ||
- (ctxt->flags & FLAGS_NEGATIVE)) {
+ (ctxt->flags & FLAGS_NEGATIVE)) {
xmlNodePtr node, seq;
/*
@@ -2372,6 +2376,9 @@ xmlRelaxNGAddValidError(xmlRelaxNGValidCtxtPtr ctxt,
} else {
node = seq = NULL;
}
+ if ((node == NULL) && (seq == NULL)) {
+ node = ctxt->pnode;
+ }
xmlRelaxNGShowValidError(ctxt, err, node, seq, arg1, arg2);
}
/*
@@ -2384,9 +2391,9 @@ xmlRelaxNGAddValidError(xmlRelaxNGValidCtxtPtr ctxt,
/************************************************************************
- * *
- * Type library hooks *
- * *
+ * *
+ * Type library hooks *
+ * *
************************************************************************/
static xmlChar *xmlRelaxNGNormalize(xmlRelaxNGValidCtxtPtr ctxt,
const xmlChar * str);
@@ -2588,13 +2595,10 @@ xmlRelaxNGSchemaTypeCompare(void *data ATTRIBUTE_UNUSED,
}
ret = xmlSchemaValPredefTypeNode(typ, value2, &res2, ctxt2);
if (ret != 0) {
- if ((comp1 == NULL) && (res1 != NULL))
+ if (res1 != (xmlSchemaValPtr) comp1)
xmlSchemaFreeValue(res1);
return (-1);
}
- if (res1 == NULL) {
- return (-1);
- }
ret = xmlSchemaCompareValues(res1, res2);
if (res1 != (xmlSchemaValPtr) comp1)
xmlSchemaFreeValue(res1);
@@ -2841,14 +2845,18 @@ xmlRelaxNGCleanupTypes(void)
}
/************************************************************************
- * *
- * Compiling element content into regexp *
- * *
+ * *
+ * Compiling element content into regexp *
+ * *
* Sometime the element content can be compiled into a pure regexp, *
* This allows a faster execution and streamability at that level *
- * *
+ * *
************************************************************************/
+/* from automata.c but not exported */
+void xmlAutomataSetFlags(xmlAutomataPtr am, int flags);
+
+
static int xmlRelaxNGTryCompile(xmlRelaxNGParserCtxtPtr ctxt,
xmlRelaxNGDefinePtr def);
@@ -3032,14 +3040,25 @@ xmlRelaxNGCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def)
ctxt->am = xmlNewAutomata();
if (ctxt->am == NULL)
return (-1);
+
+ /*
+ * assume identical strings but not same pointer are different
+ * atoms, needed for non-determinism detection
+ * That way if 2 elements with the same name are in a choice
+ * branch the automata is found non-deterministic and
+ * we fallback to the normal validation which does the right
+ * thing of exploring both choices.
+ */
+ xmlAutomataSetFlags(ctxt->am, 1);
+
ctxt->state = xmlAutomataGetInitState(ctxt->am);
while (list != NULL) {
xmlRelaxNGCompile(ctxt, list);
list = list->next;
}
xmlAutomataSetFinalState(ctxt->am, ctxt->state);
- def->contModel = xmlAutomataCompile(ctxt->am);
- xmlRegexpIsDeterminist(def->contModel);
+ if (xmlAutomataIsDeterminist(ctxt->am))
+ def->contModel = xmlAutomataCompile(ctxt->am);
xmlFreeAutomata(ctxt->am);
ctxt->state = oldstate;
@@ -3063,6 +3082,7 @@ xmlRelaxNGCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def)
ctxt->am = xmlNewAutomata();
if (ctxt->am == NULL)
return (-1);
+ xmlAutomataSetFlags(ctxt->am, 1);
ctxt->state = xmlAutomataGetInitState(ctxt->am);
while (list != NULL) {
xmlRelaxNGCompile(ctxt, list);
@@ -3071,6 +3091,11 @@ xmlRelaxNGCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def)
xmlAutomataSetFinalState(ctxt->am, ctxt->state);
def->contModel = xmlAutomataCompile(ctxt->am);
if (!xmlRegexpIsDeterminist(def->contModel)) {
+#ifdef DEBUG_COMPILE
+ xmlGenericError(xmlGenericErrorContext,
+ "Content model not determinist %s\n",
+ def->name);
+#endif
/*
* we can only use the automata if it is determinist
*/
@@ -3098,7 +3123,11 @@ xmlRelaxNGCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def)
case XML_RELAXNG_OPTIONAL:{
xmlAutomataStatePtr oldstate = ctxt->state;
- xmlRelaxNGCompile(ctxt, def->content);
+ list = def->content;
+ while (list != NULL) {
+ xmlRelaxNGCompile(ctxt, list);
+ list = list->next;
+ }
xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state);
break;
}
@@ -3294,9 +3323,9 @@ xmlRelaxNGTryCompile(xmlRelaxNGParserCtxtPtr ctxt, xmlRelaxNGDefinePtr def)
}
/************************************************************************
- * *
- * Parsing functions *
- * *
+ * *
+ * Parsing functions *
+ * *
************************************************************************/
static xmlRelaxNGDefinePtr xmlRelaxNGParseAttribute(xmlRelaxNGParserCtxtPtr
@@ -3440,6 +3469,9 @@ xmlRelaxNGGetDataTypeLibrary(xmlRelaxNGParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
{
xmlChar *ret, *escape;
+ if (node == NULL)
+ return(NULL);
+
if ((IS_RELAXNG(node, "data")) || (IS_RELAXNG(node, "value"))) {
ret = xmlGetProp(node, BAD_CAST "datatypeLibrary");
if (ret != NULL) {
@@ -3787,7 +3819,11 @@ xmlRelaxNGCompareNameClasses(xmlRelaxNGDefinePtr def1,
return (0);
return (1);
} else if (def1->type == XML_RELAXNG_EXCEPT) {
- TODO ret = 0;
+ ret = xmlRelaxNGCompareNameClasses(def1->content, def2);
+ if (ret == 0)
+ ret = 1;
+ else if (ret == 1)
+ ret = 0;
} else {
TODO ret = 0;
}
@@ -4616,6 +4652,72 @@ xmlRelaxNGParseDefine(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
}
/**
+ * xmlRelaxNGParseImportRef:
+ * @payload: the parser context
+ * @data: the current grammar
+ * @name: the reference name
+ *
+ * Import import one references into the current grammar
+ */
+static void
+xmlRelaxNGParseImportRef(void *payload, void *data, xmlChar *name) {
+ xmlRelaxNGParserCtxtPtr ctxt = (xmlRelaxNGParserCtxtPtr) data;
+ xmlRelaxNGDefinePtr def = (xmlRelaxNGDefinePtr) payload;
+ int tmp;
+
+ def->dflags |= IS_EXTERNAL_REF;
+
+ tmp = xmlHashAddEntry(ctxt->grammar->refs, name, def);
+ if (tmp < 0) {
+ xmlRelaxNGDefinePtr prev;
+
+ prev = (xmlRelaxNGDefinePtr)
+ xmlHashLookup(ctxt->grammar->refs, def->name);
+ if (prev == NULL) {
+ if (def->name != NULL) {
+ xmlRngPErr(ctxt, NULL, XML_RNGP_REF_CREATE_FAILED,
+ "Error refs definitions '%s'\n",
+ def->name, NULL);
+ } else {
+ xmlRngPErr(ctxt, NULL, XML_RNGP_REF_CREATE_FAILED,
+ "Error refs definitions\n",
+ NULL, NULL);
+ }
+ } else {
+ def->nextHash = prev->nextHash;
+ prev->nextHash = def;
+ }
+ }
+}
+
+/**
+ * xmlRelaxNGParseImportRefs:
+ * @ctxt: the parser context
+ * @grammar: the sub grammar
+ *
+ * Import references from the subgrammar into the current grammar
+ *
+ * Returns 0 in case of success, -1 in case of failure
+ */
+static int
+xmlRelaxNGParseImportRefs(xmlRelaxNGParserCtxtPtr ctxt,
+ xmlRelaxNGGrammarPtr grammar) {
+ if ((ctxt == NULL) || (grammar == NULL) || (ctxt->grammar == NULL))
+ return(-1);
+ if (grammar->refs == NULL)
+ return(0);
+ if (ctxt->grammar->refs == NULL)
+ ctxt->grammar->refs = xmlHashCreate(10);
+ if (ctxt->grammar->refs == NULL) {
+ xmlRngPErr(ctxt, NULL, XML_RNGP_REF_CREATE_FAILED,
+ "Could not create references hash\n", NULL, NULL);
+ return(-1);
+ }
+ xmlHashScan(grammar->refs, xmlRelaxNGParseImportRef, ctxt);
+ return(0);
+}
+
+/**
* xmlRelaxNGProcessExternalRef:
* @ctxt: the parser context
* @node: the externlRef node
@@ -4683,6 +4785,8 @@ xmlRelaxNGProcessExternalRef(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
if ((docu->schema != NULL) &&
(docu->schema->topgrammar != NULL)) {
docu->content = docu->schema->topgrammar->start;
+ if (docu->schema->topgrammar->refs)
+ xmlRelaxNGParseImportRefs(ctxt, docu->schema->topgrammar);
}
/*
@@ -5267,7 +5371,8 @@ xmlRelaxNGParseNameClass(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node,
} else {
xmlRngPErr(ctxt, node, XML_RNGP_CHOICE_CONTENT,
"expecting name, anyName, nsName or choice : got %s\n",
- node->name, NULL);
+ (node == NULL ? (const xmlChar *) "nothing" : node->name),
+ NULL);
return (NULL);
}
if (ret != def) {
@@ -5569,6 +5674,12 @@ xmlRelaxNGCheckReference(xmlRelaxNGDefinePtr ref,
xmlRelaxNGGrammarPtr grammar;
xmlRelaxNGDefinePtr def, cur;
+ /*
+ * Those rules don't apply to imported ref from xmlRelaxNGParseImportRef
+ */
+ if (ref->dflags & IS_EXTERNAL_REF)
+ return;
+
grammar = ctxt->grammar;
if (grammar == NULL) {
xmlRngPErr(ctxt, ref->node, XML_ERR_INTERNAL_ERROR,
@@ -6133,7 +6244,7 @@ xmlRelaxNGCheckRules(xmlRelaxNGParserCtxtPtr ctxt,
xmlRelaxNGDefinePtr cur, int flags,
xmlRelaxNGType ptype)
{
- int nflags = flags;
+ int nflags;
xmlRelaxNGContentType ret, tmp, val = XML_RELAXNG_CONTENT_EMPTY;
while (cur != NULL) {
@@ -6157,6 +6268,16 @@ xmlRelaxNGCheckRules(xmlRelaxNGParserCtxtPtr ctxt,
"Found forbidden pattern data/except//ref\n",
NULL, NULL);
}
+ if (cur->content == NULL) {
+ if (cur->type == XML_RELAXNG_PARENTREF)
+ xmlRngPErr(ctxt, cur->node, XML_RNGP_REF_NO_DEF,
+ "Internal found no define for parent refs\n",
+ NULL, NULL);
+ else
+ xmlRngPErr(ctxt, cur->node, XML_RNGP_REF_NO_DEF,
+ "Internal found no define for ref %s\n",
+ (cur->name ? cur->name: BAD_CAST "null"), NULL);
+ }
if (cur->depth > -4) {
cur->depth = -4;
ret = xmlRelaxNGCheckRules(ctxt, cur->content,
@@ -6408,6 +6529,10 @@ xmlRelaxNGCheckRules(xmlRelaxNGParserCtxtPtr ctxt,
if (ptype == XML_RELAXNG_GROUP) {
val = xmlRelaxNGGroupContentType(val, ret);
} else if (ptype == XML_RELAXNG_INTERLEAVE) {
+ /*
+ * TODO: scan complain that tmp is never used, seems on purpose
+ * need double-checking
+ */
tmp = xmlRelaxNGGroupContentType(val, ret);
if (tmp != XML_RELAXNG_CONTENT_ERROR)
tmp = xmlRelaxNGMaxContentType(val, ret);
@@ -6479,7 +6604,7 @@ xmlRelaxNGParseGrammar(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes)
}
/*
- * Apply 4.17 mergingd rules to defines and starts
+ * Apply 4.17 merging rules to defines and starts
*/
xmlRelaxNGCombineStart(ctxt, ret);
if (ret->defs != NULL) {
@@ -6495,6 +6620,9 @@ xmlRelaxNGParseGrammar(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr nodes)
ctxt);
}
+
+ /* @@@@ */
+
ctxt->grammar = old;
return (ret);
}
@@ -6528,12 +6656,17 @@ xmlRelaxNGParseDocument(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
ctxt->define = NULL;
if (IS_RELAXNG(node, "grammar")) {
schema->topgrammar = xmlRelaxNGParseGrammar(ctxt, node->children);
+ if (schema->topgrammar == NULL) {
+ xmlRelaxNGFree(schema);
+ return (NULL);
+ }
} else {
xmlRelaxNGGrammarPtr tmp, ret;
schema->topgrammar = ret = xmlRelaxNGNewGrammar(ctxt);
if (schema->topgrammar == NULL) {
- return (schema);
+ xmlRelaxNGFree(schema);
+ return (NULL);
}
/*
* Link the new grammar in the tree
@@ -6579,9 +6712,9 @@ xmlRelaxNGParseDocument(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node)
}
/************************************************************************
- * *
- * Reading RelaxNGs *
- * *
+ * *
+ * Reading RelaxNGs *
+ * *
************************************************************************/
/**
@@ -7190,7 +7323,7 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root)
}
}
/*
- * Thisd is not an else since "include" is transformed
+ * This is not an else since "include" is transformed
* into a div
*/
if (xmlStrEqual(cur->name, BAD_CAST "div")) {
@@ -7219,13 +7352,13 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root)
if (ns != NULL)
xmlFree(ns);
/*
- * Since we are about to delete cur, if it's nsDef is non-NULL we
+ * Since we are about to delete cur, if its nsDef is non-NULL we
* need to preserve it (it contains the ns definitions for the
* children we just moved). We'll just stick it on to the end
* of cur->parent's list, since it's never going to be re-serialized
* (bug 143738).
*/
- if (cur->nsDef != NULL) {
+ if ((cur->nsDef != NULL) && (cur->parent != NULL)) {
xmlNsPtr parDef = (xmlNsPtr)&cur->parent->nsDef;
while (parDef->next != NULL)
parDef = parDef->next;
@@ -7243,7 +7376,8 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root)
else if ((cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE)) {
if (IS_BLANK_NODE(cur)) {
- if (cur->parent->type == XML_ELEMENT_NODE) {
+ if ((cur->parent != NULL) &&
+ (cur->parent->type == XML_ELEMENT_NODE)) {
if ((!xmlStrEqual(cur->parent->name, BAD_CAST "value"))
&&
(!xmlStrEqual
@@ -7395,7 +7529,7 @@ xmlRelaxNGParse(xmlRelaxNGParserCtxtPtr ctxt)
xmlRngPErr(ctxt, (xmlNodePtr) doc,
XML_RNGP_EMPTY, "xmlRelaxNGParse: %s is empty\n",
(ctxt->URL ? ctxt->URL : BAD_CAST "schemas"), NULL);
-
+
xmlFreeDoc(ctxt->document);
ctxt->document = NULL;
return (NULL);
@@ -7537,9 +7671,9 @@ xmlRelaxNGSetParserStructuredErrors(xmlRelaxNGParserCtxtPtr ctxt,
#ifdef LIBXML_OUTPUT_ENABLED
/************************************************************************
- * *
- * Dump back a compiled form *
- * *
+ * *
+ * Dump back a compiled form *
+ * *
************************************************************************/
static void xmlRelaxNGDumpDefine(FILE * output,
xmlRelaxNGDefinePtr define);
@@ -7680,7 +7814,7 @@ xmlRelaxNGDumpDefine(FILE * output, xmlRelaxNGDefinePtr define)
* xmlRelaxNGDumpGrammar:
* @output: the file output
* @grammar: a grammar structure
- * @top: is this a top grammar
+ * @top: is this a top grammar
*
* Dump a RelaxNG structure back
*/
@@ -7773,9 +7907,9 @@ xmlRelaxNGDumpTree(FILE * output, xmlRelaxNGPtr schema)
#endif /* LIBXML_OUTPUT_ENABLED */
/************************************************************************
- * *
- * Validation of compiled content *
- * *
+ * *
+ * Validation of compiled content *
+ * *
************************************************************************/
static int xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGDefinePtr define);
@@ -7918,9 +8052,9 @@ xmlRelaxNGValidateCompiledContent(xmlRelaxNGValidCtxtPtr ctxt,
}
/************************************************************************
- * *
- * Progressive validation of when possible *
- * *
+ * *
+ * Progressive validation of when possible *
+ * *
************************************************************************/
static int xmlRelaxNGValidateAttributeList(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGDefinePtr defines);
@@ -8220,7 +8354,7 @@ xmlRelaxNGValidatePushElement(xmlRelaxNGValidCtxtPtr ctxt,
* xmlRelaxNGValidatePushCData:
* @ctxt: the RelaxNG validation context
* @data: some character data read
- * @len: the lenght of the data
+ * @len: the length of the data
*
* check the CData parsed for validation in the current stack
*
@@ -8343,7 +8477,7 @@ xmlRelaxNGValidateFullElement(xmlRelaxNGValidCtxtPtr ctxt,
ret = -1;
else
ret = 1;
- xmlRelaxNGFreeValidState(ctxt, state);
+ xmlRelaxNGFreeValidState(ctxt, ctxt->state);
ctxt->state = NULL;
#ifdef DEBUG_PROGRESSIVE
if (ret < 0)
@@ -8354,9 +8488,9 @@ xmlRelaxNGValidateFullElement(xmlRelaxNGValidCtxtPtr ctxt,
}
/************************************************************************
- * *
- * Generic interpreted validation implementation *
- * *
+ * *
+ * Generic interpreted validation implementation *
+ * *
************************************************************************/
static int xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGDefinePtr define);
@@ -8758,6 +8892,11 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
case XML_RELAXNG_ZEROORMORE:{
xmlChar *cur, *temp;
+ if ((ctxt->state->value == NULL) ||
+ (*ctxt->state->value == 0)) {
+ ret = 0;
+ break;
+ }
oldflags = ctxt->flags;
ctxt->flags |= FLAGS_IGNORABLE;
cur = ctxt->state->value;
@@ -8779,6 +8918,30 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGPopErrors(ctxt, 0);
break;
}
+ case XML_RELAXNG_OPTIONAL:{
+ xmlChar *temp;
+
+ if ((ctxt->state->value == NULL) ||
+ (*ctxt->state->value == 0)) {
+ ret = 0;
+ break;
+ }
+ oldflags = ctxt->flags;
+ ctxt->flags |= FLAGS_IGNORABLE;
+ temp = ctxt->state->value;
+ ret = xmlRelaxNGValidateValue(ctxt, define->content);
+ ctxt->flags = oldflags;
+ if (ret != 0) {
+ ctxt->state->value = temp;
+ if (ctxt->errNr > 0)
+ xmlRelaxNGPopErrors(ctxt, 0);
+ ret = 0;
+ break;
+ }
+ if (ctxt->errNr > 0)
+ xmlRelaxNGPopErrors(ctxt, 0);
+ break;
+ }
case XML_RELAXNG_EXCEPT:{
xmlRelaxNGDefinePtr list;
@@ -8812,7 +8975,12 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidCtxtPtr ctxt,
}
case XML_RELAXNG_REF:
case XML_RELAXNG_PARENTREF:
- ret = xmlRelaxNGValidateValue(ctxt, define->content);
+ if (define->content == NULL) {
+ VALID_ERR(XML_RELAXNG_ERR_NODEFINE);
+ ret = -1;
+ } else {
+ ret = xmlRelaxNGValidateValue(ctxt, define->content);
+ }
break;
default:
TODO ret = -1;
@@ -8889,6 +9057,19 @@ xmlRelaxNGAttributeMatch(xmlRelaxNGValidCtxtPtr ctxt,
return (ret);
list = list->next;
}
+ } else if (define->type == XML_RELAXNG_CHOICE) {
+ xmlRelaxNGDefinePtr list;
+
+ list = define->nameClass;
+ while (list != NULL) {
+ ret = xmlRelaxNGAttributeMatch(ctxt, list, prop);
+ if (ret == 1)
+ return (1);
+ if (ret < 0)
+ return (ret);
+ list = list->next;
+ }
+ return (0);
} else {
TODO}
return (1);
@@ -9248,6 +9429,10 @@ xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt,
oldstate = ctxt->state;
for (i = 0; i < nbgroups; i++) {
ctxt->state = xmlRelaxNGCopyValidState(ctxt, oldstate);
+ if (ctxt->state == NULL) {
+ ret = -1;
+ break;
+ }
group = partitions->groups[i];
if (lasts[i] != NULL) {
last = lasts[i]->next;
@@ -9319,6 +9504,7 @@ xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt,
oldstate =
ctxt->states->tabState[ctxt->states->nbState - 1];
ctxt->states->tabState[ctxt->states->nbState - 1] = NULL;
+ ctxt->states->nbState--;
}
}
for (j = 0; j < ctxt->states->nbState ; j++) {
@@ -9327,7 +9513,12 @@ xmlRelaxNGValidateInterleave(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGFreeStates(ctxt, ctxt->states);
ctxt->states = NULL;
if (found == 0) {
- VALID_ERR2(XML_RELAXNG_ERR_INTEREXTRA, cur->name);
+ if (cur == NULL) {
+ VALID_ERR2(XML_RELAXNG_ERR_INTEREXTRA,
+ (const xmlChar *) "noname");
+ } else {
+ VALID_ERR2(XML_RELAXNG_ERR_INTEREXTRA, cur->name);
+ }
ret = -1;
ctxt->state = oldstate;
goto done;
@@ -9672,7 +9863,7 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
ctxt->depth++;
switch (define->type) {
case XML_RELAXNG_EMPTY:
- node = xmlRelaxNGSkipIgnored(ctxt, node);
+ xmlRelaxNGSkipIgnored(ctxt, node);
ret = 0;
break;
case XML_RELAXNG_NOT_ALLOWED:
@@ -9828,7 +10019,8 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
ret = -1;
} else {
state = ctxt->state;
- ctxt->state->seq = nseq;
+ if (ctxt->state != NULL)
+ ctxt->state->seq = nseq;
if (ret == 0)
ret = xmlRelaxNGValidateElementEnd(ctxt, 1);
xmlRelaxNGFreeValidState(ctxt, state);
@@ -9873,8 +10065,8 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
}
for (i = 0; i < ctxt->states->nbState; i++) {
xmlRelaxNGFreeValidState(ctxt,
- ctxt->states->
- tabState[i]);
+ ctxt->states->tabState[i]);
+ ctxt->states->tabState[i] = NULL;
}
xmlRelaxNGFreeStates(ctxt, ctxt->states);
ctxt->flags = oldflags;
@@ -9996,11 +10188,8 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
} else {
for (j = 0; j < ctxt->states->nbState; j++) {
xmlRelaxNGAddStates(ctxt, res,
- xmlRelaxNGCopyValidState(ctxt,
- ctxt->
- states->
- tabState
- [j]));
+ xmlRelaxNGCopyValidState(ctxt,
+ ctxt->states->tabState[j]));
}
}
oldflags = ctxt->flags;
@@ -10029,10 +10218,7 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
j++) {
tmp =
xmlRelaxNGAddStates(ctxt, res,
- ctxt->
- states->
- tabState
- [j]);
+ ctxt->states->tabState[j]);
if (tmp == 1)
progress = 1;
}
@@ -10066,9 +10252,7 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
} else if (ctxt->states != NULL) {
for (j = 0; j < ctxt->states->nbState; j++) {
tmp = xmlRelaxNGAddStates(ctxt, res,
- ctxt->
- states->
- tabState[j]);
+ ctxt->states->tabState[j]);
if (tmp == 1)
progress = 1;
}
@@ -10106,8 +10290,7 @@ xmlRelaxNGValidateState(xmlRelaxNGValidCtxtPtr ctxt,
for (i = base; i < res->nbState; i++)
xmlRelaxNGAddStates(ctxt, states,
xmlRelaxNGCopyValidState
- (ctxt,
- res->tabState[i]));
+ (ctxt, res->tabState[i]));
ctxt->states = states;
}
}
@@ -10629,10 +10812,64 @@ xmlRelaxNGValidateDocument(xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc)
return (ret);
}
+/**
+ * xmlRelaxNGCleanPSVI:
+ * @node: an input element or document
+ *
+ * Call this routine to speed up XPath computation on static documents.
+ * This stamps all the element nodes with the document order
+ * Like for line information, the order is kept in the element->content
+ * field, the value stored is actually - the node number (starting at -1)
+ * to be able to differentiate from line numbers.
+ *
+ * Returns the number of elements found in the document or -1 in case
+ * of error.
+ */
+static void
+xmlRelaxNGCleanPSVI(xmlNodePtr node) {
+ xmlNodePtr cur;
+
+ if ((node == NULL) ||
+ ((node->type != XML_ELEMENT_NODE) &&
+ (node->type != XML_DOCUMENT_NODE) &&
+ (node->type != XML_HTML_DOCUMENT_NODE)))
+ return;
+ if (node->type == XML_ELEMENT_NODE)
+ node->psvi = NULL;
+
+ cur = node->children;
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE) {
+ cur->psvi = NULL;
+ if (cur->children != NULL) {
+ cur = cur->children;
+ continue;
+ }
+ }
+ if (cur->next != NULL) {
+ cur = cur->next;
+ continue;
+ }
+ do {
+ cur = cur->parent;
+ if (cur == NULL)
+ break;
+ if (cur == node) {
+ cur = NULL;
+ break;
+ }
+ if (cur->next != NULL) {
+ cur = cur->next;
+ break;
+ }
+ } while (cur != NULL);
+ }
+ return;
+}
/************************************************************************
- * *
- * Validation interfaces *
- * *
+ * *
+ * Validation interfaces *
+ * *
************************************************************************/
/**
@@ -10803,6 +11040,11 @@ xmlRelaxNGValidateDoc(xmlRelaxNGValidCtxtPtr ctxt, xmlDocPtr doc)
ret = xmlRelaxNGValidateDocument(ctxt, doc);
/*
+ * Remove all left PSVI
+ */
+ xmlRelaxNGCleanPSVI((xmlNodePtr) doc);
+
+ /*
* TODO: build error codes
*/
if (ret == -1)
diff --git a/gnulib-local/lib/libxml/relaxng.in.h b/gnulib-local/lib/libxml/relaxng.in.h
index 6acd467..f269c9e 100644
--- a/gnulib-local/lib/libxml/relaxng.in.h
+++ b/gnulib-local/lib/libxml/relaxng.in.h
@@ -25,11 +25,32 @@ typedef xmlRelaxNG *xmlRelaxNGPtr;
/**
- * A schemas validation context
+ * xmlRelaxNGValidityErrorFunc:
+ * @ctx: the validation context
+ * @msg: the message
+ * @...: extra arguments
+ *
+ * Signature of an error callback from a Relax-NG validation
+ */
+typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx,
+ const char *msg,
+ ...) LIBXML_ATTR_FORMAT(2,3);
+
+/**
+ * xmlRelaxNGValidityWarningFunc:
+ * @ctx: the validation context
+ * @msg: the message
+ * @...: extra arguments
+ *
+ * Signature of a warning callback from a Relax-NG validation
*/
-typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...);
-typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...);
+typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx,
+ const char *msg,
+ ...) LIBXML_ATTR_FORMAT(2,3);
+/**
+ * A schemas validation context
+ */
typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt;
typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr;
@@ -97,27 +118,27 @@ typedef enum {
XMLPUBFUN int XMLCALL
xmlRelaxNGInitTypes (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRelaxNGCleanupTypes (void);
/*
* Interfaces for parsing.
*/
-XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
+XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
xmlRelaxNGNewParserCtxt (const char *URL);
-XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
+XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
xmlRelaxNGNewMemParserCtxt (const char *buffer,
int size);
-XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
+XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
xmlRelaxNGNewDocParserCtxt (xmlDocPtr doc);
XMLPUBFUN int XMLCALL
xmlRelaxParserSetFlag (xmlRelaxNGParserCtxtPtr ctxt,
- int flag);
+ int flag);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
xmlRelaxNGValidityErrorFunc err,
xmlRelaxNGValidityWarningFunc warn,
@@ -132,12 +153,12 @@ XMLPUBFUN void XMLCALL
xmlRelaxNGParserCtxtPtr ctxt,
xmlStructuredErrorFunc serror,
void *ctx);
-XMLPUBFUN xmlRelaxNGPtr XMLCALL
+XMLPUBFUN xmlRelaxNGPtr XMLCALL
xmlRelaxNGParse (xmlRelaxNGParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRelaxNGFree (xmlRelaxNGPtr schema);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRelaxNGDump (FILE *output,
xmlRelaxNGPtr schema);
XMLPUBFUN void XMLCALL
@@ -147,12 +168,12 @@ XMLPUBFUN void XMLCALL
/*
* Interfaces for validating
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGValidityErrorFunc err,
xmlRelaxNGValidityWarningFunc warn,
void *ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
xmlRelaxNGValidityErrorFunc *err,
xmlRelaxNGValidityWarningFunc *warn,
@@ -160,29 +181,29 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN void XMLCALL
xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,
xmlStructuredErrorFunc serror, void *ctx);
-XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL
+XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL
xmlRelaxNGNewValidCtxt (xmlRelaxNGPtr schema);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxtPtr ctxt,
- xmlDocPtr doc);
+ xmlDocPtr doc);
/*
* Interfaces for progressive validation when possible
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxtPtr ctxt,
const xmlChar *data,
int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem);
diff --git a/gnulib-local/lib/libxml/save.h b/gnulib-local/lib/libxml/save.h
new file mode 100644
index 0000000..2c32a10
--- /dev/null
+++ b/gnulib-local/lib/libxml/save.h
@@ -0,0 +1,35 @@
+/*
+ * Summary: Internal Interfaces for saving in libxml2
+ * Description: this module describes a few interfaces which were
+ * addded along with the API changes in 2.9.0
+ * those are private routines at this point
+ *
+ * Copy: See Copyright for the status of this software.
+ *
+ * Author: Daniel Veillard
+ */
+
+#ifndef __XML_SAVE_H__
+#define __XML_SAVE_H__
+
+#include <libxml/tree.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#ifdef LIBXML_OUTPUT_ENABLED
+void xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc,
+ xmlAttrPtr attr, const xmlChar * string);
+void xmlBufDumpNotationTable(xmlBufPtr buf, xmlNotationTablePtr table);
+void xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem);
+void xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr);
+void xmlBufDumpEntityDecl(xmlBufPtr buf, xmlEntityPtr ent);
+xmlChar *xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __XML_SAVE_H__ */
+
diff --git a/gnulib-local/lib/libxml/schemasInternals.in.h b/gnulib-local/lib/libxml/schemasInternals.in.h
index b68a6e1..4f0ca9a 100644
--- a/gnulib-local/lib/libxml/schemasInternals.in.h
+++ b/gnulib-local/lib/libxml/schemasInternals.in.h
@@ -104,8 +104,8 @@ typedef enum {
XML_SCHEMA_TYPE_IDC_UNIQUE,
XML_SCHEMA_TYPE_IDC_KEY,
XML_SCHEMA_TYPE_IDC_KEYREF,
- XML_SCHEMA_TYPE_PARTICLE = 25,
- XML_SCHEMA_TYPE_ATTRIBUTE_USE,
+ XML_SCHEMA_TYPE_PARTICLE = 25,
+ XML_SCHEMA_TYPE_ATTRIBUTE_USE,
XML_SCHEMA_FACET_MININCLUSIVE = 1000,
XML_SCHEMA_FACET_MINEXCLUSIVE,
XML_SCHEMA_FACET_MAXINCLUSIVE,
diff --git a/gnulib-local/lib/libxml/schematron.c b/gnulib-local/lib/libxml/schematron.c
index 0a90ff8..eb4befe 100644
--- a/gnulib-local/lib/libxml/schematron.c
+++ b/gnulib-local/lib/libxml/schematron.c
@@ -53,7 +53,7 @@ static const xmlChar *xmlOldSchematronNs = SCT_OLD_NS;
#define NEXT_SCHEMATRON(node) \
while (node != NULL) { \
- if ((node->type == XML_ELEMENT_NODE ) && (node->ns != NULL) && \
+ if ((node->type == XML_ELEMENT_NODE ) && (node->ns != NULL) && \
((xmlStrEqual(node->ns->href, xmlSchematronNs)) || \
(xmlStrEqual(node->ns->href, xmlOldSchematronNs)))) \
break; \
@@ -65,7 +65,7 @@ static const xmlChar *xmlOldSchematronNs = SCT_OLD_NS;
*
* macro to flag unimplemented blocks
*/
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
@@ -165,9 +165,17 @@ struct _xmlSchematronValidCtxt {
FILE *outputFile; /* if using XML_SCHEMATRON_OUT_FILE */
xmlBufferPtr outputBuffer; /* if using XML_SCHEMATRON_OUT_BUFFER */
+#ifdef LIBXML_OUTPUT_ENABLED
xmlOutputWriteCallback iowrite; /* if using XML_SCHEMATRON_OUT_IO */
xmlOutputCloseCallback ioclose;
+#endif
void *ioctx;
+
+ /* error reporting data */
+ void *userData; /* user specific data block */
+ xmlSchematronValidityErrorFunc error;/* the callback in case of errors */
+ xmlSchematronValidityWarningFunc warning;/* callback in case of warning */
+ xmlStructuredErrorFunc serror; /* the structured function */
};
struct _xmlSchematronParserCtxt {
@@ -193,12 +201,11 @@ struct _xmlSchematronParserCtxt {
int maxIncludes; /* size of the array */
xmlNodePtr *includes; /* the array of includes */
- /* error rreporting data */
+ /* error reporting data */
void *userData; /* user specific data block */
xmlSchematronValidityErrorFunc error;/* the callback in case of errors */
xmlSchematronValidityWarningFunc warning;/* callback in case of warning */
xmlStructuredErrorFunc serror; /* the structured function */
-
};
#define XML_STRON_CTXT_PARSER 1
@@ -235,7 +242,7 @@ xmlSchematronPErrMemory(xmlSchematronParserCtxtPtr ctxt,
* @msg: the error message
* @str1: extra data
* @str2: extra data
- *
+ *
* Handle a parser error
*/
static void
@@ -563,7 +570,7 @@ xmlSchematronFree(xmlSchematronPtr schema)
if (schema->namespaces != NULL)
xmlFree((char **) schema->namespaces);
-
+
xmlSchematronFreeRules(schema->rules);
xmlSchematronFreePatterns(schema->patterns);
xmlDictFree(schema->dict);
@@ -714,6 +721,7 @@ xmlSchematronFreeParserCtxt(xmlSchematronParserCtxtPtr ctxt)
xmlFree(ctxt);
}
+#if 0
/**
* xmlSchematronPushInclude:
* @ctxt: the schema parser context
@@ -782,6 +790,7 @@ xmlSchematronPopInclude(xmlSchematronParserCtxtPtr ctxt)
return(xmlSchematronPopInclude(ctxt));
return(ret);
}
+#endif
/**
* xmlSchematronAddNamespace:
@@ -819,9 +828,9 @@ xmlSchematronAddNamespace(xmlSchematronParserCtxtPtr ctxt,
ctxt->namespaces = tmp;
ctxt->maxNamespaces *= 2;
}
- ctxt->namespaces[2 * ctxt->nbNamespaces] =
+ ctxt->namespaces[2 * ctxt->nbNamespaces] =
xmlDictLookup(ctxt->dict, ns, -1);
- ctxt->namespaces[2 * ctxt->nbNamespaces + 1] =
+ ctxt->namespaces[2 * ctxt->nbNamespaces + 1] =
xmlDictLookup(ctxt->dict, prefix, -1);
ctxt->nbNamespaces++;
ctxt->namespaces[2 * ctxt->nbNamespaces] = NULL;
@@ -987,6 +996,7 @@ xmlSchematronParsePattern(xmlSchematronParserCtxtPtr ctxt, xmlNodePtr pat)
}
}
+#if 0
/**
* xmlSchematronLoadInclude:
* @ctxt: a schema validation context
@@ -1051,6 +1061,7 @@ done:
xmlFree(URI);
return(ret);
}
+#endif
/**
* xmlSchematronParse:
@@ -1200,6 +1211,9 @@ xmlSchematronParse(xmlSchematronParserCtxtPtr ctxt)
}
/* the original document must be kept for reporting */
ret->doc = doc;
+ if (preserve) {
+ ret->preserve = 1;
+ }
preserve = 1;
exit:
@@ -1276,7 +1290,7 @@ xmlSchematronReportOutput(xmlSchematronValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
* to be deallocated by teh caller
*/
static xmlChar *
-xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
+xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
xmlNodePtr test, xmlNodePtr cur) {
xmlChar *ret = NULL;
xmlNodePtr child, node;
@@ -1302,7 +1316,7 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
xmlFree(path);
}
- if ((node->ns == NULL) || (node->ns->prefix == NULL))
+ if ((node->ns == NULL) || (node->ns->prefix == NULL))
ret = xmlStrcat(ret, node->name);
else {
ret = xmlStrcat(ret, node->ns->prefix);
@@ -1353,8 +1367,8 @@ xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
* been done.
*/
static void
-xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
- xmlSchematronTestPtr test, xmlNodePtr cur, int success) {
+xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
+ xmlSchematronTestPtr test, xmlNodePtr cur, xmlSchematronPatternPtr pattern, int success) {
if ((ctxt == NULL) || (cur == NULL) || (test == NULL))
return;
/* if quiet and not SVRL report only failures */
@@ -1385,18 +1399,41 @@ xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
report = xmlSchematronFormatReport(ctxt, test->node, cur);
if (report == NULL) {
if (test->type == XML_SCHEMATRON_ASSERT) {
- snprintf(msg, 999, "%s line %ld: node failed assert\n",
- (const char *) path, line);
+ report = xmlStrdup((const xmlChar *) "node failed assert");
} else {
- snprintf(msg, 999, "%s line %ld: node failed report\n",
- (const char *) path, line);
+ report = xmlStrdup((const xmlChar *) "node failed report");
+ }
}
- } else {
snprintf(msg, 999, "%s line %ld: %s\n", (const char *) path,
line, (const char *) report);
- xmlFree((char *) report);
+
+ if (ctxt->flags & XML_SCHEMATRON_OUT_ERROR) {
+ xmlStructuredErrorFunc schannel = NULL;
+ xmlGenericErrorFunc channel = NULL;
+ void *data = NULL;
+
+ if (ctxt != NULL) {
+ if (ctxt->serror != NULL)
+ schannel = ctxt->serror;
+ else
+ channel = ctxt->error;
+ data = ctxt->userData;
}
+
+ __xmlRaiseError(schannel, channel, data,
+ NULL, cur, XML_FROM_SCHEMATRONV,
+ (test->type == XML_SCHEMATRON_ASSERT)?XML_SCHEMATRONV_ASSERT:XML_SCHEMATRONV_REPORT,
+ XML_ERR_ERROR, NULL, line,
+ (pattern == NULL)?NULL:((const char *) pattern->name),
+ (const char *) path,
+ (const char *) report, 0, 0,
+ "%s", msg);
+ } else {
xmlSchematronReportOutput(ctxt, cur, &msg[0]);
+ }
+
+ xmlFree((char *) report);
+
if ((path != NULL) && (path != (xmlChar *) cur->name))
xmlFree(path);
}
@@ -1410,11 +1447,11 @@ xmlSchematronReportSuccess(xmlSchematronValidCtxtPtr ctxt,
* called from the validation engine when starting to check a pattern
*/
static void
-xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt,
+xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt,
xmlSchematronPatternPtr pattern) {
if ((ctxt == NULL) || (pattern == NULL))
return;
- if (ctxt->flags & XML_SCHEMATRON_OUT_QUIET)
+ if ((ctxt->flags & XML_SCHEMATRON_OUT_QUIET) || (ctxt->flags & XML_SCHEMATRON_OUT_ERROR)) /* Error gives pattern name as part of error */
return;
if (ctxt->flags & XML_SCHEMATRON_OUT_XML) {
TODO
@@ -1436,6 +1473,26 @@ xmlSchematronReportPattern(xmlSchematronValidCtxtPtr ctxt,
************************************************************************/
/**
+ * xmlSchematronSetValidStructuredErrors:
+ * @ctxt: a Schematron validation context
+ * @serror: the structured error function
+ * @ctx: the functions context
+ *
+ * Set the structured error callback
+ */
+void
+xmlSchematronSetValidStructuredErrors(xmlSchematronValidCtxtPtr ctxt,
+ xmlStructuredErrorFunc serror, void *ctx)
+{
+ if (ctxt == NULL)
+ return;
+ ctxt->serror = serror;
+ ctxt->error = NULL;
+ ctxt->warning = NULL;
+ ctxt->userData = ctx;
+}
+
+/**
* xmlSchematronNewValidCtxt:
* @schema: a precompiled XML Schematrons
* @options: a set of xmlSchematronValidOptions
@@ -1517,7 +1574,7 @@ xmlSchematronNextNode(xmlNodePtr cur) {
(cur->type != XML_DTD_NODE))
return(cur);
}
-
+
do {
cur = cur->parent;
if (cur == NULL) break;
@@ -1534,7 +1591,7 @@ xmlSchematronNextNode(xmlNodePtr cur) {
* xmlSchematronRunTest:
* @ctxt: the schema validation context
* @test: the current test
- * @instance: the document instace tree
+ * @instance: the document instace tree
* @cur: the current node in the instance
*
* Validate a rule against a tree instance at a given position
@@ -1543,7 +1600,7 @@ xmlSchematronNextNode(xmlNodePtr cur) {
*/
static int
xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
- xmlSchematronTestPtr test, xmlDocPtr instance, xmlNodePtr cur)
+ xmlSchematronTestPtr test, xmlDocPtr instance, xmlNodePtr cur, xmlSchematronPatternPtr pattern)
{
xmlXPathObjectPtr ret;
int failed;
@@ -1590,7 +1647,7 @@ xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
else if ((!failed) && (test->type == XML_SCHEMATRON_REPORT))
ctxt->nberrors++;
- xmlSchematronReportSuccess(ctxt, test, cur, !failed);
+ xmlSchematronReportSuccess(ctxt, test, cur, pattern, !failed);
return(!failed);
}
@@ -1598,7 +1655,7 @@ xmlSchematronRunTest(xmlSchematronValidCtxtPtr ctxt,
/**
* xmlSchematronValidateDoc:
* @ctxt: the schema validation context
- * @instance: the document instace tree
+ * @instance: the document instace tree
*
* Validate a tree instance against the schematron
*
@@ -1636,13 +1693,13 @@ xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
if (xmlPatternMatch(rule->pattern, cur) == 1) {
test = rule->tests;
while (test != NULL) {
- xmlSchematronRunTest(ctxt, test, instance, cur);
+ xmlSchematronRunTest(ctxt, test, instance, cur, (xmlSchematronPatternPtr)rule->pattern);
test = test->next;
}
}
rule = rule->next;
}
-
+
cur = xmlSchematronNextNode(cur);
}
} else {
@@ -1650,14 +1707,14 @@ xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
* Process all contexts one at a time
*/
pattern = ctxt->schema->patterns;
-
+
while (pattern != NULL) {
xmlSchematronReportPattern(ctxt, pattern);
/*
* TODO convert the pattern rule to a direct XPath and
* compute directly instead of using the pattern matching
- * over the full document...
+ * over the full document...
* Check the exact semantic
*/
cur = root;
@@ -1667,13 +1724,13 @@ xmlSchematronValidateDoc(xmlSchematronValidCtxtPtr ctxt, xmlDocPtr instance)
if (xmlPatternMatch(rule->pattern, cur) == 1) {
test = rule->tests;
while (test != NULL) {
- xmlSchematronRunTest(ctxt, test, instance, cur);
+ xmlSchematronRunTest(ctxt, test, instance, cur, pattern);
test = test->next;
}
}
rule = rule->patnext;
}
-
+
cur = xmlSchematronNextNode(cur);
}
pattern = pattern->next;
diff --git a/gnulib-local/lib/libxml/schematron.in.h b/gnulib-local/lib/libxml/schematron.in.h
index 6eaa699..364eaec 100644
--- a/gnulib-local/lib/libxml/schematron.in.h
+++ b/gnulib-local/lib/libxml/schematron.in.h
@@ -25,6 +25,7 @@ typedef enum {
XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */
XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */
XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */
+ XML_SCHEMATRON_OUT_ERROR = 1 << 3, /* output via xmlStructuredErrorFunc */
XML_SCHEMATRON_OUT_FILE = 1 << 8, /* output to a file descriptor */
XML_SCHEMATRON_OUT_BUFFER = 1 << 9, /* output to a buffer */
XML_SCHEMATRON_OUT_IO = 1 << 10 /* output to I/O mechanism */
@@ -37,11 +38,28 @@ typedef struct _xmlSchematron xmlSchematron;
typedef xmlSchematron *xmlSchematronPtr;
/**
- * A schemas validation context
+ * xmlSchematronValidityErrorFunc:
+ * @ctx: the validation context
+ * @msg: the message
+ * @...: extra arguments
+ *
+ * Signature of an error callback from a Schematron validation
*/
typedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...);
+
+/**
+ * xmlSchematronValidityWarningFunc:
+ * @ctx: the validation context
+ * @msg: the message
+ * @...: extra arguments
+ *
+ * Signature of a warning callback from a Schematron validation
+ */
typedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...);
+/**
+ * A schemas validation context
+ */
typedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt;
typedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr;
@@ -51,17 +69,17 @@ typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr;
/*
* Interfaces for parsing.
*/
-XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
+XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
xmlSchematronNewParserCtxt (const char *URL);
-XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
+XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
xmlSchematronNewMemParserCtxt(const char *buffer,
int size);
XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL
xmlSchematronNewDocParserCtxt(xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt);
/*****
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt,
xmlSchematronValidityErrorFunc err,
xmlSchematronValidityWarningFunc warn,
@@ -74,20 +92,20 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlSchematronIsValid (xmlSchematronValidCtxtPtr ctxt);
*****/
-XMLPUBFUN xmlSchematronPtr XMLCALL
+XMLPUBFUN xmlSchematronPtr XMLCALL
xmlSchematronParse (xmlSchematronParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchematronFree (xmlSchematronPtr schema);
/*
* Interfaces for validating
*/
-/******
XMLPUBFUN void XMLCALL
xmlSchematronSetValidStructuredErrors(
xmlSchematronValidCtxtPtr ctxt,
xmlStructuredErrorFunc serror,
void *ctx);
-XMLPUBFUN void XMLCALL
+/******
+XMLPUBFUN void XMLCALL
xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt,
xmlSchematronValidityErrorFunc err,
xmlSchematronValidityWarningFunc warn,
@@ -107,12 +125,12 @@ XMLPUBFUN int XMLCALL
xmlNodePtr elem);
*******/
-XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL
+XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL
xmlSchematronNewValidCtxt (xmlSchematronPtr schema,
- int options);
-XMLPUBFUN void XMLCALL
+ int options);
+XMLPUBFUN void XMLCALL
xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSchematronValidateDoc (xmlSchematronValidCtxtPtr ctxt,
xmlDocPtr instance);
diff --git a/gnulib-local/lib/libxml/threads.c b/gnulib-local/lib/libxml/threads.c
index 7124bca..b9d6cae 100644
--- a/gnulib-local/lib/libxml/threads.c
+++ b/gnulib-local/lib/libxml/threads.c
@@ -1,5 +1,5 @@
/**
- * threads.c: set of generic threading related routines
+ * threads.c: set of generic threading related routines
*
* See Copyright for the status of this software.
*
@@ -26,9 +26,7 @@
#endif
#ifdef HAVE_PTHREAD_H
#include <pthread.h>
-#endif
-
-#ifdef HAVE_WIN32_THREADS
+#elif defined HAVE_WIN32_THREADS
#include <windows.h>
#ifndef HAVE_COMPILER_TLS
#include <process.h>
@@ -49,7 +47,7 @@
#ifdef HAVE_PTHREAD_H
static int libxml_is_threaded = -1;
-#ifdef __GNUC__
+#if defined(__GNUC__) && defined(__GLIBC__)
#ifdef linux
#if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || (__GNUC__ > 3)
extern int pthread_once (pthread_once_t *__once_control,
@@ -63,6 +61,8 @@ extern int pthread_setspecific (pthread_key_t __key,
extern int pthread_key_create (pthread_key_t *__key,
void (*__destr_function) (void *))
__attribute((weak));
+extern int pthread_key_delete (pthread_key_t __key)
+ __attribute((weak));
extern int pthread_mutex_init ()
__attribute((weak));
extern int pthread_mutex_destroy ()
@@ -73,17 +73,23 @@ extern int pthread_mutex_unlock ()
__attribute((weak));
extern int pthread_cond_init ()
__attribute((weak));
+extern int pthread_cond_destroy ()
+ __attribute((weak));
+extern int pthread_cond_wait ()
+ __attribute((weak));
extern int pthread_equal ()
__attribute((weak));
extern pthread_t pthread_self ()
__attribute((weak));
extern int pthread_key_create ()
__attribute((weak));
+extern int pthread_key_delete ()
+ __attribute((weak));
extern int pthread_cond_signal ()
__attribute((weak));
#endif
#endif /* linux */
-#endif /* __GNUC__ */
+#endif /* defined(__GNUC__) && defined(__GLIBC__) */
#endif /* HAVE_PTHREAD_H */
/*
@@ -101,8 +107,8 @@ struct _xmlMutex {
#elif defined HAVE_WIN32_THREADS
HANDLE mutex;
#elif defined HAVE_BEOS_THREADS
- sem_id sem;
- thread_id tid;
+ sem_id sem;
+ thread_id tid;
#else
int empty;
#endif
@@ -114,21 +120,22 @@ struct _xmlMutex {
struct _xmlRMutex {
#ifdef HAVE_PTHREAD_H
pthread_mutex_t lock;
- unsigned int held;
- unsigned int waiters;
- pthread_t tid;
- pthread_cond_t cv;
+ unsigned int held;
+ unsigned int waiters;
+ pthread_t tid;
+ pthread_cond_t cv;
#elif defined HAVE_WIN32_THREADS
CRITICAL_SECTION cs;
unsigned int count;
#elif defined HAVE_BEOS_THREADS
- xmlMutexPtr lock;
- thread_id tid;
- int32 count;
+ xmlMutexPtr lock;
+ thread_id tid;
+ int32 count;
#else
int empty;
#endif
};
+
/*
* This module still has some internal static data.
* - xmlLibraryLock a global lock
@@ -136,9 +143,11 @@ struct _xmlRMutex {
*/
#ifdef HAVE_PTHREAD_H
-static pthread_key_t globalkey;
-static pthread_t mainthread;
+static pthread_key_t globalkey;
+static pthread_t mainthread;
static pthread_once_t once_control = PTHREAD_ONCE_INIT;
+static pthread_once_t once_control_init = PTHREAD_ONCE_INIT;
+static pthread_mutex_t global_init_lock = PTHREAD_MUTEX_INITIALIZER;
#elif defined HAVE_WIN32_THREADS
#if defined(HAVE_COMPILER_TLS)
static __declspec(thread) xmlGlobalState tlstate;
@@ -147,19 +156,23 @@ static __declspec(thread) int tlstate_inited = 0;
static DWORD globalkey = TLS_OUT_OF_INDEXES;
#endif /* HAVE_COMPILER_TLS */
static DWORD mainthread;
-static struct
-{
+static struct {
DWORD done;
DWORD control;
-} run_once = { 0, 0 };
+} run_once = { 0, 0};
+static volatile LPCRITICAL_SECTION global_init_lock = NULL;
+
/* endif HAVE_WIN32_THREADS */
#elif defined HAVE_BEOS_THREADS
int32 globalkey = 0;
thread_id mainthread = 0;
int32 run_once_init = 0;
+static int32 global_init_lock = -1;
+static vint32 global_init_count = 0;
#endif
-static xmlRMutexPtr xmlLibraryLock = NULL;
+static xmlRMutexPtr xmlLibraryLock = NULL;
+
#ifdef LIBXML_THREAD_ENABLED
static void xmlOnceInit(void);
#endif
@@ -181,15 +194,15 @@ xmlNewMutex(void)
return (NULL);
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0)
- pthread_mutex_init(&tok->lock, NULL);
+ pthread_mutex_init(&tok->lock, NULL);
#elif defined HAVE_WIN32_THREADS
tok->mutex = CreateMutex(NULL, FALSE, NULL);
#elif defined HAVE_BEOS_THREADS
- if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
- free(tok);
- return NULL;
- }
- tok->tid = -1;
+ if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
+ free(tok);
+ return NULL;
+ }
+ tok->tid = -1;
#endif
return (tok);
}
@@ -204,15 +217,16 @@ xmlNewMutex(void)
void
xmlFreeMutex(xmlMutexPtr tok)
{
- if (tok == NULL) return;
+ if (tok == NULL)
+ return;
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0)
- pthread_mutex_destroy(&tok->lock);
+ pthread_mutex_destroy(&tok->lock);
#elif defined HAVE_WIN32_THREADS
CloseHandle(tok->mutex);
#elif defined HAVE_BEOS_THREADS
- delete_sem(tok->sem);
+ delete_sem(tok->sem);
#endif
free(tok);
}
@@ -230,17 +244,17 @@ xmlMutexLock(xmlMutexPtr tok)
return;
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0)
- pthread_mutex_lock(&tok->lock);
+ pthread_mutex_lock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
WaitForSingleObject(tok->mutex, INFINITE);
#elif defined HAVE_BEOS_THREADS
- if (acquire_sem(tok->sem) != B_NO_ERROR) {
+ if (acquire_sem(tok->sem) != B_NO_ERROR) {
#ifdef DEBUG_THREADS
- xmlGenericError(xmlGenericErrorContext, "xmlMutexLock():BeOS:Couldn't aquire semaphore\n");
- exit();
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlMutexLock():BeOS:Couldn't aquire semaphore\n");
#endif
- }
- tok->tid = find_thread(NULL);
+ }
+ tok->tid = find_thread(NULL);
#endif
}
@@ -258,14 +272,14 @@ xmlMutexUnlock(xmlMutexPtr tok)
return;
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0)
- pthread_mutex_unlock(&tok->lock);
+ pthread_mutex_unlock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
ReleaseMutex(tok->mutex);
#elif defined HAVE_BEOS_THREADS
- if (tok->tid == find_thread(NULL)) {
- tok->tid = -1;
- release_sem(tok->sem);
- }
+ if (tok->tid == find_thread(NULL)) {
+ tok->tid = -1;
+ release_sem(tok->sem);
+ }
#endif
}
@@ -288,20 +302,20 @@ xmlNewRMutex(void)
return (NULL);
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0) {
- pthread_mutex_init(&tok->lock, NULL);
- tok->held = 0;
- tok->waiters = 0;
- pthread_cond_init(&tok->cv, NULL);
+ pthread_mutex_init(&tok->lock, NULL);
+ tok->held = 0;
+ tok->waiters = 0;
+ pthread_cond_init(&tok->cv, NULL);
}
#elif defined HAVE_WIN32_THREADS
InitializeCriticalSection(&tok->cs);
tok->count = 0;
#elif defined HAVE_BEOS_THREADS
- if ((tok->lock = xmlNewMutex()) == NULL) {
- free(tok);
- return NULL;
- }
- tok->count = 0;
+ if ((tok->lock = xmlNewMutex()) == NULL) {
+ free(tok);
+ return NULL;
+ }
+ tok->count = 0;
#endif
return (tok);
}
@@ -320,13 +334,13 @@ xmlFreeRMutex(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
return;
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded != 0) {
- pthread_mutex_destroy(&tok->lock);
- pthread_cond_destroy(&tok->cv);
+ pthread_mutex_destroy(&tok->lock);
+ pthread_cond_destroy(&tok->cv);
}
#elif defined HAVE_WIN32_THREADS
DeleteCriticalSection(&tok->cs);
#elif defined HAVE_BEOS_THREADS
- xmlFreeMutex(tok->lock);
+ xmlFreeMutex(tok->lock);
#endif
free(tok);
}
@@ -364,15 +378,15 @@ xmlRMutexLock(xmlRMutexPtr tok)
pthread_mutex_unlock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
EnterCriticalSection(&tok->cs);
- ++tok->count;
+ tok->count++;
#elif defined HAVE_BEOS_THREADS
- if (tok->lock->tid == find_thread(NULL)) {
- tok->count++;
- return;
- } else {
- xmlMutexLock(tok->lock);
- tok->count = 1;
- }
+ if (tok->lock->tid == find_thread(NULL)) {
+ tok->count++;
+ return;
+ } else {
+ xmlMutexLock(tok->lock);
+ tok->count = 1;
+ }
#endif
}
@@ -390,26 +404,139 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded == 0)
return;
-
+
pthread_mutex_lock(&tok->lock);
tok->held--;
if (tok->held == 0) {
if (tok->waiters)
pthread_cond_signal(&tok->cv);
- tok->tid = 0;
+ memset(&tok->tid, 0, sizeof(tok->tid));
}
pthread_mutex_unlock(&tok->lock);
#elif defined HAVE_WIN32_THREADS
- if (!--tok->count)
- LeaveCriticalSection(&tok->cs);
+ if (tok->count > 0) {
+ tok->count--;
+ LeaveCriticalSection(&tok->cs);
+ }
#elif defined HAVE_BEOS_THREADS
- if (tok->lock->tid == find_thread(NULL)) {
- tok->count--;
- if (tok->count == 0) {
- xmlMutexUnlock(tok->lock);
- }
- return;
- }
+ if (tok->lock->tid == find_thread(NULL)) {
+ tok->count--;
+ if (tok->count == 0) {
+ xmlMutexUnlock(tok->lock);
+ }
+ return;
+ }
+#endif
+}
+
+/**
+ * xmlGlobalInitMutexLock
+ *
+ * Makes sure that the global initialization mutex is initialized and
+ * locks it.
+ */
+void
+__xmlGlobalInitMutexLock(void)
+{
+ /* Make sure the global init lock is initialized and then lock it. */
+#ifdef HAVE_PTHREAD_H
+ /* The mutex is statically initialized, so we just lock it. */
+ if (pthread_mutex_lock != NULL)
+ pthread_mutex_lock(&global_init_lock);
+#elif defined HAVE_WIN32_THREADS
+ LPCRITICAL_SECTION cs;
+
+ /* Create a new critical section */
+ if (global_init_lock == NULL) {
+ cs = malloc(sizeof(CRITICAL_SECTION));
+ if (cs == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlGlobalInitMutexLock: out of memory\n");
+ return;
+ }
+ InitializeCriticalSection(cs);
+
+ /* Swap it into the global_init_lock */
+#ifdef InterlockedCompareExchangePointer
+ InterlockedCompareExchangePointer(&global_init_lock, cs, NULL);
+#else /* Use older void* version */
+ InterlockedCompareExchange((void **) &global_init_lock,
+ (void *) cs, NULL);
+#endif /* InterlockedCompareExchangePointer */
+
+ /* If another thread successfully recorded its critical
+ * section in the global_init_lock then discard the one
+ * allocated by this thread. */
+ if (global_init_lock != cs) {
+ DeleteCriticalSection(cs);
+ free(cs);
+ }
+ }
+
+ /* Lock the chosen critical section */
+ EnterCriticalSection(global_init_lock);
+#elif defined HAVE_BEOS_THREADS
+ int32 sem;
+
+ /* Allocate a new semaphore */
+ sem = create_sem(1, "xmlGlobalinitMutex");
+
+ while (global_init_lock == -1) {
+ if (atomic_add(&global_init_count, 1) == 0) {
+ global_init_lock = sem;
+ } else {
+ snooze(1);
+ atomic_add(&global_init_count, -1);
+ }
+ }
+
+ /* If another thread successfully recorded its critical
+ * section in the global_init_lock then discard the one
+ * allocated by this thread. */
+ if (global_init_lock != sem)
+ delete_sem(sem);
+
+ /* Acquire the chosen semaphore */
+ if (acquire_sem(global_init_lock) != B_NO_ERROR) {
+#ifdef DEBUG_THREADS
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlGlobalInitMutexLock():BeOS:Couldn't acquire semaphore\n");
+#endif
+ }
+#endif
+}
+
+void
+__xmlGlobalInitMutexUnlock(void)
+{
+#ifdef HAVE_PTHREAD_H
+ if (pthread_mutex_unlock != NULL)
+ pthread_mutex_unlock(&global_init_lock);
+#elif defined HAVE_WIN32_THREADS
+ if (global_init_lock != NULL) {
+ LeaveCriticalSection(global_init_lock);
+ }
+#elif defined HAVE_BEOS_THREADS
+ release_sem(global_init_lock);
+#endif
+}
+
+/**
+ * xmlGlobalInitMutexDestroy
+ *
+ * Makes sure that the global initialization mutex is destroyed before
+ * application termination.
+ */
+void
+__xmlGlobalInitMutexDestroy(void)
+{
+#ifdef HAVE_PTHREAD_H
+#elif defined HAVE_WIN32_THREADS
+ if (global_init_lock != NULL) {
+ DeleteCriticalSection(global_init_lock);
+ free(global_init_lock);
+ global_init_lock = NULL;
+ }
#endif
}
@@ -423,6 +550,7 @@ xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
#ifdef xmlLastError
#undef xmlLastError
#endif
+
/**
* xmlFreeGlobalState:
* @state: a thread global state
@@ -453,10 +581,13 @@ static xmlGlobalStatePtr
xmlNewGlobalState(void)
{
xmlGlobalState *gs;
-
+
gs = malloc(sizeof(xmlGlobalState));
- if (gs == NULL)
- return(NULL);
+ if (gs == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlGetGlobalState: out of memory\n");
+ return (NULL);
+ }
memset(gs, 0, sizeof(xmlGlobalState));
xmlInitializeGlobalState(gs);
@@ -464,19 +595,20 @@ xmlNewGlobalState(void)
}
#endif /* LIBXML_THREAD_ENABLED */
-
-#ifdef HAVE_WIN32_THREADS
+#ifdef HAVE_PTHREAD_H
+#elif defined HAVE_WIN32_THREADS
#if !defined(HAVE_COMPILER_TLS)
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
-typedef struct _xmlGlobalStateCleanupHelperParams
-{
+typedef struct _xmlGlobalStateCleanupHelperParams {
HANDLE thread;
void *memory;
} xmlGlobalStateCleanupHelperParams;
-static void XMLCDECL xmlGlobalStateCleanupHelper (void *p)
+static void XMLCDECL
+xmlGlobalStateCleanupHelper(void *p)
{
- xmlGlobalStateCleanupHelperParams *params = (xmlGlobalStateCleanupHelperParams *) p;
+ xmlGlobalStateCleanupHelperParams *params =
+ (xmlGlobalStateCleanupHelperParams *) p;
WaitForSingleObject(params->thread, INFINITE);
CloseHandle(params->thread);
xmlFreeGlobalState(params->memory);
@@ -485,14 +617,13 @@ static void XMLCDECL xmlGlobalStateCleanupHelper (void *p)
}
#else /* LIBXML_STATIC && !LIBXML_STATIC_FOR_DLL */
-typedef struct _xmlGlobalStateCleanupHelperParams
-{
+typedef struct _xmlGlobalStateCleanupHelperParams {
void *memory;
- struct _xmlGlobalStateCleanupHelperParams * prev;
- struct _xmlGlobalStateCleanupHelperParams * next;
+ struct _xmlGlobalStateCleanupHelperParams *prev;
+ struct _xmlGlobalStateCleanupHelperParams *next;
} xmlGlobalStateCleanupHelperParams;
-static xmlGlobalStateCleanupHelperParams * cleanup_helpers_head = NULL;
+static xmlGlobalStateCleanupHelperParams *cleanup_helpers_head = NULL;
static CRITICAL_SECTION cleanup_helpers_cs;
#endif /* LIBXMLSTATIC && !LIBXML_STATIC_FOR_DLL */
@@ -500,17 +631,20 @@ static CRITICAL_SECTION cleanup_helpers_cs;
#endif /* HAVE_WIN32_THREADS */
#if defined HAVE_BEOS_THREADS
+
/**
* xmlGlobalStateCleanup:
* @data: unused parameter
*
* Used for Beos only
*/
-void xmlGlobalStateCleanup(void *data)
+void
+xmlGlobalStateCleanup(void *data)
{
- void *globalval = tls_get(globalkey);
- if (globalval != NULL)
- xmlFreeGlobalState(globalval);
+ void *globalval = tls_get(globalkey);
+
+ if (globalval != NULL)
+ xmlFreeGlobalState(globalval);
}
#endif
@@ -528,13 +662,15 @@ xmlGetGlobalState(void)
xmlGlobalState *globalval;
if (libxml_is_threaded == 0)
- return(NULL);
+ return (NULL);
pthread_once(&once_control, xmlOnceInit);
if ((globalval = (xmlGlobalState *)
- pthread_getspecific(globalkey)) == NULL) {
+ pthread_getspecific(globalkey)) == NULL) {
xmlGlobalState *tsd = xmlNewGlobalState();
+ if (tsd == NULL)
+ return(NULL);
pthread_setspecific(globalkey, tsd);
return (tsd);
@@ -543,43 +679,54 @@ xmlGetGlobalState(void)
#elif defined HAVE_WIN32_THREADS
#if defined(HAVE_COMPILER_TLS)
if (!tlstate_inited) {
- tlstate_inited = 1;
- xmlInitializeGlobalState(&tlstate);
+ tlstate_inited = 1;
+ xmlInitializeGlobalState(&tlstate);
}
return &tlstate;
#else /* HAVE_COMPILER_TLS */
xmlGlobalState *globalval;
- xmlGlobalStateCleanupHelperParams * p;
+ xmlGlobalStateCleanupHelperParams *p;
xmlOnceInit();
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
- globalval = (xmlGlobalState *)TlsGetValue(globalkey);
+ globalval = (xmlGlobalState *) TlsGetValue(globalkey);
#else
- p = (xmlGlobalStateCleanupHelperParams*)TlsGetValue(globalkey);
- globalval = (xmlGlobalState *)(p ? p->memory : NULL);
+ p = (xmlGlobalStateCleanupHelperParams *) TlsGetValue(globalkey);
+ globalval = (xmlGlobalState *) (p ? p->memory : NULL);
#endif
if (globalval == NULL) {
- xmlGlobalState *tsd = xmlNewGlobalState();
- p = (xmlGlobalStateCleanupHelperParams *) malloc(sizeof(xmlGlobalStateCleanupHelperParams));
- p->memory = tsd;
+ xmlGlobalState *tsd = xmlNewGlobalState();
+
+ if (tsd == NULL)
+ return(NULL);
+ p = (xmlGlobalStateCleanupHelperParams *)
+ malloc(sizeof(xmlGlobalStateCleanupHelperParams));
+ if (p == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlGetGlobalState: out of memory\n");
+ xmlFreeGlobalState(tsd);
+ return(NULL);
+ }
+ p->memory = tsd;
#if defined(LIBXML_STATIC) && !defined(LIBXML_STATIC_FOR_DLL)
- DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
- GetCurrentProcess(), &p->thread, 0, TRUE, DUPLICATE_SAME_ACCESS);
- TlsSetValue(globalkey, tsd);
- _beginthread(xmlGlobalStateCleanupHelper, 0, p);
+ DuplicateHandle(GetCurrentProcess(), GetCurrentThread(),
+ GetCurrentProcess(), &p->thread, 0, TRUE,
+ DUPLICATE_SAME_ACCESS);
+ TlsSetValue(globalkey, tsd);
+ _beginthread(xmlGlobalStateCleanupHelper, 0, p);
#else
- EnterCriticalSection(&cleanup_helpers_cs);
+ EnterCriticalSection(&cleanup_helpers_cs);
if (cleanup_helpers_head != NULL) {
cleanup_helpers_head->prev = p;
}
- p->next = cleanup_helpers_head;
- p->prev = NULL;
- cleanup_helpers_head = p;
- TlsSetValue(globalkey, p);
- LeaveCriticalSection(&cleanup_helpers_cs);
+ p->next = cleanup_helpers_head;
+ p->prev = NULL;
+ cleanup_helpers_head = p;
+ TlsSetValue(globalkey, p);
+ LeaveCriticalSection(&cleanup_helpers_cs);
#endif
- return (tsd);
+ return (tsd);
}
return (globalval);
#endif /* HAVE_COMPILER_TLS */
@@ -588,9 +735,10 @@ xmlGetGlobalState(void)
xmlOnceInit();
- if ((globalval = (xmlGlobalState *)
- tls_get(globalkey)) == NULL) {
+ if ((globalval = (xmlGlobalState *) tls_get(globalkey)) == NULL) {
xmlGlobalState *tsd = xmlNewGlobalState();
+ if (tsd == NULL)
+ return (NULL);
tls_set(globalkey, tsd);
on_exit_thread(xmlGlobalStateCleanup, NULL);
@@ -598,7 +746,7 @@ xmlGetGlobalState(void)
}
return (globalval);
#else
- return(NULL);
+ return (NULL);
#endif
}
@@ -612,6 +760,8 @@ xmlGetGlobalState(void)
* xmlGetThreadId:
*
* xmlGetThreadId() find the current thread ID number
+ * Note that this is likely to be broken on some platforms using pthreads
+ * as the specification doesn't mandate pthread_t to be an integer type
*
* Returns the current thread ID number
*/
@@ -619,15 +769,21 @@ int
xmlGetThreadId(void)
{
#ifdef HAVE_PTHREAD_H
+ pthread_t id;
+ int ret;
+
if (libxml_is_threaded == 0)
- return(0);
- return((int) pthread_self());
+ return (0);
+ id = pthread_self();
+ /* horrible but preserves compat, see warning above */
+ memcpy(&ret, &id, sizeof(ret));
+ return (ret);
#elif defined HAVE_WIN32_THREADS
return GetCurrentThreadId();
#elif defined HAVE_BEOS_THREADS
- return find_thread(NULL);
+ return find_thread(NULL);
#else
- return((int) 0);
+ return ((int) 0);
#endif
}
@@ -645,25 +801,25 @@ xmlIsMainThread(void)
if (libxml_is_threaded == -1)
xmlInitThreads();
if (libxml_is_threaded == 0)
- return(1);
+ return (1);
pthread_once(&once_control, xmlOnceInit);
#elif defined HAVE_WIN32_THREADS
- xmlOnceInit ();
+ xmlOnceInit();
#elif defined HAVE_BEOS_THREADS
xmlOnceInit();
#endif
-
+
#ifdef DEBUG_THREADS
xmlGenericError(xmlGenericErrorContext, "xmlIsMainThread()\n");
#endif
#ifdef HAVE_PTHREAD_H
- return(mainthread == pthread_self());
+ return (pthread_equal(mainthread,pthread_self()));
#elif defined HAVE_WIN32_THREADS
- return(mainthread == GetCurrentThreadId ());
+ return (mainthread == GetCurrentThreadId());
#elif defined HAVE_BEOS_THREADS
- return(mainthread == find_thread(NULL));
+ return (mainthread == find_thread(NULL));
#else
- return(1);
+ return (1);
#endif
}
@@ -706,34 +862,34 @@ xmlUnlockLibrary(void)
void
xmlInitThreads(void)
{
-#ifdef DEBUG_THREADS
- xmlGenericError(xmlGenericErrorContext, "xmlInitThreads()\n");
-#endif
-#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
- InitializeCriticalSection(&cleanup_helpers_cs);
-#endif
#ifdef HAVE_PTHREAD_H
if (libxml_is_threaded == -1) {
if ((pthread_once != NULL) &&
- (pthread_getspecific != NULL) &&
- (pthread_setspecific != NULL) &&
- (pthread_key_create != NULL) &&
- (pthread_mutex_init != NULL) &&
- (pthread_mutex_destroy != NULL) &&
- (pthread_mutex_lock != NULL) &&
- (pthread_mutex_unlock != NULL) &&
- (pthread_cond_init != NULL) &&
- (pthread_equal != NULL) &&
- (pthread_self != NULL) &&
- (pthread_key_create != NULL) &&
- (pthread_cond_signal != NULL)) {
- libxml_is_threaded = 1;
+ (pthread_getspecific != NULL) &&
+ (pthread_setspecific != NULL) &&
+ (pthread_key_create != NULL) &&
+ (pthread_key_delete != NULL) &&
+ (pthread_mutex_init != NULL) &&
+ (pthread_mutex_destroy != NULL) &&
+ (pthread_mutex_lock != NULL) &&
+ (pthread_mutex_unlock != NULL) &&
+ (pthread_cond_init != NULL) &&
+ (pthread_cond_destroy != NULL) &&
+ (pthread_cond_wait != NULL) &&
+ (pthread_equal != NULL) &&
+ (pthread_self != NULL) &&
+ (pthread_cond_signal != NULL)) {
+ libxml_is_threaded = 1;
+
/* fprintf(stderr, "Running multithreaded\n"); */
- } else {
+ } else {
+
/* fprintf(stderr, "Running without multithread\n"); */
- libxml_is_threaded = 0;
- }
+ libxml_is_threaded = 0;
+ }
}
+#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
+ InitializeCriticalSection(&cleanup_helpers_cs);
#endif
}
@@ -742,6 +898,14 @@ xmlInitThreads(void)
*
* xmlCleanupThreads() is used to to cleanup all the thread related
* data of the libxml2 library once processing has ended.
+ *
+ * WARNING: if your application is multithreaded or has plugin support
+ * calling this may crash the application if another thread or
+ * a plugin is still using libxml2. It's sometimes very hard to
+ * guess if libxml2 is in use in the application, some libraries
+ * or plugins may use it without notice. In case of doubt abstain
+ * from calling this function or do it just before calling exit()
+ * to avoid leak reports from valgrind !
*/
void
xmlCleanupThreads(void)
@@ -749,27 +913,34 @@ xmlCleanupThreads(void)
#ifdef DEBUG_THREADS
xmlGenericError(xmlGenericErrorContext, "xmlCleanupThreads()\n");
#endif
-#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
+#ifdef HAVE_PTHREAD_H
+ if ((libxml_is_threaded) && (pthread_key_delete != NULL))
+ pthread_key_delete(globalkey);
+ once_control = once_control_init;
+#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
if (globalkey != TLS_OUT_OF_INDEXES) {
- xmlGlobalStateCleanupHelperParams * p;
- EnterCriticalSection(&cleanup_helpers_cs);
- p = cleanup_helpers_head;
- while (p != NULL) {
- xmlGlobalStateCleanupHelperParams * temp = p;
- p = p->next;
- xmlFreeGlobalState(temp->memory);
- free(temp);
- }
- cleanup_helpers_head = 0;
- LeaveCriticalSection(&cleanup_helpers_cs);
- TlsFree(globalkey);
- globalkey = TLS_OUT_OF_INDEXES;
+ xmlGlobalStateCleanupHelperParams *p;
+
+ EnterCriticalSection(&cleanup_helpers_cs);
+ p = cleanup_helpers_head;
+ while (p != NULL) {
+ xmlGlobalStateCleanupHelperParams *temp = p;
+
+ p = p->next;
+ xmlFreeGlobalState(temp->memory);
+ free(temp);
+ }
+ cleanup_helpers_head = 0;
+ LeaveCriticalSection(&cleanup_helpers_cs);
+ TlsFree(globalkey);
+ globalkey = TLS_OUT_OF_INDEXES;
}
DeleteCriticalSection(&cleanup_helpers_cs);
#endif
}
#ifdef LIBXML_THREAD_ENABLED
+
/**
* xmlOnceInit
*
@@ -780,38 +951,36 @@ xmlCleanupThreads(void)
* details.
*/
static void
-xmlOnceInit(void) {
+xmlOnceInit(void)
+{
#ifdef HAVE_PTHREAD_H
(void) pthread_key_create(&globalkey, xmlFreeGlobalState);
mainthread = pthread_self();
-#endif
-
-#if defined(HAVE_WIN32_THREADS)
+ __xmlInitializeDict();
+#elif defined(HAVE_WIN32_THREADS)
if (!run_once.done) {
- if (InterlockedIncrement(&run_once.control) == 1)
- {
+ if (InterlockedIncrement(&run_once.control) == 1) {
#if !defined(HAVE_COMPILER_TLS)
globalkey = TlsAlloc();
#endif
mainthread = GetCurrentThreadId();
+ __xmlInitializeDict();
run_once.done = 1;
- }
- else {
+ } else {
/* Another thread is working; give up our slice and
* wait until they're done. */
while (!run_once.done)
Sleep(0);
}
}
-#endif
-
-#ifdef HAVE_BEOS_THREADS
- if (atomic_add(&run_once_init, 1) == 0) {
- globalkey = tls_allocate();
- tls_set(globalkey, NULL);
- mainthread = find_thread(NULL);
- } else
- atomic_add(&run_once_init, -1);
+#elif defined HAVE_BEOS_THREADS
+ if (atomic_add(&run_once_init, 1) == 0) {
+ globalkey = tls_allocate();
+ tls_set(globalkey, NULL);
+ mainthread = find_thread(NULL);
+ __xmlInitializeDict();
+ } else
+ atomic_add(&run_once_init, -1);
#endif
}
#endif
@@ -827,38 +996,41 @@ xmlOnceInit(void) {
*
* Returns TRUE always
*/
-#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
+#ifdef HAVE_PTHREAD_H
+#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
#if defined(LIBXML_STATIC_FOR_DLL)
-BOOL WINAPI xmlDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+BOOL XMLCALL
+xmlDllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
#else
-BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+BOOL WINAPI
+DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
#endif
{
- switch(fdwReason) {
- case DLL_THREAD_DETACH:
- if (globalkey != TLS_OUT_OF_INDEXES) {
- xmlGlobalState *globalval = NULL;
- xmlGlobalStateCleanupHelperParams * p =
- (xmlGlobalStateCleanupHelperParams*)TlsGetValue(globalkey);
- globalval = (xmlGlobalState *)(p ? p->memory : NULL);
- if (globalval) {
- xmlFreeGlobalState(globalval);
- TlsSetValue(globalkey,NULL);
+ switch (fdwReason) {
+ case DLL_THREAD_DETACH:
+ if (globalkey != TLS_OUT_OF_INDEXES) {
+ xmlGlobalState *globalval = NULL;
+ xmlGlobalStateCleanupHelperParams *p =
+ (xmlGlobalStateCleanupHelperParams *)
+ TlsGetValue(globalkey);
+ globalval = (xmlGlobalState *) (p ? p->memory : NULL);
+ if (globalval) {
+ xmlFreeGlobalState(globalval);
+ TlsSetValue(globalkey, NULL);
+ }
+ if (p) {
+ EnterCriticalSection(&cleanup_helpers_cs);
+ if (p == cleanup_helpers_head)
+ cleanup_helpers_head = p->next;
+ else
+ p->prev->next = p->next;
+ if (p->next != NULL)
+ p->next->prev = p->prev;
+ LeaveCriticalSection(&cleanup_helpers_cs);
+ free(p);
+ }
}
- if (p)
- {
- EnterCriticalSection(&cleanup_helpers_cs);
- if (p == cleanup_helpers_head)
- cleanup_helpers_head = p->next;
- else
- p->prev->next = p->next;
- if (p->next != NULL)
- p->next->prev = p->prev;
- LeaveCriticalSection(&cleanup_helpers_cs);
- free(p);
- }
- }
- break;
+ break;
}
return TRUE;
}
diff --git a/gnulib-local/lib/libxml/threads.in.h b/gnulib-local/lib/libxml/threads.in.h
index 4f7d10f..d31f16a 100644
--- a/gnulib-local/lib/libxml/threads.in.h
+++ b/gnulib-local/lib/libxml/threads.in.h
@@ -36,42 +36,46 @@ typedef xmlRMutex *xmlRMutexPtr;
#ifdef __cplusplus
extern "C" {
#endif
-XMLPUBFUN xmlMutexPtr XMLCALL
+XMLPUBFUN xmlMutexPtr XMLCALL
xmlNewMutex (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlMutexLock (xmlMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlMutexUnlock (xmlMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeMutex (xmlMutexPtr tok);
-XMLPUBFUN xmlRMutexPtr XMLCALL
+XMLPUBFUN xmlRMutexPtr XMLCALL
xmlNewRMutex (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRMutexLock (xmlRMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRMutexUnlock (xmlRMutexPtr tok);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeRMutex (xmlRMutexPtr tok);
/*
* Library wide APIs.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlInitThreads (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlLockLibrary (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlUnlockLibrary(void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlGetThreadId (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlIsMainThread (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCleanupThreads(void);
-XMLPUBFUN xmlGlobalStatePtr XMLCALL
+XMLPUBFUN xmlGlobalStatePtr XMLCALL
xmlGetGlobalState(void);
+#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL)
+int XMLCALL xmlDllMain(void *hinstDLL, unsigned long fdwReason, void *lpvReserved);
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/gnulib-local/lib/libxml/timsort.h b/gnulib-local/lib/libxml/timsort.h
new file mode 100644
index 0000000..795f272
--- /dev/null
+++ b/gnulib-local/lib/libxml/timsort.h
@@ -0,0 +1,518 @@
+/*
+ * taken from https://github.com/swenson/sort
+ * Kept as is for the moment to be able to apply upstream patches for that
+ * code, currently used only to speed up XPath node sorting, see xpath.c
+ */
+
+/*
+ * All code in this header, unless otherwise specified, is hereby licensed under the MIT Public License:
+
+Copyright (c) 2010 Christopher Swenson
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#else
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#elif defined(WIN32)
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#endif
+#endif
+
+#ifndef MK_UINT64
+#if defined(WIN32) && defined(_MSC_VER) && _MSC_VER < 1300
+#define MK_UINT64(x) ((uint64_t)(x))
+#else
+#define MK_UINT64(x) x##ULL
+#endif
+#endif
+
+#ifndef MAX
+#define MAX(x,y) (((x) > (y) ? (x) : (y)))
+#endif
+#ifndef MIN
+#define MIN(x,y) (((x) < (y) ? (x) : (y)))
+#endif
+
+int compute_minrun(uint64_t);
+
+#ifndef CLZ
+#if defined(__GNUC__) && ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 3))
+#define CLZ __builtin_clzll
+#else
+
+int clzll(uint64_t);
+
+/* adapted from Hacker's Delight */
+int clzll(uint64_t x) /* {{{ */
+{
+ int n;
+
+ if (x == 0) return(64);
+ n = 0;
+ if (x <= MK_UINT64(0x00000000FFFFFFFF)) {n = n + 32; x = x << 32;}
+ if (x <= MK_UINT64(0x0000FFFFFFFFFFFF)) {n = n + 16; x = x << 16;}
+ if (x <= MK_UINT64(0x00FFFFFFFFFFFFFF)) {n = n + 8; x = x << 8;}
+ if (x <= MK_UINT64(0x0FFFFFFFFFFFFFFF)) {n = n + 4; x = x << 4;}
+ if (x <= MK_UINT64(0x3FFFFFFFFFFFFFFF)) {n = n + 2; x = x << 2;}
+ if (x <= MK_UINT64(0x7FFFFFFFFFFFFFFF)) {n = n + 1;}
+ return n;
+}
+/* }}} */
+
+#define CLZ clzll
+#endif
+#endif
+
+int compute_minrun(uint64_t size) /* {{{ */
+{
+ const int top_bit = 64 - CLZ(size);
+ const int shift = MAX(top_bit, 6) - 6;
+ const int minrun = size >> shift;
+ const uint64_t mask = (MK_UINT64(1) << shift) - 1;
+ if (mask & size) return minrun + 1;
+ return minrun;
+}
+/* }}} */
+
+#ifndef SORT_NAME
+#error "Must declare SORT_NAME"
+#endif
+
+#ifndef SORT_TYPE
+#error "Must declare SORT_TYPE"
+#endif
+
+#ifndef SORT_CMP
+#define SORT_CMP(x, y) ((x) < (y) ? -1 : ((x) == (y) ? 0 : 1))
+#endif
+
+
+#define SORT_SWAP(x,y) {SORT_TYPE __SORT_SWAP_t = (x); (x) = (y); (y) = __SORT_SWAP_t;}
+
+#define SORT_CONCAT(x, y) x ## _ ## y
+#define SORT_MAKE_STR1(x, y) SORT_CONCAT(x,y)
+#define SORT_MAKE_STR(x) SORT_MAKE_STR1(SORT_NAME,x)
+
+#define BINARY_INSERTION_FIND SORT_MAKE_STR(binary_insertion_find)
+#define BINARY_INSERTION_SORT_START SORT_MAKE_STR(binary_insertion_sort_start)
+#define BINARY_INSERTION_SORT SORT_MAKE_STR(binary_insertion_sort)
+#define REVERSE_ELEMENTS SORT_MAKE_STR(reverse_elements)
+#define COUNT_RUN SORT_MAKE_STR(count_run)
+#define CHECK_INVARIANT SORT_MAKE_STR(check_invariant)
+#define TIM_SORT SORT_MAKE_STR(tim_sort)
+#define TIM_SORT_RESIZE SORT_MAKE_STR(tim_sort_resize)
+#define TIM_SORT_MERGE SORT_MAKE_STR(tim_sort_merge)
+#define TIM_SORT_COLLAPSE SORT_MAKE_STR(tim_sort_collapse)
+
+#define TIM_SORT_RUN_T SORT_MAKE_STR(tim_sort_run_t)
+#define TEMP_STORAGE_T SORT_MAKE_STR(temp_storage_t)
+
+typedef struct {
+ int64_t start;
+ int64_t length;
+} TIM_SORT_RUN_T;
+
+void BINARY_INSERTION_SORT(SORT_TYPE *dst, const size_t size);
+void TIM_SORT(SORT_TYPE *dst, const size_t size);
+
+/* Function used to do a binary search for binary insertion sort */
+static int64_t BINARY_INSERTION_FIND(SORT_TYPE *dst, const SORT_TYPE x, const size_t size)
+{
+ int64_t l, c, r;
+ SORT_TYPE lx;
+ SORT_TYPE cx;
+ l = 0;
+ r = size - 1;
+ c = r >> 1;
+ lx = dst[l];
+
+ /* check for beginning conditions */
+ if (SORT_CMP(x, lx) < 0)
+ return 0;
+ else if (SORT_CMP(x, lx) == 0)
+ {
+ int64_t i = 1;
+ while (SORT_CMP(x, dst[i]) == 0) i++;
+ return i;
+ }
+
+ cx = dst[c];
+ while (1)
+ {
+ const int val = SORT_CMP(x, cx);
+ if (val < 0)
+ {
+ if (c - l <= 1) return c;
+ r = c;
+ }
+ else if (val > 0)
+ {
+ if (r - c <= 1) return c + 1;
+ l = c;
+ lx = cx;
+ }
+ else
+ {
+ do
+ {
+ cx = dst[++c];
+ } while (SORT_CMP(x, cx) == 0);
+ return c;
+ }
+ c = l + ((r - l) >> 1);
+ cx = dst[c];
+ }
+}
+
+/* Binary insertion sort, but knowing that the first "start" entries are sorted. Used in timsort. */
+static void BINARY_INSERTION_SORT_START(SORT_TYPE *dst, const size_t start, const size_t size)
+{
+ int64_t i;
+ for (i = start; i < (int64_t) size; i++)
+ {
+ int64_t j;
+ SORT_TYPE x;
+ int64_t location;
+ /* If this entry is already correct, just move along */
+ if (SORT_CMP(dst[i - 1], dst[i]) <= 0) continue;
+
+ /* Else we need to find the right place, shift everything over, and squeeze in */
+ x = dst[i];
+ location = BINARY_INSERTION_FIND(dst, x, i);
+ for (j = i - 1; j >= location; j--)
+ {
+ dst[j + 1] = dst[j];
+ }
+ dst[location] = x;
+ }
+}
+
+/* Binary insertion sort */
+void BINARY_INSERTION_SORT(SORT_TYPE *dst, const size_t size)
+{
+ BINARY_INSERTION_SORT_START(dst, 1, size);
+}
+
+/* timsort implementation, based on timsort.txt */
+
+static void REVERSE_ELEMENTS(SORT_TYPE *dst, int64_t start, int64_t end)
+{
+ while (1)
+ {
+ if (start >= end) return;
+ SORT_SWAP(dst[start], dst[end]);
+ start++;
+ end--;
+ }
+}
+
+static int64_t COUNT_RUN(SORT_TYPE *dst, const int64_t start, const size_t size)
+{
+ int64_t curr;
+ if (size - start == 1) return 1;
+ if (start >= (int64_t) size - 2)
+ {
+ if (SORT_CMP(dst[size - 2], dst[size - 1]) > 0)
+ SORT_SWAP(dst[size - 2], dst[size - 1]);
+ return 2;
+ }
+
+ curr = start + 2;
+
+ if (SORT_CMP(dst[start], dst[start + 1]) <= 0)
+ {
+ /* increasing run */
+ while (1)
+ {
+ if (curr == (int64_t) size - 1) break;
+ if (SORT_CMP(dst[curr - 1], dst[curr]) > 0) break;
+ curr++;
+ }
+ return curr - start;
+ }
+ else
+ {
+ /* decreasing run */
+ while (1)
+ {
+ if (curr == (int64_t) size - 1) break;
+ if (SORT_CMP(dst[curr - 1], dst[curr]) <= 0) break;
+ curr++;
+ }
+ /* reverse in-place */
+ REVERSE_ELEMENTS(dst, start, curr - 1);
+ return curr - start;
+ }
+}
+
+#define PUSH_NEXT() do {\
+len = COUNT_RUN(dst, curr, size);\
+run = minrun;\
+if (run < minrun) run = minrun;\
+if (run > (int64_t) size - curr) run = size - curr;\
+if (run > len)\
+{\
+ BINARY_INSERTION_SORT_START(&dst[curr], len, run);\
+ len = run;\
+}\
+{\
+run_stack[stack_curr].start = curr;\
+run_stack[stack_curr].length = len;\
+stack_curr++;\
+}\
+curr += len;\
+if (curr == (int64_t) size)\
+{\
+ /* finish up */ \
+ while (stack_curr > 1) \
+ { \
+ TIM_SORT_MERGE(dst, run_stack, stack_curr, store); \
+ run_stack[stack_curr - 2].length += run_stack[stack_curr - 1].length; \
+ stack_curr--; \
+ } \
+ if (store->storage != NULL)\
+ {\
+ free(store->storage);\
+ store->storage = NULL;\
+ }\
+ return;\
+}\
+}\
+while (0)
+
+static int CHECK_INVARIANT(TIM_SORT_RUN_T *stack, const int stack_curr)
+{
+ int64_t A, B, C;
+ if (stack_curr < 2) return 1;
+ if (stack_curr == 2)
+ {
+ const int64_t A1 = stack[stack_curr - 2].length;
+ const int64_t B1 = stack[stack_curr - 1].length;
+ if (A1 <= B1) return 0;
+ return 1;
+ }
+ A = stack[stack_curr - 3].length;
+ B = stack[stack_curr - 2].length;
+ C = stack[stack_curr - 1].length;
+ if ((A <= B + C) || (B <= C)) return 0;
+ return 1;
+}
+
+typedef struct {
+ size_t alloc;
+ SORT_TYPE *storage;
+} TEMP_STORAGE_T;
+
+
+static void TIM_SORT_RESIZE(TEMP_STORAGE_T *store, const size_t new_size)
+{
+ if (store->alloc < new_size)
+ {
+ SORT_TYPE *tempstore = (SORT_TYPE *)realloc(store->storage, new_size * sizeof(SORT_TYPE));
+ if (tempstore == NULL)
+ {
+ fprintf(stderr, "Error allocating temporary storage for tim sort: need %lu bytes", sizeof(SORT_TYPE) * new_size);
+ exit(1);
+ }
+ store->storage = tempstore;
+ store->alloc = new_size;
+ }
+}
+
+static void TIM_SORT_MERGE(SORT_TYPE *dst, const TIM_SORT_RUN_T *stack, const int stack_curr, TEMP_STORAGE_T *store)
+{
+ const int64_t A = stack[stack_curr - 2].length;
+ const int64_t B = stack[stack_curr - 1].length;
+ const int64_t curr = stack[stack_curr - 2].start;
+ SORT_TYPE *storage;
+ int64_t i, j, k;
+
+ TIM_SORT_RESIZE(store, MIN(A, B));
+ storage = store->storage;
+
+ /* left merge */
+ if (A < B)
+ {
+ memcpy(storage, &dst[curr], A * sizeof(SORT_TYPE));
+ i = 0;
+ j = curr + A;
+
+ for (k = curr; k < curr + A + B; k++)
+ {
+ if ((i < A) && (j < curr + A + B))
+ {
+ if (SORT_CMP(storage[i], dst[j]) <= 0)
+ dst[k] = storage[i++];
+ else
+ dst[k] = dst[j++];
+ }
+ else if (i < A)
+ {
+ dst[k] = storage[i++];
+ }
+ else
+ dst[k] = dst[j++];
+ }
+ }
+ /* right merge */
+ else
+ {
+ memcpy(storage, &dst[curr + A], B * sizeof(SORT_TYPE));
+ i = B - 1;
+ j = curr + A - 1;
+
+ for (k = curr + A + B - 1; k >= curr; k--)
+ {
+ if ((i >= 0) && (j >= curr))
+ {
+ if (SORT_CMP(dst[j], storage[i]) > 0)
+ dst[k] = dst[j--];
+ else
+ dst[k] = storage[i--];
+ }
+ else if (i >= 0)
+ dst[k] = storage[i--];
+ else
+ dst[k] = dst[j--];
+ }
+ }
+}
+
+static int TIM_SORT_COLLAPSE(SORT_TYPE *dst, TIM_SORT_RUN_T *stack, int stack_curr, TEMP_STORAGE_T *store, const size_t size)
+{
+ while (1) {
+ int64_t A, B, C, D;
+ int ABC, BCD, BD, CD;
+
+ /* if the stack only has one thing on it, we are done with the collapse */
+ if (stack_curr <= 1) {
+ break;
+ }
+
+ /* if this is the last merge, just do it */
+ if ((stack_curr == 2) && (stack[0].length + stack[1].length == size)) {
+ TIM_SORT_MERGE(dst, stack, stack_curr, store);
+ stack[0].length += stack[1].length;
+ stack_curr--;
+ break;
+ }
+ /* check if the invariant is off for a stack of 2 elements */
+ else if ((stack_curr == 2) && (stack[0].length <= stack[1].length)) {
+ TIM_SORT_MERGE(dst, stack, stack_curr, store);
+ stack[0].length += stack[1].length;
+ stack_curr--;
+ break;
+ } else if (stack_curr == 2) {
+ break;
+ }
+
+ B = stack[stack_curr - 3].length;
+ C = stack[stack_curr - 2].length;
+ D = stack[stack_curr - 1].length;
+
+ if (stack_curr >= 4) {
+ A = stack[stack_curr - 4].length;
+ ABC = (A <= B + C);
+ } else {
+ ABC = 0;
+ }
+
+ BCD = (B <= C + D) || ABC;
+ CD = (C <= D);
+ BD = (B < D);
+
+ /* Both invariants are good */
+ if (!BCD && !CD) {
+ break;
+ }
+
+ /* left merge */
+ if (BCD && !CD) {
+ TIM_SORT_MERGE(dst, stack, stack_curr - 1, store);
+ stack[stack_curr - 3].length += stack[stack_curr - 2].length;
+ stack[stack_curr - 2] = stack[stack_curr - 1];
+ stack_curr--;
+ } else {
+ /* right merge */
+ TIM_SORT_MERGE(dst, stack, stack_curr, store);
+ stack[stack_curr - 2].length += stack[stack_curr - 1].length;
+ stack_curr--;
+ }
+ }
+
+ return stack_curr;
+}
+
+void TIM_SORT(SORT_TYPE *dst, const size_t size)
+{
+ int minrun;
+ TEMP_STORAGE_T _store, *store;
+ TIM_SORT_RUN_T run_stack[128];
+ int stack_curr = 0;
+ int64_t len, run;
+ int64_t curr = 0;
+
+ if (size < 64)
+ {
+ BINARY_INSERTION_SORT(dst, size);
+ return;
+ }
+
+ /* compute the minimum run length */
+ minrun = compute_minrun(size);
+
+ /* temporary storage for merges */
+ store = &_store;
+ store->alloc = 0;
+ store->storage = NULL;
+
+ PUSH_NEXT();
+ PUSH_NEXT();
+ PUSH_NEXT();
+
+ while (1)
+ {
+ if (!CHECK_INVARIANT(run_stack, stack_curr))
+ {
+ stack_curr = TIM_SORT_COLLAPSE(dst, run_stack, stack_curr, store, size);
+ continue;
+ }
+ PUSH_NEXT();
+ }
+}
+
+#undef SORT_CONCAT
+#undef SORT_MAKE_STR1
+#undef SORT_MAKE_STR
+#undef SORT_NAME
+#undef SORT_TYPE
+#undef SORT_CMP
+#undef TEMP_STORAGE_T
+#undef TIM_SORT_RUN_T
+#undef PUSH_NEXT
+#undef SORT_SWAP
+#undef SORT_CONCAT
+#undef SORT_MAKE_STR1
+#undef SORT_MAKE_STR
+#undef BINARY_INSERTION_FIND
+#undef BINARY_INSERTION_SORT_START
+#undef BINARY_INSERTION_SORT
+#undef REVERSE_ELEMENTS
+#undef COUNT_RUN
+#undef TIM_SORT
+#undef TIM_SORT_RESIZE
+#undef TIM_SORT_COLLAPSE
+#undef TIM_SORT_RUN_T
+#undef TEMP_STORAGE_T
diff --git a/gnulib-local/lib/libxml/tree.c b/gnulib-local/lib/libxml/tree.c
index d5b9fec..6a158ce 100644
--- a/gnulib-local/lib/libxml/tree.c
+++ b/gnulib-local/lib/libxml/tree.c
@@ -14,7 +14,7 @@
#include "libxml.h"
#include <string.h> /* for memset() only ! */
-
+#include <limits.h>
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
@@ -41,21 +41,25 @@
#include <libxml/debugXML.h>
#endif
+#include "buf.h"
+#include "save.h"
+
int __xmlRegisterCallbacks = 0;
/************************************************************************
* *
- * Forward declarations *
+ * Forward declarations *
* *
************************************************************************/
-xmlNsPtr xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
+static xmlNsPtr
+xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
-static xmlChar* xmlGetPropNodeValueInternal(xmlAttrPtr prop);
+static xmlChar* xmlGetPropNodeValueInternal(const xmlAttr *prop);
/************************************************************************
* *
- * Tree memory error handler *
+ * Tree memory error handler *
* *
************************************************************************/
/**
@@ -92,6 +96,9 @@ xmlTreeErr(int code, xmlNodePtr node, const char *extra)
case XML_TREE_UNTERMINATED_ENTITY:
msg = "unterminated entity reference %15s\n";
break;
+ case XML_TREE_NOT_UTF8:
+ msg = "string is not in UTF-8\n";
+ break;
default:
msg = "unexpected error number\n";
}
@@ -100,7 +107,7 @@ xmlTreeErr(int code, xmlNodePtr node, const char *extra)
/************************************************************************
* *
- * A few static variables and macros *
+ * A few static variables and macros *
* *
************************************************************************/
/* #undef xmlStringText */
@@ -120,7 +127,7 @@ static int xmlCheckDTD = 1;
(n)->last = NULL; \
} else { \
while (ulccur->next != NULL) { \
- ulccur->parent = (n); \
+ ulccur->parent = (n); \
ulccur = ulccur->next; \
} \
ulccur->parent = (n); \
@@ -135,12 +142,12 @@ static int xmlCheckDTD = 1;
/************************************************************************
* *
- * Functions to move to entities.c once the *
+ * Functions to move to entities.c once the *
* API freeze is smoothen and they can be made public. *
* *
************************************************************************/
#include <libxml/hash.h>
-
+
#ifdef LIBXML_TREE_ENABLED
/**
* xmlGetEntityFromDtd:
@@ -149,17 +156,17 @@ static int xmlCheckDTD = 1;
*
* Do an entity lookup in the DTD entity hash table and
* return the corresponding entity, if found.
- *
+ *
* Returns A pointer to the entity structure or NULL if not found.
*/
static xmlEntityPtr
-xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
+xmlGetEntityFromDtd(const xmlDtd *dtd, const xmlChar *name) {
xmlEntitiesTablePtr table;
-
+
if((dtd != NULL) && (dtd->entities != NULL)) {
table = (xmlEntitiesTablePtr) dtd->entities;
return((xmlEntityPtr) xmlHashLookup(table, name));
- /* return(xmlGetEntityFromTable(table, name)); */
+ /* return(xmlGetEntityFromTable(table, name)); */
}
return(NULL);
}
@@ -167,16 +174,16 @@ xmlGetEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
* xmlGetParameterEntityFromDtd:
* @dtd: A pointer to the DTD to search
* @name: The entity name
- *
+ *
* Do an entity lookup in the DTD pararmeter entity hash table and
* return the corresponding entity, if found.
*
* Returns A pointer to the entity structure or NULL if not found.
*/
static xmlEntityPtr
-xmlGetParameterEntityFromDtd(xmlDtdPtr dtd, const xmlChar *name) {
+xmlGetParameterEntityFromDtd(const xmlDtd *dtd, const xmlChar *name) {
xmlEntitiesTablePtr table;
-
+
if ((dtd != NULL) && (dtd->pentities != NULL)) {
table = (xmlEntitiesTablePtr) dtd->pentities;
return((xmlEntityPtr) xmlHashLookup(table, name));
@@ -237,7 +244,7 @@ xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix,
/**
* xmlSplitQName2:
* @name: the full QName
- * @prefix: a xmlChar **
+ * @prefix: a xmlChar **
*
* parse an XML qualified name string
*
@@ -275,9 +282,9 @@ xmlSplitQName2(const xmlChar *name, xmlChar **prefix) {
* we are not trying to validate but just to cut, and yes it will
* work even if this is as set of UTF-8 encoded chars
*/
- while ((name[len] != 0) && (name[len] != ':'))
+ while ((name[len] != 0) && (name[len] != ':'))
len++;
-
+
if (name[len] == 0)
return(NULL);
@@ -307,7 +314,7 @@ xmlSplitQName2(const xmlChar *name, xmlChar **prefix) {
* parse an XML qualified name string,i
*
* returns NULL if it is not a Qualified Name, otherwise, update len
- * with the lenght in byte of the prefix and return a pointer
+ * with the length in byte of the prefix and return a pointer
* to the start of the name without the prefix
*/
@@ -326,9 +333,9 @@ xmlSplitQName3(const xmlChar *name, int *len) {
* we are not trying to validate but just to cut, and yes it will
* work even if this is as set of UTF-8 encoded chars
*/
- while ((name[l] != 0) && (name[l] != ':'))
+ while ((name[l] != 0) && (name[l] != ':'))
l++;
-
+
if (name[l] == 0)
return(NULL);
@@ -342,10 +349,10 @@ xmlSplitQName3(const xmlChar *name, int *len) {
* Check Name, NCName and QName strings *
* *
************************************************************************/
-
+
#define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
/**
* xmlValidateNCName:
* @value: the value to check
@@ -665,19 +672,22 @@ try_complex:
* Allocation and deallocation of basic structures *
* *
************************************************************************/
-
+
/**
* xmlSetBufferAllocationScheme:
* @scheme: allocation method to use
- *
+ *
* Set the buffer allocation method. Types are
* XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down
- * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
+ * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
* improves performance
*/
void
xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme) {
- xmlBufferAllocScheme = scheme;
+ if ((scheme == XML_BUFFER_ALLOC_EXACT) ||
+ (scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
+ (scheme == XML_BUFFER_ALLOC_HYBRID))
+ xmlBufferAllocScheme = scheme;
}
/**
@@ -685,9 +695,12 @@ xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme) {
*
* Types are
* XML_BUFFER_ALLOC_EXACT - use exact sizes, keeps memory usage down
- * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
+ * XML_BUFFER_ALLOC_DOUBLEIT - double buffer when extra needed,
* improves performance
- *
+ * XML_BUFFER_ALLOC_HYBRID - use exact sizes on small strings to keep memory usage tight
+ * in normal usage, and doubleit on large strings to avoid
+ * pathological performance.
+ *
* Returns the current allocation scheme
*/
xmlBufferAllocationScheme
@@ -704,8 +717,11 @@ xmlGetBufferAllocationScheme(void) {
* 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.
+ *
* Returns a new namespace pointer or NULL
*/
xmlNsPtr
@@ -715,8 +731,19 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) {
if ((node != NULL) && (node->type != XML_ELEMENT_NODE))
return(NULL);
- if ((prefix != NULL) && (xmlStrEqual(prefix, BAD_CAST "xml")))
- return(NULL);
+ if ((prefix != NULL) && (xmlStrEqual(prefix, BAD_CAST "xml"))) {
+ /* xml namespace is predefined, no need to add it */
+ if (xmlStrEqual(href, XML_XML_NAMESPACE))
+ return(NULL);
+
+ /*
+ * Problem, this is an attempt to bind xml prefix to a wrong
+ * namespace, which breaks
+ * Namespace constraint: Reserved Prefixes and Namespace Names
+ * from XML namespace. But documents authors may not care in
+ * their context so let's proceed.
+ */
+ }
/*
* Allocate a new Namespace and fill the fields.
@@ -730,9 +757,9 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) {
cur->type = XML_LOCAL_NAMESPACE;
if (href != NULL)
- cur->href = xmlStrdup(href);
+ cur->href = xmlStrdup(href);
if (prefix != NULL)
- cur->prefix = xmlStrdup(prefix);
+ cur->prefix = xmlStrdup(prefix);
/*
* Add it at the end to preserve parsing order ...
@@ -748,14 +775,14 @@ xmlNewNs(xmlNodePtr node, const xmlChar *href, const xmlChar *prefix) {
(xmlStrEqual(prev->prefix, cur->prefix))) {
xmlFreeNs(cur);
return(NULL);
- }
+ }
while (prev->next != NULL) {
prev = prev->next;
if (((prev->prefix == NULL) && (cur->prefix == NULL)) ||
(xmlStrEqual(prev->prefix, cur->prefix))) {
xmlFreeNs(cur);
return(NULL);
- }
+ }
}
prev->next = cur;
}
@@ -779,7 +806,9 @@ xmlSetNs(xmlNodePtr node, xmlNsPtr ns) {
#endif
return;
}
- node->ns = ns;
+ if ((node->type == XML_ELEMENT_NODE) ||
+ (node->type == XML_ATTRIBUTE_NODE))
+ node->ns = ns;
}
/**
@@ -864,11 +893,11 @@ xmlNewDtd(xmlDocPtr doc, const xmlChar *name,
cur->type = XML_DTD_NODE;
if (name != NULL)
- cur->name = xmlStrdup(name);
+ cur->name = xmlStrdup(name);
if (ExternalID != NULL)
- cur->ExternalID = xmlStrdup(ExternalID);
+ cur->ExternalID = xmlStrdup(ExternalID);
if (SystemID != NULL)
- cur->SystemID = xmlStrdup(SystemID);
+ cur->SystemID = xmlStrdup(SystemID);
if (doc != NULL)
doc->extSubset = cur;
cur->doc = doc;
@@ -887,7 +916,7 @@ xmlNewDtd(xmlDocPtr doc, const xmlChar *name,
*/
xmlDtdPtr
-xmlGetIntSubset(xmlDocPtr doc) {
+xmlGetIntSubset(const xmlDoc *doc) {
xmlNodePtr cur;
if (doc == NULL)
@@ -946,7 +975,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
}
}
if (ExternalID != NULL) {
- cur->ExternalID = xmlStrdup(ExternalID);
+ cur->ExternalID = xmlStrdup(ExternalID);
if (cur->ExternalID == NULL) {
xmlTreeErrMemory("building internal subset");
if (cur->name != NULL)
@@ -956,7 +985,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
}
}
if (SystemID != NULL) {
- cur->SystemID = xmlStrdup(SystemID);
+ cur->SystemID = xmlStrdup(SystemID);
if (cur->SystemID == NULL) {
xmlTreeErrMemory("building internal subset");
if (cur->name != NULL)
@@ -1019,7 +1048,7 @@ xmlCreateIntSubset(xmlDocPtr doc, const xmlChar *name,
* current scope
*/
#define DICT_FREE(str) \
- if ((str) && ((!dict) || \
+ if ((str) && ((!dict) || \
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
xmlFree((char *)(str));
@@ -1102,7 +1131,7 @@ xmlFreeDtd(xmlDtdPtr cur) {
/* TODO !!! */
if (cur->notations != NULL)
xmlFreeNotationTable((xmlNotationTablePtr) cur->notations);
-
+
if (cur->elements != NULL)
xmlFreeElementTable((xmlElementTablePtr) cur->elements);
if (cur->attributes != NULL)
@@ -1141,15 +1170,17 @@ xmlNewDoc(const xmlChar *version) {
memset(cur, 0, sizeof(xmlDoc));
cur->type = XML_DOCUMENT_NODE;
- cur->version = xmlStrdup(version);
+ cur->version = xmlStrdup(version);
if (cur->version == NULL) {
xmlTreeErrMemory("building doc");
xmlFree(cur);
- return(NULL);
+ return(NULL);
}
cur->standalone = -1;
cur->compression = -1; /* not initialized */
cur->doc = cur;
+ cur->parseFlags = 0;
+ cur->properties = XML_DOC_USERBUILT;
/*
* The in memory encoding is always UTF8
* This field will never change and would
@@ -1235,16 +1266,21 @@ xmlFreeDoc(xmlDocPtr cur) {
* Returns a pointer to the first child
*/
xmlNodePtr
-xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
+xmlStringLenGetNodeList(const xmlDoc *doc, const xmlChar *value, int len) {
xmlNodePtr ret = NULL, last = NULL;
xmlNodePtr node;
xmlChar *val;
const xmlChar *cur = value, *end = cur + len;
const xmlChar *q;
xmlEntityPtr ent;
+ xmlBufPtr buf;
if (value == NULL) return(NULL);
+ buf = xmlBufCreateSize(0);
+ if (buf == NULL) return(NULL);
+ xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_HYBRID);
+
q = cur;
while ((cur < end) && (*cur != 0)) {
if (cur[0] == '&') {
@@ -1255,19 +1291,8 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
* Save the current text.
*/
if (cur != q) {
- if ((last != NULL) && (last->type == XML_TEXT_NODE)) {
- xmlNodeAddContentLen(last, q, cur - q);
- } else {
- node = xmlNewDocTextLen(doc, q, cur - q);
- if (node == NULL) return(ret);
- if (last == NULL)
- last = ret = node;
- else {
- last->next = node;
- node->prev = last;
- last = node;
- }
- }
+ if (xmlBufAdd(buf, q, cur - q))
+ goto out;
}
q = cur;
if ((cur + 2 < end) && (cur[1] == '#') && (cur[2] == 'x')) {
@@ -1277,7 +1302,7 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
else
tmp = 0;
while (tmp != ';') { /* Non input consuming loop */
- if ((tmp >= '0') && (tmp <= '9'))
+ if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 16 + (tmp - '0');
else if ((tmp >= 'a') && (tmp <= 'f'))
charval = charval * 16 + (tmp - 'a') + 10;
@@ -1305,7 +1330,7 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
else
tmp = 0;
while (tmp != ';') { /* Non input consuming loops */
- if ((tmp >= '0') && (tmp <= '9'))
+ if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 10 + (tmp - '0');
else {
xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc,
@@ -1332,7 +1357,7 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
if ((cur >= end) || (*cur == 0)) {
xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY, (xmlNodePtr) doc,
(const char *) q);
- return(ret);
+ goto out;
}
if (cur != q) {
/*
@@ -1342,23 +1367,36 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
ent = xmlGetDocEntity(doc, val);
if ((ent != NULL) &&
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
- if (last == NULL) {
- node = xmlNewDocText(doc, ent->content);
- last = ret = node;
- } else if (last->type != XML_TEXT_NODE) {
- node = xmlNewDocText(doc, ent->content);
- last = xmlAddNextSibling(last, node);
- } else
- xmlNodeAddContent(last, ent->content);
-
+
+ if (xmlBufCat(buf, ent->content))
+ goto out;
+
} else {
/*
+ * Flush buffer so far
+ */
+ if (!xmlBufIsEmpty(buf)) {
+ node = xmlNewDocText(doc, NULL);
+ if (node == NULL) {
+ if (val != NULL) xmlFree(val);
+ goto out;
+ }
+ node->content = xmlBufDetach(buf);
+
+ if (last == NULL) {
+ last = ret = node;
+ } else {
+ last = xmlAddNextSibling(last, node);
+ }
+ }
+
+ /*
* Create a new REFERENCE_REF node
*/
node = xmlNewReference(doc, val);
if (node == NULL) {
if (val != NULL) xmlFree(val);
- return(ret);
+ goto out;
}
else if ((ent != NULL) && (ent->children == NULL)) {
xmlNodePtr temp;
@@ -1385,40 +1423,44 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
q = cur;
}
if (charval != 0) {
- xmlChar buf[10];
+ xmlChar buffer[10];
int l;
- l = xmlCopyCharMultiByte(buf, charval);
- buf[l] = 0;
- node = xmlNewDocText(doc, buf);
- if (node != NULL) {
- if (last == NULL) {
- last = ret = node;
- } else {
- last = xmlAddNextSibling(last, node);
- }
- }
+ l = xmlCopyCharMultiByte(buffer, charval);
+ buffer[l] = 0;
+
+ if (xmlBufCat(buf, buffer))
+ goto out;
charval = 0;
}
} else
cur++;
}
- if ((cur != q) || (ret == NULL)) {
+
+ if (cur != q) {
/*
* Handle the last piece of text.
*/
- if ((last != NULL) && (last->type == XML_TEXT_NODE)) {
- xmlNodeAddContentLen(last, q, cur - q);
+ if (xmlBufAdd(buf, q, cur - q))
+ goto out;
+ }
+
+ if (!xmlBufIsEmpty(buf)) {
+ node = xmlNewDocText(doc, NULL);
+ if (node == NULL) goto out;
+ node->content = xmlBufDetach(buf);
+
+ if (last == NULL) {
+ ret = node;
} else {
- node = xmlNewDocTextLen(doc, q, cur - q);
- if (node == NULL) return(ret);
- if (last == NULL) {
- last = ret = node;
- } else {
- last = xmlAddNextSibling(last, node);
- }
+ xmlAddNextSibling(last, node);
}
+ } else if (ret == NULL) {
+ ret = xmlNewDocText(doc, BAD_CAST "");
}
+
+out:
+ xmlBufFree(buf);
return(ret);
}
@@ -1432,16 +1474,21 @@ xmlStringLenGetNodeList(xmlDocPtr doc, const xmlChar *value, int len) {
* Returns a pointer to the first child
*/
xmlNodePtr
-xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
+xmlStringGetNodeList(const xmlDoc *doc, const xmlChar *value) {
xmlNodePtr ret = NULL, last = NULL;
xmlNodePtr node;
xmlChar *val;
const xmlChar *cur = value;
const xmlChar *q;
xmlEntityPtr ent;
+ xmlBufPtr buf;
if (value == NULL) return(NULL);
+ buf = xmlBufCreateSize(0);
+ if (buf == NULL) return(NULL);
+ xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_HYBRID);
+
q = cur;
while (*cur != 0) {
if (cur[0] == '&') {
@@ -1452,26 +1499,15 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
* Save the current text.
*/
if (cur != q) {
- if ((last != NULL) && (last->type == XML_TEXT_NODE)) {
- xmlNodeAddContentLen(last, q, cur - q);
- } else {
- node = xmlNewDocTextLen(doc, q, cur - q);
- if (node == NULL) return(ret);
- if (last == NULL)
- last = ret = node;
- else {
- last->next = node;
- node->prev = last;
- last = node;
- }
- }
+ if (xmlBufAdd(buf, q, cur - q))
+ goto out;
}
q = cur;
if ((cur[1] == '#') && (cur[2] == 'x')) {
cur += 3;
tmp = *cur;
while (tmp != ';') { /* Non input consuming loop */
- if ((tmp >= '0') && (tmp <= '9'))
+ if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 16 + (tmp - '0');
else if ((tmp >= 'a') && (tmp <= 'f'))
charval = charval * 16 + (tmp - 'a') + 10;
@@ -1493,7 +1529,7 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
cur += 2;
tmp = *cur;
while (tmp != ';') { /* Non input consuming loops */
- if ((tmp >= '0') && (tmp <= '9'))
+ if ((tmp >= '0') && (tmp <= '9'))
charval = charval * 10 + (tmp - '0');
else {
xmlTreeErr(XML_TREE_INVALID_DEC, (xmlNodePtr) doc,
@@ -1517,7 +1553,7 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
if (*cur == 0) {
xmlTreeErr(XML_TREE_UNTERMINATED_ENTITY,
(xmlNodePtr) doc, (const char *) q);
- return(ret);
+ goto out;
}
if (cur != q) {
/*
@@ -1527,23 +1563,32 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
ent = xmlGetDocEntity(doc, val);
if ((ent != NULL) &&
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
- if (last == NULL) {
- node = xmlNewDocText(doc, ent->content);
- last = ret = node;
- } else if (last->type != XML_TEXT_NODE) {
- node = xmlNewDocText(doc, ent->content);
- last = xmlAddNextSibling(last, node);
- } else
- xmlNodeAddContent(last, ent->content);
-
+
+ if (xmlBufCat(buf, ent->content))
+ goto out;
+
} else {
/*
+ * Flush buffer so far
+ */
+ if (!xmlBufIsEmpty(buf)) {
+ node = xmlNewDocText(doc, NULL);
+ node->content = xmlBufDetach(buf);
+
+ if (last == NULL) {
+ last = ret = node;
+ } else {
+ last = xmlAddNextSibling(last, node);
+ }
+ }
+
+ /*
* Create a new REFERENCE_REF node
*/
node = xmlNewReference(doc, val);
if (node == NULL) {
if (val != NULL) xmlFree(val);
- return(ret);
+ goto out;
}
else if ((ent != NULL) && (ent->children == NULL)) {
xmlNodePtr temp;
@@ -1569,20 +1614,14 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
q = cur;
}
if (charval != 0) {
- xmlChar buf[10];
+ xmlChar buffer[10];
int len;
- len = xmlCopyCharMultiByte(buf, charval);
- buf[len] = 0;
- node = xmlNewDocText(doc, buf);
- if (node != NULL) {
- if (last == NULL) {
- last = ret = node;
- } else {
- last = xmlAddNextSibling(last, node);
- }
- }
+ len = xmlCopyCharMultiByte(buffer, charval);
+ buffer[len] = 0;
+ if (xmlBufCat(buf, buffer))
+ goto out;
charval = 0;
}
} else
@@ -1592,18 +1631,22 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
/*
* Handle the last piece of text.
*/
- if ((last != NULL) && (last->type == XML_TEXT_NODE)) {
- xmlNodeAddContentLen(last, q, cur - q);
+ xmlBufAdd(buf, q, cur - q);
+ }
+
+ if (!xmlBufIsEmpty(buf)) {
+ node = xmlNewDocText(doc, NULL);
+ node->content = xmlBufDetach(buf);
+
+ if (last == NULL) {
+ ret = node;
} else {
- node = xmlNewDocTextLen(doc, q, cur - q);
- if (node == NULL) return(ret);
- if (last == NULL) {
- last = ret = node;
- } else {
- last = xmlAddNextSibling(last, node);
- }
+ xmlAddNextSibling(last, node);
}
}
+
+out:
+ xmlBufFree(buf);
return(ret);
}
@@ -1619,14 +1662,19 @@ xmlStringGetNodeList(xmlDocPtr doc, const xmlChar *value) {
* Returns a pointer to the string copy, the caller must free it with xmlFree().
*/
xmlChar *
-xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine)
+xmlNodeListGetString(xmlDocPtr doc, const xmlNode *list, int inLine)
{
- xmlNodePtr node = list;
+ const xmlNode *node = list;
xmlChar *ret = NULL;
xmlEntityPtr ent;
+ int attr;
if (list == NULL)
return (NULL);
+ if ((list->parent != NULL) && (list->parent->type == XML_ATTRIBUTE_NODE))
+ attr = 1;
+ else
+ attr = 0;
while (node != NULL) {
if ((node->type == XML_TEXT_NODE) ||
@@ -1636,7 +1684,10 @@ xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine)
} else {
xmlChar *buffer;
- buffer = xmlEncodeEntitiesReentrant(doc, node->content);
+ if (attr)
+ buffer = xmlEncodeAttributeEntities(doc, node->content);
+ else
+ buffer = xmlEncodeEntitiesReentrant(doc, node->content);
if (buffer != NULL) {
ret = xmlStrcat(ret, buffer);
xmlFree(buffer);
@@ -1701,9 +1752,9 @@ xmlNodeListGetString(xmlDocPtr doc, xmlNodePtr list, int inLine)
* Returns a pointer to the string copy, the caller must free it with xmlFree().
*/
xmlChar *
-xmlNodeListGetRawString(xmlDocPtr doc, xmlNodePtr list, int inLine)
+xmlNodeListGetRawString(const xmlDoc *doc, const xmlNode *list, int inLine)
{
- xmlNodePtr node = list;
+ const xmlNode *node = list;
xmlChar *ret = NULL;
xmlEntityPtr ent;
@@ -1780,7 +1831,9 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
xmlDocPtr doc = NULL;
if ((node != NULL) && (node->type != XML_ELEMENT_NODE)) {
- if (eatname == 1)
+ if ((eatname == 1) &&
+ ((node->doc == NULL) ||
+ (!(xmlDictOwns(node->doc->dict, name)))))
xmlFree((xmlChar *) name);
return (NULL);
}
@@ -1790,7 +1843,9 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
*/
cur = (xmlAttrPtr) xmlMalloc(sizeof(xmlAttr));
if (cur == NULL) {
- if (eatname == 1)
+ if ((eatname == 1) &&
+ ((node == NULL) || (node->doc == NULL) ||
+ (!(xmlDictOwns(node->doc->dict, name)))))
xmlFree((xmlChar *) name);
xmlTreeErrMemory("building attribute");
return (NULL);
@@ -1814,11 +1869,15 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
cur->name = name;
if (value != NULL) {
- xmlChar *buffer;
xmlNodePtr tmp;
- buffer = xmlEncodeEntitiesReentrant(doc, value);
- cur->children = xmlStringGetNodeList(doc, buffer);
+ if(!xmlCheckUTF8(value)) {
+ xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) doc,
+ NULL);
+ if (doc != NULL)
+ doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
+ }
+ cur->children = xmlNewDocText(doc, value);
cur->last = NULL;
tmp = cur->children;
while (tmp != NULL) {
@@ -1827,7 +1886,6 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
cur->last = tmp;
tmp = tmp->next;
}
- xmlFree(buffer);
}
/*
@@ -1846,7 +1904,8 @@ xmlNewPropInternal(xmlNodePtr node, xmlNsPtr ns,
}
}
- if (xmlIsID((node == NULL) ? NULL : node->doc, node, cur) == 1)
+ if ((value != NULL) && (node != NULL) &&
+ (xmlIsID(node->doc, node, cur) == 1))
xmlAddID(NULL, node->doc, value, cur);
if ((__xmlRegisterCallbacks) && (xmlRegisterNodeDefaultValue))
@@ -1927,7 +1986,7 @@ xmlNewNsPropEatName(xmlNodePtr node, xmlNsPtr ns, xmlChar *name,
return(NULL);
}
- return xmlNewPropInternal(node, ns, name, value, 1);
+ return xmlNewPropInternal(node, ns, name, value, 1);
}
/**
@@ -1966,7 +2025,7 @@ xmlNewDocProp(xmlDocPtr doc, const xmlChar *name, const xmlChar *value) {
cur->name = xmlDictLookup(doc->dict, name, -1);
else
cur->name = xmlStrdup(name);
- cur->doc = doc;
+ cur->doc = doc;
if (value != NULL) {
xmlNodePtr tmp;
@@ -2173,7 +2232,7 @@ xmlNewNode(xmlNsPtr ns, const xmlChar *name) {
}
memset(cur, 0, sizeof(xmlNode));
cur->type = XML_ELEMENT_NODE;
-
+
cur->name = xmlStrdup(name);
cur->ns = ns;
@@ -2210,13 +2269,13 @@ xmlNewNodeEatName(xmlNsPtr ns, xmlChar *name) {
*/
cur = (xmlNodePtr) xmlMalloc(sizeof(xmlNode));
if (cur == NULL) {
- xmlFree(name);
xmlTreeErrMemory("building node");
+ /* we can't check here that name comes from the doc dictionnary */
return(NULL);
}
memset(cur, 0, sizeof(xmlNode));
cur->type = XML_ELEMENT_NODE;
-
+
cur->name = name;
cur->ns = ns;
@@ -2290,6 +2349,11 @@ xmlNewDocNodeEatName(xmlDocPtr doc, xmlNsPtr ns,
cur->children = xmlStringGetNodeList(doc, content);
UPDATE_LAST_CHILD_AND_PARENT(cur)
}
+ } else {
+ /* if name don't come from the doc dictionnary free it here */
+ if ((name != NULL) && (doc != NULL) &&
+ (!(xmlDictOwns(doc->dict, name))))
+ xmlFree(name);
}
return(cur);
}
@@ -2399,9 +2463,9 @@ xmlNewText(const xmlChar *content) {
* 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.
+ * 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.
*
* Returns a pointer to the new node object.
*/
@@ -2519,7 +2583,7 @@ xmlNewCharRef(xmlDocPtr doc, const xmlChar *name) {
* Returns a pointer to the new node object.
*/
xmlNodePtr
-xmlNewReference(xmlDocPtr doc, const xmlChar *name) {
+xmlNewReference(const xmlDoc *doc, const xmlChar *name) {
xmlNodePtr cur;
xmlEntityPtr ent;
@@ -2537,7 +2601,7 @@ xmlNewReference(xmlDocPtr doc, const xmlChar *name) {
memset(cur, 0, sizeof(xmlNode));
cur->type = XML_ENTITY_REF_NODE;
- cur->doc = doc;
+ cur->doc = (xmlDoc *)doc;
if (name[0] == '&') {
int len;
name++;
@@ -2575,11 +2639,11 @@ xmlNewReference(xmlDocPtr doc, const xmlChar *name) {
* Returns a pointer to the new node object.
*/
xmlNodePtr
-xmlNewDocText(xmlDocPtr doc, const xmlChar *content) {
+xmlNewDocText(const xmlDoc *doc, const xmlChar *content) {
xmlNodePtr cur;
cur = xmlNewText(content);
- if (cur != NULL) cur->doc = doc;
+ if (cur != NULL) cur->doc = (xmlDoc *)doc;
return(cur);
}
@@ -2729,14 +2793,33 @@ void
xmlSetTreeDoc(xmlNodePtr tree, xmlDocPtr doc) {
xmlAttrPtr prop;
- if (tree == NULL)
+ if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL))
return;
if (tree->doc != doc) {
if(tree->type == XML_ELEMENT_NODE) {
prop = tree->properties;
while (prop != NULL) {
+ if (prop->atype == XML_ATTRIBUTE_ID) {
+ xmlRemoveID(tree->doc, prop);
+ }
+
prop->doc = doc;
xmlSetListDoc(prop->children, doc);
+
+ /*
+ * TODO: ID attributes should be also added to the new
+ * document, but this breaks things like xmlReplaceNode.
+ * The underlying problem is that xmlRemoveID is only called
+ * if a node is destroyed, not if it's unlinked.
+ */
+#if 0
+ if (xmlIsID(doc, tree, prop)) {
+ xmlChar *idVal = xmlNodeListGetString(doc, prop->children,
+ 1);
+ xmlAddID(NULL, doc, idVal, prop);
+ }
+#endif
+
prop = prop->next;
}
}
@@ -2757,7 +2840,7 @@ void
xmlSetListDoc(xmlNodePtr list, xmlDocPtr doc) {
xmlNodePtr cur;
- if (list == NULL)
+ if ((list == NULL) || (list->type == XML_NAMESPACE_DECL))
return;
cur = list;
while (cur != NULL) {
@@ -2849,14 +2932,14 @@ xmlNewChild(xmlNodePtr parent, xmlNsPtr ns,
/**
* xmlAddPropSibling:
- * @prev: the attribute to which @prop is added after
+ * @prev: the attribute to which @prop is added after
* @cur: the base attribute passed to calling function
* @prop: the new attribute
*
* Add a new attribute after @prev using @cur as base attribute.
* When inserting before @cur, @prev is passed as @cur->prev.
* When inserting after @cur, @prev is passed as @cur.
- * If an existing attribute is found it is detroyed prior to adding @prop.
+ * If an existing attribute is found it is detroyed prior to adding @prop.
*
* Returns the attribute being inserted or NULL in case of error.
*/
@@ -2864,7 +2947,9 @@ static xmlNodePtr
xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) {
xmlAttrPtr attr;
- if (cur->type != XML_ATTRIBUTE_NODE)
+ if ((cur == NULL) || (cur->type != XML_ATTRIBUTE_NODE) ||
+ (prop == NULL) || (prop->type != XML_ATTRIBUTE_NODE) ||
+ ((prev != NULL) && (prev->type != XML_ATTRIBUTE_NODE)))
return(NULL);
/* check if an attribute with the same name exists */
@@ -2906,20 +2991,20 @@ xmlAddPropSibling(xmlNodePtr prev, xmlNodePtr cur, xmlNodePtr prop) {
* 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.
+ * If there is an attribute with equal name, it is first destroyed.
*
* Returns the new node or NULL in case of error.
*/
xmlNodePtr
xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
- if (cur == NULL) {
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlAddNextSibling : cur == NULL\n");
#endif
return(NULL);
}
- if (elem == NULL) {
+ if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlAddNextSibling : elem == NULL\n");
@@ -2973,7 +3058,7 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
}
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
- defined(LIBXML_SCHEMAS_ENABLED)
+ defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
/**
* xmlAddPrevSibling:
* @cur: the child node
@@ -2984,20 +3069,20 @@ xmlAddNextSibling(xmlNodePtr cur, xmlNodePtr elem) {
* 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.
+ * If there is an attribute with equal name, it is first destroyed.
*
* Returns the new node or NULL in case of error.
*/
xmlNodePtr
xmlAddPrevSibling(xmlNodePtr cur, xmlNodePtr elem) {
- if (cur == NULL) {
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlAddPrevSibling : cur == NULL\n");
#endif
return(NULL);
}
- if (elem == NULL) {
+ if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlAddPrevSibling : elem == NULL\n");
@@ -3068,7 +3153,7 @@ xmlNodePtr
xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
xmlNodePtr parent;
- if (cur == NULL) {
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlAddSibling : cur == NULL\n");
@@ -3076,7 +3161,7 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
return(NULL);
}
- if (elem == NULL) {
+ if ((elem == NULL) || (elem->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlAddSibling : elem == NULL\n");
@@ -3084,11 +3169,19 @@ xmlAddSibling(xmlNodePtr cur, xmlNodePtr elem) {
return(NULL);
}
+ if (cur == elem) {
+#ifdef DEBUG_TREE
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlAddSibling : cur == elem\n");
+#endif
+ return(NULL);
+ }
+
/*
* Constant time is we can rely on the ->parent->last to find
* the last sibling.
*/
- if ((cur->type != XML_ATTRIBUTE_NODE) && (cur->parent != NULL) &&
+ if ((cur->type != XML_ATTRIBUTE_NODE) && (cur->parent != NULL) &&
(cur->parent->children != NULL) &&
(cur->parent->last != NULL) &&
(cur->parent->last->next == NULL)) {
@@ -3136,7 +3229,7 @@ xmlNodePtr
xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
xmlNodePtr prev;
- if (parent == NULL) {
+ if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlAddChildList : parent == NULL\n");
@@ -3144,7 +3237,7 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
return(NULL);
}
- if (cur == NULL) {
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlAddChildList : child == NULL\n");
@@ -3170,10 +3263,10 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
/*
* If cur and parent->last both are TEXT nodes, then merge them.
*/
- if ((cur->type == XML_TEXT_NODE) &&
+ if ((cur->type == XML_TEXT_NODE) &&
(parent->last->type == XML_TEXT_NODE) &&
(cur->name == parent->last->name)) {
- xmlNodeAddContent(parent->last, cur->content);
+ xmlNodeAddContent(parent->last, cur->content);
/*
* if it's the only child, nothing more to be done.
*/
@@ -3197,7 +3290,10 @@ xmlAddChildList(xmlNodePtr parent, xmlNodePtr cur) {
cur = cur->next;
}
cur->parent = parent;
- cur->doc = parent->doc; /* the parent may not be linked to a doc ! */
+ /* the parent may not be linked to a doc ! */
+ if (cur->doc != parent->doc) {
+ xmlSetTreeDoc(cur, parent->doc);
+ }
parent->last = cur;
return(cur);
@@ -3211,7 +3307,7 @@ xmlAddChildList(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.
+ * If there is an attribute with equal name, it is first destroyed.
*
* Returns the child or NULL in case of error.
*/
@@ -3219,7 +3315,7 @@ xmlNodePtr
xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
xmlNodePtr prev;
- if (parent == NULL) {
+ if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlAddChild : parent == NULL\n");
@@ -3227,7 +3323,7 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
return(NULL);
}
- if (cur == NULL) {
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlAddChild : child == NULL\n");
@@ -3290,9 +3386,7 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
if (cur->type == XML_ATTRIBUTE_NODE) {
if (parent->type != XML_ELEMENT_NODE)
return(NULL);
- if (parent->properties == NULL) {
- parent->properties = (xmlAttrPtr) cur;
- } else {
+ if (parent->properties != NULL) {
/* check if an attribute with the same name exists */
xmlAttrPtr lastattr;
@@ -3307,8 +3401,13 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
}
if (lastattr == (xmlAttrPtr) cur)
return(cur);
+
+ }
+ if (parent->properties == NULL) {
+ parent->properties = (xmlAttrPtr) cur;
+ } else {
/* find the end */
- lastattr = parent->properties;
+ xmlAttrPtr lastattr = parent->properties;
while (lastattr->next != NULL) {
lastattr = lastattr->next;
}
@@ -3337,8 +3436,8 @@ xmlAddChild(xmlNodePtr parent, xmlNodePtr cur) {
* Returns the last child or NULL if none.
*/
xmlNodePtr
-xmlGetLastChild(xmlNodePtr parent) {
- if (parent == NULL) {
+xmlGetLastChild(const xmlNode *parent) {
+ if ((parent == NULL) || (parent->type == XML_NAMESPACE_DECL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlGetLastChild : parent == NULL\n");
@@ -3348,6 +3447,202 @@ xmlGetLastChild(xmlNodePtr parent) {
return(parent->last);
}
+#ifdef LIBXML_TREE_ENABLED
+/*
+ * 5 interfaces from DOM ElementTraversal
+ */
+
+/**
+ * xmlChildElementCount:
+ * @parent: the parent node
+ *
+ * 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.
+ *
+ * Returns the count of element child or 0 if not available
+ */
+unsigned long
+xmlChildElementCount(xmlNodePtr parent) {
+ unsigned long ret = 0;
+ xmlNodePtr cur = NULL;
+
+ if (parent == NULL)
+ return(0);
+ switch (parent->type) {
+ case XML_ELEMENT_NODE:
+ case XML_ENTITY_NODE:
+ case XML_DOCUMENT_NODE:
+ case XML_DOCUMENT_FRAG_NODE:
+ case XML_HTML_DOCUMENT_NODE:
+ cur = parent->children;
+ break;
+ default:
+ return(0);
+ }
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE)
+ ret++;
+ cur = cur->next;
+ }
+ return(ret);
+}
+
+/**
+ * xmlFirstElementChild:
+ * @parent: the parent node
+ *
+ * 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.
+ *
+ * Returns the first element child or NULL if not available
+ */
+xmlNodePtr
+xmlFirstElementChild(xmlNodePtr parent) {
+ xmlNodePtr cur = NULL;
+
+ if (parent == NULL)
+ return(NULL);
+ switch (parent->type) {
+ case XML_ELEMENT_NODE:
+ case XML_ENTITY_NODE:
+ case XML_DOCUMENT_NODE:
+ case XML_DOCUMENT_FRAG_NODE:
+ case XML_HTML_DOCUMENT_NODE:
+ cur = parent->children;
+ break;
+ default:
+ return(NULL);
+ }
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE)
+ return(cur);
+ cur = cur->next;
+ }
+ return(NULL);
+}
+
+/**
+ * xmlLastElementChild:
+ * @parent: the parent node
+ *
+ * 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.
+ *
+ * Returns the last element child or NULL if not available
+ */
+xmlNodePtr
+xmlLastElementChild(xmlNodePtr parent) {
+ xmlNodePtr cur = NULL;
+
+ if (parent == NULL)
+ return(NULL);
+ switch (parent->type) {
+ case XML_ELEMENT_NODE:
+ case XML_ENTITY_NODE:
+ case XML_DOCUMENT_NODE:
+ case XML_DOCUMENT_FRAG_NODE:
+ case XML_HTML_DOCUMENT_NODE:
+ cur = parent->last;
+ break;
+ default:
+ return(NULL);
+ }
+ while (cur != NULL) {
+ if (cur->type == XML_ELEMENT_NODE)
+ return(cur);
+ cur = cur->prev;
+ }
+ return(NULL);
+}
+
+/**
+ * xmlPreviousElementSibling:
+ * @node: the current 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.
+ *
+ * Returns the previous element sibling or NULL if not available
+ */
+xmlNodePtr
+xmlPreviousElementSibling(xmlNodePtr node) {
+ if (node == NULL)
+ return(NULL);
+ switch (node->type) {
+ case XML_ELEMENT_NODE:
+ case XML_TEXT_NODE:
+ case XML_CDATA_SECTION_NODE:
+ case XML_ENTITY_REF_NODE:
+ case XML_ENTITY_NODE:
+ case XML_PI_NODE:
+ case XML_COMMENT_NODE:
+ case XML_XINCLUDE_START:
+ case XML_XINCLUDE_END:
+ node = node->prev;
+ break;
+ default:
+ return(NULL);
+ }
+ while (node != NULL) {
+ if (node->type == XML_ELEMENT_NODE)
+ return(node);
+ node = node->prev;
+ }
+ return(NULL);
+}
+
+/**
+ * xmlNextElementSibling:
+ * @node: the current 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.
+ *
+ * Returns the next element sibling or NULL if not available
+ */
+xmlNodePtr
+xmlNextElementSibling(xmlNodePtr node) {
+ if (node == NULL)
+ return(NULL);
+ switch (node->type) {
+ case XML_ELEMENT_NODE:
+ case XML_TEXT_NODE:
+ case XML_CDATA_SECTION_NODE:
+ case XML_ENTITY_REF_NODE:
+ case XML_ENTITY_NODE:
+ case XML_PI_NODE:
+ case XML_COMMENT_NODE:
+ case XML_DTD_NODE:
+ case XML_XINCLUDE_START:
+ case XML_XINCLUDE_END:
+ node = node->next;
+ break;
+ default:
+ return(NULL);
+ }
+ while (node != NULL) {
+ if (node->type == XML_ELEMENT_NODE)
+ return(node);
+ node = node->next;
+ }
+ return(NULL);
+}
+
+#endif /* LIBXML_TREE_ENABLED */
+
/**
* xmlFreeNodeList:
* @cur: the first node in the list
@@ -3450,6 +3745,11 @@ xmlFreeNode(xmlNodePtr cur) {
if (cur->doc != NULL) dict = cur->doc->dict;
+ if (cur->type == XML_ENTITY_DECL) {
+ xmlEntityPtr ent = (xmlEntityPtr) cur;
+ DICT_FREE(ent->SystemID);
+ DICT_FREE(ent->ExternalID);
+ }
if ((cur->children != NULL) &&
(cur->type != XML_ENTITY_REF_NODE))
xmlFreeNodeList(cur->children);
@@ -3490,6 +3790,10 @@ xmlFreeNode(xmlNodePtr cur) {
* @cur: the node
*
* 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.
*/
void
xmlUnlinkNode(xmlNodePtr cur) {
@@ -3500,6 +3804,8 @@ xmlUnlinkNode(xmlNodePtr cur) {
#endif
return;
}
+ if (cur->type == XML_NAMESPACE_DECL)
+ return;
if (cur->type == XML_DTD_NODE) {
xmlDocPtr doc;
doc = cur->doc;
@@ -3510,6 +3816,28 @@ xmlUnlinkNode(xmlNodePtr cur) {
doc->extSubset = NULL;
}
}
+ if (cur->type == XML_ENTITY_DECL) {
+ xmlDocPtr doc;
+ doc = cur->doc;
+ if (doc != NULL) {
+ if (doc->intSubset != NULL) {
+ if (xmlHashLookup(doc->intSubset->entities, cur->name) == cur)
+ xmlHashRemoveEntry(doc->intSubset->entities, cur->name,
+ NULL);
+ if (xmlHashLookup(doc->intSubset->pentities, cur->name) == cur)
+ xmlHashRemoveEntry(doc->intSubset->pentities, cur->name,
+ NULL);
+ }
+ if (doc->extSubset != NULL) {
+ if (xmlHashLookup(doc->extSubset->entities, cur->name) == cur)
+ xmlHashRemoveEntry(doc->extSubset->entities, cur->name,
+ NULL);
+ if (xmlHashLookup(doc->extSubset->pentities, cur->name) == cur)
+ xmlHashRemoveEntry(doc->extSubset->pentities, cur->name,
+ NULL);
+ }
+ }
+ }
if (cur->parent != NULL) {
xmlNodePtr parent;
parent = cur->parent;
@@ -3546,14 +3874,15 @@ xmlUnlinkNode(xmlNodePtr cur) {
xmlNodePtr
xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
if (old == cur) return(NULL);
- if ((old == NULL) || (old->parent == NULL)) {
+ if ((old == NULL) || (old->type == XML_NAMESPACE_DECL) ||
+ (old->parent == NULL)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlReplaceNode : old == NULL or without parent\n");
#endif
return(NULL);
}
- if (cur == NULL) {
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL)) {
xmlUnlinkNode(old);
return(old);
}
@@ -3605,7 +3934,7 @@ xmlReplaceNode(xmlNodePtr old, xmlNodePtr cur) {
* Copy operations *
* *
************************************************************************/
-
+
/**
* xmlCopyNamespace:
* @cur: the namespace
@@ -3667,6 +3996,8 @@ xmlCopyPropInternal(xmlDocPtr doc, xmlNodePtr target, xmlAttrPtr cur) {
xmlAttrPtr ret;
if (cur == NULL) return(NULL);
+ if ((target != NULL) && (target->type != XML_ELEMENT_NODE))
+ return(NULL);
if (target != NULL)
ret = xmlNewDocProp(target->doc, cur->name, NULL);
else if (doc != NULL)
@@ -3722,7 +4053,7 @@ xmlCopyPropInternal(xmlDocPtr doc, xmlNodePtr target, xmlAttrPtr cur) {
ret->ns = xmlNewReconciliedNs(target->doc, target, cur->ns);
}
}
-
+
} else
ret->ns = NULL;
@@ -3786,6 +4117,8 @@ xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) {
xmlAttrPtr ret = NULL;
xmlAttrPtr p = NULL,q;
+ if ((target != NULL) && (target->type != XML_ELEMENT_NODE))
+ return(NULL);
while (cur != NULL) {
q = xmlCopyProp(target, cur);
if (q == NULL)
@@ -3822,7 +4155,7 @@ xmlCopyPropList(xmlNodePtr target, xmlAttrPtr cur) {
*/
static xmlNodePtr
-xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
+xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
int extended) {
xmlNodePtr ret;
@@ -3843,7 +4176,7 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
return((xmlNodePtr) xmlCopyPropInternal(doc, parent, (xmlAttrPtr) node));
case XML_NAMESPACE_DECL:
return((xmlNodePtr) xmlCopyNamespaceList((xmlNsPtr) node));
-
+
case XML_DOCUMENT_NODE:
case XML_HTML_DOCUMENT_NODE:
#ifdef LIBXML_DOCB_ENABLED
@@ -3873,7 +4206,7 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
ret->type = node->type;
ret->doc = doc;
- ret->parent = parent;
+ ret->parent = parent;
if (node->name == xmlStringText)
ret->name = xmlStringText;
else if (node->name == xmlStringTextNoenc)
@@ -3912,10 +4245,11 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
if (tmp != ret)
return(tmp);
}
-
+
if (!extended)
goto out;
- if ((node->type == XML_ELEMENT_NODE) && (node->nsDef != NULL))
+ if (((node->type == XML_ELEMENT_NODE) ||
+ (node->type == XML_XINCLUDE_START)) && (node->nsDef != NULL))
ret->nsDef = xmlCopyNamespaceList(node->nsDef);
if (node->ns != NULL) {
@@ -3934,6 +4268,8 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
while (root->parent != NULL) root = root->parent;
ret->ns = xmlNewNs(root, ns->href, ns->prefix);
+ } else {
+ ret->ns = xmlNewReconciliedNs(doc, ret, node->ns);
}
} else {
/*
@@ -3942,7 +4278,8 @@ xmlStaticCopyNode(const xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent,
ret->ns = ns;
}
}
- if ((node->type == XML_ELEMENT_NODE) && (node->properties != NULL))
+ if (((node->type == XML_ELEMENT_NODE) ||
+ (node->type == XML_XINCLUDE_START)) && (node->properties != NULL))
ret->properties = xmlCopyPropList(ret, node->properties);
if (node->type == XML_ENTITY_REF_NODE) {
if ((doc == NULL) || (node->doc != doc)) {
@@ -3984,6 +4321,7 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
}
if (doc->intSubset == NULL) {
q = (xmlNodePtr) xmlCopyDtd( (xmlDtdPtr) node );
+ if (q == NULL) return(NULL);
q->doc = doc;
q->parent = parent;
doc->intSubset = (xmlDtdPtr) q;
@@ -3995,6 +4333,7 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
} else
#endif /* LIBXML_TREE_ENABLED */
q = xmlStaticCopyNode(node, doc, parent, 1);
+ if (q == NULL) return(NULL);
if (ret == NULL) {
q->prev = NULL;
ret = p = q;
@@ -4021,7 +4360,7 @@ xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent) {
* Returns: a new #xmlNodePtr, or NULL in case of error.
*/
xmlNodePtr
-xmlCopyNode(const xmlNodePtr node, int extended) {
+xmlCopyNode(xmlNodePtr node, int extended) {
xmlNodePtr ret;
ret = xmlStaticCopyNode(node, NULL, NULL, extended);
@@ -4041,7 +4380,7 @@ xmlCopyNode(const xmlNodePtr node, int extended) {
* Returns: a new #xmlNodePtr, or NULL in case of error.
*/
xmlNodePtr
-xmlDocCopyNode(const xmlNodePtr node, xmlDocPtr doc, int extended) {
+xmlDocCopyNode(xmlNodePtr node, xmlDocPtr doc, int extended) {
xmlNodePtr ret;
ret = xmlStaticCopyNode(node, doc, NULL, extended);
@@ -4057,7 +4396,7 @@ xmlDocCopyNode(const xmlNodePtr node, xmlDocPtr doc, int extended) {
*
* Returns: a new #xmlNodePtr, or NULL in case of error.
*/
-xmlNodePtr xmlDocCopyNodeList(xmlDocPtr doc, const xmlNodePtr node) {
+xmlNodePtr xmlDocCopyNodeList(xmlDocPtr doc, xmlNodePtr node) {
xmlNodePtr ret = xmlStaticCopyNodeList(node, doc, NULL);
return(ret);
}
@@ -4071,7 +4410,7 @@ xmlNodePtr xmlDocCopyNodeList(xmlDocPtr doc, const xmlNodePtr node) {
*
* Returns: a new #xmlNodePtr, or NULL in case of error.
*/
-xmlNodePtr xmlCopyNodeList(const xmlNodePtr node) {
+xmlNodePtr xmlCopyNodeList(xmlNodePtr node) {
xmlNodePtr ret = xmlStaticCopyNodeList(node, NULL, NULL);
return(ret);
}
@@ -4108,7 +4447,7 @@ xmlCopyDtd(xmlDtdPtr dtd) {
if (dtd->pentities != NULL)
ret->pentities = (void *) xmlCopyEntitiesTable(
(xmlEntitiesTablePtr) dtd->pentities);
-
+
cur = dtd->children;
while (cur != NULL) {
q = NULL;
@@ -4123,7 +4462,7 @@ xmlCopyDtd(xmlDtdPtr dtd) {
break;
case XML_INTERNAL_PARAMETER_ENTITY:
case XML_EXTERNAL_PARAMETER_ENTITY:
- q = (xmlNodePtr)
+ q = (xmlNodePtr)
xmlGetParameterEntityFromDtd(ret, tmp->name);
break;
case XML_INTERNAL_PREDEFINED_ENTITY:
@@ -4135,27 +4474,27 @@ xmlCopyDtd(xmlDtdPtr dtd) {
xmlGetDtdQElementDesc(ret, tmp->name, tmp->prefix);
} else if (cur->type == XML_ATTRIBUTE_DECL) {
xmlAttributePtr tmp = (xmlAttributePtr) cur;
- q = (xmlNodePtr)
+ q = (xmlNodePtr)
xmlGetDtdQAttrDesc(ret, tmp->elem, tmp->name, tmp->prefix);
} else if (cur->type == XML_COMMENT_NODE) {
q = xmlCopyNode(cur, 0);
}
-
+
if (q == NULL) {
cur = cur->next;
continue;
}
-
+
if (p == NULL)
ret->children = q;
else
- p->next = q;
-
- q->prev = p;
- q->parent = (xmlNodePtr) ret;
+ p->next = q;
+
+ q->prev = p;
+ q->parent = (xmlNodePtr) ret;
q->next = NULL;
ret->last = q;
- p = q;
+ p = q;
cur = cur->next;
}
@@ -4197,6 +4536,10 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
#ifdef LIBXML_TREE_ENABLED
if (doc->intSubset != NULL) {
ret->intSubset = xmlCopyDtd(doc->intSubset);
+ if (ret->intSubset == NULL) {
+ xmlFreeDoc(ret);
+ return(NULL);
+ }
xmlSetTreeDoc((xmlNodePtr)ret->intSubset, ret);
ret->intSubset->parent = ret;
}
@@ -4205,7 +4548,7 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
ret->oldNs = xmlCopyNamespaceList(doc->oldNs);
if (doc->children != NULL) {
xmlNodePtr tmp;
-
+
ret->children = xmlStaticCopyNodeList(doc->children, ret,
(xmlNodePtr)ret);
ret->last = NULL;
@@ -4225,41 +4568,73 @@ xmlCopyDoc(xmlDocPtr doc, int recursive) {
* Content access functions *
* *
************************************************************************/
-
+
/**
- * xmlGetLineNo:
+ * xmlGetLineNoInternal:
* @node: valid node
+ * @depth: used to limit any risk of recursion
*
- * Get line number of @node. This requires activation of this option
- * before invoking the parser by calling xmlLineNumbersDefault(1)
+ * Get line number of @node.
+ * Try to override the limitation of lines being store in 16 bits ints
*
* Returns the line number if successful, -1 otherwise
*/
-long
-xmlGetLineNo(xmlNodePtr node)
+static long
+xmlGetLineNoInternal(const xmlNode *node, int depth)
{
long result = -1;
+ if (depth >= 5)
+ return(-1);
+
if (!node)
return result;
if ((node->type == XML_ELEMENT_NODE) ||
(node->type == XML_TEXT_NODE) ||
(node->type == XML_COMMENT_NODE) ||
- (node->type == XML_PI_NODE))
- result = (long) node->line;
- else if ((node->prev != NULL) &&
+ (node->type == XML_PI_NODE)) {
+ if (node->line == 65535) {
+ if ((node->type == XML_TEXT_NODE) && (node->psvi != NULL))
+ result = (long) node->psvi;
+ else if ((node->type == XML_ELEMENT_NODE) &&
+ (node->children != NULL))
+ result = xmlGetLineNoInternal(node->children, depth + 1);
+ else if (node->next != NULL)
+ result = xmlGetLineNoInternal(node->next, depth + 1);
+ else if (node->prev != NULL)
+ result = xmlGetLineNoInternal(node->prev, depth + 1);
+ }
+ if ((result == -1) || (result == 65535))
+ result = (long) node->line;
+ } else if ((node->prev != NULL) &&
((node->prev->type == XML_ELEMENT_NODE) ||
(node->prev->type == XML_TEXT_NODE) ||
(node->prev->type == XML_COMMENT_NODE) ||
(node->prev->type == XML_PI_NODE)))
- result = xmlGetLineNo(node->prev);
+ result = xmlGetLineNoInternal(node->prev, depth + 1);
else if ((node->parent != NULL) &&
(node->parent->type == XML_ELEMENT_NODE))
- result = xmlGetLineNo(node->parent);
+ result = xmlGetLineNoInternal(node->parent, depth + 1);
return result;
}
+/**
+ * xmlGetLineNo:
+ * @node: valid node
+ *
+ * Get line number of @node.
+ * Try to override the limitation of lines being store in 16 bits ints
+ * if XML_PARSE_BIG_LINES parser option was used
+ *
+ * Returns the line number if successful, -1 otherwise
+ */
+long
+xmlGetLineNo(const xmlNode *node)
+{
+ return(xmlGetLineNoInternal(node, 0));
+}
+
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
/**
* xmlGetNodePath:
@@ -4271,9 +4646,9 @@ xmlGetLineNo(xmlNodePtr node)
* the returned string
*/
xmlChar *
-xmlGetNodePath(xmlNodePtr node)
+xmlGetNodePath(const xmlNode *node)
{
- xmlNodePtr cur, tmp, next;
+ const xmlNode *cur, *tmp, *next;
xmlChar *buffer = NULL, *temp;
size_t buf_len;
xmlChar *buf;
@@ -4282,7 +4657,7 @@ xmlGetNodePath(xmlNodePtr node)
char nametemp[100];
int occur = 0, generic;
- if (node == NULL)
+ if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
return (NULL);
buf_len = 500;
@@ -4317,7 +4692,7 @@ xmlGetNodePath(xmlNodePtr node)
if (cur->ns) {
if (cur->ns->prefix != NULL) {
snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s",
- (char *)cur->ns->prefix, (char *)cur->name);
+ (char *)cur->ns->prefix, (char *)cur->name);
nametemp[sizeof(nametemp) - 1] = 0;
name = nametemp;
} else {
@@ -4327,7 +4702,7 @@ xmlGetNodePath(xmlNodePtr node)
*/
generic = 1;
name = "*";
- }
+ }
}
next = cur->parent;
@@ -4415,7 +4790,7 @@ xmlGetNodePath(xmlNodePtr node)
{
occur = 1;
break;
- }
+ }
tmp = tmp->next;
}
} else
@@ -4458,10 +4833,10 @@ xmlGetNodePath(xmlNodePtr node)
if (cur->ns) {
if (cur->ns->prefix != NULL)
snprintf(nametemp, sizeof(nametemp) - 1, "%s:%s",
- (char *)cur->ns->prefix, (char *)cur->name);
+ (char *)cur->ns->prefix, (char *)cur->name);
else
snprintf(nametemp, sizeof(nametemp) - 1, "%s",
- (char *)cur->name);
+ (char *)cur->name);
nametemp[sizeof(nametemp) - 1] = 0;
name = nametemp;
}
@@ -4517,7 +4892,7 @@ xmlGetNodePath(xmlNodePtr node)
* Returns the #xmlNodePtr for the root or NULL
*/
xmlNodePtr
-xmlDocGetRootElement(xmlDocPtr doc) {
+xmlDocGetRootElement(const xmlDoc *doc) {
xmlNodePtr ret;
if (doc == NULL) return(NULL);
@@ -4529,7 +4904,7 @@ xmlDocGetRootElement(xmlDocPtr doc) {
}
return(ret);
}
-
+
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
/**
* xmlDocSetRootElement:
@@ -4547,7 +4922,7 @@ xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
xmlNodePtr old = NULL;
if (doc == NULL) return(NULL);
- if (root == NULL)
+ if ((root == NULL) || (root->type == XML_NAMESPACE_DECL))
return(NULL);
xmlUnlinkNode(root);
xmlSetTreeDoc(root, doc);
@@ -4571,7 +4946,7 @@ xmlDocSetRootElement(xmlDocPtr doc, xmlNodePtr root) {
return(old);
}
#endif
-
+
#if defined(LIBXML_TREE_ENABLED)
/**
* xmlNodeSetLang:
@@ -4619,7 +4994,7 @@ xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
xmlSetNsProp(cur, ns, BAD_CAST "lang", lang);
}
#endif /* LIBXML_TREE_ENABLED */
-
+
/**
* xmlNodeGetLang:
* @cur: the node being checked
@@ -4631,9 +5006,11 @@ xmlNodeSetLang(xmlNodePtr cur, const xmlChar *lang) {
* It's up to the caller to free the memory with xmlFree().
*/
xmlChar *
-xmlNodeGetLang(xmlNodePtr cur) {
+xmlNodeGetLang(const xmlNode *cur) {
xmlChar *lang;
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
+ return(NULL);
while (cur != NULL) {
lang = xmlGetNsProp(cur, BAD_CAST "lang", XML_XML_NAMESPACE);
if (lang != NULL)
@@ -4642,7 +5019,7 @@ xmlNodeGetLang(xmlNodePtr cur) {
}
return(NULL);
}
-
+
#ifdef LIBXML_TREE_ENABLED
/**
@@ -4710,9 +5087,11 @@ xmlNodeSetSpacePreserve(xmlNodePtr cur, int val) {
* Returns -1 if xml:space is not inherited, 0 if "default", 1 if "preserve"
*/
int
-xmlNodeGetSpacePreserve(xmlNodePtr cur) {
+xmlNodeGetSpacePreserve(const xmlNode *cur) {
xmlChar *space;
+ if ((cur == NULL) || (cur->type != XML_ELEMENT_NODE))
+ return(-1);
while (cur != NULL) {
space = xmlGetNsProp(cur, BAD_CAST "space", XML_XML_NAMESPACE);
if (space != NULL) {
@@ -4730,7 +5109,7 @@ xmlNodeGetSpacePreserve(xmlNodePtr cur) {
}
return(-1);
}
-
+
#ifdef LIBXML_TREE_ENABLED
/**
* xmlNodeSetName:
@@ -4743,6 +5122,7 @@ void
xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
xmlDocPtr doc;
xmlDictPtr dict;
+ const xmlChar *freeme = NULL;
if (cur == NULL) return;
if (name == NULL) return;
@@ -4780,15 +5160,19 @@ xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
dict = NULL;
if (dict != NULL) {
if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name)))
- xmlFree((xmlChar *) cur->name);
+ freeme = cur->name;
cur->name = xmlDictLookup(dict, name, -1);
} else {
- if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
+ if (cur->name != NULL)
+ freeme = cur->name;
cur->name = xmlStrdup(name);
}
+
+ if (freeme)
+ xmlFree((xmlChar *) freeme);
}
#endif
-
+
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
/**
* xmlNodeSetBase:
@@ -4801,7 +5185,7 @@ xmlNodeSetName(xmlNodePtr cur, const xmlChar *name) {
void
xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) {
xmlNsPtr ns;
- const xmlChar* fixed;
+ xmlChar* fixed;
if (cur == NULL) return;
switch(cur->type) {
@@ -4841,7 +5225,7 @@ xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) {
return;
}
}
-
+
ns = xmlSearchNsByHref(cur->doc, cur, XML_XML_NAMESPACE);
if (ns == NULL)
return;
@@ -4867,19 +5251,21 @@ xmlNodeSetBase(xmlNodePtr cur, const xmlChar* uri) {
* and
* 5.1.2. Base URI from the Encapsulating Entity
* However it does not return the document base (5.1.3), use
- * xmlDocumentGetBase() for this
+ * doc->URL in this case
*
* Returns a pointer to the base URL, or NULL if not found
* It's up to the caller to free the memory with xmlFree().
*/
xmlChar *
-xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
+xmlNodeGetBase(const xmlDoc *doc, const xmlNode *cur) {
xmlChar *oldbase = NULL;
xmlChar *base, *newbase;
- if ((cur == NULL) && (doc == NULL))
+ if ((cur == NULL) && (doc == NULL))
+ return(NULL);
+ if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL))
return(NULL);
- if (doc == NULL) doc = cur->doc;
+ if (doc == NULL) doc = cur->doc;
if ((doc != NULL) && (doc->type == XML_HTML_DOCUMENT_NODE)) {
cur = doc->children;
while ((cur != NULL) && (cur->name != NULL)) {
@@ -4941,7 +5327,7 @@ xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
}
return(oldbase);
}
-
+
/**
* xmlNodeBufGetContent:
* @buffer: a buffer
@@ -4952,31 +5338,59 @@ xmlNodeGetBase(xmlDocPtr doc, xmlNodePtr cur) {
* of the values carried by this node child's (TEXT and ENTITY_REF).
* Entity references are substituted.
* Fills up the buffer @buffer with this value
- *
+ *
* Returns 0 in case of success and -1 in case of error.
*/
int
-xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
+xmlNodeBufGetContent(xmlBufferPtr buffer, const xmlNode *cur)
{
+ xmlBufPtr buf;
+ int ret;
+
if ((cur == NULL) || (buffer == NULL)) return(-1);
+ buf = xmlBufFromBuffer(buffer);
+ ret = xmlBufGetNodeContent(buf, cur);
+ buffer = xmlBufBackToBuffer(buf);
+ if ((ret < 0) || (buffer == NULL))
+ return(-1);
+ return(0);
+}
+
+/**
+ * xmlBufGetNodeContent:
+ * @buf: a buffer xmlBufPtr
+ * @cur: the node being read
+ *
+ * Read the value of a node @cur, 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.
+ * Fills up the buffer @buf with this value
+ *
+ * Returns 0 in case of success and -1 in case of error.
+ */
+int
+xmlBufGetNodeContent(xmlBufPtr buf, const xmlNode *cur)
+{
+ if ((cur == NULL) || (buf == NULL)) return(-1);
switch (cur->type) {
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
- xmlBufferCat(buffer, cur->content);
+ xmlBufCat(buf, cur->content);
break;
case XML_DOCUMENT_FRAG_NODE:
case XML_ELEMENT_NODE:{
- xmlNodePtr tmp = cur;
+ const xmlNode *tmp = cur;
while (tmp != NULL) {
switch (tmp->type) {
case XML_CDATA_SECTION_NODE:
case XML_TEXT_NODE:
if (tmp->content != NULL)
- xmlBufferCat(buffer, tmp->content);
+ xmlBufCat(buf, tmp->content);
break;
case XML_ENTITY_REF_NODE:
- xmlNodeBufGetContent(buffer, tmp);
+ xmlBufGetNodeContent(buf, tmp);
break;
default:
break;
@@ -5020,16 +5434,16 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
while (tmp != NULL) {
if (tmp->type == XML_TEXT_NODE)
- xmlBufferCat(buffer, tmp->content);
+ xmlBufCat(buf, tmp->content);
else
- xmlNodeBufGetContent(buffer, tmp);
+ xmlBufGetNodeContent(buf, tmp);
tmp = tmp->next;
}
break;
}
case XML_COMMENT_NODE:
case XML_PI_NODE:
- xmlBufferCat(buffer, cur->content);
+ xmlBufCat(buf, cur->content);
break;
case XML_ENTITY_REF_NODE:{
xmlEntityPtr ent;
@@ -5047,7 +5461,7 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
* xmlNodeGetContent() which handles all possible node types */
tmp = ent->children;
while (tmp) {
- xmlNodeBufGetContent(buffer, tmp);
+ xmlBufGetNodeContent(buf, tmp);
tmp = tmp->next;
}
break;
@@ -5069,13 +5483,13 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
if ((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE)) {
- xmlNodeBufGetContent(buffer, cur);
+ xmlBufGetNodeContent(buf, cur);
}
cur = cur->next;
}
break;
case XML_NAMESPACE_DECL:
- xmlBufferCat(buffer, ((xmlNsPtr) cur)->href);
+ xmlBufCat(buf, ((xmlNsPtr) cur)->href);
break;
case XML_ELEMENT_DECL:
case XML_ATTRIBUTE_DECL:
@@ -5084,6 +5498,7 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
}
return(0);
}
+
/**
* xmlNodeGetContent:
* @cur: the node being read
@@ -5096,23 +5511,22 @@ xmlNodeBufGetContent(xmlBufferPtr buffer, xmlNodePtr cur)
* It's up to the caller to free the memory with xmlFree().
*/
xmlChar *
-xmlNodeGetContent(xmlNodePtr cur)
+xmlNodeGetContent(const xmlNode *cur)
{
if (cur == NULL)
return (NULL);
switch (cur->type) {
case XML_DOCUMENT_FRAG_NODE:
case XML_ELEMENT_NODE:{
- xmlBufferPtr buffer;
+ xmlBufPtr buf;
xmlChar *ret;
- buffer = xmlBufferCreateSize(64);
- if (buffer == NULL)
+ buf = xmlBufCreateSize(64);
+ if (buf == NULL)
return (NULL);
- xmlNodeBufGetContent(buffer, cur);
- ret = buffer->content;
- buffer->content = NULL;
- xmlBufferFree(buffer);
+ xmlBufGetNodeContent(buf, cur);
+ ret = xmlBufDetach(buf);
+ xmlBufFree(buf);
return (ret);
}
case XML_ATTRIBUTE_NODE:
@@ -5124,7 +5538,7 @@ xmlNodeGetContent(xmlNodePtr cur)
return (NULL);
case XML_ENTITY_REF_NODE:{
xmlEntityPtr ent;
- xmlBufferPtr buffer;
+ xmlBufPtr buf;
xmlChar *ret;
/* lookup entity declaration */
@@ -5132,15 +5546,14 @@ xmlNodeGetContent(xmlNodePtr cur)
if (ent == NULL)
return (NULL);
- buffer = xmlBufferCreate();
- if (buffer == NULL)
+ buf = xmlBufCreate();
+ if (buf == NULL)
return (NULL);
- xmlNodeBufGetContent(buffer, cur);
+ xmlBufGetNodeContent(buf, cur);
- ret = buffer->content;
- buffer->content = NULL;
- xmlBufferFree(buffer);
+ ret = xmlBufDetach(buf);
+ xmlBufFree(buf);
return (ret);
}
case XML_ENTITY_NODE:
@@ -5155,18 +5568,17 @@ xmlNodeGetContent(xmlNodePtr cur)
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE: {
- xmlBufferPtr buffer;
+ xmlBufPtr buf;
xmlChar *ret;
- buffer = xmlBufferCreate();
- if (buffer == NULL)
+ buf = xmlBufCreate();
+ if (buf == NULL)
return (NULL);
- xmlNodeBufGetContent(buffer, (xmlNodePtr) cur);
+ xmlBufGetNodeContent(buf, (xmlNodePtr) cur);
- ret = buffer->content;
- buffer->content = NULL;
- xmlBufferFree(buffer);
+ ret = xmlBufDetach(buf);
+ xmlBufFree(buf);
return (ret);
}
case XML_NAMESPACE_DECL: {
@@ -5199,6 +5611,9 @@ xmlNodeGetContent(xmlNodePtr cur)
* @content: the new value of the 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().
*/
void
xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
@@ -5228,12 +5643,12 @@ xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
if (!((cur->doc != NULL) && (cur->doc->dict != NULL) &&
(xmlDictOwns(cur->doc->dict, cur->content))))
xmlFree(cur->content);
- }
+ }
if (cur->children != NULL) xmlFreeNodeList(cur->children);
cur->last = cur->children = NULL;
if (content != NULL) {
cur->content = xmlStrdup(content);
- } else
+ } else
cur->content = NULL;
cur->properties = NULL;
cur->nsDef = NULL;
@@ -5273,6 +5688,9 @@ xmlNodeSetContent(xmlNodePtr cur, const xmlChar *content) {
* @len: the size of @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().
*/
void
xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
@@ -5303,12 +5721,12 @@ xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
if (!((cur->doc != NULL) && (cur->doc->dict != NULL) &&
(xmlDictOwns(cur->doc->dict, cur->content))))
xmlFree(cur->content);
- }
+ }
if (cur->children != NULL) xmlFreeNodeList(cur->children);
cur->children = cur->last = NULL;
if (content != NULL) {
cur->content = xmlStrndup(content, len);
- } else
+ } else
cur->content = NULL;
cur->properties = NULL;
cur->nsDef = NULL;
@@ -5342,8 +5760,11 @@ xmlNodeSetContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
* @cur: the node being modified
* @content: extra content
* @len: the size of @content
- *
+ *
* 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.
*/
void
xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
@@ -5414,8 +5835,11 @@ xmlNodeAddContentLen(xmlNodePtr cur, const xmlChar *content, int len) {
* xmlNodeAddContent:
* @cur: the node being modified
* @content: extra 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.
*/
void
xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) {
@@ -5437,7 +5861,7 @@ xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) {
* xmlTextMerge:
* @first: the first text node
* @second: the second text node being merged
- *
+ *
* Merge two text nodes into one
* Returns the first text node augmented
*/
@@ -5467,7 +5891,7 @@ xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
* namespace if defined
*/
xmlNsPtr *
-xmlGetNsList(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node)
+xmlGetNsList(const xmlDoc *doc ATTRIBUTE_UNUSED, const xmlNode *node)
{
xmlNsPtr cur;
xmlNsPtr *ret = NULL;
@@ -5475,6 +5899,9 @@ xmlGetNsList(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node)
int maxns = 10;
int i;
+ if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
+ return(NULL);
+
while (node != NULL) {
if (node->type == XML_ELEMENT_NODE) {
cur = node->nsDef;
@@ -5522,9 +5949,9 @@ xmlGetNsList(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node)
/*
* xmlTreeEnsureXMLDecl:
* @doc: the doc
-*
+*
* Ensures that there is an XML namespace declaration on the doc.
-*
+*
* Returns the XML ns-struct or NULL on API and internal errors.
*/
static xmlNsPtr
@@ -5544,7 +5971,7 @@ xmlTreeEnsureXMLDecl(xmlDocPtr doc)
}
memset(ns, 0, sizeof(xmlNs));
ns->type = XML_LOCAL_NAMESPACE;
- ns->href = xmlStrdup(XML_XML_NAMESPACE);
+ ns->href = xmlStrdup(XML_XML_NAMESPACE);
ns->prefix = xmlStrdup((const xmlChar *)"xml");
doc->oldNs = ns;
return (ns);
@@ -5569,11 +5996,11 @@ xmlTreeEnsureXMLDecl(xmlDocPtr doc)
*/
xmlNsPtr
xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
-
+
xmlNsPtr cur;
- xmlNodePtr orig = node;
+ const xmlNode *orig = node;
- if (node == NULL) return(NULL);
+ if ((node == NULL) || (node->type == XML_NAMESPACE_DECL)) return(NULL);
if ((nameSpace != NULL) &&
(xmlStrEqual(nameSpace, (const xmlChar *)"xml"))) {
if ((doc == NULL) && (node->type == XML_ELEMENT_NODE)) {
@@ -5589,8 +6016,8 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
}
memset(cur, 0, sizeof(xmlNs));
cur->type = XML_LOCAL_NAMESPACE;
- cur->href = xmlStrdup(XML_XML_NAMESPACE);
- cur->prefix = xmlStrdup((const xmlChar *)"xml");
+ cur->href = xmlStrdup(XML_XML_NAMESPACE);
+ cur->prefix = xmlStrdup((const xmlChar *)"xml");
cur->next = node->nsDef;
node->nsDef = cur;
return(cur);
@@ -5625,7 +6052,7 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
return(cur);
cur = cur->next;
}
- if (orig != node) {
+ if (orig != node) {
cur = node->ns;
if (cur != NULL) {
if ((cur->prefix == NULL) && (nameSpace == NULL) &&
@@ -5636,7 +6063,7 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
(xmlStrEqual(cur->prefix, nameSpace)))
return(cur);
}
- }
+ }
}
node = node->parent;
}
@@ -5652,7 +6079,7 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
*
* Verify that the given namespace held on @ancestor is still in scope
* on node.
- *
+ *
* Returns 1 if true, 0 if false and -1 in case of error.
*/
static int
@@ -5685,7 +6112,7 @@ xmlNsInScope(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node,
return (-1);
return (1);
}
-
+
/**
* xmlSearchNsByHref:
* @doc: the document
@@ -5703,7 +6130,7 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href)
xmlNodePtr orig = node;
int is_attr;
- if ((node == NULL) || (href == NULL))
+ if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) || (href == NULL))
return (NULL);
if (xmlStrEqual(href, XML_XML_NAMESPACE)) {
/*
@@ -5739,7 +6166,7 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href)
if (doc->oldNs == NULL)
return(xmlTreeEnsureXMLDecl(doc));
else
- return(doc->oldNs);
+ return(doc->oldNs);
}
is_attr = (node->type == XML_ATTRIBUTE_NODE);
while (node != NULL) {
@@ -5768,7 +6195,7 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href)
return (cur);
}
}
- }
+ }
}
node = node->parent;
}
@@ -5788,13 +6215,13 @@ xmlSearchNsByHref(xmlDocPtr doc, xmlNodePtr node, const xmlChar * href)
* @tree or on one of its ancestors then a new prefix is generated.
* Returns the (new) namespace definition or NULL in case of error
*/
-xmlNsPtr
+static xmlNsPtr
xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
xmlNsPtr def;
xmlChar prefix[50];
int counter = 1;
- if (tree == NULL) {
+ if ((tree == NULL) || (tree->type != XML_ELEMENT_NODE)) {
#ifdef DEBUG_TREE
xmlGenericError(xmlGenericErrorContext,
"xmlNewReconciliedNs : tree == NULL\n");
@@ -5831,7 +6258,7 @@ xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
snprintf((char *) prefix, sizeof(prefix), "default%d", counter++);
else
snprintf((char *) prefix, sizeof(prefix), "%.20s%d",
- (char *)ns->prefix, counter++);
+ (char *)ns->prefix, counter++);
def = xmlSearchNs(doc, tree, prefix);
}
@@ -6026,7 +6453,7 @@ xmlReconciliateNs(xmlDocPtr doc, xmlNodePtr tree) {
}
}
/* exit condition */
- if (node == tree)
+ if (node == tree)
node = NULL;
} else
break;
@@ -6040,7 +6467,7 @@ xmlReconciliateNs(xmlDocPtr doc, xmlNodePtr tree) {
#endif /* LIBXML_TREE_ENABLED */
static xmlAttrPtr
-xmlGetPropNodeInternal(xmlNodePtr node, const xmlChar *name,
+xmlGetPropNodeInternal(const xmlNode *node, const xmlChar *name,
const xmlChar *nsName, int useDTD)
{
xmlAttrPtr prop;
@@ -6082,14 +6509,14 @@ xmlGetPropNodeInternal(xmlNodePtr node, const xmlChar *name,
/*
* Check if there is a default/fixed attribute declaration in
* the internal or external subset.
- */
+ */
if ((node->doc != NULL) && (node->doc->intSubset != NULL)) {
xmlDocPtr doc = node->doc;
xmlAttributePtr attrDecl = NULL;
xmlChar *elemQName, *tmpstr = NULL;
/*
- * We need the QName of the element for the DTD-lookup.
+ * We need the QName of the element for the DTD-lookup.
*/
if ((node->ns != NULL) && (node->ns->prefix != NULL)) {
tmpstr = xmlStrdup(node->ns->prefix);
@@ -6140,7 +6567,7 @@ xmlGetPropNodeInternal(xmlNodePtr node, const xmlChar *name,
cur++;
}
xmlFree(nsList);
- }
+ }
if (tmpstr != NULL)
xmlFree(tmpstr);
/*
@@ -6154,7 +6581,7 @@ xmlGetPropNodeInternal(xmlNodePtr node, const xmlChar *name,
}
static xmlChar*
-xmlGetPropNodeValueInternal(xmlAttrPtr prop)
+xmlGetPropNodeValueInternal(const xmlAttr *prop)
{
if (prop == NULL)
return(NULL);
@@ -6184,7 +6611,7 @@ xmlGetPropNodeValueInternal(xmlAttrPtr prop)
} else if (prop->type == XML_ATTRIBUTE_DECL) {
return(xmlStrdup(((xmlAttributePtr)prop)->defaultValue));
}
- return(NULL);
+ return(NULL);
}
/**
@@ -6196,11 +6623,11 @@ xmlGetPropNodeValueInternal(xmlAttrPtr prop)
* This function also looks in DTD attribute declaration for #FIXED or
* default declaration values unless DTD use has been turned off.
*
- * Returns the attribute or the attribute declaration or NULL if
+ * Returns the attribute or the attribute declaration or NULL if
* neither was found.
*/
xmlAttrPtr
-xmlHasProp(xmlNodePtr node, const xmlChar *name) {
+xmlHasProp(const xmlNode *node, const xmlChar *name) {
xmlAttrPtr prop;
xmlDocPtr doc;
@@ -6255,7 +6682,7 @@ xmlHasProp(xmlNodePtr node, const xmlChar *name) {
* if neither was found.
*/
xmlAttrPtr
-xmlHasNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
+xmlHasNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace) {
return(xmlGetPropNodeInternal(node, name, nameSpace, xmlCheckDTD));
}
@@ -6277,13 +6704,13 @@ xmlHasNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
* It's up to the caller to free the memory with xmlFree().
*/
xmlChar *
-xmlGetProp(xmlNodePtr node, const xmlChar *name) {
- xmlAttrPtr prop;
+xmlGetProp(const xmlNode *node, const xmlChar *name) {
+ xmlAttrPtr prop;
prop = xmlHasProp(node, name);
if (prop == NULL)
return(NULL);
- return(xmlGetPropNodeValueInternal(prop));
+ return(xmlGetPropNodeValueInternal(prop));
}
/**
@@ -6302,9 +6729,9 @@ xmlGetProp(xmlNodePtr node, const xmlChar *name) {
* It's up to the caller to free the memory with xmlFree().
*/
xmlChar *
-xmlGetNoNsProp(xmlNodePtr node, const xmlChar *name) {
+xmlGetNoNsProp(const xmlNode *node, const xmlChar *name) {
xmlAttrPtr prop;
-
+
prop = xmlGetPropNodeInternal(node, name, NULL, xmlCheckDTD);
if (prop == NULL)
return(NULL);
@@ -6327,7 +6754,7 @@ xmlGetNoNsProp(xmlNodePtr node, const xmlChar *name) {
* It's up to the caller to free the memory with xmlFree().
*/
xmlChar *
-xmlGetNsProp(xmlNodePtr node, const xmlChar *name, const xmlChar *nameSpace) {
+xmlGetNsProp(const xmlNode *node, const xmlChar *name, const xmlChar *nameSpace) {
xmlAttrPtr prop;
prop = xmlGetPropNodeInternal(node, name, nameSpace, xmlCheckDTD);
@@ -6370,7 +6797,7 @@ xmlUnsetProp(xmlNodePtr node, const xmlChar *name) {
int
xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
xmlAttrPtr prop;
-
+
prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0);
if (prop == NULL)
return(-1);
@@ -6393,7 +6820,7 @@ xmlUnsetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name) {
* error it there's no such ns-binding for the prefix in
* scope.
* Returns the attribute pointer.
- *
+ *
*/
xmlAttrPtr
xmlSetProp(xmlNodePtr node, const xmlChar *name, const xmlChar *value) {
@@ -6436,7 +6863,7 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
const xmlChar *value)
{
xmlAttrPtr prop;
-
+
if (ns && (ns->href == NULL))
return(NULL);
prop = xmlGetPropNodeInternal(node, name, (ns != NULL) ? ns->href : NULL, 0);
@@ -6448,17 +6875,21 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
xmlRemoveID(node->doc, prop);
prop->atype = XML_ATTRIBUTE_ID;
}
- if (prop->children != NULL)
+ if (prop->children != NULL)
xmlFreeNodeList(prop->children);
prop->children = NULL;
prop->last = NULL;
prop->ns = ns;
if (value != NULL) {
- xmlChar *buffer;
xmlNodePtr tmp;
-
- buffer = xmlEncodeEntitiesReentrant(node->doc, value);
- prop->children = xmlStringGetNodeList(node->doc, buffer);
+
+ if(!xmlCheckUTF8(value)) {
+ xmlTreeErr(XML_TREE_NOT_UTF8, (xmlNodePtr) node->doc,
+ NULL);
+ if (node->doc != NULL)
+ node->doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
+ }
+ prop->children = xmlNewDocText(node->doc, value);
prop->last = NULL;
tmp = prop->children;
while (tmp != NULL) {
@@ -6467,7 +6898,6 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
prop->last = tmp;
tmp = tmp->next;
}
- xmlFree(buffer);
}
if (prop->atype == XML_ATTRIBUTE_ID)
xmlAddID(NULL, node->doc, value, prop);
@@ -6484,12 +6914,12 @@ xmlSetNsProp(xmlNodePtr node, xmlNsPtr ns, const xmlChar *name,
/**
* xmlNodeIsText:
* @node: the node
- *
+ *
* Is this node a Text node ?
* Returns 1 yes, 0 no
*/
int
-xmlNodeIsText(xmlNodePtr node) {
+xmlNodeIsText(const xmlNode *node) {
if (node == NULL) return(0);
if (node->type == XML_TEXT_NODE) return(1);
@@ -6499,14 +6929,14 @@ xmlNodeIsText(xmlNodePtr node) {
/**
* xmlIsBlankNode:
* @node: the node
- *
+ *
* Checks whether this node is an empty or whitespace only
* (and possibly ignorable) text-node.
*
* Returns 1 yes, 0 no
*/
int
-xmlIsBlankNode(xmlNodePtr node) {
+xmlIsBlankNode(const xmlNode *node) {
const xmlChar *cur;
if (node == NULL) return(0);
@@ -6528,7 +6958,7 @@ xmlIsBlankNode(xmlNodePtr node) {
* @node: the node
* @content: the content
* @len: @content length
- *
+ *
* Concat the given string at the end of the existing node content
*
* Returns -1 in case of error, 0 otherwise
@@ -6593,6 +7023,7 @@ xmlBufferCreate(void) {
return(NULL);
}
ret->content[0] = 0;
+ ret->contentIO = NULL;
return(ret);
}
@@ -6625,10 +7056,39 @@ xmlBufferCreateSize(size_t size) {
ret->content[0] = 0;
} else
ret->content = NULL;
+ ret->contentIO = NULL;
return(ret);
}
/**
+ * xmlBufferDetach:
+ * @buf: the buffer
+ *
+ * Remove the string contained in a buffer and gie it back to the
+ * caller. The buffer is reset to an empty content.
+ * This doesn't work with immutable buffers as they can't be reset.
+ *
+ * Returns the previous string contained by the buffer.
+ */
+xmlChar *
+xmlBufferDetach(xmlBufferPtr buf) {
+ xmlChar *ret;
+
+ if (buf == NULL)
+ return(NULL);
+ if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)
+ return(NULL);
+
+ ret = buf->content;
+ buf->content = NULL;
+ buf->size = 0;
+ buf->use = 0;
+
+ return ret;
+}
+
+
+/**
* xmlBufferCreateStatic:
* @mem: the memory area
* @size: the size in byte
@@ -6666,7 +7126,7 @@ xmlBufferCreateStatic(void *mem, size_t size) {
* Sets the allocation scheme for this buffer
*/
void
-xmlBufferSetAllocationScheme(xmlBufferPtr buf,
+xmlBufferSetAllocationScheme(xmlBufferPtr buf,
xmlBufferAllocationScheme scheme) {
if (buf == NULL) {
#ifdef DEBUG_BUFFER
@@ -6675,9 +7135,13 @@ xmlBufferSetAllocationScheme(xmlBufferPtr buf,
#endif
return;
}
- if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return;
-
- buf->alloc = scheme;
+ if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
+ (buf->alloc == XML_BUFFER_ALLOC_IO)) return;
+ if ((scheme == XML_BUFFER_ALLOC_DOUBLEIT) ||
+ (scheme == XML_BUFFER_ALLOC_EXACT) ||
+ (scheme == XML_BUFFER_ALLOC_HYBRID) ||
+ (scheme == XML_BUFFER_ALLOC_IMMUTABLE))
+ buf->alloc = scheme;
}
/**
@@ -6697,7 +7161,10 @@ xmlBufferFree(xmlBufferPtr buf) {
return;
}
- if ((buf->content != NULL) &&
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
+ (buf->contentIO != NULL)) {
+ xmlFree(buf->contentIO);
+ } else if ((buf->content != NULL) &&
(buf->alloc != XML_BUFFER_ALLOC_IMMUTABLE)) {
xmlFree(buf->content);
}
@@ -6717,8 +7184,15 @@ xmlBufferEmpty(xmlBufferPtr buf) {
buf->use = 0;
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) {
buf->content = BAD_CAST "";
+ } else if ((buf->alloc == XML_BUFFER_ALLOC_IO) &&
+ (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+
+ buf->size += start_buf;
+ buf->content = buf->contentIO;
+ buf->content[0] = 0;
} else {
- memset(buf->content, 0, buf->size);
+ buf->content[0] = 0;
}
}
@@ -6738,10 +7212,30 @@ xmlBufferShrink(xmlBufferPtr buf, unsigned int len) {
if (len > buf->use) return(-1);
buf->use -= len;
- if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) {
+ if ((buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) ||
+ ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL))) {
+ /*
+ * we just move the content pointer, but also make sure
+ * the perceived buffer size has shrinked accordingly
+ */
buf->content += len;
+ buf->size -= len;
+
+ /*
+ * sometimes though it maybe be better to really shrink
+ * on IO buffers
+ */
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+ if (start_buf >= buf->size) {
+ memmove(buf->contentIO, &buf->content[0], buf->use);
+ buf->content = buf->contentIO;
+ buf->content[buf->use] = 0;
+ buf->size += start_buf;
+ }
+ }
} else {
- memmove(buf->content, &buf->content[len], buf->use * sizeof(xmlChar));
+ memmove(buf->content, &buf->content[len], buf->use);
buf->content[buf->use] = 0;
}
return(len);
@@ -6766,11 +7260,13 @@ xmlBufferGrow(xmlBufferPtr buf, unsigned int len) {
if (buf->alloc == XML_BUFFER_ALLOC_IMMUTABLE) return(0);
if (len + buf->use < buf->size) return(0);
-/*
- * Windows has a BIG problem on realloc timing, so we try to double
- * the buffer size (if that's enough) (bug 146697)
- */
-#ifdef WIN32
+ /*
+ * Windows has a BIG problem on realloc timing, so we try to double
+ * the buffer size (if that's enough) (bug 146697)
+ * Apparently BSD too, and it's probably best for linux too
+ * On an embedded system this may be something to change
+ */
+#if 1
if (buf->size > len)
size = buf->size * 2;
else
@@ -6779,12 +7275,24 @@ xmlBufferGrow(xmlBufferPtr buf, unsigned int len) {
size = buf->use + len + 100;
#endif
- newbuf = (xmlChar *) xmlRealloc(buf->content, size);
- if (newbuf == NULL) {
- xmlTreeErrMemory("growing buffer");
- return(-1);
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+
+ newbuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + size);
+ if (newbuf == NULL) {
+ xmlTreeErrMemory("growing buffer");
+ return(-1);
+ }
+ buf->contentIO = newbuf;
+ buf->content = newbuf + start_buf;
+ } else {
+ newbuf = (xmlChar *) xmlRealloc(buf->content, size);
+ if (newbuf == NULL) {
+ xmlTreeErrMemory("growing buffer");
+ return(-1);
+ }
+ buf->content = newbuf;
}
- buf->content = newbuf;
buf->size = size;
return(buf->size - buf->use);
}
@@ -6831,7 +7339,7 @@ xmlBufferDump(FILE *file, xmlBufferPtr buf) {
*/
const xmlChar *
-xmlBufferContent(const xmlBufferPtr buf)
+xmlBufferContent(const xmlBuffer *buf)
{
if(!buf)
return NULL;
@@ -6841,7 +7349,7 @@ xmlBufferContent(const xmlBufferPtr buf)
/**
* xmlBufferLength:
- * @buf: the buffer
+ * @buf: the buffer
*
* Function to get the length of a buffer
*
@@ -6849,7 +7357,7 @@ xmlBufferContent(const xmlBufferPtr buf)
*/
int
-xmlBufferLength(const xmlBufferPtr buf)
+xmlBufferLength(const xmlBuffer *buf)
{
if(!buf)
return 0;
@@ -6871,6 +7379,7 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
{
unsigned int newSize;
xmlChar* rebuf = NULL;
+ size_t start_buf;
if (buf == NULL)
return(0);
@@ -6883,42 +7392,83 @@ xmlBufferResize(xmlBufferPtr buf, unsigned int size)
/* figure out new size */
switch (buf->alloc){
- case XML_BUFFER_ALLOC_DOUBLEIT:
- /*take care of empty case*/
- newSize = (buf->size ? buf->size*2 : size + 10);
- while (size > newSize) newSize *= 2;
- break;
- case XML_BUFFER_ALLOC_EXACT:
- newSize = size+10;
- break;
- default:
- newSize = size+10;
- break;
- }
-
- if (buf->content == NULL)
- rebuf = (xmlChar *) xmlMallocAtomic(newSize * sizeof(xmlChar));
- else if (buf->size - buf->use < 100) {
- rebuf = (xmlChar *) xmlRealloc(buf->content,
- newSize * sizeof(xmlChar));
- } else {
- /*
- * if we are reallocating a buffer far from being full, it's
- * better to make a new allocation and copy only the used range
- * and free the old one.
- */
- rebuf = (xmlChar *) xmlMallocAtomic(newSize * sizeof(xmlChar));
- if (rebuf != NULL) {
- memcpy(rebuf, buf->content, buf->use);
- xmlFree(buf->content);
- rebuf[buf->use] = 0;
- }
+ case XML_BUFFER_ALLOC_IO:
+ case XML_BUFFER_ALLOC_DOUBLEIT:
+ /*take care of empty case*/
+ newSize = (buf->size ? buf->size*2 : size + 10);
+ while (size > newSize) {
+ if (newSize > UINT_MAX / 2) {
+ xmlTreeErrMemory("growing buffer");
+ return 0;
+ }
+ newSize *= 2;
+ }
+ break;
+ case XML_BUFFER_ALLOC_EXACT:
+ newSize = size+10;
+ break;
+ case XML_BUFFER_ALLOC_HYBRID:
+ if (buf->use < BASE_BUFFER_SIZE)
+ newSize = size;
+ else {
+ newSize = buf->size * 2;
+ while (size > newSize) {
+ if (newSize > UINT_MAX / 2) {
+ xmlTreeErrMemory("growing buffer");
+ return 0;
+ }
+ newSize *= 2;
+ }
+ }
+ break;
+
+ default:
+ newSize = size+10;
+ break;
}
- if (rebuf == NULL) {
- xmlTreeErrMemory("growing buffer");
- return 0;
+
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ start_buf = buf->content - buf->contentIO;
+
+ if (start_buf > newSize) {
+ /* move data back to start */
+ memmove(buf->contentIO, buf->content, buf->use);
+ buf->content = buf->contentIO;
+ buf->content[buf->use] = 0;
+ buf->size += start_buf;
+ } else {
+ rebuf = (xmlChar *) xmlRealloc(buf->contentIO, start_buf + newSize);
+ if (rebuf == NULL) {
+ xmlTreeErrMemory("growing buffer");
+ return 0;
+ }
+ buf->contentIO = rebuf;
+ buf->content = rebuf + start_buf;
+ }
+ } else {
+ if (buf->content == NULL) {
+ rebuf = (xmlChar *) xmlMallocAtomic(newSize);
+ } else if (buf->size - buf->use < 100) {
+ rebuf = (xmlChar *) xmlRealloc(buf->content, newSize);
+ } else {
+ /*
+ * if we are reallocating a buffer far from being full, it's
+ * better to make a new allocation and copy only the used range
+ * and free the old one.
+ */
+ rebuf = (xmlChar *) xmlMallocAtomic(newSize);
+ if (rebuf != NULL) {
+ memcpy(rebuf, buf->content, buf->use);
+ xmlFree(buf->content);
+ rebuf[buf->use] = 0;
+ }
+ }
+ if (rebuf == NULL) {
+ xmlTreeErrMemory("growing buffer");
+ return 0;
+ }
+ buf->content = rebuf;
}
- buf->content = rebuf;
buf->size = newSize;
return 1;
@@ -6956,7 +7506,8 @@ xmlBufferAdd(xmlBufferPtr buf, const xmlChar *str, int len) {
if (len < 0)
len = xmlStrlen(str);
- if (len <= 0) return -1;
+ if (len < 0) return -1;
+ if (len == 0) return 0;
needSize = buf->use + len + 2;
if (needSize > buf->size){
@@ -7012,6 +7563,20 @@ xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) {
if (len <= 0) return -1;
+ if ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL)) {
+ size_t start_buf = buf->content - buf->contentIO;
+
+ if (start_buf > (unsigned int) len) {
+ /*
+ * We can add it in the space previously shrinked
+ */
+ buf->content -= len;
+ memmove(&buf->content[0], str, len);
+ buf->use += len;
+ buf->size += len;
+ return(0);
+ }
+ }
needSize = buf->use + len + 2;
if (needSize > buf->size){
if (!xmlBufferResize(buf, needSize)){
@@ -7020,8 +7585,8 @@ xmlBufferAddHead(xmlBufferPtr buf, const xmlChar *str, int len) {
}
}
- memmove(&buf->content[len], &buf->content[0], buf->use * sizeof(xmlChar));
- memmove(&buf->content[0], str, len * sizeof(xmlChar));
+ memmove(&buf->content[len], &buf->content[0], buf->use);
+ memmove(&buf->content[0], str, len);
buf->use += len;
buf->content[buf->use] = 0;
return 0;
@@ -7176,7 +7741,7 @@ xmlBufferWriteQuotedString(xmlBufferPtr buf, const xmlChar *string) {
* Returns 0 (uncompressed) to 9 (max compression)
*/
int
-xmlGetDocCompressMode (xmlDocPtr doc) {
+xmlGetDocCompressMode (const xmlDoc *doc) {
if (doc == NULL) return(-1);
return(doc->compression);
}
@@ -7268,7 +7833,7 @@ struct xmlNsMap {
/*
* xmlDOMWrapNsMapFree:
* @map: the ns-map
-*
+*
* Frees the ns-map
*/
static void
@@ -7299,7 +7864,7 @@ xmlDOMWrapNsMapFree(xmlNsMapPtr nsmap)
* @oldNs: the old ns-struct
* @newNs: the new ns-struct
* @depth: depth and ns-kind information
-*
+*
* Adds an ns-mapping item.
*/
static xmlNsMapItemPtr
@@ -7327,7 +7892,7 @@ xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position,
memset(map, 0, sizeof(struct xmlNsMap));
*nsmap = map;
}
-
+
if (map->pool != NULL) {
/*
* Reuse an item from the pool.
@@ -7346,11 +7911,11 @@ xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position,
}
memset(ret, 0, sizeof(struct xmlNsMapItem));
}
-
+
if (map->first == NULL) {
/*
* First ever.
- */
+ */
map->first = ret;
map->last = ret;
} else if (position == -1) {
@@ -7359,16 +7924,15 @@ xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position,
*/
ret->prev = map->last;
map->last->next = ret;
- map->last = ret;
+ map->last = ret;
} else if (position == 0) {
/*
* Set on first position.
*/
map->first->prev = ret;
- ret->next = map->first;
- map->first = ret;
- } else
- return(NULL);
+ ret->next = map->first;
+ map->first = ret;
+ }
ret->oldNs = oldNs;
ret->newNs = newNs;
@@ -7382,10 +7946,10 @@ xmlDOMWrapNsMapAddItem(xmlNsMapPtr *nsmap, int position,
* @doc: the doc
* @nsName: the namespace name
* @prefix: the prefix
-*
+*
* Creates or reuses an xmlNs struct on doc->oldNs with
* the given prefix and namespace name.
-*
+*
* Returns the aquired ns struct or NULL in case of an API
* or internal error.
*/
@@ -7416,8 +7980,11 @@ xmlDOMWrapStoreNs(xmlDocPtr doc,
}
}
/* Create. */
- ns->next = xmlNewNs(NULL, nsName, prefix);
- return (ns->next);
+ if (ns != NULL) {
+ ns->next = xmlNewNs(NULL, nsName, prefix);
+ return (ns->next);
+ }
+ return(NULL);
}
/*
@@ -7425,7 +7992,7 @@ xmlDOMWrapStoreNs(xmlDocPtr doc,
*
* Allocates and initializes a new DOM-wrapper context.
*
-* Returns the xmlDOMWrapCtxtPtr or NULL in case of an internal errror.
+* Returns the xmlDOMWrapCtxtPtr or NULL in case of an internal error.
*/
xmlDOMWrapCtxtPtr
xmlDOMWrapNewCtxt(void)
@@ -7464,9 +8031,9 @@ xmlDOMWrapFreeCtxt(xmlDOMWrapCtxtPtr ctxt)
* xmlTreeLookupNsListByPrefix:
* @nsList: a list of ns-structs
* @prefix: the searched prefix
-*
+*
* Searches for a ns-decl with the given prefix in @nsList.
-*
+*
* Returns the ns-decl if found, NULL if not found and on
* API errors.
*/
@@ -7494,9 +8061,9 @@ xmlTreeNSListLookupByPrefix(xmlNsPtr nsList, const xmlChar *prefix)
* xmlDOMWrapNSNormGatherInScopeNs:
* @map: the namespace map
* @node: the node to start with
-*
+*
* Puts in-scope namespaces into the ns-map.
-*
+*
* Returns 0 on success, -1 on API or internal errors.
*/
static int
@@ -7510,6 +8077,8 @@ xmlDOMWrapNSNormGatherInScopeNs(xmlNsMapPtr *map,
if ((map == NULL) || (*map != NULL))
return (-1);
+ if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
+ return (-1);
/*
* Get in-scope ns-decls of @parent.
*/
@@ -7588,7 +8157,7 @@ xmlDOMWrapNSNormGatherInScopeNs(xmlNsMapPtr *map,
*
* For internal use. Adds a ns-decl mapping.
*
-* Returns 0 on success, -1 on internal errors.
+* Returns 0 on success, -1 on internal errors.
*/
static int
xmlDOMWrapNSNormAddNsMapItem2(xmlNsPtr **list, int *size, int *number,
@@ -7632,7 +8201,7 @@ xmlDOMWrapNSNormAddNsMapItem2(xmlNsPtr **list, int *size, int *number,
* NOTE: This function was not intensively tested.
*
* Returns 0 on success, 1 if the node is not supported,
-* -1 on API and internal errors.
+* -1 on API and internal errors.
*/
int
xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
@@ -7649,7 +8218,7 @@ xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
if (node->parent == NULL)
return (0);
- switch (node->type) {
+ switch (node->type) {
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
@@ -7657,7 +8226,7 @@ xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
case XML_COMMENT_NODE:
xmlUnlinkNode(node);
return (0);
- case XML_ELEMENT_NODE:
+ case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
break;
default:
@@ -7681,7 +8250,7 @@ xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
}
/* No break on purpose. */
case XML_ATTRIBUTE_NODE:
- if (node->ns != NULL) {
+ if (node->ns != NULL) {
/*
* Find a mapping.
*/
@@ -7725,14 +8294,14 @@ xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr ctxt, xmlDocPtr doc,
break;
default:
goto next_sibling;
- }
-next_node:
+ }
+next_node:
if ((node->type == XML_ELEMENT_NODE) &&
(node->children != NULL)) {
node = node->children;
continue;
}
-next_sibling:
+next_sibling:
if (node == NULL)
break;
if (node->next != NULL)
@@ -7777,6 +8346,8 @@ xmlSearchNsByNamespaceStrict(xmlDocPtr doc, xmlNodePtr node,
if ((doc == NULL) || (nsName == NULL) || (retNs == NULL))
return (-1);
+ if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
+ return(-1);
*retNs = NULL;
if (xmlStrEqual(nsName, XML_XML_NAMESPACE)) {
@@ -7825,7 +8396,7 @@ xmlSearchNsByNamespaceStrict(xmlDocPtr doc, xmlNodePtr node,
*/
if (out) {
int ret;
-
+
ret = xmlNsInScope(doc, node, prev, ns->prefix);
if (ret < 0)
return (-1);
@@ -7875,8 +8446,8 @@ xmlSearchNsByPrefixStrict(xmlDocPtr doc, xmlNodePtr node,
xmlNodePtr cur;
xmlNsPtr ns;
- if ((doc == NULL) || (node == NULL))
- return (-1);
+ if ((doc == NULL) || (node == NULL) || (node->type == XML_NAMESPACE_DECL))
+ return(-1);
if (retNs)
*retNs = NULL;
@@ -7893,7 +8464,7 @@ xmlSearchNsByPrefixStrict(xmlDocPtr doc, xmlNodePtr node,
if (cur->type == XML_ELEMENT_NODE) {
if (cur->nsDef != NULL) {
ns = cur->nsDef;
- do {
+ do {
if ((prefix == ns->prefix) ||
xmlStrEqual(prefix, ns->prefix))
{
@@ -7907,7 +8478,7 @@ xmlSearchNsByPrefixStrict(xmlDocPtr doc, xmlNodePtr node,
return (1);
}
ns = ns->next;
- } while (ns != NULL);
+ } while (ns != NULL);
}
} else if ((cur->type == XML_ENTITY_NODE) ||
(cur->type == XML_ENTITY_DECL))
@@ -7944,6 +8515,9 @@ xmlDOMWrapNSNormDeclareNsForced(xmlDocPtr doc,
char buf[50];
const xmlChar *pref;
int counter = 0;
+
+ if ((doc == NULL) || (elem == NULL) || (elem->type != XML_ELEMENT_NODE))
+ return(NULL);
/*
* Create a ns-decl on @anchor.
*/
@@ -8014,12 +8588,12 @@ xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
xmlNsPtr ns,
xmlNsPtr *retNs,
xmlNsMapPtr *nsMap,
-
+
int depth,
int ancestorsOnly,
int prefixed)
{
- xmlNsMapItemPtr mi;
+ xmlNsMapItemPtr mi;
if ((doc == NULL) || (ns == NULL) || (retNs == NULL) ||
(nsMap == NULL))
@@ -8044,13 +8618,13 @@ xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
*/
if ((XML_NSMAP_NOTEMPTY(*nsMap)) &&
(! (ancestorsOnly && (elem == NULL))))
- {
+ {
/*
* Try to find an equal ns-name in in-scope ns-decls.
*/
XML_NSMAP_FOREACH(*nsMap, mi) {
- if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
- /*
+ if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
+ /*
* ancestorsOnly: This should be turned on to gain speed,
* if one knows that the branch itself was already
* ns-wellformed and no stale references existed.
@@ -8058,10 +8632,10 @@ xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
*/
((! ancestorsOnly) || (mi->depth == XML_TREE_NSMAP_PARENT)) &&
/* Skip shadowed prefixes. */
- (mi->shadowDepth == -1) &&
+ (mi->shadowDepth == -1) &&
/* Skip xmlns="" or xmlns:foo="". */
((mi->newNs->href != NULL) &&
- (mi->newNs->href[0] != 0)) &&
+ (mi->newNs->href[0] != 0)) &&
/* Ensure a prefix if wanted. */
((! prefixed) || (mi->newNs->prefix != NULL)) &&
/* Equal ns name */
@@ -8088,7 +8662,7 @@ xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
return (-1);
/*
* Insert mapping.
- */
+ */
if (xmlDOMWrapNsMapAddItem(nsMap, -1, ns,
tmpns, XML_TREE_NSMAP_DOC) == NULL) {
xmlFreeNs(tmpns);
@@ -8130,7 +8704,7 @@ xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
}
typedef enum {
- XML_DOM_RECONNS_REMOVEREDUND = 1<<0
+ XML_DOM_RECONNS_REMOVEREDUND = 1<<0
} xmlDOMReconcileNSOptions;
/*
@@ -8148,7 +8722,7 @@ typedef enum {
* NOTE: This function was not intensively tested.
*
* Returns 0 if succeeded, -1 otherwise and on API/internal errors.
-*/
+*/
int
xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
@@ -8163,7 +8737,7 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
xmlNsMapItemPtr /* topmi = NULL, */ mi;
/* @ancestorsOnly should be set by an option flag. */
int ancestorsOnly = 0;
- int optRemoveRedundantNS =
+ int optRemoveRedundantNS =
((xmlDOMReconcileNSOptions) options & XML_DOM_RECONNS_REMOVEREDUND) ? 1 : 0;
xmlNsPtr *listRedund = NULL;
int sizeRedund = 0, nbRedund = 0, ret, i, j;
@@ -8199,7 +8773,7 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
}
parnsdone = 1;
}
-
+
/*
* Lookup the ns ancestor-axis for equal ns-decls in scope.
*/
@@ -8211,7 +8785,7 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
xmlStrEqual(ns->prefix, mi->newNs->prefix)) &&
((ns->href == mi->newNs->href) ||
xmlStrEqual(ns->href, mi->newNs->href)))
- {
+ {
/*
* A redundant ns-decl was found.
* Add it to the list of redundant ns-decls.
@@ -8221,11 +8795,11 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
goto internal_error;
/*
* Remove the ns-decl from the element-node.
- */
+ */
if (prevns)
prevns->next = ns->next;
else
- cur->nsDef = ns->next;
+ cur->nsDef = ns->next;
goto next_ns_decl;
}
}
@@ -8236,7 +8810,7 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
* ns-decl is declared on the same element.
*/
if ((cur->ns != NULL) && adoptns && (cur->ns == ns))
- adoptns = 0;
+ adoptns = 0;
/*
* Does it shadow any ns-decl?
*/
@@ -8246,7 +8820,7 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
(mi->shadowDepth == -1) &&
((ns->prefix == mi->newNs->prefix) ||
xmlStrEqual(ns->prefix, mi->newNs->prefix))) {
-
+
mi->shadowDepth = depth;
}
}
@@ -8256,11 +8830,11 @@ xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt ATTRIBUTE_UNUSED,
*/
if (xmlDOMWrapNsMapAddItem(&nsMap, -1, ns, ns,
depth) == NULL)
- goto internal_error;
+ goto internal_error;
prevns = ns;
next_ns_decl:
- ns = ns->next;
+ ns = ns->next;
}
}
if (! adoptns)
@@ -8270,7 +8844,7 @@ next_ns_decl:
/* No ns, no fun. */
if (cur->ns == NULL)
goto ns_end;
-
+
if (! parnsdone) {
if ((elem->parent) &&
((xmlNodePtr) elem->parent->doc != elem->parent)) {
@@ -8289,7 +8863,7 @@ next_ns_decl:
cur->ns = listRedund[++j];
break;
}
- }
+ }
}
/*
* Adopt ns-references.
@@ -8327,7 +8901,7 @@ ns_end:
cur = (xmlNodePtr) cur->properties;
continue;
}
- break;
+ break;
default:
goto next_sibling;
}
@@ -8340,18 +8914,18 @@ into_content:
cur = cur->children;
continue;
}
-next_sibling:
+next_sibling:
if (cur == elem)
break;
if (cur->type == XML_ELEMENT_NODE) {
- if (XML_NSMAP_NOTEMPTY(nsMap)) {
+ if (XML_NSMAP_NOTEMPTY(nsMap)) {
/*
* Pop mappings.
*/
while ((nsMap->last != NULL) &&
(nsMap->last->depth >= depth))
{
- XML_NSMAP_POP(nsMap, mi)
+ XML_NSMAP_POP(nsMap, mi)
}
/*
* Unshadow.
@@ -8360,7 +8934,7 @@ next_sibling:
if (mi->shadowDepth >= depth)
mi->shadowDepth = -1;
}
- }
+ }
depth--;
}
if (cur->next != NULL)
@@ -8374,13 +8948,13 @@ next_sibling:
goto next_sibling;
}
} while (cur != NULL);
-
+
ret = 0;
goto exit;
internal_error:
ret = -1;
exit:
- if (listRedund) {
+ if (listRedund) {
for (i = 0, j = 0; i < nbRedund; i++, j += 2) {
xmlFreeNs(listRedund[j]);
}
@@ -8431,7 +9005,7 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
int parnsdone;
/* @ancestorsOnly should be set per option. */
int ancestorsOnly = 0;
-
+
/*
* Optimize string adoption for equal or none dicts.
*/
@@ -8460,6 +9034,9 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
parnsdone = 0;
cur = node;
+ if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL))
+ goto internal_error;
+
while (cur != NULL) {
/*
* Paranoid source-doc sanity check.
@@ -8485,17 +9062,17 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
}
cur->doc = destDoc;
switch (cur->type) {
- case XML_XINCLUDE_START:
+ case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
/*
* TODO
*/
return (-1);
- case XML_ELEMENT_NODE:
+ case XML_ELEMENT_NODE:
curElem = cur;
depth++;
/*
- * Namespace declarations.
+ * Namespace declarations.
* - ns->href and ns->prefix are never in the dict, so
* we need not move the values over to the destination dict.
* - Note that for custom handling of ns-references,
@@ -8519,10 +9096,10 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
* NOTE: ns->prefix and ns->href are never in the dict.
* XML_TREE_ADOPT_STR(ns->prefix)
* XML_TREE_ADOPT_STR(ns->href)
- */
+ */
/*
* Does it shadow any ns-decl?
- */
+ */
if (XML_NSMAP_NOTEMPTY(nsMap)) {
XML_NSMAP_FOREACH(nsMap, mi) {
if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
@@ -8530,7 +9107,7 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
((ns->prefix == mi->newNs->prefix) ||
xmlStrEqual(ns->prefix,
mi->newNs->prefix))) {
-
+
mi->shadowDepth = depth;
}
}
@@ -8593,7 +9170,7 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr ctxt,
* Aquire a normalized ns-decl and add it to the map.
*/
if (xmlDOMWrapNSNormAquireNormalizedNs(destDoc,
- /* ns-decls on curElem or on destDoc->oldNs */
+ /* ns-decls on curElem or on destDoc->oldNs */
destParent ? curElem : NULL,
cur->ns, &ns,
&nsMap, depth,
@@ -8629,7 +9206,7 @@ ns_end:
*/
if ((sourceDoc != NULL) &&
(((xmlAttrPtr) cur)->atype == XML_ATTRIBUTE_ID))
- {
+ {
xmlRemoveID(sourceDoc, (xmlAttrPtr) cur);
}
((xmlAttrPtr) cur)->atype = 0;
@@ -8637,13 +9214,13 @@ ns_end:
}
break;
case XML_TEXT_NODE:
- case XML_CDATA_SECTION_NODE:
+ case XML_CDATA_SECTION_NODE:
/*
* This puts the content in the dest dict, only if
* it was previously in the source dict.
*/
- XML_TREE_ADOPT_STR_2(cur->content)
- goto leave_node;
+ XML_TREE_ADOPT_STR_2(cur->content)
+ goto leave_node;
case XML_ENTITY_REF_NODE:
/*
* Remove reference to the entitity-node.
@@ -8668,7 +9245,7 @@ ns_end:
XML_TREE_ADOPT_STR(cur->name)
XML_TREE_ADOPT_STR_2(cur->content)
break;
- case XML_COMMENT_NODE:
+ case XML_COMMENT_NODE:
break;
default:
goto internal_error;
@@ -8691,15 +9268,15 @@ leave_node:
/*
* TODO: Do we expect nsDefs on XML_XINCLUDE_START?
*/
- if (XML_NSMAP_NOTEMPTY(nsMap)) {
+ if (XML_NSMAP_NOTEMPTY(nsMap)) {
/*
* Pop mappings.
*/
while ((nsMap->last != NULL) &&
(nsMap->last->depth >= depth))
{
- XML_NSMAP_POP(nsMap, mi)
- }
+ XML_NSMAP_POP(nsMap, mi)
+ }
/*
* Unshadow.
*/
@@ -8721,10 +9298,10 @@ leave_node:
goto leave_node;
}
}
-
+
goto exit;
-internal_error:
+internal_error:
ret = -1;
exit:
@@ -8742,7 +9319,7 @@ exit:
nsMap->pool = nsMap->first;
nsMap->first = NULL;
}
- } else
+ } else
xmlDOMWrapNsMapFree(nsMap);
}
return(ret);
@@ -8764,7 +9341,7 @@ exit:
* 2) If *no* @destParent is given, then @destDoc->oldNs entries are used.
* This is the case when you don't know already where the cloned branch
* will be added to.
-*
+*
* If @destParent is given, it ensures that the tree is namespace
* wellformed by creating additional ns-decls where needed.
* Note that, since prefixes of already existent ns-decls can be
@@ -8798,7 +9375,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/* gather @parent's ns-decls. */
int parnsdone = 0;
/*
- * @ancestorsOnly:
+ * @ancestorsOnly:
* TODO: @ancestorsOnly should be set per option.
*
*/
@@ -8825,7 +9402,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
return (-1);
}
if (sourceDoc == NULL)
- sourceDoc = node->doc;
+ sourceDoc = node->doc;
if (sourceDoc == NULL)
return (-1);
@@ -8837,8 +9414,11 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
nsMap = (xmlNsMapPtr) ctxt->namespaceMap;
*resNode = NULL;
-
+
cur = node;
+ if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL))
+ return(-1);
+
while (cur != NULL) {
if (cur->doc != sourceDoc) {
/*
@@ -8846,7 +9426,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
* TODO: Do we need to reconciliate XIncluded nodes?
* TODO: This here returns -1 in this case.
*/
- goto internal_error;
+ goto internal_error;
}
/*
* Create a new node.
@@ -8861,9 +9441,9 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
break;
case XML_ELEMENT_NODE:
case XML_TEXT_NODE:
- case XML_CDATA_SECTION_NODE:
+ case XML_CDATA_SECTION_NODE:
case XML_COMMENT_NODE:
- case XML_PI_NODE:
+ case XML_PI_NODE:
case XML_DOCUMENT_FRAG_NODE:
case XML_ENTITY_REF_NODE:
case XML_ENTITY_NODE:
@@ -8875,20 +9455,20 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating a node");
goto internal_error;
}
- memset(clone, 0, sizeof(xmlNode));
+ memset(clone, 0, sizeof(xmlNode));
/*
* Set hierachical links.
*/
- if (resultClone != NULL) {
+ if (resultClone != NULL) {
clone->parent = parentClone;
if (prevClone) {
prevClone->next = clone;
clone->prev = prevClone;
- } else
+ } else
parentClone->children = clone;
} else
resultClone = clone;
-
+
break;
case XML_ATTRIBUTE_NODE:
/*
@@ -8899,7 +9479,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
xmlTreeErrMemory("xmlDOMWrapCloneNode(): allocating an attr-node");
goto internal_error;
}
- memset(clone, 0, sizeof(xmlAttr));
+ memset(clone, 0, sizeof(xmlAttr));
/*
* Set hierachical links.
* TODO: Change this to add to the end of attributes.
@@ -8909,7 +9489,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
if (prevClone) {
prevClone->next = clone;
clone->prev = prevClone;
- } else
+ } else
parentClone->properties = (xmlAttrPtr) clone;
} else
resultClone = clone;
@@ -8922,8 +9502,8 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
}
clone->type = cur->type;
- clone->doc = destDoc;
-
+ clone->doc = destDoc;
+
/*
* Clone the name of the node if any.
*/
@@ -8933,14 +9513,14 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/*
* NOTE: Although xmlStringTextNoenc is never assigned to a node
* in tree.c, it might be set in Libxslt via
- * "xsl:disable-output-escaping".
+ * "xsl:disable-output-escaping".
*/
clone->name = xmlStringTextNoenc;
else if (cur->name == xmlStringComment)
clone->name = xmlStringComment;
else if (cur->name != NULL) {
DICT_CONST_COPY(cur->name, clone->name);
- }
+ }
switch (cur->type) {
case XML_XINCLUDE_START:
@@ -8963,7 +9543,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
*/
if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap,
destParent) == -1)
- goto internal_error;
+ goto internal_error;
}
parnsdone = 1;
}
@@ -8983,7 +9563,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
}
memset(cloneNs, 0, sizeof(xmlNs));
cloneNs->type = XML_LOCAL_NAMESPACE;
-
+
if (ns->href != NULL)
cloneNs->href = xmlStrdup(ns->href);
if (ns->prefix != NULL)
@@ -9004,7 +9584,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
* Does it shadow any ns-decl?
*/
if (XML_NSMAP_NOTEMPTY(nsMap)) {
- XML_NSMAP_FOREACH(nsMap, mi) {
+ XML_NSMAP_FOREACH(nsMap, mi) {
if ((mi->depth >= XML_TREE_NSMAP_PARENT) &&
(mi->shadowDepth == -1) &&
((ns->prefix == mi->newNs->prefix) ||
@@ -9029,7 +9609,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
}
/* cur->ns will be processed further down. */
break;
- case XML_ATTRIBUTE_NODE:
+ case XML_ATTRIBUTE_NODE:
/* IDs will be processed further down. */
/* cur->ns will be processed further down. */
break;
@@ -9038,12 +9618,12 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/*
* Note that this will also cover the values of attributes.
*/
- DICT_COPY(cur->content, clone->content);
+ DICT_COPY(cur->content, clone->content);
goto leave_node;
case XML_ENTITY_NODE:
/* TODO: What to do here? */
goto leave_node;
- case XML_ENTITY_REF_NODE:
+ case XML_ENTITY_REF_NODE:
if (sourceDoc != destDoc) {
if ((destDoc->intSubset) || (destDoc->extSubset)) {
xmlEntityPtr ent;
@@ -9083,13 +9663,13 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/* handle_ns_reference: */
/*
** The following will take care of references to ns-decls ********
- ** and is intended only for element- and attribute-nodes.
+ ** and is intended only for element- and attribute-nodes.
**
*/
if (! parnsdone) {
if (destParent && (ctxt == NULL)) {
if (xmlDOMWrapNSNormGatherInScopeNs(&nsMap, destParent) == -1)
- goto internal_error;
+ goto internal_error;
}
parnsdone = 1;
}
@@ -9100,7 +9680,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
/*
* Search for a mapping.
*/
- XML_NSMAP_FOREACH(nsMap, mi) {
+ XML_NSMAP_FOREACH(nsMap, mi) {
if ((mi->shadowDepth == -1) &&
(cur->ns == mi->oldNs)) {
/*
@@ -9132,7 +9712,7 @@ xmlDOMWrapCloneNode(xmlDOMWrapCtxtPtr ctxt,
* Aquire a normalized ns-decl and add it to the map.
*/
if (xmlDOMWrapNSNormAquireNormalizedNs(destDoc,
- /* ns-decls on curElem or on destDoc->oldNs */
+ /* ns-decls on curElem or on destDoc->oldNs */
destParent ? curElem : NULL,
cur->ns, &ns,
&nsMap, depth,
@@ -9155,9 +9735,9 @@ end_ns_reference:
(clone->parent != NULL))
{
if (xmlIsID(destDoc, clone->parent, (xmlAttrPtr) clone)) {
-
+
xmlChar *idVal;
-
+
idVal = xmlNodeListGetString(cur->doc, cur->children, 1);
if (idVal != NULL) {
if (xmlAddID(NULL, destDoc, idVal, (xmlAttrPtr) cur) == NULL) {
@@ -9173,12 +9753,12 @@ end_ns_reference:
**
** The following will traverse the tree **************************
**
- *
+ *
* Walk the element's attributes before descending into child-nodes.
*/
if ((cur->type == XML_ELEMENT_NODE) && (cur->properties != NULL)) {
prevClone = NULL;
- parentClone = clone;
+ parentClone = clone;
cur = (xmlNodePtr) cur->properties;
continue;
}
@@ -9208,14 +9788,14 @@ leave_node:
/*
* TODO: Do we expect nsDefs on XML_XINCLUDE_START?
*/
- if (XML_NSMAP_NOTEMPTY(nsMap)) {
+ if (XML_NSMAP_NOTEMPTY(nsMap)) {
/*
* Pop mappings.
*/
while ((nsMap->last != NULL) &&
(nsMap->last->depth >= depth))
{
- XML_NSMAP_POP(nsMap, mi)
+ XML_NSMAP_POP(nsMap, mi)
}
/*
* Unshadow.
@@ -9224,7 +9804,7 @@ leave_node:
if (mi->shadowDepth >= depth)
mi->shadowDepth = -1;
}
- }
+ }
depth--;
}
if (cur->next != NULL) {
@@ -9237,7 +9817,8 @@ leave_node:
if (clone->parent != NULL)
clone->parent->last = clone;
clone = clone->parent;
- parentClone = clone->parent;
+ if (clone != NULL)
+ parentClone = clone->parent;
/*
* Process parent --> next;
*/
@@ -9246,14 +9827,14 @@ leave_node:
} else {
/* This is for attributes only. */
clone = clone->parent;
- parentClone = clone->parent;
+ parentClone = clone->parent;
/*
* Process parent-element --> children.
*/
cur = cur->parent;
- goto into_content;
+ goto into_content;
}
- }
+ }
goto exit;
internal_error:
@@ -9274,7 +9855,7 @@ exit:
nsMap->pool = nsMap->first;
nsMap->first = NULL;
}
- } else
+ } else
xmlDOMWrapNsMapFree(nsMap);
}
/*
@@ -9314,7 +9895,7 @@ xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt,
if ((attr == NULL) || (destDoc == NULL))
return (-1);
-
+
attr->doc = destDoc;
if (attr->ns != NULL) {
xmlNsPtr ns = NULL;
@@ -9341,13 +9922,13 @@ xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt,
ns = xmlDOMWrapNSNormDeclareNsForced(destDoc, destParent,
attr->ns->href, attr->ns->prefix, 1);
}
- }
+ }
if (ns == NULL)
goto internal_error;
attr->ns = ns;
- }
-
- XML_TREE_ADOPT_STR(attr->name);
+ }
+
+ XML_TREE_ADOPT_STR(attr->name);
attr->atype = 0;
attr->psvi = NULL;
/*
@@ -9356,13 +9937,15 @@ xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt,
if (attr->children == NULL)
return (0);
cur = attr->children;
+ if ((cur != NULL) && (cur->type == XML_NAMESPACE_DECL))
+ goto internal_error;
while (cur != NULL) {
cur->doc = destDoc;
switch (cur->type) {
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
XML_TREE_ADOPT_STR_2(cur->content)
- break;
+ break;
case XML_ENTITY_REF_NODE:
/*
* Remove reference to the entitity-node.
@@ -9380,7 +9963,7 @@ xmlDOMWrapAdoptAttr(xmlDOMWrapCtxtPtr ctxt,
cur->content = ent->content;
cur->children = (xmlNodePtr) ent;
cur->last = (xmlNodePtr) ent;
- }
+ }
}
break;
default:
@@ -9417,9 +10000,9 @@ internal_error:
* References of out-of scope ns-decls are remapped to point to @destDoc:
* 1) If @destParent is given, then nsDef entries on element-nodes are used
* 2) If *no* @destParent is given, then @destDoc->oldNs entries are used
-* This is the case when you have an unliked node and just want to move it
-* to the context of
-*
+* This is the case when you have an unlinked node and just want to move it
+* to the context of
+*
* If @destParent is given, it ensures that the tree is namespace
* wellformed by creating additional ns-decls where needed.
* Note that, since prefixes of already existent ns-decls can be
@@ -9436,16 +10019,17 @@ int
xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
xmlDocPtr sourceDoc,
xmlNodePtr node,
- xmlDocPtr destDoc,
+ xmlDocPtr destDoc,
xmlNodePtr destParent,
int options)
{
- if ((node == NULL) || (destDoc == NULL) ||
+ if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) ||
+ (destDoc == NULL) ||
((destParent != NULL) && (destParent->doc != destDoc)))
return(-1);
/*
* Check node->doc sanity.
- */
+ */
if ((node->doc != NULL) && (sourceDoc != NULL) &&
(node->doc != sourceDoc)) {
/*
@@ -9458,7 +10042,7 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
if (sourceDoc == destDoc)
return (-1);
switch (node->type) {
- case XML_ELEMENT_NODE:
+ case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
@@ -9484,7 +10068,7 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
} else if (node->type == XML_ATTRIBUTE_NODE) {
return (xmlDOMWrapAdoptAttr(ctxt, sourceDoc,
(xmlAttrPtr) node, destDoc, destParent, options));
- } else {
+ } else {
xmlNodePtr cur = node;
int adoptStr = 1;
@@ -9496,7 +10080,7 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
(sourceDoc->dict == destDoc->dict))
adoptStr = 0;
switch (node->type) {
- case XML_TEXT_NODE:
+ case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
XML_TREE_ADOPT_STR_2(node->content)
break;
@@ -9529,7 +10113,7 @@ xmlDOMWrapAdoptNode(xmlDOMWrapCtxtPtr ctxt,
default:
break;
}
- }
+ }
return (0);
}
diff --git a/gnulib-local/lib/libxml/tree.in.h b/gnulib-local/lib/libxml/tree.in.h
index 321280e..4a9b3bc 100644
--- a/gnulib-local/lib/libxml/tree.in.h
+++ b/gnulib-local/lib/libxml/tree.in.h
@@ -13,6 +13,7 @@
#define __XML_TREE_H__
#include <stdio.h>
+#include <limits.h>
#include <libxml/xmlversion.h>
#include <libxml/xmlstring.h>
@@ -71,15 +72,19 @@ typedef xmlEntity *xmlEntityPtr;
*/
typedef enum {
- XML_BUFFER_ALLOC_DOUBLEIT,
- XML_BUFFER_ALLOC_EXACT,
- XML_BUFFER_ALLOC_IMMUTABLE
+ XML_BUFFER_ALLOC_DOUBLEIT, /* double each time one need to grow */
+ XML_BUFFER_ALLOC_EXACT, /* grow only to the minimal size */
+ XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer */
+ XML_BUFFER_ALLOC_IO, /* special allocation scheme used for I/O */
+ XML_BUFFER_ALLOC_HYBRID, /* exact up to a threshold, and doubleit thereafter */
+ XML_BUFFER_ALLOC_BOUNDED /* limit the upper size of the buffer */
} xmlBufferAllocationScheme;
/**
* xmlBuffer:
*
- * A buffer structure.
+ * A buffer structure, this old construct is limited to 2GB and
+ * is being deprecated, use API with xmlBuf instead
*/
typedef struct _xmlBuffer xmlBuffer;
typedef xmlBuffer *xmlBufferPtr;
@@ -88,9 +93,45 @@ struct _xmlBuffer {
unsigned int use; /* The buffer size used */
unsigned int size; /* The buffer size */
xmlBufferAllocationScheme alloc; /* The realloc method */
+ xmlChar *contentIO; /* in IO mode we may have a different base */
};
/**
+ * xmlBuf:
+ *
+ * A buffer structure, new one, the actual structure internals are not public
+ */
+
+typedef struct _xmlBuf xmlBuf;
+
+/**
+ * xmlBufPtr:
+ *
+ * A pointer to a buffer structure, the actual structure internals are not
+ * public
+ */
+
+typedef xmlBuf *xmlBufPtr;
+
+/*
+ * A few public routines for xmlBuf. As those are expected to be used
+ * mostly internally the bulk of the routines are internal in buf.h
+ */
+XMLPUBFUN xmlChar* XMLCALL xmlBufContent (const xmlBuf* buf);
+XMLPUBFUN xmlChar* XMLCALL xmlBufEnd (xmlBufPtr buf);
+XMLPUBFUN size_t XMLCALL xmlBufUse (const xmlBufPtr buf);
+XMLPUBFUN size_t XMLCALL xmlBufShrink (xmlBufPtr buf, size_t len);
+
+/*
+ * LIBXML2_NEW_BUFFER:
+ *
+ * Macro used to express that the API use the new buffers for
+ * xmlParserInputBuffer and xmlOutputBuffer. The change was
+ * introduced in 2.9.0.
+ */
+#define LIBXML2_NEW_BUFFER
+
+/**
* XML_XML_NAMESPACE:
*
* This is the namespace for the special xml: prefix predefined in the
@@ -477,11 +518,28 @@ struct _xmlNode {
/**
* XML_GET_LINE:
*
- * Macro to extract the line number of an element node.
+ * Macro to extract the line number of an element node.
*/
#define XML_GET_LINE(n) \
(xmlGetLineNo(n))
+/**
+ * xmlDocProperty
+ *
+ * Set of properties of the document as found by the parser
+ * Some of them are linked to similary named xmlParserOption
+ */
+typedef enum {
+ XML_DOC_WELLFORMED = 1<<0, /* document is XML well formed */
+ XML_DOC_NSVALID = 1<<1, /* document is Namespace valid */
+ XML_DOC_OLD10 = 1<<2, /* parsed with old XML-1.0 parser */
+ XML_DOC_DTDVALID = 1<<3, /* DTD validation was successful */
+ XML_DOC_XINCLUDE = 1<<4, /* XInclude substitution was done */
+ XML_DOC_USERBUILT = 1<<5, /* Document was built using the API
+ and not by parsing an instance */
+ XML_DOC_INTERNAL = 1<<6, /* built for internal processing */
+ XML_DOC_HTML = 1<<7 /* parsed or built HTML document */
+} xmlDocProperties;
/**
* xmlDoc:
@@ -503,7 +561,12 @@ struct _xmlDoc {
/* End of common part */
int compression;/* level of zlib compression */
- int standalone; /* standalone document (no external refs) */
+ int standalone; /* standalone document (no external refs)
+ 1 if standalone="yes"
+ 0 if standalone="no"
+ -1 if there is no XML declaration
+ -2 if there is an XML declaration, but no
+ standalone attribute was specified */
struct _xmlDtd *intSubset; /* the document internal subset */
struct _xmlDtd *extSubset; /* the document external subset */
struct _xmlNs *oldNs; /* Global namespace, the old way */
@@ -516,6 +579,10 @@ struct _xmlDoc {
actually an xmlCharEncoding */
struct _xmlDict *dict; /* dict used to allocate names or NULL */
void *psvi; /* for type/PSVI informations */
+ int parseFlags; /* set of xmlParserOption used to parse the
+ document */
+ int properties; /* set of xmlDocProperties for this document
+ set at the end of parsing */
};
@@ -525,9 +592,9 @@ typedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr;
/**
* xmlDOMWrapAcquireNsFunction:
* @ctxt: a DOM wrapper context
- * @node: the context node (element or attribute)
+ * @node: the context node (element or attribute)
* @nsName: the requested namespace name
- * @nsPrefix: the requested namespace prefix
+ * @nsPrefix: the requested namespace prefix
*
* A function called to acquire namespaces (xmlNs) from the wrapper.
*
@@ -574,7 +641,7 @@ struct _xmlDOMWrapCtxt {
/**
* xmlRootNode:
*
- * Macro for compatibility naming layer with libxml1. Maps
+ * Macro for compatibility naming layer with libxml1. Maps
* to "children".
*/
#ifndef xmlRootNode
@@ -588,436 +655,450 @@ struct _xmlDOMWrapCtxt {
/*
* Some helper functions
*/
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \
+ defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || \
+ defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || \
+ defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || \
+ defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
XMLPUBFUN int XMLCALL
xmlValidateNCName (const xmlChar *value,
int space);
#endif
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateQName (const xmlChar *value,
int space);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateName (const xmlChar *value,
int space);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateNMToken (const xmlChar *value,
int space);
#endif
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlBuildQName (const xmlChar *ncname,
const xmlChar *prefix,
xmlChar *memory,
int len);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlSplitQName2 (const xmlChar *name,
xmlChar **prefix);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlSplitQName3 (const xmlChar *name,
int *len);
/*
- * Handling Buffers.
+ * Handling Buffers, the old ones see @xmlBuf for the new ones.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme);
-XMLPUBFUN xmlBufferAllocationScheme XMLCALL
+XMLPUBFUN xmlBufferAllocationScheme XMLCALL
xmlGetBufferAllocationScheme(void);
-XMLPUBFUN xmlBufferPtr XMLCALL
+XMLPUBFUN xmlBufferPtr XMLCALL
xmlBufferCreate (void);
-XMLPUBFUN xmlBufferPtr XMLCALL
+XMLPUBFUN xmlBufferPtr XMLCALL
xmlBufferCreateSize (size_t size);
-XMLPUBFUN xmlBufferPtr XMLCALL
+XMLPUBFUN xmlBufferPtr XMLCALL
xmlBufferCreateStatic (void *mem,
size_t size);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlBufferResize (xmlBufferPtr buf,
unsigned int size);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlBufferFree (xmlBufferPtr buf);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlBufferDump (FILE *file,
xmlBufferPtr buf);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlBufferAdd (xmlBufferPtr buf,
const xmlChar *str,
int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlBufferAddHead (xmlBufferPtr buf,
const xmlChar *str,
int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlBufferCat (xmlBufferPtr buf,
const xmlChar *str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlBufferCCat (xmlBufferPtr buf,
const char *str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlBufferShrink (xmlBufferPtr buf,
unsigned int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlBufferGrow (xmlBufferPtr buf,
unsigned int len);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlBufferEmpty (xmlBufferPtr buf);
-XMLPUBFUN const xmlChar* XMLCALL
- xmlBufferContent (const xmlBufferPtr buf);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN const xmlChar* XMLCALL
+ xmlBufferContent (const xmlBuffer *buf);
+XMLPUBFUN xmlChar* XMLCALL
+ xmlBufferDetach (xmlBufferPtr buf);
+XMLPUBFUN void XMLCALL
xmlBufferSetAllocationScheme(xmlBufferPtr buf,
xmlBufferAllocationScheme scheme);
-XMLPUBFUN int XMLCALL
- xmlBufferLength (const xmlBufferPtr buf);
+XMLPUBFUN int XMLCALL
+ xmlBufferLength (const xmlBuffer *buf);
/*
* Creating/freeing new structures.
*/
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr XMLCALL
xmlCreateIntSubset (xmlDocPtr doc,
const xmlChar *name,
const xmlChar *ExternalID,
const xmlChar *SystemID);
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr XMLCALL
xmlNewDtd (xmlDocPtr doc,
const xmlChar *name,
const xmlChar *ExternalID,
const xmlChar *SystemID);
-XMLPUBFUN xmlDtdPtr XMLCALL
- xmlGetIntSubset (xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN xmlDtdPtr XMLCALL
+ xmlGetIntSubset (const xmlDoc *doc);
+XMLPUBFUN void XMLCALL
xmlFreeDtd (xmlDtdPtr cur);
#ifdef LIBXML_LEGACY_ENABLED
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr XMLCALL
xmlNewGlobalNs (xmlDocPtr doc,
const xmlChar *href,
const xmlChar *prefix);
#endif /* LIBXML_LEGACY_ENABLED */
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr XMLCALL
xmlNewNs (xmlNodePtr node,
const xmlChar *href,
const xmlChar *prefix);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeNs (xmlNsPtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeNsList (xmlNsPtr cur);
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlNewDoc (const xmlChar *version);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeDoc (xmlDocPtr cur);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr XMLCALL
xmlNewDocProp (xmlDocPtr doc,
const xmlChar *name,
const xmlChar *value);
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr XMLCALL
xmlNewProp (xmlNodePtr node,
const xmlChar *name,
const xmlChar *value);
#endif
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr XMLCALL
xmlNewNsProp (xmlNodePtr node,
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *value);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr XMLCALL
xmlNewNsPropEatName (xmlNodePtr node,
xmlNsPtr ns,
xmlChar *name,
const xmlChar *value);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreePropList (xmlAttrPtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeProp (xmlAttrPtr cur);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr XMLCALL
xmlCopyProp (xmlNodePtr target,
xmlAttrPtr cur);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr XMLCALL
xmlCopyPropList (xmlNodePtr target,
xmlAttrPtr cur);
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlDtdPtr XMLCALL
+XMLPUBFUN xmlDtdPtr XMLCALL
xmlCopyDtd (xmlDtdPtr dtd);
#endif /* LIBXML_TREE_ENABLED */
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlCopyDoc (xmlDocPtr doc,
int recursive);
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */
/*
* Creating new nodes.
*/
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocNode (xmlDocPtr doc,
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocNodeEatName (xmlDocPtr doc,
xmlNsPtr ns,
xmlChar *name,
const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewNode (xmlNsPtr ns,
const xmlChar *name);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewNodeEatName (xmlNsPtr ns,
xmlChar *name);
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewChild (xmlNodePtr parent,
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *content);
#endif
-XMLPUBFUN xmlNodePtr XMLCALL
- xmlNewDocText (xmlDocPtr doc,
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewDocText (const xmlDoc *doc,
const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewText (const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocPI (xmlDocPtr doc,
const xmlChar *name,
const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewPI (const xmlChar *name,
const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocTextLen (xmlDocPtr doc,
const xmlChar *content,
int len);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewTextLen (const xmlChar *content,
int len);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocComment (xmlDocPtr doc,
const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewComment (const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewCDataBlock (xmlDocPtr doc,
const xmlChar *content,
int len);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewCharRef (xmlDocPtr doc,
const xmlChar *name);
-XMLPUBFUN xmlNodePtr XMLCALL
- xmlNewReference (xmlDocPtr doc,
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNewReference (const xmlDoc *doc,
const xmlChar *name);
-XMLPUBFUN xmlNodePtr XMLCALL
- xmlCopyNode (const xmlNodePtr node,
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlCopyNode (xmlNodePtr node,
int recursive);
-XMLPUBFUN xmlNodePtr XMLCALL
- xmlDocCopyNode (const xmlNodePtr node,
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlDocCopyNode (xmlNodePtr node,
xmlDocPtr doc,
int recursive);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlDocCopyNodeList (xmlDocPtr doc,
- const xmlNodePtr node);
-XMLPUBFUN xmlNodePtr XMLCALL
- xmlCopyNodeList (const xmlNodePtr node);
+ xmlNodePtr node);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlCopyNodeList (xmlNodePtr node);
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewTextChild (xmlNodePtr parent,
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocRawNode (xmlDocPtr doc,
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *content);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlNewDocFragment (xmlDocPtr doc);
#endif /* LIBXML_TREE_ENABLED */
/*
* Navigating.
*/
-XMLPUBFUN long XMLCALL
- xmlGetLineNo (xmlNodePtr node);
+XMLPUBFUN long XMLCALL
+ xmlGetLineNo (const xmlNode *node);
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)
-XMLPUBFUN xmlChar * XMLCALL
- xmlGetNodePath (xmlNodePtr node);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlGetNodePath (const xmlNode *node);
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */
-XMLPUBFUN xmlNodePtr XMLCALL
- xmlDocGetRootElement (xmlDocPtr doc);
-XMLPUBFUN xmlNodePtr XMLCALL
- xmlGetLastChild (xmlNodePtr parent);
-XMLPUBFUN int XMLCALL
- xmlNodeIsText (xmlNodePtr node);
-XMLPUBFUN int XMLCALL
- xmlIsBlankNode (xmlNodePtr node);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlDocGetRootElement (const xmlDoc *doc);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlGetLastChild (const xmlNode *parent);
+XMLPUBFUN int XMLCALL
+ xmlNodeIsText (const xmlNode *node);
+XMLPUBFUN int XMLCALL
+ xmlIsBlankNode (const xmlNode *node);
/*
* Changing the structure.
*/
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlDocSetRootElement (xmlDocPtr doc,
xmlNodePtr root);
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNodeSetName (xmlNodePtr cur,
const xmlChar *name);
#endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlAddChild (xmlNodePtr parent,
xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlAddChildList (xmlNodePtr parent,
xmlNodePtr cur);
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlReplaceNode (xmlNodePtr old,
xmlNodePtr cur);
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
- defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN xmlNodePtr XMLCALL
+ defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
+XMLPUBFUN xmlNodePtr XMLCALL
xmlAddPrevSibling (xmlNodePtr cur,
xmlNodePtr elem);
#endif /* LIBXML_TREE_ENABLED || LIBXML_HTML_ENABLED || LIBXML_SCHEMAS_ENABLED */
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlAddSibling (xmlNodePtr cur,
xmlNodePtr elem);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlAddNextSibling (xmlNodePtr cur,
xmlNodePtr elem);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlUnlinkNode (xmlNodePtr cur);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlTextMerge (xmlNodePtr first,
xmlNodePtr second);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextConcat (xmlNodePtr node,
const xmlChar *content,
int len);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeNodeList (xmlNodePtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeNode (xmlNodePtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSetTreeDoc (xmlNodePtr tree,
xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSetListDoc (xmlNodePtr list,
xmlDocPtr doc);
/*
* Namespaces.
*/
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr XMLCALL
xmlSearchNs (xmlDocPtr doc,
xmlNodePtr node,
const xmlChar *nameSpace);
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr XMLCALL
xmlSearchNsByHref (xmlDocPtr doc,
xmlNodePtr node,
const xmlChar *href);
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN xmlNsPtr * XMLCALL
- xmlGetNsList (xmlDocPtr doc,
- xmlNodePtr node);
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \
+ defined(LIBXML_SCHEMAS_ENABLED)
+XMLPUBFUN xmlNsPtr * XMLCALL
+ xmlGetNsList (const xmlDoc *doc,
+ const xmlNode *node);
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSetNs (xmlNodePtr node,
xmlNsPtr ns);
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr XMLCALL
xmlCopyNamespace (xmlNsPtr cur);
-XMLPUBFUN xmlNsPtr XMLCALL
+XMLPUBFUN xmlNsPtr XMLCALL
xmlCopyNamespaceList (xmlNsPtr cur);
/*
* Changing the content.
*/
-#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
-XMLPUBFUN xmlAttrPtr XMLCALL
+#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \
+ defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)
+XMLPUBFUN xmlAttrPtr XMLCALL
xmlSetProp (xmlNodePtr node,
const xmlChar *name,
const xmlChar *value);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr XMLCALL
xmlSetNsProp (xmlNodePtr node,
xmlNsPtr ns,
const xmlChar *name,
const xmlChar *value);
-#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */
-XMLPUBFUN xmlChar * XMLCALL
- xmlGetNoNsProp (xmlNodePtr node,
+#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \
+ defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */
+XMLPUBFUN xmlChar * XMLCALL
+ xmlGetNoNsProp (const xmlNode *node,
const xmlChar *name);
-XMLPUBFUN xmlChar * XMLCALL
- xmlGetProp (xmlNodePtr node,
+XMLPUBFUN xmlChar * XMLCALL
+ xmlGetProp (const xmlNode *node,
const xmlChar *name);
-XMLPUBFUN xmlAttrPtr XMLCALL
- xmlHasProp (xmlNodePtr node,
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlHasProp (const xmlNode *node,
const xmlChar *name);
-XMLPUBFUN xmlAttrPtr XMLCALL
- xmlHasNsProp (xmlNodePtr node,
+XMLPUBFUN xmlAttrPtr XMLCALL
+ xmlHasNsProp (const xmlNode *node,
const xmlChar *name,
const xmlChar *nameSpace);
-XMLPUBFUN xmlChar * XMLCALL
- xmlGetNsProp (xmlNodePtr node,
+XMLPUBFUN xmlChar * XMLCALL
+ xmlGetNsProp (const xmlNode *node,
const xmlChar *name,
const xmlChar *nameSpace);
-XMLPUBFUN xmlNodePtr XMLCALL
- xmlStringGetNodeList (xmlDocPtr doc,
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlStringGetNodeList (const xmlDoc *doc,
const xmlChar *value);
-XMLPUBFUN xmlNodePtr XMLCALL
- xmlStringLenGetNodeList (xmlDocPtr doc,
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlStringLenGetNodeList (const xmlDoc *doc,
const xmlChar *value,
int len);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlNodeListGetString (xmlDocPtr doc,
- xmlNodePtr list,
+ const xmlNode *list,
int inLine);
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlChar * XMLCALL
- xmlNodeListGetRawString (xmlDocPtr doc,
- xmlNodePtr list,
+XMLPUBFUN xmlChar * XMLCALL
+ xmlNodeListGetRawString (const xmlDoc *doc,
+ const xmlNode *list,
int inLine);
#endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNodeSetContent (xmlNodePtr cur,
const xmlChar *content);
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNodeSetContentLen (xmlNodePtr cur,
const xmlChar *content,
int len);
#endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNodeAddContent (xmlNodePtr cur,
const xmlChar *content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNodeAddContentLen (xmlNodePtr cur,
const xmlChar *content,
int len);
-XMLPUBFUN xmlChar * XMLCALL
- xmlNodeGetContent (xmlNodePtr cur);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlNodeGetContent (const xmlNode *cur);
+
XMLPUBFUN int XMLCALL
xmlNodeBufGetContent (xmlBufferPtr buffer,
- xmlNodePtr cur);
-XMLPUBFUN xmlChar * XMLCALL
- xmlNodeGetLang (xmlNodePtr cur);
-XMLPUBFUN int XMLCALL
- xmlNodeGetSpacePreserve (xmlNodePtr cur);
+ const xmlNode *cur);
+XMLPUBFUN int XMLCALL
+ xmlBufGetNodeContent (xmlBufPtr buf,
+ const xmlNode *cur);
+
+XMLPUBFUN xmlChar * XMLCALL
+ xmlNodeGetLang (const xmlNode *cur);
+XMLPUBFUN int XMLCALL
+ xmlNodeGetSpacePreserve (const xmlNode *cur);
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNodeSetLang (xmlNodePtr cur,
const xmlChar *lang);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNodeSetSpacePreserve (xmlNodePtr cur,
int val);
#endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN xmlChar * XMLCALL
- xmlNodeGetBase (xmlDocPtr doc,
- xmlNodePtr cur);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlNodeGetBase (const xmlDoc *doc,
+ const xmlNode *cur);
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNodeSetBase (xmlNodePtr cur,
const xmlChar *uri);
#endif
@@ -1025,14 +1106,14 @@ XMLPUBFUN void XMLCALL
/*
* Removing content.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRemoveProp (xmlAttrPtr cur);
#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlUnsetNsProp (xmlNodePtr node,
xmlNsPtr ns,
const xmlChar *name);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlUnsetProp (xmlNodePtr node,
const xmlChar *name);
#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */
@@ -1040,13 +1121,13 @@ XMLPUBFUN int XMLCALL
/*
* Internal, don't use.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlBufferWriteCHAR (xmlBufferPtr buf,
const xmlChar *string);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlBufferWriteChar (xmlBufferPtr buf,
const char *string);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlBufferWriteQuotedString(xmlBufferPtr buf,
const xmlChar *string);
@@ -1061,7 +1142,7 @@ XMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf,
/*
* Namespace handling.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlReconciliateNs (xmlDocPtr doc,
xmlNodePtr tree);
#endif
@@ -1070,61 +1151,67 @@ XMLPUBFUN int XMLCALL
/*
* Saving.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDocDumpFormatMemory (xmlDocPtr cur,
xmlChar **mem,
int *size,
int format);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDocDumpMemory (xmlDocPtr cur,
xmlChar **mem,
int *size);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDocDumpMemoryEnc (xmlDocPtr out_doc,
xmlChar **doc_txt_ptr,
int * doc_txt_len,
const char *txt_encoding);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc,
xmlChar **doc_txt_ptr,
int * doc_txt_len,
const char *txt_encoding,
int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlDocFormatDump (FILE *f,
xmlDocPtr cur,
int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlDocDump (FILE *f,
xmlDocPtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlElemDump (FILE *f,
xmlDocPtr doc,
xmlNodePtr cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSaveFile (const char *filename,
xmlDocPtr cur);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSaveFormatFile (const char *filename,
xmlDocPtr cur,
int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN size_t XMLCALL
+ xmlBufNodeDump (xmlBufPtr buf,
+ xmlDocPtr doc,
+ xmlNodePtr cur,
+ int level,
+ int format);
+XMLPUBFUN int XMLCALL
xmlNodeDump (xmlBufferPtr buf,
xmlDocPtr doc,
xmlNodePtr cur,
int level,
int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSaveFileTo (xmlOutputBufferPtr buf,
xmlDocPtr cur,
const char *encoding);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSaveFormatFileTo (xmlOutputBufferPtr buf,
xmlDocPtr cur,
const char *encoding,
int format);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlNodeDumpOutput (xmlOutputBufferPtr buf,
xmlDocPtr doc,
xmlNodePtr cur,
@@ -1132,13 +1219,13 @@ XMLPUBFUN void XMLCALL
int format,
const char *encoding);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSaveFormatFileEnc (const char *filename,
xmlDocPtr cur,
const char *encoding,
int format);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSaveFileEnc (const char *filename,
xmlDocPtr cur,
const char *encoding);
@@ -1147,21 +1234,21 @@ XMLPUBFUN int XMLCALL
/*
* XHTML
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlIsXHTML (const xmlChar *systemID,
const xmlChar *publicID);
/*
* Compression.
*/
-XMLPUBFUN int XMLCALL
- xmlGetDocCompressMode (xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN int XMLCALL
+ xmlGetDocCompressMode (const xmlDoc *doc);
+XMLPUBFUN void XMLCALL
xmlSetDocCompressMode (xmlDocPtr doc,
int mode);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlGetCompressMode (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSetCompressMode (int mode);
/*
@@ -1179,7 +1266,7 @@ XMLPUBFUN int XMLCALL
xmlDOMWrapAdoptNode (xmlDOMWrapCtxtPtr ctxt,
xmlDocPtr sourceDoc,
xmlNodePtr node,
- xmlDocPtr destDoc,
+ xmlDocPtr destDoc,
xmlNodePtr destParent,
int options);
XMLPUBFUN int XMLCALL
@@ -1197,6 +1284,22 @@ XMLPUBFUN int XMLCALL
int deep,
int options);
+#ifdef LIBXML_TREE_ENABLED
+/*
+ * 5 interfaces from DOM ElementTraversal, but different in entities
+ * traversal.
+ */
+XMLPUBFUN unsigned long XMLCALL
+ xmlChildElementCount (xmlNodePtr parent);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlNextElementSibling (xmlNodePtr node);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlFirstElementChild (xmlNodePtr parent);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlLastElementChild (xmlNodePtr parent);
+XMLPUBFUN xmlNodePtr XMLCALL
+ xmlPreviousElementSibling (xmlNodePtr node);
+#endif
#ifdef __cplusplus
}
#endif
diff --git a/gnulib-local/lib/libxml/triodef.h b/gnulib-local/lib/libxml/triodef.h
new file mode 100644
index 0000000..46772ee
--- /dev/null
+++ b/gnulib-local/lib/libxml/triodef.h
@@ -0,0 +1,228 @@
+/*************************************************************************
+ *
+ * $Id$
+ *
+ * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
+ *
+ * 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
+ * MERCHANTIBILITY 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/gnulib-local/lib/libxml/trionan.c b/gnulib-local/lib/libxml/trionan.c
new file mode 100644
index 0000000..6fbabb5
--- /dev/null
+++ b/gnulib-local/lib/libxml/trionan.c
@@ -0,0 +1,914 @@
+/*************************************************************************
+ *
+ * $Id$
+ *
+ * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
+ *
+ * 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
+ * MERCHANTIBILITY 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 <math.h>
+#include <string.h>
+#include <limits.h>
+#include <float.h>
+#if defined(TRIO_PLATFORM_UNIX)
+# include <signal.h>
+#endif
+#if defined(TRIO_COMPILER_DECC)
+# if defined(__linux__)
+# include <cpml.h>
+# else
+# include <fp_class.h>
+# endif
+#endif
+#include <assert.h>
+
+#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 (amoungst 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
+ * endianess by the compiler, which means that we can support any
+ * kind of endianess. 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 <stdio.h>
+
+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/gnulib-local/lib/libxml/trionan.h b/gnulib-local/lib/libxml/trionan.h
new file mode 100644
index 0000000..be6e718
--- /dev/null
+++ b/gnulib-local/lib/libxml/trionan.h
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * $Id$
+ *
+ * Copyright (C) 2001 Bjorn Reese <breese@users.sourceforge.net>
+ *
+ * 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
+ * MERCHANTIBILITY 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/gnulib-local/lib/libxml/uri.c b/gnulib-local/lib/libxml/uri.c
index 1e29223..ff47abb 100644
--- a/gnulib-local/lib/libxml/uri.c
+++ b/gnulib-local/lib/libxml/uri.c
@@ -1,7 +1,7 @@
/**
- * uri.c: set of generic URI related routines
+ * uri.c: set of generic URI related routines
*
- * Reference: RFCs 2396, 2732 and 2373
+ * Reference: RFCs 3986, 2732 and 2373
*
* See Copyright for the status of this software.
*
@@ -18,14 +18,41 @@
#include <libxml/globals.h>
#include <libxml/xmlerror.h>
-/************************************************************************
- * *
- * Macros to differentiate various character type *
- * directly extracted from RFC 2396 *
- * *
- ************************************************************************/
+/**
+ * MAX_URI_LENGTH:
+ *
+ * The definition of the URI regexp in the above RFC has no size limit
+ * In practice they are usually relativey short except for the
+ * data URI scheme as defined in RFC 2397. Even for data URI the usual
+ * maximum size before hitting random practical limits is around 64 KB
+ * and 4KB is usually a maximum admitted limit for proper operations.
+ * The value below is more a security limit than anything else and
+ * really should never be hit by 'normal' operations
+ * Set to 1 MByte in 2012, this is only enforced on output
+ */
+#define MAX_URI_LENGTH 1024 * 1024
+
+static void
+xmlURIErrMemory(const char *extra)
+{
+ if (extra)
+ __xmlRaiseError(NULL, NULL, NULL,
+ NULL, NULL, XML_FROM_URI,
+ XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0,
+ extra, NULL, NULL, 0, 0,
+ "Memory allocation failed : %s\n", extra);
+ else
+ __xmlRaiseError(NULL, NULL, NULL,
+ NULL, NULL, XML_FROM_URI,
+ XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0,
+ NULL, NULL, NULL, 0, 0,
+ "Memory allocation failed\n");
+}
+
+static void xmlCleanURI(xmlURIPtr uri);
/*
+ * Old rule from 2396 used in legacy handling code
* alpha = lowalpha | upalpha
*/
#define IS_ALPHA(x) (IS_LOWALPHA(x) || IS_UPALPHA(x))
@@ -61,31 +88,30 @@
#define IS_ALPHANUM(x) (IS_ALPHA(x) || IS_DIGIT(x))
/*
- * hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
- * "a" | "b" | "c" | "d" | "e" | "f"
- */
-
-#define IS_HEX(x) ((IS_DIGIT(x)) || (((x) >= 'a') && ((x) <= 'f')) || \
- (((x) >= 'A') && ((x) <= 'F')))
-
-/*
* mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
*/
-#define IS_MARK(x) (((x) == '-') || ((x) == '_') || ((x) == '.') || \
- ((x) == '!') || ((x) == '~') || ((x) == '*') || ((x) == '\'') || \
+#define IS_MARK(x) (((x) == '-') || ((x) == '_') || ((x) == '.') || \
+ ((x) == '!') || ((x) == '~') || ((x) == '*') || ((x) == '\'') || \
((x) == '(') || ((x) == ')'))
+/*
+ * unwise = "{" | "}" | "|" | "\" | "^" | "`"
+ */
+#define IS_UNWISE(p) \
+ (((*(p) == '{')) || ((*(p) == '}')) || ((*(p) == '|')) || \
+ ((*(p) == '\\')) || ((*(p) == '^')) || ((*(p) == '[')) || \
+ ((*(p) == ']')) || ((*(p) == '`')))
/*
* reserved = ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | "," |
- * "[" | "]"
+ * "[" | "]"
*/
-#define IS_RESERVED(x) (((x) == ';') || ((x) == '/') || ((x) == '?') || \
- ((x) == ':') || ((x) == '@') || ((x) == '&') || ((x) == '=') || \
- ((x) == '+') || ((x) == '$') || ((x) == ',') || ((x) == '[') || \
- ((x) == ']'))
+#define IS_RESERVED(x) (((x) == ';') || ((x) == '/') || ((x) == '?') || \
+ ((x) == ':') || ((x) == '@') || ((x) == '&') || ((x) == '=') || \
+ ((x) == '+') || ((x) == '$') || ((x) == ',') || ((x) == '[') || \
+ ((x) == ']'))
/*
* unreserved = alphanum | mark
@@ -94,98 +120,879 @@
#define IS_UNRESERVED(x) (IS_ALPHANUM(x) || IS_MARK(x))
/*
- * escaped = "%" hex hex
+ * Skip to next pointer char, handle escaped sequences
*/
-#define IS_ESCAPED(p) ((*(p) == '%') && (IS_HEX((p)[1])) && \
- (IS_HEX((p)[2])))
+#define NEXT(p) ((*p == '%')? p += 3 : p++)
/*
- * uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
- * "&" | "=" | "+" | "$" | ","
+ * Productions from the spec.
+ *
+ * authority = server | reg_name
+ * reg_name = 1*( unreserved | escaped | "$" | "," |
+ * ";" | ":" | "@" | "&" | "=" | "+" )
+ *
+ * path = [ abs_path | opaque_part ]
*/
-#define IS_URIC_NO_SLASH(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) ||\
- ((*(p) == ';')) || ((*(p) == '?')) || ((*(p) == ':')) ||\
- ((*(p) == '@')) || ((*(p) == '&')) || ((*(p) == '=')) ||\
- ((*(p) == '+')) || ((*(p) == '$')) || ((*(p) == ',')))
+
+#define STRNDUP(s, n) (char *) xmlStrndup((const xmlChar *)(s), (n))
+
+/************************************************************************
+ * *
+ * RFC 3986 parser *
+ * *
+ ************************************************************************/
+
+#define ISA_DIGIT(p) ((*(p) >= '0') && (*(p) <= '9'))
+#define ISA_ALPHA(p) (((*(p) >= 'a') && (*(p) <= 'z')) || \
+ ((*(p) >= 'A') && (*(p) <= 'Z')))
+#define ISA_HEXDIG(p) \
+ (ISA_DIGIT(p) || ((*(p) >= 'a') && (*(p) <= 'f')) || \
+ ((*(p) >= 'A') && (*(p) <= 'F')))
/*
- * pchar = unreserved | escaped | ":" | "@" | "&" | "=" | "+" | "$" | ","
+ * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
+ * / "*" / "+" / "," / ";" / "="
*/
-#define IS_PCHAR(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) || \
- ((*(p) == ':')) || ((*(p) == '@')) || ((*(p) == '&')) ||\
- ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) ||\
- ((*(p) == ',')))
+#define ISA_SUB_DELIM(p) \
+ (((*(p) == '!')) || ((*(p) == '$')) || ((*(p) == '&')) || \
+ ((*(p) == '(')) || ((*(p) == ')')) || ((*(p) == '*')) || \
+ ((*(p) == '+')) || ((*(p) == ',')) || ((*(p) == ';')) || \
+ ((*(p) == '=')) || ((*(p) == '\'')))
/*
- * rel_segment = 1*( unreserved | escaped |
- * ";" | "@" | "&" | "=" | "+" | "$" | "," )
+ * gen-delims = ":" / "/" / "?" / "#" / "[" / "]" / "@"
*/
+#define ISA_GEN_DELIM(p) \
+ (((*(p) == ':')) || ((*(p) == '/')) || ((*(p) == '?')) || \
+ ((*(p) == '#')) || ((*(p) == '[')) || ((*(p) == ']')) || \
+ ((*(p) == '@')))
-#define IS_SEGMENT(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) || \
- ((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) || \
- ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) || \
- ((*(p) == ',')))
+/*
+ * reserved = gen-delims / sub-delims
+ */
+#define ISA_RESERVED(p) (ISA_GEN_DELIM(p) || (ISA_SUB_DELIM(p)))
/*
- * scheme = alpha *( alpha | digit | "+" | "-" | "." )
+ * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
*/
+#define ISA_UNRESERVED(p) \
+ ((ISA_ALPHA(p)) || (ISA_DIGIT(p)) || ((*(p) == '-')) || \
+ ((*(p) == '.')) || ((*(p) == '_')) || ((*(p) == '~')))
-#define IS_SCHEME(x) ((IS_ALPHA(x)) || (IS_DIGIT(x)) || \
- ((x) == '+') || ((x) == '-') || ((x) == '.'))
+/*
+ * pct-encoded = "%" HEXDIG HEXDIG
+ */
+#define ISA_PCT_ENCODED(p) \
+ ((*(p) == '%') && (ISA_HEXDIG(p + 1)) && (ISA_HEXDIG(p + 2)))
/*
- * reg_name = 1*( unreserved | escaped | "$" | "," |
- * ";" | ":" | "@" | "&" | "=" | "+" )
+ * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
*/
+#define ISA_PCHAR(p) \
+ (ISA_UNRESERVED(p) || ISA_PCT_ENCODED(p) || ISA_SUB_DELIM(p) || \
+ ((*(p) == ':')) || ((*(p) == '@')))
-#define IS_REG_NAME(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) || \
- ((*(p) == '$')) || ((*(p) == ',')) || ((*(p) == ';')) || \
- ((*(p) == ':')) || ((*(p) == '@')) || ((*(p) == '&')) || \
- ((*(p) == '=')) || ((*(p) == '+')))
+/**
+ * xmlParse3986Scheme:
+ * @uri: pointer to an URI structure
+ * @str: pointer to the string to analyze
+ *
+ * Parse an URI scheme
+ *
+ * ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986Scheme(xmlURIPtr uri, const char **str) {
+ const char *cur;
-/*
- * userinfo = *( unreserved | escaped | ";" | ":" | "&" | "=" |
- * "+" | "$" | "," )
+ if (str == NULL)
+ return(-1);
+
+ cur = *str;
+ if (!ISA_ALPHA(cur))
+ return(2);
+ cur++;
+ while (ISA_ALPHA(cur) || ISA_DIGIT(cur) ||
+ (*cur == '+') || (*cur == '-') || (*cur == '.')) cur++;
+ if (uri != NULL) {
+ if (uri->scheme != NULL) xmlFree(uri->scheme);
+ uri->scheme = STRNDUP(*str, cur - *str);
+ }
+ *str = cur;
+ return(0);
+}
+
+/**
+ * xmlParse3986Fragment:
+ * @uri: pointer to an URI structure
+ * @str: pointer to the string to analyze
+ *
+ * Parse the query part of an URI
+ *
+ * fragment = *( pchar / "/" / "?" )
+ * NOTE: the strict syntax as defined by 3986 does not allow '[' and ']'
+ * in the fragment identifier but this is used very broadly for
+ * xpointer scheme selection, so we are allowing it here to not break
+ * for example all the DocBook processing chains.
+ *
+ * Returns 0 or the error code
*/
-#define IS_USERINFO(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) || \
- ((*(p) == ';')) || ((*(p) == ':')) || ((*(p) == '&')) || \
- ((*(p) == '=')) || ((*(p) == '+')) || ((*(p) == '$')) || \
- ((*(p) == ',')))
+static int
+xmlParse3986Fragment(xmlURIPtr uri, const char **str)
+{
+ const char *cur;
-/*
- * uric = reserved | unreserved | escaped
+ if (str == NULL)
+ return (-1);
+
+ cur = *str;
+
+ while ((ISA_PCHAR(cur)) || (*cur == '/') || (*cur == '?') ||
+ (*cur == '[') || (*cur == ']') ||
+ ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
+ NEXT(cur);
+ if (uri != NULL) {
+ if (uri->fragment != NULL)
+ xmlFree(uri->fragment);
+ if (uri->cleanup & 2)
+ uri->fragment = STRNDUP(*str, cur - *str);
+ else
+ uri->fragment = xmlURIUnescapeString(*str, cur - *str, NULL);
+ }
+ *str = cur;
+ return (0);
+}
+
+/**
+ * xmlParse3986Query:
+ * @uri: pointer to an URI structure
+ * @str: pointer to the string to analyze
+ *
+ * Parse the query part of an URI
+ *
+ * query = *uric
+ *
+ * Returns 0 or the error code
*/
+static int
+xmlParse3986Query(xmlURIPtr uri, const char **str)
+{
+ const char *cur;
-#define IS_URIC(p) ((IS_UNRESERVED(*(p))) || (IS_ESCAPED(p)) || \
- (IS_RESERVED(*(p))))
+ if (str == NULL)
+ return (-1);
-/*
-* unwise = "{" | "}" | "|" | "\" | "^" | "`"
-*/
+ cur = *str;
-#define IS_UNWISE(p) \
- (((*(p) == '{')) || ((*(p) == '}')) || ((*(p) == '|')) || \
- ((*(p) == '\\')) || ((*(p) == '^')) || ((*(p) == '[')) || \
- ((*(p) == ']')) || ((*(p) == '`')))
+ while ((ISA_PCHAR(cur)) || (*cur == '/') || (*cur == '?') ||
+ ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
+ NEXT(cur);
+ if (uri != NULL) {
+ if (uri->query != NULL)
+ xmlFree(uri->query);
+ if (uri->cleanup & 2)
+ uri->query = STRNDUP(*str, cur - *str);
+ else
+ uri->query = xmlURIUnescapeString(*str, cur - *str, NULL);
-/*
- * Skip to next pointer char, handle escaped sequences
+ /* Save the raw bytes of the query as well.
+ * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00114
+ */
+ if (uri->query_raw != NULL)
+ xmlFree (uri->query_raw);
+ uri->query_raw = STRNDUP (*str, cur - *str);
+ }
+ *str = cur;
+ return (0);
+}
+
+/**
+ * xmlParse3986Port:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse a port part and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * port = *DIGIT
+ *
+ * Returns 0 or the error code
*/
+static int
+xmlParse3986Port(xmlURIPtr uri, const char **str)
+{
+ const char *cur = *str;
-#define NEXT(p) ((*p == '%')? p += 3 : p++)
+ if (ISA_DIGIT(cur)) {
+ if (uri != NULL)
+ uri->port = 0;
+ while (ISA_DIGIT(cur)) {
+ if (uri != NULL)
+ uri->port = uri->port * 10 + (*cur - '0');
+ cur++;
+ }
+ *str = cur;
+ return(0);
+ }
+ return(1);
+}
-/*
- * Productions from the spec.
+/**
+ * xmlParse3986Userinfo:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
*
- * authority = server | reg_name
- * reg_name = 1*( unreserved | escaped | "$" | "," |
- * ";" | ":" | "@" | "&" | "=" | "+" )
+ * Parse an user informations part and fills in the appropriate fields
+ * of the @uri structure
*
- * path = [ abs_path | opaque_part ]
+ * userinfo = *( unreserved / pct-encoded / sub-delims / ":" )
+ *
+ * Returns 0 or the error code
*/
+static int
+xmlParse3986Userinfo(xmlURIPtr uri, const char **str)
+{
+ const char *cur;
-#define STRNDUP(s, n) (char *) xmlStrndup((const xmlChar *)(s), (n))
+ cur = *str;
+ while (ISA_UNRESERVED(cur) || ISA_PCT_ENCODED(cur) ||
+ ISA_SUB_DELIM(cur) || (*cur == ':'))
+ NEXT(cur);
+ if (*cur == '@') {
+ if (uri != NULL) {
+ if (uri->user != NULL) xmlFree(uri->user);
+ if (uri->cleanup & 2)
+ uri->user = STRNDUP(*str, cur - *str);
+ else
+ uri->user = xmlURIUnescapeString(*str, cur - *str, NULL);
+ }
+ *str = cur;
+ return(0);
+ }
+ return(1);
+}
+
+/**
+ * xmlParse3986DecOctet:
+ * @str: the string to analyze
+ *
+ * dec-octet = DIGIT ; 0-9
+ * / %x31-39 DIGIT ; 10-99
+ * / "1" 2DIGIT ; 100-199
+ * / "2" %x30-34 DIGIT ; 200-249
+ * / "25" %x30-35 ; 250-255
+ *
+ * Skip a dec-octet.
+ *
+ * Returns 0 if found and skipped, 1 otherwise
+ */
+static int
+xmlParse3986DecOctet(const char **str) {
+ const char *cur = *str;
+
+ if (!(ISA_DIGIT(cur)))
+ return(1);
+ if (!ISA_DIGIT(cur+1))
+ cur++;
+ else if ((*cur != '0') && (ISA_DIGIT(cur + 1)) && (!ISA_DIGIT(cur+2)))
+ cur += 2;
+ else if ((*cur == '1') && (ISA_DIGIT(cur + 1)) && (ISA_DIGIT(cur + 2)))
+ cur += 3;
+ else if ((*cur == '2') && (*(cur + 1) >= '0') &&
+ (*(cur + 1) <= '4') && (ISA_DIGIT(cur + 2)))
+ cur += 3;
+ else if ((*cur == '2') && (*(cur + 1) == '5') &&
+ (*(cur + 2) >= '0') && (*(cur + 1) <= '5'))
+ cur += 3;
+ else
+ return(1);
+ *str = cur;
+ return(0);
+}
+/**
+ * xmlParse3986Host:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an host part and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * host = IP-literal / IPv4address / reg-name
+ * IP-literal = "[" ( IPv6address / IPvFuture ) "]"
+ * IPv4address = dec-octet "." dec-octet "." dec-octet "." dec-octet
+ * reg-name = *( unreserved / pct-encoded / sub-delims )
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986Host(xmlURIPtr uri, const char **str)
+{
+ const char *cur = *str;
+ const char *host;
+
+ host = cur;
+ /*
+ * IPv6 and future adressing scheme are enclosed between brackets
+ */
+ if (*cur == '[') {
+ cur++;
+ while ((*cur != ']') && (*cur != 0))
+ cur++;
+ if (*cur != ']')
+ return(1);
+ cur++;
+ goto found;
+ }
+ /*
+ * try to parse an IPv4
+ */
+ if (ISA_DIGIT(cur)) {
+ if (xmlParse3986DecOctet(&cur) != 0)
+ goto not_ipv4;
+ if (*cur != '.')
+ goto not_ipv4;
+ cur++;
+ if (xmlParse3986DecOctet(&cur) != 0)
+ goto not_ipv4;
+ if (*cur != '.')
+ goto not_ipv4;
+ if (xmlParse3986DecOctet(&cur) != 0)
+ goto not_ipv4;
+ if (*cur != '.')
+ goto not_ipv4;
+ if (xmlParse3986DecOctet(&cur) != 0)
+ goto not_ipv4;
+ goto found;
+not_ipv4:
+ cur = *str;
+ }
+ /*
+ * then this should be a hostname which can be empty
+ */
+ while (ISA_UNRESERVED(cur) || ISA_PCT_ENCODED(cur) || ISA_SUB_DELIM(cur))
+ NEXT(cur);
+found:
+ if (uri != NULL) {
+ if (uri->authority != NULL) xmlFree(uri->authority);
+ uri->authority = NULL;
+ if (uri->server != NULL) xmlFree(uri->server);
+ if (cur != host) {
+ if (uri->cleanup & 2)
+ uri->server = STRNDUP(host, cur - host);
+ else
+ uri->server = xmlURIUnescapeString(host, cur - host, NULL);
+ } else
+ uri->server = NULL;
+ }
+ *str = cur;
+ return(0);
+}
+
+/**
+ * xmlParse3986Authority:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an authority part and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * authority = [ userinfo "@" ] host [ ":" port ]
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986Authority(xmlURIPtr uri, const char **str)
+{
+ const char *cur;
+ int ret;
+
+ cur = *str;
+ /*
+ * try to parse an userinfo and check for the trailing @
+ */
+ ret = xmlParse3986Userinfo(uri, &cur);
+ if ((ret != 0) || (*cur != '@'))
+ cur = *str;
+ else
+ cur++;
+ ret = xmlParse3986Host(uri, &cur);
+ if (ret != 0) return(ret);
+ if (*cur == ':') {
+ cur++;
+ ret = xmlParse3986Port(uri, &cur);
+ if (ret != 0) return(ret);
+ }
+ *str = cur;
+ return(0);
+}
+
+/**
+ * xmlParse3986Segment:
+ * @str: the string to analyze
+ * @forbid: an optional forbidden character
+ * @empty: allow an empty segment
+ *
+ * Parse a segment and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * segment = *pchar
+ * segment-nz = 1*pchar
+ * segment-nz-nc = 1*( unreserved / pct-encoded / sub-delims / "@" )
+ * ; non-zero-length segment without any colon ":"
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986Segment(const char **str, char forbid, int empty)
+{
+ const char *cur;
+
+ cur = *str;
+ if (!ISA_PCHAR(cur)) {
+ if (empty)
+ return(0);
+ return(1);
+ }
+ while (ISA_PCHAR(cur) && (*cur != forbid))
+ NEXT(cur);
+ *str = cur;
+ return (0);
+}
+
+/**
+ * xmlParse3986PathAbEmpty:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an path absolute or empty and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * path-abempty = *( "/" segment )
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986PathAbEmpty(xmlURIPtr uri, const char **str)
+{
+ const char *cur;
+ int ret;
+
+ cur = *str;
+
+ while (*cur == '/') {
+ cur++;
+ ret = xmlParse3986Segment(&cur, 0, 1);
+ if (ret != 0) return(ret);
+ }
+ if (uri != NULL) {
+ if (uri->path != NULL) xmlFree(uri->path);
+ if (*str != cur) {
+ if (uri->cleanup & 2)
+ uri->path = STRNDUP(*str, cur - *str);
+ else
+ uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ } else {
+ uri->path = NULL;
+ }
+ }
+ *str = cur;
+ return (0);
+}
+
+/**
+ * xmlParse3986PathAbsolute:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an path absolute and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * path-absolute = "/" [ segment-nz *( "/" segment ) ]
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986PathAbsolute(xmlURIPtr uri, const char **str)
+{
+ const char *cur;
+ int ret;
+
+ cur = *str;
+
+ if (*cur != '/')
+ return(1);
+ cur++;
+ ret = xmlParse3986Segment(&cur, 0, 0);
+ if (ret == 0) {
+ while (*cur == '/') {
+ cur++;
+ ret = xmlParse3986Segment(&cur, 0, 1);
+ if (ret != 0) return(ret);
+ }
+ }
+ if (uri != NULL) {
+ if (uri->path != NULL) xmlFree(uri->path);
+ if (cur != *str) {
+ if (uri->cleanup & 2)
+ uri->path = STRNDUP(*str, cur - *str);
+ else
+ uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ } else {
+ uri->path = NULL;
+ }
+ }
+ *str = cur;
+ return (0);
+}
+
+/**
+ * xmlParse3986PathRootless:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an path without root and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * path-rootless = segment-nz *( "/" segment )
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986PathRootless(xmlURIPtr uri, const char **str)
+{
+ const char *cur;
+ int ret;
+
+ cur = *str;
+
+ ret = xmlParse3986Segment(&cur, 0, 0);
+ if (ret != 0) return(ret);
+ while (*cur == '/') {
+ cur++;
+ ret = xmlParse3986Segment(&cur, 0, 1);
+ if (ret != 0) return(ret);
+ }
+ if (uri != NULL) {
+ if (uri->path != NULL) xmlFree(uri->path);
+ if (cur != *str) {
+ if (uri->cleanup & 2)
+ uri->path = STRNDUP(*str, cur - *str);
+ else
+ uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ } else {
+ uri->path = NULL;
+ }
+ }
+ *str = cur;
+ return (0);
+}
+
+/**
+ * xmlParse3986PathNoScheme:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an path which is not a scheme and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * path-noscheme = segment-nz-nc *( "/" segment )
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986PathNoScheme(xmlURIPtr uri, const char **str)
+{
+ const char *cur;
+ int ret;
+
+ cur = *str;
+
+ ret = xmlParse3986Segment(&cur, ':', 0);
+ if (ret != 0) return(ret);
+ while (*cur == '/') {
+ cur++;
+ ret = xmlParse3986Segment(&cur, 0, 1);
+ if (ret != 0) return(ret);
+ }
+ if (uri != NULL) {
+ if (uri->path != NULL) xmlFree(uri->path);
+ if (cur != *str) {
+ if (uri->cleanup & 2)
+ uri->path = STRNDUP(*str, cur - *str);
+ else
+ uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
+ } else {
+ uri->path = NULL;
+ }
+ }
+ *str = cur;
+ return (0);
+}
+
+/**
+ * xmlParse3986HierPart:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an hierarchical part and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * hier-part = "//" authority path-abempty
+ * / path-absolute
+ * / path-rootless
+ * / path-empty
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986HierPart(xmlURIPtr uri, const char **str)
+{
+ const char *cur;
+ int ret;
+
+ cur = *str;
+
+ if ((*cur == '/') && (*(cur + 1) == '/')) {
+ cur += 2;
+ ret = xmlParse3986Authority(uri, &cur);
+ if (ret != 0) return(ret);
+ if (uri->server == NULL)
+ uri->port = -1;
+ ret = xmlParse3986PathAbEmpty(uri, &cur);
+ if (ret != 0) return(ret);
+ *str = cur;
+ return(0);
+ } else if (*cur == '/') {
+ ret = xmlParse3986PathAbsolute(uri, &cur);
+ if (ret != 0) return(ret);
+ } else if (ISA_PCHAR(cur)) {
+ ret = xmlParse3986PathRootless(uri, &cur);
+ if (ret != 0) return(ret);
+ } else {
+ /* path-empty is effectively empty */
+ if (uri != NULL) {
+ if (uri->path != NULL) xmlFree(uri->path);
+ uri->path = NULL;
+ }
+ }
+ *str = cur;
+ return (0);
+}
+
+/**
+ * xmlParse3986RelativeRef:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an URI string and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * relative-ref = relative-part [ "?" query ] [ "#" fragment ]
+ * relative-part = "//" authority path-abempty
+ * / path-absolute
+ * / path-noscheme
+ * / path-empty
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986RelativeRef(xmlURIPtr uri, const char *str) {
+ int ret;
+
+ if ((*str == '/') && (*(str + 1) == '/')) {
+ str += 2;
+ ret = xmlParse3986Authority(uri, &str);
+ if (ret != 0) return(ret);
+ ret = xmlParse3986PathAbEmpty(uri, &str);
+ if (ret != 0) return(ret);
+ } else if (*str == '/') {
+ ret = xmlParse3986PathAbsolute(uri, &str);
+ if (ret != 0) return(ret);
+ } else if (ISA_PCHAR(str)) {
+ ret = xmlParse3986PathNoScheme(uri, &str);
+ if (ret != 0) return(ret);
+ } else {
+ /* path-empty is effectively empty */
+ if (uri != NULL) {
+ if (uri->path != NULL) xmlFree(uri->path);
+ uri->path = NULL;
+ }
+ }
+
+ if (*str == '?') {
+ str++;
+ ret = xmlParse3986Query(uri, &str);
+ if (ret != 0) return(ret);
+ }
+ if (*str == '#') {
+ str++;
+ ret = xmlParse3986Fragment(uri, &str);
+ if (ret != 0) return(ret);
+ }
+ if (*str != 0) {
+ xmlCleanURI(uri);
+ return(1);
+ }
+ return(0);
+}
+
+
+/**
+ * xmlParse3986URI:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an URI string and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * scheme ":" hier-part [ "?" query ] [ "#" fragment ]
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986URI(xmlURIPtr uri, const char *str) {
+ int ret;
+
+ ret = xmlParse3986Scheme(uri, &str);
+ if (ret != 0) return(ret);
+ if (*str != ':') {
+ return(1);
+ }
+ str++;
+ ret = xmlParse3986HierPart(uri, &str);
+ if (ret != 0) return(ret);
+ if (*str == '?') {
+ str++;
+ ret = xmlParse3986Query(uri, &str);
+ if (ret != 0) return(ret);
+ }
+ if (*str == '#') {
+ str++;
+ ret = xmlParse3986Fragment(uri, &str);
+ if (ret != 0) return(ret);
+ }
+ if (*str != 0) {
+ xmlCleanURI(uri);
+ return(1);
+ }
+ return(0);
+}
+
+/**
+ * xmlParse3986URIReference:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an URI reference string and fills in the appropriate fields
+ * of the @uri structure
+ *
+ * URI-reference = URI / relative-ref
+ *
+ * Returns 0 or the error code
+ */
+static int
+xmlParse3986URIReference(xmlURIPtr uri, const char *str) {
+ int ret;
+
+ if (str == NULL)
+ return(-1);
+ xmlCleanURI(uri);
+
+ /*
+ * Try first to parse absolute refs, then fallback to relative if
+ * it fails.
+ */
+ ret = xmlParse3986URI(uri, str);
+ if (ret != 0) {
+ xmlCleanURI(uri);
+ ret = xmlParse3986RelativeRef(uri, str);
+ if (ret != 0) {
+ xmlCleanURI(uri);
+ return(ret);
+ }
+ }
+ return(0);
+}
+
+/**
+ * xmlParseURI:
+ * @str: the URI string to analyze
+ *
+ * Parse an URI based on RFC 3986
+ *
+ * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
+ *
+ * Returns a newly built xmlURIPtr or NULL in case of error
+ */
+xmlURIPtr
+xmlParseURI(const char *str) {
+ xmlURIPtr uri;
+ int ret;
+
+ if (str == NULL)
+ return(NULL);
+ uri = xmlCreateURI();
+ if (uri != NULL) {
+ ret = xmlParse3986URIReference(uri, str);
+ if (ret) {
+ xmlFreeURI(uri);
+ return(NULL);
+ }
+ }
+ return(uri);
+}
+
+/**
+ * xmlParseURIReference:
+ * @uri: pointer to an URI structure
+ * @str: the string to analyze
+ *
+ * Parse an URI reference string based on RFC 3986 and fills in the
+ * appropriate fields of the @uri structure
+ *
+ * URI-reference = URI / relative-ref
+ *
+ * Returns 0 or the error code
+ */
+int
+xmlParseURIReference(xmlURIPtr uri, const char *str) {
+ return(xmlParse3986URIReference(uri, str));
+}
+
+/**
+ * xmlParseURIRaw:
+ * @str: the URI string to analyze
+ * @raw: if 1 unescaping of URI pieces are disabled
+ *
+ * Parse an URI but allows to keep intact the original fragments.
+ *
+ * URI-reference = URI / relative-ref
+ *
+ * Returns a newly built xmlURIPtr or NULL in case of error
+ */
+xmlURIPtr
+xmlParseURIRaw(const char *str, int raw) {
+ xmlURIPtr uri;
+ int ret;
+
+ if (str == NULL)
+ return(NULL);
+ uri = xmlCreateURI();
+ if (uri != NULL) {
+ if (raw) {
+ uri->cleanup |= 2;
+ }
+ ret = xmlParseURIReference(uri, str);
+ if (ret) {
+ xmlFreeURI(uri);
+ return(NULL);
+ }
+ }
+ return(uri);
+}
/************************************************************************
* *
@@ -206,8 +1013,7 @@ xmlCreateURI(void) {
ret = (xmlURIPtr) xmlMalloc(sizeof(xmlURI));
if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlCreateURI: out of memory\n");
+ xmlURIErrMemory("creating URI structure\n");
return(NULL);
}
memset(ret, 0, sizeof(xmlURI));
@@ -215,6 +1021,31 @@ xmlCreateURI(void) {
}
/**
+ * xmlSaveUriRealloc:
+ *
+ * Function to handle properly a reallocation when saving an URI
+ * Also imposes some limit on the length of an URI string output
+ */
+static xmlChar *
+xmlSaveUriRealloc(xmlChar *ret, int *max) {
+ xmlChar *temp;
+ int tmp;
+
+ if (*max > MAX_URI_LENGTH) {
+ xmlURIErrMemory("reaching arbitrary MAX_URI_LENGTH limit\n");
+ return(NULL);
+ }
+ tmp = *max * 2;
+ temp = (xmlChar *) xmlRealloc(ret, (tmp + 1));
+ if (temp == NULL) {
+ xmlURIErrMemory("saving URI\n");
+ return(NULL);
+ }
+ *max = tmp;
+ return(temp);
+}
+
+/**
* xmlSaveUri:
* @uri: pointer to an xmlURI
*
@@ -225,6 +1056,7 @@ xmlCreateURI(void) {
xmlChar *
xmlSaveUri(xmlURIPtr uri) {
xmlChar *ret = NULL;
+ xmlChar *temp;
const char *p;
int len;
int max;
@@ -235,8 +1067,7 @@ xmlSaveUri(xmlURIPtr uri) {
max = 80;
ret = (xmlChar *) xmlMallocAtomic((max + 1) * sizeof(xmlChar));
if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
+ xmlURIErrMemory("saving URI\n");
return(NULL);
}
len = 0;
@@ -245,24 +1076,16 @@ xmlSaveUri(xmlURIPtr uri) {
p = uri->scheme;
while (*p != 0) {
if (len >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
ret[len++] = *p++;
}
if (len >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
ret[len++] = ':';
}
@@ -270,13 +1093,9 @@ xmlSaveUri(xmlURIPtr uri) {
p = uri->opaque;
while (*p != 0) {
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
if (IS_RESERVED(*(p)) || IS_UNRESERVED(*(p)))
ret[len++] = *p++;
@@ -289,15 +1108,11 @@ xmlSaveUri(xmlURIPtr uri) {
}
}
} else {
- if (uri->server != NULL) {
+ if ((uri->server != NULL) || (uri->port == -1)) {
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
ret[len++] = '/';
ret[len++] = '/';
@@ -305,14 +1120,9 @@ xmlSaveUri(xmlURIPtr uri) {
p = uri->user;
while (*p != 0) {
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
if ((IS_UNRESERVED(*(p))) ||
((*(p) == ';')) || ((*(p) == ':')) ||
@@ -329,68 +1139,45 @@ xmlSaveUri(xmlURIPtr uri) {
}
}
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
ret[len++] = '@';
}
- p = uri->server;
- while (*p != 0) {
- if (len >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
+ if (uri->server != NULL) {
+ p = uri->server;
+ while (*p != 0) {
+ if (len >= max) {
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
+ ret[len++] = *p++;
}
- ret[len++] = *p++;
- }
- if (uri->port > 0) {
- if (len + 10 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
+ if (uri->port > 0) {
+ if (len + 10 >= max) {
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
+ len += snprintf((char *) &ret[len], max - len, ":%d", uri->port);
}
- len += snprintf((char *) &ret[len], max - len, ":%d", uri->port);
}
} else if (uri->authority != NULL) {
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
ret[len++] = '/';
ret[len++] = '/';
p = uri->authority;
while (*p != 0) {
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
if ((IS_UNRESERVED(*(p))) ||
((*(p) == '$')) || ((*(p) == ',')) || ((*(p) == ';')) ||
@@ -407,30 +1194,37 @@ xmlSaveUri(xmlURIPtr uri) {
}
} else if (uri->scheme != NULL) {
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
- ret[len++] = '/';
- ret[len++] = '/';
}
if (uri->path != NULL) {
p = uri->path;
+ /*
+ * the colon in file:///d: should not be escaped or
+ * Windows accesses fail later.
+ */
+ if ((uri->scheme != NULL) &&
+ (p[0] == '/') &&
+ (((p[1] >= 'a') && (p[1] <= 'z')) ||
+ ((p[1] >= 'A') && (p[1] <= 'Z'))) &&
+ (p[2] == ':') &&
+ (xmlStrEqual(BAD_CAST uri->scheme, BAD_CAST "file"))) {
+ if (len + 3 >= max) {
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
+ }
+ ret[len++] = *p++;
+ ret[len++] = *p++;
+ ret[len++] = *p++;
+ }
while (*p != 0) {
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
if ((IS_UNRESERVED(*(p))) || ((*(p) == '/')) ||
((*(p) == ';')) || ((*(p) == '@')) || ((*(p) == '&')) ||
@@ -446,31 +1240,37 @@ xmlSaveUri(xmlURIPtr uri) {
}
}
}
- if (uri->query != NULL) {
- if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
+ if (uri->query_raw != NULL) {
+ if (len + 1 >= max) {
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
+ }
+ ret[len++] = '?';
+ p = uri->query_raw;
+ while (*p != 0) {
+ if (len + 1 >= max) {
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
+ ret[len++] = *p++;
+ }
+ } else if (uri->query != NULL) {
+ if (len + 3 >= max) {
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
ret[len++] = '?';
p = uri->query;
while (*p != 0) {
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
- if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
+ if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
ret[len++] = *p++;
else {
int val = *(unsigned char *)p++;
@@ -484,29 +1284,19 @@ xmlSaveUri(xmlURIPtr uri) {
}
if (uri->fragment != NULL) {
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
ret[len++] = '#';
p = uri->fragment;
while (*p != 0) {
if (len + 3 >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret,
- (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
- if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
+ if ((IS_UNRESERVED(*(p))) || (IS_RESERVED(*(p))))
ret[len++] = *p++;
else {
int val = *(unsigned char *)p++;
@@ -518,16 +1308,16 @@ xmlSaveUri(xmlURIPtr uri) {
}
}
if (len >= max) {
- max *= 2;
- ret = (xmlChar *) xmlRealloc(ret, (max + 1) * sizeof(xmlChar));
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlSaveUri: out of memory\n");
- return(NULL);
- }
+ temp = xmlSaveUriRealloc(ret, &max);
+ if (temp == NULL) goto mem_error;
+ ret = temp;
}
- ret[len++] = 0;
+ ret[len] = 0;
return(ret);
+
+mem_error:
+ xmlFree(ret);
+ return(NULL);
}
/**
@@ -574,6 +1364,8 @@ xmlCleanURI(xmlURIPtr uri) {
uri->authority = NULL;
if (uri->query != NULL) xmlFree(uri->query);
uri->query = NULL;
+ if (uri->query_raw != NULL) xmlFree(uri->query_raw);
+ uri->query_raw = NULL;
}
/**
@@ -594,6 +1386,7 @@ xmlFreeURI(xmlURIPtr uri) {
if (uri->opaque != NULL) xmlFree(uri->opaque);
if (uri->authority != NULL) xmlFree(uri->authority);
if (uri->query != NULL) xmlFree(uri->query);
+ if (uri->query_raw != NULL) xmlFree(uri->query_raw);
xmlFree(uri);
}
@@ -738,10 +1531,11 @@ xmlNormalizeURIPath(char *path) {
break;
}
/* Valgrind complained, strcpy(cur, segp + 3); */
- /* string will overlap, do not use strcpy */
- tmp = cur;
- segp += 3;
- while ((*tmp++ = *segp++) != 0);
+ /* string will overlap, do not use strcpy */
+ tmp = cur;
+ segp += 3;
+ while ((*tmp++ = *segp++) != 0)
+ ;
/* If there are no previous segments, then keep going from here. */
segp = cur;
@@ -805,10 +1599,13 @@ static int is_hex(char c) {
* @len: the length in bytes to unescape (or <= 0 to indicate full string)
* @target: optional destination buffer
*
- * Unescaping routine, does not do validity checks !
- * Output is direct unsigned char translation of %XX values (no encoding)
+ * Unescaping routine, but does not check that the string is an URI. The
+ * output is a direct unsigned char translation of %XX values (no encoding)
+ * Note that the length of the result can only be smaller or same size as
+ * the input string.
*
- * Returns an copy of the string, but unescaped
+ * Returns a copy of the string, but unescaped, will return NULL only in case
+ * of error
*/
char *
xmlURIUnescapeString(const char *str, int len, char *target) {
@@ -823,8 +1620,7 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
if (target == NULL) {
ret = (char *) xmlMallocAtomic(len + 1);
if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlURIUnescapeString: out of memory\n");
+ xmlURIErrMemory("unescaping URI value\n");
return(NULL);
}
} else
@@ -834,14 +1630,14 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
while(len > 0) {
if ((len > 2) && (*in == '%') && (is_hex(in[1])) && (is_hex(in[2]))) {
in++;
- if ((*in >= '0') && (*in <= '9'))
+ if ((*in >= '0') && (*in <= '9'))
*out = (*in - '0');
else if ((*in >= 'a') && (*in <= 'f'))
*out = (*in - 'a') + 10;
else if ((*in >= 'A') && (*in <= 'F'))
*out = (*in - 'A') + 10;
in++;
- if ((*in >= '0') && (*in <= '9'))
+ if ((*in >= '0') && (*in <= '9'))
*out = *out * 16 + (*in - '0');
else if ((*in >= 'a') && (*in <= 'f'))
*out = *out * 16 + (*in - 'a') + 10;
@@ -872,9 +1668,9 @@ xmlURIUnescapeString(const char *str, int len, char *target) {
xmlChar *
xmlURIEscapeStr(const xmlChar *str, const xmlChar *list) {
xmlChar *ret, ch;
+ xmlChar *temp;
const xmlChar *in;
-
- unsigned int len, out;
+ int len, out;
if (str == NULL)
return(NULL);
@@ -886,21 +1682,20 @@ xmlURIEscapeStr(const xmlChar *str, const xmlChar *list) {
len += 20;
ret = (xmlChar *) xmlMallocAtomic(len);
if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlURIEscapeStr: out of memory\n");
+ xmlURIErrMemory("escaping URI value\n");
return(NULL);
}
in = (const xmlChar *) str;
out = 0;
while(*in != 0) {
if (len - out <= 3) {
- len += 20;
- ret = (xmlChar *) xmlRealloc(ret, len);
- if (ret == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlURIEscapeStr: out of memory\n");
+ temp = xmlSaveUriRealloc(ret, &len);
+ if (temp == NULL) {
+ xmlURIErrMemory("escaping URI value\n");
+ xmlFree(ret);
return(NULL);
}
+ ret = temp;
}
ch = *in;
@@ -951,9 +1746,9 @@ xmlURIEscape(const xmlChar * str)
int ret2;
#define NULLCHK(p) if(!p) { \
- xmlGenericError(xmlGenericErrorContext, \
- "xmlURIEscape: out of memory\n"); \
- return NULL; }
+ xmlURIErrMemory("escaping URI value\n"); \
+ xmlFreeURI(uri); \
+ return NULL; } \
if (str == NULL)
return (NULL);
@@ -996,7 +1791,7 @@ xmlURIEscape(const xmlChar * str)
if (uri->user) {
segment = xmlURIEscapeStr(BAD_CAST uri->user, BAD_CAST ";:&=+$,");
NULLCHK(segment)
- ret = xmlStrcat(ret,BAD_CAST "//");
+ ret = xmlStrcat(ret,BAD_CAST "//");
ret = xmlStrcat(ret, segment);
ret = xmlStrcat(ret, BAD_CAST "@");
xmlFree(segment);
@@ -1006,7 +1801,7 @@ xmlURIEscape(const xmlChar * str)
segment = xmlURIEscapeStr(BAD_CAST uri->server, BAD_CAST "/?;:@");
NULLCHK(segment)
if (uri->user == NULL)
- ret = xmlStrcat(ret, BAD_CAST "//");
+ ret = xmlStrcat(ret, BAD_CAST "//");
ret = xmlStrcat(ret, segment);
xmlFree(segment);
}
@@ -1027,7 +1822,11 @@ xmlURIEscape(const xmlChar * str)
xmlFree(segment);
}
- if (uri->query) {
+ if (uri->query_raw) {
+ ret = xmlStrcat(ret, BAD_CAST "?");
+ ret = xmlStrcat(ret, BAD_CAST uri->query_raw);
+ }
+ else if (uri->query) {
segment =
xmlURIEscapeStr(BAD_CAST uri->query, BAD_CAST ";/?:@&=+,$");
NULLCHK(segment)
@@ -1059,780 +1858,6 @@ xmlURIEscape(const xmlChar * str)
/************************************************************************
* *
- * Escaped URI parsing *
- * *
- ************************************************************************/
-
-/**
- * xmlParseURIFragment:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- *
- * Parse an URI fragment string and fills in the appropriate fields
- * of the @uri structure.
- *
- * fragment = *uric
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseURIFragment(xmlURIPtr uri, const char **str)
-{
- const char *cur;
-
- if (str == NULL)
- return (-1);
-
- cur = *str;
-
- while (IS_URIC(cur) || IS_UNWISE(cur))
- NEXT(cur);
- if (uri != NULL) {
- if (uri->fragment != NULL)
- xmlFree(uri->fragment);
- if (uri->cleanup & 2)
- uri->fragment = STRNDUP(*str, cur - *str);
- else
- uri->fragment = xmlURIUnescapeString(*str, cur - *str, NULL);
- }
- *str = cur;
- return (0);
-}
-
-/**
- * xmlParseURIQuery:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- *
- * Parse the query part of an URI
- *
- * query = *uric
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseURIQuery(xmlURIPtr uri, const char **str)
-{
- const char *cur;
-
- if (str == NULL)
- return (-1);
-
- cur = *str;
-
- while ((IS_URIC(cur)) ||
- ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
- NEXT(cur);
- if (uri != NULL) {
- if (uri->query != NULL)
- xmlFree(uri->query);
- if (uri->cleanup & 2)
- uri->query = STRNDUP(*str, cur - *str);
- else
- uri->query = xmlURIUnescapeString(*str, cur - *str, NULL);
- }
- *str = cur;
- return (0);
-}
-
-/**
- * xmlParseURIScheme:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- *
- * Parse an URI scheme
- *
- * scheme = alpha *( alpha | digit | "+" | "-" | "." )
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseURIScheme(xmlURIPtr uri, const char **str) {
- const char *cur;
-
- if (str == NULL)
- return(-1);
-
- cur = *str;
- if (!IS_ALPHA(*cur))
- return(2);
- cur++;
- while (IS_SCHEME(*cur)) cur++;
- if (uri != NULL) {
- if (uri->scheme != NULL) xmlFree(uri->scheme);
- uri->scheme = STRNDUP(*str, cur - *str);
- }
- *str = cur;
- return(0);
-}
-
-/**
- * xmlParseURIOpaquePart:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- *
- * Parse an URI opaque part
- *
- * opaque_part = uric_no_slash *uric
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseURIOpaquePart(xmlURIPtr uri, const char **str)
-{
- const char *cur;
-
- if (str == NULL)
- return (-1);
-
- cur = *str;
- if (!((IS_URIC_NO_SLASH(cur)) ||
- ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))) {
- return (3);
- }
- NEXT(cur);
- while ((IS_URIC(cur)) ||
- ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
- NEXT(cur);
- if (uri != NULL) {
- if (uri->opaque != NULL)
- xmlFree(uri->opaque);
- if (uri->cleanup & 2)
- uri->opaque = STRNDUP(*str, cur - *str);
- else
- uri->opaque = xmlURIUnescapeString(*str, cur - *str, NULL);
- }
- *str = cur;
- return (0);
-}
-
-/**
- * xmlParseURIServer:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- *
- * Parse a server subpart of an URI, it's a finer grain analysis
- * of the authority part.
- *
- * server = [ [ userinfo "@" ] hostport ]
- * userinfo = *( unreserved | escaped |
- * ";" | ":" | "&" | "=" | "+" | "$" | "," )
- * hostport = host [ ":" port ]
- * host = hostname | IPv4address | IPv6reference
- * hostname = *( domainlabel "." ) toplabel [ "." ]
- * domainlabel = alphanum | alphanum *( alphanum | "-" ) alphanum
- * toplabel = alpha | alpha *( alphanum | "-" ) alphanum
- * IPv6reference = "[" IPv6address "]"
- * IPv6address = hexpart [ ":" IPv4address ]
- * IPv4address = 1*3digit "." 1*3digit "." 1*3digit "." 1*3digit
- * hexpart = hexseq | hexseq "::" [ hexseq ]| "::" [ hexseq ]
- * hexseq = hex4 *( ":" hex4)
- * hex4 = 1*4hexdig
- * port = *digit
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseURIServer(xmlURIPtr uri, const char **str) {
- const char *cur;
- const char *host, *tmp;
- const int IPV4max = 4;
- const int IPV6max = 8;
- int oct;
-
- if (str == NULL)
- return(-1);
-
- cur = *str;
-
- /*
- * is there a userinfo ?
- */
- while (IS_USERINFO(cur)) NEXT(cur);
- if (*cur == '@') {
- if (uri != NULL) {
- if (uri->user != NULL) xmlFree(uri->user);
- if (uri->cleanup & 2)
- uri->path = STRNDUP(*str, cur - *str);
- else
- uri->user = xmlURIUnescapeString(*str, cur - *str, NULL);
- }
- cur++;
- } else {
- if (uri != NULL) {
- if (uri->user != NULL) xmlFree(uri->user);
- uri->user = NULL;
- }
- cur = *str;
- }
- /*
- * This can be empty in the case where there is no server
- */
- host = cur;
- if (*cur == '/') {
- if (uri != NULL) {
- if (uri->authority != NULL) xmlFree(uri->authority);
- uri->authority = NULL;
- if (uri->server != NULL) xmlFree(uri->server);
- uri->server = NULL;
- uri->port = 0;
- }
- return(0);
- }
- /*
- * host part of hostport can denote an IPV4 address, an IPV6 address
- * or an unresolved name. Check the IP first, its easier to detect
- * errors if wrong one.
- * An IPV6 address must start with a '[' and end with a ']'.
- */
- if (*cur == '[') {
- int compress=0;
- cur++;
- for (oct = 0; oct < IPV6max; ++oct) {
- if (*cur == ':') {
- if (compress)
- return(3); /* multiple compression attempted */
- if (!oct) { /* initial char is compression */
- if (*++cur != ':')
- return(3);
- }
- compress = 1; /* set compression-encountered flag */
- cur++; /* skip over the second ':' */
- continue;
- }
- while(IS_HEX(*cur)) cur++;
- if (oct == (IPV6max-1))
- continue;
- if (*cur != ':')
- break;
- cur++;
- }
- if ((!compress) && (oct != IPV6max))
- return(3);
- if (*cur != ']')
- return(3);
- if (uri != NULL) {
- if (uri->server != NULL) xmlFree(uri->server);
- uri->server = (char *)xmlStrndup((xmlChar *)host+1,
- (cur-host)-1);
- }
- cur++;
- } else {
- /*
- * Not IPV6, maybe IPV4
- */
- for (oct = 0; oct < IPV4max; ++oct) {
- if (*cur == '.')
- return(3); /* e.g. http://.xml/ or http://18.29..30/ */
- while(IS_DIGIT(*cur)) cur++;
- if (oct == (IPV4max-1))
- continue;
- if (*cur != '.')
- break;
- cur++;
- }
- }
- if ((host[0] != '[') && (oct < IPV4max || (*cur == '.' && cur++) ||
- IS_ALPHA(*cur))) {
- /* maybe host_name */
- if (!IS_ALPHANUM(*cur))
- return(4); /* e.g. http://xml.$oft */
- do {
- do ++cur; while (IS_ALPHANUM(*cur));
- if (*cur == '-') {
- --cur;
- if (*cur == '.')
- return(5); /* e.g. http://xml.-soft */
- ++cur;
- continue;
- }
- if (*cur == '.') {
- --cur;
- if (*cur == '-')
- return(6); /* e.g. http://xml-.soft */
- if (*cur == '.')
- return(7); /* e.g. http://xml..soft */
- ++cur;
- continue;
- }
- break;
- } while (1);
- tmp = cur;
- if (tmp[-1] == '.')
- --tmp; /* e.g. http://xml.$Oft/ */
- do --tmp; while (tmp >= host && IS_ALPHANUM(*tmp));
- if ((++tmp == host || tmp[-1] == '.') && !IS_ALPHA(*tmp))
- return(8); /* e.g. http://xmlsOft.0rg/ */
- }
- if (uri != NULL) {
- if (uri->authority != NULL) xmlFree(uri->authority);
- uri->authority = NULL;
- if (host[0] != '[') { /* it's not an IPV6 addr */
- if (uri->server != NULL) xmlFree(uri->server);
- if (uri->cleanup & 2)
- uri->server = STRNDUP(host, cur - host);
- else
- uri->server = xmlURIUnescapeString(host, cur - host, NULL);
- }
- }
- /*
- * finish by checking for a port presence.
- */
- if (*cur == ':') {
- cur++;
- if (IS_DIGIT(*cur)) {
- if (uri != NULL)
- uri->port = 0;
- while (IS_DIGIT(*cur)) {
- if (uri != NULL)
- uri->port = uri->port * 10 + (*cur - '0');
- cur++;
- }
- }
- }
- *str = cur;
- return(0);
-}
-
-/**
- * xmlParseURIRelSegment:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- *
- * Parse an URI relative segment
- *
- * rel_segment = 1*( unreserved | escaped | ";" | "@" | "&" | "=" |
- * "+" | "$" | "," )
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseURIRelSegment(xmlURIPtr uri, const char **str)
-{
- const char *cur;
-
- if (str == NULL)
- return (-1);
-
- cur = *str;
- if (!((IS_SEGMENT(cur)) ||
- ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))) {
- return (3);
- }
- NEXT(cur);
- while ((IS_SEGMENT(cur)) ||
- ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
- NEXT(cur);
- if (uri != NULL) {
- if (uri->path != NULL)
- xmlFree(uri->path);
- if (uri->cleanup & 2)
- uri->path = STRNDUP(*str, cur - *str);
- else
- uri->path = xmlURIUnescapeString(*str, cur - *str, NULL);
- }
- *str = cur;
- return (0);
-}
-
-/**
- * xmlParseURIPathSegments:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- * @slash: should we add a leading slash
- *
- * Parse an URI set of path segments
- *
- * path_segments = segment *( "/" segment )
- * segment = *pchar *( ";" param )
- * param = *pchar
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseURIPathSegments(xmlURIPtr uri, const char **str, int slash)
-{
- const char *cur;
-
- if (str == NULL)
- return (-1);
-
- cur = *str;
-
- do {
- while ((IS_PCHAR(cur)) ||
- ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
- NEXT(cur);
- while (*cur == ';') {
- cur++;
- while ((IS_PCHAR(cur)) ||
- ((uri != NULL) && (uri->cleanup & 1) && (IS_UNWISE(cur))))
- NEXT(cur);
- }
- if (*cur != '/')
- break;
- cur++;
- } while (1);
- if (uri != NULL) {
- int len, len2 = 0;
- char *path;
-
- /*
- * Concat the set of path segments to the current path
- */
- len = cur - *str;
- if (slash)
- len++;
-
- if (uri->path != NULL) {
- len2 = strlen(uri->path);
- len += len2;
- }
- path = (char *) xmlMallocAtomic(len + 1);
- if (path == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlParseURIPathSegments: out of memory\n");
- *str = cur;
- return (-1);
- }
- if (uri->path != NULL)
- memcpy(path, uri->path, len2);
- if (slash) {
- path[len2] = '/';
- len2++;
- }
- path[len2] = 0;
- if (cur - *str > 0) {
- if (uri->cleanup & 2) {
- memcpy(&path[len2], *str, cur - *str);
- path[len2 + (cur - *str)] = 0;
- } else
- xmlURIUnescapeString(*str, cur - *str, &path[len2]);
- }
- if (uri->path != NULL)
- xmlFree(uri->path);
- uri->path = path;
- }
- *str = cur;
- return (0);
-}
-
-/**
- * xmlParseURIAuthority:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- *
- * Parse the authority part of an URI.
- *
- * authority = server | reg_name
- * server = [ [ userinfo "@" ] hostport ]
- * reg_name = 1*( unreserved | escaped | "$" | "," | ";" | ":" |
- * "@" | "&" | "=" | "+" )
- *
- * Note : this is completely ambiguous since reg_name is allowed to
- * use the full set of chars in use by server:
- *
- * 3.2.1. Registry-based Naming Authority
- *
- * The structure of a registry-based naming authority is specific
- * to the URI scheme, but constrained to the allowed characters
- * for an authority component.
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseURIAuthority(xmlURIPtr uri, const char **str) {
- const char *cur;
- int ret;
-
- if (str == NULL)
- return(-1);
-
- cur = *str;
-
- /*
- * try first to parse it as a server string.
- */
- ret = xmlParseURIServer(uri, str);
- if ((ret == 0) && (*str != NULL) &&
- ((**str == 0) || (**str == '/') || (**str == '?')))
- return(0);
- *str = cur;
-
- /*
- * failed, fallback to reg_name
- */
- if (!IS_REG_NAME(cur)) {
- return(5);
- }
- NEXT(cur);
- while (IS_REG_NAME(cur)) NEXT(cur);
- if (uri != NULL) {
- if (uri->server != NULL) xmlFree(uri->server);
- uri->server = NULL;
- if (uri->user != NULL) xmlFree(uri->user);
- uri->user = NULL;
- if (uri->authority != NULL) xmlFree(uri->authority);
- if (uri->cleanup & 2)
- uri->authority = STRNDUP(*str, cur - *str);
- else
- uri->authority = xmlURIUnescapeString(*str, cur - *str, NULL);
- }
- *str = cur;
- return(0);
-}
-
-/**
- * xmlParseURIHierPart:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- *
- * Parse an URI hierarchical part
- *
- * hier_part = ( net_path | abs_path ) [ "?" query ]
- * abs_path = "/" path_segments
- * net_path = "//" authority [ abs_path ]
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseURIHierPart(xmlURIPtr uri, const char **str) {
- int ret;
- const char *cur;
-
- if (str == NULL)
- return(-1);
-
- cur = *str;
-
- if ((cur[0] == '/') && (cur[1] == '/')) {
- cur += 2;
- ret = xmlParseURIAuthority(uri, &cur);
- if (ret != 0)
- return(ret);
- if (cur[0] == '/') {
- cur++;
- ret = xmlParseURIPathSegments(uri, &cur, 1);
- }
- } else if (cur[0] == '/') {
- cur++;
- ret = xmlParseURIPathSegments(uri, &cur, 1);
- } else {
- return(4);
- }
- if (ret != 0)
- return(ret);
- if (*cur == '?') {
- cur++;
- ret = xmlParseURIQuery(uri, &cur);
- if (ret != 0)
- return(ret);
- }
- *str = cur;
- return(0);
-}
-
-/**
- * xmlParseAbsoluteURI:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- *
- * Parse an URI reference string and fills in the appropriate fields
- * of the @uri structure
- *
- * absoluteURI = scheme ":" ( hier_part | opaque_part )
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseAbsoluteURI(xmlURIPtr uri, const char **str) {
- int ret;
- const char *cur;
-
- if (str == NULL)
- return(-1);
-
- cur = *str;
-
- ret = xmlParseURIScheme(uri, str);
- if (ret != 0) return(ret);
- if (**str != ':') {
- *str = cur;
- return(1);
- }
- (*str)++;
- if (**str == '/')
- return(xmlParseURIHierPart(uri, str));
- return(xmlParseURIOpaquePart(uri, str));
-}
-
-/**
- * xmlParseRelativeURI:
- * @uri: pointer to an URI structure
- * @str: pointer to the string to analyze
- *
- * Parse an relative URI string and fills in the appropriate fields
- * of the @uri structure
- *
- * relativeURI = ( net_path | abs_path | rel_path ) [ "?" query ]
- * abs_path = "/" path_segments
- * net_path = "//" authority [ abs_path ]
- * rel_path = rel_segment [ abs_path ]
- *
- * Returns 0 or the error code
- */
-static int
-xmlParseRelativeURI(xmlURIPtr uri, const char **str) {
- int ret = 0;
- const char *cur;
-
- if (str == NULL)
- return(-1);
-
- cur = *str;
- if ((cur[0] == '/') && (cur[1] == '/')) {
- cur += 2;
- ret = xmlParseURIAuthority(uri, &cur);
- if (ret != 0)
- return(ret);
- if (cur[0] == '/') {
- cur++;
- ret = xmlParseURIPathSegments(uri, &cur, 1);
- }
- } else if (cur[0] == '/') {
- cur++;
- ret = xmlParseURIPathSegments(uri, &cur, 1);
- } else if (cur[0] != '#' && cur[0] != '?') {
- ret = xmlParseURIRelSegment(uri, &cur);
- if (ret != 0)
- return(ret);
- if (cur[0] == '/') {
- cur++;
- ret = xmlParseURIPathSegments(uri, &cur, 1);
- }
- }
- if (ret != 0)
- return(ret);
- if (*cur == '?') {
- cur++;
- ret = xmlParseURIQuery(uri, &cur);
- if (ret != 0)
- return(ret);
- }
- *str = cur;
- return(ret);
-}
-
-/**
- * xmlParseURIReference:
- * @uri: pointer to an URI structure
- * @str: the string to analyze
- *
- * Parse an URI reference string and fills in the appropriate fields
- * of the @uri structure
- *
- * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
- *
- * Returns 0 or the error code
- */
-int
-xmlParseURIReference(xmlURIPtr uri, const char *str) {
- int ret;
- const char *tmp = str;
-
- if (str == NULL)
- return(-1);
- xmlCleanURI(uri);
-
- /*
- * Try first to parse absolute refs, then fallback to relative if
- * it fails.
- */
- ret = xmlParseAbsoluteURI(uri, &str);
- if (ret != 0) {
- xmlCleanURI(uri);
- str = tmp;
- ret = xmlParseRelativeURI(uri, &str);
- }
- if (ret != 0) {
- xmlCleanURI(uri);
- return(ret);
- }
-
- if (*str == '#') {
- str++;
- ret = xmlParseURIFragment(uri, &str);
- if (ret != 0) return(ret);
- }
- if (*str != 0) {
- xmlCleanURI(uri);
- return(1);
- }
- return(0);
-}
-
-/**
- * xmlParseURI:
- * @str: the URI string to analyze
- *
- * Parse an URI
- *
- * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
- *
- * Returns a newly built xmlURIPtr or NULL in case of error
- */
-xmlURIPtr
-xmlParseURI(const char *str) {
- xmlURIPtr uri;
- int ret;
-
- if (str == NULL)
- return(NULL);
- uri = xmlCreateURI();
- if (uri != NULL) {
- ret = xmlParseURIReference(uri, str);
- if (ret) {
- xmlFreeURI(uri);
- return(NULL);
- }
- }
- return(uri);
-}
-
-/**
- * xmlParseURIRaw:
- * @str: the URI string to analyze
- * @raw: if 1 unescaping of URI pieces are disabled
- *
- * Parse an URI but allows to keep intact the original fragments.
- *
- * URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
- *
- * Returns a newly built xmlURIPtr or NULL in case of error
- */
-xmlURIPtr
-xmlParseURIRaw(const char *str, int raw) {
- xmlURIPtr uri;
- int ret;
-
- if (str == NULL)
- return(NULL);
- uri = xmlCreateURI();
- if (uri != NULL) {
- if (raw) {
- uri->cleanup |= 2;
- }
- ret = xmlParseURIReference(uri, str);
- if (ret) {
- xmlFreeURI(uri);
- return(NULL);
- }
- }
- return(uri);
-}
-
-/************************************************************************
- * *
* Public functions *
* *
************************************************************************/
@@ -1844,7 +1869,7 @@ xmlParseURIRaw(const char *str, int raw) {
*
* 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
+ * base URI. This is processed according to section 5.2 of the
* RFC 2396
*
* 5.2. Resolving Relative References to Absolute Form
@@ -1868,7 +1893,7 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
* as a reference to "." rather than as a synonym for the current
* URI. Should we do that here?
*/
- if (URI == NULL)
+ if (URI == NULL)
ret = -1;
else {
if (*URI) {
@@ -1939,12 +1964,16 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
res->server = xmlMemStrdup(bas->server);
if (bas->user != NULL)
res->user = xmlMemStrdup(bas->user);
- res->port = bas->port;
+ res->port = bas->port;
}
if (bas->path != NULL)
res->path = xmlMemStrdup(bas->path);
- if (ref->query != NULL)
+ if (ref->query_raw != NULL)
+ res->query_raw = xmlMemStrdup (ref->query_raw);
+ else if (ref->query != NULL)
res->query = xmlMemStrdup(ref->query);
+ else if (bas->query_raw != NULL)
+ res->query_raw = xmlMemStrdup(bas->query_raw);
else if (bas->query != NULL)
res->query = xmlMemStrdup(bas->query);
if (ref->fragment != NULL)
@@ -1964,8 +1993,10 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
}
if (bas->scheme != NULL)
res->scheme = xmlMemStrdup(bas->scheme);
-
- if (ref->query != NULL)
+
+ if (ref->query_raw != NULL)
+ res->query_raw = xmlMemStrdup(ref->query_raw);
+ else if (ref->query != NULL)
res->query = xmlMemStrdup(ref->query);
if (ref->fragment != NULL)
res->fragment = xmlMemStrdup(ref->fragment);
@@ -1984,7 +2015,7 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
res->server = xmlMemStrdup(ref->server);
if (ref->user != NULL)
res->user = xmlMemStrdup(ref->user);
- res->port = ref->port;
+ res->port = ref->port;
}
if (ref->path != NULL)
res->path = xmlMemStrdup(ref->path);
@@ -1996,7 +2027,7 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
res->server = xmlMemStrdup(bas->server);
if (bas->user != NULL)
res->user = xmlMemStrdup(bas->user);
- res->port = bas->port;
+ res->port = bas->port;
}
/*
@@ -2024,8 +2055,7 @@ xmlBuildURI(const xmlChar *URI, const xmlChar *base) {
len += strlen(bas->path);
res->path = (char *) xmlMallocAtomic(len);
if (res->path == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlBuildURI: out of memory\n");
+ xmlURIErrMemory("resolving URI against base\n");
goto done;
}
res->path[0] = 0;
@@ -2209,7 +2239,8 @@ xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
uptr = (xmlChar *) ref->path;
if (*uptr == '/')
uptr++;
- val = xmlStrdup(uptr);
+ /* exception characters from xmlSaveUri */
+ val = xmlURIEscapeStr(uptr, BAD_CAST "/;&=+$,");
}
goto done;
}
@@ -2270,10 +2301,11 @@ xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
}
len = xmlStrlen (uptr) + 1;
}
-
+
if (nbslash == 0) {
if (uptr != NULL)
- val = xmlStrdup (uptr);
+ /* exception characters from xmlSaveUri */
+ val = xmlURIEscapeStr(uptr, BAD_CAST "/;&=+$,");
goto done;
}
@@ -2284,8 +2316,7 @@ xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
*/
val = (xmlChar *) xmlMalloc (len + 3 * nbslash);
if (val == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlBuildRelativeURI: out of memory\n");
+ xmlURIErrMemory("building relative URI\n");
goto done;
}
vptr = val;
@@ -2313,6 +2344,12 @@ xmlBuildRelativeURI (const xmlChar * URI, const xmlChar * base)
vptr[len - 1] = 0;
}
+ /* escape the freshly-built path */
+ vptr = val;
+ /* exception characters from xmlSaveUri */
+ val = xmlURIEscapeStr(vptr, BAD_CAST "/;&=+$,");
+ xmlFree(vptr);
+
done:
/*
* Free the working variables
@@ -2331,14 +2368,14 @@ done:
* xmlCanonicPath:
* @path: the resource locator in a filesystem notation
*
- * Constructs a canonic path from the specified path.
+ * Constructs a canonic path from the specified path.
*
- * Returns a new canonic path, or a duplicate of the path parameter if the
+ * 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
+ * by the returned string. If there is insufficient memory available, or the
* argument is NULL, the function returns NULL.
*/
-#define IS_WINDOWS_PATH(p) \
+#define IS_WINDOWS_PATH(p) \
((p != NULL) && \
(((p[0] >= 'a') && (p[0] <= 'z')) || \
((p[0] >= 'A') && (p[0] <= 'Z'))) && \
@@ -2346,7 +2383,11 @@ done:
xmlChar *
xmlCanonicPath(const xmlChar *path)
{
-#if defined(_WIN32) && !defined(__CYGWIN__)
+/*
+ * For Windows implementations, additional work needs to be done to
+ * replace backslashes in pathnames with "forward slashes"
+ */
+#if defined(_WIN32) && !defined(__CYGWIN__)
int len = 0;
int i = 0;
xmlChar *p = NULL;
@@ -2357,11 +2398,30 @@ xmlCanonicPath(const xmlChar *path)
if (path == NULL)
return(NULL);
+
+#if defined(_WIN32)
+ /*
+ * We must not change the backslashes to slashes if the the path
+ * starts with \\?\
+ * Those paths can be up to 32k characters long.
+ * Was added specifically for OpenOffice, those paths can't be converted
+ * to URIs anyway.
+ */
+ if ((path[0] == '\\') && (path[1] == '\\') && (path[2] == '?') &&
+ (path[3] == '\\') )
+ return xmlStrdup((const xmlChar *) path);
+#endif
+
+ /* sanitize filename starting with // so it can be used as URI */
+ if ((path[0] == '/') && (path[1] == '/') && (path[2] != '/'))
+ path++;
+
if ((uri = xmlParseURI((const char *) path)) != NULL) {
xmlFreeURI(uri);
return xmlStrdup(path);
}
+ /* Check if this is an "absolute uri" */
absuri = xmlStrstr(path, BAD_CAST "://");
if (absuri != NULL) {
int l, j;
@@ -2370,47 +2430,55 @@ xmlCanonicPath(const xmlChar *path)
/*
* this looks like an URI where some parts have not been
- * escaped leading to a parsing problem check that the first
+ * escaped leading to a parsing problem. Check that the first
* part matches a protocol.
*/
l = absuri - path;
+ /* Bypass if first part (part before the '://') is > 20 chars */
if ((l <= 0) || (l > 20))
goto path_processing;
+ /* Bypass if any non-alpha characters are present in first part */
for (j = 0;j < l;j++) {
c = path[j];
if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'))))
goto path_processing;
}
+ /* Escape all except the characters specified in the supplied path */
escURI = xmlURIEscapeStr(path, BAD_CAST ":/?_.#&;=");
if (escURI != NULL) {
+ /* Try parsing the escaped path */
uri = xmlParseURI((const char *) escURI);
+ /* If successful, return the escaped string */
if (uri != NULL) {
xmlFreeURI(uri);
return escURI;
}
- xmlFreeURI(uri);
}
}
path_processing:
-#if defined(_WIN32) && !defined(__CYGWIN__)
+/* For Windows implementations, replace backslashes with 'forward slashes' */
+#if defined(_WIN32) && !defined(__CYGWIN__)
/*
- * This really need to be cleaned up by someone with a Windows box
+ * Create a URI structure
*/
uri = xmlCreateURI();
- if (uri == NULL) {
+ if (uri == NULL) { /* Guard against 'out of memory' */
return(NULL);
}
len = xmlStrlen(path);
if ((len > 2) && IS_WINDOWS_PATH(path)) {
+ /* make the scheme 'file' */
uri->scheme = xmlStrdup(BAD_CAST "file");
+ /* allocate space for leading '/' + path + string terminator */
uri->path = xmlMallocAtomic(len + 2);
if (uri->path == NULL) {
- xmlFreeURI(uri);
+ xmlFreeURI(uri); /* Guard agains 'out of memory' */
return(NULL);
}
+ /* Put in leading '/' plus path */
uri->path[0] = '/';
p = uri->path + 1;
strncpy(p, path, len + 1);
@@ -2422,18 +2490,15 @@ path_processing:
}
p = uri->path;
}
+ /* Now change all occurences of '\' to '/' */
while (*p != '\0') {
if (*p == '\\')
*p = '/';
p++;
}
- if (uri->path == NULL) {
- xmlFreeURI(uri);
- return(NULL);
- }
if (uri->scheme == NULL) {
- ret = xmlStrdup((const xmlChar *) path);
+ ret = xmlStrdup((const xmlChar *) uri->path);
} else {
ret = xmlSaveUri(uri);
}
@@ -2451,7 +2516,7 @@ path_processing:
*
* Constructs an URI expressing the existing path
*
- * Returns a new URI, or a duplicate of the path parameter if the
+ * Returns a new URI, 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.
@@ -2473,6 +2538,24 @@ xmlPathToURI(const xmlChar *path)
cal = xmlCanonicPath(path);
if (cal == NULL)
return(NULL);
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /* xmlCanonicPath can return an URI on Windows (is that the intended behaviour?)
+ If 'cal' is a valid URI allready then we are done here, as continuing would make
+ it invalid. */
+ if ((uri = xmlParseURI((const char *) cal)) != NULL) {
+ xmlFreeURI(uri);
+ return cal;
+ }
+ /* 'cal' can contain a relative path with backslashes. If that is processed
+ by xmlSaveURI, they will be escaped and the external entity loader machinery
+ will fail. So convert them to slashes. Misuse 'ret' for walking. */
+ ret = cal;
+ while (*ret != '\0') {
+ if (*ret == '\\')
+ *ret = '/';
+ ret++;
+ }
+#endif
memset(&temp, 0, sizeof(temp));
temp.path = (char *) cal;
ret = xmlSaveUri(&temp);
diff --git a/gnulib-local/lib/libxml/uri.in.h b/gnulib-local/lib/libxml/uri.in.h
index 5e29671..db48262 100644
--- a/gnulib-local/lib/libxml/uri.in.h
+++ b/gnulib-local/lib/libxml/uri.in.h
@@ -23,6 +23,10 @@ extern "C" {
*
* A parsed URI reference. This is a struct containing the various fields
* as described in RFC 2396 but separated for further processing.
+ *
+ * Note: query is a deprecated field which is incorrectly unescaped.
+ * query_raw takes precedence over query if the former is set.
+ * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00127
*/
typedef struct _xmlURI xmlURI;
typedef xmlURI *xmlURIPtr;
@@ -34,9 +38,10 @@ struct _xmlURI {
char *user; /* the user part */
int port; /* the port number */
char *path; /* the path string */
- char *query; /* the query string */
+ char *query; /* the query string (deprecated - use with caution) */
char *fragment; /* the fragment identifier */
int cleanup; /* parsing potentially unclean URI */
+ char *query_raw; /* the query string (as it appears in the URI) */
};
/*
@@ -44,43 +49,43 @@ struct _xmlURI {
* xmlChar * xmlNodeGetBase (xmlDocPtr doc,
* xmlNodePtr cur);
*/
-XMLPUBFUN xmlURIPtr XMLCALL
+XMLPUBFUN xmlURIPtr XMLCALL
xmlCreateURI (void);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlBuildURI (const xmlChar *URI,
- const xmlChar *base);
-XMLPUBFUN xmlChar * XMLCALL
+ const xmlChar *base);
+XMLPUBFUN xmlChar * XMLCALL
xmlBuildRelativeURI (const xmlChar *URI,
- const xmlChar *base);
-XMLPUBFUN xmlURIPtr XMLCALL
+ const xmlChar *base);
+XMLPUBFUN xmlURIPtr XMLCALL
xmlParseURI (const char *str);
-XMLPUBFUN xmlURIPtr XMLCALL
+XMLPUBFUN xmlURIPtr XMLCALL
xmlParseURIRaw (const char *str,
int raw);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParseURIReference (xmlURIPtr uri,
const char *str);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlSaveUri (xmlURIPtr uri);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlPrintURI (FILE *stream,
xmlURIPtr uri);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlURIEscapeStr (const xmlChar *str,
- const xmlChar *list);
-XMLPUBFUN char * XMLCALL
+ const xmlChar *list);
+XMLPUBFUN char * XMLCALL
xmlURIUnescapeString (const char *str,
int len,
char *target);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlNormalizeURIPath (char *path);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlURIEscape (const xmlChar *str);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeURI (xmlURIPtr uri);
-XMLPUBFUN xmlChar* XMLCALL
+XMLPUBFUN xmlChar* XMLCALL
xmlCanonicPath (const xmlChar *path);
-XMLPUBFUN xmlChar* XMLCALL
+XMLPUBFUN xmlChar* XMLCALL
xmlPathToURI (const xmlChar *path);
#ifdef __cplusplus
diff --git a/gnulib-local/lib/libxml/valid.c b/gnulib-local/lib/libxml/valid.c
index a239e68..45a3f70 100644
--- a/gnulib-local/lib/libxml/valid.c
+++ b/gnulib-local/lib/libxml/valid.c
@@ -31,11 +31,16 @@ static xmlElementPtr xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name,
/* #define DEBUG_VALID_ALGO */
/* #define DEBUG_REGEXP_ALGO */
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
+#ifdef LIBXML_VALID_ENABLED
+static int
+xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type,
+ const xmlChar *value);
+#endif
/************************************************************************
* *
* Error handling routines *
@@ -117,7 +122,7 @@ xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error,
__xmlRaiseError(NULL, channel, data,
pctxt, NULL, XML_FROM_VALID, error,
XML_ERR_ERROR, NULL, 0, NULL, NULL, NULL, 0, 0,
- msg);
+ "%s", msg);
}
#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
@@ -296,7 +301,7 @@ vstateVPush(xmlValidCtxtPtr ctxt, xmlElementPtr elemDecl, xmlNodePtr node) {
if (elemDecl->contModel == NULL)
xmlValidBuildContentModel(ctxt, elemDecl);
if (elemDecl->contModel != NULL) {
- ctxt->vstateTab[ctxt->vstateNr].exec =
+ ctxt->vstateTab[ctxt->vstateNr].exec =
xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL);
} else {
ctxt->vstateTab[ctxt->vstateNr].exec = NULL;
@@ -618,7 +623,7 @@ xmlValidStateDebug(xmlValidCtxtPtr ctxt) {
#define DEBUG_VALID_STATE(n,c) xmlValidStateDebug(ctxt);
#define DEBUG_VALID_MSG(m) \
xmlGenericError(xmlGenericErrorContext, "%s\n", m);
-
+
#else
#define DEBUG_VALID_STATE(n,c)
#define DEBUG_VALID_MSG(m)
@@ -632,8 +637,6 @@ xmlValidStateDebug(xmlValidCtxtPtr ctxt) {
else if ((doc->intSubset == NULL) && \
(doc->extSubset == NULL)) return(0)
-xmlAttributePtr xmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem);
-
#ifdef LIBXML_REGEXP_ENABLED
/************************************************************************
@@ -673,7 +676,7 @@ xmlValidBuildAContentModel(xmlElementContentPtr content,
xmlAutomataStatePtr oldstate = ctxt->state;
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(content->name, content->prefix, fn, 50);
if (fullname == NULL) {
xmlVErrMemory(ctxt, "Building content model");
@@ -698,9 +701,9 @@ xmlValidBuildAContentModel(xmlElementContentPtr content,
break;
case XML_ELEMENT_CONTENT_MULT:
ctxt->state = xmlAutomataNewEpsilon(ctxt->am,
- ctxt->state, NULL);
+ ctxt->state, NULL);
xmlAutomataNewTransition(ctxt->am,
- ctxt->state, ctxt->state, fullname, NULL);
+ ctxt->state, ctxt->state, fullname, NULL);
break;
}
if ((fullname != fn) && (fullname != content->name))
@@ -749,7 +752,7 @@ xmlValidBuildAContentModel(xmlElementContentPtr content,
xmlElementContentOccur ocur;
ocur = content->ocur;
- if ((ocur == XML_ELEMENT_CONTENT_PLUS) ||
+ if ((ocur == XML_ELEMENT_CONTENT_PLUS) ||
(ocur == XML_ELEMENT_CONTENT_MULT)) {
ctxt->state = xmlAutomataNewEpsilon(ctxt->am,
ctxt->state, NULL);
@@ -941,7 +944,7 @@ xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name,
}
break;
default:
- xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
"Internal: ELEMENT content corrupted invalid type\n",
NULL);
return(NULL);
@@ -998,7 +1001,7 @@ xmlNewElementContent(const xmlChar *name, xmlElementContentType type) {
* @cur: An element content pointer.
*
* Build a copy of an element content description.
- *
+ *
* Returns the new xmlElementContentPtr or NULL in case of error.
*/
xmlElementContentPtr
@@ -1025,7 +1028,7 @@ xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) {
else
ret->name = xmlStrdup(cur->name);
}
-
+
if (cur->prefix != NULL) {
if (dict)
ret->prefix = xmlDictLookup(dict, cur->prefix, -1);
@@ -1055,7 +1058,7 @@ xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) {
else
tmp->name = xmlStrdup(cur->name);
}
-
+
if (cur->prefix != NULL) {
if (dict)
tmp->prefix = xmlDictLookup(dict, cur->prefix, -1);
@@ -1079,7 +1082,7 @@ xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) {
*
* Build a copy of an element content description.
* Deprecated, use xmlCopyDocElementContent instead
- *
+ *
* Returns the new xmlElementContentPtr or NULL in case of error.
*/
xmlElementContentPtr
@@ -1111,7 +1114,7 @@ xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) {
case XML_ELEMENT_CONTENT_OR:
break;
default:
- xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
"Internal: ELEMENT content corrupted invalid type\n",
NULL);
return;
@@ -1197,7 +1200,7 @@ xmlDumpElementContent(xmlBufferPtr buf, xmlElementContentPtr content, int glob)
xmlDumpElementContent(buf, content->c2, 0);
break;
default:
- xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
"Internal: ELEMENT content corrupted invalid type\n",
NULL);
}
@@ -1394,7 +1397,7 @@ xmlAddElementDecl(xmlValidCtxtPtr ctxt,
switch (type) {
case XML_ELEMENT_TYPE_EMPTY:
if (content != NULL) {
- xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlAddElementDecl: content != NULL for EMPTY\n",
NULL);
return(NULL);
@@ -1402,7 +1405,7 @@ xmlAddElementDecl(xmlValidCtxtPtr ctxt,
break;
case XML_ELEMENT_TYPE_ANY:
if (content != NULL) {
- xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlAddElementDecl: content != NULL for ANY\n",
NULL);
return(NULL);
@@ -1410,7 +1413,7 @@ xmlAddElementDecl(xmlValidCtxtPtr ctxt,
break;
case XML_ELEMENT_TYPE_MIXED:
if (content == NULL) {
- xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlAddElementDecl: content == NULL for MIXED\n",
NULL);
return(NULL);
@@ -1418,14 +1421,14 @@ xmlAddElementDecl(xmlValidCtxtPtr ctxt,
break;
case XML_ELEMENT_TYPE_ELEMENT:
if (content == NULL) {
- xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlAddElementDecl: content == NULL for ELEMENT\n",
NULL);
return(NULL);
}
break;
default:
- xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
"Internal: ELEMENT decl corrupted invalid type\n",
NULL);
return(NULL);
@@ -1605,7 +1608,7 @@ xmlFreeElementTable(xmlElementTablePtr table) {
* @elem: An element
*
* Build a copy of an element.
- *
+ *
* Returns the new xmlElementPtr or NULL in case of error.
*/
static xmlElementPtr
@@ -1639,7 +1642,7 @@ xmlCopyElement(xmlElementPtr elem) {
* @table: An element table
*
* Build a copy of an element table.
- *
+ *
* Returns the new xmlElementTablePtr or NULL in case of error.
*/
xmlElementTablePtr
@@ -1704,7 +1707,7 @@ xmlDumpElementDecl(xmlBufferPtr buf, xmlElementPtr elem) {
xmlBufferWriteChar(buf, ">\n");
break;
default:
- xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
"Internal: ELEMENT struct corrupted invalid type\n",
NULL);
}
@@ -1795,6 +1798,7 @@ xmlCopyEnumeration(xmlEnumerationPtr cur) {
if (cur == NULL) return(NULL);
ret = xmlCreateEnumeration((xmlChar *) cur->name);
+ if (ret == NULL) return(NULL);
if (cur->next != NULL) ret->next = xmlCopyEnumeration(cur->next);
else ret->next = NULL;
@@ -1815,7 +1819,7 @@ static void
xmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) {
if ((buf == NULL) || (cur == NULL))
return;
-
+
xmlBufferWriteCHAR(buf, cur->name);
if (cur->next == NULL)
xmlBufferWriteChar(buf, ")");
@@ -1828,53 +1832,6 @@ xmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) {
#ifdef LIBXML_VALID_ENABLED
/**
- * xmlScanAttributeDeclCallback:
- * @attr: the attribute decl
- * @list: the list to update
- *
- * Callback called by xmlScanAttributeDecl when a new attribute
- * has to be entered in the list.
- */
-static void
-xmlScanAttributeDeclCallback(xmlAttributePtr attr, xmlAttributePtr *list,
- const xmlChar* name ATTRIBUTE_UNUSED) {
- attr->nexth = *list;
- *list = attr;
-}
-
-/**
- * xmlScanAttributeDecl:
- * @dtd: pointer to the DTD
- * @elem: the element name
- *
- * When inserting a new element scan the DtD for existing attributes
- * for that element and initialize the Attribute chain
- *
- * Returns the pointer to the first attribute decl in the chain,
- * possibly NULL.
- */
-xmlAttributePtr
-xmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem) {
- xmlAttributePtr ret = NULL;
- xmlAttributeTablePtr table;
-
- if (dtd == NULL) {
- return(NULL);
- }
- if (elem == NULL) {
- return(NULL);
- }
- table = (xmlAttributeTablePtr) dtd->attributes;
- if (table == NULL)
- return(NULL);
-
- /* WRONG !!! */
- xmlHashScan3(table, NULL, NULL, elem,
- (xmlHashScanner) xmlScanAttributeDeclCallback, &ret);
- return(ret);
-}
-
-/**
* xmlScanIDAttributeDecl:
* @ctxt: the validation context
* @elem: the element name
@@ -2017,14 +1974,14 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
case XML_ATTRIBUTE_NOTATION:
break;
default:
- xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
"Internal: ATTRIBUTE struct corrupted invalid type\n",
NULL);
xmlFreeEnumeration(tree);
return(NULL);
}
- if ((defaultValue != NULL) &&
- (!xmlValidateAttributeValue(type, defaultValue))) {
+ if ((defaultValue != NULL) &&
+ (!xmlValidateAttributeValueInternal(dtd->doc, type, defaultValue))) {
xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_DEFAULT,
"Attribute %s of %s: invalid default value\n",
elem, name, defaultValue);
@@ -2042,8 +1999,10 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
(dtd->doc->intSubset != NULL) &&
(dtd->doc->intSubset->attributes != NULL)) {
ret = xmlHashLookup3(dtd->doc->intSubset->attributes, name, ns, elem);
- if (ret != NULL)
+ if (ret != NULL) {
+ xmlFreeEnumeration(tree);
return(NULL);
+ }
}
/*
@@ -2057,6 +2016,7 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
if (table == NULL) {
xmlVErrMemory(ctxt,
"xmlAddAttributeDecl: Table creation failed!\n");
+ xmlFreeEnumeration(tree);
return(NULL);
}
@@ -2064,6 +2024,7 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
ret = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
if (ret == NULL) {
xmlVErrMemory(ctxt, "malloc failed");
+ xmlFreeEnumeration(tree);
return(NULL);
}
memset(ret, 0, sizeof(xmlAttribute));
@@ -2193,7 +2154,7 @@ xmlFreeAttributeTable(xmlAttributeTablePtr table) {
* @attr: An attribute
*
* Build a copy of an attribute.
- *
+ *
* Returns the new xmlAttributePtr or NULL in case of error.
*/
static xmlAttributePtr
@@ -2226,7 +2187,7 @@ xmlCopyAttribute(xmlAttributePtr attr) {
* @table: An attribute table
*
* Build a copy of an attribute table.
- *
+ *
* Returns the new xmlAttributeTablePtr or NULL in case of error.
*/
xmlAttributeTablePtr
@@ -2291,7 +2252,7 @@ xmlDumpAttributeDecl(xmlBufferPtr buf, xmlAttributePtr attr) {
xmlDumpEnumeration(buf, attr->tree);
break;
default:
- xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
"Internal: ATTRIBUTE struct corrupted invalid type\n",
NULL);
}
@@ -2308,7 +2269,7 @@ xmlDumpAttributeDecl(xmlBufferPtr buf, xmlAttributePtr attr) {
xmlBufferWriteChar(buf, " #FIXED");
break;
default:
- xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
+ xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
"Internal: ATTRIBUTE struct corrupted invalid def\n",
NULL);
}
@@ -2438,7 +2399,7 @@ xmlAddNotationDecl(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd,
*/
if (xmlHashAddEntry(table, name, ret)) {
#ifdef LIBXML_VALID_ENABLED
- xmlErrValid(NULL, XML_DTD_NOTATION_REDEFINED,
+ xmlErrValid(NULL, XML_DTD_NOTATION_REDEFINED,
"xmlAddNotationDecl: %s already defined\n",
(const char *) name);
#endif /* LIBXML_VALID_ENABLED */
@@ -2465,7 +2426,7 @@ xmlFreeNotationTable(xmlNotationTablePtr table) {
* @nota: A notation
*
* Build a copy of a notation.
- *
+ *
* Returns the new xmlNotationPtr or NULL in case of error.
*/
static xmlNotationPtr
@@ -2497,7 +2458,7 @@ xmlCopyNotation(xmlNotationPtr nota) {
* @table: A notation table
*
* Build a copy of a notation table.
- *
+ *
* Returns the new xmlNotationTablePtr or NULL in case of error.
*/
xmlNotationTablePtr
@@ -2575,7 +2536,7 @@ xmlDumpNotationTable(xmlBufferPtr buf, xmlNotationTablePtr table) {
* current scope
*/
#define DICT_FREE(str) \
- if ((str) && ((!dict) || \
+ if ((str) && ((!dict) || \
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
xmlFree((char *)(str));
@@ -2613,7 +2574,7 @@ xmlFreeID(xmlIDPtr id) {
*
* Returns NULL if not, otherwise the new xmlIDPtr
*/
-xmlIDPtr
+xmlIDPtr
xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
xmlAttrPtr attr) {
xmlIDPtr ret;
@@ -2673,10 +2634,9 @@ xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
/*
* The id is already defined in this DTD.
*/
- if ((ctxt != NULL) && (ctxt->error != NULL)) {
+ if (ctxt != NULL) {
xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED,
- "ID %s already defined\n",
- value, NULL, NULL);
+ "ID %s already defined\n", value, NULL, NULL);
}
#endif /* LIBXML_VALID_ENABLED */
xmlFreeID(ret);
@@ -2719,14 +2679,15 @@ xmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) {
(!strcmp((char *) attr->ns->prefix, "xml")))
return(1);
if (doc == NULL) return(0);
- if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
+ if ((doc->intSubset == NULL) && (doc->extSubset == NULL) &&
+ (doc->type != XML_HTML_DOCUMENT_NODE)) {
return(0);
} else if (doc->type == XML_HTML_DOCUMENT_NODE) {
if ((xmlStrEqual(BAD_CAST "id", attr->name)) ||
((xmlStrEqual(BAD_CAST "name", attr->name)) &&
- ((elem == NULL) || (!xmlStrEqual(elem->name, BAD_CAST "input")))))
+ ((elem == NULL) || (xmlStrEqual(elem->name, BAD_CAST "a")))))
return(1);
- return(0);
+ return(0);
} else if (elem == NULL) {
return(0);
} else {
@@ -2779,23 +2740,24 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
if (doc == NULL) return(-1);
if (attr == NULL) return(-1);
+
table = (xmlIDTablePtr) doc->ids;
- if (table == NULL)
+ if (table == NULL)
return(-1);
- if (attr == NULL)
- return(-1);
ID = xmlNodeListGetString(doc, attr->children, 1);
if (ID == NULL)
- return(-1);
+ return(-1);
+
id = xmlHashLookup(table, ID);
if (id == NULL || id->attr != attr) {
- xmlFree(ID);
- return(-1);
+ xmlFree(ID);
+ return(-1);
}
+
xmlHashRemoveEntry(table, ID, (xmlHashDeallocator) xmlFreeID);
xmlFree(ID);
- attr->atype = 0;
+ attr->atype = 0;
return(0);
}
@@ -2808,7 +2770,7 @@ xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
*
* Returns NULL if not found, otherwise the xmlAttrPtr defining the ID
*/
-xmlAttrPtr
+xmlAttrPtr
xmlGetID(xmlDocPtr doc, const xmlChar *ID) {
xmlIDTablePtr table;
xmlIDPtr id;
@@ -2822,7 +2784,7 @@ xmlGetID(xmlDocPtr doc, const xmlChar *ID) {
}
table = (xmlIDTablePtr) doc->ids;
- if (table == NULL)
+ if (table == NULL)
return(NULL);
id = xmlHashLookup(table, ID);
@@ -2843,7 +2805,7 @@ xmlGetID(xmlDocPtr doc, const xmlChar *ID) {
* Refs *
* *
************************************************************************/
-typedef struct xmlRemoveMemo_t
+typedef struct xmlRemoveMemo_t
{
xmlListPtr l;
xmlAttrPtr ap;
@@ -2851,7 +2813,7 @@ typedef struct xmlRemoveMemo_t
typedef xmlRemoveMemo *xmlRemoveMemoPtr;
-typedef struct xmlValidateMemo_t
+typedef struct xmlValidateMemo_t
{
xmlValidCtxtPtr ctxt;
const xmlChar *name;
@@ -2934,7 +2896,7 @@ xmlDummyCompare(const void *data0 ATTRIBUTE_UNUSED,
*
* Returns NULL if not, otherwise the new xmlRefPtr
*/
-xmlRefPtr
+xmlRefPtr
xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
xmlAttrPtr attr) {
xmlRefPtr ret;
@@ -2998,19 +2960,32 @@ xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value,
xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
"xmlAddRef: Reference list creation failed!\n",
NULL);
- return(NULL);
+ goto failed;
}
if (xmlHashAddEntry(table, value, ref_list) < 0) {
xmlListDelete(ref_list);
xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
"xmlAddRef: Reference list insertion failed!\n",
NULL);
- return(NULL);
+ goto failed;
}
}
-/* xmlListInsert(ref_list, ret); */
- xmlListAppend(ref_list, ret);
+ if (xmlListAppend(ref_list, ret) != 0) {
+ xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
+ "xmlAddRef: Reference list insertion failed!\n",
+ NULL);
+ goto failed;
+ }
return(ret);
+failed:
+ if (ret != NULL) {
+ if (ret->value != NULL)
+ xmlFree((char *)ret->value);
+ if (ret->name != NULL)
+ xmlFree((char *)ret->name);
+ xmlFree(ret);
+ }
+ return(NULL);
}
/**
@@ -3049,7 +3024,7 @@ xmlIsRef(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) {
return(0);
} else if (doc->type == XML_HTML_DOCUMENT_NODE) {
/* TODO @@@ */
- return(0);
+ return(0);
} else {
xmlAttributePtr attrDecl;
@@ -3085,21 +3060,21 @@ xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) {
if (doc == NULL) return(-1);
if (attr == NULL) return(-1);
+
table = (xmlRefTablePtr) doc->refs;
- if (table == NULL)
+ if (table == NULL)
return(-1);
- if (attr == NULL)
- return(-1);
ID = xmlNodeListGetString(doc, attr->children, 1);
if (ID == NULL)
return(-1);
- ref_list = xmlHashLookup(table, ID);
+ ref_list = xmlHashLookup(table, ID);
if(ref_list == NULL) {
xmlFree(ID);
return (-1);
}
+
/* At this point, ref_list refers to a list of references which
* have the same key as the supplied attr. Our list of references
* is ordered by reference address and we don't have that information
@@ -3112,7 +3087,7 @@ xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) {
*/
target.l = ref_list;
target.ap = attr;
-
+
/* Remove the supplied attr from our list */
xmlListWalk(ref_list, xmlWalkRemoveRef, &target);
@@ -3129,11 +3104,11 @@ xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) {
* @doc: pointer to the document
* @ID: the ID value
*
- * Find the set of references for the supplied ID.
+ * Find the set of references for the supplied ID.
*
* Returns NULL if not found, otherwise node set for the ID.
*/
-xmlListPtr
+xmlListPtr
xmlGetRefs(xmlDocPtr doc, const xmlChar *ID) {
xmlRefTablePtr table;
@@ -3146,7 +3121,7 @@ xmlGetRefs(xmlDocPtr doc, const xmlChar *ID) {
}
table = (xmlRefTablePtr) doc->refs;
- if (table == NULL)
+ if (table == NULL)
return(NULL);
return (xmlHashLookup(table, ID));
@@ -3211,7 +3186,7 @@ xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, int create) {
if (dtd->doc != NULL)
dict = dtd->doc->dict;
- if (!create)
+ if (!create)
return(NULL);
/*
* Create the Element table if needed.
@@ -3377,7 +3352,8 @@ int
xmlValidateNotationUse(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
const xmlChar *notationName) {
xmlNotationPtr notaDecl;
- if ((doc == NULL) || (doc->intSubset == NULL)) return(-1);
+ if ((doc == NULL) || (doc->intSubset == NULL) ||
+ (notationName == NULL)) return(-1);
notaDecl = xmlGetDtdNotationDesc(doc->intSubset, notationName);
if ((notaDecl == NULL) && (doc->extSubset != NULL))
@@ -3432,8 +3408,78 @@ xmlIsMixedElement(xmlDocPtr doc, const xmlChar *name) {
}
#ifdef LIBXML_VALID_ENABLED
+
+static int
+xmlIsDocNameStartChar(xmlDocPtr doc, int c) {
+ if ((doc == NULL) || (doc->properties & XML_DOC_OLD10) == 0) {
+ /*
+ * Use the new checks of production [4] [4a] amd [5] of the
+ * Update 5 of XML-1.0
+ */
+ if (((c >= 'a') && (c <= 'z')) ||
+ ((c >= 'A') && (c <= 'Z')) ||
+ (c == '_') || (c == ':') ||
+ ((c >= 0xC0) && (c <= 0xD6)) ||
+ ((c >= 0xD8) && (c <= 0xF6)) ||
+ ((c >= 0xF8) && (c <= 0x2FF)) ||
+ ((c >= 0x370) && (c <= 0x37D)) ||
+ ((c >= 0x37F) && (c <= 0x1FFF)) ||
+ ((c >= 0x200C) && (c <= 0x200D)) ||
+ ((c >= 0x2070) && (c <= 0x218F)) ||
+ ((c >= 0x2C00) && (c <= 0x2FEF)) ||
+ ((c >= 0x3001) && (c <= 0xD7FF)) ||
+ ((c >= 0xF900) && (c <= 0xFDCF)) ||
+ ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
+ ((c >= 0x10000) && (c <= 0xEFFFF)))
+ return(1);
+ } else {
+ if (IS_LETTER(c) || (c == '_') || (c == ':'))
+ return(1);
+ }
+ return(0);
+}
+
+static int
+xmlIsDocNameChar(xmlDocPtr doc, int c) {
+ if ((doc == NULL) || (doc->properties & XML_DOC_OLD10) == 0) {
+ /*
+ * Use the new checks of production [4] [4a] amd [5] of the
+ * Update 5 of XML-1.0
+ */
+ if (((c >= 'a') && (c <= 'z')) ||
+ ((c >= 'A') && (c <= 'Z')) ||
+ ((c >= '0') && (c <= '9')) || /* !start */
+ (c == '_') || (c == ':') ||
+ (c == '-') || (c == '.') || (c == 0xB7) || /* !start */
+ ((c >= 0xC0) && (c <= 0xD6)) ||
+ ((c >= 0xD8) && (c <= 0xF6)) ||
+ ((c >= 0xF8) && (c <= 0x2FF)) ||
+ ((c >= 0x300) && (c <= 0x36F)) || /* !start */
+ ((c >= 0x370) && (c <= 0x37D)) ||
+ ((c >= 0x37F) && (c <= 0x1FFF)) ||
+ ((c >= 0x200C) && (c <= 0x200D)) ||
+ ((c >= 0x203F) && (c <= 0x2040)) || /* !start */
+ ((c >= 0x2070) && (c <= 0x218F)) ||
+ ((c >= 0x2C00) && (c <= 0x2FEF)) ||
+ ((c >= 0x3001) && (c <= 0xD7FF)) ||
+ ((c >= 0xF900) && (c <= 0xFDCF)) ||
+ ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
+ ((c >= 0x10000) && (c <= 0xEFFFF)))
+ return(1);
+ } else {
+ if ((IS_LETTER(c)) || (IS_DIGIT(c)) ||
+ (c == '.') || (c == '-') ||
+ (c == '_') || (c == ':') ||
+ (IS_COMBINING(c)) ||
+ (IS_EXTENDER(c)))
+ return(1);
+ }
+ return(0);
+}
+
/**
* xmlValidateNameValue:
+ * @doc: pointer to the document or NULL
* @value: an Name value
*
* Validate that the given value match Name production
@@ -3441,8 +3487,8 @@ xmlIsMixedElement(xmlDocPtr doc, const xmlChar *name) {
* returns 1 if valid or 0 otherwise
*/
-int
-xmlValidateNameValue(const xmlChar *value) {
+static int
+xmlValidateNameValueInternal(xmlDocPtr doc, const xmlChar *value) {
const xmlChar *cur;
int val, len;
@@ -3450,18 +3496,12 @@ xmlValidateNameValue(const xmlChar *value) {
cur = value;
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
- if (!IS_LETTER(val) && (val != '_') &&
- (val != ':')) {
+ if (!xmlIsDocNameStartChar(doc, val))
return(0);
- }
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3472,7 +3512,22 @@ xmlValidateNameValue(const xmlChar *value) {
}
/**
- * xmlValidateNamesValue:
+ * xmlValidateNameValue:
+ * @value: an Name value
+ *
+ * Validate that the given value match Name production
+ *
+ * returns 1 if valid or 0 otherwise
+ */
+
+int
+xmlValidateNameValue(const xmlChar *value) {
+ return(xmlValidateNameValueInternal(NULL, value));
+}
+
+/**
+ * xmlValidateNamesValueInternal:
+ * @doc: pointer to the document or NULL
* @value: an Names value
*
* Validate that the given value match Names production
@@ -3480,8 +3535,8 @@ xmlValidateNameValue(const xmlChar *value) {
* returns 1 if valid or 0 otherwise
*/
-int
-xmlValidateNamesValue(const xmlChar *value) {
+static int
+xmlValidateNamesValueInternal(xmlDocPtr doc, const xmlChar *value) {
const xmlChar *cur;
int val, len;
@@ -3489,19 +3544,13 @@ xmlValidateNamesValue(const xmlChar *value) {
cur = value;
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
-
- if (!IS_LETTER(val) && (val != '_') &&
- (val != ':')) {
+
+ if (!xmlIsDocNameStartChar(doc, val))
return(0);
- }
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3513,18 +3562,13 @@ xmlValidateNamesValue(const xmlChar *value) {
cur += len;
}
- if (!IS_LETTER(val) && (val != '_') &&
- (val != ':')) {
+ if (!xmlIsDocNameStartChar(doc, val))
return(0);
- }
+
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3536,18 +3580,33 @@ xmlValidateNamesValue(const xmlChar *value) {
}
/**
- * xmlValidateNmtokenValue:
+ * xmlValidateNamesValue:
+ * @value: an Names value
+ *
+ * Validate that the given value match Names production
+ *
+ * returns 1 if valid or 0 otherwise
+ */
+
+int
+xmlValidateNamesValue(const xmlChar *value) {
+ return(xmlValidateNamesValueInternal(NULL, value));
+}
+
+/**
+ * xmlValidateNmtokenValueInternal:
+ * @doc: pointer to the document or NULL
* @value: an Nmtoken value
*
* Validate that the given value match Nmtoken production
*
* [ VC: Name Token ]
- *
+ *
* returns 1 if valid or 0 otherwise
*/
-int
-xmlValidateNmtokenValue(const xmlChar *value) {
+static int
+xmlValidateNmtokenValueInternal(xmlDocPtr doc, const xmlChar *value) {
const xmlChar *cur;
int val, len;
@@ -3555,19 +3614,13 @@ xmlValidateNmtokenValue(const xmlChar *value) {
cur = value;
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
-
- if (!IS_LETTER(val) && !IS_DIGIT(val) &&
- (val != '.') && (val != '-') &&
- (val != '_') && (val != ':') &&
- (!IS_COMBINING(val)) &&
- (!IS_EXTENDER(val)))
+
+ if (!xmlIsDocNameChar(doc, val))
return(0);
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ val = xmlStringCurrentChar(NULL, cur, &len);
+ cur += len;
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3578,18 +3631,35 @@ xmlValidateNmtokenValue(const xmlChar *value) {
}
/**
- * xmlValidateNmtokensValue:
+ * xmlValidateNmtokenValue:
+ * @value: an Nmtoken value
+ *
+ * Validate that the given value match Nmtoken production
+ *
+ * [ VC: Name Token ]
+ *
+ * returns 1 if valid or 0 otherwise
+ */
+
+int
+xmlValidateNmtokenValue(const xmlChar *value) {
+ return(xmlValidateNmtokenValueInternal(NULL, value));
+}
+
+/**
+ * xmlValidateNmtokensValueInternal:
+ * @doc: pointer to the document or NULL
* @value: an Nmtokens value
*
* Validate that the given value match Nmtokens production
*
* [ VC: Name Token ]
- *
+ *
* returns 1 if valid or 0 otherwise
*/
-int
-xmlValidateNmtokensValue(const xmlChar *value) {
+static int
+xmlValidateNmtokensValueInternal(xmlDocPtr doc, const xmlChar *value) {
const xmlChar *cur;
int val, len;
@@ -3597,24 +3667,16 @@ xmlValidateNmtokensValue(const xmlChar *value) {
cur = value;
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
-
+
while (IS_BLANK(val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
- if (!IS_LETTER(val) && !IS_DIGIT(val) &&
- (val != '.') && (val != '-') &&
- (val != '_') && (val != ':') &&
- (!IS_COMBINING(val)) &&
- (!IS_EXTENDER(val)))
+ if (!xmlIsDocNameChar(doc, val))
return(0);
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3627,18 +3689,13 @@ xmlValidateNmtokensValue(const xmlChar *value) {
}
if (val == 0) return(1);
- if (!IS_LETTER(val) && !IS_DIGIT(val) &&
- (val != '.') && (val != '-') &&
- (val != '_') && (val != ':') &&
- (!IS_COMBINING(val)) &&
- (!IS_EXTENDER(val)))
+ if (!xmlIsDocNameChar(doc, val))
return(0);
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ val = xmlStringCurrentChar(NULL, cur, &len);
+ cur += len;
+
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3650,6 +3707,22 @@ xmlValidateNmtokensValue(const xmlChar *value) {
}
/**
+ * xmlValidateNmtokensValue:
+ * @value: an Nmtokens value
+ *
+ * Validate that the given value match Nmtokens production
+ *
+ * [ VC: Name Token ]
+ *
+ * returns 1 if valid or 0 otherwise
+ */
+
+int
+xmlValidateNmtokensValue(const xmlChar *value) {
+ return(xmlValidateNmtokensValueInternal(NULL, value));
+}
+
+/**
* xmlValidateNotationDecl:
* @ctxt: the validation context
* @doc: a document instance
@@ -3673,6 +3746,40 @@ xmlValidateNotationDecl(xmlValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlDocPtr doc ATT
}
/**
+ * xmlValidateAttributeValueInternal:
+ * @doc: the document
+ * @type: an attribute type
+ * @value: an attribute value
+ *
+ * Validate that the given attribute value match the proper production
+ *
+ * returns 1 if valid or 0 otherwise
+ */
+
+static int
+xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type,
+ const xmlChar *value) {
+ switch (type) {
+ case XML_ATTRIBUTE_ENTITIES:
+ case XML_ATTRIBUTE_IDREFS:
+ return(xmlValidateNamesValueInternal(doc, value));
+ case XML_ATTRIBUTE_ENTITY:
+ case XML_ATTRIBUTE_IDREF:
+ case XML_ATTRIBUTE_ID:
+ case XML_ATTRIBUTE_NOTATION:
+ return(xmlValidateNameValueInternal(doc, value));
+ case XML_ATTRIBUTE_NMTOKENS:
+ case XML_ATTRIBUTE_ENUMERATION:
+ return(xmlValidateNmtokensValueInternal(doc, value));
+ case XML_ATTRIBUTE_NMTOKEN:
+ return(xmlValidateNmtokenValueInternal(doc, value));
+ case XML_ATTRIBUTE_CDATA:
+ break;
+ }
+ return(1);
+}
+
+/**
* xmlValidateAttributeValue:
* @type: an attribute type
* @value: an attribute value
@@ -3692,31 +3799,13 @@ xmlValidateNotationDecl(xmlValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlDocPtr doc ATT
*
* [ VC: Name Token ]
* Values of type NMTOKEN must match the Nmtoken production; values
- * of type NMTOKENS must match Nmtokens.
+ * of type NMTOKENS must match Nmtokens.
*
* returns 1 if valid or 0 otherwise
*/
-
int
xmlValidateAttributeValue(xmlAttributeType type, const xmlChar *value) {
- switch (type) {
- case XML_ATTRIBUTE_ENTITIES:
- case XML_ATTRIBUTE_IDREFS:
- return(xmlValidateNamesValue(value));
- case XML_ATTRIBUTE_ENTITY:
- case XML_ATTRIBUTE_IDREF:
- case XML_ATTRIBUTE_ID:
- case XML_ATTRIBUTE_NOTATION:
- return(xmlValidateNameValue(value));
- case XML_ATTRIBUTE_NMTOKENS:
- case XML_ATTRIBUTE_ENUMERATION:
- return(xmlValidateNmtokensValue(value));
- case XML_ATTRIBUTE_NMTOKEN:
- return(xmlValidateNmtokenValue(value));
- case XML_ATTRIBUTE_CDATA:
- break;
- }
- return(1);
+ return(xmlValidateAttributeValueInternal(NULL, type, value));
}
/**
@@ -3769,7 +3858,7 @@ xmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
if ((ent == NULL) && (doc->standalone == 1)) {
doc->standalone = 0;
ent = xmlGetDocEntity(doc, value);
- }
+ }
if (ent == NULL) {
xmlErrValidNode(ctxt, (xmlNodePtr) doc,
XML_DTD_UNKNOWN_ENTITY,
@@ -3880,7 +3969,7 @@ xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) {
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
if (fullname == NULL)
return(NULL);
@@ -3965,13 +4054,10 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) {
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
if (fullname == NULL)
return(NULL);
- attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name);
- if ((attrDecl == NULL) && (doc->extSubset != NULL))
- attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name);
if ((fullname != fn) && (fullname != elem->name))
xmlFree(fullname);
}
@@ -4034,11 +4120,12 @@ xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
int val;
CHECK_DTD;
if(attr == NULL) return(1);
-
+
/* Attribute Default Legal */
/* Enumeration */
if (attr->defaultValue != NULL) {
- val = xmlValidateAttributeValue(attr->atype, attr->defaultValue);
+ val = xmlValidateAttributeValueInternal(doc, attr->atype,
+ attr->defaultValue);
if (val == 0) {
xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ATTRIBUTE_DEFAULT,
"Syntax of default value for attribute %s of %s is not valid\n",
@@ -4081,7 +4168,7 @@ xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
}
}
if (nbId > 1) {
-
+
xmlErrValidNodeNr(ctxt, (xmlNodePtr) attr, XML_DTD_ID_SUBSET,
"Element %s has %d ID attribute defined in the internal subset : %s\n",
attr->elem, nbId, attr->name);
@@ -4144,7 +4231,7 @@ xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlElementPtr tst;
CHECK_DTD;
-
+
if (elem == NULL) return(1);
#if 0
@@ -4169,15 +4256,15 @@ xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
while (next != NULL) {
if (next->type == XML_ELEMENT_CONTENT_ELEMENT) {
if ((xmlStrEqual(next->name, name)) &&
- (xmlStrEqual(next->prefix, cur->prefix))) {
- if (cur->prefix == NULL) {
+ (xmlStrEqual(next->prefix, cur->c1->prefix))) {
+ if (cur->c1->prefix == NULL) {
xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
"Definition of %s has duplicate references of %s\n",
elem->name, name, NULL);
} else {
xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
"Definition of %s has duplicate references of %s:%s\n",
- elem->name, cur->prefix, name);
+ elem->name, cur->c1->prefix, name);
}
ret = 0;
}
@@ -4186,15 +4273,15 @@ xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
if (next->c1 == NULL) break;
if (next->c1->type != XML_ELEMENT_CONTENT_ELEMENT) break;
if ((xmlStrEqual(next->c1->name, name)) &&
- (xmlStrEqual(next->c1->prefix, cur->prefix))) {
- if (cur->prefix == NULL) {
+ (xmlStrEqual(next->c1->prefix, cur->c1->prefix))) {
+ if (cur->c1->prefix == NULL) {
xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
"Definition of %s has duplicate references to %s\n",
elem->name, name, NULL);
} else {
xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
"Definition of %s has duplicate references to %s:%s\n",
- elem->name, cur->prefix, name);
+ elem->name, cur->c1->prefix, name);
}
ret = 0;
}
@@ -4261,7 +4348,7 @@ xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
int
xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
- xmlNodePtr elem, xmlAttrPtr attr, const xmlChar *value)
+ xmlNodePtr elem, xmlAttrPtr attr, const xmlChar *value)
{
xmlAttributePtr attrDecl = NULL;
int val;
@@ -4274,7 +4361,7 @@ xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) {
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
if (fullname == NULL)
return(0);
@@ -4319,7 +4406,7 @@ xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
}
attr->atype = attrDecl->atype;
- val = xmlValidateAttributeValue(attrDecl->atype, value);
+ val = xmlValidateAttributeValueInternal(doc, attrDecl->atype, value);
if (val == 0) {
xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE,
"Syntax of value for attribute %s of %s is not valid\n",
@@ -4358,7 +4445,7 @@ xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
nota = xmlGetDtdNotationDesc(doc->intSubset, value);
if (nota == NULL)
nota = xmlGetDtdNotationDesc(doc->extSubset, value);
-
+
if (nota == NULL) {
xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION,
"Value \"%s\" for attribute %s of %s is not a declared Notation\n",
@@ -4451,7 +4538,7 @@ xmlNodePtr elem, const xmlChar *prefix, xmlNsPtr ns, const xmlChar *value) {
if (prefix != NULL) {
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(elem->name, prefix, fn, 50);
if (fullname == NULL) {
xmlVErrMemory(ctxt, "Validating namespace");
@@ -4504,7 +4591,7 @@ xmlNodePtr elem, const xmlChar *prefix, xmlNsPtr ns, const xmlChar *value) {
return(0);
}
- val = xmlValidateAttributeValue(attrDecl->atype, value);
+ val = xmlValidateAttributeValueInternal(doc, attrDecl->atype, value);
if (val == 0) {
if (ns->prefix != NULL) {
xmlErrValidNode(ctxt, elem, XML_DTD_INVALID_DEFAULT,
@@ -4555,7 +4642,7 @@ xmlNodePtr elem, const xmlChar *prefix, xmlNsPtr ns, const xmlChar *value) {
nota = xmlGetDtdNotationDesc(doc->intSubset, value);
if (nota == NULL)
nota = xmlGetDtdNotationDesc(doc->extSubset, value);
-
+
if (nota == NULL) {
if (ns->prefix != NULL) {
xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION,
@@ -4691,7 +4778,7 @@ xmlValidateElementType(xmlValidCtxtPtr ctxt) {
NODE = xmlValidateSkipIgnorable(NODE);
if ((NODE == NULL) && (CONT == NULL))
return(1);
- if ((NODE == NULL) &&
+ if ((NODE == NULL) &&
((CONT->ocur == XML_ELEMENT_CONTENT_MULT) ||
(CONT->ocur == XML_ELEMENT_CONTENT_OPT))) {
return(1);
@@ -5150,7 +5237,7 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
xmlElementContentPtr cont;
const xmlChar *name;
- if (elemDecl == NULL)
+ if ((elemDecl == NULL) || (parent == NULL) || (ctxt == NULL))
return(-1);
cont = elemDecl->content;
name = elemDecl->name;
@@ -5200,7 +5287,7 @@ xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child,
if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(cur->name,
cur->ns->prefix, fn, 50);
if (fullname == NULL) {
@@ -5314,7 +5401,7 @@ fail:
last = tmp;
}
if (cur->type == XML_CDATA_SECTION_NODE) {
- /*
+ /*
* E59 spaces in CDATA does not match the
* nonterminal S
*/
@@ -5431,7 +5518,8 @@ xmlValidateOneCdataElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
int ret = 1;
xmlNodePtr cur, child;
- if ((ctxt == NULL) || (doc == NULL) || (elem == NULL))
+ if ((ctxt == NULL) || (doc == NULL) || (elem == NULL) ||
+ (elem->type != XML_ELEMENT_NODE))
return(0);
child = elem->children;
@@ -5512,7 +5600,7 @@ xmlValidateCheckMixed(xmlValidCtxtPtr ctxt,
} else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
(cont->c1 == NULL) ||
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){
- xmlErrValid(NULL, XML_DTD_MIXED_CORRUPT,
+ xmlErrValid(NULL, XML_DTD_MIXED_CORRUPT,
"Internal: MIXED struct corrupted\n",
NULL);
break;
@@ -5536,7 +5624,7 @@ xmlValidateCheckMixed(xmlValidCtxtPtr ctxt,
} else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
(cont->c1 == NULL) ||
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){
- xmlErrValid(ctxt, XML_DTD_MIXED_CORRUPT,
+ xmlErrValid(ctxt, XML_DTD_MIXED_CORRUPT,
"Internal: MIXED struct corrupted\n",
NULL);
break;
@@ -5565,7 +5653,7 @@ xmlValidGetElemDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlElementPtr elemDecl = NULL;
const xmlChar *prefix = NULL;
- if ((ctxt == NULL) || (doc == NULL) ||
+ if ((ctxt == NULL) || (doc == NULL) ||
(elem == NULL) || (elem->name == NULL))
return(NULL);
if (extsubset != NULL)
@@ -5709,7 +5797,7 @@ xmlValidatePushElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
* xmlValidatePushCData:
* @ctxt: the validation context
* @data: some character data read
- * @len: the lenght of the data
+ * @len: the length of the data
*
* check the CData parsed for validation in the current stack
*
@@ -5931,7 +6019,7 @@ xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
return(0);
/*
- * If vstateNr is not zero that means continuous validation is
+ * If vstateNr is not zero that means continuous validation is
* activated, do not try to check the content model at that level.
*/
if (ctxt->vstateNr == 0) {
@@ -5974,7 +6062,7 @@ xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
if ((child->ns != NULL) && (child->ns->prefix != NULL)) {
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(child->name, child->ns->prefix,
fn, 50);
if (fullname == NULL)
@@ -5992,7 +6080,7 @@ xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
} else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
(cont->c1 == NULL) ||
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){
- xmlErrValid(NULL, XML_DTD_MIXED_CORRUPT,
+ xmlErrValid(NULL, XML_DTD_MIXED_CORRUPT,
"Internal: MIXED struct corrupted\n",
NULL);
break;
@@ -6015,7 +6103,7 @@ xmlValidateOneElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
} else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
(cont->c1 == NULL) ||
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)) {
- xmlErrValid(ctxt, XML_DTD_MIXED_CORRUPT,
+ xmlErrValid(ctxt, XML_DTD_MIXED_CORRUPT,
"Internal: MIXED struct corrupted\n",
NULL);
break;
@@ -6095,7 +6183,7 @@ child_ok:
}
} else {
xmlAttrPtr attrib;
-
+
attrib = elem->properties;
while (attrib != NULL) {
if (xmlStrEqual(attrib->name, attr->name)) {
@@ -6110,18 +6198,18 @@ child_ok:
* allow to define the URI instead of the prefix :-(
*/
if (nameSpace == NULL) {
- if (qualified < 0)
+ if (qualified < 0)
qualified = 0;
} else if (!xmlStrEqual(nameSpace->prefix,
attr->prefix)) {
- if (qualified < 1)
+ if (qualified < 1)
qualified = 1;
} else
goto found;
} else {
/*
* We should allow applications to define namespaces
- * for their application even if the DTD doesn't
+ * for their application even if the DTD doesn't
* carry one, otherwise, basically we would always
* break.
*/
@@ -6194,7 +6282,7 @@ child_ok:
}
}
}
-found:
+found:
attr = attr->nexth;
}
return(ret);
@@ -6241,7 +6329,7 @@ xmlValidateRoot(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
if ((root->ns != NULL) && (root->ns->prefix != NULL)) {
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(root->name, root->ns->prefix, fn, 50);
if (fullname == NULL) {
xmlVErrMemory(ctxt, NULL);
@@ -6252,7 +6340,7 @@ xmlValidateRoot(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
xmlFree(fullname);
if (ret == 1)
goto name_ok;
- }
+ }
if ((xmlStrEqual(doc->intSubset->name, BAD_CAST "HTML")) &&
(xmlStrEqual(root->name, BAD_CAST "html")))
goto name_ok;
@@ -6273,7 +6361,7 @@ name_ok:
* @doc: a document instance
* @elem: an element instance
*
- * Try to validate the subtree under an element
+ * Try to validate the subtree under an element
*
* returns 1 if valid or 0 otherwise
*/
@@ -6293,7 +6381,8 @@ xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) {
* they don't really mean anything validation wise.
*/
if ((elem->type == XML_XINCLUDE_START) ||
- (elem->type == XML_XINCLUDE_END))
+ (elem->type == XML_XINCLUDE_END) ||
+ (elem->type == XML_NAMESPACE_DECL))
return(1);
CHECK_DTD;
@@ -6452,7 +6541,7 @@ xmlValidateCheckRefCallback(xmlListPtr ref_list, xmlValidCtxtPtr ctxt,
memo.name = name;
xmlListWalk(ref_list, xmlWalkValidateList, &memo);
-
+
}
/**
@@ -6464,7 +6553,7 @@ xmlValidateCheckRefCallback(xmlListPtr ref_list, xmlValidCtxtPtr ctxt,
* 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
*
* returns 1 if valid or 0 otherwise
@@ -6473,15 +6562,20 @@ xmlValidateCheckRefCallback(xmlListPtr ref_list, xmlValidCtxtPtr ctxt,
int
xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
xmlRefTablePtr table;
+ unsigned int save;
if (ctxt == NULL)
return(0);
if (doc == NULL) {
- xmlErrValid(ctxt, XML_DTD_NO_DOC,
+ xmlErrValid(ctxt, XML_DTD_NO_DOC,
"xmlValidateDocumentFinal: doc == NULL\n", NULL);
return(0);
}
+ /* trick to get correct line id report */
+ save = ctxt->finishDtd;
+ ctxt->finishDtd = 0;
+
/*
* Check all the NOTATION/NOTATIONS attributes
*/
@@ -6495,6 +6589,8 @@ xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
ctxt->doc = doc;
ctxt->valid = 1;
xmlHashScan(table, (xmlHashScanner) xmlValidateCheckRefCallback, ctxt);
+
+ ctxt->finishDtd = save;
return(ctxt->valid);
}
@@ -6589,7 +6685,7 @@ xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
case XML_ATTRIBUTE_ENTITIES:
case XML_ATTRIBUTE_NOTATION:
if (cur->defaultValue != NULL) {
-
+
ret = xmlValidateAttributeValue2(ctxt, ctxt->doc, cur->name,
cur->atype, cur->defaultValue);
if ((ret == 0) && (ctxt->valid == 1))
@@ -6646,9 +6742,9 @@ xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
* subsets have been parsed
*
* basically it does the following checks described by the XML Rec
- * - check that ENTITY and ENTITIES type attributes default or
+ * - check that ENTITY and ENTITIES type attributes default or
* possible values matches one of the defined entities.
- * - check that NOTATION type attributes default or
+ * - check that NOTATION type attributes default or
* possible values matches one of the defined notations.
*
* returns 1 if valid or 0 if invalid and -1 if not well-formed
@@ -6660,7 +6756,7 @@ xmlValidateDtdFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
xmlAttributeTablePtr table;
xmlEntitiesTablePtr entities;
- if (doc == NULL) return(0);
+ if ((doc == NULL) || (ctxt == NULL)) return(0);
if ((doc->intSubset == NULL) && (doc->extSubset == NULL))
return(0);
ctxt->doc = doc;
@@ -6719,7 +6815,7 @@ xmlValidateDocument(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
xmlChar *sysID;
if (doc->intSubset->SystemID != NULL) {
sysID = xmlBuildURI(doc->intSubset->SystemID,
- doc->URL);
+ doc->URL);
if (sysID == NULL) {
xmlErrValid(ctxt, XML_DTD_LOAD_ERROR,
"Could not build URI for external subset \"%s\"\n",
@@ -6792,17 +6888,17 @@ xmlValidGetPotentialChildren(xmlElementContent *ctree,
if (*len >= max) return(*len);
switch (ctree->type) {
- case XML_ELEMENT_CONTENT_PCDATA:
+ case XML_ELEMENT_CONTENT_PCDATA:
for (i = 0; i < *len;i++)
if (xmlStrEqual(BAD_CAST "#PCDATA", names[i])) return(*len);
names[(*len)++] = BAD_CAST "#PCDATA";
break;
- case XML_ELEMENT_CONTENT_ELEMENT:
+ case XML_ELEMENT_CONTENT_ELEMENT:
for (i = 0; i < *len;i++)
if (xmlStrEqual(ctree->name, names[i])) return(*len);
names[(*len)++] = ctree->name;
break;
- case XML_ELEMENT_CONTENT_SEQ:
+ case XML_ELEMENT_CONTENT_SEQ:
xmlValidGetPotentialChildren(ctree->c1, names, len, max);
xmlValidGetPotentialChildren(ctree->c2, names, len, max);
break;
@@ -6811,7 +6907,7 @@ xmlValidGetPotentialChildren(xmlElementContent *ctree,
xmlValidGetPotentialChildren(ctree->c2, names, len, max);
break;
}
-
+
return(*len);
}
@@ -6853,19 +6949,19 @@ xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names,
int max) {
xmlValidCtxt vctxt;
int nb_valid_elements = 0;
- const xmlChar *elements[256];
+ const xmlChar *elements[256]={0};
int nb_elements = 0, i;
const xmlChar *name;
-
+
xmlNode *ref_node;
xmlNode *parent;
xmlNode *test_node;
-
+
xmlNode *prev_next;
xmlNode *next_prev;
xmlNode *parent_childs;
xmlNode *parent_last;
-
+
xmlElement *element_desc;
if (prev == NULL && next == NULL)
@@ -6890,7 +6986,7 @@ xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names,
element_desc = xmlGetDtdElementDesc(parent->doc->extSubset,
parent->name);
if (element_desc == NULL) return(-1);
-
+
/*
* Do a backup of the current tree structure
*/
@@ -6901,16 +6997,19 @@ xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names,
/*
* Creates a dummy node and insert it into the tree
- */
+ */
test_node = xmlNewDocNode (ref_node->doc, NULL, BAD_CAST "<!dummy?>", NULL);
+ if (test_node == NULL)
+ return(-1);
+
test_node->parent = parent;
test_node->prev = prev;
test_node->next = next;
name = test_node->name;
-
+
if (prev) prev->next = test_node;
else parent->children = test_node;
-
+
if (next) next->prev = test_node;
else parent->last = test_node;
@@ -6920,7 +7019,7 @@ xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names,
*/
nb_elements = xmlValidGetPotentialChildren(element_desc->content,
elements, &nb_elements, 256);
-
+
for (i = 0;i < nb_elements;i++) {
test_node->name = elements[i];
if (xmlValidateOneElement(&vctxt, parent->doc, parent)) {
diff --git a/gnulib-local/lib/libxml/valid.in.h b/gnulib-local/lib/libxml/valid.in.h
index 7492d28..2bc7b38 100644
--- a/gnulib-local/lib/libxml/valid.in.h
+++ b/gnulib-local/lib/libxml/valid.in.h
@@ -41,7 +41,7 @@ typedef xmlValidState *xmlValidStatePtr;
*/
typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx,
const char *msg,
- ...);
+ ...) LIBXML_ATTR_FORMAT(2,3);
/**
* xmlValidityWarningFunc:
@@ -56,7 +56,7 @@ typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx,
*/
typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx,
const char *msg,
- ...);
+ ...) LIBXML_ATTR_FORMAT(2,3);
#ifdef IN_LIBXML
/**
@@ -150,55 +150,55 @@ typedef struct _xmlHashTable xmlRefTable;
typedef xmlRefTable *xmlRefTablePtr;
/* Notation */
-XMLPUBFUN xmlNotationPtr XMLCALL
+XMLPUBFUN xmlNotationPtr XMLCALL
xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
xmlDtdPtr dtd,
const xmlChar *name,
const xmlChar *PublicID,
const xmlChar *SystemID);
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlNotationTablePtr XMLCALL
+XMLPUBFUN xmlNotationTablePtr XMLCALL
xmlCopyNotationTable (xmlNotationTablePtr table);
#endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeNotationTable (xmlNotationTablePtr table);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDumpNotationDecl (xmlBufferPtr buf,
xmlNotationPtr nota);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDumpNotationTable (xmlBufferPtr buf,
xmlNotationTablePtr table);
#endif /* LIBXML_OUTPUT_ENABLED */
/* Element Content */
/* the non Doc version are being deprecated */
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XMLPUBFUN xmlElementContentPtr XMLCALL
xmlNewElementContent (const xmlChar *name,
xmlElementContentType type);
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XMLPUBFUN xmlElementContentPtr XMLCALL
xmlCopyElementContent (xmlElementContentPtr content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeElementContent (xmlElementContentPtr cur);
/* the new versions with doc argument */
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XMLPUBFUN xmlElementContentPtr XMLCALL
xmlNewDocElementContent (xmlDocPtr doc,
const xmlChar *name,
xmlElementContentType type);
-XMLPUBFUN xmlElementContentPtr XMLCALL
+XMLPUBFUN xmlElementContentPtr XMLCALL
xmlCopyDocElementContent(xmlDocPtr doc,
xmlElementContentPtr content);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeDocElementContent(xmlDocPtr doc,
xmlElementContentPtr cur);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSnprintfElementContent(char *buf,
int size,
xmlElementContentPtr content,
int englob);
#ifdef LIBXML_OUTPUT_ENABLED
/* DEPRECATED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSprintfElementContent(char *buf,
xmlElementContentPtr content,
int englob);
@@ -206,39 +206,39 @@ XMLPUBFUN void XMLCALL
/* DEPRECATED */
/* Element */
-XMLPUBFUN xmlElementPtr XMLCALL
+XMLPUBFUN xmlElementPtr XMLCALL
xmlAddElementDecl (xmlValidCtxtPtr ctxt,
xmlDtdPtr dtd,
const xmlChar *name,
xmlElementTypeVal type,
xmlElementContentPtr content);
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlElementTablePtr XMLCALL
+XMLPUBFUN xmlElementTablePtr XMLCALL
xmlCopyElementTable (xmlElementTablePtr table);
#endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeElementTable (xmlElementTablePtr table);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDumpElementTable (xmlBufferPtr buf,
xmlElementTablePtr table);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDumpElementDecl (xmlBufferPtr buf,
xmlElementPtr elem);
#endif /* LIBXML_OUTPUT_ENABLED */
/* Enumeration */
-XMLPUBFUN xmlEnumerationPtr XMLCALL
+XMLPUBFUN xmlEnumerationPtr XMLCALL
xmlCreateEnumeration (const xmlChar *name);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeEnumeration (xmlEnumerationPtr cur);
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlEnumerationPtr XMLCALL
+XMLPUBFUN xmlEnumerationPtr XMLCALL
xmlCopyEnumeration (xmlEnumerationPtr cur);
#endif /* LIBXML_TREE_ENABLED */
/* Attribute */
-XMLPUBFUN xmlAttributePtr XMLCALL
+XMLPUBFUN xmlAttributePtr XMLCALL
xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
xmlDtdPtr dtd,
const xmlChar *elem,
@@ -249,55 +249,55 @@ XMLPUBFUN xmlAttributePtr XMLCALL
const xmlChar *defaultValue,
xmlEnumerationPtr tree);
#ifdef LIBXML_TREE_ENABLED
-XMLPUBFUN xmlAttributeTablePtr XMLCALL
+XMLPUBFUN xmlAttributeTablePtr XMLCALL
xmlCopyAttributeTable (xmlAttributeTablePtr table);
#endif /* LIBXML_TREE_ENABLED */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeAttributeTable (xmlAttributeTablePtr table);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDumpAttributeTable (xmlBufferPtr buf,
xmlAttributeTablePtr table);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlDumpAttributeDecl (xmlBufferPtr buf,
xmlAttributePtr attr);
#endif /* LIBXML_OUTPUT_ENABLED */
/* IDs */
-XMLPUBFUN xmlIDPtr XMLCALL
+XMLPUBFUN xmlIDPtr XMLCALL
xmlAddID (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
const xmlChar *value,
xmlAttrPtr attr);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeIDTable (xmlIDTablePtr table);
-XMLPUBFUN xmlAttrPtr XMLCALL
+XMLPUBFUN xmlAttrPtr XMLCALL
xmlGetID (xmlDocPtr doc,
const xmlChar *ID);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlIsID (xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr);
-XMLPUBFUN int XMLCALL
- xmlRemoveID (xmlDocPtr doc,
+XMLPUBFUN int XMLCALL
+ xmlRemoveID (xmlDocPtr doc,
xmlAttrPtr attr);
/* IDREFs */
-XMLPUBFUN xmlRefPtr XMLCALL
+XMLPUBFUN xmlRefPtr XMLCALL
xmlAddRef (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
const xmlChar *value,
xmlAttrPtr attr);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeRefTable (xmlRefTablePtr table);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlIsRef (xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr);
-XMLPUBFUN int XMLCALL
- xmlRemoveRef (xmlDocPtr doc,
+XMLPUBFUN int XMLCALL
+ xmlRemoveRef (xmlDocPtr doc,
xmlAttrPtr attr);
-XMLPUBFUN xmlListPtr XMLCALL
+XMLPUBFUN xmlListPtr XMLCALL
xmlGetRefs (xmlDocPtr doc,
const xmlChar *ID);
@@ -306,146 +306,146 @@ XMLPUBFUN xmlListPtr XMLCALL
*/
#ifdef LIBXML_VALID_ENABLED
/* Allocate/Release Validation Contexts */
-XMLPUBFUN xmlValidCtxtPtr XMLCALL
+XMLPUBFUN xmlValidCtxtPtr XMLCALL
xmlNewValidCtxt(void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeValidCtxt(xmlValidCtxtPtr);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateRoot (xmlValidCtxtPtr ctxt,
xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlElementPtr elem);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlValidNormalizeAttributeValue(xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *name,
const xmlChar *value);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *name,
const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlAttributePtr attr);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateAttributeValue(xmlAttributeType type,
const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNotationPtr nota);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateDtd (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlDtdPtr dtd);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateDocument (xmlValidCtxtPtr ctxt,
xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateElement (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateOneElement (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr,
const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *prefix,
xmlNsPtr ns,
const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
xmlDocPtr doc);
#endif /* LIBXML_VALID_ENABLED */
#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
const xmlChar *notationName);
#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlIsMixedElement (xmlDocPtr doc,
const xmlChar *name);
-XMLPUBFUN xmlAttributePtr XMLCALL
+XMLPUBFUN xmlAttributePtr XMLCALL
xmlGetDtdAttrDesc (xmlDtdPtr dtd,
const xmlChar *elem,
const xmlChar *name);
-XMLPUBFUN xmlAttributePtr XMLCALL
+XMLPUBFUN xmlAttributePtr XMLCALL
xmlGetDtdQAttrDesc (xmlDtdPtr dtd,
const xmlChar *elem,
const xmlChar *name,
const xmlChar *prefix);
-XMLPUBFUN xmlNotationPtr XMLCALL
+XMLPUBFUN xmlNotationPtr XMLCALL
xmlGetDtdNotationDesc (xmlDtdPtr dtd,
const xmlChar *name);
-XMLPUBFUN xmlElementPtr XMLCALL
+XMLPUBFUN xmlElementPtr XMLCALL
xmlGetDtdQElementDesc (xmlDtdPtr dtd,
const xmlChar *name,
const xmlChar *prefix);
-XMLPUBFUN xmlElementPtr XMLCALL
+XMLPUBFUN xmlElementPtr XMLCALL
xmlGetDtdElementDesc (xmlDtdPtr dtd,
const xmlChar *name);
#ifdef LIBXML_VALID_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidGetPotentialChildren(xmlElementContent *ctree,
const xmlChar **names,
int *len,
int max);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidGetValidElements(xmlNode *prev,
xmlNode *next,
const xmlChar **names,
int max);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateNameValue (const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateNamesValue (const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateNmtokenValue (const xmlChar *value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidateNmtokensValue(const xmlChar *value);
#ifdef LIBXML_REGEXP_ENABLED
/*
* Validation based on the regexp support
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
xmlElementPtr elem);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidatePushElement (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *qname);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidatePushCData (xmlValidCtxtPtr ctxt,
const xmlChar *data,
int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlValidatePopElement (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
diff --git a/gnulib-local/lib/libxml/xinclude.c b/gnulib-local/lib/libxml/xinclude.c
index c58bbcf..ff3dafb 100644
--- a/gnulib-local/lib/libxml/xinclude.c
+++ b/gnulib-local/lib/libxml/xinclude.c
@@ -17,6 +17,7 @@
#include <libxml/tree.h>
#include <libxml/parser.h>
#include <libxml/uri.h>
+#include <libxml/xpath.h>
#include <libxml/xpointer.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlerror.h>
@@ -26,6 +27,7 @@
#ifdef LIBXML_XINCLUDE_ENABLED
#include <libxml/xinclude.h>
+#include "buf.h"
#define XINCLUDE_MAX_DEPTH 40
@@ -92,7 +94,7 @@ xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree);
/************************************************************************
* *
- * XInclude error handler *
+ * XInclude error handler *
* *
************************************************************************/
@@ -412,14 +414,13 @@ xmlXIncludeFreeContext(xmlXIncludeCtxtPtr ctxt) {
* xmlXIncludeParseFile:
* @ctxt: the XInclude context
* @URL: the URL or file path
- *
+ *
* parse a document for XInclude
*/
static xmlDocPtr
xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
xmlDocPtr ret;
xmlParserCtxtPtr pctxt;
- char *directory = NULL;
xmlParserInputPtr inputStream;
xmlInitParser();
@@ -434,20 +435,20 @@ xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
* pass in the application data to the parser context.
*/
pctxt->_private = ctxt->_private;
-
+
/*
* try to ensure that new documents included are actually
* built with the same dictionary as the including document.
*/
- if ((ctxt->doc != NULL) && (ctxt->doc->dict != NULL) &&
- (pctxt->dict != NULL)) {
- xmlDictFree(pctxt->dict);
+ if ((ctxt->doc != NULL) && (ctxt->doc->dict != NULL)) {
+ if (pctxt->dict != NULL)
+ xmlDictFree(pctxt->dict);
pctxt->dict = ctxt->doc->dict;
xmlDictReference(pctxt->dict);
}
xmlCtxtUseOptions(pctxt, ctxt->parseFlags | XML_PARSE_DTDLOAD);
-
+
inputStream = xmlLoadExternalEntity(URL, NULL, pctxt);
if (inputStream == NULL) {
xmlFreeParserCtxt(pctxt);
@@ -456,10 +457,8 @@ xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
inputPush(pctxt, inputStream);
- if ((pctxt->directory == NULL) && (directory == NULL))
- directory = xmlParserGetDirectory(URL);
- if ((pctxt->directory == NULL) && (directory != NULL))
- pctxt->directory = (char *) xmlStrdup((xmlChar *) directory);
+ if (pctxt->directory == NULL)
+ pctxt->directory = xmlParserGetDirectory(URL);
pctxt->loadsubset |= XML_DETECT_IDS;
@@ -475,7 +474,7 @@ xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
pctxt->myDoc = NULL;
}
xmlFreeParserCtxt(pctxt);
-
+
return(ret);
}
@@ -483,7 +482,7 @@ xmlXIncludeParseFile(xmlXIncludeCtxtPtr ctxt, const char *URL) {
* xmlXIncludeAddNode:
* @ctxt: the XInclude context
* @cur: the new node
- *
+ *
* Add a new node to process to an XInclude context
*/
static int
@@ -514,11 +513,10 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF);
if (href == NULL) {
href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */
- if (href == NULL)
+ if (href == NULL)
return(-1);
- local = 1;
}
- if (href[0] == '#')
+ if ((href[0] == '#') || (href[0] == 0))
local = 1;
parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE);
if (parse != NULL) {
@@ -617,6 +615,19 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
}
/*
+ * If local and xml then we need a fragment
+ */
+ if ((local == 1) && (xml == 1) &&
+ ((fragment == NULL) || (fragment[0] == 0))) {
+ xmlXIncludeErr(ctxt, cur, XML_XINCLUDE_RECURSION,
+ "detected a local recursion with no xpointer in %s\n",
+ URL);
+ if (fragment != NULL)
+ xmlFree(fragment);
+ return(-1);
+ }
+
+ /*
* Check the URL against the stack for recursions
*/
if ((!local) && (xml == 1)) {
@@ -646,7 +657,7 @@ xmlXIncludeAddNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr cur) {
* @ctxt: the XInclude context
* @doc: the new document
* @url: the associated URL
- *
+ *
* The XInclude recursive nature is handled at this point.
*/
static void
@@ -673,6 +684,10 @@ xmlXIncludeRecurseDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc,
newctxt = xmlXIncludeNewContext(doc);
if (newctxt != NULL) {
/*
+ * Copy the private user data
+ */
+ newctxt->_private = ctxt->_private;
+ /*
* Copy the existing document set
*/
newctxt->incMax = ctxt->incMax;
@@ -736,7 +751,7 @@ xmlXIncludeRecurseDoc(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc,
* @ctxt: the XInclude context
* @txt: the new text node
* @url: the associated URL
- *
+ *
* Add a new txtument to the list
*/
static void
@@ -785,13 +800,17 @@ xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) {
* *
************************************************************************/
+static xmlNodePtr
+xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
+ xmlDocPtr source, xmlNodePtr elem);
+
/**
* xmlXIncludeCopyNode:
* @ctxt: the XInclude context
* @target: the document target
* @source: the document source
* @elem: the element
- *
+ *
* Make a copy of the node while preserving the XInclude semantic
* of the Infoset copy
*/
@@ -805,7 +824,10 @@ xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
return(NULL);
if (elem->type == XML_DTD_NODE)
return(NULL);
- result = xmlDocCopyNode(elem, target, 1);
+ if (elem->type == XML_DOCUMENT_NODE)
+ result = xmlXIncludeCopyNodeList(ctxt, target, source, elem->children);
+ else
+ result = xmlDocCopyNode(elem, target, 1);
return(result);
}
@@ -815,7 +837,7 @@ xmlXIncludeCopyNode(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
* @target: the document target
* @source: the document source
* @elem: the element list
- *
+ *
* Make a copy of the node list while preserving the XInclude semantic
* of the Infoset copy
*/
@@ -854,11 +876,11 @@ xmlXIncludeCopyNodeList(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
static xmlNodePtr
xmlXIncludeGetNthChild(xmlNodePtr cur, int no) {
int i;
- if (cur == NULL)
- return(cur);
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
+ return(NULL);
cur = cur->children;
for (i = 0;i <= no;cur = cur->next) {
- if (cur == NULL)
+ if (cur == NULL)
return(cur);
if ((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_DOCUMENT_NODE) ||
@@ -902,11 +924,13 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
return(NULL);
start = (xmlNodePtr) range->user;
- if (start == NULL)
+ if ((start == NULL) || (start->type == XML_NAMESPACE_DECL))
return(NULL);
end = range->user2;
if (end == NULL)
return(xmlDocCopyNode(start, target, 1));
+ if (end->type == XML_NAMESPACE_DECL)
+ return(NULL);
cur = start;
index1 = range->index;
@@ -954,7 +978,6 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
if ((cur == start) && (index1 > 1)) {
content += (index1 - 1);
len -= (index1 - 1);
- index1 = 0;
} else {
len = index2;
}
@@ -966,7 +989,7 @@ xmlXIncludeCopyRange(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
/* prune and return full set */
if (level == lastLevel)
xmlAddNextSibling(last, tmp);
- else
+ else
xmlAddChild(last, tmp);
return(list);
} else { /* ending node not a text node */
@@ -1185,6 +1208,7 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
}
break;
}
+#ifdef LIBXML_XPTR_ENABLED
case XPATH_LOCATIONSET: {
xmlLocationSetPtr set = (xmlLocationSetPtr) obj->user;
if (set == NULL)
@@ -1204,7 +1228,6 @@ xmlXIncludeCopyXPointer(xmlXIncludeCtxtPtr ctxt, xmlDocPtr target,
}
break;
}
-#ifdef LIBXML_XPTR_ENABLED
case XPATH_RANGE:
return(xmlXIncludeCopyRange(ctxt, target, source, obj));
#endif
@@ -1270,7 +1293,7 @@ xmlXIncludeMergeEntity(xmlEntityPtr ent, xmlXIncludeMergeDataPtr data,
if (prev != NULL) {
if (ent->etype != prev->etype)
goto error;
-
+
if ((ent->SystemID != NULL) && (prev->SystemID != NULL)) {
if (!xmlStrEqual(ent->SystemID, prev->SystemID))
goto error;
@@ -1370,7 +1393,7 @@ xmlXIncludeMergeEntities(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc,
* @ctxt: the XInclude context
* @url: the associated URL
* @nr: the xinclude node number
- *
+ *
* Load the document, and store the result in the XInclude context
*
* Returns 0 in case of success, -1 in case of failure
@@ -1394,7 +1417,7 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
*/
uri = xmlParseURI((const char *)url);
if (uri == NULL) {
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_HREF_URI,
"invalid value URI %s\n", url);
return(-1);
@@ -1412,7 +1435,7 @@ xmlXIncludeLoadDoc(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
xmlFreeURI(uri);
if (URL == NULL) {
if (ctxt->incTab != NULL)
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_HREF_URI,
"invalid value URI %s\n", url);
else
@@ -1531,7 +1554,7 @@ loaded:
ctxt->incTab[nr]->inc = xmlXIncludeCopyNodeList(ctxt, ctxt->doc,
doc, doc->children);
}
- }
+ }
#ifdef LIBXML_XPTR_ENABLED
else {
/*
@@ -1549,7 +1572,7 @@ loaded:
xptrctxt = xmlXPtrNewContext(doc, NULL, NULL);
}
if (xptrctxt == NULL) {
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_XPTR_FAILED,
"could not create XPointer context\n", NULL);
xmlFree(URL);
@@ -1575,7 +1598,7 @@ loaded:
case XPATH_POINT:
case XPATH_USERS:
case XPATH_XSLT_TREE:
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_XPTR_RESULT,
"XPointer is not a range: #%s\n",
fragment);
@@ -1602,6 +1625,7 @@ loaded:
if (set->nodeTab[i] == NULL)
continue;
switch (set->nodeTab[i]->type) {
+ case XML_ELEMENT_NODE:
case XML_TEXT_NODE:
case XML_CDATA_SECTION_NODE:
case XML_ENTITY_REF_NODE:
@@ -1614,28 +1638,16 @@ loaded:
case XML_DOCB_DOCUMENT_NODE:
#endif
continue;
- case XML_ELEMENT_NODE: {
- xmlChar *nodeBase;
- xmlNodePtr el = set->nodeTab[i];
-
- nodeBase = xmlNodeGetBase(el->doc, el);
- if (nodeBase != NULL) {
- if (!xmlStrEqual(nodeBase, el->doc->URL))
- xmlNodeSetBase(el, nodeBase);
- xmlFree(nodeBase);
- }
- continue;
- }
case XML_ATTRIBUTE_NODE:
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_XPTR_RESULT,
"XPointer selects an attribute: #%s\n",
fragment);
set->nodeTab[i] = NULL;
continue;
case XML_NAMESPACE_DECL:
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_XPTR_RESULT,
"XPointer selects a namespace: #%s\n",
fragment);
@@ -1650,7 +1662,7 @@ loaded:
case XML_ENTITY_DECL:
case XML_XINCLUDE_START:
case XML_XINCLUDE_END:
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_XPTR_RESULT,
"XPointer selects unexpected nodes: #%s\n",
fragment);
@@ -1676,7 +1688,9 @@ loaded:
/*
* Do the xml:base fixup if needed
*/
- if ((doc != NULL) && (URL != NULL) && (xmlStrchr(URL, (xmlChar) '/'))) {
+ if ((doc != NULL) && (URL != NULL) &&
+ (!(ctxt->parseFlags & XML_PARSE_NOBASEFIX)) &&
+ (!(doc->parseFlags & XML_PARSE_NOBASEFIX))) {
xmlNodePtr node;
xmlChar *base;
xmlChar *curBase;
@@ -1694,7 +1708,7 @@ loaded:
*/
curBase = xmlBuildRelativeURI(URL, ctxt->base);
if (curBase == NULL) { /* Error return */
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_HREF_URI,
"trying to build relative URI from %s\n", URL);
} else {
@@ -1735,7 +1749,7 @@ loaded:
xmlChar *relBase;
relBase = xmlBuildURI(xmlBase, base);
if (relBase == NULL) { /* error */
- xmlXIncludeErr(ctxt,
+ xmlXIncludeErr(ctxt,
ctxt->incTab[nr]->ref,
XML_XINCLUDE_HREF_URI,
"trying to rebuild base from %s\n",
@@ -1772,7 +1786,7 @@ loaded:
* @ctxt: the XInclude context
* @url: the associated URL
* @nr: the xinclude node number
- *
+ *
* Load the content, and store the result in the XInclude context
*
* Returns 0 in case of success, -1 in case of failure
@@ -1786,6 +1800,9 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
int i;
xmlChar *encoding = NULL;
xmlCharEncoding enc = (xmlCharEncoding) 0;
+ xmlParserCtxtPtr pctxt;
+ xmlParserInputPtr inputStream;
+ int xinclude_multibyte_fallback_used = 0;
/*
* Check the URL and remove any fragment identifier
@@ -1816,7 +1833,7 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
* directly through ctxt->doc.
*/
if (URL[0] == 0) {
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_TEXT_DOCUMENT,
"text serialization of document not available\n", NULL);
xmlFree(URL);
@@ -1860,40 +1877,65 @@ xmlXIncludeLoadTxt(xmlXIncludeCtxtPtr ctxt, const xmlChar *url, int nr) {
/*
* Load it.
*/
- buf = xmlParserInputBufferCreateFilename((const char *)URL, enc);
+ pctxt = xmlNewParserCtxt();
+ inputStream = xmlLoadExternalEntity((const char*)URL, NULL, pctxt);
+ if(inputStream == NULL) {
+ xmlFreeParserCtxt(pctxt);
+ xmlFree(URL);
+ return(-1);
+ }
+ buf = inputStream->buf;
if (buf == NULL) {
+ xmlFreeInputStream (inputStream);
+ xmlFreeParserCtxt(pctxt);
xmlFree(URL);
return(-1);
}
+ if (buf->encoder)
+ xmlCharEncCloseFunc(buf->encoder);
+ buf->encoder = xmlGetCharEncodingHandler(enc);
node = xmlNewText(NULL);
/*
* Scan all chars from the resource and add the to the node
*/
+xinclude_multibyte_fallback:
while (xmlParserInputBufferRead(buf, 128) > 0) {
int len;
const xmlChar *content;
- content = xmlBufferContent(buf->buffer);
- len = xmlBufferLength(buf->buffer);
+ content = xmlBufContent(buf->buffer);
+ len = xmlBufLength(buf->buffer);
for (i = 0;i < len;) {
int cur;
int l;
cur = xmlStringCurrentChar(NULL, &content[i], &l);
if (!IS_CHAR(cur)) {
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
- XML_XINCLUDE_INVALID_CHAR,
- "%s contains invalid char\n", URL);
+ /* Handle splitted multibyte char at buffer boundary */
+ if (((len - i) < 4) && (!xinclude_multibyte_fallback_used)) {
+ xinclude_multibyte_fallback_used = 1;
+ xmlBufShrink(buf->buffer, i);
+ goto xinclude_multibyte_fallback;
+ } else {
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ XML_XINCLUDE_INVALID_CHAR,
+ "%s contains invalid char\n", URL);
+ xmlFreeParserInputBuffer(buf);
+ xmlFree(URL);
+ return(-1);
+ }
} else {
+ xinclude_multibyte_fallback_used = 0;
xmlNodeAddContentLen(node, &content[i], l);
}
i += l;
}
- xmlBufferShrink(buf->buffer, len);
+ xmlBufShrink(buf->buffer, len);
}
- xmlFreeParserInputBuffer(buf);
+ xmlFreeParserCtxt(pctxt);
xmlXIncludeAddTxt(ctxt, node, URL);
+ xmlFreeInputStream(inputStream);
loaded:
/*
@@ -1909,7 +1951,7 @@ loaded:
* @ctxt: the XInclude context
* @fallback: the fallback node
* @nr: the xinclude node number
- *
+ *
* Load the content of the fallback node, and store the result
* in the XInclude context
*
@@ -1919,8 +1961,9 @@ static int
xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) {
xmlXIncludeCtxtPtr newctxt;
int ret = 0;
-
- if ((fallback == NULL) || (ctxt == NULL))
+
+ if ((fallback == NULL) || (fallback->type == XML_NAMESPACE_DECL) ||
+ (ctxt == NULL))
return(-1);
if (fallback->children != NULL) {
/*
@@ -1930,6 +1973,7 @@ xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) {
newctxt = xmlXIncludeNewContext(ctxt->doc);
if (newctxt == NULL)
return (-1);
+ newctxt->_private = ctxt->_private;
newctxt->base = xmlStrdup(ctxt->base); /* Inherit the base from the existing context */
xmlXIncludeSetFlags(newctxt, ctxt->parseFlags);
ret = xmlXIncludeDoProcess(newctxt, ctxt->doc, fallback->children);
@@ -2004,7 +2048,7 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
href = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_HREF);
if (href == NULL) {
href = xmlStrdup(BAD_CAST ""); /* @@@@ href is now optional */
- if (href == NULL)
+ if (href == NULL)
return(-1);
}
parse = xmlXIncludeGetProp(ctxt, cur, XINCLUDE_PARSE);
@@ -2049,7 +2093,7 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
xmlFree(eschref);
}
if (URI == NULL) {
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_HREF_URI, "failed build URL\n", NULL);
if (parse != NULL)
xmlFree(parse);
@@ -2082,7 +2126,7 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
* Restore the original base before checking for fallback
*/
ctxt->base = oldBase;
-
+
if (ret < 0) {
xmlNodePtr children;
@@ -2100,14 +2144,14 @@ xmlXIncludeLoadNode(xmlXIncludeCtxtPtr ctxt, int nr) {
((xmlStrEqual(children->ns->href, XINCLUDE_NS)) ||
(xmlStrEqual(children->ns->href, XINCLUDE_OLD_NS)))) {
ret = xmlXIncludeLoadFallback(ctxt, children, nr);
- if (ret == 0)
+ if (ret == 0)
break;
}
children = children->next;
}
}
if (ret < 0) {
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_NO_FALLBACK,
"could not load %s, and no fallback was found\n",
URI);
@@ -2145,7 +2189,7 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
if ((nr < 0) || (nr >= ctxt->incNr))
return(-1);
cur = ctxt->incTab[nr]->ref;
- if (cur == NULL)
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
return(-1);
/*
@@ -2176,7 +2220,7 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
tmp = tmp->next;
}
if (nb_elem > 1) {
- xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
+ xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
XML_XINCLUDE_MULTIPLE_ROOT,
"XInclude error: would result in multiple root nodes\n",
NULL);
@@ -2223,7 +2267,7 @@ xmlXIncludeIncludeNode(xmlXIncludeCtxtPtr ctxt, int nr) {
}
}
-
+
return(0);
}
@@ -2320,7 +2364,7 @@ xmlXIncludeDoProcess(xmlXIncludeCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr tree) {
int ret = 0;
int i, start;
- if ((doc == NULL) || (tree == NULL))
+ if ((doc == NULL) || (tree == NULL) || (tree->type == XML_NAMESPACE_DECL))
return(-1);
if (ctxt == NULL)
return(-1);
@@ -2415,7 +2459,43 @@ xmlXIncludeSetFlags(xmlXIncludeCtxtPtr ctxt, int flags) {
ctxt->parseFlags = flags;
return(0);
}
-
+
+/**
+ * xmlXIncludeProcessTreeFlagsData:
+ * @tree: an XML node
+ * @flags: a set of xmlParserOption used for parsing XML includes
+ * @data: application data that will be passed to the parser context
+ * in the _private field of the parser context(s)
+ *
+ * Implement the XInclude substitution on the XML node @tree
+ *
+ * Returns 0 if no substitution were done, -1 if some processing failed
+ * or the number of substitutions done.
+ */
+
+int
+xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree, int flags, void *data) {
+ xmlXIncludeCtxtPtr ctxt;
+ int ret = 0;
+
+ if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL) ||
+ (tree->doc == NULL))
+ return(-1);
+
+ ctxt = xmlXIncludeNewContext(tree->doc);
+ if (ctxt == NULL)
+ return(-1);
+ ctxt->_private = data;
+ ctxt->base = xmlStrdup((xmlChar *)tree->doc->URL);
+ xmlXIncludeSetFlags(ctxt, flags);
+ ret = xmlXIncludeDoProcess(ctxt, tree->doc, tree);
+ if ((ret >= 0) && (ctxt->nbErrors > 0))
+ ret = -1;
+
+ xmlXIncludeFreeContext(ctxt);
+ return(ret);
+}
+
/**
* xmlXIncludeProcessFlagsData:
* @doc: an XML document
@@ -2430,27 +2510,14 @@ xmlXIncludeSetFlags(xmlXIncludeCtxtPtr ctxt, int flags) {
*/
int
xmlXIncludeProcessFlagsData(xmlDocPtr doc, int flags, void *data) {
- xmlXIncludeCtxtPtr ctxt;
xmlNodePtr tree;
- int ret = 0;
if (doc == NULL)
return(-1);
tree = xmlDocGetRootElement(doc);
if (tree == NULL)
return(-1);
- ctxt = xmlXIncludeNewContext(doc);
- if (ctxt == NULL)
- return(-1);
- ctxt->_private = data;
- ctxt->base = xmlStrdup((xmlChar *)doc->URL);
- xmlXIncludeSetFlags(ctxt, flags);
- ret = xmlXIncludeDoProcess(ctxt, doc, tree);
- if ((ret >= 0) && (ctxt->nbErrors > 0))
- ret = -1;
-
- xmlXIncludeFreeContext(ctxt);
- return(ret);
+ return(xmlXIncludeProcessTreeFlagsData(tree, flags, data));
}
/**
@@ -2497,7 +2564,8 @@ xmlXIncludeProcessTreeFlags(xmlNodePtr tree, int flags) {
xmlXIncludeCtxtPtr ctxt;
int ret = 0;
- if ((tree == NULL) || (tree->doc == NULL))
+ if ((tree == NULL) || (tree->type == XML_NAMESPACE_DECL) ||
+ (tree->doc == NULL))
return(-1);
ctxt = xmlXIncludeNewContext(tree->doc);
if (ctxt == NULL)
@@ -2541,7 +2609,8 @@ int
xmlXIncludeProcessNode(xmlXIncludeCtxtPtr ctxt, xmlNodePtr node) {
int ret = 0;
- if ((node == NULL) || (node->doc == NULL) || (ctxt == NULL))
+ if ((node == NULL) || (node->type == XML_NAMESPACE_DECL) ||
+ (node->doc == NULL) || (ctxt == NULL))
return(-1);
ret = xmlXIncludeDoProcess(ctxt, node->doc, node);
if ((ret >= 0) && (ctxt->nbErrors > 0))
diff --git a/gnulib-local/lib/libxml/xinclude.in.h b/gnulib-local/lib/libxml/xinclude.in.h
index ba9c9b5..863ab25 100644
--- a/gnulib-local/lib/libxml/xinclude.in.h
+++ b/gnulib-local/lib/libxml/xinclude.in.h
@@ -89,18 +89,22 @@ typedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr;
/*
* standalone processing
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXIncludeProcess (xmlDocPtr doc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXIncludeProcessFlags (xmlDocPtr doc,
int flags);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXIncludeProcessFlagsData(xmlDocPtr doc,
int flags,
void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
+ xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree,
+ int flags,
+ void *data);
+XMLPUBFUN int XMLCALL
xmlXIncludeProcessTree (xmlNodePtr tree);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXIncludeProcessTreeFlags(xmlNodePtr tree,
int flags);
/*
diff --git a/gnulib-local/lib/libxml/xlink.c b/gnulib-local/lib/libxml/xlink.c
index 0d9be73..c0e4ff3 100644
--- a/gnulib-local/lib/libxml/xlink.c
+++ b/gnulib-local/lib/libxml/xlink.c
@@ -47,7 +47,7 @@
* Default setting and related functions *
* *
****************************************************************/
-
+
static xlinkHandlerPtr xlinkDefaultHandler = NULL;
static xlinkNodeDetectFunc xlinkDefaultDetect = NULL;
@@ -93,7 +93,7 @@ xlinkGetDefaultDetect (void) {
*
* Set the default xlink detection routine
*/
-void
+void
xlinkSetDefaultDetect (xlinkNodeDetectFunc func) {
xlinkDefaultDetect = func;
}
@@ -104,7 +104,7 @@ xlinkSetDefaultDetect (xlinkNodeDetectFunc func) {
* *
****************************************************************/
-
+
/**
* xlinkIsLink:
* @doc: the document containing the node
@@ -119,7 +119,7 @@ xlinkSetDefaultDetect (xlinkNodeDetectFunc func) {
* Returns the xlinkType of the node (XLINK_TYPE_NONE if there is no
* link detected.
*/
-xlinkType
+xlinkType
xlinkIsLink (xmlDocPtr doc, xmlNodePtr node) {
xmlChar *type = NULL, *role = NULL;
xlinkType ret = XLINK_TYPE_NONE;
@@ -150,14 +150,14 @@ xlinkIsLink (xmlDocPtr doc, xmlNodePtr node) {
if (type != NULL) {
if (xmlStrEqual(type, BAD_CAST "simple")) {
ret = XLINK_TYPE_SIMPLE;
- } if (xmlStrEqual(type, BAD_CAST "extended")) {
+ } else if (xmlStrEqual(type, BAD_CAST "extended")) {
role = xmlGetNsProp(node, BAD_CAST "role", XLINK_NAMESPACE);
if (role != NULL) {
xmlNsPtr xlink;
xlink = xmlSearchNs(doc, node, XLINK_NAMESPACE);
if (xlink == NULL) {
/* Humm, fallback method */
- if (xmlStrEqual(role, BAD_CAST"xlink:external-linkset"))
+ if (xmlStrEqual(role, BAD_CAST"xlink:external-linkset"))
ret = XLINK_TYPE_EXTENDED_SET;
} else {
xmlChar buf[200];
diff --git a/gnulib-local/lib/libxml/xlink.in.h b/gnulib-local/lib/libxml/xlink.in.h
index 083c7ed..a209a99 100644
--- a/gnulib-local/lib/libxml/xlink.in.h
+++ b/gnulib-local/lib/libxml/xlink.in.h
@@ -57,7 +57,7 @@ typedef enum {
* xlinkNodeDetectFunc:
* @ctx: user data pointer
* @node: the node to check
- *
+ *
* This is the prototype for the link detection routine.
* It calls the default link detection callbacks upon link detection.
*/
@@ -157,26 +157,26 @@ struct _xlinkHandler {
/*
* The default detection routine, can be overridden, they call the default
- * detection callbacks.
+ * detection callbacks.
*/
-XMLPUBFUN xlinkNodeDetectFunc XMLCALL
+XMLPUBFUN xlinkNodeDetectFunc XMLCALL
xlinkGetDefaultDetect (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xlinkSetDefaultDetect (xlinkNodeDetectFunc func);
/*
* Routines to set/get the default handlers.
*/
-XMLPUBFUN xlinkHandlerPtr XMLCALL
+XMLPUBFUN xlinkHandlerPtr XMLCALL
xlinkGetDefaultHandler (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xlinkSetDefaultHandler (xlinkHandlerPtr handler);
/*
* Link detection module itself.
*/
-XMLPUBFUN xlinkType XMLCALL
+XMLPUBFUN xlinkType XMLCALL
xlinkIsLink (xmlDocPtr doc,
xmlNodePtr node);
diff --git a/gnulib-local/lib/libxml/xmlIO.c b/gnulib-local/lib/libxml/xmlIO.c
index 90db848..8b13184 100644
--- a/gnulib-local/lib/libxml/xmlIO.c
+++ b/gnulib-local/lib/libxml/xmlIO.c
@@ -35,11 +35,18 @@
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
+#ifdef HAVE_LZMA_H
+#include <lzma.h>
+#endif
-#ifdef WIN32
+#if defined(WIN32) || defined(_WIN32)
#include <windows.h>
#endif
+#if defined(_WIN32_WCE)
+#include <winnls.h> /* for CP_UTF8 */
+#endif
+
/* Figure a portable way to know if a file is a directory. */
#ifndef HAVE_STAT
# ifdef HAVE__STAT
@@ -89,6 +96,9 @@
#endif
#include <libxml/globals.h>
+#include "buf.h"
+#include "enc.h"
+
/* #define VERBOSE_FAILURE */
/* #define DEBUG_EXTERNAL_ENTITIES */
/* #define DEBUG_INPUT */
@@ -131,11 +141,14 @@ typedef struct _xmlOutputCallback {
static xmlOutputCallback xmlOutputCallbackTable[MAX_OUTPUT_CALLBACK];
static int xmlOutputCallbackNr = 0;
static int xmlOutputCallbackInitialized = 0;
+
+xmlOutputBufferPtr
+xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);
#endif /* LIBXML_OUTPUT_ENABLED */
/************************************************************************
* *
- * Tree memory error handler *
+ * Tree memory error handler *
* *
************************************************************************/
@@ -418,7 +431,7 @@ __xmlIOErr(int domain, int code, const char *extra)
idx = 0;
if (code >= XML_IO_UNKNOWN) idx = code - XML_IO_UNKNOWN;
if (idx >= (sizeof(IOerr) / sizeof(IOerr[0]))) idx = 0;
-
+
__xmlSimpleError(domain, code, NULL, IOerr[idx], extra);
}
@@ -470,12 +483,12 @@ __xmlLoaderErr(void *ctx, const char *msg, const char *filename)
XML_IO_LOAD_ERROR, level, NULL, 0,
filename, NULL, NULL, 0, 0,
msg, filename);
-
+
}
/************************************************************************
* *
- * Tree memory error handler *
+ * Tree memory error handler *
* *
************************************************************************/
/**
@@ -497,7 +510,7 @@ xmlNormalizeWindowsPath(const xmlChar *path)
* xmlCleanupInputCallbacks:
*
* clears the entire input callback table. this includes the
- * compiled-in I/O.
+ * compiled-in I/O.
*/
void
xmlCleanupInputCallbacks(void)
@@ -522,7 +535,7 @@ xmlCleanupInputCallbacks(void)
* xmlPopInputCallbacks:
*
* Clear the top input callback from the input stack. this includes the
- * compiled-in I/O.
+ * compiled-in I/O.
*
* Returns the number of input callback registered or -1 in case of error.
*/
@@ -534,7 +547,7 @@ xmlPopInputCallbacks(void)
if (xmlInputCallbackNr <= 0)
return(-1);
-
+
xmlInputCallbackNr--;
xmlInputCallbackTable[xmlInputCallbackNr].matchcallback = NULL;
xmlInputCallbackTable[xmlInputCallbackNr].opencallback = NULL;
@@ -549,7 +562,7 @@ xmlPopInputCallbacks(void)
* xmlCleanupOutputCallbacks:
*
* clears the entire output callback table. this includes the
- * compiled-in I/O callbacks.
+ * compiled-in I/O callbacks.
*/
void
xmlCleanupOutputCallbacks(void)
@@ -606,6 +619,34 @@ xmlWrapOpenUtf8(const char *path,int mode)
return fd;
}
+#ifdef HAVE_ZLIB_H
+static gzFile
+xmlWrapGzOpenUtf8(const char *path, const char *mode)
+{
+ gzFile fd;
+ wchar_t *wPath;
+
+ fd = gzopen (path, mode);
+ if (fd)
+ return fd;
+
+ wPath = __xmlIOWin32UTF8ToWChar(path);
+ if(wPath)
+ {
+ int d, m = (strstr(mode, "r") ? O_RDONLY : O_RDWR);
+#ifdef _O_BINARY
+ m |= (strstr(mode, "b") ? _O_BINARY : 0);
+#endif
+ d = _wopen(wPath, m);
+ if (d >= 0)
+ fd = gzdopen(d, mode);
+ xmlFree(wPath);
+ }
+
+ return fd;
+}
+#endif
+
/**
* xmlWrapStatUtf8:
* @path: the path in utf-8 encoding
@@ -672,7 +713,10 @@ typedef int (* xmlWrapStatFunc) (const char *f, struct stat *s);
static xmlWrapStatFunc xmlWrapStat = xmlWrapStatNative;
typedef FILE* (* xmlWrapOpenFunc)(const char *f,int mode);
static xmlWrapOpenFunc xmlWrapOpen = xmlWrapOpenNative;
-
+#ifdef HAVE_ZLIB_H
+typedef gzFile (* xmlWrapGzOpenFunc) (const char *f, const char *mode);
+static xmlWrapGzOpenFunc xmlWrapGzOpen = gzopen;
+#endif
/**
* xmlInitPlatformSpecificIo:
*
@@ -692,9 +736,15 @@ xmlInitPlatformSpecificIo(void)
if(GetVersionEx(&osvi) && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT)) {
xmlWrapStat = xmlWrapStatUtf8;
xmlWrapOpen = xmlWrapOpenUtf8;
+#ifdef HAVE_ZLIB_H
+ xmlWrapGzOpen = xmlWrapGzOpenUtf8;
+#endif
} else {
xmlWrapStat = xmlWrapStatNative;
xmlWrapOpen = xmlWrapOpenNative;
+#ifdef HAVE_ZLIB_H
+ xmlWrapGzOpen = gzopen;
+#endif
}
xmlPlatformIoInitialized = 1;
@@ -721,13 +771,21 @@ int
xmlCheckFilename (const char *path)
{
#ifdef HAVE_STAT
- struct stat stat_buffer;
+ struct stat stat_buffer;
#endif
- if (path == NULL)
- return(0);
+ if (path == NULL)
+ return(0);
#ifdef HAVE_STAT
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
+ /*
+ * On Windows stat and wstat do not work with long pathname,
+ * which start with '\\?\'
+ */
+ if ((path[0] == '\\') && (path[1] == '\\') && (path[2] == '?') &&
+ (path[3] == '\\') )
+ return 1;
+
if (xmlWrapStat(path, &stat_buffer) == -1)
return 0;
#else
@@ -742,7 +800,14 @@ xmlCheckFilename (const char *path)
return 1;
}
-static int
+/**
+ * xmlNop:
+ *
+ * No Operation function, does nothing, no input
+ *
+ * Returns zero
+ */
+int
xmlNop(void) {
return(0);
}
@@ -829,7 +894,7 @@ xmlFileMatch (const char *filename ATTRIBUTE_UNUSED) {
*/
static void *
xmlFileOpen_real (const char *filename) {
- const char *path = NULL;
+ const char *path = filename;
FILE *fd;
if (filename == NULL)
@@ -840,23 +905,27 @@ xmlFileOpen_real (const char *filename) {
return((void *) fd);
}
- if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost/", 17))
+ if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost/", 17)) {
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
path = &filename[17];
#else
path = &filename[16];
#endif
- else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
+ } else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
path = &filename[8];
#else
path = &filename[7];
#endif
- } else
- path = filename;
+ } else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:/", 6)) {
+ /* lots of generators seems to lazy to read RFC 1738 */
+#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)
+ path = &filename[6];
+#else
+ path = &filename[5];
+#endif
+ }
- if (path == NULL)
- return(NULL);
if (!xmlCheckFilename(path))
return(NULL);
@@ -883,13 +952,15 @@ xmlFileOpen (const char *filename) {
char *unescaped;
void *retval;
- unescaped = xmlURIUnescapeString(filename, 0, NULL);
- if (unescaped != NULL) {
- retval = xmlFileOpen_real(unescaped);
- xmlFree(unescaped);
- } else {
- retval = xmlFileOpen_real(filename);
+ retval = xmlFileOpen_real(filename);
+ if (retval == NULL) {
+ unescaped = xmlURIUnescapeString(filename, 0, NULL);
+ if (unescaped != NULL) {
+ retval = xmlFileOpen_real(unescaped);
+ xmlFree(unescaped);
+ }
}
+
return retval;
}
@@ -925,7 +996,7 @@ xmlFileOpenW (const char *filename) {
#else
path = &filename[7];
#endif
- } else
+ } else
path = filename;
if (path == NULL)
@@ -934,7 +1005,7 @@ xmlFileOpenW (const char *filename) {
#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
fd = xmlWrapOpen(path, 1);
#else
- fd = fopen(path, "wb");
+ fd = fopen(path, "wb");
#endif /* WIN32 */
if (fd == NULL) xmlIOErr(0, path);
@@ -955,7 +1026,7 @@ xmlFileOpenW (const char *filename) {
int
xmlFileRead (void * context, char * buffer, int len) {
int ret;
- if ((context == NULL) || (buffer == NULL))
+ if ((context == NULL) || (buffer == NULL))
return(-1);
ret = fread(&buffer[0], 1, len, (FILE *) context);
if (ret < 0) xmlIOErr(0, "fread()");
@@ -977,7 +1048,7 @@ static int
xmlFileWrite (void * context, const char * buffer, int len) {
int items;
- if ((context == NULL) || (buffer == NULL))
+ if ((context == NULL) || (buffer == NULL))
return(-1);
items = fwrite(&buffer[0], len, 1, (FILE *) context);
if ((items == 0) && (ferror((FILE *) context))) {
@@ -1092,7 +1163,12 @@ xmlGzfileOpen_real (const char *filename) {
gzFile fd;
if (!strcmp(filename, "-")) {
- fd = gzdopen(dup(0), "rb");
+ int duped_fd = dup(fileno(stdin));
+ fd = gzdopen(duped_fd, "rb");
+ if (fd == Z_NULL && duped_fd >= 0) {
+ close(duped_fd); /* gzdOpen() does not close on failure */
+ }
+
return((void *) fd);
}
@@ -1108,7 +1184,7 @@ xmlGzfileOpen_real (const char *filename) {
#else
path = &filename[7];
#endif
- } else
+ } else
path = filename;
if (path == NULL)
@@ -1116,7 +1192,11 @@ xmlGzfileOpen_real (const char *filename) {
if (!xmlCheckFilename(path))
return(NULL);
+#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
+ fd = xmlWrapGzOpen(path, "rb");
+#else
fd = gzopen(path, "rb");
+#endif
return((void *) fd);
}
@@ -1162,7 +1242,12 @@ xmlGzfileOpenW (const char *filename, int compression) {
snprintf(mode, sizeof(mode), "wb%d", compression);
if (!strcmp(filename, "-")) {
- fd = gzdopen(dup(1), mode);
+ int duped_fd = dup(fileno(stdout));
+ fd = gzdopen(duped_fd, "rb");
+ if (fd == Z_NULL && duped_fd >= 0) {
+ close(duped_fd); /* gzdOpen() does not close on failure */
+ }
+
return((void *) fd);
}
@@ -1178,13 +1263,17 @@ xmlGzfileOpenW (const char *filename, int compression) {
#else
path = &filename[7];
#endif
- } else
+ } else
path = filename;
if (path == NULL)
return(NULL);
+#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
+ fd = xmlWrapGzOpen(path, mode);
+#else
fd = gzopen(path, mode);
+#endif
return((void *) fd);
}
#endif /* LIBXML_OUTPUT_ENABLED */
@@ -1245,6 +1334,125 @@ xmlGzfileClose (void * context) {
}
#endif /* HAVE_ZLIB_H */
+#ifdef LIBXML_LZMA_ENABLED
+/************************************************************************
+ * *
+ * I/O for compressed file accesses *
+ * *
+ ************************************************************************/
+#include "xzlib.h"
+/**
+ * xmlXzfileMatch:
+ * @filename: the URI for matching
+ *
+ * input from compressed file test
+ *
+ * Returns 1 if matches, 0 otherwise
+ */
+static int
+xmlXzfileMatch (const char *filename ATTRIBUTE_UNUSED) {
+ return(1);
+}
+
+/**
+ * xmlXzFileOpen_real:
+ * @filename: the URI for matching
+ *
+ * input from compressed file open
+ * if @filename is " " then the standard input is used
+ *
+ * Returns an I/O context or NULL in case of error
+ */
+static void *
+xmlXzfileOpen_real (const char *filename) {
+ const char *path = NULL;
+ xzFile fd;
+
+ if (!strcmp(filename, "-")) {
+ fd = __libxml2_xzdopen(dup(fileno(stdin)), "rb");
+ return((void *) fd);
+ }
+
+ if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file://localhost/", 17)) {
+ path = &filename[16];
+ } else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:///", 8)) {
+ path = &filename[7];
+ } else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST "file:/", 6)) {
+ /* lots of generators seems to lazy to read RFC 1738 */
+ path = &filename[5];
+ } else
+ path = filename;
+
+ if (path == NULL)
+ return(NULL);
+ if (!xmlCheckFilename(path))
+ return(NULL);
+
+ fd = __libxml2_xzopen(path, "rb");
+ return((void *) fd);
+}
+
+/**
+ * xmlXzfileOpen:
+ * @filename: the URI for matching
+ *
+ * Wrapper around xmlXzfileOpen_real that try it with an unescaped
+ * version of @filename, if this fails fallback to @filename
+ *
+ * Returns a handler or NULL in case or failure
+ */
+static void *
+xmlXzfileOpen (const char *filename) {
+ char *unescaped;
+ void *retval;
+
+ retval = xmlXzfileOpen_real(filename);
+ if (retval == NULL) {
+ unescaped = xmlURIUnescapeString(filename, 0, NULL);
+ if (unescaped != NULL) {
+ retval = xmlXzfileOpen_real(unescaped);
+ }
+ xmlFree(unescaped);
+ }
+
+ return retval;
+}
+
+/**
+ * xmlXzfileRead:
+ * @context: the I/O context
+ * @buffer: where to drop data
+ * @len: number of bytes to write
+ *
+ * Read @len bytes to @buffer from the compressed I/O channel.
+ *
+ * Returns the number of bytes written
+ */
+static int
+xmlXzfileRead (void * context, char * buffer, int len) {
+ int ret;
+
+ ret = __libxml2_xzread((xzFile) context, &buffer[0], len);
+ if (ret < 0) xmlIOErr(0, "xzread()");
+ return(ret);
+}
+
+/**
+ * xmlXzfileClose:
+ * @context: the I/O context
+ *
+ * Close a compressed I/O channel
+ */
+static int
+xmlXzfileClose (void * context) {
+ int ret;
+
+ ret = (__libxml2_xzclose((xzFile) context) == LZMA_OK ) ? 0 : -1;
+ if (ret < 0) xmlIOErr(0, "xzclose()");
+ return(ret);
+}
+#endif /* LIBXML_LZMA_ENABLED */
+
#ifdef LIBXML_HTTP_ENABLED
/************************************************************************
* *
@@ -1306,7 +1514,7 @@ append_reverse_ulong( xmlZMemBuff * buff, unsigned long data ) {
/*
** This is plagiarized from putLong in gzio.c (zlib source) where
- ** the number "4" is hardcoded. If zlib is ever patched to
+ ** the number "4" is hardcoded. If zlib is ever patched to
** support 64 bit file sizes, this code would need to be patched
** as well.
*/
@@ -1358,7 +1566,7 @@ xmlFreeZMemBuff( xmlZMemBuffPtr buff ) {
*
* Create a memory buffer to hold the compressed XML document. The
* compressed document in memory will end up being identical to what
- * would be created if gzopen/gzwrite/gzclose were being used to
+ * would be created if gzopen/gzwrite/gzclose were being used to
* write the document to disk. The code for the header/trailer data to
* the compression is plagiarized from the zlib source files.
*/
@@ -1407,7 +1615,7 @@ xmlCreateZMemBuff( int compression ) {
buff->crc = crc32( 0L, NULL, 0 );
hdr_lgth = snprintf( (char *)buff->zbuff, buff->size,
"%c%c%c%c%c%c%c%c%c%c",
- GZ_MAGIC1, GZ_MAGIC2, Z_DEFLATED,
+ GZ_MAGIC1, GZ_MAGIC2, Z_DEFLATED,
0, 0, 0, 0, 0, 0, LXML_ZLIB_OS_CODE );
buff->zctrl.next_out = buff->zbuff + hdr_lgth;
buff->zctrl.avail_out = buff->size - hdr_lgth;
@@ -1445,11 +1653,11 @@ xmlZMemBuffExtend( xmlZMemBuffPtr buff, size_t ext_amt ) {
new_size = buff->size + ext_amt;
#ifdef DEBUG_HTTP
- if ( cur_used > new_size )
+ if ( cur_used > new_size )
xmlGenericError( xmlGenericErrorContext,
"xmlZMemBuffExtend: %s\n%s %d bytes.\n",
"Buffer overwrite detected during compressed memory",
- "buffer extension. Overflowed by",
+ "buffer extension. Overflowed by",
(cur_used - new_size ) );
#endif
@@ -1587,7 +1795,7 @@ xmlZMemBuffGetContent( xmlZMemBuffPtr buff, char ** data_ref ) {
"Error flushing zlib buffers. Error code", z_err );
xmlIOErr(XML_IO_WRITE, (const char *) msg);
}
-
+
return ( zlgth );
}
#endif /* LIBXML_OUTPUT_ENABLED */
@@ -1707,7 +1915,7 @@ xmlIOHTTPOpenW(const char *post_uri, int compression)
{
/* Any character conversions should have been done before this */
- ctxt->doc_buff = xmlAllocOutputBuffer(NULL);
+ ctxt->doc_buff = xmlAllocOutputBufferInternal(NULL);
}
if (ctxt->doc_buff == NULL) {
@@ -1718,7 +1926,7 @@ xmlIOHTTPOpenW(const char *post_uri, int compression)
return (ctxt);
}
#endif /* LIBXML_OUTPUT_ENABLED */
-
+
#ifdef LIBXML_OUTPUT_ENABLED
/**
* xmlIOHTTPDfltOpenW
@@ -1746,7 +1954,7 @@ xmlIOHTTPDfltOpenW( const char * post_uri ) {
*
* Returns the number of bytes written
*/
-int
+int
xmlIOHTTPRead(void * context, char * buffer, int len) {
if ((buffer == NULL) || (len < 0)) return(-1);
return(xmlNanoHTTPRead(context, &buffer[0], len));
@@ -1766,7 +1974,7 @@ xmlIOHTTPRead(void * context, char * buffer, int len) {
*/
static int
-xmlIOHTTPWrite( void * context, const char * buffer, int len ) {
+xmlIOHTTPWrite( void * context, const char * buffer, int len ) {
xmlIOHTTPWriteCtxtPtr ctxt = context;
@@ -1778,7 +1986,7 @@ xmlIOHTTPWrite( void * context, const char * buffer, int len ) {
/* Use gzwrite or fwrite as previously setup in the open call */
#ifdef HAVE_ZLIB_H
- if ( ctxt->compression > 0 )
+ if ( ctxt->compression > 0 )
len = xmlZMemBuffAppend( ctxt->doc_buff, buffer, len );
else
@@ -1853,8 +2061,8 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
/* Pull the data out of the memory output buffer */
xmlOutputBufferPtr dctxt = ctxt->doc_buff;
- http_content = (char *)dctxt->buffer->content;
- content_lgth = dctxt->buffer->use;
+ http_content = (char *) xmlBufContent(dctxt->buffer);
+ content_lgth = xmlBufUse(dctxt->buffer);
}
if ( http_content == NULL ) {
@@ -1869,7 +2077,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
else {
http_ctxt = xmlNanoHTTPMethod( ctxt->uri, http_mthd, http_content,
- &content_type, content_encoding,
+ &content_type, content_encoding,
content_lgth );
if ( http_ctxt != NULL ) {
@@ -1888,7 +2096,7 @@ xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
/*
** Since either content or reply may be gzipped,
- ** dump them to separate files instead of the
+ ** dump them to separate files instead of the
** standard error context.
*/
@@ -2025,7 +2233,7 @@ xmlIOFTPOpen (const char *filename) {
*
* Returns the number of bytes written
*/
-int
+int
xmlIOFTPRead(void * context, char * buffer, int len) {
if ((buffer == NULL) || (len < 0)) return(-1);
return(xmlNanoFTPRead(context, &buffer[0], len));
@@ -2088,7 +2296,7 @@ int
xmlRegisterOutputCallbacks(xmlOutputMatchCallback matchFunc,
xmlOutputOpenCallback openFunc, xmlOutputWriteCallback writeFunc,
xmlOutputCloseCallback closeFunc) {
- if (xmlOutputCallbackNr >= MAX_INPUT_CALLBACK) {
+ if (xmlOutputCallbackNr >= MAX_OUTPUT_CALLBACK) {
return(-1);
}
xmlOutputCallbackTable[xmlOutputCallbackNr].matchcallback = matchFunc;
@@ -2120,6 +2328,10 @@ xmlRegisterDefaultInputCallbacks(void) {
xmlRegisterInputCallbacks(xmlGzfileMatch, xmlGzfileOpen,
xmlGzfileRead, xmlGzfileClose);
#endif /* HAVE_ZLIB_H */
+#ifdef LIBXML_LZMA_ENABLED
+ xmlRegisterInputCallbacks(xmlXzfileMatch, xmlXzfileOpen,
+ xmlXzfileRead, xmlXzfileClose);
+#endif /* LIBXML_LZMA_ENABLED */
#ifdef LIBXML_HTTP_ENABLED
xmlRegisterInputCallbacks(xmlIOHTTPMatch, xmlIOHTTPOpen,
@@ -2217,15 +2429,15 @@ xmlAllocParserInputBuffer(xmlCharEncoding enc) {
return(NULL);
}
memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
- ret->buffer = xmlBufferCreateSize(2 * xmlDefaultBufferSize);
+ ret->buffer = xmlBufCreateSize(2 * xmlDefaultBufferSize);
if (ret->buffer == NULL) {
xmlFree(ret);
return(NULL);
}
- ret->buffer->alloc = XML_BUFFER_ALLOC_DOUBLEIT;
+ xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT);
ret->encoder = xmlGetCharEncodingHandler(enc);
if (ret->encoder != NULL)
- ret->raw = xmlBufferCreateSize(2 * xmlDefaultBufferSize);
+ ret->raw = xmlBufCreateSize(2 * xmlDefaultBufferSize);
else
ret->raw = NULL;
ret->readcallback = NULL;
@@ -2256,19 +2468,80 @@ xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) {
return(NULL);
}
memset(ret, 0, (size_t) sizeof(xmlOutputBuffer));
- ret->buffer = xmlBufferCreate();
+ ret->buffer = xmlBufCreate();
+ if (ret->buffer == NULL) {
+ xmlFree(ret);
+ return(NULL);
+ }
+
+ /* try to avoid a performance problem with Windows realloc() */
+ if (xmlBufGetAllocationScheme(ret->buffer) == XML_BUFFER_ALLOC_EXACT)
+ xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_DOUBLEIT);
+
+ ret->encoder = encoder;
+ if (encoder != NULL) {
+ ret->conv = xmlBufCreateSize(4000);
+ if (ret->conv == NULL) {
+ xmlFree(ret);
+ return(NULL);
+ }
+
+ /*
+ * This call is designed to initiate the encoder state
+ */
+ xmlCharEncOutput(ret, 1);
+ } else
+ ret->conv = NULL;
+ ret->writecallback = NULL;
+ ret->closecallback = NULL;
+ ret->context = NULL;
+ ret->written = 0;
+
+ return(ret);
+}
+
+/**
+ * xmlAllocOutputBufferInternal:
+ * @encoder: the encoding converter or NULL
+ *
+ * Create a buffered parser output
+ *
+ * Returns the new parser output or NULL
+ */
+xmlOutputBufferPtr
+xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder) {
+ xmlOutputBufferPtr ret;
+
+ ret = (xmlOutputBufferPtr) xmlMalloc(sizeof(xmlOutputBuffer));
+ if (ret == NULL) {
+ xmlIOErrMemory("creating output buffer");
+ return(NULL);
+ }
+ memset(ret, 0, (size_t) sizeof(xmlOutputBuffer));
+ ret->buffer = xmlBufCreate();
if (ret->buffer == NULL) {
xmlFree(ret);
return(NULL);
}
- ret->buffer->alloc = XML_BUFFER_ALLOC_DOUBLEIT;
+
+
+ /*
+ * For conversion buffers we use the special IO handling
+ */
+ xmlBufSetAllocationScheme(ret->buffer, XML_BUFFER_ALLOC_IO);
+
ret->encoder = encoder;
if (encoder != NULL) {
- ret->conv = xmlBufferCreateSize(4000);
+ ret->conv = xmlBufCreateSize(4000);
+ if (ret->conv == NULL) {
+ xmlFree(ret);
+ return(NULL);
+ }
+
/*
* This call is designed to initiate the encoder state
*/
- xmlCharEncOutFunc(encoder, ret->conv, NULL);
+ xmlCharEncOutput(ret, 1);
} else
ret->conv = NULL;
ret->writecallback = NULL;
@@ -2278,6 +2551,7 @@ xmlAllocOutputBuffer(xmlCharEncodingHandlerPtr encoder) {
return(ret);
}
+
#endif /* LIBXML_OUTPUT_ENABLED */
/**
@@ -2291,7 +2565,7 @@ xmlFreeParserInputBuffer(xmlParserInputBufferPtr in) {
if (in == NULL) return;
if (in->raw) {
- xmlBufferFree(in->raw);
+ xmlBufFree(in->raw);
in->raw = NULL;
}
if (in->encoder != NULL) {
@@ -2301,7 +2575,7 @@ xmlFreeParserInputBuffer(xmlParserInputBufferPtr in) {
in->closecallback(in->context);
}
if (in->buffer != NULL) {
- xmlBufferFree(in->buffer);
+ xmlBufFree(in->buffer);
in->buffer = NULL;
}
@@ -2333,14 +2607,14 @@ xmlOutputBufferClose(xmlOutputBufferPtr out)
}
written = out->written;
if (out->conv) {
- xmlBufferFree(out->conv);
+ xmlBufFree(out->conv);
out->conv = NULL;
}
if (out->encoder != NULL) {
xmlCharEncCloseFunc(out->encoder);
}
if (out->buffer != NULL) {
- xmlBufferFree(out->buffer);
+ xmlBufFree(out->buffer);
out->buffer = NULL;
}
@@ -2392,6 +2666,9 @@ __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
#ifdef HAVE_ZLIB_H
if ((xmlInputCallbackTable[i].opencallback == xmlGzfileOpen) &&
(strcmp(URI, "-") != 0)) {
+#if defined(ZLIB_VERNUM) && ZLIB_VERNUM >= 0x1230
+ ret->compressed = !gzdirect(context);
+#else
if (((z_stream *)context)->avail_in > 4) {
char *cptr, buff4[4];
cptr = (char *) ((z_stream *)context)->next_in;
@@ -2403,6 +2680,13 @@ __xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
gzrewind(context);
}
}
+#endif
+ }
+#endif
+#ifdef LIBXML_LZMA_ENABLED
+ if ((xmlInputCallbackTable[i].opencallback == xmlXzfileOpen) &&
+ (strcmp(URI, "-") != 0)) {
+ ret->compressed = __libxml2_xzcompressed(context);
}
#endif
}
@@ -2478,7 +2762,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
if ((compression > 0) && (compression <= 9) && (is_file_uri == 1)) {
context = xmlGzfileOpenW(unescaped, compression);
if (context != NULL) {
- ret = xmlAllocOutputBuffer(encoder);
+ ret = xmlAllocOutputBufferInternal(encoder);
if (ret != NULL) {
ret->context = context;
ret->writecallback = xmlGzfileWrite;
@@ -2515,7 +2799,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
if ((compression > 0) && (compression <= 9) && (is_file_uri == 1)) {
context = xmlGzfileOpenW(URI, compression);
if (context != NULL) {
- ret = xmlAllocOutputBuffer(encoder);
+ ret = xmlAllocOutputBufferInternal(encoder);
if (ret != NULL) {
ret->context = context;
ret->writecallback = xmlGzfileWrite;
@@ -2548,7 +2832,7 @@ __xmlOutputBufferCreateFilename(const char *URI,
/*
* Allocate the Output buffer front-end.
*/
- ret = xmlAllocOutputBuffer(encoder);
+ ret = xmlAllocOutputBufferInternal(encoder);
if (ret != NULL) {
ret->context = context;
ret->writecallback = xmlOutputCallbackTable[i].writecallback;
@@ -2585,7 +2869,7 @@ xmlOutputBufferCreateFilename(const char *URI,
/**
* xmlParserInputBufferCreateFile:
- * @file: a FILE*
+ * @file: a FILE*
* @enc: the charset encoding if known
*
* Create a buffered parser input for the progressive parsing of a FILE *
@@ -2615,7 +2899,7 @@ xmlParserInputBufferCreateFile(FILE *file, xmlCharEncoding enc) {
#ifdef LIBXML_OUTPUT_ENABLED
/**
* xmlOutputBufferCreateFile:
- * @file: a FILE*
+ * @file: a FILE*
* @encoder: the encoding converter or NULL
*
* Create a buffered output for the progressive saving to a FILE *
@@ -2632,7 +2916,7 @@ xmlOutputBufferCreateFile(FILE *file, xmlCharEncodingHandlerPtr encoder) {
if (file == NULL) return(NULL);
- ret = xmlAllocOutputBuffer(encoder);
+ ret = xmlAllocOutputBufferInternal(encoder);
if (ret != NULL) {
ret->context = file;
ret->writecallback = xmlFileWrite;
@@ -2666,6 +2950,39 @@ xmlOutputBufferCreateBuffer(xmlBufferPtr buffer,
return(ret);
}
+/**
+ * xmlOutputBufferGetContent:
+ * @out: an xmlOutputBufferPtr
+ *
+ * Gives a pointer to the data currently held in the output buffer
+ *
+ * Returns a pointer to the data or NULL in case of error
+ */
+const xmlChar *
+xmlOutputBufferGetContent(xmlOutputBufferPtr out) {
+ if ((out == NULL) || (out->buffer == NULL))
+ return(NULL);
+
+ return(xmlBufContent(out->buffer));
+}
+
+/**
+ * xmlOutputBufferGetSize:
+ * @out: an xmlOutputBufferPtr
+ *
+ * Gives the length of the data currently held in the output buffer
+ *
+ * Returns 0 in case or error or no data is held, the size otherwise
+ */
+size_t
+xmlOutputBufferGetSize(xmlOutputBufferPtr out) {
+ if ((out == NULL) || (out->buffer == NULL))
+ return(0);
+
+ return(xmlBufUse(out->buffer));
+}
+
+
#endif /* LIBXML_OUTPUT_ENABLED */
/**
@@ -2718,7 +3035,7 @@ xmlParserInputBufferCreateMem(const char *mem, int size, xmlCharEncoding enc) {
ret->context = (void *) mem;
ret->readcallback = (xmlInputReadCallback) xmlNop;
ret->closecallback = NULL;
- errcode = xmlBufferAdd(ret->buffer, (const xmlChar *) mem, size);
+ errcode = xmlBufAdd(ret->buffer, (const xmlChar *) mem, size);
if (errcode != 0) {
xmlFree(ret);
return(NULL);
@@ -2755,14 +3072,14 @@ xmlParserInputBufferCreateStatic(const char *mem, int size,
return(NULL);
}
memset(ret, 0, (size_t) sizeof(xmlParserInputBuffer));
- ret->buffer = xmlBufferCreateStatic((void *)mem, (size_t) size);
+ ret->buffer = xmlBufCreateStatic((void *)mem, (size_t) size);
if (ret->buffer == NULL) {
xmlFree(ret);
return(NULL);
}
ret->encoder = xmlGetCharEncodingHandler(enc);
if (ret->encoder != NULL)
- ret->raw = xmlBufferCreateSize(2 * xmlDefaultBufferSize);
+ ret->raw = xmlBufCreateSize(2 * xmlDefaultBufferSize);
else
ret->raw = NULL;
ret->compressed = -1;
@@ -2779,7 +3096,7 @@ xmlParserInputBufferCreateStatic(const char *mem, int size,
* @fd: a file descriptor number
* @encoder: the encoding converter or NULL
*
- * Create a buffered output for the progressive saving
+ * Create a buffered output for the progressive saving
* to a file descriptor
*
* Returns the new parser output or NULL
@@ -2790,7 +3107,7 @@ xmlOutputBufferCreateFd(int fd, xmlCharEncodingHandlerPtr encoder) {
if (fd < 0) return(NULL);
- ret = xmlAllocOutputBuffer(encoder);
+ ret = xmlAllocOutputBufferInternal(encoder);
if (ret != NULL) {
ret->context = (void *) (long) fd;
ret->writecallback = xmlFdWrite;
@@ -2851,7 +3168,7 @@ xmlOutputBufferCreateIO(xmlOutputWriteCallback iowrite,
if (iowrite == NULL) return(NULL);
- ret = xmlAllocOutputBuffer(encoder);
+ ret = xmlAllocOutputBufferInternal(encoder);
if (ret != NULL) {
ret->context = (void *) ioctx;
ret->writecallback = iowrite;
@@ -2931,33 +3248,33 @@ xmlParserInputBufferPush(xmlParserInputBufferPtr in,
* Store the data in the incoming raw buffer
*/
if (in->raw == NULL) {
- in->raw = xmlBufferCreate();
+ in->raw = xmlBufCreate();
}
- ret = xmlBufferAdd(in->raw, (const xmlChar *) buf, len);
+ ret = xmlBufAdd(in->raw, (const xmlChar *) buf, len);
if (ret != 0)
return(-1);
/*
* convert as much as possible to the parser reading buffer.
*/
- use = in->raw->use;
- nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
+ use = xmlBufUse(in->raw);
+ nbchars = xmlCharEncInput(in, 1);
if (nbchars < 0) {
xmlIOErr(XML_IO_ENCODER, NULL);
in->error = XML_IO_ENCODER;
return(-1);
}
- in->rawconsumed += (use - in->raw->use);
+ in->rawconsumed += (use - xmlBufUse(in->raw));
} else {
nbchars = len;
- ret = xmlBufferAdd(in->buffer, (xmlChar *) buf, nbchars);
+ ret = xmlBufAdd(in->buffer, (xmlChar *) buf, nbchars);
if (ret != 0)
return(-1);
}
#ifdef DEBUG_INPUT
xmlGenericError(xmlGenericErrorContext,
"I/O: pushed %d chars, buffer %d/%d\n",
- nbchars, in->buffer->use, in->buffer->size);
+ nbchars, xmlBufUse(in->buffer), xmlBufLength(in->buffer));
#endif
return(nbchars);
}
@@ -2995,29 +3312,23 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
char *buffer = NULL;
int res = 0;
int nbchars = 0;
- int buffree;
- unsigned int needSize;
if ((in == NULL) || (in->error)) return(-1);
if ((len <= MINLEN) && (len != 4))
len = MINLEN;
- buffree = in->buffer->size - in->buffer->use;
- if (buffree <= 0) {
+ if (xmlBufAvail(in->buffer) <= 0) {
xmlIOErr(XML_IO_BUFFER_FULL, NULL);
in->error = XML_IO_BUFFER_FULL;
return(-1);
}
- needSize = in->buffer->use + len + 1;
- if (needSize > in->buffer->size){
- if (!xmlBufferResize(in->buffer, needSize)){
- xmlIOErrMemory("growing input buffer");
- in->error = XML_ERR_NO_MEMORY;
- return(-1);
- }
+ if (xmlBufGrow(in->buffer, len + 1) < 0) {
+ xmlIOErrMemory("growing input buffer");
+ in->error = XML_ERR_NO_MEMORY;
+ return(-1);
}
- buffer = (char *)&in->buffer->content[in->buffer->use];
+ buffer = (char *)xmlBufEnd(in->buffer);
/*
* Call the read method for this I/O type.
@@ -3034,6 +3345,17 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
if (res < 0) {
return(-1);
}
+
+ /*
+ * try to establish compressed status of input if not done already
+ */
+ if (in->compressed == -1) {
+#ifdef LIBXML_LZMA_ENABLED
+ if (in->readcallback == xmlXzfileRead)
+ in->compressed = __libxml2_xzcompressed(in->context);
+#endif
+ }
+
len = res;
if (in->encoder != NULL) {
unsigned int use;
@@ -3042,32 +3364,31 @@ xmlParserInputBufferGrow(xmlParserInputBufferPtr in, int len) {
* Store the data in the incoming raw buffer
*/
if (in->raw == NULL) {
- in->raw = xmlBufferCreate();
+ in->raw = xmlBufCreate();
}
- res = xmlBufferAdd(in->raw, (const xmlChar *) buffer, len);
+ res = xmlBufAdd(in->raw, (const xmlChar *) buffer, len);
if (res != 0)
return(-1);
/*
* convert as much as possible to the parser reading buffer.
*/
- use = in->raw->use;
- nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw);
+ use = xmlBufUse(in->raw);
+ nbchars = xmlCharEncInput(in, 1);
if (nbchars < 0) {
xmlIOErr(XML_IO_ENCODER, NULL);
in->error = XML_IO_ENCODER;
return(-1);
}
- in->rawconsumed += (use - in->raw->use);
+ in->rawconsumed += (use - xmlBufUse(in->raw));
} else {
nbchars = len;
- in->buffer->use += nbchars;
- buffer[nbchars] = 0;
+ xmlBufAddLen(in->buffer, nbchars);
}
#ifdef DEBUG_INPUT
xmlGenericError(xmlGenericErrorContext,
- "I/O: read %d chars, buffer %d/%d\n",
- nbchars, in->buffer->use, in->buffer->size);
+ "I/O: read %d chars, buffer %d\n",
+ nbchars, xmlBufUse(in->buffer));
#endif
return(nbchars);
}
@@ -3089,8 +3410,7 @@ xmlParserInputBufferRead(xmlParserInputBufferPtr in, int len) {
if ((in == NULL) || (in->error)) return(-1);
if (in->readcallback != NULL)
return(xmlParserInputBufferGrow(in, len));
- else if ((in->buffer != NULL) &&
- (in->buffer->alloc == XML_BUFFER_ALLOC_IMMUTABLE))
+ else if (xmlBufGetAllocationScheme(in->buffer) == XML_BUFFER_ALLOC_IMMUTABLE)
return(0);
else
return(-1);
@@ -3135,30 +3455,30 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
* Store the data in the incoming raw buffer
*/
if (out->conv == NULL) {
- out->conv = xmlBufferCreate();
+ out->conv = xmlBufCreate();
}
- ret = xmlBufferAdd(out->buffer, (const xmlChar *) buf, chunk);
+ ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk);
if (ret != 0)
return(-1);
- if ((out->buffer->use < MINLEN) && (chunk == len))
+ if ((xmlBufUse(out->buffer) < MINLEN) && (chunk == len))
goto done;
/*
* convert as much as possible to the parser reading buffer.
*/
- ret = xmlCharEncOutFunc(out->encoder, out->conv, out->buffer);
+ ret = xmlCharEncOutput(out, 0);
if ((ret < 0) && (ret != -3)) {
xmlIOErr(XML_IO_ENCODER, NULL);
out->error = XML_IO_ENCODER;
return(-1);
}
- nbchars = out->conv->use;
+ nbchars = xmlBufUse(out->conv);
} else {
- ret = xmlBufferAdd(out->buffer, (const xmlChar *) buf, chunk);
+ ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk);
if (ret != 0)
return(-1);
- nbchars = out->buffer->use;
+ nbchars = xmlBufUse(out->buffer);
}
buf += chunk;
len -= chunk;
@@ -3171,15 +3491,15 @@ xmlOutputBufferWrite(xmlOutputBufferPtr out, int len, const char *buf) {
* second write the stuff to the I/O channel
*/
if (out->encoder != NULL) {
- ret = out->writecallback(out->context,
- (const char *)out->conv->content, nbchars);
+ ret = out->writecallback(out->context,
+ (const char *)xmlBufContent(out->conv), nbchars);
if (ret >= 0)
- xmlBufferShrink(out->conv, ret);
+ xmlBufShrink(out->conv, ret);
} else {
- ret = out->writecallback(out->context,
- (const char *)out->buffer->content, nbchars);
+ ret = out->writecallback(out->context,
+ (const char *)xmlBufContent(out->buffer), nbchars);
if (ret >= 0)
- xmlBufferShrink(out->buffer, ret);
+ xmlBufShrink(out->buffer, ret);
}
if (ret < 0) {
xmlIOErr(XML_IO_WRITE, NULL);
@@ -3221,9 +3541,9 @@ xmlEscapeContent(unsigned char* out, int *outlen,
const unsigned char* inend;
inend = in + (*inlen);
-
+
while ((in < inend) && (out < outend)) {
- if (*in == '<') {
+ if (*in == '<') {
if (outend - out < 4) break;
*out++ = '&';
*out++ = 'l';
@@ -3253,7 +3573,7 @@ xmlEscapeContent(unsigned char* out, int *outlen,
*out++ = (unsigned char) *in;
}
++in;
- }
+ }
*outlen = out - outstart;
*inlen = in - base;
return(0);
@@ -3287,7 +3607,8 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
if ((out == NULL) || (out->error) || (str == NULL) ||
(out->buffer == NULL) ||
- (out->buffer->alloc == XML_BUFFER_ALLOC_IMMUTABLE)) return(-1);
+ (xmlBufGetAllocationScheme(out->buffer) == XML_BUFFER_ALLOC_IMMUTABLE))
+ return(-1);
len = strlen((const char *)str);
if (len < 0) return(0);
if (out->error) return(-1);
@@ -3300,7 +3621,18 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
* how many bytes to consume and how many bytes to store.
*/
cons = len;
- chunk = (out->buffer->size - out->buffer->use) - 1;
+ chunk = xmlBufAvail(out->buffer) - 1;
+
+ /*
+ * make sure we have enough room to save first, if this is
+ * not the case force a flush, but make sure we stay in the loop
+ */
+ if (chunk < 40) {
+ if (xmlBufGrow(out->buffer, 100) < 0)
+ return(-1);
+ oldwritten = -1;
+ continue;
+ }
/*
* first handle encoding stuff.
@@ -3310,36 +3642,33 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
* Store the data in the incoming raw buffer
*/
if (out->conv == NULL) {
- out->conv = xmlBufferCreate();
+ out->conv = xmlBufCreate();
}
- ret = escaping(out->buffer->content + out->buffer->use ,
+ ret = escaping(xmlBufEnd(out->buffer) ,
&chunk, str, &cons);
if ((ret < 0) || (chunk == 0)) /* chunk==0 => nothing done */
return(-1);
- out->buffer->use += chunk;
- out->buffer->content[out->buffer->use] = 0;
+ xmlBufAddLen(out->buffer, chunk);
- if ((out->buffer->use < MINLEN) && (cons == len))
+ if ((xmlBufUse(out->buffer) < MINLEN) && (cons == len))
goto done;
/*
* convert as much as possible to the output buffer.
*/
- ret = xmlCharEncOutFunc(out->encoder, out->conv, out->buffer);
+ ret = xmlCharEncOutput(out, 0);
if ((ret < 0) && (ret != -3)) {
xmlIOErr(XML_IO_ENCODER, NULL);
out->error = XML_IO_ENCODER;
return(-1);
}
- nbchars = out->conv->use;
+ nbchars = xmlBufUse(out->conv);
} else {
- ret = escaping(out->buffer->content + out->buffer->use ,
- &chunk, str, &cons);
+ ret = escaping(xmlBufEnd(out->buffer), &chunk, str, &cons);
if ((ret < 0) || (chunk == 0)) /* chunk==0 => nothing done */
return(-1);
- out->buffer->use += chunk;
- out->buffer->content[out->buffer->use] = 0;
- nbchars = out->buffer->use;
+ xmlBufAddLen(out->buffer, chunk);
+ nbchars = xmlBufUse(out->buffer);
}
str += cons;
len -= cons;
@@ -3352,15 +3681,15 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
* second write the stuff to the I/O channel
*/
if (out->encoder != NULL) {
- ret = out->writecallback(out->context,
- (const char *)out->conv->content, nbchars);
+ ret = out->writecallback(out->context,
+ (const char *)xmlBufContent(out->conv), nbchars);
if (ret >= 0)
- xmlBufferShrink(out->conv, ret);
+ xmlBufShrink(out->conv, ret);
} else {
- ret = out->writecallback(out->context,
- (const char *)out->buffer->content, nbchars);
+ ret = out->writecallback(out->context,
+ (const char *)xmlBufContent(out->buffer), nbchars);
if (ret >= 0)
- xmlBufferShrink(out->buffer, ret);
+ xmlBufShrink(out->buffer, ret);
}
if (ret < 0) {
xmlIOErr(XML_IO_WRITE, NULL);
@@ -3368,8 +3697,8 @@ xmlOutputBufferWriteEscape(xmlOutputBufferPtr out, const xmlChar *str,
return(ret);
}
out->written += ret;
- } else if (out->buffer->size - out->buffer->use < MINLEN) {
- xmlBufferResize(out->buffer, out->buffer->size + MINLEN);
+ } else if (xmlBufAvail(out->buffer) < MINLEN) {
+ xmlBufGrow(out->buffer, MINLEN);
}
written += nbchars;
} while ((len > 0) && (oldwritten != written));
@@ -3398,7 +3727,7 @@ done:
int
xmlOutputBufferWriteString(xmlOutputBufferPtr out, const char *str) {
int len;
-
+
if ((out == NULL) || (out->error)) return(-1);
if (str == NULL)
return(-1);
@@ -3427,14 +3756,16 @@ xmlOutputBufferFlush(xmlOutputBufferPtr out) {
*/
if ((out->conv != NULL) && (out->encoder != NULL)) {
/*
- * convert as much as possible to the parser reading buffer.
+ * convert as much as possible to the parser output buffer.
*/
- nbchars = xmlCharEncOutFunc(out->encoder, out->conv, out->buffer);
- if (nbchars < 0) {
- xmlIOErr(XML_IO_ENCODER, NULL);
- out->error = XML_IO_ENCODER;
- return(-1);
- }
+ do {
+ nbchars = xmlCharEncOutput(out, 0);
+ if (nbchars < 0) {
+ xmlIOErr(XML_IO_ENCODER, NULL);
+ out->error = XML_IO_ENCODER;
+ return(-1);
+ }
+ } while (nbchars);
}
/*
@@ -3443,14 +3774,16 @@ xmlOutputBufferFlush(xmlOutputBufferPtr out) {
if ((out->conv != NULL) && (out->encoder != NULL) &&
(out->writecallback != NULL)) {
ret = out->writecallback(out->context,
- (const char *)out->conv->content, out->conv->use);
+ (const char *)xmlBufContent(out->conv),
+ xmlBufUse(out->conv));
if (ret >= 0)
- xmlBufferShrink(out->conv, ret);
+ xmlBufShrink(out->conv, ret);
} else if (out->writecallback != NULL) {
ret = out->writecallback(out->context,
- (const char *)out->buffer->content, out->buffer->use);
+ (const char *)xmlBufContent(out->buffer),
+ xmlBufUse(out->buffer));
if (ret >= 0)
- xmlBufferShrink(out->buffer, ret);
+ xmlBufShrink(out->buffer, ret);
}
if (ret < 0) {
xmlIOErr(XML_IO_FLUSH, NULL);
@@ -3480,7 +3813,6 @@ xmlParserGetDirectory(const char *filename) {
char *ret = NULL;
char dir[1024];
char *cur;
- char sep = '/';
#ifdef _WIN32_WCE /* easy way by now ... wince does not have dirs! */
return NULL;
@@ -3490,18 +3822,21 @@ xmlParserGetDirectory(const char *filename) {
xmlRegisterDefaultInputCallbacks();
if (filename == NULL) return(NULL);
+
#if defined(WIN32) && !defined(__CYGWIN__)
- sep = '\\';
+# define IS_XMLPGD_SEP(ch) ((ch=='/')||(ch=='\\'))
+#else
+# define IS_XMLPGD_SEP(ch) (ch=='/')
#endif
strncpy(dir, filename, 1023);
dir[1023] = 0;
cur = &dir[strlen(dir)];
while (cur > dir) {
- if (*cur == sep) break;
+ if (IS_XMLPGD_SEP(*cur)) break;
cur --;
}
- if (*cur == sep) {
+ if (IS_XMLPGD_SEP(*cur)) {
if (cur == dir) dir[1] = 0;
else *cur = 0;
ret = xmlMemStrdup(dir);
@@ -3512,6 +3847,7 @@ xmlParserGetDirectory(const char *filename) {
}
}
return(ret);
+#undef IS_XMLPGD_SEP
}
/****************************************************************
@@ -3612,9 +3948,9 @@ static int xmlNoNetExists(const char *URL) {
#else
path = &URL[7];
#endif
- } else
+ } else
path = URL;
-
+
return xmlCheckFilename(path);
}
@@ -3632,7 +3968,7 @@ static int xmlNoNetExists(const char *URL) {
*
* Returns a new allocated URL, or NULL.
*/
-xmlChar *
+static xmlChar *
xmlResolveResourceFromCatalog(const char *URL, const char *ID,
xmlParserCtxtPtr ctxt) {
xmlChar *resource = NULL;
@@ -3802,9 +4138,9 @@ xmlLoadExternalEntity(const char *URL, const char *ID,
}
/************************************************************************
- * *
- * Disabling Network access *
- * *
+ * *
+ * Disabling Network access *
+ * *
************************************************************************/
/**
diff --git a/gnulib-local/lib/libxml/xmlIO.in.h b/gnulib-local/lib/libxml/xmlIO.in.h
index eea9ed6..3e41744 100644
--- a/gnulib-local/lib/libxml/xmlIO.in.h
+++ b/gnulib-local/lib/libxml/xmlIO.in.h
@@ -26,7 +26,7 @@ extern "C" {
* xmlInputMatchCallback:
* @filename: the filename or URI
*
- * Callback used in the I/O Input API to detect if the current handler
+ * Callback used in the I/O Input API to detect if the current handler
* can provide input fonctionnalities for this resource.
*
* Returns 1 if yes and 0 if another Input module should be used
@@ -72,7 +72,7 @@ typedef int (XMLCALL *xmlInputCloseCallback) (void * context);
* xmlOutputMatchCallback:
* @filename: the filename or URI
*
- * Callback used in the I/O Output API to detect if the current handler
+ * Callback used in the I/O Output API to detect if the current handler
* can provide output fonctionnalities for this resource.
*
* Returns 1 if yes and 0 if another Output module should be used
@@ -126,11 +126,11 @@ struct _xmlParserInputBuffer {
void* context;
xmlInputReadCallback readcallback;
xmlInputCloseCallback closecallback;
-
+
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
-
- xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 */
- xmlBufferPtr raw; /* if encoder != NULL buffer for raw input */
+
+ xmlBufPtr buffer; /* Local buffer encoded in UTF-8 */
+ xmlBufPtr raw; /* if encoder != NULL buffer for raw input */
int compressed; /* -1=unknown, 0=not compressed, 1=compressed */
int error;
unsigned long rawconsumed;/* amount consumed from raw */
@@ -142,11 +142,11 @@ struct _xmlOutputBuffer {
void* context;
xmlOutputWriteCallback writecallback;
xmlOutputCloseCallback closecallback;
-
+
xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */
-
- xmlBufferPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
- xmlBufferPtr conv; /* if encoder != NULL buffer for output */
+
+ xmlBufPtr buffer; /* Local buffer encoded in UTF-8 or ISOLatin */
+ xmlBufPtr conv; /* if encoder != NULL buffer for output */
int written; /* total number of byte written */
int error;
};
@@ -155,13 +155,13 @@ struct _xmlOutputBuffer {
/*
* Interfaces for input
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCleanupInputCallbacks (void);
XMLPUBFUN int XMLCALL
xmlPopInputCallbacks (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRegisterDefaultInputCallbacks (void);
XMLPUBFUN xmlParserInputBufferPtr XMLCALL
xmlAllocParserInputBuffer (xmlCharEncoding enc);
@@ -186,22 +186,22 @@ XMLPUBFUN xmlParserInputBufferPtr XMLCALL
xmlInputCloseCallback ioclose,
void *ioctx,
xmlCharEncoding enc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParserInputBufferRead (xmlParserInputBufferPtr in,
int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
int len);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlParserInputBufferPush (xmlParserInputBufferPtr in,
int len,
const char *buf);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeParserInputBuffer (xmlParserInputBufferPtr in);
-XMLPUBFUN char * XMLCALL
+XMLPUBFUN char * XMLCALL
xmlParserGetDirectory (const char *filename);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRegisterInputCallbacks (xmlInputMatchCallback matchFunc,
xmlInputOpenCallback openFunc,
xmlInputReadCallback readFunc,
@@ -209,15 +209,15 @@ XMLPUBFUN int XMLCALL
xmlParserInputBufferPtr
__xmlParserInputBufferCreateFilename(const char *URI,
- xmlCharEncoding enc);
+ xmlCharEncoding enc);
#ifdef LIBXML_OUTPUT_ENABLED
/*
* Interfaces for output
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCleanupOutputCallbacks (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRegisterDefaultOutputCallbacks(void);
XMLPUBFUN xmlOutputBufferPtr XMLCALL
xmlAllocOutputBuffer (xmlCharEncodingHandlerPtr encoder);
@@ -245,24 +245,30 @@ XMLPUBFUN xmlOutputBufferPtr XMLCALL
void *ioctx,
xmlCharEncodingHandlerPtr encoder);
-XMLPUBFUN int XMLCALL
+/* Couple of APIs to get the output without digging into the buffers */
+XMLPUBFUN const xmlChar * XMLCALL
+ xmlOutputBufferGetContent (xmlOutputBufferPtr out);
+XMLPUBFUN size_t XMLCALL
+ xmlOutputBufferGetSize (xmlOutputBufferPtr out);
+
+XMLPUBFUN int XMLCALL
xmlOutputBufferWrite (xmlOutputBufferPtr out,
int len,
const char *buf);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlOutputBufferWriteString (xmlOutputBufferPtr out,
const char *str);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlOutputBufferWriteEscape (xmlOutputBufferPtr out,
const xmlChar *str,
xmlCharEncodingOutputFunc escaping);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlOutputBufferFlush (xmlOutputBufferPtr out);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlOutputBufferClose (xmlOutputBufferPtr out);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRegisterOutputCallbacks (xmlOutputMatchCallback matchFunc,
xmlOutputOpenCallback openFunc,
xmlOutputWriteCallback writeFunc,
@@ -275,10 +281,10 @@ xmlOutputBufferPtr
#ifdef LIBXML_HTTP_ENABLED
/* This function only exists if HTTP support built into the library */
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRegisterHTTPPostCallbacks (void );
#endif /* LIBXML_HTTP_ENABLED */
-
+
#endif /* LIBXML_OUTPUT_ENABLED */
XMLPUBFUN xmlParserInputPtr XMLCALL
@@ -288,69 +294,69 @@ XMLPUBFUN xmlParserInputPtr XMLCALL
/*
* A predefined entity loader disabling network accesses
*/
-XMLPUBFUN xmlParserInputPtr XMLCALL
+XMLPUBFUN xmlParserInputPtr XMLCALL
xmlNoNetExternalEntityLoader (const char *URL,
const char *ID,
xmlParserCtxtPtr ctxt);
-/*
- * xmlNormalizeWindowsPath is obsolete, don't use it.
+/*
+ * xmlNormalizeWindowsPath is obsolete, don't use it.
* Check xmlCanonicPath in uri.h for a better alternative.
*/
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlNormalizeWindowsPath (const xmlChar *path);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlCheckFilename (const char *path);
/**
- * Default 'file://' protocol callbacks
+ * Default 'file://' protocol callbacks
*/
-XMLPUBFUN int XMLCALL
- xmlFileMatch (const char *filename);
-XMLPUBFUN void * XMLCALL
- xmlFileOpen (const char *filename);
-XMLPUBFUN int XMLCALL
- xmlFileRead (void * context,
- char * buffer,
+XMLPUBFUN int XMLCALL
+ xmlFileMatch (const char *filename);
+XMLPUBFUN void * XMLCALL
+ xmlFileOpen (const char *filename);
+XMLPUBFUN int XMLCALL
+ xmlFileRead (void * context,
+ char * buffer,
int len);
-XMLPUBFUN int XMLCALL
- xmlFileClose (void * context);
+XMLPUBFUN int XMLCALL
+ xmlFileClose (void * context);
/**
- * Default 'http://' protocol callbacks
+ * Default 'http://' protocol callbacks
*/
#ifdef LIBXML_HTTP_ENABLED
-XMLPUBFUN int XMLCALL
- xmlIOHTTPMatch (const char *filename);
-XMLPUBFUN void * XMLCALL
- xmlIOHTTPOpen (const char *filename);
+XMLPUBFUN int XMLCALL
+ xmlIOHTTPMatch (const char *filename);
+XMLPUBFUN void * XMLCALL
+ xmlIOHTTPOpen (const char *filename);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
xmlIOHTTPOpenW (const char * post_uri,
int compression );
#endif /* LIBXML_OUTPUT_ENABLED */
-XMLPUBFUN int XMLCALL
- xmlIOHTTPRead (void * context,
- char * buffer,
+XMLPUBFUN int XMLCALL
+ xmlIOHTTPRead (void * context,
+ char * buffer,
int len);
-XMLPUBFUN int XMLCALL
- xmlIOHTTPClose (void * context);
+XMLPUBFUN int XMLCALL
+ xmlIOHTTPClose (void * context);
#endif /* LIBXML_HTTP_ENABLED */
/**
- * Default 'ftp://' protocol callbacks
+ * Default 'ftp://' protocol callbacks
*/
-#ifdef LIBXML_FTP_ENABLED
-XMLPUBFUN int XMLCALL
- xmlIOFTPMatch (const char *filename);
-XMLPUBFUN void * XMLCALL
- xmlIOFTPOpen (const char *filename);
-XMLPUBFUN int XMLCALL
- xmlIOFTPRead (void * context,
- char * buffer,
+#ifdef LIBXML_FTP_ENABLED
+XMLPUBFUN int XMLCALL
+ xmlIOFTPMatch (const char *filename);
+XMLPUBFUN void * XMLCALL
+ xmlIOFTPOpen (const char *filename);
+XMLPUBFUN int XMLCALL
+ xmlIOFTPRead (void * context,
+ char * buffer,
int len);
-XMLPUBFUN int XMLCALL
- xmlIOFTPClose (void * context);
+XMLPUBFUN int XMLCALL
+ xmlIOFTPClose (void * context);
#endif /* LIBXML_FTP_ENABLED */
#ifdef __cplusplus
diff --git a/gnulib-local/lib/libxml/xmlautomata.in.h b/gnulib-local/lib/libxml/xmlautomata.in.h
index f98b55e..bf1b131 100644
--- a/gnulib-local/lib/libxml/xmlautomata.in.h
+++ b/gnulib-local/lib/libxml/xmlautomata.in.h
@@ -40,25 +40,25 @@ typedef xmlAutomataState *xmlAutomataStatePtr;
/*
* Building API
*/
-XMLPUBFUN xmlAutomataPtr XMLCALL
+XMLPUBFUN xmlAutomataPtr XMLCALL
xmlNewAutomata (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlFreeAutomata (xmlAutomataPtr am);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataGetInitState (xmlAutomataPtr am);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlAutomataSetFinalState (xmlAutomataPtr am,
xmlAutomataStatePtr state);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewState (xmlAutomataPtr am);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewTransition (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
const xmlChar *token,
void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewTransition2 (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
@@ -73,7 +73,7 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
const xmlChar *token2,
void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewCountTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
@@ -81,7 +81,7 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
int min,
int max,
void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewCountTrans2 (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
@@ -90,7 +90,7 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
int min,
int max,
void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewOnceTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
@@ -99,46 +99,46 @@ XMLPUBFUN xmlAutomataStatePtr XMLCALL
int max,
void *data);
XMLPUBFUN xmlAutomataStatePtr XMLCALL
- xmlAutomataNewOnceTrans2 (xmlAutomataPtr am,
+ xmlAutomataNewOnceTrans2 (xmlAutomataPtr am,
xmlAutomataStatePtr from,
- xmlAutomataStatePtr to,
+ xmlAutomataStatePtr to,
const xmlChar *token,
const xmlChar *token2,
- int min,
- int max,
+ int min,
+ int max,
void *data);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewAllTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
int lax);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewEpsilon (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewCountedTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
int counter);
-XMLPUBFUN xmlAutomataStatePtr XMLCALL
+XMLPUBFUN xmlAutomataStatePtr XMLCALL
xmlAutomataNewCounterTrans (xmlAutomataPtr am,
xmlAutomataStatePtr from,
xmlAutomataStatePtr to,
int counter);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlAutomataNewCounter (xmlAutomataPtr am,
int min,
int max);
-XMLPUBFUN xmlRegexpPtr XMLCALL
+XMLPUBFUN xmlRegexpPtr XMLCALL
xmlAutomataCompile (xmlAutomataPtr am);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlAutomataIsDeterminist (xmlAutomataPtr am);
#ifdef __cplusplus
}
-#endif
+#endif
#endif /* LIBXML_AUTOMATA_ENABLED */
#endif /* LIBXML_REGEXP_ENABLED */
diff --git a/gnulib-local/lib/libxml/xmlerror.in.h b/gnulib-local/lib/libxml/xmlerror.in.h
index c5f2164..43e68ca 100644
--- a/gnulib-local/lib/libxml/xmlerror.in.h
+++ b/gnulib-local/lib/libxml/xmlerror.in.h
@@ -61,7 +61,10 @@ typedef enum {
XML_FROM_CHECK, /* The error checking module */
XML_FROM_WRITER, /* The xmlwriter module */
XML_FROM_MODULE, /* The dynamically loaded module module*/
- XML_FROM_I18N /* The module handling character conversion */
+ XML_FROM_I18N, /* The module handling character conversion */
+ XML_FROM_SCHEMATRONV,/* The Schematron validator module */
+ XML_FROM_BUFFER, /* The buffers module */
+ XML_FROM_URI /* The URI module */
} xmlErrorDomain;
/**
@@ -83,7 +86,7 @@ struct _xmlError {
char *str2; /* extra string information */
char *str3; /* extra string information */
int int1; /* extra number information */
- int int2; /* column number of the error or 0 if N/A (todo: rename this field when we would break ABI) */
+ int int2; /* error column # or 0 if N/A (todo: rename field when we would brk ABI) */
void *ctxt; /* the parser context if available */
void *node; /* the node in the tree */
};
@@ -202,11 +205,16 @@ typedef enum {
XML_ERR_NOTATION_PROCESSING, /* 105 */
XML_WAR_NS_COLUMN, /* 106 */
XML_WAR_ENTITY_REDEFINED, /* 107 */
+ XML_ERR_UNKNOWN_VERSION, /* 108 */
+ XML_ERR_VERSION_MISMATCH, /* 109 */
+ XML_ERR_NAME_TOO_LONG, /* 110 */
+ XML_ERR_USER_STOP, /* 111 */
XML_NS_ERR_XML_NAMESPACE = 200,
XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */
XML_NS_ERR_QNAME, /* 202 */
XML_NS_ERR_ATTRIBUTE_REDEFINED, /* 203 */
XML_NS_ERR_EMPTY, /* 204 */
+ XML_NS_ERR_COLON, /* 205 */
XML_DTD_ATTRIBUTE_DEFAULT = 500,
XML_DTD_ATTRIBUTE_REDEFINED, /* 501 */
XML_DTD_ATTRIBUTE_VALUE, /* 502 */
@@ -248,6 +256,7 @@ typedef enum {
XML_DTD_STANDALONE_DEFAULTED, /* 538 */
XML_DTD_XMLID_VALUE, /* 539 */
XML_DTD_XMLID_TYPE, /* 540 */
+ XML_DTD_DUP_TOKEN, /* 541 */
XML_HTML_STRUCURE_ERROR = 800,
XML_HTML_UNKNOWN_TAG, /* 801 */
XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000,
@@ -398,6 +407,7 @@ typedef enum {
XML_TREE_INVALID_HEX = 1300,
XML_TREE_INVALID_DEC, /* 1301 */
XML_TREE_UNTERMINATED_ENTITY, /* 1302 */
+ XML_TREE_NOT_UTF8, /* 1303 */
XML_SAVE_NOT_UTF8 = 1400,
XML_SAVE_CHAR_INVALID, /* 1401 */
XML_SAVE_NO_DOCTYPE, /* 1402 */
@@ -639,7 +649,7 @@ typedef enum {
XML_SCHEMAV_CVC_ELT_4_3, /* 1852 */
XML_SCHEMAV_CVC_ELT_5_1_1, /* 1853 */
XML_SCHEMAV_CVC_ELT_5_1_2, /* 1854 */
- XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */
+ XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */
XML_SCHEMAV_CVC_ELT_5_2_2_1, /* 1856 */
XML_SCHEMAV_CVC_ELT_5_2_2_2_1, /* 1857 */
XML_SCHEMAV_CVC_ELT_5_2_2_2_2, /* 1858 */
@@ -664,7 +674,7 @@ typedef enum {
XML_SCHEMAV_CVC_IDC, /* 1877 */
XML_SCHEMAV_CVC_WILDCARD, /* 1878 */
XML_SCHEMAV_MISC, /* 1879 */
- XML_XPTR_UNKNOWN_SCHEME = 1900,
+ XML_XPTR_UNKNOWN_SCHEME = 1900,
XML_XPTR_CHILDSEQ_START, /* 1901 */
XML_XPTR_EVAL_FAILED, /* 1902 */
XML_XPTR_EXTRA_OBJECTS, /* 1903 */
@@ -685,15 +695,15 @@ typedef enum {
XML_SCHEMAP_SRC_SIMPLE_TYPE_2, /* 3001 */
XML_SCHEMAP_SRC_SIMPLE_TYPE_3, /* 3002 */
XML_SCHEMAP_SRC_SIMPLE_TYPE_4, /* 3003 */
- XML_SCHEMAP_SRC_RESOLVE, /* 3004 */
+ XML_SCHEMAP_SRC_RESOLVE, /* 3004 */
XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, /* 3005 */
XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, /* 3006 */
XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, /* 3007 */
XML_SCHEMAP_ST_PROPS_CORRECT_1, /* 3008 */
XML_SCHEMAP_ST_PROPS_CORRECT_2, /* 3009 */
- XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */
+ XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */
XML_SCHEMAP_COS_ST_RESTRICTS_1_1, /* 3011 */
- XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */
+ XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */
XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, /* 3013 */
XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, /* 3014 */
XML_SCHEMAP_COS_ST_RESTRICTS_2_1, /* 3015 */
@@ -712,7 +722,7 @@ typedef enum {
XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, /* 3028 */
XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, /* 3029 */
XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, /* 3030 */
- XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */
+ XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */
XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, /* 3032 */
XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, /* 3033 */
XML_SCHEMAP_S4S_ELEM_MISSING, /* 3034 */
@@ -731,14 +741,14 @@ typedef enum {
XML_SCHEMAP_E_PROPS_CORRECT_4, /* 3047 */
XML_SCHEMAP_E_PROPS_CORRECT_5, /* 3048 */
XML_SCHEMAP_E_PROPS_CORRECT_6, /* 3049 */
- XML_SCHEMAP_SRC_INCLUDE, /* 3050 */
+ XML_SCHEMAP_SRC_INCLUDE, /* 3050 */
XML_SCHEMAP_SRC_ATTRIBUTE_1, /* 3051 */
XML_SCHEMAP_SRC_ATTRIBUTE_2, /* 3052 */
XML_SCHEMAP_SRC_ATTRIBUTE_3_1, /* 3053 */
XML_SCHEMAP_SRC_ATTRIBUTE_3_2, /* 3054 */
XML_SCHEMAP_SRC_ATTRIBUTE_4, /* 3055 */
XML_SCHEMAP_NO_XMLNS, /* 3056 */
- XML_SCHEMAP_NO_XSI, /* 3057 */
+ XML_SCHEMAP_NO_XSI, /* 3057 */
XML_SCHEMAP_COS_VALID_DEFAULT_1, /* 3058 */
XML_SCHEMAP_COS_VALID_DEFAULT_2_1, /* 3059 */
XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, /* 3060 */
@@ -773,6 +783,8 @@ typedef enum {
XML_SCHEMAP_AU_PROPS_CORRECT, /* 3088 */
XML_SCHEMAP_A_PROPS_CORRECT_3, /* 3089 */
XML_SCHEMAP_COS_ALL_LIMITED, /* 3090 */
+ XML_SCHEMATRONV_ASSERT = 4000, /* 4000 */
+ XML_SCHEMATRONV_REPORT,
XML_MODULE_OPEN = 4900, /* 4900 */
XML_MODULE_CLOSE, /* 4901 */
XML_CHECK_FOUND_ELEMENT = 5000,
@@ -817,11 +829,8 @@ typedef enum {
XML_I18N_NO_HANDLER, /* 6001 */
XML_I18N_EXCESS_HANDLER, /* 6002 */
XML_I18N_CONV_FAILED, /* 6003 */
- XML_I18N_NO_OUTPUT /* 6004 */
-#if 0
- XML_CHECK_, /* 5033 */
- XML_CHECK_X /* 503 */
-#endif
+ XML_I18N_NO_OUTPUT, /* 6004 */
+ XML_BUF_OVERFLOW = 7000
} xmlParserErrors;
/**
@@ -835,7 +844,7 @@ typedef enum {
*/
typedef void (XMLCDECL *xmlGenericErrorFunc) (void *ctx,
const char *msg,
- ...);
+ ...) LIBXML_ATTR_FORMAT(2,3);
/**
* xmlStructuredErrorFunc:
* @userData: user provided data for the error callback
@@ -850,38 +859,38 @@ typedef void (XMLCALL *xmlStructuredErrorFunc) (void *userData, xmlErrorPtr erro
* Use the following function to reset the two global variables
* xmlGenericError and xmlGenericErrorContext.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSetGenericErrorFunc (void *ctx,
xmlGenericErrorFunc handler);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
initGenericErrorDefaultFunc (xmlGenericErrorFunc *handler);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSetStructuredErrorFunc (void *ctx,
xmlStructuredErrorFunc handler);
/*
* Default message routines used by SAX and Valid context for error
* and warning reporting.
*/
-XMLPUBFUN void XMLCDECL
+XMLPUBFUN void XMLCDECL
xmlParserError (void *ctx,
const char *msg,
- ...);
-XMLPUBFUN void XMLCDECL
+ ...) LIBXML_ATTR_FORMAT(2,3);
+XMLPUBFUN void XMLCDECL
xmlParserWarning (void *ctx,
const char *msg,
- ...);
-XMLPUBFUN void XMLCDECL
+ ...) LIBXML_ATTR_FORMAT(2,3);
+XMLPUBFUN void XMLCDECL
xmlParserValidityError (void *ctx,
const char *msg,
- ...);
-XMLPUBFUN void XMLCDECL
+ ...) LIBXML_ATTR_FORMAT(2,3);
+XMLPUBFUN void XMLCDECL
xmlParserValidityWarning (void *ctx,
const char *msg,
- ...);
-XMLPUBFUN void XMLCALL
+ ...) LIBXML_ATTR_FORMAT(2,3);
+XMLPUBFUN void XMLCALL
xmlParserPrintFileInfo (xmlParserInputPtr input);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlParserPrintFileContext (xmlParserInputPtr input);
/*
@@ -899,19 +908,19 @@ XMLPUBFUN void XMLCALL
xmlResetError (xmlErrorPtr err);
XMLPUBFUN int XMLCALL
xmlCopyError (xmlErrorPtr from,
- xmlErrorPtr to);
+ xmlErrorPtr to);
#ifdef IN_LIBXML
/*
* Internal callback reporting routine
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
__xmlRaiseError (xmlStructuredErrorFunc schannel,
- xmlGenericErrorFunc channel,
- void *data,
+ xmlGenericErrorFunc channel,
+ void *data,
void *ctx,
- void *node,
- int domain,
+ void *node,
+ int domain,
int code,
xmlErrorLevel level,
const char *file,
@@ -922,10 +931,10 @@ XMLPUBFUN void XMLCALL
int int1,
int col,
const char *msg,
- ...);
-XMLPUBFUN void XMLCALL
+ ...) LIBXML_ATTR_FORMAT(16,17);
+XMLPUBFUN void XMLCALL
__xmlSimpleError (int domain,
- int code,
+ int code,
xmlNodePtr node,
const char *msg,
const char *extra);
diff --git a/gnulib-local/lib/libxml/xmlexports.in.h b/gnulib-local/lib/libxml/xmlexports.in.h
index 29a6f54..2c79f81 100644
--- a/gnulib-local/lib/libxml/xmlexports.in.h
+++ b/gnulib-local/lib/libxml/xmlexports.in.h
@@ -43,7 +43,7 @@
/**
* XMLCDECL:
*
- * Macro which declares the calling convention for exported functions that
+ * Macro which declares the calling convention for exported functions that
* use '...'.
*/
#define XMLCDECL
@@ -108,9 +108,14 @@
#undef XMLPUBVAR
#undef XMLCALL
#undef XMLCDECL
+ /*
+ * if defined(IN_LIBXML) this raises problems on mingw with msys
+ * _imp__xmlFree listed as missing. Try to workaround the problem
+ * by also making that declaration when compiling client code.
+ */
#if defined(IN_LIBXML) && !defined(LIBXML_STATIC)
#define XMLPUBFUN __declspec(dllexport)
- #define XMLPUBVAR __declspec(dllexport)
+ #define XMLPUBVAR __declspec(dllexport) extern
#else
#define XMLPUBFUN
#if !defined(LIBXML_STATIC)
diff --git a/gnulib-local/lib/libxml/xmlmemory.c b/gnulib-local/lib/libxml/xmlmemory.c
index 362a0b0..f24fd6d 100644
--- a/gnulib-local/lib/libxml/xmlmemory.c
+++ b/gnulib-local/lib/libxml/xmlmemory.c
@@ -34,7 +34,7 @@
/**
* MEM_LIST:
*
- * keep track of all allocated blocks for error reporting
+ * keep track of all allocated blocks for error reporting
* Always build the memory list !
*/
#ifdef DEBUG_MEMORY_LOCATION
@@ -58,7 +58,7 @@ void xmlMallocBreakpoint(void);
/************************************************************************
* *
- * Macros, variables and associated types *
+ * Macros, variables and associated types *
* *
************************************************************************/
@@ -162,7 +162,7 @@ xmlMallocLoc(size_t size, const char * file, int line)
{
MEMHDR *p;
void *ret;
-
+
if (!xmlMemInitialized) xmlInitMemory();
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
@@ -170,7 +170,7 @@ xmlMallocLoc(size_t size, const char * file, int line)
#endif
TEST_POINT
-
+
p = (MEMHDR *) malloc(RESERVE_SIZE+size);
if (!p) {
@@ -178,7 +178,7 @@ xmlMallocLoc(size_t size, const char * file, int line)
"xmlMallocLoc : Out of free space\n");
xmlMemoryDump();
return(NULL);
- }
+ }
p->mh_tag = MEMTAG;
p->mh_size = size;
p->mh_type = MALLOC_TYPE;
@@ -193,19 +193,20 @@ xmlMallocLoc(size_t size, const char * file, int line)
debugmem_list_add(p);
#endif
xmlMutexUnlock(xmlMemMutex);
-
+
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
"Malloc(%d) Ok\n",size);
#endif
-
+
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
ret = HDR_2_CLIENT(p);
if (xmlMemTraceBlockAt == ret) {
xmlGenericError(xmlGenericErrorContext,
- "%p : Malloc(%d) Ok\n", xmlMemTraceBlockAt, size);
+ "%p : Malloc(%lu) Ok\n", xmlMemTraceBlockAt,
+ (long unsigned)size);
xmlMallocBreakpoint();
}
@@ -230,7 +231,7 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
{
MEMHDR *p;
void *ret;
-
+
if (!xmlMemInitialized) xmlInitMemory();
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
@@ -238,7 +239,7 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
#endif
TEST_POINT
-
+
p = (MEMHDR *) malloc(RESERVE_SIZE+size);
if (!p) {
@@ -246,7 +247,7 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
"xmlMallocLoc : Out of free space\n");
xmlMemoryDump();
return(NULL);
- }
+ }
p->mh_tag = MEMTAG;
p->mh_size = size;
p->mh_type = MALLOC_ATOMIC_TYPE;
@@ -266,14 +267,15 @@ xmlMallocAtomicLoc(size_t size, const char * file, int line)
xmlGenericError(xmlGenericErrorContext,
"Malloc(%d) Ok\n",size);
#endif
-
+
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
ret = HDR_2_CLIENT(p);
if (xmlMemTraceBlockAt == ret) {
xmlGenericError(xmlGenericErrorContext,
- "%p : Malloc(%d) Ok\n", xmlMemTraceBlockAt, size);
+ "%p : Malloc(%lu) Ok\n", xmlMemTraceBlockAt,
+ (long unsigned)size);
xmlMallocBreakpoint();
}
@@ -311,7 +313,7 @@ xmlMemMalloc(size_t size)
void *
xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
{
- MEMHDR *p;
+ MEMHDR *p, *tmp;
unsigned long number;
#ifdef DEBUG_MEMORY
size_t oldsize;
@@ -341,15 +343,18 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
debugmem_list_delete(p);
#endif
xmlMutexUnlock(xmlMemMutex);
-
- p = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
- if (!p) {
+
+ tmp = (MEMHDR *) realloc(p,RESERVE_SIZE+size);
+ if (!tmp) {
+ free(p);
goto error;
}
+ p = tmp;
if (xmlMemTraceBlockAt == ptr) {
xmlGenericError(xmlGenericErrorContext,
- "%p : Realloced(%d -> %d) Ok\n",
- xmlMemTraceBlockAt, p->mh_size, size);
+ "%p : Realloced(%lu -> %lu) Ok\n",
+ xmlMemTraceBlockAt, (long unsigned)p->mh_size,
+ (long unsigned)size);
xmlMallocBreakpoint();
}
p->mh_tag = MEMTAG;
@@ -374,8 +379,8 @@ xmlReallocLoc(void *ptr,size_t size, const char * file, int line)
"Realloced(%d to %d) Ok\n", oldsize, size);
#endif
return(HDR_2_CLIENT(p));
-
-error:
+
+error:
return(NULL);
}
@@ -409,6 +414,9 @@ xmlMemFree(void *ptr)
size_t size;
#endif
+ if (ptr == NULL)
+ return;
+
if (ptr == (void *) -1) {
xmlGenericError(xmlGenericErrorContext,
"trying to free pointer from freed area\n");
@@ -452,10 +460,10 @@ xmlMemFree(void *ptr)
xmlGenericError(xmlGenericErrorContext,
"Freed(%d) Ok\n", size);
#endif
-
+
return;
-
-error:
+
+error:
xmlGenericError(xmlGenericErrorContext,
"xmlMemFree(%lX) error\n", (unsigned long) ptr);
xmlMallocBreakpoint();
@@ -501,16 +509,13 @@ xmlMemStrdupLoc(const char *str, const char *file, int line)
debugmem_list_add(p);
#endif
xmlMutexUnlock(xmlMemMutex);
-
+
s = (char *) HDR_2_CLIENT(p);
-
+
if (xmlMemStopAtBlock == p->mh_number) xmlMallocBreakpoint();
- if (s != NULL)
- strcpy(s,str);
- else
- goto error;
-
+ strcpy(s,str);
+
TEST_POINT
if (xmlMemTraceBlockAt == s) {
@@ -549,7 +554,12 @@ xmlMemoryStrdup(const char *str) {
int
xmlMemUsed(void) {
- return(debugMemSize);
+ int res;
+
+ xmlMutexLock(xmlMemMutex);
+ res = debugMemSize;
+ xmlMutexUnlock(xmlMemMutex);
+ return(res);
}
/**
@@ -562,7 +572,12 @@ xmlMemUsed(void) {
int
xmlMemBlocks(void) {
- return(debugMemBlocks);
+ int res;
+
+ xmlMutexLock(xmlMemMutex);
+ res = debugMemBlocks;
+ xmlMutexUnlock(xmlMemMutex);
+ return(res);
}
#ifdef MEM_LIST
@@ -577,13 +592,15 @@ xmlMemBlocks(void) {
static void
xmlMemContentShow(FILE *fp, MEMHDR *p)
{
- int i,j,k,len = p->mh_size;
- const char *buf = (const char *) HDR_2_CLIENT(p);
+ int i,j,k,len;
+ const char *buf;
if (p == NULL) {
fprintf(fp, " NULL");
return;
}
+ len = p->mh_size;
+ buf = (const char *) HDR_2_CLIENT(p);
for (i = 0;i < len;i++) {
if (buf[i] == 0) break;
@@ -614,7 +631,7 @@ xmlMemContentShow(FILE *fp, MEMHDR *p)
} else if ((i == 0) && (buf[i] == 0)) {
fprintf(fp," null");
} else {
- if (buf[i] == 0) fprintf(fp," \"%.25s\"", buf);
+ if (buf[i] == 0) fprintf(fp," \"%.25s\"", buf);
else {
fprintf(fp," [");
for (j = 0;j < i;j++)
@@ -626,6 +643,79 @@ xmlMemContentShow(FILE *fp, MEMHDR *p)
#endif
/**
+ * xmlMemDisplayLast:
+ * @fp: a FILE descriptor used as the output file, if NULL, the result is
+ * written to the file .memorylist
+ * @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.
+ */
+
+void
+xmlMemDisplayLast(FILE *fp, long nbBytes)
+{
+#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++;
+ if (nb < 100)
+ xmlMemContentShow(fp, p);
+ else
+ fprintf(fp," skip");
+
+ 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
@@ -662,7 +752,7 @@ xmlMemDisplay(FILE *fp)
fprintf(fp," %s\n\n", buf);
#endif
-
+
fprintf(fp," MEMORY ALLOCATED : %lu, MAX was %lu\n",
debugMemSize, debugMaxMemSize);
fprintf(fp,"BLOCK NUMBER SIZE TYPE\n");
@@ -739,7 +829,7 @@ static void debugmem_list_delete(MEMHDR *p)
*
* internal error function.
*/
-
+
static void debugmem_tag_error(void *p)
{
xmlGenericError(xmlGenericErrorContext,
@@ -799,7 +889,7 @@ xmlMemShow(FILE *fp, int nr ATTRIBUTE_UNUSED)
}
}
xmlMutexUnlock(xmlMemMutex);
-#endif /* MEM_LIST */
+#endif /* MEM_LIST */
}
/**
@@ -846,11 +936,11 @@ xmlInitMemory(void)
{
#ifdef HAVE_STDLIB_H
char *breakpoint;
-#endif
+#endif
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
"xmlInitMemory()\n");
-#endif
+#endif
/*
This is really not good code (see Bug 130419). Suggestions for
improvement will be welcome!
@@ -864,18 +954,18 @@ xmlInitMemory(void)
if (breakpoint != NULL) {
sscanf(breakpoint, "%ud", &xmlMemStopAtBlock);
}
-#endif
+#endif
#ifdef HAVE_STDLIB_H
breakpoint = getenv("XML_MEM_TRACE");
if (breakpoint != NULL) {
sscanf(breakpoint, "%p", &xmlMemTraceBlockAt);
}
-#endif
-
+#endif
+
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
"xmlInitMemory() Ok\n");
-#endif
+#endif
return(0);
}
@@ -890,7 +980,7 @@ xmlCleanupMemory(void) {
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
"xmlCleanupMemory()\n");
-#endif
+#endif
if (xmlMemInitialized == 0)
return;
@@ -900,7 +990,7 @@ xmlCleanupMemory(void) {
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
"xmlCleanupMemory() Ok\n");
-#endif
+#endif
}
/**
@@ -924,7 +1014,7 @@ xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
"xmlMemSetup()\n");
-#endif
+#endif
if (freeFunc == NULL)
return(-1);
if (mallocFunc == NULL)
@@ -941,7 +1031,7 @@ xmlMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
"xmlMemSetup() Ok\n");
-#endif
+#endif
return(0);
}
@@ -991,7 +1081,7 @@ xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
"xmlGcMemSetup()\n");
-#endif
+#endif
if (freeFunc == NULL)
return(-1);
if (mallocFunc == NULL)
@@ -1010,7 +1100,7 @@ xmlGcMemSetup(xmlFreeFunc freeFunc, xmlMallocFunc mallocFunc,
#ifdef DEBUG_MEMORY
xmlGenericError(xmlGenericErrorContext,
"xmlGcMemSetup() Ok\n");
-#endif
+#endif
return(0);
}
diff --git a/gnulib-local/lib/libxml/xmlmemory.in.h b/gnulib-local/lib/libxml/xmlmemory.in.h
index 235721c..17e375a 100644
--- a/gnulib-local/lib/libxml/xmlmemory.in.h
+++ b/gnulib-local/lib/libxml/xmlmemory.in.h
@@ -20,7 +20,7 @@
*
* DEBUG_MEMORY replaces the allocator with a collect and debug
* shell to the libc allocator.
- * DEBUG_MEMORY should only be activated when debugging
+ * DEBUG_MEMORY should only be activated when debugging
* libxml i.e. if libxml has been configured with --with-debug-mem too.
*/
/* #define DEBUG_MEMORY_FREED */
@@ -35,7 +35,7 @@
/**
* DEBUG_MEMORY_LOCATION:
*
- * DEBUG_MEMORY_LOCATION should be activated only when debugging
+ * DEBUG_MEMORY_LOCATION should be activated only when debugging
* libxml i.e. if libxml has been configured with --with-debug-mem too.
*/
#ifdef DEBUG_MEMORY_LOCATION
@@ -63,7 +63,7 @@ typedef void (XMLCALL *xmlFreeFunc)(void *mem);
*
* Returns a pointer to the newly allocated block or NULL in case of error.
*/
-typedef void *(XMLCALL *xmlMallocFunc)(size_t size);
+typedef void *(LIBXML_ATTR_ALLOC_SIZE(1) XMLCALL *xmlMallocFunc)(size_t size);
/**
* xmlReallocFunc:
@@ -88,11 +88,11 @@ typedef char *(XMLCALL *xmlStrdupFunc)(const char *str);
/*
* The 4 interfaces used for all memory handling within libxml.
-LIBXML_DLL_IMPORT extern xmlFreeFunc xmlFree;
-LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMalloc;
-LIBXML_DLL_IMPORT extern xmlMallocFunc xmlMallocAtomic;
-LIBXML_DLL_IMPORT extern xmlReallocFunc xmlRealloc;
-LIBXML_DLL_IMPORT extern xmlStrdupFunc xmlMemStrdup;
+LIBXML_DLL_IMPORT xmlFreeFunc xmlFree;
+LIBXML_DLL_IMPORT xmlMallocFunc xmlMalloc;
+LIBXML_DLL_IMPORT xmlMallocFunc xmlMallocAtomic;
+LIBXML_DLL_IMPORT xmlReallocFunc xmlRealloc;
+LIBXML_DLL_IMPORT xmlStrdupFunc xmlMemStrdup;
*/
/*
@@ -105,18 +105,18 @@ XMLPUBFUN int XMLCALL
xmlMallocFunc mallocFunc,
xmlReallocFunc reallocFunc,
xmlStrdupFunc strdupFunc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlMemGet (xmlFreeFunc *freeFunc,
xmlMallocFunc *mallocFunc,
xmlReallocFunc *reallocFunc,
xmlStrdupFunc *strdupFunc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlGcMemSetup (xmlFreeFunc freeFunc,
xmlMallocFunc mallocFunc,
xmlMallocFunc mallocAtomicFunc,
xmlReallocFunc reallocFunc,
xmlStrdupFunc strdupFunc);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlGcMemGet (xmlFreeFunc *freeFunc,
xmlMallocFunc *mallocFunc,
xmlMallocFunc *mallocAtomicFunc,
@@ -126,42 +126,44 @@ XMLPUBFUN int XMLCALL
/*
* Initialization of the memory layer.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlInitMemory (void);
-/*
+/*
* Cleanup of the memory layer.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlCleanupMemory (void);
/*
* These are specific to the XML debug memory wrapper.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlMemUsed (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlMemBlocks (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlMemDisplay (FILE *fp);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
+ xmlMemDisplayLast(FILE *fp, long nbBytes);
+XMLPUBFUN void XMLCALL
xmlMemShow (FILE *fp, int nr);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlMemoryDump (void);
-XMLPUBFUN void * XMLCALL
- xmlMemMalloc (size_t size);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
+ xmlMemMalloc (size_t size) LIBXML_ATTR_ALLOC_SIZE(1);
+XMLPUBFUN void * XMLCALL
xmlMemRealloc (void *ptr,size_t size);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlMemFree (void *ptr);
-XMLPUBFUN char * XMLCALL
+XMLPUBFUN char * XMLCALL
xmlMemoryStrdup (const char *str);
-XMLPUBFUN void * XMLCALL
- xmlMallocLoc (size_t size, const char *file, int line);
-XMLPUBFUN void * XMLCALL
+XMLPUBFUN void * XMLCALL
+ xmlMallocLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);
+XMLPUBFUN void * XMLCALL
xmlReallocLoc (void *ptr, size_t size, const char *file, int line);
-XMLPUBFUN void * XMLCALL
- xmlMallocAtomicLoc (size_t size, const char *file, int line);
-XMLPUBFUN char * XMLCALL
+XMLPUBFUN void * XMLCALL
+ xmlMallocAtomicLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);
+XMLPUBFUN char * XMLCALL
xmlMemStrdupLoc (const char *str, const char *file, int line);
diff --git a/gnulib-local/lib/libxml/xmlmodule.c b/gnulib-local/lib/libxml/xmlmodule.c
index 15bcf07..50ed666 100644
--- a/gnulib-local/lib/libxml/xmlmodule.c
+++ b/gnulib-local/lib/libxml/xmlmodule.c
@@ -30,7 +30,7 @@ static int xmlModulePlatformSymbol(void *handle, const char *name, void **result
/************************************************************************
* *
- * module memory error handler *
+ * module memory error handler *
* *
************************************************************************/
@@ -61,6 +61,10 @@ xmlModuleErrMemory(xmlModulePtr module, const char *extra)
* @options: a set of xmlModuleOption
*
* Opens a module/shared library given its name or path
+ * NOTE: that due to portability issues, behaviour can only be
+ * guaranteed with @name using ASCII. We canot guarantee that
+ * an UTF-8 string would work, which is why name is a const char *
+ * and not a const xmlChar * .
* TODO: options are not yet implemented.
*
* Returns a handle for the module or NULL in case of error
@@ -99,6 +103,10 @@ xmlModuleOpen(const char *name, int options ATTRIBUTE_UNUSED)
* @symbol: the resulting symbol address
*
* Lookup for a symbol address in the given module
+ * NOTE: that due to portability issues, behaviour can only be
+ * guaranteed with @name using ASCII. We canot guarantee that
+ * an UTF-8 string would work, which is why name is a const char *
+ * and not a const xmlChar * .
*
* Returns 0 if the symbol was found, or -1 in case of error
*/
@@ -106,8 +114,8 @@ int
xmlModuleSymbol(xmlModulePtr module, const char *name, void **symbol)
{
int rc = -1;
-
- if ((NULL == module) || (symbol == NULL)) {
+
+ if ((NULL == module) || (symbol == NULL) || (name == NULL)) {
__xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_MODULE,
XML_MODULE_OPEN, XML_ERR_FATAL, NULL, 0, 0,
NULL, NULL, 0, 0, "null parameter\n");
@@ -190,7 +198,7 @@ xmlModuleFree(xmlModulePtr module)
return (0);
}
-#ifdef HAVE_DLOPEN
+#if defined(HAVE_DLOPEN) && !defined(_WIN32)
#ifdef HAVE_DLFCN_H
#include <dlfcn.h>
#endif
@@ -300,7 +308,7 @@ xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
static void *
xmlModulePlatformOpen(const char *name)
{
- return LoadLibrary(name);
+ return LoadLibraryA(name);
}
/*
@@ -326,7 +334,14 @@ xmlModulePlatformClose(void *handle)
static int
xmlModulePlatformSymbol(void *handle, const char *name, void **symbol)
{
+#ifdef _WIN32_WCE
+ /*
+ * GetProcAddressA seems only available on WinCE
+ */
+ *symbol = GetProcAddressA(handle, name);
+#else
*symbol = GetProcAddress(handle, name);
+#endif
return (NULL == *symbol) ? -1 : 0;
}
diff --git a/gnulib-local/lib/libxml/xmlmodule.in.h b/gnulib-local/lib/libxml/xmlmodule.in.h
index 8f4a560..9667820 100644
--- a/gnulib-local/lib/libxml/xmlmodule.in.h
+++ b/gnulib-local/lib/libxml/xmlmodule.in.h
@@ -50,7 +50,7 @@ XMLPUBFUN int XMLCALL xmlModuleFree (xmlModulePtr module);
#ifdef __cplusplus
}
-#endif
+#endif
#endif /* LIBXML_MODULES_ENABLED */
diff --git a/gnulib-local/lib/libxml/xmlreader.c b/gnulib-local/lib/libxml/xmlreader.c
index c8bcf7b..471e7e2 100644
--- a/gnulib-local/lib/libxml/xmlreader.c
+++ b/gnulib-local/lib/libxml/xmlreader.c
@@ -1,7 +1,7 @@
/*
* xmlreader.c: implements the xmlTextReader streaming node API
*
- * NOTE:
+ * NOTE:
* XmlTextReader.Normalization Property won't be supported, since
* it makes the parser non compliant to the XML recommendation
*
@@ -44,6 +44,33 @@
#include <libxml/pattern.h>
#endif
+#include "buf.h"
+
+#define MAX_ERR_MSG_SIZE 64000
+
+/*
+ * The following VA_COPY was coded following an example in
+ * the Samba project. It may not be sufficient for some
+ * esoteric implementations of va_list but (hopefully) will
+ * be sufficient for libxml2.
+ */
+#ifndef VA_COPY
+ #ifdef HAVE_VA_COPY
+ #define VA_COPY(dest, src) va_copy(dest, src)
+ #else
+ #ifdef HAVE___VA_COPY
+ #define VA_COPY(dest,src) __va_copy(dest, src)
+ #else
+ #ifndef VA_LIST_IS_ARRAY
+ #define VA_COPY(dest,src) (dest) = (src)
+ #else
+ #include <string.h>
+ #define VA_COPY(dest,src) memcpy((char *)(dest),(char *)(src),sizeof(va_list))
+ #endif
+ #endif
+ #endif
+#endif
+
/* #define DEBUG_CALLBACKS */
/* #define DEBUG_READER */
@@ -52,7 +79,7 @@
*
* macro to flag unimplemented blocks
*/
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
@@ -107,14 +134,14 @@ struct _xmlTextReader {
endElementNsSAX2Func endElementNs; /* idem */
charactersSAXFunc characters;
cdataBlockSAXFunc cdataBlock;
- unsigned int base; /* base of the segment in the input */
- unsigned int cur; /* current position in the input */
+ unsigned int base; /* base of the segment in the input */
+ unsigned int cur; /* current position in the input */
xmlNodePtr node; /* current node */
xmlNodePtr curnode;/* current attribute node */
int depth; /* depth of the current node */
xmlNodePtr faketext;/* fake xmlNs chld */
int preserve;/* preserve the resulting document */
- xmlBufferPtr buffer; /* used to return const xmlChar * */
+ xmlBufPtr buffer; /* used to return const xmlChar * */
xmlDictPtr dict; /* the context dictionnary */
/* entity stack when traversing entities content */
@@ -131,6 +158,7 @@ struct _xmlTextReader {
/* Handling of RelaxNG validation */
xmlRelaxNGPtr rngSchemas; /* The Relax NG schemas */
xmlRelaxNGValidCtxtPtr rngValidCtxt;/* The Relax NG validation context */
+ int rngPreserveCtxt; /* 1 if the context was provided by the user */
int rngValidErrors;/* The number of errors detected */
xmlNodePtr rngFullNode; /* the node if RNG not progressive */
/* Handling of Schemas validation */
@@ -186,7 +214,7 @@ static int xmlTextReaderNextTree(xmlTextReaderPtr reader);
* current scope
*/
#define DICT_FREE(str) \
- if ((str) && ((!dict) || \
+ if ((str) && ((!dict) || \
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
xmlFree((char *)(str));
@@ -231,11 +259,9 @@ xmlTextReaderRemoveID(xmlDocPtr doc, xmlAttrPtr attr) {
if (doc == NULL) return(-1);
if (attr == NULL) return(-1);
table = (xmlIDTablePtr) doc->ids;
- if (table == NULL)
+ if (table == NULL)
return(-1);
- if (attr == NULL)
- return(-1);
ID = xmlNodeListGetString(doc, attr->children, 1);
if (ID == NULL)
return(-1);
@@ -260,7 +286,10 @@ static void
xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
xmlDictPtr dict;
- dict = reader->ctxt->dict;
+ if ((reader != NULL) && (reader->ctxt != NULL))
+ dict = reader->ctxt->dict;
+ else
+ dict = NULL;
if (cur == NULL) return;
if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
@@ -297,7 +326,7 @@ xmlTextReaderFreeProp(xmlTextReaderPtr reader, xmlAttrPtr cur) {
static void
xmlTextReaderFreePropList(xmlTextReaderPtr reader, xmlAttrPtr cur) {
xmlAttrPtr next;
- if (cur == NULL) return;
+
while (cur != NULL) {
next = cur->next;
xmlTextReaderFreeProp(reader, cur);
@@ -318,7 +347,10 @@ xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur) {
xmlNodePtr next;
xmlDictPtr dict;
- dict = reader->ctxt->dict;
+ if ((reader != NULL) && (reader->ctxt != NULL))
+ dict = reader->ctxt->dict;
+ else
+ dict = NULL;
if (cur == NULL) return;
if (cur->type == XML_NAMESPACE_DECL) {
xmlFreeNsList((xmlNsPtr) cur);
@@ -395,7 +427,10 @@ static void
xmlTextReaderFreeNode(xmlTextReaderPtr reader, xmlNodePtr cur) {
xmlDictPtr dict;
- dict = reader->ctxt->dict;
+ if ((reader != NULL) && (reader->ctxt != NULL))
+ dict = reader->ctxt->dict;
+ else
+ dict = NULL;
if (cur->type == XML_DTD_NODE) {
xmlFreeDtd((xmlDtdPtr) cur);
return;
@@ -787,9 +822,10 @@ xmlTextReaderCDataBlock(void *ctx, const xmlChar *ch, int len)
*/
static int
xmlTextReaderPushData(xmlTextReaderPtr reader) {
- xmlBufferPtr inbuf;
+ xmlBufPtr inbuf;
int val, s;
xmlTextReaderState oldstate;
+ int alloc;
if ((reader->input == NULL) || (reader->input->buffer == NULL))
return(-1);
@@ -797,17 +833,18 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
oldstate = reader->state;
reader->state = XML_TEXTREADER_NONE;
inbuf = reader->input->buffer;
+ alloc = xmlBufGetAllocationScheme(inbuf);
while (reader->state == XML_TEXTREADER_NONE) {
- if (inbuf->use < reader->cur + CHUNK_SIZE) {
+ if (xmlBufUse(inbuf) < reader->cur + CHUNK_SIZE) {
/*
* Refill the buffer unless we are at the end of the stream
*/
if (reader->mode != XML_TEXTREADER_MODE_EOF) {
val = xmlParserInputBufferRead(reader->input, 4096);
if ((val == 0) &&
- (inbuf->alloc == XML_BUFFER_ALLOC_IMMUTABLE)) {
- if (inbuf->use == reader->cur) {
+ (alloc == XML_BUFFER_ALLOC_IMMUTABLE)) {
+ if (xmlBufUse(inbuf) == reader->cur) {
reader->mode = XML_TEXTREADER_MODE_EOF;
reader->state = oldstate;
}
@@ -823,28 +860,30 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
break;
}
- } else
+ } else
break;
}
/*
* parse by block of CHUNK_SIZE bytes, various tests show that
* it's the best tradeoff at least on a 1.2GH Duron
*/
- if (inbuf->use >= reader->cur + CHUNK_SIZE) {
+ if (xmlBufUse(inbuf) >= reader->cur + CHUNK_SIZE) {
val = xmlParseChunk(reader->ctxt,
- (const char *) &inbuf->content[reader->cur],
- CHUNK_SIZE, 0);
+ (const char *) xmlBufContent(inbuf) + reader->cur,
+ CHUNK_SIZE, 0);
reader->cur += CHUNK_SIZE;
- if ((val != 0) || (reader->ctxt->wellFormed == 0))
- return(-1);
+ if (val != 0)
+ reader->ctxt->wellFormed = 0;
+ if (reader->ctxt->wellFormed == 0)
+ break;
} else {
- s = inbuf->use - reader->cur;
+ s = xmlBufUse(inbuf) - reader->cur;
val = xmlParseChunk(reader->ctxt,
- (const char *) &inbuf->content[reader->cur],
- s, 0);
+ (const char *) xmlBufContent(inbuf) + reader->cur,
+ s, 0);
reader->cur += s;
- if ((val != 0) || (reader->ctxt->wellFormed == 0))
- return(-1);
+ if (val != 0)
+ reader->ctxt->wellFormed = 0;
break;
}
}
@@ -853,10 +892,10 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
* Discard the consumed input when needed and possible
*/
if (reader->mode == XML_TEXTREADER_MODE_INTERACTIVE) {
- if (inbuf->alloc != XML_BUFFER_ALLOC_IMMUTABLE) {
+ if (alloc != XML_BUFFER_ALLOC_IMMUTABLE) {
if ((reader->cur >= 4096) &&
- (inbuf->use - reader->cur <= CHUNK_SIZE)) {
- val = xmlBufferShrink(inbuf, reader->cur);
+ (xmlBufUse(inbuf) - reader->cur <= CHUNK_SIZE)) {
+ val = xmlBufShrink(inbuf, reader->cur);
if (val >= 0) {
reader->cur -= val;
}
@@ -869,18 +908,27 @@ xmlTextReaderPushData(xmlTextReaderPtr reader) {
* parser.
*/
else if (reader->mode == XML_TEXTREADER_MODE_EOF) {
- if (reader->mode != XML_TEXTREADER_DONE) {
- s = inbuf->use - reader->cur;
+ if (reader->state != XML_TEXTREADER_DONE) {
+ s = xmlBufUse(inbuf) - reader->cur;
val = xmlParseChunk(reader->ctxt,
- (const char *) &inbuf->content[reader->cur],
- s, 1);
- reader->cur = inbuf->use;
- reader->mode = XML_TEXTREADER_DONE;
- if ((val != 0) || (reader->ctxt->wellFormed == 0))
- return(-1);
+ (const char *) xmlBufContent(inbuf) + reader->cur,
+ s, 1);
+ reader->cur = xmlBufUse(inbuf);
+ reader->state = XML_TEXTREADER_DONE;
+ if (val != 0) {
+ if (reader->ctxt->wellFormed)
+ reader->ctxt->wellFormed = 0;
+ else
+ return(-1);
+ }
}
}
reader->state = oldstate;
+ if (reader->ctxt->wellFormed == 0) {
+ reader->mode = XML_TEXTREADER_MODE_EOF;
+ return(-1);
+ }
+
return(0);
}
@@ -949,7 +997,7 @@ printf("Expand failed !\n");
* xmlTextReaderValidateCData:
* @reader: the xmlTextReaderPtr used
* @data: pointer to the CData
- * @len: lenght of the CData block in bytes.
+ * @len: length of the CData block in bytes.
*
* Push some CData for validation
*/
@@ -1012,7 +1060,7 @@ xmlTextReaderValidatePop(xmlTextReaderPtr reader) {
int ret;
if (reader->rngFullNode != NULL) {
- if (node == reader->rngFullNode)
+ if (node == reader->rngFullNode)
reader->rngFullNode = NULL;
return;
}
@@ -1047,7 +1095,7 @@ xmlTextReaderValidateEntity(xmlTextReaderPtr reader) {
*/
if ((node->children == NULL) && (ctxt->sax != NULL) &&
(ctxt->sax->getEntity != NULL)) {
- node->children = (xmlNodePtr)
+ node->children = (xmlNodePtr)
ctxt->sax->getEntity(ctxt, node->name);
}
@@ -1169,8 +1217,10 @@ xmlTextReaderDoExpand(xmlTextReaderPtr reader) {
if (reader->mode == XML_TEXTREADER_MODE_EOF)
return(1);
val = xmlTextReaderPushData(reader);
- if (val < 0)
+ if (val < 0){
+ reader->mode = XML_TEXTREADER_MODE_ERROR;
return(-1);
+ }
} while(reader->mode != XML_TEXTREADER_MODE_EOF);
return(1);
}
@@ -1191,6 +1241,9 @@ xmlTextReaderCollectSiblings(xmlNodePtr node)
xmlBufferPtr buffer;
xmlChar *ret;
+ if ((node == NULL) || (node->type == XML_NAMESPACE_DECL))
+ return(NULL);
+
buffer = xmlBufferCreate();
if (buffer == NULL)
return NULL;
@@ -1235,7 +1288,7 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
xmlTextReaderState oldstate = XML_TEXTREADER_START;
xmlNodePtr oldnode = NULL;
-
+
if (reader == NULL)
return(-1);
reader->curnode = NULL;
@@ -1243,8 +1296,6 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
return(xmlTextReaderReadTree(reader));
if (reader->ctxt == NULL)
return(-1);
- if (reader->ctxt->wellFormed != 1)
- return(-1);
#ifdef DEBUG_READER
fprintf(stderr, "\nREAD ");
@@ -1257,17 +1308,23 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
*/
do {
val = xmlTextReaderPushData(reader);
- if (val < 0)
+ if (val < 0){
+ reader->mode = XML_TEXTREADER_MODE_ERROR;
+ reader->state = XML_TEXTREADER_ERROR;
return(-1);
+ }
} while ((reader->ctxt->node == NULL) &&
((reader->mode != XML_TEXTREADER_MODE_EOF) &&
- (reader->mode != XML_TEXTREADER_DONE)));
+ (reader->state != XML_TEXTREADER_DONE)));
if (reader->ctxt->node == NULL) {
if (reader->ctxt->myDoc != NULL) {
reader->node = reader->ctxt->myDoc->children;
}
- if (reader->node == NULL)
+ if (reader->node == NULL){
+ reader->mode = XML_TEXTREADER_MODE_ERROR;
+ reader->state = XML_TEXTREADER_ERROR;
return(-1);
+ }
reader->state = XML_TEXTREADER_ELEMENT;
} else {
if (reader->ctxt->myDoc != NULL) {
@@ -1287,7 +1344,7 @@ xmlTextReaderRead(xmlTextReaderPtr reader) {
get_next_node:
if (reader->node == NULL) {
- if (reader->mode == XML_TEXTREADER_DONE)
+ if (reader->mode == XML_TEXTREADER_MODE_EOF)
return(0);
else
return(-1);
@@ -1314,8 +1371,11 @@ get_next_node:
(reader->ctxt->node == reader->node->parent)) &&
(reader->ctxt->instate != XML_PARSER_EOF)) {
val = xmlTextReaderPushData(reader);
- if (val < 0)
+ if (val < 0){
+ reader->mode = XML_TEXTREADER_MODE_ERROR;
+ reader->state = XML_TEXTREADER_ERROR;
return(-1);
+ }
if (reader->node == NULL)
goto node_end;
}
@@ -1362,8 +1422,7 @@ get_next_node:
#endif
(reader->entNr == 0) &&
(reader->node->prev != NULL) &&
- (reader->node->prev->type != XML_DTD_NODE) &&
- (reader->entNr == 0)) {
+ (reader->node->prev->type != XML_DTD_NODE)) {
xmlNodePtr tmp = reader->node->prev;
if ((tmp->extra & NODE_IS_PRESERVED) == 0) {
xmlUnlinkNode(tmp);
@@ -1381,7 +1440,7 @@ get_next_node:
goto node_found;
}
#ifdef LIBXML_REGEXP_ENABLED
- if ((reader->validate) && (reader->node->type == XML_ELEMENT_NODE))
+ if ((reader->validate != XML_TEXTREADER_NOT_VALIDATE) && (reader->node->type == XML_ELEMENT_NODE))
xmlTextReaderValidatePop(reader);
#endif /* LIBXML_REGEXP_ENABLED */
if ((reader->preserves > 0) &&
@@ -1394,9 +1453,9 @@ get_next_node:
(reader->node->type == XML_DOCB_DOCUMENT_NODE) ||
#endif
(reader->node->type == XML_HTML_DOCUMENT_NODE)) {
- if (reader->mode != XML_TEXTREADER_DONE) {
+ if (reader->mode != XML_TEXTREADER_MODE_EOF) {
val = xmlParseChunk(reader->ctxt, "", 0, 1);
- reader->mode = XML_TEXTREADER_DONE;
+ reader->state = XML_TEXTREADER_DONE;
if (val != 0)
return(-1);
}
@@ -1406,14 +1465,13 @@ get_next_node:
/*
* Cleanup of the old node
*/
- if ((reader->preserves == 0) &&
+ if ((oldnode != NULL) && (reader->preserves == 0) &&
#ifdef LIBXML_XINCLUDE_ENABLED
(reader->in_xinclude == 0) &&
#endif
(reader->entNr == 0) &&
(oldnode->type != XML_DTD_NODE) &&
- ((oldnode->extra & NODE_IS_PRESERVED) == 0) &&
- (reader->entNr == 0)) {
+ ((oldnode->extra & NODE_IS_PRESERVED) == 0)) {
xmlUnlinkNode(oldnode);
xmlTextReaderFreeNode(reader, oldnode);
}
@@ -1459,7 +1517,7 @@ node_found:
(xmlStrEqual(reader->node->ns->href, XINCLUDE_OLD_NS)))) {
if (reader->xincctxt == NULL) {
reader->xincctxt = xmlXIncludeNewContext(reader->ctxt->myDoc);
- xmlXIncludeSetFlags(reader->xincctxt,
+ xmlXIncludeSetFlags(reader->xincctxt,
reader->parserFlags & (~XML_PARSE_NOXINCNODE));
}
/*
@@ -1472,7 +1530,7 @@ node_found:
if ((reader->node != NULL) && (reader->node->type == XML_XINCLUDE_START)) {
reader->in_xinclude++;
goto get_next_node;
- }
+ }
if ((reader->node != NULL) && (reader->node->type == XML_XINCLUDE_END)) {
reader->in_xinclude--;
goto get_next_node;
@@ -1490,7 +1548,7 @@ node_found:
*/
if ((reader->node->children == NULL) && (reader->ctxt->sax != NULL) &&
(reader->ctxt->sax->getEntity != NULL)) {
- reader->node->children = (xmlNodePtr)
+ reader->node->children = (xmlNodePtr)
reader->ctxt->sax->getEntity(reader->ctxt, reader->node->name);
}
@@ -1515,10 +1573,10 @@ node_found:
goto get_next_node;
}
#ifdef LIBXML_REGEXP_ENABLED
- if ((reader->validate) && (reader->node != NULL)) {
+ if ((reader->validate != XML_TEXTREADER_NOT_VALIDATE) && (reader->node != NULL)) {
xmlNodePtr node = reader->node;
- if ((node->type == XML_ELEMENT_NODE) &&
+ if ((node->type == XML_ELEMENT_NODE) &&
((reader->state != XML_TEXTREADER_END) &&
(reader->state != XML_TEXTREADER_BACKTRACK))) {
xmlTextReaderValidatePush(reader);
@@ -1543,14 +1601,14 @@ node_found:
#endif /* LIBXML_PATTERN_ENABLED */
#ifdef LIBXML_SCHEMAS_ENABLED
if ((reader->validate == XML_TEXTREADER_VALIDATE_XSD) &&
- (reader->xsdValidErrors == 0) &&
+ (reader->xsdValidErrors == 0) &&
(reader->xsdValidCtxt != NULL)) {
reader->xsdValidErrors = !xmlSchemaIsValid(reader->xsdValidCtxt);
}
#endif /* LIBXML_PATTERN_ENABLED */
return(1);
node_end:
- reader->mode = XML_TEXTREADER_DONE;
+ reader->state = XML_TEXTREADER_DONE;
return(0);
}
@@ -1634,7 +1692,7 @@ xmlTextReaderNext(xmlTextReaderPtr reader) {
* Reads the contents of the current node, including child nodes and markup.
*
* Returns a string containing the XML content, or NULL if the current node
- * is neither an element nor attribute, or has no child nodes. The
+ * is neither an element nor attribute, or has no child nodes. The
* string must be deallocated by the caller.
*/
xmlChar *
@@ -1679,9 +1737,9 @@ xmlTextReaderReadInnerXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
*
* Reads the contents of the current node, including child nodes and markup.
*
- * Returns a string containing the XML content, or NULL if the current node
- * is neither an element nor attribute, or has no child nodes. The
- * string must be deallocated by the caller.
+ * Returns a string containing the node and any XML content, or NULL if the
+ * current node cannot be serialized. The string must be deallocated
+ * by the caller.
*/
xmlChar *
xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
@@ -1696,7 +1754,11 @@ xmlTextReaderReadOuterXml(xmlTextReaderPtr reader ATTRIBUTE_UNUSED)
if (xmlTextReaderExpand(reader) == NULL) {
return NULL;
}
- node = xmlDocCopyNode(node, doc, 1);
+ if (node->type == XML_DTD_NODE) {
+ node = (xmlNodePtr) xmlCopyDtd((xmlDtdPtr) node);
+ } else {
+ node = xmlDocCopyNode(node, doc, 1);
+ }
buff = xmlBufferCreate();
if (xmlNodeDump(buff, doc, node, 0, 0) == -1) {
xmlFreeNode(node);
@@ -1741,6 +1803,7 @@ xmlTextReaderReadString(xmlTextReaderPtr reader)
if (xmlTextReaderDoExpand(reader) != -1) {
return xmlTextReaderCollectSiblings(node->children);
}
+ break;
case XML_ATTRIBUTE_NODE:
TODO
break;
@@ -1838,17 +1901,22 @@ xmlTextReaderNextTree(xmlTextReaderPtr reader)
}
if (reader->state != XML_TEXTREADER_BACKTRACK) {
- if (reader->node->children != 0) {
- reader->node = reader->node->children;
- reader->depth++;
+ /* Here removed traversal to child, because we want to skip the subtree,
+ replace with traversal to sibling to skip subtree */
+ if (reader->node->next != 0) {
+ /* Move to sibling if present,skipping sub-tree */
+ reader->node = reader->node->next;
reader->state = XML_TEXTREADER_START;
return(1);
}
+ /* if reader->node->next is NULL mean no subtree for current node,
+ so need to move to sibling of parent node if present */
if ((reader->node->type == XML_ELEMENT_NODE) ||
(reader->node->type == XML_ATTRIBUTE_NODE)) {
reader->state = XML_TEXTREADER_BACKTRACK;
- return(1);
+ /* This will move to parent if present */
+ xmlTextReaderRead(reader);
}
}
@@ -1867,7 +1935,8 @@ xmlTextReaderNextTree(xmlTextReaderPtr reader)
reader->node = reader->node->parent;
reader->depth--;
reader->state = XML_TEXTREADER_BACKTRACK;
- return(1);
+ /* Repeat process to move to sibling of parent node if present */
+ xmlTextReaderNextTree(reader);
}
reader->state = XML_TEXTREADER_END;
@@ -2015,16 +2084,19 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
ret->entMax = 0;
ret->entNr = 0;
ret->input = input;
- ret->buffer = xmlBufferCreateSize(100);
+ ret->buffer = xmlBufCreateSize(100);
if (ret->buffer == NULL) {
xmlFree(ret);
xmlGenericError(xmlGenericErrorContext,
"xmlNewTextReader : malloc failed\n");
return(NULL);
}
+ /* no operation on a reader should require a huge buffer */
+ xmlBufSetAllocationScheme(ret->buffer,
+ XML_BUFFER_ALLOC_BOUNDED);
ret->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
if (ret->sax == NULL) {
- xmlBufferFree(ret->buffer);
+ xmlBufFree(ret->buffer);
xmlFree(ret);
xmlGenericError(xmlGenericErrorContext,
"xmlNewTextReader : malloc failed\n");
@@ -2057,12 +2129,13 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
ret->mode = XML_TEXTREADER_MODE_INITIAL;
ret->node = NULL;
ret->curnode = NULL;
- if (ret->input->buffer->use < 4) {
+ if (xmlBufUse(ret->input->buffer) < 4) {
xmlParserInputBufferRead(input, 4);
}
- if (ret->input->buffer->use >= 4) {
+ if (xmlBufUse(ret->input->buffer) >= 4) {
ret->ctxt = xmlCreatePushParserCtxt(ret->sax, NULL,
- (const char *) ret->input->buffer->content, 4, URI);
+ (const char *) xmlBufContent(ret->input->buffer),
+ 4, URI);
ret->base = 0;
ret->cur = 4;
} else {
@@ -2070,11 +2143,11 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
ret->base = 0;
ret->cur = 0;
}
-
+
if (ret->ctxt == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlNewTextReader : malloc failed\n");
- xmlBufferFree(ret->buffer);
+ xmlBufFree(ret->buffer);
xmlFree(ret->sax);
xmlFree(ret);
return(NULL);
@@ -2147,7 +2220,8 @@ xmlFreeTextReader(xmlTextReaderPtr reader) {
reader->rngSchemas = NULL;
}
if (reader->rngValidCtxt != NULL) {
- xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
+ if (! reader->rngPreserveCtxt)
+ xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
reader->rngValidCtxt = NULL;
}
if (reader->xsdPlug != NULL) {
@@ -2178,6 +2252,9 @@ xmlFreeTextReader(xmlTextReaderPtr reader) {
xmlFree(reader->patternTab);
}
#endif
+ if (reader->faketext != NULL) {
+ xmlFreeNode(reader->faketext);
+ }
if (reader->ctxt != NULL) {
if (reader->dict == reader->ctxt->dict)
reader->dict = NULL;
@@ -2199,11 +2276,8 @@ xmlFreeTextReader(xmlTextReaderPtr reader) {
xmlFree(reader->sax);
if ((reader->input != NULL) && (reader->allocs & XML_TEXTREADER_INPUT))
xmlFreeParserInputBuffer(reader->input);
- if (reader->faketext != NULL) {
- xmlFreeNode(reader->faketext);
- }
if (reader->buffer != NULL)
- xmlBufferFree(reader->buffer);
+ xmlBufFree(reader->buffer);
if (reader->entTab != NULL)
xmlFree(reader->entTab);
if (reader->dict != NULL)
@@ -2272,7 +2346,7 @@ xmlTextReaderGetAttributeNo(xmlTextReaderPtr reader, int no) {
if (reader->curnode != NULL)
return(NULL);
/* TODO: handle the xmlDecl */
- if (reader->node->type != XML_ELEMENT_NODE)
+ if (reader->node->type != XML_ELEMENT_NODE)
return(NULL);
ns = reader->node->nsDef;
@@ -2402,7 +2476,7 @@ xmlTextReaderGetAttributeNs(xmlTextReaderPtr reader, const xmlChar *localName,
}
ns = reader->node->nsDef;
while (ns != NULL) {
- if ((prefix == NULL && ns->prefix == NULL) ||
+ if ((prefix == NULL && ns->prefix == NULL) ||
((ns->prefix != NULL) && (xmlStrEqual(ns->prefix, localName)))) {
return xmlStrdup(ns->href);
}
@@ -2514,7 +2588,7 @@ xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader, int no) {
if (reader->node == NULL)
return(-1);
/* TODO: handle the xmlDecl */
- if (reader->node->type != XML_ELEMENT_NODE)
+ if (reader->node->type != XML_ELEMENT_NODE)
return(-1);
reader->curnode = NULL;
@@ -2601,7 +2675,7 @@ xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader, const xmlChar *name) {
}
return(0);
}
-
+
/*
* Namespace default decl
*/
@@ -2678,7 +2752,7 @@ xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,
}
ns = reader->node->nsDef;
while (ns != NULL) {
- if ((prefix == NULL && ns->prefix == NULL) ||
+ if ((prefix == NULL && ns->prefix == NULL) ||
((ns->prefix != NULL) && (xmlStrEqual(ns->prefix, localName)))) {
reader->curnode = (xmlNodePtr) ns;
return(1);
@@ -2824,7 +2898,7 @@ xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader) {
xmlNsPtr ns = (xmlNsPtr) reader->curnode;
if (reader->faketext == NULL) {
- reader->faketext = xmlNewDocText(reader->node->doc,
+ reader->faketext = xmlNewDocText(reader->node->doc,
ns->href);
} else {
if ((reader->faketext->content != NULL) &&
@@ -2862,7 +2936,7 @@ xmlTextReaderConstEncoding(xmlTextReaderPtr reader) {
doc = reader->ctxt->myDoc;
if (doc == NULL)
return(NULL);
-
+
if (doc->encoding == NULL)
return(NULL);
else
@@ -2894,7 +2968,7 @@ xmlTextReaderAttributeCount(xmlTextReaderPtr reader) {
return(-1);
if (reader->node == NULL)
return(0);
-
+
if (reader->curnode != NULL)
node = reader->curnode;
else
@@ -2925,14 +2999,14 @@ xmlTextReaderAttributeCount(xmlTextReaderPtr reader) {
*
* Get the node type of the current node
* Reference:
- * http://dotgnu.org/pnetlib-doc/System/Xml/XmlNodeType.html
+ * http://www.gnu.org/software/dotgnu/pnetlib-doc/System/Xml/XmlNodeType.html
*
* Returns the xmlNodeType of the current node or -1 in case of error
*/
int
xmlTextReaderNodeType(xmlTextReaderPtr reader) {
xmlNodePtr node;
-
+
if (reader == NULL)
return(-1);
if (reader->node == NULL)
@@ -3028,7 +3102,8 @@ xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader) {
*
* The local name of the node.
*
- * Returns the local name or NULL if not available
+ * Returns the local name or NULL if not available,
+ * if non NULL it need to be freed by the caller.
*/
xmlChar *
xmlTextReaderLocalName(xmlTextReaderPtr reader) {
@@ -3089,7 +3164,8 @@ xmlTextReaderConstLocalName(xmlTextReaderPtr reader) {
*
* The qualified name of the node, equal to Prefix :LocalName.
*
- * Returns the local name or NULL if not available
+ * Returns the local name or NULL if not available,
+ * if non NULL it need to be freed by the caller.
*/
xmlChar *
xmlTextReaderName(xmlTextReaderPtr reader) {
@@ -3108,7 +3184,7 @@ xmlTextReaderName(xmlTextReaderPtr reader) {
if ((node->ns == NULL) ||
(node->ns->prefix == NULL))
return(xmlStrdup(node->name));
-
+
ret = xmlStrdup(node->ns->prefix);
ret = xmlStrcat(ret, BAD_CAST ":");
ret = xmlStrcat(ret, node->name);
@@ -3232,7 +3308,8 @@ xmlTextReaderConstName(xmlTextReaderPtr reader) {
*
* A shorthand reference to the namespace associated with the node.
*
- * Returns the prefix or NULL if not available
+ * Returns the prefix or NULL if not available,
+ * if non NULL it need to be freed by the caller.
*/
xmlChar *
xmlTextReaderPrefix(xmlTextReaderPtr reader) {
@@ -3295,7 +3372,8 @@ xmlTextReaderConstPrefix(xmlTextReaderPtr reader) {
*
* The URI defining the namespace associated with the node.
*
- * Returns the namespace URI or NULL if not available
+ * Returns the namespace URI or NULL if not available,
+ * if non NULL it need to be freed by the caller.
*/
xmlChar *
xmlTextReaderNamespaceUri(xmlTextReaderPtr reader) {
@@ -3350,7 +3428,8 @@ xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader) {
*
* The base URI of the node.
*
- * Returns the base URI or NULL if not available
+ * Returns the base URI or NULL if not available,
+ * if non NULL it need to be freed by the caller.
*/
xmlChar *
xmlTextReaderBaseUri(xmlTextReaderPtr reader) {
@@ -3540,22 +3619,35 @@ xmlTextReaderConstValue(xmlTextReaderPtr reader) {
return(((xmlNsPtr) node)->href);
case XML_ATTRIBUTE_NODE:{
xmlAttrPtr attr = (xmlAttrPtr) node;
+ const xmlChar *ret;
if ((attr->children != NULL) &&
(attr->children->type == XML_TEXT_NODE) &&
(attr->children->next == NULL))
return(attr->children->content);
else {
- if (reader->buffer == NULL)
- reader->buffer = xmlBufferCreateSize(100);
if (reader->buffer == NULL) {
- xmlGenericError(xmlGenericErrorContext,
- "xmlTextReaderSetup : malloc failed\n");
- return (NULL);
+ reader->buffer = xmlBufCreateSize(100);
+ if (reader->buffer == NULL) {
+ xmlGenericError(xmlGenericErrorContext,
+ "xmlTextReaderSetup : malloc failed\n");
+ return (NULL);
+ }
+ xmlBufSetAllocationScheme(reader->buffer,
+ XML_BUFFER_ALLOC_BOUNDED);
+ } else
+ xmlBufEmpty(reader->buffer);
+ xmlBufGetNodeContent(reader->buffer, node);
+ ret = xmlBufContent(reader->buffer);
+ if (ret == NULL) {
+ /* error on the buffer best to reallocate */
+ xmlBufFree(reader->buffer);
+ reader->buffer = xmlBufCreateSize(100);
+ xmlBufSetAllocationScheme(reader->buffer,
+ XML_BUFFER_ALLOC_BOUNDED);
+ ret = BAD_CAST "";
}
- reader->buffer->use = 0;
- xmlNodeBufGetContent(reader->buffer, node);
- return(reader->buffer->content);
+ return(ret);
}
break;
}
@@ -3608,7 +3700,8 @@ xmlTextReaderQuoteChar(xmlTextReaderPtr reader) {
*
* The xml:lang scope within which the node resides.
*
- * Returns the xml:lang value or NULL if none exists.
+ * Returns the xml:lang value or NULL if none exists.,
+ * if non NULL it need to be freed by the caller.
*/
xmlChar *
xmlTextReaderXmlLang(xmlTextReaderPtr reader) {
@@ -3833,7 +3926,7 @@ xmlNodePtr
xmlTextReaderCurrentNode(xmlTextReaderPtr reader) {
if (reader == NULL)
return(NULL);
-
+
if (reader->curnode != NULL)
return(reader->curnode);
return(reader->node);
@@ -3855,7 +3948,7 @@ xmlTextReaderPreserve(xmlTextReaderPtr reader) {
if (reader == NULL)
return(NULL);
-
+
if (reader->curnode != NULL)
cur = reader->curnode;
else
@@ -3868,7 +3961,7 @@ xmlTextReaderPreserve(xmlTextReaderPtr reader) {
cur->extra |= NODE_IS_SPRESERVED;
}
reader->preserves++;
-
+
parent = cur->parent;;
while (parent != NULL) {
if (parent->type == XML_ELEMENT_NODE)
@@ -3884,7 +3977,7 @@ xmlTextReaderPreserve(xmlTextReaderPtr reader) {
* @reader: the xmlTextReaderPtr used
* @pattern: an XPath subset pattern
* @namespaces: the prefix definitions, array of [URI, prefix] or NULL
- *
+ *
* This tells the XML Reader to preserve all nodes matched by the
* pattern. The caller must also use xmlTextReaderCurrentDoc() to
* keep an handle on the resulting document once parsing has finished
@@ -3899,7 +3992,7 @@ xmlTextReaderPreservePattern(xmlTextReaderPtr reader, const xmlChar *pattern,
if ((reader == NULL) || (pattern == NULL))
return(-1);
-
+
comp = xmlPatterncompile(pattern, reader->dict, 0, namespaces);
if (comp == NULL)
return(-1);
@@ -3936,7 +4029,7 @@ xmlTextReaderPreservePattern(xmlTextReaderPtr reader, const xmlChar *pattern,
* @reader: the xmlTextReaderPtr used
*
* Hacking interface allowing to get the xmlDocPtr correponding to the
- * current document being accessed by the xmlTextReader.
+ * current document being accessed by the xmlTextReader.
* NOTE: as a result of this call, the reader will not destroy the
* associated XML document and calling xmlFreeDoc() on the result
* is needed once the reader parsing has finished.
@@ -3949,75 +4042,82 @@ xmlTextReaderCurrentDoc(xmlTextReaderPtr reader) {
return(NULL);
if (reader->doc != NULL)
return(reader->doc);
- if ((reader == NULL) || (reader->ctxt == NULL) ||
- (reader->ctxt->myDoc == NULL))
+ if ((reader->ctxt == NULL) || (reader->ctxt->myDoc == NULL))
return(NULL);
-
+
reader->preserve = 1;
return(reader->ctxt->myDoc);
}
#ifdef LIBXML_SCHEMAS_ENABLED
+static char *xmlTextReaderBuildMessage(const char *msg, va_list ap);
-static char *
-xmlTextReaderBuildMessage(const char *msg, va_list ap);
-
-static void XMLCDECL
+static void XMLCDECL
xmlTextReaderValidityError(void *ctxt, const char *msg, ...);
-static void XMLCDECL
+static void XMLCDECL
xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...);
-static void XMLCDECL xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...)
+static void XMLCDECL
+xmlTextReaderValidityErrorRelay(void *ctx, const char *msg, ...)
{
- xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
- char * str;
- va_list ap;
-
- va_start(ap,msg);
- str = xmlTextReaderBuildMessage(msg,ap);
- if (!reader->errorFunc) {
- xmlTextReaderValidityError(ctx, "%s", str);
- } else {
- reader->errorFunc(reader->errorFuncArg, str, XML_PARSER_SEVERITY_VALIDITY_ERROR, NULL /* locator */);
- }
- if (str != NULL)
- xmlFree(str);
- va_end(ap);
+ xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
+
+ char *str;
+
+ va_list ap;
+
+ va_start(ap, msg);
+ str = xmlTextReaderBuildMessage(msg, ap);
+ if (!reader->errorFunc) {
+ xmlTextReaderValidityError(ctx, "%s", str);
+ } else {
+ reader->errorFunc(reader->errorFuncArg, str,
+ XML_PARSER_SEVERITY_VALIDITY_ERROR,
+ NULL /* locator */ );
+ }
+ if (str != NULL)
+ xmlFree(str);
+ va_end(ap);
}
-static void XMLCDECL xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...)
+static void XMLCDECL
+xmlTextReaderValidityWarningRelay(void *ctx, const char *msg, ...)
{
- xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
- char * str;
- va_list ap;
-
- va_start(ap,msg);
- str = xmlTextReaderBuildMessage(msg,ap);
- if (!reader->errorFunc) {
- xmlTextReaderValidityWarning(ctx, "%s", str);
- } else {
- reader->errorFunc(reader->errorFuncArg, str, XML_PARSER_SEVERITY_VALIDITY_WARNING, NULL /* locator */);
- }
- if (str != NULL)
- xmlFree(str);
- va_end(ap);
+ xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx;
+
+ char *str;
+
+ va_list ap;
+
+ va_start(ap, msg);
+ str = xmlTextReaderBuildMessage(msg, ap);
+ if (!reader->errorFunc) {
+ xmlTextReaderValidityWarning(ctx, "%s", str);
+ } else {
+ reader->errorFunc(reader->errorFuncArg, str,
+ XML_PARSER_SEVERITY_VALIDITY_WARNING,
+ NULL /* locator */ );
+ }
+ if (str != NULL)
+ xmlFree(str);
+ va_end(ap);
}
-static void
-xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error);
+static void
+ xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error);
-static void xmlTextReaderValidityStructuredRelay(void * userData, xmlErrorPtr error)
+static void
+xmlTextReaderValidityStructuredRelay(void *userData, xmlErrorPtr error)
{
- xmlTextReaderPtr reader = (xmlTextReaderPtr) userData;
+ xmlTextReaderPtr reader = (xmlTextReaderPtr) userData;
- if (reader->sErrorFunc) {
- reader->sErrorFunc(reader->errorFuncArg, error);
- } else {
- xmlTextReaderStructuredError(reader, error);
- }
+ if (reader->sErrorFunc) {
+ reader->sErrorFunc(reader->errorFuncArg, error);
+ } else {
+ xmlTextReaderStructuredError(reader, error);
+ }
}
-
/**
* xmlTextReaderRelaxNGSetSchema:
* @reader: the xmlTextReaderPtr used
@@ -4042,9 +4142,11 @@ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
reader->rngSchemas = NULL;
}
if (reader->rngValidCtxt != NULL) {
- xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
+ if (! reader->rngPreserveCtxt)
+ xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
reader->rngValidCtxt = NULL;
}
+ reader->rngPreserveCtxt = 0;
return(0);
}
if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
@@ -4054,9 +4156,11 @@ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
reader->rngSchemas = NULL;
}
if (reader->rngValidCtxt != NULL) {
- xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
+ if (! reader->rngPreserveCtxt)
+ xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
reader->rngValidCtxt = NULL;
}
+ reader->rngPreserveCtxt = 0;
reader->rngValidCtxt = xmlRelaxNGNewValidCtxt(schema);
if (reader->rngValidCtxt == NULL)
return(-1);
@@ -4067,7 +4171,7 @@ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
reader);
}
if (reader->sErrorFunc != NULL) {
- xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
+ xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
xmlTextReaderValidityStructuredRelay,
reader);
}
@@ -4078,6 +4182,60 @@ xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader, xmlRelaxNGPtr schema) {
}
/**
+ * xmlTextReaderLocator:
+ * @ctx: the xmlTextReaderPtr used
+ * @file: returned file information
+ * @line: returned line information
+ *
+ * Internal locator function for the readers
+ *
+ * Returns 0 in case the Schema validation could be (des)activated and
+ * -1 in case of error.
+ */
+static int
+xmlTextReaderLocator(void *ctx, const char **file, unsigned long *line) {
+ xmlTextReaderPtr reader;
+
+ if ((ctx == NULL) || ((file == NULL) && (line == NULL)))
+ return(-1);
+
+ if (file != NULL)
+ *file = NULL;
+ if (line != NULL)
+ *line = 0;
+
+ reader = (xmlTextReaderPtr) ctx;
+ if ((reader->ctxt != NULL) && (reader->ctxt->input != NULL)) {
+ if (file != NULL)
+ *file = reader->ctxt->input->filename;
+ if (line != NULL)
+ *line = reader->ctxt->input->line;
+ return(0);
+ }
+ if (reader->node != NULL) {
+ long res;
+ int ret = 0;
+
+ if (line != NULL) {
+ res = xmlGetLineNo(reader->node);
+ if (res > 0)
+ *line = (unsigned long) res;
+ else
+ ret = -1;
+ }
+ if (file != NULL) {
+ xmlDocPtr doc = reader->node->doc;
+ if ((doc != NULL) && (doc->URL != NULL))
+ *file = (const char *) doc->URL;
+ else
+ ret = -1;
+ }
+ return(ret);
+ }
+ return(-1);
+}
+
+/**
* xmlTextReaderSetSchema:
* @reader: the xmlTextReaderPtr used
* @schema: a precompiled Schema schema
@@ -4103,15 +4261,15 @@ xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema) {
if (reader->xsdValidCtxt != NULL) {
if (! reader->xsdPreserveCtxt)
xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
- reader->xsdValidCtxt = NULL;
+ reader->xsdValidCtxt = NULL;
}
reader->xsdPreserveCtxt = 0;
if (reader->xsdSchemas != NULL) {
xmlSchemaFree(reader->xsdSchemas);
reader->xsdSchemas = NULL;
- }
+ }
return(0);
- }
+ }
if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
return(-1);
if (reader->xsdPlug != NULL) {
@@ -4120,7 +4278,7 @@ xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema) {
}
if (reader->xsdValidCtxt != NULL) {
if (! reader->xsdPreserveCtxt)
- xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
+ xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
reader->xsdValidCtxt = NULL;
}
reader->xsdPreserveCtxt = 0;
@@ -4144,6 +4302,10 @@ xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema) {
reader->xsdValidCtxt = NULL;
return(-1);
}
+ xmlSchemaValidateSetLocator(reader->xsdValidCtxt,
+ xmlTextReaderLocator,
+ (void *) reader);
+
if (reader->errorFunc != NULL) {
xmlSchemaSetValidErrors(reader->xsdValidCtxt,
xmlTextReaderValidityErrorRelay,
@@ -4161,67 +4323,91 @@ xmlTextReaderSetSchema(xmlTextReaderPtr reader, xmlSchemaPtr schema) {
}
/**
- * xmlTextReaderRelaxNGValidate:
+ * xmlTextReaderRelaxNGValidateInternal:
* @reader: the xmlTextReaderPtr used
* @rng: the path to a RelaxNG schema or NULL
+ * @ctxt: the RelaxNG schema validation context or NULL
+ * @options: options (not yet used)
*
* Use RelaxNG to validate the document as it is processed.
* Activation is only possible before the first Read().
- * if @rng is NULL, then RelaxNG validation is desactivated.
+ * If both @rng and @ctxt are NULL, then RelaxNG validation is deactivated.
*
- * Returns 0 in case the RelaxNG validation could be (des)activated and
- * -1 in case of error.
+ * Returns 0 in case the RelaxNG validation could be (de)activated and
+ * -1 in case of error.
*/
-int
-xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) {
- xmlRelaxNGParserCtxtPtr ctxt;
-
+static int
+xmlTextReaderRelaxNGValidateInternal(xmlTextReaderPtr reader,
+ const char *rng,
+ xmlRelaxNGValidCtxtPtr ctxt,
+ int options ATTRIBUTE_UNUSED)
+{
if (reader == NULL)
- return(-1);
-
- if (rng == NULL) {
- if (reader->rngValidCtxt != NULL) {
+ return(-1);
+
+ if ((rng != NULL) && (ctxt != NULL))
+ return (-1);
+
+ if (((rng != NULL) || (ctxt != NULL)) &&
+ ((reader->mode != XML_TEXTREADER_MODE_INITIAL) ||
+ (reader->ctxt == NULL)))
+ return(-1);
+
+ /* Cleanup previous validation stuff. */
+ if (reader->rngValidCtxt != NULL) {
+ if ( !reader->rngPreserveCtxt)
xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
- reader->rngValidCtxt = NULL;
- }
- if (reader->rngSchemas != NULL) {
- xmlRelaxNGFree(reader->rngSchemas);
- reader->rngSchemas = NULL;
- }
- return(0);
+ reader->rngValidCtxt = NULL;
}
- if (reader->mode != XML_TEXTREADER_MODE_INITIAL)
- return(-1);
+ reader->rngPreserveCtxt = 0;
if (reader->rngSchemas != NULL) {
xmlRelaxNGFree(reader->rngSchemas);
reader->rngSchemas = NULL;
}
- if (reader->rngValidCtxt != NULL) {
- xmlRelaxNGFreeValidCtxt(reader->rngValidCtxt);
- reader->rngValidCtxt = NULL;
- }
- ctxt = xmlRelaxNGNewParserCtxt(rng);
- if (reader->errorFunc != NULL) {
- xmlRelaxNGSetParserErrors(ctxt,
- xmlTextReaderValidityErrorRelay,
- xmlTextReaderValidityWarningRelay,
- reader);
+
+ if ((rng == NULL) && (ctxt == NULL)) {
+ /* We just want to deactivate the validation, so get out. */
+ return(0);
}
+
+
+ if (rng != NULL) {
+ xmlRelaxNGParserCtxtPtr pctxt;
+ /* Parse the schema and create validation environment. */
+
+ pctxt = xmlRelaxNGNewParserCtxt(rng);
+ if (reader->errorFunc != NULL) {
+ xmlRelaxNGSetParserErrors(pctxt,
+ xmlTextReaderValidityErrorRelay,
+ xmlTextReaderValidityWarningRelay,
+ reader);
+ }
if (reader->sErrorFunc != NULL) {
- xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
- xmlTextReaderValidityStructuredRelay,
- reader);
- }
- reader->rngSchemas = xmlRelaxNGParse(ctxt);
- xmlRelaxNGFreeParserCtxt(ctxt);
- if (reader->rngSchemas == NULL)
- return(-1);
- reader->rngValidCtxt = xmlRelaxNGNewValidCtxt(reader->rngSchemas);
- if (reader->rngValidCtxt == NULL) {
- xmlRelaxNGFree(reader->rngSchemas);
- reader->rngSchemas = NULL;
- return(-1);
+ xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
+ xmlTextReaderValidityStructuredRelay,
+ reader);
+ }
+ reader->rngSchemas = xmlRelaxNGParse(pctxt);
+ xmlRelaxNGFreeParserCtxt(pctxt);
+ if (reader->rngSchemas == NULL)
+ return(-1);
+ reader->rngValidCtxt = xmlRelaxNGNewValidCtxt(reader->rngSchemas);
+ if (reader->rngValidCtxt == NULL) {
+ xmlRelaxNGFree(reader->rngSchemas);
+ reader->rngSchemas = NULL;
+ return(-1);
+ }
+ } else {
+ /* Use the given validation context. */
+ reader->rngValidCtxt = ctxt;
+ reader->rngPreserveCtxt = 1;
}
+ /*
+ * Redirect the validation context's error channels to use
+ * the reader channels.
+ * TODO: In case the user provides the validation context we
+ * could make this redirection optional.
+ */
if (reader->errorFunc != NULL) {
xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
xmlTextReaderValidityErrorRelay,
@@ -4229,7 +4415,7 @@ xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng) {
reader);
}
if (reader->sErrorFunc != NULL) {
- xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
+ xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
xmlTextReaderValidityStructuredRelay,
reader);
}
@@ -4258,7 +4444,7 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
const char *xsd,
xmlSchemaValidCtxtPtr ctxt,
int options ATTRIBUTE_UNUSED)
-{
+{
if (reader == NULL)
return(-1);
@@ -4269,7 +4455,7 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
((reader->mode != XML_TEXTREADER_MODE_INITIAL) ||
(reader->ctxt == NULL)))
return(-1);
-
+
/* Cleanup previous validation stuff. */
if (reader->xsdPlug != NULL) {
xmlSchemaSAXUnplug(reader->xsdPlug);
@@ -4277,20 +4463,20 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
}
if (reader->xsdValidCtxt != NULL) {
if (! reader->xsdPreserveCtxt)
- xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
+ xmlSchemaFreeValidCtxt(reader->xsdValidCtxt);
reader->xsdValidCtxt = NULL;
}
reader->xsdPreserveCtxt = 0;
if (reader->xsdSchemas != NULL) {
xmlSchemaFree(reader->xsdSchemas);
reader->xsdSchemas = NULL;
- }
+ }
if ((xsd == NULL) && (ctxt == NULL)) {
/* We just want to deactivate the validation, so get out. */
return(0);
- }
-
+ }
+
if (xsd != NULL) {
xmlSchemaParserCtxtPtr pctxt;
/* Parse the schema and create validation environment. */
@@ -4322,18 +4508,21 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
return(-1);
}
} else {
- /* Use the given validation context. */
+ /* Use the given validation context. */
reader->xsdValidCtxt = ctxt;
reader->xsdPreserveCtxt = 1;
reader->xsdPlug = xmlSchemaSAXPlug(reader->xsdValidCtxt,
&(reader->ctxt->sax),
&(reader->ctxt->userData));
- if (reader->xsdPlug == NULL) {
+ if (reader->xsdPlug == NULL) {
reader->xsdValidCtxt = NULL;
reader->xsdPreserveCtxt = 0;
return(-1);
}
}
+ xmlSchemaValidateSetLocator(reader->xsdValidCtxt,
+ xmlTextReaderLocator,
+ (void *) reader);
/*
* Redirect the validation context's error channels to use
* the reader channels.
@@ -4347,7 +4536,7 @@ xmlTextReaderSchemaValidateInternal(xmlTextReaderPtr reader,
reader);
}
if (reader->sErrorFunc != NULL) {
- xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt,
+ xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt,
xmlTextReaderValidityStructuredRelay,
reader);
}
@@ -4394,6 +4583,46 @@ xmlTextReaderSchemaValidate(xmlTextReaderPtr reader, const char *xsd)
{
return(xmlTextReaderSchemaValidateInternal(reader, xsd, NULL, 0));
}
+
+/**
+ * xmlTextReaderRelaxNGValidateCtxt:
+ * @reader: the xmlTextReaderPtr used
+ * @ctxt: the RelaxNG schema validation context or NULL
+ * @options: options (not used yet)
+ *
+ * Use RelaxNG schema context to validate the document as it is processed.
+ * Activation is only possible before the first Read().
+ * If @ctxt is NULL, then RelaxNG schema validation is deactivated.
+ *
+ * Returns 0 in case the schemas validation could be (de)activated and
+ * -1 in case of error.
+ */
+int
+xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,
+ xmlRelaxNGValidCtxtPtr ctxt,
+ int options)
+{
+ return(xmlTextReaderRelaxNGValidateInternal(reader, NULL, ctxt, options));
+}
+
+/**
+ * xmlTextReaderRelaxNGValidate:
+ * @reader: the xmlTextReaderPtr used
+ * @rng: the path to a RelaxNG schema or NULL
+ *
+ * Use RelaxNG schema to validate the document as it is processed.
+ * Activation is only possible before the first Read().
+ * If @rng is NULL, then RelaxNG schema validation is deactivated.
+ *
+ * Returns 0 in case the schemas validation could be (de)activated and
+ * -1 in case of error.
+ */
+int
+xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader, const char *rng)
+{
+ return(xmlTextReaderRelaxNGValidateInternal(reader, rng, NULL, 0));
+}
+
#endif
/**
@@ -4418,7 +4647,7 @@ xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader) {
node = reader->curnode;
else
node = reader->node;
-
+
if (XML_NAMESPACE_DECL == node->type)
return(1);
else
@@ -4442,10 +4671,10 @@ xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader) {
if (reader->doc != NULL)
doc = reader->doc;
else if (reader->ctxt != NULL)
- doc = reader->ctxt->myDoc;
+ doc = reader->ctxt->myDoc;
if (doc == NULL)
return(NULL);
-
+
if (doc->version == NULL)
return(NULL);
else
@@ -4486,30 +4715,32 @@ xmlTextReaderStandalone(xmlTextReaderPtr reader) {
/* helper to build a xmlMalloc'ed string from a format and va_list */
static char *
xmlTextReaderBuildMessage(const char *msg, va_list ap) {
- int size;
+ int size = 0;
int chars;
char *larger;
- char *str;
-
- str = (char *) xmlMallocAtomic(150);
- if (str == NULL) {
- xmlGenericError(xmlGenericErrorContext, "xmlMalloc failed !\n");
- return NULL;
- }
-
- size = 150;
+ char *str = NULL;
+ va_list aq;
while (1) {
- chars = vsnprintf(str, size, msg, ap);
- if ((chars > -1) && (chars < size))
+ VA_COPY(aq, ap);
+ chars = vsnprintf(str, size, msg, aq);
+ va_end(aq);
+ if (chars < 0) {
+ xmlGenericError(xmlGenericErrorContext, "vsnprintf failed !\n");
+ if (str)
+ xmlFree(str);
+ return NULL;
+ }
+ if ((chars < size) || (size == MAX_ERR_MSG_SIZE))
break;
- if (chars > -1)
- size += chars + 1;
- else
- size += 100;
+ if (chars < MAX_ERR_MSG_SIZE)
+ size = chars + 1;
+ else
+ size = MAX_ERR_MSG_SIZE;
if ((larger = (char *) xmlRealloc(str, size)) == NULL) {
xmlGenericError(xmlGenericErrorContext, "xmlRealloc failed !\n");
- xmlFree(str);
+ if (str)
+ xmlFree(str);
return NULL;
}
str = larger;
@@ -4545,7 +4776,7 @@ xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator) {
input = ctx->inputTab[ctx->inputNr - 2];
if (input != NULL) {
ret = input->line;
- }
+ }
else {
ret = -1;
}
@@ -4560,7 +4791,8 @@ xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator) {
*
* Obtain the base URI for the given locator.
*
- * Returns the base URI or NULL in case of error.
+ * Returns the base URI or NULL in case of error,
+ * if non NULL it need to be freed by the caller.
*/
xmlChar *
xmlTextReaderLocatorBaseURI(xmlTextReaderLocatorPtr locator) {
@@ -4581,7 +4813,7 @@ xmlTextReaderLocatorBaseURI(xmlTextReaderLocatorPtr locator) {
input = ctx->inputTab[ctx->inputNr - 2];
if (input != NULL) {
ret = xmlStrdup(BAD_CAST input->filename);
- }
+ }
else {
ret = NULL;
}
@@ -4591,87 +4823,95 @@ xmlTextReaderLocatorBaseURI(xmlTextReaderLocatorPtr locator) {
}
static void
-xmlTextReaderGenericError(void *ctxt, xmlParserSeverities severity, char *str) {
- xmlParserCtxtPtr ctx = (xmlParserCtxtPtr)ctxt;
- xmlTextReaderPtr reader = (xmlTextReaderPtr)ctx->_private;
+xmlTextReaderGenericError(void *ctxt, xmlParserSeverities severity,
+ char *str)
+{
+ xmlParserCtxtPtr ctx = (xmlParserCtxtPtr) ctxt;
+
+ xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx->_private;
if (str != NULL) {
- if (reader->errorFunc)
- reader->errorFunc(reader->errorFuncArg,
- str,
- severity,
- (xmlTextReaderLocatorPtr)ctx);
- xmlFree(str);
+ if (reader->errorFunc)
+ reader->errorFunc(reader->errorFuncArg, str, severity,
+ (xmlTextReaderLocatorPtr) ctx);
+ xmlFree(str);
}
}
-static void
-xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error) {
- xmlParserCtxtPtr ctx = (xmlParserCtxtPtr) ctxt;
- xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx->_private;
+static void
+xmlTextReaderStructuredError(void *ctxt, xmlErrorPtr error)
+{
+ xmlParserCtxtPtr ctx = (xmlParserCtxtPtr) ctxt;
+
+ xmlTextReaderPtr reader = (xmlTextReaderPtr) ctx->_private;
- if (error && reader->sErrorFunc) {
- reader->sErrorFunc(reader->errorFuncArg,
- (xmlErrorPtr) error);
- }
+ if (error && reader->sErrorFunc) {
+ reader->sErrorFunc(reader->errorFuncArg, (xmlErrorPtr) error);
+ }
}
-static void XMLCDECL
-xmlTextReaderError(void *ctxt, const char *msg, ...) {
+static void XMLCDECL
+xmlTextReaderError(void *ctxt, const char *msg, ...)
+{
va_list ap;
- va_start(ap,msg);
+ va_start(ap, msg);
xmlTextReaderGenericError(ctxt,
XML_PARSER_SEVERITY_ERROR,
- xmlTextReaderBuildMessage(msg,ap));
+ xmlTextReaderBuildMessage(msg, ap));
va_end(ap);
}
-static void XMLCDECL
-xmlTextReaderWarning(void *ctxt, const char *msg, ...) {
+static void XMLCDECL
+xmlTextReaderWarning(void *ctxt, const char *msg, ...)
+{
va_list ap;
- va_start(ap,msg);
+ va_start(ap, msg);
xmlTextReaderGenericError(ctxt,
XML_PARSER_SEVERITY_WARNING,
- xmlTextReaderBuildMessage(msg,ap));
+ xmlTextReaderBuildMessage(msg, ap));
va_end(ap);
}
-static void XMLCDECL
-xmlTextReaderValidityError(void *ctxt, const char *msg, ...) {
+static void XMLCDECL
+xmlTextReaderValidityError(void *ctxt, const char *msg, ...)
+{
va_list ap;
+
int len = xmlStrlen((const xmlChar *) msg);
if ((len > 1) && (msg[len - 2] != ':')) {
- /*
- * some callbacks only report locator information:
- * skip them (mimicking behaviour in error.c)
- */
- va_start(ap,msg);
- xmlTextReaderGenericError(ctxt,
- XML_PARSER_SEVERITY_VALIDITY_ERROR,
- xmlTextReaderBuildMessage(msg,ap));
- va_end(ap);
+ /*
+ * some callbacks only report locator information:
+ * skip them (mimicking behaviour in error.c)
+ */
+ va_start(ap, msg);
+ xmlTextReaderGenericError(ctxt,
+ XML_PARSER_SEVERITY_VALIDITY_ERROR,
+ xmlTextReaderBuildMessage(msg, ap));
+ va_end(ap);
}
}
-static void XMLCDECL
-xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...) {
+static void XMLCDECL
+xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...)
+{
va_list ap;
+
int len = xmlStrlen((const xmlChar *) msg);
if ((len != 0) && (msg[len - 1] != ':')) {
- /*
- * some callbacks only report locator information:
- * skip them (mimicking behaviour in error.c)
- */
- va_start(ap,msg);
- xmlTextReaderGenericError(ctxt,
- XML_PARSER_SEVERITY_VALIDITY_WARNING,
- xmlTextReaderBuildMessage(msg,ap));
- va_end(ap);
+ /*
+ * some callbacks only report locator information:
+ * skip them (mimicking behaviour in error.c)
+ */
+ va_start(ap, msg);
+ xmlTextReaderGenericError(ctxt,
+ XML_PARSER_SEVERITY_VALIDITY_WARNING,
+ xmlTextReaderBuildMessage(msg, ap));
+ va_end(ap);
}
}
@@ -4686,53 +4926,58 @@ xmlTextReaderValidityWarning(void *ctxt, const char *msg, ...) {
* If @f is NULL, the default error and warning handlers are restored.
*/
void
-xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
- xmlTextReaderErrorFunc f,
- void *arg) {
+xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
+ xmlTextReaderErrorFunc f, void *arg)
+{
if (f != NULL) {
- reader->ctxt->sax->error = xmlTextReaderError;
- reader->ctxt->sax->serror = NULL;
- reader->ctxt->vctxt.error = xmlTextReaderValidityError;
- reader->ctxt->sax->warning = xmlTextReaderWarning;
- reader->ctxt->vctxt.warning = xmlTextReaderValidityWarning;
- reader->errorFunc = f;
- reader->sErrorFunc = NULL;
- reader->errorFuncArg = arg;
+ reader->ctxt->sax->error = xmlTextReaderError;
+ reader->ctxt->sax->serror = NULL;
+ reader->ctxt->vctxt.error = xmlTextReaderValidityError;
+ reader->ctxt->sax->warning = xmlTextReaderWarning;
+ reader->ctxt->vctxt.warning = xmlTextReaderValidityWarning;
+ reader->errorFunc = f;
+ reader->sErrorFunc = NULL;
+ reader->errorFuncArg = arg;
#ifdef LIBXML_SCHEMAS_ENABLED
- if (reader->rngValidCtxt) {
- xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
- xmlTextReaderValidityErrorRelay,
- xmlTextReaderValidityWarningRelay,
- reader);
- xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL, reader);
- }
- if (reader->xsdValidCtxt) {
- xmlSchemaSetValidErrors(reader->xsdValidCtxt,
- xmlTextReaderValidityErrorRelay,
- xmlTextReaderValidityWarningRelay,
- reader);
- xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL, reader);
- }
+ if (reader->rngValidCtxt) {
+ xmlRelaxNGSetValidErrors(reader->rngValidCtxt,
+ xmlTextReaderValidityErrorRelay,
+ xmlTextReaderValidityWarningRelay,
+ reader);
+ xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL,
+ reader);
+ }
+ if (reader->xsdValidCtxt) {
+ xmlSchemaSetValidErrors(reader->xsdValidCtxt,
+ xmlTextReaderValidityErrorRelay,
+ xmlTextReaderValidityWarningRelay,
+ reader);
+ xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL,
+ reader);
+ }
#endif
- }
- else {
- /* restore defaults */
- reader->ctxt->sax->error = xmlParserError;
- reader->ctxt->vctxt.error = xmlParserValidityError;
- reader->ctxt->sax->warning = xmlParserWarning;
- reader->ctxt->vctxt.warning = xmlParserValidityWarning;
- reader->errorFunc = NULL;
- reader->sErrorFunc = NULL;
- reader->errorFuncArg = NULL;
+ } else {
+ /* restore defaults */
+ reader->ctxt->sax->error = xmlParserError;
+ reader->ctxt->vctxt.error = xmlParserValidityError;
+ reader->ctxt->sax->warning = xmlParserWarning;
+ reader->ctxt->vctxt.warning = xmlParserValidityWarning;
+ reader->errorFunc = NULL;
+ reader->sErrorFunc = NULL;
+ reader->errorFuncArg = NULL;
#ifdef LIBXML_SCHEMAS_ENABLED
- if (reader->rngValidCtxt) {
- xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL, reader);
- xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL, reader);
- }
- if (reader->xsdValidCtxt) {
- xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL, reader);
- xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL, reader);
- }
+ if (reader->rngValidCtxt) {
+ xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL,
+ reader);
+ xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL,
+ reader);
+ }
+ if (reader->xsdValidCtxt) {
+ xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL,
+ reader);
+ xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL,
+ reader);
+ }
#endif
}
}
@@ -4748,54 +4993,59 @@ xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
* If @f is NULL, the default error and warning handlers are restored.
*/
void
-xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
- xmlStructuredErrorFunc f,
- void *arg) {
- if (f != NULL) {
- reader->ctxt->sax->error = NULL;
- reader->ctxt->sax->serror = xmlTextReaderStructuredError;
- reader->ctxt->vctxt.error = xmlTextReaderValidityError;
- reader->ctxt->sax->warning = xmlTextReaderWarning;
- reader->ctxt->vctxt.warning = xmlTextReaderValidityWarning;
- reader->sErrorFunc = f;
- reader->errorFunc = NULL;
- reader->errorFuncArg = arg;
+xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
+ xmlStructuredErrorFunc f, void *arg)
+{
+ if (f != NULL) {
+ reader->ctxt->sax->error = NULL;
+ reader->ctxt->sax->serror = xmlTextReaderStructuredError;
+ reader->ctxt->vctxt.error = xmlTextReaderValidityError;
+ reader->ctxt->sax->warning = xmlTextReaderWarning;
+ reader->ctxt->vctxt.warning = xmlTextReaderValidityWarning;
+ reader->sErrorFunc = f;
+ reader->errorFunc = NULL;
+ reader->errorFuncArg = arg;
#ifdef LIBXML_SCHEMAS_ENABLED
- if (reader->rngValidCtxt) {
- xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL, reader);
- xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
- xmlTextReaderValidityStructuredRelay,
- reader);
- }
- if (reader->xsdValidCtxt) {
- xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL, reader);
- xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt,
- xmlTextReaderValidityStructuredRelay,
- reader);
- }
+ if (reader->rngValidCtxt) {
+ xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL,
+ reader);
+ xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt,
+ xmlTextReaderValidityStructuredRelay,
+ reader);
+ }
+ if (reader->xsdValidCtxt) {
+ xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL,
+ reader);
+ xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt,
+ xmlTextReaderValidityStructuredRelay,
+ reader);
+ }
#endif
- }
- else {
- /* restore defaults */
- reader->ctxt->sax->error = xmlParserError;
- reader->ctxt->sax->serror = NULL;
- reader->ctxt->vctxt.error = xmlParserValidityError;
- reader->ctxt->sax->warning = xmlParserWarning;
- reader->ctxt->vctxt.warning = xmlParserValidityWarning;
- reader->errorFunc = NULL;
- reader->sErrorFunc = NULL;
- reader->errorFuncArg = NULL;
+ } else {
+ /* restore defaults */
+ reader->ctxt->sax->error = xmlParserError;
+ reader->ctxt->sax->serror = NULL;
+ reader->ctxt->vctxt.error = xmlParserValidityError;
+ reader->ctxt->sax->warning = xmlParserWarning;
+ reader->ctxt->vctxt.warning = xmlParserValidityWarning;
+ reader->errorFunc = NULL;
+ reader->sErrorFunc = NULL;
+ reader->errorFuncArg = NULL;
#ifdef LIBXML_SCHEMAS_ENABLED
- if (reader->rngValidCtxt) {
- xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL, reader);
- xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL, reader);
- }
- if (reader->xsdValidCtxt) {
- xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL, reader);
- xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL, reader);
- }
+ if (reader->rngValidCtxt) {
+ xmlRelaxNGSetValidErrors(reader->rngValidCtxt, NULL, NULL,
+ reader);
+ xmlRelaxNGSetValidStructuredErrors(reader->rngValidCtxt, NULL,
+ reader);
+ }
+ if (reader->xsdValidCtxt) {
+ xmlSchemaSetValidErrors(reader->xsdValidCtxt, NULL, NULL,
+ reader);
+ xmlSchemaSetValidStructuredErrors(reader->xsdValidCtxt, NULL,
+ reader);
+ }
#endif
- }
+ }
}
/**
@@ -4807,17 +5057,19 @@ xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
* Returns the flag value 1 if valid, 0 if no, and -1 in case of error
*/
int
-xmlTextReaderIsValid(xmlTextReaderPtr reader) {
- if (reader == NULL) return(-1);
+xmlTextReaderIsValid(xmlTextReaderPtr reader)
+{
+ if (reader == NULL)
+ return (-1);
#ifdef LIBXML_SCHEMAS_ENABLED
if (reader->validate == XML_TEXTREADER_VALIDATE_RNG)
- return(reader->rngValidErrors == 0);
+ return (reader->rngValidErrors == 0);
if (reader->validate == XML_TEXTREADER_VALIDATE_XSD)
- return(reader->xsdValidErrors == 0);
+ return (reader->xsdValidErrors == 0);
#endif
if ((reader->ctxt != NULL) && (reader->ctxt->validate == 1))
- return(reader->ctxt->valid);
- return(0);
+ return (reader->ctxt->valid);
+ return (0);
}
/**
@@ -4829,14 +5081,14 @@ xmlTextReaderIsValid(xmlTextReaderPtr reader) {
* Retrieve the error callback function and user argument.
*/
void
-xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
- xmlTextReaderErrorFunc *f,
- void **arg) {
- if (f != NULL) *f = reader->errorFunc;
- if (arg != NULL) *arg = reader->errorFuncArg;
+xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
+ xmlTextReaderErrorFunc * f, void **arg)
+{
+ if (f != NULL)
+ *f = reader->errorFunc;
+ if (arg != NULL)
+ *arg = reader->errorFuncArg;
}
-
-
/************************************************************************
* *
* New set (2.6.0) of simpler and more flexible APIs *
@@ -4846,22 +5098,26 @@ xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
/**
* xmlTextReaderSetup:
* @reader: an XML reader
+ * @input: xmlParserInputBufferPtr used to feed the reader, will
+ * be destroyed with it.
* @URL: the base URL to use for the document
* @encoding: the document encoding, or NULL
* @options: a combination of xmlParserOption
- * @reuse: keep the context for reuse
*
* Setup an XML reader with new options
- *
+ *
* Returns 0 in case of success and -1 in case of error.
*/
-static int
+int
xmlTextReaderSetup(xmlTextReaderPtr reader,
xmlParserInputBufferPtr input, const char *URL,
const char *encoding, int options)
{
- if (reader == NULL)
+ if (reader == NULL) {
+ if (input != NULL)
+ xmlFreeParserInputBuffer(input);
return (-1);
+ }
/*
* we force the generation of compact text nodes on the reader
@@ -4884,12 +5140,15 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
reader->allocs |= XML_TEXTREADER_INPUT;
}
if (reader->buffer == NULL)
- reader->buffer = xmlBufferCreateSize(100);
+ reader->buffer = xmlBufCreateSize(100);
if (reader->buffer == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlTextReaderSetup : malloc failed\n");
return (-1);
}
+ /* no operation on a reader should require a huge buffer */
+ xmlBufSetAllocationScheme(reader->buffer,
+ XML_BUFFER_ALLOC_BOUNDED);
if (reader->sax == NULL)
reader->sax = (xmlSAXHandler *) xmlMalloc(sizeof(xmlSAXHandler));
if (reader->sax == NULL) {
@@ -4925,13 +5184,14 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
reader->node = NULL;
reader->curnode = NULL;
if (input != NULL) {
- if (reader->input->buffer->use < 4) {
+ if (xmlBufUse(reader->input->buffer) < 4) {
xmlParserInputBufferRead(input, 4);
}
if (reader->ctxt == NULL) {
- if (reader->input->buffer->use >= 4) {
+ if (xmlBufUse(reader->input->buffer) >= 4) {
reader->ctxt = xmlCreatePushParserCtxt(reader->sax, NULL,
- (const char *) reader->input->buffer->content, 4, URL);
+ (const char *) xmlBufContent(reader->input->buffer),
+ 4, URL);
reader->base = 0;
reader->cur = 4;
} else {
@@ -4960,10 +5220,7 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
inputStream->filename = (char *)
xmlCanonicPath((const xmlChar *) URL);
inputStream->buf = buf;
- inputStream->base = inputStream->buf->buffer->content;
- inputStream->cur = inputStream->buf->buffer->content;
- inputStream->end =
- &inputStream->buf->buffer->content[inputStream->buf->buffer->use];
+ xmlBufResetInput(buf->buffer, inputStream);
inputPush(reader->ctxt, inputStream);
reader->cur = 0;
@@ -5064,14 +5321,14 @@ xmlTextReaderByteConsumed(xmlTextReaderPtr reader) {
return(-1);
return(xmlByteConsumed(reader->ctxt));
}
-
+
/**
* xmlReaderWalker:
* @doc: a preparsed document
*
* Create an xmltextReader for a preparsed document.
- *
+ *
* Returns the new reader or NULL in case of error.
*/
xmlTextReaderPtr
@@ -5112,7 +5369,7 @@ xmlReaderWalker(xmlDocPtr doc)
*
* Create an xmltextReader for an XML in-memory document.
* The parsing flags @options are a combination of xmlParserOption.
- *
+ *
* Returns the new reader or NULL in case of error.
*/
xmlTextReaderPtr
@@ -5137,7 +5394,7 @@ xmlReaderForDoc(const xmlChar * cur, const char *URL, const char *encoding,
*
* parse an XML file from the filesystem or the network.
* The parsing flags @options are a combination of xmlParserOption.
- *
+ *
* Returns the new reader or NULL in case of error.
*/
xmlTextReaderPtr
@@ -5162,7 +5419,7 @@ xmlReaderForFile(const char *filename, const char *encoding, int options)
*
* Create an xmltextReader for an XML in-memory document.
* The parsing flags @options are a combination of xmlParserOption.
- *
+ *
* Returns the new reader or NULL in case of error.
*/
xmlTextReaderPtr
@@ -5198,7 +5455,7 @@ xmlReaderForMemory(const char *buffer, int size, const char *URL,
* The parsing flags @options are a combination of xmlParserOption.
* NOTE that the file descriptor will not be closed when the
* reader is closed or reset.
- *
+ *
* Returns the new reader or NULL in case of error.
*/
xmlTextReaderPtr
@@ -5235,7 +5492,7 @@ xmlReaderForFd(int fd, const char *URL, const char *encoding, int options)
*
* Create an xmltextReader for an XML document from I/O functions and source.
* The parsing flags @options are a combination of xmlParserOption.
- *
+ *
* Returns the new reader or NULL in case of error.
*/
xmlTextReaderPtr
@@ -5251,8 +5508,11 @@ xmlReaderForIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
XML_CHAR_ENCODING_NONE);
- if (input == NULL)
+ if (input == NULL) {
+ if (ioclose != NULL)
+ ioclose(ioctx);
return (NULL);
+ }
reader = xmlNewTextReader(input, URL);
if (reader == NULL) {
xmlFreeParserInputBuffer(input);
@@ -5270,7 +5530,7 @@ xmlReaderForIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
*
* Setup an xmltextReader to parse a preparsed XML document.
* This reuses the existing @reader xmlTextReader.
- *
+ *
* Returns 0 in case of success and -1 in case of error
*/
int
@@ -5318,7 +5578,7 @@ xmlReaderNewWalker(xmlTextReaderPtr reader, xmlDocPtr doc)
* Setup an xmltextReader to parse an XML in-memory document.
* The parsing flags @options are a combination of xmlParserOption.
* This reuses the existing @reader xmlTextReader.
- *
+ *
* Returns 0 in case of success and -1 in case of error
*/
int
@@ -5348,7 +5608,7 @@ xmlReaderNewDoc(xmlTextReaderPtr reader, const xmlChar * cur,
* parse an XML file from the filesystem or the network.
* The parsing flags @options are a combination of xmlParserOption.
* This reuses the existing @reader xmlTextReader.
- *
+ *
* Returns 0 in case of success and -1 in case of error
*/
int
@@ -5382,7 +5642,7 @@ xmlReaderNewFile(xmlTextReaderPtr reader, const char *filename,
* Setup an xmltextReader to parse an XML in-memory document.
* The parsing flags @options are a combination of xmlParserOption.
* This reuses the existing @reader xmlTextReader.
- *
+ *
* Returns 0 in case of success and -1 in case of error
*/
int
@@ -5417,7 +5677,7 @@ xmlReaderNewMemory(xmlTextReaderPtr reader, const char *buffer, int size,
* reader is closed or reset.
* The parsing flags @options are a combination of xmlParserOption.
* This reuses the existing @reader xmlTextReader.
- *
+ *
* Returns 0 in case of success and -1 in case of error
*/
int
@@ -5452,7 +5712,7 @@ xmlReaderNewFd(xmlTextReaderPtr reader, int fd,
* and source.
* The parsing flags @options are a combination of xmlParserOption.
* This reuses the existing @reader xmlTextReader.
- *
+ *
* Returns 0 in case of success and -1 in case of error
*/
int
@@ -5469,16 +5729,21 @@ xmlReaderNewIO(xmlTextReaderPtr reader, xmlInputReadCallback ioread,
input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx,
XML_CHAR_ENCODING_NONE);
- if (input == NULL)
+ if (input == NULL) {
+ if (ioclose != NULL)
+ ioclose(ioctx);
return (-1);
+ }
return (xmlTextReaderSetup(reader, input, URL, encoding, options));
}
+
/************************************************************************
* *
* Utilities *
* *
************************************************************************/
#ifdef NOT_USED_YET
+
/**
* xmlBase64Decode:
* @in: the input buffer
@@ -5494,22 +5759,34 @@ xmlReaderNewIO(xmlTextReaderPtr reader, xmlInputReadCallback ioread,
*/
static int
xmlBase64Decode(const unsigned char *in, unsigned long *inlen,
- unsigned char *to, unsigned long *tolen) {
- unsigned long incur; /* current index in in[] */
- unsigned long inblk; /* last block index in in[] */
- unsigned long outcur; /* current index in out[] */
- unsigned long inmax; /* size of in[] */
- unsigned long outmax; /* size of out[] */
- unsigned char cur; /* the current value read from in[] */
- unsigned char intmp[4], outtmp[4]; /* temporary buffers for the convert */
- int nbintmp; /* number of byte in intmp[] */
- int is_ignore; /* cur should be ignored */
- int is_end = 0; /* the end of the base64 was found */
+ unsigned char *to, unsigned long *tolen)
+{
+ unsigned long incur; /* current index in in[] */
+
+ unsigned long inblk; /* last block index in in[] */
+
+ unsigned long outcur; /* current index in out[] */
+
+ unsigned long inmax; /* size of in[] */
+
+ unsigned long outmax; /* size of out[] */
+
+ unsigned char cur; /* the current value read from in[] */
+
+ unsigned char intmp[4], outtmp[4]; /* temporary buffers for the convert */
+
+ int nbintmp; /* number of byte in intmp[] */
+
+ int is_ignore; /* cur should be ignored */
+
+ int is_end = 0; /* the end of the base64 was found */
+
int retval = 1;
+
int i;
if ((in == NULL) || (inlen == NULL) || (to == NULL) || (tolen == NULL))
- return(-1);
+ return (-1);
incur = 0;
inblk = 0;
@@ -5535,16 +5812,17 @@ xmlBase64Decode(const unsigned char *in, unsigned long *inlen,
cur = 63;
else if (cur == '.')
cur = 0;
- else if (cur == '=') /*no op , end of the base64 stream */
+ else if (cur == '=') /*no op , end of the base64 stream */
is_end = 1;
else {
is_ignore = 1;
- if (nbintmp == 0)
- inblk = incur;
- }
+ if (nbintmp == 0)
+ inblk = incur;
+ }
if (!is_ignore) {
int nbouttmp = 3;
+
int is_break = 0;
if (is_end) {
@@ -5558,30 +5836,30 @@ xmlBase64Decode(const unsigned char *in, unsigned long *inlen,
is_break = 1;
}
intmp[nbintmp++] = cur;
- /*
- * if intmp is full, push the 4byte sequence as a 3 byte
- * sequence out
- */
+ /*
+ * if intmp is full, push the 4byte sequence as a 3 byte
+ * sequence out
+ */
if (nbintmp == 4) {
nbintmp = 0;
outtmp[0] = (intmp[0] << 2) | ((intmp[1] & 0x30) >> 4);
outtmp[1] =
((intmp[1] & 0x0F) << 4) | ((intmp[2] & 0x3C) >> 2);
outtmp[2] = ((intmp[2] & 0x03) << 6) | (intmp[3] & 0x3F);
- if (outcur + 3 >= outmax) {
- retval = 2;
- break;
- }
+ if (outcur + 3 >= outmax) {
+ retval = 2;
+ break;
+ }
for (i = 0; i < nbouttmp; i++)
- to[outcur++] = outtmp[i];
- inblk = incur;
+ to[outcur++] = outtmp[i];
+ inblk = incur;
}
if (is_break) {
- retval = 0;
+ retval = 0;
break;
- }
+ }
}
}
@@ -5594,14 +5872,23 @@ xmlBase64Decode(const unsigned char *in, unsigned long *inlen,
* Test routine for the xmlBase64Decode function
*/
#if 0
-int main(int argc, char **argv) {
+int
+main(int argc, char **argv)
+{
char *input = " VW4 gcGV0 \n aXQgdGVzdCAuCg== ";
+
char output[100];
+
char output2[100];
+
char output3[100];
+
unsigned long inlen = strlen(input);
+
unsigned long outlen = 100;
+
int ret;
+
unsigned long cons, tmp, tmp2, prod;
/*
@@ -5610,25 +5897,28 @@ int main(int argc, char **argv) {
ret = xmlBase64Decode(input, &inlen, output, &outlen);
output[outlen] = 0;
- printf("ret: %d, inlen: %ld , outlen: %ld, output: '%s'\n", ret, inlen, outlen, output);
-
+ printf("ret: %d, inlen: %ld , outlen: %ld, output: '%s'\n", ret, inlen,
+ outlen, output)indent: Standard input:179: Error:Unmatched #endif
+;
+
/*
* output chunking
*/
cons = 0;
prod = 0;
while (cons < inlen) {
- tmp = 5;
- tmp2 = inlen - cons;
+ tmp = 5;
+ tmp2 = inlen - cons;
- printf("%ld %ld\n", cons, prod);
- ret = xmlBase64Decode(&input[cons], &tmp2, &output2[prod], &tmp);
- cons += tmp2;
- prod += tmp;
- printf("%ld %ld\n", cons, prod);
+ printf("%ld %ld\n", cons, prod);
+ ret = xmlBase64Decode(&input[cons], &tmp2, &output2[prod], &tmp);
+ cons += tmp2;
+ prod += tmp;
+ printf("%ld %ld\n", cons, prod);
}
output2[outlen] = 0;
- printf("ret: %d, cons: %ld , prod: %ld, output: '%s'\n", ret, cons, prod, output2);
+ printf("ret: %d, cons: %ld , prod: %ld, output: '%s'\n", ret, cons,
+ prod, output2);
/*
* input chunking
@@ -5636,20 +5926,21 @@ int main(int argc, char **argv) {
cons = 0;
prod = 0;
while (cons < inlen) {
- tmp = 100 - prod;
- tmp2 = inlen - cons;
- if (tmp2 > 5)
- tmp2 = 5;
+ tmp = 100 - prod;
+ tmp2 = inlen - cons;
+ if (tmp2 > 5)
+ tmp2 = 5;
- printf("%ld %ld\n", cons, prod);
- ret = xmlBase64Decode(&input[cons], &tmp2, &output3[prod], &tmp);
- cons += tmp2;
- prod += tmp;
- printf("%ld %ld\n", cons, prod);
+ printf("%ld %ld\n", cons, prod);
+ ret = xmlBase64Decode(&input[cons], &tmp2, &output3[prod], &tmp);
+ cons += tmp2;
+ prod += tmp;
+ printf("%ld %ld\n", cons, prod);
}
output3[outlen] = 0;
- printf("ret: %d, cons: %ld , prod: %ld, output: '%s'\n", ret, cons, prod, output3);
- return(0);
+ printf("ret: %d, cons: %ld , prod: %ld, output: '%s'\n", ret, cons,
+ prod, output3);
+ return (0);
}
#endif
diff --git a/gnulib-local/lib/libxml/xmlreader.in.h b/gnulib-local/lib/libxml/xmlreader.in.h
index 1d12988..2c99e3a 100644
--- a/gnulib-local/lib/libxml/xmlreader.in.h
+++ b/gnulib-local/lib/libxml/xmlreader.in.h
@@ -18,13 +18,26 @@
#include <libxml/xmlschemas.h>
#endif
-#ifdef LIBXML_READER_ENABLED
-
#ifdef __cplusplus
extern "C" {
#endif
/**
+ * xmlParserSeverities:
+ *
+ * How severe an error callback is when the per-reader error callback API
+ * is used.
+ */
+typedef enum {
+ XML_PARSER_SEVERITY_VALIDITY_WARNING = 1,
+ XML_PARSER_SEVERITY_VALIDITY_ERROR = 2,
+ XML_PARSER_SEVERITY_WARNING = 3,
+ XML_PARSER_SEVERITY_ERROR = 4
+} xmlParserSeverities;
+
+#ifdef LIBXML_READER_ENABLED
+
+/**
* xmlTextReaderMode:
*
* Internal state values for the reader.
@@ -42,7 +55,7 @@ typedef enum {
* xmlParserProperties:
*
* Some common options to use with xmlTextReaderSetParserProp, but it
- * is better to use xmlParserOption and the xmlReaderNewxxx and
+ * is better to use xmlParserOption and the xmlReaderNewxxx and
* xmlReaderForxxx APIs now.
*/
typedef enum {
@@ -53,19 +66,6 @@ typedef enum {
} xmlParserProperties;
/**
- * xmlParserSeverities:
- *
- * How severe an error callback is when the per-reader error callback API
- * is used.
- */
-typedef enum {
- XML_PARSER_SEVERITY_VALIDITY_WARNING = 1,
- XML_PARSER_SEVERITY_VALIDITY_ERROR = 2,
- XML_PARSER_SEVERITY_WARNING = 3,
- XML_PARSER_SEVERITY_ERROR = 4
-} xmlParserSeverities;
-
-/**
* xmlReaderTypes:
*
* Predefined constants for the different types of nodes.
@@ -111,128 +111,134 @@ typedef xmlTextReader *xmlTextReaderPtr;
XMLPUBFUN xmlTextReaderPtr XMLCALL
xmlNewTextReader (xmlParserInputBufferPtr input,
const char *URI);
-XMLPUBFUN xmlTextReaderPtr XMLCALL
+XMLPUBFUN xmlTextReaderPtr XMLCALL
xmlNewTextReaderFilename(const char *URI);
-XMLPUBFUN void XMLCALL
+
+XMLPUBFUN void XMLCALL
xmlFreeTextReader (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderSetup(xmlTextReaderPtr reader,
+ xmlParserInputBufferPtr input, const char *URL,
+ const char *encoding, int options);
+
/*
* Iterators
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderRead (xmlTextReaderPtr reader);
#ifdef LIBXML_WRITER_ENABLED
-XMLPUBFUN xmlChar * XMLCALL
- xmlTextReaderReadInnerXml (xmlTextReaderPtr reader);
-
-XMLPUBFUN xmlChar * XMLCALL
- xmlTextReaderReadOuterXml (xmlTextReaderPtr reader);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderReadInnerXml(xmlTextReaderPtr reader);
+
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderReadOuterXml(xmlTextReaderPtr reader);
#endif
-XMLPUBFUN xmlChar * XMLCALL
- xmlTextReaderReadString (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
- xmlTextReaderReadAttributeValue (xmlTextReaderPtr reader);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderReadString (xmlTextReaderPtr reader);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderReadAttributeValue(xmlTextReaderPtr reader);
/*
* Attributes of the node
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderAttributeCount(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderDepth (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderHasAttributes(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderHasValue(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderIsDefault (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderIsEmptyElement(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderNodeType (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderQuoteChar (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderReadState (xmlTextReaderPtr reader);
XMLPUBFUN int XMLCALL
xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlTextReaderConstBaseUri (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlTextReaderConstLocalName (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlTextReaderConstName (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlTextReaderConstPrefix (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlTextReaderConstXmlLang (xmlTextReaderPtr reader);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlTextReaderConstString (xmlTextReaderPtr reader,
- const xmlChar *str);
-XMLPUBFUN const xmlChar * XMLCALL
+ const xmlChar *str);
+XMLPUBFUN const xmlChar * XMLCALL
xmlTextReaderConstValue (xmlTextReaderPtr reader);
/*
* use the Const version of the routine for
* better performance and simpler code
*/
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderBaseUri (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderLocalName (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderName (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderNamespaceUri(xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderPrefix (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderXmlLang (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderValue (xmlTextReaderPtr reader);
/*
* Methods of the XmlTextReader
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderClose (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderGetAttributeNo (xmlTextReaderPtr reader,
int no);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderGetAttribute (xmlTextReaderPtr reader,
const xmlChar *name);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderGetAttributeNs (xmlTextReaderPtr reader,
const xmlChar *localName,
const xmlChar *namespaceURI);
-XMLPUBFUN xmlParserInputBufferPtr XMLCALL
+XMLPUBFUN xmlParserInputBufferPtr XMLCALL
xmlTextReaderGetRemainder (xmlTextReaderPtr reader);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlTextReaderLookupNamespace(xmlTextReaderPtr reader,
const xmlChar *prefix);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader,
int no);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader,
const xmlChar *name);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,
const xmlChar *localName,
const xmlChar *namespaceURI);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderMoveToElement (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderNormalization (xmlTextReaderPtr reader);
XMLPUBFUN const xmlChar * XMLCALL
xmlTextReaderConstEncoding (xmlTextReaderPtr reader);
@@ -240,14 +246,14 @@ XMLPUBFUN const xmlChar * XMLCALL
/*
* Extensions
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderSetParserProp (xmlTextReaderPtr reader,
int prop,
int value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderGetParserProp (xmlTextReaderPtr reader,
int prop);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlTextReaderCurrentNode (xmlTextReaderPtr reader);
XMLPUBFUN int XMLCALL
@@ -256,41 +262,46 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlTextReaderPreserve (xmlTextReaderPtr reader);
#ifdef LIBXML_PATTERN_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderPreservePattern(xmlTextReaderPtr reader,
- const xmlChar *pattern,
+ const xmlChar *pattern,
const xmlChar **namespaces);
#endif /* LIBXML_PATTERN_ENABLED */
-XMLPUBFUN xmlDocPtr XMLCALL
+XMLPUBFUN xmlDocPtr XMLCALL
xmlTextReaderCurrentDoc (xmlTextReaderPtr reader);
-XMLPUBFUN xmlNodePtr XMLCALL
+XMLPUBFUN xmlNodePtr XMLCALL
xmlTextReaderExpand (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderNext (xmlTextReaderPtr reader);
XMLPUBFUN int XMLCALL
xmlTextReaderNextSibling (xmlTextReaderPtr reader);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderIsValid (xmlTextReaderPtr reader);
#ifdef LIBXML_SCHEMAS_ENABLED
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,
const char *rng);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
+ xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,
+ xmlRelaxNGValidCtxtPtr ctxt,
+ int options);
+
+XMLPUBFUN int XMLCALL
xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,
xmlRelaxNGPtr schema);
XMLPUBFUN int XMLCALL
xmlTextReaderSchemaValidate (xmlTextReaderPtr reader,
- const char *xsd);
+ const char *xsd);
XMLPUBFUN int XMLCALL
xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,
xmlSchemaValidCtxtPtr ctxt,
int options);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlTextReaderSetSchema (xmlTextReaderPtr reader,
- xmlSchemaPtr schema);
+ xmlSchemaPtr schema);
#endif
XMLPUBFUN const xmlChar * XMLCALL
xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);
@@ -376,33 +387,42 @@ XMLPUBFUN int XMLCALL
* Error handling extensions
*/
typedef void * xmlTextReaderLocatorPtr;
-typedef void (XMLCALL *xmlTextReaderErrorFunc) (void *arg,
- const char *msg,
- xmlParserSeverities severity,
- xmlTextReaderLocatorPtr locator);
-XMLPUBFUN int XMLCALL
- xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);
-/*int xmlTextReaderLocatorLinePosition(xmlTextReaderLocatorPtr locator);*/
-XMLPUBFUN xmlChar * XMLCALL
- xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);
-XMLPUBFUN void XMLCALL
- xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
- xmlTextReaderErrorFunc f,
- void *arg);
+
+/**
+ * xmlTextReaderErrorFunc:
+ * @arg: the user argument
+ * @msg: the message
+ * @severity: the severity of the error
+ * @locator: a locator indicating where the error occured
+ *
+ * Signature of an error callback from a reader parser
+ */
+typedef void (XMLCALL *xmlTextReaderErrorFunc)(void *arg,
+ const char *msg,
+ xmlParserSeverities severity,
+ xmlTextReaderLocatorPtr locator);
+XMLPUBFUN int XMLCALL
+ xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);
+XMLPUBFUN void XMLCALL
+ xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,
+ xmlTextReaderErrorFunc f,
+ void *arg);
XMLPUBFUN void XMLCALL
- xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
- xmlStructuredErrorFunc f,
- void *arg);
-XMLPUBFUN void XMLCALL
- xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
- xmlTextReaderErrorFunc *f,
- void **arg);
+ xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,
+ xmlStructuredErrorFunc f,
+ void *arg);
+XMLPUBFUN void XMLCALL
+ xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,
+ xmlTextReaderErrorFunc *f,
+ void **arg);
+
+#endif /* LIBXML_READER_ENABLED */
#ifdef __cplusplus
}
#endif
-#endif /* LIBXML_READER_ENABLED */
-
#endif /* __XML_XMLREADER_H__ */
diff --git a/gnulib-local/lib/libxml/xmlregexp.c b/gnulib-local/lib/libxml/xmlregexp.c
index e7d519e..3e912ab 100644
--- a/gnulib-local/lib/libxml/xmlregexp.c
+++ b/gnulib-local/lib/libxml/xmlregexp.c
@@ -1,7 +1,7 @@
/*
* regexp.c: generic and extensible Regular Expression engine
*
- * Basically designed with the purpose of compiling regexps for
+ * Basically designed with the purpose of compiling regexps for
* the variety of validation/shemas mechanisms now available in
* XML related specifications these include:
* - XML-1.0 DTD validation
@@ -44,6 +44,9 @@
#define MAX_PUSH 10000000
+#ifdef ERROR
+#undef ERROR
+#endif
#define ERROR(str) \
ctxt->error = XML_REGEXP_COMPILE_ERROR; \
xmlRegexpErrCompile(ctxt, str);
@@ -54,21 +57,26 @@
#define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
#define NEXTL(l) ctxt->cur += l;
#define XML_REG_STRING_SEPARATOR '|'
+/*
+ * Need PREV to check on a '-' within a Character Group. May only be used
+ * when it's guaranteed that cur is not at the beginning of ctxt->string!
+ */
+#define PREV (ctxt->cur[-1])
/**
* TODO:
*
* macro to flag unimplemented blocks
*/
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
/************************************************************************
- * *
- * Datatypes and structures *
- * *
+ * *
+ * Datatypes and structures *
+ * *
************************************************************************/
/*
@@ -145,7 +153,8 @@ typedef enum {
XML_REGEXP_START_STATE = 1,
XML_REGEXP_FINAL_STATE,
XML_REGEXP_TRANS_STATE,
- XML_REGEXP_SINK_STATE
+ XML_REGEXP_SINK_STATE,
+ XML_REGEXP_UNREACH_STATE
} xmlRegStateType;
typedef enum {
@@ -183,6 +192,7 @@ struct _xmlRegAtom {
int neg;
int codepoint;
xmlRegStatePtr start;
+ xmlRegStatePtr start0;
xmlRegStatePtr stop;
int maxRanges;
int nbRanges;
@@ -212,6 +222,7 @@ struct _xmlRegTrans {
struct _xmlAutomataState {
xmlRegStateType type;
xmlRegMarkedType mark;
+ xmlRegMarkedType markd;
xmlRegMarkedType reached;
int no;
int maxTrans;
@@ -226,6 +237,8 @@ struct _xmlAutomataState {
typedef struct _xmlAutomata xmlRegParserCtxt;
typedef xmlRegParserCtxt *xmlRegParserCtxtPtr;
+#define AM_AUTOMATA_RNG 1
+
struct _xmlAutomata {
xmlChar *string;
xmlChar *cur;
@@ -253,6 +266,7 @@ struct _xmlAutomata {
int determinist;
int negs;
+ int flags;
};
struct _xmlRegexp {
@@ -264,6 +278,7 @@ struct _xmlRegexp {
int nbCounters;
xmlRegCounter *counters;
int determinist;
+ int flags;
/*
* That's the compact form for determinists automatas
*/
@@ -346,9 +361,11 @@ static int xmlRegCheckCharacter(xmlRegAtomPtr atom, int codepoint);
static int xmlRegCheckCharacterRange(xmlRegAtomType type, int codepoint,
int neg, int start, int end, const xmlChar *blockName);
+void xmlAutomataSetFlags(xmlAutomataPtr am, int flags);
+
/************************************************************************
* *
- * Regexp memory error handler *
+ * Regexp memory error handler *
* *
************************************************************************/
/**
@@ -395,9 +412,9 @@ xmlRegexpErrCompile(xmlRegParserCtxtPtr ctxt, const char *extra)
}
/************************************************************************
- * *
- * Allocation/Deallocation *
- * *
+ * *
+ * Allocation/Deallocation *
+ * *
************************************************************************/
static int xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt);
@@ -427,6 +444,7 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
ret->nbCounters = ctxt->nbCounters;
ret->counters = ctxt->counters;
ret->determinist = ctxt->determinist;
+ ret->flags = ctxt->flags;
if (ret->determinist == -1) {
xmlRegexpIsDeterminist(ret);
}
@@ -727,11 +745,41 @@ xmlRegFreeRange(xmlRegRangePtr range) {
}
/**
+ * xmlRegCopyRange:
+ * @range: the regexp range
+ *
+ * Copy a regexp range
+ *
+ * Returns the new copy or NULL in case of error.
+ */
+static xmlRegRangePtr
+xmlRegCopyRange(xmlRegParserCtxtPtr ctxt, xmlRegRangePtr range) {
+ xmlRegRangePtr ret;
+
+ if (range == NULL)
+ return(NULL);
+
+ ret = xmlRegNewRange(ctxt, range->neg, range->type, range->start,
+ range->end);
+ if (ret == NULL)
+ return(NULL);
+ if (range->blockName != NULL) {
+ ret->blockName = xmlStrdup(range->blockName);
+ if (ret->blockName == NULL) {
+ xmlRegexpErrMemory(ctxt, "allocating range");
+ xmlRegFreeRange(ret);
+ return(NULL);
+ }
+ }
+ return(ret);
+}
+
+/**
* xmlRegNewAtom:
* @ctxt: the regexp parser context
* @type: the type of atom
*
- * Allocate a new regexp range
+ * Allocate a new atom
*
* Returns the new atom or NULL in case of error
*/
@@ -778,6 +826,52 @@ xmlRegFreeAtom(xmlRegAtomPtr atom) {
xmlFree(atom);
}
+/**
+ * xmlRegCopyAtom:
+ * @ctxt: the regexp parser context
+ * @atom: the oiginal atom
+ *
+ * Allocate a new regexp range
+ *
+ * Returns the new atom or NULL in case of error
+ */
+static xmlRegAtomPtr
+xmlRegCopyAtom(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom) {
+ xmlRegAtomPtr ret;
+
+ ret = (xmlRegAtomPtr) xmlMalloc(sizeof(xmlRegAtom));
+ if (ret == NULL) {
+ xmlRegexpErrMemory(ctxt, "copying atom");
+ return(NULL);
+ }
+ memset(ret, 0, sizeof(xmlRegAtom));
+ ret->type = atom->type;
+ ret->quant = atom->quant;
+ ret->min = atom->min;
+ ret->max = atom->max;
+ if (atom->nbRanges > 0) {
+ int i;
+
+ ret->ranges = (xmlRegRangePtr *) xmlMalloc(sizeof(xmlRegRangePtr) *
+ atom->nbRanges);
+ if (ret->ranges == NULL) {
+ xmlRegexpErrMemory(ctxt, "copying atom");
+ goto error;
+ }
+ for (i = 0;i < atom->nbRanges;i++) {
+ ret->ranges[i] = xmlRegCopyRange(ctxt, atom->ranges[i]);
+ if (ret->ranges[i] == NULL)
+ goto error;
+ ret->nbRanges = i + 1;
+ }
+ }
+ return(ret);
+
+error:
+ xmlRegFreeAtom(ret);
+ return(NULL);
+}
+
static xmlRegStatePtr
xmlRegNewState(xmlRegParserCtxtPtr ctxt) {
xmlRegStatePtr ret;
@@ -841,9 +935,9 @@ xmlRegFreeParserCtxt(xmlRegParserCtxtPtr ctxt) {
}
/************************************************************************
- * *
- * Display of Data structures *
- * *
+ * *
+ * Display of Data structures *
+ * *
************************************************************************/
static void
@@ -1050,7 +1144,7 @@ xmlRegPrintTrans(FILE *output, xmlRegTransPtr trans) {
fprintf(output, "char %c ", trans->atom->codepoint);
fprintf(output, "atom %d, to %d\n", trans->atom->no, trans->to);
}
-
+
static void
xmlRegPrintState(FILE *output, xmlRegStatePtr state) {
int i;
@@ -1064,7 +1158,7 @@ xmlRegPrintState(FILE *output, xmlRegStatePtr state) {
fprintf(output, "START ");
if (state->type == XML_REGEXP_FINAL_STATE)
fprintf(output, "FINAL ");
-
+
fprintf(output, "%d, %d transitions:\n", state->no, state->nbTrans);
for (i = 0;i < state->nbTrans; i++) {
xmlRegPrintTrans(output, &(state->trans[i]));
@@ -1114,12 +1208,12 @@ xmlRegPrintCtxt(FILE *output, xmlRegParserCtxtPtr ctxt) {
#endif
/************************************************************************
- * *
+ * *
* Finite Automata structures manipulations *
- * *
+ * *
************************************************************************/
-static void
+static void
xmlRegAtomAddRange(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom,
int neg, xmlRegAtomType type, int start, int end,
xmlChar *blockName) {
@@ -1159,7 +1253,7 @@ xmlRegAtomAddRange(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom,
return;
range->blockName = blockName;
atom->ranges[atom->nbRanges++] = range;
-
+
}
static int
@@ -1190,7 +1284,7 @@ xmlRegGetCounter(xmlRegParserCtxtPtr ctxt) {
return(ctxt->nbCounters++);
}
-static int
+static int
xmlRegAtomPush(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom) {
if (atom == NULL) {
ERROR("atom push: atom is NULL");
@@ -1222,7 +1316,7 @@ xmlRegAtomPush(xmlRegParserCtxtPtr ctxt, xmlRegAtomPtr atom) {
return(0);
}
-static void
+static void
xmlRegStateAddTransTo(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr target,
int from) {
if (target->maxTransTo == 0) {
@@ -1250,7 +1344,7 @@ xmlRegStateAddTransTo(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr target,
target->nbTransTo++;
}
-static void
+static void
xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
xmlRegAtomPtr atom, xmlRegStatePtr target,
int counter, int count) {
@@ -1316,7 +1410,7 @@ xmlRegStateAddTrans(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
printf("counted %d\n", counter);
else if (atom == NULL)
printf("epsilon transition\n");
- else if (atom != NULL)
+ else if (atom != NULL)
xmlRegPrintAtom(stdout, atom);
#endif
@@ -1449,6 +1543,8 @@ xmlFAGenerateCountedTransition(xmlRegParserCtxtPtr ctxt,
static int
xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
xmlRegStatePtr to, xmlRegAtomPtr atom) {
+ xmlRegStatePtr end;
+
if (atom == NULL) {
ERROR("genrate transition: atom == NULL");
return(-1);
@@ -1468,7 +1564,7 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
*/
xmlFAGenerateEpsilonTransition(ctxt, atom->stop, to);
#ifdef DV
- } else if ((to == NULL) && (atom->quant != XML_REGEXP_QUANT_RANGE) &&
+ } else if ((to == NULL) && (atom->quant != XML_REGEXP_QUANT_RANGE) &&
(atom->quant != XML_REGEXP_QUANT_ONCE)) {
to = xmlRegNewState(ctxt);
xmlRegStatePush(ctxt, to);
@@ -1482,10 +1578,15 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
/*
* transition done to the state after end of atom.
* 1. set transition from atom start to new state
- * 2. set transition from atom end to this state.
+ * 2. set transition from atom end to this state.
*/
- xmlFAGenerateEpsilonTransition(ctxt, atom->start, 0);
- xmlFAGenerateEpsilonTransition(ctxt, atom->stop, ctxt->state);
+ if (to == NULL) {
+ xmlFAGenerateEpsilonTransition(ctxt, atom->start, 0);
+ xmlFAGenerateEpsilonTransition(ctxt, atom->stop,
+ ctxt->state);
+ } else {
+ xmlFAGenerateEpsilonTransition(ctxt, atom->start, to);
+ }
break;
case XML_REGEXP_QUANT_MULT:
atom->quant = XML_REGEXP_QUANT_ONCE;
@@ -1498,58 +1599,89 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
break;
case XML_REGEXP_QUANT_RANGE: {
int counter;
- xmlRegStatePtr newstate;
+ xmlRegStatePtr inter, newstate;
/*
- * This one is nasty:
- * 1/ if range has minOccurs == 0, create a new state
- * and create epsilon transitions from atom->start
- * to atom->stop, as well as atom->start to the new
- * state
- * 2/ register a new counter
- * 3/ register an epsilon transition associated to
- * this counter going from atom->stop to atom->start
- * 4/ create a new state
- * 5/ generate a counted transition from atom->stop to
- * that state
+ * create the final state now if needed
*/
- if (atom->min == 0) {
- xmlFAGenerateEpsilonTransition(ctxt, atom->start,
- atom->stop);
+ if (to != NULL) {
+ newstate = to;
+ } else {
newstate = xmlRegNewState(ctxt);
xmlRegStatePush(ctxt, newstate);
- ctxt->state = newstate;
+ }
+
+ /*
+ * The principle here is to use counted transition
+ * to avoid explosion in the number of states in the
+ * graph. This is clearly more complex but should not
+ * be exploitable at runtime.
+ */
+ if ((atom->min == 0) && (atom->start0 == NULL)) {
+ xmlRegAtomPtr copy;
+ /*
+ * duplicate a transition based on atom to count next
+ * occurences after 1. We cannot loop to atom->start
+ * directly because we need an epsilon transition to
+ * newstate.
+ */
+ /* ???? For some reason it seems we never reach that
+ case, I suppose this got optimized out before when
+ building the automata */
+ copy = xmlRegCopyAtom(ctxt, atom);
+ if (copy == NULL)
+ return(-1);
+ copy->quant = XML_REGEXP_QUANT_ONCE;
+ copy->min = 0;
+ copy->max = 0;
+
+ if (xmlFAGenerateTransitions(ctxt, atom->start, NULL, copy)
+ < 0)
+ return(-1);
+ inter = ctxt->state;
+ counter = xmlRegGetCounter(ctxt);
+ ctxt->counters[counter].min = atom->min - 1;
+ ctxt->counters[counter].max = atom->max - 1;
+ /* count the number of times we see it again */
+ xmlFAGenerateCountedEpsilonTransition(ctxt, inter,
+ atom->stop, counter);
+ /* allow a way out based on the count */
+ xmlFAGenerateCountedTransition(ctxt, inter,
+ newstate, counter);
+ /* and also allow a direct exit for 0 */
xmlFAGenerateEpsilonTransition(ctxt, atom->start,
- newstate);
+ newstate);
+ } else {
+ /*
+ * either we need the atom at least once or there
+ * is an atom->start0 allowing to easilly plug the
+ * epsilon transition.
+ */
+ counter = xmlRegGetCounter(ctxt);
+ ctxt->counters[counter].min = atom->min - 1;
+ ctxt->counters[counter].max = atom->max - 1;
+ /* count the number of times we see it again */
+ xmlFAGenerateCountedEpsilonTransition(ctxt, atom->stop,
+ atom->start, counter);
+ /* allow a way out based on the count */
+ xmlFAGenerateCountedTransition(ctxt, atom->stop,
+ newstate, counter);
+ /* and if needed allow a direct exit for 0 */
+ if (atom->min == 0)
+ xmlFAGenerateEpsilonTransition(ctxt, atom->start0,
+ newstate);
+
}
- counter = xmlRegGetCounter(ctxt);
- ctxt->counters[counter].min = atom->min - 1;
- ctxt->counters[counter].max = atom->max - 1;
atom->min = 0;
atom->max = 0;
atom->quant = XML_REGEXP_QUANT_ONCE;
- if (to != NULL) {
- newstate = to;
- } else {
- newstate = xmlRegNewState(ctxt);
- xmlRegStatePush(ctxt, newstate);
- }
ctxt->state = newstate;
- xmlFAGenerateCountedTransition(ctxt, atom->stop,
- newstate, counter);
-
- /*
- * first check count and if OK jump forward;
- * if checking fail increment count and jump back
- */
- xmlFAGenerateCountedEpsilonTransition(ctxt, atom->stop,
- atom->start, counter);
}
default:
break;
}
return(0);
- }
+ }
if ((atom->min == 0) && (atom->max == 0) &&
(atom->quant == XML_REGEXP_QUANT_RANGE)) {
/*
@@ -1576,11 +1708,30 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
return(-1);
}
}
+ end = to;
+ if ((atom->quant == XML_REGEXP_QUANT_MULT) ||
+ (atom->quant == XML_REGEXP_QUANT_PLUS)) {
+ /*
+ * Do not pollute the target state by adding transitions from
+ * it as it is likely to be the shared target of multiple branches.
+ * So isolate with an epsilon transition.
+ */
+ xmlRegStatePtr tmp;
+
+ tmp = xmlRegNewState(ctxt);
+ if (tmp != NULL)
+ xmlRegStatePush(ctxt, tmp);
+ else {
+ return(-1);
+ }
+ xmlFAGenerateEpsilonTransition(ctxt, tmp, to);
+ to = tmp;
+ }
if (xmlRegAtomPush(ctxt, atom) < 0) {
return(-1);
}
xmlRegStateAddTrans(ctxt, from, atom, to, -1, -1);
- ctxt->state = to;
+ ctxt->state = end;
switch (atom->quant) {
case XML_REGEXP_QUANT_OPT:
atom->quant = XML_REGEXP_QUANT_ONCE;
@@ -1595,6 +1746,13 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
atom->quant = XML_REGEXP_QUANT_ONCE;
xmlRegStateAddTrans(ctxt, to, atom, to, -1, -1);
break;
+ case XML_REGEXP_QUANT_RANGE:
+#if DV_test
+ if (atom->min == 0) {
+ xmlFAGenerateEpsilonTransition(ctxt, from, to);
+ }
+#endif
+ break;
default:
break;
}
@@ -1605,7 +1763,7 @@ xmlFAGenerateTransitions(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr from,
* xmlFAReduceEpsilonTransitions:
* @ctxt: a regexp parser context
* @fromnr: the from state
- * @tonr: the to state
+ * @tonr: the to state
* @counter: should that transition be associated to a counted
*
*/
@@ -1649,7 +1807,7 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
int newto = to->trans[transnr].to;
xmlRegStateAddTrans(ctxt, from, NULL,
- ctxt->states[newto],
+ ctxt->states[newto],
-1, to->trans[transnr].count);
} else {
#ifdef DEBUG_REGEXP_GRAPH
@@ -1671,11 +1829,11 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
int newto = to->trans[transnr].to;
if (to->trans[transnr].counter >= 0) {
- xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
- ctxt->states[newto],
+ xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
+ ctxt->states[newto],
to->trans[transnr].counter, -1);
} else {
- xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
+ xmlRegStateAddTrans(ctxt, from, to->trans[transnr].atom,
ctxt->states[newto], counter, -1);
}
}
@@ -1687,7 +1845,7 @@ xmlFAReduceEpsilonTransitions(xmlRegParserCtxtPtr ctxt, int fromnr,
* xmlFAEliminateSimpleEpsilonTransitions:
* @ctxt: a regexp parser context
*
- * Eliminating general epsilon transitions can get costly in the general
+ * Eliminating general epsilon transitions can get costly in the general
* algorithm due to the large amount of generated new transitions and
* associated comparisons. However for simple epsilon transition used just
* to separate building blocks when generating the automata this can be
@@ -1709,6 +1867,8 @@ xmlFAEliminateSimpleEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
continue;
if (state->nbTrans != 1)
continue;
+ if (state->type == XML_REGEXP_UNREACH_STATE)
+ continue;
/* is the only transition out a basic transition */
if ((state->trans[0].atom == NULL) &&
(state->trans[0].to >= 0) &&
@@ -1721,48 +1881,37 @@ xmlFAEliminateSimpleEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
#ifdef DEBUG_REGEXP_GRAPH
printf("Found simple epsilon trans from start %d to %d\n",
statenr, newto);
-#endif
+#endif
} else {
#ifdef DEBUG_REGEXP_GRAPH
printf("Found simple epsilon trans from %d to %d\n",
statenr, newto);
-#endif
+#endif
for (i = 0;i < state->nbTransTo;i++) {
tmp = ctxt->states[state->transTo[i]];
for (j = 0;j < tmp->nbTrans;j++) {
if (tmp->trans[j].to == statenr) {
- tmp->trans[j].to = newto;
-#ifdef DEBUG_REGEXP_GRAPH
- printf("Changed transition %d on %d to go to %d\n",
- j, tmp->no, newto);
-#endif
- xmlRegStateAddTransTo(ctxt, ctxt->states[newto],
- tmp->no);
- }
- }
- }
-#if 0
- for (i = 0;i < ctxt->nbStates;i++) {
- tmp = ctxt->states[i];
- for (j = 0;j < tmp->nbTrans;j++) {
- if (tmp->trans[j].to == statenr) {
- tmp->trans[j].to = newto;
#ifdef DEBUG_REGEXP_GRAPH
printf("Changed transition %d on %d to go to %d\n",
j, tmp->no, newto);
-#endif
+#endif
+ tmp->trans[j].to = -1;
+ xmlRegStateAddTrans(ctxt, tmp, tmp->trans[j].atom,
+ ctxt->states[newto],
+ tmp->trans[j].counter,
+ tmp->trans[j].count);
}
}
}
-#endif
if (state->type == XML_REGEXP_FINAL_STATE)
ctxt->states[newto]->type = XML_REGEXP_FINAL_STATE;
/* eliminate the transition completely */
state->nbTrans = 0;
+ state->type = XML_REGEXP_UNREACH_STATE;
}
-
+
}
}
}
@@ -1779,16 +1928,33 @@ xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
if (ctxt->states == NULL) return;
+ /*
+ * Eliminate simple epsilon transition and the associated unreachable
+ * states.
+ */
xmlFAEliminateSimpleEpsilonTransitions(ctxt);
+ for (statenr = 0;statenr < ctxt->nbStates;statenr++) {
+ state = ctxt->states[statenr];
+ if ((state != NULL) && (state->type == XML_REGEXP_UNREACH_STATE)) {
+#ifdef DEBUG_REGEXP_GRAPH
+ printf("Removed unreachable state %d\n", statenr);
+#endif
+ xmlRegFreeState(state);
+ ctxt->states[statenr] = NULL;
+ }
+ }
has_epsilon = 0;
/*
- * build the completed transitions bypassing the epsilons
+ * Build the completed transitions bypassing the epsilons
* Use a marking algorithm to avoid loops
- * mark sink states too.
+ * Mark sink states too.
+ * Process from the latests states backward to the start when
+ * there is long cascading epsilon chains this minimize the
+ * recursions and transition compares when adding the new ones
*/
- for (statenr = 0;statenr < ctxt->nbStates;statenr++) {
+ for (statenr = ctxt->nbStates - 1;statenr >= 0;statenr--) {
state = ctxt->states[statenr];
if (state == NULL)
continue;
@@ -1812,8 +1978,9 @@ xmlFAEliminateEpsilonTransitions(xmlRegParserCtxtPtr ctxt) {
printf("Found epsilon trans %d from %d to %d\n",
transnr, statenr, newto);
#endif
- state->mark = XML_REGEXP_MARK_START;
has_epsilon = 1;
+ state->trans[transnr].to = -2;
+ state->mark = XML_REGEXP_MARK_START;
xmlFAReduceEpsilonTransitions(ctxt, statenr,
newto, state->trans[transnr].counter);
state->mark = XML_REGEXP_MARK_NORMAL;
@@ -1932,12 +2099,13 @@ xmlFACompareRanges(xmlRegRangePtr range1, xmlRegRangePtr range2) {
(range2->type == XML_REGEXP_EPSILON)) {
return(0);
} else if (range1->type == range2->type) {
- if ((range1->type != XML_REGEXP_CHARVAL) ||
- (range1->end < range2->start) ||
- (range2->end < range1->start))
- ret = 1;
- else
+ if (range1->type != XML_REGEXP_CHARVAL)
+ ret = 1;
+ else if ((range1->end < range2->start) ||
+ (range2->end < range1->start))
ret = 0;
+ else
+ ret = 1;
} else if (range1->type == XML_REGEXP_CHARVAL) {
int codepoint;
int neg = 0;
@@ -1945,7 +2113,7 @@ xmlFACompareRanges(xmlRegRangePtr range1, xmlRegRangePtr range2) {
/*
* just check all codepoints in the range for acceptance,
* this is usually way cheaper since done only once at
- * compilation than testing over and over at runtime or
+ * compilation than testing over and over at runtime or
* pushing too many states when evaluating.
*/
if (((range1->neg == 0) && (range2->neg != 0)) ||
@@ -2064,7 +2232,7 @@ xmlFACompareRanges(xmlRegRangePtr range1, xmlRegRangePtr range2) {
if (((range1->neg == 0) && (range2->neg != 0)) ||
((range1->neg != 0) && (range2->neg == 0)))
ret = !ret;
- return(1);
+ return(ret);
}
/**
@@ -2272,6 +2440,7 @@ xmlFACompareAtomTypes(xmlRegAtomType type1, xmlRegAtomType type2) {
* xmlFAEqualAtoms:
* @atom1: an atom
* @atom2: an atom
+ * @deep: if not set only compare string pointers
*
* Compares two atoms to check whether they are the same exactly
* this is used to remove equivalent transitions
@@ -2279,7 +2448,7 @@ xmlFACompareAtomTypes(xmlRegAtomType type1, xmlRegAtomType type2) {
* Returns 1 if same and 0 otherwise
*/
static int
-xmlFAEqualAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2) {
+xmlFAEqualAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2, int deep) {
int ret = 0;
if (atom1 == atom2)
@@ -2294,8 +2463,11 @@ xmlFAEqualAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2) {
ret = 0;
break;
case XML_REGEXP_STRING:
- ret = xmlStrEqual((xmlChar *)atom1->valuep,
- (xmlChar *)atom2->valuep);
+ if (!deep)
+ ret = (atom1->valuep == atom2->valuep);
+ else
+ ret = xmlStrEqual((xmlChar *)atom1->valuep,
+ (xmlChar *)atom2->valuep);
break;
case XML_REGEXP_CHARVAL:
ret = (atom1->codepoint == atom2->codepoint);
@@ -2313,6 +2485,7 @@ xmlFAEqualAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2) {
* xmlFACompareAtoms:
* @atom1: an atom
* @atom2: an atom
+ * @deep: if not set only compare string pointers
*
* Compares two atoms to check whether they intersect in some ways,
* this is used by xmlFAComputesDeterminism and xmlFARecurseDeterminism only
@@ -2320,7 +2493,7 @@ xmlFAEqualAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2) {
* Returns 1 if yes and 0 otherwise
*/
static int
-xmlFACompareAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2) {
+xmlFACompareAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2, int deep) {
int ret = 1;
if (atom1 == atom2)
@@ -2346,8 +2519,11 @@ xmlFACompareAtoms(xmlRegAtomPtr atom1, xmlRegAtomPtr atom2) {
}
switch (atom1->type) {
case XML_REGEXP_STRING:
- ret = xmlRegStrEqualWildcard((xmlChar *)atom1->valuep,
- (xmlChar *)atom2->valuep);
+ if (!deep)
+ ret = (atom1->valuep != atom2->valuep);
+ else
+ ret = xmlRegStrEqualWildcard((xmlChar *)atom1->valuep,
+ (xmlChar *)atom2->valuep);
break;
case XML_REGEXP_EPSILON:
goto not_determinist;
@@ -2410,9 +2586,16 @@ xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
int res;
int transnr, nbTrans;
xmlRegTransPtr t1;
+ int deep = 1;
if (state == NULL)
return(ret);
+ if (state->markd == XML_REGEXP_MARK_VISITED)
+ return(ret);
+
+ if (ctxt->flags & AM_AUTOMATA_RNG)
+ deep = 0;
+
/*
* don't recurse on transitions potentially added in the course of
* the elimination.
@@ -2424,10 +2607,12 @@ xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
* check transitions conflicting with the one looked at
*/
if (t1->atom == NULL) {
- if (t1->to == -1)
+ if (t1->to < 0)
continue;
+ state->markd = XML_REGEXP_MARK_VISITED;
res = xmlFARecurseDeterminism(ctxt, ctxt->states[t1->to],
to, atom);
+ state->markd = 0;
if (res == 0) {
ret = 0;
/* t1->nd = 1; */
@@ -2436,7 +2621,7 @@ xmlFARecurseDeterminism(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr state,
}
if (t1->to != to)
continue;
- if (xmlFACompareAtoms(t1->atom, atom)) {
+ if (xmlFACompareAtoms(t1->atom, atom, deep)) {
ret = 0;
/* mark the transition as non-deterministic */
t1->nd = 1;
@@ -2460,6 +2645,7 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
xmlRegTransPtr t1, t2, last;
int i;
int ret = 1;
+ int deep = 1;
#ifdef DEBUG_REGEXP_GRAPH
printf("xmlFAComputesDeterminism\n");
@@ -2468,6 +2654,9 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
if (ctxt->determinist != -1)
return(ctxt->determinist);
+ if (ctxt->flags & AM_AUTOMATA_RNG)
+ deep = 0;
+
/*
* First cleanup the automata removing cancelled transitions
*/
@@ -2495,7 +2684,13 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
continue;
if (t2->atom != NULL) {
if (t1->to == t2->to) {
- if (xmlFAEqualAtoms(t1->atom, t2->atom))
+ /*
+ * Here we use deep because we want to keep the
+ * transitions which indicate a conflict
+ */
+ if (xmlFAEqualAtoms(t1->atom, t2->atom, deep) &&
+ (t1->counter == t2->counter) &&
+ (t1->count == t2->count))
t2->to = -1; /* eliminated */
}
}
@@ -2530,8 +2725,11 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
if (t2->to == -1) /* eliminated */
continue;
if (t2->atom != NULL) {
- /* not determinist ! */
- if (xmlFACompareAtoms(t1->atom, t2->atom)) {
+ /*
+ * But here we don't use deep because we want to
+ * find transitions which indicate a conflict
+ */
+ if (xmlFACompareAtoms(t1->atom, t2->atom, 1)) {
ret = 0;
/* mark the transitions as non-deterministic ones */
t1->nd = 1;
@@ -2583,9 +2781,9 @@ xmlFAComputesDeterminism(xmlRegParserCtxtPtr ctxt) {
}
/************************************************************************
- * *
+ * *
* Routines to check input against transition atoms *
- * *
+ * *
************************************************************************/
static int
@@ -2614,7 +2812,7 @@ xmlRegCheckCharacterRange(xmlRegAtomType type, int codepoint, int neg,
case XML_REGEXP_NOTINITNAME:
neg = !neg;
case XML_REGEXP_INITNAME:
- ret = (IS_LETTER(codepoint) ||
+ ret = (IS_LETTER(codepoint) ||
(codepoint == '_') || (codepoint == ':'));
break;
case XML_REGEXP_NOTNAMECHAR:
@@ -2862,9 +3060,9 @@ xmlRegCheckCharacter(xmlRegAtomPtr atom, int codepoint) {
}
/************************************************************************
- * *
+ * *
* Saving and restoring state of an execution context *
- * *
+ * *
************************************************************************/
#ifdef DEBUG_REGEXP_EXEC
@@ -2875,7 +3073,8 @@ xmlFARegDebugExec(xmlRegExecCtxtPtr exec) {
int i;
printf(": ");
for (i = 0;(i < 3) && (i < exec->inputStackNr);i++)
- printf("%s ", exec->inputStack[exec->inputStackNr - (i + 1)]);
+ printf("%s ", (const char *)
+ exec->inputStack[exec->inputStackNr - (i + 1)].value);
} else {
printf(": %s", &(exec->inputString[exec->index]));
}
@@ -2963,8 +3162,10 @@ xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) {
exec->status = -6;
return;
}
- memcpy(exec->counts, exec->rollbacks[exec->nbRollbacks].counts,
+ if (exec->counts) {
+ memcpy(exec->counts, exec->rollbacks[exec->nbRollbacks].counts,
exec->comp->nbCounters * sizeof(int));
+ }
}
#ifdef DEBUG_REGEXP_EXEC
@@ -2974,9 +3175,9 @@ xmlFARegExecRollBack(xmlRegExecCtxtPtr exec) {
}
/************************************************************************
- * *
+ * *
* Verifier, running an input against a compiled regexp *
- * *
+ * *
************************************************************************/
static int
@@ -3008,9 +3209,10 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
memset(exec->counts, 0, comp->nbCounters * sizeof(int));
} else
exec->counts = NULL;
- while ((exec->status == 0) &&
+ while ((exec->status == 0) && (exec->state != NULL) &&
((exec->inputString[exec->index] != 0) ||
- (exec->state->type != XML_REGEXP_FINAL_STATE))) {
+ ((exec->state != NULL) &&
+ (exec->state->type != XML_REGEXP_FINAL_STATE)))) {
xmlRegTransPtr trans;
xmlRegAtomPtr atom;
@@ -3081,12 +3283,22 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
* this is a multiple input sequence
* If there is a counter associated increment it now.
* before potentially saving and rollback
+ * do not increment if the counter is already over the
+ * maximum limit in which case get to next transition
*/
if (trans->counter >= 0) {
- if (exec->counts == NULL) {
+ xmlRegCounterPtr counter;
+
+ if ((exec->counts == NULL) ||
+ (exec->comp == NULL) ||
+ (exec->comp->counters == NULL)) {
exec->status = -1;
goto error;
}
+ counter = &exec->comp->counters[trans->counter];
+ if (exec->counts[trans->counter] >= counter->max)
+ continue; /* for loop on transitions */
+
#ifdef DEBUG_REGEXP_EXEC
printf("Increasing count %d\n", trans->counter);
#endif
@@ -3182,10 +3394,18 @@ xmlFARegExec(xmlRegexpPtr comp, const xmlChar *content) {
xmlFARegExecSave(exec);
}
if (trans->counter >= 0) {
- if (exec->counts == NULL) {
- exec->status = -1;
+ xmlRegCounterPtr counter;
+
+ /* make sure we don't go over the counter maximum value */
+ if ((exec->counts == NULL) ||
+ (exec->comp == NULL) ||
+ (exec->comp->counters == NULL)) {
+ exec->status = -1;
goto error;
}
+ counter = &exec->comp->counters[trans->counter];
+ if (exec->counts[trans->counter] >= counter->max)
+ continue; /* for loop on transitions */
#ifdef DEBUG_REGEXP_EXEC
printf("Increasing count %d\n", trans->counter);
#endif
@@ -3243,6 +3463,8 @@ error:
}
xmlFree(exec->rollbacks);
}
+ if (exec->state == NULL)
+ return(-1);
if (exec->counts != NULL)
xmlFree(exec->counts);
if (exec->status == 0)
@@ -3256,9 +3478,9 @@ error:
}
/************************************************************************
- * *
+ * *
* Progressive interface to the verifier one atom at a time *
- * *
+ * *
************************************************************************/
#ifdef DEBUG_ERR
static void testerr(xmlRegExecCtxtPtr exec);
@@ -3375,7 +3597,7 @@ xmlFARegExecSaveInputString(xmlRegExecCtxtPtr exec, const xmlChar *value,
#endif
if (exec->inputStackMax == 0) {
exec->inputStackMax = 4;
- exec->inputStack = (xmlRegInputTokenPtr)
+ exec->inputStack = (xmlRegInputTokenPtr)
xmlMalloc(exec->inputStackMax * sizeof(xmlRegInputToken));
if (exec->inputStack == NULL) {
xmlRegexpErrMemory(NULL, "pushing input string");
@@ -3404,11 +3626,11 @@ xmlFARegExecSaveInputString(xmlRegExecCtxtPtr exec, const xmlChar *value,
/**
* xmlRegStrEqualWildcard:
- * @expStr: the string to be evaluated
+ * @expStr: the string to be evaluated
* @valStr: the validation string
*
* Checks if both strings are equal or have the same content. "*"
- * can be used as a wildcard in @valStr; "|" is used as a seperator of
+ * can be used as a wildcard in @valStr; "|" is used as a seperator of
* substrings in both @expStr and @valStr.
*
* Returns 1 if the comparison is satisfied and the number of substrings
@@ -3474,7 +3696,7 @@ xmlRegCompactPushString(xmlRegExecCtxtPtr exec,
if ((comp == NULL) || (comp->compact == NULL) || (comp->stringMap == NULL))
return(-1);
-
+
if (value == NULL) {
/*
* are we at a final state ?
@@ -3495,9 +3717,9 @@ xmlRegCompactPushString(xmlRegExecCtxtPtr exec,
for (i = 0;i < comp->nbstrings;i++) {
target = comp->compact[state * (comp->nbstrings + 1) + i + 1];
if ((target > 0) && (target <= comp->nbstates)) {
- target--; /* to avoid 0 */
+ target--; /* to avoid 0 */
if (xmlRegStrEqualWildcard(comp->stringMap[i], value)) {
- exec->index = target;
+ exec->index = target;
if ((exec->callback != NULL) && (comp->transdata != NULL)) {
exec->callback(exec->data, value,
comp->transdata[state * comp->nbstrings + i], data);
@@ -3631,7 +3853,7 @@ xmlRegExecPushStringInternal(xmlRegExecCtxtPtr exec, const xmlChar *value,
continue;
counter = &exec->comp->counters[t->counter];
count = exec->counts[t->counter];
- if ((count < counter->max) &&
+ if ((count < counter->max) &&
(t->atom != NULL) &&
(xmlStrEqual(value, t->atom->valuep))) {
ret = 0;
@@ -3871,7 +4093,7 @@ rollback:
*/
exec->determinist = 0;
xmlFARegExecRollBack(exec);
- if (exec->status == 0) {
+ if ((exec->inputStack != NULL ) && (exec->status == 0)) {
value = exec->inputStack[exec->index].value;
data = exec->inputStack[exec->index].data;
#ifdef DEBUG_PUSH
@@ -3989,7 +4211,7 @@ xmlRegExecGetValues(xmlRegExecCtxtPtr exec, int err,
int maxval;
int nb = 0;
- if ((exec == NULL) || (nbval == NULL) || (nbneg == NULL) ||
+ if ((exec == NULL) || (nbval == NULL) || (nbneg == NULL) ||
(values == NULL) || (*nbval <= 0))
return(-1);
@@ -4086,7 +4308,7 @@ xmlRegExecGetValues(xmlRegExecCtxtPtr exec, int err,
(*nbval)++;
}
} else {
- if ((exec->comp->states[trans->to] != NULL) &&
+ if ((exec->comp != NULL) && (exec->comp->states[trans->to] != NULL) &&
(exec->comp->states[trans->to]->type !=
XML_REGEXP_SINK_STATE)) {
if (atom->neg)
@@ -4095,7 +4317,7 @@ xmlRegExecGetValues(xmlRegExecCtxtPtr exec, int err,
values[nb++] = (xmlChar *) atom->valuep;
(*nbval)++;
}
- }
+ }
}
for (transno = 0;
(transno < state->nbTrans) && (nb < maxval);
@@ -4122,7 +4344,7 @@ xmlRegExecGetValues(xmlRegExecCtxtPtr exec, int err,
values[nb++] = (xmlChar *) atom->valuep;
(*nbneg)++;
}
- }
+ }
}
}
return(0);
@@ -4353,10 +4575,10 @@ progress:
}
#endif
/************************************************************************
- * *
+ * *
* Parser for the Schemas Datatype Regular Expressions *
* http://www.w3.org/TR/2001/REC-xmlschema-2-20010502/#regexs *
- * *
+ * *
************************************************************************/
/**
@@ -4385,7 +4607,7 @@ xmlFAIsChar(xmlRegParserCtxtPtr ctxt) {
*
* [27] charProp ::= IsCategory | IsBlock
* [28] IsCategory ::= Letters | Marks | Numbers | Punctuation |
- * Separators | Symbols | Others
+ * Separators | Symbols | Others
* [29] Letters ::= 'L' [ultmo]?
* [30] Marks ::= 'M' [nce]?
* [31] Numbers ::= 'N' [dlo]?
@@ -4400,7 +4622,7 @@ xmlFAParseCharProp(xmlRegParserCtxtPtr ctxt) {
int cur;
xmlRegAtomType type = (xmlRegAtomType) 0;
xmlChar *blockName = NULL;
-
+
cur = CUR;
if (cur == 'L') {
NEXT;
@@ -4572,15 +4794,15 @@ xmlFAParseCharProp(xmlRegParserCtxtPtr ctxt) {
NEXT;
start = ctxt->cur;
cur = CUR;
- if (((cur >= 'a') && (cur <= 'z')) ||
- ((cur >= 'A') && (cur <= 'Z')) ||
- ((cur >= '0') && (cur <= '9')) ||
+ if (((cur >= 'a') && (cur <= 'z')) ||
+ ((cur >= 'A') && (cur <= 'Z')) ||
+ ((cur >= '0') && (cur <= '9')) ||
(cur == 0x2D)) {
NEXT;
cur = CUR;
- while (((cur >= 'a') && (cur <= 'z')) ||
- ((cur >= 'A') && (cur <= 'Z')) ||
- ((cur >= '0') && (cur <= '9')) ||
+ while (((cur >= 'a') && (cur <= 'z')) ||
+ ((cur >= 'A') && (cur <= 'Z')) ||
+ ((cur >= '0') && (cur <= '9')) ||
(cur == 0x2D)) {
NEXT;
cur = CUR;
@@ -4606,7 +4828,7 @@ xmlFAParseCharProp(xmlRegParserCtxtPtr ctxt) {
* xmlFAParseCharClassEsc:
* @ctxt: a regexp parser context
*
- * [23] charClassEsc ::= ( SingleCharEsc | MultiCharEsc | catEsc | complEsc )
+ * [23] charClassEsc ::= ( SingleCharEsc | MultiCharEsc | catEsc | complEsc )
* [24] SingleCharEsc ::= '\' [nrt\|.?*+(){}#x2D#x5B#x5D#x5E]
* [25] catEsc ::= '\p{' charProp '}'
* [26] complEsc ::= '\P{' charProp '}'
@@ -4682,6 +4904,17 @@ xmlFAParseCharClassEsc(xmlRegParserCtxtPtr ctxt) {
}
}
} else if (ctxt->atom->type == XML_REGEXP_RANGES) {
+ switch (cur) {
+ case 'n':
+ cur = '\n';
+ break;
+ case 'r':
+ cur = '\r';
+ break;
+ case 't':
+ cur = '\t';
+ break;
+ }
xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg,
XML_REGEXP_CHARVAL, cur, cur, NULL);
}
@@ -4692,34 +4925,34 @@ xmlFAParseCharClassEsc(xmlRegParserCtxtPtr ctxt) {
xmlRegAtomType type = XML_REGEXP_ANYSPACE;
switch (cur) {
- case 's':
+ case 's':
type = XML_REGEXP_ANYSPACE;
break;
- case 'S':
+ case 'S':
type = XML_REGEXP_NOTSPACE;
break;
- case 'i':
+ case 'i':
type = XML_REGEXP_INITNAME;
break;
- case 'I':
+ case 'I':
type = XML_REGEXP_NOTINITNAME;
break;
- case 'c':
+ case 'c':
type = XML_REGEXP_NAMECHAR;
break;
- case 'C':
+ case 'C':
type = XML_REGEXP_NOTNAMECHAR;
break;
- case 'd':
+ case 'd':
type = XML_REGEXP_DECIMAL;
break;
- case 'D':
+ case 'D':
type = XML_REGEXP_NOTDECIMAL;
break;
- case 'w':
+ case 'w':
type = XML_REGEXP_REALCHAR;
break;
- case 'W':
+ case 'W':
type = XML_REGEXP_NOTREALCHAR;
break;
}
@@ -4730,72 +4963,16 @@ xmlFAParseCharClassEsc(xmlRegParserCtxtPtr ctxt) {
xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg,
type, 0, 0, NULL);
}
- }
-}
-
-/**
- * xmlFAParseCharRef:
- * @ctxt: a regexp parser context
- *
- * [19] XmlCharRef ::= ( '&#' [0-9]+ ';' ) | (' &#x' [0-9a-fA-F]+ ';' )
- */
-static int
-xmlFAParseCharRef(xmlRegParserCtxtPtr ctxt) {
- int ret = 0, cur;
-
- if ((CUR != '&') || (NXT(1) != '#'))
- return(-1);
- NEXT;
- NEXT;
- cur = CUR;
- if (cur == 'x') {
- NEXT;
- cur = CUR;
- if (((cur >= '0') && (cur <= '9')) ||
- ((cur >= 'a') && (cur <= 'f')) ||
- ((cur >= 'A') && (cur <= 'F'))) {
- while (((cur >= '0') && (cur <= '9')) ||
- ((cur >= 'a') && (cur <= 'f')) ||
- ((cur >= 'A') && (cur <= 'F'))) {
- if ((cur >= '0') && (cur <= '9'))
- ret = ret * 16 + cur - '0';
- else if ((cur >= 'a') && (cur <= 'f'))
- ret = ret * 16 + 10 + (cur - 'a');
- else
- ret = ret * 16 + 10 + (cur - 'A');
- NEXT;
- cur = CUR;
- }
- } else {
- ERROR("Char ref: expecting [0-9A-F]");
- return(-1);
- }
- } else {
- if ((cur >= '0') && (cur <= '9')) {
- while ((cur >= '0') && (cur <= '9')) {
- ret = ret * 10 + cur - '0';
- NEXT;
- cur = CUR;
- }
- } else {
- ERROR("Char ref: expecting [0-9]");
- return(-1);
- }
- }
- if (cur != ';') {
- ERROR("Char ref: expecting ';'");
- return(-1);
} else {
- NEXT;
+ ERROR("Wrong escape sequence, misuse of character '\\'");
}
- return(ret);
}
/**
* xmlFAParseCharRange:
* @ctxt: a regexp parser context
*
- * [17] charRange ::= seRange | XmlCharRef | XmlCharIncDash
+ * [17] charRange ::= seRange | XmlCharRef | XmlCharIncDash
* [18] seRange ::= charOrEsc '-' charOrEsc
* [20] charOrEsc ::= XmlChar | SingleCharEsc
* [21] XmlChar ::= [^\#x2D#x5B#x5D]
@@ -4812,12 +4989,6 @@ xmlFAParseCharRange(xmlRegParserCtxtPtr ctxt) {
return;
}
- if ((CUR == '&') && (NXT(1) == '#')) {
- end = start = xmlFAParseCharRef(ctxt);
- xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg,
- XML_REGEXP_CHARVAL, start, end, NULL);
- return;
- }
cur = CUR;
if (cur == '\\') {
NEXT;
@@ -4842,10 +5013,15 @@ xmlFAParseCharRange(xmlRegParserCtxtPtr ctxt) {
ERROR("Expecting a char range");
return;
}
- NEXTL(len);
- if (start == '-') {
+ /*
+ * Since we are "inside" a range, we can assume ctxt->cur is past
+ * the start of ctxt->string, and PREV should be safe
+ */
+ if ((start == '-') && (NXT(1) != ']') && (PREV != '[') && (PREV != '^')) {
+ NEXTL(len);
return;
}
+ NEXTL(len);
cur = CUR;
if ((cur != '-') || (NXT(1) == ']')) {
xmlRegAtomAddRange(ctxt, ctxt->atom, ctxt->neg,
@@ -4896,7 +5072,7 @@ xmlFAParseCharRange(xmlRegParserCtxtPtr ctxt) {
static void
xmlFAParsePosCharGroup(xmlRegParserCtxtPtr ctxt) {
do {
- if ((CUR == '\\') || (CUR == '.')) {
+ if (CUR == '\\') {
xmlFAParseCharClassEsc(ctxt);
} else {
xmlFAParseCharRange(ctxt);
@@ -4911,7 +5087,7 @@ xmlFAParsePosCharGroup(xmlRegParserCtxtPtr ctxt) {
*
* [13] charGroup ::= posCharGroup | negCharGroup | charClassSub
* [15] negCharGroup ::= '^' posCharGroup
- * [16] charClassSub ::= ( posCharGroup | negCharGroup ) '-' charClassExpr
+ * [16] charClassSub ::= ( posCharGroup | negCharGroup ) '-' charClassExpr
* [12] charClassExpr ::= '[' charGroup ']'
*/
static void
@@ -5085,9 +5261,15 @@ xmlFAParseAtom(xmlRegParserCtxtPtr ctxt) {
} else if (CUR == ')') {
return(0);
} else if (CUR == '(') {
- xmlRegStatePtr start, oldend;
+ xmlRegStatePtr start, oldend, start0;
NEXT;
+ /*
+ * this extra Epsilon transition is needed if we count with 0 allowed
+ * unfortunately this can't be known at that point
+ */
+ xmlFAGenerateEpsilonTransition(ctxt, ctxt->state, NULL);
+ start0 = ctxt->state;
xmlFAGenerateEpsilonTransition(ctxt, ctxt->state, NULL);
start = ctxt->state;
oldend = ctxt->end;
@@ -5103,6 +5285,7 @@ xmlFAParseAtom(xmlRegParserCtxtPtr ctxt) {
if (ctxt->atom == NULL)
return(-1);
ctxt->atom->start = start;
+ ctxt->atom->start0 = start0;
ctxt->atom->stop = ctxt->state;
ctxt->end = oldend;
return(1);
@@ -5152,7 +5335,7 @@ xmlFAParseBranch(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr to) {
previous = ctxt->state;
ret = xmlFAParsePiece(ctxt);
if (ret != 0) {
- if (xmlFAGenerateTransitions(ctxt, previous,
+ if (xmlFAGenerateTransitions(ctxt, previous,
(CUR=='|' || CUR==')') ? to : NULL, ctxt->atom) < 0)
return(-1);
previous = ctxt->state;
@@ -5161,7 +5344,7 @@ xmlFAParseBranch(xmlRegParserCtxtPtr ctxt, xmlRegStatePtr to) {
while ((ret != 0) && (ctxt->error == 0)) {
ret = xmlFAParsePiece(ctxt);
if (ret != 0) {
- if (xmlFAGenerateTransitions(ctxt, previous,
+ if (xmlFAGenerateTransitions(ctxt, previous,
(CUR=='|' || CUR==')') ? to : NULL, ctxt->atom) < 0)
return(-1);
previous = ctxt->state;
@@ -5199,6 +5382,10 @@ xmlFAParseRegExp(xmlRegParserCtxtPtr ctxt, int top) {
end = ctxt->state;
while ((CUR == '|') && (ctxt->error == 0)) {
NEXT;
+ if (CUR == 0) {
+ ERROR("expecting a branch after |")
+ return;
+ }
ctxt->state = start;
ctxt->end = NULL;
xmlFAParseBranch(ctxt, end);
@@ -5210,9 +5397,9 @@ xmlFAParseRegExp(xmlRegParserCtxtPtr ctxt, int top) {
}
/************************************************************************
- * *
- * The basic API *
- * *
+ * *
+ * The basic API *
+ * *
************************************************************************/
/**
@@ -5281,6 +5468,10 @@ xmlRegexpCompile(const xmlChar *regexp) {
if (CUR != 0) {
ERROR("xmlFAParseRegExp: extra characters");
}
+ if (ctxt->error != 0) {
+ xmlRegFreeParserCtxt(ctxt);
+ return(NULL);
+ }
ctxt->end = ctxt->state;
ctxt->start->type = XML_REGEXP_START_STATE;
ctxt->end->type = XML_REGEXP_FINAL_STATE;
@@ -5345,10 +5536,12 @@ xmlRegexpIsDeterminist(xmlRegexpPtr comp) {
am->nbStates = comp->nbStates;
am->states = comp->states;
am->determinist = -1;
+ am->flags = comp->flags;
ret = xmlFAComputesDeterminism(am);
am->atoms = NULL;
am->states = NULL;
xmlFreeAutomata(am);
+ comp->determinist = ret;
return(ret);
}
@@ -5393,9 +5586,9 @@ xmlRegFreeRegexp(xmlRegexpPtr regexp) {
#ifdef LIBXML_AUTOMATA_ENABLED
/************************************************************************
- * *
- * The Automata interface *
- * *
+ * *
+ * The Automata interface *
+ * *
************************************************************************/
/**
@@ -5426,6 +5619,7 @@ xmlNewAutomata(void) {
xmlFreeAutomata(ctxt);
return(NULL);
}
+ ctxt->flags = 0;
return(ctxt);
}
@@ -5444,6 +5638,20 @@ xmlFreeAutomata(xmlAutomataPtr am) {
}
/**
+ * xmlAutomataSetFlags:
+ * @am: an automata
+ * @flags: a set of internal flags
+ *
+ * Set some flags on the automata
+ */
+void
+xmlAutomataSetFlags(xmlAutomataPtr am, int flags) {
+ if (am == NULL)
+ return;
+ am->flags |= flags;
+}
+
+/**
* xmlAutomataGetInitState:
* @am: an automata
*
@@ -5501,8 +5709,6 @@ xmlAutomataNewTransition(xmlAutomataPtr am, xmlAutomataStatePtr from,
if (atom == NULL)
return(NULL);
atom->data = data;
- if (atom == NULL)
- return(NULL);
atom->valuep = xmlStrdup(token);
if (xmlFAGenerateTransitions(am, from, to, atom) < 0) {
@@ -5651,7 +5857,7 @@ xmlAutomataNewNegTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
- * activated by a succession of input of value @token and @token2 and
+ * activated by a succession of input of value @token and @token2 and
* whose number is between @min and @max
*
* Returns the target state or NULL in case of error
@@ -5805,8 +6011,8 @@ xmlAutomataNewCountTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
*
* If @to is NULL, this creates first a new target state in the automata
* and then adds a transition from the @from state to the target state
- * activated by a succession of input of value @token and @token2 and whose
- * number is between @min and @max, moreover that transition can only be
+ * activated by a succession of input of value @token and @token2 and whose
+ * number is between @min and @max, moreover that transition can only be
* crossed once.
*
* Returns the target state or NULL in case of error
@@ -5848,7 +6054,7 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
str[lenn + lenp + 1] = 0;
atom->valuep = str;
- }
+ }
atom->data = data;
atom->quant = XML_REGEXP_QUANT_ONCEONLY;
atom->min = min;
@@ -5871,7 +6077,7 @@ xmlAutomataNewOnceTrans2(xmlAutomataPtr am, xmlAutomataStatePtr from,
return(to);
}
-
+
/**
* xmlAutomataNewOnceTrans:
@@ -5940,7 +6146,7 @@ xmlAutomataNewOnceTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
*/
xmlAutomataStatePtr
xmlAutomataNewState(xmlAutomataPtr am) {
- xmlAutomataStatePtr to;
+ xmlAutomataStatePtr to;
if (am == NULL)
return(NULL);
@@ -6007,7 +6213,7 @@ xmlAutomataNewAllTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
*
* Returns the counter number or -1 in case of error
*/
-int
+int
xmlAutomataNewCounter(xmlAutomataPtr am, int min, int max) {
int ret;
@@ -6079,7 +6285,7 @@ xmlAutomataNewCounterTrans(xmlAutomataPtr am, xmlAutomataStatePtr from,
*
* Returns the compiled regexp or NULL in case of error
*/
-xmlRegexpPtr
+xmlRegexpPtr
xmlAutomataCompile(xmlAutomataPtr am) {
xmlRegexpPtr ret;
@@ -6099,7 +6305,7 @@ xmlAutomataCompile(xmlAutomataPtr am) {
*
* Returns 1 if true, 0 if not, and -1 in case of error
*/
-int
+int
xmlAutomataIsDeterminist(xmlAutomataPtr am) {
int ret;
@@ -6129,6 +6335,7 @@ struct _xmlExpCtxt {
int size;
int nbElems;
int nb_nodes;
+ int maxNodes;
const char *expr;
const char *cur;
int nb_cons;
@@ -6151,13 +6358,14 @@ xmlExpNewCtxt(int maxNodes, xmlDictPtr dict) {
if (maxNodes <= 4096)
maxNodes = 4096;
-
+
ret = (xmlExpCtxtPtr) xmlMalloc(sizeof(xmlExpCtxt));
if (ret == NULL)
return(NULL);
memset(ret, 0, sizeof(xmlExpCtxt));
ret->size = size;
ret->nbElems = 0;
+ ret->maxNodes = maxNodes;
ret->table = xmlMalloc(size * sizeof(xmlExpNodePtr));
if (ret->table == NULL) {
xmlFree(ret);
@@ -6204,7 +6412,7 @@ xmlExpFreeCtxt(xmlExpCtxtPtr ctxt) {
/* #define DEBUG_DERIV */
/*
- * TODO:
+ * TODO:
* - Wildcards
* - public API for creation
*
@@ -6272,7 +6480,7 @@ static unsigned short
xmlExpHashNameComputeKey(const xmlChar *name) {
unsigned short value = 0L;
char ch;
-
+
if (name != NULL) {
value += 30 * (*name);
while ((ch = *name++) != 0) {
@@ -6291,7 +6499,7 @@ xmlExpHashComputeKey(xmlExpNodeType type, xmlExpNodePtr left,
xmlExpNodePtr right) {
unsigned long value;
unsigned short ret;
-
+
switch (type) {
case XML_EXP_SEQ:
value = left->key;
@@ -6432,7 +6640,7 @@ xmlExpHashGetEntry(xmlExpCtxtPtr ctxt, xmlExpNodeType type,
left->exp_left->ref++;
tmp = xmlExpHashGetEntry(ctxt, XML_EXP_OR, left->exp_left, tmp,
NULL, 0, 0);
-
+
xmlExpFree(ctxt, left);
return(tmp);
}
@@ -6489,7 +6697,7 @@ xmlExpHashGetEntry(xmlExpCtxtPtr ctxt, xmlExpNodeType type,
return(right);
}
kbase = xmlExpHashComputeKey(type, left, right);
- } else
+ } else
return(NULL);
key = kbase % ctxt->size;
@@ -6630,7 +6838,7 @@ xmlExpRef(xmlExpNodePtr exp) {
* xmlExpNewAtom:
* @ctxt: the expression context
* @name: the atom name
- * @len: the atom name lenght in byte (or -1);
+ * @len: the atom name length in byte (or -1);
*
* Get the atom associated to this name from that context
*
@@ -6730,7 +6938,7 @@ xmlExpNewRange(xmlExpCtxtPtr ctxt, xmlExpNodePtr subset, int min, int max) {
************************************************************************/
static int
-xmlExpGetLanguageInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp,
+xmlExpGetLanguageInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp,
const xmlChar**list, int len, int nb) {
int tmp, tmp2;
tail:
@@ -6743,7 +6951,7 @@ tail:
return(0);
if (nb >= len)
return(-2);
- list[nb++] = exp->exp_str;
+ list[nb] = exp->exp_str;
return(1);
case XML_EXP_COUNT:
exp = exp->exp_left;
@@ -6767,7 +6975,7 @@ tail:
* @ctxt: the expression context
* @exp: the expression
* @langList: where to store the tokens
- * @len: the allocated lenght of @list
+ * @len: the allocated length of @list
*
* Find all the strings used in @exp and store them in @list
*
@@ -6775,7 +6983,7 @@ tail:
* -2 if there is more than @len strings
*/
int
-xmlExpGetLanguage(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp,
+xmlExpGetLanguage(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp,
const xmlChar**langList, int len) {
if ((ctxt == NULL) || (exp == NULL) || (langList == NULL) || (len <= 0))
return(-1);
@@ -6783,7 +6991,7 @@ xmlExpGetLanguage(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp,
}
static int
-xmlExpGetStartInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp,
+xmlExpGetStartInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp,
const xmlChar**list, int len, int nb) {
int tmp, tmp2;
tail:
@@ -6798,7 +7006,7 @@ tail:
return(0);
if (nb >= len)
return(-2);
- list[nb++] = exp->exp_str;
+ list[nb] = exp->exp_str;
return(1);
case XML_EXP_COUNT:
exp = exp->exp_left;
@@ -6833,7 +7041,7 @@ tail:
* @ctxt: the expression context
* @exp: the expression
* @tokList: where to store the tokens
- * @len: the allocated lenght of @list
+ * @len: the allocated length of @list
*
* Find all the strings that appears at the start of the languages
* accepted by @exp and store them in @list. E.g. for (a, b) | c
@@ -6843,7 +7051,7 @@ tail:
* -2 if there is more than @len strings
*/
int
-xmlExpGetStart(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp,
+xmlExpGetStart(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp,
const xmlChar**tokList, int len) {
if ((ctxt == NULL) || (exp == NULL) || (tokList == NULL) || (len <= 0))
return(-1);
@@ -7540,7 +7748,7 @@ xmlExpExpDeriveInt(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
xmlFree((xmlChar **) tab);
return(ret);
}
-
+
/**
* xmlExpExpDerive:
* @ctxt: the expressions context
@@ -7592,7 +7800,7 @@ xmlExpExpDerive(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
int
xmlExpSubsume(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
xmlExpNodePtr tmp;
-
+
if ((exp == NULL) || (ctxt == NULL) || (sub == NULL))
return(-1);
@@ -7636,7 +7844,7 @@ xmlExpSubsume(xmlExpCtxtPtr ctxt, xmlExpNodePtr exp, xmlExpNodePtr sub) {
/************************************************************************
* *
- * Parsing expression *
+ * Parsing expression *
* *
************************************************************************/
@@ -7740,7 +7948,7 @@ parse_quantifier:
ret = xmlExpHashGetEntry(ctxt, XML_EXP_COUNT, ret, NULL, NULL,
0, -1);
SKIP_BLANKS
- }
+ }
return(ret);
}
@@ -7862,7 +8070,7 @@ xmlExpDumpInt(xmlBufferPtr buf, xmlExpNodePtr expr, int glob) {
break;
case XML_EXP_COUNT: {
char rep[40];
-
+
c = expr->exp_left;
if ((c->type == XML_EXP_SEQ) || (c->type == XML_EXP_OR))
xmlExpDumpInt(buf, c, 1);
diff --git a/gnulib-local/lib/libxml/xmlregexp.in.h b/gnulib-local/lib/libxml/xmlregexp.in.h
index 022cd6a..7009645 100644
--- a/gnulib-local/lib/libxml/xmlregexp.in.h
+++ b/gnulib-local/lib/libxml/xmlregexp.in.h
@@ -38,7 +38,7 @@ typedef xmlRegExecCtxt *xmlRegExecCtxtPtr;
#ifdef __cplusplus
}
-#endif
+#endif
#include <libxml/tree.h>
#include <libxml/dict.h>
#ifdef __cplusplus
@@ -51,16 +51,22 @@ extern "C" {
XMLPUBFUN xmlRegexpPtr XMLCALL
xmlRegexpCompile (const xmlChar *regexp);
XMLPUBFUN void XMLCALL xmlRegFreeRegexp(xmlRegexpPtr regexp);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRegexpExec (xmlRegexpPtr comp,
const xmlChar *value);
-XMLPUBFUN void XMLCALL
- xmlRegexpPrint (FILE *output,
+XMLPUBFUN void XMLCALL
+ xmlRegexpPrint (FILE *output,
xmlRegexpPtr regexp);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRegexpIsDeterminist(xmlRegexpPtr comp);
-/*
+/**
+ * xmlRegExecCallbacks:
+ * @exec: the regular expression context
+ * @token: the current token string
+ * @transdata: transition data
+ * @inputdata: input data
+ *
* Callback function when doing a transition in the automata
*/
typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,
@@ -71,17 +77,17 @@ typedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,
/*
* The progressive API
*/
-XMLPUBFUN xmlRegExecCtxtPtr XMLCALL
- xmlRegNewExecCtxt (xmlRegexpPtr comp,
+XMLPUBFUN xmlRegExecCtxtPtr XMLCALL
+ xmlRegNewExecCtxt (xmlRegexpPtr comp,
xmlRegExecCallbacks callback,
void *data);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlRegFreeExecCtxt (xmlRegExecCtxtPtr exec);
-XMLPUBFUN int XMLCALL
- xmlRegExecPushString(xmlRegExecCtxtPtr exec,
+XMLPUBFUN int XMLCALL
+ xmlRegExecPushString(xmlRegExecCtxtPtr exec,
const xmlChar *value,
void *data);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlRegExecPushString2(xmlRegExecCtxtPtr exec,
const xmlChar *value,
const xmlChar *value2,
@@ -89,15 +95,15 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlRegExecNextValues(xmlRegExecCtxtPtr exec,
- int *nbval,
- int *nbneg,
+ int *nbval,
+ int *nbneg,
xmlChar **values,
int *terminal);
XMLPUBFUN int XMLCALL
xmlRegExecErrInfo (xmlRegExecCtxtPtr exec,
- const xmlChar **string,
+ const xmlChar **string,
int *nbval,
- int *nbneg,
+ int *nbneg,
xmlChar **values,
int *terminal);
#ifdef LIBXML_EXPR_ENABLED
@@ -135,7 +141,7 @@ typedef enum {
} xmlExpNodeType;
/*
- * 2 core expressions shared by all for the empty language set
+ * 2 core expressions shared by all for the empty language set
* and for the set with just the empty token
*/
XMLPUBVAR xmlExpNodePtr forbiddenExp;
@@ -209,7 +215,7 @@ XMLPUBFUN void XMLCALL
#endif /* LIBXML_EXPR_ENABLED */
#ifdef __cplusplus
}
-#endif
+#endif
#endif /* LIBXML_REGEXP_ENABLED */
diff --git a/gnulib-local/lib/libxml/xmlsave.c b/gnulib-local/lib/libxml/xmlsave.c
index 6963e7b..774404b 100644
--- a/gnulib-local/lib/libxml/xmlsave.c
+++ b/gnulib-local/lib/libxml/xmlsave.c
@@ -19,6 +19,10 @@
#include <libxml/HTMLtree.h>
+#include "buf.h"
+#include "enc.h"
+#include "save.h"
+
/************************************************************************
* *
* XHTML detection *
@@ -66,7 +70,7 @@ xmlIsXHTML(const xmlChar *systemID, const xmlChar *publicID) {
#ifdef LIBXML_OUTPUT_ENABLED
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
@@ -92,7 +96,7 @@ struct _xmlSaveCtxt {
/************************************************************************
* *
- * Output error handlers *
+ * Output error handlers *
* *
************************************************************************/
/**
@@ -210,9 +214,9 @@ xmlEscapeEntities(unsigned char* out, int *outlen,
int val;
inend = in + (*inlen);
-
+
while ((in < inend) && (out < outend)) {
- if (*in == '<') {
+ if (*in == '<') {
if (outend - out < 4) break;
*out++ = '&';
*out++ = 'l';
@@ -248,7 +252,7 @@ xmlEscapeEntities(unsigned char* out, int *outlen,
/*
* We assume we have UTF-8 input.
*/
- if (outend - out < 10) break;
+ if (outend - out < 11) break;
if (*in < 0xC0) {
xmlSaveErr(XML_SAVE_NOT_UTF8, NULL, NULL);
@@ -408,13 +412,15 @@ xmlNewSaveCtxt(const char *encoding, int options)
ret->options = options;
if (options & XML_SAVE_FORMAT)
ret->format = 1;
+ else if (options & XML_SAVE_WSNONSIG)
+ ret->format = 2;
return(ret);
}
/************************************************************************
* *
- * Dumping XML tree content to a simple buffer *
+ * Dumping XML tree content to a simple buffer *
* *
************************************************************************/
/**
@@ -434,14 +440,14 @@ xmlAttrSerializeContent(xmlOutputBufferPtr buf, xmlAttrPtr attr)
while (children != NULL) {
switch (children->type) {
case XML_TEXT_NODE:
- xmlAttrSerializeTxtContent(buf->buffer, attr->doc,
- attr, children->content);
+ xmlBufAttrSerializeTxtContent(buf->buffer, attr->doc,
+ attr, children->content);
break;
case XML_ENTITY_REF_NODE:
- xmlBufferAdd(buf->buffer, BAD_CAST "&", 1);
- xmlBufferAdd(buf->buffer, children->name,
+ xmlBufAdd(buf->buffer, BAD_CAST "&", 1);
+ xmlBufAdd(buf->buffer, children->name,
xmlStrlen(children->name));
- xmlBufferAdd(buf->buffer, BAD_CAST ";", 1);
+ xmlBufAdd(buf->buffer, BAD_CAST ";", 1);
break;
default:
/* should not happen unless we have a badly built tree */
@@ -451,12 +457,136 @@ xmlAttrSerializeContent(xmlOutputBufferPtr buf, xmlAttrPtr attr)
}
}
+/**
+ * xmlBufDumpNotationTable:
+ * @buf: an xmlBufPtr output
+ * @table: A notation table
+ *
+ * This will dump the content of the notation table as an XML DTD definition
+ */
+void
+xmlBufDumpNotationTable(xmlBufPtr buf, xmlNotationTablePtr table) {
+ xmlBufferPtr buffer;
+
+ buffer = xmlBufferCreate();
+ if (buffer == NULL) {
+ /*
+ * TODO set the error in buf
+ */
+ return;
+ }
+ xmlDumpNotationTable(buffer, table);
+ xmlBufMergeBuffer(buf, buffer);
+}
+
+/**
+ * xmlBufDumpElementDecl:
+ * @buf: an xmlBufPtr output
+ * @elem: An element table
+ *
+ * This will dump the content of the element declaration as an XML
+ * DTD definition
+ */
+void
+xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem) {
+ xmlBufferPtr buffer;
+
+ buffer = xmlBufferCreate();
+ if (buffer == NULL) {
+ /*
+ * TODO set the error in buf
+ */
+ return;
+ }
+ xmlDumpElementDecl(buffer, elem);
+ xmlBufMergeBuffer(buf, buffer);
+}
+
+/**
+ * xmlBufDumpAttributeDecl:
+ * @buf: an xmlBufPtr output
+ * @attr: An attribute declaration
+ *
+ * This will dump the content of the attribute declaration as an XML
+ * DTD definition
+ */
+void
+xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr) {
+ xmlBufferPtr buffer;
+
+ buffer = xmlBufferCreate();
+ if (buffer == NULL) {
+ /*
+ * TODO set the error in buf
+ */
+ return;
+ }
+ xmlDumpAttributeDecl(buffer, attr);
+ xmlBufMergeBuffer(buf, buffer);
+}
+
+/**
+ * xmlBufDumpEntityDecl:
+ * @buf: an xmlBufPtr output
+ * @ent: An entity table
+ *
+ * This will dump the content of the entity table as an XML DTD definition
+ */
+void
+xmlBufDumpEntityDecl(xmlBufPtr buf, xmlEntityPtr ent) {
+ xmlBufferPtr buffer;
+
+ buffer = xmlBufferCreate();
+ if (buffer == NULL) {
+ /*
+ * TODO set the error in buf
+ */
+ return;
+ }
+ xmlDumpEntityDecl(buffer, ent);
+ xmlBufMergeBuffer(buf, buffer);
+}
+
/************************************************************************
* *
- * Dumping XML tree content to an I/O output buffer *
+ * Dumping XML tree content to an I/O output buffer *
* *
************************************************************************/
+static int xmlSaveSwitchEncoding(xmlSaveCtxtPtr ctxt, const char *encoding) {
+ xmlOutputBufferPtr buf = ctxt->buf;
+
+ if ((encoding != NULL) && (buf->encoder == NULL) && (buf->conv == NULL)) {
+ buf->encoder = xmlFindCharEncodingHandler((const char *)encoding);
+ if (buf->encoder == NULL) {
+ xmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL,
+ (const char *)encoding);
+ return(-1);
+ }
+ buf->conv = xmlBufCreate();
+ if (buf->conv == NULL) {
+ xmlCharEncCloseFunc(buf->encoder);
+ xmlSaveErrMemory("creating encoding buffer");
+ return(-1);
+ }
+ /*
+ * initialize the state, e.g. if outputting a BOM
+ */
+ xmlCharEncOutput(buf, 1);
+ }
+ return(0);
+}
+
+static int xmlSaveClearEncoding(xmlSaveCtxtPtr ctxt) {
+ xmlOutputBufferPtr buf = ctxt->buf;
+ xmlOutputBufferFlush(buf);
+ xmlCharEncCloseFunc(buf->encoder);
+ xmlBufFree(buf->conv);
+ buf->encoder = NULL;
+ buf->conv = NULL;
+ return(0);
+}
+
#ifdef LIBXML_HTML_ENABLED
static void
xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur);
@@ -467,28 +597,86 @@ void xmlNsListDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur);
static int xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur);
/**
+ * xmlOutputBufferWriteWSNonSig:
+ * @ctxt: The save context
+ * @extra: Number of extra indents to apply to ctxt->level
+ *
+ * Write out formatting for non-significant whitespace output.
+ */
+static void
+xmlOutputBufferWriteWSNonSig(xmlSaveCtxtPtr ctxt, int extra)
+{
+ int i;
+ if ((ctxt == NULL) || (ctxt->buf == NULL))
+ return;
+ xmlOutputBufferWrite(ctxt->buf, 1, "\n");
+ for (i = 0; i < (ctxt->level + extra); i += ctxt->indent_nr) {
+ xmlOutputBufferWrite(ctxt->buf, ctxt->indent_size *
+ ((ctxt->level + extra - i) > ctxt->indent_nr ?
+ ctxt->indent_nr : (ctxt->level + extra - i)),
+ ctxt->indent);
+ }
+}
+
+/**
* xmlNsDumpOutput:
* @buf: the XML buffer output
* @cur: a namespace
+ * @ctxt: the output save context. Optional.
*
* Dump a local Namespace definition.
* Should be called in the context of attributes dumps.
+ * If @ctxt is supplied, @buf should be its buffer.
*/
static void
-xmlNsDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur) {
+xmlNsDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur, xmlSaveCtxtPtr ctxt) {
if ((cur == NULL) || (buf == NULL)) return;
if ((cur->type == XML_LOCAL_NAMESPACE) && (cur->href != NULL)) {
if (xmlStrEqual(cur->prefix, BAD_CAST "xml"))
return;
+ if (ctxt != NULL && ctxt->format == 2)
+ xmlOutputBufferWriteWSNonSig(ctxt, 2);
+ else
+ xmlOutputBufferWrite(buf, 1, " ");
+
/* Within the context of an element attributes */
if (cur->prefix != NULL) {
- xmlOutputBufferWrite(buf, 7, " xmlns:");
+ xmlOutputBufferWrite(buf, 6, "xmlns:");
xmlOutputBufferWriteString(buf, (const char *)cur->prefix);
} else
- xmlOutputBufferWrite(buf, 6, " xmlns");
+ xmlOutputBufferWrite(buf, 5, "xmlns");
xmlOutputBufferWrite(buf, 1, "=");
- xmlBufferWriteQuotedString(buf->buffer, cur->href);
+ xmlBufWriteQuotedString(buf->buffer, cur->href);
+ }
+}
+
+/**
+ * xmlNsDumpOutputCtxt
+ * @ctxt: the save context
+ * @cur: a namespace
+ *
+ * Dump a local Namespace definition to a save context.
+ * Should be called in the context of attribute dumps.
+ */
+static void
+xmlNsDumpOutputCtxt(xmlSaveCtxtPtr ctxt, xmlNsPtr cur) {
+ xmlNsDumpOutput(ctxt->buf, cur, ctxt);
+}
+
+/**
+ * xmlNsListDumpOutputCtxt
+ * @ctxt: the save context
+ * @cur: the first namespace
+ *
+ * Dump a list of local namespace definitions to a save context.
+ * Should be called in the context of attribute dumps.
+ */
+static void
+xmlNsListDumpOutputCtxt(xmlSaveCtxtPtr ctxt, xmlNsPtr cur) {
+ while (cur != NULL) {
+ xmlNsDumpOutput(ctxt->buf, cur, ctxt);
+ cur = cur->next;
}
}
@@ -503,7 +691,7 @@ xmlNsDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur) {
void
xmlNsListDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur) {
while (cur != NULL) {
- xmlNsDumpOutput(buf, cur);
+ xmlNsDumpOutput(buf, cur, NULL);
cur = cur->next;
}
}
@@ -512,7 +700,7 @@ xmlNsListDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur) {
* xmlDtdDumpOutput:
* @buf: the XML buffer output
* @dtd: the pointer to the DTD
- *
+ *
* Dump the XML document DTD, if any.
*/
static void
@@ -529,12 +717,12 @@ xmlDtdDumpOutput(xmlSaveCtxtPtr ctxt, xmlDtdPtr dtd) {
xmlOutputBufferWriteString(buf, (const char *)dtd->name);
if (dtd->ExternalID != NULL) {
xmlOutputBufferWrite(buf, 8, " PUBLIC ");
- xmlBufferWriteQuotedString(buf->buffer, dtd->ExternalID);
+ xmlBufWriteQuotedString(buf->buffer, dtd->ExternalID);
xmlOutputBufferWrite(buf, 1, " ");
- xmlBufferWriteQuotedString(buf->buffer, dtd->SystemID);
+ xmlBufWriteQuotedString(buf->buffer, dtd->SystemID);
} else if (dtd->SystemID != NULL) {
xmlOutputBufferWrite(buf, 8, " SYSTEM ");
- xmlBufferWriteQuotedString(buf->buffer, dtd->SystemID);
+ xmlBufWriteQuotedString(buf->buffer, dtd->SystemID);
}
if ((dtd->entities == NULL) && (dtd->elements == NULL) &&
(dtd->attributes == NULL) && (dtd->notations == NULL) &&
@@ -549,7 +737,8 @@ xmlDtdDumpOutput(xmlSaveCtxtPtr ctxt, xmlDtdPtr dtd) {
*/
if ((dtd->notations != NULL) && ((dtd->doc == NULL) ||
(dtd->doc->intSubset == dtd))) {
- xmlDumpNotationTable(buf->buffer, (xmlNotationTablePtr) dtd->notations);
+ xmlBufDumpNotationTable(buf->buffer,
+ (xmlNotationTablePtr) dtd->notations);
}
format = ctxt->format;
level = ctxt->level;
@@ -578,7 +767,10 @@ xmlAttrDumpOutput(xmlSaveCtxtPtr ctxt, xmlAttrPtr cur) {
if (cur == NULL) return;
buf = ctxt->buf;
if (buf == NULL) return;
- xmlOutputBufferWrite(buf, 1, " ");
+ if (ctxt->format == 2)
+ xmlOutputBufferWriteWSNonSig(ctxt, 2);
+ else
+ xmlOutputBufferWrite(buf, 1, " ");
if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) {
xmlOutputBufferWriteString(buf, (const char *)cur->ns->prefix);
xmlOutputBufferWrite(buf, 1, ":");
@@ -622,20 +814,82 @@ xmlNodeListDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
if (cur == NULL) return;
buf = ctxt->buf;
while (cur != NULL) {
- if ((ctxt->format) && (xmlIndentTreeOutput) &&
- (cur->type == XML_ELEMENT_NODE))
+ if ((ctxt->format == 1) && (xmlIndentTreeOutput) &&
+ ((cur->type == XML_ELEMENT_NODE) ||
+ (cur->type == XML_COMMENT_NODE) ||
+ (cur->type == XML_PI_NODE)))
xmlOutputBufferWrite(buf, ctxt->indent_size *
- (ctxt->level > ctxt->indent_nr ?
+ (ctxt->level > ctxt->indent_nr ?
ctxt->indent_nr : ctxt->level),
ctxt->indent);
xmlNodeDumpOutputInternal(ctxt, cur);
- if (ctxt->format) {
+ if (ctxt->format == 1) {
xmlOutputBufferWrite(buf, 1, "\n");
}
cur = cur->next;
}
}
+#ifdef LIBXML_HTML_ENABLED
+/**
+ * xmlNodeDumpOutputInternal:
+ * @cur: the current node
+ *
+ * Dump an HTML node, recursive behaviour, children are printed too.
+ */
+static int
+htmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
+ const xmlChar *oldenc = NULL;
+ const xmlChar *oldctxtenc = ctxt->encoding;
+ const xmlChar *encoding = ctxt->encoding;
+ xmlOutputBufferPtr buf = ctxt->buf;
+ int switched_encoding = 0;
+ xmlDocPtr doc;
+
+ xmlInitParser();
+
+ doc = cur->doc;
+ if (doc != NULL) {
+ oldenc = doc->encoding;
+ if (ctxt->encoding != NULL) {
+ doc->encoding = BAD_CAST ctxt->encoding;
+ } else if (doc->encoding != NULL) {
+ encoding = doc->encoding;
+ }
+ }
+
+ if ((encoding != NULL) && (doc != NULL))
+ htmlSetMetaEncoding(doc, (const xmlChar *) encoding);
+ if ((encoding == NULL) && (doc != NULL))
+ encoding = htmlGetMetaEncoding(doc);
+ if (encoding == NULL)
+ encoding = BAD_CAST "HTML";
+ if ((encoding != NULL) && (oldctxtenc == NULL) &&
+ (buf->encoder == NULL) && (buf->conv == NULL)) {
+ if (xmlSaveSwitchEncoding(ctxt, (const char*) encoding) < 0) {
+ doc->encoding = oldenc;
+ return(-1);
+ }
+ switched_encoding = 1;
+ }
+ if (ctxt->options & XML_SAVE_FORMAT)
+ htmlNodeDumpFormatOutput(buf, doc, cur,
+ (const char *)encoding, 1);
+ else
+ htmlNodeDumpFormatOutput(buf, doc, cur,
+ (const char *)encoding, 0);
+ /*
+ * Restore the state of the saving context at the end of the document
+ */
+ if ((switched_encoding) && (oldctxtenc == NULL)) {
+ xmlSaveClearEncoding(ctxt);
+ }
+ if (doc != NULL)
+ doc->encoding = oldenc;
+ return(0);
+}
+#endif
+
/**
* xmlNodeDumpOutputInternal:
* @cur: the current node
@@ -660,6 +914,19 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
xmlDocContentDumpOutput(ctxt, (xmlDocPtr) cur);
return;
}
+#ifdef LIBXML_HTML_ENABLED
+ if (ctxt->options & XML_SAVE_XHTML) {
+ xhtmlNodeDumpOutput(ctxt, cur);
+ return;
+ }
+ if (((cur->type != XML_NAMESPACE_DECL) && (cur->doc != NULL) &&
+ (cur->doc->type == XML_HTML_DOCUMENT_NODE) &&
+ ((ctxt->options & XML_SAVE_AS_XML) == 0)) ||
+ (ctxt->options & XML_SAVE_AS_HTML)) {
+ htmlNodeDumpOutputInternal(ctxt, cur);
+ return;
+ }
+#endif
if (cur->type == XML_DTD_NODE) {
xmlDtdDumpOutput(ctxt, (xmlDtdPtr) cur);
return;
@@ -669,15 +936,15 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
return;
}
if (cur->type == XML_ELEMENT_DECL) {
- xmlDumpElementDecl(buf->buffer, (xmlElementPtr) cur);
+ xmlBufDumpElementDecl(buf->buffer, (xmlElementPtr) cur);
return;
}
if (cur->type == XML_ATTRIBUTE_DECL) {
- xmlDumpAttributeDecl(buf->buffer, (xmlAttributePtr) cur);
+ xmlBufDumpAttributeDecl(buf->buffer, (xmlAttributePtr) cur);
return;
}
if (cur->type == XML_ENTITY_DECL) {
- xmlDumpEntityDecl(buf->buffer, (xmlEntityPtr) cur);
+ xmlBufDumpEntityDecl(buf->buffer, (xmlEntityPtr) cur);
return;
}
if (cur->type == XML_TEXT_NODE) {
@@ -699,13 +966,18 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
xmlOutputBufferWrite(buf, 2, "<?");
xmlOutputBufferWriteString(buf, (const char *)cur->name);
if (cur->content != NULL) {
- xmlOutputBufferWrite(buf, 1, " ");
+ if (ctxt->format == 2)
+ xmlOutputBufferWriteWSNonSig(ctxt, 0);
+ else
+ xmlOutputBufferWrite(buf, 1, " ");
xmlOutputBufferWriteString(buf, (const char *)cur->content);
}
xmlOutputBufferWrite(buf, 2, "?>");
} else {
xmlOutputBufferWrite(buf, 2, "<?");
xmlOutputBufferWriteString(buf, (const char *)cur->name);
+ if (ctxt->format == 2)
+ xmlOutputBufferWriteWSNonSig(ctxt, 0);
xmlOutputBufferWrite(buf, 2, "?>");
}
return;
@@ -725,8 +997,8 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
return;
}
if (cur->type == XML_CDATA_SECTION_NODE) {
- if (cur->content == NULL) {
- xmlOutputBufferWrite(buf, 12, "<![CDATA[]]>");
+ if (cur->content == NULL || *cur->content == '\0') {
+ xmlOutputBufferWrite(buf, 12, "<![CDATA[]]>");
} else {
start = end = cur->content;
while (*end != '\0') {
@@ -753,7 +1025,7 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
return;
}
if (cur->type == XML_NAMESPACE_DECL) {
- xmlNsDumpOutput(buf, (xmlNsPtr) cur);
+ xmlNsDumpOutputCtxt(ctxt, (xmlNsPtr) cur);
return;
}
@@ -778,28 +1050,32 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
xmlOutputBufferWriteString(buf, (const char *)cur->name);
if (cur->nsDef)
- xmlNsListDumpOutput(buf, cur->nsDef);
+ xmlNsListDumpOutputCtxt(ctxt, cur->nsDef);
if (cur->properties != NULL)
xmlAttrListDumpOutput(ctxt, cur->properties);
if (((cur->type == XML_ELEMENT_NODE) || (cur->content == NULL)) &&
(cur->children == NULL) && ((ctxt->options & XML_SAVE_NO_EMPTY) == 0)) {
+ if (ctxt->format == 2)
+ xmlOutputBufferWriteWSNonSig(ctxt, 0);
xmlOutputBufferWrite(buf, 2, "/>");
ctxt->format = format;
return;
}
+ if (ctxt->format == 2)
+ xmlOutputBufferWriteWSNonSig(ctxt, 1);
xmlOutputBufferWrite(buf, 1, ">");
if ((cur->type != XML_ELEMENT_NODE) && (cur->content != NULL)) {
xmlOutputBufferWriteEscape(buf, cur->content, ctxt->escape);
}
if (cur->children != NULL) {
- if (ctxt->format) xmlOutputBufferWrite(buf, 1, "\n");
+ if (ctxt->format == 1) xmlOutputBufferWrite(buf, 1, "\n");
if (ctxt->level >= 0) ctxt->level++;
xmlNodeListDumpOutput(ctxt, cur->children);
if (ctxt->level > 0) ctxt->level--;
- if ((xmlIndentTreeOutput) && (ctxt->format))
+ if ((xmlIndentTreeOutput) && (ctxt->format == 1))
xmlOutputBufferWrite(buf, ctxt->indent_size *
- (ctxt->level > ctxt->indent_nr ?
+ (ctxt->level > ctxt->indent_nr ?
ctxt->indent_nr : ctxt->level),
ctxt->indent);
}
@@ -810,6 +1086,8 @@ xmlNodeDumpOutputInternal(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
}
xmlOutputBufferWriteString(buf, (const char *)cur->name);
+ if (ctxt->format == 2)
+ xmlOutputBufferWriteWSNonSig(ctxt, 0);
xmlOutputBufferWrite(buf, 1, ">");
ctxt->format = format;
}
@@ -832,11 +1110,15 @@ xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur) {
xmlCharEncodingOutputFunc oldescape = ctxt->escape;
xmlCharEncodingOutputFunc oldescapeAttr = ctxt->escapeAttr;
xmlOutputBufferPtr buf = ctxt->buf;
- xmlCharEncodingHandlerPtr handler = NULL;
xmlCharEncoding enc;
+ int switched_encoding = 0;
xmlInitParser();
+ if ((cur->type != XML_HTML_DOCUMENT_NODE) &&
+ (cur->type != XML_DOCUMENT_NODE))
+ return(-1);
+
if (ctxt->encoding != NULL) {
cur->encoding = BAD_CAST ctxt->encoding;
} else if (cur->encoding != NULL) {
@@ -846,110 +1128,125 @@ xmlDocContentDumpOutput(xmlSaveCtxtPtr ctxt, xmlDocPtr cur) {
xmlGetCharEncodingName((xmlCharEncoding) cur->charset);
}
- enc = xmlParseCharEncoding((const char*) encoding);
- if ((encoding != NULL) && (oldctxtenc == NULL) &&
- (buf->encoder == NULL) && (buf->conv == NULL) &&
- ((ctxt->options & XML_SAVE_NO_DECL) == 0)) {
- if ((enc != XML_CHAR_ENCODING_UTF8) &&
- (enc != XML_CHAR_ENCODING_NONE) &&
- (enc != XML_CHAR_ENCODING_ASCII)) {
- /*
- * we need to switch to this encoding but just for this document
- * since we output the XMLDecl the conversion must be done to not
- * generate not well formed documents.
- */
- buf->encoder = xmlFindCharEncodingHandler((const char *)encoding);
- if (buf->encoder == NULL) {
- xmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL,
- (const char *)encoding);
+ if (((cur->type == XML_HTML_DOCUMENT_NODE) &&
+ ((ctxt->options & XML_SAVE_AS_XML) == 0) &&
+ ((ctxt->options & XML_SAVE_XHTML) == 0)) ||
+ (ctxt->options & XML_SAVE_AS_HTML)) {
+#ifdef LIBXML_HTML_ENABLED
+ if (encoding != NULL)
+ htmlSetMetaEncoding(cur, (const xmlChar *) encoding);
+ if (encoding == NULL)
+ encoding = htmlGetMetaEncoding(cur);
+ if (encoding == NULL)
+ encoding = BAD_CAST "HTML";
+ if ((encoding != NULL) && (oldctxtenc == NULL) &&
+ (buf->encoder == NULL) && (buf->conv == NULL)) {
+ if (xmlSaveSwitchEncoding(ctxt, (const char*) encoding) < 0) {
+ cur->encoding = oldenc;
return(-1);
}
- buf->conv = xmlBufferCreate();
- if (buf->conv == NULL) {
- xmlCharEncCloseFunc(buf->encoder);
- xmlSaveErrMemory("creating encoding buffer");
- return(-1);
+ }
+ if (ctxt->options & XML_SAVE_FORMAT)
+ htmlDocContentDumpFormatOutput(buf, cur,
+ (const char *)encoding, 1);
+ else
+ htmlDocContentDumpFormatOutput(buf, cur,
+ (const char *)encoding, 0);
+ if (ctxt->encoding != NULL)
+ cur->encoding = oldenc;
+ return(0);
+#else
+ return(-1);
+#endif
+ } else if ((cur->type == XML_DOCUMENT_NODE) ||
+ (ctxt->options & XML_SAVE_AS_XML) ||
+ (ctxt->options & XML_SAVE_XHTML)) {
+ enc = xmlParseCharEncoding((const char*) encoding);
+ if ((encoding != NULL) && (oldctxtenc == NULL) &&
+ (buf->encoder == NULL) && (buf->conv == NULL) &&
+ ((ctxt->options & XML_SAVE_NO_DECL) == 0)) {
+ if ((enc != XML_CHAR_ENCODING_UTF8) &&
+ (enc != XML_CHAR_ENCODING_NONE) &&
+ (enc != XML_CHAR_ENCODING_ASCII)) {
+ /*
+ * we need to switch to this encoding but just for this
+ * document since we output the XMLDecl the conversion
+ * must be done to not generate not well formed documents.
+ */
+ if (xmlSaveSwitchEncoding(ctxt, (const char*) encoding) < 0) {
+ cur->encoding = oldenc;
+ return(-1);
+ }
+ switched_encoding = 1;
}
- /*
- * initialize the state, e.g. if outputting a BOM
- */
- xmlCharEncOutFunc(buf->encoder, buf->conv, NULL);
+ if (ctxt->escape == xmlEscapeEntities)
+ ctxt->escape = NULL;
+ if (ctxt->escapeAttr == xmlEscapeEntities)
+ ctxt->escapeAttr = NULL;
}
- if (ctxt->escape == xmlEscapeEntities)
- ctxt->escape = NULL;
- if (ctxt->escapeAttr == xmlEscapeEntities)
- ctxt->escapeAttr = NULL;
- }
- /*
- * Save the XML declaration
- */
- if ((ctxt->options & XML_SAVE_NO_DECL) == 0) {
- xmlOutputBufferWrite(buf, 14, "<?xml version=");
- if (cur->version != NULL)
- xmlBufferWriteQuotedString(buf->buffer, cur->version);
- else
- xmlOutputBufferWrite(buf, 5, "\"1.0\"");
- if (encoding != NULL) {
- xmlOutputBufferWrite(buf, 10, " encoding=");
- xmlBufferWriteQuotedString(buf->buffer, (xmlChar *) encoding);
- }
- switch (cur->standalone) {
- case 0:
- xmlOutputBufferWrite(buf, 16, " standalone=\"no\"");
- break;
- case 1:
- xmlOutputBufferWrite(buf, 17, " standalone=\"yes\"");
- break;
+ /*
+ * Save the XML declaration
+ */
+ if ((ctxt->options & XML_SAVE_NO_DECL) == 0) {
+ xmlOutputBufferWrite(buf, 14, "<?xml version=");
+ if (cur->version != NULL)
+ xmlBufWriteQuotedString(buf->buffer, cur->version);
+ else
+ xmlOutputBufferWrite(buf, 5, "\"1.0\"");
+ if (encoding != NULL) {
+ xmlOutputBufferWrite(buf, 10, " encoding=");
+ xmlBufWriteQuotedString(buf->buffer, (xmlChar *) encoding);
+ }
+ switch (cur->standalone) {
+ case 0:
+ xmlOutputBufferWrite(buf, 16, " standalone=\"no\"");
+ break;
+ case 1:
+ xmlOutputBufferWrite(buf, 17, " standalone=\"yes\"");
+ break;
+ }
+ xmlOutputBufferWrite(buf, 3, "?>\n");
}
- xmlOutputBufferWrite(buf, 3, "?>\n");
- }
#ifdef LIBXML_HTML_ENABLED
- if ((ctxt->options & XML_SAVE_NO_XHTML) == 0) {
- dtd = xmlGetIntSubset(cur);
- if (dtd != NULL) {
- is_xhtml = xmlIsXHTML(dtd->SystemID, dtd->ExternalID);
- if (is_xhtml < 0) is_xhtml = 0;
+ if (ctxt->options & XML_SAVE_XHTML)
+ is_xhtml = 1;
+ if ((ctxt->options & XML_SAVE_NO_XHTML) == 0) {
+ dtd = xmlGetIntSubset(cur);
+ if (dtd != NULL) {
+ is_xhtml = xmlIsXHTML(dtd->SystemID, dtd->ExternalID);
+ if (is_xhtml < 0) is_xhtml = 0;
+ }
}
- }
#endif
- if (cur->children != NULL) {
- xmlNodePtr child = cur->children;
+ if (cur->children != NULL) {
+ xmlNodePtr child = cur->children;
- while (child != NULL) {
- ctxt->level = 0;
+ while (child != NULL) {
+ ctxt->level = 0;
#ifdef LIBXML_HTML_ENABLED
- if (is_xhtml)
- xhtmlNodeDumpOutput(ctxt, child);
- else
+ if (is_xhtml)
+ xhtmlNodeDumpOutput(ctxt, child);
+ else
#endif
- xmlNodeDumpOutputInternal(ctxt, child);
- xmlOutputBufferWrite(buf, 1, "\n");
- child = child->next;
+ xmlNodeDumpOutputInternal(ctxt, child);
+ xmlOutputBufferWrite(buf, 1, "\n");
+ child = child->next;
+ }
}
}
- if (ctxt->encoding != NULL)
- cur->encoding = oldenc;
-
+
/*
* Restore the state of the saving context at the end of the document
*/
- if ((encoding != NULL) && (oldctxtenc == NULL) &&
- ((ctxt->options & XML_SAVE_NO_DECL) == 0)) {
- if ((enc != XML_CHAR_ENCODING_UTF8) &&
- (enc != XML_CHAR_ENCODING_NONE) &&
- (enc != XML_CHAR_ENCODING_ASCII)) {
- xmlOutputBufferFlush(buf);
- xmlCharEncCloseFunc(buf->encoder);
- xmlBufferFree(buf->conv);
- buf->encoder = NULL;
- buf->conv = NULL;
- }
+ if ((switched_encoding) && (oldctxtenc == NULL)) {
+ xmlSaveClearEncoding(ctxt);
ctxt->escape = oldescape;
ctxt->escapeAttr = oldescapeAttr;
}
+ cur->encoding = oldenc;
return(0);
}
@@ -1058,7 +1355,7 @@ xhtmlAttrListDumpOutput(xmlSaveCtxtPtr ctxt, xmlAttrPtr cur) {
if ((cur->ns != NULL) && (xmlStrEqual(cur->name, BAD_CAST "lang")) &&
(xmlStrEqual(cur->ns->prefix, BAD_CAST "xml")))
xml_lang = cur;
- else if ((cur->ns == NULL) &&
+ else if ((cur->ns == NULL) &&
((cur->children == NULL) ||
(cur->children->content == NULL) ||
(cur->children->content[0] == 0)) &&
@@ -1098,7 +1395,7 @@ xhtmlAttrListDumpOutput(xmlSaveCtxtPtr ctxt, xmlAttrPtr cur) {
xmlOutputBufferWrite(buf, 11, " xml:lang=\"");
xmlAttrSerializeContent(buf, lang);
xmlOutputBufferWrite(buf, 1, "\"");
- } else
+ } else
if ((xml_lang != NULL) && (lang == NULL)) {
xmlOutputBufferWrite(buf, 7, " lang=\"");
xmlAttrSerializeContent(buf, xml_lang);
@@ -1126,14 +1423,14 @@ xhtmlNodeListDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
if (cur == NULL) return;
buf = ctxt->buf;
while (cur != NULL) {
- if ((ctxt->format) && (xmlIndentTreeOutput) &&
+ if ((ctxt->format == 1) && (xmlIndentTreeOutput) &&
(cur->type == XML_ELEMENT_NODE))
xmlOutputBufferWrite(buf, ctxt->indent_size *
- (ctxt->level > ctxt->indent_nr ?
+ (ctxt->level > ctxt->indent_nr ?
ctxt->indent_nr : ctxt->level),
ctxt->indent);
xhtmlNodeDumpOutput(ctxt, cur);
- if (ctxt->format) {
+ if (ctxt->format == 1) {
xmlOutputBufferWrite(buf, 1, "\n");
}
cur = cur->next;
@@ -1168,6 +1465,10 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
return;
if (cur->type == XML_XINCLUDE_END)
return;
+ if (cur->type == XML_NAMESPACE_DECL) {
+ xmlNsDumpOutputCtxt(ctxt, (xmlNsPtr) cur);
+ return;
+ }
if (cur->type == XML_DTD_NODE) {
xmlDtdDumpOutput(ctxt, (xmlDtdPtr) cur);
return;
@@ -1178,15 +1479,15 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
}
buf = ctxt->buf;
if (cur->type == XML_ELEMENT_DECL) {
- xmlDumpElementDecl(buf->buffer, (xmlElementPtr) cur);
+ xmlBufDumpElementDecl(buf->buffer, (xmlElementPtr) cur);
return;
}
if (cur->type == XML_ATTRIBUTE_DECL) {
- xmlDumpAttributeDecl(buf->buffer, (xmlAttributePtr) cur);
+ xmlBufDumpAttributeDecl(buf->buffer, (xmlAttributePtr) cur);
return;
}
if (cur->type == XML_ENTITY_DECL) {
- xmlDumpEntityDecl(buf->buffer, (xmlEntityPtr) cur);
+ xmlBufDumpEntityDecl(buf->buffer, (xmlEntityPtr) cur);
return;
}
if (cur->type == XML_TEXT_NODE) {
@@ -1235,30 +1536,38 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
return;
}
if (cur->type == XML_CDATA_SECTION_NODE) {
- start = end = cur->content;
- while (*end != '\0') {
- if (*end == ']' && *(end + 1) == ']' && *(end + 2) == '>') {
- end = end + 2;
+ if (cur->content == NULL || *cur->content == '\0') {
+ xmlOutputBufferWrite(buf, 12, "<![CDATA[]]>");
+ } else {
+ start = end = cur->content;
+ while (*end != '\0') {
+ if (*end == ']' && *(end + 1) == ']' && *(end + 2) == '>') {
+ end = end + 2;
+ xmlOutputBufferWrite(buf, 9, "<![CDATA[");
+ xmlOutputBufferWrite(buf, end - start, (const char *)start);
+ xmlOutputBufferWrite(buf, 3, "]]>");
+ start = end;
+ }
+ end++;
+ }
+ if (start != end) {
xmlOutputBufferWrite(buf, 9, "<![CDATA[");
- xmlOutputBufferWrite(buf, end - start, (const char *)start);
+ xmlOutputBufferWriteString(buf, (const char *)start);
xmlOutputBufferWrite(buf, 3, "]]>");
- start = end;
}
- end++;
- }
- if (start != end) {
- xmlOutputBufferWrite(buf, 9, "<![CDATA[");
- xmlOutputBufferWriteString(buf, (const char *)start);
- xmlOutputBufferWrite(buf, 3, "]]>");
}
return;
}
+ if (cur->type == XML_ATTRIBUTE_NODE) {
+ xmlAttrDumpOutput(ctxt, (xmlAttrPtr) cur);
+ return;
+ }
format = ctxt->format;
if (format == 1) {
tmp = cur->children;
while (tmp != NULL) {
- if ((tmp->type == XML_TEXT_NODE) ||
+ if ((tmp->type == XML_TEXT_NODE) ||
(tmp->type == XML_ENTITY_REF_NODE)) {
format = 0;
break;
@@ -1274,7 +1583,7 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
xmlOutputBufferWriteString(buf, (const char *)cur->name);
if (cur->nsDef)
- xmlNsListDumpOutput(buf, cur->nsDef);
+ xmlNsListDumpOutputCtxt(ctxt, cur->nsDef);
if ((xmlStrEqual(cur->name, BAD_CAST "html") &&
(cur->ns == NULL) && (cur->nsDef == NULL))) {
/*
@@ -1286,10 +1595,10 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
if (cur->properties != NULL)
xhtmlAttrListDumpOutput(ctxt, cur->properties);
- if ((cur->type == XML_ELEMENT_NODE) &&
- (cur->parent != NULL) &&
- (cur->parent->parent == (xmlNodePtr) cur->doc) &&
- xmlStrEqual(cur->name, BAD_CAST"head") &&
+ if ((cur->type == XML_ELEMENT_NODE) &&
+ (cur->parent != NULL) &&
+ (cur->parent->parent == (xmlNodePtr) cur->doc) &&
+ xmlStrEqual(cur->name, BAD_CAST"head") &&
xmlStrEqual(cur->parent->name, BAD_CAST"html")) {
tmp = cur->children;
@@ -1322,11 +1631,11 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
} else {
if (addmeta == 1) {
xmlOutputBufferWrite(buf, 1, ">");
- if (ctxt->format) {
+ if (ctxt->format == 1) {
xmlOutputBufferWrite(buf, 1, "\n");
if (xmlIndentTreeOutput)
xmlOutputBufferWrite(buf, ctxt->indent_size *
- (ctxt->level + 1 > ctxt->indent_nr ?
+ (ctxt->level + 1 > ctxt->indent_nr ?
ctxt->indent_nr : ctxt->level + 1), ctxt->indent);
}
xmlOutputBufferWriteString(buf,
@@ -1337,7 +1646,7 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
xmlOutputBufferWrite(buf, 5, "UTF-8");
}
xmlOutputBufferWrite(buf, 4, "\" />");
- if (ctxt->format)
+ if (ctxt->format == 1)
xmlOutputBufferWrite(buf, 1, "\n");
} else {
xmlOutputBufferWrite(buf, 1, ">");
@@ -1357,11 +1666,11 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
}
xmlOutputBufferWrite(buf, 1, ">");
if (addmeta == 1) {
- if (ctxt->format) {
+ if (ctxt->format == 1) {
xmlOutputBufferWrite(buf, 1, "\n");
if (xmlIndentTreeOutput)
xmlOutputBufferWrite(buf, ctxt->indent_size *
- (ctxt->level + 1 > ctxt->indent_nr ?
+ (ctxt->level + 1 > ctxt->indent_nr ?
ctxt->indent_nr : ctxt->level + 1), ctxt->indent);
}
xmlOutputBufferWriteString(buf,
@@ -1451,16 +1760,16 @@ xhtmlNodeDumpOutput(xmlSaveCtxtPtr ctxt, xmlNodePtr cur) {
if (cur->children != NULL) {
int indent = ctxt->format;
-
- if (format) xmlOutputBufferWrite(buf, 1, "\n");
+
+ if (format == 1) xmlOutputBufferWrite(buf, 1, "\n");
if (ctxt->level >= 0) ctxt->level++;
ctxt->format = format;
xhtmlNodeListDumpOutput(ctxt, cur->children);
if (ctxt->level > 0) ctxt->level--;
ctxt->format = indent;
- if ((xmlIndentTreeOutput) && (format))
+ if ((xmlIndentTreeOutput) && (format == 1))
xmlOutputBufferWrite(buf, ctxt->indent_size *
- (ctxt->level > ctxt->indent_nr ?
+ (ctxt->level > ctxt->indent_nr ?
ctxt->indent_nr : ctxt->level),
ctxt->indent);
}
@@ -1726,18 +2035,19 @@ xmlSaveSetAttrEscape(xmlSaveCtxtPtr ctxt, xmlCharEncodingOutputFunc escape)
* Public entry points based on buffers *
* *
************************************************************************/
+
/**
- * xmlAttrSerializeTxtContent:
- * @buf: the XML buffer output
+ * xmlBufAttrSerializeTxtContent:
+ * @buf: and xmlBufPtr output
* @doc: the document
* @attr: the attribute node
* @string: the text content
*
- * Serialize text attribute values to an xml simple buffer
+ * Serialize text attribute values to an xmlBufPtr
*/
void
-xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
- xmlAttrPtr attr, const xmlChar * string)
+xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc,
+ xmlAttrPtr attr, const xmlChar * string)
{
xmlChar *base, *cur;
@@ -1747,44 +2057,44 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
while (*cur != 0) {
if (*cur == '\n') {
if (base != cur)
- xmlBufferAdd(buf, base, cur - base);
- xmlBufferAdd(buf, BAD_CAST "&#10;", 5);
+ xmlBufAdd(buf, base, cur - base);
+ xmlBufAdd(buf, BAD_CAST "&#10;", 5);
cur++;
base = cur;
} else if (*cur == '\r') {
if (base != cur)
- xmlBufferAdd(buf, base, cur - base);
- xmlBufferAdd(buf, BAD_CAST "&#13;", 5);
+ xmlBufAdd(buf, base, cur - base);
+ xmlBufAdd(buf, BAD_CAST "&#13;", 5);
cur++;
base = cur;
} else if (*cur == '\t') {
if (base != cur)
- xmlBufferAdd(buf, base, cur - base);
- xmlBufferAdd(buf, BAD_CAST "&#9;", 4);
+ xmlBufAdd(buf, base, cur - base);
+ xmlBufAdd(buf, BAD_CAST "&#9;", 4);
cur++;
base = cur;
} else if (*cur == '"') {
if (base != cur)
- xmlBufferAdd(buf, base, cur - base);
- xmlBufferAdd(buf, BAD_CAST "&quot;", 6);
+ xmlBufAdd(buf, base, cur - base);
+ xmlBufAdd(buf, BAD_CAST "&quot;", 6);
cur++;
base = cur;
} else if (*cur == '<') {
if (base != cur)
- xmlBufferAdd(buf, base, cur - base);
- xmlBufferAdd(buf, BAD_CAST "&lt;", 4);
+ xmlBufAdd(buf, base, cur - base);
+ xmlBufAdd(buf, BAD_CAST "&lt;", 4);
cur++;
base = cur;
} else if (*cur == '>') {
if (base != cur)
- xmlBufferAdd(buf, base, cur - base);
- xmlBufferAdd(buf, BAD_CAST "&gt;", 4);
+ xmlBufAdd(buf, base, cur - base);
+ xmlBufAdd(buf, BAD_CAST "&gt;", 4);
cur++;
base = cur;
} else if (*cur == '&') {
if (base != cur)
- xmlBufferAdd(buf, base, cur - base);
- xmlBufferAdd(buf, BAD_CAST "&amp;", 5);
+ xmlBufAdd(buf, base, cur - base);
+ xmlBufAdd(buf, BAD_CAST "&amp;", 5);
cur++;
base = cur;
} else if ((*cur >= 0x80) && ((doc == NULL) ||
@@ -1792,17 +2102,17 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
/*
* We assume we have UTF-8 content.
*/
- unsigned char tmp[10];
+ unsigned char tmp[12];
int val = 0, l = 1;
if (base != cur)
- xmlBufferAdd(buf, base, cur - base);
+ xmlBufAdd(buf, base, cur - base);
if (*cur < 0xC0) {
xmlSaveErr(XML_SAVE_NOT_UTF8, (xmlNodePtr) attr, NULL);
if (doc != NULL)
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
xmlSerializeHexCharRef(tmp, *cur);
- xmlBufferAdd(buf, (xmlChar *) tmp, -1);
+ xmlBufAdd(buf, (xmlChar *) tmp, -1);
cur++;
base = cur;
continue;
@@ -1832,9 +2142,9 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
xmlSaveErr(XML_SAVE_CHAR_INVALID, (xmlNodePtr) attr, NULL);
if (doc != NULL)
doc->encoding = xmlStrdup(BAD_CAST "ISO-8859-1");
-
+
xmlSerializeHexCharRef(tmp, *cur);
- xmlBufferAdd(buf, (xmlChar *) tmp, -1);
+ xmlBufAdd(buf, (xmlChar *) tmp, -1);
cur++;
base = cur;
continue;
@@ -1844,7 +2154,7 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
* as a char ref
*/
xmlSerializeHexCharRef(tmp, val);
- xmlBufferAdd(buf, (xmlChar *) tmp, -1);
+ xmlBufAdd(buf, (xmlChar *) tmp, -1);
cur += l;
base = cur;
} else {
@@ -1852,7 +2162,31 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
}
}
if (base != cur)
- xmlBufferAdd(buf, base, cur - base);
+ xmlBufAdd(buf, base, cur - base);
+}
+
+/**
+ * xmlAttrSerializeTxtContent:
+ * @buf: the XML buffer output
+ * @doc: the document
+ * @attr: the attribute node
+ * @string: the text content
+ *
+ * Serialize text attribute values to an xml simple buffer
+ */
+void
+xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
+ xmlAttrPtr attr, const xmlChar * string)
+{
+ xmlBufPtr buffer;
+
+ if ((buf == NULL) || (string == NULL))
+ return;
+ buffer = xmlBufFromBuffer(buf);
+ if (buffer == NULL)
+ return;
+ xmlBufAttrSerializeTxtContent(buffer, doc, attr, string);
+ xmlBufBackToBuffer(buffer);
}
/**
@@ -1866,6 +2200,8 @@ xmlAttrSerializeTxtContent(xmlBufferPtr buf, xmlDocPtr doc,
* Dump an XML node, recursive behaviour,children are printed too.
* Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1
* or xmlKeepBlanksDefault(0) was called
+ * Since this is using xmlBuffer structures it is limited to 2GB and somehow
+ * deprecated, use xmlBufNodeDump() instead.
*
* Returns the number of bytes written to the buffer or -1 in case of error
*/
@@ -1873,9 +2209,45 @@ int
xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
int format)
{
- unsigned int use;
+ xmlBufPtr buffer;
+ int ret;
+
+ if ((buf == NULL) || (cur == NULL))
+ return(-1);
+ buffer = xmlBufFromBuffer(buf);
+ if (buffer == NULL)
+ return(-1);
+ ret = xmlBufNodeDump(buffer, doc, cur, level, format);
+ xmlBufBackToBuffer(buffer);
+ if (ret > INT_MAX)
+ return(-1);
+ return((int) ret);
+}
+
+/**
+ * xmlBufNodeDump:
+ * @buf: the XML buffer output
+ * @doc: the document
+ * @cur: the current node
+ * @level: the imbrication level for indenting
+ * @format: is formatting allowed
+ *
+ * Dump an XML node, recursive behaviour,children are printed too.
+ * Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1
+ * or xmlKeepBlanksDefault(0) was called
+ *
+ * Returns the number of bytes written to the buffer, in case of error 0
+ * is returned or @buf stores the error
+ */
+
+size_t
+xmlBufNodeDump(xmlBufPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
+ int format)
+{
+ size_t use;
int ret;
xmlOutputBufferPtr outbuf;
+ int oldalloc;
xmlInitParser();
@@ -1906,10 +2278,13 @@ xmlNodeDump(xmlBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur, int level,
outbuf->context = NULL;
outbuf->written = 0;
- use = buf->use;
+ use = xmlBufUse(buf);
+ oldalloc = xmlBufGetAllocationScheme(buf);
+ xmlBufSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
xmlNodeDumpOutput(outbuf, doc, cur, level, format, NULL);
+ xmlBufSetAllocationScheme(buf, oldalloc);
xmlFree(outbuf);
- ret = buf->use - use;
+ ret = xmlBufUse(buf) - use;
return (ret);
}
@@ -1996,9 +2371,10 @@ xmlNodeDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr doc, xmlNodePtr cur,
ctxt.doc = doc;
ctxt.buf = buf;
ctxt.level = level;
- ctxt.format = format;
+ ctxt.format = format ? 1 : 0;
ctxt.encoding = (const xmlChar *) encoding;
xmlSaveCtxtInit(&ctxt);
+ ctxt.options |= XML_SAVE_AS_XML;
#ifdef LIBXML_HTML_ENABLED
dtd = xmlGetIntSubset(doc);
@@ -2081,17 +2457,18 @@ xmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc, xmlChar **doc_txt_ptr,
ctxt.doc = out_doc;
ctxt.buf = out_buff;
ctxt.level = 0;
- ctxt.format = format;
+ ctxt.format = format ? 1 : 0;
ctxt.encoding = (const xmlChar *) txt_encoding;
xmlSaveCtxtInit(&ctxt);
+ ctxt.options |= XML_SAVE_AS_XML;
xmlDocContentDumpOutput(&ctxt, out_doc);
xmlOutputBufferFlush(out_buff);
if (out_buff->conv != NULL) {
- *doc_txt_len = out_buff->conv->use;
- *doc_txt_ptr = xmlStrndup(out_buff->conv->content, *doc_txt_len);
+ *doc_txt_len = xmlBufUse(out_buff->conv);
+ *doc_txt_ptr = xmlStrndup(xmlBufContent(out_buff->conv), *doc_txt_len);
} else {
- *doc_txt_len = out_buff->buffer->use;
- *doc_txt_ptr = xmlStrndup(out_buff->buffer->content, *doc_txt_len);
+ *doc_txt_len = xmlBufUse(out_buff->buffer);
+ *doc_txt_ptr = xmlStrndup(xmlBufContent(out_buff->buffer),*doc_txt_len);
}
(void)xmlOutputBufferClose(out_buff);
@@ -2186,21 +2563,23 @@ xmlDocFormatDump(FILE *f, xmlDocPtr cur, int format) {
encoding = (const char *) cur->encoding;
if (encoding != NULL) {
- handler = xmlFindCharEncodingHandler(encoding);
- if (handler == NULL) {
- xmlFree((char *) cur->encoding);
- cur->encoding = NULL;
- }
+ handler = xmlFindCharEncodingHandler(encoding);
+ if (handler == NULL) {
+ xmlFree((char *) cur->encoding);
+ cur->encoding = NULL;
+ encoding = NULL;
}
+ }
buf = xmlOutputBufferCreateFile(f, handler);
if (buf == NULL) return(-1);
memset(&ctxt, 0, sizeof(ctxt));
ctxt.doc = cur;
ctxt.buf = buf;
ctxt.level = 0;
- ctxt.format = format;
+ ctxt.format = format ? 1 : 0;
ctxt.encoding = (const xmlChar *) encoding;
xmlSaveCtxtInit(&ctxt);
+ ctxt.options |= XML_SAVE_AS_XML;
xmlDocContentDumpOutput(&ctxt, cur);
ret = xmlOutputBufferClose(buf);
@@ -2250,6 +2629,7 @@ xmlSaveFileTo(xmlOutputBufferPtr buf, xmlDocPtr cur, const char *encoding) {
ctxt.format = 0;
ctxt.encoding = (const xmlChar *) encoding;
xmlSaveCtxtInit(&ctxt);
+ ctxt.options |= XML_SAVE_AS_XML;
xmlDocContentDumpOutput(&ctxt, cur);
ret = xmlOutputBufferClose(buf);
return(ret);
@@ -2286,9 +2666,10 @@ xmlSaveFormatFileTo(xmlOutputBufferPtr buf, xmlDocPtr cur,
ctxt.doc = cur;
ctxt.buf = buf;
ctxt.level = 0;
- ctxt.format = format;
+ ctxt.format = format ? 1 : 0;
ctxt.encoding = (const xmlChar *) encoding;
xmlSaveCtxtInit(&ctxt);
+ ctxt.options |= XML_SAVE_AS_XML;
xmlDocContentDumpOutput(&ctxt, cur);
ret = xmlOutputBufferClose(buf);
return (ret);
@@ -2331,7 +2712,7 @@ xmlSaveFormatFileEnc( const char * filename, xmlDocPtr cur,
#ifdef HAVE_ZLIB_H
if (cur->compression < 0) cur->compression = xmlGetCompressMode();
#endif
- /*
+ /*
* save the content to a temp buffer.
*/
buf = xmlOutputBufferCreateFilename(filename, handler, cur->compression);
@@ -2340,9 +2721,10 @@ xmlSaveFormatFileEnc( const char * filename, xmlDocPtr cur,
ctxt.doc = cur;
ctxt.buf = buf;
ctxt.level = 0;
- ctxt.format = format;
+ ctxt.format = format ? 1 : 0;
ctxt.encoding = (const xmlChar *) encoding;
xmlSaveCtxtInit(&ctxt);
+ ctxt.options |= XML_SAVE_AS_XML;
xmlDocContentDumpOutput(&ctxt, cur);
diff --git a/gnulib-local/lib/libxml/xmlsave.in.h b/gnulib-local/lib/libxml/xmlsave.in.h
index c71c71a..fb329b2 100644
--- a/gnulib-local/lib/libxml/xmlsave.in.h
+++ b/gnulib-local/lib/libxml/xmlsave.in.h
@@ -30,7 +30,11 @@ typedef enum {
XML_SAVE_FORMAT = 1<<0, /* format save output */
XML_SAVE_NO_DECL = 1<<1, /* drop the xml declaration */
XML_SAVE_NO_EMPTY = 1<<2, /* no empty tags */
- XML_SAVE_NO_XHTML = 1<<3 /* disable XHTML1 specific rules */
+ XML_SAVE_NO_XHTML = 1<<3, /* disable XHTML1 specific rules */
+ XML_SAVE_XHTML = 1<<4, /* force XHTML1 specific rules */
+ XML_SAVE_AS_XML = 1<<5, /* force XML serialization on HTML doc */
+ XML_SAVE_AS_HTML = 1<<6, /* force HTML serialization on XML doc */
+ XML_SAVE_WSNONSIG = 1<<7 /* format with non-significant whitespace */
} xmlSaveOption;
diff --git a/gnulib-local/lib/libxml/xmlschemas.c b/gnulib-local/lib/libxml/xmlschemas.c
index 11e3eac..fe533e6 100644
--- a/gnulib-local/lib/libxml/xmlschemas.c
+++ b/gnulib-local/lib/libxml/xmlschemas.c
@@ -90,7 +90,7 @@
#ifndef DEBUG_IDC_NODE_TABLE
#define DEBUG_IDC_NODE_TABLE
#endif
-#endif
+#endif
/* #define ENABLE_PARTICLE_RESTRICTION 1 */
@@ -107,7 +107,7 @@
#endif
#define UNBOUNDED (1 << 30)
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
@@ -374,7 +374,7 @@ typedef xmlSchemaBucket *xmlSchemaBucketPtr;
#define XML_SCHEMA_SCHEMA_REDEFINE 3
/**
- * xmlSchemaSchemaRelation:
+ * xmlSchemaSchemaRelation:
*
* Used to create a graph of schema relationships.
*/
@@ -402,12 +402,12 @@ struct _xmlSchemaBucket {
int parsed;
int imported;
int preserveDoc;
- xmlSchemaItemListPtr globals; /* Global components. */
+ xmlSchemaItemListPtr globals; /* Global components. */
xmlSchemaItemListPtr locals; /* Local components. */
};
/**
- * xmlSchemaImport:
+ * xmlSchemaImport:
* (extends xmlSchemaBucket)
*
* Reflects a schema. Holds some information
@@ -422,9 +422,9 @@ struct _xmlSchemaImport {
const xmlChar *schemaLocation; /* The URI of the schema document. */
/* For chameleon includes, @origTargetNamespace will be NULL */
const xmlChar *origTargetNamespace;
- /*
+ /*
* For chameleon includes, @targetNamespace will be the
- * targetNamespace of the including schema.
+ * targetNamespace of the including schema.
*/
const xmlChar *targetNamespace;
xmlDocPtr doc; /* The schema node-tree. */
@@ -457,7 +457,7 @@ struct _xmlSchemaInclude {
int parsed;
int imported;
int preserveDoc;
- xmlSchemaItemListPtr globals; /* Global components. */
+ xmlSchemaItemListPtr globals; /* Global components. */
xmlSchemaItemListPtr locals; /* Local components. */
/* The owning main or import schema bucket. */
@@ -517,7 +517,7 @@ struct _xmlSchemaAttributeUse {
xmlSchemaTypeType type;
xmlSchemaAnnotPtr annot;
xmlSchemaAttributeUsePtr next; /* The next attr. use. */
- /*
+ /*
* The attr. decl. OR a QName-ref. to an attr. decl. OR
* a QName-ref. to an attribute group definition.
*/
@@ -573,7 +573,7 @@ struct _xmlSchemaConstructionCtxt {
xmlDictPtr dict;
xmlSchemaItemListPtr buckets; /* List of schema buckets. */
/* xmlSchemaItemListPtr relations; */ /* List of schema relations. */
- xmlSchemaBucketPtr bucket; /* The current schema bucket */
+ xmlSchemaBucketPtr bucket; /* The current schema bucket */
xmlSchemaItemListPtr pending; /* All Components of all schemas that
need to be fixed. */
xmlHashTablePtr substGroups;
@@ -629,7 +629,7 @@ struct _xmlSchemaParserCtxt {
xmlSchemaBucketPtr redefined; /* The schema to be redefined. */
xmlSchemaRedefPtr redef; /* Used for redefinitions. */
- int redefCounter; /* Used for redefinitions. */
+ int redefCounter; /* Used for redefinitions. */
xmlSchemaItemListPtr attrProhibs;
};
@@ -783,7 +783,7 @@ struct _xmlSchemaPSVIIDCNode {
xmlNodePtr node;
xmlSchemaPSVIIDCKeyPtr *keys;
int nodeLine;
- int nodeQNameID;
+ int nodeQNameID;
};
@@ -879,7 +879,7 @@ struct _xmlSchemaIDCMatcher {
struct _xmlSchemaNodeInfo {
int nodeType;
xmlNodePtr node;
- int nodeLine;
+ int nodeLine;
const xmlChar *localName;
const xmlChar *nsName;
const xmlChar *value;
@@ -901,7 +901,7 @@ struct _xmlSchemaNodeInfo {
const xmlChar **nsBindings; /* Namespace bindings on this element */
int nbNsBindings;
- int sizeNsBindings;
+ int sizeNsBindings;
int hasKeyrefs;
int appliedXPath; /* Indicates that an XPath has been applied. */
@@ -938,7 +938,7 @@ typedef xmlSchemaAttrInfo *xmlSchemaAttrInfoPtr;
struct _xmlSchemaAttrInfo {
int nodeType;
xmlNodePtr node;
- int nodeLine;
+ int nodeLine;
const xmlChar *localName;
const xmlChar *nsName;
const xmlChar *value;
@@ -975,6 +975,7 @@ struct _xmlSchemaValidCtxt {
xmlSAXHandlerPtr sax;
xmlParserCtxtPtr parserCtxt;
void *user_data; /* TODO: What is this for? */
+ char *filename;
int err;
int nberrors;
@@ -1028,6 +1029,10 @@ struct _xmlSchemaValidCtxt {
int hasKeyrefs;
int createIDCNodeTables;
int psviExposeIDCNodeTables;
+
+ /* Locator for error reporting in streaming mode */
+ xmlSchemaValidityLocatorFunc locFunc;
+ void *locCtxt;
};
/**
@@ -1043,9 +1048,9 @@ struct _xmlSchemaSubstGroup {
};
/************************************************************************
- * *
- * Some predeclarations *
- * *
+ * *
+ * Some predeclarations *
+ * *
************************************************************************/
static int xmlSchemaParseInclude(xmlSchemaParserCtxtPtr ctxt,
@@ -1098,7 +1103,7 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt,
/************************************************************************
* *
- * Helper functions *
+ * Helper functions *
* *
************************************************************************/
@@ -1172,7 +1177,7 @@ xmlSchemaGetComponentTypeStr(xmlSchemaBasicItemPtr item)
if (WXS_IS_COMPLEX(WXS_TYPE_CAST item))
return(BAD_CAST "complex type definition");
else
- return(BAD_CAST "simple type definition");
+ return(BAD_CAST "simple type definition");
default:
return(xmlSchemaItemTypeToStr(item->type));
}
@@ -1300,11 +1305,11 @@ xmlSchemaFormatQName(xmlChar **buf,
*buf = xmlStrcat(*buf, localName);
} else {
*buf = xmlStrcat(*buf, BAD_CAST "(NULL)");
- }
+ }
return ((const xmlChar *) *buf);
}
-static const xmlChar*
+static const xmlChar*
xmlSchemaFormatQNameNs(xmlChar **buf, xmlNsPtr ns, const xmlChar *localName)
{
if (ns != NULL)
@@ -1466,7 +1471,7 @@ xmlSchemaWildcardPCToString(int pc)
* @retValue: the returned value
* @ws: the whitespace type of the value
*
- * Get a the cononical representation of the value.
+ * Get a the canonical representation of the value.
* The caller has to free the returned retValue.
*
* Returns 0 if the value could be built and -1 in case of
@@ -1480,16 +1485,16 @@ xmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val,
int list;
xmlSchemaValType valType;
const xmlChar *value, *value2 = NULL;
-
+
if ((retValue == NULL) || (val == NULL))
return (-1);
list = xmlSchemaValueGetNext(val) ? 1 : 0;
*retValue = NULL;
do {
- value = NULL;
- valType = xmlSchemaGetValType(val);
- switch (valType) {
+ value = NULL;
+ valType = xmlSchemaGetValType(val);
+ switch (valType) {
case XML_SCHEMAS_STRING:
case XML_SCHEMAS_NORMSTRING:
case XML_SCHEMAS_ANYSIMPLETYPE:
@@ -1502,7 +1507,7 @@ xmlSchemaGetCanonValueWhtspExt(xmlSchemaValPtr val,
if (value2 != NULL)
value = value2;
}
- break;
+ break;
default:
if (xmlSchemaGetCanonValue(val, &value2) == -1) {
if (value2 != NULL)
@@ -1540,29 +1545,29 @@ internal_error:
* @buf: the string buffer
* @itemDes: the designation of the item
* @itemName: the name of the item
- * @item: the item as an object
+ * @item: the item as an object
* @itemNode: the node of the item
* @local: the local name
* @parsing: if the function is used during the parse
*
* Returns a representation of the given item used
- * for error reports.
+ * for error reports.
*
- * The following order is used to build the resulting
+ * The following order is used to build the resulting
* designation if the arguments are not NULL:
* 1a. If itemDes not NULL -> itemDes
* 1b. If (itemDes not NULL) and (itemName not NULL)
* -> itemDes + itemName
* 2. If the preceding was NULL and (item not NULL) -> item
* 3. If the preceding was NULL and (itemNode not NULL) -> itemNode
- *
+ *
* If the itemNode is an attribute node, the name of the attribute
* will be appended to the result.
*
* Returns the formatted string and sets @buf to the resulting value.
- */
-static xmlChar*
-xmlSchemaFormatItemForReport(xmlChar **buf,
+ */
+static xmlChar*
+xmlSchemaFormatItemForReport(xmlChar **buf,
const xmlChar *itemDes,
xmlSchemaBasicItemPtr item,
xmlNodePtr itemNode)
@@ -1574,9 +1579,9 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
xmlFree(*buf);
*buf = NULL;
}
-
+
if (itemDes != NULL) {
- *buf = xmlStrdup(itemDes);
+ *buf = xmlStrdup(itemDes);
} else if (item != NULL) {
switch (item->type) {
case XML_SCHEMA_TYPE_BASIC: {
@@ -1634,7 +1639,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
break;
case XML_SCHEMA_TYPE_ATTRIBUTE_USE: {
xmlSchemaAttributeUsePtr ause;
-
+
ause = WXS_ATTR_USE_CAST item;
*buf = xmlStrdup(BAD_CAST "attribute use ");
if (WXS_ATTRUSE_DECL(ause) != NULL) {
@@ -1650,7 +1655,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
break;
case XML_SCHEMA_TYPE_ATTRIBUTE: {
xmlSchemaAttributePtr attr;
-
+
attr = (xmlSchemaAttributePtr) item;
*buf = xmlStrdup(BAD_CAST "attribute decl.");
*buf = xmlStrcat(*buf, BAD_CAST " '");
@@ -1666,7 +1671,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
case XML_SCHEMA_TYPE_ELEMENT: {
xmlSchemaElementPtr elem;
- elem = (xmlSchemaElementPtr) item;
+ elem = (xmlSchemaElementPtr) item;
*buf = xmlStrdup(BAD_CAST "element decl.");
*buf = xmlStrcat(*buf, BAD_CAST " '");
*buf = xmlStrcat(*buf, xmlSchemaFormatQName(&str,
@@ -1676,7 +1681,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
break;
case XML_SCHEMA_TYPE_IDC_UNIQUE:
case XML_SCHEMA_TYPE_IDC_KEY:
- case XML_SCHEMA_TYPE_IDC_KEYREF:
+ case XML_SCHEMA_TYPE_IDC_KEYREF:
if (item->type == XML_SCHEMA_TYPE_IDC_UNIQUE)
*buf = xmlStrdup(BAD_CAST "unique '");
else if (item->type == XML_SCHEMA_TYPE_IDC_KEY)
@@ -1732,7 +1737,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
default:
named = 0;
}
- } else
+ } else
named = 0;
if ((named == 0) && (itemNode != NULL)) {
@@ -1740,7 +1745,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
if (itemNode->type == XML_ATTRIBUTE_NODE)
elem = itemNode->parent;
- else
+ else
elem = itemNode;
*buf = xmlStrdup(BAD_CAST "Element '");
if (elem->ns != NULL) {
@@ -1750,7 +1755,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
} else
*buf = xmlStrcat(*buf, elem->name);
*buf = xmlStrcat(*buf, BAD_CAST "'");
-
+
}
if ((itemNode != NULL) && (itemNode->type == XML_ATTRIBUTE_NODE)) {
*buf = xmlStrcat(*buf, BAD_CAST ", attribute '");
@@ -1763,7 +1768,7 @@ xmlSchemaFormatItemForReport(xmlChar **buf,
*buf = xmlStrcat(*buf, BAD_CAST "'");
}
FREE_AND_NULL(str)
-
+
return (*buf);
}
@@ -1786,13 +1791,13 @@ xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt,
int res, found = 0;
if (*buf != NULL)
- xmlFree(*buf);
+ xmlFree(*buf);
*buf = NULL;
do {
/*
* Use the whitespace type of the base type.
- */
+ */
ws = xmlSchemaGetWhiteSpaceFacetValue(type->baseType);
for (facet = type->facets; facet != NULL; facet = facet->next) {
if (facet->type != XML_SCHEMA_FACET_ENUMERATION)
@@ -1836,7 +1841,7 @@ xmlSchemaFormatFacetEnumSet(xmlSchemaAbstractCtxtPtr actxt,
/************************************************************************
* *
- * Error functions *
+ * Error functions *
* *
************************************************************************/
@@ -1881,7 +1886,7 @@ xmlSchemaPErrMemory(xmlSchemaParserCtxtPtr ctxt,
* @msg: the error message
* @str1: extra data
* @str2: extra data
- *
+ *
* Handle a parser error
*/
static void
@@ -1914,7 +1919,7 @@ xmlSchemaPErr(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
* @msg: the error message
* @str1: extra data
* @str2: extra data
- *
+ *
* Handle a parser error
*/
static void
@@ -1933,7 +1938,7 @@ xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
* xmlSchemaPErrExt:
* @ctxt: the parsing context
* @node: the context node
- * @error: the error code
+ * @error: the error code
* @strData1: extra data
* @strData2: extra data
* @strData3: extra data
@@ -1943,13 +1948,13 @@ xmlSchemaPErr2(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
* @str3: extra parameter for the message display
* @str4: extra parameter for the message display
* @str5: extra parameter for the message display
- *
+ *
* Handle a parser error
*/
static void
xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
- const xmlChar * strData1, const xmlChar * strData2,
- const xmlChar * strData3, const char *msg, const xmlChar * str1,
+ const xmlChar * strData1, const xmlChar * strData2,
+ const xmlChar * strData3, const char *msg, const xmlChar * str1,
const xmlChar * str2, const xmlChar * str3, const xmlChar * str4,
const xmlChar * str5)
{
@@ -1967,14 +1972,14 @@ xmlSchemaPErrExt(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node, int error,
}
__xmlRaiseError(schannel, channel, data, ctxt, node, XML_FROM_SCHEMASP,
error, XML_ERR_ERROR, NULL, 0,
- (const char *) strData1, (const char *) strData2,
- (const char *) strData3, 0, 0, msg, str1, str2,
+ (const char *) strData1, (const char *) strData2,
+ (const char *) strData3, 0, 0, msg, str1, str2,
str3, str4, str5);
}
/************************************************************************
* *
- * Allround error functions *
+ * Allround error functions *
* *
************************************************************************/
@@ -2016,7 +2021,7 @@ xmlSchemaPSimpleInternalErr(xmlNodePtr node,
* @str1: extra data
* @str2: extra data
* @str3: extra data
- *
+ *
* Handle a validation error
*/
static void
@@ -2028,16 +2033,17 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
{
xmlStructuredErrorFunc schannel = NULL;
xmlGenericErrorFunc channel = NULL;
- void *data = NULL;
-
+ void *data = NULL;
+
if (ctxt != NULL) {
if (ctxt->type == XML_SCHEMA_CTXT_VALIDATOR) {
xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctxt;
const char *file = NULL;
+ int col = 0;
if (errorLevel != XML_ERR_WARNING) {
vctxt->nberrors++;
vctxt->err = error;
- channel = vctxt->error;
+ channel = vctxt->error;
} else {
channel = vctxt->warning;
}
@@ -2062,6 +2068,7 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
(vctxt->parserCtxt->input != NULL)) {
file = vctxt->parserCtxt->input->filename;
line = vctxt->parserCtxt->input->line;
+ col = vctxt->parserCtxt->input->col;
}
} else {
/*
@@ -2077,19 +2084,33 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
else if ((vctxt->parserCtxt != NULL) &&
(vctxt->parserCtxt->input != NULL))
file = vctxt->parserCtxt->input->filename;
- }
+ }
+ if (vctxt->locFunc != NULL) {
+ if ((file == NULL) || (line == 0)) {
+ unsigned long l;
+ const char *f;
+ vctxt->locFunc(vctxt->locCtxt, &f, &l);
+ if (file == NULL)
+ file = f;
+ if (line == 0)
+ line = (int) l;
+ }
+ }
+ if ((file == NULL) && (vctxt->filename != NULL))
+ file = vctxt->filename;
+
__xmlRaiseError(schannel, channel, data, ctxt,
node, XML_FROM_SCHEMASV,
error, errorLevel, file, line,
(const char *) str1, (const char *) str2,
- (const char *) str3, 0, 0, msg, str1, str2, str3, str4);
+ (const char *) str3, 0, col, msg, str1, str2, str3, str4);
} else if (ctxt->type == XML_SCHEMA_CTXT_PARSER) {
xmlSchemaParserCtxtPtr pctxt = (xmlSchemaParserCtxtPtr) ctxt;
if (errorLevel != XML_ERR_WARNING) {
pctxt->nberrors++;
pctxt->err = error;
- channel = pctxt->error;
+ channel = pctxt->error;
} else {
channel = pctxt->warning;
}
@@ -2115,11 +2136,11 @@ xmlSchemaErr4Line(xmlSchemaAbstractCtxtPtr ctxt,
* @str1: extra data
* @str2: extra data
* @str3: extra data
- *
+ *
* Handle a validation error
*/
static void
-xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt,
+xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt,
int error, xmlNodePtr node, const char *msg,
const xmlChar *str1, const xmlChar *str2, const xmlChar *str3)
{
@@ -2128,7 +2149,7 @@ xmlSchemaErr3(xmlSchemaAbstractCtxtPtr actxt,
}
static void
-xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt,
+xmlSchemaErr4(xmlSchemaAbstractCtxtPtr actxt,
int error, xmlNodePtr node, const char *msg,
const xmlChar *str1, const xmlChar *str2,
const xmlChar *str3, const xmlChar *str4)
@@ -2157,7 +2178,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
(node->type != XML_ELEMENT_NODE) &&
(node->type != XML_ATTRIBUTE_NODE))
{
- /*
+ /*
* Don't try to format other nodes than element and
* attribute nodes.
* Play save and return an empty string.
@@ -2171,7 +2192,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
*/
if (node->type == XML_ATTRIBUTE_NODE) {
xmlNodePtr elem = node->parent;
-
+
*msg = xmlStrdup(BAD_CAST "Element '");
if (elem->ns != NULL)
*msg = xmlStrcat(*msg, xmlSchemaFormatQName(&str,
@@ -2181,7 +2202,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
NULL, elem->name));
FREE_AND_NULL(str);
*msg = xmlStrcat(*msg, BAD_CAST "', ");
- *msg = xmlStrcat(*msg, BAD_CAST "attribute '");
+ *msg = xmlStrcat(*msg, BAD_CAST "attribute '");
} else {
*msg = xmlStrdup(BAD_CAST "Element '");
}
@@ -2197,7 +2218,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) actxt;
/*
* Work on node infos.
- */
+ */
if (vctxt->inode->nodeType == XML_ATTRIBUTE_NODE) {
xmlSchemaNodeInfoPtr ielem =
vctxt->elemInfos[vctxt->depth];
@@ -2207,7 +2228,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
ielem->nsName, ielem->localName));
FREE_AND_NULL(str);
*msg = xmlStrcat(*msg, BAD_CAST "', ");
- *msg = xmlStrcat(*msg, BAD_CAST "attribute '");
+ *msg = xmlStrcat(*msg, BAD_CAST "attribute '");
} else {
*msg = xmlStrdup(BAD_CAST "Element '");
}
@@ -2216,7 +2237,7 @@ xmlSchemaFormatNodeForError(xmlChar ** msg,
FREE_AND_NULL(str);
*msg = xmlStrcat(*msg, BAD_CAST "': ");
} else if (actxt->type == XML_SCHEMA_CTXT_PARSER) {
- /*
+ /*
* Hmm, no node while parsing?
* Return an empty string, in case NULL will break something.
*/
@@ -2254,7 +2275,7 @@ xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt,
return;
msg = xmlStrdup(BAD_CAST "Internal error: ");
msg = xmlStrcat(msg, BAD_CAST funcName);
- msg = xmlStrcat(msg, BAD_CAST ", ");
+ msg = xmlStrcat(msg, BAD_CAST ", ");
msg = xmlStrcat(msg, BAD_CAST message);
msg = xmlStrcat(msg, BAD_CAST ".\n");
@@ -2262,7 +2283,7 @@ xmlSchemaInternalErr2(xmlSchemaAbstractCtxtPtr actxt,
xmlSchemaErr(actxt, XML_SCHEMAV_INTERNAL, NULL,
(const char *) msg, str1, str2);
- else if (actxt->type == XML_SCHEMA_CTXT_PARSER)
+ else if (actxt->type == XML_SCHEMA_CTXT_PARSER)
xmlSchemaErr(actxt, XML_SCHEMAP_INTERNAL, NULL,
(const char *) msg, str1, str2);
@@ -2309,7 +2330,7 @@ xmlSchemaCustomErr4(xmlSchemaAbstractCtxtPtr actxt,
} else
xmlSchemaFormatNodeForError(&msg, actxt, node);
msg = xmlStrcat(msg, (const xmlChar *) message);
- msg = xmlStrcat(msg, BAD_CAST ".\n");
+ msg = xmlStrcat(msg, BAD_CAST ".\n");
xmlSchemaErr4(actxt, error, node,
(const char *) msg, str1, str2, str3, str4);
FREE_AND_NULL(msg)
@@ -2325,7 +2346,7 @@ xmlSchemaCustomErr(xmlSchemaAbstractCtxtPtr actxt,
const xmlChar *str2)
{
xmlSchemaCustomErr4(actxt, error, node, item,
- message, str1, str2, NULL, NULL);
+ message, str1, str2, NULL, NULL);
}
@@ -2344,8 +2365,8 @@ xmlSchemaCustomWarning(xmlSchemaAbstractCtxtPtr actxt,
xmlSchemaFormatNodeForError(&msg, actxt, node);
msg = xmlStrcat(msg, (const xmlChar *) message);
- msg = xmlStrcat(msg, BAD_CAST ".\n");
-
+ msg = xmlStrcat(msg, BAD_CAST ".\n");
+
/* URGENT TODO: Set the error code to something sane. */
xmlSchemaErr4Line(actxt, XML_ERR_WARNING, error, node, 0,
(const char *) msg, str1, str2, str3, NULL);
@@ -2365,15 +2386,15 @@ xmlSchemaKeyrefErr(xmlSchemaValidCtxtPtr vctxt,
const xmlChar *str2)
{
xmlChar *msg = NULL, *qname = NULL;
-
- msg = xmlStrdup(BAD_CAST "Element '%s': ");
+
+ msg = xmlStrdup(BAD_CAST "Element '%s': ");
msg = xmlStrcat(msg, (const xmlChar *) message);
msg = xmlStrcat(msg, BAD_CAST ".\n");
xmlSchemaErr4Line(ACTXT_CAST vctxt, XML_ERR_ERROR,
error, NULL, idcNode->nodeLine, (const char *) msg,
xmlSchemaFormatQName(&qname,
vctxt->nodeQNames->items[idcNode->nodeQNameID +1],
- vctxt->nodeQNames->items[idcNode->nodeQNameID]),
+ vctxt->nodeQNames->items[idcNode->nodeQNameID]),
str1, str2, NULL);
FREE_AND_NULL(qname);
FREE_AND_NULL(msg);
@@ -2456,7 +2477,7 @@ xmlSchemaSimpleTypeErr(xmlSchemaAbstractCtxtPtr actxt,
if (type->builtInType != 0) {
msg = xmlStrcat(msg, BAD_CAST "xs:");
msg = xmlStrcat(msg, type->name);
- } else
+ } else
msg = xmlStrcat(msg,
xmlSchemaFormatQName(&str,
type->targetNamespace, type->name));
@@ -2494,12 +2515,12 @@ xmlSchemaIllegalAttrErr(xmlSchemaAbstractCtxtPtr actxt,
xmlNodePtr node)
{
xmlChar *msg = NULL, *str = NULL;
-
+
xmlSchemaFormatNodeForError(&msg, actxt, node);
msg = xmlStrcat(msg, BAD_CAST "The attribute '%s' is not allowed.\n");
xmlSchemaErr(actxt, error, node, (const char *) msg,
xmlSchemaFormatErrorNodeQName(&str, (xmlSchemaNodeInfoPtr) ni, node),
- NULL);
+ NULL);
FREE_AND_NULL(str)
FREE_AND_NULL(msg)
}
@@ -2518,7 +2539,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
xmlChar *localName, *nsName;
const xmlChar *cur, *end;
int i;
-
+
xmlSchemaFormatNodeForError(&msg, actxt, node);
msg = xmlStrcat(msg, (const xmlChar *) message);
msg = xmlStrcat(msg, BAD_CAST ".");
@@ -2533,7 +2554,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
} else
str = xmlStrdup(BAD_CAST " Expected is ( ");
nsName = NULL;
-
+
for (i = 0; i < nbval + nbneg; i++) {
cur = values[i];
if (cur == NULL)
@@ -2547,7 +2568,7 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
* Get the local name.
*/
localName = NULL;
-
+
end = cur;
if (*end == '*') {
localName = xmlStrdup(BAD_CAST "*");
@@ -2556,8 +2577,8 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
while ((*end != 0) && (*end != '|'))
end++;
localName = xmlStrncat(localName, BAD_CAST cur, end - cur);
- }
- if (*end != 0) {
+ }
+ if (*end != 0) {
end++;
/*
* Skip "*|*" if they come with negated expressions, since
@@ -2573,12 +2594,12 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
} else {
while (*end != 0)
end++;
-
+
if (i >= nbval)
nsName = xmlStrdup(BAD_CAST "{##other:");
else
nsName = xmlStrdup(BAD_CAST "{");
-
+
nsName = xmlStrncat(nsName, BAD_CAST cur, end - cur);
nsName = xmlStrcat(nsName, BAD_CAST "}");
}
@@ -2588,13 +2609,13 @@ xmlSchemaComplexTypeErr(xmlSchemaAbstractCtxtPtr actxt,
FREE_AND_NULL(localName);
continue;
}
- }
+ }
str = xmlStrcat(str, BAD_CAST localName);
FREE_AND_NULL(localName);
-
+
if (i < nbval + nbneg -1)
str = xmlStrcat(str, BAD_CAST ", ");
- }
+ }
str = xmlStrcat(str, BAD_CAST " ).\n");
msg = xmlStrcat(msg, BAD_CAST str);
FREE_AND_NULL(str)
@@ -2626,8 +2647,8 @@ xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt,
/*
* If enumerations are validated, one must not expect the
* facet to be given.
- */
- } else
+ */
+ } else
facetType = facet->type;
msg = xmlStrcat(msg, BAD_CAST "[");
msg = xmlStrcat(msg, BAD_CAST "facet '");
@@ -2655,31 +2676,31 @@ xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt,
snprintf(actLen, 24, "%lu", length);
if (facetType == XML_SCHEMA_FACET_LENGTH)
- msg = xmlStrcat(msg,
- BAD_CAST "this differs from the allowed length of '%s'.\n");
+ msg = xmlStrcat(msg,
+ BAD_CAST "this differs from the allowed length of '%s'.\n");
else if (facetType == XML_SCHEMA_FACET_MAXLENGTH)
- msg = xmlStrcat(msg,
+ msg = xmlStrcat(msg,
BAD_CAST "this exceeds the allowed maximum length of '%s'.\n");
else if (facetType == XML_SCHEMA_FACET_MINLENGTH)
- msg = xmlStrcat(msg,
+ msg = xmlStrcat(msg,
BAD_CAST "this underruns the allowed minimum length of '%s'.\n");
-
+
if (nodeType == XML_ATTRIBUTE_NODE)
xmlSchemaErr3(actxt, error, node, (const char *) msg,
value, (const xmlChar *) actLen, (const xmlChar *) len);
- else
+ else
xmlSchemaErr(actxt, error, node, (const char *) msg,
(const xmlChar *) actLen, (const xmlChar *) len);
-
+
} else if (facetType == XML_SCHEMA_FACET_ENUMERATION) {
msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not an element "
"of the set {%s}.\n");
- xmlSchemaErr(actxt, error, node, (const char *) msg, value,
+ xmlSchemaErr(actxt, error, node, (const char *) msg, value,
xmlSchemaFormatFacetEnumSet(actxt, &str, type));
} else if (facetType == XML_SCHEMA_FACET_PATTERN) {
msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not accepted "
"by the pattern '%s'.\n");
- xmlSchemaErr(actxt, error, node, (const char *) msg, value,
+ xmlSchemaErr(actxt, error, node, (const char *) msg, value,
facet->value);
} else if (facetType == XML_SCHEMA_FACET_MININCLUSIVE) {
msg = xmlStrcat(msg, BAD_CAST "The value '%s' is less than the "
@@ -2711,10 +2732,10 @@ xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt,
"digits than are allowed ('%s').\n");
xmlSchemaErr(actxt, error, node, (const char*) msg, value,
facet->value);
- } else if (nodeType == XML_ATTRIBUTE_NODE) {
+ } else if (nodeType == XML_ATTRIBUTE_NODE) {
msg = xmlStrcat(msg, BAD_CAST "The value '%s' is not facet-valid.\n");
- xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL);
- } else {
+ xmlSchemaErr(actxt, error, node, (const char *) msg, value, NULL);
+ } else {
msg = xmlStrcat(msg, BAD_CAST "The value is not facet-valid.\n");
xmlSchemaErr(actxt, error, node, (const char *) msg, NULL, NULL);
}
@@ -2722,7 +2743,7 @@ xmlSchemaFacetErr(xmlSchemaAbstractCtxtPtr actxt,
msg = xmlStrcat(msg, (const xmlChar *) message);
msg = xmlStrcat(msg, BAD_CAST ".\n");
xmlSchemaErr(actxt, error, node, (const char *) msg, str1, str2);
- }
+ }
FREE_AND_NULL(str)
xmlFree(msg);
}
@@ -2967,9 +2988,9 @@ xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt,
const xmlChar *str3,const xmlChar *str4)
{
xmlChar *str = NULL, *msg = NULL;
-
+
xmlSchemaFormatItemForReport(&msg, NULL, ownerItem, NULL);
- msg = xmlStrcat(msg, BAD_CAST ", ");
+ msg = xmlStrcat(msg, BAD_CAST ", ");
msg = xmlStrcat(msg,
BAD_CAST xmlSchemaFormatItemForReport(&str, NULL,
WXS_BASIC_CAST attruse, NULL));
@@ -2977,7 +2998,7 @@ xmlSchemaPAttrUseErr4(xmlSchemaParserCtxtPtr ctxt,
msg = xmlStrcat(msg, BAD_CAST ": ");
msg = xmlStrcat(msg, (const xmlChar *) message);
msg = xmlStrcat(msg, BAD_CAST ".\n");
- xmlSchemaErr4(ACTXT_CAST ctxt, error, node,
+ xmlSchemaErr4(ACTXT_CAST ctxt, error, node,
(const char *) msg, str1, str2, str3, str4);
xmlFree(msg);
}
@@ -3071,7 +3092,7 @@ xmlSchemaPMutualExclAttrErr(xmlSchemaParserCtxtPtr ctxt,
* @error: the error code
* @type: the type specifier
* @ownerDes: the designation of the owner
- * @ownerItem: the schema object if existent
+ * @ownerItem: the schema object if existent
* @node: the validated node
* @value: the validated value
*
@@ -3079,7 +3100,7 @@ xmlSchemaPMutualExclAttrErr(xmlSchemaParserCtxtPtr ctxt,
* TODO: Should this report the value of an element as well?
*/
static void
-xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
+xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
xmlParserErrors error,
xmlSchemaBasicItemPtr ownerItem ATTRIBUTE_UNUSED,
xmlNodePtr node,
@@ -3091,37 +3112,37 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
const xmlChar *str2)
{
xmlChar *msg = NULL;
-
+
xmlSchemaFormatNodeForError(&msg, ACTXT_CAST ctxt, node);
if (message == NULL) {
/*
* Use default messages.
- */
+ */
if (type != NULL) {
if (node->type == XML_ATTRIBUTE_NODE)
msg = xmlStrcat(msg, BAD_CAST "'%s' is not a valid value of ");
else
msg = xmlStrcat(msg, BAD_CAST "The character content is not a "
- "valid value of ");
+ "valid value of ");
if (! xmlSchemaIsGlobalItem(type))
msg = xmlStrcat(msg, BAD_CAST "the local ");
else
msg = xmlStrcat(msg, BAD_CAST "the ");
-
+
if (WXS_IS_ATOMIC(type))
msg = xmlStrcat(msg, BAD_CAST "atomic type");
else if (WXS_IS_LIST(type))
msg = xmlStrcat(msg, BAD_CAST "list type");
else if (WXS_IS_UNION(type))
msg = xmlStrcat(msg, BAD_CAST "union type");
-
+
if (xmlSchemaIsGlobalItem(type)) {
xmlChar *str = NULL;
msg = xmlStrcat(msg, BAD_CAST " '");
if (type->builtInType != 0) {
msg = xmlStrcat(msg, BAD_CAST "xs:");
msg = xmlStrcat(msg, type->name);
- } else
+ } else
msg = xmlStrcat(msg,
xmlSchemaFormatQName(&str,
type->targetNamespace, type->name));
@@ -3134,7 +3155,7 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
else
msg = xmlStrcat(msg, BAD_CAST "The character content is not "
"valid.");
- }
+ }
if (expected) {
msg = xmlStrcat(msg, BAD_CAST " Expected is '");
msg = xmlStrcat(msg, BAD_CAST expected);
@@ -3151,7 +3172,7 @@ xmlSchemaPSimpleTypeErr(xmlSchemaParserCtxtPtr ctxt,
xmlSchemaPErrExt(ctxt, node, error, NULL, NULL, NULL,
(const char*) msg, str1, str2, NULL, NULL, NULL);
}
- /* Cleanup. */
+ /* Cleanup. */
FREE_AND_NULL(msg)
}
@@ -3199,25 +3220,25 @@ xmlSchemaPContentErr(xmlSchemaParserCtxtPtr ctxt,
}
/************************************************************************
- * *
- * Streamable error functions *
- * *
+ * *
+ * Streamable error functions *
+ * *
************************************************************************/
/************************************************************************
- * *
- * Validation helper functions *
- * *
+ * *
+ * Validation helper functions *
+ * *
************************************************************************/
/************************************************************************
- * *
- * Allocation functions *
- * *
+ * *
+ * Allocation functions *
+ * *
************************************************************************/
/**
@@ -3372,7 +3393,7 @@ xmlSchemaItemListAddSize(xmlSchemaItemListPtr list,
static int
xmlSchemaItemListInsert(xmlSchemaItemListPtr list, void *item, int idx)
-{
+{
if (list->items == NULL) {
list->items = (void **) xmlMalloc(
20 * sizeof(void *));
@@ -3412,7 +3433,7 @@ xmlSchemaItemListInsertSize(xmlSchemaItemListPtr list,
int initialSize,
void *item,
int idx)
-{
+{
if (list->items == NULL) {
if (initialSize <= 0)
initialSize = 1;
@@ -3467,7 +3488,7 @@ xmlSchemaItemListRemove(xmlSchemaItemListPtr list, int idx)
list->sizeItems = 0;
} else if (list->nbItems -1 == idx) {
list->nbItems--;
- } else {
+ } else {
for (i = idx; i < list->nbItems -1; i++)
list->items[i] = list->items[i+1];
list->nbItems--;
@@ -3502,19 +3523,19 @@ xmlSchemaBucketFree(xmlSchemaBucketPtr bucket)
}
if (bucket->locals != NULL) {
xmlSchemaComponentListFree(bucket->locals);
- xmlSchemaItemListFree(bucket->locals);
+ xmlSchemaItemListFree(bucket->locals);
}
if (bucket->relations != NULL) {
xmlSchemaSchemaRelationPtr prev, cur = bucket->relations;
do {
- prev = cur;
+ prev = cur;
cur = cur->next;
xmlFree(prev);
} while (cur != NULL);
}
if ((! bucket->preserveDoc) && (bucket->doc != NULL)) {
xmlFreeDoc(bucket->doc);
- }
+ }
if (bucket->type == XML_SCHEMA_SCHEMA_IMPORT) {
if (WXS_IMPBUCKET(bucket)->schema != NULL)
xmlSchemaFree(WXS_IMPBUCKET(bucket)->schema);
@@ -3559,7 +3580,7 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
xmlFree(ret);
return(NULL);
}
- /*
+ /*
* The following will assure that only the first bucket is marked as
* XML_SCHEMA_SCHEMA_MAIN and it points to the *main* schema.
* For each following import buckets an xmlSchema will be created.
@@ -3573,7 +3594,7 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaBucketFree(ret);
return(NULL);
}
- /* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */
+ /* Force the type to be XML_SCHEMA_SCHEMA_MAIN. */
ret->type = XML_SCHEMA_SCHEMA_MAIN;
/* Point to the *main* schema. */
WXS_CONSTRUCTOR(pctxt)->mainBucket = ret;
@@ -3583,12 +3604,12 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
*/
mainSchema->targetNamespace = targetNamespace;
} else {
- if (type == XML_SCHEMA_SCHEMA_MAIN) {
+ if (type == XML_SCHEMA_SCHEMA_MAIN) {
PERROR_INT("xmlSchemaBucketCreate",
"main bucket but it's not the first one");
xmlSchemaBucketFree(ret);
return(NULL);
- } else if (type == XML_SCHEMA_SCHEMA_IMPORT) {
+ } else if (type == XML_SCHEMA_SCHEMA_IMPORT) {
/*
* Create a schema for imports and assign the
* targetNamespace.
@@ -3600,7 +3621,7 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
}
WXS_IMPBUCKET(ret)->schema->targetNamespace = targetNamespace;
}
- }
+ }
if (WXS_IS_BUCKET_IMPMAIN(type)) {
int res;
/*
@@ -3643,11 +3664,11 @@ xmlSchemaBucketCreate(xmlSchemaParserCtxtPtr pctxt,
if (mainSchema->includes == NULL) {
xmlSchemaBucketFree(ret);
return(NULL);
- }
+ }
}
xmlSchemaItemListAdd(mainSchema->includes, ret);
}
- /*
+ /*
* Add to list of all buckets; this is used for lookup
* during schema construction time only.
*/
@@ -4015,7 +4036,7 @@ xmlSchemaComponentListFree(xmlSchemaItemListPtr list)
for (i = 0; i < list->nbItems; i++) {
item = items[i];
if (item == NULL)
- continue;
+ continue;
switch (item->type) {
case XML_SCHEMA_TYPE_SIMPLE:
case XML_SCHEMA_TYPE_COMPLEX:
@@ -4122,7 +4143,7 @@ xmlSchemaFree(xmlSchemaPtr schema)
xmlSchemaItemListPtr list = (xmlSchemaItemListPtr) schema->includes;
int i;
for (i = 0; i < list->nbItems; i++) {
- xmlSchemaBucketFree((xmlSchemaBucketPtr) list->items[i]);
+ xmlSchemaBucketFree((xmlSchemaBucketPtr) list->items[i]);
}
xmlSchemaItemListFree(list);
}
@@ -4135,9 +4156,9 @@ xmlSchemaFree(xmlSchemaPtr schema)
}
/************************************************************************
- * *
- * Debug functions *
- * *
+ * *
+ * Debug functions *
+ * *
************************************************************************/
#ifdef LIBXML_OUTPUT_ENABLED
@@ -4274,7 +4295,7 @@ xmlSchemaContentModelDump(xmlSchemaParticlePtr particle, FILE * output, int dept
for (i = 0;((i < depth) && (i < 25));i++)
shift[2 * i] = shift[2 * i + 1] = ' ';
shift[2 * i] = shift[2 * i + 1] = 0;
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
if (particle->children == NULL) {
fprintf(output, "MISSING particle term\n");
return;
@@ -4330,7 +4351,7 @@ xmlSchemaContentModelDump(xmlSchemaParticlePtr particle, FILE * output, int dept
/**
* xmlSchemaAttrUsesDump:
* @uses: attribute uses list
- * @output: the file output
+ * @output: the file output
*
* Dumps a list of attribute use components.
*/
@@ -4347,7 +4368,7 @@ xmlSchemaAttrUsesDump(xmlSchemaItemListPtr uses, FILE * output)
if ((uses == NULL) || (uses->nbItems == 0))
return;
- fprintf(output, " attributes:\n");
+ fprintf(output, " attributes:\n");
for (i = 0; i < uses->nbItems; i++) {
use = uses->items[i];
if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
@@ -4533,7 +4554,7 @@ xmlSchemaDebugDumpIDCTable(FILE * output,
return;
do {
fprintf(output, "IDC: BINDING '%s' (%d)\n",
- xmlSchemaGetComponentQName(&str,
+ xmlSchemaGetComponentQName(&str,
bind->definition), bind->nbNodes);
FREE_AND_NULL(str)
for (i = 0; i < bind->nbNodes; i++) {
@@ -4587,7 +4608,7 @@ xmlSchemaDebugDumpIDCTable(FILE * output,
/************************************************************************
* *
- * Utilities *
+ * Utilities *
* *
************************************************************************/
@@ -4634,7 +4655,7 @@ xmlSchemaGetPropNodeNs(xmlNodePtr node, const char *uri, const char *name)
xmlAttrPtr prop;
if ((node == NULL) || (name == NULL))
- return(NULL);
+ return(NULL);
prop = node->properties;
while (prop != NULL) {
if ((prop->ns != NULL) &&
@@ -4692,9 +4713,9 @@ xmlSchemaGetProp(xmlSchemaParserCtxtPtr ctxt, xmlNodePtr node,
}
/************************************************************************
- * *
- * Parsing functions *
- * *
+ * *
+ * Parsing functions *
+ * *
************************************************************************/
#define WXS_FIND_GLOBAL_ITEM(slot) \
@@ -4729,12 +4750,12 @@ xmlSchemaGetElem(xmlSchemaPtr schema, const xmlChar * name,
const xmlChar * nsName)
{
xmlSchemaElementPtr ret = NULL;
-
+
if ((name == NULL) || (schema == NULL))
return(NULL);
if (schema != NULL) {
WXS_FIND_GLOBAL_ITEM(elemDecl)
- }
+ }
exit:
#ifdef DEBUG
if (ret == NULL) {
@@ -4765,9 +4786,9 @@ xmlSchemaGetType(xmlSchemaPtr schema, const xmlChar * name,
xmlSchemaTypePtr ret = NULL;
if (name == NULL)
- return (NULL);
+ return (NULL);
/* First try the built-in types. */
- if ((nsName != NULL) && xmlStrEqual(nsName, xmlSchemaNs)) {
+ if ((nsName != NULL) && xmlStrEqual(nsName, xmlSchemaNs)) {
ret = xmlSchemaGetPredefinedType(name, nsName);
if (ret != NULL)
goto exit;
@@ -4780,7 +4801,7 @@ xmlSchemaGetType(xmlSchemaPtr schema, const xmlChar * name,
}
if (schema != NULL) {
WXS_FIND_GLOBAL_ITEM(typeDecl)
- }
+ }
exit:
#ifdef DEBUG
@@ -4891,7 +4912,7 @@ xmlSchemaGetGroup(xmlSchemaPtr schema, const xmlChar * name,
WXS_FIND_GLOBAL_ITEM(groupDecl)
}
exit:
-
+
#ifdef DEBUG
if (ret == NULL) {
if (nsName == NULL)
@@ -4966,9 +4987,9 @@ xmlSchemaGetNamedComponent(xmlSchemaPtr schema,
}
/************************************************************************
- * *
- * Parsing functions *
- * *
+ * *
+ * Parsing functions *
+ * *
************************************************************************/
#define IS_BLANK_NODE(n) \
@@ -5000,7 +5021,7 @@ xmlSchemaIsBlank(xmlChar * str, int len)
str++;
len--;
}
-
+
return (1);
}
@@ -5061,7 +5082,7 @@ xmlSchemaFindRedefCompInGraph(xmlSchemaBucketPtr bucket,
default:
/* Should not be hit. */
return(NULL);
- }
+ }
}
}
subschemas:
@@ -5209,7 +5230,7 @@ xmlSchemaAddAttributeUse(xmlSchemaParserCtxtPtr pctxt,
* resolve references to the redefined components and to check constraints.
*/
static xmlSchemaRedefPtr
-xmlSchemaAddRedef(xmlSchemaParserCtxtPtr pctxt,
+xmlSchemaAddRedef(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaBucketPtr targetBucket,
void *item,
const xmlChar *refName,
@@ -5272,7 +5293,7 @@ xmlSchemaAddAttributeGroupDefinition(xmlSchemaParserCtxtPtr pctxt,
ret->type = XML_SCHEMA_TYPE_ATTRIBUTEGROUP;
ret->name = name;
ret->targetNamespace = nsName;
- ret->node = node;
+ ret->node = node;
/* TODO: Remove the flag. */
ret->flags |= XML_SCHEMAS_ATTRGROUP_GLOBAL;
@@ -5282,7 +5303,7 @@ xmlSchemaAddAttributeGroupDefinition(xmlSchemaParserCtxtPtr pctxt,
if (pctxt->redef == NULL) {
xmlFree(ret);
return(NULL);
- }
+ }
pctxt->redefCounter = 0;
}
WXS_ADD_GLOBAL(pctxt, ret);
@@ -5371,13 +5392,13 @@ xmlSchemaAddType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
if (ctxt->redef == NULL) {
xmlFree(ret);
return(NULL);
- }
+ }
ctxt->redefCounter = 0;
}
WXS_ADD_GLOBAL(ctxt, ret);
} else
WXS_ADD_LOCAL(ctxt, ret);
- WXS_ADD_PENDING(ctxt, ret);
+ WXS_ADD_PENDING(ctxt, ret);
return (ret);
}
@@ -5509,7 +5530,7 @@ xmlSchemaAddParticle(xmlSchemaParserCtxtPtr ctxt,
ret->children = NULL;
WXS_ADD_LOCAL(ctxt, ret);
- /*
+ /*
* Note that addition to pending components will be done locally
* to the specific parsing function, since the most particles
* need not to be fixed up (i.e. the reference to be resolved).
@@ -5558,7 +5579,7 @@ xmlSchemaAddModelGroupDefinition(xmlSchemaParserCtxtPtr ctxt,
if (ctxt->redef == NULL) {
xmlFree(ret);
return(NULL);
- }
+ }
ctxt->redefCounter = 0;
}
WXS_ADD_GLOBAL(ctxt, ret);
@@ -5595,7 +5616,7 @@ xmlSchemaAddIDC(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
const xmlChar *name, const xmlChar *nsName,
int category, xmlNodePtr node)
{
- xmlSchemaIDCPtr ret = NULL;
+ xmlSchemaIDCPtr ret = NULL;
if ((ctxt == NULL) || (schema == NULL) || (name == NULL))
return (NULL);
@@ -5611,8 +5632,8 @@ xmlSchemaAddIDC(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
ret->targetNamespace = nsName;
ret->name = name;
ret->type = category;
- ret->node = node;
-
+ ret->node = node;
+
WXS_ADD_GLOBAL(ctxt, ret);
/*
* Only keyrefs need to be fixup up.
@@ -5648,7 +5669,7 @@ xmlSchemaAddWildcard(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
}
memset(ret, 0, sizeof(xmlSchemaWildcard));
ret->type = type;
- ret->node = node;
+ ret->node = node;
WXS_ADD_LOCAL(ctxt, ret);
return (ret);
}
@@ -5704,7 +5725,7 @@ xmlSchemaSubstGroupAdd(xmlSchemaParserCtxtPtr pctxt,
static xmlSchemaSubstGroupPtr
xmlSchemaSubstGroupGet(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaElementPtr head)
-{
+{
if (WXS_SUBST_GROUPS(pctxt) == NULL)
return(NULL);
return(xmlHashLookup2(WXS_SUBST_GROUPS(pctxt),
@@ -5743,9 +5764,9 @@ xmlSchemaAddElementSubstitutionMember(xmlSchemaParserCtxtPtr pctxt,
}
/************************************************************************
- * *
+ * *
* Utilities for parsing *
- * *
+ * *
************************************************************************/
/**
@@ -5939,7 +5960,7 @@ xmlSchemaPValAttrNodeID(xmlSchemaParserCtxtPtr ctxt, xmlAttrPtr attr)
xmlFree((xmlChar *) value);
value = strip;
}
- res = xmlAddID(NULL, attr->doc, value, attr);
+ res = xmlAddID(NULL, attr->doc, value, attr);
if (res == NULL) {
ret = XML_SCHEMAP_S4S_ATTR_INVALID_VALUE;
xmlSchemaPSimpleTypeErr(ctxt,
@@ -6120,7 +6141,7 @@ xmlSchemaPGetBoolNodeValue(xmlSchemaParserCtxtPtr ctxt,
value = xmlNodeGetContent(node);
/*
* 3.2.2.1 Lexical representation
- * An instance of a datatype that is defined as ·boolean·
+ * An instance of a datatype that is defined as `boolean`
* can have the following legal literals {true, false, 1, 0}.
*/
if (xmlStrEqual(BAD_CAST value, BAD_CAST "true"))
@@ -6168,7 +6189,7 @@ xmlGetBooleanProp(xmlSchemaParserCtxtPtr ctxt,
return (def);
/*
* 3.2.2.1 Lexical representation
- * An instance of a datatype that is defined as ·boolean·
+ * An instance of a datatype that is defined as `boolean`
* can have the following legal literals {true, false, 1, 0}.
*/
if (xmlStrEqual(val, BAD_CAST "true"))
@@ -6191,9 +6212,9 @@ xmlGetBooleanProp(xmlSchemaParserCtxtPtr ctxt,
}
/************************************************************************
- * *
+ * *
* Shema extraction from an Infoset *
- * *
+ * *
************************************************************************/
static xmlSchemaTypePtr xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr
ctxt, xmlSchemaPtr schema,
@@ -6288,7 +6309,7 @@ xmlSchemaPValAttrNodeValue(xmlSchemaParserCtxtPtr pctxt,
ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
else
ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
- xmlSchemaPSimpleTypeErr(pctxt,
+ xmlSchemaPSimpleTypeErr(pctxt,
ret, ownerItem, (xmlNodePtr) attr,
type, NULL, value, NULL, NULL, NULL);
}
@@ -6352,7 +6373,7 @@ xmlSchemaPValAttrNode(xmlSchemaParserCtxtPtr ctxt,
* number otherwise and -1 in case of an internal or API error.
*/
static int
-xmlSchemaPValAttr(xmlSchemaParserCtxtPtr ctxt,
+xmlSchemaPValAttr(xmlSchemaParserCtxtPtr ctxt,
xmlSchemaBasicItemPtr ownerItem,
xmlNodePtr ownerElem,
const char *name,
@@ -6442,7 +6463,7 @@ xmlSchemaCheckReference(xmlSchemaParserCtxtPtr pctxt,
* @type: the hosting type where the attributes will be anchored
*
* Parses attribute uses and attribute declarations and
- * attribute group references.
+ * attribute group references.
*/
static int
xmlSchemaParseLocalAttributes(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
@@ -6797,7 +6818,7 @@ xmlSchemaParseWildcardNs(xmlSchemaParserCtxtPtr ctxt,
tmp->next = NULL;
if (wildc->nsSet == NULL)
wildc->nsSet = tmp;
- else
+ else if (lastNs != NULL)
lastNs->next = tmp;
lastNs = tmp;
}
@@ -7085,7 +7106,7 @@ xmlSchemaParseLocalAttribute(xmlSchemaParserCtxtPtr pctxt,
int parentType)
{
const xmlChar *attrValue, *name = NULL, *ns = NULL;
- xmlSchemaAttributeUsePtr use = NULL;
+ xmlSchemaAttributeUsePtr use = NULL;
xmlNodePtr child = NULL;
xmlAttrPtr attr;
const xmlChar *tmpNs = NULL, *tmpName = NULL, *defValue = NULL;
@@ -7139,7 +7160,7 @@ xmlSchemaParseLocalAttribute(xmlSchemaParserCtxtPtr pctxt,
/*
* Evaluate the target namespace
*/
- hasForm = 1;
+ hasForm = 1;
attrValue = xmlSchemaGetNodeContent(pctxt,
(xmlNodePtr) attr);
if (xmlStrEqual(attrValue, BAD_CAST "qualified")) {
@@ -7210,7 +7231,7 @@ xmlSchemaParseLocalAttribute(xmlSchemaParserCtxtPtr pctxt,
attr_next:
attr = attr->next;
- }
+ }
/*
* 3.2.3 : 2
* If default and use are both present, use must have
@@ -7236,7 +7257,7 @@ attr_next:
/* TODO: move XML_SCHEMAS_QUALIF_ATTR to the parser. */
if ((! hasForm) && (schema->flags & XML_SCHEMAS_QUALIF_ATTR))
- ns = pctxt->targetNamespace;
+ ns = pctxt->targetNamespace;
/*
* 3.2.6 Schema Component Constraint: xsi: Not Allowed
* TODO: Move this to the component layer.
@@ -7293,7 +7314,7 @@ attr_next:
use->attrDecl = attrDecl;
/*
* Value constraint.
- */
+ */
if (defValue != NULL) {
attrDecl->defValue = defValue;
if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
@@ -7333,14 +7354,14 @@ attr_next:
if (defValueType == WXS_ATTR_DEF_VAL_FIXED)
use->flags |= XML_SCHEMA_ATTR_USE_FIXED;
}
-
+
check_children:
/*
* And now for the children...
*/
child = node->children;
if (occurs == XML_SCHEMAS_ATTR_USE_PROHIBITED) {
- xmlSchemaAttributeUseProhibPtr prohib;
+ xmlSchemaAttributeUseProhibPtr prohib;
if (IS_SCHEMA(child, "annotation")) {
xmlSchemaParseAnnotation(pctxt, child, 0);
@@ -7355,7 +7376,7 @@ check_children:
/*
* Check for pointlessness of attribute prohibitions.
*/
- if (parentType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) {
+ if (parentType == XML_SCHEMA_TYPE_ATTRIBUTEGROUP) {
xmlSchemaCustomWarning(ACTXT_CAST pctxt,
XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH,
node, NULL,
@@ -7373,7 +7394,7 @@ check_children:
return(NULL);
}
if (! isRef) {
- tmpName = name;
+ tmpName = name;
tmpNs = ns;
}
/*
@@ -7381,7 +7402,7 @@ check_children:
*/
if (uses) {
int i;
-
+
for (i = 0; i < uses->nbItems; i++) {
use = uses->items[i];
if ((use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) &&
@@ -7389,16 +7410,16 @@ check_children:
(tmpNs == (WXS_ATTR_PROHIB_CAST use)->targetNamespace))
{
xmlChar *str = NULL;
-
+
xmlSchemaCustomWarning(ACTXT_CAST pctxt,
XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH,
node, NULL,
"Skipping duplicate attribute use prohibition '%s'",
xmlSchemaFormatQName(&str, tmpNs, tmpName),
NULL, NULL);
- FREE_AND_NULL(str)
+ FREE_AND_NULL(str)
return(NULL);
- }
+ }
}
}
/*
@@ -7417,7 +7438,7 @@ check_children:
WXS_ADD_PENDING(pctxt, prohib);
}
return(WXS_BASIC_CAST prohib);
- } else {
+ } else {
if (IS_SCHEMA(child, "annotation")) {
/*
* TODO: Should this go into the attr decl?
@@ -7464,7 +7485,7 @@ check_children:
NULL, node, child, NULL,
"(annotation?, simpleType?)");
}
- }
+ }
return (WXS_BASIC_CAST use);
}
@@ -7486,7 +7507,7 @@ xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt,
* 3.2.3 Constraints on XML Representations of Attribute Declarations
*/
if ((pctxt == NULL) || (schema == NULL) || (node == NULL))
- return (NULL);
+ return (NULL);
/*
* 3.2.3 : 3.1
* One of ref or name must be present, but not both
@@ -7532,7 +7553,7 @@ xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt,
if (ret == NULL)
return (NULL);
ret->flags |= XML_SCHEMAS_ATTR_GLOBAL;
-
+
/*
* Check for illegal attributes.
*/
@@ -7546,7 +7567,7 @@ xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt,
(!xmlStrEqual(attr->name, BAD_CAST "type")))
{
xmlSchemaPIllegalAttrErr(pctxt,
- XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
+ XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
}
} else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) {
xmlSchemaPIllegalAttrErr(pctxt,
@@ -7556,7 +7577,7 @@ xmlSchemaParseGlobalAttribute(xmlSchemaParserCtxtPtr pctxt,
}
xmlSchemaPValAttrQName(pctxt, schema, NULL,
node, "type", &ret->typeNs, &ret->typeName);
-
+
xmlSchemaPValAttrID(pctxt, node, BAD_CAST "id");
/*
* Attribute "fixed".
@@ -7641,12 +7662,12 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt,
XML_SCHEMAP_S4S_ATTR_MISSING,
NULL, node, "ref", NULL);
return (NULL);
- }
+ }
xmlSchemaPValAttrNodeQName(pctxt, schema,
NULL, attr, &refNs, &ref);
if (xmlSchemaCheckReference(pctxt, schema, node, attr, refNs) != 0)
return(NULL);
-
+
/*
* Check for illegal attributes.
*/
@@ -7698,13 +7719,13 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt,
/*
* SPEC src-redefine:
* (7.1) "If it has an <attributeGroup> among its contents
- * the ·actual value· of whose ref [attribute] is the same
- * as the ·actual value· of its own name attribute plus
+ * the `actual value` of whose ref [attribute] is the same
+ * as the `actual value` of its own name attribute plus
* target namespace, then it must have exactly one such group."
*/
if (pctxt->redefCounter != 0) {
xmlChar *str = NULL;
-
+
xmlSchemaCustomErr(ACTXT_CAST pctxt,
XML_SCHEMAP_SRC_REDEFINE, node, NULL,
"The redefining attribute group definition "
@@ -7738,7 +7759,7 @@ xmlSchemaParseAttributeGroupRef(xmlSchemaParserCtxtPtr pctxt,
ret->node = node;
/* Add to pending items, to be able to resolve the reference. */
WXS_ADD_PENDING(pctxt, ret);
- }
+ }
return (ret);
}
@@ -7785,7 +7806,7 @@ xmlSchemaParseAttributeGroupDefinition(xmlSchemaParserCtxtPtr pctxt,
ret = xmlSchemaAddAttributeGroupDefinition(pctxt, schema,
name, pctxt->targetNamespace, node);
if (ret == NULL)
- return (NULL);
+ return (NULL);
/*
* Check for illegal attributes.
*/
@@ -8185,7 +8206,7 @@ xmlSchemaAddAnnotation(xmlSchemaAnnotItemPtr annItem,
* Returns the parsed identity-constraint definition.
*/
static xmlSchemaIDCSelectPtr
-xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt,
+xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt,
xmlSchemaIDCPtr idc,
xmlNodePtr node,
int isField)
@@ -8227,7 +8248,7 @@ xmlSchemaParseIDCSelectorAndField(xmlSchemaParserCtxtPtr ctxt,
*/
attr = xmlSchemaGetPropNode(node, "xpath");
if (attr == NULL) {
- xmlSchemaPMissingAttrErr(ctxt,
+ xmlSchemaPMissingAttrErr(ctxt,
XML_SCHEMAP_S4S_ATTR_MISSING,
NULL, node,
"name", NULL);
@@ -8848,7 +8869,7 @@ xmlSchemaParseUnion(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
type->flags |= XML_SCHEMAS_TYPE_VARIETY_UNION;
/*
* SPEC (Base type) (2) "If the <list> or <union> alternative is chosen,
- * then the ·simple ur-type definition·."
+ * then the `simple ur-type definition`."
*/
type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYSIMPLETYPE);
/*
@@ -9016,7 +9037,7 @@ xmlSchemaParseList(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
type->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST;
/*
* SPEC (Base type) (2) "If the <list> or <union> alternative is chosen,
- * then the ·simple ur-type definition·."
+ * then the `simple ur-type definition`."
*/
type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYSIMPLETYPE);
/*
@@ -9161,9 +9182,9 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
}
/*
* TargetNamespace:
- * SPEC "The ·actual value· of the targetNamespace [attribute]
+ * SPEC "The `actual value` of the targetNamespace [attribute]
* of the <schema> ancestor element information item if present,
- * otherwise ·absent·.
+ * otherwise `absent`.
*/
if (topLevel == 0) {
#ifdef ENABLE_NAMED_LOCALS
@@ -9195,7 +9216,7 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
if (attr->ns == NULL) {
if (!xmlStrEqual(attr->name, BAD_CAST "id")) {
xmlSchemaPIllegalAttrErr(ctxt,
- XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
+ XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
}
} else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) {
xmlSchemaPIllegalAttrErr(ctxt,
@@ -9266,9 +9287,9 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* And now for the children...
*/
oldCtxtType = ctxt->ctxtType;
-
+
ctxt->ctxtType = type;
-
+
child = node->children;
if (IS_SCHEMA(child, "annotation")) {
type->annot = xmlSchemaParseAnnotation(ctxt, child, 1);
@@ -9278,10 +9299,10 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
xmlSchemaPContentErr(ctxt, XML_SCHEMAP_S4S_ELEM_MISSING,
NULL, node, child, NULL,
"(annotation?, (restriction | list | union))");
- } else if (IS_SCHEMA(child, "restriction")) {
+ } else if (IS_SCHEMA(child, "restriction")) {
xmlSchemaParseRestriction(ctxt, schema, child,
- XML_SCHEMA_TYPE_SIMPLE);
- hasRestriction = 1;
+ XML_SCHEMA_TYPE_SIMPLE);
+ hasRestriction = 1;
child = child->next;
} else if (IS_SCHEMA(child, "list")) {
xmlSchemaParseList(ctxt, schema, child);
@@ -9298,8 +9319,8 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
/*
* REDEFINE: SPEC src-redefine (5)
* "Within the [children], each <simpleType> must have a
- * <restriction> among its [children] ... the ·actual value· of whose
- * base [attribute] must be the same as the ·actual value· of its own
+ * <restriction> among its [children] ... the `actual value` of whose
+ * base [attribute] must be the same as the `actual value` of its own
* name attribute plus target namespace;"
*/
if (topLevel && ctxt->isRedefine && (! hasRestriction)) {
@@ -9307,7 +9328,7 @@ xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
NULL, node, "This is a redefinition, thus the "
"<simpleType> must have a <restriction> child", NULL);
}
-
+
ctxt->ctxtType = oldCtxtType;
return (type);
}
@@ -9373,13 +9394,13 @@ xmlSchemaParseModelGroupDefRef(xmlSchemaParserCtxtPtr ctxt,
xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id");
item = xmlSchemaAddParticle(ctxt, node, min, max);
if (item == NULL)
- return (NULL);
+ return (NULL);
/*
* Create a qname-reference and set as the term; it will be substituted
* for the model group after the reference has been resolved.
*/
item->children = (xmlSchemaTreeItemPtr)
- xmlSchemaNewQNameRef(ctxt, XML_SCHEMA_TYPE_GROUP, ref, refNs);
+ xmlSchemaNewQNameRef(ctxt, XML_SCHEMA_TYPE_GROUP, ref, refNs);
xmlSchemaPCheckParticleCorrect_2(ctxt, item, node, min, max);
/*
* And now for the children...
@@ -9419,7 +9440,7 @@ xmlSchemaParseModelGroupDefRef(xmlSchemaParserCtxtPtr ctxt,
* Note that the contraint src-redefine (6.2) can't be applied until
* references have been resolved. So we will do this at the
* component fixup level.
- *
+ *
* *WARNING* this interface is highly subject to change
*
* Returns -1 in case of error, 0 if the declaration is improper and
@@ -9493,7 +9514,7 @@ xmlSchemaParseModelGroupDefinition(xmlSchemaParserCtxtPtr ctxt,
child = child->next;
}
-
+
if (child != NULL) {
xmlSchemaPContentErr(ctxt,
@@ -9631,7 +9652,7 @@ xmlSchemaParseSchemaElement(xmlSchemaParserCtxtPtr ctxt,
attr = xmlSchemaGetPropNode(node, "version");
if (attr != NULL) {
res = xmlSchemaPValAttrNode(ctxt, NULL, NULL, attr,
- xmlSchemaGetBuiltInType(XML_SCHEMAS_TOKEN), &val);
+ xmlSchemaGetBuiltInType(XML_SCHEMAS_TOKEN), &val);
HFAILURE;
}
*/
@@ -9691,7 +9712,7 @@ xmlSchemaParseSchemaElement(xmlSchemaParserCtxtPtr ctxt,
}
attr = xmlSchemaGetPropNode(node, "blockDefault");
if (attr != NULL) {
- val = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr);
+ val = xmlSchemaGetNodeContent(ctxt, (xmlNodePtr) attr);
res = xmlSchemaPValAttrBlockFinal(val, &(schema->flags), -1,
XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION,
XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION,
@@ -9752,14 +9773,14 @@ xmlSchemaParseSchemaTopLevel(xmlSchemaParserCtxtPtr ctxt,
HFAILURE;
HSTOP(ctxt);
if (tmpOldErrs != ctxt->nberrors)
- goto exit;
+ goto exit;
} else if (IS_SCHEMA(child, "include")) {
tmpOldErrs = ctxt->nberrors;
res = xmlSchemaParseInclude(ctxt, schema, child);
HFAILURE;
HSTOP(ctxt);
if (tmpOldErrs != ctxt->nberrors)
- goto exit;
+ goto exit;
} else if (IS_SCHEMA(child, "redefine")) {
tmpOldErrs = ctxt->nberrors;
res = xmlSchemaParseRedefine(ctxt, schema, child);
@@ -9884,7 +9905,7 @@ xmlSchemaConstructionCtxtFree(xmlSchemaConstructionCtxtPtr con)
xmlFree(con);
}
-static xmlSchemaConstructionCtxtPtr
+static xmlSchemaConstructionCtxtPtr
xmlSchemaConstructionCtxtCreate(xmlDictPtr dict)
{
xmlSchemaConstructionCtxtPtr ret;
@@ -9954,10 +9975,10 @@ xmlSchemaNewParserCtxtUseDict(const char *URL, xmlDictPtr dict)
xmlSchemaParserCtxtPtr ret;
ret = xmlSchemaParserCtxtCreate();
- if (ret == NULL)
+ if (ret == NULL)
return (NULL);
ret->dict = dict;
- xmlDictReference(dict);
+ xmlDictReference(dict);
if (URL != NULL)
ret->URL = xmlDictLookup(dict, (const xmlChar *) URL, -1);
return (ret);
@@ -10082,8 +10103,8 @@ xmlSchemaParseNewDocWithContext(xmlSchemaParserCtxtPtr pctxt,
xmlNodePtr node;
int ret, oldErrs;
xmlSchemaBucketPtr oldbucket = pctxt->constructor->bucket;
-
- /*
+
+ /*
* Save old values; reset the *main* schema.
* URGENT TODO: This is not good; move the per-document information
* to the parser. Get rid of passing the main schema to the
@@ -10093,9 +10114,9 @@ xmlSchemaParseNewDocWithContext(xmlSchemaParserCtxtPtr pctxt,
oldDoc = schema->doc;
if (schema->flags != 0)
xmlSchemaClearSchemaDefaults(schema);
- schema->doc = bucket->doc;
+ schema->doc = bucket->doc;
pctxt->schema = schema;
- /*
+ /*
* Keep the current target namespace on the parser *not* on the
* main schema.
*/
@@ -10108,7 +10129,7 @@ xmlSchemaParseNewDocWithContext(xmlSchemaParserCtxtPtr pctxt,
* We are parsing the schema for schemas!
*/
pctxt->isS4S = 1;
- }
+ }
/* Mark it as parsed, even if parsing fails. */
bucket->parsed++;
/* Compile the schema doc. */
@@ -10132,7 +10153,7 @@ xmlSchemaParseNewDocWithContext(xmlSchemaParserCtxtPtr pctxt,
ret = pctxt->err;
goto exit;
}
-
+
exit:
WXS_CONSTRUCTOR(pctxt)->bucket = oldbucket;
/* Restore schema values. */
@@ -10165,7 +10186,7 @@ xmlSchemaParseNewDoc(xmlSchemaParserCtxtPtr pctxt,
PERROR_INT("xmlSchemaParseNewDoc",
"no constructor");
return(-1);
- }
+ }
/* Create and init the temporary parser context. */
newpctxt = xmlSchemaNewParserCtxtUseDict(
(const char *) bucket->schemaLocation, pctxt->dict);
@@ -10173,7 +10194,7 @@ xmlSchemaParseNewDoc(xmlSchemaParserCtxtPtr pctxt,
return(-1);
newpctxt->constructor = pctxt->constructor;
/*
- * TODO: Can we avoid that the parser knows about the main schema?
+ * TODO: Can we avoid that the parser knows about the main schema?
* It would be better if he knows about the current schema bucket
* only.
*/
@@ -10183,16 +10204,16 @@ xmlSchemaParseNewDoc(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaSetParserStructuredErrors(newpctxt, pctxt->serror,
pctxt->errCtxt);
newpctxt->counter = pctxt->counter;
-
+
res = xmlSchemaParseNewDocWithContext(newpctxt, schema, bucket);
-
+
/* Channel back errors and cleanup the temporary parser context. */
if (res != 0)
pctxt->err = res;
pctxt->nberrors += newpctxt->nberrors;
pctxt->counter = newpctxt->counter;
- newpctxt->constructor = NULL;
+ newpctxt->constructor = NULL;
/* Free the parser context. */
xmlSchemaFreeParserCtxt(newpctxt);
return(res);
@@ -10217,11 +10238,11 @@ xmlSchemaSchemaRelationAddChild(xmlSchemaBucketPtr bucket,
static const xmlChar *
xmlSchemaBuildAbsoluteURI(xmlDictPtr dict, const xmlChar* location,
xmlNodePtr ctxtNode)
-{
+{
/*
* Build an absolue location URI.
*/
- if (location != NULL) {
+ if (location != NULL) {
if (ctxtNode == NULL)
return(location);
else {
@@ -10244,7 +10265,7 @@ xmlSchemaBuildAbsoluteURI(xmlDictPtr dict, const xmlChar* location,
}
return(NULL);
}
-
+
/**
@@ -10267,8 +10288,8 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
const char *schemaBuffer,
int schemaBufferLen,
xmlNodePtr invokingNode,
- const xmlChar *sourceTargetNamespace,
- const xmlChar *importNamespace,
+ const xmlChar *sourceTargetNamespace,
+ const xmlChar *importNamespace,
xmlSchemaBucketPtr *bucket)
{
const xmlChar *targetNamespace = NULL;
@@ -10279,7 +10300,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
if (bucket != NULL)
*bucket = NULL;
-
+
switch (type) {
case XML_SCHEMA_SCHEMA_IMPORT:
case XML_SCHEMA_SCHEMA_MAIN:
@@ -10291,23 +10312,23 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
case XML_SCHEMA_SCHEMA_REDEFINE:
err = XML_SCHEMAP_SRC_REDEFINE;
break;
- }
-
+ }
+
/* Special handling for the main schema:
* skip the location and relation logic and just parse the doc.
* We need just a bucket to be returned in this case.
- */
+ */
if ((type == XML_SCHEMA_SCHEMA_MAIN) || (! WXS_HAS_BUCKETS(pctxt)))
- goto doc_load;
+ goto doc_load;
- /* Note that we expect the location to be an absulute URI. */
+ /* Note that we expect the location to be an absulute URI. */
if (schemaLocation != NULL) {
bkt = xmlSchemaGetSchemaBucket(pctxt, schemaLocation);
if ((bkt != NULL) &&
(pctxt->constructor->bucket == bkt)) {
/* Report self-imports/inclusions/redefinitions. */
-
+
xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
invokingNode, NULL,
"The schema must not import/include/redefine itself",
@@ -10320,7 +10341,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
*/
relation = xmlSchemaSchemaRelationCreate();
if (relation == NULL)
- return(-1);
+ return(-1);
xmlSchemaSchemaRelationAddChild(pctxt->constructor->bucket,
relation);
relation->type = type;
@@ -10329,7 +10350,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
* Save the namespace import information.
*/
if (WXS_IS_BUCKET_IMPMAIN(type)) {
- relation->importNamespace = importNamespace;
+ relation->importNamespace = importNamespace;
if (schemaLocation == NULL) {
/*
* No location; this is just an import of the namespace.
@@ -10342,32 +10363,48 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
}
/* Did we already fetch the doc? */
- if (bkt != NULL) {
- /* TODO: The following nasty cases will produce an error. */
+ if (bkt != NULL) {
if ((WXS_IS_BUCKET_IMPMAIN(type)) && (! bkt->imported)) {
- /* We included/redefined and then try to import a schema. */
- xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
- invokingNode, NULL,
- "The schema document '%s' cannot be imported, since "
- "it was already included or redefined",
- schemaLocation, NULL);
- goto exit;
+ /*
+ * We included/redefined and then try to import a schema,
+ * but the new location provided for import was different.
+ */
+ if (schemaLocation == NULL)
+ schemaLocation = BAD_CAST "in_memory_buffer";
+ if (!xmlStrEqual(schemaLocation,
+ bkt->schemaLocation)) {
+ xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
+ invokingNode, NULL,
+ "The schema document '%s' cannot be imported, since "
+ "it was already included or redefined",
+ schemaLocation, NULL);
+ goto exit;
+ }
} else if ((! WXS_IS_BUCKET_IMPMAIN(type)) && (bkt->imported)) {
- /* We imported and then try to include/redefine a schema. */
- xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
- invokingNode, NULL,
- "The schema document '%s' cannot be included or "
- "redefined, since it was already imported",
- schemaLocation, NULL);
- goto exit;
- }
+ /*
+ * We imported and then try to include/redefine a schema,
+ * but the new location provided for the include/redefine
+ * was different.
+ */
+ if (schemaLocation == NULL)
+ schemaLocation = BAD_CAST "in_memory_buffer";
+ if (!xmlStrEqual(schemaLocation,
+ bkt->schemaLocation)) {
+ xmlSchemaCustomErr(ACTXT_CAST pctxt, err,
+ invokingNode, NULL,
+ "The schema document '%s' cannot be included or "
+ "redefined, since it was already imported",
+ schemaLocation, NULL);
+ goto exit;
+ }
+ }
}
-
+
if (WXS_IS_BUCKET_IMPMAIN(type)) {
/*
* Given that the schemaLocation [attribute] is only a hint, it is open
* to applications to ignore all but the first <import> for a given
- * namespace, regardless of the ·actual value· of schemaLocation, but
+ * namespace, regardless of the `actual value` of schemaLocation, but
* such a strategy risks missing useful information when new
* schemaLocations are offered.
*
@@ -10383,7 +10420,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
* 5 Attempt to resolve the namespace name to locate such a resource.
*
* NOTE: (3) and (5) are not supported.
- */
+ */
if (bkt != NULL) {
relation->bucket = bkt;
goto exit;
@@ -10391,7 +10428,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
bkt = xmlSchemaGetSchemaBucketByTNS(pctxt,
importNamespace, 1);
- if (bkt != NULL) {
+ if (bkt != NULL) {
relation->bucket = bkt;
if (bkt->schemaLocation == NULL) {
/* First given location of the schema; load the doc. */
@@ -10404,6 +10441,9 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
* URGENT TODO: We should report a warning here.
* res = XML_SCHEMAP_SRC_IMPORT;
*/
+ if (schemaLocation == NULL)
+ schemaLocation = BAD_CAST "in_memory_buffer";
+
xmlSchemaCustomWarning(ACTXT_CAST pctxt,
XML_SCHEMAP_WARN_SKIP_SCHEMA,
invokingNode, NULL,
@@ -10414,19 +10454,19 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
}
goto exit;
}
- }
- /*
+ }
+ /*
* No bucket + first location: load the doc and create a
* bucket.
*/
} else {
/* <include> and <redefine> */
if (bkt != NULL) {
-
+
if ((bkt->origTargetNamespace == NULL) &&
(bkt->targetNamespace != sourceTargetNamespace)) {
xmlSchemaBucketPtr chamel;
-
+
/*
* Chameleon include/redefine: skip loading only if it was
* aleady build for the targetNamespace of the including
@@ -10451,7 +10491,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
relation->bucket = chamel;
goto exit;
}
- /*
+ /*
* We need to parse the chameleon again for a different
* targetNamespace.
* CHAMELEON TODO: Optimize this by only parsing the
@@ -10462,7 +10502,7 @@ xmlSchemaAddSchemaDoc(xmlSchemaParserCtxtPtr pctxt,
} else {
relation->bucket = bkt;
goto exit;
- }
+ }
}
}
if ((bkt != NULL) && (bkt->doc != NULL)) {
@@ -10484,7 +10524,8 @@ doc_load:
if (schemaDoc->URL != NULL)
schemaLocation = xmlDictLookup(pctxt->dict,
schemaDoc->URL, -1);
-
+ else
+ schemaLocation = BAD_CAST "in_memory_buffer";
} else if ((schemaLocation != NULL) || (schemaBuffer != NULL)) {
xmlParserCtxtPtr parserCtxt;
@@ -10511,9 +10552,9 @@ doc_load:
/* Parse from memory buffer. */
doc = xmlCtxtReadMemory(parserCtxt, schemaBuffer, schemaBufferLen,
NULL, NULL, SCHEMAS_PARSE_OPTIONS);
- schemaLocation = xmlStrdup(BAD_CAST "in_memory_buffer");
+ schemaLocation = BAD_CAST "in_memory_buffer";
if (doc != NULL)
- doc->URL = schemaLocation;
+ doc->URL = xmlStrdup(schemaLocation);
}
/*
* For <import>:
@@ -10547,7 +10588,7 @@ doc_load:
xmlSchemaCustomErr(ACTXT_CAST pctxt, res,
invokingNode, NULL,
"Failed to parse the XML resource '%s'",
- schemaLocation, NULL);
+ schemaLocation, NULL);
}
}
xmlFreeParserCtxt(parserCtxt);
@@ -10567,11 +10608,11 @@ doc_load:
if (doc != NULL) {
xmlNodePtr docElem = NULL;
- located = 1;
+ located = 1;
docElem = xmlDocGetRootElement(doc);
if (docElem == NULL) {
xmlSchemaCustomErr(ACTXT_CAST pctxt, XML_SCHEMAP_NOROOT,
- invokingNode, NULL,
+ invokingNode, NULL,
"The document '%s' has no document element",
schemaLocation, NULL);
goto exit_error;
@@ -10590,14 +10631,14 @@ doc_load:
schemaLocation, NULL);
goto exit_error;
}
- /*
+ /*
* Note that we don't apply a type check for the
* targetNamespace value here.
*/
targetNamespace = xmlSchemaGetProp(pctxt, docElem,
"targetNamespace");
}
-
+
/* after_doc_loading: */
if ((bkt == NULL) && located) {
/* Only create a bucket if the schema was located. */
@@ -10624,14 +10665,14 @@ doc_load:
if (relation != NULL)
relation->bucket = bkt;
}
-
+
exit:
/*
* Return the bucket explicitely; this is needed for the
* main schema.
*/
if (bucket != NULL)
- *bucket = bkt;
+ *bucket = bkt;
return (0);
exit_error:
@@ -10647,7 +10688,7 @@ exit_failure:
xmlFreeDoc(doc);
if (bkt != NULL)
bkt->doc = NULL;
- }
+ }
return (-1);
}
@@ -10716,7 +10757,7 @@ xmlSchemaParseImport(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema,
XML_SCHEMAP_S4S_ATTR_INVALID_VALUE,
NULL, node,
xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYURI),
- NULL, namespaceName, NULL, NULL, NULL);
+ NULL, schemaLocation, NULL, NULL, NULL);
return (pctxt->err);
}
/*
@@ -10747,8 +10788,8 @@ xmlSchemaParseImport(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema,
thisTargetNamespace = WXS_BUCKET(pctxt)->origTargetNamespace;
if (namespaceName != NULL) {
/*
- * 1.1 If the namespace [attribute] is present, then its ·actual value·
- * must not match the ·actual value· of the enclosing <schema>'s
+ * 1.1 If the namespace [attribute] is present, then its `actual value`
+ * must not match the `actual value` of the enclosing <schema>'s
* targetNamespace [attribute].
*/
if (xmlStrEqual(thisTargetNamespace, namespaceName)) {
@@ -10802,11 +10843,11 @@ xmlSchemaParseImport(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema,
"Failed to locate a schema at location '%s'. "
"Skipping the import", schemaLocation, NULL, NULL);
}
-
- if ((bucket != NULL) && CAN_PARSE_SCHEMA(bucket)) {
+
+ if ((bucket != NULL) && CAN_PARSE_SCHEMA(bucket)) {
ret = xmlSchemaParseNewDoc(pctxt, schema, bucket);
}
-
+
return (ret);
}
@@ -10888,7 +10929,7 @@ xmlSchemaParseIncludeOrRedefineAttrs(xmlSchemaParserCtxtPtr pctxt,
XML_SCHEMAP_SRC_REDEFINE,
NULL, node,
"The schema document '%s' cannot redefine itself.",
- *schemaLocation);
+ *schemaLocation);
} else {
xmlSchemaPCustomErr(pctxt,
XML_SCHEMAP_SRC_INCLUDE,
@@ -10898,7 +10939,7 @@ xmlSchemaParseIncludeOrRedefineAttrs(xmlSchemaParserCtxtPtr pctxt,
}
goto exit_error;
}
-
+
return(0);
exit_error:
return(pctxt->err);
@@ -10928,19 +10969,19 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
res = xmlSchemaParseIncludeOrRedefineAttrs(pctxt, schema,
node, (xmlChar **) (&schemaLocation), type);
if (res != 0)
- return(res);
+ return(res);
/*
* Load and add the schema document.
*/
res = xmlSchemaAddSchemaDoc(pctxt, type, schemaLocation, NULL,
NULL, 0, node, pctxt->targetNamespace, NULL, &bucket);
if (res != 0)
- return(res);
+ return(res);
/*
* If we get no schema bucket back, then this means that the schema
* document could not be located or was broken XML or was not
* a schema document.
- */
+ */
if ((bucket == NULL) || (bucket->doc == NULL)) {
if (type == XML_SCHEMA_SCHEMA_INCLUDE) {
/*
@@ -10949,7 +10990,7 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
* for inclusions, since the that was the feedback from the
* schema people. I.e. the following spec piece will *not* be
* satisfied:
- * SPEC src-include: "It is not an error for the ·actual value· of the
+ * SPEC src-include: "It is not an error for the `actual value` of the
* schemaLocation [attribute] to fail to resolve it all, in which
* case no corresponding inclusion is performed.
* So do we need a warning report here?"
@@ -10966,7 +11007,7 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
*
* SPEC src-redefine (1)
* "If there are any element information items among the [children]
- * other than <annotation> then the ·actual value· of the
+ * other than <annotation> then the `actual value` of the
* schemaLocation [attribute] must successfully resolve."
* TODO: Ask the WG if a the location has always to resolve
* here as well!
@@ -10982,13 +11023,13 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
* Check targetNamespace sanity before parsing the new schema.
* TODO: Note that we won't check further content if the
* targetNamespace was bad.
- */
- if (bucket->origTargetNamespace != NULL) {
+ */
+ if (bucket->origTargetNamespace != NULL) {
/*
* SPEC src-include (2.1)
- * "SII has a targetNamespace [attribute], and its ·actual
- * value· is identical to the ·actual value· of the targetNamespace
- * [attribute] of SII’ (which must have such an [attribute])."
+ * "SII has a targetNamespace [attribute], and its `actual
+ * value` is identical to the `actual value` of the targetNamespace
+ * [attribute] of SII' (which must have such an [attribute])."
*/
if (pctxt->targetNamespace == NULL) {
xmlSchemaCustomErr(ACTXT_CAST pctxt,
@@ -11012,28 +11053,29 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
pctxt->targetNamespace);
goto exit_error;
}
- } else if (pctxt->targetNamespace != NULL) {
+ } else if (pctxt->targetNamespace != NULL) {
/*
* Chameleons: the original target namespace will
* differ from the resulting namespace.
*/
isChameleon = 1;
if (bucket->parsed &&
- (bucket->targetNamespace != pctxt->targetNamespace)) {
- /*
- * This is a sanity check, I dunno yet if this can happen.
- */
- PERROR_INT("xmlSchemaParseIncludeOrRedefine",
- "trying to use an already parsed schema for a "
- "different targetNamespace");
- return(-1);
+ bucket->origTargetNamespace != NULL) {
+ xmlSchemaCustomErr(ACTXT_CAST pctxt,
+ XML_SCHEMAP_SRC_INCLUDE,
+ node, NULL,
+ "The target namespace of the included/redefined schema "
+ "'%s' has to be absent or the same as the "
+ "including/redefining schema's target namespace",
+ schemaLocation, NULL);
+ goto exit_error;
}
bucket->targetNamespace = pctxt->targetNamespace;
}
- }
+ }
/*
* Parse the schema.
- */
+ */
if (bucket && (!bucket->parsed) && (bucket->doc != NULL)) {
if (isChameleon) {
/* TODO: Get rid of this flag on the schema itself. */
@@ -11050,8 +11092,8 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
/*
* And now for the children...
*/
- child = node->children;
- if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
+ child = node->children;
+ if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
/*
* Parse (simpleType | complexType | group | attributeGroup))*
*/
@@ -11074,7 +11116,7 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
} else if (IS_SCHEMA(child, "complexType")) {
xmlSchemaParseComplexType(pctxt, schema, child, 1);
/* hasRedefinitions = 1; */
- } else if (IS_SCHEMA(child, "group")) {
+ } else if (IS_SCHEMA(child, "group")) {
/* hasRedefinitions = 1; */
xmlSchemaParseModelGroupDefinition(pctxt,
schema, child);
@@ -11094,7 +11136,7 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
*/
child = child->next;
}
- }
+ }
if (child != NULL) {
res = XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED;
if (type == XML_SCHEMA_SCHEMA_REDEFINE) {
@@ -11105,8 +11147,8 @@ xmlSchemaParseIncludeOrRedefine(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaPContentErr(pctxt, res,
NULL, node, child, NULL,
"(annotation?)");
- }
- }
+ }
+ }
return(res);
exit_error:
@@ -11156,7 +11198,7 @@ xmlSchemaParseInclude(xmlSchemaParserCtxtPtr pctxt, xmlSchemaPtr schema,
* Redefinition Constraints and Semantics (src-redefine)
* (6.1), (6.1.1), (6.1.2)
*
- * Schema Component Constraint:
+ * Schema Component Constraint:
* All Group Limited (cos-all-limited) (2)
* TODO: Actually this should go to component-level checks,
* but is done here due to performance. Move it to an other layer
@@ -11335,8 +11377,8 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
/*
* SPEC src-redefine:
* (6.1) "If it has a <group> among its contents at
- * some level the ·actual value· of whose ref
- * [attribute] is the same as the ·actual value· of
+ * some level the `actual value` of whose ref
+ * [attribute] is the same as the `actual value` of
* its own name attribute plus target namespace, then
* all of the following must be true:"
* (6.1.1) "It must have exactly one such group."
@@ -11361,9 +11403,9 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
xmlChar *str = NULL;
/*
* SPEC src-redefine:
- * (6.1.2) "The ·actual value· of both that
+ * (6.1.2) "The `actual value` of both that
* group's minOccurs and maxOccurs [attribute]
- * must be 1 (or ·absent·).
+ * must be 1 (or `absent`).
*/
xmlSchemaCustomErr(ACTXT_CAST ctxt,
XML_SCHEMAP_SRC_REDEFINE, child, NULL,
@@ -11380,7 +11422,7 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
}
ctxt->redef->reference = WXS_BASIC_CAST part;
ctxt->redefCounter++;
- }
+ }
}
} else if (IS_SCHEMA(child, "any")) {
part = (xmlSchemaTreeItemPtr)
@@ -11417,7 +11459,7 @@ xmlSchemaParseModelGroup(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
WXS_ADD_PENDING(ctxt, item);
}
if (withParticle)
- return ((xmlSchemaTreeItemPtr) particle);
+ return ((xmlSchemaTreeItemPtr) particle);
else
return ((xmlSchemaTreeItemPtr) item);
}
@@ -11469,7 +11511,7 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
*/
xmlSchemaPValAttrID(ctxt, node, BAD_CAST "id");
/*
- * Attribute
+ * Attribute
*/
/*
* Extract the base type. The "base" attribute is mandatory if inside
@@ -11477,8 +11519,8 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
*
* SPEC (1.2) "...otherwise (<restriction> has no <simpleType> "
* among its [children]), the simple type definition which is
- * the {content type} of the type definition ·resolved· to by
- * the ·actual value· of the base [attribute]"
+ * the {content type} of the type definition `resolved` to by
+ * the `actual value` of the base [attribute]"
*/
if (xmlSchemaPValAttrQName(ctxt, schema, NULL, node, "base",
&(type->baseNs), &(type->base)) == 0)
@@ -11501,8 +11543,8 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
/*
* REDEFINE: SPEC src-redefine (5)
* "Within the [children], each <simpleType> must have a
- * <restriction> among its [children] ... the ·actual value· of
- * whose base [attribute] must be the same as the ·actual value·
+ * <restriction> among its [children] ... the `actual value` of
+ * whose base [attribute] must be the same as the `actual value`
* of its own name attribute plus target namespace;"
*/
xmlSchemaPCustomErrExt(ctxt, XML_SCHEMAP_SRC_REDEFINE,
@@ -11518,7 +11560,7 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
type->base = NULL;
type->baseNs = NULL;
}
- }
+ }
}
/*
* And now for the children...
@@ -11585,7 +11627,7 @@ xmlSchemaParseRestriction(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
/*
* Model group reference <group>.
*/
- } else if (IS_SCHEMA(child, "group")) {
+ } else if (IS_SCHEMA(child, "group")) {
type->subtypes = (xmlSchemaTypePtr)
xmlSchemaParseModelGroupDefRef(ctxt, schema, child);
/*
@@ -11923,13 +11965,13 @@ xmlSchemaParseSimpleContent(xmlSchemaParserCtxtPtr ctxt,
xmlSchemaPContentErr(ctxt,
XML_SCHEMAP_S4S_ELEM_MISSING,
NULL, node, NULL, NULL,
- "(annotation?, (restriction | extension))");
+ "(annotation?, (restriction | extension))");
}
if (child == NULL) {
xmlSchemaPContentErr(ctxt,
XML_SCHEMAP_S4S_ELEM_MISSING,
NULL, node, NULL, NULL,
- "(annotation?, (restriction | extension))");
+ "(annotation?, (restriction | extension))");
}
if (IS_SCHEMA(child, "restriction")) {
xmlSchemaParseRestriction(ctxt, schema, child,
@@ -12086,7 +12128,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
} else if (xmlSchemaPValAttrNode(ctxt, NULL, attr,
xmlSchemaGetBuiltInType(XML_SCHEMAS_NCNAME), &name) != 0) {
return (NULL);
- }
+ }
}
if (topLevel == 0) {
@@ -12175,7 +12217,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
NULL, (xmlNodePtr) attr, NULL,
"(#all | List of (extension | restriction))",
attrValue, NULL, NULL, NULL);
- } else
+ } else
final = 1;
} else if (xmlStrEqual(attr->name, BAD_CAST "block")) {
/*
@@ -12193,7 +12235,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
NULL, (xmlNodePtr) attr, NULL,
"(#all | List of (extension | restriction)) ",
attrValue, NULL, NULL, NULL);
- } else
+ } else
block = 1;
} else {
xmlSchemaPIllegalAttrErr(ctxt,
@@ -12204,7 +12246,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
}
} else if (xmlStrEqual(attr->ns->href, xmlSchemaNs)) {
- xmlSchemaPIllegalAttrErr(ctxt,
+ xmlSchemaPIllegalAttrErr(ctxt,
XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, NULL, attr);
}
attr = attr->next;
@@ -12263,7 +12305,7 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
* SPEC
* "...the third alternative (neither <simpleContent> nor
* <complexContent>) is chosen. This case is understood as shorthand
- * for complex content restricting the ·ur-type definition·, and the
+ * for complex content restricting the `ur-type definition`, and the
* details of the mappings should be modified as necessary.
*/
type->baseType = xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYTYPE);
@@ -12332,15 +12374,15 @@ xmlSchemaParseComplexType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
}
/************************************************************************
- * *
- * Validating using Schemas *
- * *
+ * *
+ * Validating using Schemas *
+ * *
************************************************************************/
/************************************************************************
- * *
- * Reading/Writing Schemas *
- * *
+ * *
+ * Reading/Writing Schemas *
+ * *
************************************************************************/
#if 0 /* Will be enabled if it is clear what options are needed. */
@@ -12440,7 +12482,7 @@ xmlSchemaNewMemParserCtxt(const char *buffer, int size)
return(NULL);
ret->buffer = buffer;
ret->size = size;
- ret->dict = xmlDictCreate();
+ ret->dict = xmlDictCreate();
return (ret);
}
@@ -12483,7 +12525,7 @@ xmlSchemaFreeParserCtxt(xmlSchemaParserCtxtPtr ctxt)
if (ctxt == NULL)
return;
if (ctxt->doc != NULL && !ctxt->preserve)
- xmlFreeDoc(ctxt->doc);
+ xmlFreeDoc(ctxt->doc);
if (ctxt->vctxt != NULL) {
xmlSchemaFreeValidCtxt(ctxt->vctxt);
}
@@ -12504,7 +12546,12 @@ xmlSchemaFreeParserCtxt(xmlSchemaParserCtxtPtr ctxt)
* *
************************************************************************/
-static void
+/**
+ * xmlSchemaBuildContentModelForSubstGroup:
+ *
+ * Returns 1 if nillable, 0 otherwise
+ */
+static int
xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaParticlePtr particle, int counter, xmlAutomataStatePtr end)
{
@@ -12512,6 +12559,7 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaElementPtr elemDecl, member;
xmlSchemaSubstGroupPtr substGroup;
int i;
+ int ret = 0;
elemDecl = (xmlSchemaElementPtr) particle->children;
/*
@@ -12527,7 +12575,7 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt,
"Internal error: xmlSchemaBuildContentModelForSubstGroup, "
"declaration is marked having a subst. group but none "
"available.\n", elemDecl->name, NULL);
- return;
+ return(0);
}
if (counter >= 0) {
/*
@@ -12565,7 +12613,7 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt,
* was incorrectly used instead of xmlAutomataNewTransition2()
* (seems like a copy&paste bug from the XML_SCHEMA_TYPE_ALL
* section in xmlSchemaBuildAContentModel() ).
- * TODO: Check if xmlAutomataNewOnceTrans2() was instead
+ * TODO: Check if xmlAutomataNewOnceTrans2() was instead
* intended for the above "counter" section originally. I.e.,
* check xs:all with subst-groups.
*
@@ -12574,7 +12622,7 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt,
* 1, 1, member);
*/
tmp = xmlAutomataNewTransition2(pctxt->am, start, NULL,
- member->name, member->targetNamespace, member);
+ member->name, member->targetNamespace, member);
xmlAutomataNewEpsilon(pctxt->am, tmp, end);
}
} else {
@@ -12607,21 +12655,31 @@ xmlSchemaBuildContentModelForSubstGroup(xmlSchemaParserCtxtPtr pctxt,
xmlAutomataNewCountedTrans(pctxt->am, hop, start, counter);
xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter);
}
- if (particle->minOccurs == 0)
+ if (particle->minOccurs == 0) {
xmlAutomataNewEpsilon(pctxt->am, start, end);
+ ret = 1;
+ }
pctxt->state = end;
+ return(ret);
}
-static void
+/**
+ * xmlSchemaBuildContentModelForElement:
+ *
+ * Returns 1 if nillable, 0 otherwise
+ */
+static int
xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt,
xmlSchemaParticlePtr particle)
{
+ int ret = 0;
+
if (((xmlSchemaElementPtr) particle->children)->flags &
XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD) {
/*
* Substitution groups.
*/
- xmlSchemaBuildContentModelForSubstGroup(ctxt, particle, -1, NULL);
+ ret = xmlSchemaBuildContentModelForSubstGroup(ctxt, particle, -1, NULL);
} else {
xmlSchemaElementPtr elemDecl;
xmlAutomataStatePtr start;
@@ -12629,7 +12687,7 @@ xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt,
elemDecl = (xmlSchemaElementPtr) particle->children;
if (elemDecl->flags & XML_SCHEMAS_ELEM_ABSTRACT)
- return;
+ return(0);
if (particle->maxOccurs == 1) {
start = ctxt->state;
ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL,
@@ -12637,11 +12695,11 @@ xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt,
} else if ((particle->maxOccurs >= UNBOUNDED) &&
(particle->minOccurs < 2)) {
/* Special case. */
- start = ctxt->state;
+ start = ctxt->state;
ctxt->state = xmlAutomataNewTransition2(ctxt->am, start, NULL,
- elemDecl->name, elemDecl->targetNamespace, elemDecl);
+ elemDecl->name, elemDecl->targetNamespace, elemDecl);
ctxt->state = xmlAutomataNewTransition2(ctxt->am, ctxt->state, ctxt->state,
- elemDecl->name, elemDecl->targetNamespace, elemDecl);
+ elemDecl->name, elemDecl->targetNamespace, elemDecl);
} else {
int counter;
int maxOccurs = particle->maxOccurs == UNBOUNDED ?
@@ -12657,9 +12715,12 @@ xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt,
ctxt->state = xmlAutomataNewCounterTrans(ctxt->am, ctxt->state,
NULL, counter);
}
- if (particle->minOccurs == 0)
+ if (particle->minOccurs == 0) {
xmlAutomataNewEpsilon(ctxt->am, start, ctxt->state);
+ ret = 1;
+ }
}
+ return(ret);
}
/**
@@ -12670,21 +12731,24 @@ xmlSchemaBuildContentModelForElement(xmlSchemaParserCtxtPtr ctxt,
*
* Create the automaton for the {content type} of a complex type.
*
+ * Returns 1 if the content is nillable, 0 otherwise
*/
-static void
+static int
xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaParticlePtr particle)
{
+ int ret = 0, tmp2;
+
if (particle == NULL) {
- PERROR_INT("xmlSchemaBuildAContentModel", "particle is NULL");
- return;
+ PERROR_INT("xmlSchemaBuildAContentModel", "particle is NULL");
+ return(1);
}
if (particle->children == NULL) {
/*
* Just return in this case. A missing "term" of the particle
* might arise due to an invalid "term" component.
*/
- return;
+ return(1);
}
switch (particle->children->type) {
@@ -12736,7 +12800,8 @@ xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt,
int counter;
xmlAutomataStatePtr hop;
int maxOccurs =
- particle->maxOccurs == UNBOUNDED ? UNBOUNDED : particle->maxOccurs - 1;
+ particle->maxOccurs == UNBOUNDED ? UNBOUNDED :
+ particle->maxOccurs - 1;
int minOccurs =
particle->minOccurs < 1 ? 0 : particle->minOccurs - 1;
@@ -12771,243 +12836,282 @@ xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt,
}
if (particle->minOccurs == 0) {
xmlAutomataNewEpsilon(pctxt->am, start, end);
+ ret = 1;
}
pctxt->state = end;
break;
}
case XML_SCHEMA_TYPE_ELEMENT:
- xmlSchemaBuildContentModelForElement(pctxt, particle);
+ ret = xmlSchemaBuildContentModelForElement(pctxt, particle);
break;
case XML_SCHEMA_TYPE_SEQUENCE:{
- xmlSchemaTreeItemPtr sub;
+ xmlSchemaTreeItemPtr sub;
- /*
- * If max and min occurances are default (1) then
- * simply iterate over the particles of the <sequence>.
- */
- if ((particle->minOccurs == 1) && (particle->maxOccurs == 1)) {
- sub = particle->children->children;
- while (sub != NULL) {
- xmlSchemaBuildAContentModel(pctxt,
- (xmlSchemaParticlePtr) sub);
- sub = sub->next;
- }
- } else {
- xmlAutomataStatePtr oldstate = pctxt->state;
-
- if (particle->maxOccurs >= UNBOUNDED) {
- if (particle->minOccurs > 1) {
- xmlAutomataStatePtr tmp;
- int counter;
-
- pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
- oldstate, NULL);
- oldstate = pctxt->state;
+ ret = 1;
+ /*
+ * If max and min occurances are default (1) then
+ * simply iterate over the particles of the <sequence>.
+ */
+ if ((particle->minOccurs == 1) && (particle->maxOccurs == 1)) {
+ sub = particle->children->children;
- counter = xmlAutomataNewCounter(pctxt->am,
- particle->minOccurs - 1, UNBOUNDED);
+ while (sub != NULL) {
+ tmp2 = xmlSchemaBuildAContentModel(pctxt,
+ (xmlSchemaParticlePtr) sub);
+ if (tmp2 != 1) ret = 0;
+ sub = sub->next;
+ }
+ } else {
+ xmlAutomataStatePtr oldstate = pctxt->state;
- sub = particle->children->children;
- while (sub != NULL) {
- xmlSchemaBuildAContentModel(pctxt,
- (xmlSchemaParticlePtr) sub);
- sub = sub->next;
- }
- tmp = pctxt->state;
- xmlAutomataNewCountedTrans(pctxt->am, tmp,
- oldstate, counter);
- pctxt->state =
- xmlAutomataNewCounterTrans(pctxt->am, tmp,
- NULL, counter);
-
- } else {
- pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
- oldstate, NULL);
- oldstate = pctxt->state;
-
- sub = particle->children->children;
- while (sub != NULL) {
- xmlSchemaBuildAContentModel(pctxt,
- (xmlSchemaParticlePtr) sub);
- sub = sub->next;
- }
- xmlAutomataNewEpsilon(pctxt->am, pctxt->state,
- oldstate);
- /*
- * epsilon needed to block previous trans from
- * being allowed to enter back from another
- * construct
- */
- pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
- pctxt->state, NULL);
- if (particle->minOccurs == 0) {
- xmlAutomataNewEpsilon(pctxt->am,
- oldstate, pctxt->state);
- }
- }
- } else if ((particle->maxOccurs > 1)
- || (particle->minOccurs > 1)) {
+ if (particle->maxOccurs >= UNBOUNDED) {
+ if (particle->minOccurs > 1) {
xmlAutomataStatePtr tmp;
int counter;
pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
- oldstate, NULL);
+ oldstate, NULL);
oldstate = pctxt->state;
counter = xmlAutomataNewCounter(pctxt->am,
- particle->minOccurs - 1,
- particle->maxOccurs - 1);
+ particle->minOccurs - 1, UNBOUNDED);
sub = particle->children->children;
while (sub != NULL) {
- xmlSchemaBuildAContentModel(pctxt,
- (xmlSchemaParticlePtr) sub);
+ tmp2 = xmlSchemaBuildAContentModel(pctxt,
+ (xmlSchemaParticlePtr) sub);
+ if (tmp2 != 1) ret = 0;
sub = sub->next;
}
tmp = pctxt->state;
- xmlAutomataNewCountedTrans(pctxt->am,
- tmp, oldstate, counter);
+ xmlAutomataNewCountedTrans(pctxt->am, tmp,
+ oldstate, counter);
pctxt->state =
- xmlAutomataNewCounterTrans(pctxt->am, tmp, NULL,
- counter);
- if (particle->minOccurs == 0) {
+ xmlAutomataNewCounterTrans(pctxt->am, tmp,
+ NULL, counter);
+ if (ret == 1)
xmlAutomataNewEpsilon(pctxt->am,
- oldstate, pctxt->state);
- }
+ oldstate, pctxt->state);
+
} else {
+ pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
+ oldstate, NULL);
+ oldstate = pctxt->state;
+
sub = particle->children->children;
while (sub != NULL) {
- xmlSchemaBuildAContentModel(pctxt,
- (xmlSchemaParticlePtr) sub);
+ tmp2 = xmlSchemaBuildAContentModel(pctxt,
+ (xmlSchemaParticlePtr) sub);
+ if (tmp2 != 1) ret = 0;
sub = sub->next;
}
+ xmlAutomataNewEpsilon(pctxt->am, pctxt->state,
+ oldstate);
+ /*
+ * epsilon needed to block previous trans from
+ * being allowed to enter back from another
+ * construct
+ */
+ pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
+ pctxt->state, NULL);
if (particle->minOccurs == 0) {
- xmlAutomataNewEpsilon(pctxt->am, oldstate,
- pctxt->state);
+ xmlAutomataNewEpsilon(pctxt->am,
+ oldstate, pctxt->state);
+ ret = 1;
}
}
- }
- break;
- }
- case XML_SCHEMA_TYPE_CHOICE:{
- xmlSchemaTreeItemPtr sub;
- xmlAutomataStatePtr start, end;
+ } else if ((particle->maxOccurs > 1)
+ || (particle->minOccurs > 1)) {
+ xmlAutomataStatePtr tmp;
+ int counter;
- start = pctxt->state;
- end = xmlAutomataNewState(pctxt->am);
+ pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
+ oldstate, NULL);
+ oldstate = pctxt->state;
- /*
- * iterate over the subtypes and remerge the end with an
- * epsilon transition
- */
- if (particle->maxOccurs == 1) {
- sub = particle->children->children;
+ counter = xmlAutomataNewCounter(pctxt->am,
+ particle->minOccurs - 1,
+ particle->maxOccurs - 1);
+
+ sub = particle->children->children;
while (sub != NULL) {
- pctxt->state = start;
- xmlSchemaBuildAContentModel(pctxt,
- (xmlSchemaParticlePtr) sub);
- xmlAutomataNewEpsilon(pctxt->am, pctxt->state, end);
+ tmp2 = xmlSchemaBuildAContentModel(pctxt,
+ (xmlSchemaParticlePtr) sub);
+ if (tmp2 != 1) ret = 0;
sub = sub->next;
}
+ tmp = pctxt->state;
+ xmlAutomataNewCountedTrans(pctxt->am,
+ tmp, oldstate, counter);
+ pctxt->state =
+ xmlAutomataNewCounterTrans(pctxt->am, tmp, NULL,
+ counter);
+ if ((particle->minOccurs == 0) || (ret == 1)) {
+ xmlAutomataNewEpsilon(pctxt->am,
+ oldstate, pctxt->state);
+ ret = 1;
+ }
} else {
- int counter;
- xmlAutomataStatePtr hop, base;
- int maxOccurs = particle->maxOccurs == UNBOUNDED ?
- UNBOUNDED : particle->maxOccurs - 1;
- int minOccurs =
- particle->minOccurs < 1 ? 0 : particle->minOccurs - 1;
-
- /*
- * use a counter to keep track of the number of transtions
- * which went through the choice.
- */
- counter =
- xmlAutomataNewCounter(pctxt->am, minOccurs, maxOccurs);
- hop = xmlAutomataNewState(pctxt->am);
- base = xmlAutomataNewState(pctxt->am);
-
- sub = particle->children->children;
+ sub = particle->children->children;
while (sub != NULL) {
- pctxt->state = base;
- xmlSchemaBuildAContentModel(pctxt,
- (xmlSchemaParticlePtr) sub);
- xmlAutomataNewEpsilon(pctxt->am, pctxt->state, hop);
+ tmp2 = xmlSchemaBuildAContentModel(pctxt,
+ (xmlSchemaParticlePtr) sub);
+ if (tmp2 != 1) ret = 0;
sub = sub->next;
}
- xmlAutomataNewEpsilon(pctxt->am, start, base);
- xmlAutomataNewCountedTrans(pctxt->am, hop, base, counter);
- xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter);
- }
- if (particle->minOccurs == 0) {
- xmlAutomataNewEpsilon(pctxt->am, start, end);
+
+ /*
+ * epsilon needed to block previous trans from
+ * being allowed to enter back from another
+ * construct
+ */
+ pctxt->state = xmlAutomataNewEpsilon(pctxt->am,
+ pctxt->state, NULL);
+
+ if (particle->minOccurs == 0) {
+ xmlAutomataNewEpsilon(pctxt->am, oldstate,
+ pctxt->state);
+ ret = 1;
+ }
}
- pctxt->state = end;
- break;
}
- case XML_SCHEMA_TYPE_ALL:{
- xmlAutomataStatePtr start;
- xmlSchemaParticlePtr sub;
- xmlSchemaElementPtr elemDecl;
- int lax;
-
- sub = (xmlSchemaParticlePtr) particle->children->children;
- if (sub == NULL)
- break;
- start = pctxt->state;
+ break;
+ }
+ case XML_SCHEMA_TYPE_CHOICE:{
+ xmlSchemaTreeItemPtr sub;
+ xmlAutomataStatePtr start, end;
+
+ ret = 0;
+ start = pctxt->state;
+ end = xmlAutomataNewState(pctxt->am);
+
+ /*
+ * iterate over the subtypes and remerge the end with an
+ * epsilon transition
+ */
+ if (particle->maxOccurs == 1) {
+ sub = particle->children->children;
while (sub != NULL) {
pctxt->state = start;
+ tmp2 = xmlSchemaBuildAContentModel(pctxt,
+ (xmlSchemaParticlePtr) sub);
+ if (tmp2 == 1) ret = 1;
+ xmlAutomataNewEpsilon(pctxt->am, pctxt->state, end);
+ sub = sub->next;
+ }
+ } else {
+ int counter;
+ xmlAutomataStatePtr hop, base;
+ int maxOccurs = particle->maxOccurs == UNBOUNDED ?
+ UNBOUNDED : particle->maxOccurs - 1;
+ int minOccurs =
+ particle->minOccurs < 1 ? 0 : particle->minOccurs - 1;
- elemDecl = (xmlSchemaElementPtr) sub->children;
- if (elemDecl == NULL) {
- PERROR_INT("xmlSchemaBuildAContentModel",
- "<element> particle has no term");
- return;
- };
- /*
- * NOTE: The {max occurs} of all the particles in the
- * {particles} of the group must be 0 or 1; this is
- * already ensured during the parse of the content of
- * <all>.
- */
- if (elemDecl->flags & XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD) {
- int counter;
-
- /*
- * This is an abstract group, we need to share
- * the same counter for all the element transitions
- * derived from the group
- */
- counter = xmlAutomataNewCounter(pctxt->am,
- sub->minOccurs, sub->maxOccurs);
- xmlSchemaBuildContentModelForSubstGroup(pctxt,
- sub, counter, pctxt->state);
- } else {
- if ((sub->minOccurs == 1) &&
- (sub->maxOccurs == 1)) {
- xmlAutomataNewOnceTrans2(pctxt->am, pctxt->state,
- pctxt->state,
- elemDecl->name,
- elemDecl->targetNamespace,
- 1, 1, elemDecl);
- } else if ((sub->minOccurs == 0) &&
- (sub->maxOccurs == 1)) {
-
- xmlAutomataNewCountTrans2(pctxt->am, pctxt->state,
- pctxt->state,
- elemDecl->name,
- elemDecl->targetNamespace,
- 0,
- 1,
- elemDecl);
- }
- }
- sub = (xmlSchemaParticlePtr) sub->next;
+ /*
+ * use a counter to keep track of the number of transtions
+ * which went through the choice.
+ */
+ counter =
+ xmlAutomataNewCounter(pctxt->am, minOccurs, maxOccurs);
+ hop = xmlAutomataNewState(pctxt->am);
+ base = xmlAutomataNewState(pctxt->am);
+
+ sub = particle->children->children;
+ while (sub != NULL) {
+ pctxt->state = base;
+ tmp2 = xmlSchemaBuildAContentModel(pctxt,
+ (xmlSchemaParticlePtr) sub);
+ if (tmp2 == 1) ret = 1;
+ xmlAutomataNewEpsilon(pctxt->am, pctxt->state, hop);
+ sub = sub->next;
}
- lax = particle->minOccurs == 0;
- pctxt->state =
- xmlAutomataNewAllTrans(pctxt->am, pctxt->state, NULL, lax);
+ xmlAutomataNewEpsilon(pctxt->am, start, base);
+ xmlAutomataNewCountedTrans(pctxt->am, hop, base, counter);
+ xmlAutomataNewCounterTrans(pctxt->am, hop, end, counter);
+ if (ret == 1)
+ xmlAutomataNewEpsilon(pctxt->am, base, end);
+ }
+ if (particle->minOccurs == 0) {
+ xmlAutomataNewEpsilon(pctxt->am, start, end);
+ ret = 1;
+ }
+ pctxt->state = end;
+ break;
+ }
+ case XML_SCHEMA_TYPE_ALL:{
+ xmlAutomataStatePtr start, tmp;
+ xmlSchemaParticlePtr sub;
+ xmlSchemaElementPtr elemDecl;
+
+ ret = 1;
+
+ sub = (xmlSchemaParticlePtr) particle->children->children;
+ if (sub == NULL)
break;
+
+ ret = 0;
+
+ start = pctxt->state;
+ tmp = xmlAutomataNewState(pctxt->am);
+ xmlAutomataNewEpsilon(pctxt->am, pctxt->state, tmp);
+ pctxt->state = tmp;
+ while (sub != NULL) {
+ pctxt->state = tmp;
+
+ elemDecl = (xmlSchemaElementPtr) sub->children;
+ if (elemDecl == NULL) {
+ PERROR_INT("xmlSchemaBuildAContentModel",
+ "<element> particle has no term");
+ return(ret);
+ };
+ /*
+ * NOTE: The {max occurs} of all the particles in the
+ * {particles} of the group must be 0 or 1; this is
+ * already ensured during the parse of the content of
+ * <all>.
+ */
+ if (elemDecl->flags & XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD) {
+ int counter;
+
+ /*
+ * This is an abstract group, we need to share
+ * the same counter for all the element transitions
+ * derived from the group
+ */
+ counter = xmlAutomataNewCounter(pctxt->am,
+ sub->minOccurs, sub->maxOccurs);
+ xmlSchemaBuildContentModelForSubstGroup(pctxt,
+ sub, counter, pctxt->state);
+ } else {
+ if ((sub->minOccurs == 1) &&
+ (sub->maxOccurs == 1)) {
+ xmlAutomataNewOnceTrans2(pctxt->am, pctxt->state,
+ pctxt->state,
+ elemDecl->name,
+ elemDecl->targetNamespace,
+ 1, 1, elemDecl);
+ } else if ((sub->minOccurs == 0) &&
+ (sub->maxOccurs == 1)) {
+
+ xmlAutomataNewCountTrans2(pctxt->am, pctxt->state,
+ pctxt->state,
+ elemDecl->name,
+ elemDecl->targetNamespace,
+ 0,
+ 1,
+ elemDecl);
+ }
+ }
+ sub = (xmlSchemaParticlePtr) sub->next;
+ }
+ pctxt->state =
+ xmlAutomataNewAllTrans(pctxt->am, pctxt->state, NULL, 0);
+ if (particle->minOccurs == 0) {
+ xmlAutomataNewEpsilon(pctxt->am, start, pctxt->state);
+ ret = 1;
}
+ break;
+ }
case XML_SCHEMA_TYPE_GROUP:
/*
* If we hit a model group definition, then this means that
@@ -13016,14 +13120,16 @@ xmlSchemaBuildAContentModel(xmlSchemaParserCtxtPtr pctxt,
* TODO: But the group should be substituted and not occur at
* all in the content model at this point. Fix this.
*/
+ ret = 1;
break;
default:
xmlSchemaInternalErr2(ACTXT_CAST pctxt,
"xmlSchemaBuildAContentModel",
"found unexpected term of type '%s' in content model",
WXS_ITEM_TYPE_NAME(particle->children), NULL);
- return;
+ return(ret);
}
+ return(ret);
}
/**
@@ -13107,8 +13213,8 @@ xmlSchemaResolveElementReferences(xmlSchemaElementPtr elemDecl,
if ((elemDecl->subtypes == NULL) && (elemDecl->namedType != NULL)) {
xmlSchemaTypePtr type;
- /* (type definition) ... otherwise the type definition ·resolved·
- * to by the ·actual value· of the type [attribute] ...
+ /* (type definition) ... otherwise the type definition `resolved`
+ * to by the `actual value` of the type [attribute] ...
*/
type = xmlSchemaGetType(ctxt->schema, elemDecl->namedType,
elemDecl->namedTypeNs);
@@ -13146,7 +13252,7 @@ xmlSchemaResolveElementReferences(xmlSchemaElementPtr elemDecl,
/*
* The type definitions is set to:
* SPEC "...the {type definition} of the element
- * declaration ·resolved· to by the ·actual value·
+ * declaration `resolved` to by the `actual value`
* of the substitutionGroup [attribute], if present"
*/
if (elemDecl->subtypes == NULL)
@@ -13184,8 +13290,8 @@ xmlSchemaResolveUnionMemberTypes(xmlSchemaParserCtxtPtr ctxt,
/*
* SPEC (1) "If the <union> alternative is chosen, then [Definition:]
- * define the explicit members as the type definitions ·resolved·
- * to by the items in the ·actual value· of the memberTypes [attribute],
+ * define the explicit members as the type definitions `resolved`
+ * to by the items in the `actual value` of the memberTypes [attribute],
* if any, followed by the type definitions corresponding to the
* <simpleType>s among the [children] of <union>, if any."
*/
@@ -13298,7 +13404,6 @@ xmlSchemaIsUserDerivedFromBuiltInType(xmlSchemaTypePtr type, int valType)
return (0);
}
-#endif
static xmlSchemaTypePtr
xmlSchemaQueryBuiltInType(xmlSchemaTypePtr type)
@@ -13311,6 +13416,7 @@ xmlSchemaQueryBuiltInType(xmlSchemaTypePtr type)
return(type);
return(xmlSchemaQueryBuiltInType(type->subtypes));
}
+#endif
/**
* xmlSchemaGetPrimitiveType:
@@ -13480,7 +13586,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
return (0);
}
/*
- * 3 If both O1 and O2 are sets of (namespace names or ·absent·),
+ * 3 If both O1 and O2 are sets of (namespace names or `absent`),
* then the union of those sets must be the value.
*/
if ((completeWild->nsSet != NULL) && (curWild->nsSet != NULL)) {
@@ -13514,7 +13620,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
}
/*
* 4 If the two are negations of different values (namespace names
- * or ·absent·), then a pair of not and ·absent· must be the value.
+ * or `absent`), then a pair of not and `absent` must be the value.
*/
if ((completeWild->negNsSet != NULL) &&
(curWild->negNsSet != NULL) &&
@@ -13556,7 +13662,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
if (nsFound && absentFound) {
/*
* 5.1 If the set S includes both the negated namespace
- * name and ·absent·, then any must be the value.
+ * name and `absent`, then any must be the value.
*/
completeWild->any = 1;
if (completeWild->nsSet != NULL) {
@@ -13570,7 +13676,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
} else if (nsFound && (!absentFound)) {
/*
* 5.2 If the set S includes the negated namespace name
- * but not ·absent·, then a pair of not and ·absent· must
+ * but not `absent`, then a pair of not and `absent` must
* be the value.
*/
if (completeWild->nsSet != NULL) {
@@ -13585,7 +13691,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
completeWild->negNsSet->value = NULL;
} else if ((!nsFound) && absentFound) {
/*
- * 5.3 If the set S includes ·absent· but not the negated
+ * 5.3 If the set S includes `absent` but not the negated
* namespace name, then the union is not expressible.
*/
xmlSchemaPErr(ctxt, completeWild->node,
@@ -13596,7 +13702,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
} else if ((!nsFound) && (!absentFound)) {
/*
* 5.4 If the set S does not include either the negated namespace
- * name or ·absent·, then whichever of O1 or O2 is a pair of not
+ * name or `absent`, then whichever of O1 or O2 is a pair of not
* and a namespace name must be the value.
*/
if (completeWild->negNsSet == NULL) {
@@ -13630,7 +13736,7 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
while (cur != NULL) {
if (cur->value == NULL) {
/*
- * 6.1 If the set S includes ·absent·, then any must be the
+ * 6.1 If the set S includes `absent`, then any must be the
* value.
*/
completeWild->any = 1;
@@ -13648,8 +13754,8 @@ xmlSchemaUnionWildcards(xmlSchemaParserCtxtPtr ctxt,
}
if (completeWild->negNsSet == NULL) {
/*
- * 6.2 If the set S does not include ·absent·, then a pair of not
- * and ·absent· must be the value.
+ * 6.2 If the set S does not include `absent`, then a pair of not
+ * and `absent` must be the value.
*/
if (completeWild->nsSet != NULL) {
xmlSchemaFreeWildcardNsSet(completeWild->nsSet);
@@ -13732,9 +13838,9 @@ xmlSchemaIntersectWildcards(xmlSchemaParserCtxtPtr ctxt,
}
/*
* 3 If either O1 or O2 is a pair of not and a value (a namespace
- * name or ·absent·) and the other is a set of (namespace names or
- * ·absent·), then that set, minus the negated value if it was in
- * the set, minus ·absent· if it was in the set, must be the value.
+ * name or `absent`) and the other is a set of (namespace names or
+ * `absent`), then that set, minus the negated value if it was in
+ * the set, minus `absent` if it was in the set, must be the value.
*/
if (((completeWild->negNsSet != NULL) && (curWild->nsSet != NULL)) ||
((curWild->negNsSet != NULL) && (completeWild->nsSet != NULL))) {
@@ -13783,7 +13889,7 @@ xmlSchemaIntersectWildcards(xmlSchemaParserCtxtPtr ctxt,
return(0);
}
/*
- * 4 If both O1 and O2 are sets of (namespace names or ·absent·),
+ * 4 If both O1 and O2 are sets of (namespace names or `absent`),
* then the intersection of those sets must be the value.
*/
if ((completeWild->nsSet != NULL) && (curWild->nsSet != NULL)) {
@@ -13833,7 +13939,7 @@ xmlSchemaIntersectWildcards(xmlSchemaParserCtxtPtr ctxt,
}
/*
* 6 If the one is a negation of a namespace name and the other
- * is a negation of ·absent·, then the one which is the negation
+ * is a negation of `absent`, then the one which is the negation
* of a namespace name must be the value.
*/
if ((completeWild->negNsSet != NULL) && (curWild->negNsSet != NULL) &&
@@ -13865,15 +13971,15 @@ xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub,
if (super->any)
return (0);
/*
- * 2.1 sub must be a pair of not and a namespace name or ·absent·.
+ * 2.1 sub must be a pair of not and a namespace name or `absent`.
* 2.2 super must be a pair of not and the same value.
*/
if ((sub->negNsSet != NULL) &&
(super->negNsSet != NULL) &&
- (sub->negNsSet->value == sub->negNsSet->value))
+ (sub->negNsSet->value == super->negNsSet->value))
return (0);
/*
- * 3.1 sub must be a set whose members are either namespace names or ·absent·.
+ * 3.1 sub must be a set whose members are either namespace names or `absent`.
*/
if (sub->nsSet != NULL) {
/*
@@ -13904,7 +14010,7 @@ xmlSchemaCheckCOSNSSubset(xmlSchemaWildcardPtr sub,
xmlSchemaWildcardNsPtr cur;
/*
* 3.2.2 super must be a pair of not and a namespace name or
- * ·absent· and that value must not be in sub's set.
+ * `absent` and that value must not be in sub's set.
*/
cur = sub->nsSet;
while (cur != NULL) {
@@ -13929,7 +14035,7 @@ xmlSchemaGetEffectiveValueConstraint(xmlSchemaAttributeUsePtr attruse,
if (val != 0)
*val = NULL;
- if (attruse->defValue != NULL) {
+ if (attruse->defValue != NULL) {
*value = attruse->defValue;
if (val != NULL)
*val = attruse->defVal;
@@ -14009,12 +14115,12 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaItemListPtr baseUses,
xmlSchemaWildcardPtr wild,
xmlSchemaWildcardPtr baseWild)
-{
+{
xmlSchemaAttributeUsePtr cur = NULL, bcur;
int i, j, found; /* err = 0; */
const xmlChar *bEffValue;
int effFixed;
-
+
if (uses != NULL) {
for (i = 0; i < uses->nbItems; i++) {
cur = uses->items[i];
@@ -14022,7 +14128,7 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
if (baseUses == NULL)
goto not_found;
for (j = 0; j < baseUses->nbItems; j++) {
- bcur = baseUses->items[j];
+ bcur = baseUses->items[j];
if ((WXS_ATTRUSE_DECL_NAME(cur) ==
WXS_ATTRUSE_DECL_NAME(bcur)) &&
(WXS_ATTRUSE_DECL_TNS(cur) ==
@@ -14035,7 +14141,7 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
* namespace}, then all of the following must be true:"
*/
found = 1;
-
+
if ((cur->occurs == XML_SCHEMAS_ATTR_USE_OPTIONAL) &&
(bcur->occurs == XML_SCHEMAS_ATTR_USE_REQUIRED))
{
@@ -14061,12 +14167,12 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
WXS_ATTRUSE_TYPEDEF(bcur), 0) != 0)
{
xmlChar *strA = NULL, *strB = NULL, *strC = NULL;
-
+
/*
* SPEC (2.1.2) "R's {attribute declaration}'s
* {type definition} must be validly derived from
* B's {type definition} given the empty set as
- * defined in Type Derivation OK (Simple) (§3.14.6)."
+ * defined in Type Derivation OK (Simple) ($3.14.6)."
*/
xmlSchemaPAttrUseErr4(pctxt,
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2,
@@ -14098,17 +14204,17 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
/*
* 2.1.3 ... one of the following must be true
*
- * 2.1.3.1 B's ·effective value constraint· is
- * ·absent· or default.
+ * 2.1.3.1 B's `effective value constraint` is
+ * `absent` or default.
*/
if ((bEffValue != NULL) &&
(effFixed == 1)) {
const xmlChar *rEffValue = NULL;
-
+
xmlSchemaGetEffectiveValueConstraint(bcur,
&effFixed, &rEffValue, NULL);
/*
- * 2.1.3.2 R's ·effective value constraint· is
+ * 2.1.3.2 R's `effective value constraint` is
* fixed with the same string as B's.
* MAYBE TODO: Compare the computed values.
* Hmm, it says "same string" so
@@ -14118,7 +14224,7 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
(! WXS_ARE_DEFAULT_STR_EQUAL(rEffValue, bEffValue)))
{
xmlChar *str = NULL;
-
+
xmlSchemaPAttrUseErr4(pctxt,
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3,
WXS_ITEM_NODE(item), item, cur,
@@ -14137,21 +14243,21 @@ xmlSchemaCheckDerivationOKRestriction2to4(xmlSchemaParserCtxtPtr pctxt,
break;
}
}
-not_found:
+not_found:
if (!found) {
/*
* (2.2) "otherwise the {base type definition} must have an
* {attribute wildcard} and the {target namespace} of the
- * R's {attribute declaration} must be ·valid· with respect
+ * R's {attribute declaration} must be `valid` with respect
* to that wildcard, as defined in Wildcard allows Namespace
- * Name (§3.10.4)."
+ * Name ($3.10.4)."
*/
if ((baseWild == NULL) ||
(xmlSchemaCheckCVCWildcardNamespace(baseWild,
(WXS_ATTRUSE_DECL(cur))->targetNamespace) != 0))
{
xmlChar *str = NULL;
-
+
xmlSchemaPAttrUseErr4(pctxt,
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2,
WXS_ITEM_NODE(item), item, cur,
@@ -14167,7 +14273,7 @@ not_found:
}
}
/*
- * SPEC derivation-ok-restriction (3):
+ * SPEC derivation-ok-restriction (3):
* (3) "For each attribute use in the {attribute uses} of the {base type
* definition} whose {required} is true, there must be an attribute
* use with an {attribute declaration} with the same {name} and
@@ -14182,7 +14288,7 @@ not_found:
found = 0;
if (uses != NULL) {
for (i = 0; i < uses->nbItems; i++) {
- cur = uses->items[i];
+ cur = uses->items[i];
if ((WXS_ATTRUSE_DECL_NAME(cur) ==
WXS_ATTRUSE_DECL_NAME(bcur)) &&
(WXS_ATTRUSE_DECL_TNS(cur) ==
@@ -14194,7 +14300,7 @@ not_found:
}
if (!found) {
xmlChar *strA = NULL, *strB = NULL;
-
+
xmlSchemaCustomErr4(ACTXT_CAST pctxt,
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3,
NULL, item,
@@ -14216,19 +14322,19 @@ not_found:
/*
* (4) "If there is an {attribute wildcard}, all of the
* following must be true:"
- */
+ */
if (baseWild == NULL) {
xmlChar *str = NULL;
/*
* (4.1) "The {base type definition} must also have one."
- */
+ */
xmlSchemaCustomErr4(ACTXT_CAST pctxt,
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1,
NULL, item,
"The %s has an attribute wildcard, "
"but the %s %s '%s' does not have one",
- WXS_ITEM_TYPE_NAME(item),
+ WXS_ITEM_TYPE_NAME(item),
WXS_ACTION_STR(action),
WXS_ITEM_TYPE_NAME(baseItem),
xmlSchemaGetComponentQName(&str, baseItem));
@@ -14242,7 +14348,7 @@ not_found:
* (4.2) "The complex type definition's {attribute wildcard}'s
* {namespace constraint} must be a subset of the {base type
* definition}'s {attribute wildcard}'s {namespace constraint},
- * as defined by Wildcard Subset (§3.10.6)."
+ * as defined by Wildcard Subset ($3.10.6)."
*/
xmlSchemaCustomErr4(ACTXT_CAST pctxt,
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2,
@@ -14256,8 +14362,8 @@ not_found:
FREE_AND_NULL(str);
return(pctxt->err);
}
- /* 4.3 Unless the {base type definition} is the ·ur-type
- * definition·, the complex type definition's {attribute
+ /* 4.3 Unless the {base type definition} is the `ur-type
+ * definition`, the complex type definition's {attribute
* wildcard}'s {process contents} must be identical to or
* stronger than the {base type definition}'s {attribute
* wildcard}'s {process contents}, where strict is stronger
@@ -14308,7 +14414,7 @@ xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaTypePtr type)
{
xmlSchemaTypePtr baseType = NULL;
- xmlSchemaAttributeUsePtr use;
+ xmlSchemaAttributeUsePtr use;
xmlSchemaItemListPtr uses, baseUses, prohibs = NULL;
if (type->baseType == NULL) {
@@ -14316,7 +14422,7 @@ xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt,
"no base type");
return (-1);
}
- baseType = type->baseType;
+ baseType = type->baseType;
if (WXS_IS_TYPE_NOT_FIXED(baseType))
if (xmlSchemaTypeFixup(baseType, ACTXT_CAST pctxt) == -1)
return(-1);
@@ -14328,7 +14434,7 @@ xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt,
* wildcard, i.e. intersect multiple wildcards.
* Move attribute prohibitions into a separate list.
*/
- if (uses != NULL) {
+ if (uses != NULL) {
if (WXS_IS_RESTRICTION(type)) {
/*
* This one will transfer all attr. prohibitions
@@ -14362,7 +14468,7 @@ xmlSchemaFixupTypeAttributeUses(xmlSchemaParserCtxtPtr pctxt,
if (WXS_IS_RESTRICTION(type)) {
int usesCount;
- xmlSchemaAttributeUsePtr tmp;
+ xmlSchemaAttributeUsePtr tmp;
if (uses != NULL)
usesCount = uses->nbItems;
@@ -14412,15 +14518,15 @@ inherit_next: {}
}
} else {
/* Extension. */
- for (i = 0; i < baseUses->nbItems; i++) {
- use = baseUses->items[i];
+ for (i = 0; i < baseUses->nbItems; i++) {
+ use = baseUses->items[i];
if (uses == NULL) {
type->attrUses = xmlSchemaItemListCreate();
if (type->attrUses == NULL)
goto exit_failure;
uses = type->attrUses;
}
- xmlSchemaItemListAddSize(uses, baseUses->nbItems, use);
+ xmlSchemaItemListAddSize(uses, baseUses->nbItems, use);
}
}
}
@@ -14440,10 +14546,10 @@ inherit_next: {}
/*
* Compute the complete wildcard.
*/
- if (WXS_IS_EXTENSION(type)) {
+ if (WXS_IS_EXTENSION(type)) {
if (baseType->attributeWildcard != NULL) {
/*
- * (3.2.2.1) "If the ·base wildcard· is non-·absent·, then
+ * (3.2.2.1) "If the `base wildcard` is non-`absent`, then
* the appropriate case among the following:"
*/
if (type->attributeWildcard != NULL) {
@@ -14451,26 +14557,26 @@ inherit_next: {}
* Union the complete wildcard with the base wildcard.
* SPEC {attribute wildcard}
* (3.2.2.1.2) "otherwise a wildcard whose {process contents}
- * and {annotation} are those of the ·complete wildcard·,
+ * and {annotation} are those of the `complete wildcard`,
* and whose {namespace constraint} is the intensional union
- * of the {namespace constraint} of the ·complete wildcard·
- * and of the ·base wildcard·, as defined in Attribute
- * Wildcard Union (§3.10.6)."
+ * of the {namespace constraint} of the `complete wildcard`
+ * and of the `base wildcard`, as defined in Attribute
+ * Wildcard Union ($3.10.6)."
*/
if (xmlSchemaUnionWildcards(pctxt, type->attributeWildcard,
baseType->attributeWildcard) == -1)
- goto exit_failure;
+ goto exit_failure;
} else {
/*
- * (3.2.2.1.1) "If the ·complete wildcard· is ·absent·,
- * then the ·base wildcard·."
+ * (3.2.2.1.1) "If the `complete wildcard` is `absent`,
+ * then the `base wildcard`."
*/
type->attributeWildcard = baseType->attributeWildcard;
- }
+ }
} else {
/*
- * (3.2.2.2) "otherwise (the ·base wildcard· is ·absent·) the
- * ·complete wildcard"
+ * (3.2.2.2) "otherwise (the `base wildcard` is `absent`) the
+ * `complete wildcard`"
* NOOP
*/
}
@@ -14478,11 +14584,11 @@ inherit_next: {}
/*
* SPEC {attribute wildcard}
* (3.1) "If the <restriction> alternative is chosen, then the
- * ·complete wildcard·;"
+ * `complete wildcard`;"
* NOOP
*/
}
-
+
return (0);
exit_failure:
@@ -14586,6 +14692,7 @@ xmlSchemaGetParticleTotalRangeMin(xmlSchemaParticlePtr particle)
}
}
+#if 0
/**
* xmlSchemaGetParticleTotalRangeMax:
* @particle: the particle
@@ -14645,6 +14752,7 @@ xmlSchemaGetParticleTotalRangeMax(xmlSchemaParticlePtr particle)
return (particle->maxOccurs * sum);
}
}
+#endif
/**
* xmlSchemaIsParticleEmptiable:
@@ -14725,12 +14833,12 @@ xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr actxt,
/* 2.2 */
if (type->baseType == baseType) {
/*
- * 2.2.1 D's ·base type definition· is B.
+ * 2.2.1 D's `base type definition` is B.
*/
return (0);
}
/*
- * 2.2.2 D's ·base type definition· is not the ·ur-type definition·
+ * 2.2.2 D's `base type definition` is not the `ur-type definition`
* and is validly derived from B given the subset, as defined by this
* constraint.
*/
@@ -14740,8 +14848,8 @@ xmlSchemaCheckCOSSTDerivedOK(xmlSchemaAbstractCtxtPtr actxt,
return (0);
}
/*
- * 2.2.3 D's {variety} is list or union and B is the ·simple ur-type
- * definition·.
+ * 2.2.3 D's {variety} is list or union and B is the `simple ur-type
+ * definition`.
*/
if (WXS_IS_ANY_SIMPLE_TYPE(baseType) &&
(WXS_IS_LIST(type) || WXS_IS_UNION(type))) {
@@ -14857,10 +14965,10 @@ static int
xmlSchemaCheckUnionTypeDefCircularRecur(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaTypePtr ctxType,
xmlSchemaTypeLinkPtr members)
-{
+{
xmlSchemaTypeLinkPtr member;
xmlSchemaTypePtr memberType;
-
+
member = members;
while (member != NULL) {
memberType = member->type;
@@ -14961,7 +15069,7 @@ xmlSchemaResolveTypeReferences(xmlSchemaTypePtr typeDef,
}
return;
}
- }
+ }
/*
* The ball of letters below means, that if we have a particle
* which has a QName-helper component as its {term}, we want
@@ -15004,7 +15112,7 @@ xmlSchemaResolveTypeReferences(xmlSchemaTypePtr typeDef,
* particle's {term}.
*/
WXS_TYPE_PARTICLE_TERM(typeDef) = WXS_MODELGROUPDEF_MODEL(groupDef);
-
+
if (WXS_MODELGROUPDEF_MODEL(groupDef)->type == XML_SCHEMA_TYPE_ALL) {
/*
* SPEC cos-all-limited (1.2)
@@ -15053,14 +15161,14 @@ xmlSchemaCheckSTPropsCorrect(xmlSchemaParserCtxtPtr ctxt,
* NOTE: This is somehow redundant, since we actually built a simple type
* to have all the needed information; this acts as an self test.
*/
- /* Base type: If the datatype has been ·derived· by ·restriction·
- * then the Simple Type Definition component from which it is ·derived·,
- * otherwise the Simple Type Definition for anySimpleType (§4.1.6).
+ /* Base type: If the datatype has been `derived` by `restriction`
+ * then the Simple Type Definition component from which it is `derived`,
+ * otherwise the Simple Type Definition for anySimpleType ($4.1.6).
*/
if (baseType == NULL) {
/*
* TODO: Think about: "modulo the impact of Missing
- * Sub-components (§5.3)."
+ * Sub-components ($5.3)."
*/
xmlSchemaPCustomErr(ctxt,
XML_SCHEMAP_ST_PROPS_CORRECT_1,
@@ -15078,13 +15186,14 @@ xmlSchemaCheckSTPropsCorrect(xmlSchemaParserCtxtPtr ctxt,
FREE_AND_NULL(str)
return (XML_SCHEMAP_ST_PROPS_CORRECT_1);
}
- if ( (WXS_IS_LIST(type) || WXS_IS_UNION(type)) &&
- (WXS_IS_RESTRICTION(type) == 0) &&
- (! WXS_IS_ANY_SIMPLE_TYPE(baseType))) {
+ if ((WXS_IS_LIST(type) || WXS_IS_UNION(type)) &&
+ (WXS_IS_RESTRICTION(type) == 0) &&
+ ((! WXS_IS_ANY_SIMPLE_TYPE(baseType)) &&
+ (baseType->type != XML_SCHEMA_TYPE_SIMPLE))) {
xmlSchemaPCustomErr(ctxt,
XML_SCHEMAP_ST_PROPS_CORRECT_1,
WXS_BASIC_CAST type, NULL,
- "A type, derived by list or union, must have"
+ "A type, derived by list or union, must have "
"the simple ur-type definition as base type, not '%s'",
xmlSchemaGetComponentQName(&str, baseType));
FREE_AND_NULL(str)
@@ -15119,10 +15228,10 @@ xmlSchemaCheckSTPropsCorrect(xmlSchemaParserCtxtPtr ctxt,
}
/*
- * 2 All simple type definitions must be derived ultimately from the ·simple
- * ur-type definition (so· circular definitions are disallowed). That is, it
- * must be possible to reach a built-in primitive datatype or the ·simple
- * ur-type definition· by repeatedly following the {base type definition}.
+ * 2 All simple type definitions must be derived ultimately from the `simple
+ * ur-type definition` (so circular definitions are disallowed). That is, it
+ * must be possible to reach a built-in primitive datatype or the `simple
+ * ur-type definition` by repeatedly following the {base type definition}.
*
* NOTE: this is done in xmlSchemaCheckTypeDefCircular().
*/
@@ -15306,10 +15415,10 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
}
/*
* MAYBE TODO: (Hmm, not really) Datatypes states:
- * A ·list· datatype can be ·derived· from an ·atomic· datatype
- * whose ·lexical space· allows space (such as string or anyURI)or
- * a ·union· datatype any of whose {member type definitions}'s
- * ·lexical space· allows space.
+ * A `list` datatype can be `derived` from an `atomic` datatype
+ * whose `lexical space` allows space (such as string or anyURI)or
+ * a `union` datatype any of whose {member type definitions}'s
+ * `lexical space` allows space.
*/
} else {
/*
@@ -15346,7 +15455,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
/*
* 2.3.2.3 The {item type definition} must be validly derived
* from the {base type definition}'s {item type definition} given
- * the empty set, as defined in Type Derivation OK (Simple) (§3.14.6).
+ * the empty set, as defined in Type Derivation OK (Simple) ($3.14.6).
*/
{
xmlSchemaTypePtr baseItemType;
@@ -15393,7 +15502,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
case XML_SCHEMA_FACET_WHITESPACE:
/*
* TODO: 2.5.1.2 List datatypes
- * The value of ·whiteSpace· is fixed to the value collapse.
+ * The value of `whiteSpace` is fixed to the value collapse.
*/
case XML_SCHEMA_FACET_PATTERN:
case XML_SCHEMA_FACET_ENUMERATION:
@@ -15446,8 +15555,8 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
member = member->next;
}
/*
- * 3.3.1 If the {base type definition} is the ·simple ur-type
- * definition·
+ * 3.3.1 If the {base type definition} is the `simple ur-type
+ * definition`
*/
if (type->baseType->builtInType == XML_SCHEMAS_ANYSIMPLETYPE) {
/*
@@ -15509,7 +15618,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
* 3.3.2.3 The {member type definitions}, in order, must be validly
* derived from the corresponding type definitions in the {base
* type definition}'s {member type definitions} given the empty set,
- * as defined in Type Derivation OK (Simple) (§3.14.6).
+ * as defined in Type Derivation OK (Simple) ($3.14.6).
*/
{
xmlSchemaTypeLinkPtr baseMember;
@@ -15557,7 +15666,8 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
return (XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3);
}
member = member->next;
- baseMember = baseMember->next;
+ if (baseMember != NULL)
+ baseMember = baseMember->next;
}
}
}
@@ -15601,7 +15711,7 @@ xmlSchemaCheckCOSSTRestricts(xmlSchemaParserCtxtPtr pctxt,
* @ctxt: the schema parser context
* @type: the simple type definition
*
- * Checks crc-simple-type constraints.
+ * Checks crc-simple-type constraints.
*
* Returns 0 if the constraints are satisfied,
* if not a positive error code and -1 on internal
@@ -15615,8 +15725,8 @@ xmlSchemaCheckSRCSimpleType(xmlSchemaParserCtxtPtr ctxt,
/*
* src-simple-type.1 The corresponding simple type definition, if any,
* must satisfy the conditions set out in Constraints on Simple Type
- * Definition Schema Components (§3.14.6).
- */
+ * Definition Schema Components ($3.14.6).
+ */
if (WXS_IS_RESTRICTION(type)) {
/*
* src-simple-type.2 "If the <restriction> alternative is chosen,
@@ -15625,7 +15735,7 @@ xmlSchemaCheckSRCSimpleType(xmlSchemaParserCtxtPtr ctxt,
* NOTE: This is checked in the parse function of <restriction>.
*/
/*
- *
+ *
*/
} else if (WXS_IS_LIST(type)) {
/* src-simple-type.3 "If the <list> alternative is chosen, either it must have
@@ -15634,8 +15744,8 @@ xmlSchemaCheckSRCSimpleType(xmlSchemaParserCtxtPtr ctxt,
*
* NOTE: This is checked in the parse function of <list>.
*/
- } else if (WXS_IS_UNION(type)) {
- /*
+ } else if (WXS_IS_UNION(type)) {
+ /*
* src-simple-type.4 is checked in xmlSchemaCheckUnionTypeDefCircular().
*/
}
@@ -15713,8 +15823,8 @@ xmlSchemaParseCheckCOSValidDefault(xmlSchemaParserCtxtPtr pctxt,
* SPEC (2.1) "its {content type} must be a simple type definition
* or mixed."
* SPEC (2.2.2) "If the {content type} is mixed, then the {content
- * type}'s particle must be ·emptiable· as defined by
- * Particle Emptiable (§3.9.6)."
+ * type}'s particle must be `emptiable` as defined by
+ * Particle Emptiable ($3.9.6)."
*/
if ((! WXS_HAS_SIMPLE_CONTENT(type)) &&
((! WXS_HAS_MIXED_CONTENT(type)) || (! WXS_EMPTIABLE(type)))) {
@@ -15730,14 +15840,14 @@ xmlSchemaParseCheckCOSValidDefault(xmlSchemaParserCtxtPtr pctxt,
}
/*
* 1 If the type definition is a simple type definition, then the string
- * must be ·valid· with respect to that definition as defined by String
- * Valid (§3.14.4).
+ * must be `valid` with respect to that definition as defined by String
+ * Valid ($3.14.4).
*
* AND
*
* 2.2.1 If the {content type} is a simple type definition, then the
- * string must be ·valid· with respect to that simple type definition
- * as defined by String Valid (§3.14.4).
+ * string must be `valid` with respect to that simple type definition
+ * as defined by String Valid ($3.14.4).
*/
if (WXS_IS_SIMPLE(type))
ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt, node,
@@ -15778,8 +15888,8 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
*
* SPEC (1) "The values of the properties of a complex type definition must
* be as described in the property tableau in The Complex Type Definition
- * Schema Component (§3.4.1), modulo the impact of Missing
- * Sub-components (§5.3)."
+ * Schema Component ($3.4.1), modulo the impact of Missing
+ * Sub-components ($5.3)."
*/
if ((type->baseType != NULL) &&
(WXS_IS_SIMPLE(type->baseType)) &&
@@ -15790,15 +15900,15 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
*/
xmlSchemaCustomErr(ACTXT_CAST pctxt,
XML_SCHEMAP_SRC_CT_1,
- NULL, WXS_BASIC_CAST type,
+ NULL, WXS_BASIC_CAST type,
"If the base type is a simple type, the derivation method must be "
"'extension'", NULL, NULL);
return (XML_SCHEMAP_SRC_CT_1);
}
/*
- * SPEC (3) "Circular definitions are disallowed, except for the ·ur-type
- * definition·. That is, it must be possible to reach the ·ur-type
- * definition by repeatedly following the {base type definition}."
+ * SPEC (3) "Circular definitions are disallowed, except for the `ur-type
+ * definition`. That is, it must be possible to reach the `ur-type
+ * definition` by repeatedly following the {base type definition}."
*
* NOTE (3) is done in xmlSchemaCheckTypeDefCircular().
*/
@@ -15807,7 +15917,7 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
* - attribute uses need to be already inherited (apply attr. prohibitions)
* - attribute group references need to be expanded already
* - simple types need to be typefixed already
- */
+ */
if (type->attrUses &&
(((xmlSchemaItemListPtr) type->attrUses)->nbItems > 1))
{
@@ -15817,8 +15927,8 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
for (i = uses->nbItems -1; i >= 0; i--) {
use = uses->items[i];
-
- /*
+
+ /*
* SPEC ct-props-correct
* (4) "Two distinct attribute declarations in the
* {attribute uses} must not have identical {name}s and
@@ -15859,10 +15969,10 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
if (WXS_ATTRUSE_TYPEDEF(use) != NULL) {
if (xmlSchemaIsDerivedFromBuiltInType(
WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID))
- {
+ {
if (hasId) {
xmlChar *str = NULL;
-
+
xmlSchemaCustomErr(ACTXT_CAST pctxt,
XML_SCHEMAP_AG_PROPS_CORRECT,
NULL, WXS_BASIC_CAST type,
@@ -15876,7 +15986,7 @@ xmlSchemaCheckCTPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
if (xmlSchemaItemListRemove(uses, i) == -1)
goto exit_failure;
}
-
+
hasId = 1;
}
}
@@ -15950,8 +16060,8 @@ xmlSchemaCheckCOSCTDerivedOK(xmlSchemaAbstractCtxtPtr actxt,
if (type->baseType == baseType)
return (0);
/*
- * SPEC (2.3.1) "D's {base type definition} must not be the ·ur-type
- * definition·."
+ * SPEC (2.3.1) "D's {base type definition} must not be the `ur-type
+ * definition`."
*/
if (WXS_IS_ANYTYPE(type->baseType))
return (1);
@@ -15968,7 +16078,7 @@ xmlSchemaCheckCOSCTDerivedOK(xmlSchemaAbstractCtxtPtr actxt,
/*
* SPEC (2.3.2.2) "If D's {base type definition} is simple, then it
* must be validly derived from B given the subset as defined in Type
- * Derivation OK (Simple) (§3.14.6).
+ * Derivation OK (Simple) ($3.14.6).
*/
return (xmlSchemaCheckCOSSTDerivedOK(actxt, type->baseType,
baseType, set));
@@ -16029,7 +16139,7 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
* SPEC (1) "If the {base type definition} is a complex type definition,
* then all of the following must be true:"
*/
- if (WXS_IS_COMPLEX(base)) {
+ if (WXS_IS_COMPLEX(base)) {
/*
* SPEC (1.1) "The {final} of the {base type definition} must not
* contain extension."
@@ -16042,7 +16152,7 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
"contains 'extension'", NULL);
return (XML_SCHEMAP_COS_CT_EXTENDS_1_1);
}
-
+
/*
* ATTENTION: The constrains (1.2) and (1.3) are not applied,
* since they are automatically satisfied through the
@@ -16086,11 +16196,11 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
}
if (! found) {
xmlChar *str = NULL;
-
+
xmlSchemaCustomErr(ACTXT_CAST ctxt,
XML_SCHEMAP_COS_CT_EXTENDS_1_2,
NULL, WXS_BASIC_CAST type,
- /*
+ /*
* TODO: The report does not indicate that also the
* type needs to be the same.
*/
@@ -16108,9 +16218,9 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
* definition must also have one, and the base type definition's
* {attribute wildcard}'s {namespace constraint} must be a subset
* of the complex type definition's {attribute wildcard}'s {namespace
- * constraint}, as defined by Wildcard Subset (§3.10.6)."
+ * constraint}, as defined by Wildcard Subset ($3.10.6)."
*/
-
+
/*
* MAYBE TODO: Enable if ever needed. But this will be needed only
* if created the type via a schema construction API.
@@ -16118,7 +16228,7 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
if (base->attributeWildcard != NULL) {
if (type->attributeWilcard == NULL) {
xmlChar *str = NULL;
-
+
xmlSchemaCustomErr(ACTXT_CAST pctxt,
XML_SCHEMAP_COS_CT_EXTENDS_1_3,
NULL, type,
@@ -16131,7 +16241,7 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
base->attributeWildcard, type->attributeWildcard))
{
xmlChar *str = NULL;
-
+
xmlSchemaCustomErr(ACTXT_CAST pctxt,
XML_SCHEMAP_COS_CT_EXTENDS_1_3,
NULL, type,
@@ -16205,9 +16315,9 @@ xmlSchemaCheckCOSCTExtends(xmlSchemaParserCtxtPtr ctxt,
}
/*
* URGENT TODO SPEC (1.4.3.2.2.2) "The particle of the
- * complex type definition must be a ·valid extension·
+ * complex type definition must be a `valid extension`
* of the {base type definition}'s particle, as defined
- * in Particle Valid (Extension) (§3.9.6)."
+ * in Particle Valid (Extension) ($3.9.6)."
*
* NOTE that we won't check "Particle Valid (Extension)",
* since it is ensured by the derivation process in
@@ -16285,7 +16395,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
*/
base = type->baseType;
if (! WXS_IS_COMPLEX(base)) {
- xmlSchemaCustomErr(ACTXT_CAST ctxt,
+ xmlSchemaCustomErr(ACTXT_CAST ctxt,
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
type->node, WXS_BASIC_CAST type,
"The base type must be a complex type", NULL, NULL);
@@ -16296,7 +16406,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
* SPEC (1) "The {base type definition} must be a complex type
* definition whose {final} does not contain restriction."
*/
- xmlSchemaCustomErr(ACTXT_CAST ctxt,
+ xmlSchemaCustomErr(ACTXT_CAST ctxt,
XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1,
type->node, WXS_BASIC_CAST type,
"The 'final' of the base type definition "
@@ -16324,7 +16434,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
if (base->builtInType == XML_SCHEMAS_ANYTYPE) {
/*
* SPEC (5.1) "The {base type definition} must be the
- * ·ur-type definition·."
+ * `ur-type definition`."
* PASS
*/
} else if ((type->contentType == XML_SCHEMA_CONTENT_SIMPLE) ||
@@ -16343,11 +16453,11 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
* SPEC (5.2.2.1) "The {content type} of the {base type
* definition} must be a simple type definition from which
* the {content type} is validly derived given the empty
- * set as defined in Type Derivation OK (Simple) (§3.14.6)."
+ * set as defined in Type Derivation OK (Simple) ($3.14.6)."
*
* ATTENTION TODO: This seems not needed if the type implicitely
* derived from the base type.
- *
+ *
*/
err = xmlSchemaCheckCOSSTDerivedOK(ACTXT_CAST ctxt,
type->contentTypeDef, base->contentTypeDef, 0);
@@ -16374,8 +16484,8 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
(xmlSchemaParticlePtr) base->subtypes))) {
/*
* SPEC (5.2.2.2) "The {base type definition} must be mixed
- * and have a particle which is ·emptiable· as defined in
- * Particle Emptiable (§3.9.6)."
+ * and have a particle which is `emptiable` as defined in
+ * Particle Emptiable ($3.9.6)."
* PASS
*/
} else {
@@ -16404,7 +16514,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
/*
* SPEC (5.3.2.2) "The {content type} of the {base type
* definition} must be elementOnly or mixed and have a particle
- * which is ·emptiable· as defined in Particle Emptiable (§3.9.6)."
+ * which is `emptiable` as defined in Particle Emptiable ($3.9.6)."
* PASS
*/
} else {
@@ -16421,7 +16531,7 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
/*
* SPEC (5.4.1.1) "The {content type} of the complex type definition
* itself must be element-only"
- */
+ */
if (WXS_HAS_MIXED_CONTENT(type) && (! WXS_HAS_MIXED_CONTENT(base))) {
/*
* SPEC (5.4.1.2) "The {content type} of the complex type
@@ -16437,9 +16547,9 @@ xmlSchemaCheckDerivationOKRestriction(xmlSchemaParserCtxtPtr ctxt,
}
/*
* SPEC (5.4.2) "The particle of the complex type definition itself
- * must be a ·valid restriction· of the particle of the {content
+ * must be a `valid restriction` of the particle of the {content
* type} of the {base type definition} as defined in Particle Valid
- * (Restriction) (§3.9.6).
+ * (Restriction) ($3.9.6).
*
* URGENT TODO: (5.4.2)
*/
@@ -16508,7 +16618,7 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt,
if (! WXS_HAS_SIMPLE_CONTENT(type)) {
/*
* 1 If the <complexContent> alternative is chosen, the type definition
- * ·resolved· to by the ·actual value· of the base [attribute]
+ * `resolved` to by the `actual value` of the base [attribute]
* must be a complex type definition;
*/
if (! WXS_IS_COMPLEX(base)) {
@@ -16528,7 +16638,7 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt,
* SPEC
* 2 If the <simpleContent> alternative is chosen, all of the
* following must be true:
- * 2.1 The type definition ·resolved· to by the ·actual value· of the
+ * 2.1 The type definition `resolved` to by the `actual value` of the
* base [attribute] must be one of the following:
*/
if (WXS_IS_SIMPLE(base)) {
@@ -16578,11 +16688,11 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt,
if (! xmlSchemaIsParticleEmptiable(
(xmlSchemaParticlePtr) base->subtypes)) {
ret = XML_SCHEMAP_SRC_CT_1;
- } else
+ } else
/*
* Attention: at this point the <simpleType> child is in
* ->contentTypeDef (put there during parsing).
- */
+ */
if (type->contentTypeDef == NULL) {
xmlChar *str = NULL;
/*
@@ -16634,14 +16744,14 @@ xmlSchemaCheckSRCCT(xmlSchemaParserCtxtPtr ctxt,
/*
* SPEC (3) "The corresponding complex type definition component must
* satisfy the conditions set out in Constraints on Complex Type
- * Definition Schema Components (§3.4.6);"
+ * Definition Schema Components ($3.4.6);"
* NOTE (3) will be done in xmlSchemaTypeFixup().
*/
/*
* SPEC (4) If clause 2.2.1 or clause 2.2.2 in the correspondence specification
* above for {attribute wildcard} is satisfied, the intensional
* intersection must be expressible, as defined in Attribute Wildcard
- * Intersection (§3.10.6).
+ * Intersection ($3.10.6).
* NOTE (4) is done in xmlSchemaFixupTypeAttributeUses().
*/
return (ret);
@@ -16712,7 +16822,7 @@ xmlSchemaCheckRCaseNameAndTypeOK(xmlSchemaParserCtxtPtr ctxt,
return (1);
/*
* SPEC (2) "R's occurrence range is a valid restriction of B's
- * occurrence range as defined by Occurrence Range OK (§3.9.6)."
+ * occurrence range as defined by Occurrence Range OK ($3.9.6)."
*/
if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
b->minOccurs, b->maxOccurs) != 0)
@@ -16804,19 +16914,19 @@ xmlSchemaCheckRCaseNSCompat(xmlSchemaParserCtxtPtr ctxt,
{
/* TODO:Error codes (rcase-NSCompat). */
/*
- * SPEC "For an element declaration particle to be a ·valid restriction·
+ * SPEC "For an element declaration particle to be a `valid restriction`
* of a wildcard particle all of the following must be true:"
*
- * SPEC (1) "The element declaration's {target namespace} is ·valid·
+ * SPEC (1) "The element declaration's {target namespace} is `valid`
* with respect to the wildcard's {namespace constraint} as defined by
- * Wildcard allows Namespace Name (§3.10.4)."
+ * Wildcard allows Namespace Name ($3.10.4)."
*/
if (xmlSchemaCheckCVCWildcardNamespace((xmlSchemaWildcardPtr) b->children,
((xmlSchemaElementPtr) r->children)->targetNamespace) != 0)
return (1);
/*
* SPEC (2) "R's occurrence range is a valid restriction of B's
- * occurrence range as defined by Occurrence Range OK (§3.9.6)."
+ * occurrence range as defined by Occurrence Range OK ($3.9.6)."
*/
if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
b->minOccurs, b->maxOccurs) != 0)
@@ -16876,21 +16986,21 @@ xmlSchemaCheckRCaseNSSubset(xmlSchemaParserCtxtPtr ctxt,
/* TODO: Error codes (rcase-NSSubset). */
/*
* SPEC (1) "R's occurrence range is a valid restriction of B's
- * occurrence range as defined by Occurrence Range OK (§3.9.6)."
+ * occurrence range as defined by Occurrence Range OK ($3.9.6)."
*/
if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
b->minOccurs, b->maxOccurs))
return (1);
/*
* SPEC (2) "R's {namespace constraint} must be an intensional subset
- * of B's {namespace constraint} as defined by Wildcard Subset (§3.10.6)."
+ * of B's {namespace constraint} as defined by Wildcard Subset ($3.10.6)."
*/
if (xmlSchemaCheckCOSNSSubset((xmlSchemaWildcardPtr) r->children,
(xmlSchemaWildcardPtr) b->children))
return (1);
/*
- * SPEC (3) "Unless B is the content model wildcard of the ·ur-type
- * definition·, R's {process contents} must be identical to or stronger
+ * SPEC (3) "Unless B is the content model wildcard of the `ur-type
+ * definition`, R's {process contents} must be identical to or stronger
* than B's {process contents}, where strict is stronger than lax is
* stronger than skip."
*/
@@ -16940,6 +17050,7 @@ xmlSchemaCheckCOSParticleRestrict(xmlSchemaParserCtxtPtr ctxt,
return (0);
}
+#if 0
/**
* xmlSchemaCheckRCaseNSRecurseCheckCardinality:
* @ctxt: the schema parser context
@@ -16967,12 +17078,12 @@ xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt,
if ((r->children == NULL) || (r->children->children == NULL))
return (-1);
/*
- * SPEC "For a group particle to be a ·valid restriction· of a
+ * SPEC "For a group particle to be a `valid restriction` of a
* wildcard particle..."
*
- * SPEC (1) "Every member of the {particles} of the group is a ·valid
- * restriction· of the wildcard as defined by
- * Particle Valid (Restriction) (§3.9.6)."
+ * SPEC (1) "Every member of the {particles} of the group is a `valid
+ * restriction` of the wildcard as defined by
+ * Particle Valid (Restriction) ($3.9.6)."
*/
part = (xmlSchemaParticlePtr) r->children->children;
do {
@@ -16983,7 +17094,7 @@ xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt,
/*
* SPEC (2) "The effective total range of the group [...] is a
* valid restriction of B's occurrence range as defined by
- * Occurrence Range OK (§3.9.6)."
+ * Occurrence Range OK ($3.9.6)."
*/
if (xmlSchemaCheckParticleRangeOK(
xmlSchemaGetParticleTotalRangeMin(r),
@@ -16992,6 +17103,7 @@ xmlSchemaCheckRCaseNSRecurseCheckCardinality(xmlSchemaParserCtxtPtr ctxt,
return (1);
return (0);
}
+#endif
/**
* xmlSchemaCheckRCaseRecurse:
@@ -17022,11 +17134,11 @@ xmlSchemaCheckRCaseRecurse(xmlSchemaParserCtxtPtr ctxt,
(r->children->type != b->children->type))
return (-1);
/*
- * SPEC "For an all or sequence group particle to be a ·valid
- * restriction· of another group particle with the same {compositor}..."
+ * SPEC "For an all or sequence group particle to be a `valid
+ * restriction` of another group particle with the same {compositor}..."
*
* SPEC (1) "R's occurrence range is a valid restriction of B's
- * occurrence range as defined by Occurrence Range OK (§3.9.6)."
+ * occurrence range as defined by Occurrence Range OK ($3.9.6)."
*/
if (xmlSchemaCheckParticleRangeOK(r->minOccurs, r->maxOccurs,
b->minOccurs, b->maxOccurs))
@@ -17123,7 +17235,7 @@ xmlSchemaDeriveAndValidateFacets(xmlSchemaParserCtxtPtr pctxt,
/*
* SPEC st-restrict-facets 1:
- * "The {variety} of R is the same as that of B."
+ * "The {variety} of R is the same as that of B."
*/
/*
* SPEC st-restrict-facets 2:
@@ -17277,7 +17389,7 @@ xmlSchemaDeriveAndValidateFacets(xmlSchemaParserCtxtPtr pctxt,
flength = bflength;
if (flength) {
if (! fminlen)
- flength = bflength;
+ fminlen = bfminlen;
if (fminlen) {
/* (1.1) length >= minLength */
res = xmlSchemaCompareValues(flength->val, fminlen->val);
@@ -17595,7 +17707,7 @@ xmlSchemaDeriveAndValidateFacets(xmlSchemaParserCtxtPtr pctxt,
* The whitespace must be stronger.
*/
if (facet->whitespace < bfacet->whitespace) {
- FACET_RESTR_ERR(flength,
+ FACET_RESTR_ERR(facet,
"The 'whitespace' value has to be equal to "
"or stronger than the 'whitespace' value of "
"the base type")
@@ -17650,7 +17762,7 @@ xmlSchemaFinishMemberTypeDefinitionsProperty(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaTypeLinkPtr link, lastLink, prevLink, subLink, newLink;
/*
* The actual value is then formed by replacing any union type
- * definition in the ·explicit members· with the members of their
+ * definition in the `explicit members` with the members of their
* {member type definitions}, in order.
*
* TODO: There's a bug entry at
@@ -17696,7 +17808,7 @@ xmlSchemaFinishMemberTypeDefinitionsProperty(xmlSchemaParserCtxtPtr pctxt,
static void
xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type)
-{
+{
int has = 0, needVal = 0, normVal = 0;
has = (type->baseType->flags & XML_SCHEMAS_TYPE_HAS_FACETS) ? 1 : 0;
@@ -17708,7 +17820,7 @@ xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type)
}
if (type->facets != NULL) {
xmlSchemaFacetPtr fac;
-
+
for (fac = type->facets; fac != NULL; fac = fac->next) {
switch (fac->type) {
case XML_SCHEMA_FACET_WHITESPACE:
@@ -17726,7 +17838,7 @@ xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type)
has = 1;
break;
}
- }
+ }
}
if (normVal)
type->flags |= XML_SCHEMAS_TYPE_NORMVALUENEEDED;
@@ -17743,24 +17855,24 @@ xmlSchemaTypeFixupOptimFacets(xmlSchemaTypePtr type)
if ((prim->builtInType != XML_SCHEMAS_ANYSIMPLETYPE) &&
(prim->builtInType != XML_SCHEMAS_STRING)) {
type->flags |= XML_SCHEMAS_TYPE_FACETSNEEDVALUE;
- }
- }
+ }
+ }
}
static int
xmlSchemaTypeFixupWhitespace(xmlSchemaTypePtr type)
{
-
-
+
+
/*
* Evaluate the whitespace-facet value.
- */
+ */
if (WXS_IS_LIST(type)) {
type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE;
return (0);
} else if (WXS_IS_UNION(type))
return (0);
-
+
if (type->facetSet != NULL) {
xmlSchemaFacetLinkPtr lin;
@@ -17784,23 +17896,23 @@ xmlSchemaTypeFixupWhitespace(xmlSchemaTypePtr type)
}
}
/*
- * For all ·atomic· datatypes other than string (and types ·derived·
- * by ·restriction· from it) the value of whiteSpace is fixed to
+ * For all `atomic` datatypes other than string (and types `derived`
+ * by `restriction` from it) the value of whiteSpace is fixed to
* collapse
*/
{
xmlSchemaTypePtr anc;
- for (anc = type->baseType; anc != NULL &&
+ for (anc = type->baseType; anc != NULL &&
anc->builtInType != XML_SCHEMAS_ANYTYPE;
anc = anc->baseType) {
if (anc->type == XML_SCHEMA_TYPE_BASIC) {
- if (anc->builtInType == XML_SCHEMAS_NORMSTRING) {
+ if (anc->builtInType == XML_SCHEMAS_NORMSTRING) {
type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_REPLACE;
} else if ((anc->builtInType == XML_SCHEMAS_STRING) ||
- (anc->builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) {
+ (anc->builtInType == XML_SCHEMAS_ANYSIMPLETYPE)) {
type->flags |= XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE;
} else
@@ -17837,7 +17949,7 @@ xmlSchemaFixupSimpleTypeStageOne(xmlSchemaParserCtxtPtr pctxt,
} else if (WXS_IS_UNION(type)) {
/*
* Corresponds to <simpleType><union>...
- */
+ */
if (type->memberTypes == NULL) {
/*
* This one is really needed, so get out.
@@ -17845,8 +17957,8 @@ xmlSchemaFixupSimpleTypeStageOne(xmlSchemaParserCtxtPtr pctxt,
PERROR_INT("xmlSchemaFixupSimpleTypeStageOne",
"union type has no member-types assigned");
return(-1);
- }
- } else {
+ }
+ } else {
/*
* Corresponds to <simpleType><restriction>...
*/
@@ -17961,7 +18073,7 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt,
}
if (WXS_IS_TYPE_NOT_FIXED(type->baseType))
xmlSchemaTypeFixup(type->baseType, ACTXT_CAST pctxt);
- /*
+ /*
* If a member type of a union is a union itself, we need to substitute
* that member type for its member types.
* NOTE that this might change in WXS 1.1; i.e. we will keep the union
@@ -17969,12 +18081,12 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt,
*/
if ((type->memberTypes != NULL) &&
(xmlSchemaFinishMemberTypeDefinitionsProperty(pctxt, type) == -1))
- return(-1);
+ return(-1);
/*
- * SPEC src-simple-type 1
+ * SPEC src-simple-type 1
* "The corresponding simple type definition, if any, must satisfy
* the conditions set out in Constraints on Simple Type Definition
- * Schema Components (§3.14.6)."
+ * Schema Components ($3.14.6)."
*/
/*
* Schema Component Constraint: Simple Type Definition Properties Correct
@@ -17982,7 +18094,7 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt,
*/
res = xmlSchemaCheckSTPropsCorrect(pctxt, type);
HFAILURE HERROR
- /*
+ /*
* Schema Component Constraint: Derivation Valid (Restriction, Simple)
* (cos-st-restricts)
*/
@@ -18015,7 +18127,7 @@ xmlSchemaFixupSimpleTypeStageTwo(xmlSchemaParserCtxtPtr pctxt,
*/
res = xmlSchemaTypeFixupWhitespace(type);
HFAILURE HERROR
- xmlSchemaTypeFixupOptimFacets(type);
+ xmlSchemaTypeFixupOptimFacets(type);
exit_error:
#ifdef DEBUG_TYPE
@@ -18046,7 +18158,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
PERROR_INT("xmlSchemaFixupComplexType",
"missing baseType");
goto exit_failure;
- }
+ }
/*
* Fixup the base type.
*/
@@ -18058,12 +18170,12 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
* TODO: Generate a warning!
*/
return(0);
- }
+ }
/*
* This basically checks if the base type can be derived.
*/
res = xmlSchemaCheckSRCCT(pctxt, type);
- HFAILURE HERROR
+ HFAILURE HERROR
/*
* Fixup the content type.
*/
@@ -18137,7 +18249,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
type->facets = NULL;
content->facetSet = type->facetSet;
type->facetSet = NULL;
-
+
type->contentTypeDef = content;
if (WXS_IS_TYPE_NOT_FIXED(contentBase))
xmlSchemaTypeFixup(contentBase, ACTXT_CAST pctxt);
@@ -18146,10 +18258,10 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
* for circularity here.
*/
res = xmlSchemaFixupSimpleTypeStageOne(pctxt, content);
- HFAILURE HERROR
+ HFAILURE HERROR
res = xmlSchemaFixupSimpleTypeStageTwo(pctxt, content);
- HFAILURE HERROR
-
+ HFAILURE HERROR
+
} else if ((WXS_IS_COMPLEX(baseType)) &&
(baseType->contentType == XML_SCHEMA_CONTENT_MIXED) &&
(WXS_IS_RESTRICTION(type))) {
@@ -18234,7 +18346,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
( ((xmlSchemaTreeItemPtr) particle->children)->children == NULL))) {
if (type->flags & XML_SCHEMAS_TYPE_MIXED) {
/*
- * SPEC (2.1.4) "If the ·effective mixed· is true, then
+ * SPEC (2.1.4) "If the `effective mixed` is true, then
* a particle whose properties are as follows:..."
*
* Empty sequence model group with
@@ -18259,7 +18371,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
XML_SCHEMA_TYPE_SEQUENCE, type->node);
if (particle->children == NULL)
goto exit_failure;
-
+
type->subtypes = (xmlSchemaTypePtr) particle;
}
dummySequence = 1;
@@ -18296,7 +18408,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
if (type->contentType == XML_SCHEMA_CONTENT_EMPTY) {
/*
* SPEC (3.2.1)
- * "If the ·effective content· is empty, then the
+ * "If the `effective content` is empty, then the
* {content type} of the [...] base ..."
*/
type->contentType = baseType->contentType;
@@ -18394,8 +18506,8 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
particle->children->children =
(xmlSchemaTreeItemPtr) xmlSchemaAddParticle(pctxt,
type->node,
- ((xmlSchemaParticlePtr) type->subtypes)->minOccurs,
- ((xmlSchemaParticlePtr) type->subtypes)->maxOccurs);
+ ((xmlSchemaParticlePtr) baseType->subtypes)->minOccurs,
+ ((xmlSchemaParticlePtr) baseType->subtypes)->maxOccurs);
if (particle->children->children == NULL)
goto exit_failure;
particle = (xmlSchemaParticlePtr)
@@ -18403,7 +18515,7 @@ xmlSchemaFixupComplexType(xmlSchemaParserCtxtPtr pctxt,
particle->children =
((xmlSchemaParticlePtr) baseType->subtypes)->children;
/*
- * SPEC "followed by the ·effective content·."
+ * SPEC "followed by the `effective content`."
*/
particle->next = effectiveContent;
/*
@@ -18547,12 +18659,12 @@ xmlSchemaCheckFacet(xmlSchemaFacetPtr facet,
/* 4.3.5.5 Constraints on enumeration Schema Components
* Schema Component Constraint: enumeration valid restriction
- * It is an ·error· if any member of {value} is not in the
- * ·value space· of {base type definition}.
+ * It is an `error` if any member of {value} is not in the
+ * `value space` of {base type definition}.
*
* minInclusive, maxInclusive, minExclusive, maxExclusive:
- * The value ·must· be in the
- * ·value space· of the ·base type·.
+ * The value `must` be in the
+ * `value space` of the `base type`.
*/
/*
* This function is intended to deliver a compiled value
@@ -18572,11 +18684,11 @@ xmlSchemaCheckFacet(xmlSchemaFacetPtr facet,
}
} else
base = typeDecl;
-
+
if (! ctxtGiven) {
/*
* A context is needed if called from RelaxNG.
- */
+ */
pctxt = xmlSchemaNewParserCtxt("*");
if (pctxt == NULL)
return (-1);
@@ -18587,17 +18699,17 @@ xmlSchemaCheckFacet(xmlSchemaFacetPtr facet,
* facet->node is just the node holding the facet
* definition, *not* the attribute holding the *value*
* of the facet.
- */
+ */
ret = xmlSchemaVCheckCVCSimpleType(
ACTXT_CAST pctxt, facet->node, base,
facet->value, &(facet->val), 1, 1, 0);
if (ret != 0) {
if (ret < 0) {
/* No error message for RelaxNG. */
- if (ctxtGiven) {
+ if (ctxtGiven) {
xmlSchemaCustomErr(ACTXT_CAST pctxt,
XML_SCHEMAP_INTERNAL, facet->node, NULL,
- "Internal error: xmlSchemaCheckFacet, "
+ "Internal error: xmlSchemaCheckFacet, "
"failed to validate the value '%s' of the "
"facet '%s' against the base type",
facet->value, xmlSchemaFacetTypeToString(facet->type));
@@ -18672,17 +18784,17 @@ xmlSchemaCheckFacet(xmlSchemaFacetPtr facet,
/* error code */
xmlSchemaCustomErr4(ACTXT_CAST pctxt,
ret, facet->node, WXS_BASIC_CAST typeDecl,
- "The value '%s' of the facet '%s' is not a valid '%s'",
+ "The value '%s' of the facet '%s' is not a valid '%s'",
facet->value,
xmlSchemaFacetTypeToString(facet->type),
- (facet->type != XML_SCHEMA_FACET_TOTALDIGITS) ?
+ (facet->type != XML_SCHEMA_FACET_TOTALDIGITS) ?
BAD_CAST "nonNegativeInteger" :
BAD_CAST "positiveInteger",
NULL);
}
}
break;
-
+
case XML_SCHEMA_FACET_WHITESPACE:{
if (xmlStrEqual(facet->value, BAD_CAST "preserve")) {
facet->whitespace = XML_SCHEMAS_FACET_PRESERVE;
@@ -18895,7 +19007,7 @@ xmlSchemaModelGroupToModelGroupDefFixup(
{
particle = WXS_PTC_CAST particle->next;
continue;
- }
+ }
if (WXS_MODELGROUPDEF_MODEL(WXS_PARTICLE_TERM(particle)) == NULL) {
/*
* TODO: Remove the particle.
@@ -18945,7 +19057,7 @@ xmlSchemaCheckAttrGroupCircularRecur(xmlSchemaAttributeGroupPtr ctxtGr,
if (gr == ctxtGr)
return(ref);
if (gr->flags & XML_SCHEMAS_ATTRGROUP_MARKED)
- continue;
+ continue;
/*
* Mark as visited to avoid infinite recursion on
* circular references not yet examined.
@@ -18955,12 +19067,12 @@ xmlSchemaCheckAttrGroupCircularRecur(xmlSchemaAttributeGroupPtr ctxtGr,
{
gr->flags |= XML_SCHEMAS_ATTRGROUP_MARKED;
circ = xmlSchemaCheckAttrGroupCircularRecur(ctxtGr,
- (xmlSchemaItemListPtr) gr->attrUses);
+ (xmlSchemaItemListPtr) gr->attrUses);
gr->flags ^= XML_SCHEMAS_ATTRGROUP_MARKED;
if (circ != NULL)
return (circ);
}
-
+
}
}
return (NULL);
@@ -18987,9 +19099,9 @@ xmlSchemaCheckAttrGroupCircular(xmlSchemaAttributeGroupPtr attrGr,
* not be an <attributeGroup> with ref [attribute] which resolves
* to the component corresponding to this <attributeGroup>. Indirect
* circularity is also ruled out. That is, when QName resolution
- * (Schema Document) (§3.15.3) is applied to a ·QName· arising from
+ * (Schema Document) ($3.15.3) is applied to a `QName` arising from
* any <attributeGroup>s with a ref [attribute] among the [children],
- * it must not be the case that a ·QName· is encountered at any depth
+ * it must not be the case that a `QName` is encountered at any depth
* which resolves to the component corresponding to this <attributeGroup>.
*/
if (attrGr->attrUses == NULL)
@@ -18998,9 +19110,9 @@ xmlSchemaCheckAttrGroupCircular(xmlSchemaAttributeGroupPtr attrGr,
return(0);
else {
xmlSchemaQNameRefPtr circ;
-
+
circ = xmlSchemaCheckAttrGroupCircularRecur(attrGr,
- (xmlSchemaItemListPtr) attrGr->attrUses);
+ (xmlSchemaItemListPtr) attrGr->attrUses);
if (circ != NULL) {
xmlChar *str = NULL;
/*
@@ -19032,7 +19144,7 @@ xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt,
* xmlSchemaExpandAttributeGroupRefs:
* @pctxt: the parser context
* @node: the node of the component holding the attribute uses
- * @completeWild: the intersected wildcard to be returned
+ * @completeWild: the intersected wildcard to be returned
* @list: the attribute uses
*
* Substitutes contained attribute group references
@@ -19061,7 +19173,7 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt,
for (i = 0; i < list->nbItems; i++) {
use = list->items[i];
- if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
+ if (use->type == XML_SCHEMA_EXTRA_ATTR_USE_PROHIB) {
if (prohibs == NULL) {
PERROR_INT("xmlSchemaExpandAttributeGroupRefs",
"unexpected attr prohibition found");
@@ -19076,7 +19188,7 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt,
/*
* Note that duplicate prohibitions were already
* handled at parsing time.
- */
+ */
/*
* Add to list of prohibitions.
*/
@@ -19129,7 +19241,7 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt,
*completeWild = tmpWild;
created = 1;
}
-
+
if (xmlSchemaIntersectWildcards(pctxt, *completeWild,
gr->attributeWildcard) == -1)
return(-1);
@@ -19139,7 +19251,8 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt,
* Just remove the reference if the referenced group does not
* contain any attribute uses.
*/
- if (gr->attrUses == NULL) {
+ sublist = ((xmlSchemaItemListPtr) gr->attrUses);
+ if ((sublist == NULL) || sublist->nbItems == 0) {
if (xmlSchemaItemListRemove(list, i) == -1)
return(-1);
i--;
@@ -19148,18 +19261,15 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt,
/*
* Add the attribute uses.
*/
- sublist = ((xmlSchemaItemListPtr) gr->attrUses);
- if (sublist->nbItems != 0) {
- list->items[i] = sublist->items[0];
- if (sublist->nbItems != 1) {
- for (j = 1; j < sublist->nbItems; j++) {
- i++;
- if (xmlSchemaItemListInsert(list,
- sublist->items[j], i) == -1)
- return(-1);
- }
+ list->items[i] = sublist->items[0];
+ if (sublist->nbItems != 1) {
+ for (j = 1; j < sublist->nbItems; j++) {
+ i++;
+ if (xmlSchemaItemListInsert(list,
+ sublist->items[j], i) == -1)
+ return(-1);
}
- }
+ }
}
}
@@ -19205,7 +19315,7 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt,
/**
* xmlSchemaAttributeGroupExpandRefs:
* @pctxt: the parser context
- * @attrGr: the attribute group definition
+ * @attrGr: the attribute group definition
*
* Computation of:
* {attribute uses} property
@@ -19217,7 +19327,7 @@ xmlSchemaExpandAttributeGroupRefs(xmlSchemaParserCtxtPtr pctxt,
static int
xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaAttributeGroupPtr attrGr)
-{
+{
if ((attrGr->attrUses == NULL) ||
(attrGr->flags & XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED))
return(0);
@@ -19225,33 +19335,33 @@ xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt,
attrGr->flags |= XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED;
if (xmlSchemaExpandAttributeGroupRefs(pctxt, WXS_BASIC_CAST attrGr,
&(attrGr->attributeWildcard), attrGr->attrUses, NULL) == -1)
- return(-1);
+ return(-1);
return(0);
}
/**
* xmlSchemaAttributeGroupExpandRefs:
* @pctxt: the parser context
- * @attrGr: the attribute group definition
+ * @attrGr: the attribute group definition
*
* Substitutes contained attribute group references
* for their attribute uses. Wilcards are intersected.
- *
+ *
* Schema Component Constraint:
- * Attribute Group Definition Properties Correct (ag-props-correct)
+ * Attribute Group Definition Properties Correct (ag-props-correct)
*/
static int
xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaAttributeGroupPtr attrGr)
-{
+{
/*
* SPEC ag-props-correct
* (1) "The values of the properties of an attribute group definition
* must be as described in the property tableau in The Attribute
- * Group Definition Schema Component (§3.6.1), modulo the impact of
- * Missing Sub-components (§5.3);"
+ * Group Definition Schema Component ($3.6.1), modulo the impact of
+ * Missing Sub-components ($5.3);"
*/
-
+
if ((attrGr->attrUses != NULL) &&
(WXS_LIST_CAST attrGr->attrUses)->nbItems > 1)
{
@@ -19260,7 +19370,7 @@ xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
int i, j, hasId = 0;
for (i = uses->nbItems -1; i >= 0; i--) {
- use = uses->items[i];
+ use = uses->items[i];
/*
* SPEC ag-props-correct
* (2) "Two distinct members of the {attribute uses} must not have
@@ -19276,7 +19386,7 @@ xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
WXS_ATTRUSE_DECL_TNS(tmp)))
{
xmlChar *str = NULL;
-
+
xmlSchemaCustomErr(ACTXT_CAST pctxt,
XML_SCHEMAP_AG_PROPS_CORRECT,
attrGr->node, WXS_BASIC_CAST attrGr,
@@ -19300,13 +19410,13 @@ xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
* are derived from ID."
* TODO: Does 'derived' include member-types of unions?
*/
- if (WXS_ATTRUSE_TYPEDEF(use) != NULL) {
+ if (WXS_ATTRUSE_TYPEDEF(use) != NULL) {
if (xmlSchemaIsDerivedFromBuiltInType(
WXS_ATTRUSE_TYPEDEF(use), XML_SCHEMAS_ID))
- {
+ {
if (hasId) {
xmlChar *str = NULL;
-
+
xmlSchemaCustomErr(ACTXT_CAST pctxt,
XML_SCHEMAP_AG_PROPS_CORRECT,
attrGr->node, WXS_BASIC_CAST attrGr,
@@ -19319,7 +19429,7 @@ xmlSchemaCheckAGPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
FREE_AND_NULL(str);
if (xmlSchemaItemListRemove(uses, i) == -1)
return(-1);
- }
+ }
hasId = 1;
}
}
@@ -19383,10 +19493,10 @@ xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
* SPEC a-props-correct (1)
* "The values of the properties of an attribute declaration must
* be as described in the property tableau in The Attribute
- * Declaration Schema Component (§3.2.1), modulo the impact of
- * Missing Sub-components (§5.3)."
+ * Declaration Schema Component ($3.2.1), modulo the impact of
+ * Missing Sub-components ($5.3)."
*/
-
+
if (WXS_ATTR_TYPEDEF(attr) == NULL)
return(0);
@@ -19412,9 +19522,9 @@ xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
/*
* SPEC a-props-correct (2)
* "if there is a {value constraint}, the canonical lexical
- * representation of its value must be ·valid· with respect
- * to the {type definition} as defined in String Valid (§3.14.4)."
- * TODO: Don't care about the *cononical* stuff here, this requirement
+ * representation of its value must be `valid` with respect
+ * to the {type definition} as defined in String Valid ($3.14.4)."
+ * TODO: Don't care about the *canonical* stuff here, this requirement
* will be removed in WXS 1.1 anyway.
*/
ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST pctxt,
@@ -19435,7 +19545,7 @@ xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
return(pctxt->err);
}
}
-
+
return(0);
}
@@ -19481,15 +19591,15 @@ xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
/*
* SPEC (1) "The values of the properties of an element declaration
* must be as described in the property tableau in The Element
- * Declaration Schema Component (§3.3.1), modulo the impact of Missing
- * Sub-components (§5.3)."
+ * Declaration Schema Component ($3.3.1), modulo the impact of Missing
+ * Sub-components ($5.3)."
*/
if (WXS_SUBST_HEAD(elemDecl) != NULL) {
xmlSchemaElementPtr head = WXS_SUBST_HEAD(elemDecl), circ;
xmlSchemaCheckElementDeclComponent(head, pctxt);
/*
- * SPEC (3) "If there is a non-·absent· {substitution group
+ * SPEC (3) "If there is a non-`absent` {substitution group
* affiliation}, then {scope} must be global."
*/
if ((elemDecl->flags & XML_SCHEMAS_ELEM_GLOBAL) == 0) {
@@ -19533,9 +19643,9 @@ xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
* of the element declaration must be validly derived from the {type
* definition} of the {substitution group affiliation}, given the value
* of the {substitution group exclusions} of the {substitution group
- * affiliation}, as defined in Type Derivation OK (Complex) (§3.4.6)
+ * affiliation}, as defined in Type Derivation OK (Complex) ($3.4.6)
* (if the {type definition} is complex) or as defined in
- * Type Derivation OK (Simple) (§3.14.6) (if the {type definition} is
+ * Type Derivation OK (Simple) ($3.14.6) (if the {type definition} is
* simple)."
*
* NOTE: {substitution group exclusions} means the values of the
@@ -19599,9 +19709,9 @@ xmlSchemaCheckElemPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
/*
* SPEC (2) "If there is a {value constraint}, the canonical lexical
- * representation of its value must be ·valid· with respect to the
+ * representation of its value must be `valid` with respect to the
* {type definition} as defined in Element Default Valid (Immediate)
- * (§3.3.6)."
+ * ($3.3.6)."
*/
if (typeDef == NULL) {
xmlSchemaPErr(pctxt, elemDecl->node,
@@ -19669,7 +19779,7 @@ xmlSchemaCheckElemSubstGroup(xmlSchemaParserCtxtPtr ctxt,
/*
* SPEC (2) "It is validly substitutable for HEAD subject to HEAD's
* {disallowed substitutions} as the blocking constraint, as defined in
- * Substitution Group OK (Transitive) (§3.3.6)."
+ * Substitution Group OK (Transitive) ($3.3.6)."
*/
for (head = WXS_SUBST_HEAD(elemDecl); head != NULL;
head = WXS_SUBST_HEAD(head)) {
@@ -19761,12 +19871,12 @@ add_member:
* @ctxtParticle: the first particle of the context component
* @searchParticle: the element declaration particle to be analysed
*
- * Schema Component Constraint: Element Declarations Consistent
+ * Schema Component Constraint: Element Declarations Consistent
*/
static int
xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt,
xmlSchemaBasicItemPtr ctxtComponent,
- xmlSchemaParticlePtr ctxtParticle,
+ xmlSchemaParticlePtr ctxtParticle,
xmlSchemaParticlePtr searchParticle,
xmlSchemaParticlePtr curParticle,
int search)
@@ -19775,7 +19885,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt,
int ret = 0;
xmlSchemaParticlePtr cur = curParticle;
- if (curParticle == NULL) {
+ if (curParticle == NULL) {
return(0);
}
if (WXS_PARTICLE_TERM(curParticle) == NULL) {
@@ -19784,7 +19894,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt,
* might arise due to an invalid "term" component.
*/
return(0);
- }
+ }
while (cur != NULL) {
switch (WXS_PARTICLE_TERM(cur)->type) {
case XML_SCHEMA_TYPE_ANY:
@@ -19794,7 +19904,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt,
ret = xmlSchemaCheckElementDeclConsistent(pctxt,
ctxtComponent, ctxtParticle, cur, ctxtParticle, 1);
if (ret != 0)
- return(ret);
+ return(ret);
} else {
xmlSchemaElementPtr elem =
WXS_ELEM_CAST(WXS_PARTICLE_TERM(cur));
@@ -19802,7 +19912,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt,
* SPEC Element Declarations Consistent:
* "If the {particles} contains, either directly,
* indirectly (that is, within the {particles} of a
- * contained model group, recursively) or ·implicitly·
+ * contained model group, recursively) or `implicitly`
* two or more element declaration particles with
* the same {name} and {target namespace}, then
* all their type definitions must be the same
@@ -19814,7 +19924,7 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt,
WXS_PARTICLE_TERM_AS_ELEM(searchParticle)->targetNamespace))
{
xmlChar *strA = NULL, *strB = NULL;
-
+
xmlSchemaCustomErr(ACTXT_CAST pctxt,
/* TODO: error code */
XML_SCHEMAP_COS_NONAMBIG,
@@ -19831,16 +19941,16 @@ xmlSchemaCheckElementDeclConsistent(xmlSchemaParserCtxtPtr pctxt,
FREE_AND_NULL(strB);
return(XML_SCHEMAP_COS_NONAMBIG);
}
- }
+ }
break;
- case XML_SCHEMA_TYPE_SEQUENCE: {
+ case XML_SCHEMA_TYPE_SEQUENCE: {
break;
}
case XML_SCHEMA_TYPE_CHOICE:{
/*
xmlSchemaTreeItemPtr sub;
-
- sub = WXS_PARTICLE_TERM(particle)->children; (xmlSchemaParticlePtr)
+
+ sub = WXS_PARTICLE_TERM(particle)->children; (xmlSchemaParticlePtr)
while (sub != NULL) {
ret = xmlSchemaCheckElementDeclConsistent(pctxt, ctxtComponent,
ctxtParticle, ctxtElem);
@@ -19877,7 +19987,7 @@ exit:
* @name: the name of the attribute
*
* Validates the value constraints of an element declaration.
- * Adds substitution group members.
+ * Adds substitution group members.
*/
static void
xmlSchemaCheckElementDeclComponent(xmlSchemaElementPtr elemDecl,
@@ -19892,7 +20002,7 @@ xmlSchemaCheckElementDeclComponent(xmlSchemaElementPtr elemDecl,
/*
* Adds substitution group members.
*/
- xmlSchemaCheckElemSubstGroup(ctxt, elemDecl);
+ xmlSchemaCheckElemSubstGroup(ctxt, elemDecl);
}
}
@@ -19922,7 +20032,7 @@ xmlSchemaResolveModelGroupParticleReferences(
XML_SCHEMA_EXTRA_QNAMEREF))
{
goto next_particle;
- }
+ }
ref = WXS_QNAME_CAST WXS_PARTICLE_TERM(particle);
/*
* Resolve the reference.
@@ -19938,7 +20048,7 @@ xmlSchemaResolveModelGroupParticleReferences(
ref->targetNamespace, ref->itemType, NULL);
/* TODO: remove the particle. */
goto next_particle;
- }
+ }
if (refItem->type == XML_SCHEMA_TYPE_GROUP) {
if (WXS_MODELGROUPDEF_MODEL(refItem) == NULL)
/* TODO: remove the particle. */
@@ -19988,9 +20098,9 @@ next_particle:
static int
xmlSchemaAreValuesEqual(xmlSchemaValPtr x,
- xmlSchemaValPtr y)
-{
- xmlSchemaTypePtr tx, ty, ptx, pty;
+ xmlSchemaValPtr y)
+{
+ xmlSchemaTypePtr tx, ty, ptx, pty;
int ret;
while (x != NULL) {
@@ -20000,12 +20110,12 @@ xmlSchemaAreValuesEqual(xmlSchemaValPtr x,
ptx = xmlSchemaGetPrimitiveType(tx);
pty = xmlSchemaGetPrimitiveType(ty);
/*
- * (1) if a datatype T' is ·derived· by ·restriction· from an
- * atomic datatype T then the ·value space· of T' is a subset of
- * the ·value space· of T. */
+ * (1) if a datatype T' is `derived` by `restriction` from an
+ * atomic datatype T then the `value space` of T' is a subset of
+ * the `value space` of T. */
/*
- * (2) if datatypes T' and T'' are ·derived· by ·restriction·
- * from a common atomic ancestor T then the ·value space·s of T'
+ * (2) if datatypes T' and T'' are `derived` by `restriction`
+ * from a common atomic ancestor T then the `value space`s of T'
* and T'' may overlap.
*/
if (ptx != pty)
@@ -20036,7 +20146,7 @@ xmlSchemaAreValuesEqual(xmlSchemaValPtr x,
if (x != NULL) {
y = xmlSchemaValueGetNext(y);
if (y == NULL)
- return (0);
+ return (0);
} else if (xmlSchemaValueGetNext(y) != NULL)
return (0);
else
@@ -20073,7 +20183,7 @@ xmlSchemaResolveAttrUseReferences(xmlSchemaAttributeUsePtr ause,
ref->name, ref->targetNamespace);
if (ause->attrDecl == NULL) {
xmlSchemaPResCompAttrErr(ctxt,
- XML_SCHEMAP_SRC_RESOLVE,
+ XML_SCHEMAP_SRC_RESOLVE,
WXS_BASIC_CAST ause, ause->node,
"ref", ref->name, ref->targetNamespace,
XML_SCHEMA_TYPE_ATTRIBUTE, NULL);
@@ -20086,11 +20196,11 @@ xmlSchemaResolveAttrUseReferences(xmlSchemaAttributeUsePtr ause,
/**
* xmlSchemaCheckAttrUsePropsCorrect:
* @ctxt: a parser context
- * @use: an attribute use
+ * @use: an attribute use
*
* Schema Component Constraint:
* Attribute Use Correct (au-props-correct)
- *
+ *
*/
static int
xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt,
@@ -20100,16 +20210,16 @@ xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt,
return(-1);
if ((use->defValue == NULL) || (WXS_ATTRUSE_DECL(use) == NULL) ||
((WXS_ATTRUSE_DECL(use))->type != XML_SCHEMA_TYPE_ATTRIBUTE))
- return(0);
+ return(0);
/*
* SPEC au-props-correct (1)
* "The values of the properties of an attribute use must be as
* described in the property tableau in The Attribute Use Schema
- * Component (§3.5.1), modulo the impact of Missing
- * Sub-components (§5.3)."
+ * Component ($3.5.1), modulo the impact of Missing
+ * Sub-components ($5.3)."
*/
-
+
if (((WXS_ATTRUSE_DECL(use))->defValue != NULL) &&
((WXS_ATTRUSE_DECL(use))->flags & XML_SCHEMAS_ATTR_FIXED) &&
((use->flags & XML_SCHEMA_ATTR_USE_FIXED) == 0))
@@ -20129,7 +20239,7 @@ xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt,
if ((use->defVal != NULL) && (WXS_ATTRUSE_TYPEDEF(use) != NULL)) {
int ret;
/*
- * TODO: The spec seems to be missing a check of the
+ * TODO: The spec seems to be missing a check of the
* value constraint of the attribute use. We will do it here.
*/
/*
@@ -20146,7 +20256,7 @@ xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt,
NULL, NULL);
return(ctxt->err);
}
-
+
ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST ctxt,
use->node, WXS_ATTRUSE_TYPEDEF(use),
use->defValue, &(use->defVal),
@@ -20197,7 +20307,7 @@ xmlSchemaCheckAttrUsePropsCorrect(xmlSchemaParserCtxtPtr ctxt,
/**
* xmlSchemaResolveAttrTypeReferences:
* @item: an attribute declaration
- * @ctxt: a parser context
+ * @ctxt: a parser context
*
* Resolves the referenced type definition component.
*/
@@ -20208,8 +20318,8 @@ xmlSchemaResolveAttrTypeReferences(xmlSchemaAttributePtr item,
/*
* The simple type definition corresponding to the <simpleType> element
* information item in the [children], if present, otherwise the simple
- * type definition ·resolved· to by the ·actual value· of the type
- * [attribute], if present, otherwise the ·simple ur-type definition·.
+ * type definition `resolved` to by the `actual value` of the type
+ * [attribute], if present, otherwise the `simple ur-type definition`.
*/
if (item->flags & XML_SCHEMAS_ATTR_INTERNAL_RESOLVED)
return(0);
@@ -20288,7 +20398,7 @@ xmlSchemaResolveIDCKeyReferences(xmlSchemaIDCPtr idc,
((xmlSchemaIDCPtr) idc->ref->item)->nbFields) {
xmlChar *str = NULL;
xmlSchemaIDCPtr refer;
-
+
refer = (xmlSchemaIDCPtr) idc->ref->item;
/*
* SPEC c-props-correct(2)
@@ -20347,7 +20457,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
int wasRedefined;
if (redef == NULL)
- return(0);
+ return(0);
do {
item = redef->item;
@@ -20362,7 +20472,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
* <redefine>d schema. Currenlty we latter approach is used.
* SUPPLEMENT: It seems that the WG moves towards the latter
* approach, so we are doing it right.
- *
+ *
*/
prev = xmlSchemaFindRedefCompInGraph(
redef->targetBucket, item->type,
@@ -20373,11 +20483,11 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
/*
* SPEC src-redefine:
- * (6.2.1) "The ·actual value· of its own name attribute plus
- * target namespace must successfully ·resolve· to a model
+ * (6.2.1) "The `actual value` of its own name attribute plus
+ * target namespace must successfully `resolve` to a model
* group definition in I."
- * (7.2.1) "The ·actual value· of its own name attribute plus
- * target namespace must successfully ·resolve· to an attribute
+ * (7.2.1) "The `actual value` of its own name attribute plus
+ * target namespace must successfully `resolve` to an attribute
* group definition in I."
*
@@ -20394,7 +20504,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
/*
* TODO: error code.
* Probably XML_SCHEMAP_SRC_RESOLVE, if this is using the
- * reference kind.
+ * reference kind.
*/
XML_SCHEMAP_SRC_REDEFINE, node, NULL,
"The %s '%s' to be redefined could not be found in "
@@ -20402,7 +20512,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
WXS_ITEM_TYPE_NAME(item),
xmlSchemaFormatQName(&str, redef->refTargetNs,
redef->refName));
- FREE_AND_NULL(str);
+ FREE_AND_NULL(str);
err = pctxt->err;
redef = redef->next;
continue;
@@ -20428,7 +20538,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
* base type of the redefining type.
* TODO: How
*/
- ((xmlSchemaTypePtr) item)->baseType =
+ ((xmlSchemaTypePtr) item)->baseType =
(xmlSchemaTypePtr) prev;
break;
case XML_SCHEMA_TYPE_GROUP:
@@ -20483,7 +20593,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
default:
PERROR_INT("xmlSchemaResolveRedefReferences",
"Unexpected redefined component type");
- return(-1);
+ return(-1);
}
if (wasRedefined) {
xmlChar *str = NULL;
@@ -20493,7 +20603,7 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
node = WXS_ITEM_NODE(redef->reference);
else
node = WXS_ITEM_NODE(redef->item);
-
+
xmlSchemaCustomErr(ACTXT_CAST pctxt,
/* TODO: error code. */
XML_SCHEMAP_SRC_REDEFINE,
@@ -20502,12 +20612,12 @@ xmlSchemaCheckSRCRedefineFirst(xmlSchemaParserCtxtPtr pctxt)
"redefinition of the same component is not supported",
xmlSchemaGetComponentDesignation(&str, prev),
NULL);
- FREE_AND_NULL(str)
+ FREE_AND_NULL(str)
err = pctxt->err;
redef = redef->next;
continue;
}
- redef = redef->next;
+ redef = redef->next;
} while (redef != NULL);
return(err);
@@ -20521,7 +20631,7 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt)
xmlSchemaBasicItemPtr item;
if (redef == NULL)
- return(0);
+ return(0);
do {
if (redef->target == NULL) {
@@ -20529,7 +20639,7 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt)
continue;
}
item = redef->item;
-
+
switch (item->type) {
case XML_SCHEMA_TYPE_SIMPLE:
case XML_SCHEMA_TYPE_COMPLEX:
@@ -20538,7 +20648,7 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt)
* type to be 'absent', we'll NULL it.
*/
(WXS_TYPE_CAST redef->target)->name = NULL;
-
+
/*
* TODO: Seems like there's nothing more to do. The normal
* inheritance mechanism is used. But not 100% sure.
@@ -20550,10 +20660,10 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt)
* SPEC src-redefine:
* (6.2.2) "The {model group} of the model group definition
* which corresponds to it per XML Representation of Model
- * Group Definition Schema Components (§3.7.2) must be a
- * ·valid restriction· of the {model group} of that model
+ * Group Definition Schema Components ($3.7.2) must be a
+ * `valid restriction` of the {model group} of that model
* group definition in I, as defined in Particle Valid
- * (Restriction) (§3.9.6)."
+ * (Restriction) ($3.9.6)."
*/
break;
case XML_SCHEMA_TYPE_ATTRIBUTEGROUP:
@@ -20562,11 +20672,11 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt)
* (7.2.2) "The {attribute uses} and {attribute wildcard} of
* the attribute group definition which corresponds to it
* per XML Representation of Attribute Group Definition Schema
- * Components (§3.6.2) must be ·valid restrictions· of the
+ * Components ($3.6.2) must be `valid restrictions` of the
* {attribute uses} and {attribute wildcard} of that attribute
* group definition in I, as defined in clause 2, clause 3 and
* clause 4 of Derivation Valid (Restriction, Complex)
- * (§3.4.6) (where references to the base type definition are
+ * ($3.4.6) (where references to the base type definition are
* understood as references to the attribute group definition
* in I)."
*/
@@ -20587,7 +20697,7 @@ xmlSchemaCheckSRCRedefineSecond(xmlSchemaParserCtxtPtr pctxt)
} while (redef != NULL);
return(0);
}
-
+
static int
xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt,
@@ -20621,8 +20731,8 @@ xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt,
return(-1);
if (bucket->flags & XML_SCHEMA_BUCKET_COMPS_ADDED)
return(0);
- bucket->flags |= XML_SCHEMA_BUCKET_COMPS_ADDED;
-
+ bucket->flags |= XML_SCHEMA_BUCKET_COMPS_ADDED;
+
for (i = 0; i < bucket->globals->nbItems; i++) {
item = bucket->globals->items[i];
table = NULL;
@@ -20663,12 +20773,12 @@ xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt,
case XML_SCHEMA_TYPE_NOTATION:
name = ((xmlSchemaNotationPtr) item)->name;
WXS_GET_GLOBAL_HASH(bucket, notaDecl)
- break;
+ break;
default:
PERROR_INT("xmlSchemaAddComponents",
"Unexpected global component type");
- continue;
- }
+ continue;
+ }
if (*table == NULL) {
*table = xmlHashCreateDict(10, pctxt->dict);
if (*table == NULL) {
@@ -20676,11 +20786,11 @@ xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt,
"failed to create a component hash table");
return(-1);
}
- }
+ }
err = xmlHashAddEntry(*table, name, item);
- if (err != 0) {
+ if (err != 0) {
xmlChar *str = NULL;
-
+
xmlSchemaCustomErr(ACTXT_CAST pctxt,
XML_SCHEMAP_REDEFINED_TYPE,
WXS_ITEM_NODE(item),
@@ -20688,7 +20798,7 @@ xmlSchemaAddComponents(xmlSchemaParserCtxtPtr pctxt,
"A global %s '%s' does already exist",
WXS_ITEM_TYPE_NAME(item),
xmlSchemaGetComponentQName(&str, item));
- FREE_AND_NULL(str);
+ FREE_AND_NULL(str);
}
}
/*
@@ -20722,34 +20832,34 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
if ((con->pending == NULL) ||
(con->pending->nbItems == 0))
- return(0);
+ return(0);
/*
* Since xmlSchemaFixupComplexType() will create new particles
* (local components), and those particle components need a bucket
* on the constructor, we'll assure here that the constructor has
* a bucket.
- * TODO: Think about storing locals _only_ on the main bucket.
- */
+ * TODO: Think about storing locals _only_ on the main bucket.
+ */
if (con->bucket == NULL)
- con->bucket = rootBucket;
+ con->bucket = rootBucket;
/* TODO:
* SPEC (src-redefine):
* (6.2) "If it has no such self-reference, then all of the
* following must be true:"
-
+
* (6.2.2) The {model group} of the model group definition which
* corresponds to it per XML Representation of Model Group
- * Definition Schema Components (§3.7.2) must be a ·valid
- * restriction· of the {model group} of that model group definition
- * in I, as defined in Particle Valid (Restriction) (§3.9.6)."
+ * Definition Schema Components ($3.7.2) must be a `valid
+ * restriction` of the {model group} of that model group definition
+ * in I, as defined in Particle Valid (Restriction) ($3.9.6)."
*/
xmlSchemaCheckSRCRedefineFirst(pctxt);
/*
* Add global components to the schemata's hash tables.
- */
+ */
xmlSchemaAddComponents(pctxt, rootBucket);
pctxt->ctxtType = NULL;
@@ -20759,7 +20869,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
* Now that we have parsed *all* the schema document(s) and converted
* them to schema components, we can resolve references, apply component
* constraints, create the FSA from the content model, etc.
- */
+ */
/*
* Resolve references of..
*
@@ -20780,7 +20890,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
* 6. IDC key-references:
* - the referenced IDC 'key' or 'unique' definition
* 7. Attribute prohibitions which had a "ref" attribute.
- */
+ */
for (i = 0; i < nbItems; i++) {
item = items[i];
switch (item->type) {
@@ -20806,7 +20916,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
FIXHFAILURE;
break;
case XML_SCHEMA_EXTRA_QNAMEREF:
- if ((WXS_QNAME_CAST item)->itemType ==
+ if ((WXS_QNAME_CAST item)->itemType ==
XML_SCHEMA_TYPE_ATTRIBUTEGROUP)
{
xmlSchemaResolveAttrGroupReferences(
@@ -20843,11 +20953,11 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
}
if (pctxt->nberrors != 0)
goto exit_error;
-
+
/*
* Now that all references are resolved we
* can check for circularity of...
- * 1. the base axis of type definitions
+ * 1. the base axis of type definitions
* 2. nested model group definitions
* 3. nested attribute group definitions
* TODO: check for circual substitution groups.
@@ -20882,7 +20992,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
break;
default:
break;
- }
+ }
}
if (pctxt->nberrors != 0)
goto exit_error;
@@ -20898,7 +21008,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
item = items[i];
switch (item->type) {
case XML_SCHEMA_TYPE_SEQUENCE:
- case XML_SCHEMA_TYPE_CHOICE:
+ case XML_SCHEMA_TYPE_CHOICE:
xmlSchemaModelGroupToModelGroupDefFixup(pctxt,
WXS_MODEL_GROUP_CAST item);
break;
@@ -20929,7 +21039,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
}
if (pctxt->nberrors != 0)
goto exit_error;
- /*
+ /*
* First compute the variety of simple types. This is needed as
* a seperate step, since otherwise we won't be able to detect
* circular union types in all cases.
@@ -20959,7 +21069,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
switch (item->type) {
case XML_SCHEMA_TYPE_SIMPLE:
if (((xmlSchemaTypePtr) item)->memberTypes != NULL) {
- xmlSchemaCheckUnionTypeDefCircular(pctxt,
+ xmlSchemaCheckUnionTypeDefCircular(pctxt,
(xmlSchemaTypePtr) item);
FIXHFAILURE;
}
@@ -20970,7 +21080,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
}
if (pctxt->nberrors != 0)
goto exit_error;
-
+
/*
* Do the complete type fixup for simple types.
*/
@@ -20998,10 +21108,10 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
for (i = 0; i < nbItems; i++) {
item = items[i];
switch (item->type) {
- case XML_SCHEMA_TYPE_ATTRIBUTE:
+ case XML_SCHEMA_TYPE_ATTRIBUTE:
xmlSchemaCheckAttrPropsCorrect(pctxt, WXS_ATTR_CAST item);
FIXHFAILURE;
- break;
+ break;
default:
break;
}
@@ -21010,7 +21120,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
goto exit_error;
/*
* Apply constraints for attribute uses.
- */
+ */
for (i = 0; i < nbItems; i++) {
item = items[i];
switch (item->type) {
@@ -21057,7 +21167,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
if (pctxt->nberrors != 0)
goto exit_error;
- /*
+ /*
* Complex types are builded and checked.
*/
for (i = 0; i < nbItems; i++) {
@@ -21081,8 +21191,8 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
* will create particles and model groups in some cases.
*/
items = (xmlSchemaTreeItemPtr *) con->pending->items;
- nbItems = con->pending->nbItems;
-
+ nbItems = con->pending->nbItems;
+
/*
* Apply some constraints for element declarations.
*/
@@ -21091,7 +21201,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
switch (item->type) {
case XML_SCHEMA_TYPE_ELEMENT:
elemDecl = (xmlSchemaElementPtr) item;
-
+
if ((elemDecl->flags & XML_SCHEMAS_ELEM_INTERNAL_CHECKED) == 0)
{
xmlSchemaCheckElementDeclComponent(
@@ -21121,7 +21231,7 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
}
if (pctxt->nberrors != 0)
goto exit_error;
-
+
/*
* Finally we can build the automaton from the content model of
* complex types.
@@ -21142,10 +21252,10 @@ xmlSchemaFixupComponents(xmlSchemaParserCtxtPtr pctxt,
goto exit_error;
/*
* URGENT TODO: cos-element-consistent
- */
- goto exit;
+ */
+ goto exit;
-exit_error:
+exit_error:
ret = pctxt->err;
goto exit;
@@ -21159,12 +21269,12 @@ exit:
* if not cleared here.
*/
con->bucket = oldbucket;
- con->pending->nbItems = 0;
+ con->pending->nbItems = 0;
if (con->substGroups != NULL) {
xmlHashFree(con->substGroups,
(xmlHashDeallocator) xmlSchemaSubstGroupFree);
con->substGroups = NULL;
- }
+ }
if (con->redefs != NULL) {
xmlSchemaRedefListFree(con->redefs);
con->redefs = NULL;
@@ -21227,11 +21337,11 @@ xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt)
if (res == -1)
goto exit_failure;
if (res != 0)
- goto exit;
+ goto exit;
if (bucket == NULL) {
/* TODO: Error code, actually we failed to *locate* the schema. */
- if (ctxt->URL)
+ if (ctxt->URL)
xmlSchemaCustomErr(ACTXT_CAST ctxt, XML_SCHEMAP_FAILED_LOAD,
NULL, NULL,
"Failed to locate the main schema resource at '%s'",
@@ -21242,16 +21352,16 @@ xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt)
"Failed to locate the main schema resource",
NULL, NULL);
goto exit;
- }
+ }
/* Then do the parsing for good. */
if (xmlSchemaParseNewDocWithContext(ctxt, mainSchema, bucket) == -1)
goto exit_failure;
if (ctxt->nberrors != 0)
goto exit;
-
+
mainSchema->doc = bucket->doc;
mainSchema->preserve = ctxt->preserve;
-
+
ctxt->schema = mainSchema;
if (xmlSchemaFixupComponents(ctxt, WXS_CONSTRUCTOR(ctxt)->mainBucket) == -1)
@@ -21261,8 +21371,8 @@ xmlSchemaParse(xmlSchemaParserCtxtPtr ctxt)
* TODO: This is not nice, since we cannot distinguish from the
* result if there was an internal error or not.
*/
-exit:
- if (ctxt->nberrors != 0) {
+exit:
+ if (ctxt->nberrors != 0) {
if (mainSchema) {
xmlSchemaFree(mainSchema);
mainSchema = NULL;
@@ -21276,7 +21386,7 @@ exit:
ctxt->schema = NULL;
return(mainSchema);
exit_failure:
- /*
+ /*
* Quite verbose, but should catch internal errors, which were
* not communitated.
*/
@@ -21290,7 +21400,7 @@ exit_failure:
ctxt->ownsConstructor = 0;
}
PERROR_INT2("xmlSchemaParse",
- "An internal error occured");
+ "An internal error occured");
ctxt->schema = NULL;
return(NULL);
}
@@ -21427,8 +21537,8 @@ xmlSchemaGetWhiteSpaceFacetValue(xmlSchemaTypePtr type)
return(XML_SCHEMA_WHITESPACE_REPLACE);
else {
/*
- * For all ·atomic· datatypes other than string (and types ·derived·
- * by ·restriction· from it) the value of whiteSpace is fixed to
+ * For all `atomic` datatypes other than string (and types `derived`
+ * by `restriction` from it) the value of whiteSpace is fixed to
* collapse
* Note that this includes built-in list datatypes.
*/
@@ -21453,16 +21563,16 @@ xmlSchemaGetWhiteSpaceFacetValue(xmlSchemaTypePtr type)
}
/************************************************************************
- * *
- * Simple type validation *
- * *
+ * *
+ * Simple type validation *
+ * *
************************************************************************/
/************************************************************************
- * *
- * DOM Validation code *
- * *
+ * *
+ * DOM Validation code *
+ * *
************************************************************************/
/**
@@ -21515,11 +21625,11 @@ xmlSchemaAssembleByLocation(xmlSchemaValidCtxtPtr vctxt,
* XML_SCHEMA_SCHEMA_MAIN if it is the first schema document.
*/
ret = xmlSchemaAddSchemaDoc(pctxt, XML_SCHEMA_SCHEMA_IMPORT,
- location, NULL, NULL, 0, node, NULL, nsName,
+ location, NULL, NULL, 0, node, NULL, nsName,
&bucket);
if (ret != 0)
- return(ret);
- if (bucket == NULL) {
+ return(ret);
+ if (bucket == NULL) {
/*
* Generate a warning that the document could not be located.
*/
@@ -21549,17 +21659,17 @@ xmlSchemaAssembleByLocation(xmlSchemaValidCtxtPtr vctxt,
pctxt->nberrors = 0;
pctxt->err = 0;
pctxt->doc = bucket->doc;
-
- ret = xmlSchemaParseNewDocWithContext(pctxt, schema, bucket);
+
+ ret = xmlSchemaParseNewDocWithContext(pctxt, schema, bucket);
if (ret == -1) {
pctxt->doc = NULL;
goto exit_failure;
}
/* Paranoid error channelling. */
if ((ret == 0) && (pctxt->nberrors != 0))
- ret = pctxt->err;
- if (pctxt->nberrors == 0) {
- /*
+ ret = pctxt->err;
+ if (pctxt->nberrors == 0) {
+ /*
* Only bother to fixup pending components, if there was
* no error yet.
* For every XSI acquired schema (and its sub-schemata) we will
@@ -21575,7 +21685,7 @@ xmlSchemaAssembleByLocation(xmlSchemaValidCtxtPtr vctxt,
vctxt->err = ret;
vctxt->nberrors += pctxt->nberrors;
} else {
- /* Add to validation error sum. */
+ /* Add to validation error sum. */
vctxt->nberrors += pctxt->nberrors;
}
pctxt->doc = NULL;
@@ -21586,7 +21696,7 @@ exit_failure:
}
static xmlSchemaAttrInfoPtr
-xmlSchemaGetMetaAttrInfo(xmlSchemaValidCtxtPtr vctxt,
+xmlSchemaGetMetaAttrInfo(xmlSchemaValidCtxtPtr vctxt,
int metaType)
{
if (vctxt->nbAttrInfos == 0)
@@ -21676,7 +21786,7 @@ xmlSchemaAssembleByXSI(xmlSchemaValidCtxtPtr vctxt)
/*
* If using @schemaLocation then tuples are expected.
* I.e. the namespace name *and* the document's URI.
- */
+ */
xmlSchemaCustomWarning(ACTXT_CAST vctxt, XML_SCHEMAV_MISC,
iattr->node, NULL,
"The value must consist of tuples: the target namespace "
@@ -21705,7 +21815,7 @@ xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt,
if (vctxt->sax != NULL) {
int i, j;
xmlSchemaNodeInfoPtr inode;
-
+
for (i = vctxt->depth; i >= 0; i--) {
if (vctxt->elemInfos[i]->nbNsBindings != 0) {
inode = vctxt->elemInfos[i];
@@ -21719,16 +21829,16 @@ xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt,
* Note that the namespace bindings are already
* in a string dict.
*/
- return (inode->nsBindings[j+1]);
+ return (inode->nsBindings[j+1]);
}
}
}
}
return (NULL);
-#ifdef LIBXML_WRITER_ENABLED
+#ifdef LIBXML_READER_ENABLED
} else if (vctxt->reader != NULL) {
xmlChar *nsName;
-
+
nsName = xmlTextReaderLookupNamespace(vctxt->reader, prefix);
if (nsName != NULL) {
const xmlChar *ret;
@@ -21760,7 +21870,7 @@ xmlSchemaLookupNamespace(xmlSchemaValidCtxtPtr vctxt,
* This one works on the schema of the validation context.
*/
static int
-xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt,
+xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt,
xmlSchemaPtr schema,
xmlNodePtr node,
const xmlChar *value,
@@ -21785,7 +21895,7 @@ xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt,
if (prefix != NULL) {
const xmlChar *nsName = NULL;
- if (vctxt != NULL)
+ if (vctxt != NULL)
nsName = xmlSchemaLookupNamespace(vctxt, BAD_CAST prefix);
else if (node != NULL) {
xmlNsPtr ns = xmlSearchNs(node->doc, node, prefix);
@@ -21802,9 +21912,9 @@ xmlSchemaValidateNotation(xmlSchemaValidCtxtPtr vctxt,
return (1);
}
if (xmlSchemaGetNotation(schema, localName, nsName) != NULL) {
- if (valNeeded && (val != NULL)) {
- (*val) = xmlSchemaNewNOTATIONValue(BAD_CAST localName,
- BAD_CAST xmlStrdup(nsName));
+ if ((valNeeded) && (val != NULL)) {
+ (*val) = xmlSchemaNewNOTATIONValue(xmlStrdup(localName),
+ xmlStrdup(nsName));
if (*val == NULL)
ret = -1;
}
@@ -21856,9 +21966,9 @@ xmlSchemaVAddNodeQName(xmlSchemaValidCtxtPtr vctxt,
}
/************************************************************************
- * *
+ * *
* Validation of identity-constraints (IDC) *
- * *
+ * *
************************************************************************/
/**
@@ -21900,6 +22010,20 @@ xmlSchemaAugmentIDC(xmlSchemaIDCPtr idcDef,
}
/**
+ * xmlSchemaAugmentImportedIDC:
+ * @imported: the imported schema
+ *
+ * Creates an augmented IDC definition for the imported schema.
+ */
+static void
+xmlSchemaAugmentImportedIDC(xmlSchemaImportPtr imported, xmlSchemaValidCtxtPtr vctxt) {
+ if (imported->schema->idcDef != NULL) {
+ xmlHashScan(imported->schema->idcDef ,
+ (xmlHashScanner) xmlSchemaAugmentIDC, vctxt);
+ }
+}
+
+/**
* xmlSchemaIDCNewBinding:
* @idcDef: the IDC definition of this binding
*
@@ -22123,7 +22247,7 @@ xmlSchemaIDCFreeBinding(xmlSchemaPSVIIDCBindingPtr bind)
if (bind->nodeTable != NULL)
xmlFree(bind->nodeTable);
if (bind->dupls != NULL)
- xmlSchemaItemListFree(bind->dupls);
+ xmlSchemaItemListFree(bind->dupls);
xmlFree(bind);
}
@@ -22158,12 +22282,12 @@ xmlSchemaIDCFreeMatcherList(xmlSchemaIDCMatcherPtr matcher)
while (matcher != NULL) {
next = matcher->next;
- if (matcher->keySeqs != NULL) {
+ if (matcher->keySeqs != NULL) {
int i;
for (i = 0; i < matcher->sizeKeySeqs; i++)
if (matcher->keySeqs[i] != NULL)
xmlFree(matcher->keySeqs[i]);
- xmlFree(matcher->keySeqs);
+ xmlFree(matcher->keySeqs);
}
if (matcher->targets != NULL) {
if (matcher->idcType == XML_SCHEMA_TYPE_IDC_KEYREF) {
@@ -22203,7 +22327,7 @@ xmlSchemaIDCReleaseMatcherList(xmlSchemaValidCtxtPtr vctxt,
while (matcher != NULL) {
next = matcher->next;
- if (matcher->keySeqs != NULL) {
+ if (matcher->keySeqs != NULL) {
int i;
/*
* Don't free the array, but only the content.
@@ -22232,7 +22356,7 @@ xmlSchemaIDCReleaseMatcherList(xmlSchemaValidCtxtPtr vctxt,
}
xmlSchemaItemListFree(matcher->targets);
matcher->targets = NULL;
- }
+ }
matcher->next = NULL;
/*
* Cache the matcher.
@@ -22274,7 +22398,7 @@ xmlSchemaIDCAddStateObject(xmlSchemaValidCtxtPtr vctxt,
sto = vctxt->xpathStatePool;
vctxt->xpathStatePool = sto->next;
sto->next = NULL;
- } else {
+ } else {
/*
* Create a new state object.
*/
@@ -22285,10 +22409,10 @@ xmlSchemaIDCAddStateObject(xmlSchemaValidCtxtPtr vctxt,
return (-1);
}
memset(sto, 0, sizeof(xmlSchemaIDCStateObj));
- }
+ }
/*
- * Add to global list.
- */
+ * Add to global list.
+ */
if (vctxt->xpathStates != NULL)
sto->next = vctxt->xpathStates;
vctxt->xpathStates = sto;
@@ -22308,13 +22432,13 @@ xmlSchemaIDCAddStateObject(xmlSchemaValidCtxtPtr vctxt,
VERROR_INT("xmlSchemaIDCAddStateObject",
"failed to create an XPath validation context");
return (-1);
- }
+ }
sto->type = type;
sto->depth = vctxt->depth;
sto->matcher = matcher;
sto->sel = sel;
sto->nbHistory = 0;
-
+
#ifdef DEBUG_IDC
xmlGenericError(xmlGenericErrorContext, "IDC: STO push '%s'\n",
sto->sel->xpath);
@@ -22338,7 +22462,7 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
{
xmlSchemaIDCStateObjPtr sto, head = NULL, first;
int res, resolved = 0, depth = vctxt->depth;
-
+
if (vctxt->xpathStates == NULL)
return (0);
@@ -22347,8 +22471,8 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
#ifdef DEBUG_IDC
{
xmlChar *str = NULL;
- xmlGenericError(xmlGenericErrorContext,
- "IDC: EVAL on %s, depth %d, type %d\n",
+ xmlGenericError(xmlGenericErrorContext,
+ "IDC: EVAL on %s, depth %d, type %d\n",
xmlSchemaFormatQName(&str, vctxt->inode->nsName,
vctxt->inode->localName), depth, nodeType);
FREE_AND_NULL(str)
@@ -22362,10 +22486,10 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
while (sto != head) {
#ifdef DEBUG_IDC
if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR)
- xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] selector '%s'\n",
+ xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] selector '%s'\n",
sto->matcher->aidc->def->name, sto->sel->xpath);
else
- xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] field '%s'\n",
+ xmlGenericError(xmlGenericErrorContext, "IDC: ['%s'] field '%s'\n",
sto->matcher->aidc->def->name, sto->sel->xpath);
#endif
if (nodeType == XML_ELEMENT_NODE)
@@ -22395,7 +22519,7 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
if (sto->history == NULL) {
sto->history = (int *) xmlMalloc(5 * sizeof(int));
if (sto->history == NULL) {
- xmlSchemaVErrMemory(NULL,
+ xmlSchemaVErrMemory(NULL,
"allocating the state object history", NULL);
return(-1);
}
@@ -22405,11 +22529,11 @@ xmlSchemaXPathEvaluate(xmlSchemaValidCtxtPtr vctxt,
sto->history = (int *) xmlRealloc(sto->history,
sto->sizeHistory * sizeof(int));
if (sto->history == NULL) {
- xmlSchemaVErrMemory(NULL,
+ xmlSchemaVErrMemory(NULL,
"re-allocating the state object history", NULL);
return(-1);
}
- }
+ }
sto->history[sto->nbHistory++] = depth;
#ifdef DEBUG_IDC
@@ -22478,7 +22602,7 @@ xmlSchemaFormatIDCKeySequence(xmlSchemaValidCtxtPtr vctxt,
*buf = xmlStrdup(BAD_CAST "[");
for (i = 0; i < count; i++) {
*buf = xmlStrcat(*buf, BAD_CAST "'");
- res = xmlSchemaGetCanonValueWhtspExt(seq[i]->val,
+ res = xmlSchemaGetCanonValueWhtspExt(seq[i]->val,
xmlSchemaGetWhiteSpaceFacetValue(seq[i]->type),
&value);
if (res == 0)
@@ -22536,7 +22660,7 @@ xmlSchemaXPathPop(xmlSchemaValidCtxtPtr vctxt)
*
* Processes and pops the history items of the IDC state objects.
* IDC key-sequences are validated/created on IDC bindings.
- *
+ *
* Returns 0 on success and -1 on internal errors.
*/
static int
@@ -22555,13 +22679,13 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
#ifdef DEBUG_IDC
{
xmlChar *str = NULL;
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"IDC: BACK on %s, depth %d\n",
xmlSchemaFormatQName(&str, vctxt->inode->nsName,
vctxt->inode->localName), vctxt->depth);
FREE_AND_NULL(str)
}
-#endif
+#endif
/*
* Evaluate the state objects.
*/
@@ -22587,14 +22711,14 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
if (matchDepth != depth) {
sto = sto->next;
continue;
- }
+ }
if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_FIELD) {
/*
* NOTE: According to
* http://www.w3.org/Bugs/Public/show_bug.cgi?id=2198
* ... the simple-content of complex types is also allowed.
*/
-
+
if (WXS_IS_COMPLEX(type)) {
if (WXS_HAS_SIMPLE_CONTENT(type)) {
/*
@@ -22609,17 +22733,17 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
}
} else
simpleType = NULL;
- } else
+ } else
simpleType = type;
if (simpleType == NULL) {
xmlChar *str = NULL;
-
+
/*
* Not qualified if the field resolves to a node of non
* simple type.
- */
+ */
xmlSchemaCustomErr(ACTXT_CAST vctxt,
- XML_SCHEMAV_CVC_IDC, NULL,
+ XML_SCHEMAV_CVC_IDC, NULL,
WXS_BASIC_CAST sto->matcher->aidc->def,
"The XPath '%s' of a field of %s does evaluate to a node of "
"non-simple type",
@@ -22629,7 +22753,7 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
sto->nbHistory--;
goto deregister_check;
}
-
+
if ((key == NULL) && (vctxt->inode->val == NULL)) {
/*
* Failed to provide the normalized value; maybe
@@ -22645,13 +22769,13 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
xmlSchemaIDCMatcherPtr matcher = sto->matcher;
xmlSchemaPSVIIDCKeyPtr *keySeq;
int pos, idx;
-
+
/*
* The key will be anchored on the matcher's list of
* key-sequences. The position in this list is determined
* by the target node's depth relative to the matcher's
* depth of creation (i.e. the depth of the scope element).
- *
+ *
* Element Depth Pos List-entries
* <scope> 0 NULL
* <bar> 1 NULL
@@ -22662,23 +22786,23 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
* The size of the list is only dependant on the depth of
* the tree.
* An entry will be NULLed in selector_leave, i.e. when
- * we hit the target's
- */
+ * we hit the target's
+ */
pos = sto->depth - matcher->depth;
idx = sto->sel->index;
-
+
/*
* Create/grow the array of key-sequences.
*/
if (matcher->keySeqs == NULL) {
- if (pos > 9)
+ if (pos > 9)
matcher->sizeKeySeqs = pos * 2;
else
matcher->sizeKeySeqs = 10;
- matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **)
+ matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **)
xmlMalloc(matcher->sizeKeySeqs *
- sizeof(xmlSchemaPSVIIDCKeyPtr *));
- if (matcher->keySeqs == NULL) {
+ sizeof(xmlSchemaPSVIIDCKeyPtr *));
+ if (matcher->keySeqs == NULL) {
xmlSchemaVErrMemory(NULL,
"allocating an array of key-sequences",
NULL);
@@ -22687,9 +22811,9 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
memset(matcher->keySeqs, 0,
matcher->sizeKeySeqs *
sizeof(xmlSchemaPSVIIDCKeyPtr *));
- } else if (pos >= matcher->sizeKeySeqs) {
+ } else if (pos >= matcher->sizeKeySeqs) {
int i = matcher->sizeKeySeqs;
-
+
matcher->sizeKeySeqs *= 2;
matcher->keySeqs = (xmlSchemaPSVIIDCKeyPtr **)
xmlRealloc(matcher->keySeqs,
@@ -22705,29 +22829,29 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
* The array needs to be NULLed.
* TODO: Use memset?
*/
- for (; i < matcher->sizeKeySeqs; i++)
- matcher->keySeqs[i] = NULL;
+ for (; i < matcher->sizeKeySeqs; i++)
+ matcher->keySeqs[i] = NULL;
}
-
+
/*
* Get/create the key-sequence.
*/
- keySeq = matcher->keySeqs[pos];
- if (keySeq == NULL) {
+ keySeq = matcher->keySeqs[pos];
+ if (keySeq == NULL) {
goto create_sequence;
} else if (keySeq[idx] != NULL) {
xmlChar *str = NULL;
/*
* cvc-identity-constraint:
- * 3 For each node in the ·target node set· all
+ * 3 For each node in the `target node set` all
* of the {fields}, with that node as the context
* node, evaluate to either an empty node-set or
* a node-set with exactly one member, which must
* have a simple type.
- *
+ *
* The key was already set; report an error.
*/
- xmlSchemaCustomErr(ACTXT_CAST vctxt,
+ xmlSchemaCustomErr(ACTXT_CAST vctxt,
XML_SCHEMAV_CVC_IDC, NULL,
WXS_BASIC_CAST matcher->aidc->def,
"The XPath '%s' of a field of %s evaluates to a "
@@ -22738,27 +22862,27 @@ xmlSchemaXPathProcessHistory(xmlSchemaValidCtxtPtr vctxt,
sto->nbHistory--;
goto deregister_check;
} else
- goto create_key;
-
+ goto create_key;
+
create_sequence:
/*
* Create a key-sequence.
*/
keySeq = (xmlSchemaPSVIIDCKeyPtr *) xmlMalloc(
- matcher->aidc->def->nbFields *
+ matcher->aidc->def->nbFields *
sizeof(xmlSchemaPSVIIDCKeyPtr));
if (keySeq == NULL) {
- xmlSchemaVErrMemory(NULL,
+ xmlSchemaVErrMemory(NULL,
"allocating an IDC key-sequence", NULL);
- return(-1);
- }
- memset(keySeq, 0, matcher->aidc->def->nbFields *
+ return(-1);
+ }
+ memset(keySeq, 0, matcher->aidc->def->nbFields *
sizeof(xmlSchemaPSVIIDCKeyPtr));
matcher->keySeqs[pos] = keySeq;
create_key:
/*
* Create a key once per node only.
- */
+ */
if (key == NULL) {
key = (xmlSchemaPSVIIDCKeyPtr) xmlMalloc(
sizeof(xmlSchemaPSVIIDCKey));
@@ -22767,7 +22891,7 @@ create_key:
"allocating a IDC key", NULL);
xmlFree(keySeq);
matcher->keySeqs[pos] = NULL;
- return(-1);
+ return(-1);
}
/*
* Consume the compiled value.
@@ -22783,10 +22907,10 @@ create_key:
return (-1);
}
}
- keySeq[idx] = key;
+ keySeq[idx] = key;
}
} else if (sto->type == XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) {
-
+
xmlSchemaPSVIIDCKeyPtr **keySeq = NULL;
/* xmlSchemaPSVIIDCBindingPtr bind; */
xmlSchemaPSVIIDCNodePtr ntItem;
@@ -22797,22 +22921,22 @@ create_key:
/*
* Here we have the following scenario:
* An IDC 'selector' state object resolved to a target node,
- * during the time this target node was in the
- * ancestor-or-self axis, the 'field' state object(s) looked
- * out for matching nodes to create a key-sequence for this
+ * during the time this target node was in the
+ * ancestor-or-self axis, the 'field' state object(s) looked
+ * out for matching nodes to create a key-sequence for this
* target node. Now we are back to this target node and need
- * to put the key-sequence, together with the target node
- * itself, into the node-table of the corresponding IDC
+ * to put the key-sequence, together with the target node
+ * itself, into the node-table of the corresponding IDC
* binding.
*/
matcher = sto->matcher;
idc = matcher->aidc->def;
nbKeys = idc->nbFields;
- pos = depth - matcher->depth;
+ pos = depth - matcher->depth;
/*
* Check if the matcher has any key-sequences at all, plus
* if it has a key-sequence for the current target node.
- */
+ */
if ((matcher->keySeqs == NULL) ||
(matcher->sizeKeySeqs <= pos)) {
if (idc->type == XML_SCHEMA_TYPE_IDC_KEY)
@@ -22820,15 +22944,15 @@ create_key:
else
goto selector_leave;
}
-
- keySeq = &(matcher->keySeqs[pos]);
+
+ keySeq = &(matcher->keySeqs[pos]);
if (*keySeq == NULL) {
if (idc->type == XML_SCHEMA_TYPE_IDC_KEY)
goto selector_key_error;
else
goto selector_leave;
}
-
+
for (i = 0; i < nbKeys; i++) {
if ((*keySeq)[i] == NULL) {
/*
@@ -22839,18 +22963,18 @@ create_key:
* All fields of a "key" IDC must resolve.
*/
goto selector_key_error;
- }
+ }
goto selector_leave;
}
}
/*
* All fields did resolve.
*/
-
+
/*
* 4.1 If the {identity-constraint category} is unique(/key),
- * then no two members of the ·qualified node set· have
- * ·key-sequences· whose members are pairwise equal, as
+ * then no two members of the `qualified node set` have
+ * `key-sequences` whose members are pairwise equal, as
* defined by Equal in [XML Schemas: Datatypes].
*
* Get the IDC binding from the matcher and check for
@@ -22860,10 +22984,10 @@ create_key:
bind = xmlSchemaIDCAcquireBinding(vctxt, matcher);
#endif
targets = xmlSchemaIDCAcquireTargetList(vctxt, matcher);
- if ((idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) &&
+ if ((idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) &&
(targets->nbItems != 0)) {
xmlSchemaPSVIIDCKeyPtr ckey, bkey, *bkeySeq;
-
+
i = 0;
res = 0;
/*
@@ -22874,7 +22998,7 @@ create_key:
((xmlSchemaPSVIIDCNodePtr) targets->items[i])->keys;
for (j = 0; j < nbKeys; j++) {
ckey = (*keySeq)[j];
- bkey = bkeySeq[j];
+ bkey = bkeySeq[j];
res = xmlSchemaAreValuesEqual(ckey->val, bkey->val);
if (res == -1) {
return (-1);
@@ -22896,10 +23020,10 @@ create_key:
} while (i < targets->nbItems);
if (i != targets->nbItems) {
xmlChar *str = NULL, *strB = NULL;
- /*
+ /*
* TODO: Try to report the key-sequence.
*/
- xmlSchemaCustomErr(ACTXT_CAST vctxt,
+ xmlSchemaCustomErr(ACTXT_CAST vctxt,
XML_SCHEMAV_CVC_IDC, NULL,
WXS_BASIC_CAST idc,
"Duplicate key-sequence %s in %s",
@@ -22917,15 +23041,15 @@ create_key:
ntItem = (xmlSchemaPSVIIDCNodePtr) xmlMalloc(
sizeof(xmlSchemaPSVIIDCNode));
if (ntItem == NULL) {
- xmlSchemaVErrMemory(NULL,
+ xmlSchemaVErrMemory(NULL,
"allocating an IDC node-table item", NULL);
xmlFree(*keySeq);
*keySeq = NULL;
return(-1);
- }
+ }
memset(ntItem, 0, sizeof(xmlSchemaPSVIIDCNode));
-
- /*
+
+ /*
* Store the node-table item in a global list.
*/
if (idc->type != XML_SCHEMA_TYPE_IDC_KEYREF) {
@@ -22947,7 +23071,7 @@ create_key:
xmlFree(ntItem);
xmlFree(*keySeq);
*keySeq = NULL;
- return (-1);
+ return (-1);
}
}
/*
@@ -22959,11 +23083,11 @@ create_key:
ntItem->keys = *keySeq;
*keySeq = NULL;
#if 0
- if (xmlSchemaIDCAppendNodeTableItem(bind, ntItem) == -1) {
+ if (xmlSchemaIDCAppendNodeTableItem(bind, ntItem) == -1)
#endif
if (xmlSchemaItemListAdd(targets, ntItem) == -1) {
if (idc->type == XML_SCHEMA_TYPE_IDC_KEYREF) {
- /*
+ /*
* Free the item, since keyref items won't be
* put on a global list.
*/
@@ -22972,18 +23096,18 @@ create_key:
}
return (-1);
}
-
+
goto selector_leave;
selector_key_error:
{
xmlChar *str = NULL;
/*
- * 4.2.1 (KEY) The ·target node set· and the
- * ·qualified node set· are equal, that is, every
- * member of the ·target node set· is also a member
- * of the ·qualified node set· and vice versa.
+ * 4.2.1 (KEY) The `target node set` and the
+ * `qualified node set` are equal, that is, every
+ * member of the `target node set` is also a member
+ * of the `qualified node set` and vice versa.
*/
- xmlSchemaCustomErr(ACTXT_CAST vctxt,
+ xmlSchemaCustomErr(ACTXT_CAST vctxt,
XML_SCHEMAV_CVC_IDC, NULL,
WXS_BASIC_CAST idc,
"Not all fields of %s evaluate to a node",
@@ -22999,7 +23123,7 @@ selector_leave:
*keySeq = NULL;
}
} /* if selector */
-
+
sto->nbHistory--;
deregister_check:
@@ -23050,15 +23174,15 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt,
xmlSchemaIDCMatcherPtr matcher, last = NULL;
xmlSchemaIDCPtr idc, refIdc;
xmlSchemaIDCAugPtr aidc;
-
+
idc = (xmlSchemaIDCPtr) elemDecl->idcs;
if (idc == NULL)
return (0);
-
+
#ifdef DEBUG_IDC
{
xmlChar *str = NULL;
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"IDC: REGISTER on %s, depth %d\n",
(char *) xmlSchemaFormatQName(&str, vctxt->inode->nsName,
vctxt->inode->localName), vctxt->depth);
@@ -23099,7 +23223,7 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt,
"Could not find an augmented IDC item for an IDC "
"definition");
return (-1);
- }
+ }
if ((aidc->keyrefDepth == -1) ||
(vctxt->depth < aidc->keyrefDepth))
aidc->keyrefDepth = vctxt->depth;
@@ -23130,10 +23254,10 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt,
vctxt->idcMatcherCache = matcher->nextCached;
matcher->nextCached = NULL;
} else {
- matcher = (xmlSchemaIDCMatcherPtr)
+ matcher = (xmlSchemaIDCMatcherPtr)
xmlMalloc(sizeof(xmlSchemaIDCMatcher));
if (matcher == NULL) {
- xmlSchemaVErrMemory(vctxt,
+ xmlSchemaVErrMemory(vctxt,
"allocating an IDC matcher", NULL);
return (-1);
}
@@ -23146,16 +23270,16 @@ xmlSchemaIDCRegisterMatchers(xmlSchemaValidCtxtPtr vctxt,
last = matcher;
matcher->type = IDC_MATCHER;
- matcher->depth = vctxt->depth;
+ matcher->depth = vctxt->depth;
matcher->aidc = aidc;
matcher->idcType = aidc->def->type;
-#ifdef DEBUG_IDC
+#ifdef DEBUG_IDC
xmlGenericError(xmlGenericErrorContext, "IDC: register matcher\n");
-#endif
+#endif
/*
- * Init the automaton state object.
+ * Init the automaton state object.
*/
- if (xmlSchemaIDCAddStateObject(vctxt, matcher,
+ if (xmlSchemaIDCAddStateObject(vctxt, matcher,
idc->selector, XPATH_STATE_OBJ_TYPE_IDC_SELECTOR) == -1)
return (-1);
@@ -23172,7 +23296,7 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt,
int res, i, j, k, nbTargets, nbFields, nbDupls, nbNodeTable;
xmlSchemaPSVIIDCKeyPtr *keys, *ntkeys;
xmlSchemaPSVIIDCNodePtr *targets, *dupls;
-
+
xmlSchemaIDCMatcherPtr matcher = ielem->idcMatchers;
/* vctxt->createIDCNodeTables */
while (matcher != NULL) {
@@ -23206,7 +23330,7 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt,
nbDupls = bind->dupls->nbItems;
} else {
dupls = NULL;
- nbDupls = 0;
+ nbDupls = 0;
}
if (bind->nodeTable != NULL) {
nbNodeTable = bind->nbNodes;
@@ -23219,29 +23343,29 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt,
* Transfer all IDC target-nodes to the IDC node-table.
*/
bind->nodeTable =
- (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;
+ (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;
bind->sizeNodes = matcher->targets->sizeItems;
bind->nbNodes = matcher->targets->nbItems;
matcher->targets->items = NULL;
matcher->targets->sizeItems = 0;
- matcher->targets->nbItems = 0;
+ matcher->targets->nbItems = 0;
} else {
/*
* Compare the key-sequences and add to the IDC node-table.
*/
nbTargets = matcher->targets->nbItems;
- targets = (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;
+ targets = (xmlSchemaPSVIIDCNodePtr *) matcher->targets->items;
nbFields = matcher->aidc->def->nbFields;
i = 0;
do {
keys = targets[i]->keys;
- if (nbDupls) {
+ if (nbDupls) {
/*
* Search in already found duplicates first.
*/
j = 0;
- do {
+ do {
if (nbFields == 1) {
res = xmlSchemaAreValuesEqual(keys[0]->val,
dupls[j]->keys[0]->val);
@@ -23276,11 +23400,11 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt,
}
}
j++;
- } while (j < nbDupls);
+ } while (j < nbDupls);
}
if (nbNodeTable) {
j = 0;
- do {
+ do {
if (nbFields == 1) {
res = xmlSchemaAreValuesEqual(keys[0]->val,
bind->nodeTable[j]->keys[0]->val);
@@ -23307,7 +23431,7 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt,
goto next_node_table_entry;
}
}
- }
+ }
/*
* Add the duplicate to the list of duplicates.
*/
@@ -23315,7 +23439,7 @@ xmlSchemaIDCFillNodeTables(xmlSchemaValidCtxtPtr vctxt,
bind->dupls = xmlSchemaItemListCreate();
if (bind->dupls == NULL)
goto internal_error;
- }
+ }
if (xmlSchemaItemListAdd(bind->dupls, bind->nodeTable[j]) == -1)
goto internal_error;
/*
@@ -23350,12 +23474,12 @@ internal_error:
}
/**
- * xmlSchemaBubbleIDCNodeTables:
+ * xmlSchemaBubbleIDCNodeTables:
* @depth: the current tree depth
*
- * Merges IDC bindings of an element at @depth into the corresponding IDC
- * bindings of its parent element. If a duplicate note-table entry is found,
- * both, the parent node-table entry and child entry are discarded from the
+ * Merges IDC bindings of an element at @depth into the corresponding IDC
+ * bindings of its parent element. If a duplicate note-table entry is found,
+ * both, the parent node-table entry and child entry are discarded from the
* node-table of the parent.
*
* Returns 0 if OK and -1 on internal errors.
@@ -23369,19 +23493,19 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
xmlSchemaIDCAugPtr aidc;
int i, j, k, ret = 0, nbFields, oldNum, oldDupls;
- bind = vctxt->inode->idcTable;
+ bind = vctxt->inode->idcTable;
if (bind == NULL) {
/* Fine, no table, no bubbles. */
return (0);
}
-
+
parTable = &(vctxt->elemInfos[vctxt->depth -1]->idcTable);
/*
* Walk all bindings; create new or add to existing bindings.
* Remove duplicate key-sequences.
*/
while (bind != NULL) {
-
+
if ((bind->nbNodes == 0) && WXS_ILIST_IS_EMPTY(bind->dupls))
goto next_binding;
/*
@@ -23391,7 +23515,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
aidc = vctxt->aidcs;
do {
if (aidc->def == bind->definition) {
- if ((aidc->keyrefDepth == -1) ||
+ if ((aidc->keyrefDepth == -1) ||
(aidc->keyrefDepth >= vctxt->depth)) {
goto next_binding;
}
@@ -23407,7 +23531,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
* Search a matching parent binding for the
* IDC definition.
*/
- while (parBind != NULL) {
+ while (parBind != NULL) {
if (parBind->definition == bind->definition)
break;
parBind = parBind->next;
@@ -23415,7 +23539,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
if (parBind != NULL) {
/*
- * Compare every node-table entry of the child node,
+ * Compare every node-table entry of the child node,
* i.e. the key-sequence within, ...
*/
oldNum = parBind->nbNodes; /* Skip newly added items. */
@@ -23425,12 +23549,12 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
dupls = (xmlSchemaPSVIIDCNodePtr *) parBind->dupls->items;
} else {
dupls = NULL;
- oldDupls = 0;
+ oldDupls = 0;
}
-
+
parNodes = parBind->nodeTable;
nbFields = bind->definition->nbFields;
-
+
for (i = 0; i < bind->nbNodes; i++) {
node = bind->nodeTable[i];
if (node == NULL)
@@ -23440,7 +23564,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
* evaluated to be a duplicate key-sequence.
*/
if (oldDupls) {
- j = 0;
+ j = 0;
while (j < oldDupls) {
if (nbFields == 1) {
ret = xmlSchemaAreValuesEqual(
@@ -23473,12 +23597,12 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
/* Duplicate found. Skip this entry. */
continue;
}
- }
+ }
/*
* ... and with every key-sequence of the parent node.
*/
if (oldNum) {
- j = 0;
+ j = 0;
while (j < oldNum) {
parNode = parNodes[j];
if (nbFields == 1) {
@@ -23491,7 +23615,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
j++;
continue;
}
- } else {
+ } else {
for (k = 0; k < nbFields; k++) {
ret = xmlSchemaAreValuesEqual(
node->keys[k]->val,
@@ -23512,20 +23636,20 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
* Handle duplicates. Move the duplicate in
* the parent's node-table to the list of
* duplicates.
- */
+ */
oldNum--;
parBind->nbNodes--;
/*
* Move last old item to pos of duplicate.
*/
parNodes[j] = parNodes[oldNum];
-
+
if (parBind->nbNodes != oldNum) {
/*
- * If new items exist, move last new item to
+ * If new items exist, move last new item to
* last of old items.
*/
- parNodes[oldNum] =
+ parNodes[oldNum] =
parNodes[parBind->nbNodes];
}
if (parBind->dupls == NULL) {
@@ -23533,31 +23657,31 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
if (parBind->dupls == NULL)
goto internal_error;
}
- xmlSchemaItemListAdd(parBind->dupls, parNode);
+ xmlSchemaItemListAdd(parBind->dupls, parNode);
} else {
/*
- * Add the node-table entry (node and key-sequence) of
+ * Add the node-table entry (node and key-sequence) of
* the child node to the node table of the parent node.
*/
- if (parBind->nodeTable == NULL) {
- parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
+ if (parBind->nodeTable == NULL) {
+ parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
xmlMalloc(10 * sizeof(xmlSchemaPSVIIDCNodePtr));
if (parBind->nodeTable == NULL) {
- xmlSchemaVErrMemory(NULL,
+ xmlSchemaVErrMemory(NULL,
"allocating IDC list of node-table items", NULL);
goto internal_error;
}
parBind->sizeNodes = 1;
} else if (parBind->nbNodes >= parBind->sizeNodes) {
parBind->sizeNodes *= 2;
- parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
- xmlRealloc(parBind->nodeTable, parBind->sizeNodes *
+ parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
+ xmlRealloc(parBind->nodeTable, parBind->sizeNodes *
sizeof(xmlSchemaPSVIIDCNodePtr));
if (parBind->nodeTable == NULL) {
- xmlSchemaVErrMemory(NULL,
+ xmlSchemaVErrMemory(NULL,
"re-allocating IDC list of node-table items", NULL);
goto internal_error;
- }
+ }
}
parNodes = parBind->nodeTable;
/*
@@ -23567,9 +23691,9 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
parNodes[parBind->nbNodes++] = node;
}
- }
-
- }
+ }
+
+ }
} else {
/*
* No binding for the IDC was found: create a new one and
@@ -23578,7 +23702,7 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
parBind = xmlSchemaIDCNewBinding(bind->definition);
if (parBind == NULL)
goto internal_error;
-
+
/*
* TODO: Hmm, how to optimize the initial number of
* allocated entries?
@@ -23604,11 +23728,11 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
/*
* Copy the entries.
*/
- parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
+ parBind->nodeTable = (xmlSchemaPSVIIDCNodePtr *)
xmlMalloc(bind->nbNodes *
sizeof(xmlSchemaPSVIIDCNodePtr));
if (parBind->nodeTable == NULL) {
- xmlSchemaVErrMemory(NULL,
+ xmlSchemaVErrMemory(NULL,
"allocating an array of IDC node-table "
"items", NULL);
xmlSchemaIDCFreeBinding(parBind);
@@ -23627,15 +23751,17 @@ xmlSchemaBubbleIDCNodeTables(xmlSchemaValidCtxtPtr vctxt)
if (parBind->dupls != NULL)
xmlSchemaItemListFree(parBind->dupls);
parBind->dupls = bind->dupls;
- bind->dupls = NULL;
- }
- if (*parTable == NULL)
- *parTable = parBind;
- else {
- parBind->next = *parTable;
- *parTable = parBind;
- }
- }
+ bind->dupls = NULL;
+ }
+ if (parTable != NULL) {
+ if (*parTable == NULL)
+ *parTable = parBind;
+ else {
+ parBind->next = *parTable;
+ *parTable = parBind;
+ }
+ }
+ }
next_binding:
bind = bind->next;
@@ -23658,7 +23784,7 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt)
{
xmlSchemaIDCMatcherPtr matcher;
xmlSchemaPSVIIDCBindingPtr bind;
-
+
matcher = vctxt->inode->idcMatchers;
/*
* Find a keyref.
@@ -23679,7 +23805,7 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt)
*/
bind = vctxt->inode->idcTable;
while (bind != NULL) {
- if ((xmlSchemaIDCPtr) matcher->aidc->def->ref->item ==
+ if ((xmlSchemaIDCPtr) matcher->aidc->def->ref->item ==
bind->definition)
break;
bind = bind->next;
@@ -23748,7 +23874,7 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt)
}
}
}
-
+
if (res == 0) {
xmlChar *str = NULL, *strB = NULL;
xmlSchemaKeyrefErr(vctxt,
@@ -23770,9 +23896,9 @@ xmlSchemaCheckCVCIDCKeyRef(xmlSchemaValidCtxtPtr vctxt)
}
/************************************************************************
- * *
- * XML Reader validation code *
- * *
+ * *
+ * XML Reader validation code *
+ * *
************************************************************************/
static xmlSchemaAttrInfoPtr
@@ -23832,7 +23958,7 @@ xmlSchemaValidatorPushAttribute(xmlSchemaValidCtxtPtr vctxt,
xmlNodePtr attrNode,
int nodeLine,
const xmlChar *localName,
- const xmlChar *nsName,
+ const xmlChar *nsName,
int ownedNames,
xmlChar *value,
int ownedValue)
@@ -23858,7 +23984,7 @@ xmlSchemaValidatorPushAttribute(xmlSchemaValidCtxtPtr vctxt,
if (nsName != NULL) {
if (xmlStrEqual(localName, BAD_CAST "nil")) {
if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) {
- attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_NIL;
+ attr->metaType = XML_SCHEMA_ATTR_INFO_META_XSI_NIL;
}
} else if (xmlStrEqual(localName, BAD_CAST "type")) {
if (xmlStrEqual(attr->nsName, xmlSchemaInstanceNs)) {
@@ -24060,6 +24186,7 @@ xmlSchemaValidateFacets(xmlSchemaAbstractCtxtPtr actxt,
else
goto pattern_and_enum;
}
+
/*
* Whitespace handling is only of importance for string-based
* types.
@@ -24070,16 +24197,15 @@ xmlSchemaValidateFacets(xmlSchemaAbstractCtxtPtr actxt,
ws = xmlSchemaGetWhiteSpaceFacetValue(type);
} else
ws = XML_SCHEMA_WHITESPACE_COLLAPSE;
+
/*
* If the value was not computed (for string or
* anySimpleType based types), then use the provided
* type.
*/
- if (val == NULL)
- valType = valType;
- else
+ if (val != NULL)
valType = xmlSchemaGetValType(val);
-
+
ret = 0;
for (facetLink = type->facetSet; facetLink != NULL;
facetLink = facetLink->next) {
@@ -24128,11 +24254,11 @@ WXS_IS_LIST:
ret = 0;
for (facetLink = type->facetSet; facetLink != NULL;
facetLink = facetLink->next) {
-
+
switch (facetLink->facet->type) {
case XML_SCHEMA_FACET_LENGTH:
case XML_SCHEMA_FACET_MINLENGTH:
- case XML_SCHEMA_FACET_MAXLENGTH:
+ case XML_SCHEMA_FACET_MAXLENGTH:
ret = xmlSchemaValidateListSimpleTypeFacet(facetLink->facet,
value, length, NULL);
break;
@@ -24144,7 +24270,7 @@ WXS_IS_LIST:
"validating against a list type facet");
return (-1);
} else if (ret > 0) {
- if (fireErrors)
+ if (fireErrors)
xmlSchemaFacetErr(actxt, ret, node,
value, length, type, facetLink->facet, NULL, NULL, NULL);
else
@@ -24221,7 +24347,7 @@ pattern_and_enum:
if (facetLink->facet->type != XML_SCHEMA_FACET_PATTERN)
continue;
found = 1;
- /*
+ /*
* NOTE that for patterns, @value needs to be the
* normalized vaule.
*/
@@ -24233,7 +24359,7 @@ pattern_and_enum:
"validating against a pattern facet");
return (-1);
} else {
- /*
+ /*
* Save the last non-validating facet.
*/
facet = facetLink->facet;
@@ -24256,12 +24382,12 @@ pattern_and_enum:
return (error);
}
-
+
static xmlChar *
xmlSchemaNormalizeValue(xmlSchemaTypePtr type,
const xmlChar *value)
{
- switch (xmlSchemaGetWhiteSpaceFacetValue(type)) {
+ switch (xmlSchemaGetWhiteSpaceFacetValue(type)) {
case XML_SCHEMA_WHITESPACE_COLLAPSE:
return (xmlSchemaCollapseString(value));
case XML_SCHEMA_WHITESPACE_REPLACE:
@@ -24280,7 +24406,7 @@ xmlSchemaValidateQName(xmlSchemaValidCtxtPtr vctxt,
int ret;
const xmlChar *nsName;
xmlChar *local, *prefix = NULL;
-
+
ret = xmlValidateQName(value, 1);
if (ret != 0) {
if (ret == -1) {
@@ -24303,7 +24429,7 @@ xmlSchemaValidateQName(xmlSchemaValidCtxtPtr vctxt,
* - is there a default namespace?
*/
nsName = xmlSchemaLookupNamespace(vctxt, prefix);
-
+
if (prefix != NULL) {
xmlFree(prefix);
/*
@@ -24360,7 +24486,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
value = normValue; \
isNormalized = 1; \
}
-
+
if ((retVal != NULL) && (*retVal != NULL)) {
xmlSchemaFreeValue(*retVal);
*retVal = NULL;
@@ -24375,14 +24501,14 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
*/
/*
* 2.1 If The definition is ENTITY or is validly derived from ENTITY given
- * the empty set, as defined in Type Derivation OK (Simple) (§3.14.6), then
- * the string must be a ·declared entity name·.
+ * the empty set, as defined in Type Derivation OK (Simple) ($3.14.6), then
+ * the string must be a `declared entity name`.
*/
/*
* 2.2 If The definition is ENTITIES or is validly derived from ENTITIES
- * given the empty set, as defined in Type Derivation OK (Simple) (§3.14.6),
- * then every whitespace-delimited substring of the string must be a ·declared
- * entity name·.
+ * given the empty set, as defined in Type Derivation OK (Simple) ($3.14.6),
+ * then every whitespace-delimited substring of the string must be a `declared
+ * entity name`.
*/
/*
* 2.3 otherwise no further condition applies.
@@ -24394,8 +24520,8 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
if (WXS_IS_ANY_SIMPLE_TYPE(type) || WXS_IS_ATOMIC(type)) {
xmlSchemaTypePtr biType; /* The built-in type. */
/*
- * SPEC (1.2.1) "if {variety} is ·atomic· then the string must ·match·
- * a literal in the ·lexical space· of {base type definition}"
+ * SPEC (1.2.1) "if {variety} is `atomic` then the string must `match`
+ * a literal in the `lexical space` of {base type definition}"
*/
/*
* Whitespace-normalize.
@@ -24421,9 +24547,9 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
* NOTATIONs need to be processed here, since they need
* to lookup in the hashtable of NOTATION declarations of the schema.
*/
- if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) {
- switch (biType->builtInType) {
- case XML_SCHEMAS_NOTATION:
+ if (actxt->type == XML_SCHEMA_CTXT_VALIDATOR) {
+ switch (biType->builtInType) {
+ case XML_SCHEMAS_NOTATION:
ret = xmlSchemaValidateNotation(
(xmlSchemaValidCtxtPtr) actxt,
((xmlSchemaValidCtxtPtr) actxt)->schema,
@@ -24437,14 +24563,14 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
/* ws = xmlSchemaGetWhiteSpaceFacetValue(type); */
if (valNeeded)
ret = xmlSchemaValPredefTypeNodeNoNorm(biType,
- value, &val, NULL);
+ value, &val, node);
else
ret = xmlSchemaValPredefTypeNodeNoNorm(biType,
- value, NULL, NULL);
+ value, NULL, node);
break;
}
- } else if (actxt->type == XML_SCHEMA_CTXT_PARSER) {
- switch (biType->builtInType) {
+ } else if (actxt->type == XML_SCHEMA_CTXT_PARSER) {
+ switch (biType->builtInType) {
case XML_SCHEMAS_NOTATION:
ret = xmlSchemaValidateNotation(NULL,
((xmlSchemaParserCtxtPtr) actxt)->schema, node,
@@ -24459,7 +24585,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
ret = xmlSchemaValPredefTypeNodeNoNorm(biType,
value, NULL, node);
break;
- }
+ }
} else {
/*
* Validation via a public API is not implemented yet.
@@ -24476,7 +24602,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
if (WXS_IS_LIST(type))
ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
else
- ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
+ ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
}
if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) {
/*
@@ -24491,10 +24617,10 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
"validating facets of atomic simple type");
goto internal_error;
}
- if (WXS_IS_LIST(type))
+ if (WXS_IS_LIST(type))
ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
else
- ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
+ ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
}
}
if (fireErrors && (ret > 0))
@@ -24506,9 +24632,9 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
xmlChar *tmpValue = NULL;
unsigned long len = 0;
xmlSchemaValPtr prevVal = NULL, curVal = NULL;
- /* 1.2.2 if {variety} is ·list· then the string must be a sequence
- * of white space separated tokens, each of which ·match·es a literal
- * in the ·lexical space· of {item type definition}
+ /* 1.2.2 if {variety} is `list` then the string must be a sequence
+ * of white space separated tokens, each of which `match`es a literal
+ * in the `lexical space` of {item type definition}
*/
/*
* Note that XML_SCHEMAS_TYPE_NORMVALUENEEDED will be set if
@@ -24519,7 +24645,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
* VAL TODO: Optimize validation of empty values.
* VAL TODO: We do not have computed values for lists.
*/
- itemType = WXS_LIST_ITEMTYPE(type);
+ itemType = WXS_LIST_ITEMTYPE(type);
cur = value;
do {
while (IS_BLANK_CH(*cur))
@@ -24558,7 +24684,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
}
ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2;
break;
- }
+ }
cur = end;
} while (*cur != 0);
FREE_AND_NULL(tmpValue);
@@ -24579,7 +24705,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
}
}
if (fireErrors && (ret > 0)) {
- /*
+ /*
* Report the normalized value.
*/
normalize = 1;
@@ -24589,10 +24715,10 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
} else if (WXS_IS_UNION(type)) {
xmlSchemaTypeLinkPtr memberLink;
/*
- * TODO: For all datatypes ·derived· by ·union· whiteSpace does
- * not apply directly; however, the normalization behavior of ·union·
+ * TODO: For all datatypes `derived` by `union` whiteSpace does
+ * not apply directly; however, the normalization behavior of `union`
* types is controlled by the value of whiteSpace on that one of the
- * ·memberTypes· against which the ·union· is successfully validated.
+ * `memberTypes` against which the `union` is successfully validated.
*
* This means that the value is normalized by the first validating
* member type, then the facets of the union type are applied. This
@@ -24600,8 +24726,8 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
*/
/*
- * 1.2.3 if {variety} is ·union· then the string must ·match· a
- * literal in the ·lexical space· of at least one member of
+ * 1.2.3 if {variety} is `union` then the string must `match` a
+ * literal in the `lexical space` of at least one member of
* {member type definitions}
*/
memberLink = xmlSchemaGetUnionSimpleTypeMemberTypes(type);
@@ -24609,7 +24735,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
AERROR_INT("xmlSchemaVCheckCVCSimpleType",
"union simple type has no member types");
goto internal_error;
- }
+ }
/*
* Always normalize union type values, since we currently
* cannot store the whitespace information with the value
@@ -24617,7 +24743,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
* not possible.
*/
while (memberLink != NULL) {
- if (valNeeded)
+ if (valNeeded)
ret = xmlSchemaVCheckCVCSimpleType(actxt, node,
memberLink->type, value, &val, 0, 1, 0);
else
@@ -24640,9 +24766,9 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
*/
if ((ret == 0) && (type->flags & XML_SCHEMAS_TYPE_HAS_FACETS)) {
/*
- * The normalization behavior of ·union· types is controlled by
- * the value of whiteSpace on that one of the ·memberTypes·
- * against which the ·union· is successfully validated.
+ * The normalization behavior of `union` types is controlled by
+ * the value of whiteSpace on that one of the `memberTypes`
+ * against which the `union` is successfully validated.
*/
NORMALIZE(memberLink->type);
ret = xmlSchemaValidateFacets(actxt, node, type,
@@ -24654,7 +24780,7 @@ xmlSchemaVCheckCVCSimpleType(xmlSchemaAbstractCtxtPtr actxt,
"validating facets of union simple type");
goto internal_error;
}
- ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3;
+ ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3;
}
}
if (fireErrors && (ret > 0))
@@ -24802,14 +24928,14 @@ xmlSchemaProcessXSIType(xmlSchemaValidCtxtPtr vctxt,
/*
* SPEC cvc-elt (3.3.4) : (4.3) (Type Derivation OK)
- * "The ·local type definition· must be validly
+ * "The `local type definition` must be validly
* derived from the {type definition} given the union of
* the {disallowed substitutions} and the {type definition}'s
* {prohibited substitutions}, as defined in
- * Type Derivation OK (Complex) (§3.4.6)
+ * Type Derivation OK (Complex) ($3.4.6)
* (if it is a complex type definition),
* or given {disallowed substitutions} as defined in Type
- * Derivation OK (Simple) (§3.14.6) (if it is a simple type
+ * Derivation OK (Simple) ($3.14.6) (if it is a simple type
* definition)."
*
* {disallowed substitutions}: the "block" on the element decl.
@@ -24892,9 +25018,9 @@ xmlSchemaValidateElemDecl(xmlSchemaValidCtxtPtr vctxt)
return (vctxt->err);
}
if (actualType == NULL) {
- VERROR(XML_SCHEMAV_CVC_TYPE_1, NULL,
- "The type definition is absent");
- return (XML_SCHEMAV_CVC_TYPE_1);
+ VERROR(XML_SCHEMAV_CVC_TYPE_1, NULL,
+ "The type definition is absent");
+ return (XML_SCHEMAV_CVC_TYPE_1);
}
if (vctxt->nbAttrInfos != 0) {
int ret;
@@ -24984,9 +25110,9 @@ xmlSchemaValidateElemDecl(xmlSchemaValidCtxtPtr vctxt)
* No actual type definition.
*/
if (actualType == NULL) {
- VERROR(XML_SCHEMAV_CVC_TYPE_1, NULL,
- "The type definition is absent");
- return (XML_SCHEMAV_CVC_TYPE_1);
+ VERROR(XML_SCHEMAV_CVC_TYPE_1, NULL,
+ "The type definition is absent");
+ return (XML_SCHEMAV_CVC_TYPE_1);
}
/*
* Remember the actual type definition.
@@ -25069,19 +25195,19 @@ xmlSchemaClearAttrInfos(xmlSchemaValidCtxtPtr vctxt)
static int
xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
{
- xmlSchemaTypePtr type = vctxt->inode->typeDef;
+ xmlSchemaTypePtr type = vctxt->inode->typeDef;
xmlSchemaItemListPtr attrUseList;
xmlSchemaAttributeUsePtr attrUse = NULL;
xmlSchemaAttributePtr attrDecl = NULL;
- xmlSchemaAttrInfoPtr iattr, tmpiattr;
+ xmlSchemaAttrInfoPtr iattr, tmpiattr;
int i, j, found, nbAttrs, nbUses;
int xpathRes = 0, res, wildIDs = 0, fixed;
xmlNodePtr defAttrOwnerElem = NULL;
/*
* SPEC (cvc-attribute)
- * (1) "The declaration must not be ·absent· (see Missing
- * Sub-components (§5.3) for how this can fail to be
+ * (1) "The declaration must not be `absent` (see Missing
+ * Sub-components ($5.3) for how this can fail to be
* the case)."
* (2) "Its {type definition} must not be absent."
*
@@ -25131,15 +25257,15 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
* use with an {attribute declaration} whose {name} matches
* the attribute information item's [local name] and whose
* {target namespace} is identical to the attribute information
- * item's [namespace name] (where an ·absent· {target namespace}
+ * item's [namespace name] (where an `absent` {target namespace}
* is taken to be identical to a [namespace name] with no value),
- * then the attribute information must be ·valid· with respect
+ * then the attribute information must be `valid` with respect
* to that attribute use as per Attribute Locally Valid (Use)
- * (§3.5.4). In this case the {attribute declaration} of that
- * attribute use is the ·context-determined declaration· for the
+ * ($3.5.4). In this case the {attribute declaration} of that
+ * attribute use is the `context-determined declaration` for the
* attribute information item with respect to Schema-Validity
- * Assessment (Attribute) (§3.2.4) and
- * Assessment Outcome (Attribute) (§3.2.5).
+ * Assessment (Attribute) ($3.2.4) and
+ * Assessment Outcome (Attribute) ($3.2.5).
*/
iattr->state = XML_SCHEMAS_ATTR_ASSESSED;
iattr->use = attrUse;
@@ -25173,7 +25299,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
}
tmpiattr->state = XML_SCHEMAS_ATTR_ERR_MISSING;
tmpiattr->use = attrUse;
- tmpiattr->decl = attrDecl;
+ tmpiattr->decl = attrDecl;
} else if ((attrUse->occurs == XML_SCHEMAS_ATTR_USE_OPTIONAL) &&
((attrUse->defValue != NULL) ||
(attrDecl->defValue != NULL))) {
@@ -25198,7 +25324,6 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
if (vctxt->nbAttrInfos == 0)
return (0);
- nbUses = vctxt->nbAttrInfos;
/*
* Validate against the wildcard.
*/
@@ -25217,13 +25342,13 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
continue;
/*
* SPEC (cvc-complex-type)
- * (3.2.2) "The attribute information item must be ·valid· with
- * respect to it as defined in Item Valid (Wildcard) (§3.10.4)."
+ * (3.2.2) "The attribute information item must be `valid` with
+ * respect to it as defined in Item Valid (Wildcard) ($3.10.4)."
*
* SPEC Item Valid (Wildcard) (cvc-wildcard)
- * "... its [namespace name] must be ·valid· with respect to
+ * "... its [namespace name] must be `valid` with respect to
* the wildcard constraint, as defined in Wildcard allows
- * Namespace Name (§3.10.4)."
+ * Namespace Name ($3.10.4)."
*/
if (xmlSchemaCheckCVCWildcardNamespace(type->attributeWildcard,
iattr->nsName) == 0) {
@@ -25259,11 +25384,11 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
* SPEC (cvc-complex-type)
* (5) "Let [Definition:] the wild IDs be the set of
* all attribute information item to which clause 3.2
- * applied and whose ·validation· resulted in a
- * ·context-determined declaration· of mustFind or no
- * ·context-determined declaration· at all, and whose
+ * applied and whose `validation` resulted in a
+ * `context-determined declaration` of mustFind or no
+ * `context-determined declaration` at all, and whose
* [local name] and [namespace name] resolve (as
- * defined by QName resolution (Instance) (§3.15.4)) to
+ * defined by QName resolution (Instance) ($3.15.4)) to
* an attribute declaration whose {type definition} is
* or is derived from ID. Then all of the following
* must be true:"
@@ -25273,7 +25398,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
iattr->typeDef, XML_SCHEMAS_ID)) {
/*
* SPEC (5.1) "There must be no more than one
- * item in ·wild IDs·."
+ * item in `wild IDs`."
*/
if (wildIDs != 0) {
/* VAL TODO */
@@ -25284,21 +25409,23 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
wildIDs++;
/*
* SPEC (cvc-complex-type)
- * (5.2) "If ·wild IDs· is non-empty, there must not
+ * (5.2) "If `wild IDs` is non-empty, there must not
* be any attribute uses among the {attribute uses}
* whose {attribute declaration}'s {type definition}
* is or is derived from ID."
*/
- for (j = 0; j < attrUseList->nbItems; j++) {
- if (xmlSchemaIsDerivedFromBuiltInType(
- WXS_ATTRUSE_TYPEDEF(attrUseList->items[j]),
- XML_SCHEMAS_ID)) {
- /* URGENT VAL TODO: implement */
- iattr->state = XML_SCHEMAS_ATTR_ERR_WILD_AND_USE_ID;
- TODO
- break;
- }
- }
+ if (attrUseList != NULL) {
+ for (j = 0; j < attrUseList->nbItems; j++) {
+ if (xmlSchemaIsDerivedFromBuiltInType(
+ WXS_ATTRUSE_TYPEDEF(attrUseList->items[j]),
+ XML_SCHEMAS_ID)) {
+ /* URGENT VAL TODO: implement */
+ iattr->state = XML_SCHEMAS_ATTR_ERR_WILD_AND_USE_ID;
+ TODO
+ break;
+ }
+ }
+ }
}
} else if (type->attributeWildcard->processContents ==
XML_SCHEMAS_ANY_LAX) {
@@ -25401,7 +25528,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
* VAL TODO: Should we use the *normalized* value? This currently
* uses the *initial* value.
*/
-
+
if (defAttrOwnerElem) {
xmlChar *normValue;
const xmlChar *value;
@@ -25419,7 +25546,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
if (xmlNewProp(defAttrOwnerElem,
iattr->localName, value) == NULL) {
VERROR_INT("xmlSchemaVAttributesComplex",
- "callling xmlNewProp()");
+ "calling xmlNewProp()");
if (normValue != NULL)
xmlFree(normValue);
goto internal_error;
@@ -25492,9 +25619,9 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
fixed = 0;
/*
* SPEC (cvc-attribute)
- * (3) "The item's ·normalized value· must be locally ·valid·
- * with respect to that {type definition} as per
- * String Valid (§3.14.4)."
+ * (3) "The item's `normalized value` must be locally `valid`
+ * with respect to that {type definition} as per
+ * String Valid ($3.14.4)."
*
* VAL TODO: Do we already have the
* "normalized attribute value" here?
@@ -25514,7 +25641,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
iattr->node, iattr->typeDef, iattr->value, NULL,
1, 0, 0);
}
-
+
if (res != 0) {
if (res == -1) {
VERROR_INT("xmlSchemaVAttributesComplex",
@@ -25529,12 +25656,12 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
goto eval_idcs;
}
- if (fixed) {
+ if (fixed) {
/*
* SPEC Attribute Locally Valid (Use) (cvc-au)
- * "For an attribute information item to be·valid·
+ * "For an attribute information item to be `valid`
* with respect to an attribute use its *normalized*
- * value· must match the *canonical* lexical
+ * value must match the *canonical* lexical
* representation of the attribute use's {value
* constraint}value, if it is present and fixed."
*
@@ -25543,7 +25670,7 @@ xmlSchemaVAttributesComplex(xmlSchemaValidCtxtPtr vctxt)
*/
/*
* SPEC Attribute Locally Valid (cvc-attribute)
- * (4) "The item's *actual* value· must match the *value* of
+ * (4) "The item's *actual* value must match the *value* of
* the {value constraint}, if it is present and fixed."
*/
if (iattr->val == NULL) {
@@ -25635,8 +25762,8 @@ eval_idcs:
xmlSchemaCustomErr(ACTXT_CAST vctxt,
XML_SCHEMAV_CVC_AU, NULL, NULL,
"The value '%s' does not match the fixed "
- "value constraint '%s'",
- iattr->value, iattr->vcValue);
+ "value constraint '%s'",
+ iattr->value, iattr->vcValue);
break;
case XML_SCHEMAS_ATTR_ERR_WILD_STRICT_NO_DECL:
VERROR(XML_SCHEMAV_CVC_WILDCARD, NULL,
@@ -25698,7 +25825,7 @@ xmlSchemaValidateElemWildcard(xmlSchemaValidCtxtPtr vctxt,
xmlSchemaElementPtr decl = NULL;
decl = xmlSchemaGetElem(vctxt->schema,
- vctxt->inode->localName, vctxt->inode->nsName);
+ vctxt->inode->localName, vctxt->inode->nsName);
if (decl != NULL) {
vctxt->inode->decl = decl;
return (0);
@@ -25756,16 +25883,16 @@ static int
xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt,
const xmlChar *value,
xmlSchemaValPtr *val)
-{
+{
int ret = 0;
xmlSchemaNodeInfoPtr inode = vctxt->inode;
/*
* cos-valid-default:
* Schema Component Constraint: Element Default Valid (Immediate)
- * For a string to be a valid default with respect to a type
+ * For a string to be a valid default with respect to a type
* definition the appropriate case among the following must be true:
- */
+ */
if WXS_IS_COMPLEX(inode->typeDef) {
/*
* Complex type.
@@ -25773,8 +25900,8 @@ xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt,
* SPEC (2.1) "its {content type} must be a simple type definition
* or mixed."
* SPEC (2.2.2) "If the {content type} is mixed, then the {content
- * type}'s particle must be ·emptiable· as defined by
- * Particle Emptiable (§3.9.6)."
+ * type}'s particle must be `emptiable` as defined by
+ * Particle Emptiable ($3.9.6)."
*/
if ((! WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) &&
((! WXS_HAS_MIXED_CONTENT(inode->typeDef)) ||
@@ -25787,18 +25914,18 @@ xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt,
"or mixed content and a particle emptiable");
return(ret);
}
- }
+ }
/*
- * 1 If the type definition is a simple type definition, then the string
- * must be ·valid· with respect to that definition as defined by String
- * Valid (§3.14.4).
+ * 1 If the type definition is a simple type definition, then the string
+ * must be `valid` with respect to that definition as defined by String
+ * Valid ($3.14.4).
*
* AND
*
- * 2.2.1 If the {content type} is a simple type definition, then the
- * string must be ·valid· with respect to that simple type definition
- * as defined by String Valid (§3.14.4).
- */
+ * 2.2.1 If the {content type} is a simple type definition, then the
+ * string must be `valid` with respect to that simple type definition
+ * as defined by String Valid ($3.14.4).
+ */
if (WXS_IS_SIMPLE(inode->typeDef)) {
ret = xmlSchemaVCheckCVCSimpleType(ACTXT_CAST vctxt,
@@ -25812,7 +25939,7 @@ xmlSchemaCheckCOSValidDefault(xmlSchemaValidCtxtPtr vctxt,
if (ret < 0) {
VERROR_INT("xmlSchemaCheckCOSValidDefault",
"calling xmlSchemaVCheckCVCSimpleType()");
- }
+ }
return (ret);
}
@@ -25846,13 +25973,13 @@ xmlSchemaVContentModelCallback(xmlSchemaValidCtxtPtr vctxt ATTRIBUTE_UNUSED,
static int
xmlSchemaValidatorPushElem(xmlSchemaValidCtxtPtr vctxt)
-{
+{
vctxt->inode = xmlSchemaGetFreshElemInfo(vctxt);
if (vctxt->inode == NULL) {
VERROR_INT("xmlSchemaValidatorPushElem",
"calling xmlSchemaGetFreshElemInfo()");
return (-1);
- }
+ }
vctxt->nbAttrInfos = 0;
return (0);
}
@@ -25875,7 +26002,7 @@ xmlSchemaVCheckINodeDataType(xmlSchemaValidCtxtPtr vctxt,
-/*
+/*
* Process END of element.
*/
static int
@@ -25894,7 +26021,7 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
*/
vctxt->skipDepth = vctxt->depth -1;
goto end_elem;
- }
+ }
if ((inode->typeDef == NULL) ||
(inode->flags & XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE)) {
/*
@@ -25914,8 +26041,8 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
* Workaround for "anyType".
*/
if (inode->typeDef->builtInType == XML_SCHEMAS_ANYTYPE)
- goto character_content;
-
+ goto character_content;
+
if ((inode->flags & XML_SCHEMA_ELEM_INFO_ERR_BAD_CONTENT) == 0) {
xmlChar *values[10];
int terminal, nbval = 10, nbneg;
@@ -25936,16 +26063,30 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
#ifdef DEBUG_AUTOMATA
xmlGenericError(xmlGenericErrorContext,
"AUTOMATON create on '%s'\n", inode->localName);
-#endif
+#endif
+ }
+
+ /*
+ * Do not check further content if the node has been nilled
+ */
+ if (INODE_NILLED(inode)) {
+ ret = 0;
+#ifdef DEBUG_AUTOMATA
+ xmlGenericError(xmlGenericErrorContext,
+ "AUTOMATON succeeded on nilled '%s'\n",
+ inode->localName);
+#endif
+ goto skip_nilled;
}
+
/*
* Get hold of the still expected content, since a further
* call to xmlRegExecPushString() will loose this information.
- */
+ */
xmlRegExecNextValues(inode->regexCtxt,
&nbval, &nbneg, &values[0], &terminal);
ret = xmlRegExecPushString(inode->regexCtxt, NULL, NULL);
- if (ret <= 0) {
+ if ((ret<0) || ((ret==0) && (!INODE_NILLED(inode)))) {
/*
* Still missing something.
*/
@@ -25975,6 +26116,9 @@ xmlSchemaValidatorPopElem(xmlSchemaValidCtxtPtr vctxt)
}
}
+
+skip_nilled:
+
if (inode->typeDef->contentType == XML_SCHEMA_CONTENT_ELEMENTS)
goto end_elem;
@@ -25991,14 +26135,14 @@ character_content:
/*
* Speedup if no declaration exists.
*/
- if (WXS_IS_SIMPLE(inode->typeDef)) {
+ if (WXS_IS_SIMPLE(inode->typeDef)) {
ret = xmlSchemaVCheckINodeDataType(vctxt,
inode, inode->typeDef, inode->value);
} else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
ret = xmlSchemaVCheckINodeDataType(vctxt,
inode, inode->typeDef->contentTypeDef,
inode->value);
- }
+ }
if (ret < 0) {
VERROR_INT("xmlSchemaValidatorPopElem",
"calling xmlSchemaVCheckCVCSimpleType()");
@@ -26007,26 +26151,26 @@ character_content:
goto end_elem;
}
/*
- * cvc-elt (3.3.4) : 5
+ * cvc-elt (3.3.4) : 5
* The appropriate case among the following must be true:
*/
/*
- * cvc-elt (3.3.4) : 5.1
- * If the declaration has a {value constraint},
- * the item has neither element nor character [children] and
+ * cvc-elt (3.3.4) : 5.1
+ * If the declaration has a {value constraint},
+ * the item has neither element nor character [children] and
* clause 3.2 has not applied, then all of the following must be true:
*/
if ((inode->decl->value != NULL) &&
- (inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY) &&
+ (inode->flags & XML_SCHEMA_ELEM_INFO_EMPTY) &&
(! INODE_NILLED(inode))) {
/*
- * cvc-elt (3.3.4) : 5.1.1
- * If the ·actual type definition· is a ·local type definition·
+ * cvc-elt (3.3.4) : 5.1.1
+ * If the `actual type definition` is a `local type definition`
* then the canonical lexical representation of the {value constraint}
- * value must be a valid default for the ·actual type definition· as
- * defined in Element Default Valid (Immediate) (§3.3.6).
+ * value must be a valid default for the `actual type definition` as
+ * defined in Element Default Valid (Immediate) ($3.3.6).
*/
- /*
+ /*
* NOTE: 'local' above means types acquired by xsi:type.
* NOTE: Although the *canonical* value is stated, it is not
* relevant if canonical or not. Additionally XML Schema 1.1
@@ -26049,22 +26193,22 @@ character_content:
* (see following).
*/
goto default_psvi;
- }
- /*
- * cvc-elt (3.3.4) : 5.1.2
- * The element information item with the canonical lexical
- * representation of the {value constraint} value used as its
- * ·normalized value· must be ·valid· with respect to the
- * ·actual type definition· as defined by Element Locally Valid (Type)
- * (§3.3.4).
- */
+ }
+ /*
+ * cvc-elt (3.3.4) : 5.1.2
+ * The element information item with the canonical lexical
+ * representation of the {value constraint} value used as its
+ * `normalized value` must be `valid` with respect to the
+ * `actual type definition` as defined by Element Locally Valid (Type)
+ * ($3.3.4).
+ */
if (WXS_IS_SIMPLE(inode->typeDef)) {
ret = xmlSchemaVCheckINodeDataType(vctxt,
inode, inode->typeDef, inode->decl->value);
} else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
ret = xmlSchemaVCheckINodeDataType(vctxt,
inode, inode->typeDef->contentTypeDef,
- inode->decl->value);
+ inode->decl->value);
}
if (ret != 0) {
if (ret < 0) {
@@ -26085,7 +26229,7 @@ default_psvi:
xmlChar *normValue;
/*
* VAL TODO: Normalize the value.
- */
+ */
normValue = xmlSchemaNormalizeValue(inode->typeDef,
inode->decl->value);
if (normValue != NULL) {
@@ -26098,42 +26242,42 @@ default_psvi:
"calling xmlNewText()");
goto internal_error;
} else
- xmlAddChild(inode->node, textChild);
+ xmlAddChild(inode->node, textChild);
}
-
- } else if (! INODE_NILLED(inode)) {
+
+ } else if (! INODE_NILLED(inode)) {
/*
- * 5.2.1 The element information item must be ·valid· with respect
- * to the ·actual type definition· as defined by Element Locally
- * Valid (Type) (§3.3.4).
- */
+ * 5.2.1 The element information item must be `valid` with respect
+ * to the `actual type definition` as defined by Element Locally
+ * Valid (Type) ($3.3.4).
+ */
if (WXS_IS_SIMPLE(inode->typeDef)) {
/*
* SPEC (cvc-type) (3.1)
* "If the type definition is a simple type definition, ..."
* (3.1.3) "If clause 3.2 of Element Locally Valid
- * (Element) (§3.3.4) did not apply, then the ·normalized value·
- * must be ·valid· with respect to the type definition as defined
- * by String Valid (§3.14.4).
- */
+ * (Element) ($3.3.4) did not apply, then the `normalized value`
+ * must be `valid` with respect to the type definition as defined
+ * by String Valid ($3.14.4).
+ */
ret = xmlSchemaVCheckINodeDataType(vctxt,
inode, inode->typeDef, inode->value);
} else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
/*
* SPEC (cvc-type) (3.2) "If the type definition is a complex type
* definition, then the element information item must be
- * ·valid· with respect to the type definition as per
- * Element Locally Valid (Complex Type) (§3.4.4);"
+ * `valid` with respect to the type definition as per
+ * Element Locally Valid (Complex Type) ($3.4.4);"
*
* SPEC (cvc-complex-type) (2.2)
- * "If the {content type} is a simple type definition, ...
- * the ·normalized value· of the element information item is
- * ·valid· with respect to that simple type definition as
- * defined by String Valid (§3.14.4)."
+ * "If the {content type} is a simple type definition, ...
+ * the `normalized value` of the element information item is
+ * `valid` with respect to that simple type definition as
+ * defined by String Valid ($3.14.4)."
*/
ret = xmlSchemaVCheckINodeDataType(vctxt,
inode, inode->typeDef->contentTypeDef, inode->value);
- }
+ }
if (ret != 0) {
if (ret < 0) {
VERROR_INT("xmlSchemaValidatorPopElem",
@@ -26143,7 +26287,7 @@ default_psvi:
goto end_elem;
}
/*
- * 5.2.2 If there is a fixed {value constraint} and clause 3.2 has
+ * 5.2.2 If there is a fixed {value constraint} and clause 3.2 has
* not applied, all of the following must be true:
*/
if ((inode->decl->value != NULL) &&
@@ -26154,7 +26298,7 @@ default_psvi:
* done on computed values.
*/
/*
- * 5.2.2.1 The element information item must have no element
+ * 5.2.2.1 The element information item must have no element
* information item [children].
*/
if (inode->flags &
@@ -26166,28 +26310,28 @@ default_psvi:
goto end_elem;
} else {
/*
- * 5.2.2.2 The appropriate case among the following must
+ * 5.2.2.2 The appropriate case among the following must
* be true:
- */
+ */
if (WXS_HAS_MIXED_CONTENT(inode->typeDef)) {
/*
- * 5.2.2.2.1 If the {content type} of the ·actual type
- * definition· is mixed, then the *initial value* of the
- * item must match the canonical lexical representation
+ * 5.2.2.2.1 If the {content type} of the `actual type
+ * definition` is mixed, then the *initial value* of the
+ * item must match the canonical lexical representation
* of the {value constraint} value.
*
- * ... the *initial value* of an element information
- * item is the string composed of, in order, the
- * [character code] of each character information item in
+ * ... the *initial value* of an element information
+ * item is the string composed of, in order, the
+ * [character code] of each character information item in
* the [children] of that element information item.
- */
+ */
if (! xmlStrEqual(inode->value, inode->decl->value)){
- /*
+ /*
* VAL TODO: Report invalid & expected values as well.
* VAL TODO: Implement the canonical stuff.
*/
ret = XML_SCHEMAV_CVC_ELT_5_2_2_2_1;
- xmlSchemaCustomErr(ACTXT_CAST vctxt,
+ xmlSchemaCustomErr(ACTXT_CAST vctxt,
ret, NULL, NULL,
"The initial value '%s' does not match the fixed "
"value constraint '%s'",
@@ -26196,9 +26340,9 @@ default_psvi:
}
} else if (WXS_HAS_SIMPLE_CONTENT(inode->typeDef)) {
/*
- * 5.2.2.2.2 If the {content type} of the ·actual type
- * definition· is a simple type definition, then the
- * *actual value* of the item must match the canonical
+ * 5.2.2.2.2 If the {content type} of the `actual type
+ * definition` is a simple type definition, then the
+ * *actual value* of the item must match the canonical
* lexical representation of the {value constraint} value.
*/
/*
@@ -26213,16 +26357,16 @@ default_psvi:
xmlSchemaCustomErr(ACTXT_CAST vctxt,
ret, NULL, NULL,
"The actual value '%s' does not match the fixed "
- "value constraint '%s'",
+ "value constraint '%s'",
inode->value,
inode->decl->value);
goto end_elem;
- }
+ }
}
- }
+ }
}
}
-
+
end_elem:
if (vctxt->depth < 0) {
/* TODO: raise error? */
@@ -26232,15 +26376,15 @@ end_elem:
vctxt->skipDepth = -1;
/*
* Evaluate the history of XPath state objects.
- */
+ */
if (inode->appliedXPath &&
(xmlSchemaXPathProcessHistory(vctxt, vctxt->depth) == -1))
goto internal_error;
/*
* MAYBE TODO:
- * SPEC (6) "The element information item must be ·valid· with
+ * SPEC (6) "The element information item must be `valid` with
* respect to each of the {identity-constraint definitions} as per
- * Identity-constraint Satisfied (§3.11.4)."
+ * Identity-constraint Satisfied ($3.11.4)."
*/
/*
* PSVI TODO: If we expose IDC node-tables via PSVI then the tables
@@ -26248,7 +26392,7 @@ end_elem:
* We will currently build IDC node-tables and bubble them only if
* keyrefs do exist.
*/
-
+
/*
* Add the current IDC target-nodes to the IDC node-tables.
*/
@@ -26282,7 +26426,7 @@ end_elem:
*/
if (xmlSchemaBubbleIDCNodeTables(vctxt) == -1)
goto internal_error;
- }
+ }
}
/*
* Clear the current ielem.
@@ -26315,11 +26459,11 @@ end_elem:
aidc = aidc->next;
} while (aidc != NULL);
}
- vctxt->depth--;
+ vctxt->depth--;
vctxt->inode = vctxt->elemInfos[vctxt->depth];
/*
- * VAL TODO: 7 If the element information item is the ·validation root·, it must be
- * ·valid· per Validation Root Valid (ID/IDREF) (§3.3.4).
+ * VAL TODO: 7 If the element information item is the `validation root`, it must be
+ * `valid` per Validation Root Valid (ID/IDREF) ($3.3.4).
*/
return (ret);
@@ -26400,11 +26544,11 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
* Fallback to "anyType".
*
* SPEC (cvc-assess-elt)
- * "If the item cannot be ·strictly assessed·, [...]
+ * "If the item cannot be `strictly assessed`, [...]
* an element information item's schema validity may be laxly
- * assessed if its ·context-determined declaration· is not
- * skip by ·validating· with respect to the ·ur-type
- * definition· as per Element Locally Valid (Type) (§3.3.4)."
+ * assessed if its `context-determined declaration` is not
+ * skip by `validating` with respect to the `ur-type
+ * definition` as per Element Locally Valid (Type) ($3.3.4)."
*/
vctxt->inode->typeDef =
xmlSchemaGetBuiltInType(XML_SCHEMAS_ANYTYPE);
@@ -26476,9 +26620,9 @@ xmlSchemaValidateChildElem(xmlSchemaValidCtxtPtr vctxt)
* SPEC (2.4) "If the {content type} is element-only or mixed,
* then the sequence of the element information item's
* element information item [children], if any, taken in
- * order, is ·valid· with respect to the {content type}'s
+ * order, is `valid` with respect to the {content type}'s
* particle, as defined in Element Sequence Locally Valid
- * (Particle) (§3.9.4)."
+ * (Particle) ($3.9.4)."
*/
ret = xmlRegExecPushString2(regexCtxt,
vctxt->inode->localName,
@@ -26575,7 +26719,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt,
if (consumed != NULL)
*consumed = 0;
if (INODE_NILLED(vctxt->inode)) {
- /*
+ /*
* SPEC cvc-elt (3.3.4 - 3.2.1)
* "The element information item must have no character or
* element information item [children]."
@@ -26591,7 +26735,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt,
* information item [children]."
*/
if (vctxt->inode->typeDef->contentType ==
- XML_SCHEMA_CONTENT_EMPTY) {
+ XML_SCHEMA_CONTENT_EMPTY) {
VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, NULL,
"Character content is not allowed, "
"because the content type is empty");
@@ -26602,12 +26746,12 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt,
XML_SCHEMA_CONTENT_ELEMENTS) {
if ((nodeType != XML_TEXT_NODE) ||
(! xmlSchemaIsBlank((xmlChar *) value, len))) {
- /*
- * SPEC cvc-complex-type (2.3)
- * "If the {content type} is element-only, then the
- * element information item has no character information
- * item [children] other than those whose [character
- * code] is defined as a white space in [XML 1.0 (Second
+ /*
+ * SPEC cvc-complex-type (2.3)
+ * "If the {content type} is element-only, then the
+ * element information item has no character information
+ * item [children] other than those whose [character
+ * code] is defined as a white space in [XML 1.0 (Second
* Edition)]."
*/
VERROR(XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, NULL,
@@ -26617,7 +26761,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt,
}
return (0);
}
-
+
if ((value == NULL) || (value[0] == 0))
return (0);
/*
@@ -26629,7 +26773,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt,
((vctxt->inode->decl == NULL) ||
(vctxt->inode->decl->value == NULL)))
return (0);
-
+
if (vctxt->inode->value == NULL) {
/*
* Set the value.
@@ -26672,7 +26816,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt,
len = xmlStrlen(value);
/*
* Concat the value.
- */
+ */
if (vctxt->inode->flags & XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES) {
vctxt->inode->value = BAD_CAST xmlStrncat(
(xmlChar *) vctxt->inode->value, value, len);
@@ -26681,7 +26825,7 @@ xmlSchemaVPushText(xmlSchemaValidCtxtPtr vctxt,
BAD_CAST xmlStrncatNew(vctxt->inode->value, value, len);
vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_FLAG_OWNED_VALUES;
}
- }
+ }
return (0);
}
@@ -26698,7 +26842,7 @@ xmlSchemaValidateElem(xmlSchemaValidCtxtPtr vctxt)
goto internal_error;
}
if (vctxt->xsiAssemble) {
- /*
+ /*
* We will stop validation if there was an error during
* dynamic schema construction.
* Note that we simply set @skipDepth to 0, this could
@@ -26715,6 +26859,11 @@ xmlSchemaValidateElem(xmlSchemaValidCtxtPtr vctxt)
vctxt->skipDepth = 0;
return(ret);
}
+ /*
+ * Augment the IDC definitions for the main schema and all imported ones
+ * NOTE: main schema is the first in the imported list
+ */
+ xmlHashScan(vctxt->schema->schemasImports,(xmlHashScanner)xmlSchemaAugmentImportedIDC, vctxt);
}
if (vctxt->depth > 0) {
/*
@@ -26808,15 +26957,15 @@ type_validation:
if (vctxt->inode->typeDef == NULL) {
vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE;
ret = XML_SCHEMAV_CVC_TYPE_1;
- VERROR(ret, NULL,
- "The type definition is absent");
+ VERROR(ret, NULL,
+ "The type definition is absent");
goto exit;
- }
+ }
if (vctxt->inode->typeDef->flags & XML_SCHEMAS_TYPE_ABSTRACT) {
vctxt->inode->flags |= XML_SCHEMA_NODE_INFO_ERR_BAD_TYPE;
ret = XML_SCHEMAV_CVC_TYPE_2;
- VERROR(ret, NULL,
- "The type definition is abstract");
+ VERROR(ret, NULL,
+ "The type definition is abstract");
goto exit;
}
/*
@@ -26897,7 +27046,7 @@ root_found:
nodeType = xmlTextReaderNodeType(vctxt->reader);
if (nodeType == XML_ELEMENT_NODE) {
-
+
vctxt->depth++;
if (xmlSchemaValidatorPushElem(vctxt) == -1) {
VERROR_INT("xmlSchemaVReaderWalk",
@@ -27063,17 +27212,17 @@ internal_error:
#endif
/************************************************************************
- * *
- * SAX validation handlers *
- * *
+ * *
+ * SAX validation handlers *
+ * *
************************************************************************/
/*
* Process text content.
*/
static void
-xmlSchemaSAXHandleText(void *ctx,
- const xmlChar * ch,
+xmlSchemaSAXHandleText(void *ctx,
+ const xmlChar * ch,
int len)
{
xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx;
@@ -27097,10 +27246,10 @@ xmlSchemaSAXHandleText(void *ctx,
* Process CDATA content.
*/
static void
-xmlSchemaSAXHandleCDataSection(void *ctx,
- const xmlChar * ch,
+xmlSchemaSAXHandleCDataSection(void *ctx,
+ const xmlChar * ch,
int len)
-{
+{
xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx;
if (vctxt->depth < 0)
@@ -27134,20 +27283,20 @@ xmlSchemaSAXHandleReference(void *ctx ATTRIBUTE_UNUSED,
static void
xmlSchemaSAXHandleStartElementNs(void *ctx,
- const xmlChar * localname,
- const xmlChar * prefix ATTRIBUTE_UNUSED,
- const xmlChar * URI,
- int nb_namespaces,
- const xmlChar ** namespaces,
- int nb_attributes,
- int nb_defaulted ATTRIBUTE_UNUSED,
+ const xmlChar * localname,
+ const xmlChar * prefix ATTRIBUTE_UNUSED,
+ const xmlChar * URI,
+ int nb_namespaces,
+ const xmlChar ** namespaces,
+ int nb_attributes,
+ int nb_defaulted ATTRIBUTE_UNUSED,
const xmlChar ** attributes)
-{
+{
xmlSchemaValidCtxtPtr vctxt = (xmlSchemaValidCtxtPtr) ctx;
int ret;
xmlSchemaNodeInfoPtr ielem;
int i, j;
-
+
/*
* SAX VAL TODO: What to do with nb_defaulted?
*/
@@ -27175,16 +27324,16 @@ xmlSchemaSAXHandleStartElementNs(void *ctx,
ielem->flags |= XML_SCHEMA_ELEM_INFO_EMPTY;
/*
* Register namespaces on the elem info.
- */
+ */
if (nb_namespaces != 0) {
/*
* Although the parser builds its own namespace list,
* we have no access to it, so we'll use an own one.
*/
- for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) {
+ for (i = 0, j = 0; i < nb_namespaces; i++, j += 2) {
/*
* Store prefix and namespace name.
- */
+ */
if (ielem->nsBindings == NULL) {
ielem->nsBindings =
(const xmlChar **) xmlMalloc(10 *
@@ -27220,7 +27369,7 @@ xmlSchemaSAXHandleStartElementNs(void *ctx,
} else
ielem->nsBindings[ielem->nbNsBindings * 2 + 1] =
namespaces[j+1];
- ielem->nbNsBindings++;
+ ielem->nbNsBindings++;
}
}
/*
@@ -27234,7 +27383,7 @@ xmlSchemaSAXHandleStartElementNs(void *ctx,
for (j = 0, i = 0; i < nb_attributes; i++, j += 5) {
/*
* Duplicate the value.
- */
+ */
value = xmlStrndup(attributes[j+3],
attributes[j+4] - attributes[j+3]);
/*
@@ -27261,7 +27410,7 @@ xmlSchemaSAXHandleStartElementNs(void *ctx,
goto internal_error;
}
goto exit;
- }
+ }
exit:
return;
@@ -27316,9 +27465,9 @@ internal_error:
}
/************************************************************************
- * *
- * Validation interfaces *
- * *
+ * *
+ * Validation interfaces *
+ * *
************************************************************************/
/**
@@ -27348,8 +27497,28 @@ xmlSchemaNewValidCtxt(xmlSchemaPtr schema)
}
/**
+ * xmlSchemaValidateSetFilename:
+ * @vctxt: the schema validation context
+ * @filename: the file name
+ *
+ * Workaround to provide file error reporting information when this is
+ * not provided by current APIs
+ */
+void
+xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt, const char *filename) {
+ if (vctxt == NULL)
+ return;
+ if (vctxt->filename != NULL)
+ xmlFree(vctxt->filename);
+ if (filename != NULL)
+ vctxt->filename = (char *) xmlStrdup((const xmlChar *) filename);
+ else
+ vctxt->filename = NULL;
+}
+
+/**
* xmlSchemaClearValidCtxt:
- * @ctxt: the schema validation context
+ * @vctxt: the schema validation context
*
* Free the resources associated to the schema validation context;
* leaves some fields alive intended for reuse of the context.
@@ -27371,7 +27540,7 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt)
#ifdef LIBXML_READER_ENABLED
vctxt->reader = NULL;
#endif
- vctxt->hasKeyrefs = 0;
+ vctxt->hasKeyrefs = 0;
if (vctxt->value != NULL) {
xmlSchemaFreeValue(vctxt->value);
@@ -27441,7 +27610,7 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt)
break;
xmlSchemaClearElemInfo(vctxt, ei);
}
- }
+ }
xmlSchemaItemListClear(vctxt->nodeQNames);
/* Recreate the dict. */
xmlDictFree(vctxt->dict);
@@ -27450,6 +27619,11 @@ xmlSchemaClearValidCtxt(xmlSchemaValidCtxtPtr vctxt)
* where the user provides the dict?
*/
vctxt->dict = xmlDictCreate();
+
+ if (vctxt->filename != NULL) {
+ xmlFree(vctxt->filename);
+ vctxt->filename = NULL;
+ }
}
/**
@@ -27535,6 +27709,8 @@ xmlSchemaFreeValidCtxt(xmlSchemaValidCtxtPtr ctxt)
xmlSchemaItemListFree(ctxt->nodeQNames);
if (ctxt->dict != NULL)
xmlDictFree(ctxt->dict);
+ if (ctxt->filename != NULL)
+ xmlFree(ctxt->filename);
xmlFree(ctxt);
}
@@ -27543,7 +27719,7 @@ xmlSchemaFreeValidCtxt(xmlSchemaValidCtxtPtr ctxt)
* @ctxt: the schema validation context
*
* Check if any error was detected during validation.
- *
+ *
* Returns 1 if valid so far, 0 if errors were detected, and -1 in case
* of internal error.
*/
@@ -27602,7 +27778,7 @@ xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
/**
* xmlSchemaGetValidErrors:
- * @ctxt: a XML-Schema validation context
+ * @ctxt: a XML-Schema validation context
* @err: the error function result
* @warn: the warning function result
* @ctx: the functions context result
@@ -27663,7 +27839,7 @@ xmlSchemaSetValidOptions(xmlSchemaValidCtxtPtr ctxt,
/**
* xmlSchemaValidCtxtGetOptions:
- * @ctxt: a schema validation context
+ * @ctxt: a schema validation context
*
* Get the validation context options.
*
@@ -27689,7 +27865,10 @@ xmlSchemaVDocWalk(xmlSchemaValidCtxtPtr vctxt)
const xmlChar *nsName;
/* DOC VAL TODO: Move this to the start function. */
- valRoot = xmlDocGetRootElement(vctxt->doc);
+ if (vctxt->validationRoot != NULL)
+ valRoot = vctxt->validationRoot;
+ else
+ valRoot = xmlDocGetRootElement(vctxt->doc);
if (valRoot == NULL) {
/* VAL TODO: Error code? */
VERROR(1, NULL, "The document has no document element");
@@ -27731,7 +27910,7 @@ xmlSchemaVDocWalk(xmlSchemaValidCtxtPtr vctxt)
nsName = NULL;
ret = xmlSchemaValidatorPushAttribute(vctxt,
(xmlNodePtr) attr,
- /*
+ /*
* Note that we give it the line number of the
* parent element.
*/
@@ -27787,7 +27966,7 @@ xmlSchemaVDocWalk(xmlSchemaValidCtxtPtr vctxt)
(node->type == XML_ENTITY_REF_NODE)) {
/*
* DOC VAL TODO: What to do with entities?
- */
+ */
VERROR_INT("xmlSchemaVDocWalk",
"there is at least one entity reference in the node-tree "
"currently being validated. Processing of entities with "
@@ -27847,7 +28026,7 @@ static int
xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
/*
* Some initialization.
- */
+ */
vctxt->err = 0;
vctxt->nberrors = 0;
vctxt->depth = -1;
@@ -27864,9 +28043,9 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
*/
if (vctxt->schema == NULL) {
xmlSchemaParserCtxtPtr pctxt;
-
+
vctxt->xsiAssemble = 1;
- /*
+ /*
* If not schema was given then we will create a schema
* dynamically using XSI schema locations.
*
@@ -27882,8 +28061,8 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
*/
vctxt->schema = xmlSchemaNewSchema(pctxt);
if (vctxt->schema == NULL)
- return (-1);
- /*
+ return (-1);
+ /*
* Create the schema construction context.
*/
pctxt->constructor = xmlSchemaConstructionCtxtCreate(pctxt->dict);
@@ -27894,14 +28073,13 @@ xmlSchemaPreRun(xmlSchemaValidCtxtPtr vctxt) {
* Take ownership of the constructor to be able to free it.
*/
pctxt->ownsConstructor = 1;
- }
+ }
/*
- * Augment the IDC definitions.
+ * Augment the IDC definitions for the main schema and all imported ones
+ * NOTE: main schema if the first in the imported list
*/
- if (vctxt->schema->idcDef != NULL) {
- xmlHashScan(vctxt->schema->idcDef,
- (xmlHashScanner) xmlSchemaAugmentIDC, vctxt);
- }
+ xmlHashScan(vctxt->schema->schemasImports,(xmlHashScanner)xmlSchemaAugmentImportedIDC, vctxt);
+
return(0);
}
@@ -28011,9 +28189,9 @@ xmlSchemaValidateDoc(xmlSchemaValidCtxtPtr ctxt, xmlDocPtr doc)
/************************************************************************
- * *
- * Function and data for SAX streaming API *
- * *
+ * *
+ * Function and data for SAX streaming API *
+ * *
************************************************************************/
typedef struct _xmlSchemaSplitSAXData xmlSchemaSplitSAXData;
typedef xmlSchemaSplitSAXData *xmlSchemaSplitSAXDataPtr;
@@ -28089,8 +28267,8 @@ externalSubsetSplit(void *ctx, const xmlChar *name,
{
xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
if ((ctxt != NULL) && (ctxt->user_sax != NULL) &&
- (ctxt->user_sax->internalSubset != NULL))
- ctxt->user_sax->internalSubset(ctxt->user_data, name, ExternalID,
+ (ctxt->user_sax->externalSubset != NULL))
+ ctxt->user_sax->externalSubset(ctxt->user_data, name, ExternalID,
SystemID);
}
@@ -28296,8 +28474,8 @@ cdataBlockSplit(void *ctx, const xmlChar *value, int len)
if (ctxt == NULL)
return;
if ((ctxt->user_sax != NULL) &&
- (ctxt->user_sax->ignorableWhitespace != NULL))
- ctxt->user_sax->ignorableWhitespace(ctxt->user_data, value, len);
+ (ctxt->user_sax->cdataBlock != NULL))
+ ctxt->user_sax->cdataBlock(ctxt->user_data, value, len);
if (ctxt->ctxt != NULL)
xmlSchemaSAXHandleCDataSection(ctxt->ctxt, value, len);
}
@@ -28316,10 +28494,10 @@ referenceSplit(void *ctx, const xmlChar *name)
}
static void
-startElementNsSplit(void *ctx, const xmlChar * localname,
- const xmlChar * prefix, const xmlChar * URI,
- int nb_namespaces, const xmlChar ** namespaces,
- int nb_attributes, int nb_defaulted,
+startElementNsSplit(void *ctx, const xmlChar * localname,
+ const xmlChar * prefix, const xmlChar * URI,
+ int nb_namespaces, const xmlChar ** namespaces,
+ int nb_attributes, int nb_defaulted,
const xmlChar ** attributes) {
xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
if (ctxt == NULL)
@@ -28338,7 +28516,7 @@ startElementNsSplit(void *ctx, const xmlChar * localname,
}
static void
-endElementNsSplit(void *ctx, const xmlChar * localname,
+endElementNsSplit(void *ctx, const xmlChar * localname,
const xmlChar * prefix, const xmlChar * URI) {
xmlSchemaSAXPlugPtr ctxt = (xmlSchemaSAXPlugPtr) ctx;
if (ctxt == NULL)
@@ -28379,7 +28557,7 @@ xmlSchemaSAXPlug(xmlSchemaValidCtxtPtr ctxt,
old_sax = *sax;
if ((old_sax != NULL) && (old_sax->initialized != XML_SAX2_MAGIC))
return(NULL);
- if ((old_sax != NULL) &&
+ if ((old_sax != NULL) &&
(old_sax->startElementNs == NULL) && (old_sax->endElementNs == NULL) &&
((old_sax->startElement != NULL) || (old_sax->endElement != NULL)))
return(NULL);
@@ -28397,7 +28575,7 @@ xmlSchemaSAXPlug(xmlSchemaValidCtxtPtr ctxt,
ret->ctxt = ctxt;
ret->user_sax_ptr = sax;
ret->user_sax = old_sax;
- if (old_sax == NULL) {
+ if (old_sax == NULL) {
/*
* go direct, no need for the split block and functions.
*/
@@ -28418,7 +28596,7 @@ xmlSchemaSAXPlug(xmlSchemaValidCtxtPtr ctxt,
} else {
/*
* for each callback unused by Schemas initialize it to the Split
- * routine only if non NULL in the user block, this can speed up
+ * routine only if non NULL in the user block, this can speed up
* things at the SAX level.
*/
if (old_sax->internalSubset != NULL)
@@ -28530,6 +28708,63 @@ xmlSchemaSAXUnplug(xmlSchemaSAXPlugPtr plug)
}
/**
+ * xmlSchemaValidateSetLocator:
+ * @vctxt: a schema validation context
+ * @f: the locator function pointer
+ * @ctxt: the locator context
+ *
+ * Allows to set a locator function to the validation context,
+ * which will be used to provide file and line information since
+ * those are not provided as part of the SAX validation flow
+ * Setting @f to NULL disable the locator.
+ */
+
+void
+xmlSchemaValidateSetLocator(xmlSchemaValidCtxtPtr vctxt,
+ xmlSchemaValidityLocatorFunc f,
+ void *ctxt)
+{
+ if (vctxt == NULL) return;
+ vctxt->locFunc = f;
+ vctxt->locCtxt = ctxt;
+}
+
+/**
+ * xmlSchemaValidateStreamLocator:
+ * @ctx: the xmlTextReaderPtr used
+ * @file: returned file information
+ * @line: returned line information
+ *
+ * Internal locator function for the readers
+ *
+ * Returns 0 in case the Schema validation could be (des)activated and
+ * -1 in case of error.
+ */
+static int
+xmlSchemaValidateStreamLocator(void *ctx, const char **file,
+ unsigned long *line) {
+ xmlParserCtxtPtr ctxt;
+
+ if ((ctx == NULL) || ((file == NULL) && (line == NULL)))
+ return(-1);
+
+ if (file != NULL)
+ *file = NULL;
+ if (line != NULL)
+ *line = 0;
+
+ ctxt = (xmlParserCtxtPtr) ctx;
+ if (ctxt->input != NULL) {
+ if (file != NULL)
+ *file = ctxt->input->filename;
+ if (line != NULL)
+ *line = ctxt->input->line;
+ return(0);
+ }
+ return(-1);
+}
+
+/**
* xmlSchemaValidateStream:
* @ctxt: a schema validation context
* @input: the input to use for reading the data
@@ -28571,7 +28806,8 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
if (options)
xmlCtxtUseOptions(pctxt, options);
#endif
- pctxt->linenumbers = 1;
+ pctxt->linenumbers = 1;
+ xmlSchemaValidateSetLocator(ctxt, xmlSchemaValidateStreamLocator, pctxt);
inputStream = xmlNewIOInputStream(pctxt, input, enc);;
if (inputStream == NULL) {
@@ -28600,7 +28836,7 @@ xmlSchemaValidateStream(xmlSchemaValidCtxtPtr ctxt,
ret = ctxt->parserCtxt->errNo;
if (ret == 0)
ret = 1;
- }
+ }
done:
ctxt->parserCtxt = NULL;
@@ -28639,16 +28875,33 @@ xmlSchemaValidateFile(xmlSchemaValidCtxtPtr ctxt,
if ((ctxt == NULL) || (filename == NULL))
return (-1);
-
+
input = xmlParserInputBufferCreateFilename(filename,
XML_CHAR_ENCODING_NONE);
if (input == NULL)
return (-1);
ret = xmlSchemaValidateStream(ctxt, input, XML_CHAR_ENCODING_NONE,
- NULL, NULL);
+ NULL, NULL);
return (ret);
}
+/**
+ * xmlSchemaValidCtxtGetParserCtxt:
+ * @ctxt: a schema validation context
+ *
+ * allow access to the parser context of the schema validation context
+ *
+ * Returns the parser context of the schema validation context or NULL
+ * in case of error.
+ */
+xmlParserCtxtPtr
+xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt)
+{
+ if (ctxt == NULL)
+ return(NULL);
+ return (ctxt->parserCtxt);
+}
+
#define bottom_xmlschemas
#include "elfgcchack.h"
#endif /* LIBXML_SCHEMAS_ENABLED */
diff --git a/gnulib-local/lib/libxml/xmlschemas.in.h b/gnulib-local/lib/libxml/xmlschemas.in.h
index 15faef5..97930c7 100644
--- a/gnulib-local/lib/libxml/xmlschemas.in.h
+++ b/gnulib-local/lib/libxml/xmlschemas.in.h
@@ -56,7 +56,7 @@ typedef enum {
/*
* ATTENTION: Change xmlSchemaSetValidOptions's check
-* for invalid values, if adding to the validation
+* for invalid values, if adding to the validation
* options below.
*/
/**
@@ -85,30 +85,65 @@ typedef struct _xmlSchema xmlSchema;
typedef xmlSchema *xmlSchemaPtr;
/**
- * A schemas validation context
+ * xmlSchemaValidityErrorFunc:
+ * @ctx: the validation context
+ * @msg: the message
+ * @...: extra arguments
+ *
+ * Signature of an error callback from an XSD validation
+ */
+typedef void (XMLCDECL *xmlSchemaValidityErrorFunc)
+ (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+
+/**
+ * xmlSchemaValidityWarningFunc:
+ * @ctx: the validation context
+ * @msg: the message
+ * @...: extra arguments
+ *
+ * Signature of a warning callback from an XSD validation
*/
-typedef void (XMLCDECL *xmlSchemaValidityErrorFunc) (void *ctx, const char *msg, ...);
-typedef void (XMLCDECL *xmlSchemaValidityWarningFunc) (void *ctx, const char *msg, ...);
+typedef void (XMLCDECL *xmlSchemaValidityWarningFunc)
+ (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
+/**
+ * A schemas validation context
+ */
typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
+/**
+ * xmlSchemaValidityLocatorFunc:
+ * @ctx: user provided context
+ * @file: returned file information
+ * @line: returned line information
+ *
+ * A schemas validation locator, a callback called by the validator.
+ * This is used when file or node informations are not available
+ * to find out what file and line number are affected
+ *
+ * Returns: 0 in case of success and -1 in case of error
+ */
+
+typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx,
+ const char **file, unsigned long *line);
+
/*
* Interfaces for parsing.
*/
-XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
+XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
xmlSchemaNewParserCtxt (const char *URL);
-XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
+XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
xmlSchemaNewMemParserCtxt (const char *buffer,
int size);
XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
xmlSchemaNewDocParserCtxt (xmlDocPtr doc);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt,
xmlSchemaValidityErrorFunc err,
xmlSchemaValidityWarningFunc warn,
@@ -125,19 +160,19 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);
-XMLPUBFUN xmlSchemaPtr XMLCALL
+XMLPUBFUN xmlSchemaPtr XMLCALL
xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchemaFree (xmlSchemaPtr schema);
#ifdef LIBXML_OUTPUT_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchemaDump (FILE *output,
xmlSchemaPtr schema);
#endif /* LIBXML_OUTPUT_ENABLED */
/*
* Interfaces for validating
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
xmlSchemaValidityErrorFunc err,
xmlSchemaValidityWarningFunc warn,
@@ -154,14 +189,17 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
int options);
+XMLPUBFUN void XMLCALL
+ xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
+ const char *filename);
XMLPUBFUN int XMLCALL
xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
-XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
+XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt,
xmlDocPtr instance);
XMLPUBFUN int XMLCALL
@@ -178,8 +216,11 @@ XMLPUBFUN int XMLCALL
const char * filename,
int options);
+XMLPUBFUN xmlParserCtxtPtr XMLCALL
+ xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
+
/*
- * Interface to insert Schemas SAX velidation in a SAX stream
+ * Interface to insert Schemas SAX validation in a SAX stream
*/
typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
@@ -190,6 +231,13 @@ XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
void **user_data);
XMLPUBFUN int XMLCALL
xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
+
+
+XMLPUBFUN void XMLCALL
+ xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,
+ xmlSchemaValidityLocatorFunc f,
+ void *ctxt);
+
#ifdef __cplusplus
}
#endif
diff --git a/gnulib-local/lib/libxml/xmlschemastypes.c b/gnulib-local/lib/libxml/xmlschemastypes.c
index a35c539..ff64f50 100644
--- a/gnulib-local/lib/libxml/xmlschemastypes.c
+++ b/gnulib-local/lib/libxml/xmlschemastypes.c
@@ -40,7 +40,7 @@ extern double xmlXPathPINF;
extern double xmlXPathNINF;
#endif
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
@@ -75,7 +75,7 @@ typedef struct _xmlSchemaValDuration xmlSchemaValDuration;
typedef xmlSchemaValDuration *xmlSchemaValDurationPtr;
struct _xmlSchemaValDuration {
long mon; /* mon stores years also */
- long day;
+ long day;
double sec; /* sec stores min and hour also */
};
@@ -189,7 +189,7 @@ static xmlSchemaTypePtr xmlSchemaTypeNmtokensDef = NULL;
/************************************************************************
* *
- * Datatype error handlers *
+ * Datatype error handlers *
* *
************************************************************************/
/**
@@ -206,7 +206,7 @@ xmlSchemaTypeErrMemory(xmlNodePtr node, const char *extra)
/************************************************************************
* *
- * Base types support *
+ * Base types support *
* *
************************************************************************/
@@ -242,6 +242,10 @@ xmlSchemaNewMinLengthFacet(int value)
}
ret->type = XML_SCHEMA_FACET_MINLENGTH;
ret->val = xmlSchemaNewValue(XML_SCHEMAS_NNINTEGER);
+ if (ret->val == NULL) {
+ xmlFree(ret);
+ return(NULL);
+ }
ret->val->value.decimal.lo = value;
return (ret);
}
@@ -254,7 +258,7 @@ xmlSchemaNewMinLengthFacet(int value)
* Initialize one primitive built-in type
*/
static xmlSchemaTypePtr
-xmlSchemaInitBasicType(const char *name, xmlSchemaValType type,
+xmlSchemaInitBasicType(const char *name, xmlSchemaValType type,
xmlSchemaTypePtr baseType) {
xmlSchemaTypePtr ret;
@@ -267,31 +271,31 @@ xmlSchemaInitBasicType(const char *name, xmlSchemaValType type,
ret->name = (const xmlChar *)name;
ret->targetNamespace = XML_SCHEMAS_NAMESPACE_NAME;
ret->type = XML_SCHEMA_TYPE_BASIC;
- ret->baseType = baseType;
+ ret->baseType = baseType;
ret->contentType = XML_SCHEMA_CONTENT_BASIC;
/*
* Primitive types.
*/
- switch (type) {
- case XML_SCHEMAS_STRING:
- case XML_SCHEMAS_DECIMAL:
- case XML_SCHEMAS_DATE:
- case XML_SCHEMAS_DATETIME:
- case XML_SCHEMAS_TIME:
- case XML_SCHEMAS_GYEAR:
- case XML_SCHEMAS_GYEARMONTH:
- case XML_SCHEMAS_GMONTH:
- case XML_SCHEMAS_GMONTHDAY:
- case XML_SCHEMAS_GDAY:
- case XML_SCHEMAS_DURATION:
- case XML_SCHEMAS_FLOAT:
- case XML_SCHEMAS_DOUBLE:
- case XML_SCHEMAS_BOOLEAN:
- case XML_SCHEMAS_ANYURI:
- case XML_SCHEMAS_HEXBINARY:
- case XML_SCHEMAS_BASE64BINARY:
- case XML_SCHEMAS_QNAME:
- case XML_SCHEMAS_NOTATION:
+ switch (type) {
+ case XML_SCHEMAS_STRING:
+ case XML_SCHEMAS_DECIMAL:
+ case XML_SCHEMAS_DATE:
+ case XML_SCHEMAS_DATETIME:
+ case XML_SCHEMAS_TIME:
+ case XML_SCHEMAS_GYEAR:
+ case XML_SCHEMAS_GYEARMONTH:
+ case XML_SCHEMAS_GMONTH:
+ case XML_SCHEMAS_GMONTHDAY:
+ case XML_SCHEMAS_GDAY:
+ case XML_SCHEMAS_DURATION:
+ case XML_SCHEMAS_FLOAT:
+ case XML_SCHEMAS_DOUBLE:
+ case XML_SCHEMAS_BOOLEAN:
+ case XML_SCHEMAS_ANYURI:
+ case XML_SCHEMAS_HEXBINARY:
+ case XML_SCHEMAS_BASE64BINARY:
+ case XML_SCHEMAS_QNAME:
+ case XML_SCHEMAS_NOTATION:
ret->flags |= XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE;
break;
default:
@@ -309,7 +313,7 @@ xmlSchemaInitBasicType(const char *name, xmlSchemaValType type,
case XML_SCHEMAS_ENTITIES:
ret->flags |= XML_SCHEMAS_TYPE_VARIETY_LIST;
ret->facets = xmlSchemaNewMinLengthFacet(1);
- ret->flags |= XML_SCHEMAS_TYPE_HAS_FACETS;
+ ret->flags |= XML_SCHEMAS_TYPE_HAS_FACETS;
break;
default:
ret->flags |= XML_SCHEMAS_TYPE_VARIETY_ATOMIC;
@@ -390,19 +394,19 @@ xmlSchemaInitTypes(void)
return;
xmlSchemaTypesBank = xmlHashCreate(40);
-
+
/*
* 3.4.7 Built-in Complex Type Definition
*/
xmlSchemaTypeAnyTypeDef = xmlSchemaInitBasicType("anyType",
- XML_SCHEMAS_ANYTYPE,
+ XML_SCHEMAS_ANYTYPE,
NULL);
xmlSchemaTypeAnyTypeDef->baseType = xmlSchemaTypeAnyTypeDef;
xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED;
/*
* Init the content type.
*/
- xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED;
+ xmlSchemaTypeAnyTypeDef->contentType = XML_SCHEMA_CONTENT_MIXED;
{
xmlSchemaParticlePtr particle;
xmlSchemaModelGroupPtr sequence;
@@ -420,7 +424,7 @@ xmlSchemaInitTypes(void)
return;
}
memset(sequence, 0, sizeof(xmlSchemaModelGroup));
- sequence->type = XML_SCHEMA_TYPE_SEQUENCE;
+ sequence->type = XML_SCHEMA_TYPE_SEQUENCE;
particle->children = (xmlSchemaTreeItemPtr) sequence;
/* Second particle. */
particle = xmlSchemaAddParticle();
@@ -437,9 +441,9 @@ xmlSchemaInitTypes(void)
}
memset(wild, 0, sizeof(xmlSchemaWildcard));
wild->type = XML_SCHEMA_TYPE_ANY;
- wild->any = 1;
- wild->processContents = XML_SCHEMAS_ANY_LAX;
- particle->children = (xmlSchemaTreeItemPtr) wild;
+ wild->any = 1;
+ wild->processContents = XML_SCHEMAS_ANY_LAX;
+ particle->children = (xmlSchemaTreeItemPtr) wild;
/*
* Create the attribute wildcard.
*/
@@ -451,10 +455,10 @@ xmlSchemaInitTypes(void)
}
memset(wild, 0, sizeof(xmlSchemaWildcard));
wild->any = 1;
- wild->processContents = XML_SCHEMAS_ANY_LAX;
+ wild->processContents = XML_SCHEMAS_ANY_LAX;
xmlSchemaTypeAnyTypeDef->attributeWildcard = wild;
}
- xmlSchemaTypeAnySimpleTypeDef = xmlSchemaInitBasicType("anySimpleType",
+ xmlSchemaTypeAnySimpleTypeDef = xmlSchemaInitBasicType("anySimpleType",
XML_SCHEMAS_ANYSIMPLETYPE,
xmlSchemaTypeAnyTypeDef);
/*
@@ -513,7 +517,7 @@ xmlSchemaInitTypes(void)
xmlSchemaTypeAnySimpleTypeDef);
xmlSchemaTypeNotationDef = xmlSchemaInitBasicType("NOTATION",
XML_SCHEMAS_NOTATION,
- xmlSchemaTypeAnySimpleTypeDef);
+ xmlSchemaTypeAnySimpleTypeDef);
xmlSchemaTypeQNameDef = xmlSchemaInitBasicType("QName",
XML_SCHEMAS_QNAME,
xmlSchemaTypeAnySimpleTypeDef);
@@ -583,7 +587,7 @@ xmlSchemaInitTypes(void)
xmlSchemaTypeNCNameDef);
xmlSchemaTypeIdrefDef = xmlSchemaInitBasicType("IDREF",
XML_SCHEMAS_IDREF,
- xmlSchemaTypeNCNameDef);
+ xmlSchemaTypeNCNameDef);
xmlSchemaTypeEntityDef = xmlSchemaInitBasicType("ENTITY",
XML_SCHEMAS_ENTITY,
xmlSchemaTypeNCNameDef);
@@ -615,7 +619,7 @@ xmlSchemaInitTypes(void)
*
* Cleanup the default XML Schemas type library
*/
-void
+void
xmlSchemaCleanupTypes(void) {
if (xmlSchemaTypesInitialized == 0)
return;
@@ -629,13 +633,13 @@ xmlSchemaCleanupTypes(void) {
/* Content type. */
particle = (xmlSchemaParticlePtr) xmlSchemaTypeAnyTypeDef->subtypes;
/* Wildcard. */
- xmlSchemaFreeWildcard((xmlSchemaWildcardPtr)
+ xmlSchemaFreeWildcard((xmlSchemaWildcardPtr)
particle->children->children->children);
xmlFree((xmlSchemaParticlePtr) particle->children->children);
/* Sequence model group. */
xmlFree((xmlSchemaModelGroupPtr) particle->children);
xmlFree((xmlSchemaParticlePtr) particle);
- xmlSchemaTypeAnyTypeDef->subtypes = NULL;
+ xmlSchemaTypeAnyTypeDef->subtypes = NULL;
}
xmlHashFree(xmlSchemaTypesBank, (xmlHashDeallocator) xmlSchemaFreeType);
xmlSchemaTypesInitialized = 0;
@@ -665,12 +669,12 @@ xmlSchemaIsBuiltInTypeFacet(xmlSchemaTypePtr type, int facetType)
(facetType == XML_SCHEMA_FACET_WHITESPACE))
return (1);
else
- return (0);
+ return (0);
case XML_SCHEMAS_STRING:
case XML_SCHEMAS_NOTATION:
case XML_SCHEMAS_QNAME:
- case XML_SCHEMAS_ANYURI:
- case XML_SCHEMAS_BASE64BINARY:
+ case XML_SCHEMAS_ANYURI:
+ case XML_SCHEMAS_BASE64BINARY:
case XML_SCHEMAS_HEXBINARY:
if ((facetType == XML_SCHEMA_FACET_LENGTH) ||
(facetType == XML_SCHEMA_FACET_MINLENGTH) ||
@@ -693,12 +697,12 @@ xmlSchemaIsBuiltInTypeFacet(xmlSchemaTypePtr type, int facetType)
(facetType == XML_SCHEMA_FACET_MINEXCLUSIVE))
return (1);
else
- return (0);
+ return (0);
case XML_SCHEMAS_TIME:
- case XML_SCHEMAS_GDAY:
+ case XML_SCHEMAS_GDAY:
case XML_SCHEMAS_GMONTH:
- case XML_SCHEMAS_GMONTHDAY:
- case XML_SCHEMAS_GYEAR:
+ case XML_SCHEMAS_GMONTHDAY:
+ case XML_SCHEMAS_GYEAR:
case XML_SCHEMAS_GYEARMONTH:
case XML_SCHEMAS_DATE:
case XML_SCHEMAS_DATETIME:
@@ -714,7 +718,7 @@ xmlSchemaIsBuiltInTypeFacet(xmlSchemaTypePtr type, int facetType)
(facetType == XML_SCHEMA_FACET_MINEXCLUSIVE))
return (1);
else
- return (0);
+ return (0);
default:
break;
}
@@ -736,7 +740,7 @@ xmlSchemaGetBuiltInType(xmlSchemaValType type)
if (xmlSchemaTypesInitialized == 0)
xmlSchemaInitTypes();
switch (type) {
-
+
case XML_SCHEMAS_ANYSIMPLETYPE:
return (xmlSchemaTypeAnySimpleTypeDef);
case XML_SCHEMAS_STRING:
@@ -752,7 +756,7 @@ xmlSchemaGetBuiltInType(xmlSchemaValType type)
case XML_SCHEMAS_GMONTH:
return (xmlSchemaTypeGMonthDef);
case XML_SCHEMAS_GMONTHDAY:
- return (xmlSchemaTypeGMonthDayDef);
+ return (xmlSchemaTypeGMonthDayDef);
case XML_SCHEMAS_GYEAR:
return (xmlSchemaTypeGYearDef);
case XML_SCHEMAS_GYEARMONTH:
@@ -828,7 +832,7 @@ xmlSchemaGetBuiltInType(xmlSchemaValType type)
case XML_SCHEMAS_BASE64BINARY:
return (xmlSchemaTypeBase64BinaryDef);
case XML_SCHEMAS_ANYTYPE:
- return (xmlSchemaTypeAnyTypeDef);
+ return (xmlSchemaTypeAnyTypeDef);
default:
return (NULL);
}
@@ -880,7 +884,7 @@ xmlSchemaValueGetNext(xmlSchemaValPtr cur) {
*/
const xmlChar *
xmlSchemaValueGetAsString(xmlSchemaValPtr val)
-{
+{
if (val == NULL)
return (NULL);
switch (val->type) {
@@ -913,7 +917,7 @@ xmlSchemaValueGetAsString(xmlSchemaValPtr val)
*/
int
xmlSchemaValueGetAsBoolean(xmlSchemaValPtr val)
-{
+{
if ((val == NULL) || (val->type != XML_SCHEMAS_BOOLEAN))
return (0);
return (val->value.b);
@@ -924,8 +928,8 @@ xmlSchemaValueGetAsBoolean(xmlSchemaValPtr val)
* @type: the value type
* @value: the value
*
- * Allocate a new simple type value. The type can be
- * of XML_SCHEMAS_STRING.
+ * Allocate a new simple type value. The type can be
+ * of XML_SCHEMAS_STRING.
* WARNING: This one is intended to be expanded for other
* string based types. We need this for anySimpleType as well.
* The given value is consumed and freed with the struct.
@@ -1007,11 +1011,11 @@ xmlSchemaNewQNameValue(const xmlChar *namespaceName,
*
* Cleanup the default XML Schemas type library
*/
-void
+void
xmlSchemaFreeValue(xmlSchemaValPtr value) {
xmlSchemaValPtr prev;
- while (value != NULL) {
+ while (value != NULL) {
switch (value->type) {
case XML_SCHEMAS_STRING:
case XML_SCHEMAS_NORMSTRING:
@@ -1025,7 +1029,7 @@ xmlSchemaFreeValue(xmlSchemaValPtr value) {
case XML_SCHEMAS_IDREF:
case XML_SCHEMAS_IDREFS:
case XML_SCHEMAS_ENTITY:
- case XML_SCHEMAS_ENTITIES:
+ case XML_SCHEMAS_ENTITIES:
case XML_SCHEMAS_ANYURI:
case XML_SCHEMAS_ANYSIMPLETYPE:
if (value->value.str != NULL)
@@ -1052,7 +1056,7 @@ xmlSchemaFreeValue(xmlSchemaValPtr value) {
prev = value;
value = value->next;
xmlFree(prev);
- }
+ }
}
/**
@@ -1088,9 +1092,9 @@ xmlSchemaGetBuiltInListSimpleTypeItemType(xmlSchemaTypePtr type)
if ((type == NULL) || (type->type != XML_SCHEMA_TYPE_BASIC))
return (NULL);
switch (type->builtInType) {
- case XML_SCHEMAS_NMTOKENS:
+ case XML_SCHEMAS_NMTOKENS:
return (xmlSchemaTypeNmtokenDef );
- case XML_SCHEMAS_IDREFS:
+ case XML_SCHEMAS_IDREFS:
return (xmlSchemaTypeIdrefDef);
case XML_SCHEMAS_ENTITIES:
return (xmlSchemaTypeEntityDef);
@@ -1342,13 +1346,13 @@ _xmlSchemaParseGDay (xmlSchemaValDatePtr dt, const xmlChar **str) {
*/
static int
_xmlSchemaParseTime (xmlSchemaValDatePtr dt, const xmlChar **str) {
- const xmlChar *cur = *str;
+ const xmlChar *cur = *str;
int ret = 0;
int value = 0;
PARSE_2_DIGITS(value, cur, ret);
if (ret != 0)
- return ret;
+ return ret;
if (*cur != ':')
return 1;
if (!VALID_HOUR(value))
@@ -1614,7 +1618,7 @@ xmlSchemaValidateDates (xmlSchemaValType type,
const xmlChar *rewnd = cur;
cur++;
- ret = _xmlSchemaParseGDay(&(dt->value.date), &cur);
+ ret = _xmlSchemaParseGDay(&(dt->value.date), &cur);
if ((ret == 0) && ((*cur == 0) || (*cur != ':'))) {
/*
@@ -1852,7 +1856,7 @@ xmlSchemaValidateDuration (xmlSchemaTypePtr type ATTRIBUTE_UNUSED,
}
cur++;
if (collapse)
- while IS_WSP_BLANK_CH(*cur) cur++;
+ while IS_WSP_BLANK_CH(*cur) cur++;
}
if (isneg) {
@@ -1908,13 +1912,13 @@ xmlSchemaStrip(const xmlChar *value) {
*/
xmlChar *
xmlSchemaWhiteSpaceReplace(const xmlChar *value) {
- const xmlChar *cur = value;
- xmlChar *ret = NULL, *mcur;
+ const xmlChar *cur = value;
+ xmlChar *ret = NULL, *mcur;
- if (value == NULL)
+ if (value == NULL)
return(NULL);
-
- while ((*cur != 0) &&
+
+ while ((*cur != 0) &&
(((*cur) != 0xd) && ((*cur) != 0x9) && ((*cur) != 0xa))) {
cur++;
}
@@ -1927,7 +1931,7 @@ xmlSchemaWhiteSpaceReplace(const xmlChar *value) {
if ( ((*mcur) == 0xd) || ((*mcur) == 0x9) || ((*mcur) == 0xa) )
*mcur = ' ';
mcur++;
- } while (*mcur != 0);
+ } while (*mcur != 0);
return(ret);
}
@@ -2063,7 +2067,7 @@ xmlSchemaValAtomicListNode(xmlSchemaTypePtr type, const xmlChar *value,
* Parse an unsigned long into 3 fields.
*
* Returns the number of significant digits in the number or
- * -1 if overflow of the capacity
+ * -1 if overflow of the capacity and -2 if it's not a number.
*/
static int
xmlSchemaParseUInt(const xmlChar **str, unsigned long *llo,
@@ -2072,6 +2076,9 @@ xmlSchemaParseUInt(const xmlChar **str, unsigned long *llo,
const xmlChar *tmp, *cur = *str;
int ret = 0, i = 0;
+ if (!((*cur >= '0') && (*cur <= '9')))
+ return(-2);
+
while (*cur == '0') { /* ignore leading zeroes */
cur++;
}
@@ -2145,7 +2152,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
if ((flags == 0) && (value != NULL)) {
if ((type->builtInType != XML_SCHEMAS_STRING) &&
- (type->builtInType != XML_SCHEMAS_ANYTYPE) &&
+ (type->builtInType != XML_SCHEMAS_ANYTYPE) &&
(type->builtInType != XML_SCHEMAS_ANYSIMPLETYPE)) {
if (type->builtInType == XML_SCHEMAS_NORMSTRING)
norm = xmlSchemaWhiteSpaceReplace(value);
@@ -2157,7 +2164,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
}
switch (type->builtInType) {
- case XML_SCHEMAS_UNKNOWN:
+ case XML_SCHEMAS_UNKNOWN:
goto error;
case XML_SCHEMAS_ANYTYPE:
case XML_SCHEMAS_ANYSIMPLETYPE:
@@ -2168,10 +2175,10 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
*val = v;
} else {
goto error;
- }
+ }
}
goto return0;
- case XML_SCHEMAS_STRING:
+ case XML_SCHEMAS_STRING:
if (! normOnTheFly) {
const xmlChar *cur = value;
@@ -2250,7 +2257,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
const xmlChar *cur = value;
unsigned int len, neg, integ, hasLeadingZeroes;
xmlChar cval[25];
- xmlChar *cptr = cval;
+ xmlChar *cptr = cval;
if ((cur == NULL) || (*cur == 0))
goto return1;
@@ -2324,10 +2331,10 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
v = xmlSchemaNewValue(XML_SCHEMAS_DECIMAL);
if (v != NULL) {
/*
- * Now evaluate the significant digits of the number
- */
+ * Now evaluate the significant digits of the number
+ */
if (len != 0) {
-
+
if (integ != ~0u) {
/*
* Get rid of trailing zeroes in the
@@ -2342,9 +2349,9 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
* Terminate the (preparsed) string.
*/
if (len != 0) {
- *cptr = 0;
+ *cptr = 0;
cptr = cval;
-
+
xmlSchemaParseUInt((const xmlChar **)&cptr,
&v->value.decimal.lo,
&v->value.decimal.mi,
@@ -2386,9 +2393,11 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
normOnTheFly);
break;
case XML_SCHEMAS_FLOAT:
- case XML_SCHEMAS_DOUBLE:{
+ case XML_SCHEMAS_DOUBLE: {
const xmlChar *cur = value;
int neg = 0;
+ int digits_before = 0;
+ int digits_after = 0;
if (normOnTheFly)
while IS_WSP_BLANK_CH(*cur) cur++;
@@ -2461,12 +2470,17 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
goto return1;
while ((*cur >= '0') && (*cur <= '9')) {
cur++;
+ digits_before++;
}
if (*cur == '.') {
cur++;
- while ((*cur >= '0') && (*cur <= '9'))
+ while ((*cur >= '0') && (*cur <= '9')) {
cur++;
+ digits_after++;
+ }
}
+ if ((digits_before == 0) && (digits_after == 0))
+ goto return1;
if ((*cur == 'e') || (*cur == 'E')) {
cur++;
if ((*cur == '-') || (*cur == '+'))
@@ -2594,8 +2608,8 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
} else {
cur++;
}
- }
- }
+ }
+ }
if (val != NULL) {
v = xmlSchemaNewValue(XML_SCHEMAS_TOKEN);
if (v != NULL) {
@@ -2608,7 +2622,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
goto return0;
}
case XML_SCHEMAS_LANGUAGE:
- if (normOnTheFly) {
+ if (normOnTheFly) {
norm = xmlSchemaCollapseString(value);
if (norm != NULL)
value = norm;
@@ -2893,15 +2907,26 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
}
goto done;
}
- case XML_SCHEMAS_ANYURI:{
+ case XML_SCHEMAS_ANYURI:{
if (*value != 0) {
xmlURIPtr uri;
- if (normOnTheFly) {
+ xmlChar *tmpval, *cur;
+ if (normOnTheFly) {
norm = xmlSchemaCollapseString(value);
if (norm != NULL)
value = norm;
}
- uri = xmlParseURI((const char *) value);
+ tmpval = xmlStrdup(value);
+ for (cur = tmpval; *cur; ++cur) {
+ if (*cur < 32 || *cur >= 127 || *cur == ' ' ||
+ *cur == '<' || *cur == '>' || *cur == '"' ||
+ *cur == '{' || *cur == '}' || *cur == '|' ||
+ *cur == '\\' || *cur == '^' || *cur == '`' ||
+ *cur == '\'')
+ *cur = '_';
+ }
+ uri = xmlParseURI((const char *) tmpval);
+ xmlFree(tmpval);
if (uri == NULL)
goto return1;
xmlFreeURI(uri);
@@ -2975,12 +3000,12 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
}
case XML_SCHEMAS_BASE64BINARY:{
/* ISSUE:
- *
+ *
* Ignore all stray characters? (yes, currently)
* Worry about long lines? (no, currently)
- *
+ *
* rfc2045.txt:
- *
+ *
* "The encoded output stream must be represented in lines of
* no more than 76 characters each. All line breaks or other
* characters not found in Table 1 must be ignored by decoding
@@ -3116,7 +3141,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
} else if (*cur == '+')
cur++;
ret = xmlSchemaParseUInt(&cur, &lo, &mi, &hi);
- if (ret == -1)
+ if (ret < 0)
goto return1;
if (normOnTheFly)
while IS_WSP_BLANK_CH(*cur) cur++;
@@ -3161,7 +3186,7 @@ xmlSchemaValAtomicType(xmlSchemaTypePtr type, const xmlChar * value,
case XML_SCHEMAS_BYTE:
case XML_SCHEMAS_SHORT:
case XML_SCHEMAS_INT:{
- const xmlChar *cur = value;
+ const xmlChar *cur = value;
unsigned long lo, mi, hi;
int sign = 0;
@@ -3391,7 +3416,7 @@ xmlSchemaCompareDecimals(xmlSchemaValPtr x, xmlSchemaValPtr y)
/*
* First test: If x is -ve and not zero
*/
- if ((x->value.decimal.sign) &&
+ if ((x->value.decimal.sign) &&
((x->value.decimal.lo != 0) ||
(x->value.decimal.mi != 0) ||
(x->value.decimal.hi != 0))) {
@@ -3548,8 +3573,8 @@ xmlSchemaCompareDurations(xmlSchemaValPtr x, xmlSchemaValPtr y)
/* seconds */
sec = x->value.dur.sec - y->value.dur.sec;
- carry = (long)sec / SECS_PER_DAY;
- sec -= (double)(carry * SECS_PER_DAY);
+ carry = (long)(sec / SECS_PER_DAY);
+ sec -= ((double)carry) * SECS_PER_DAY;
/* days */
day = x->value.dur.day - y->value.dur.day + carry;
@@ -3632,7 +3657,7 @@ xmlSchemaDupVal (xmlSchemaValPtr v)
xmlSchemaValPtr ret = xmlSchemaNewValue(v->type);
if (ret == NULL)
return NULL;
-
+
memcpy(ret, v, sizeof(xmlSchemaVal));
ret->next = NULL;
return ret;
@@ -3678,7 +3703,7 @@ xmlSchemaCopyValue(xmlSchemaValPtr val)
if (val->value.str != NULL)
cur->value.str = xmlStrdup(BAD_CAST val->value.str);
break;
- case XML_SCHEMAS_QNAME:
+ case XML_SCHEMAS_QNAME:
case XML_SCHEMAS_NOTATION:
cur = xmlSchemaDupVal(val);
if (val->value.qname.name != NULL)
@@ -3820,16 +3845,17 @@ _xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur)
if (tyr == 0)
tyr--;
/*
- * Coverity detected an overrun in daysInMonth
+ * Coverity detected an overrun in daysInMonth
* of size 12 at position 12 with index variable "((r)->mon - 1)"
*/
- if (tmon < 0)
- tmon = 0;
+ if (tmon < 1)
+ tmon = 1;
if (tmon > 12)
tmon = 12;
tempdays += MAX_DAYINMONTH(tyr, tmon);
carry = -1;
- } else if (tempdays > (long) MAX_DAYINMONTH(r->year, r->mon)) {
+ } else if (VALID_YEAR(r->year) && VALID_MONTH(r->mon) &&
+ tempdays > (long) MAX_DAYINMONTH(r->year, r->mon)) {
tempdays = tempdays - MAX_DAYINMONTH(r->year, r->mon);
carry = 1;
} else
@@ -3845,7 +3871,7 @@ _xmlSchemaDateAdd (xmlSchemaValPtr dt, xmlSchemaValPtr dur)
r->year++;
}
}
-
+
r->day = tempdays;
/*
@@ -3910,7 +3936,7 @@ xmlSchemaDateNormalize (xmlSchemaValPtr dt, double offset)
* _xmlSchemaDateCastYMToDays:
* @dt: an #xmlSchemaValPtr
*
- * Convert mon and year of @dt to total number of days. Take the
+ * Convert mon and year of @dt to total number of days. Take the
* number of years since (or before) 1 AD and add the number of leap
* years. This is a function because negative
* years must be handled a little differently and there is no zero year.
@@ -4090,7 +4116,7 @@ xmlSchemaCompareDates (xmlSchemaValPtr x, xmlSchemaValPtr y)
ret = -1;
else if (sec > 0.0)
ret = 1;
-
+
}
xmlSchemaFreeValue(p1);
xmlSchemaFreeValue(q1);
@@ -4231,7 +4257,7 @@ xmlSchemaComparePreserveReplaceStrings(const xmlChar *x,
int invert)
{
int tmp;
-
+
while ((*x != 0) && (*y != 0)) {
if (IS_WSP_REPLACE_CH(*y)) {
if (! IS_WSP_SPACE_CH(*x)) {
@@ -4246,7 +4272,7 @@ xmlSchemaComparePreserveReplaceStrings(const xmlChar *x,
else
return(1);
}
- }
+ }
} else {
tmp = *x - *y;
if (tmp < 0) {
@@ -4300,7 +4326,7 @@ xmlSchemaComparePreserveCollapseStrings(const xmlChar *x,
{
int tmp;
- /*
+ /*
* Skip leading blank chars of the collapsed string.
*/
while IS_WSP_BLANK_CH(*y)
@@ -4389,12 +4415,12 @@ xmlSchemaCompareReplaceCollapseStrings(const xmlChar *x,
{
int tmp;
- /*
+ /*
* Skip leading blank chars of the collapsed string.
*/
while IS_WSP_BLANK_CH(*y)
y++;
-
+
while ((*x != 0) && (*y != 0)) {
if IS_WSP_BLANK_CH(*y) {
if (! IS_WSP_BLANK_CH(*x)) {
@@ -4414,8 +4440,8 @@ xmlSchemaCompareReplaceCollapseStrings(const xmlChar *x,
}
}
x++;
- y++;
- /*
+ y++;
+ /*
* Skip contiguous blank chars of the collapsed string.
*/
while IS_WSP_BLANK_CH(*y)
@@ -4449,7 +4475,7 @@ xmlSchemaCompareReplaceCollapseStrings(const xmlChar *x,
return(-1);
else
return(1);
- }
+ }
if (*y != 0) {
/*
* Skip trailing blank chars of the collapsed string.
@@ -4482,27 +4508,27 @@ xmlSchemaCompareReplacedStrings(const xmlChar *x,
const xmlChar *y)
{
int tmp;
-
+
while ((*x != 0) && (*y != 0)) {
if IS_WSP_BLANK_CH(*y) {
if (! IS_WSP_BLANK_CH(*x)) {
if ((*x - 0x20) < 0)
- return(-1);
+ return(-1);
else
return(1);
- }
+ }
} else {
if IS_WSP_BLANK_CH(*x) {
if ((0x20 - *y) < 0)
- return(-1);
+ return(-1);
else
return(1);
}
tmp = *x - *y;
if (tmp < 0)
- return(-1);
+ return(-1);
if (tmp > 0)
- return(1);
+ return(1);
}
x++;
y++;
@@ -4528,7 +4554,7 @@ static int
xmlSchemaCompareNormStrings(const xmlChar *x,
const xmlChar *y) {
int tmp;
-
+
while (IS_BLANK_CH(*x)) x++;
while (IS_BLANK_CH(*y)) y++;
while ((*x != 0) && (*y != 0)) {
@@ -4721,13 +4747,13 @@ xmlSchemaCompareValuesInternal(xmlSchemaValType xtype,
(ytype == XML_SCHEMAS_GYEARMONTH))
return (xmlSchemaCompareDates(x, y));
return (-2);
- /*
+ /*
* Note that we will support comparison of string types against
* anySimpleType as well.
*/
case XML_SCHEMAS_ANYSIMPLETYPE:
case XML_SCHEMAS_STRING:
- case XML_SCHEMAS_NORMSTRING:
+ case XML_SCHEMAS_NORMSTRING:
case XML_SCHEMAS_TOKEN:
case XML_SCHEMAS_LANGUAGE:
case XML_SCHEMAS_NMTOKEN:
@@ -4751,10 +4777,10 @@ xmlSchemaCompareValuesInternal(xmlSchemaValType xtype,
/*
* TODO: Compare those against QName.
*/
- if (ytype == XML_SCHEMAS_QNAME) {
+ if (ytype == XML_SCHEMAS_QNAME) {
TODO
if (y == NULL)
- return(-2);
+ return(-2);
return (-2);
}
if ((ytype == XML_SCHEMAS_ANYSIMPLETYPE) ||
@@ -4776,7 +4802,7 @@ xmlSchemaCompareValuesInternal(xmlSchemaValType xtype,
/* TODO: What about x < y or x > y. */
if (xmlStrEqual(xv, yv))
return (0);
- else
+ else
return (2);
} else if (yws == XML_SCHEMA_WHITESPACE_REPLACE)
return (xmlSchemaComparePreserveReplaceStrings(xv, yv, 0));
@@ -4802,7 +4828,7 @@ xmlSchemaCompareValuesInternal(xmlSchemaValType xtype,
return (xmlSchemaCompareNormStrings(xv, yv));
} else
return (-2);
-
+
}
return (-2);
}
@@ -4873,7 +4899,7 @@ xmlSchemaCompareValuesInternal(xmlSchemaValType xtype,
else
return(-1);
}
- return (-2);
+ return (-2);
case XML_SCHEMAS_IDREFS:
case XML_SCHEMAS_ENTITIES:
case XML_SCHEMAS_NMTOKENS:
@@ -4908,7 +4934,7 @@ xmlSchemaCompareValues(xmlSchemaValPtr x, xmlSchemaValPtr y) {
if (y->type == XML_SCHEMAS_STRING)
yws = XML_SCHEMA_WHITESPACE_PRESERVE;
- else if (x->type == XML_SCHEMAS_NORMSTRING)
+ else if (y->type == XML_SCHEMAS_NORMSTRING)
yws = XML_SCHEMA_WHITESPACE_REPLACE;
else
yws = XML_SCHEMA_WHITESPACE_COLLAPSE;
@@ -5061,7 +5087,7 @@ xmlSchemaValidateListSimpleTypeFacet(xmlSchemaFacetPtr facet,
if (expectedLen != NULL)
*expectedLen = facet->val->value.decimal.lo;
return (XML_SCHEMAV_CVC_LENGTH_VALID);
- }
+ }
} else if (facet->type == XML_SCHEMA_FACET_MINLENGTH) {
if (actualLen < facet->val->value.decimal.lo) {
if (expectedLen != NULL)
@@ -5075,12 +5101,12 @@ xmlSchemaValidateListSimpleTypeFacet(xmlSchemaFacetPtr facet,
return (XML_SCHEMAV_CVC_MAXLENGTH_VALID);
}
} else
- /*
- * NOTE: That we can pass NULL as xmlSchemaValPtr to
+ /*
+ * NOTE: That we can pass NULL as xmlSchemaValPtr to
* xmlSchemaValidateFacet, since the remaining facet types
- * are: XML_SCHEMA_FACET_PATTERN, XML_SCHEMA_FACET_ENUMERATION.
+ * are: XML_SCHEMA_FACET_PATTERN, XML_SCHEMA_FACET_ENUMERATION.
*/
- return(xmlSchemaValidateFacet(NULL, facet, value, NULL));
+ return(xmlSchemaValidateFacet(NULL, facet, value, NULL));
return (0);
}
@@ -5093,7 +5119,7 @@ xmlSchemaValidateListSimpleTypeFacet(xmlSchemaFacetPtr facet,
* @ws: the whitespace type of the value
* @length: the actual length of the value
*
- * Checka a value against a "length", "minLength" and "maxLength"
+ * Checka a value against a "length", "minLength" and "maxLength"
* facet; sets @length to the computed length of @value.
*
* Returns 0 if the value is valid, a positive error code
@@ -5101,11 +5127,11 @@ xmlSchemaValidateListSimpleTypeFacet(xmlSchemaFacetPtr facet,
*/
static int
xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
- xmlSchemaTypeType valType,
+ xmlSchemaValType valType,
const xmlChar *value,
- xmlSchemaValPtr val,
+ xmlSchemaValPtr val,
unsigned long *length,
- xmlSchemaWhitespaceValueType ws)
+ xmlSchemaWhitespaceValueType ws)
{
unsigned int len = 0;
@@ -5116,7 +5142,7 @@ xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
(facet->type != XML_SCHEMA_FACET_MAXLENGTH) &&
(facet->type != XML_SCHEMA_FACET_MINLENGTH))
return (-1);
-
+
/*
* TODO: length, maxLength and minLength must be of type
* nonNegativeInteger only. Check if decimal is used somehow.
@@ -5150,7 +5176,7 @@ xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)
len = xmlSchemaNormLen(value);
else
- /*
+ /*
* Should be OK for "preserve" as well.
*/
len = xmlUTF8Strlen(value);
@@ -5162,7 +5188,7 @@ xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
case XML_SCHEMAS_NMTOKEN:
case XML_SCHEMAS_NAME:
case XML_SCHEMAS_NCNAME:
- case XML_SCHEMAS_ID:
+ case XML_SCHEMAS_ID:
/*
* FIXME: What exactly to do with anyURI?
*/
@@ -5171,11 +5197,11 @@ xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
len = xmlSchemaNormLen(value);
break;
case XML_SCHEMAS_QNAME:
- case XML_SCHEMAS_NOTATION:
- /*
+ case XML_SCHEMAS_NOTATION:
+ /*
* For QName and NOTATION, those facets are
* deprecated and should be ignored.
- */
+ */
return (0);
default:
TODO
@@ -5195,7 +5221,7 @@ xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
if (len > facet->val->value.decimal.lo)
return(XML_SCHEMAV_CVC_MAXLENGTH_VALID);
}
-
+
return (0);
}
@@ -5207,18 +5233,18 @@ xmlSchemaValidateLengthFacetInternal(xmlSchemaFacetPtr facet,
* @val: the precomputed value
* @length: the actual length of the value
*
- * Checka a value against a "length", "minLength" and "maxLength"
+ * Checka a value against a "length", "minLength" and "maxLength"
* facet; sets @length to the computed length of @value.
*
* Returns 0 if the value is valid, a positive error code
* otherwise and -1 in case of an internal or API error.
*/
int
-xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type,
+xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type,
xmlSchemaFacetPtr facet,
const xmlChar *value,
xmlSchemaValPtr val,
- unsigned long *length)
+ unsigned long *length)
{
if (type == NULL)
return(-1);
@@ -5228,7 +5254,7 @@ xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type,
}
/**
- * xmlSchemaValidateLengthFacetWhtsp:
+ * xmlSchemaValidateLengthFacetWhtsp:
* @facet: the facet to check
* @valType: the built-in type
* @value: the lexical repr. of the value to be validated
@@ -5236,7 +5262,7 @@ xmlSchemaValidateLengthFacet(xmlSchemaTypePtr type,
* @ws: the whitespace type of the value
* @length: the actual length of the value
*
- * Checka a value against a "length", "minLength" and "maxLength"
+ * Checka a value against a "length", "minLength" and "maxLength"
* facet; sets @length to the computed length of @value.
*
* Returns 0 if the value is valid, a positive error code
@@ -5271,7 +5297,7 @@ xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet,
static int
xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
xmlSchemaWhitespaceValueType fws,
- xmlSchemaValType valType,
+ xmlSchemaValType valType,
const xmlChar *value,
xmlSchemaValPtr val,
xmlSchemaWhitespaceValueType ws)
@@ -5283,7 +5309,7 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
switch (facet->type) {
case XML_SCHEMA_FACET_PATTERN:
- /*
+ /*
* NOTE that for patterns, the @value needs to be the normalized
* value, *not* the lexical initial value or the canonical value.
*/
@@ -5384,7 +5410,7 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
else {
switch (valType) {
case XML_SCHEMAS_STRING:
- case XML_SCHEMAS_NORMSTRING:
+ case XML_SCHEMAS_NORMSTRING:
if (ws == XML_SCHEMA_WHITESPACE_UNKNOWN) {
/*
* This is to ensure API compatibility with the old
@@ -5400,13 +5426,13 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
if (ws == XML_SCHEMA_WHITESPACE_COLLAPSE)
len = xmlSchemaNormLen(value);
else
- /*
+ /*
* Should be OK for "preserve" as well.
*/
len = xmlUTF8Strlen(value);
}
break;
- case XML_SCHEMAS_IDREF:
+ case XML_SCHEMAS_IDREF:
case XML_SCHEMAS_TOKEN:
case XML_SCHEMAS_LANGUAGE:
case XML_SCHEMAS_NMTOKEN:
@@ -5415,11 +5441,11 @@ xmlSchemaValidateFacetInternal(xmlSchemaFacetPtr facet,
case XML_SCHEMAS_ID:
case XML_SCHEMAS_ANYURI:
if (value != NULL)
- len = xmlSchemaNormLen(value);
- break;
+ len = xmlSchemaNormLen(value);
+ break;
default:
TODO
- }
+ }
}
if (facet->type == XML_SCHEMA_FACET_LENGTH) {
if (len != facet->val->value.decimal.lo)
@@ -5529,7 +5555,7 @@ xmlSchemaValidateFacet(xmlSchemaTypePtr base,
int
xmlSchemaValidateFacetWhtsp(xmlSchemaFacetPtr facet,
xmlSchemaWhitespaceValueType fws,
- xmlSchemaValType valType,
+ xmlSchemaValType valType,
const xmlChar *value,
xmlSchemaValPtr val,
xmlSchemaWhitespaceValueType ws)
@@ -5590,13 +5616,13 @@ xmlSchemaFormatFloat(double number, char buffer[], int buffersize)
/*
* Result is in work, and after_fraction points
* just past the fractional part.
- * Use scientific notation
+ * Use scientific notation
*/
integer_place = DBL_DIG + EXPONENT_DIGITS + 1;
fraction_place = DBL_DIG - 1;
snprintf(work, sizeof(work),"%*.*e",
integer_place, fraction_place, number);
- after_fraction = strchr(work + DBL_DIG, 'e');
+ after_fraction = strchr(work + DBL_DIG, 'e');
/* Remove fractional trailing zeroes */
ptr = after_fraction;
while (*(--ptr) == '0')
@@ -5623,12 +5649,12 @@ xmlSchemaFormatFloat(double number, char buffer[], int buffersize)
* @val: the precomputed value
* @retValue: the returned value
*
- * Get a the cononical lexical representation of the value.
+ * Get the canonical lexical representation of the value.
* The caller has to FREE the returned retValue.
*
* WARNING: Some value types are not supported yet, resulting
* in a @retValue of "???".
- *
+ *
* TODO: XML Schema 1.0 does not define canonical representations
* for: duration, gYearMonth, gYear, gMonthDay, gMonth, gDay,
* anyURI, QName, NOTATION. This will be fixed in XML Schema 1.1.
@@ -5648,7 +5674,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
if (val->value.str == NULL)
*retValue = BAD_CAST xmlStrdup(BAD_CAST "");
else
- *retValue =
+ *retValue =
BAD_CAST xmlStrdup((const xmlChar *) val->value.str);
break;
case XML_SCHEMAS_NORMSTRING:
@@ -5665,7 +5691,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
case XML_SCHEMAS_TOKEN:
case XML_SCHEMAS_LANGUAGE:
case XML_SCHEMAS_NMTOKEN:
- case XML_SCHEMAS_NAME:
+ case XML_SCHEMAS_NAME:
case XML_SCHEMAS_NCNAME:
case XML_SCHEMAS_ID:
case XML_SCHEMAS_IDREF:
@@ -5674,10 +5700,10 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
case XML_SCHEMAS_ANYURI: /* Unclear */
if (val->value.str == NULL)
return (-1);
- *retValue =
+ *retValue =
BAD_CAST xmlSchemaCollapseString(BAD_CAST val->value.str);
if (*retValue == NULL)
- *retValue =
+ *retValue =
BAD_CAST xmlStrdup((const xmlChar *) val->value.str);
break;
case XML_SCHEMAS_QNAME:
@@ -5699,7 +5725,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
/*
* TODO: Lookout for a more simple implementation.
*/
- if ((val->value.decimal.total == 1) &&
+ if ((val->value.decimal.total == 1) &&
(val->value.decimal.lo == 0)) {
*retValue = xmlStrdup(BAD_CAST "0.0");
} else {
@@ -5733,7 +5759,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
else
snprintf(offs, bufsize - (offs - buf),
"%lu", dec.lo);
-
+
if (dec.frac != 0) {
if (dec.frac != dec.total) {
int diff = dec.total - dec.frac;
@@ -5746,7 +5772,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
unsigned int i = 0;
/*
* Insert missing zeroes behind the decimal point.
- */
+ */
while (*(offs + i) != 0)
i++;
if (i < dec.total) {
@@ -5883,7 +5909,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
snprintf((char *) *retValue, 6, "---%02u",
val->value.date.day);
}
- break;
+ break;
case XML_SCHEMAS_GMONTHDAY: {
/* TODO: Unclear in XML Schema 1.0 */
/* TODO: What to do with the timezone? */
@@ -5900,14 +5926,14 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
/* TODO: What to do with the timezone? */
if (val->value.date.year < 0)
snprintf(buf, 35, "-%04ld-%02u",
- labs(val->value.date.year),
+ labs(val->value.date.year),
val->value.date.mon);
else
snprintf(buf, 35, "%04ld-%02u",
val->value.date.year, val->value.date.mon);
*retValue = BAD_CAST xmlStrdup(BAD_CAST buf);
}
- break;
+ break;
case XML_SCHEMAS_TIME:
{
char buf[30];
@@ -5918,8 +5944,8 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
norm = xmlSchemaDateNormalize(val, 0);
if (norm == NULL)
return (-1);
- /*
- * TODO: Check if "%.14g" is portable.
+ /*
+ * TODO: Check if "%.14g" is portable.
*/
snprintf(buf, 30,
"%02u:%02u:%02.14gZ",
@@ -5935,7 +5961,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
val->value.date.sec);
}
*retValue = BAD_CAST xmlStrdup(BAD_CAST buf);
- }
+ }
break;
case XML_SCHEMAS_DATE:
{
@@ -5963,7 +5989,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
val->value.date.day);
}
*retValue = BAD_CAST xmlStrdup(BAD_CAST buf);
- }
+ }
break;
case XML_SCHEMAS_DATETIME:
{
@@ -6007,8 +6033,8 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
*retValue = BAD_CAST xmlStrdup(BAD_CAST val->value.base64.str);
break;
case XML_SCHEMAS_FLOAT: {
- char buf[30];
- /*
+ char buf[30];
+ /*
* |m| < 16777216, -149 <= e <= 104.
* TODO: Handle, NaN, INF, -INF. The format is not
* yet conformant. The c type float does not cover
@@ -6029,7 +6055,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
snprintf(buf, 40, "%01.14e", val->value.d);
*retValue = BAD_CAST xmlStrdup(BAD_CAST buf);
}
- break;
+ break;
default:
*retValue = BAD_CAST xmlStrdup(BAD_CAST "???");
return (1);
@@ -6045,7 +6071,7 @@ xmlSchemaGetCanonValue(xmlSchemaValPtr val, const xmlChar **retValue)
* @retValue: the returned value
* @ws: the whitespace type of the value
*
- * Get a the cononical representation of the value.
+ * Get the canonical representation of the value.
* The caller has to free the returned @retValue.
*
* Returns 0 if the value could be built, 1 if the value type is
@@ -6088,7 +6114,7 @@ xmlSchemaGetCanonValueWhtsp(xmlSchemaValPtr val,
break;
default:
return (xmlSchemaGetCanonValue(val, retValue));
- }
+ }
return (0);
}
diff --git a/gnulib-local/lib/libxml/xmlschemastypes.in.h b/gnulib-local/lib/libxml/xmlschemastypes.in.h
index 9a3a7a1..35d48d4 100644
--- a/gnulib-local/lib/libxml/xmlschemastypes.in.h
+++ b/gnulib-local/lib/libxml/xmlschemastypes.in.h
@@ -30,23 +30,23 @@ typedef enum {
XML_SCHEMA_WHITESPACE_COLLAPSE = 3
} xmlSchemaWhitespaceValueType;
-XMLPUBFUN void XMLCALL
- xmlSchemaInitTypes (void);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
+ xmlSchemaInitTypes (void);
+XMLPUBFUN void XMLCALL
xmlSchemaCleanupTypes (void);
-XMLPUBFUN xmlSchemaTypePtr XMLCALL
+XMLPUBFUN xmlSchemaTypePtr XMLCALL
xmlSchemaGetPredefinedType (const xmlChar *name,
const xmlChar *ns);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSchemaValidatePredefinedType (xmlSchemaTypePtr type,
const xmlChar *value,
xmlSchemaValPtr *val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSchemaValPredefTypeNode (xmlSchemaTypePtr type,
const xmlChar *value,
xmlSchemaValPtr *val,
xmlNodePtr node);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSchemaValidateFacet (xmlSchemaTypePtr base,
xmlSchemaFacetPtr facet,
const xmlChar *value,
@@ -54,25 +54,25 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlSchemaValidateFacetWhtsp (xmlSchemaFacetPtr facet,
xmlSchemaWhitespaceValueType fws,
- xmlSchemaValType valType,
+ xmlSchemaValType valType,
const xmlChar *value,
xmlSchemaValPtr val,
xmlSchemaWhitespaceValueType ws);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchemaFreeValue (xmlSchemaValPtr val);
-XMLPUBFUN xmlSchemaFacetPtr XMLCALL
+XMLPUBFUN xmlSchemaFacetPtr XMLCALL
xmlSchemaNewFacet (void);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSchemaCheckFacet (xmlSchemaFacetPtr facet,
xmlSchemaTypePtr typeDecl,
xmlSchemaParserCtxtPtr ctxt,
const xmlChar *name);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlSchemaFreeFacet (xmlSchemaFacetPtr facet);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlSchemaCompareValues (xmlSchemaValPtr x,
xmlSchemaValPtr y);
-XMLPUBFUN xmlSchemaTypePtr XMLCALL
+XMLPUBFUN xmlSchemaTypePtr XMLCALL
xmlSchemaGetBuiltInListSimpleTypeItemType (xmlSchemaTypePtr type);
XMLPUBFUN int XMLCALL
xmlSchemaValidateListSimpleTypeFacet (xmlSchemaFacetPtr facet,
@@ -82,7 +82,7 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN xmlSchemaTypePtr XMLCALL
xmlSchemaGetBuiltInType (xmlSchemaValType type);
XMLPUBFUN int XMLCALL
- xmlSchemaIsBuiltInTypeFacet (xmlSchemaTypePtr type,
+ xmlSchemaIsBuiltInTypeFacet (xmlSchemaTypePtr type,
int facetType);
XMLPUBFUN xmlChar * XMLCALL
xmlSchemaCollapseString (const xmlChar *value);
@@ -91,7 +91,7 @@ XMLPUBFUN xmlChar * XMLCALL
XMLPUBFUN unsigned long XMLCALL
xmlSchemaGetFacetValueAsULong (xmlSchemaFacetPtr facet);
XMLPUBFUN int XMLCALL
- xmlSchemaValidateLengthFacet (xmlSchemaTypePtr type,
+ xmlSchemaValidateLengthFacet (xmlSchemaTypePtr type,
xmlSchemaFacetPtr facet,
const xmlChar *value,
xmlSchemaValPtr val,
@@ -100,19 +100,19 @@ XMLPUBFUN int XMLCALL
xmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet,
xmlSchemaValType valType,
const xmlChar *value,
- xmlSchemaValPtr val,
+ xmlSchemaValPtr val,
unsigned long *length,
xmlSchemaWhitespaceValueType ws);
XMLPUBFUN int XMLCALL
- xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type,
+ xmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type,
const xmlChar *value,
- xmlSchemaValPtr *val,
+ xmlSchemaValPtr *val,
xmlNodePtr node);
XMLPUBFUN int XMLCALL
xmlSchemaGetCanonValue (xmlSchemaValPtr val,
const xmlChar **retValue);
XMLPUBFUN int XMLCALL
- xmlSchemaGetCanonValueWhtsp (xmlSchemaValPtr val,
+ xmlSchemaGetCanonValueWhtsp (xmlSchemaValPtr val,
const xmlChar **retValue,
xmlSchemaWhitespaceValueType ws);
XMLPUBFUN int XMLCALL
diff --git a/gnulib-local/lib/libxml/xmlstring.c b/gnulib-local/lib/libxml/xmlstring.c
index 4f3b373..a37220d 100644
--- a/gnulib-local/lib/libxml/xmlstring.c
+++ b/gnulib-local/lib/libxml/xmlstring.c
@@ -3,7 +3,7 @@
*
* This module provides various utility functions for manipulating
* the xmlChar* type. All functions named xmlStr* have been moved here
- * from the parser.c file (their original home).
+ * from the parser.c file (their original home).
*
* See Copyright for the status of this software.
*
@@ -40,7 +40,7 @@
xmlChar *
xmlStrndup(const xmlChar *cur, int len) {
xmlChar *ret;
-
+
if ((cur == NULL) || (len < 0)) return(NULL);
ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar));
if (ret == NULL) {
@@ -85,7 +85,7 @@ xmlChar *
xmlCharStrndup(const char *cur, int len) {
int i;
xmlChar *ret;
-
+
if ((cur == NULL) || (len < 0)) return(NULL);
ret = (xmlChar *) xmlMallocAtomic((len + 1) * sizeof(xmlChar));
if (ret == NULL) {
@@ -170,7 +170,7 @@ xmlStrEqual(const xmlChar *str1, const xmlChar *str2) {
* @name: the localname of the QName
* @str: the second xmlChar *
*
- * Check if a QName is Equal to a given string
+ * Check if a QName is Equal to a given string
*
* Returns 1 if they are equal, 0 if they are different
*/
@@ -340,7 +340,7 @@ xmlStrchr(const xmlChar *str, xmlChar val) {
const xmlChar *
xmlStrstr(const xmlChar *str, const xmlChar *val) {
int n;
-
+
if (str == NULL) return(NULL);
if (val == NULL) return(NULL);
n = xmlStrlen(val);
@@ -366,9 +366,9 @@ xmlStrstr(const xmlChar *str, const xmlChar *val) {
*/
const xmlChar *
-xmlStrcasestr(const xmlChar *str, xmlChar *val) {
+xmlStrcasestr(const xmlChar *str, const xmlChar *val) {
int n;
-
+
if (str == NULL) return(NULL);
if (val == NULL) return(NULL);
n = xmlStrlen(val);
@@ -396,7 +396,7 @@ xmlStrcasestr(const xmlChar *str, xmlChar *val) {
xmlChar *
xmlStrsub(const xmlChar *str, int start, int len) {
int i;
-
+
if (str == NULL) return(NULL);
if (start < 0) return(NULL);
if (len < 0) return(NULL);
@@ -519,7 +519,7 @@ xmlStrcat(xmlChar *cur, const xmlChar *add) {
const xmlChar *p = add;
if (add == NULL) return(cur);
- if (cur == NULL)
+ if (cur == NULL)
return(xmlStrdup(add));
while (*p != 0) p++; /* non input consuming */
@@ -537,20 +537,20 @@ xmlStrcat(xmlChar *cur, const xmlChar *add) {
*
* Returns the number of characters written to @buf or -1 if an error occurs.
*/
-int XMLCDECL
+int XMLCDECL
xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) {
va_list args;
int ret;
-
+
if((buf == NULL) || (msg == NULL)) {
return(-1);
}
-
+
va_start(args, msg);
ret = vsnprintf((char *) buf, len, (const char *) msg, args);
va_end(args);
buf[len - 1] = 0; /* be safe ! */
-
+
return(ret);
}
@@ -565,17 +565,17 @@ xmlStrPrintf(xmlChar *buf, int len, const xmlChar *msg, ...) {
*
* Returns the number of characters written to @buf or -1 if an error occurs.
*/
-int
+int
xmlStrVPrintf(xmlChar *buf, int len, const xmlChar *msg, va_list ap) {
int ret;
-
+
if((buf == NULL) || (msg == NULL)) {
return(-1);
}
-
+
ret = vsnprintf((char *) buf, len, (const char *) msg, ap);
buf[len - 1] = 0; /* be safe ! */
-
+
return(ret);
}
@@ -858,7 +858,7 @@ xmlChar *
xmlUTF8Strndup(const xmlChar *utf, int len) {
xmlChar *ret;
int i;
-
+
if ((utf == NULL) || (len < 0)) return(NULL);
i = xmlUTF8Strsize(utf, len);
ret = (xmlChar *) xmlMallocAtomic((i + 1) * sizeof(xmlChar));
diff --git a/gnulib-local/lib/libxml/xmlstring.in.h b/gnulib-local/lib/libxml/xmlstring.in.h
index 1dfc5ea..2036236 100644
--- a/gnulib-local/lib/libxml/xmlstring.in.h
+++ b/gnulib-local/lib/libxml/xmlstring.in.h
@@ -59,7 +59,7 @@ XMLPUBFUN const xmlChar * XMLCALL
const xmlChar *val);
XMLPUBFUN const xmlChar * XMLCALL
xmlStrcasestr (const xmlChar *str,
- xmlChar *val);
+ const xmlChar *val);
XMLPUBFUN int XMLCALL
xmlStrcmp (const xmlChar *str1,
const xmlChar *str2);
@@ -113,16 +113,16 @@ XMLPUBFUN int XMLCALL
XMLPUBFUN int XMLCALL
xmlUTF8Strsize (const xmlChar *utf,
int len);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlUTF8Strndup (const xmlChar *utf,
int len);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlUTF8Strpos (const xmlChar *utf,
int pos);
XMLPUBFUN int XMLCALL
xmlUTF8Strloc (const xmlChar *utf,
const xmlChar *utfchar);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlUTF8Strsub (const xmlChar *utf,
int start,
int len);
diff --git a/gnulib-local/lib/libxml/xmlunicode.c b/gnulib-local/lib/libxml/xmlunicode.c
index 450d0f0..ce6e9a4 100644
--- a/gnulib-local/lib/libxml/xmlunicode.c
+++ b/gnulib-local/lib/libxml/xmlunicode.c
@@ -204,729 +204,729 @@ static xmlUnicodeRange xmlUnicodeCats[] = {
{"Zp", xmlUCSIsCatZp},
{"Zs", xmlUCSIsCatZs}};
-static const xmlChSRange xmlCS[] = {{0x0, 0x1f}, {0x7f, 0x9f},
- {0xad, 0xad}, {0x600, 0x603}, {0x6dd, 0x6dd}, {0x70f, 0x70f},
- {0x17b4, 0x17b5}, {0x200b, 0x200f}, {0x202a, 0x202e}, {0x2060, 0x2063},
- {0x206a, 0x206f}, {0xd800, 0xd800}, {0xdb7f, 0xdb80}, {0xdbff, 0xdc00},
+static const xmlChSRange xmlCS[] = {{0x0, 0x1f}, {0x7f, 0x9f},
+ {0xad, 0xad}, {0x600, 0x603}, {0x6dd, 0x6dd}, {0x70f, 0x70f},
+ {0x17b4, 0x17b5}, {0x200b, 0x200f}, {0x202a, 0x202e}, {0x2060, 0x2063},
+ {0x206a, 0x206f}, {0xd800, 0xd800}, {0xdb7f, 0xdb80}, {0xdbff, 0xdc00},
{0xdfff, 0xe000}, {0xf8ff, 0xf8ff}, {0xfeff, 0xfeff}, {0xfff9, 0xfffb} };
-static const xmlChLRange xmlCL[] = {{0x1d173, 0x1d17a}, {0xe0001, 0xe0001},
- {0xe0020, 0xe007f}, {0xf0000, 0xf0000}, {0xffffd, 0xffffd},
+static const xmlChLRange xmlCL[] = {{0x1d173, 0x1d17a}, {0xe0001, 0xe0001},
+ {0xe0020, 0xe007f}, {0xf0000, 0xf0000}, {0xffffd, 0xffffd},
{0x100000, 0x100000}, {0x10fffd, 0x10fffd} };
static xmlChRangeGroup xmlCG = {18,7,xmlCS,xmlCL};
-static const xmlChSRange xmlCfS[] = {{0xad, 0xad}, {0x600, 0x603},
- {0x6dd, 0x6dd}, {0x70f, 0x70f}, {0x17b4, 0x17b5}, {0x200b, 0x200f},
- {0x202a, 0x202e}, {0x2060, 0x2063}, {0x206a, 0x206f}, {0xfeff, 0xfeff},
+static const xmlChSRange xmlCfS[] = {{0xad, 0xad}, {0x600, 0x603},
+ {0x6dd, 0x6dd}, {0x70f, 0x70f}, {0x17b4, 0x17b5}, {0x200b, 0x200f},
+ {0x202a, 0x202e}, {0x2060, 0x2063}, {0x206a, 0x206f}, {0xfeff, 0xfeff},
{0xfff9, 0xfffb} };
-static const xmlChLRange xmlCfL[] = {{0x1d173, 0x1d17a}, {0xe0001, 0xe0001},
+static const xmlChLRange xmlCfL[] = {{0x1d173, 0x1d17a}, {0xe0001, 0xe0001},
{0xe0020, 0xe007f} };
static xmlChRangeGroup xmlCfG = {11,3,xmlCfS,xmlCfL};
-static const xmlChSRange xmlLS[] = {{0x41, 0x5a}, {0x61, 0x7a},
- {0xaa, 0xaa}, {0xb5, 0xb5}, {0xba, 0xba}, {0xc0, 0xd6}, {0xd8, 0xf6},
- {0xf8, 0x236}, {0x250, 0x2c1}, {0x2c6, 0x2d1}, {0x2e0, 0x2e4},
- {0x2ee, 0x2ee}, {0x37a, 0x37a}, {0x386, 0x386}, {0x388, 0x38a},
- {0x38c, 0x38c}, {0x38e, 0x3a1}, {0x3a3, 0x3ce}, {0x3d0, 0x3f5},
- {0x3f7, 0x3fb}, {0x400, 0x481}, {0x48a, 0x4ce}, {0x4d0, 0x4f5},
- {0x4f8, 0x4f9}, {0x500, 0x50f}, {0x531, 0x556}, {0x559, 0x559},
- {0x561, 0x587}, {0x5d0, 0x5ea}, {0x5f0, 0x5f2}, {0x621, 0x63a},
- {0x640, 0x64a}, {0x66e, 0x66f}, {0x671, 0x6d3}, {0x6d5, 0x6d5},
- {0x6e5, 0x6e6}, {0x6ee, 0x6ef}, {0x6fa, 0x6fc}, {0x6ff, 0x6ff},
- {0x710, 0x710}, {0x712, 0x72f}, {0x74d, 0x74f}, {0x780, 0x7a5},
- {0x7b1, 0x7b1}, {0x904, 0x939}, {0x93d, 0x93d}, {0x950, 0x950},
- {0x958, 0x961}, {0x985, 0x98c}, {0x98f, 0x990}, {0x993, 0x9a8},
- {0x9aa, 0x9b0}, {0x9b2, 0x9b2}, {0x9b6, 0x9b9}, {0x9bd, 0x9bd},
- {0x9dc, 0x9dd}, {0x9df, 0x9e1}, {0x9f0, 0x9f1}, {0xa05, 0xa0a},
- {0xa0f, 0xa10}, {0xa13, 0xa28}, {0xa2a, 0xa30}, {0xa32, 0xa33},
- {0xa35, 0xa36}, {0xa38, 0xa39}, {0xa59, 0xa5c}, {0xa5e, 0xa5e},
- {0xa72, 0xa74}, {0xa85, 0xa8d}, {0xa8f, 0xa91}, {0xa93, 0xaa8},
- {0xaaa, 0xab0}, {0xab2, 0xab3}, {0xab5, 0xab9}, {0xabd, 0xabd},
- {0xad0, 0xad0}, {0xae0, 0xae1}, {0xb05, 0xb0c}, {0xb0f, 0xb10},
- {0xb13, 0xb28}, {0xb2a, 0xb30}, {0xb32, 0xb33}, {0xb35, 0xb39},
- {0xb3d, 0xb3d}, {0xb5c, 0xb5d}, {0xb5f, 0xb61}, {0xb71, 0xb71},
- {0xb83, 0xb83}, {0xb85, 0xb8a}, {0xb8e, 0xb90}, {0xb92, 0xb95},
- {0xb99, 0xb9a}, {0xb9c, 0xb9c}, {0xb9e, 0xb9f}, {0xba3, 0xba4},
- {0xba8, 0xbaa}, {0xbae, 0xbb5}, {0xbb7, 0xbb9}, {0xc05, 0xc0c},
- {0xc0e, 0xc10}, {0xc12, 0xc28}, {0xc2a, 0xc33}, {0xc35, 0xc39},
- {0xc60, 0xc61}, {0xc85, 0xc8c}, {0xc8e, 0xc90}, {0xc92, 0xca8},
- {0xcaa, 0xcb3}, {0xcb5, 0xcb9}, {0xcbd, 0xcbd}, {0xcde, 0xcde},
- {0xce0, 0xce1}, {0xd05, 0xd0c}, {0xd0e, 0xd10}, {0xd12, 0xd28},
- {0xd2a, 0xd39}, {0xd60, 0xd61}, {0xd85, 0xd96}, {0xd9a, 0xdb1},
- {0xdb3, 0xdbb}, {0xdbd, 0xdbd}, {0xdc0, 0xdc6}, {0xe01, 0xe30},
- {0xe32, 0xe33}, {0xe40, 0xe46}, {0xe81, 0xe82}, {0xe84, 0xe84},
- {0xe87, 0xe88}, {0xe8a, 0xe8a}, {0xe8d, 0xe8d}, {0xe94, 0xe97},
- {0xe99, 0xe9f}, {0xea1, 0xea3}, {0xea5, 0xea5}, {0xea7, 0xea7},
- {0xeaa, 0xeab}, {0xead, 0xeb0}, {0xeb2, 0xeb3}, {0xebd, 0xebd},
- {0xec0, 0xec4}, {0xec6, 0xec6}, {0xedc, 0xedd}, {0xf00, 0xf00},
- {0xf40, 0xf47}, {0xf49, 0xf6a}, {0xf88, 0xf8b}, {0x1000, 0x1021},
- {0x1023, 0x1027}, {0x1029, 0x102a}, {0x1050, 0x1055}, {0x10a0, 0x10c5},
- {0x10d0, 0x10f8}, {0x1100, 0x1159}, {0x115f, 0x11a2}, {0x11a8, 0x11f9},
- {0x1200, 0x1206}, {0x1208, 0x1246}, {0x1248, 0x1248}, {0x124a, 0x124d},
- {0x1250, 0x1256}, {0x1258, 0x1258}, {0x125a, 0x125d}, {0x1260, 0x1286},
- {0x1288, 0x1288}, {0x128a, 0x128d}, {0x1290, 0x12ae}, {0x12b0, 0x12b0},
- {0x12b2, 0x12b5}, {0x12b8, 0x12be}, {0x12c0, 0x12c0}, {0x12c2, 0x12c5},
- {0x12c8, 0x12ce}, {0x12d0, 0x12d6}, {0x12d8, 0x12ee}, {0x12f0, 0x130e},
- {0x1310, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x131e}, {0x1320, 0x1346},
- {0x1348, 0x135a}, {0x13a0, 0x13f4}, {0x1401, 0x166c}, {0x166f, 0x1676},
- {0x1681, 0x169a}, {0x16a0, 0x16ea}, {0x1700, 0x170c}, {0x170e, 0x1711},
- {0x1720, 0x1731}, {0x1740, 0x1751}, {0x1760, 0x176c}, {0x176e, 0x1770},
- {0x1780, 0x17b3}, {0x17d7, 0x17d7}, {0x17dc, 0x17dc}, {0x1820, 0x1877},
- {0x1880, 0x18a8}, {0x1900, 0x191c}, {0x1950, 0x196d}, {0x1970, 0x1974},
- {0x1d00, 0x1d6b}, {0x1e00, 0x1e9b}, {0x1ea0, 0x1ef9}, {0x1f00, 0x1f15},
- {0x1f18, 0x1f1d}, {0x1f20, 0x1f45}, {0x1f48, 0x1f4d}, {0x1f50, 0x1f57},
- {0x1f59, 0x1f59}, {0x1f5b, 0x1f5b}, {0x1f5d, 0x1f5d}, {0x1f5f, 0x1f7d},
- {0x1f80, 0x1fb4}, {0x1fb6, 0x1fbc}, {0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4},
- {0x1fc6, 0x1fcc}, {0x1fd0, 0x1fd3}, {0x1fd6, 0x1fdb}, {0x1fe0, 0x1fec},
- {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffc}, {0x2071, 0x2071}, {0x207f, 0x207f},
- {0x2102, 0x2102}, {0x2107, 0x2107}, {0x210a, 0x2113}, {0x2115, 0x2115},
- {0x2119, 0x211d}, {0x2124, 0x2124}, {0x2126, 0x2126}, {0x2128, 0x2128},
- {0x212a, 0x212d}, {0x212f, 0x2131}, {0x2133, 0x2139}, {0x213d, 0x213f},
- {0x2145, 0x2149}, {0x3005, 0x3006}, {0x3031, 0x3035}, {0x303b, 0x303c},
- {0x3041, 0x3096}, {0x309d, 0x309f}, {0x30a1, 0x30fa}, {0x30fc, 0x30ff},
- {0x3105, 0x312c}, {0x3131, 0x318e}, {0x31a0, 0x31b7}, {0x31f0, 0x31ff},
- {0x3400, 0x3400}, {0x4db5, 0x4db5}, {0x4e00, 0x4e00}, {0x9fa5, 0x9fa5},
- {0xa000, 0xa48c}, {0xac00, 0xac00}, {0xd7a3, 0xd7a3}, {0xf900, 0xfa2d},
- {0xfa30, 0xfa6a}, {0xfb00, 0xfb06}, {0xfb13, 0xfb17}, {0xfb1d, 0xfb1d},
- {0xfb1f, 0xfb28}, {0xfb2a, 0xfb36}, {0xfb38, 0xfb3c}, {0xfb3e, 0xfb3e},
- {0xfb40, 0xfb41}, {0xfb43, 0xfb44}, {0xfb46, 0xfbb1}, {0xfbd3, 0xfd3d},
- {0xfd50, 0xfd8f}, {0xfd92, 0xfdc7}, {0xfdf0, 0xfdfb}, {0xfe70, 0xfe74},
- {0xfe76, 0xfefc}, {0xff21, 0xff3a}, {0xff41, 0xff5a}, {0xff66, 0xffbe},
+static const xmlChSRange xmlLS[] = {{0x41, 0x5a}, {0x61, 0x7a},
+ {0xaa, 0xaa}, {0xb5, 0xb5}, {0xba, 0xba}, {0xc0, 0xd6}, {0xd8, 0xf6},
+ {0xf8, 0x236}, {0x250, 0x2c1}, {0x2c6, 0x2d1}, {0x2e0, 0x2e4},
+ {0x2ee, 0x2ee}, {0x37a, 0x37a}, {0x386, 0x386}, {0x388, 0x38a},
+ {0x38c, 0x38c}, {0x38e, 0x3a1}, {0x3a3, 0x3ce}, {0x3d0, 0x3f5},
+ {0x3f7, 0x3fb}, {0x400, 0x481}, {0x48a, 0x4ce}, {0x4d0, 0x4f5},
+ {0x4f8, 0x4f9}, {0x500, 0x50f}, {0x531, 0x556}, {0x559, 0x559},
+ {0x561, 0x587}, {0x5d0, 0x5ea}, {0x5f0, 0x5f2}, {0x621, 0x63a},
+ {0x640, 0x64a}, {0x66e, 0x66f}, {0x671, 0x6d3}, {0x6d5, 0x6d5},
+ {0x6e5, 0x6e6}, {0x6ee, 0x6ef}, {0x6fa, 0x6fc}, {0x6ff, 0x6ff},
+ {0x710, 0x710}, {0x712, 0x72f}, {0x74d, 0x74f}, {0x780, 0x7a5},
+ {0x7b1, 0x7b1}, {0x904, 0x939}, {0x93d, 0x93d}, {0x950, 0x950},
+ {0x958, 0x961}, {0x985, 0x98c}, {0x98f, 0x990}, {0x993, 0x9a8},
+ {0x9aa, 0x9b0}, {0x9b2, 0x9b2}, {0x9b6, 0x9b9}, {0x9bd, 0x9bd},
+ {0x9dc, 0x9dd}, {0x9df, 0x9e1}, {0x9f0, 0x9f1}, {0xa05, 0xa0a},
+ {0xa0f, 0xa10}, {0xa13, 0xa28}, {0xa2a, 0xa30}, {0xa32, 0xa33},
+ {0xa35, 0xa36}, {0xa38, 0xa39}, {0xa59, 0xa5c}, {0xa5e, 0xa5e},
+ {0xa72, 0xa74}, {0xa85, 0xa8d}, {0xa8f, 0xa91}, {0xa93, 0xaa8},
+ {0xaaa, 0xab0}, {0xab2, 0xab3}, {0xab5, 0xab9}, {0xabd, 0xabd},
+ {0xad0, 0xad0}, {0xae0, 0xae1}, {0xb05, 0xb0c}, {0xb0f, 0xb10},
+ {0xb13, 0xb28}, {0xb2a, 0xb30}, {0xb32, 0xb33}, {0xb35, 0xb39},
+ {0xb3d, 0xb3d}, {0xb5c, 0xb5d}, {0xb5f, 0xb61}, {0xb71, 0xb71},
+ {0xb83, 0xb83}, {0xb85, 0xb8a}, {0xb8e, 0xb90}, {0xb92, 0xb95},
+ {0xb99, 0xb9a}, {0xb9c, 0xb9c}, {0xb9e, 0xb9f}, {0xba3, 0xba4},
+ {0xba8, 0xbaa}, {0xbae, 0xbb5}, {0xbb7, 0xbb9}, {0xc05, 0xc0c},
+ {0xc0e, 0xc10}, {0xc12, 0xc28}, {0xc2a, 0xc33}, {0xc35, 0xc39},
+ {0xc60, 0xc61}, {0xc85, 0xc8c}, {0xc8e, 0xc90}, {0xc92, 0xca8},
+ {0xcaa, 0xcb3}, {0xcb5, 0xcb9}, {0xcbd, 0xcbd}, {0xcde, 0xcde},
+ {0xce0, 0xce1}, {0xd05, 0xd0c}, {0xd0e, 0xd10}, {0xd12, 0xd28},
+ {0xd2a, 0xd39}, {0xd60, 0xd61}, {0xd85, 0xd96}, {0xd9a, 0xdb1},
+ {0xdb3, 0xdbb}, {0xdbd, 0xdbd}, {0xdc0, 0xdc6}, {0xe01, 0xe30},
+ {0xe32, 0xe33}, {0xe40, 0xe46}, {0xe81, 0xe82}, {0xe84, 0xe84},
+ {0xe87, 0xe88}, {0xe8a, 0xe8a}, {0xe8d, 0xe8d}, {0xe94, 0xe97},
+ {0xe99, 0xe9f}, {0xea1, 0xea3}, {0xea5, 0xea5}, {0xea7, 0xea7},
+ {0xeaa, 0xeab}, {0xead, 0xeb0}, {0xeb2, 0xeb3}, {0xebd, 0xebd},
+ {0xec0, 0xec4}, {0xec6, 0xec6}, {0xedc, 0xedd}, {0xf00, 0xf00},
+ {0xf40, 0xf47}, {0xf49, 0xf6a}, {0xf88, 0xf8b}, {0x1000, 0x1021},
+ {0x1023, 0x1027}, {0x1029, 0x102a}, {0x1050, 0x1055}, {0x10a0, 0x10c5},
+ {0x10d0, 0x10f8}, {0x1100, 0x1159}, {0x115f, 0x11a2}, {0x11a8, 0x11f9},
+ {0x1200, 0x1206}, {0x1208, 0x1246}, {0x1248, 0x1248}, {0x124a, 0x124d},
+ {0x1250, 0x1256}, {0x1258, 0x1258}, {0x125a, 0x125d}, {0x1260, 0x1286},
+ {0x1288, 0x1288}, {0x128a, 0x128d}, {0x1290, 0x12ae}, {0x12b0, 0x12b0},
+ {0x12b2, 0x12b5}, {0x12b8, 0x12be}, {0x12c0, 0x12c0}, {0x12c2, 0x12c5},
+ {0x12c8, 0x12ce}, {0x12d0, 0x12d6}, {0x12d8, 0x12ee}, {0x12f0, 0x130e},
+ {0x1310, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x131e}, {0x1320, 0x1346},
+ {0x1348, 0x135a}, {0x13a0, 0x13f4}, {0x1401, 0x166c}, {0x166f, 0x1676},
+ {0x1681, 0x169a}, {0x16a0, 0x16ea}, {0x1700, 0x170c}, {0x170e, 0x1711},
+ {0x1720, 0x1731}, {0x1740, 0x1751}, {0x1760, 0x176c}, {0x176e, 0x1770},
+ {0x1780, 0x17b3}, {0x17d7, 0x17d7}, {0x17dc, 0x17dc}, {0x1820, 0x1877},
+ {0x1880, 0x18a8}, {0x1900, 0x191c}, {0x1950, 0x196d}, {0x1970, 0x1974},
+ {0x1d00, 0x1d6b}, {0x1e00, 0x1e9b}, {0x1ea0, 0x1ef9}, {0x1f00, 0x1f15},
+ {0x1f18, 0x1f1d}, {0x1f20, 0x1f45}, {0x1f48, 0x1f4d}, {0x1f50, 0x1f57},
+ {0x1f59, 0x1f59}, {0x1f5b, 0x1f5b}, {0x1f5d, 0x1f5d}, {0x1f5f, 0x1f7d},
+ {0x1f80, 0x1fb4}, {0x1fb6, 0x1fbc}, {0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4},
+ {0x1fc6, 0x1fcc}, {0x1fd0, 0x1fd3}, {0x1fd6, 0x1fdb}, {0x1fe0, 0x1fec},
+ {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ffc}, {0x2071, 0x2071}, {0x207f, 0x207f},
+ {0x2102, 0x2102}, {0x2107, 0x2107}, {0x210a, 0x2113}, {0x2115, 0x2115},
+ {0x2119, 0x211d}, {0x2124, 0x2124}, {0x2126, 0x2126}, {0x2128, 0x2128},
+ {0x212a, 0x212d}, {0x212f, 0x2131}, {0x2133, 0x2139}, {0x213d, 0x213f},
+ {0x2145, 0x2149}, {0x3005, 0x3006}, {0x3031, 0x3035}, {0x303b, 0x303c},
+ {0x3041, 0x3096}, {0x309d, 0x309f}, {0x30a1, 0x30fa}, {0x30fc, 0x30ff},
+ {0x3105, 0x312c}, {0x3131, 0x318e}, {0x31a0, 0x31b7}, {0x31f0, 0x31ff},
+ {0x3400, 0x3400}, {0x4db5, 0x4db5}, {0x4e00, 0x4e00}, {0x9fa5, 0x9fa5},
+ {0xa000, 0xa48c}, {0xac00, 0xac00}, {0xd7a3, 0xd7a3}, {0xf900, 0xfa2d},
+ {0xfa30, 0xfa6a}, {0xfb00, 0xfb06}, {0xfb13, 0xfb17}, {0xfb1d, 0xfb1d},
+ {0xfb1f, 0xfb28}, {0xfb2a, 0xfb36}, {0xfb38, 0xfb3c}, {0xfb3e, 0xfb3e},
+ {0xfb40, 0xfb41}, {0xfb43, 0xfb44}, {0xfb46, 0xfbb1}, {0xfbd3, 0xfd3d},
+ {0xfd50, 0xfd8f}, {0xfd92, 0xfdc7}, {0xfdf0, 0xfdfb}, {0xfe70, 0xfe74},
+ {0xfe76, 0xfefc}, {0xff21, 0xff3a}, {0xff41, 0xff5a}, {0xff66, 0xffbe},
{0xffc2, 0xffc7}, {0xffca, 0xffcf}, {0xffd2, 0xffd7}, {0xffda, 0xffdc} };
-static const xmlChLRange xmlLL[] = {{0x10000, 0x1000b}, {0x1000d, 0x10026},
- {0x10028, 0x1003a}, {0x1003c, 0x1003d}, {0x1003f, 0x1004d},
- {0x10050, 0x1005d}, {0x10080, 0x100fa}, {0x10300, 0x1031e},
- {0x10330, 0x10349}, {0x10380, 0x1039d}, {0x10400, 0x1049d},
- {0x10800, 0x10805}, {0x10808, 0x10808}, {0x1080a, 0x10835},
- {0x10837, 0x10838}, {0x1083c, 0x1083c}, {0x1083f, 0x1083f},
- {0x1d400, 0x1d454}, {0x1d456, 0x1d49c}, {0x1d49e, 0x1d49f},
- {0x1d4a2, 0x1d4a2}, {0x1d4a5, 0x1d4a6}, {0x1d4a9, 0x1d4ac},
- {0x1d4ae, 0x1d4b9}, {0x1d4bb, 0x1d4bb}, {0x1d4bd, 0x1d4c3},
- {0x1d4c5, 0x1d505}, {0x1d507, 0x1d50a}, {0x1d50d, 0x1d514},
- {0x1d516, 0x1d51c}, {0x1d51e, 0x1d539}, {0x1d53b, 0x1d53e},
- {0x1d540, 0x1d544}, {0x1d546, 0x1d546}, {0x1d54a, 0x1d550},
- {0x1d552, 0x1d6a3}, {0x1d6a8, 0x1d6c0}, {0x1d6c2, 0x1d6da},
- {0x1d6dc, 0x1d6fa}, {0x1d6fc, 0x1d714}, {0x1d716, 0x1d734},
- {0x1d736, 0x1d74e}, {0x1d750, 0x1d76e}, {0x1d770, 0x1d788},
- {0x1d78a, 0x1d7a8}, {0x1d7aa, 0x1d7c2}, {0x1d7c4, 0x1d7c9},
+static const xmlChLRange xmlLL[] = {{0x10000, 0x1000b}, {0x1000d, 0x10026},
+ {0x10028, 0x1003a}, {0x1003c, 0x1003d}, {0x1003f, 0x1004d},
+ {0x10050, 0x1005d}, {0x10080, 0x100fa}, {0x10300, 0x1031e},
+ {0x10330, 0x10349}, {0x10380, 0x1039d}, {0x10400, 0x1049d},
+ {0x10800, 0x10805}, {0x10808, 0x10808}, {0x1080a, 0x10835},
+ {0x10837, 0x10838}, {0x1083c, 0x1083c}, {0x1083f, 0x1083f},
+ {0x1d400, 0x1d454}, {0x1d456, 0x1d49c}, {0x1d49e, 0x1d49f},
+ {0x1d4a2, 0x1d4a2}, {0x1d4a5, 0x1d4a6}, {0x1d4a9, 0x1d4ac},
+ {0x1d4ae, 0x1d4b9}, {0x1d4bb, 0x1d4bb}, {0x1d4bd, 0x1d4c3},
+ {0x1d4c5, 0x1d505}, {0x1d507, 0x1d50a}, {0x1d50d, 0x1d514},
+ {0x1d516, 0x1d51c}, {0x1d51e, 0x1d539}, {0x1d53b, 0x1d53e},
+ {0x1d540, 0x1d544}, {0x1d546, 0x1d546}, {0x1d54a, 0x1d550},
+ {0x1d552, 0x1d6a3}, {0x1d6a8, 0x1d6c0}, {0x1d6c2, 0x1d6da},
+ {0x1d6dc, 0x1d6fa}, {0x1d6fc, 0x1d714}, {0x1d716, 0x1d734},
+ {0x1d736, 0x1d74e}, {0x1d750, 0x1d76e}, {0x1d770, 0x1d788},
+ {0x1d78a, 0x1d7a8}, {0x1d7aa, 0x1d7c2}, {0x1d7c4, 0x1d7c9},
{0x20000, 0x20000}, {0x2a6d6, 0x2a6d6}, {0x2f800, 0x2fa1d} };
static xmlChRangeGroup xmlLG = {279,50,xmlLS,xmlLL};
-static const xmlChSRange xmlLlS[] = {{0x61, 0x7a}, {0xaa, 0xaa},
- {0xb5, 0xb5}, {0xba, 0xba}, {0xdf, 0xf6}, {0xf8, 0xff}, {0x101, 0x101},
- {0x103, 0x103}, {0x105, 0x105}, {0x107, 0x107}, {0x109, 0x109},
- {0x10b, 0x10b}, {0x10d, 0x10d}, {0x10f, 0x10f}, {0x111, 0x111},
- {0x113, 0x113}, {0x115, 0x115}, {0x117, 0x117}, {0x119, 0x119},
- {0x11b, 0x11b}, {0x11d, 0x11d}, {0x11f, 0x11f}, {0x121, 0x121},
- {0x123, 0x123}, {0x125, 0x125}, {0x127, 0x127}, {0x129, 0x129},
- {0x12b, 0x12b}, {0x12d, 0x12d}, {0x12f, 0x12f}, {0x131, 0x131},
- {0x133, 0x133}, {0x135, 0x135}, {0x137, 0x138}, {0x13a, 0x13a},
- {0x13c, 0x13c}, {0x13e, 0x13e}, {0x140, 0x140}, {0x142, 0x142},
- {0x144, 0x144}, {0x146, 0x146}, {0x148, 0x149}, {0x14b, 0x14b},
- {0x14d, 0x14d}, {0x14f, 0x14f}, {0x151, 0x151}, {0x153, 0x153},
- {0x155, 0x155}, {0x157, 0x157}, {0x159, 0x159}, {0x15b, 0x15b},
- {0x15d, 0x15d}, {0x15f, 0x15f}, {0x161, 0x161}, {0x163, 0x163},
- {0x165, 0x165}, {0x167, 0x167}, {0x169, 0x169}, {0x16b, 0x16b},
- {0x16d, 0x16d}, {0x16f, 0x16f}, {0x171, 0x171}, {0x173, 0x173},
- {0x175, 0x175}, {0x177, 0x177}, {0x17a, 0x17a}, {0x17c, 0x17c},
- {0x17e, 0x180}, {0x183, 0x183}, {0x185, 0x185}, {0x188, 0x188},
- {0x18c, 0x18d}, {0x192, 0x192}, {0x195, 0x195}, {0x199, 0x19b},
- {0x19e, 0x19e}, {0x1a1, 0x1a1}, {0x1a3, 0x1a3}, {0x1a5, 0x1a5},
- {0x1a8, 0x1a8}, {0x1aa, 0x1ab}, {0x1ad, 0x1ad}, {0x1b0, 0x1b0},
- {0x1b4, 0x1b4}, {0x1b6, 0x1b6}, {0x1b9, 0x1ba}, {0x1bd, 0x1bf},
- {0x1c6, 0x1c6}, {0x1c9, 0x1c9}, {0x1cc, 0x1cc}, {0x1ce, 0x1ce},
- {0x1d0, 0x1d0}, {0x1d2, 0x1d2}, {0x1d4, 0x1d4}, {0x1d6, 0x1d6},
- {0x1d8, 0x1d8}, {0x1da, 0x1da}, {0x1dc, 0x1dd}, {0x1df, 0x1df},
- {0x1e1, 0x1e1}, {0x1e3, 0x1e3}, {0x1e5, 0x1e5}, {0x1e7, 0x1e7},
- {0x1e9, 0x1e9}, {0x1eb, 0x1eb}, {0x1ed, 0x1ed}, {0x1ef, 0x1f0},
- {0x1f3, 0x1f3}, {0x1f5, 0x1f5}, {0x1f9, 0x1f9}, {0x1fb, 0x1fb},
- {0x1fd, 0x1fd}, {0x1ff, 0x1ff}, {0x201, 0x201}, {0x203, 0x203},
- {0x205, 0x205}, {0x207, 0x207}, {0x209, 0x209}, {0x20b, 0x20b},
- {0x20d, 0x20d}, {0x20f, 0x20f}, {0x211, 0x211}, {0x213, 0x213},
- {0x215, 0x215}, {0x217, 0x217}, {0x219, 0x219}, {0x21b, 0x21b},
- {0x21d, 0x21d}, {0x21f, 0x21f}, {0x221, 0x221}, {0x223, 0x223},
- {0x225, 0x225}, {0x227, 0x227}, {0x229, 0x229}, {0x22b, 0x22b},
- {0x22d, 0x22d}, {0x22f, 0x22f}, {0x231, 0x231}, {0x233, 0x236},
- {0x250, 0x2af}, {0x390, 0x390}, {0x3ac, 0x3ce}, {0x3d0, 0x3d1},
- {0x3d5, 0x3d7}, {0x3d9, 0x3d9}, {0x3db, 0x3db}, {0x3dd, 0x3dd},
- {0x3df, 0x3df}, {0x3e1, 0x3e1}, {0x3e3, 0x3e3}, {0x3e5, 0x3e5},
- {0x3e7, 0x3e7}, {0x3e9, 0x3e9}, {0x3eb, 0x3eb}, {0x3ed, 0x3ed},
- {0x3ef, 0x3f3}, {0x3f5, 0x3f5}, {0x3f8, 0x3f8}, {0x3fb, 0x3fb},
- {0x430, 0x45f}, {0x461, 0x461}, {0x463, 0x463}, {0x465, 0x465},
- {0x467, 0x467}, {0x469, 0x469}, {0x46b, 0x46b}, {0x46d, 0x46d},
- {0x46f, 0x46f}, {0x471, 0x471}, {0x473, 0x473}, {0x475, 0x475},
- {0x477, 0x477}, {0x479, 0x479}, {0x47b, 0x47b}, {0x47d, 0x47d},
- {0x47f, 0x47f}, {0x481, 0x481}, {0x48b, 0x48b}, {0x48d, 0x48d},
- {0x48f, 0x48f}, {0x491, 0x491}, {0x493, 0x493}, {0x495, 0x495},
- {0x497, 0x497}, {0x499, 0x499}, {0x49b, 0x49b}, {0x49d, 0x49d},
- {0x49f, 0x49f}, {0x4a1, 0x4a1}, {0x4a3, 0x4a3}, {0x4a5, 0x4a5},
- {0x4a7, 0x4a7}, {0x4a9, 0x4a9}, {0x4ab, 0x4ab}, {0x4ad, 0x4ad},
- {0x4af, 0x4af}, {0x4b1, 0x4b1}, {0x4b3, 0x4b3}, {0x4b5, 0x4b5},
- {0x4b7, 0x4b7}, {0x4b9, 0x4b9}, {0x4bb, 0x4bb}, {0x4bd, 0x4bd},
- {0x4bf, 0x4bf}, {0x4c2, 0x4c2}, {0x4c4, 0x4c4}, {0x4c6, 0x4c6},
- {0x4c8, 0x4c8}, {0x4ca, 0x4ca}, {0x4cc, 0x4cc}, {0x4ce, 0x4ce},
- {0x4d1, 0x4d1}, {0x4d3, 0x4d3}, {0x4d5, 0x4d5}, {0x4d7, 0x4d7},
- {0x4d9, 0x4d9}, {0x4db, 0x4db}, {0x4dd, 0x4dd}, {0x4df, 0x4df},
- {0x4e1, 0x4e1}, {0x4e3, 0x4e3}, {0x4e5, 0x4e5}, {0x4e7, 0x4e7},
- {0x4e9, 0x4e9}, {0x4eb, 0x4eb}, {0x4ed, 0x4ed}, {0x4ef, 0x4ef},
- {0x4f1, 0x4f1}, {0x4f3, 0x4f3}, {0x4f5, 0x4f5}, {0x4f9, 0x4f9},
- {0x501, 0x501}, {0x503, 0x503}, {0x505, 0x505}, {0x507, 0x507},
- {0x509, 0x509}, {0x50b, 0x50b}, {0x50d, 0x50d}, {0x50f, 0x50f},
- {0x561, 0x587}, {0x1d00, 0x1d2b}, {0x1d62, 0x1d6b}, {0x1e01, 0x1e01},
- {0x1e03, 0x1e03}, {0x1e05, 0x1e05}, {0x1e07, 0x1e07}, {0x1e09, 0x1e09},
- {0x1e0b, 0x1e0b}, {0x1e0d, 0x1e0d}, {0x1e0f, 0x1e0f}, {0x1e11, 0x1e11},
- {0x1e13, 0x1e13}, {0x1e15, 0x1e15}, {0x1e17, 0x1e17}, {0x1e19, 0x1e19},
- {0x1e1b, 0x1e1b}, {0x1e1d, 0x1e1d}, {0x1e1f, 0x1e1f}, {0x1e21, 0x1e21},
- {0x1e23, 0x1e23}, {0x1e25, 0x1e25}, {0x1e27, 0x1e27}, {0x1e29, 0x1e29},
- {0x1e2b, 0x1e2b}, {0x1e2d, 0x1e2d}, {0x1e2f, 0x1e2f}, {0x1e31, 0x1e31},
- {0x1e33, 0x1e33}, {0x1e35, 0x1e35}, {0x1e37, 0x1e37}, {0x1e39, 0x1e39},
- {0x1e3b, 0x1e3b}, {0x1e3d, 0x1e3d}, {0x1e3f, 0x1e3f}, {0x1e41, 0x1e41},
- {0x1e43, 0x1e43}, {0x1e45, 0x1e45}, {0x1e47, 0x1e47}, {0x1e49, 0x1e49},
- {0x1e4b, 0x1e4b}, {0x1e4d, 0x1e4d}, {0x1e4f, 0x1e4f}, {0x1e51, 0x1e51},
- {0x1e53, 0x1e53}, {0x1e55, 0x1e55}, {0x1e57, 0x1e57}, {0x1e59, 0x1e59},
- {0x1e5b, 0x1e5b}, {0x1e5d, 0x1e5d}, {0x1e5f, 0x1e5f}, {0x1e61, 0x1e61},
- {0x1e63, 0x1e63}, {0x1e65, 0x1e65}, {0x1e67, 0x1e67}, {0x1e69, 0x1e69},
- {0x1e6b, 0x1e6b}, {0x1e6d, 0x1e6d}, {0x1e6f, 0x1e6f}, {0x1e71, 0x1e71},
- {0x1e73, 0x1e73}, {0x1e75, 0x1e75}, {0x1e77, 0x1e77}, {0x1e79, 0x1e79},
- {0x1e7b, 0x1e7b}, {0x1e7d, 0x1e7d}, {0x1e7f, 0x1e7f}, {0x1e81, 0x1e81},
- {0x1e83, 0x1e83}, {0x1e85, 0x1e85}, {0x1e87, 0x1e87}, {0x1e89, 0x1e89},
- {0x1e8b, 0x1e8b}, {0x1e8d, 0x1e8d}, {0x1e8f, 0x1e8f}, {0x1e91, 0x1e91},
- {0x1e93, 0x1e93}, {0x1e95, 0x1e9b}, {0x1ea1, 0x1ea1}, {0x1ea3, 0x1ea3},
- {0x1ea5, 0x1ea5}, {0x1ea7, 0x1ea7}, {0x1ea9, 0x1ea9}, {0x1eab, 0x1eab},
- {0x1ead, 0x1ead}, {0x1eaf, 0x1eaf}, {0x1eb1, 0x1eb1}, {0x1eb3, 0x1eb3},
- {0x1eb5, 0x1eb5}, {0x1eb7, 0x1eb7}, {0x1eb9, 0x1eb9}, {0x1ebb, 0x1ebb},
- {0x1ebd, 0x1ebd}, {0x1ebf, 0x1ebf}, {0x1ec1, 0x1ec1}, {0x1ec3, 0x1ec3},
- {0x1ec5, 0x1ec5}, {0x1ec7, 0x1ec7}, {0x1ec9, 0x1ec9}, {0x1ecb, 0x1ecb},
- {0x1ecd, 0x1ecd}, {0x1ecf, 0x1ecf}, {0x1ed1, 0x1ed1}, {0x1ed3, 0x1ed3},
- {0x1ed5, 0x1ed5}, {0x1ed7, 0x1ed7}, {0x1ed9, 0x1ed9}, {0x1edb, 0x1edb},
- {0x1edd, 0x1edd}, {0x1edf, 0x1edf}, {0x1ee1, 0x1ee1}, {0x1ee3, 0x1ee3},
- {0x1ee5, 0x1ee5}, {0x1ee7, 0x1ee7}, {0x1ee9, 0x1ee9}, {0x1eeb, 0x1eeb},
- {0x1eed, 0x1eed}, {0x1eef, 0x1eef}, {0x1ef1, 0x1ef1}, {0x1ef3, 0x1ef3},
- {0x1ef5, 0x1ef5}, {0x1ef7, 0x1ef7}, {0x1ef9, 0x1ef9}, {0x1f00, 0x1f07},
- {0x1f10, 0x1f15}, {0x1f20, 0x1f27}, {0x1f30, 0x1f37}, {0x1f40, 0x1f45},
- {0x1f50, 0x1f57}, {0x1f60, 0x1f67}, {0x1f70, 0x1f7d}, {0x1f80, 0x1f87},
- {0x1f90, 0x1f97}, {0x1fa0, 0x1fa7}, {0x1fb0, 0x1fb4}, {0x1fb6, 0x1fb7},
- {0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4}, {0x1fc6, 0x1fc7}, {0x1fd0, 0x1fd3},
- {0x1fd6, 0x1fd7}, {0x1fe0, 0x1fe7}, {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ff7},
- {0x2071, 0x2071}, {0x207f, 0x207f}, {0x210a, 0x210a}, {0x210e, 0x210f},
- {0x2113, 0x2113}, {0x212f, 0x212f}, {0x2134, 0x2134}, {0x2139, 0x2139},
- {0x213d, 0x213d}, {0x2146, 0x2149}, {0xfb00, 0xfb06}, {0xfb13, 0xfb17},
+static const xmlChSRange xmlLlS[] = {{0x61, 0x7a}, {0xaa, 0xaa},
+ {0xb5, 0xb5}, {0xba, 0xba}, {0xdf, 0xf6}, {0xf8, 0xff}, {0x101, 0x101},
+ {0x103, 0x103}, {0x105, 0x105}, {0x107, 0x107}, {0x109, 0x109},
+ {0x10b, 0x10b}, {0x10d, 0x10d}, {0x10f, 0x10f}, {0x111, 0x111},
+ {0x113, 0x113}, {0x115, 0x115}, {0x117, 0x117}, {0x119, 0x119},
+ {0x11b, 0x11b}, {0x11d, 0x11d}, {0x11f, 0x11f}, {0x121, 0x121},
+ {0x123, 0x123}, {0x125, 0x125}, {0x127, 0x127}, {0x129, 0x129},
+ {0x12b, 0x12b}, {0x12d, 0x12d}, {0x12f, 0x12f}, {0x131, 0x131},
+ {0x133, 0x133}, {0x135, 0x135}, {0x137, 0x138}, {0x13a, 0x13a},
+ {0x13c, 0x13c}, {0x13e, 0x13e}, {0x140, 0x140}, {0x142, 0x142},
+ {0x144, 0x144}, {0x146, 0x146}, {0x148, 0x149}, {0x14b, 0x14b},
+ {0x14d, 0x14d}, {0x14f, 0x14f}, {0x151, 0x151}, {0x153, 0x153},
+ {0x155, 0x155}, {0x157, 0x157}, {0x159, 0x159}, {0x15b, 0x15b},
+ {0x15d, 0x15d}, {0x15f, 0x15f}, {0x161, 0x161}, {0x163, 0x163},
+ {0x165, 0x165}, {0x167, 0x167}, {0x169, 0x169}, {0x16b, 0x16b},
+ {0x16d, 0x16d}, {0x16f, 0x16f}, {0x171, 0x171}, {0x173, 0x173},
+ {0x175, 0x175}, {0x177, 0x177}, {0x17a, 0x17a}, {0x17c, 0x17c},
+ {0x17e, 0x180}, {0x183, 0x183}, {0x185, 0x185}, {0x188, 0x188},
+ {0x18c, 0x18d}, {0x192, 0x192}, {0x195, 0x195}, {0x199, 0x19b},
+ {0x19e, 0x19e}, {0x1a1, 0x1a1}, {0x1a3, 0x1a3}, {0x1a5, 0x1a5},
+ {0x1a8, 0x1a8}, {0x1aa, 0x1ab}, {0x1ad, 0x1ad}, {0x1b0, 0x1b0},
+ {0x1b4, 0x1b4}, {0x1b6, 0x1b6}, {0x1b9, 0x1ba}, {0x1bd, 0x1bf},
+ {0x1c6, 0x1c6}, {0x1c9, 0x1c9}, {0x1cc, 0x1cc}, {0x1ce, 0x1ce},
+ {0x1d0, 0x1d0}, {0x1d2, 0x1d2}, {0x1d4, 0x1d4}, {0x1d6, 0x1d6},
+ {0x1d8, 0x1d8}, {0x1da, 0x1da}, {0x1dc, 0x1dd}, {0x1df, 0x1df},
+ {0x1e1, 0x1e1}, {0x1e3, 0x1e3}, {0x1e5, 0x1e5}, {0x1e7, 0x1e7},
+ {0x1e9, 0x1e9}, {0x1eb, 0x1eb}, {0x1ed, 0x1ed}, {0x1ef, 0x1f0},
+ {0x1f3, 0x1f3}, {0x1f5, 0x1f5}, {0x1f9, 0x1f9}, {0x1fb, 0x1fb},
+ {0x1fd, 0x1fd}, {0x1ff, 0x1ff}, {0x201, 0x201}, {0x203, 0x203},
+ {0x205, 0x205}, {0x207, 0x207}, {0x209, 0x209}, {0x20b, 0x20b},
+ {0x20d, 0x20d}, {0x20f, 0x20f}, {0x211, 0x211}, {0x213, 0x213},
+ {0x215, 0x215}, {0x217, 0x217}, {0x219, 0x219}, {0x21b, 0x21b},
+ {0x21d, 0x21d}, {0x21f, 0x21f}, {0x221, 0x221}, {0x223, 0x223},
+ {0x225, 0x225}, {0x227, 0x227}, {0x229, 0x229}, {0x22b, 0x22b},
+ {0x22d, 0x22d}, {0x22f, 0x22f}, {0x231, 0x231}, {0x233, 0x236},
+ {0x250, 0x2af}, {0x390, 0x390}, {0x3ac, 0x3ce}, {0x3d0, 0x3d1},
+ {0x3d5, 0x3d7}, {0x3d9, 0x3d9}, {0x3db, 0x3db}, {0x3dd, 0x3dd},
+ {0x3df, 0x3df}, {0x3e1, 0x3e1}, {0x3e3, 0x3e3}, {0x3e5, 0x3e5},
+ {0x3e7, 0x3e7}, {0x3e9, 0x3e9}, {0x3eb, 0x3eb}, {0x3ed, 0x3ed},
+ {0x3ef, 0x3f3}, {0x3f5, 0x3f5}, {0x3f8, 0x3f8}, {0x3fb, 0x3fb},
+ {0x430, 0x45f}, {0x461, 0x461}, {0x463, 0x463}, {0x465, 0x465},
+ {0x467, 0x467}, {0x469, 0x469}, {0x46b, 0x46b}, {0x46d, 0x46d},
+ {0x46f, 0x46f}, {0x471, 0x471}, {0x473, 0x473}, {0x475, 0x475},
+ {0x477, 0x477}, {0x479, 0x479}, {0x47b, 0x47b}, {0x47d, 0x47d},
+ {0x47f, 0x47f}, {0x481, 0x481}, {0x48b, 0x48b}, {0x48d, 0x48d},
+ {0x48f, 0x48f}, {0x491, 0x491}, {0x493, 0x493}, {0x495, 0x495},
+ {0x497, 0x497}, {0x499, 0x499}, {0x49b, 0x49b}, {0x49d, 0x49d},
+ {0x49f, 0x49f}, {0x4a1, 0x4a1}, {0x4a3, 0x4a3}, {0x4a5, 0x4a5},
+ {0x4a7, 0x4a7}, {0x4a9, 0x4a9}, {0x4ab, 0x4ab}, {0x4ad, 0x4ad},
+ {0x4af, 0x4af}, {0x4b1, 0x4b1}, {0x4b3, 0x4b3}, {0x4b5, 0x4b5},
+ {0x4b7, 0x4b7}, {0x4b9, 0x4b9}, {0x4bb, 0x4bb}, {0x4bd, 0x4bd},
+ {0x4bf, 0x4bf}, {0x4c2, 0x4c2}, {0x4c4, 0x4c4}, {0x4c6, 0x4c6},
+ {0x4c8, 0x4c8}, {0x4ca, 0x4ca}, {0x4cc, 0x4cc}, {0x4ce, 0x4ce},
+ {0x4d1, 0x4d1}, {0x4d3, 0x4d3}, {0x4d5, 0x4d5}, {0x4d7, 0x4d7},
+ {0x4d9, 0x4d9}, {0x4db, 0x4db}, {0x4dd, 0x4dd}, {0x4df, 0x4df},
+ {0x4e1, 0x4e1}, {0x4e3, 0x4e3}, {0x4e5, 0x4e5}, {0x4e7, 0x4e7},
+ {0x4e9, 0x4e9}, {0x4eb, 0x4eb}, {0x4ed, 0x4ed}, {0x4ef, 0x4ef},
+ {0x4f1, 0x4f1}, {0x4f3, 0x4f3}, {0x4f5, 0x4f5}, {0x4f9, 0x4f9},
+ {0x501, 0x501}, {0x503, 0x503}, {0x505, 0x505}, {0x507, 0x507},
+ {0x509, 0x509}, {0x50b, 0x50b}, {0x50d, 0x50d}, {0x50f, 0x50f},
+ {0x561, 0x587}, {0x1d00, 0x1d2b}, {0x1d62, 0x1d6b}, {0x1e01, 0x1e01},
+ {0x1e03, 0x1e03}, {0x1e05, 0x1e05}, {0x1e07, 0x1e07}, {0x1e09, 0x1e09},
+ {0x1e0b, 0x1e0b}, {0x1e0d, 0x1e0d}, {0x1e0f, 0x1e0f}, {0x1e11, 0x1e11},
+ {0x1e13, 0x1e13}, {0x1e15, 0x1e15}, {0x1e17, 0x1e17}, {0x1e19, 0x1e19},
+ {0x1e1b, 0x1e1b}, {0x1e1d, 0x1e1d}, {0x1e1f, 0x1e1f}, {0x1e21, 0x1e21},
+ {0x1e23, 0x1e23}, {0x1e25, 0x1e25}, {0x1e27, 0x1e27}, {0x1e29, 0x1e29},
+ {0x1e2b, 0x1e2b}, {0x1e2d, 0x1e2d}, {0x1e2f, 0x1e2f}, {0x1e31, 0x1e31},
+ {0x1e33, 0x1e33}, {0x1e35, 0x1e35}, {0x1e37, 0x1e37}, {0x1e39, 0x1e39},
+ {0x1e3b, 0x1e3b}, {0x1e3d, 0x1e3d}, {0x1e3f, 0x1e3f}, {0x1e41, 0x1e41},
+ {0x1e43, 0x1e43}, {0x1e45, 0x1e45}, {0x1e47, 0x1e47}, {0x1e49, 0x1e49},
+ {0x1e4b, 0x1e4b}, {0x1e4d, 0x1e4d}, {0x1e4f, 0x1e4f}, {0x1e51, 0x1e51},
+ {0x1e53, 0x1e53}, {0x1e55, 0x1e55}, {0x1e57, 0x1e57}, {0x1e59, 0x1e59},
+ {0x1e5b, 0x1e5b}, {0x1e5d, 0x1e5d}, {0x1e5f, 0x1e5f}, {0x1e61, 0x1e61},
+ {0x1e63, 0x1e63}, {0x1e65, 0x1e65}, {0x1e67, 0x1e67}, {0x1e69, 0x1e69},
+ {0x1e6b, 0x1e6b}, {0x1e6d, 0x1e6d}, {0x1e6f, 0x1e6f}, {0x1e71, 0x1e71},
+ {0x1e73, 0x1e73}, {0x1e75, 0x1e75}, {0x1e77, 0x1e77}, {0x1e79, 0x1e79},
+ {0x1e7b, 0x1e7b}, {0x1e7d, 0x1e7d}, {0x1e7f, 0x1e7f}, {0x1e81, 0x1e81},
+ {0x1e83, 0x1e83}, {0x1e85, 0x1e85}, {0x1e87, 0x1e87}, {0x1e89, 0x1e89},
+ {0x1e8b, 0x1e8b}, {0x1e8d, 0x1e8d}, {0x1e8f, 0x1e8f}, {0x1e91, 0x1e91},
+ {0x1e93, 0x1e93}, {0x1e95, 0x1e9b}, {0x1ea1, 0x1ea1}, {0x1ea3, 0x1ea3},
+ {0x1ea5, 0x1ea5}, {0x1ea7, 0x1ea7}, {0x1ea9, 0x1ea9}, {0x1eab, 0x1eab},
+ {0x1ead, 0x1ead}, {0x1eaf, 0x1eaf}, {0x1eb1, 0x1eb1}, {0x1eb3, 0x1eb3},
+ {0x1eb5, 0x1eb5}, {0x1eb7, 0x1eb7}, {0x1eb9, 0x1eb9}, {0x1ebb, 0x1ebb},
+ {0x1ebd, 0x1ebd}, {0x1ebf, 0x1ebf}, {0x1ec1, 0x1ec1}, {0x1ec3, 0x1ec3},
+ {0x1ec5, 0x1ec5}, {0x1ec7, 0x1ec7}, {0x1ec9, 0x1ec9}, {0x1ecb, 0x1ecb},
+ {0x1ecd, 0x1ecd}, {0x1ecf, 0x1ecf}, {0x1ed1, 0x1ed1}, {0x1ed3, 0x1ed3},
+ {0x1ed5, 0x1ed5}, {0x1ed7, 0x1ed7}, {0x1ed9, 0x1ed9}, {0x1edb, 0x1edb},
+ {0x1edd, 0x1edd}, {0x1edf, 0x1edf}, {0x1ee1, 0x1ee1}, {0x1ee3, 0x1ee3},
+ {0x1ee5, 0x1ee5}, {0x1ee7, 0x1ee7}, {0x1ee9, 0x1ee9}, {0x1eeb, 0x1eeb},
+ {0x1eed, 0x1eed}, {0x1eef, 0x1eef}, {0x1ef1, 0x1ef1}, {0x1ef3, 0x1ef3},
+ {0x1ef5, 0x1ef5}, {0x1ef7, 0x1ef7}, {0x1ef9, 0x1ef9}, {0x1f00, 0x1f07},
+ {0x1f10, 0x1f15}, {0x1f20, 0x1f27}, {0x1f30, 0x1f37}, {0x1f40, 0x1f45},
+ {0x1f50, 0x1f57}, {0x1f60, 0x1f67}, {0x1f70, 0x1f7d}, {0x1f80, 0x1f87},
+ {0x1f90, 0x1f97}, {0x1fa0, 0x1fa7}, {0x1fb0, 0x1fb4}, {0x1fb6, 0x1fb7},
+ {0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4}, {0x1fc6, 0x1fc7}, {0x1fd0, 0x1fd3},
+ {0x1fd6, 0x1fd7}, {0x1fe0, 0x1fe7}, {0x1ff2, 0x1ff4}, {0x1ff6, 0x1ff7},
+ {0x2071, 0x2071}, {0x207f, 0x207f}, {0x210a, 0x210a}, {0x210e, 0x210f},
+ {0x2113, 0x2113}, {0x212f, 0x212f}, {0x2134, 0x2134}, {0x2139, 0x2139},
+ {0x213d, 0x213d}, {0x2146, 0x2149}, {0xfb00, 0xfb06}, {0xfb13, 0xfb17},
{0xff41, 0xff5a} };
-static const xmlChLRange xmlLlL[] = {{0x10428, 0x1044f}, {0x1d41a, 0x1d433},
- {0x1d44e, 0x1d454}, {0x1d456, 0x1d467}, {0x1d482, 0x1d49b},
- {0x1d4b6, 0x1d4b9}, {0x1d4bb, 0x1d4bb}, {0x1d4bd, 0x1d4c3},
- {0x1d4c5, 0x1d4cf}, {0x1d4ea, 0x1d503}, {0x1d51e, 0x1d537},
- {0x1d552, 0x1d56b}, {0x1d586, 0x1d59f}, {0x1d5ba, 0x1d5d3},
- {0x1d5ee, 0x1d607}, {0x1d622, 0x1d63b}, {0x1d656, 0x1d66f},
- {0x1d68a, 0x1d6a3}, {0x1d6c2, 0x1d6da}, {0x1d6dc, 0x1d6e1},
- {0x1d6fc, 0x1d714}, {0x1d716, 0x1d71b}, {0x1d736, 0x1d74e},
- {0x1d750, 0x1d755}, {0x1d770, 0x1d788}, {0x1d78a, 0x1d78f},
+static const xmlChLRange xmlLlL[] = {{0x10428, 0x1044f}, {0x1d41a, 0x1d433},
+ {0x1d44e, 0x1d454}, {0x1d456, 0x1d467}, {0x1d482, 0x1d49b},
+ {0x1d4b6, 0x1d4b9}, {0x1d4bb, 0x1d4bb}, {0x1d4bd, 0x1d4c3},
+ {0x1d4c5, 0x1d4cf}, {0x1d4ea, 0x1d503}, {0x1d51e, 0x1d537},
+ {0x1d552, 0x1d56b}, {0x1d586, 0x1d59f}, {0x1d5ba, 0x1d5d3},
+ {0x1d5ee, 0x1d607}, {0x1d622, 0x1d63b}, {0x1d656, 0x1d66f},
+ {0x1d68a, 0x1d6a3}, {0x1d6c2, 0x1d6da}, {0x1d6dc, 0x1d6e1},
+ {0x1d6fc, 0x1d714}, {0x1d716, 0x1d71b}, {0x1d736, 0x1d74e},
+ {0x1d750, 0x1d755}, {0x1d770, 0x1d788}, {0x1d78a, 0x1d78f},
{0x1d7aa, 0x1d7c2}, {0x1d7c4, 0x1d7c9} };
static xmlChRangeGroup xmlLlG = {396,28,xmlLlS,xmlLlL};
-static const xmlChSRange xmlLmS[] = {{0x2b0, 0x2c1}, {0x2c6, 0x2d1},
- {0x2e0, 0x2e4}, {0x2ee, 0x2ee}, {0x37a, 0x37a}, {0x559, 0x559},
- {0x640, 0x640}, {0x6e5, 0x6e6}, {0xe46, 0xe46}, {0xec6, 0xec6},
- {0x17d7, 0x17d7}, {0x1843, 0x1843}, {0x1d2c, 0x1d61}, {0x3005, 0x3005},
- {0x3031, 0x3035}, {0x303b, 0x303b}, {0x309d, 0x309e}, {0x30fc, 0x30fe},
+static const xmlChSRange xmlLmS[] = {{0x2b0, 0x2c1}, {0x2c6, 0x2d1},
+ {0x2e0, 0x2e4}, {0x2ee, 0x2ee}, {0x37a, 0x37a}, {0x559, 0x559},
+ {0x640, 0x640}, {0x6e5, 0x6e6}, {0xe46, 0xe46}, {0xec6, 0xec6},
+ {0x17d7, 0x17d7}, {0x1843, 0x1843}, {0x1d2c, 0x1d61}, {0x3005, 0x3005},
+ {0x3031, 0x3035}, {0x303b, 0x303b}, {0x309d, 0x309e}, {0x30fc, 0x30fe},
{0xff70, 0xff70}, {0xff9e, 0xff9f} };
static xmlChRangeGroup xmlLmG = {20,0,xmlLmS,NULL};
-static const xmlChSRange xmlLoS[] = {{0x1bb, 0x1bb}, {0x1c0, 0x1c3},
- {0x5d0, 0x5ea}, {0x5f0, 0x5f2}, {0x621, 0x63a}, {0x641, 0x64a},
- {0x66e, 0x66f}, {0x671, 0x6d3}, {0x6d5, 0x6d5}, {0x6ee, 0x6ef},
- {0x6fa, 0x6fc}, {0x6ff, 0x6ff}, {0x710, 0x710}, {0x712, 0x72f},
- {0x74d, 0x74f}, {0x780, 0x7a5}, {0x7b1, 0x7b1}, {0x904, 0x939},
- {0x93d, 0x93d}, {0x950, 0x950}, {0x958, 0x961}, {0x985, 0x98c},
- {0x98f, 0x990}, {0x993, 0x9a8}, {0x9aa, 0x9b0}, {0x9b2, 0x9b2},
- {0x9b6, 0x9b9}, {0x9bd, 0x9bd}, {0x9dc, 0x9dd}, {0x9df, 0x9e1},
- {0x9f0, 0x9f1}, {0xa05, 0xa0a}, {0xa0f, 0xa10}, {0xa13, 0xa28},
- {0xa2a, 0xa30}, {0xa32, 0xa33}, {0xa35, 0xa36}, {0xa38, 0xa39},
- {0xa59, 0xa5c}, {0xa5e, 0xa5e}, {0xa72, 0xa74}, {0xa85, 0xa8d},
- {0xa8f, 0xa91}, {0xa93, 0xaa8}, {0xaaa, 0xab0}, {0xab2, 0xab3},
- {0xab5, 0xab9}, {0xabd, 0xabd}, {0xad0, 0xad0}, {0xae0, 0xae1},
- {0xb05, 0xb0c}, {0xb0f, 0xb10}, {0xb13, 0xb28}, {0xb2a, 0xb30},
- {0xb32, 0xb33}, {0xb35, 0xb39}, {0xb3d, 0xb3d}, {0xb5c, 0xb5d},
- {0xb5f, 0xb61}, {0xb71, 0xb71}, {0xb83, 0xb83}, {0xb85, 0xb8a},
- {0xb8e, 0xb90}, {0xb92, 0xb95}, {0xb99, 0xb9a}, {0xb9c, 0xb9c},
- {0xb9e, 0xb9f}, {0xba3, 0xba4}, {0xba8, 0xbaa}, {0xbae, 0xbb5},
- {0xbb7, 0xbb9}, {0xc05, 0xc0c}, {0xc0e, 0xc10}, {0xc12, 0xc28},
- {0xc2a, 0xc33}, {0xc35, 0xc39}, {0xc60, 0xc61}, {0xc85, 0xc8c},
- {0xc8e, 0xc90}, {0xc92, 0xca8}, {0xcaa, 0xcb3}, {0xcb5, 0xcb9},
- {0xcbd, 0xcbd}, {0xcde, 0xcde}, {0xce0, 0xce1}, {0xd05, 0xd0c},
- {0xd0e, 0xd10}, {0xd12, 0xd28}, {0xd2a, 0xd39}, {0xd60, 0xd61},
- {0xd85, 0xd96}, {0xd9a, 0xdb1}, {0xdb3, 0xdbb}, {0xdbd, 0xdbd},
- {0xdc0, 0xdc6}, {0xe01, 0xe30}, {0xe32, 0xe33}, {0xe40, 0xe45},
- {0xe81, 0xe82}, {0xe84, 0xe84}, {0xe87, 0xe88}, {0xe8a, 0xe8a},
- {0xe8d, 0xe8d}, {0xe94, 0xe97}, {0xe99, 0xe9f}, {0xea1, 0xea3},
- {0xea5, 0xea5}, {0xea7, 0xea7}, {0xeaa, 0xeab}, {0xead, 0xeb0},
- {0xeb2, 0xeb3}, {0xebd, 0xebd}, {0xec0, 0xec4}, {0xedc, 0xedd},
- {0xf00, 0xf00}, {0xf40, 0xf47}, {0xf49, 0xf6a}, {0xf88, 0xf8b},
- {0x1000, 0x1021}, {0x1023, 0x1027}, {0x1029, 0x102a}, {0x1050, 0x1055},
- {0x10d0, 0x10f8}, {0x1100, 0x1159}, {0x115f, 0x11a2}, {0x11a8, 0x11f9},
- {0x1200, 0x1206}, {0x1208, 0x1246}, {0x1248, 0x1248}, {0x124a, 0x124d},
- {0x1250, 0x1256}, {0x1258, 0x1258}, {0x125a, 0x125d}, {0x1260, 0x1286},
- {0x1288, 0x1288}, {0x128a, 0x128d}, {0x1290, 0x12ae}, {0x12b0, 0x12b0},
- {0x12b2, 0x12b5}, {0x12b8, 0x12be}, {0x12c0, 0x12c0}, {0x12c2, 0x12c5},
- {0x12c8, 0x12ce}, {0x12d0, 0x12d6}, {0x12d8, 0x12ee}, {0x12f0, 0x130e},
- {0x1310, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x131e}, {0x1320, 0x1346},
- {0x1348, 0x135a}, {0x13a0, 0x13f4}, {0x1401, 0x166c}, {0x166f, 0x1676},
- {0x1681, 0x169a}, {0x16a0, 0x16ea}, {0x1700, 0x170c}, {0x170e, 0x1711},
- {0x1720, 0x1731}, {0x1740, 0x1751}, {0x1760, 0x176c}, {0x176e, 0x1770},
- {0x1780, 0x17b3}, {0x17dc, 0x17dc}, {0x1820, 0x1842}, {0x1844, 0x1877},
- {0x1880, 0x18a8}, {0x1900, 0x191c}, {0x1950, 0x196d}, {0x1970, 0x1974},
- {0x2135, 0x2138}, {0x3006, 0x3006}, {0x303c, 0x303c}, {0x3041, 0x3096},
- {0x309f, 0x309f}, {0x30a1, 0x30fa}, {0x30ff, 0x30ff}, {0x3105, 0x312c},
- {0x3131, 0x318e}, {0x31a0, 0x31b7}, {0x31f0, 0x31ff}, {0x3400, 0x3400},
- {0x4db5, 0x4db5}, {0x4e00, 0x4e00}, {0x9fa5, 0x9fa5}, {0xa000, 0xa48c},
- {0xac00, 0xac00}, {0xd7a3, 0xd7a3}, {0xf900, 0xfa2d}, {0xfa30, 0xfa6a},
- {0xfb1d, 0xfb1d}, {0xfb1f, 0xfb28}, {0xfb2a, 0xfb36}, {0xfb38, 0xfb3c},
- {0xfb3e, 0xfb3e}, {0xfb40, 0xfb41}, {0xfb43, 0xfb44}, {0xfb46, 0xfbb1},
- {0xfbd3, 0xfd3d}, {0xfd50, 0xfd8f}, {0xfd92, 0xfdc7}, {0xfdf0, 0xfdfb},
- {0xfe70, 0xfe74}, {0xfe76, 0xfefc}, {0xff66, 0xff6f}, {0xff71, 0xff9d},
- {0xffa0, 0xffbe}, {0xffc2, 0xffc7}, {0xffca, 0xffcf}, {0xffd2, 0xffd7},
+static const xmlChSRange xmlLoS[] = {{0x1bb, 0x1bb}, {0x1c0, 0x1c3},
+ {0x5d0, 0x5ea}, {0x5f0, 0x5f2}, {0x621, 0x63a}, {0x641, 0x64a},
+ {0x66e, 0x66f}, {0x671, 0x6d3}, {0x6d5, 0x6d5}, {0x6ee, 0x6ef},
+ {0x6fa, 0x6fc}, {0x6ff, 0x6ff}, {0x710, 0x710}, {0x712, 0x72f},
+ {0x74d, 0x74f}, {0x780, 0x7a5}, {0x7b1, 0x7b1}, {0x904, 0x939},
+ {0x93d, 0x93d}, {0x950, 0x950}, {0x958, 0x961}, {0x985, 0x98c},
+ {0x98f, 0x990}, {0x993, 0x9a8}, {0x9aa, 0x9b0}, {0x9b2, 0x9b2},
+ {0x9b6, 0x9b9}, {0x9bd, 0x9bd}, {0x9dc, 0x9dd}, {0x9df, 0x9e1},
+ {0x9f0, 0x9f1}, {0xa05, 0xa0a}, {0xa0f, 0xa10}, {0xa13, 0xa28},
+ {0xa2a, 0xa30}, {0xa32, 0xa33}, {0xa35, 0xa36}, {0xa38, 0xa39},
+ {0xa59, 0xa5c}, {0xa5e, 0xa5e}, {0xa72, 0xa74}, {0xa85, 0xa8d},
+ {0xa8f, 0xa91}, {0xa93, 0xaa8}, {0xaaa, 0xab0}, {0xab2, 0xab3},
+ {0xab5, 0xab9}, {0xabd, 0xabd}, {0xad0, 0xad0}, {0xae0, 0xae1},
+ {0xb05, 0xb0c}, {0xb0f, 0xb10}, {0xb13, 0xb28}, {0xb2a, 0xb30},
+ {0xb32, 0xb33}, {0xb35, 0xb39}, {0xb3d, 0xb3d}, {0xb5c, 0xb5d},
+ {0xb5f, 0xb61}, {0xb71, 0xb71}, {0xb83, 0xb83}, {0xb85, 0xb8a},
+ {0xb8e, 0xb90}, {0xb92, 0xb95}, {0xb99, 0xb9a}, {0xb9c, 0xb9c},
+ {0xb9e, 0xb9f}, {0xba3, 0xba4}, {0xba8, 0xbaa}, {0xbae, 0xbb5},
+ {0xbb7, 0xbb9}, {0xc05, 0xc0c}, {0xc0e, 0xc10}, {0xc12, 0xc28},
+ {0xc2a, 0xc33}, {0xc35, 0xc39}, {0xc60, 0xc61}, {0xc85, 0xc8c},
+ {0xc8e, 0xc90}, {0xc92, 0xca8}, {0xcaa, 0xcb3}, {0xcb5, 0xcb9},
+ {0xcbd, 0xcbd}, {0xcde, 0xcde}, {0xce0, 0xce1}, {0xd05, 0xd0c},
+ {0xd0e, 0xd10}, {0xd12, 0xd28}, {0xd2a, 0xd39}, {0xd60, 0xd61},
+ {0xd85, 0xd96}, {0xd9a, 0xdb1}, {0xdb3, 0xdbb}, {0xdbd, 0xdbd},
+ {0xdc0, 0xdc6}, {0xe01, 0xe30}, {0xe32, 0xe33}, {0xe40, 0xe45},
+ {0xe81, 0xe82}, {0xe84, 0xe84}, {0xe87, 0xe88}, {0xe8a, 0xe8a},
+ {0xe8d, 0xe8d}, {0xe94, 0xe97}, {0xe99, 0xe9f}, {0xea1, 0xea3},
+ {0xea5, 0xea5}, {0xea7, 0xea7}, {0xeaa, 0xeab}, {0xead, 0xeb0},
+ {0xeb2, 0xeb3}, {0xebd, 0xebd}, {0xec0, 0xec4}, {0xedc, 0xedd},
+ {0xf00, 0xf00}, {0xf40, 0xf47}, {0xf49, 0xf6a}, {0xf88, 0xf8b},
+ {0x1000, 0x1021}, {0x1023, 0x1027}, {0x1029, 0x102a}, {0x1050, 0x1055},
+ {0x10d0, 0x10f8}, {0x1100, 0x1159}, {0x115f, 0x11a2}, {0x11a8, 0x11f9},
+ {0x1200, 0x1206}, {0x1208, 0x1246}, {0x1248, 0x1248}, {0x124a, 0x124d},
+ {0x1250, 0x1256}, {0x1258, 0x1258}, {0x125a, 0x125d}, {0x1260, 0x1286},
+ {0x1288, 0x1288}, {0x128a, 0x128d}, {0x1290, 0x12ae}, {0x12b0, 0x12b0},
+ {0x12b2, 0x12b5}, {0x12b8, 0x12be}, {0x12c0, 0x12c0}, {0x12c2, 0x12c5},
+ {0x12c8, 0x12ce}, {0x12d0, 0x12d6}, {0x12d8, 0x12ee}, {0x12f0, 0x130e},
+ {0x1310, 0x1310}, {0x1312, 0x1315}, {0x1318, 0x131e}, {0x1320, 0x1346},
+ {0x1348, 0x135a}, {0x13a0, 0x13f4}, {0x1401, 0x166c}, {0x166f, 0x1676},
+ {0x1681, 0x169a}, {0x16a0, 0x16ea}, {0x1700, 0x170c}, {0x170e, 0x1711},
+ {0x1720, 0x1731}, {0x1740, 0x1751}, {0x1760, 0x176c}, {0x176e, 0x1770},
+ {0x1780, 0x17b3}, {0x17dc, 0x17dc}, {0x1820, 0x1842}, {0x1844, 0x1877},
+ {0x1880, 0x18a8}, {0x1900, 0x191c}, {0x1950, 0x196d}, {0x1970, 0x1974},
+ {0x2135, 0x2138}, {0x3006, 0x3006}, {0x303c, 0x303c}, {0x3041, 0x3096},
+ {0x309f, 0x309f}, {0x30a1, 0x30fa}, {0x30ff, 0x30ff}, {0x3105, 0x312c},
+ {0x3131, 0x318e}, {0x31a0, 0x31b7}, {0x31f0, 0x31ff}, {0x3400, 0x3400},
+ {0x4db5, 0x4db5}, {0x4e00, 0x4e00}, {0x9fa5, 0x9fa5}, {0xa000, 0xa48c},
+ {0xac00, 0xac00}, {0xd7a3, 0xd7a3}, {0xf900, 0xfa2d}, {0xfa30, 0xfa6a},
+ {0xfb1d, 0xfb1d}, {0xfb1f, 0xfb28}, {0xfb2a, 0xfb36}, {0xfb38, 0xfb3c},
+ {0xfb3e, 0xfb3e}, {0xfb40, 0xfb41}, {0xfb43, 0xfb44}, {0xfb46, 0xfbb1},
+ {0xfbd3, 0xfd3d}, {0xfd50, 0xfd8f}, {0xfd92, 0xfdc7}, {0xfdf0, 0xfdfb},
+ {0xfe70, 0xfe74}, {0xfe76, 0xfefc}, {0xff66, 0xff6f}, {0xff71, 0xff9d},
+ {0xffa0, 0xffbe}, {0xffc2, 0xffc7}, {0xffca, 0xffcf}, {0xffd2, 0xffd7},
{0xffda, 0xffdc} };
-static const xmlChLRange xmlLoL[] = {{0x10000, 0x1000b}, {0x1000d, 0x10026},
- {0x10028, 0x1003a}, {0x1003c, 0x1003d}, {0x1003f, 0x1004d},
- {0x10050, 0x1005d}, {0x10080, 0x100fa}, {0x10300, 0x1031e},
- {0x10330, 0x10349}, {0x10380, 0x1039d}, {0x10450, 0x1049d},
- {0x10800, 0x10805}, {0x10808, 0x10808}, {0x1080a, 0x10835},
- {0x10837, 0x10838}, {0x1083c, 0x1083c}, {0x1083f, 0x1083f},
+static const xmlChLRange xmlLoL[] = {{0x10000, 0x1000b}, {0x1000d, 0x10026},
+ {0x10028, 0x1003a}, {0x1003c, 0x1003d}, {0x1003f, 0x1004d},
+ {0x10050, 0x1005d}, {0x10080, 0x100fa}, {0x10300, 0x1031e},
+ {0x10330, 0x10349}, {0x10380, 0x1039d}, {0x10450, 0x1049d},
+ {0x10800, 0x10805}, {0x10808, 0x10808}, {0x1080a, 0x10835},
+ {0x10837, 0x10838}, {0x1083c, 0x1083c}, {0x1083f, 0x1083f},
{0x20000, 0x20000}, {0x2a6d6, 0x2a6d6}, {0x2f800, 0x2fa1d} };
static xmlChRangeGroup xmlLoG = {211,20,xmlLoS,xmlLoL};
-static const xmlChSRange xmlLtS[] = {{0x1c5, 0x1c5}, {0x1c8, 0x1c8},
- {0x1cb, 0x1cb}, {0x1f2, 0x1f2}, {0x1f88, 0x1f8f}, {0x1f98, 0x1f9f},
+static const xmlChSRange xmlLtS[] = {{0x1c5, 0x1c5}, {0x1c8, 0x1c8},
+ {0x1cb, 0x1cb}, {0x1f2, 0x1f2}, {0x1f88, 0x1f8f}, {0x1f98, 0x1f9f},
{0x1fa8, 0x1faf}, {0x1fbc, 0x1fbc}, {0x1fcc, 0x1fcc}, {0x1ffc, 0x1ffc} };
static xmlChRangeGroup xmlLtG = {10,0,xmlLtS,NULL};
-static const xmlChSRange xmlLuS[] = {{0x41, 0x5a}, {0xc0, 0xd6},
- {0xd8, 0xde}, {0x100, 0x100}, {0x102, 0x102}, {0x104, 0x104},
- {0x106, 0x106}, {0x108, 0x108}, {0x10a, 0x10a}, {0x10c, 0x10c},
- {0x10e, 0x10e}, {0x110, 0x110}, {0x112, 0x112}, {0x114, 0x114},
- {0x116, 0x116}, {0x118, 0x118}, {0x11a, 0x11a}, {0x11c, 0x11c},
- {0x11e, 0x11e}, {0x120, 0x120}, {0x122, 0x122}, {0x124, 0x124},
- {0x126, 0x126}, {0x128, 0x128}, {0x12a, 0x12a}, {0x12c, 0x12c},
- {0x12e, 0x12e}, {0x130, 0x130}, {0x132, 0x132}, {0x134, 0x134},
- {0x136, 0x136}, {0x139, 0x139}, {0x13b, 0x13b}, {0x13d, 0x13d},
- {0x13f, 0x13f}, {0x141, 0x141}, {0x143, 0x143}, {0x145, 0x145},
- {0x147, 0x147}, {0x14a, 0x14a}, {0x14c, 0x14c}, {0x14e, 0x14e},
- {0x150, 0x150}, {0x152, 0x152}, {0x154, 0x154}, {0x156, 0x156},
- {0x158, 0x158}, {0x15a, 0x15a}, {0x15c, 0x15c}, {0x15e, 0x15e},
- {0x160, 0x160}, {0x162, 0x162}, {0x164, 0x164}, {0x166, 0x166},
- {0x168, 0x168}, {0x16a, 0x16a}, {0x16c, 0x16c}, {0x16e, 0x16e},
- {0x170, 0x170}, {0x172, 0x172}, {0x174, 0x174}, {0x176, 0x176},
- {0x178, 0x179}, {0x17b, 0x17b}, {0x17d, 0x17d}, {0x181, 0x182},
- {0x184, 0x184}, {0x186, 0x187}, {0x189, 0x18b}, {0x18e, 0x191},
- {0x193, 0x194}, {0x196, 0x198}, {0x19c, 0x19d}, {0x19f, 0x1a0},
- {0x1a2, 0x1a2}, {0x1a4, 0x1a4}, {0x1a6, 0x1a7}, {0x1a9, 0x1a9},
- {0x1ac, 0x1ac}, {0x1ae, 0x1af}, {0x1b1, 0x1b3}, {0x1b5, 0x1b5},
- {0x1b7, 0x1b8}, {0x1bc, 0x1bc}, {0x1c4, 0x1c4}, {0x1c7, 0x1c7},
- {0x1ca, 0x1ca}, {0x1cd, 0x1cd}, {0x1cf, 0x1cf}, {0x1d1, 0x1d1},
- {0x1d3, 0x1d3}, {0x1d5, 0x1d5}, {0x1d7, 0x1d7}, {0x1d9, 0x1d9},
- {0x1db, 0x1db}, {0x1de, 0x1de}, {0x1e0, 0x1e0}, {0x1e2, 0x1e2},
- {0x1e4, 0x1e4}, {0x1e6, 0x1e6}, {0x1e8, 0x1e8}, {0x1ea, 0x1ea},
- {0x1ec, 0x1ec}, {0x1ee, 0x1ee}, {0x1f1, 0x1f1}, {0x1f4, 0x1f4},
- {0x1f6, 0x1f8}, {0x1fa, 0x1fa}, {0x1fc, 0x1fc}, {0x1fe, 0x1fe},
- {0x200, 0x200}, {0x202, 0x202}, {0x204, 0x204}, {0x206, 0x206},
- {0x208, 0x208}, {0x20a, 0x20a}, {0x20c, 0x20c}, {0x20e, 0x20e},
- {0x210, 0x210}, {0x212, 0x212}, {0x214, 0x214}, {0x216, 0x216},
- {0x218, 0x218}, {0x21a, 0x21a}, {0x21c, 0x21c}, {0x21e, 0x21e},
- {0x220, 0x220}, {0x222, 0x222}, {0x224, 0x224}, {0x226, 0x226},
- {0x228, 0x228}, {0x22a, 0x22a}, {0x22c, 0x22c}, {0x22e, 0x22e},
- {0x230, 0x230}, {0x232, 0x232}, {0x386, 0x386}, {0x388, 0x38a},
- {0x38c, 0x38c}, {0x38e, 0x38f}, {0x391, 0x3a1}, {0x3a3, 0x3ab},
- {0x3d2, 0x3d4}, {0x3d8, 0x3d8}, {0x3da, 0x3da}, {0x3dc, 0x3dc},
- {0x3de, 0x3de}, {0x3e0, 0x3e0}, {0x3e2, 0x3e2}, {0x3e4, 0x3e4},
- {0x3e6, 0x3e6}, {0x3e8, 0x3e8}, {0x3ea, 0x3ea}, {0x3ec, 0x3ec},
- {0x3ee, 0x3ee}, {0x3f4, 0x3f4}, {0x3f7, 0x3f7}, {0x3f9, 0x3fa},
- {0x400, 0x42f}, {0x460, 0x460}, {0x462, 0x462}, {0x464, 0x464},
- {0x466, 0x466}, {0x468, 0x468}, {0x46a, 0x46a}, {0x46c, 0x46c},
- {0x46e, 0x46e}, {0x470, 0x470}, {0x472, 0x472}, {0x474, 0x474},
- {0x476, 0x476}, {0x478, 0x478}, {0x47a, 0x47a}, {0x47c, 0x47c},
- {0x47e, 0x47e}, {0x480, 0x480}, {0x48a, 0x48a}, {0x48c, 0x48c},
- {0x48e, 0x48e}, {0x490, 0x490}, {0x492, 0x492}, {0x494, 0x494},
- {0x496, 0x496}, {0x498, 0x498}, {0x49a, 0x49a}, {0x49c, 0x49c},
- {0x49e, 0x49e}, {0x4a0, 0x4a0}, {0x4a2, 0x4a2}, {0x4a4, 0x4a4},
- {0x4a6, 0x4a6}, {0x4a8, 0x4a8}, {0x4aa, 0x4aa}, {0x4ac, 0x4ac},
- {0x4ae, 0x4ae}, {0x4b0, 0x4b0}, {0x4b2, 0x4b2}, {0x4b4, 0x4b4},
- {0x4b6, 0x4b6}, {0x4b8, 0x4b8}, {0x4ba, 0x4ba}, {0x4bc, 0x4bc},
- {0x4be, 0x4be}, {0x4c0, 0x4c1}, {0x4c3, 0x4c3}, {0x4c5, 0x4c5},
- {0x4c7, 0x4c7}, {0x4c9, 0x4c9}, {0x4cb, 0x4cb}, {0x4cd, 0x4cd},
- {0x4d0, 0x4d0}, {0x4d2, 0x4d2}, {0x4d4, 0x4d4}, {0x4d6, 0x4d6},
- {0x4d8, 0x4d8}, {0x4da, 0x4da}, {0x4dc, 0x4dc}, {0x4de, 0x4de},
- {0x4e0, 0x4e0}, {0x4e2, 0x4e2}, {0x4e4, 0x4e4}, {0x4e6, 0x4e6},
- {0x4e8, 0x4e8}, {0x4ea, 0x4ea}, {0x4ec, 0x4ec}, {0x4ee, 0x4ee},
- {0x4f0, 0x4f0}, {0x4f2, 0x4f2}, {0x4f4, 0x4f4}, {0x4f8, 0x4f8},
- {0x500, 0x500}, {0x502, 0x502}, {0x504, 0x504}, {0x506, 0x506},
- {0x508, 0x508}, {0x50a, 0x50a}, {0x50c, 0x50c}, {0x50e, 0x50e},
- {0x531, 0x556}, {0x10a0, 0x10c5}, {0x1e00, 0x1e00}, {0x1e02, 0x1e02},
- {0x1e04, 0x1e04}, {0x1e06, 0x1e06}, {0x1e08, 0x1e08}, {0x1e0a, 0x1e0a},
- {0x1e0c, 0x1e0c}, {0x1e0e, 0x1e0e}, {0x1e10, 0x1e10}, {0x1e12, 0x1e12},
- {0x1e14, 0x1e14}, {0x1e16, 0x1e16}, {0x1e18, 0x1e18}, {0x1e1a, 0x1e1a},
- {0x1e1c, 0x1e1c}, {0x1e1e, 0x1e1e}, {0x1e20, 0x1e20}, {0x1e22, 0x1e22},
- {0x1e24, 0x1e24}, {0x1e26, 0x1e26}, {0x1e28, 0x1e28}, {0x1e2a, 0x1e2a},
- {0x1e2c, 0x1e2c}, {0x1e2e, 0x1e2e}, {0x1e30, 0x1e30}, {0x1e32, 0x1e32},
- {0x1e34, 0x1e34}, {0x1e36, 0x1e36}, {0x1e38, 0x1e38}, {0x1e3a, 0x1e3a},
- {0x1e3c, 0x1e3c}, {0x1e3e, 0x1e3e}, {0x1e40, 0x1e40}, {0x1e42, 0x1e42},
- {0x1e44, 0x1e44}, {0x1e46, 0x1e46}, {0x1e48, 0x1e48}, {0x1e4a, 0x1e4a},
- {0x1e4c, 0x1e4c}, {0x1e4e, 0x1e4e}, {0x1e50, 0x1e50}, {0x1e52, 0x1e52},
- {0x1e54, 0x1e54}, {0x1e56, 0x1e56}, {0x1e58, 0x1e58}, {0x1e5a, 0x1e5a},
- {0x1e5c, 0x1e5c}, {0x1e5e, 0x1e5e}, {0x1e60, 0x1e60}, {0x1e62, 0x1e62},
- {0x1e64, 0x1e64}, {0x1e66, 0x1e66}, {0x1e68, 0x1e68}, {0x1e6a, 0x1e6a},
- {0x1e6c, 0x1e6c}, {0x1e6e, 0x1e6e}, {0x1e70, 0x1e70}, {0x1e72, 0x1e72},
- {0x1e74, 0x1e74}, {0x1e76, 0x1e76}, {0x1e78, 0x1e78}, {0x1e7a, 0x1e7a},
- {0x1e7c, 0x1e7c}, {0x1e7e, 0x1e7e}, {0x1e80, 0x1e80}, {0x1e82, 0x1e82},
- {0x1e84, 0x1e84}, {0x1e86, 0x1e86}, {0x1e88, 0x1e88}, {0x1e8a, 0x1e8a},
- {0x1e8c, 0x1e8c}, {0x1e8e, 0x1e8e}, {0x1e90, 0x1e90}, {0x1e92, 0x1e92},
- {0x1e94, 0x1e94}, {0x1ea0, 0x1ea0}, {0x1ea2, 0x1ea2}, {0x1ea4, 0x1ea4},
- {0x1ea6, 0x1ea6}, {0x1ea8, 0x1ea8}, {0x1eaa, 0x1eaa}, {0x1eac, 0x1eac},
- {0x1eae, 0x1eae}, {0x1eb0, 0x1eb0}, {0x1eb2, 0x1eb2}, {0x1eb4, 0x1eb4},
- {0x1eb6, 0x1eb6}, {0x1eb8, 0x1eb8}, {0x1eba, 0x1eba}, {0x1ebc, 0x1ebc},
- {0x1ebe, 0x1ebe}, {0x1ec0, 0x1ec0}, {0x1ec2, 0x1ec2}, {0x1ec4, 0x1ec4},
- {0x1ec6, 0x1ec6}, {0x1ec8, 0x1ec8}, {0x1eca, 0x1eca}, {0x1ecc, 0x1ecc},
- {0x1ece, 0x1ece}, {0x1ed0, 0x1ed0}, {0x1ed2, 0x1ed2}, {0x1ed4, 0x1ed4},
- {0x1ed6, 0x1ed6}, {0x1ed8, 0x1ed8}, {0x1eda, 0x1eda}, {0x1edc, 0x1edc},
- {0x1ede, 0x1ede}, {0x1ee0, 0x1ee0}, {0x1ee2, 0x1ee2}, {0x1ee4, 0x1ee4},
- {0x1ee6, 0x1ee6}, {0x1ee8, 0x1ee8}, {0x1eea, 0x1eea}, {0x1eec, 0x1eec},
- {0x1eee, 0x1eee}, {0x1ef0, 0x1ef0}, {0x1ef2, 0x1ef2}, {0x1ef4, 0x1ef4},
- {0x1ef6, 0x1ef6}, {0x1ef8, 0x1ef8}, {0x1f08, 0x1f0f}, {0x1f18, 0x1f1d},
- {0x1f28, 0x1f2f}, {0x1f38, 0x1f3f}, {0x1f48, 0x1f4d}, {0x1f59, 0x1f59},
- {0x1f5b, 0x1f5b}, {0x1f5d, 0x1f5d}, {0x1f5f, 0x1f5f}, {0x1f68, 0x1f6f},
- {0x1fb8, 0x1fbb}, {0x1fc8, 0x1fcb}, {0x1fd8, 0x1fdb}, {0x1fe8, 0x1fec},
- {0x1ff8, 0x1ffb}, {0x2102, 0x2102}, {0x2107, 0x2107}, {0x210b, 0x210d},
- {0x2110, 0x2112}, {0x2115, 0x2115}, {0x2119, 0x211d}, {0x2124, 0x2124},
- {0x2126, 0x2126}, {0x2128, 0x2128}, {0x212a, 0x212d}, {0x2130, 0x2131},
+static const xmlChSRange xmlLuS[] = {{0x41, 0x5a}, {0xc0, 0xd6},
+ {0xd8, 0xde}, {0x100, 0x100}, {0x102, 0x102}, {0x104, 0x104},
+ {0x106, 0x106}, {0x108, 0x108}, {0x10a, 0x10a}, {0x10c, 0x10c},
+ {0x10e, 0x10e}, {0x110, 0x110}, {0x112, 0x112}, {0x114, 0x114},
+ {0x116, 0x116}, {0x118, 0x118}, {0x11a, 0x11a}, {0x11c, 0x11c},
+ {0x11e, 0x11e}, {0x120, 0x120}, {0x122, 0x122}, {0x124, 0x124},
+ {0x126, 0x126}, {0x128, 0x128}, {0x12a, 0x12a}, {0x12c, 0x12c},
+ {0x12e, 0x12e}, {0x130, 0x130}, {0x132, 0x132}, {0x134, 0x134},
+ {0x136, 0x136}, {0x139, 0x139}, {0x13b, 0x13b}, {0x13d, 0x13d},
+ {0x13f, 0x13f}, {0x141, 0x141}, {0x143, 0x143}, {0x145, 0x145},
+ {0x147, 0x147}, {0x14a, 0x14a}, {0x14c, 0x14c}, {0x14e, 0x14e},
+ {0x150, 0x150}, {0x152, 0x152}, {0x154, 0x154}, {0x156, 0x156},
+ {0x158, 0x158}, {0x15a, 0x15a}, {0x15c, 0x15c}, {0x15e, 0x15e},
+ {0x160, 0x160}, {0x162, 0x162}, {0x164, 0x164}, {0x166, 0x166},
+ {0x168, 0x168}, {0x16a, 0x16a}, {0x16c, 0x16c}, {0x16e, 0x16e},
+ {0x170, 0x170}, {0x172, 0x172}, {0x174, 0x174}, {0x176, 0x176},
+ {0x178, 0x179}, {0x17b, 0x17b}, {0x17d, 0x17d}, {0x181, 0x182},
+ {0x184, 0x184}, {0x186, 0x187}, {0x189, 0x18b}, {0x18e, 0x191},
+ {0x193, 0x194}, {0x196, 0x198}, {0x19c, 0x19d}, {0x19f, 0x1a0},
+ {0x1a2, 0x1a2}, {0x1a4, 0x1a4}, {0x1a6, 0x1a7}, {0x1a9, 0x1a9},
+ {0x1ac, 0x1ac}, {0x1ae, 0x1af}, {0x1b1, 0x1b3}, {0x1b5, 0x1b5},
+ {0x1b7, 0x1b8}, {0x1bc, 0x1bc}, {0x1c4, 0x1c4}, {0x1c7, 0x1c7},
+ {0x1ca, 0x1ca}, {0x1cd, 0x1cd}, {0x1cf, 0x1cf}, {0x1d1, 0x1d1},
+ {0x1d3, 0x1d3}, {0x1d5, 0x1d5}, {0x1d7, 0x1d7}, {0x1d9, 0x1d9},
+ {0x1db, 0x1db}, {0x1de, 0x1de}, {0x1e0, 0x1e0}, {0x1e2, 0x1e2},
+ {0x1e4, 0x1e4}, {0x1e6, 0x1e6}, {0x1e8, 0x1e8}, {0x1ea, 0x1ea},
+ {0x1ec, 0x1ec}, {0x1ee, 0x1ee}, {0x1f1, 0x1f1}, {0x1f4, 0x1f4},
+ {0x1f6, 0x1f8}, {0x1fa, 0x1fa}, {0x1fc, 0x1fc}, {0x1fe, 0x1fe},
+ {0x200, 0x200}, {0x202, 0x202}, {0x204, 0x204}, {0x206, 0x206},
+ {0x208, 0x208}, {0x20a, 0x20a}, {0x20c, 0x20c}, {0x20e, 0x20e},
+ {0x210, 0x210}, {0x212, 0x212}, {0x214, 0x214}, {0x216, 0x216},
+ {0x218, 0x218}, {0x21a, 0x21a}, {0x21c, 0x21c}, {0x21e, 0x21e},
+ {0x220, 0x220}, {0x222, 0x222}, {0x224, 0x224}, {0x226, 0x226},
+ {0x228, 0x228}, {0x22a, 0x22a}, {0x22c, 0x22c}, {0x22e, 0x22e},
+ {0x230, 0x230}, {0x232, 0x232}, {0x386, 0x386}, {0x388, 0x38a},
+ {0x38c, 0x38c}, {0x38e, 0x38f}, {0x391, 0x3a1}, {0x3a3, 0x3ab},
+ {0x3d2, 0x3d4}, {0x3d8, 0x3d8}, {0x3da, 0x3da}, {0x3dc, 0x3dc},
+ {0x3de, 0x3de}, {0x3e0, 0x3e0}, {0x3e2, 0x3e2}, {0x3e4, 0x3e4},
+ {0x3e6, 0x3e6}, {0x3e8, 0x3e8}, {0x3ea, 0x3ea}, {0x3ec, 0x3ec},
+ {0x3ee, 0x3ee}, {0x3f4, 0x3f4}, {0x3f7, 0x3f7}, {0x3f9, 0x3fa},
+ {0x400, 0x42f}, {0x460, 0x460}, {0x462, 0x462}, {0x464, 0x464},
+ {0x466, 0x466}, {0x468, 0x468}, {0x46a, 0x46a}, {0x46c, 0x46c},
+ {0x46e, 0x46e}, {0x470, 0x470}, {0x472, 0x472}, {0x474, 0x474},
+ {0x476, 0x476}, {0x478, 0x478}, {0x47a, 0x47a}, {0x47c, 0x47c},
+ {0x47e, 0x47e}, {0x480, 0x480}, {0x48a, 0x48a}, {0x48c, 0x48c},
+ {0x48e, 0x48e}, {0x490, 0x490}, {0x492, 0x492}, {0x494, 0x494},
+ {0x496, 0x496}, {0x498, 0x498}, {0x49a, 0x49a}, {0x49c, 0x49c},
+ {0x49e, 0x49e}, {0x4a0, 0x4a0}, {0x4a2, 0x4a2}, {0x4a4, 0x4a4},
+ {0x4a6, 0x4a6}, {0x4a8, 0x4a8}, {0x4aa, 0x4aa}, {0x4ac, 0x4ac},
+ {0x4ae, 0x4ae}, {0x4b0, 0x4b0}, {0x4b2, 0x4b2}, {0x4b4, 0x4b4},
+ {0x4b6, 0x4b6}, {0x4b8, 0x4b8}, {0x4ba, 0x4ba}, {0x4bc, 0x4bc},
+ {0x4be, 0x4be}, {0x4c0, 0x4c1}, {0x4c3, 0x4c3}, {0x4c5, 0x4c5},
+ {0x4c7, 0x4c7}, {0x4c9, 0x4c9}, {0x4cb, 0x4cb}, {0x4cd, 0x4cd},
+ {0x4d0, 0x4d0}, {0x4d2, 0x4d2}, {0x4d4, 0x4d4}, {0x4d6, 0x4d6},
+ {0x4d8, 0x4d8}, {0x4da, 0x4da}, {0x4dc, 0x4dc}, {0x4de, 0x4de},
+ {0x4e0, 0x4e0}, {0x4e2, 0x4e2}, {0x4e4, 0x4e4}, {0x4e6, 0x4e6},
+ {0x4e8, 0x4e8}, {0x4ea, 0x4ea}, {0x4ec, 0x4ec}, {0x4ee, 0x4ee},
+ {0x4f0, 0x4f0}, {0x4f2, 0x4f2}, {0x4f4, 0x4f4}, {0x4f8, 0x4f8},
+ {0x500, 0x500}, {0x502, 0x502}, {0x504, 0x504}, {0x506, 0x506},
+ {0x508, 0x508}, {0x50a, 0x50a}, {0x50c, 0x50c}, {0x50e, 0x50e},
+ {0x531, 0x556}, {0x10a0, 0x10c5}, {0x1e00, 0x1e00}, {0x1e02, 0x1e02},
+ {0x1e04, 0x1e04}, {0x1e06, 0x1e06}, {0x1e08, 0x1e08}, {0x1e0a, 0x1e0a},
+ {0x1e0c, 0x1e0c}, {0x1e0e, 0x1e0e}, {0x1e10, 0x1e10}, {0x1e12, 0x1e12},
+ {0x1e14, 0x1e14}, {0x1e16, 0x1e16}, {0x1e18, 0x1e18}, {0x1e1a, 0x1e1a},
+ {0x1e1c, 0x1e1c}, {0x1e1e, 0x1e1e}, {0x1e20, 0x1e20}, {0x1e22, 0x1e22},
+ {0x1e24, 0x1e24}, {0x1e26, 0x1e26}, {0x1e28, 0x1e28}, {0x1e2a, 0x1e2a},
+ {0x1e2c, 0x1e2c}, {0x1e2e, 0x1e2e}, {0x1e30, 0x1e30}, {0x1e32, 0x1e32},
+ {0x1e34, 0x1e34}, {0x1e36, 0x1e36}, {0x1e38, 0x1e38}, {0x1e3a, 0x1e3a},
+ {0x1e3c, 0x1e3c}, {0x1e3e, 0x1e3e}, {0x1e40, 0x1e40}, {0x1e42, 0x1e42},
+ {0x1e44, 0x1e44}, {0x1e46, 0x1e46}, {0x1e48, 0x1e48}, {0x1e4a, 0x1e4a},
+ {0x1e4c, 0x1e4c}, {0x1e4e, 0x1e4e}, {0x1e50, 0x1e50}, {0x1e52, 0x1e52},
+ {0x1e54, 0x1e54}, {0x1e56, 0x1e56}, {0x1e58, 0x1e58}, {0x1e5a, 0x1e5a},
+ {0x1e5c, 0x1e5c}, {0x1e5e, 0x1e5e}, {0x1e60, 0x1e60}, {0x1e62, 0x1e62},
+ {0x1e64, 0x1e64}, {0x1e66, 0x1e66}, {0x1e68, 0x1e68}, {0x1e6a, 0x1e6a},
+ {0x1e6c, 0x1e6c}, {0x1e6e, 0x1e6e}, {0x1e70, 0x1e70}, {0x1e72, 0x1e72},
+ {0x1e74, 0x1e74}, {0x1e76, 0x1e76}, {0x1e78, 0x1e78}, {0x1e7a, 0x1e7a},
+ {0x1e7c, 0x1e7c}, {0x1e7e, 0x1e7e}, {0x1e80, 0x1e80}, {0x1e82, 0x1e82},
+ {0x1e84, 0x1e84}, {0x1e86, 0x1e86}, {0x1e88, 0x1e88}, {0x1e8a, 0x1e8a},
+ {0x1e8c, 0x1e8c}, {0x1e8e, 0x1e8e}, {0x1e90, 0x1e90}, {0x1e92, 0x1e92},
+ {0x1e94, 0x1e94}, {0x1ea0, 0x1ea0}, {0x1ea2, 0x1ea2}, {0x1ea4, 0x1ea4},
+ {0x1ea6, 0x1ea6}, {0x1ea8, 0x1ea8}, {0x1eaa, 0x1eaa}, {0x1eac, 0x1eac},
+ {0x1eae, 0x1eae}, {0x1eb0, 0x1eb0}, {0x1eb2, 0x1eb2}, {0x1eb4, 0x1eb4},
+ {0x1eb6, 0x1eb6}, {0x1eb8, 0x1eb8}, {0x1eba, 0x1eba}, {0x1ebc, 0x1ebc},
+ {0x1ebe, 0x1ebe}, {0x1ec0, 0x1ec0}, {0x1ec2, 0x1ec2}, {0x1ec4, 0x1ec4},
+ {0x1ec6, 0x1ec6}, {0x1ec8, 0x1ec8}, {0x1eca, 0x1eca}, {0x1ecc, 0x1ecc},
+ {0x1ece, 0x1ece}, {0x1ed0, 0x1ed0}, {0x1ed2, 0x1ed2}, {0x1ed4, 0x1ed4},
+ {0x1ed6, 0x1ed6}, {0x1ed8, 0x1ed8}, {0x1eda, 0x1eda}, {0x1edc, 0x1edc},
+ {0x1ede, 0x1ede}, {0x1ee0, 0x1ee0}, {0x1ee2, 0x1ee2}, {0x1ee4, 0x1ee4},
+ {0x1ee6, 0x1ee6}, {0x1ee8, 0x1ee8}, {0x1eea, 0x1eea}, {0x1eec, 0x1eec},
+ {0x1eee, 0x1eee}, {0x1ef0, 0x1ef0}, {0x1ef2, 0x1ef2}, {0x1ef4, 0x1ef4},
+ {0x1ef6, 0x1ef6}, {0x1ef8, 0x1ef8}, {0x1f08, 0x1f0f}, {0x1f18, 0x1f1d},
+ {0x1f28, 0x1f2f}, {0x1f38, 0x1f3f}, {0x1f48, 0x1f4d}, {0x1f59, 0x1f59},
+ {0x1f5b, 0x1f5b}, {0x1f5d, 0x1f5d}, {0x1f5f, 0x1f5f}, {0x1f68, 0x1f6f},
+ {0x1fb8, 0x1fbb}, {0x1fc8, 0x1fcb}, {0x1fd8, 0x1fdb}, {0x1fe8, 0x1fec},
+ {0x1ff8, 0x1ffb}, {0x2102, 0x2102}, {0x2107, 0x2107}, {0x210b, 0x210d},
+ {0x2110, 0x2112}, {0x2115, 0x2115}, {0x2119, 0x211d}, {0x2124, 0x2124},
+ {0x2126, 0x2126}, {0x2128, 0x2128}, {0x212a, 0x212d}, {0x2130, 0x2131},
{0x2133, 0x2133}, {0x213e, 0x213f}, {0x2145, 0x2145}, {0xff21, 0xff3a} };
-static const xmlChLRange xmlLuL[] = {{0x10400, 0x10427}, {0x1d400, 0x1d419},
- {0x1d434, 0x1d44d}, {0x1d468, 0x1d481}, {0x1d49c, 0x1d49c},
- {0x1d49e, 0x1d49f}, {0x1d4a2, 0x1d4a2}, {0x1d4a5, 0x1d4a6},
- {0x1d4a9, 0x1d4ac}, {0x1d4ae, 0x1d4b5}, {0x1d4d0, 0x1d4e9},
- {0x1d504, 0x1d505}, {0x1d507, 0x1d50a}, {0x1d50d, 0x1d514},
- {0x1d516, 0x1d51c}, {0x1d538, 0x1d539}, {0x1d53b, 0x1d53e},
- {0x1d540, 0x1d544}, {0x1d546, 0x1d546}, {0x1d54a, 0x1d550},
- {0x1d56c, 0x1d585}, {0x1d5a0, 0x1d5b9}, {0x1d5d4, 0x1d5ed},
- {0x1d608, 0x1d621}, {0x1d63c, 0x1d655}, {0x1d670, 0x1d689},
- {0x1d6a8, 0x1d6c0}, {0x1d6e2, 0x1d6fa}, {0x1d71c, 0x1d734},
+static const xmlChLRange xmlLuL[] = {{0x10400, 0x10427}, {0x1d400, 0x1d419},
+ {0x1d434, 0x1d44d}, {0x1d468, 0x1d481}, {0x1d49c, 0x1d49c},
+ {0x1d49e, 0x1d49f}, {0x1d4a2, 0x1d4a2}, {0x1d4a5, 0x1d4a6},
+ {0x1d4a9, 0x1d4ac}, {0x1d4ae, 0x1d4b5}, {0x1d4d0, 0x1d4e9},
+ {0x1d504, 0x1d505}, {0x1d507, 0x1d50a}, {0x1d50d, 0x1d514},
+ {0x1d516, 0x1d51c}, {0x1d538, 0x1d539}, {0x1d53b, 0x1d53e},
+ {0x1d540, 0x1d544}, {0x1d546, 0x1d546}, {0x1d54a, 0x1d550},
+ {0x1d56c, 0x1d585}, {0x1d5a0, 0x1d5b9}, {0x1d5d4, 0x1d5ed},
+ {0x1d608, 0x1d621}, {0x1d63c, 0x1d655}, {0x1d670, 0x1d689},
+ {0x1d6a8, 0x1d6c0}, {0x1d6e2, 0x1d6fa}, {0x1d71c, 0x1d734},
{0x1d756, 0x1d76e}, {0x1d790, 0x1d7a8} };
static xmlChRangeGroup xmlLuG = {390,31,xmlLuS,xmlLuL};
-static const xmlChSRange xmlMS[] = {{0x300, 0x357}, {0x35d, 0x36f},
- {0x483, 0x486}, {0x488, 0x489}, {0x591, 0x5a1}, {0x5a3, 0x5b9},
- {0x5bb, 0x5bd}, {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c4},
- {0x610, 0x615}, {0x64b, 0x658}, {0x670, 0x670}, {0x6d6, 0x6dc},
- {0x6de, 0x6e4}, {0x6e7, 0x6e8}, {0x6ea, 0x6ed}, {0x711, 0x711},
- {0x730, 0x74a}, {0x7a6, 0x7b0}, {0x901, 0x903}, {0x93c, 0x93c},
- {0x93e, 0x94d}, {0x951, 0x954}, {0x962, 0x963}, {0x981, 0x983},
- {0x9bc, 0x9bc}, {0x9be, 0x9c4}, {0x9c7, 0x9c8}, {0x9cb, 0x9cd},
- {0x9d7, 0x9d7}, {0x9e2, 0x9e3}, {0xa01, 0xa03}, {0xa3c, 0xa3c},
- {0xa3e, 0xa42}, {0xa47, 0xa48}, {0xa4b, 0xa4d}, {0xa70, 0xa71},
- {0xa81, 0xa83}, {0xabc, 0xabc}, {0xabe, 0xac5}, {0xac7, 0xac9},
- {0xacb, 0xacd}, {0xae2, 0xae3}, {0xb01, 0xb03}, {0xb3c, 0xb3c},
- {0xb3e, 0xb43}, {0xb47, 0xb48}, {0xb4b, 0xb4d}, {0xb56, 0xb57},
- {0xb82, 0xb82}, {0xbbe, 0xbc2}, {0xbc6, 0xbc8}, {0xbca, 0xbcd},
- {0xbd7, 0xbd7}, {0xc01, 0xc03}, {0xc3e, 0xc44}, {0xc46, 0xc48},
- {0xc4a, 0xc4d}, {0xc55, 0xc56}, {0xc82, 0xc83}, {0xcbc, 0xcbc},
- {0xcbe, 0xcc4}, {0xcc6, 0xcc8}, {0xcca, 0xccd}, {0xcd5, 0xcd6},
- {0xd02, 0xd03}, {0xd3e, 0xd43}, {0xd46, 0xd48}, {0xd4a, 0xd4d},
- {0xd57, 0xd57}, {0xd82, 0xd83}, {0xdca, 0xdca}, {0xdcf, 0xdd4},
- {0xdd6, 0xdd6}, {0xdd8, 0xddf}, {0xdf2, 0xdf3}, {0xe31, 0xe31},
- {0xe34, 0xe3a}, {0xe47, 0xe4e}, {0xeb1, 0xeb1}, {0xeb4, 0xeb9},
- {0xebb, 0xebc}, {0xec8, 0xecd}, {0xf18, 0xf19}, {0xf35, 0xf35},
- {0xf37, 0xf37}, {0xf39, 0xf39}, {0xf3e, 0xf3f}, {0xf71, 0xf84},
- {0xf86, 0xf87}, {0xf90, 0xf97}, {0xf99, 0xfbc}, {0xfc6, 0xfc6},
- {0x102c, 0x1032}, {0x1036, 0x1039}, {0x1056, 0x1059}, {0x1712, 0x1714},
- {0x1732, 0x1734}, {0x1752, 0x1753}, {0x1772, 0x1773}, {0x17b6, 0x17d3},
- {0x17dd, 0x17dd}, {0x180b, 0x180d}, {0x18a9, 0x18a9}, {0x1920, 0x192b},
- {0x1930, 0x193b}, {0x20d0, 0x20ea}, {0x302a, 0x302f}, {0x3099, 0x309a},
+static const xmlChSRange xmlMS[] = {{0x300, 0x357}, {0x35d, 0x36f},
+ {0x483, 0x486}, {0x488, 0x489}, {0x591, 0x5a1}, {0x5a3, 0x5b9},
+ {0x5bb, 0x5bd}, {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c4},
+ {0x610, 0x615}, {0x64b, 0x658}, {0x670, 0x670}, {0x6d6, 0x6dc},
+ {0x6de, 0x6e4}, {0x6e7, 0x6e8}, {0x6ea, 0x6ed}, {0x711, 0x711},
+ {0x730, 0x74a}, {0x7a6, 0x7b0}, {0x901, 0x903}, {0x93c, 0x93c},
+ {0x93e, 0x94d}, {0x951, 0x954}, {0x962, 0x963}, {0x981, 0x983},
+ {0x9bc, 0x9bc}, {0x9be, 0x9c4}, {0x9c7, 0x9c8}, {0x9cb, 0x9cd},
+ {0x9d7, 0x9d7}, {0x9e2, 0x9e3}, {0xa01, 0xa03}, {0xa3c, 0xa3c},
+ {0xa3e, 0xa42}, {0xa47, 0xa48}, {0xa4b, 0xa4d}, {0xa70, 0xa71},
+ {0xa81, 0xa83}, {0xabc, 0xabc}, {0xabe, 0xac5}, {0xac7, 0xac9},
+ {0xacb, 0xacd}, {0xae2, 0xae3}, {0xb01, 0xb03}, {0xb3c, 0xb3c},
+ {0xb3e, 0xb43}, {0xb47, 0xb48}, {0xb4b, 0xb4d}, {0xb56, 0xb57},
+ {0xb82, 0xb82}, {0xbbe, 0xbc2}, {0xbc6, 0xbc8}, {0xbca, 0xbcd},
+ {0xbd7, 0xbd7}, {0xc01, 0xc03}, {0xc3e, 0xc44}, {0xc46, 0xc48},
+ {0xc4a, 0xc4d}, {0xc55, 0xc56}, {0xc82, 0xc83}, {0xcbc, 0xcbc},
+ {0xcbe, 0xcc4}, {0xcc6, 0xcc8}, {0xcca, 0xccd}, {0xcd5, 0xcd6},
+ {0xd02, 0xd03}, {0xd3e, 0xd43}, {0xd46, 0xd48}, {0xd4a, 0xd4d},
+ {0xd57, 0xd57}, {0xd82, 0xd83}, {0xdca, 0xdca}, {0xdcf, 0xdd4},
+ {0xdd6, 0xdd6}, {0xdd8, 0xddf}, {0xdf2, 0xdf3}, {0xe31, 0xe31},
+ {0xe34, 0xe3a}, {0xe47, 0xe4e}, {0xeb1, 0xeb1}, {0xeb4, 0xeb9},
+ {0xebb, 0xebc}, {0xec8, 0xecd}, {0xf18, 0xf19}, {0xf35, 0xf35},
+ {0xf37, 0xf37}, {0xf39, 0xf39}, {0xf3e, 0xf3f}, {0xf71, 0xf84},
+ {0xf86, 0xf87}, {0xf90, 0xf97}, {0xf99, 0xfbc}, {0xfc6, 0xfc6},
+ {0x102c, 0x1032}, {0x1036, 0x1039}, {0x1056, 0x1059}, {0x1712, 0x1714},
+ {0x1732, 0x1734}, {0x1752, 0x1753}, {0x1772, 0x1773}, {0x17b6, 0x17d3},
+ {0x17dd, 0x17dd}, {0x180b, 0x180d}, {0x18a9, 0x18a9}, {0x1920, 0x192b},
+ {0x1930, 0x193b}, {0x20d0, 0x20ea}, {0x302a, 0x302f}, {0x3099, 0x309a},
{0xfb1e, 0xfb1e}, {0xfe00, 0xfe0f}, {0xfe20, 0xfe23} };
-static const xmlChLRange xmlML[] = {{0x1d165, 0x1d169}, {0x1d16d, 0x1d172},
- {0x1d17b, 0x1d182}, {0x1d185, 0x1d18b}, {0x1d1aa, 0x1d1ad},
+static const xmlChLRange xmlML[] = {{0x1d165, 0x1d169}, {0x1d16d, 0x1d172},
+ {0x1d17b, 0x1d182}, {0x1d185, 0x1d18b}, {0x1d1aa, 0x1d1ad},
{0xe0100, 0xe01ef} };
static xmlChRangeGroup xmlMG = {113,6,xmlMS,xmlML};
-static const xmlChSRange xmlMcS[] = {{0x903, 0x903}, {0x93e, 0x940},
- {0x949, 0x94c}, {0x982, 0x983}, {0x9be, 0x9c0}, {0x9c7, 0x9c8},
- {0x9cb, 0x9cc}, {0x9d7, 0x9d7}, {0xa03, 0xa03}, {0xa3e, 0xa40},
- {0xa83, 0xa83}, {0xabe, 0xac0}, {0xac9, 0xac9}, {0xacb, 0xacc},
- {0xb02, 0xb03}, {0xb3e, 0xb3e}, {0xb40, 0xb40}, {0xb47, 0xb48},
- {0xb4b, 0xb4c}, {0xb57, 0xb57}, {0xbbe, 0xbbf}, {0xbc1, 0xbc2},
- {0xbc6, 0xbc8}, {0xbca, 0xbcc}, {0xbd7, 0xbd7}, {0xc01, 0xc03},
- {0xc41, 0xc44}, {0xc82, 0xc83}, {0xcbe, 0xcbe}, {0xcc0, 0xcc4},
- {0xcc7, 0xcc8}, {0xcca, 0xccb}, {0xcd5, 0xcd6}, {0xd02, 0xd03},
- {0xd3e, 0xd40}, {0xd46, 0xd48}, {0xd4a, 0xd4c}, {0xd57, 0xd57},
- {0xd82, 0xd83}, {0xdcf, 0xdd1}, {0xdd8, 0xddf}, {0xdf2, 0xdf3},
- {0xf3e, 0xf3f}, {0xf7f, 0xf7f}, {0x102c, 0x102c}, {0x1031, 0x1031},
- {0x1038, 0x1038}, {0x1056, 0x1057}, {0x17b6, 0x17b6}, {0x17be, 0x17c5},
- {0x17c7, 0x17c8}, {0x1923, 0x1926}, {0x1929, 0x192b}, {0x1930, 0x1931},
+static const xmlChSRange xmlMcS[] = {{0x903, 0x903}, {0x93e, 0x940},
+ {0x949, 0x94c}, {0x982, 0x983}, {0x9be, 0x9c0}, {0x9c7, 0x9c8},
+ {0x9cb, 0x9cc}, {0x9d7, 0x9d7}, {0xa03, 0xa03}, {0xa3e, 0xa40},
+ {0xa83, 0xa83}, {0xabe, 0xac0}, {0xac9, 0xac9}, {0xacb, 0xacc},
+ {0xb02, 0xb03}, {0xb3e, 0xb3e}, {0xb40, 0xb40}, {0xb47, 0xb48},
+ {0xb4b, 0xb4c}, {0xb57, 0xb57}, {0xbbe, 0xbbf}, {0xbc1, 0xbc2},
+ {0xbc6, 0xbc8}, {0xbca, 0xbcc}, {0xbd7, 0xbd7}, {0xc01, 0xc03},
+ {0xc41, 0xc44}, {0xc82, 0xc83}, {0xcbe, 0xcbe}, {0xcc0, 0xcc4},
+ {0xcc7, 0xcc8}, {0xcca, 0xccb}, {0xcd5, 0xcd6}, {0xd02, 0xd03},
+ {0xd3e, 0xd40}, {0xd46, 0xd48}, {0xd4a, 0xd4c}, {0xd57, 0xd57},
+ {0xd82, 0xd83}, {0xdcf, 0xdd1}, {0xdd8, 0xddf}, {0xdf2, 0xdf3},
+ {0xf3e, 0xf3f}, {0xf7f, 0xf7f}, {0x102c, 0x102c}, {0x1031, 0x1031},
+ {0x1038, 0x1038}, {0x1056, 0x1057}, {0x17b6, 0x17b6}, {0x17be, 0x17c5},
+ {0x17c7, 0x17c8}, {0x1923, 0x1926}, {0x1929, 0x192b}, {0x1930, 0x1931},
{0x1933, 0x1938} };
static const xmlChLRange xmlMcL[] = {{0x1d165, 0x1d166}, {0x1d16d, 0x1d172} };
static xmlChRangeGroup xmlMcG = {55,2,xmlMcS,xmlMcL};
-static const xmlChSRange xmlMnS[] = {{0x300, 0x357}, {0x35d, 0x36f},
- {0x483, 0x486}, {0x591, 0x5a1}, {0x5a3, 0x5b9}, {0x5bb, 0x5bd},
- {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c4}, {0x610, 0x615},
- {0x64b, 0x658}, {0x670, 0x670}, {0x6d6, 0x6dc}, {0x6df, 0x6e4},
- {0x6e7, 0x6e8}, {0x6ea, 0x6ed}, {0x711, 0x711}, {0x730, 0x74a},
- {0x7a6, 0x7b0}, {0x901, 0x902}, {0x93c, 0x93c}, {0x941, 0x948},
- {0x94d, 0x94d}, {0x951, 0x954}, {0x962, 0x963}, {0x981, 0x981},
- {0x9bc, 0x9bc}, {0x9c1, 0x9c4}, {0x9cd, 0x9cd}, {0x9e2, 0x9e3},
- {0xa01, 0xa02}, {0xa3c, 0xa3c}, {0xa41, 0xa42}, {0xa47, 0xa48},
- {0xa4b, 0xa4d}, {0xa70, 0xa71}, {0xa81, 0xa82}, {0xabc, 0xabc},
- {0xac1, 0xac5}, {0xac7, 0xac8}, {0xacd, 0xacd}, {0xae2, 0xae3},
- {0xb01, 0xb01}, {0xb3c, 0xb3c}, {0xb3f, 0xb3f}, {0xb41, 0xb43},
- {0xb4d, 0xb4d}, {0xb56, 0xb56}, {0xb82, 0xb82}, {0xbc0, 0xbc0},
- {0xbcd, 0xbcd}, {0xc3e, 0xc40}, {0xc46, 0xc48}, {0xc4a, 0xc4d},
- {0xc55, 0xc56}, {0xcbc, 0xcbc}, {0xcbf, 0xcbf}, {0xcc6, 0xcc6},
- {0xccc, 0xccd}, {0xd41, 0xd43}, {0xd4d, 0xd4d}, {0xdca, 0xdca},
- {0xdd2, 0xdd4}, {0xdd6, 0xdd6}, {0xe31, 0xe31}, {0xe34, 0xe3a},
- {0xe47, 0xe4e}, {0xeb1, 0xeb1}, {0xeb4, 0xeb9}, {0xebb, 0xebc},
- {0xec8, 0xecd}, {0xf18, 0xf19}, {0xf35, 0xf35}, {0xf37, 0xf37},
- {0xf39, 0xf39}, {0xf71, 0xf7e}, {0xf80, 0xf84}, {0xf86, 0xf87},
- {0xf90, 0xf97}, {0xf99, 0xfbc}, {0xfc6, 0xfc6}, {0x102d, 0x1030},
- {0x1032, 0x1032}, {0x1036, 0x1037}, {0x1039, 0x1039}, {0x1058, 0x1059},
- {0x1712, 0x1714}, {0x1732, 0x1734}, {0x1752, 0x1753}, {0x1772, 0x1773},
- {0x17b7, 0x17bd}, {0x17c6, 0x17c6}, {0x17c9, 0x17d3}, {0x17dd, 0x17dd},
- {0x180b, 0x180d}, {0x18a9, 0x18a9}, {0x1920, 0x1922}, {0x1927, 0x1928},
- {0x1932, 0x1932}, {0x1939, 0x193b}, {0x20d0, 0x20dc}, {0x20e1, 0x20e1},
- {0x20e5, 0x20ea}, {0x302a, 0x302f}, {0x3099, 0x309a}, {0xfb1e, 0xfb1e},
+static const xmlChSRange xmlMnS[] = {{0x300, 0x357}, {0x35d, 0x36f},
+ {0x483, 0x486}, {0x591, 0x5a1}, {0x5a3, 0x5b9}, {0x5bb, 0x5bd},
+ {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c4}, {0x610, 0x615},
+ {0x64b, 0x658}, {0x670, 0x670}, {0x6d6, 0x6dc}, {0x6df, 0x6e4},
+ {0x6e7, 0x6e8}, {0x6ea, 0x6ed}, {0x711, 0x711}, {0x730, 0x74a},
+ {0x7a6, 0x7b0}, {0x901, 0x902}, {0x93c, 0x93c}, {0x941, 0x948},
+ {0x94d, 0x94d}, {0x951, 0x954}, {0x962, 0x963}, {0x981, 0x981},
+ {0x9bc, 0x9bc}, {0x9c1, 0x9c4}, {0x9cd, 0x9cd}, {0x9e2, 0x9e3},
+ {0xa01, 0xa02}, {0xa3c, 0xa3c}, {0xa41, 0xa42}, {0xa47, 0xa48},
+ {0xa4b, 0xa4d}, {0xa70, 0xa71}, {0xa81, 0xa82}, {0xabc, 0xabc},
+ {0xac1, 0xac5}, {0xac7, 0xac8}, {0xacd, 0xacd}, {0xae2, 0xae3},
+ {0xb01, 0xb01}, {0xb3c, 0xb3c}, {0xb3f, 0xb3f}, {0xb41, 0xb43},
+ {0xb4d, 0xb4d}, {0xb56, 0xb56}, {0xb82, 0xb82}, {0xbc0, 0xbc0},
+ {0xbcd, 0xbcd}, {0xc3e, 0xc40}, {0xc46, 0xc48}, {0xc4a, 0xc4d},
+ {0xc55, 0xc56}, {0xcbc, 0xcbc}, {0xcbf, 0xcbf}, {0xcc6, 0xcc6},
+ {0xccc, 0xccd}, {0xd41, 0xd43}, {0xd4d, 0xd4d}, {0xdca, 0xdca},
+ {0xdd2, 0xdd4}, {0xdd6, 0xdd6}, {0xe31, 0xe31}, {0xe34, 0xe3a},
+ {0xe47, 0xe4e}, {0xeb1, 0xeb1}, {0xeb4, 0xeb9}, {0xebb, 0xebc},
+ {0xec8, 0xecd}, {0xf18, 0xf19}, {0xf35, 0xf35}, {0xf37, 0xf37},
+ {0xf39, 0xf39}, {0xf71, 0xf7e}, {0xf80, 0xf84}, {0xf86, 0xf87},
+ {0xf90, 0xf97}, {0xf99, 0xfbc}, {0xfc6, 0xfc6}, {0x102d, 0x1030},
+ {0x1032, 0x1032}, {0x1036, 0x1037}, {0x1039, 0x1039}, {0x1058, 0x1059},
+ {0x1712, 0x1714}, {0x1732, 0x1734}, {0x1752, 0x1753}, {0x1772, 0x1773},
+ {0x17b7, 0x17bd}, {0x17c6, 0x17c6}, {0x17c9, 0x17d3}, {0x17dd, 0x17dd},
+ {0x180b, 0x180d}, {0x18a9, 0x18a9}, {0x1920, 0x1922}, {0x1927, 0x1928},
+ {0x1932, 0x1932}, {0x1939, 0x193b}, {0x20d0, 0x20dc}, {0x20e1, 0x20e1},
+ {0x20e5, 0x20ea}, {0x302a, 0x302f}, {0x3099, 0x309a}, {0xfb1e, 0xfb1e},
{0xfe00, 0xfe0f}, {0xfe20, 0xfe23} };
-static const xmlChLRange xmlMnL[] = {{0x1d167, 0x1d169}, {0x1d17b, 0x1d182},
+static const xmlChLRange xmlMnL[] = {{0x1d167, 0x1d169}, {0x1d17b, 0x1d182},
{0x1d185, 0x1d18b}, {0x1d1aa, 0x1d1ad}, {0xe0100, 0xe01ef} };
static xmlChRangeGroup xmlMnG = {108,5,xmlMnS,xmlMnL};
-static const xmlChSRange xmlNS[] = {{0x30, 0x39}, {0xb2, 0xb3},
- {0xb9, 0xb9}, {0xbc, 0xbe}, {0x660, 0x669}, {0x6f0, 0x6f9},
- {0x966, 0x96f}, {0x9e6, 0x9ef}, {0x9f4, 0x9f9}, {0xa66, 0xa6f},
- {0xae6, 0xaef}, {0xb66, 0xb6f}, {0xbe7, 0xbf2}, {0xc66, 0xc6f},
- {0xce6, 0xcef}, {0xd66, 0xd6f}, {0xe50, 0xe59}, {0xed0, 0xed9},
- {0xf20, 0xf33}, {0x1040, 0x1049}, {0x1369, 0x137c}, {0x16ee, 0x16f0},
- {0x17e0, 0x17e9}, {0x17f0, 0x17f9}, {0x1810, 0x1819}, {0x1946, 0x194f},
- {0x2070, 0x2070}, {0x2074, 0x2079}, {0x2080, 0x2089}, {0x2153, 0x2183},
- {0x2460, 0x249b}, {0x24ea, 0x24ff}, {0x2776, 0x2793}, {0x3007, 0x3007},
- {0x3021, 0x3029}, {0x3038, 0x303a}, {0x3192, 0x3195}, {0x3220, 0x3229},
+static const xmlChSRange xmlNS[] = {{0x30, 0x39}, {0xb2, 0xb3},
+ {0xb9, 0xb9}, {0xbc, 0xbe}, {0x660, 0x669}, {0x6f0, 0x6f9},
+ {0x966, 0x96f}, {0x9e6, 0x9ef}, {0x9f4, 0x9f9}, {0xa66, 0xa6f},
+ {0xae6, 0xaef}, {0xb66, 0xb6f}, {0xbe7, 0xbf2}, {0xc66, 0xc6f},
+ {0xce6, 0xcef}, {0xd66, 0xd6f}, {0xe50, 0xe59}, {0xed0, 0xed9},
+ {0xf20, 0xf33}, {0x1040, 0x1049}, {0x1369, 0x137c}, {0x16ee, 0x16f0},
+ {0x17e0, 0x17e9}, {0x17f0, 0x17f9}, {0x1810, 0x1819}, {0x1946, 0x194f},
+ {0x2070, 0x2070}, {0x2074, 0x2079}, {0x2080, 0x2089}, {0x2153, 0x2183},
+ {0x2460, 0x249b}, {0x24ea, 0x24ff}, {0x2776, 0x2793}, {0x3007, 0x3007},
+ {0x3021, 0x3029}, {0x3038, 0x303a}, {0x3192, 0x3195}, {0x3220, 0x3229},
{0x3251, 0x325f}, {0x3280, 0x3289}, {0x32b1, 0x32bf}, {0xff10, 0xff19} };
-static const xmlChLRange xmlNL[] = {{0x10107, 0x10133}, {0x10320, 0x10323},
+static const xmlChLRange xmlNL[] = {{0x10107, 0x10133}, {0x10320, 0x10323},
{0x1034a, 0x1034a}, {0x104a0, 0x104a9}, {0x1d7ce, 0x1d7ff} };
static xmlChRangeGroup xmlNG = {42,5,xmlNS,xmlNL};
-static const xmlChSRange xmlNdS[] = {{0x30, 0x39}, {0x660, 0x669},
- {0x6f0, 0x6f9}, {0x966, 0x96f}, {0x9e6, 0x9ef}, {0xa66, 0xa6f},
- {0xae6, 0xaef}, {0xb66, 0xb6f}, {0xbe7, 0xbef}, {0xc66, 0xc6f},
- {0xce6, 0xcef}, {0xd66, 0xd6f}, {0xe50, 0xe59}, {0xed0, 0xed9},
- {0xf20, 0xf29}, {0x1040, 0x1049}, {0x1369, 0x1371}, {0x17e0, 0x17e9},
+static const xmlChSRange xmlNdS[] = {{0x30, 0x39}, {0x660, 0x669},
+ {0x6f0, 0x6f9}, {0x966, 0x96f}, {0x9e6, 0x9ef}, {0xa66, 0xa6f},
+ {0xae6, 0xaef}, {0xb66, 0xb6f}, {0xbe7, 0xbef}, {0xc66, 0xc6f},
+ {0xce6, 0xcef}, {0xd66, 0xd6f}, {0xe50, 0xe59}, {0xed0, 0xed9},
+ {0xf20, 0xf29}, {0x1040, 0x1049}, {0x1369, 0x1371}, {0x17e0, 0x17e9},
{0x1810, 0x1819}, {0x1946, 0x194f}, {0xff10, 0xff19} };
static const xmlChLRange xmlNdL[] = {{0x104a0, 0x104a9}, {0x1d7ce, 0x1d7ff} };
static xmlChRangeGroup xmlNdG = {21,2,xmlNdS,xmlNdL};
-static const xmlChSRange xmlNoS[] = {{0xb2, 0xb3}, {0xb9, 0xb9},
- {0xbc, 0xbe}, {0x9f4, 0x9f9}, {0xbf0, 0xbf2}, {0xf2a, 0xf33},
- {0x1372, 0x137c}, {0x17f0, 0x17f9}, {0x2070, 0x2070}, {0x2074, 0x2079},
- {0x2080, 0x2089}, {0x2153, 0x215f}, {0x2460, 0x249b}, {0x24ea, 0x24ff},
- {0x2776, 0x2793}, {0x3192, 0x3195}, {0x3220, 0x3229}, {0x3251, 0x325f},
+static const xmlChSRange xmlNoS[] = {{0xb2, 0xb3}, {0xb9, 0xb9},
+ {0xbc, 0xbe}, {0x9f4, 0x9f9}, {0xbf0, 0xbf2}, {0xf2a, 0xf33},
+ {0x1372, 0x137c}, {0x17f0, 0x17f9}, {0x2070, 0x2070}, {0x2074, 0x2079},
+ {0x2080, 0x2089}, {0x2153, 0x215f}, {0x2460, 0x249b}, {0x24ea, 0x24ff},
+ {0x2776, 0x2793}, {0x3192, 0x3195}, {0x3220, 0x3229}, {0x3251, 0x325f},
{0x3280, 0x3289}, {0x32b1, 0x32bf} };
static const xmlChLRange xmlNoL[] = {{0x10107, 0x10133}, {0x10320, 0x10323} };
static xmlChRangeGroup xmlNoG = {20,2,xmlNoS,xmlNoL};
-static const xmlChSRange xmlPS[] = {{0x21, 0x23}, {0x25, 0x2a},
- {0x2c, 0x2f}, {0x3a, 0x3b}, {0x3f, 0x40}, {0x5b, 0x5d}, {0x5f, 0x5f},
- {0x7b, 0x7b}, {0x7d, 0x7d}, {0xa1, 0xa1}, {0xab, 0xab}, {0xb7, 0xb7},
- {0xbb, 0xbb}, {0xbf, 0xbf}, {0x37e, 0x37e}, {0x387, 0x387},
- {0x55a, 0x55f}, {0x589, 0x58a}, {0x5be, 0x5be}, {0x5c0, 0x5c0},
- {0x5c3, 0x5c3}, {0x5f3, 0x5f4}, {0x60c, 0x60d}, {0x61b, 0x61b},
- {0x61f, 0x61f}, {0x66a, 0x66d}, {0x6d4, 0x6d4}, {0x700, 0x70d},
- {0x964, 0x965}, {0x970, 0x970}, {0xdf4, 0xdf4}, {0xe4f, 0xe4f},
- {0xe5a, 0xe5b}, {0xf04, 0xf12}, {0xf3a, 0xf3d}, {0xf85, 0xf85},
- {0x104a, 0x104f}, {0x10fb, 0x10fb}, {0x1361, 0x1368}, {0x166d, 0x166e},
- {0x169b, 0x169c}, {0x16eb, 0x16ed}, {0x1735, 0x1736}, {0x17d4, 0x17d6},
- {0x17d8, 0x17da}, {0x1800, 0x180a}, {0x1944, 0x1945}, {0x2010, 0x2027},
- {0x2030, 0x2043}, {0x2045, 0x2051}, {0x2053, 0x2054}, {0x2057, 0x2057},
- {0x207d, 0x207e}, {0x208d, 0x208e}, {0x2329, 0x232a}, {0x23b4, 0x23b6},
- {0x2768, 0x2775}, {0x27e6, 0x27eb}, {0x2983, 0x2998}, {0x29d8, 0x29db},
- {0x29fc, 0x29fd}, {0x3001, 0x3003}, {0x3008, 0x3011}, {0x3014, 0x301f},
- {0x3030, 0x3030}, {0x303d, 0x303d}, {0x30a0, 0x30a0}, {0x30fb, 0x30fb},
- {0xfd3e, 0xfd3f}, {0xfe30, 0xfe52}, {0xfe54, 0xfe61}, {0xfe63, 0xfe63},
- {0xfe68, 0xfe68}, {0xfe6a, 0xfe6b}, {0xff01, 0xff03}, {0xff05, 0xff0a},
- {0xff0c, 0xff0f}, {0xff1a, 0xff1b}, {0xff1f, 0xff20}, {0xff3b, 0xff3d},
+static const xmlChSRange xmlPS[] = {{0x21, 0x23}, {0x25, 0x2a},
+ {0x2c, 0x2f}, {0x3a, 0x3b}, {0x3f, 0x40}, {0x5b, 0x5d}, {0x5f, 0x5f},
+ {0x7b, 0x7b}, {0x7d, 0x7d}, {0xa1, 0xa1}, {0xab, 0xab}, {0xb7, 0xb7},
+ {0xbb, 0xbb}, {0xbf, 0xbf}, {0x37e, 0x37e}, {0x387, 0x387},
+ {0x55a, 0x55f}, {0x589, 0x58a}, {0x5be, 0x5be}, {0x5c0, 0x5c0},
+ {0x5c3, 0x5c3}, {0x5f3, 0x5f4}, {0x60c, 0x60d}, {0x61b, 0x61b},
+ {0x61f, 0x61f}, {0x66a, 0x66d}, {0x6d4, 0x6d4}, {0x700, 0x70d},
+ {0x964, 0x965}, {0x970, 0x970}, {0xdf4, 0xdf4}, {0xe4f, 0xe4f},
+ {0xe5a, 0xe5b}, {0xf04, 0xf12}, {0xf3a, 0xf3d}, {0xf85, 0xf85},
+ {0x104a, 0x104f}, {0x10fb, 0x10fb}, {0x1361, 0x1368}, {0x166d, 0x166e},
+ {0x169b, 0x169c}, {0x16eb, 0x16ed}, {0x1735, 0x1736}, {0x17d4, 0x17d6},
+ {0x17d8, 0x17da}, {0x1800, 0x180a}, {0x1944, 0x1945}, {0x2010, 0x2027},
+ {0x2030, 0x2043}, {0x2045, 0x2051}, {0x2053, 0x2054}, {0x2057, 0x2057},
+ {0x207d, 0x207e}, {0x208d, 0x208e}, {0x2329, 0x232a}, {0x23b4, 0x23b6},
+ {0x2768, 0x2775}, {0x27e6, 0x27eb}, {0x2983, 0x2998}, {0x29d8, 0x29db},
+ {0x29fc, 0x29fd}, {0x3001, 0x3003}, {0x3008, 0x3011}, {0x3014, 0x301f},
+ {0x3030, 0x3030}, {0x303d, 0x303d}, {0x30a0, 0x30a0}, {0x30fb, 0x30fb},
+ {0xfd3e, 0xfd3f}, {0xfe30, 0xfe52}, {0xfe54, 0xfe61}, {0xfe63, 0xfe63},
+ {0xfe68, 0xfe68}, {0xfe6a, 0xfe6b}, {0xff01, 0xff03}, {0xff05, 0xff0a},
+ {0xff0c, 0xff0f}, {0xff1a, 0xff1b}, {0xff1f, 0xff20}, {0xff3b, 0xff3d},
{0xff3f, 0xff3f}, {0xff5b, 0xff5b}, {0xff5d, 0xff5d}, {0xff5f, 0xff65} };
static const xmlChLRange xmlPL[] = {{0x10100, 0x10101}, {0x1039f, 0x1039f} };
static xmlChRangeGroup xmlPG = {84,2,xmlPS,xmlPL};
-static const xmlChSRange xmlPdS[] = {{0x2d, 0x2d}, {0x58a, 0x58a},
- {0x1806, 0x1806}, {0x2010, 0x2015}, {0x301c, 0x301c}, {0x3030, 0x3030},
- {0x30a0, 0x30a0}, {0xfe31, 0xfe32}, {0xfe58, 0xfe58}, {0xfe63, 0xfe63},
+static const xmlChSRange xmlPdS[] = {{0x2d, 0x2d}, {0x58a, 0x58a},
+ {0x1806, 0x1806}, {0x2010, 0x2015}, {0x301c, 0x301c}, {0x3030, 0x3030},
+ {0x30a0, 0x30a0}, {0xfe31, 0xfe32}, {0xfe58, 0xfe58}, {0xfe63, 0xfe63},
{0xff0d, 0xff0d} };
static xmlChRangeGroup xmlPdG = {11,0,xmlPdS,NULL};
-static const xmlChSRange xmlPeS[] = {{0x29, 0x29}, {0x5d, 0x5d},
- {0x7d, 0x7d}, {0xf3b, 0xf3b}, {0xf3d, 0xf3d}, {0x169c, 0x169c},
- {0x2046, 0x2046}, {0x207e, 0x207e}, {0x208e, 0x208e}, {0x232a, 0x232a},
- {0x23b5, 0x23b5}, {0x2769, 0x2769}, {0x276b, 0x276b}, {0x276d, 0x276d},
- {0x276f, 0x276f}, {0x2771, 0x2771}, {0x2773, 0x2773}, {0x2775, 0x2775},
- {0x27e7, 0x27e7}, {0x27e9, 0x27e9}, {0x27eb, 0x27eb}, {0x2984, 0x2984},
- {0x2986, 0x2986}, {0x2988, 0x2988}, {0x298a, 0x298a}, {0x298c, 0x298c},
- {0x298e, 0x298e}, {0x2990, 0x2990}, {0x2992, 0x2992}, {0x2994, 0x2994},
- {0x2996, 0x2996}, {0x2998, 0x2998}, {0x29d9, 0x29d9}, {0x29db, 0x29db},
- {0x29fd, 0x29fd}, {0x3009, 0x3009}, {0x300b, 0x300b}, {0x300d, 0x300d},
- {0x300f, 0x300f}, {0x3011, 0x3011}, {0x3015, 0x3015}, {0x3017, 0x3017},
- {0x3019, 0x3019}, {0x301b, 0x301b}, {0x301e, 0x301f}, {0xfd3f, 0xfd3f},
- {0xfe36, 0xfe36}, {0xfe38, 0xfe38}, {0xfe3a, 0xfe3a}, {0xfe3c, 0xfe3c},
- {0xfe3e, 0xfe3e}, {0xfe40, 0xfe40}, {0xfe42, 0xfe42}, {0xfe44, 0xfe44},
- {0xfe48, 0xfe48}, {0xfe5a, 0xfe5a}, {0xfe5c, 0xfe5c}, {0xfe5e, 0xfe5e},
- {0xff09, 0xff09}, {0xff3d, 0xff3d}, {0xff5d, 0xff5d}, {0xff60, 0xff60},
+static const xmlChSRange xmlPeS[] = {{0x29, 0x29}, {0x5d, 0x5d},
+ {0x7d, 0x7d}, {0xf3b, 0xf3b}, {0xf3d, 0xf3d}, {0x169c, 0x169c},
+ {0x2046, 0x2046}, {0x207e, 0x207e}, {0x208e, 0x208e}, {0x232a, 0x232a},
+ {0x23b5, 0x23b5}, {0x2769, 0x2769}, {0x276b, 0x276b}, {0x276d, 0x276d},
+ {0x276f, 0x276f}, {0x2771, 0x2771}, {0x2773, 0x2773}, {0x2775, 0x2775},
+ {0x27e7, 0x27e7}, {0x27e9, 0x27e9}, {0x27eb, 0x27eb}, {0x2984, 0x2984},
+ {0x2986, 0x2986}, {0x2988, 0x2988}, {0x298a, 0x298a}, {0x298c, 0x298c},
+ {0x298e, 0x298e}, {0x2990, 0x2990}, {0x2992, 0x2992}, {0x2994, 0x2994},
+ {0x2996, 0x2996}, {0x2998, 0x2998}, {0x29d9, 0x29d9}, {0x29db, 0x29db},
+ {0x29fd, 0x29fd}, {0x3009, 0x3009}, {0x300b, 0x300b}, {0x300d, 0x300d},
+ {0x300f, 0x300f}, {0x3011, 0x3011}, {0x3015, 0x3015}, {0x3017, 0x3017},
+ {0x3019, 0x3019}, {0x301b, 0x301b}, {0x301e, 0x301f}, {0xfd3f, 0xfd3f},
+ {0xfe36, 0xfe36}, {0xfe38, 0xfe38}, {0xfe3a, 0xfe3a}, {0xfe3c, 0xfe3c},
+ {0xfe3e, 0xfe3e}, {0xfe40, 0xfe40}, {0xfe42, 0xfe42}, {0xfe44, 0xfe44},
+ {0xfe48, 0xfe48}, {0xfe5a, 0xfe5a}, {0xfe5c, 0xfe5c}, {0xfe5e, 0xfe5e},
+ {0xff09, 0xff09}, {0xff3d, 0xff3d}, {0xff5d, 0xff5d}, {0xff60, 0xff60},
{0xff63, 0xff63} };
static xmlChRangeGroup xmlPeG = {63,0,xmlPeS,NULL};
-static const xmlChSRange xmlPoS[] = {{0x21, 0x23}, {0x25, 0x27},
- {0x2a, 0x2a}, {0x2c, 0x2c}, {0x2e, 0x2f}, {0x3a, 0x3b}, {0x3f, 0x40},
- {0x5c, 0x5c}, {0xa1, 0xa1}, {0xb7, 0xb7}, {0xbf, 0xbf}, {0x37e, 0x37e},
- {0x387, 0x387}, {0x55a, 0x55f}, {0x589, 0x589}, {0x5be, 0x5be},
- {0x5c0, 0x5c0}, {0x5c3, 0x5c3}, {0x5f3, 0x5f4}, {0x60c, 0x60d},
- {0x61b, 0x61b}, {0x61f, 0x61f}, {0x66a, 0x66d}, {0x6d4, 0x6d4},
- {0x700, 0x70d}, {0x964, 0x965}, {0x970, 0x970}, {0xdf4, 0xdf4},
- {0xe4f, 0xe4f}, {0xe5a, 0xe5b}, {0xf04, 0xf12}, {0xf85, 0xf85},
- {0x104a, 0x104f}, {0x10fb, 0x10fb}, {0x1361, 0x1368}, {0x166d, 0x166e},
- {0x16eb, 0x16ed}, {0x1735, 0x1736}, {0x17d4, 0x17d6}, {0x17d8, 0x17da},
- {0x1800, 0x1805}, {0x1807, 0x180a}, {0x1944, 0x1945}, {0x2016, 0x2017},
- {0x2020, 0x2027}, {0x2030, 0x2038}, {0x203b, 0x203e}, {0x2041, 0x2043},
- {0x2047, 0x2051}, {0x2053, 0x2053}, {0x2057, 0x2057}, {0x23b6, 0x23b6},
- {0x3001, 0x3003}, {0x303d, 0x303d}, {0xfe30, 0xfe30}, {0xfe45, 0xfe46},
- {0xfe49, 0xfe4c}, {0xfe50, 0xfe52}, {0xfe54, 0xfe57}, {0xfe5f, 0xfe61},
- {0xfe68, 0xfe68}, {0xfe6a, 0xfe6b}, {0xff01, 0xff03}, {0xff05, 0xff07},
- {0xff0a, 0xff0a}, {0xff0c, 0xff0c}, {0xff0e, 0xff0f}, {0xff1a, 0xff1b},
+static const xmlChSRange xmlPoS[] = {{0x21, 0x23}, {0x25, 0x27},
+ {0x2a, 0x2a}, {0x2c, 0x2c}, {0x2e, 0x2f}, {0x3a, 0x3b}, {0x3f, 0x40},
+ {0x5c, 0x5c}, {0xa1, 0xa1}, {0xb7, 0xb7}, {0xbf, 0xbf}, {0x37e, 0x37e},
+ {0x387, 0x387}, {0x55a, 0x55f}, {0x589, 0x589}, {0x5be, 0x5be},
+ {0x5c0, 0x5c0}, {0x5c3, 0x5c3}, {0x5f3, 0x5f4}, {0x60c, 0x60d},
+ {0x61b, 0x61b}, {0x61f, 0x61f}, {0x66a, 0x66d}, {0x6d4, 0x6d4},
+ {0x700, 0x70d}, {0x964, 0x965}, {0x970, 0x970}, {0xdf4, 0xdf4},
+ {0xe4f, 0xe4f}, {0xe5a, 0xe5b}, {0xf04, 0xf12}, {0xf85, 0xf85},
+ {0x104a, 0x104f}, {0x10fb, 0x10fb}, {0x1361, 0x1368}, {0x166d, 0x166e},
+ {0x16eb, 0x16ed}, {0x1735, 0x1736}, {0x17d4, 0x17d6}, {0x17d8, 0x17da},
+ {0x1800, 0x1805}, {0x1807, 0x180a}, {0x1944, 0x1945}, {0x2016, 0x2017},
+ {0x2020, 0x2027}, {0x2030, 0x2038}, {0x203b, 0x203e}, {0x2041, 0x2043},
+ {0x2047, 0x2051}, {0x2053, 0x2053}, {0x2057, 0x2057}, {0x23b6, 0x23b6},
+ {0x3001, 0x3003}, {0x303d, 0x303d}, {0xfe30, 0xfe30}, {0xfe45, 0xfe46},
+ {0xfe49, 0xfe4c}, {0xfe50, 0xfe52}, {0xfe54, 0xfe57}, {0xfe5f, 0xfe61},
+ {0xfe68, 0xfe68}, {0xfe6a, 0xfe6b}, {0xff01, 0xff03}, {0xff05, 0xff07},
+ {0xff0a, 0xff0a}, {0xff0c, 0xff0c}, {0xff0e, 0xff0f}, {0xff1a, 0xff1b},
{0xff1f, 0xff20}, {0xff3c, 0xff3c}, {0xff61, 0xff61}, {0xff64, 0xff64} };
static const xmlChLRange xmlPoL[] = {{0x10100, 0x10101}, {0x1039f, 0x1039f} };
static xmlChRangeGroup xmlPoG = {72,2,xmlPoS,xmlPoL};
-static const xmlChSRange xmlPsS[] = {{0x28, 0x28}, {0x5b, 0x5b},
- {0x7b, 0x7b}, {0xf3a, 0xf3a}, {0xf3c, 0xf3c}, {0x169b, 0x169b},
- {0x201a, 0x201a}, {0x201e, 0x201e}, {0x2045, 0x2045}, {0x207d, 0x207d},
- {0x208d, 0x208d}, {0x2329, 0x2329}, {0x23b4, 0x23b4}, {0x2768, 0x2768},
- {0x276a, 0x276a}, {0x276c, 0x276c}, {0x276e, 0x276e}, {0x2770, 0x2770},
- {0x2772, 0x2772}, {0x2774, 0x2774}, {0x27e6, 0x27e6}, {0x27e8, 0x27e8},
- {0x27ea, 0x27ea}, {0x2983, 0x2983}, {0x2985, 0x2985}, {0x2987, 0x2987},
- {0x2989, 0x2989}, {0x298b, 0x298b}, {0x298d, 0x298d}, {0x298f, 0x298f},
- {0x2991, 0x2991}, {0x2993, 0x2993}, {0x2995, 0x2995}, {0x2997, 0x2997},
- {0x29d8, 0x29d8}, {0x29da, 0x29da}, {0x29fc, 0x29fc}, {0x3008, 0x3008},
- {0x300a, 0x300a}, {0x300c, 0x300c}, {0x300e, 0x300e}, {0x3010, 0x3010},
- {0x3014, 0x3014}, {0x3016, 0x3016}, {0x3018, 0x3018}, {0x301a, 0x301a},
- {0x301d, 0x301d}, {0xfd3e, 0xfd3e}, {0xfe35, 0xfe35}, {0xfe37, 0xfe37},
- {0xfe39, 0xfe39}, {0xfe3b, 0xfe3b}, {0xfe3d, 0xfe3d}, {0xfe3f, 0xfe3f},
- {0xfe41, 0xfe41}, {0xfe43, 0xfe43}, {0xfe47, 0xfe47}, {0xfe59, 0xfe59},
- {0xfe5b, 0xfe5b}, {0xfe5d, 0xfe5d}, {0xff08, 0xff08}, {0xff3b, 0xff3b},
+static const xmlChSRange xmlPsS[] = {{0x28, 0x28}, {0x5b, 0x5b},
+ {0x7b, 0x7b}, {0xf3a, 0xf3a}, {0xf3c, 0xf3c}, {0x169b, 0x169b},
+ {0x201a, 0x201a}, {0x201e, 0x201e}, {0x2045, 0x2045}, {0x207d, 0x207d},
+ {0x208d, 0x208d}, {0x2329, 0x2329}, {0x23b4, 0x23b4}, {0x2768, 0x2768},
+ {0x276a, 0x276a}, {0x276c, 0x276c}, {0x276e, 0x276e}, {0x2770, 0x2770},
+ {0x2772, 0x2772}, {0x2774, 0x2774}, {0x27e6, 0x27e6}, {0x27e8, 0x27e8},
+ {0x27ea, 0x27ea}, {0x2983, 0x2983}, {0x2985, 0x2985}, {0x2987, 0x2987},
+ {0x2989, 0x2989}, {0x298b, 0x298b}, {0x298d, 0x298d}, {0x298f, 0x298f},
+ {0x2991, 0x2991}, {0x2993, 0x2993}, {0x2995, 0x2995}, {0x2997, 0x2997},
+ {0x29d8, 0x29d8}, {0x29da, 0x29da}, {0x29fc, 0x29fc}, {0x3008, 0x3008},
+ {0x300a, 0x300a}, {0x300c, 0x300c}, {0x300e, 0x300e}, {0x3010, 0x3010},
+ {0x3014, 0x3014}, {0x3016, 0x3016}, {0x3018, 0x3018}, {0x301a, 0x301a},
+ {0x301d, 0x301d}, {0xfd3e, 0xfd3e}, {0xfe35, 0xfe35}, {0xfe37, 0xfe37},
+ {0xfe39, 0xfe39}, {0xfe3b, 0xfe3b}, {0xfe3d, 0xfe3d}, {0xfe3f, 0xfe3f},
+ {0xfe41, 0xfe41}, {0xfe43, 0xfe43}, {0xfe47, 0xfe47}, {0xfe59, 0xfe59},
+ {0xfe5b, 0xfe5b}, {0xfe5d, 0xfe5d}, {0xff08, 0xff08}, {0xff3b, 0xff3b},
{0xff5b, 0xff5b}, {0xff5f, 0xff5f}, {0xff62, 0xff62} };
static xmlChRangeGroup xmlPsG = {65,0,xmlPsS,NULL};
-static const xmlChSRange xmlSS[] = {{0x24, 0x24}, {0x2b, 0x2b},
- {0x3c, 0x3e}, {0x5e, 0x5e}, {0x60, 0x60}, {0x7c, 0x7c}, {0x7e, 0x7e},
- {0xa2, 0xa9}, {0xac, 0xac}, {0xae, 0xb1}, {0xb4, 0xb4}, {0xb6, 0xb6},
- {0xb8, 0xb8}, {0xd7, 0xd7}, {0xf7, 0xf7}, {0x2c2, 0x2c5},
- {0x2d2, 0x2df}, {0x2e5, 0x2ed}, {0x2ef, 0x2ff}, {0x374, 0x375},
- {0x384, 0x385}, {0x3f6, 0x3f6}, {0x482, 0x482}, {0x60e, 0x60f},
- {0x6e9, 0x6e9}, {0x6fd, 0x6fe}, {0x9f2, 0x9f3}, {0x9fa, 0x9fa},
- {0xaf1, 0xaf1}, {0xb70, 0xb70}, {0xbf3, 0xbfa}, {0xe3f, 0xe3f},
- {0xf01, 0xf03}, {0xf13, 0xf17}, {0xf1a, 0xf1f}, {0xf34, 0xf34},
- {0xf36, 0xf36}, {0xf38, 0xf38}, {0xfbe, 0xfc5}, {0xfc7, 0xfcc},
- {0xfcf, 0xfcf}, {0x17db, 0x17db}, {0x1940, 0x1940}, {0x19e0, 0x19ff},
- {0x1fbd, 0x1fbd}, {0x1fbf, 0x1fc1}, {0x1fcd, 0x1fcf}, {0x1fdd, 0x1fdf},
- {0x1fed, 0x1fef}, {0x1ffd, 0x1ffe}, {0x2044, 0x2044}, {0x2052, 0x2052},
- {0x207a, 0x207c}, {0x208a, 0x208c}, {0x20a0, 0x20b1}, {0x2100, 0x2101},
- {0x2103, 0x2106}, {0x2108, 0x2109}, {0x2114, 0x2114}, {0x2116, 0x2118},
- {0x211e, 0x2123}, {0x2125, 0x2125}, {0x2127, 0x2127}, {0x2129, 0x2129},
- {0x212e, 0x212e}, {0x2132, 0x2132}, {0x213a, 0x213b}, {0x2140, 0x2144},
- {0x214a, 0x214b}, {0x2190, 0x2328}, {0x232b, 0x23b3}, {0x23b7, 0x23d0},
- {0x2400, 0x2426}, {0x2440, 0x244a}, {0x249c, 0x24e9}, {0x2500, 0x2617},
- {0x2619, 0x267d}, {0x2680, 0x2691}, {0x26a0, 0x26a1}, {0x2701, 0x2704},
- {0x2706, 0x2709}, {0x270c, 0x2727}, {0x2729, 0x274b}, {0x274d, 0x274d},
- {0x274f, 0x2752}, {0x2756, 0x2756}, {0x2758, 0x275e}, {0x2761, 0x2767},
- {0x2794, 0x2794}, {0x2798, 0x27af}, {0x27b1, 0x27be}, {0x27d0, 0x27e5},
- {0x27f0, 0x2982}, {0x2999, 0x29d7}, {0x29dc, 0x29fb}, {0x29fe, 0x2b0d},
- {0x2e80, 0x2e99}, {0x2e9b, 0x2ef3}, {0x2f00, 0x2fd5}, {0x2ff0, 0x2ffb},
- {0x3004, 0x3004}, {0x3012, 0x3013}, {0x3020, 0x3020}, {0x3036, 0x3037},
- {0x303e, 0x303f}, {0x309b, 0x309c}, {0x3190, 0x3191}, {0x3196, 0x319f},
- {0x3200, 0x321e}, {0x322a, 0x3243}, {0x3250, 0x3250}, {0x3260, 0x327d},
- {0x327f, 0x327f}, {0x328a, 0x32b0}, {0x32c0, 0x32fe}, {0x3300, 0x33ff},
- {0x4dc0, 0x4dff}, {0xa490, 0xa4c6}, {0xfb29, 0xfb29}, {0xfdfc, 0xfdfd},
- {0xfe62, 0xfe62}, {0xfe64, 0xfe66}, {0xfe69, 0xfe69}, {0xff04, 0xff04},
- {0xff0b, 0xff0b}, {0xff1c, 0xff1e}, {0xff3e, 0xff3e}, {0xff40, 0xff40},
- {0xff5c, 0xff5c}, {0xff5e, 0xff5e}, {0xffe0, 0xffe6}, {0xffe8, 0xffee},
+static const xmlChSRange xmlSS[] = {{0x24, 0x24}, {0x2b, 0x2b},
+ {0x3c, 0x3e}, {0x5e, 0x5e}, {0x60, 0x60}, {0x7c, 0x7c}, {0x7e, 0x7e},
+ {0xa2, 0xa9}, {0xac, 0xac}, {0xae, 0xb1}, {0xb4, 0xb4}, {0xb6, 0xb6},
+ {0xb8, 0xb8}, {0xd7, 0xd7}, {0xf7, 0xf7}, {0x2c2, 0x2c5},
+ {0x2d2, 0x2df}, {0x2e5, 0x2ed}, {0x2ef, 0x2ff}, {0x374, 0x375},
+ {0x384, 0x385}, {0x3f6, 0x3f6}, {0x482, 0x482}, {0x60e, 0x60f},
+ {0x6e9, 0x6e9}, {0x6fd, 0x6fe}, {0x9f2, 0x9f3}, {0x9fa, 0x9fa},
+ {0xaf1, 0xaf1}, {0xb70, 0xb70}, {0xbf3, 0xbfa}, {0xe3f, 0xe3f},
+ {0xf01, 0xf03}, {0xf13, 0xf17}, {0xf1a, 0xf1f}, {0xf34, 0xf34},
+ {0xf36, 0xf36}, {0xf38, 0xf38}, {0xfbe, 0xfc5}, {0xfc7, 0xfcc},
+ {0xfcf, 0xfcf}, {0x17db, 0x17db}, {0x1940, 0x1940}, {0x19e0, 0x19ff},
+ {0x1fbd, 0x1fbd}, {0x1fbf, 0x1fc1}, {0x1fcd, 0x1fcf}, {0x1fdd, 0x1fdf},
+ {0x1fed, 0x1fef}, {0x1ffd, 0x1ffe}, {0x2044, 0x2044}, {0x2052, 0x2052},
+ {0x207a, 0x207c}, {0x208a, 0x208c}, {0x20a0, 0x20b1}, {0x2100, 0x2101},
+ {0x2103, 0x2106}, {0x2108, 0x2109}, {0x2114, 0x2114}, {0x2116, 0x2118},
+ {0x211e, 0x2123}, {0x2125, 0x2125}, {0x2127, 0x2127}, {0x2129, 0x2129},
+ {0x212e, 0x212e}, {0x2132, 0x2132}, {0x213a, 0x213b}, {0x2140, 0x2144},
+ {0x214a, 0x214b}, {0x2190, 0x2328}, {0x232b, 0x23b3}, {0x23b7, 0x23d0},
+ {0x2400, 0x2426}, {0x2440, 0x244a}, {0x249c, 0x24e9}, {0x2500, 0x2617},
+ {0x2619, 0x267d}, {0x2680, 0x2691}, {0x26a0, 0x26a1}, {0x2701, 0x2704},
+ {0x2706, 0x2709}, {0x270c, 0x2727}, {0x2729, 0x274b}, {0x274d, 0x274d},
+ {0x274f, 0x2752}, {0x2756, 0x2756}, {0x2758, 0x275e}, {0x2761, 0x2767},
+ {0x2794, 0x2794}, {0x2798, 0x27af}, {0x27b1, 0x27be}, {0x27d0, 0x27e5},
+ {0x27f0, 0x2982}, {0x2999, 0x29d7}, {0x29dc, 0x29fb}, {0x29fe, 0x2b0d},
+ {0x2e80, 0x2e99}, {0x2e9b, 0x2ef3}, {0x2f00, 0x2fd5}, {0x2ff0, 0x2ffb},
+ {0x3004, 0x3004}, {0x3012, 0x3013}, {0x3020, 0x3020}, {0x3036, 0x3037},
+ {0x303e, 0x303f}, {0x309b, 0x309c}, {0x3190, 0x3191}, {0x3196, 0x319f},
+ {0x3200, 0x321e}, {0x322a, 0x3243}, {0x3250, 0x3250}, {0x3260, 0x327d},
+ {0x327f, 0x327f}, {0x328a, 0x32b0}, {0x32c0, 0x32fe}, {0x3300, 0x33ff},
+ {0x4dc0, 0x4dff}, {0xa490, 0xa4c6}, {0xfb29, 0xfb29}, {0xfdfc, 0xfdfd},
+ {0xfe62, 0xfe62}, {0xfe64, 0xfe66}, {0xfe69, 0xfe69}, {0xff04, 0xff04},
+ {0xff0b, 0xff0b}, {0xff1c, 0xff1e}, {0xff3e, 0xff3e}, {0xff40, 0xff40},
+ {0xff5c, 0xff5c}, {0xff5e, 0xff5e}, {0xffe0, 0xffe6}, {0xffe8, 0xffee},
{0xfffc, 0xfffd} };
-static const xmlChLRange xmlSL[] = {{0x10102, 0x10102}, {0x10137, 0x1013f},
- {0x1d000, 0x1d0f5}, {0x1d100, 0x1d126}, {0x1d12a, 0x1d164},
- {0x1d16a, 0x1d16c}, {0x1d183, 0x1d184}, {0x1d18c, 0x1d1a9},
- {0x1d1ae, 0x1d1dd}, {0x1d300, 0x1d356}, {0x1d6c1, 0x1d6c1},
- {0x1d6db, 0x1d6db}, {0x1d6fb, 0x1d6fb}, {0x1d715, 0x1d715},
- {0x1d735, 0x1d735}, {0x1d74f, 0x1d74f}, {0x1d76f, 0x1d76f},
+static const xmlChLRange xmlSL[] = {{0x10102, 0x10102}, {0x10137, 0x1013f},
+ {0x1d000, 0x1d0f5}, {0x1d100, 0x1d126}, {0x1d12a, 0x1d164},
+ {0x1d16a, 0x1d16c}, {0x1d183, 0x1d184}, {0x1d18c, 0x1d1a9},
+ {0x1d1ae, 0x1d1dd}, {0x1d300, 0x1d356}, {0x1d6c1, 0x1d6c1},
+ {0x1d6db, 0x1d6db}, {0x1d6fb, 0x1d6fb}, {0x1d715, 0x1d715},
+ {0x1d735, 0x1d735}, {0x1d74f, 0x1d74f}, {0x1d76f, 0x1d76f},
{0x1d789, 0x1d789}, {0x1d7a9, 0x1d7a9}, {0x1d7c3, 0x1d7c3} };
static xmlChRangeGroup xmlSG = {133,20,xmlSS,xmlSL};
-static const xmlChSRange xmlScS[] = {{0x24, 0x24}, {0xa2, 0xa5},
- {0x9f2, 0x9f3}, {0xaf1, 0xaf1}, {0xbf9, 0xbf9}, {0xe3f, 0xe3f},
- {0x17db, 0x17db}, {0x20a0, 0x20b1}, {0xfdfc, 0xfdfc}, {0xfe69, 0xfe69},
+static const xmlChSRange xmlScS[] = {{0x24, 0x24}, {0xa2, 0xa5},
+ {0x9f2, 0x9f3}, {0xaf1, 0xaf1}, {0xbf9, 0xbf9}, {0xe3f, 0xe3f},
+ {0x17db, 0x17db}, {0x20a0, 0x20b1}, {0xfdfc, 0xfdfc}, {0xfe69, 0xfe69},
{0xff04, 0xff04}, {0xffe0, 0xffe1}, {0xffe5, 0xffe6} };
static xmlChRangeGroup xmlScG = {13,0,xmlScS,NULL};
-static const xmlChSRange xmlSkS[] = {{0x5e, 0x5e}, {0x60, 0x60},
- {0xa8, 0xa8}, {0xaf, 0xaf}, {0xb4, 0xb4}, {0xb8, 0xb8}, {0x2c2, 0x2c5},
- {0x2d2, 0x2df}, {0x2e5, 0x2ed}, {0x2ef, 0x2ff}, {0x374, 0x375},
- {0x384, 0x385}, {0x1fbd, 0x1fbd}, {0x1fbf, 0x1fc1}, {0x1fcd, 0x1fcf},
- {0x1fdd, 0x1fdf}, {0x1fed, 0x1fef}, {0x1ffd, 0x1ffe}, {0x309b, 0x309c},
+static const xmlChSRange xmlSkS[] = {{0x5e, 0x5e}, {0x60, 0x60},
+ {0xa8, 0xa8}, {0xaf, 0xaf}, {0xb4, 0xb4}, {0xb8, 0xb8}, {0x2c2, 0x2c5},
+ {0x2d2, 0x2df}, {0x2e5, 0x2ed}, {0x2ef, 0x2ff}, {0x374, 0x375},
+ {0x384, 0x385}, {0x1fbd, 0x1fbd}, {0x1fbf, 0x1fc1}, {0x1fcd, 0x1fcf},
+ {0x1fdd, 0x1fdf}, {0x1fed, 0x1fef}, {0x1ffd, 0x1ffe}, {0x309b, 0x309c},
{0xff3e, 0xff3e}, {0xff40, 0xff40}, {0xffe3, 0xffe3} };
static xmlChRangeGroup xmlSkG = {22,0,xmlSkS,NULL};
-static const xmlChSRange xmlSmS[] = {{0x2b, 0x2b}, {0x3c, 0x3e},
- {0x7c, 0x7c}, {0x7e, 0x7e}, {0xac, 0xac}, {0xb1, 0xb1}, {0xd7, 0xd7},
- {0xf7, 0xf7}, {0x3f6, 0x3f6}, {0x2044, 0x2044}, {0x2052, 0x2052},
- {0x207a, 0x207c}, {0x208a, 0x208c}, {0x2140, 0x2144}, {0x214b, 0x214b},
- {0x2190, 0x2194}, {0x219a, 0x219b}, {0x21a0, 0x21a0}, {0x21a3, 0x21a3},
- {0x21a6, 0x21a6}, {0x21ae, 0x21ae}, {0x21ce, 0x21cf}, {0x21d2, 0x21d2},
- {0x21d4, 0x21d4}, {0x21f4, 0x22ff}, {0x2308, 0x230b}, {0x2320, 0x2321},
- {0x237c, 0x237c}, {0x239b, 0x23b3}, {0x25b7, 0x25b7}, {0x25c1, 0x25c1},
- {0x25f8, 0x25ff}, {0x266f, 0x266f}, {0x27d0, 0x27e5}, {0x27f0, 0x27ff},
- {0x2900, 0x2982}, {0x2999, 0x29d7}, {0x29dc, 0x29fb}, {0x29fe, 0x2aff},
- {0xfb29, 0xfb29}, {0xfe62, 0xfe62}, {0xfe64, 0xfe66}, {0xff0b, 0xff0b},
- {0xff1c, 0xff1e}, {0xff5c, 0xff5c}, {0xff5e, 0xff5e}, {0xffe2, 0xffe2},
+static const xmlChSRange xmlSmS[] = {{0x2b, 0x2b}, {0x3c, 0x3e},
+ {0x7c, 0x7c}, {0x7e, 0x7e}, {0xac, 0xac}, {0xb1, 0xb1}, {0xd7, 0xd7},
+ {0xf7, 0xf7}, {0x3f6, 0x3f6}, {0x2044, 0x2044}, {0x2052, 0x2052},
+ {0x207a, 0x207c}, {0x208a, 0x208c}, {0x2140, 0x2144}, {0x214b, 0x214b},
+ {0x2190, 0x2194}, {0x219a, 0x219b}, {0x21a0, 0x21a0}, {0x21a3, 0x21a3},
+ {0x21a6, 0x21a6}, {0x21ae, 0x21ae}, {0x21ce, 0x21cf}, {0x21d2, 0x21d2},
+ {0x21d4, 0x21d4}, {0x21f4, 0x22ff}, {0x2308, 0x230b}, {0x2320, 0x2321},
+ {0x237c, 0x237c}, {0x239b, 0x23b3}, {0x25b7, 0x25b7}, {0x25c1, 0x25c1},
+ {0x25f8, 0x25ff}, {0x266f, 0x266f}, {0x27d0, 0x27e5}, {0x27f0, 0x27ff},
+ {0x2900, 0x2982}, {0x2999, 0x29d7}, {0x29dc, 0x29fb}, {0x29fe, 0x2aff},
+ {0xfb29, 0xfb29}, {0xfe62, 0xfe62}, {0xfe64, 0xfe66}, {0xff0b, 0xff0b},
+ {0xff1c, 0xff1e}, {0xff5c, 0xff5c}, {0xff5e, 0xff5e}, {0xffe2, 0xffe2},
{0xffe9, 0xffec} };
-static const xmlChLRange xmlSmL[] = {{0x1d6c1, 0x1d6c1}, {0x1d6db, 0x1d6db},
- {0x1d6fb, 0x1d6fb}, {0x1d715, 0x1d715}, {0x1d735, 0x1d735},
- {0x1d74f, 0x1d74f}, {0x1d76f, 0x1d76f}, {0x1d789, 0x1d789},
+static const xmlChLRange xmlSmL[] = {{0x1d6c1, 0x1d6c1}, {0x1d6db, 0x1d6db},
+ {0x1d6fb, 0x1d6fb}, {0x1d715, 0x1d715}, {0x1d735, 0x1d735},
+ {0x1d74f, 0x1d74f}, {0x1d76f, 0x1d76f}, {0x1d789, 0x1d789},
{0x1d7a9, 0x1d7a9}, {0x1d7c3, 0x1d7c3} };
static xmlChRangeGroup xmlSmG = {48,10,xmlSmS,xmlSmL};
-static const xmlChSRange xmlSoS[] = {{0xa6, 0xa7}, {0xa9, 0xa9},
- {0xae, 0xae}, {0xb0, 0xb0}, {0xb6, 0xb6}, {0x482, 0x482},
- {0x60e, 0x60f}, {0x6e9, 0x6e9}, {0x6fd, 0x6fe}, {0x9fa, 0x9fa},
- {0xb70, 0xb70}, {0xbf3, 0xbf8}, {0xbfa, 0xbfa}, {0xf01, 0xf03},
- {0xf13, 0xf17}, {0xf1a, 0xf1f}, {0xf34, 0xf34}, {0xf36, 0xf36},
- {0xf38, 0xf38}, {0xfbe, 0xfc5}, {0xfc7, 0xfcc}, {0xfcf, 0xfcf},
- {0x1940, 0x1940}, {0x19e0, 0x19ff}, {0x2100, 0x2101}, {0x2103, 0x2106},
- {0x2108, 0x2109}, {0x2114, 0x2114}, {0x2116, 0x2118}, {0x211e, 0x2123},
- {0x2125, 0x2125}, {0x2127, 0x2127}, {0x2129, 0x2129}, {0x212e, 0x212e},
- {0x2132, 0x2132}, {0x213a, 0x213b}, {0x214a, 0x214a}, {0x2195, 0x2199},
- {0x219c, 0x219f}, {0x21a1, 0x21a2}, {0x21a4, 0x21a5}, {0x21a7, 0x21ad},
- {0x21af, 0x21cd}, {0x21d0, 0x21d1}, {0x21d3, 0x21d3}, {0x21d5, 0x21f3},
- {0x2300, 0x2307}, {0x230c, 0x231f}, {0x2322, 0x2328}, {0x232b, 0x237b},
- {0x237d, 0x239a}, {0x23b7, 0x23d0}, {0x2400, 0x2426}, {0x2440, 0x244a},
- {0x249c, 0x24e9}, {0x2500, 0x25b6}, {0x25b8, 0x25c0}, {0x25c2, 0x25f7},
- {0x2600, 0x2617}, {0x2619, 0x266e}, {0x2670, 0x267d}, {0x2680, 0x2691},
- {0x26a0, 0x26a1}, {0x2701, 0x2704}, {0x2706, 0x2709}, {0x270c, 0x2727},
- {0x2729, 0x274b}, {0x274d, 0x274d}, {0x274f, 0x2752}, {0x2756, 0x2756},
- {0x2758, 0x275e}, {0x2761, 0x2767}, {0x2794, 0x2794}, {0x2798, 0x27af},
- {0x27b1, 0x27be}, {0x2800, 0x28ff}, {0x2b00, 0x2b0d}, {0x2e80, 0x2e99},
- {0x2e9b, 0x2ef3}, {0x2f00, 0x2fd5}, {0x2ff0, 0x2ffb}, {0x3004, 0x3004},
- {0x3012, 0x3013}, {0x3020, 0x3020}, {0x3036, 0x3037}, {0x303e, 0x303f},
- {0x3190, 0x3191}, {0x3196, 0x319f}, {0x3200, 0x321e}, {0x322a, 0x3243},
- {0x3250, 0x3250}, {0x3260, 0x327d}, {0x327f, 0x327f}, {0x328a, 0x32b0},
- {0x32c0, 0x32fe}, {0x3300, 0x33ff}, {0x4dc0, 0x4dff}, {0xa490, 0xa4c6},
- {0xfdfd, 0xfdfd}, {0xffe4, 0xffe4}, {0xffe8, 0xffe8}, {0xffed, 0xffee},
+static const xmlChSRange xmlSoS[] = {{0xa6, 0xa7}, {0xa9, 0xa9},
+ {0xae, 0xae}, {0xb0, 0xb0}, {0xb6, 0xb6}, {0x482, 0x482},
+ {0x60e, 0x60f}, {0x6e9, 0x6e9}, {0x6fd, 0x6fe}, {0x9fa, 0x9fa},
+ {0xb70, 0xb70}, {0xbf3, 0xbf8}, {0xbfa, 0xbfa}, {0xf01, 0xf03},
+ {0xf13, 0xf17}, {0xf1a, 0xf1f}, {0xf34, 0xf34}, {0xf36, 0xf36},
+ {0xf38, 0xf38}, {0xfbe, 0xfc5}, {0xfc7, 0xfcc}, {0xfcf, 0xfcf},
+ {0x1940, 0x1940}, {0x19e0, 0x19ff}, {0x2100, 0x2101}, {0x2103, 0x2106},
+ {0x2108, 0x2109}, {0x2114, 0x2114}, {0x2116, 0x2118}, {0x211e, 0x2123},
+ {0x2125, 0x2125}, {0x2127, 0x2127}, {0x2129, 0x2129}, {0x212e, 0x212e},
+ {0x2132, 0x2132}, {0x213a, 0x213b}, {0x214a, 0x214a}, {0x2195, 0x2199},
+ {0x219c, 0x219f}, {0x21a1, 0x21a2}, {0x21a4, 0x21a5}, {0x21a7, 0x21ad},
+ {0x21af, 0x21cd}, {0x21d0, 0x21d1}, {0x21d3, 0x21d3}, {0x21d5, 0x21f3},
+ {0x2300, 0x2307}, {0x230c, 0x231f}, {0x2322, 0x2328}, {0x232b, 0x237b},
+ {0x237d, 0x239a}, {0x23b7, 0x23d0}, {0x2400, 0x2426}, {0x2440, 0x244a},
+ {0x249c, 0x24e9}, {0x2500, 0x25b6}, {0x25b8, 0x25c0}, {0x25c2, 0x25f7},
+ {0x2600, 0x2617}, {0x2619, 0x266e}, {0x2670, 0x267d}, {0x2680, 0x2691},
+ {0x26a0, 0x26a1}, {0x2701, 0x2704}, {0x2706, 0x2709}, {0x270c, 0x2727},
+ {0x2729, 0x274b}, {0x274d, 0x274d}, {0x274f, 0x2752}, {0x2756, 0x2756},
+ {0x2758, 0x275e}, {0x2761, 0x2767}, {0x2794, 0x2794}, {0x2798, 0x27af},
+ {0x27b1, 0x27be}, {0x2800, 0x28ff}, {0x2b00, 0x2b0d}, {0x2e80, 0x2e99},
+ {0x2e9b, 0x2ef3}, {0x2f00, 0x2fd5}, {0x2ff0, 0x2ffb}, {0x3004, 0x3004},
+ {0x3012, 0x3013}, {0x3020, 0x3020}, {0x3036, 0x3037}, {0x303e, 0x303f},
+ {0x3190, 0x3191}, {0x3196, 0x319f}, {0x3200, 0x321e}, {0x322a, 0x3243},
+ {0x3250, 0x3250}, {0x3260, 0x327d}, {0x327f, 0x327f}, {0x328a, 0x32b0},
+ {0x32c0, 0x32fe}, {0x3300, 0x33ff}, {0x4dc0, 0x4dff}, {0xa490, 0xa4c6},
+ {0xfdfd, 0xfdfd}, {0xffe4, 0xffe4}, {0xffe8, 0xffe8}, {0xffed, 0xffee},
{0xfffc, 0xfffd} };
-static const xmlChLRange xmlSoL[] = {{0x10102, 0x10102}, {0x10137, 0x1013f},
- {0x1d000, 0x1d0f5}, {0x1d100, 0x1d126}, {0x1d12a, 0x1d164},
- {0x1d16a, 0x1d16c}, {0x1d183, 0x1d184}, {0x1d18c, 0x1d1a9},
+static const xmlChLRange xmlSoL[] = {{0x10102, 0x10102}, {0x10137, 0x1013f},
+ {0x1d000, 0x1d0f5}, {0x1d100, 0x1d126}, {0x1d12a, 0x1d164},
+ {0x1d16a, 0x1d16c}, {0x1d183, 0x1d184}, {0x1d18c, 0x1d1a9},
{0x1d1ae, 0x1d1dd}, {0x1d300, 0x1d356} };
static xmlChRangeGroup xmlSoG = {103,10,xmlSoS,xmlSoL};
-static const xmlChSRange xmlZS[] = {{0x20, 0x20}, {0xa0, 0xa0},
- {0x1680, 0x1680}, {0x180e, 0x180e}, {0x2000, 0x200a}, {0x2028, 0x2029},
+static const xmlChSRange xmlZS[] = {{0x20, 0x20}, {0xa0, 0xa0},
+ {0x1680, 0x1680}, {0x180e, 0x180e}, {0x2000, 0x200a}, {0x2028, 0x2029},
{0x202f, 0x202f}, {0x205f, 0x205f}, {0x3000, 0x3000} };
static xmlChRangeGroup xmlZG = {9,0,xmlZS,NULL};
@@ -961,7 +961,7 @@ static xmlIntFunc
else
low = mid + 1;
}
- return (NULL);
+ return (NULL);
}
/**
diff --git a/gnulib-local/lib/libxml/xmlversion.in.h b/gnulib-local/lib/libxml/xmlversion.in.h
index 4c6d2bd..f7b483a 100644
--- a/gnulib-local/lib/libxml/xmlversion.in.h
+++ b/gnulib-local/lib/libxml/xmlversion.in.h
@@ -29,28 +29,28 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
*
* the version string like "1.2.3"
*/
-#define LIBXML_DOTTED_VERSION "2.6.27"
+#define LIBXML_DOTTED_VERSION "2.9.3"
/**
* LIBXML_VERSION:
*
* the version number: 1.2.3 value is 10203
*/
-#define LIBXML_VERSION 20627
+#define LIBXML_VERSION 20903
/**
* LIBXML_VERSION_STRING:
*
* the version number string, 1.2.3 value is "10203"
*/
-#define LIBXML_VERSION_STRING "20627"
+#define LIBXML_VERSION_STRING "20903"
/**
* LIBXML_VERSION_EXTRA:
*
* extra version information, used to show a CVS compilation
*/
-#define LIBXML_VERSION_EXTRA "-CVS2872"
+#define LIBXML_VERSION_EXTRA "-GITCVE-2015-8242"
/**
* LIBXML_TEST_VERSION:
@@ -58,7 +58,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
* Macro to check that the libxml version in use is compatible with
* the version the software has been compiled against
*/
-#define LIBXML_TEST_VERSION xmlCheckVersion(20627);
+#define LIBXML_TEST_VERSION xmlCheckVersion(20903);
#ifndef VMS
#if 0
@@ -91,12 +91,22 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
* Whether the thread support is configured in
*/
#if 0
-#if defined(_REENTRANT) || defined(__MT__) || (_POSIX_C_SOURCE - 0 >= 199506L)
+#if defined(_REENTRANT) || defined(__MT__) || \
+ (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L))
#define LIBXML_THREAD_ENABLED
#endif
#endif
/**
+ * LIBXML_THREAD_ALLOC_ENABLED:
+ *
+ * Whether the allocation hooks are per-thread
+ */
+#if 0
+#define LIBXML_THREAD_ALLOC_ENABLED
+#endif
+
+/**
* LIBXML_TREE_ENABLED:
*
* Whether the DOM like tree manipulation API support is configured in
@@ -236,7 +246,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
*
* Whether XPath is configured in
*/
-#if 0
+#if 1
#define LIBXML_XPATH_ENABLED
#endif
@@ -245,7 +255,7 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
*
* Whether XPointer is configured in
*/
-#if 0
+#if 1
#define LIBXML_XPTR_ENABLED
#endif
@@ -268,6 +278,15 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#endif
/**
+ * LIBXML_ICU_ENABLED:
+ *
+ * Whether icu support is available
+ */
+#if 0
+#define LIBXML_ICU_ENABLED
+#endif
+
+/**
* LIBXML_ISO8859X_ENABLED:
*
* Whether ISO-8859-* support is made available in case iconv is not
@@ -382,21 +401,86 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
#endif
/**
- * ATTRIBUTE_UNUSED:
+ * LIBXML_LZMA_ENABLED:
*
- * Macro used to signal to GCC unused function parameters
+ * Whether the Lzma support is compiled in
*/
+#if 0
+#define LIBXML_LZMA_ENABLED
+#endif
+
#ifdef __GNUC__
#ifdef HAVE_ANSIDECL_H
#include <ansidecl.h>
#endif
+
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * Macro used to signal to GCC unused function parameters
+ */
+
#ifndef ATTRIBUTE_UNUSED
-#define ATTRIBUTE_UNUSED __attribute__((unused))
+# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
+# define ATTRIBUTE_UNUSED __attribute__((unused))
+# else
+# define ATTRIBUTE_UNUSED
+# endif
#endif
+
+/**
+ * LIBXML_ATTR_ALLOC_SIZE:
+ *
+ * Macro used to indicate to GCC this is an allocator function
+ */
+
+#ifndef LIBXML_ATTR_ALLOC_SIZE
+# if (!defined(__clang__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))))
+# define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
+# else
+# define LIBXML_ATTR_ALLOC_SIZE(x)
+# endif
#else
-#define ATTRIBUTE_UNUSED
+# define LIBXML_ATTR_ALLOC_SIZE(x)
+#endif
+
+/**
+ * LIBXML_ATTR_FORMAT:
+ *
+ * Macro used to indicate to GCC the parameter are printf like
+ */
+
+#ifndef LIBXML_ATTR_FORMAT
+# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))
+# define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
+# else
+# define LIBXML_ATTR_FORMAT(fmt,args)
+# endif
+#else
+# define LIBXML_ATTR_FORMAT(fmt,args)
#endif
+#else /* ! __GNUC__ */
+/**
+ * ATTRIBUTE_UNUSED:
+ *
+ * Macro used to signal to GCC unused function parameters
+ */
+#define ATTRIBUTE_UNUSED
+/**
+ * LIBXML_ATTR_ALLOC_SIZE:
+ *
+ * Macro used to indicate to GCC this is an allocator function
+ */
+#define LIBXML_ATTR_ALLOC_SIZE(x)
+/**
+ * LIBXML_ATTR_FORMAT:
+ *
+ * Macro used to indicate to GCC the parameter are printf like
+ */
+#define LIBXML_ATTR_FORMAT(fmt,args)
+#endif /* __GNUC__ */
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/gnulib-local/lib/libxml/xmlwriter.c b/gnulib-local/lib/libxml/xmlwriter.c
index 5821056..fac20ac 100644
--- a/gnulib-local/lib/libxml/xmlwriter.c
+++ b/gnulib-local/lib/libxml/xmlwriter.c
@@ -10,7 +10,6 @@
#define IN_LIBXML
#include "libxml.h"
-
#include <string.h>
#include <libxml/xmlmemory.h>
@@ -22,15 +21,18 @@
#include <libxml/xmlwriter.h>
+#include "buf.h"
+#include "enc.h"
+#include "save.h"
+
#define B64LINELEN 72
#define B64CRLF "\r\n"
/*
* The following VA_COPY was coded following an example in
* the Samba project. It may not be sufficient for some
- * esoteric implementations of va_list (i.e. it may need
- * something involving a memcpy) but (hopefully) will be
- * sufficient for libxml2.
+ * esoteric implementations of va_list but (hopefully) will
+ * be sufficient for libxml2.
*/
#ifndef VA_COPY
#ifdef HAVE_VA_COPY
@@ -39,7 +41,12 @@
#ifdef HAVE___VA_COPY
#define VA_COPY(dest,src) __va_copy(dest, src)
#else
- #define VA_COPY(dest,src) (dest) = (src)
+ #ifndef VA_LIST_IS_ARRAY
+ #define VA_COPY(dest,src) (dest) = (src)
+ #else
+ #include <string.h>
+ #define VA_COPY(dest,src) memcpy((char *)(dest),(char *)(src),sizeof(va_list))
+ #endif
#endif
#endif
#endif
@@ -98,6 +105,7 @@ struct _xmlTextWriter {
static void xmlFreeTextWriterStackEntry(xmlLinkPtr lk);
static int xmlCmpTextWriterStackEntry(const void *data0,
const void *data1);
+static int xmlTextWriterOutputNSDecl(xmlTextWriterPtr writer);
static void xmlFreeTextWriterNsStackEntry(xmlLinkPtr lk);
static int xmlCmpTextWriterNsStackEntry(const void *data0,
const void *data1);
@@ -129,10 +137,10 @@ xmlWriterErrMsg(xmlTextWriterPtr ctxt, xmlParserErrors error,
if (ctxt != NULL) {
__xmlRaiseError(NULL, NULL, NULL, ctxt->ctxt,
NULL, XML_FROM_WRITER, error, XML_ERR_FATAL,
- NULL, 0, NULL, NULL, NULL, 0, 0, msg);
+ NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg);
} else {
__xmlRaiseError(NULL, NULL, NULL, NULL, NULL, XML_FROM_WRITER, error,
- XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, msg);
+ XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, "%s", msg);
}
}
@@ -242,8 +250,8 @@ xmlNewTextWriterFilename(const char *uri, int compression)
out = xmlOutputBufferCreateFilename(uri, NULL, compression);
if (out == NULL) {
- xmlWriterErrMsg(NULL, XML_ERR_NO_MEMORY,
- "xmlNewTextWriterFilename : out of memory!\n");
+ xmlWriterErrMsg(NULL, XML_IO_EIO,
+ "xmlNewTextWriterFilename : cannot open uri\n");
return NULL;
}
@@ -370,7 +378,7 @@ xmlNewTextWriterDoc(xmlDocPtr * doc, int compression)
ctxt = xmlCreatePushParserCtxt(&saxHandler, NULL, NULL, 0, NULL);
if (ctxt == NULL) {
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
- "xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n");
+ "xmlNewTextWriterDoc : error at xmlCreatePushParserCtxt!\n");
return NULL;
}
/*
@@ -389,8 +397,10 @@ xmlNewTextWriterDoc(xmlDocPtr * doc, int compression)
ret = xmlNewTextWriterPushParser(ctxt, compression);
if (ret == NULL) {
+ xmlFreeDoc(ctxt->myDoc);
+ xmlFreeParserCtxt(ctxt);
xmlWriterErrMsg(NULL, XML_ERR_INTERNAL_ERROR,
- "xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n");
+ "xmlNewTextWriterDoc : error at xmlNewTextWriterPushParser!\n");
return NULL;
}
@@ -545,8 +555,10 @@ xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version,
writer->out->encoder = encoder;
if (encoder != NULL) {
- writer->out->conv = xmlBufferCreateSize(4000);
- xmlCharEncOutFunc(encoder, writer->out->conv, NULL);
+ if (writer->out->conv == NULL) {
+ writer->out->conv = xmlBufCreateSize(4000);
+ }
+ xmlCharEncOutput(writer->out, 1);
if ((writer->doc != NULL) && (writer->doc->encoding == NULL))
writer->doc->encoding = xmlStrdup((xmlChar *)writer->out->encoder->name);
} else
@@ -624,9 +636,10 @@ xmlTextWriterStartDocument(xmlTextWriterPtr writer, const char *version,
* xmlTextWriterEndDocument:
* @writer: the xmlTextWriterPtr
*
- * End an xml document. All open elements are closed
+ * End an xml document. All open elements are closed, and
+ * the content is flushed to the output.
*
- * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
+ * Returns the bytes written or -1 in case of error
*/
int
xmlTextWriterEndDocument(xmlTextWriterPtr writer)
@@ -700,6 +713,9 @@ xmlTextWriterEndDocument(xmlTextWriterPtr writer)
return -1;
sum += count;
}
+
+ sum += xmlTextWriterFlush(writer);
+
return sum;
}
@@ -735,6 +751,11 @@ xmlTextWriterStartComment(xmlTextWriterPtr writer)
case XML_TEXTWRITER_NONE:
break;
case XML_TEXTWRITER_NAME:
+ /* Output namespace declarations */
+ count = xmlTextWriterOutputNSDecl(writer);
+ if (count < 0)
+ return -1;
+ sum += count;
count = xmlOutputBufferWriteString(writer->out, ">");
if (count < 0)
return -1;
@@ -887,8 +908,8 @@ xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
}
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteComment(writer, buf);
@@ -966,6 +987,11 @@ xmlTextWriterStartElement(xmlTextWriterPtr writer, const xmlChar * name)
sum += count;
/* fallthrough */
case XML_TEXTWRITER_NAME:
+ /* Output namespace declarations */
+ count = xmlTextWriterOutputNSDecl(writer);
+ if (count < 0)
+ return -1;
+ sum += count;
count = xmlOutputBufferWriteString(writer->out, ">");
if (count < 0)
return -1;
@@ -1056,17 +1082,31 @@ xmlTextWriterStartElementNS(xmlTextWriterPtr writer,
sum += count;
if (namespaceURI != 0) {
+ xmlTextWriterNsStackEntry *p = (xmlTextWriterNsStackEntry *)
+ xmlMalloc(sizeof(xmlTextWriterNsStackEntry));
+ if (p == 0) {
+ xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
+ "xmlTextWriterStartElementNS : out of memory!\n");
+ return -1;
+ }
+
buf = xmlStrdup(BAD_CAST "xmlns");
if (prefix != 0) {
buf = xmlStrcat(buf, BAD_CAST ":");
buf = xmlStrcat(buf, prefix);
}
- count = xmlTextWriterWriteAttribute(writer, buf, namespaceURI);
- xmlFree(buf);
- if (count < 0)
+ p->prefix = buf;
+ p->uri = xmlStrdup(namespaceURI);
+ if (p->uri == 0) {
+ xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
+ "xmlTextWriterStartElementNS : out of memory!\n");
+ xmlFree(p);
return -1;
- sum += count;
+ }
+ p->elem = xmlListFront(writer->nodes);
+
+ xmlListPushFront(writer->nsstack, p);
}
return sum;
@@ -1092,22 +1132,37 @@ xmlTextWriterEndElement(xmlTextWriterPtr writer)
return -1;
lk = xmlListFront(writer->nodes);
- if (lk == 0)
+ if (lk == 0) {
+ xmlListDelete(writer->nsstack);
+ writer->nsstack = NULL;
return -1;
+ }
p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk);
- if (p == 0)
+ if (p == 0) {
+ xmlListDelete(writer->nsstack);
+ writer->nsstack = NULL;
return -1;
+ }
sum = 0;
switch (p->state) {
case XML_TEXTWRITER_ATTRIBUTE:
count = xmlTextWriterEndAttribute(writer);
- if (count < 0)
+ if (count < 0) {
+ xmlListDelete(writer->nsstack);
+ writer->nsstack = NULL;
return -1;
+ }
sum += count;
/* fallthrough */
case XML_TEXTWRITER_NAME:
+ /* Output namespace declarations */
+ count = xmlTextWriterOutputNSDecl(writer);
+ if (count < 0)
+ return -1;
+ sum += count;
+
if (writer->indent) /* next element needs indent */
writer->doindent = 1;
count = xmlOutputBufferWriteString(writer->out, "/>");
@@ -1185,12 +1240,26 @@ xmlTextWriterFullEndElement(xmlTextWriterPtr writer)
sum += count;
/* fallthrough */
case XML_TEXTWRITER_NAME:
+ /* Output namespace declarations */
+ count = xmlTextWriterOutputNSDecl(writer);
+ if (count < 0)
+ return -1;
+ sum += count;
+
count = xmlOutputBufferWriteString(writer->out, ">");
if (count < 0)
return -1;
sum += count;
+ if (writer->indent)
+ writer->doindent = 0;
/* fallthrough */
case XML_TEXTWRITER_TEXT:
+ if ((writer->indent) && (writer->doindent)) {
+ count = xmlTextWriterWriteIndent(writer);
+ sum += count;
+ writer->doindent = 1;
+ } else
+ writer->doindent = 1;
count = xmlOutputBufferWriteString(writer->out, "</");
if (count < 0)
return -1;
@@ -1209,6 +1278,11 @@ xmlTextWriterFullEndElement(xmlTextWriterPtr writer)
return -1;
}
+ if (writer->indent) {
+ count = xmlOutputBufferWriteString(writer->out, "\n");
+ sum += count;
+ }
+
xmlListPopFront(writer->nodes);
return sum;
}
@@ -1259,8 +1333,8 @@ xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer, const char *format,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteRaw(writer, buf);
@@ -1388,8 +1462,8 @@ xmlTextWriterWriteVFormatString(xmlTextWriterPtr writer,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteString(writer, buf);
@@ -1435,8 +1509,8 @@ xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content)
break;
case XML_TEXTWRITER_ATTRIBUTE:
buf = NULL;
- xmlAttrSerializeTxtContent(writer->out->buffer, writer->doc,
- NULL, content);
+ xmlBufAttrSerializeTxtContent(writer->out->buffer,
+ writer->doc, NULL, content);
break;
default:
break;
@@ -1446,12 +1520,13 @@ xmlTextWriterWriteString(xmlTextWriterPtr writer, const xmlChar * content)
if (buf != NULL) {
count = xmlTextWriterWriteRaw(writer, buf);
- if (count < 0)
- return -1;
- sum += count;
if (buf != content) /* buf was allocated by us, so free it */
xmlFree(buf);
+
+ if (count < 0)
+ return -1;
+ sum += count;
}
return sum;
@@ -1596,7 +1671,7 @@ xmlTextWriterWriteBase64(xmlTextWriterPtr writer, const char *data,
* Write hqx encoded data to an xmlOutputBuffer.
* ::todo
*
- * Returns the bytes written (may be 0 because of buffering)
+ * Returns the bytes written (may be 0 because of buffering)
* or -1 in case of error
*/
static int
@@ -1605,8 +1680,8 @@ xmlOutputBufferWriteBinHex(xmlOutputBufferPtr out,
{
int count;
int sum;
- static char hex[16] =
- {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+ static char hex[16] =
+ {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
int i;
if ((out == NULL) || (data == NULL) || (len < 0)) {
@@ -1768,6 +1843,57 @@ xmlTextWriterStartAttributeNS(xmlTextWriterPtr writer,
if ((writer == NULL) || (name == NULL) || (*name == '\0'))
return -1;
+ /* Handle namespace first in case of error */
+ if (namespaceURI != 0) {
+ xmlTextWriterNsStackEntry nsentry, *curns;
+
+ buf = xmlStrdup(BAD_CAST "xmlns");
+ if (prefix != 0) {
+ buf = xmlStrcat(buf, BAD_CAST ":");
+ buf = xmlStrcat(buf, prefix);
+ }
+
+ nsentry.prefix = buf;
+ nsentry.uri = (xmlChar *)namespaceURI;
+ nsentry.elem = xmlListFront(writer->nodes);
+
+ curns = (xmlTextWriterNsStackEntry *)xmlListSearch(writer->nsstack,
+ (void *)&nsentry);
+ if ((curns != NULL)) {
+ xmlFree(buf);
+ if (xmlStrcmp(curns->uri, namespaceURI) == 0) {
+ /* Namespace already defined on element skip */
+ buf = NULL;
+ } else {
+ /* Prefix mismatch so error out */
+ return -1;
+ }
+ }
+
+ /* Do not add namespace decl to list - it is already there */
+ if (buf != NULL) {
+ p = (xmlTextWriterNsStackEntry *)
+ xmlMalloc(sizeof(xmlTextWriterNsStackEntry));
+ if (p == 0) {
+ xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
+ "xmlTextWriterStartAttributeNS : out of memory!\n");
+ return -1;
+ }
+
+ p->prefix = buf;
+ p->uri = xmlStrdup(namespaceURI);
+ if (p->uri == 0) {
+ xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
+ "xmlTextWriterStartAttributeNS : out of memory!\n");
+ xmlFree(p);
+ return -1;
+ }
+ p->elem = xmlListFront(writer->nodes);
+
+ xmlListPushFront(writer->nsstack, p);
+ }
+ }
+
buf = NULL;
if (prefix != 0) {
buf = xmlStrdup(prefix);
@@ -1782,34 +1908,6 @@ xmlTextWriterStartAttributeNS(xmlTextWriterPtr writer,
return -1;
sum += count;
- if (namespaceURI != 0) {
- buf = xmlStrdup(BAD_CAST "xmlns");
- if (prefix != 0) {
- buf = xmlStrcat(buf, BAD_CAST ":");
- buf = xmlStrcat(buf, prefix);
- }
-
- p = (xmlTextWriterNsStackEntry *)
- xmlMalloc(sizeof(xmlTextWriterNsStackEntry));
- if (p == 0) {
- xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
- "xmlTextWriterStartAttributeNS : out of memory!\n");
- return -1;
- }
-
- p->prefix = buf;
- p->uri = xmlStrdup(namespaceURI);
- if (p->uri == 0) {
- xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
- "xmlTextWriterStartAttributeNS : out of memory!\n");
- xmlFree(p);
- return -1;
- }
- p->elem = xmlListFront(writer->nodes);
-
- xmlListPushFront(writer->nsstack, p);
- }
-
return sum;
}
@@ -1828,22 +1926,17 @@ xmlTextWriterEndAttribute(xmlTextWriterPtr writer)
int sum;
xmlLinkPtr lk;
xmlTextWriterStackEntry *p;
- xmlTextWriterNsStackEntry *np;
if (writer == NULL)
return -1;
lk = xmlListFront(writer->nodes);
if (lk == 0) {
- xmlListDelete(writer->nsstack);
- writer->nsstack = NULL;
return -1;
}
p = (xmlTextWriterStackEntry *) xmlLinkGetData(lk);
if (p == 0) {
- xmlListDelete(writer->nsstack);
- writer->nsstack = NULL;
return -1;
}
@@ -1854,45 +1947,11 @@ xmlTextWriterEndAttribute(xmlTextWriterPtr writer)
count = xmlOutputBufferWrite(writer->out, 1, &writer->qchar);
if (count < 0) {
- xmlListDelete(writer->nsstack);
- writer->nsstack = NULL;
return -1;
}
sum += count;
-
- while (!xmlListEmpty(writer->nsstack)) {
- xmlChar *namespaceURI = NULL;
- xmlChar *prefix = NULL;
-
- lk = xmlListFront(writer->nsstack);
- np = (xmlTextWriterNsStackEntry *) xmlLinkGetData(lk);
-
- if (np != 0) {
- namespaceURI = xmlStrdup(np->uri);
- prefix = xmlStrdup(np->prefix);
- }
-
- xmlListPopFront(writer->nsstack);
-
- if (np != 0) {
- count =
- xmlTextWriterWriteAttribute(writer, prefix,
- namespaceURI);
- xmlFree(namespaceURI);
- xmlFree(prefix);
-
- if (count < 0) {
- xmlListDelete(writer->nsstack);
- writer->nsstack = NULL;
- return -1;
- }
- sum += count;
- }
- }
break;
-
default:
- xmlListClear(writer->nsstack);
return -1;
}
@@ -1949,8 +2008,8 @@ xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteAttribute(writer, name, buf);
@@ -2051,8 +2110,8 @@ xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteAttributeNS(writer, prefix, name, namespaceURI,
buf);
@@ -2081,38 +2140,24 @@ xmlTextWriterWriteAttributeNS(xmlTextWriterPtr writer,
{
int count;
int sum;
- xmlChar *buf;
if ((writer == NULL) || (name == NULL) || (*name == '\0'))
return -1;
- buf = NULL;
- if (prefix != NULL) {
- buf = xmlStrdup(prefix);
- buf = xmlStrcat(buf, BAD_CAST ":");
- }
- buf = xmlStrcat(buf, name);
-
sum = 0;
- count = xmlTextWriterWriteAttribute(writer, buf, content);
- xmlFree(buf);
+ count = xmlTextWriterStartAttributeNS(writer, prefix, name, namespaceURI);
+ if (count < 0)
+ return -1;
+ sum += count;
+ count = xmlTextWriterWriteString(writer, content);
+ if (count < 0)
+ return -1;
+ sum += count;
+ count = xmlTextWriterEndAttribute(writer);
if (count < 0)
return -1;
sum += count;
- if (namespaceURI != NULL) {
- buf = NULL;
- buf = xmlStrdup(BAD_CAST "xmlns");
- if (prefix != NULL) {
- buf = xmlStrcat(buf, BAD_CAST ":");
- buf = xmlStrcat(buf, prefix);
- }
- count = xmlTextWriterWriteAttribute(writer, buf, namespaceURI);
- xmlFree(buf);
- if (count < 0)
- return -1;
- sum += count;
- }
return sum;
}
@@ -2166,8 +2211,8 @@ xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteElement(writer, name, buf);
@@ -2197,10 +2242,12 @@ xmlTextWriterWriteElement(xmlTextWriterPtr writer, const xmlChar * name,
if (count == -1)
return -1;
sum += count;
- count = xmlTextWriterWriteString(writer, content);
- if (count == -1)
- return -1;
- sum += count;
+ if (content != NULL) {
+ count = xmlTextWriterWriteString(writer, content);
+ if (count == -1)
+ return -1;
+ sum += count;
+ }
count = xmlTextWriterEndElement(writer);
if (count == -1)
return -1;
@@ -2268,8 +2315,8 @@ xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteElementNS(writer, prefix, name, namespaceURI,
buf);
@@ -2359,6 +2406,11 @@ xmlTextWriterStartPI(xmlTextWriterPtr writer, const xmlChar * target)
sum += count;
/* fallthrough */
case XML_TEXTWRITER_NAME:
+ /* Output namespace declarations */
+ count = xmlTextWriterOutputNSDecl(writer);
+ if (count < 0)
+ return -1;
+ sum += count;
count = xmlOutputBufferWriteString(writer->out, ">");
if (count < 0)
return -1;
@@ -2454,8 +2506,8 @@ xmlTextWriterEndPI(xmlTextWriterPtr writer)
if (writer->indent) {
count = xmlOutputBufferWriteString(writer->out, "\n");
- if (count < 0)
- return -1;
+ if (count < 0)
+ return -1;
sum += count;
}
@@ -2512,8 +2564,8 @@ xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWritePI(writer, target, buf);
@@ -2583,6 +2635,7 @@ xmlTextWriterStartCDATA(xmlTextWriterPtr writer)
if (p != 0) {
switch (p->state) {
case XML_TEXTWRITER_NONE:
+ case XML_TEXTWRITER_TEXT:
case XML_TEXTWRITER_PI:
case XML_TEXTWRITER_PI_TEXT:
break;
@@ -2593,6 +2646,11 @@ xmlTextWriterStartCDATA(xmlTextWriterPtr writer)
sum += count;
/* fallthrough */
case XML_TEXTWRITER_NAME:
+ /* Output namespace declarations */
+ count = xmlTextWriterOutputNSDecl(writer);
+ if (count < 0)
+ return -1;
+ sum += count;
count = xmlOutputBufferWriteString(writer->out, ">");
if (count < 0)
return -1;
@@ -2719,8 +2777,8 @@ xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer, const char *format,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteCDATA(writer, buf);
@@ -3037,8 +3095,8 @@ xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteDTD(writer, name, pubid, sysid, buf);
@@ -3275,8 +3333,8 @@ xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteDTDElement(writer, name, buf);
@@ -3512,8 +3570,8 @@ xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteDTDAttlist(writer, name, buf);
@@ -3774,8 +3832,8 @@ xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,
return -1;
buf = xmlTextWriterVSprintf(format, argptr);
- if (buf == 0)
- return 0;
+ if (buf == NULL)
+ return -1;
rc = xmlTextWriterWriteDTDInternalEntity(writer, pe, name, buf);
@@ -4249,6 +4307,51 @@ xmlCmpTextWriterStackEntry(const void *data0, const void *data1)
*/
/**
+ * xmlTextWriterOutputNSDecl:
+ * @writer: the xmlTextWriterPtr
+ *
+ * Output the current namespace declarations.
+ */
+static int
+xmlTextWriterOutputNSDecl(xmlTextWriterPtr writer)
+{
+ xmlLinkPtr lk;
+ xmlTextWriterNsStackEntry *np;
+ int count;
+ int sum;
+
+ sum = 0;
+ while (!xmlListEmpty(writer->nsstack)) {
+ xmlChar *namespaceURI = NULL;
+ xmlChar *prefix = NULL;
+
+ lk = xmlListFront(writer->nsstack);
+ np = (xmlTextWriterNsStackEntry *) xmlLinkGetData(lk);
+
+ if (np != 0) {
+ namespaceURI = xmlStrdup(np->uri);
+ prefix = xmlStrdup(np->prefix);
+ }
+
+ xmlListPopFront(writer->nsstack);
+
+ if (np != 0) {
+ count = xmlTextWriterWriteAttribute(writer, prefix, namespaceURI);
+ xmlFree(namespaceURI);
+ xmlFree(prefix);
+
+ if (count < 0) {
+ xmlListDelete(writer->nsstack);
+ writer->nsstack = NULL;
+ return -1;
+ }
+ sum += count;
+ }
+ }
+ return sum;
+}
+
+/**
* xmlFreeTextWriterNsStackEntry:
* @lk: the xmlLinkPtr
*
@@ -4301,8 +4404,8 @@ xmlCmpTextWriterNsStackEntry(const void *data0, const void *data1)
rc = xmlStrcmp(p0->prefix, p1->prefix);
- if (rc == 0)
- rc = p0->elem == p1->elem;
+ if ((rc != 0) || (p0->elem != p1->elem))
+ rc = -1;
return rc;
}
@@ -4513,6 +4616,26 @@ xmlTextWriterSetIndentString(xmlTextWriterPtr writer, const xmlChar * str)
}
/**
+ * xmlTextWriterSetQuoteChar:
+ * @writer: the xmlTextWriterPtr
+ * @quotechar: the quote character
+ *
+ * Set the character used for quoting attributes.
+ *
+ * Returns -1 on error or 0 otherwise.
+ */
+int
+xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar)
+{
+ if ((writer == NULL) || ((quotechar != '\'') && (quotechar != '"')))
+ return -1;
+
+ writer->qchar = quotechar;
+
+ return 0;
+}
+
+/**
* xmlTextWriterWriteIndent:
* @writer: the xmlTextWriterPtr
*
@@ -4569,6 +4692,11 @@ xmlTextWriterHandleStateDependencies(xmlTextWriterPtr writer,
sum = 0;
switch (p->state) {
case XML_TEXTWRITER_NAME:
+ /* Output namespace declarations */
+ count = xmlTextWriterOutputNSDecl(writer);
+ if (count < 0)
+ return -1;
+ sum += count;
extra[0] = '>';
p->state = XML_TEXTWRITER_TEXT;
break;
diff --git a/gnulib-local/lib/libxml/xmlwriter.in.h b/gnulib-local/lib/libxml/xmlwriter.in.h
index 31ceb5f..dd5add3 100644
--- a/gnulib-local/lib/libxml/xmlwriter.in.h
+++ b/gnulib-local/lib/libxml/xmlwriter.in.h
@@ -1,4 +1,3 @@
-
/*
* Summary: text writing API for XML
* Description: text writing API for XML
@@ -69,11 +68,13 @@ extern "C" {
XMLPUBFUN int XMLCALL xmlTextWriterEndComment(xmlTextWriterPtr writer);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(2,3);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,
const char *format,
- va_list argptr);
+ va_list argptr)
+ LIBXML_ATTR_FORMAT(2,0);
XMLPUBFUN int XMLCALL xmlTextWriterWriteComment(xmlTextWriterPtr
writer,
const xmlChar *
@@ -102,12 +103,14 @@ extern "C" {
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,
const xmlChar * name,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(3,4);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
- va_list argptr);
+ va_list argptr)
+ LIBXML_ATTR_FORMAT(3,0);
XMLPUBFUN int XMLCALL xmlTextWriterWriteElement(xmlTextWriterPtr
writer,
const xmlChar * name,
@@ -118,14 +121,16 @@ extern "C" {
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(5,6);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const char *format,
- va_list argptr);
+ va_list argptr)
+ LIBXML_ATTR_FORMAT(5,0);
XMLPUBFUN int XMLCALL xmlTextWriterWriteElementNS(xmlTextWriterPtr
writer,
const xmlChar *
@@ -141,10 +146,12 @@ extern "C" {
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(2,3);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer,
- const char *format, va_list argptr);
+ const char *format, va_list argptr)
+ LIBXML_ATTR_FORMAT(2,0);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteRawLen(xmlTextWriterPtr writer,
const xmlChar * content, int len);
@@ -154,12 +161,14 @@ extern "C" {
XMLPUBFUN int XMLCALL xmlTextWriterWriteFormatString(xmlTextWriterPtr
writer,
const char
- *format, ...);
+ *format, ...)
+ LIBXML_ATTR_FORMAT(2,3);
XMLPUBFUN int XMLCALL xmlTextWriterWriteVFormatString(xmlTextWriterPtr
writer,
const char
*format,
- va_list argptr);
+ va_list argptr)
+ LIBXML_ATTR_FORMAT(2,0);
XMLPUBFUN int XMLCALL xmlTextWriterWriteString(xmlTextWriterPtr writer,
const xmlChar *
content);
@@ -193,12 +202,14 @@ extern "C" {
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,
const xmlChar * name,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(3,4);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
- va_list argptr);
+ va_list argptr)
+ LIBXML_ATTR_FORMAT(3,0);
XMLPUBFUN int XMLCALL xmlTextWriterWriteAttribute(xmlTextWriterPtr
writer,
const xmlChar * name,
@@ -209,14 +220,16 @@ extern "C" {
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(5,6);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,
const xmlChar * prefix,
const xmlChar * name,
const xmlChar * namespaceURI,
const char *format,
- va_list argptr);
+ va_list argptr)
+ LIBXML_ATTR_FORMAT(5,0);
XMLPUBFUN int XMLCALL xmlTextWriterWriteAttributeNS(xmlTextWriterPtr
writer,
const xmlChar *
@@ -242,11 +255,13 @@ extern "C" {
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer,
const xmlChar * target,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(3,4);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,
const xmlChar * target,
- const char *format, va_list argptr);
+ const char *format, va_list argptr)
+ LIBXML_ATTR_FORMAT(3,0);
XMLPUBFUN int XMLCALL
xmlTextWriterWritePI(xmlTextWriterPtr writer,
const xmlChar * target,
@@ -270,10 +285,12 @@ extern "C" {
*/
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(2,3);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer,
- const char *format, va_list argptr);
+ const char *format, va_list argptr)
+ LIBXML_ATTR_FORMAT(2,0);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteCDATA(xmlTextWriterPtr writer,
const xmlChar * content);
@@ -296,13 +313,15 @@ extern "C" {
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(5,6);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,
const xmlChar * name,
const xmlChar * pubid,
const xmlChar * sysid,
- const char *format, va_list argptr);
+ const char *format, va_list argptr)
+ LIBXML_ATTR_FORMAT(5,0);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTD(xmlTextWriterPtr writer,
const xmlChar * name,
@@ -332,12 +351,14 @@ extern "C" {
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,
const xmlChar * name,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(3,4);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
- va_list argptr);
+ va_list argptr)
+ LIBXML_ATTR_FORMAT(3,0);
XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDElement(xmlTextWriterPtr
writer,
const xmlChar *
@@ -360,12 +381,14 @@ extern "C" {
XMLPUBFUN int XMLCALL
xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,
const xmlChar * name,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(3,4);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,
const xmlChar * name,
const char *format,
- va_list argptr);
+ va_list argptr)
+ LIBXML_ATTR_FORMAT(3,0);
XMLPUBFUN int XMLCALL xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr
writer,
const xmlChar *
@@ -389,13 +412,15 @@ extern "C" {
xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
- const char *format, ...);
+ const char *format, ...)
+ LIBXML_ATTR_FORMAT(4,5);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,
int pe,
const xmlChar * name,
const char *format,
- va_list argptr);
+ va_list argptr)
+ LIBXML_ATTR_FORMAT(4,0);
XMLPUBFUN int XMLCALL
xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,
int pe,
@@ -445,6 +470,10 @@ extern "C" {
xmlTextWriterSetIndentString(xmlTextWriterPtr writer,
const xmlChar * str);
+ XMLPUBFUN int XMLCALL
+ xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar);
+
+
/*
* misc
*/
diff --git a/gnulib-local/lib/libxml/xpath.c b/gnulib-local/lib/libxml/xpath.c
index 8964628..935fcff 100644
--- a/gnulib-local/lib/libxml/xpath.c
+++ b/gnulib-local/lib/libxml/xpath.c
@@ -55,15 +55,26 @@
#include <libxml/pattern.h>
#endif
+#include "buf.h"
+
#ifdef LIBXML_PATTERN_ENABLED
#define XPATH_STREAMING
#endif
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
+/**
+ * WITH_TIM_SORT:
+ *
+ * Use the Timsort algorithm provided in timsort.h to sort
+ * nodeset as this is a great improvement over the old Shell sort
+ * used in xmlXPathNodeSetSort()
+ */
+#define WITH_TIM_SORT
+
/*
* XP_OPTIMIZED_NON_ELEM_COMPARISON:
* If defined, this will use xmlXPathCmpNodesExt() instead of
@@ -79,7 +90,7 @@
* XP_OPTIMIZED_FILTER_FIRST:
* If defined, this will optimize expressions like "key('foo', 'val')[b][1]"
* in a way, that it stop evaluation at the first node.
-*/
+*/
#define XP_OPTIMIZED_FILTER_FIRST
/*
@@ -90,18 +101,373 @@
/* #define XP_DEBUG_OBJ_USAGE */
/*
+ * XPATH_MAX_STEPS:
+ * when compiling an XPath expression we arbitrary limit the maximum
+ * number of step operation in the compiled expression. 1000000 is
+ * an insanely large value which should never be reached under normal
+ * circumstances
+ */
+#define XPATH_MAX_STEPS 1000000
+
+/*
+ * XPATH_MAX_STACK_DEPTH:
+ * when evaluating an XPath expression we arbitrary limit the maximum
+ * number of object allowed to be pushed on the stack. 1000000 is
+ * an insanely large value which should never be reached under normal
+ * circumstances
+ */
+#define XPATH_MAX_STACK_DEPTH 1000000
+
+/*
+ * XPATH_MAX_NODESET_LENGTH:
+ * when evaluating an XPath expression nodesets are created and we
+ * arbitrary limit the maximum length of those node set. 10000000 is
+ * an insanely large value which should never be reached under normal
+ * circumstances, one would first need to construct an in memory tree
+ * with more than 10 millions nodes.
+ */
+#define XPATH_MAX_NODESET_LENGTH 10000000
+
+/*
* TODO:
* There are a few spots where some tests are done which depend upon ascii
* data. These should be enhanced for full UTF8 support (see particularly
* any use of the macros IS_ASCII_CHARACTER and IS_ASCII_DIGIT)
*/
+#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON
+/**
+ * xmlXPathCmpNodesExt:
+ * @node1: the first node
+ * @node2: the second node
+ *
+ * Compare two nodes w.r.t document order.
+ * This one is optimized for handling of non-element nodes.
+ *
+ * Returns -2 in case of error 1 if first point < second point, 0 if
+ * it's the same node, -1 otherwise
+ */
+static int
+xmlXPathCmpNodesExt(xmlNodePtr node1, xmlNodePtr node2) {
+ int depth1, depth2;
+ int misc = 0, precedence1 = 0, precedence2 = 0;
+ xmlNodePtr miscNode1 = NULL, miscNode2 = NULL;
+ xmlNodePtr cur, root;
+ long l1, l2;
+
+ if ((node1 == NULL) || (node2 == NULL))
+ return(-2);
+
+ if (node1 == node2)
+ return(0);
+
+ /*
+ * a couple of optimizations which will avoid computations in most cases
+ */
+ switch (node1->type) {
+ case XML_ELEMENT_NODE:
+ if (node2->type == XML_ELEMENT_NODE) {
+ if ((0 > (long) node1->content) && /* TODO: Would a != 0 suffice here? */
+ (0 > (long) node2->content) &&
+ (node1->doc == node2->doc))
+ {
+ l1 = -((long) node1->content);
+ l2 = -((long) node2->content);
+ if (l1 < l2)
+ return(1);
+ if (l1 > l2)
+ return(-1);
+ } else
+ goto turtle_comparison;
+ }
+ break;
+ case XML_ATTRIBUTE_NODE:
+ precedence1 = 1; /* element is owner */
+ miscNode1 = node1;
+ node1 = node1->parent;
+ misc = 1;
+ break;
+ case XML_TEXT_NODE:
+ case XML_CDATA_SECTION_NODE:
+ case XML_COMMENT_NODE:
+ case XML_PI_NODE: {
+ miscNode1 = node1;
+ /*
+ * Find nearest element node.
+ */
+ if (node1->prev != NULL) {
+ do {
+ node1 = node1->prev;
+ if (node1->type == XML_ELEMENT_NODE) {
+ precedence1 = 3; /* element in prev-sibl axis */
+ break;
+ }
+ if (node1->prev == NULL) {
+ precedence1 = 2; /* element is parent */
+ /*
+ * URGENT TODO: Are there any cases, where the
+ * parent of such a node is not an element node?
+ */
+ node1 = node1->parent;
+ break;
+ }
+ } while (1);
+ } else {
+ precedence1 = 2; /* element is parent */
+ node1 = node1->parent;
+ }
+ if ((node1 == NULL) || (node1->type != XML_ELEMENT_NODE) ||
+ (0 <= (long) node1->content)) {
+ /*
+ * Fallback for whatever case.
+ */
+ node1 = miscNode1;
+ precedence1 = 0;
+ } else
+ misc = 1;
+ }
+ break;
+ case XML_NAMESPACE_DECL:
+ /*
+ * TODO: why do we return 1 for namespace nodes?
+ */
+ return(1);
+ default:
+ break;
+ }
+ switch (node2->type) {
+ case XML_ELEMENT_NODE:
+ break;
+ case XML_ATTRIBUTE_NODE:
+ precedence2 = 1; /* element is owner */
+ miscNode2 = node2;
+ node2 = node2->parent;
+ misc = 1;
+ break;
+ case XML_TEXT_NODE:
+ case XML_CDATA_SECTION_NODE:
+ case XML_COMMENT_NODE:
+ case XML_PI_NODE: {
+ miscNode2 = node2;
+ if (node2->prev != NULL) {
+ do {
+ node2 = node2->prev;
+ if (node2->type == XML_ELEMENT_NODE) {
+ precedence2 = 3; /* element in prev-sibl axis */
+ break;
+ }
+ if (node2->prev == NULL) {
+ precedence2 = 2; /* element is parent */
+ node2 = node2->parent;
+ break;
+ }
+ } while (1);
+ } else {
+ precedence2 = 2; /* element is parent */
+ node2 = node2->parent;
+ }
+ if ((node2 == NULL) || (node2->type != XML_ELEMENT_NODE) ||
+ (0 <= (long) node2->content))
+ {
+ node2 = miscNode2;
+ precedence2 = 0;
+ } else
+ misc = 1;
+ }
+ break;
+ case XML_NAMESPACE_DECL:
+ return(1);
+ default:
+ break;
+ }
+ if (misc) {
+ if (node1 == node2) {
+ if (precedence1 == precedence2) {
+ /*
+ * The ugly case; but normally there aren't many
+ * adjacent non-element nodes around.
+ */
+ cur = miscNode2->prev;
+ while (cur != NULL) {
+ if (cur == miscNode1)
+ return(1);
+ if (cur->type == XML_ELEMENT_NODE)
+ return(-1);
+ cur = cur->prev;
+ }
+ return (-1);
+ } else {
+ /*
+ * Evaluate based on higher precedence wrt to the element.
+ * TODO: This assumes attributes are sorted before content.
+ * Is this 100% correct?
+ */
+ if (precedence1 < precedence2)
+ return(1);
+ else
+ return(-1);
+ }
+ }
+ /*
+ * Special case: One of the helper-elements is contained by the other.
+ * <foo>
+ * <node2>
+ * <node1>Text-1(precedence1 == 2)</node1>
+ * </node2>
+ * Text-6(precedence2 == 3)
+ * </foo>
+ */
+ if ((precedence2 == 3) && (precedence1 > 1)) {
+ cur = node1->parent;
+ while (cur) {
+ if (cur == node2)
+ return(1);
+ cur = cur->parent;
+ }
+ }
+ if ((precedence1 == 3) && (precedence2 > 1)) {
+ cur = node2->parent;
+ while (cur) {
+ if (cur == node1)
+ return(-1);
+ cur = cur->parent;
+ }
+ }
+ }
+
+ /*
+ * Speedup using document order if availble.
+ */
+ if ((node1->type == XML_ELEMENT_NODE) &&
+ (node2->type == XML_ELEMENT_NODE) &&
+ (0 > (long) node1->content) &&
+ (0 > (long) node2->content) &&
+ (node1->doc == node2->doc)) {
+
+ l1 = -((long) node1->content);
+ l2 = -((long) node2->content);
+ if (l1 < l2)
+ return(1);
+ if (l1 > l2)
+ return(-1);
+ }
+
+turtle_comparison:
+
+ if (node1 == node2->prev)
+ return(1);
+ if (node1 == node2->next)
+ return(-1);
+ /*
+ * compute depth to root
+ */
+ for (depth2 = 0, cur = node2; cur->parent != NULL; cur = cur->parent) {
+ if (cur->parent == node1)
+ return(1);
+ depth2++;
+ }
+ root = cur;
+ for (depth1 = 0, cur = node1; cur->parent != NULL; cur = cur->parent) {
+ if (cur->parent == node2)
+ return(-1);
+ depth1++;
+ }
+ /*
+ * Distinct document (or distinct entities :-( ) case.
+ */
+ if (root != cur) {
+ return(-2);
+ }
+ /*
+ * get the nearest common ancestor.
+ */
+ while (depth1 > depth2) {
+ depth1--;
+ node1 = node1->parent;
+ }
+ while (depth2 > depth1) {
+ depth2--;
+ node2 = node2->parent;
+ }
+ while (node1->parent != node2->parent) {
+ node1 = node1->parent;
+ node2 = node2->parent;
+ /* should not happen but just in case ... */
+ if ((node1 == NULL) || (node2 == NULL))
+ return(-2);
+ }
+ /*
+ * Find who's first.
+ */
+ if (node1 == node2->prev)
+ return(1);
+ if (node1 == node2->next)
+ return(-1);
+ /*
+ * Speedup using document order if availble.
+ */
+ if ((node1->type == XML_ELEMENT_NODE) &&
+ (node2->type == XML_ELEMENT_NODE) &&
+ (0 > (long) node1->content) &&
+ (0 > (long) node2->content) &&
+ (node1->doc == node2->doc)) {
+
+ l1 = -((long) node1->content);
+ l2 = -((long) node2->content);
+ if (l1 < l2)
+ return(1);
+ if (l1 > l2)
+ return(-1);
+ }
+
+ for (cur = node1->next;cur != NULL;cur = cur->next)
+ if (cur == node2)
+ return(1);
+ return(-1); /* assume there is no sibling list corruption */
+}
+#endif /* XP_OPTIMIZED_NON_ELEM_COMPARISON */
+
+/*
+ * Wrapper for the Timsort argorithm from timsort.h
+ */
+#ifdef WITH_TIM_SORT
+#define SORT_NAME libxml_domnode
+#define SORT_TYPE xmlNodePtr
+/**
+ * wrap_cmp:
+ * @x: a node
+ * @y: another node
+ *
+ * Comparison function for the Timsort implementation
+ *
+ * Returns -2 in case of error -1 if first point < second point, 0 if
+ * it's the same node, +1 otherwise
+ */
+static
+int wrap_cmp( xmlNodePtr x, xmlNodePtr y );
+#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON
+ static int wrap_cmp( xmlNodePtr x, xmlNodePtr y )
+ {
+ int res = xmlXPathCmpNodesExt(x, y);
+ return res == -2 ? res : -res;
+ }
+#else
+ static int wrap_cmp( xmlNodePtr x, xmlNodePtr y )
+ {
+ int res = xmlXPathCmpNodes(x, y);
+ return res == -2 ? res : -res;
+ }
+#endif
+#define SORT_CMP(x, y) (wrap_cmp(x, y))
+#include "timsort.h"
+#endif /* WITH_TIM_SORT */
+
#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
/************************************************************************
- * *
- * Floating point stuff *
- * *
+ * *
+ * Floating point stuff *
+ * *
************************************************************************/
#ifndef TRIO_REPLACE_STDIO
@@ -142,7 +508,7 @@ xmlXPathInit(void) {
* Provides a portable isnan() function to detect whether a double
* is a NotaNumber. Based on trio code
* http://sourceforge.net/projects/ctrio/
- *
+ *
* Returns 1 if the value is a NaN, 0 otherwise
*/
int
@@ -157,7 +523,7 @@ xmlXPathIsNaN(double val) {
* Provides a portable isinf() function to detect whether a double
* is a +Infinite or -Infinite. Based on trio code
* http://sourceforge.net/projects/ctrio/
- *
+ *
* Returns 1 vi the value is +Infinite, -1 if -Infinite, 0 otherwise
*/
int
@@ -174,7 +540,7 @@ xmlXPathIsInf(double val) {
* Provides a portable function to detect the sign of a double
* Modified from trio code
* http://sourceforge.net/projects/ctrio/
- *
+ *
* Returns 1 if the value is Negative, 0 if positive
*/
static int
@@ -187,22 +553,23 @@ xmlXPathGetSign(double val) {
* TODO: when compatibility allows remove all "fake node libxslt" strings
* the test should just be name[0] = ' '
*/
-/* #define DEBUG */
-/* #define DEBUG_STEP */
-/* #define DEBUG_STEP_NTH */
-/* #define DEBUG_EXPR */
-/* #define DEBUG_EVAL_COUNTS */
+#ifdef DEBUG_XPATH_EXPRESSION
+#define DEBUG_STEP
+#define DEBUG_EXPR
+#define DEBUG_EVAL_COUNTS
+#endif
static xmlNs xmlXPathXMLNamespaceStruct = {
NULL,
XML_NAMESPACE_DECL,
XML_XML_NAMESPACE,
BAD_CAST "xml",
+ NULL,
NULL
};
static xmlNsPtr xmlXPathXMLNamespace = &xmlXPathXMLNamespaceStruct;
#ifndef LIBXML_THREAD_ENABLED
-/*
+/*
* Optimizer is disabled only when threaded apps are detected while
* the library ain't compiled for thread safety.
*/
@@ -251,6 +618,8 @@ static const char *xmlXPathErrorMessages[] = {
"Encoding error\n",
"Char out of XML range\n",
"Invalid or incomplete context\n",
+ "Stack usage error\n",
+ "Forbidden variable\n",
"?? Unknown error ??\n" /* Must be last in the list! */
};
#define MAXERRNO ((int)(sizeof(xmlXPathErrorMessages) / \
@@ -333,7 +702,7 @@ xmlXPathErr(xmlXPathParserContextPtr ctxt, int error)
error + XML_XPATH_EXPRESSION_OK - XPATH_EXPRESSION_OK,
XML_ERR_ERROR, NULL, 0,
NULL, NULL, NULL, 0, 0,
- xmlXPathErrorMessages[error]);
+ "%s", xmlXPathErrorMessages[error]);
return;
}
ctxt->error = error;
@@ -344,12 +713,12 @@ xmlXPathErr(xmlXPathParserContextPtr ctxt, int error)
XML_ERR_ERROR, NULL, 0,
(const char *) ctxt->base, NULL, NULL,
ctxt->cur - ctxt->base, 0,
- xmlXPathErrorMessages[error]);
+ "%s", xmlXPathErrorMessages[error]);
return;
}
/* cleanup current last error */
- xmlResetError(&ctxt->context->lastError);
+ xmlResetError(&ctxt->context->lastError);
ctxt->context->lastError.domain = XML_FROM_XPATH;
ctxt->context->lastError.code = error + XML_XPATH_EXPRESSION_OK -
@@ -368,7 +737,7 @@ xmlXPathErr(xmlXPathParserContextPtr ctxt, int error)
XML_ERR_ERROR, NULL, 0,
(const char *) ctxt->base, NULL, NULL,
ctxt->cur - ctxt->base, 0,
- xmlXPathErrorMessages[error]);
+ "%s", xmlXPathErrorMessages[error]);
}
}
@@ -389,9 +758,9 @@ xmlXPatherror(xmlXPathParserContextPtr ctxt, const char *file ATTRIBUTE_UNUSED,
}
/************************************************************************
- * *
- * Utilities *
- * *
+ * *
+ * Utilities *
+ * *
************************************************************************/
/**
@@ -411,15 +780,14 @@ struct _xmlPointerList {
* and here, we should make the functions public.
*/
static int
-xmlPointerListAddSize(xmlPointerListPtr list,
+xmlPointerListAddSize(xmlPointerListPtr list,
void *item,
int initialSize)
{
if (list->items == NULL) {
if (initialSize <= 0)
initialSize = 1;
- list->items = (void **) xmlMalloc(
- initialSize * sizeof(void *));
+ list->items = (void **) xmlMalloc(initialSize * sizeof(void *));
if (list->items == NULL) {
xmlXPathErrMemory(NULL,
"xmlPointerListCreate: allocating item\n");
@@ -428,12 +796,17 @@ xmlPointerListAddSize(xmlPointerListPtr list,
list->number = 0;
list->size = initialSize;
} else if (list->size <= list->number) {
+ if (list->size > 50000000) {
+ xmlXPathErrMemory(NULL,
+ "xmlPointerListAddSize: re-allocating item\n");
+ return(-1);
+ }
list->size *= 2;
list->items = (void **) xmlRealloc(list->items,
list->size * sizeof(void *));
if (list->items == NULL) {
xmlXPathErrMemory(NULL,
- "xmlPointerListCreate: re-allocating item\n");
+ "xmlPointerListAddSize: re-allocating item\n");
list->size = 0;
return(-1);
}
@@ -485,9 +858,9 @@ xmlPointerListFree(xmlPointerListPtr list)
}
/************************************************************************
- * *
- * Parser Types *
- * *
+ * *
+ * Parser Types *
+ * *
************************************************************************/
/*
@@ -532,7 +905,7 @@ typedef enum {
AXIS_PARENT,
AXIS_PRECEDING,
AXIS_PRECEDING_SIBLING,
- AXIS_SELF
+ AXIS_SELF
} xmlXPathAxisVal;
typedef enum {
@@ -548,11 +921,9 @@ typedef enum {
NODE_TYPE_NODE = 0,
NODE_TYPE_COMMENT = XML_COMMENT_NODE,
NODE_TYPE_TEXT = XML_TEXT_NODE,
- NODE_TYPE_PI = XML_PI_NODE
+ NODE_TYPE_PI = XML_PI_NODE
} xmlXPathTypeVal;
-#define XP_REWRITE_DOS_CHILD_ELEM 1
-
typedef struct _xmlXPathStepOp xmlXPathStepOp;
typedef xmlXPathStepOp *xmlXPathStepOpPtr;
struct _xmlXPathStepOp {
@@ -566,7 +937,6 @@ struct _xmlXPathStepOp {
void *value5;
void *cache;
void *cacheURI;
- int rewriteType;
};
struct _xmlXPathCompExpr {
@@ -586,9 +956,9 @@ struct _xmlXPathCompExpr {
};
/************************************************************************
- * *
- * Forward declarations *
- * *
+ * *
+ * Forward declarations *
+ * *
************************************************************************/
static void
xmlXPathFreeValueTree(xmlNodeSetPtr obj);
@@ -603,9 +973,9 @@ xmlXPathCompOpEvalToBoolean(xmlXPathParserContextPtr ctxt,
int isPredicate);
/************************************************************************
- * *
- * Parser Type functions *
- * *
+ * *
+ * Parser Type functions *
+ * *
************************************************************************/
/**
@@ -721,6 +1091,10 @@ xmlXPathCompExprAdd(xmlXPathCompExprPtr comp, int ch1, int ch2,
if (comp->nbStep >= comp->maxStep) {
xmlXPathStepOp *real;
+ if (comp->maxStep >= XPATH_MAX_STEPS) {
+ xmlXPathErrMemory(NULL, "adding step\n");
+ return(-1);
+ }
comp->maxStep *= 2;
real = (xmlXPathStepOp *) xmlRealloc(comp->steps,
comp->maxStep * sizeof(xmlXPathStepOp));
@@ -732,7 +1106,6 @@ xmlXPathCompExprAdd(xmlXPathCompExprPtr comp, int ch1, int ch2,
comp->steps = real;
}
comp->last = comp->nbStep;
- comp->steps[comp->nbStep].rewriteType = 0;
comp->steps[comp->nbStep].ch1 = ch1;
comp->steps[comp->nbStep].ch2 = ch2;
comp->steps[comp->nbStep].op = op;
@@ -795,19 +1168,19 @@ xmlXPathCompSwap(xmlXPathStepOpPtr op) {
xmlXPathCompExprAdd(ctxt->comp, ctxt->comp->last, -1, \
(op), (val), (val2), (val3), (val4), (val5))
-#define PUSH_LEAVE_EXPR(op, val, val2) \
+#define PUSH_LEAVE_EXPR(op, val, val2) \
xmlXPathCompExprAdd(ctxt->comp, -1, -1, (op), (val), (val2), 0 ,NULL ,NULL)
-#define PUSH_UNARY_EXPR(op, ch, val, val2) \
+#define PUSH_UNARY_EXPR(op, ch, val, val2) \
xmlXPathCompExprAdd(ctxt->comp, (ch), -1, (op), (val), (val2), 0 ,NULL ,NULL)
-#define PUSH_BINARY_EXPR(op, ch1, ch2, val, val2) \
+#define PUSH_BINARY_EXPR(op, ch1, ch2, val, val2) \
xmlXPathCompExprAdd(ctxt->comp, (ch1), (ch2), (op), \
(val), (val2), 0 ,NULL ,NULL)
/************************************************************************
* *
- * XPath object cache structures *
+ * XPath object cache structures *
* *
************************************************************************/
@@ -839,8 +1212,8 @@ struct _xmlXPathContextCache {
int dbgCachedLocset;
int dbgCachedUsers;
int dbgCachedXSLTTree;
- int dbgCachedUndefined;
-
+ int dbgCachedUndefined;
+
int dbgReusedAll;
int dbgReusedNodeset;
@@ -859,11 +1232,11 @@ struct _xmlXPathContextCache {
/************************************************************************
* *
- * Debugging related functions *
+ * Debugging related functions *
* *
************************************************************************/
-#define STRANGE \
+#define STRANGE \
xmlGenericError(xmlGenericErrorContext, \
"Internal error at %s:%d\n", \
__FILE__, __LINE__);
@@ -878,15 +1251,15 @@ xmlXPathDebugDumpNode(FILE *output, xmlNodePtr cur, int depth) {
shift[2 * i] = shift[2 * i + 1] = ' ';
shift[2 * i] = shift[2 * i + 1] = 0;
if (cur == NULL) {
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "Node is NULL !\n");
return;
-
+
}
if ((cur->type == XML_DOCUMENT_NODE) ||
(cur->type == XML_HTML_DOCUMENT_NODE)) {
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, " /\n");
} else if (cur->type == XML_ATTRIBUTE_NODE)
xmlDebugDumpAttr(output, (xmlAttrPtr)cur, depth);
@@ -903,10 +1276,10 @@ xmlXPathDebugDumpNodeList(FILE *output, xmlNodePtr cur, int depth) {
shift[2 * i] = shift[2 * i + 1] = ' ';
shift[2 * i] = shift[2 * i + 1] = 0;
if (cur == NULL) {
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "Node is NULL !\n");
return;
-
+
}
while (cur != NULL) {
@@ -926,16 +1299,16 @@ xmlXPathDebugDumpNodeSet(FILE *output, xmlNodeSetPtr cur, int depth) {
shift[2 * i] = shift[2 * i + 1] = 0;
if (cur == NULL) {
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "NodeSet is NULL !\n");
return;
-
+
}
if (cur != NULL) {
fprintf(output, "Set contains %d nodes:\n", cur->nodeNr);
for (i = 0;i < cur->nodeNr;i++) {
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "%d", i + 1);
xmlXPathDebugDumpNode(output, cur->nodeTab[i], depth + 1);
}
@@ -952,13 +1325,13 @@ xmlXPathDebugDumpValueTree(FILE *output, xmlNodeSetPtr cur, int depth) {
shift[2 * i] = shift[2 * i + 1] = 0;
if ((cur == NULL) || (cur->nodeNr == 0) || (cur->nodeTab[0] == NULL)) {
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "Value Tree is NULL !\n");
return;
-
+
}
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "%d", i + 1);
xmlXPathDebugDumpNodeList(output, cur->nodeTab[0]->children, depth + 1);
}
@@ -973,14 +1346,14 @@ xmlXPathDebugDumpLocationSet(FILE *output, xmlLocationSetPtr cur, int depth) {
shift[2 * i] = shift[2 * i + 1] = 0;
if (cur == NULL) {
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "LocationSet is NULL !\n");
return;
-
+
}
for (i = 0;i < cur->locNr;i++) {
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "%d : ", i + 1);
xmlXPathDebugDumpObject(output, cur->locTab[i], depth + 1);
}
@@ -1007,7 +1380,7 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
shift[2 * i] = shift[2 * i + 1] = 0;
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
if (cur == NULL) {
fprintf(output, "Object is empty (NULL)\n");
@@ -1062,7 +1435,7 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
if ((cur->user2 == NULL) ||
((cur->user2 == cur->user) && (cur->index == cur->index2))) {
fprintf(output, "Object is a collapsed range :\n");
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
if (cur->index >= 0)
fprintf(output, "index %d in ", cur->index);
fprintf(output, "node\n");
@@ -1070,14 +1443,14 @@ xmlXPathDebugDumpObject(FILE *output, xmlXPathObjectPtr cur, int depth) {
depth + 1);
} else {
fprintf(output, "Object is a range :\n");
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "From ");
if (cur->index >= 0)
fprintf(output, "index %d in ", cur->index);
fprintf(output, "node\n");
xmlXPathDebugDumpNode(output, (xmlNodePtr) cur->user,
depth + 1);
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "To ");
if (cur->index2 >= 0)
fprintf(output, "index %d in ", cur->index2);
@@ -1110,7 +1483,7 @@ xmlXPathDebugDumpStepOp(FILE *output, xmlXPathCompExprPtr comp,
shift[2 * i] = shift[2 * i + 1] = ' ';
shift[2 * i] = shift[2 * i + 1] = 0;
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
if (op == NULL) {
fprintf(output, "Step is NULL\n");
return;
@@ -1297,7 +1670,7 @@ xmlXPathDebugDumpCompExpr(FILE *output, xmlXPathCompExprPtr comp,
shift[2 * i] = shift[2 * i + 1] = ' ';
shift[2 * i] = shift[2 * i + 1] = 0;
- fprintf(output, shift);
+ fprintf(output, "%s", shift);
fprintf(output, "Compiled Expression : %d elements\n",
comp->nbStep);
@@ -1332,7 +1705,7 @@ static int xmlXPathDebugObjTotalRange = 0;
static int xmlXPathDebugObjTotalLocset = 0;
static int xmlXPathDebugObjTotalUsers = 0;
static int xmlXPathDebugObjTotalXSLTTree = 0;
-static int xmlXPathDebugObjTotalAll = 0;
+static int xmlXPathDebugObjTotalAll = 0;
static int xmlXPathDebugObjMaxUndefined = 0;
static int xmlXPathDebugObjMaxNodeset = 0;
@@ -1365,7 +1738,7 @@ xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt)
cache->dbgCachedLocset = 0;
cache->dbgCachedUsers = 0;
cache->dbgCachedXSLTTree = 0;
- cache->dbgCachedUndefined = 0;
+ cache->dbgCachedUndefined = 0;
cache->dbgReusedAll = 0;
cache->dbgReusedNodeset = 0;
@@ -1379,7 +1752,7 @@ xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt)
cache->dbgReusedXSLTTree = 0;
cache->dbgReusedUndefined = 0;
}
- }
+ }
xmlXPathDebugObjCounterUndefined = 0;
xmlXPathDebugObjCounterNodeset = 0;
@@ -1392,7 +1765,7 @@ xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt)
xmlXPathDebugObjCounterUsers = 0;
xmlXPathDebugObjCounterXSLTTree = 0;
xmlXPathDebugObjCounterAll = 0;
-
+
xmlXPathDebugObjTotalUndefined = 0;
xmlXPathDebugObjTotalNodeset = 0;
xmlXPathDebugObjTotalBool = 0;
@@ -1403,7 +1776,7 @@ xmlXPathDebugObjUsageReset(xmlXPathContextPtr ctxt)
xmlXPathDebugObjTotalLocset = 0;
xmlXPathDebugObjTotalUsers = 0;
xmlXPathDebugObjTotalXSLTTree = 0;
- xmlXPathDebugObjTotalAll = 0;
+ xmlXPathDebugObjTotalAll = 0;
xmlXPathDebugObjMaxUndefined = 0;
xmlXPathDebugObjMaxNodeset = 0;
@@ -1429,10 +1802,10 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
if (ctxt->cache != NULL) {
xmlXPathContextCachePtr cache =
(xmlXPathContextCachePtr) ctxt->cache;
-
+
isCached = 1;
-
- cache->dbgReusedAll++;
+
+ cache->dbgReusedAll++;
switch (objType) {
case XPATH_UNDEFINED:
cache->dbgReusedUndefined++;
@@ -1466,7 +1839,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
break;
default:
break;
- }
+ }
}
}
@@ -1474,7 +1847,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_UNDEFINED:
if (! isCached)
xmlXPathDebugObjTotalUndefined++;
- xmlXPathDebugObjCounterUndefined++;
+ xmlXPathDebugObjCounterUndefined++;
if (xmlXPathDebugObjCounterUndefined >
xmlXPathDebugObjMaxUndefined)
xmlXPathDebugObjMaxUndefined =
@@ -1483,7 +1856,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_NODESET:
if (! isCached)
xmlXPathDebugObjTotalNodeset++;
- xmlXPathDebugObjCounterNodeset++;
+ xmlXPathDebugObjCounterNodeset++;
if (xmlXPathDebugObjCounterNodeset >
xmlXPathDebugObjMaxNodeset)
xmlXPathDebugObjMaxNodeset =
@@ -1492,7 +1865,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_BOOLEAN:
if (! isCached)
xmlXPathDebugObjTotalBool++;
- xmlXPathDebugObjCounterBool++;
+ xmlXPathDebugObjCounterBool++;
if (xmlXPathDebugObjCounterBool >
xmlXPathDebugObjMaxBool)
xmlXPathDebugObjMaxBool =
@@ -1501,7 +1874,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_NUMBER:
if (! isCached)
xmlXPathDebugObjTotalNumber++;
- xmlXPathDebugObjCounterNumber++;
+ xmlXPathDebugObjCounterNumber++;
if (xmlXPathDebugObjCounterNumber >
xmlXPathDebugObjMaxNumber)
xmlXPathDebugObjMaxNumber =
@@ -1510,7 +1883,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_STRING:
if (! isCached)
xmlXPathDebugObjTotalString++;
- xmlXPathDebugObjCounterString++;
+ xmlXPathDebugObjCounterString++;
if (xmlXPathDebugObjCounterString >
xmlXPathDebugObjMaxString)
xmlXPathDebugObjMaxString =
@@ -1519,7 +1892,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_POINT:
if (! isCached)
xmlXPathDebugObjTotalPoint++;
- xmlXPathDebugObjCounterPoint++;
+ xmlXPathDebugObjCounterPoint++;
if (xmlXPathDebugObjCounterPoint >
xmlXPathDebugObjMaxPoint)
xmlXPathDebugObjMaxPoint =
@@ -1546,7 +1919,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_USERS:
if (! isCached)
xmlXPathDebugObjTotalUsers++;
- xmlXPathDebugObjCounterUsers++;
+ xmlXPathDebugObjCounterUsers++;
if (xmlXPathDebugObjCounterUsers >
xmlXPathDebugObjMaxUsers)
xmlXPathDebugObjMaxUsers =
@@ -1555,7 +1928,7 @@ xmlXPathDebugObjUsageRequested(xmlXPathContextPtr ctxt,
case XPATH_XSLT_TREE:
if (! isCached)
xmlXPathDebugObjTotalXSLTTree++;
- xmlXPathDebugObjCounterXSLTTree++;
+ xmlXPathDebugObjCounterXSLTTree++;
if (xmlXPathDebugObjCounterXSLTTree >
xmlXPathDebugObjMaxXSLTTree)
xmlXPathDebugObjMaxXSLTTree =
@@ -1584,8 +1957,8 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
xmlXPathContextCachePtr cache =
(xmlXPathContextCachePtr) ctxt->cache;
- isCached = 1;
-
+ isCached = 1;
+
cache->dbgCachedAll++;
switch (objType) {
case XPATH_UNDEFINED:
@@ -1621,7 +1994,7 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
default:
break;
}
-
+
}
}
switch (objType) {
@@ -1657,7 +2030,7 @@ xmlXPathDebugObjUsageReleased(xmlXPathContextPtr ctxt,
break;
default:
break;
- }
+ }
xmlXPathDebugObjCounterAll--;
}
@@ -1680,7 +2053,7 @@ xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt)
reqNumber = xmlXPathDebugObjTotalNumber;
reqXSLTTree = xmlXPathDebugObjTotalXSLTTree;
reqUndefined = xmlXPathDebugObjTotalUndefined;
-
+
printf("# XPath object usage:\n");
if (ctxt != NULL) {
@@ -1702,7 +2075,7 @@ xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt)
reqXSLTTree += reXSLTTree;
reUndefined = cache->dbgReusedUndefined;
reqUndefined += reUndefined;
-
+
caAll = cache->dbgCachedAll;
caBool = cache->dbgCachedBool;
caNodeset = cache->dbgCachedNodeset;
@@ -1710,7 +2083,7 @@ xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt)
caNumber = cache->dbgCachedNumber;
caXSLTTree = cache->dbgCachedXSLTTree;
caUndefined = cache->dbgCachedUndefined;
-
+
if (cache->nodesetObjs)
leftObjs -= cache->nodesetObjs->number;
if (cache->stringObjs)
@@ -1723,8 +2096,8 @@ xmlXPathDebugObjUsageDisplay(xmlXPathContextPtr ctxt)
leftObjs -= cache->miscObjs->number;
}
}
-
- printf("# all\n");
+
+ printf("# all\n");
printf("# total : %d\n", reqAll);
printf("# left : %d\n", leftObjs);
printf("# created: %d\n", xmlXPathDebugObjTotalAll);
@@ -1847,7 +2220,7 @@ xmlXPathFreeCache(xmlXPathContextCachePtr cache)
if (cache->numberObjs)
xmlXPathCacheFreeObjectList(cache->numberObjs);
if (cache->miscObjs)
- xmlXPathCacheFreeObjectList(cache->miscObjs);
+ xmlXPathCacheFreeObjectList(cache->miscObjs);
xmlFree(cache);
}
@@ -1856,7 +2229,7 @@ xmlXPathFreeCache(xmlXPathContextCachePtr cache)
*
* @ctxt: the XPath context
* @active: enables/disables (creates/frees) the cache
- * @value: a value with semantics dependant on @options
+ * @value: a value with semantics dependant on @options
* @options: options (currently only the value 0 is used)
*
* Creates/frees an object cache on the XPath context.
@@ -1883,7 +2256,7 @@ xmlXPathContextSetCache(xmlXPathContextPtr ctxt,
return(-1);
if (active) {
xmlXPathContextCachePtr cache;
-
+
if (ctxt->cache == NULL) {
ctxt->cache = xmlXPathNewCache();
if (ctxt->cache == NULL)
@@ -1918,7 +2291,7 @@ xmlXPathContextSetCache(xmlXPathContextPtr ctxt,
*/
static xmlXPathObjectPtr
xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
-{
+{
if ((ctxt != NULL) && (ctxt->cache != NULL)) {
xmlXPathContextCachePtr cache =
(xmlXPathContextCachePtr) ctxt->cache;
@@ -1927,7 +2300,7 @@ xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
(cache->miscObjs->number != 0))
{
xmlXPathObjectPtr ret;
-
+
ret = (xmlXPathObjectPtr)
cache->miscObjs->items[--cache->miscObjs->number];
ret->type = XPATH_NODESET;
@@ -1935,12 +2308,12 @@ xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
#ifdef XP_DEBUG_OBJ_USAGE
xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
#endif
- return(ret);
+ return(ret);
}
}
-
+
return(xmlXPathWrapNodeSet(val));
-
+
}
/**
@@ -1955,16 +2328,16 @@ xmlXPathCacheWrapNodeSet(xmlXPathContextPtr ctxt, xmlNodeSetPtr val)
*/
static xmlXPathObjectPtr
xmlXPathCacheWrapString(xmlXPathContextPtr ctxt, xmlChar *val)
-{
+{
if ((ctxt != NULL) && (ctxt->cache != NULL)) {
xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
if ((cache->stringObjs != NULL) &&
(cache->stringObjs->number != 0))
{
-
+
xmlXPathObjectPtr ret;
-
+
ret = (xmlXPathObjectPtr)
cache->stringObjs->items[--cache->stringObjs->number];
ret->type = XPATH_STRING;
@@ -2013,20 +2386,20 @@ xmlXPathCacheNewNodeSet(xmlXPathContextPtr ctxt, xmlNodePtr val)
if ((cache->nodesetObjs != NULL) &&
(cache->nodesetObjs->number != 0))
- {
+ {
xmlXPathObjectPtr ret;
/*
* Use the nodset-cache.
- */
+ */
ret = (xmlXPathObjectPtr)
cache->nodesetObjs->items[--cache->nodesetObjs->number];
ret->type = XPATH_NODESET;
ret->boolval = 0;
- if (val) {
+ if (val) {
if ((ret->nodesetval->nodeMax == 0) ||
(val->type == XML_NAMESPACE_DECL))
{
- xmlXPathNodeSetAddUnique(ret->nodesetval, val);
+ xmlXPathNodeSetAddUnique(ret->nodesetval, val);
} else {
ret->nodesetval->nodeTab[0] = val;
ret->nodesetval->nodeNr = 1;
@@ -2050,6 +2423,11 @@ xmlXPathCacheNewNodeSet(xmlXPathContextPtr ctxt, xmlNodePtr val)
ret->type = XPATH_NODESET;
ret->boolval = 0;
ret->nodesetval = xmlXPathNodeSetCreate(val);
+ if (ret->nodesetval == NULL) {
+ ctxt->lastError.domain = XML_FROM_XPATH;
+ ctxt->lastError.code = XML_ERR_NO_MEMORY;
+ return(NULL);
+ }
#ifdef XP_DEBUG_OBJ_USAGE
xmlXPathDebugObjUsageRequested(ctxt, XPATH_NODESET);
#endif
@@ -2071,15 +2449,15 @@ xmlXPathCacheNewNodeSet(xmlXPathContextPtr ctxt, xmlNodePtr val)
*/
static xmlXPathObjectPtr
xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val)
-{
+{
if ((ctxt != NULL) && (ctxt->cache)) {
xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
if ((cache->stringObjs != NULL) &&
(cache->stringObjs->number != 0))
- {
+ {
xmlXPathObjectPtr ret;
-
+
ret = (xmlXPathObjectPtr)
cache->stringObjs->items[--cache->stringObjs->number];
@@ -2120,15 +2498,15 @@ xmlXPathCacheNewCString(xmlXPathContextPtr ctxt, const char *val)
*/
static xmlXPathObjectPtr
xmlXPathCacheNewString(xmlXPathContextPtr ctxt, const xmlChar *val)
-{
+{
if ((ctxt != NULL) && (ctxt->cache)) {
xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
if ((cache->stringObjs != NULL) &&
(cache->stringObjs->number != 0))
- {
+ {
xmlXPathObjectPtr ret;
-
+
ret = (xmlXPathObjectPtr)
cache->stringObjs->items[--cache->stringObjs->number];
ret->type = XPATH_STRING;
@@ -2174,15 +2552,15 @@ xmlXPathCacheNewString(xmlXPathContextPtr ctxt, const xmlChar *val)
*/
static xmlXPathObjectPtr
xmlXPathCacheNewBoolean(xmlXPathContextPtr ctxt, int val)
-{
+{
if ((ctxt != NULL) && (ctxt->cache)) {
xmlXPathContextCachePtr cache = (xmlXPathContextCachePtr) ctxt->cache;
if ((cache->booleanObjs != NULL) &&
(cache->booleanObjs->number != 0))
- {
+ {
xmlXPathObjectPtr ret;
-
+
ret = (xmlXPathObjectPtr)
cache->booleanObjs->items[--cache->booleanObjs->number];
ret->type = XPATH_BOOLEAN;
@@ -2228,9 +2606,9 @@ xmlXPathCacheNewFloat(xmlXPathContextPtr ctxt, double val)
if ((cache->numberObjs != NULL) &&
(cache->numberObjs->number != 0))
- {
+ {
xmlXPathObjectPtr ret;
-
+
ret = (xmlXPathObjectPtr)
cache->numberObjs->items[--cache->numberObjs->number];
ret->type = XPATH_NUMBER;
@@ -2272,7 +2650,7 @@ xmlXPathCacheNewFloat(xmlXPathContextPtr ctxt, double val)
static xmlXPathObjectPtr
xmlXPathCacheConvertString(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
- xmlChar *res = NULL;
+ xmlChar *res = NULL;
if (val == NULL)
return(xmlXPathCacheNewCString(ctxt, ""));
@@ -2356,7 +2734,7 @@ xmlXPathCacheObjectCopy(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val)
static xmlXPathObjectPtr
xmlXPathCacheConvertBoolean(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
xmlXPathObjectPtr ret;
-
+
if (val == NULL)
return(xmlXPathCacheNewBoolean(ctxt, 0));
if (val->type == XPATH_BOOLEAN)
@@ -2380,7 +2758,7 @@ xmlXPathCacheConvertBoolean(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
static xmlXPathObjectPtr
xmlXPathCacheConvertNumber(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
xmlXPathObjectPtr ret;
-
+
if (val == NULL)
return(xmlXPathCacheNewFloat(ctxt, 0.0));
if (val->type == XPATH_NUMBER)
@@ -2392,11 +2770,47 @@ xmlXPathCacheConvertNumber(xmlXPathContextPtr ctxt, xmlXPathObjectPtr val) {
/************************************************************************
* *
- * Parser stacks related functions and macros *
+ * Parser stacks related functions and macros *
* *
************************************************************************/
/**
+ * xmlXPathSetFrame:
+ * @ctxt: an XPath parser context
+ *
+ * Set the callee evaluation frame
+ *
+ * Returns the previous frame value to be restored once done
+ */
+static int
+xmlXPathSetFrame(xmlXPathParserContextPtr ctxt) {
+ int ret;
+
+ if (ctxt == NULL)
+ return(0);
+ ret = ctxt->valueFrame;
+ ctxt->valueFrame = ctxt->valueNr;
+ return(ret);
+}
+
+/**
+ * xmlXPathPopFrame:
+ * @ctxt: an XPath parser context
+ * @frame: the previous frame value
+ *
+ * Remove the callee evaluation frame
+ */
+static void
+xmlXPathPopFrame(xmlXPathParserContextPtr ctxt, int frame) {
+ if (ctxt == NULL)
+ return;
+ if (ctxt->valueNr < ctxt->valueFrame) {
+ xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR);
+ }
+ ctxt->valueFrame = frame;
+}
+
+/**
* valuePop:
* @ctxt: an XPath evaluation context
*
@@ -2411,6 +2825,12 @@ valuePop(xmlXPathParserContextPtr ctxt)
if ((ctxt == NULL) || (ctxt->valueNr <= 0))
return (NULL);
+
+ if (ctxt->valueNr <= ctxt->valueFrame) {
+ xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_STACK_ERROR);
+ return (NULL);
+ }
+
ctxt->valueNr--;
if (ctxt->valueNr > 0)
ctxt->value = ctxt->valueTab[ctxt->valueNr - 1];
@@ -2436,11 +2856,17 @@ valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value)
if (ctxt->valueNr >= ctxt->valueMax) {
xmlXPathObjectPtr *tmp;
+ if (ctxt->valueMax >= XPATH_MAX_STACK_DEPTH) {
+ xmlXPathErrMemory(NULL, "XPath stack depth limit reached\n");
+ ctxt->error = XPATH_MEMORY_ERROR;
+ return (0);
+ }
tmp = (xmlXPathObjectPtr *) xmlRealloc(ctxt->valueTab,
2 * ctxt->valueMax *
sizeof(ctxt->valueTab[0]));
if (tmp == NULL) {
- xmlGenericError(xmlGenericErrorContext, "realloc failed !\n");
+ xmlXPathErrMemory(NULL, "pushing value\n");
+ ctxt->error = XPATH_MEMORY_ERROR;
return (0);
}
ctxt->valueMax *= 2;
@@ -2631,7 +3057,7 @@ xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) {
#define NEXTL(l) ctxt->cur += l
-#define SKIP_BLANKS \
+#define SKIP_BLANKS \
while (IS_BLANK_CH(*(ctxt->cur))) NEXT
#define CURRENT (*ctxt->cur)
@@ -2647,9 +3073,10 @@ xmlXPathPopExternal (xmlXPathParserContextPtr ctxt) {
#define UPPER_DOUBLE 1E9
#define LOWER_DOUBLE 1E-5
+#define LOWER_DOUBLE_EXP 5
#define INTEGER_DIGITS DBL_DIG
-#define FRACTION_DIGITS (DBL_DIG + 1)
+#define FRACTION_DIGITS (DBL_DIG + 1 + (LOWER_DOUBLE_EXP))
#define EXPONENT_DIGITS (3 + 2)
/**
@@ -2700,8 +3127,16 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
*ptr = 0;
}
} else {
- /* 3 is sign, decimal point, and terminating zero */
- char work[DBL_DIG + EXPONENT_DIGITS + 3];
+ /*
+ For the dimension of work,
+ DBL_DIG is number of significant digits
+ EXPONENT is only needed for "scientific notation"
+ 3 is sign, decimal point, and terminating zero
+ LOWER_DOUBLE_EXP is max number of leading zeroes in fraction
+ Note that this dimension is slightly (a few characters)
+ larger than actually necessary.
+ */
+ char work[DBL_DIG + EXPONENT_DIGITS + 3 + LOWER_DOUBLE_EXP];
int integer_place, fraction_place;
char *ptr;
char *after_fraction;
@@ -2724,24 +3159,31 @@ xmlXPathFormatNumber(double number, char buffer[], int buffersize)
size = snprintf(work, sizeof(work),"%*.*e",
integer_place, fraction_place, number);
while ((size > 0) && (work[size] != 'e')) size--;
- after_fraction = work + size;
}
else {
/* Use regular notation */
- if (absolute_value > 0.0)
- integer_place = 1 + (int)log10(absolute_value);
- else
- integer_place = 0;
- fraction_place = (integer_place > 0)
- ? DBL_DIG - integer_place
- : DBL_DIG;
+ if (absolute_value > 0.0) {
+ integer_place = (int)log10(absolute_value);
+ if (integer_place > 0)
+ fraction_place = DBL_DIG - integer_place - 1;
+ else
+ fraction_place = DBL_DIG - integer_place;
+ } else {
+ fraction_place = 1;
+ }
size = snprintf(work, sizeof(work), "%0.*f",
fraction_place, number);
- after_fraction = work + size;
+ }
+
+ /* Remove leading spaces sometimes inserted by snprintf */
+ while (work[0] == ' ') {
+ for (ptr = &work[0];(ptr[0] = ptr[1]);ptr++);
+ size--;
}
/* Remove fractional trailing zeroes */
+ after_fraction = work + size;
ptr = after_fraction;
while (*(--ptr) == '0')
;
@@ -2840,6 +3282,8 @@ xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) {
/*
* a couple of optimizations which will avoid computations in most cases
*/
+ if (node1 == node2) /* trivial case */
+ return(0);
if (node1->type == XML_ATTRIBUTE_NODE) {
attr1 = 1;
attrNode1 = node1;
@@ -2963,297 +3407,6 @@ xmlXPathCmpNodes(xmlNodePtr node1, xmlNodePtr node2) {
return(-1); /* assume there is no sibling list corruption */
}
-#ifdef XP_OPTIMIZED_NON_ELEM_COMPARISON
-/**
- * xmlXPathCmpNodesExt:
- * @node1: the first node
- * @node2: the second node
- *
- * Compare two nodes w.r.t document order.
- * This one is optimized for handling of non-element nodes.
- *
- * Returns -2 in case of error 1 if first point < second point, 0 if
- * it's the same node, -1 otherwise
- */
-static int
-xmlXPathCmpNodesExt(xmlNodePtr node1, xmlNodePtr node2) {
- int depth1, depth2;
- int misc = 0, precedence1 = 0, precedence2 = 0;
- xmlNodePtr miscNode1 = NULL, miscNode2 = NULL;
- xmlNodePtr cur, root;
- long l1, l2;
-
- if ((node1 == NULL) || (node2 == NULL))
- return(-2);
-
- if (node1 == node2)
- return(0);
-
- /*
- * a couple of optimizations which will avoid computations in most cases
- */
- switch (node1->type) {
- case XML_ELEMENT_NODE:
- if (node2->type == XML_ELEMENT_NODE) {
- if ((0 > (long) node1->content) && /* TODO: Would a != 0 suffice here? */
- (0 > (long) node2->content) &&
- (node1->doc == node2->doc))
- {
- l1 = -((long) node1->content);
- l2 = -((long) node2->content);
- if (l1 < l2)
- return(1);
- if (l1 > l2)
- return(-1);
- } else
- goto turtle_comparison;
- }
- break;
- case XML_ATTRIBUTE_NODE:
- precedence1 = 1; /* element is owner */
- miscNode1 = node1;
- node1 = node1->parent;
- misc = 1;
- break;
- case XML_TEXT_NODE:
- case XML_CDATA_SECTION_NODE:
- case XML_COMMENT_NODE:
- case XML_PI_NODE: {
- miscNode1 = node1;
- /*
- * Find nearest element node.
- */
- if (node1->prev != NULL) {
- do {
- node1 = node1->prev;
- if (node1->type == XML_ELEMENT_NODE) {
- precedence1 = 3; /* element in prev-sibl axis */
- break;
- }
- if (node1->prev == NULL) {
- precedence1 = 2; /* element is parent */
- /*
- * URGENT TODO: Are there any cases, where the
- * parent of such a node is not an element node?
- */
- node1 = node1->parent;
- break;
- }
- } while (1);
- } else {
- precedence1 = 2; /* element is parent */
- node1 = node1->parent;
- }
- if ((node1 == NULL) || (node1->type != XML_ELEMENT_NODE)) {
- /*
- * Fallback for whatever case.
- */
- node1 = miscNode1;
- precedence1 = 0;
- } else
- misc = 1;
- }
- break;
- case XML_NAMESPACE_DECL:
- /*
- * TODO: why do we return 1 for namespace nodes?
- */
- return(1);
- default:
- break;
- }
- switch (node2->type) {
- case XML_ELEMENT_NODE:
- break;
- case XML_ATTRIBUTE_NODE:
- precedence2 = 1; /* element is owner */
- miscNode2 = node2;
- node2 = node2->parent;
- misc = 1;
- break;
- case XML_TEXT_NODE:
- case XML_CDATA_SECTION_NODE:
- case XML_COMMENT_NODE:
- case XML_PI_NODE: {
- miscNode2 = node2;
- if (node2->prev != NULL) {
- do {
- node2 = node2->prev;
- if (node2->type == XML_ELEMENT_NODE) {
- precedence2 = 3; /* element in prev-sibl axis */
- break;
- }
- if (node2->prev == NULL) {
- precedence2 = 2; /* element is parent */
- node2 = node2->parent;
- break;
- }
- } while (1);
- } else {
- precedence2 = 2; /* element is parent */
- node2 = node2->parent;
- }
- if ((node2 == NULL) || (node2->type != XML_ELEMENT_NODE) ||
- (0 <= (long) node1->content))
- {
- node2 = miscNode2;
- precedence2 = 0;
- } else
- misc = 1;
- }
- break;
- case XML_NAMESPACE_DECL:
- return(1);
- default:
- break;
- }
- if (misc) {
- if (node1 == node2) {
- if (precedence1 == precedence2) {
- /*
- * The ugly case; but normally there aren't many
- * adjacent non-element nodes around.
- */
- cur = miscNode2->prev;
- while (cur != NULL) {
- if (cur == miscNode1)
- return(1);
- if (cur->type == XML_ELEMENT_NODE)
- return(-1);
- cur = cur->prev;
- }
- return (-1);
- } else {
- /*
- * Evaluate based on higher precedence wrt to the element.
- * TODO: This assumes attributes are sorted before content.
- * Is this 100% correct?
- */
- if (precedence1 < precedence2)
- return(1);
- else
- return(-1);
- }
- }
- /*
- * Special case: One of the helper-elements is contained by the other.
- * <foo>
- * <node2>
- * <node1>Text-1(precedence1 == 2)</node1>
- * </node2>
- * Text-6(precedence2 == 3)
- * </foo>
- */
- if ((precedence2 == 3) && (precedence1 > 1)) {
- cur = node1->parent;
- while (cur) {
- if (cur == node2)
- return(1);
- cur = cur->parent;
- }
- }
- if ((precedence1 == 3) && (precedence2 > 1)) {
- cur = node2->parent;
- while (cur) {
- if (cur == node1)
- return(-1);
- cur = cur->parent;
- }
- }
- }
-
- /*
- * Speedup using document order if availble.
- */
- if ((node1->type == XML_ELEMENT_NODE) &&
- (node2->type == XML_ELEMENT_NODE) &&
- (0 > (long) node1->content) &&
- (0 > (long) node2->content) &&
- (node1->doc == node2->doc)) {
-
- l1 = -((long) node1->content);
- l2 = -((long) node2->content);
- if (l1 < l2)
- return(1);
- if (l1 > l2)
- return(-1);
- }
-
-turtle_comparison:
-
- if (node1 == node2->prev)
- return(1);
- if (node1 == node2->next)
- return(-1);
- /*
- * compute depth to root
- */
- for (depth2 = 0, cur = node2;cur->parent != NULL;cur = cur->parent) {
- if (cur == node1)
- return(1);
- depth2++;
- }
- root = cur;
- for (depth1 = 0, cur = node1;cur->parent != NULL;cur = cur->parent) {
- if (cur == node2)
- return(-1);
- depth1++;
- }
- /*
- * Distinct document (or distinct entities :-( ) case.
- */
- if (root != cur) {
- return(-2);
- }
- /*
- * get the nearest common ancestor.
- */
- while (depth1 > depth2) {
- depth1--;
- node1 = node1->parent;
- }
- while (depth2 > depth1) {
- depth2--;
- node2 = node2->parent;
- }
- while (node1->parent != node2->parent) {
- node1 = node1->parent;
- node2 = node2->parent;
- /* should not happen but just in case ... */
- if ((node1 == NULL) || (node2 == NULL))
- return(-2);
- }
- /*
- * Find who's first.
- */
- if (node1 == node2->prev)
- return(1);
- if (node1 == node2->next)
- return(-1);
- /*
- * Speedup using document order if availble.
- */
- if ((node1->type == XML_ELEMENT_NODE) &&
- (node2->type == XML_ELEMENT_NODE) &&
- (0 > (long) node1->content) &&
- (0 > (long) node2->content) &&
- (node1->doc == node2->doc)) {
-
- l1 = -((long) node1->content);
- l2 = -((long) node2->content);
- if (l1 < l2)
- return(1);
- if (l1 > l2)
- return(-1);
- }
-
- for (cur = node1->next;cur != NULL;cur = cur->next)
- if (cur == node2)
- return(1);
- return(-1); /* assume there is no sibling list corruption */
-}
-#endif /* XP_OPTIMIZED_NON_ELEM_COMPARISON */
-
/**
* xmlXPathNodeSetSort:
* @set: the node set
@@ -3262,13 +3415,19 @@ turtle_comparison:
*/
void
xmlXPathNodeSetSort(xmlNodeSetPtr set) {
+#ifndef WITH_TIM_SORT
int i, j, incr, len;
xmlNodePtr tmp;
+#endif
if (set == NULL)
return;
- /* Use Shell's sort to sort the node-set */
+#ifndef WITH_TIM_SORT
+ /*
+ * Use the old Shell's sort implementation to sort the node-set
+ * Timsort ought to be quite faster
+ */
len = set->nodeNr;
for (incr = len / 2; incr > 0; incr /= 2) {
for (i = incr; i < len; i++) {
@@ -3291,6 +3450,9 @@ xmlXPathNodeSetSort(xmlNodeSetPtr set) {
}
}
}
+#else /* WITH_TIM_SORT */
+ libxml_domnode_tim_sort(set->nodeTab, set->nodeNr);
+#endif /* WITH_TIM_SORT */
}
#define XML_NODESET_DEFAULT 10
@@ -3325,9 +3487,9 @@ xmlXPathNodeSetDupNs(xmlNodePtr node, xmlNsPtr ns) {
memset(cur, 0, sizeof(xmlNs));
cur->type = XML_NAMESPACE_DECL;
if (ns->href != NULL)
- cur->href = xmlStrdup(ns->href);
+ cur->href = xmlStrdup(ns->href);
if (ns->prefix != NULL)
- cur->prefix = xmlStrdup(ns->prefix);
+ cur->prefix = xmlStrdup(ns->prefix);
cur->next = (xmlNsPtr) node;
return((xmlNodePtr) cur);
}
@@ -3421,7 +3583,7 @@ xmlXPathNodeSetCreateSize(int size) {
return(NULL);
}
memset(ret->nodeTab, 0 , size * (size_t) sizeof(xmlNodePtr));
- ret->nodeMax = size;
+ ret->nodeMax = size;
return(ret);
}
@@ -3469,16 +3631,18 @@ xmlXPathNodeSetContains (xmlNodeSetPtr cur, xmlNodePtr val) {
* @ns: a the namespace node
*
* add a new namespace node to an existing NodeSet
+ *
+ * Returns 0 in case of success and -1 in case of error
*/
-void
+int
xmlXPathNodeSetAddNs(xmlNodeSetPtr cur, xmlNodePtr node, xmlNsPtr ns) {
int i;
-
+
if ((cur == NULL) || (ns == NULL) || (node == NULL) ||
(ns->type != XML_NAMESPACE_DECL) ||
(node->type != XML_ELEMENT_NODE))
- return;
+ return(-1);
/* @@ with_ns to check whether namespace nodes should be looked at @@ */
/*
@@ -3489,7 +3653,7 @@ xmlXPathNodeSetAddNs(xmlNodeSetPtr cur, xmlNodePtr node, xmlNsPtr ns) {
(cur->nodeTab[i]->type == XML_NAMESPACE_DECL) &&
(((xmlNsPtr)cur->nodeTab[i])->next == (xmlNsPtr) node) &&
(xmlStrEqual(ns->prefix, ((xmlNsPtr)cur->nodeTab[i])->prefix)))
- return;
+ return(0);
}
/*
@@ -3500,7 +3664,7 @@ xmlXPathNodeSetAddNs(xmlNodeSetPtr cur, xmlNodePtr node, xmlNsPtr ns) {
sizeof(xmlNodePtr));
if (cur->nodeTab == NULL) {
xmlXPathErrMemory(NULL, "growing nodeset\n");
- return;
+ return(-1);
}
memset(cur->nodeTab, 0 ,
XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
@@ -3508,16 +3672,21 @@ xmlXPathNodeSetAddNs(xmlNodeSetPtr cur, xmlNodePtr node, xmlNsPtr ns) {
} else if (cur->nodeNr == cur->nodeMax) {
xmlNodePtr *temp;
- cur->nodeMax *= 2;
- temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax *
+ if (cur->nodeMax >= XPATH_MAX_NODESET_LENGTH) {
+ xmlXPathErrMemory(NULL, "growing nodeset hit limit\n");
+ return(-1);
+ }
+ temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * 2 *
sizeof(xmlNodePtr));
if (temp == NULL) {
xmlXPathErrMemory(NULL, "growing nodeset\n");
- return;
+ return(-1);
}
+ cur->nodeMax *= 2;
cur->nodeTab = temp;
}
cur->nodeTab[cur->nodeNr++] = xmlXPathNodeSetDupNs(node, ns);
+ return(0);
}
/**
@@ -3526,24 +3695,21 @@ xmlXPathNodeSetAddNs(xmlNodeSetPtr cur, xmlNodePtr node, xmlNsPtr ns) {
* @val: a new xmlNodePtr
*
* add a new xmlNodePtr to an existing NodeSet
+ *
+ * Returns 0 in case of success, and -1 in case of error
*/
-void
+int
xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
int i;
- if ((cur == NULL) || (val == NULL)) return;
-
-#if 0
- if ((val->type == XML_ELEMENT_NODE) && (val->name[0] == ' '))
- return; /* an XSLT fake node */
-#endif
+ if ((cur == NULL) || (val == NULL)) return(-1);
/* @@ with_ns to check whether namespace nodes should be looked at @@ */
/*
* prevent duplcates
*/
for (i = 0;i < cur->nodeNr;i++)
- if (cur->nodeTab[i] == val) return;
+ if (cur->nodeTab[i] == val) return(0);
/*
* grow the nodeTab if needed
@@ -3553,7 +3719,7 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
sizeof(xmlNodePtr));
if (cur->nodeTab == NULL) {
xmlXPathErrMemory(NULL, "growing nodeset\n");
- return;
+ return(-1);
}
memset(cur->nodeTab, 0 ,
XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
@@ -3561,22 +3727,27 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
} else if (cur->nodeNr == cur->nodeMax) {
xmlNodePtr *temp;
- cur->nodeMax *= 2;
- temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax *
+ if (cur->nodeMax >= XPATH_MAX_NODESET_LENGTH) {
+ xmlXPathErrMemory(NULL, "growing nodeset hit limit\n");
+ return(-1);
+ }
+ temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * 2 *
sizeof(xmlNodePtr));
if (temp == NULL) {
xmlXPathErrMemory(NULL, "growing nodeset\n");
- return;
+ return(-1);
}
+ cur->nodeMax *= 2;
cur->nodeTab = temp;
}
if (val->type == XML_NAMESPACE_DECL) {
xmlNsPtr ns = (xmlNsPtr) val;
- cur->nodeTab[cur->nodeNr++] =
+ cur->nodeTab[cur->nodeNr++] =
xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
} else
cur->nodeTab[cur->nodeNr++] = val;
+ return(0);
}
/**
@@ -3586,15 +3757,12 @@ xmlXPathNodeSetAdd(xmlNodeSetPtr cur, xmlNodePtr val) {
*
* add a new xmlNodePtr to an existing NodeSet, optimized version
* when we are sure the node is not already in the set.
+ *
+ * Returns 0 in case of success and -1 in case of failure
*/
-void
+int
xmlXPathNodeSetAddUnique(xmlNodeSetPtr cur, xmlNodePtr val) {
- if ((cur == NULL) || (val == NULL)) return;
-
-#if 0
- if ((val->type == XML_ELEMENT_NODE) && (val->name[0] == ' '))
- return; /* an XSLT fake node */
-#endif
+ if ((cur == NULL) || (val == NULL)) return(-1);
/* @@ with_ns to check whether namespace nodes should be looked at @@ */
/*
@@ -3605,7 +3773,7 @@ xmlXPathNodeSetAddUnique(xmlNodeSetPtr cur, xmlNodePtr val) {
sizeof(xmlNodePtr));
if (cur->nodeTab == NULL) {
xmlXPathErrMemory(NULL, "growing nodeset\n");
- return;
+ return(-1);
}
memset(cur->nodeTab, 0 ,
XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
@@ -3613,22 +3781,27 @@ xmlXPathNodeSetAddUnique(xmlNodeSetPtr cur, xmlNodePtr val) {
} else if (cur->nodeNr == cur->nodeMax) {
xmlNodePtr *temp;
- cur->nodeMax *= 2;
- temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax *
+ if (cur->nodeMax >= XPATH_MAX_NODESET_LENGTH) {
+ xmlXPathErrMemory(NULL, "growing nodeset hit limit\n");
+ return(-1);
+ }
+ temp = (xmlNodePtr *) xmlRealloc(cur->nodeTab, cur->nodeMax * 2 *
sizeof(xmlNodePtr));
if (temp == NULL) {
xmlXPathErrMemory(NULL, "growing nodeset\n");
- return;
+ return(-1);
}
cur->nodeTab = temp;
+ cur->nodeMax *= 2;
}
if (val->type == XML_NAMESPACE_DECL) {
xmlNsPtr ns = (xmlNsPtr) val;
- cur->nodeTab[cur->nodeNr++] =
+ cur->nodeTab[cur->nodeNr++] =
xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
} else
cur->nodeTab[cur->nodeNr++] = val;
+ return(0);
}
/**
@@ -3649,6 +3822,8 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
if (val2 == NULL) return(val1);
if (val1 == NULL) {
val1 = xmlXPathNodeSetCreate(NULL);
+ if (val1 == NULL)
+ return (NULL);
#if 0
/*
* TODO: The optimization won't work in every case, since
@@ -3658,7 +3833,7 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
* If there was a flag on the nodesetval, indicating that
* some temporary nodes are in, that would be helpfull.
*/
- /*
+ /*
* Optimization: Create an equally sized node-set
* and memcpy the content.
*/
@@ -3682,7 +3857,7 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
initNr = val1->nodeNr;
for (i = 0;i < val2->nodeNr;i++) {
- n2 = val2->nodeTab[i];
+ n2 = val2->nodeTab[i];
/*
* check against duplicates
*/
@@ -3693,7 +3868,7 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
skip = 1;
break;
} else if ((n1->type == XML_NAMESPACE_DECL) &&
- (n2->type == XML_NAMESPACE_DECL)) {
+ (n2->type == XML_NAMESPACE_DECL)) {
if ((((xmlNsPtr) n1)->next == ((xmlNsPtr) n2)->next) &&
(xmlStrEqual(((xmlNsPtr) n1)->prefix,
((xmlNsPtr) n2)->prefix)))
@@ -3722,14 +3897,18 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
} else if (val1->nodeNr == val1->nodeMax) {
xmlNodePtr *temp;
- val1->nodeMax *= 2;
- temp = (xmlNodePtr *) xmlRealloc(val1->nodeTab, val1->nodeMax *
+ if (val1->nodeMax >= XPATH_MAX_NODESET_LENGTH) {
+ xmlXPathErrMemory(NULL, "merging nodeset hit limit\n");
+ return(NULL);
+ }
+ temp = (xmlNodePtr *) xmlRealloc(val1->nodeTab, val1->nodeMax * 2 *
sizeof(xmlNodePtr));
if (temp == NULL) {
xmlXPathErrMemory(NULL, "merging nodeset\n");
return(NULL);
}
val1->nodeTab = temp;
+ val1->nodeMax *= 2;
}
if (n2->type == XML_NAMESPACE_DECL) {
xmlNsPtr ns = (xmlNsPtr) n2;
@@ -3743,66 +3922,6 @@ xmlXPathNodeSetMerge(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
return(val1);
}
-#if 0 /* xmlXPathNodeSetMergeUnique() is currently not used anymore */
-/**
- * xmlXPathNodeSetMergeUnique:
- * @val1: the first NodeSet or NULL
- * @val2: the second NodeSet
- *
- * Merges two nodesets, all nodes from @val2 are added to @val1
- * if @val1 is NULL, a new set is created and copied from @val2
- *
- * Returns @val1 once extended or NULL in case of error.
- */
-static xmlNodeSetPtr
-xmlXPathNodeSetMergeUnique(xmlNodeSetPtr val1, xmlNodeSetPtr val2) {
- int i;
-
- if (val2 == NULL) return(val1);
- if (val1 == NULL) {
- val1 = xmlXPathNodeSetCreate(NULL);
- }
-
- /* @@ with_ns to check whether namespace nodes should be looked at @@ */
-
- for (i = 0;i < val2->nodeNr;i++) {
- /*
- * grow the nodeTab if needed
- */
- if (val1->nodeMax == 0) {
- val1->nodeTab = (xmlNodePtr *) xmlMalloc(XML_NODESET_DEFAULT *
- sizeof(xmlNodePtr));
- if (val1->nodeTab == NULL) {
- xmlXPathErrMemory(NULL, "merging nodeset\n");
- return(NULL);
- }
- memset(val1->nodeTab, 0 ,
- XML_NODESET_DEFAULT * (size_t) sizeof(xmlNodePtr));
- val1->nodeMax = XML_NODESET_DEFAULT;
- } else if (val1->nodeNr == val1->nodeMax) {
- xmlNodePtr *temp;
-
- val1->nodeMax *= 2;
- temp = (xmlNodePtr *) xmlRealloc(val1->nodeTab, val1->nodeMax *
- sizeof(xmlNodePtr));
- if (temp == NULL) {
- xmlXPathErrMemory(NULL, "merging nodeset\n");
- return(NULL);
- }
- val1->nodeTab = temp;
- }
- if (val2->nodeTab[i]->type == XML_NAMESPACE_DECL) {
- xmlNsPtr ns = (xmlNsPtr) val2->nodeTab[i];
-
- val1->nodeTab[val1->nodeNr++] =
- xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
- } else
- val1->nodeTab[val1->nodeNr++] = val2->nodeTab[i];
- }
-
- return(val1);
-}
-#endif /* xmlXPathNodeSetMergeUnique() is currently not used anymore */
/**
* xmlXPathNodeSetMergeAndClear:
@@ -3838,9 +3957,11 @@ xmlXPathNodeSetMergeAndClear(xmlNodeSetPtr set1, xmlNodeSetPtr set2,
xmlNodePtr n1, n2;
if (set1 == NULL)
- set1 = xmlXPathNodeSetCreate(NULL);
+ set1 = xmlXPathNodeSetCreate(NULL);
+ if (set1 == NULL)
+ return (NULL);
- initNbSet1 = set1->nodeNr;
+ initNbSet1 = set1->nodeNr;
for (i = 0;i < set2->nodeNr;i++) {
n2 = set2->nodeTab[i];
/*
@@ -3853,11 +3974,11 @@ xmlXPathNodeSetMergeAndClear(xmlNodeSetPtr set1, xmlNodeSetPtr set2,
*/
for (j = 0; j < initNbSet1; j++) {
n1 = set1->nodeTab[j];
- if (n1 == n2) {
+ if (n1 == n2) {
goto skip_node;
} else if ((n1->type == XML_NAMESPACE_DECL) &&
(n2->type == XML_NAMESPACE_DECL))
- {
+ {
if ((((xmlNsPtr) n1)->next == ((xmlNsPtr) n2)->next) &&
(xmlStrEqual(((xmlNsPtr) n1)->prefix,
((xmlNsPtr) n2)->prefix)))
@@ -3886,19 +4007,23 @@ xmlXPathNodeSetMergeAndClear(xmlNodeSetPtr set1, xmlNodeSetPtr set2,
set1->nodeMax = XML_NODESET_DEFAULT;
} else if (set1->nodeNr >= set1->nodeMax) {
xmlNodePtr *temp;
-
- set1->nodeMax *= 2;
+
+ if (set1->nodeMax >= XPATH_MAX_NODESET_LENGTH) {
+ xmlXPathErrMemory(NULL, "merging nodeset hit limit\n");
+ return(NULL);
+ }
temp = (xmlNodePtr *) xmlRealloc(
- set1->nodeTab, set1->nodeMax * sizeof(xmlNodePtr));
+ set1->nodeTab, set1->nodeMax * 2 * sizeof(xmlNodePtr));
if (temp == NULL) {
xmlXPathErrMemory(NULL, "merging nodeset\n");
return(NULL);
}
set1->nodeTab = temp;
+ set1->nodeMax *= 2;
}
if (n2->type == XML_NAMESPACE_DECL) {
xmlNsPtr ns = (xmlNsPtr) n2;
-
+
set1->nodeTab[set1->nodeNr++] =
xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
} else
@@ -3926,7 +4051,7 @@ skip_node:
static xmlNodeSetPtr
xmlXPathNodeSetMergeAndClearNoDupls(xmlNodeSetPtr set1, xmlNodeSetPtr set2,
int hasNullEntries)
-{
+{
if (set2 == NULL)
return(set1);
if ((set1 == NULL) && (hasNullEntries == 0)) {
@@ -3948,14 +4073,16 @@ xmlXPathNodeSetMergeAndClearNoDupls(xmlNodeSetPtr set1, xmlNodeSetPtr set2,
if (set1 == NULL)
set1 = xmlXPathNodeSetCreate(NULL);
-
+ if (set1 == NULL)
+ return (NULL);
+
for (i = 0;i < set2->nodeNr;i++) {
n2 = set2->nodeTab[i];
/*
* Skip NULLed entries.
*/
if (n2 == NULL)
- continue;
+ continue;
if (set1->nodeMax == 0) {
set1->nodeTab = (xmlNodePtr *) xmlMalloc(
XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
@@ -3968,15 +4095,19 @@ xmlXPathNodeSetMergeAndClearNoDupls(xmlNodeSetPtr set1, xmlNodeSetPtr set2,
set1->nodeMax = XML_NODESET_DEFAULT;
} else if (set1->nodeNr >= set1->nodeMax) {
xmlNodePtr *temp;
-
- set1->nodeMax *= 2;
+
+ if (set1->nodeMax >= XPATH_MAX_NODESET_LENGTH) {
+ xmlXPathErrMemory(NULL, "merging nodeset hit limit\n");
+ return(NULL);
+ }
temp = (xmlNodePtr *) xmlRealloc(
- set1->nodeTab, set1->nodeMax * sizeof(xmlNodePtr));
+ set1->nodeTab, set1->nodeMax * 2 * sizeof(xmlNodePtr));
if (temp == NULL) {
xmlXPathErrMemory(NULL, "merging nodeset\n");
return(NULL);
}
set1->nodeTab = temp;
+ set1->nodeMax *= 2;
}
set1->nodeTab[set1->nodeNr++] = n2;
}
@@ -4007,7 +4138,7 @@ xmlXPathNodeSetDel(xmlNodeSetPtr cur, xmlNodePtr val) {
if (i >= cur->nodeNr) { /* not found */
#ifdef DEBUG
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"xmlXPathNodeSetDel: Node %s wasn't found in NodeList\n",
val->name);
#endif
@@ -4067,7 +4198,7 @@ xmlXPathFreeNodeSet(xmlNodeSetPtr obj) {
/**
* xmlXPathNodeSetClear:
* @set: the node set to clear
- *
+ *
* Clears the list from all temporary XPath objects (e.g. namespace nodes
* are feed), but does *not* free the list itself. Sets the length of the
* list to 0.
@@ -4080,13 +4211,13 @@ xmlXPathNodeSetClear(xmlNodeSetPtr set, int hasNsNodes)
else if (hasNsNodes) {
int i;
xmlNodePtr node;
-
+
for (i = 0; i < set->nodeNr; i++) {
node = set->nodeTab[i];
if ((node != NULL) &&
(node->type == XML_NAMESPACE_DECL))
xmlXPathNodeSetFreeNs((xmlNsPtr) node);
- }
+ }
}
set->nodeNr = 0;
}
@@ -4095,7 +4226,7 @@ xmlXPathNodeSetClear(xmlNodeSetPtr set, int hasNsNodes)
* xmlXPathNodeSetClearFromPos:
* @set: the node set to be cleared
* @pos: the start position to clear from
- *
+ *
* Clears the list from temporary XPath objects (e.g. namespace nodes
* are feed) starting with the entry at @pos, but does *not* free the list
* itself. Sets the length of the list to @pos.
@@ -4108,13 +4239,13 @@ xmlXPathNodeSetClearFromPos(xmlNodeSetPtr set, int pos, int hasNsNodes)
else if ((hasNsNodes)) {
int i;
xmlNodePtr node;
-
+
for (i = pos; i < set->nodeNr; i++) {
node = set->nodeTab[i];
if ((node != NULL) &&
(node->type == XML_NAMESPACE_DECL))
xmlXPathNodeSetFreeNs((xmlNsPtr) node);
- }
+ }
}
set->nodeNr = pos;
}
@@ -4267,8 +4398,12 @@ xmlXPathNewNodeSetList(xmlNodeSetPtr val)
ret = xmlXPathNewNodeSet(NULL);
else {
ret = xmlXPathNewNodeSet(val->nodeTab[0]);
- for (i = 1; i < val->nodeNr; ++i)
- xmlXPathNodeSetAddUnique(ret->nodesetval, val->nodeTab[i]);
+ if (ret) {
+ for (i = 1; i < val->nodeNr; ++i) {
+ if (xmlXPathNodeSetAddUnique(ret->nodesetval, val->nodeTab[i])
+ < 0) break;
+ }
+ }
}
return (ret);
@@ -4344,8 +4479,10 @@ xmlXPathDifference (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) {
for (i = 0; i < l1; i++) {
cur = xmlXPathNodeSetItem(nodes1, i);
- if (!xmlXPathNodeSetContains(nodes2, cur))
- xmlXPathNodeSetAddUnique(ret, cur);
+ if (!xmlXPathNodeSetContains(nodes2, cur)) {
+ if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
+ break;
+ }
}
return(ret);
}
@@ -4367,6 +4504,8 @@ xmlXPathIntersection (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) {
int i, l1;
xmlNodePtr cur;
+ if (ret == NULL)
+ return(ret);
if (xmlXPathNodeSetIsEmpty(nodes1))
return(ret);
if (xmlXPathNodeSetIsEmpty(nodes2))
@@ -4376,8 +4515,10 @@ xmlXPathIntersection (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) {
for (i = 0; i < l1; i++) {
cur = xmlXPathNodeSetItem(nodes1, i);
- if (xmlXPathNodeSetContains(nodes2, cur))
- xmlXPathNodeSetAddUnique(ret, cur);
+ if (xmlXPathNodeSetContains(nodes2, cur)) {
+ if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
+ break;
+ }
}
return(ret);
}
@@ -4388,7 +4529,7 @@ xmlXPathIntersection (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) {
*
* Implements the EXSLT - Sets distinct() function:
* node-set set:distinct (node-set)
- *
+ *
* Returns a subset of the nodes contained in @nodes, or @nodes if
* it is empty
*/
@@ -4404,6 +4545,8 @@ xmlXPathDistinctSorted (xmlNodeSetPtr nodes) {
return(nodes);
ret = xmlXPathNodeSetCreate(NULL);
+ if (ret == NULL)
+ return(ret);
l = xmlXPathNodeSetGetLength(nodes);
hash = xmlHashCreate (l);
for (i = 0; i < l; i++) {
@@ -4411,7 +4554,8 @@ xmlXPathDistinctSorted (xmlNodeSetPtr nodes) {
strval = xmlXPathCastNodeToString(cur);
if (xmlHashLookup(hash, strval) == NULL) {
xmlHashAddEntry(hash, strval, strval);
- xmlXPathNodeSetAddUnique(ret, cur);
+ if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
+ break;
} else {
xmlFree(strval);
}
@@ -4492,6 +4636,8 @@ xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, xmlNodePtr node) {
return(nodes);
ret = xmlXPathNodeSetCreate(NULL);
+ if (ret == NULL)
+ return(ret);
if (xmlXPathNodeSetIsEmpty(nodes) ||
(!xmlXPathNodeSetContains(nodes, node)))
return(ret);
@@ -4501,7 +4647,8 @@ xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes, xmlNodePtr node) {
cur = xmlXPathNodeSetItem(nodes, i);
if (cur == node)
break;
- xmlXPathNodeSetAddUnique(ret, cur);
+ if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
+ break;
}
return(ret);
}
@@ -4594,17 +4741,21 @@ xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes, xmlNodePtr node) {
return(nodes);
ret = xmlXPathNodeSetCreate(NULL);
+ if (ret == NULL)
+ return(ret);
if (xmlXPathNodeSetIsEmpty(nodes) ||
(!xmlXPathNodeSetContains(nodes, node)))
return(ret);
l = xmlXPathNodeSetGetLength(nodes);
- for (i = l; i > 0; i--) {
+ for (i = l - 1; i >= 0; i--) {
cur = xmlXPathNodeSetItem(nodes, i);
if (cur == node)
break;
- xmlXPathNodeSetAddUnique(ret, cur);
+ if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
+ break;
}
+ xmlXPathNodeSetSort(ret); /* bug 413451 */
return(ret);
}
@@ -4690,7 +4841,7 @@ xmlXPathTrailing (xmlNodeSetPtr nodes1, xmlNodeSetPtr nodes2) {
*
* Returns 0 in case of success, -1 in case of error
*/
-int
+int
xmlXPathRegisterFunc(xmlXPathContextPtr ctxt, const xmlChar *name,
xmlXPathFunction f) {
return(xmlXPathRegisterFuncNS(ctxt, name, NULL, f));
@@ -4784,7 +4935,7 @@ xmlXPathFunction
xmlXPathFunctionLookupNS(xmlXPathContextPtr ctxt, const xmlChar *name,
const xmlChar *ns_uri) {
xmlXPathFunction ret;
-
+
if (ctxt == NULL)
return(NULL);
if (name == NULL)
@@ -4838,7 +4989,7 @@ xmlXPathRegisteredFuncsCleanup(xmlXPathContextPtr ctxt) {
*
* Returns 0 in case of success, -1 in case of error
*/
-int
+int
xmlXPathRegisterVariable(xmlXPathContextPtr ctxt, const xmlChar *name,
xmlXPathObjectPtr value) {
return(xmlXPathRegisterVariableNS(ctxt, name, NULL, value));
@@ -4870,7 +5021,7 @@ xmlXPathRegisterVariableNS(xmlXPathContextPtr ctxt, const xmlChar *name,
if (ctxt->varHash == NULL)
return(-1);
if (value == NULL)
- return(xmlHashRemoveEntry2(ctxt->varHash, name, ns_uri,
+ return(xmlHashRemoveEntry2(ctxt->varHash, name, ns_uri,
(xmlHashDeallocator)xmlXPathFreeObject));
return(xmlHashUpdateEntry2(ctxt->varHash, name, ns_uri,
(void *) value,
@@ -4926,7 +5077,7 @@ xmlXPathVariableLookup(xmlXPathContextPtr ctxt, const xmlChar *name) {
* @ns_uri: the variable namespace URI
*
* Search in the Variable array of the context for the given
- * variable value.
+ * variable value.
*
* Returns the a copy of the value or NULL if not found
*/
@@ -4971,7 +5122,7 @@ xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt) {
/**
* xmlXPathRegisterNs:
* @ctxt: the XPath context
- * @prefix: the namespace prefix
+ * @prefix: the namespace prefix cannot be NULL or empty string
* @ns_uri: the namespace name
*
* Register a new namespace. If @ns_uri is NULL it unregisters
@@ -4986,6 +5137,8 @@ xmlXPathRegisterNs(xmlXPathContextPtr ctxt, const xmlChar *prefix,
return(-1);
if (prefix == NULL)
return(-1);
+ if (prefix[0] == 0)
+ return(-1);
if (ctxt->nsHash == NULL)
ctxt->nsHash = xmlHashCreate(10);
@@ -5309,7 +5462,7 @@ xmlXPathObjectCopy(xmlXPathObjectPtr val) {
#endif
case XPATH_USERS:
ret->user = val->user;
- break;
+ break;
case XPATH_UNDEFINED:
xmlGenericError(xmlGenericErrorContext,
"xmlXPathObjectCopy: unsupported type %d\n",
@@ -5338,7 +5491,7 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) {
#endif
obj->type = XPATH_XSLT_TREE; /* TODO: Just for debugging. */
if (obj->nodesetval != NULL)
- xmlXPathFreeValueTree(obj->nodesetval);
+ xmlXPathFreeValueTree(obj->nodesetval);
} else {
if (obj->nodesetval != NULL)
xmlXPathFreeNodeSet(obj->nodesetval);
@@ -5355,7 +5508,7 @@ xmlXPathFreeObject(xmlXPathObjectPtr obj) {
#ifdef XP_DEBUG_OBJ_USAGE
xmlXPathDebugObjUsageReleased(NULL, obj->type);
#endif
- xmlFree(obj);
+ xmlFree(obj);
}
/**
@@ -5378,7 +5531,7 @@ xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
return;
if ((ctxt == NULL) || (ctxt->cache == NULL)) {
xmlXPathFreeObject(obj);
- } else {
+ } else {
xmlXPathContextCachePtr cache =
(xmlXPathContextCachePtr) ctxt->cache;
@@ -5387,7 +5540,7 @@ xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
case XPATH_XSLT_TREE:
if (obj->nodesetval != NULL) {
if (obj->boolval) {
- /*
+ /*
* It looks like the @boolval is used for
* evaluation if this an XSLT Result Tree Fragment.
* TODO: Check if this assumption is correct.
@@ -5434,7 +5587,7 @@ xmlXPathReleaseObject(xmlXPathContextPtr ctxt, xmlXPathObjectPtr obj)
xmlXPtrFreeLocationSet(obj->user);
}
goto free_obj;
-#endif
+#endif
default:
goto free_obj;
}
@@ -5455,7 +5608,7 @@ obj_cached:
if (obj->nodesetval != NULL) {
xmlNodeSetPtr tmpset = obj->nodesetval;
-
+
/*
* TODO: Due to those nasty ns-nodes, we need to traverse
* the list and free the ns-nodes.
@@ -5478,7 +5631,7 @@ obj_cached:
if ((tmpset->nodeTab[0] != NULL) &&
(tmpset->nodeTab[0]->type == XML_NAMESPACE_DECL))
xmlXPathNodeSetFreeNs((xmlNsPtr) tmpset->nodeTab[0]);
- }
+ }
tmpset->nodeNr = 0;
memset(obj, 0, sizeof(xmlXPathObject));
obj->nodesetval = tmpset;
@@ -5490,7 +5643,7 @@ obj_cached:
free_obj:
/*
* Cache is full; free the object.
- */
+ */
if (obj->nodesetval != NULL)
xmlXPathFreeNodeSet(obj->nodesetval);
#ifdef XP_DEBUG_OBJ_USAGE
@@ -5570,7 +5723,10 @@ xmlXPathCastNumberToString (double val) {
*/
xmlChar *
xmlXPathCastNodeToString (xmlNodePtr node) {
- return(xmlNodeGetContent(node));
+xmlChar *ret;
+ if ((ret = xmlNodeGetContent(node)) == NULL)
+ ret = xmlStrdup((const xmlChar *) "");
+ return(ret);
}
/**
@@ -5598,7 +5754,7 @@ xmlXPathCastNodeSetToString (xmlNodeSetPtr ns) {
* Converts an existing object to its string() equivalent
*
* Returns the allocated string value of the object, NULL in case of error.
- * It's up to the caller to free the string memory with xmlFree().
+ * It's up to the caller to free the string memory with xmlFree().
*/
xmlChar *
xmlXPathCastToString(xmlXPathObjectPtr val) {
@@ -5989,7 +6145,7 @@ xmlXPathNewContext(xmlDocPtr doc) {
}
#endif
- xmlXPathRegisterAllFunctions(ret);
+ xmlXPathRegisterAllFunctions(ret);
return(ret);
}
@@ -6020,7 +6176,7 @@ xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
************************************************************************/
#define CHECK_CTXT(ctxt) \
- if (ctxt == NULL) { \
+ if (ctxt == NULL) { \
__xmlRaiseError(NULL, NULL, NULL, \
NULL, NULL, XML_FROM_XPATH, \
XML_ERR_INTERNAL_ERROR, XML_ERR_FATAL, \
@@ -6031,7 +6187,7 @@ xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
} \
#define CHECK_CTXT_NEG(ctxt) \
- if (ctxt == NULL) { \
+ if (ctxt == NULL) { \
__xmlRaiseError(NULL, NULL, NULL, \
NULL, NULL, XML_FROM_XPATH, \
XML_ERR_INTERNAL_ERROR, XML_ERR_FATAL, \
@@ -6044,7 +6200,7 @@ xmlXPathFreeContext(xmlXPathContextPtr ctxt) {
#define CHECK_CONTEXT(ctxt) \
if ((ctxt == NULL) || (ctxt->doc == NULL) || \
- (ctxt->doc->children == NULL)) { \
+ (ctxt->doc->children == NULL)) { \
xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_INVALID_CTXT); \
return(NULL); \
}
@@ -6107,7 +6263,7 @@ xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) {
memset(ret, 0 , (size_t) sizeof(xmlXPathParserContext));
/* Allocate the value stack */
- ret->valueTab = (xmlXPathObjectPtr *)
+ ret->valueTab = (xmlXPathObjectPtr *)
xmlMalloc(10 * sizeof(xmlXPathObjectPtr));
if (ret->valueTab == NULL) {
xmlFree(ret);
@@ -6117,6 +6273,7 @@ xmlXPathCompParserContext(xmlXPathCompExprPtr comp, xmlXPathContextPtr ctxt) {
ret->valueNr = 0;
ret->valueMax = 10;
ret->value = NULL;
+ ret->valueFrame = 0;
ret->context = ctxt;
ret->comp = comp;
@@ -6254,7 +6411,7 @@ xmlXPathNodeValHash(xmlNodePtr node) {
tmp = tmp->next;
continue;
}
-
+
do {
tmp = tmp->parent;
if (tmp == NULL)
@@ -6413,7 +6570,7 @@ xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
* If both objects to be compared are node-sets, then the comparison
* will be true if and only if there is a node in the first node-set
* and a node in the second node-set such that the result of performing
- * the comparison on the string-values of the two nodes is true.
+ * the comparison on the string-values of the two nodes is true.
* ....
* When neither object to be compared is a node-set and the operator
* is <=, <, >= or >, then the objects are compared by converting both
@@ -6427,7 +6584,7 @@ xmlXPathCompareNodeSetString(xmlXPathParserContextPtr ctxt, int inf, int strict,
* represented by the string; any other string is converted to NaN
*
* Conclusion all nodes need to be converted first to their string value
- * and then the comparison must be done when possible
+ * and then the comparison must be done when possible
*/
static int
xmlXPathCompareNodeSets(int inf, int strict,
@@ -6482,7 +6639,7 @@ xmlXPathCompareNodeSets(int inf, int strict,
}
if (xmlXPathIsNaN(values2[j]))
continue;
- if (inf && strict)
+ if (inf && strict)
ret = (val1 < values2[j]);
else if (inf && !strict)
ret = (val1 <= values2[j]);
@@ -6822,7 +6979,7 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
case XPATH_STRING:
if ((arg2->stringval == NULL) ||
(arg2->stringval[0] == 0)) ret = 0;
- else
+ else
ret = 1;
ret = (arg1->boolval == ret);
break;
@@ -6857,7 +7014,7 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
case XPATH_NUMBER:
/* Hand check NaN and Infinity equalities */
if (xmlXPathIsNaN(arg1->floatval) ||
- xmlXPathIsNaN(arg2->floatval)) {
+ xmlXPathIsNaN(arg2->floatval)) {
ret = 0;
} else if (xmlXPathIsInf(arg1->floatval) == 1) {
if (xmlXPathIsInf(arg2->floatval) == 1)
@@ -6905,7 +7062,7 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
case XPATH_BOOLEAN:
if ((arg1->stringval == NULL) ||
(arg1->stringval[0] == 0)) ret = 0;
- else
+ else
ret = 1;
ret = (arg2->boolval == ret);
break;
@@ -6918,7 +7075,7 @@ xmlXPathEqualValuesCommon(xmlXPathParserContextPtr ctxt,
arg1 = valuePop(ctxt);
/* Hand check NaN and Infinity equalities */
if (xmlXPathIsNaN(arg1->floatval) ||
- xmlXPathIsNaN(arg2->floatval)) {
+ xmlXPathIsNaN(arg2->floatval)) {
ret = 0;
} else if (xmlXPathIsInf(arg1->floatval) == 1) {
if (xmlXPathIsInf(arg2->floatval) == 1)
@@ -6984,7 +7141,7 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
int ret = 0;
if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
- arg2 = valuePop(ctxt);
+ arg2 = valuePop(ctxt);
arg1 = valuePop(ctxt);
if ((arg1 == NULL) || (arg2 == NULL)) {
if (arg1 != NULL)
@@ -7030,7 +7187,7 @@ xmlXPathEqualValues(xmlXPathParserContextPtr ctxt) {
case XPATH_BOOLEAN:
if ((arg1->nodesetval == NULL) ||
(arg1->nodesetval->nodeNr == 0)) ret = 0;
- else
+ else
ret = 1;
ret = (ret == arg2->boolval);
break;
@@ -7069,7 +7226,7 @@ xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
int ret = 0;
if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
- arg2 = valuePop(ctxt);
+ arg2 = valuePop(ctxt);
arg1 = valuePop(ctxt);
if ((arg1 == NULL) || (arg2 == NULL)) {
if (arg1 != NULL)
@@ -7115,7 +7272,7 @@ xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
case XPATH_BOOLEAN:
if ((arg1->nodesetval == NULL) ||
(arg1->nodesetval->nodeNr == 0)) ret = 0;
- else
+ else
ret = 1;
ret = (ret != arg2->boolval);
break;
@@ -7146,7 +7303,7 @@ xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt) {
* @inf: less than (1) or greater than (0)
* @strict: is the comparison strict
*
- * Implement the compare operation on XPath objects:
+ * Implement the compare operation on XPath objects:
* @arg1 < @arg2 (1, 1, ...
* @arg1 <= @arg2 (1, 0, ...
* @arg1 > @arg2 (0, 1, ...
@@ -7170,7 +7327,7 @@ xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict) {
xmlXPathObjectPtr arg1, arg2;
if ((ctxt == NULL) || (ctxt->context == NULL)) return(0);
- arg2 = valuePop(ctxt);
+ arg2 = valuePop(ctxt);
arg1 = valuePop(ctxt);
if ((arg1 == NULL) || (arg2 == NULL)) {
if (arg1 != NULL)
@@ -7411,7 +7568,7 @@ xmlXPathDivValues(xmlXPathParserContextPtr ctxt) {
ctxt->value->floatval = xmlXPathPINF;
else if (ctxt->value->floatval < 0)
ctxt->value->floatval = xmlXPathNINF;
- } else
+ } else
ctxt->value->floatval /= val;
}
@@ -7619,6 +7776,7 @@ xmlXPathNextChildElement(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
return(NULL);
}
+#if 0
/**
* xmlXPathNextDescendantOrSelfElemParent:
* @ctxt: the XPath Parser context
@@ -7646,10 +7804,10 @@ xmlXPathNextDescendantOrSelfElemParent(xmlNodePtr cur,
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
- case XML_HTML_DOCUMENT_NODE:
+ case XML_HTML_DOCUMENT_NODE:
return(contextNode);
default:
- return(NULL);
+ return(NULL);
}
return(NULL);
} else {
@@ -7660,7 +7818,7 @@ xmlXPathNextDescendantOrSelfElemParent(xmlNodePtr cur,
case XML_ELEMENT_NODE:
/* TODO: OK to have XInclude here? */
case XML_XINCLUDE_START:
- case XML_DOCUMENT_FRAG_NODE:
+ case XML_DOCUMENT_FRAG_NODE:
if (cur != start)
return(cur);
if (cur->children != NULL) {
@@ -7668,9 +7826,9 @@ xmlXPathNextDescendantOrSelfElemParent(xmlNodePtr cur,
continue;
}
break;
-#ifdef LIBXML_DOCB_ENABLED
/* Not sure if we need those here. */
case XML_DOCUMENT_NODE:
+#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
case XML_HTML_DOCUMENT_NODE:
@@ -7679,13 +7837,13 @@ xmlXPathNextDescendantOrSelfElemParent(xmlNodePtr cur,
return(xmlDocGetRootElement((xmlDocPtr) cur));
default:
break;
- }
-
+ }
+
next_sibling:
if ((cur == NULL) || (cur == contextNode))
- return(NULL);
+ return(NULL);
if (cur->next != NULL) {
- cur = cur->next;
+ cur = cur->next;
} else {
cur = cur->parent;
goto next_sibling;
@@ -7693,7 +7851,8 @@ next_sibling:
}
}
return(NULL);
-}
+}
+#endif
/**
* xmlXPathNextDescendant:
@@ -7721,11 +7880,13 @@ xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
return(ctxt->context->node->children);
}
+ if (cur->type == XML_NAMESPACE_DECL)
+ return(NULL);
if (cur->children != NULL) {
/*
* Do not descend on entities declarations
*/
- if (cur->children->type != XML_ENTITY_DECL) {
+ if (cur->children->type != XML_ENTITY_DECL) {
cur = cur->children;
/*
* Skip DTDs
@@ -7743,7 +7904,7 @@ xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
(cur->type != XML_DTD_NODE))
return(cur);
}
-
+
do {
cur = cur->parent;
if (cur == NULL) break;
@@ -7772,14 +7933,14 @@ xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
xmlNodePtr
xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
- if (cur == NULL) {
- if (ctxt->context->node == NULL)
- return(NULL);
- if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
- (ctxt->context->node->type == XML_NAMESPACE_DECL))
- return(NULL);
+ if (cur == NULL)
return(ctxt->context->node);
- }
+
+ if (ctxt->context->node == NULL)
+ return(NULL);
+ if ((ctxt->context->node->type == XML_ATTRIBUTE_NODE) ||
+ (ctxt->context->node->type == XML_NAMESPACE_DECL))
+ return(NULL);
return(xmlXPathNextDescendant(ctxt, cur));
}
@@ -7842,7 +8003,7 @@ xmlXPathNextParent(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
return(NULL);
case XML_NAMESPACE_DECL: {
xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
-
+
if ((ns->next != NULL) &&
(ns->next->type != XML_NAMESPACE_DECL))
return((xmlNodePtr) ns->next);
@@ -7915,7 +8076,7 @@ xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
return(NULL);
case XML_NAMESPACE_DECL: {
xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
-
+
if ((ns->next != NULL) &&
(ns->next->type != XML_NAMESPACE_DECL))
return((xmlNodePtr) ns->next);
@@ -7959,7 +8120,7 @@ xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
}
case XML_NAMESPACE_DECL: {
xmlNsPtr ns = (xmlNsPtr) ctxt->context->node;
-
+
if ((ns->next != NULL) &&
(ns->next->type != XML_NAMESPACE_DECL))
return((xmlNodePtr) ns->next);
@@ -8069,9 +8230,17 @@ xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
xmlNodePtr
xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
- if (cur != NULL && cur->children != NULL)
- return cur->children ;
- if (cur == NULL) cur = ctxt->context->node;
+ if ((cur != NULL) && (cur->type != XML_ATTRIBUTE_NODE) &&
+ (cur->type != XML_NAMESPACE_DECL) && (cur->children != NULL))
+ return(cur->children);
+
+ if (cur == NULL) {
+ cur = ctxt->context->node;
+ if (cur->type == XML_NAMESPACE_DECL)
+ return(NULL);
+ if (cur->type == XML_ATTRIBUTE_NODE)
+ cur = cur->parent;
+ }
if (cur == NULL) return(NULL) ; /* ERROR */
if (cur->next != NULL) return(cur->next) ;
do {
@@ -8095,6 +8264,10 @@ xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
static int
xmlXPathIsAncestor(xmlNodePtr ancestor, xmlNodePtr node) {
if ((ancestor == NULL) || (node == NULL)) return(0);
+ if (node->type == XML_NAMESPACE_DECL)
+ return(0);
+ if (ancestor->type == XML_NAMESPACE_DECL)
+ return(0);
/* nodes need to be in the same document */
if (ancestor->doc != node->doc) return(0);
/* avoid searching if ancestor or node is the root node */
@@ -8125,9 +8298,14 @@ xmlNodePtr
xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur)
{
if ((ctxt == NULL) || (ctxt->context == NULL)) return(NULL);
- if (cur == NULL)
+ if (cur == NULL) {
cur = ctxt->context->node;
- if (cur == NULL)
+ if (cur->type == XML_NAMESPACE_DECL)
+ return(NULL);
+ if (cur->type == XML_ATTRIBUTE_NODE)
+ return(cur->parent);
+ }
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
return (NULL);
if ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE))
cur = cur->prev;
@@ -8156,7 +8334,7 @@ xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt, xmlNodePtr cur)
* node that are before the context node in document order, excluding any
* ancestors and excluding attribute nodes and namespace nodes; the nodes are
* ordered in reverse document order
- * This is a faster implementation but internal only since it requires a
+ * This is a faster implementation but internal only since it requires a
* state kept in the parser context: ctxt->ancestor.
*
* Returns the next element following that axis
@@ -8170,10 +8348,12 @@ xmlXPathNextPrecedingInternal(xmlXPathParserContextPtr ctxt,
cur = ctxt->context->node;
if (cur == NULL)
return (NULL);
- if (cur->type == XML_NAMESPACE_DECL)
- cur = (xmlNodePtr)((xmlNsPtr)cur)->next;
+ if (cur->type == XML_NAMESPACE_DECL)
+ return (NULL);
ctxt->ancestor = cur->parent;
}
+ if (cur->type == XML_NAMESPACE_DECL)
+ return(NULL);
if ((cur->prev != NULL) && (cur->prev->type == XML_DTD_NODE))
cur = cur->prev;
while (cur->prev == NULL) {
@@ -8213,7 +8393,7 @@ xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt, xmlNodePtr cur) {
if (ctxt->context->tmpNsList == NULL && cur != (xmlNodePtr) xmlXPathXMLNamespace) {
if (ctxt->context->tmpNsList != NULL)
xmlFree(ctxt->context->tmpNsList);
- ctxt->context->tmpNsList =
+ ctxt->context->tmpNsList =
xmlGetNsList(ctxt->context->doc, ctxt->context->node);
ctxt->context->tmpNsNr = 0;
if (ctxt->context->tmpNsList != NULL) {
@@ -8361,7 +8541,7 @@ xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr cur;
CHECK_ARITY(1);
- if ((ctxt->value == NULL) ||
+ if ((ctxt->value == NULL) ||
((ctxt->value->type != XPATH_NODESET) &&
(ctxt->value->type != XPATH_XSLT_TREE)))
XP_ERROR(XPATH_INVALID_TYPE);
@@ -8381,7 +8561,7 @@ xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs) {
int i = 0;
tmp = cur->nodesetval->nodeTab[0];
- if (tmp != NULL) {
+ if ((tmp != NULL) && (tmp->type != XML_NAMESPACE_DECL)) {
tmp = tmp->children;
while (tmp != NULL) {
tmp = tmp->next;
@@ -8414,6 +8594,8 @@ xmlXPathGetElementsByIds (xmlDocPtr doc, const xmlChar *ids) {
if (ids == NULL) return(NULL);
ret = xmlXPathNodeSetCreate(NULL);
+ if (ret == NULL)
+ return(ret);
while (IS_BLANK_CH(*cur)) cur++;
while (*cur != 0) {
@@ -8481,6 +8663,11 @@ xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs) {
int i;
ret = xmlXPathNodeSetCreate(NULL);
+ /*
+ * FIXME -- in an out-of-memory condition this will behave badly.
+ * The solution is not clear -- we already popped an item from
+ * ctxt, so the object is in a corrupt state.
+ */
if (obj->nodesetval != NULL) {
for (i = 0; i < obj->nodesetval->nodeNr; i++) {
@@ -8499,7 +8686,7 @@ xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs) {
}
obj = xmlXPathCacheConvertString(ctxt->context, obj);
ret = xmlXPathGetElementsByIds(ctxt->context->doc, obj->stringval);
- valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret));
+ valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret));
xmlXPathReleaseObject(ctxt->context, obj);
return;
}
@@ -8530,7 +8717,7 @@ xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs) {
}
CHECK_ARITY(1);
- if ((ctxt->value == NULL) ||
+ if ((ctxt->value == NULL) ||
((ctxt->value->type != XPATH_NODESET) &&
(ctxt->value->type != XPATH_XSLT_TREE)))
XP_ERROR(XPATH_INVALID_TYPE);
@@ -8588,7 +8775,7 @@ xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs) {
nargs = 1;
}
CHECK_ARITY(1);
- if ((ctxt->value == NULL) ||
+ if ((ctxt->value == NULL) ||
((ctxt->value->type != XPATH_NODESET) &&
(ctxt->value->type != XPATH_XSLT_TREE)))
XP_ERROR(XPATH_INVALID_TYPE);
@@ -8672,7 +8859,7 @@ xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs)
cur->nodesetval->nodeTab[i]->name));
} else {
xmlChar *fullname;
-
+
fullname = xmlBuildQName(cur->nodesetval->nodeTab[i]->name,
cur->nodesetval->nodeTab[i]->ns->prefix,
NULL, 0);
@@ -8707,11 +8894,11 @@ xmlXPathNameFunction(xmlXPathParserContextPtr ctxt, int nargs)
* the node in the node-set that is first in document order.
* If the node-set is empty, an empty string is returned.
* - A number is converted to a string as follows
- * + NaN is converted to the string NaN
- * + positive zero is converted to the string 0
- * + negative zero is converted to the string 0
- * + positive infinity is converted to the string Infinity
- * + negative infinity is converted to the string -Infinity
+ * + NaN is converted to the string NaN
+ * + positive zero is converted to the string 0
+ * + negative zero is converted to the string 0
+ * + positive infinity is converted to the string Infinity
+ * + negative infinity is converted to the string -Infinity
* + if the number is an integer, the number is represented in
* decimal form as a Number with no decimal point and no leading
* zeros, preceded by a minus sign (-) if the number is negative
@@ -8785,7 +8972,7 @@ xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs) {
CHECK_TYPE(XPATH_STRING);
cur = valuePop(ctxt);
valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
- xmlUTF8Strlen(cur->stringval)));
+ xmlUTF8Strlen(cur->stringval)));
xmlXPathReleaseObject(ctxt->context, cur);
}
@@ -8924,12 +9111,12 @@ xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* or equal to the second argument and, if the third argument is specified,
* less than the sum of the second and third arguments; the comparisons
* and addition used for the above follow the standard IEEE 754 rules. Thus:
- * - substring("12345", 1.5, 2.6) returns "234"
- * - substring("12345", 0, 3) returns "12"
- * - substring("12345", 0 div 0, 3) returns ""
- * - substring("12345", 1, 0 div 0) returns ""
- * - substring("12345", -42, 1 div 0) returns "12345"
- * - substring("12345", -1 div 0, 1 div 0) returns ""
+ * - substring("12345", 1.5, 2.6) returns "234"
+ * - substring("12345", 0, 3) returns "12"
+ * - substring("12345", 0 div 0, 3) returns ""
+ * - substring("12345", 1, 0 div 0) returns ""
+ * - substring("12345", -42, 1 div 0) returns "12345"
+ * - substring("12345", -1 div 0, 1 div 0) returns ""
*/
void
xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
@@ -8970,18 +9157,18 @@ xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*/
if (nargs != 3) {
le = (double)m;
- if (in < 1.0)
+ if (in < 1.0)
in = 1.0;
}
- /* Need to check for the special cases where either
+ /* Need to check for the special cases where either
* the index is NaN, the length is NaN, or both
* arguments are infinity (relying on Inf + -Inf = NaN)
*/
- if (!xmlXPathIsNaN(in + le) && !xmlXPathIsInf(in)) {
+ if (!xmlXPathIsInf(in) && !xmlXPathIsNaN(in + le)) {
/*
* To meet the requirements of the spec, the arguments
- * must be converted to integer format before
+ * must be converted to integer format before
* initial index calculations are done
*
* First we go to integer form, rounding up
@@ -9044,26 +9231,26 @@ void
xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr str;
xmlXPathObjectPtr find;
- xmlBufferPtr target;
+ xmlBufPtr target;
const xmlChar *point;
int offset;
-
+
CHECK_ARITY(2);
CAST_TO_STRING;
find = valuePop(ctxt);
CAST_TO_STRING;
str = valuePop(ctxt);
-
- target = xmlBufferCreate();
+
+ target = xmlBufCreate();
if (target) {
point = xmlStrstr(str->stringval, find->stringval);
if (point) {
offset = (int)(point - str->stringval);
- xmlBufferAdd(target, str->stringval, offset);
+ xmlBufAdd(target, str->stringval, offset);
}
valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
- xmlBufferContent(target)));
- xmlBufferFree(target);
+ xmlBufContent(target)));
+ xmlBufFree(target);
}
xmlXPathReleaseObject(ctxt->context, str);
xmlXPathReleaseObject(ctxt->context, find);
@@ -9087,27 +9274,27 @@ void
xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr str;
xmlXPathObjectPtr find;
- xmlBufferPtr target;
+ xmlBufPtr target;
const xmlChar *point;
int offset;
-
+
CHECK_ARITY(2);
CAST_TO_STRING;
find = valuePop(ctxt);
CAST_TO_STRING;
str = valuePop(ctxt);
-
- target = xmlBufferCreate();
+
+ target = xmlBufCreate();
if (target) {
point = xmlStrstr(str->stringval, find->stringval);
if (point) {
offset = (int)(point - str->stringval) + xmlStrlen(find->stringval);
- xmlBufferAdd(target, &str->stringval[offset],
+ xmlBufAdd(target, &str->stringval[offset],
xmlStrlen(str->stringval) - offset);
}
valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
- xmlBufferContent(target)));
- xmlBufferFree(target);
+ xmlBufContent(target)));
+ xmlBufFree(target);
}
xmlXPathReleaseObject(ctxt->context, str);
xmlXPathReleaseObject(ctxt->context, find);
@@ -9131,9 +9318,9 @@ void
xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr obj = NULL;
xmlChar *source = NULL;
- xmlBufferPtr target;
+ xmlBufPtr target;
xmlChar blank;
-
+
if (ctxt == NULL) return;
if (nargs == 0) {
/* Use current context node */
@@ -9149,13 +9336,13 @@ xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
obj = valuePop(ctxt);
source = obj->stringval;
- target = xmlBufferCreate();
+ target = xmlBufCreate();
if (target && source) {
-
+
/* Skip leading whitespaces */
while (IS_BLANK_CH(*source))
source++;
-
+
/* Collapse intermediate whitespaces, and skip trailing whitespaces */
blank = 0;
while (*source) {
@@ -9163,16 +9350,16 @@ xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
blank = 0x20;
} else {
if (blank) {
- xmlBufferAdd(target, &blank, 1);
+ xmlBufAdd(target, &blank, 1);
blank = 0;
}
- xmlBufferAdd(target, source, 1);
+ xmlBufAdd(target, source, 1);
}
source++;
}
valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
- xmlBufferContent(target)));
- xmlBufferFree(target);
+ xmlBufContent(target)));
+ xmlBufFree(target);
}
xmlXPathReleaseObject(ctxt->context, obj);
}
@@ -9203,7 +9390,7 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr str;
xmlXPathObjectPtr from;
xmlXPathObjectPtr to;
- xmlBufferPtr target;
+ xmlBufPtr target;
int offset, max;
xmlChar ch;
const xmlChar *point;
@@ -9218,7 +9405,7 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
CAST_TO_STRING;
str = valuePop(ctxt);
- target = xmlBufferCreate();
+ target = xmlBufCreate();
if (target) {
max = xmlUTF8Strlen(to->stringval);
for (cptr = str->stringval; (ch=*cptr); ) {
@@ -9227,10 +9414,10 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
if (offset < max) {
point = xmlUTF8Strpos(to->stringval, offset);
if (point)
- xmlBufferAdd(target, point, xmlUTF8Strsize(point, 1));
+ xmlBufAdd(target, point, xmlUTF8Strsize(point, 1));
}
} else
- xmlBufferAdd(target, cptr, xmlUTF8Strsize(cptr, 1));
+ xmlBufAdd(target, cptr, xmlUTF8Strsize(cptr, 1));
/* Step to next character in input */
cptr++;
@@ -9239,6 +9426,7 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
if ( (ch & 0xc0) != 0xc0 ) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathTranslateFunction: Invalid UTF8 string\n");
+ /* not asserting an XPath error is probably better */
break;
}
/* then skip over remaining bytes for this char */
@@ -9246,6 +9434,7 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
if ( (*cptr++ & 0xc0) != 0x80 ) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathTranslateFunction: Invalid UTF8 string\n");
+ /* not asserting an XPath error is probably better */
break;
}
if (ch & 0x80) /* must have had error encountered */
@@ -9254,8 +9443,8 @@ xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs) {
}
}
valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
- xmlBufferContent(target)));
- xmlBufferFree(target);
+ xmlBufContent(target)));
+ xmlBufFree(target);
xmlXPathReleaseObject(ctxt->context, str);
xmlXPathReleaseObject(ctxt->context, from);
xmlXPathReleaseObject(ctxt->context, to);
@@ -9430,7 +9619,7 @@ xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs) {
double res = 0.0;
CHECK_ARITY(1);
- if ((ctxt->value == NULL) ||
+ if ((ctxt->value == NULL) ||
((ctxt->value->type != XPATH_NODESET) &&
(ctxt->value->type != XPATH_XSLT_TREE)))
XP_ERROR(XPATH_INVALID_TYPE);
@@ -9549,14 +9738,14 @@ xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs) {
if (ctxt->value->floatval < 0) {
if (ctxt->value->floatval < f - 0.5)
ctxt->value->floatval = f - 1;
- else
+ else
ctxt->value->floatval = f;
if (ctxt->value->floatval == 0)
ctxt->value->floatval = xmlXPathNZERO;
} else {
if (ctxt->value->floatval < f + 0.5)
ctxt->value->floatval = f;
- else
+ else
ctxt->value->floatval = f + 1;
}
}
@@ -9607,7 +9796,7 @@ xmlXPathCurrentChar(xmlXPathParserContextPtr ctxt, int *len) {
* UCS-4 range (hex.) UTF-8 octet sequence (binary)
* 0000 0000-0000 007F 0xxxxxxx
* 0000 0080-0000 07FF 110xxxxx 10xxxxxx
- * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
+ * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx
*
* Check for the 0x110000 limit too
*/
@@ -9644,7 +9833,7 @@ xmlXPathCurrentChar(xmlXPathParserContextPtr ctxt, int *len) {
}
if (!IS_CHAR(val)) {
XP_ERROR0(XPATH_INVALID_CHAR_ERROR);
- }
+ }
return(val);
} else {
/* 1-byte code */
@@ -9716,7 +9905,7 @@ xmlXPathParseNCName(xmlXPathParserContextPtr ctxt) {
/**
* xmlXPathParseQName:
* @ctxt: the XPath Parser context
- * @prefix: a xmlChar **
+ * @prefix: a xmlChar **
*
* parse an XML qualified name
*
@@ -9736,7 +9925,7 @@ xmlXPathParseQName(xmlXPathParserContextPtr ctxt, xmlChar **prefix) {
*prefix = NULL;
ret = xmlXPathParseNCName(ctxt);
- if (CUR == ':') {
+ if (ret && CUR == ':') {
*prefix = ret;
NEXT;
ret = xmlXPathParseNCName(ctxt);
@@ -9762,7 +9951,7 @@ xmlChar *
xmlXPathParseName(xmlXPathParserContextPtr ctxt) {
const xmlChar *in;
xmlChar *ret;
- int count = 0;
+ size_t count = 0;
if ((ctxt == NULL) || (ctxt->cur == NULL)) return(NULL);
/*
@@ -9781,6 +9970,10 @@ xmlXPathParseName(xmlXPathParserContextPtr ctxt) {
in++;
if ((*in > 0) && (*in < 0x80)) {
count = in - ctxt->cur;
+ if (count > XML_MAX_NAME_LENGTH) {
+ ctxt->cur = in;
+ XP_ERRORNULL(XPATH_EXPR_ERROR);
+ }
ret = xmlStrndup(ctxt->cur, count);
ctxt->cur = in;
return(ret);
@@ -9810,7 +10003,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
((IS_LETTER(c)) || (IS_DIGIT(c)) ||
(c == '.') || (c == '-') ||
- (c == '_') || ((qualified) && (c == ':')) ||
+ (c == '_') || ((qualified) && (c == ':')) ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
COPY_BUF(l,buf,len,c);
@@ -9823,7 +10016,10 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
*/
xmlChar *buffer;
int max = len * 2;
-
+
+ if (len > XML_MAX_NAME_LENGTH) {
+ XP_ERRORNULL(XPATH_EXPR_ERROR);
+ }
buffer = (xmlChar *) xmlMallocAtomic(max * sizeof(xmlChar));
if (buffer == NULL) {
XP_ERRORNULL(XPATH_MEMORY_ERROR);
@@ -9831,10 +10027,13 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) {
memcpy(buffer, buf, len);
while ((IS_LETTER(c)) || (IS_DIGIT(c)) || /* test bigname.xml */
(c == '.') || (c == '-') ||
- (c == '_') || ((qualified) && (c == ':')) ||
+ (c == '_') || ((qualified) && (c == ':')) ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c))) {
if (len + 10 > max) {
+ if (max > XML_MAX_NAME_LENGTH) {
+ XP_ERRORNULL(XPATH_EXPR_ERROR);
+ }
max *= 2;
buffer = (xmlChar *) xmlRealloc(buffer,
max * sizeof(xmlChar));
@@ -9878,7 +10077,7 @@ static double my_pow10[MAX_FRAC+1] = {
* [30a] Float ::= Number ('e' Digits?)?
*
* [30] Number ::= Digits ('.' Digits?)?
- * | '.' Digits
+ * | '.' Digits
* [31] Digits ::= [0-9]+
*
* Compile a Number in the string
@@ -9977,7 +10176,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) {
* @ctxt: the XPath Parser context
*
* [30] Number ::= Digits ('.' Digits?)?
- * | '.' Digits
+ * | '.' Digits
* [31] Digits ::= [0-9]+
*
* Compile a Number, then push it on the stack
@@ -9987,7 +10186,6 @@ static void
xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
{
double ret = 0.0;
- double mult = 1;
int ok = 0;
int exponent = 0;
int is_exponent_negative = 0;
@@ -10023,15 +10221,23 @@ xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
}
#endif
if (CUR == '.') {
+ int v, frac = 0;
+ double fraction = 0;
+
NEXT;
if (((CUR < '0') || (CUR > '9')) && (!ok)) {
XP_ERROR(XPATH_NUMBER_ERROR);
}
- while ((CUR >= '0') && (CUR <= '9')) {
- mult /= 10;
- ret = ret + (CUR - '0') * mult;
+ while ((CUR >= '0') && (CUR <= '9') && (frac < MAX_FRAC)) {
+ v = (CUR - '0');
+ fraction = fraction * 10 + v;
+ frac = frac + 1;
NEXT;
}
+ fraction /= my_pow10[frac];
+ ret = ret + fraction;
+ while ((CUR >= '0') && (CUR <= '9'))
+ NEXT;
}
if ((CUR == 'e') || (CUR == 'E')) {
NEXT;
@@ -10157,9 +10363,9 @@ xmlXPathCompLiteral(xmlXPathParserContextPtr ctxt) {
*
* Early evaluation is possible since:
* The variable bindings [...] used to evaluate a subexpression are
- * always the same as those used to evaluate the containing expression.
+ * always the same as those used to evaluate the containing expression.
*
- * [36] VariableReference ::= '$' QName
+ * [36] VariableReference ::= '$' QName
*/
static void
xmlXPathCompVariableReference(xmlXPathParserContextPtr ctxt) {
@@ -10180,7 +10386,7 @@ xmlXPathCompVariableReference(xmlXPathParserContextPtr ctxt) {
name, prefix);
SKIP_BLANKS;
if ((ctxt->context != NULL) && (ctxt->context->flags & XML_XPATH_NOVAR)) {
- XP_ERROR(XPATH_UNDEF_VARIABLE_ERROR);
+ XP_ERROR(XPATH_FORBID_VARIABLE_ERROR);
}
}
@@ -10218,7 +10424,7 @@ xmlXPathIsNodeType(const xmlChar *name) {
* @ctxt: the XPath Parser context
*
* [16] FunctionCall ::= FunctionName '(' ( Argument ( ',' Argument)*)? ')'
- * [17] Argument ::= Expr
+ * [17] Argument ::= Expr
*
* Compile a function call, the evaluation of all arguments are
* pushed on the stack
@@ -10232,6 +10438,7 @@ xmlXPathCompFunctionCall(xmlXPathParserContextPtr ctxt) {
name = xmlXPathParseQName(ctxt, &prefix);
if (name == NULL) {
+ xmlFree(prefix);
XP_ERROR(XPATH_EXPR_ERROR);
}
SKIP_BLANKS;
@@ -10264,7 +10471,11 @@ xmlXPathCompFunctionCall(xmlXPathParserContextPtr ctxt) {
int op1 = ctxt->comp->last;
ctxt->comp->last = -1;
xmlXPathCompileExpr(ctxt, sort);
- CHECK_ERROR;
+ if (ctxt->error != XPATH_EXPRESSION_OK) {
+ xmlFree(name);
+ xmlFree(prefix);
+ return;
+ }
PUSH_BINARY_EXPR(XPATH_OP_ARG, op1, ctxt->comp->last, 0, 0);
nbargs++;
if (CUR == ')') break;
@@ -10285,11 +10496,11 @@ xmlXPathCompFunctionCall(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompPrimaryExpr:
* @ctxt: the XPath Parser context
*
- * [15] PrimaryExpr ::= VariableReference
+ * [15] PrimaryExpr ::= VariableReference
* | '(' Expr ')'
- * | Literal
- * | Number
- * | FunctionCall
+ * | Literal
+ * | Number
+ * | FunctionCall
*
* Compile a primary expression.
*/
@@ -10321,8 +10532,8 @@ xmlXPathCompPrimaryExpr(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompFilterExpr:
* @ctxt: the XPath Parser context
*
- * [20] FilterExpr ::= PrimaryExpr
- * | FilterExpr Predicate
+ * [20] FilterExpr ::= PrimaryExpr
+ * | FilterExpr Predicate
*
* Compile a filter expression.
* Square brackets are used to filter expressions in the same way that
@@ -10337,13 +10548,13 @@ xmlXPathCompFilterExpr(xmlXPathParserContextPtr ctxt) {
xmlXPathCompPrimaryExpr(ctxt);
CHECK_ERROR;
SKIP_BLANKS;
-
+
while (CUR == '[') {
xmlXPathCompPredicate(ctxt, 1);
SKIP_BLANKS;
}
-
+
}
/**
@@ -10382,7 +10593,7 @@ xmlXPathScanName(xmlXPathParserContextPtr ctxt) {
while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */
((IS_LETTER(c)) || (IS_DIGIT(c)) ||
(c == '.') || (c == '-') ||
- (c == '_') || (c == ':') ||
+ (c == '_') || (c == ':') ||
(IS_COMBINING(c)) ||
(IS_EXTENDER(c)))) {
len += l;
@@ -10398,10 +10609,10 @@ xmlXPathScanName(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompPathExpr:
* @ctxt: the XPath Parser context
*
- * [19] PathExpr ::= LocationPath
- * | FilterExpr
- * | FilterExpr '/' RelativeLocationPath
- * | FilterExpr '//' RelativeLocationPath
+ * [19] PathExpr ::= LocationPath
+ * | FilterExpr
+ * | FilterExpr '/' RelativeLocationPath
+ * | FilterExpr '//' RelativeLocationPath
*
* Compile a path expression.
* The / operator and // operators combine an arbitrary expression
@@ -10418,8 +10629,8 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
xmlChar *name = NULL; /* we may have to preparse a name to find out */
SKIP_BLANKS;
- if ((CUR == '$') || (CUR == '(') ||
- (IS_ASCII_DIGIT(CUR)) ||
+ if ((CUR == '$') || (CUR == '(') ||
+ (IS_ASCII_DIGIT(CUR)) ||
(CUR == '\'') || (CUR == '"') ||
(CUR == '.' && IS_ASCII_DIGIT(NXT(1)))) {
lc = 0;
@@ -10459,7 +10670,7 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
} else if (name != NULL) {
int len =xmlStrlen(name);
-
+
while (NXT(len) != 0) {
if (NXT(len) == '/') {
/* element name */
@@ -10526,7 +10737,7 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
/* make sure all cases are covered explicitly */
XP_ERROR(XPATH_EXPR_ERROR);
}
- }
+ }
if (lc) {
if (CUR == '/') {
@@ -10558,8 +10769,8 @@ xmlXPathCompPathExpr(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompUnionExpr:
* @ctxt: the XPath Parser context
*
- * [18] UnionExpr ::= PathExpr
- * | UnionExpr '|' PathExpr
+ * [18] UnionExpr ::= PathExpr
+ * | UnionExpr '|' PathExpr
*
* Compile an union expression.
*/
@@ -10587,8 +10798,8 @@ xmlXPathCompUnionExpr(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompUnaryExpr:
* @ctxt: the XPath Parser context
*
- * [27] UnaryExpr ::= UnionExpr
- * | '-' UnaryExpr
+ * [27] UnaryExpr ::= UnionExpr
+ * | '-' UnaryExpr
*
* Compile an unary expression.
*/
@@ -10620,10 +10831,10 @@ xmlXPathCompUnaryExpr(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompMultiplicativeExpr:
* @ctxt: the XPath Parser context
*
- * [26] MultiplicativeExpr ::= UnaryExpr
- * | MultiplicativeExpr MultiplyOperator UnaryExpr
- * | MultiplicativeExpr 'div' UnaryExpr
- * | MultiplicativeExpr 'mod' UnaryExpr
+ * [26] MultiplicativeExpr ::= UnaryExpr
+ * | MultiplicativeExpr MultiplyOperator UnaryExpr
+ * | MultiplicativeExpr 'div' UnaryExpr
+ * | MultiplicativeExpr 'mod' UnaryExpr
* [34] MultiplyOperator ::= '*'
*
* Compile an Additive expression.
@@ -10634,7 +10845,7 @@ xmlXPathCompMultiplicativeExpr(xmlXPathParserContextPtr ctxt) {
xmlXPathCompUnaryExpr(ctxt);
CHECK_ERROR;
SKIP_BLANKS;
- while ((CUR == '*') ||
+ while ((CUR == '*') ||
((CUR == 'd') && (NXT(1) == 'i') && (NXT(2) == 'v')) ||
((CUR == 'm') && (NXT(1) == 'o') && (NXT(2) == 'd'))) {
int op = -1;
@@ -10662,9 +10873,9 @@ xmlXPathCompMultiplicativeExpr(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompAdditiveExpr:
* @ctxt: the XPath Parser context
*
- * [25] AdditiveExpr ::= MultiplicativeExpr
- * | AdditiveExpr '+' MultiplicativeExpr
- * | AdditiveExpr '-' MultiplicativeExpr
+ * [25] AdditiveExpr ::= MultiplicativeExpr
+ * | AdditiveExpr '+' MultiplicativeExpr
+ * | AdditiveExpr '-' MultiplicativeExpr
*
* Compile an Additive expression.
*/
@@ -10694,11 +10905,11 @@ xmlXPathCompAdditiveExpr(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompRelationalExpr:
* @ctxt: the XPath Parser context
*
- * [24] RelationalExpr ::= AdditiveExpr
- * | RelationalExpr '<' AdditiveExpr
- * | RelationalExpr '>' AdditiveExpr
- * | RelationalExpr '<=' AdditiveExpr
- * | RelationalExpr '>=' AdditiveExpr
+ * [24] RelationalExpr ::= AdditiveExpr
+ * | RelationalExpr '<' AdditiveExpr
+ * | RelationalExpr '>' AdditiveExpr
+ * | RelationalExpr '<=' AdditiveExpr
+ * | RelationalExpr '>=' AdditiveExpr
*
* A <= B > C is allowed ? Answer from James, yes with
* (AdditiveExpr <= AdditiveExpr) > AdditiveExpr
@@ -10738,9 +10949,9 @@ xmlXPathCompRelationalExpr(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompEqualityExpr:
* @ctxt: the XPath Parser context
*
- * [23] EqualityExpr ::= RelationalExpr
- * | EqualityExpr '=' RelationalExpr
- * | EqualityExpr '!=' RelationalExpr
+ * [23] EqualityExpr ::= RelationalExpr
+ * | EqualityExpr '=' RelationalExpr
+ * | EqualityExpr '!=' RelationalExpr
*
* A != B != C is allowed ? Answer from James, yes with
* (RelationalExpr = RelationalExpr) = RelationalExpr
@@ -10775,8 +10986,8 @@ xmlXPathCompEqualityExpr(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompAndExpr:
* @ctxt: the XPath Parser context
*
- * [22] AndExpr ::= EqualityExpr
- * | AndExpr 'and' EqualityExpr
+ * [22] AndExpr ::= EqualityExpr
+ * | AndExpr 'and' EqualityExpr
*
* Compile an AND expression.
*
@@ -10801,9 +11012,9 @@ xmlXPathCompAndExpr(xmlXPathParserContextPtr ctxt) {
* xmlXPathCompileExpr:
* @ctxt: the XPath Parser context
*
- * [14] Expr ::= OrExpr
- * [21] OrExpr ::= AndExpr
- * | OrExpr 'or' AndExpr
+ * [14] Expr ::= OrExpr
+ * [21] OrExpr ::= AndExpr
+ * | OrExpr 'or' AndExpr
*
* Parse and compile an expression
*/
@@ -10819,7 +11030,6 @@ xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort) {
xmlXPathCompAndExpr(ctxt);
CHECK_ERROR;
PUSH_BINARY_EXPR(XPATH_OP_OR, op1, ctxt->comp->last, 0, 0);
- op1 = ctxt->comp->nbStep;
SKIP_BLANKS;
}
if ((sort) && (ctxt->comp->steps[ctxt->comp->last].op != XPATH_OP_VALUE)) {
@@ -10839,7 +11049,7 @@ xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort) {
* @filter: act as a filter
*
* [8] Predicate ::= '[' PredicateExpr ']'
- * [9] PredicateExpr ::= Expr
+ * [9] PredicateExpr ::= Expr
*
* Compile a predicate expression
*/
@@ -10956,7 +11166,7 @@ xmlXPathCompNodeTest(xmlXPathParserContextPtr ctxt, xmlXPathTestVal *test,
}
*test = NODE_TEST_TYPE;
-
+
SKIP_BLANKS;
if (*type == NODE_TYPE_PI) {
/*
@@ -11092,7 +11302,7 @@ xmlXPathIsAxisName(const xmlChar *name) {
* @ctxt: the XPath Parser context
*
* [4] Step ::= AxisSpecifier NodeTest Predicate*
- * | AbbreviatedStep
+ * | AbbreviatedStep
*
* [12] AbbreviatedStep ::= '.' | '..'
*
@@ -11201,7 +11411,10 @@ xmlXPathCompStep(xmlXPathParserContextPtr ctxt) {
}
}
- CHECK_ERROR;
+ if (ctxt->error != XPATH_EXPRESSION_OK) {
+ xmlFree(name);
+ return;
+ }
name = xmlXPathCompNodeTest(ctxt, &test, &type, &prefix, name);
if (test == 0)
@@ -11264,10 +11477,10 @@ eval_predicates:
* xmlXPathCompRelativeLocationPath:
* @ctxt: the XPath Parser context
*
- * [3] RelativeLocationPath ::= Step
- * | RelativeLocationPath '/' Step
- * | AbbreviatedRelativeLocationPath
- * [11] AbbreviatedRelativeLocationPath ::= RelativeLocationPath '//' Step
+ * [3] RelativeLocationPath ::= Step
+ * | RelativeLocationPath '/' Step
+ * | AbbreviatedRelativeLocationPath
+ * [11] AbbreviatedRelativeLocationPath ::= RelativeLocationPath '//' Step
*
* Compile a relative location path.
*/
@@ -11285,6 +11498,7 @@ xmlXPathCompRelativeLocationPath
SKIP_BLANKS;
}
xmlXPathCompStep(ctxt);
+ CHECK_ERROR;
SKIP_BLANKS;
while (CUR == '/') {
if ((CUR == '/') && (NXT(1) == '/')) {
@@ -11306,12 +11520,12 @@ xmlXPathCompRelativeLocationPath
* xmlXPathCompLocationPath:
* @ctxt: the XPath Parser context
*
- * [1] LocationPath ::= RelativeLocationPath
- * | AbsoluteLocationPath
+ * [1] LocationPath ::= RelativeLocationPath
+ * | AbsoluteLocationPath
* [2] AbsoluteLocationPath ::= '/' RelativeLocationPath?
- * | AbbreviatedAbsoluteLocationPath
- * [10] AbbreviatedAbsoluteLocationPath ::=
- * '//' RelativeLocationPath
+ * | AbbreviatedAbsoluteLocationPath
+ * [10] AbbreviatedAbsoluteLocationPath ::=
+ * '//' RelativeLocationPath
*
* Compile a location path
*
@@ -11344,13 +11558,14 @@ xmlXPathCompLocationPath(xmlXPathParserContextPtr ctxt) {
(CUR == '@') || (CUR == '*')))
xmlXPathCompRelativeLocationPath(ctxt);
}
+ CHECK_ERROR;
}
}
}
/************************************************************************
* *
- * XPath precompiled expression evaluation *
+ * XPath precompiled expression evaluation *
* *
************************************************************************/
@@ -11359,12 +11574,11 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op);
#ifdef DEBUG_STEP
static void
-xmlXPathDebugDumpStepAxis(xmlXPathAxisVal axis,
- xmlXPathTestVal test,
+xmlXPathDebugDumpStepAxis(xmlXPathStepOpPtr op,
int nbNodes)
{
xmlGenericError(xmlGenericErrorContext, "new step : ");
- switch (axis) {
+ switch (op->value) {
case AXIS_ANCESTOR:
xmlGenericError(xmlGenericErrorContext, "axis 'ancestors' ");
break;
@@ -11411,14 +11625,14 @@ xmlXPathDebugDumpStepAxis(xmlXPathAxisVal axis,
}
xmlGenericError(xmlGenericErrorContext,
" context contains %d nodes\n", nbNodes);
- switch (test) {
+ switch (op->value2) {
case NODE_TEST_NONE:
xmlGenericError(xmlGenericErrorContext,
" searching for none !!!\n");
break;
case NODE_TEST_TYPE:
xmlGenericError(xmlGenericErrorContext,
- " searching for type %d\n", type);
+ " searching for type %d\n", op->value3);
break;
case NODE_TEST_PI:
xmlGenericError(xmlGenericErrorContext,
@@ -11431,14 +11645,14 @@ xmlXPathDebugDumpStepAxis(xmlXPathAxisVal axis,
case NODE_TEST_NS:
xmlGenericError(xmlGenericErrorContext,
" searching for namespace %s\n",
- prefix);
+ op->value5);
break;
case NODE_TEST_NAME:
xmlGenericError(xmlGenericErrorContext,
- " searching for name %s\n", name);
- if (prefix != NULL)
+ " searching for name %s\n", op->value5);
+ if (op->value4)
xmlGenericError(xmlGenericErrorContext,
- " with namespace %s\n", prefix);
+ " with namespace %s\n", op->value4);
break;
}
xmlGenericError(xmlGenericErrorContext, "Testing : ");
@@ -11467,7 +11681,7 @@ xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
CHECK_ERROR0;
if (contextSize <= 0)
return(0);
- }
+ }
if (op->ch2 != -1) {
xmlXPathContextPtr xpctxt = ctxt->context;
xmlNodePtr contextNode, oldContextNode;
@@ -11511,7 +11725,7 @@ xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
/*
* Get the expression of this predicate.
*/
- exprOp = &ctxt->comp->steps[op->ch2];
+ exprOp = &ctxt->comp->steps[op->ch2];
newContextSize = 0;
for (i = 0; i < set->nodeNr; i++) {
if (set->nodeTab[i] == NULL)
@@ -11521,8 +11735,8 @@ xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
xpctxt->node = contextNode;
xpctxt->contextSize = contextSize;
xpctxt->proximityPosition = ++contextPos;
-
- /*
+
+ /*
* Also set the xpath document in case things like
* key() are evaluated in the predicate.
*/
@@ -11536,16 +11750,23 @@ xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
*/
if (contextObj == NULL)
contextObj = xmlXPathCacheNewNodeSet(xpctxt, contextNode);
- else
- xmlXPathNodeSetAddUnique(contextObj->nodesetval,
- contextNode);
+ else {
+ if (xmlXPathNodeSetAddUnique(contextObj->nodesetval,
+ contextNode) < 0) {
+ ctxt->error = XPATH_MEMORY_ERROR;
+ goto evaluation_exit;
+ }
+ }
valuePush(ctxt, contextObj);
res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
- if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1))
- goto evaluation_error;
+ if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
+ xmlXPathNodeSetClear(set, hasNsNodes);
+ newContextSize = 0;
+ goto evaluation_exit;
+ }
if (res != 0) {
newContextSize++;
@@ -11573,18 +11794,13 @@ xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
contextObj = NULL;
}
}
- goto evaluation_exit;
-evaluation_error:
- xmlXPathNodeSetClear(set, hasNsNodes);
- newContextSize = 0;
-
-evaluation_exit:
if (contextObj != NULL) {
if (ctxt->value == contextObj)
valuePop(ctxt);
xmlXPathReleaseObject(xpctxt, contextObj);
- }
+ }
+evaluation_exit:
if (exprRes != NULL)
xmlXPathReleaseObject(ctxt->context, exprRes);
/*
@@ -11641,6 +11857,7 @@ xmlXPathCompOpEvalPositionalPredicate(xmlXPathParserContextPtr ctxt,
xmlXPathObjectPtr contextObj = NULL, exprRes = NULL;
xmlNodePtr oldContextNode, contextNode = NULL;
xmlXPathContextPtr xpctxt = ctxt->context;
+ int frame;
#ifdef LIBXML_XPTR_ENABLED
/*
@@ -11660,6 +11877,8 @@ xmlXPathCompOpEvalPositionalPredicate(xmlXPathParserContextPtr ctxt,
*/
exprOp = &ctxt->comp->steps[op->ch2];
for (i = 0; i < set->nodeNr; i++) {
+ xmlXPathObjectPtr tmp;
+
if (set->nodeTab[i] == NULL)
continue;
@@ -11667,7 +11886,7 @@ xmlXPathCompOpEvalPositionalPredicate(xmlXPathParserContextPtr ctxt,
xpctxt->node = contextNode;
xpctxt->contextSize = contextSize;
xpctxt->proximityPosition = ++contextPos;
-
+
/*
* Initialize the new set.
* Also set the xpath document in case things like
@@ -11683,15 +11902,33 @@ xmlXPathCompOpEvalPositionalPredicate(xmlXPathParserContextPtr ctxt,
*/
if (contextObj == NULL)
contextObj = xmlXPathCacheNewNodeSet(xpctxt, contextNode);
- else
- xmlXPathNodeSetAddUnique(contextObj->nodesetval,
- contextNode);
+ else {
+ if (xmlXPathNodeSetAddUnique(contextObj->nodesetval,
+ contextNode) < 0) {
+ ctxt->error = XPATH_MEMORY_ERROR;
+ goto evaluation_exit;
+ }
+ }
+ frame = xmlXPathSetFrame(ctxt);
valuePush(ctxt, contextObj);
res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
-
- if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1))
+ tmp = valuePop(ctxt);
+ xmlXPathPopFrame(ctxt, frame);
+
+ if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
+ while (tmp != contextObj) {
+ /*
+ * Free up the result
+ * then pop off contextObj, which will be freed later
+ */
+ xmlXPathReleaseObject(xpctxt, tmp);
+ tmp = valuePop(ctxt);
+ }
goto evaluation_error;
+ }
+ /* push the result back onto the stack */
+ valuePush(ctxt, tmp);
if (res)
pos++;
@@ -11714,9 +11951,9 @@ xmlXPathCompOpEvalPositionalPredicate(xmlXPathParserContextPtr ctxt,
}
xmlXPathNodeSetClear(set, hasNsNodes);
set->nodeNr = 1;
- set->nodeTab[0] = contextNode;
+ set->nodeTab[0] = contextNode;
goto evaluation_exit;
- }
+ }
if (pos == maxPos) {
/*
* We are done.
@@ -11780,7 +12017,7 @@ evaluation_exit:
static int
xmlXPathIsPositionalPredicate(xmlXPathParserContextPtr ctxt,
- xmlXPathStepOpPtr op,
+ xmlXPathStepOpPtr op,
int *maxPos)
{
@@ -11789,7 +12026,7 @@ xmlXPathIsPositionalPredicate(xmlXPathParserContextPtr ctxt,
/*
* BIG NOTE: This is not intended for XPATH_OP_FILTER yet!
*/
-
+
/*
* If not -1, then ch1 will point to:
* 1) For predicates (XPATH_OP_PREDICATE):
@@ -11798,13 +12035,13 @@ xmlXPathIsPositionalPredicate(xmlXPathParserContextPtr ctxt,
* - an inner filter operater OR
* - an expression selecting the node set.
* E.g. "key('a', 'b')" or "(//foo | //bar)".
- */
+ */
if ((op->op != XPATH_OP_PREDICATE) && (op->op != XPATH_OP_FILTER))
return(0);
if (op->ch2 != -1) {
exprOp = &ctxt->comp->steps[op->ch2];
- } else
+ } else
return(0);
if ((exprOp != NULL) &&
@@ -11823,10 +12060,10 @@ xmlXPathIsPositionalPredicate(xmlXPathParserContextPtr ctxt,
* Maybe we could rewrite the AST to ease the optimization.
*/
*maxPos = (int) ((xmlXPathObjectPtr) exprOp->value4)->floatval;
-
+
if (((xmlXPathObjectPtr) exprOp->value4)->floatval ==
(float) *maxPos)
- {
+ {
return(1);
}
}
@@ -11843,22 +12080,25 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
#define XP_TEST_HIT \
if (hasAxisRange != 0) { \
if (++pos == maxPos) { \
- addNode(seq, cur); \
- goto axis_range_end; } \
+ if (addNode(seq, cur) < 0) \
+ ctxt->error = XPATH_MEMORY_ERROR; \
+ goto axis_range_end; } \
} else { \
- addNode(seq, cur); \
+ if (addNode(seq, cur) < 0) \
+ ctxt->error = XPATH_MEMORY_ERROR; \
if (breakOnFirstHit) goto first_hit; }
#define XP_TEST_HIT_NS \
if (hasAxisRange != 0) { \
if (++pos == maxPos) { \
hasNsNodes = 1; \
- xmlXPathNodeSetAddNs(seq, xpctxt->node, (xmlNsPtr) cur); \
+ if (xmlXPathNodeSetAddNs(seq, xpctxt->node, (xmlNsPtr) cur) < 0) \
+ ctxt->error = XPATH_MEMORY_ERROR; \
goto axis_range_end; } \
} else { \
hasNsNodes = 1; \
- xmlXPathNodeSetAddNs(seq, \
- xpctxt->node, (xmlNsPtr) cur); \
+ if (xmlXPathNodeSetAddNs(seq, xpctxt->node, (xmlNsPtr) cur) < 0) \
+ ctxt->error = XPATH_MEMORY_ERROR; \
if (breakOnFirstHit) goto first_hit; }
xmlXPathAxisVal axis = (xmlXPathAxisVal) op->value;
@@ -11878,8 +12118,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
xmlNodeSetPtr contextSeq;
int contextIdx;
xmlNodePtr contextNode;
- /* The context node for a compound traversal */
- xmlNodePtr outerContextNode;
/* The final resulting node set wrt to all context nodes */
xmlNodeSetPtr outSeq;
/*
@@ -11887,7 +12125,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
* Used to feed predicate evaluation.
*/
xmlNodeSetPtr seq;
- xmlNodePtr cur;
+ xmlNodePtr cur;
/* First predicate operator */
xmlXPathStepOpPtr predOp;
int maxPos; /* The requested position() (when a "[n]" predicate) */
@@ -11895,11 +12133,9 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
int breakOnFirstHit;
xmlXPathTraversalFunction next = NULL;
- /* compound axis traversal */
- xmlXPathTraversalFunctionExt outerNext = NULL;
- void (*addNode) (xmlNodeSetPtr, xmlNodePtr);
+ int (*addNode) (xmlNodeSetPtr, xmlNodePtr);
xmlXPathNodeSetMergeFunction mergeAndClear;
- xmlNodePtr oldContextNode;
+ xmlNodePtr oldContextNode;
xmlXPathContextPtr xpctxt = ctxt->context;
@@ -11914,7 +12150,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
xmlXPathReleaseObject(xpctxt, obj);
XP_ERROR0(XPATH_UNDEF_PREFIX_ERROR);
}
- }
+ }
/*
* Setup axis.
*
@@ -11928,7 +12164,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
* avoid a duplicate-aware merge, if the axis to be traversed is e.g.
* the descendant-or-self axis.
*/
- addNode = xmlXPathNodeSetAdd;
mergeAndClear = xmlXPathNodeSetMergeAndClear;
switch (axis) {
case AXIS_ANCESTOR:
@@ -11947,13 +12182,6 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
break;
case AXIS_CHILD:
last = NULL;
- if (op->rewriteType == XP_REWRITE_DOS_CHILD_ELEM) {
- /*
- * This iterator will give us only nodes which can
- * hold element nodes.
- */
- outerNext = xmlXPathNextDescendantOrSelfElemParent;
- }
if (((test == NODE_TEST_NAME) || (test == NODE_TEST_ALL)) &&
(type == NODE_TYPE_NODE))
{
@@ -12008,20 +12236,20 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
}
#ifdef DEBUG_STEP
- xmlXPathDebugDumpStepAxis(axis, test,
- (obj->nodesetval != NULL) ? obj->nodsetval->nodeNr : 0);
+ xmlXPathDebugDumpStepAxis(op,
+ (obj->nodesetval != NULL) ? obj->nodesetval->nodeNr : 0);
#endif
if (next == NULL) {
- xmlXPathReleaseObject(xpctxt, obj);
+ xmlXPathReleaseObject(xpctxt, obj);
return(0);
- }
+ }
contextSeq = obj->nodesetval;
if ((contextSeq == NULL) || (contextSeq->nodeNr <= 0)) {
xmlXPathReleaseObject(xpctxt, obj);
valuePush(ctxt, xmlXPathCacheWrapNodeSet(xpctxt, NULL));
return(0);
- }
+ }
/*
* Predicate optimization ---------------------------------------------
* If this step has a last predicate, which contains a position(),
@@ -12029,7 +12257,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
* the short-hand form, i.e., "[n]".
*
* Example - expression "/foo[parent::bar][1]":
- *
+ *
* COLLECT 'child' 'name' 'node' foo -- op (we are here)
* ROOT -- op->ch1
* PREDICATE -- op->ch2 (predOp)
@@ -12062,7 +12290,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
*/
predOp = NULL;
hasAxisRange = 1;
- }
+ }
}
}
breakOnFirstHit = ((toBool) && (predOp == NULL)) ? 1 : 0;
@@ -12071,7 +12299,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
*/
/*
* 2.3 Node Tests
- * - For the attribute axis, the principal node type is attribute.
+ * - For the attribute axis, the principal node type is attribute.
* - For the namespace axis, the principal node type is namespace.
* - For other axes, the principal node type is element.
*
@@ -12083,33 +12311,14 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
addNode = xmlXPathNodeSetAddUnique;
outSeq = NULL;
seq = NULL;
- outerContextNode = NULL;
contextNode = NULL;
contextIdx = 0;
- while ((contextIdx < contextSeq->nodeNr) || (contextNode != NULL)) {
- if (outerNext != NULL) {
- /*
- * This is a compound traversal.
- */
- if (contextNode == NULL) {
- /*
- * Set the context for the outer traversal.
- */
- outerContextNode = contextSeq->nodeTab[contextIdx++];
- contextNode = outerNext(NULL, outerContextNode);
- } else
- contextNode = outerNext(contextNode, outerContextNode);
- if (contextNode == NULL)
- continue;
- /*
- * Set the context for the main traversal.
- */
- xpctxt->node = contextNode;
- } else
- xpctxt->node = contextSeq->nodeTab[contextIdx++];
-
+ while (((contextIdx < contextSeq->nodeNr) || (contextNode != NULL)) &&
+ (ctxt->error == XPATH_EXPRESSION_OK)) {
+ xpctxt->node = contextSeq->nodeTab[contextIdx++];
+
if (seq == NULL) {
seq = xmlXPathNodeSetCreate(NULL);
if (seq == NULL) {
@@ -12163,6 +12372,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
#ifdef DEBUG_STEP
xmlGenericError(xmlGenericErrorContext, " %s", cur->name);
#endif
+
switch (test) {
case NODE_TEST_NONE:
total = 0;
@@ -12181,7 +12391,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
#ifdef LIBXML_DOCB_ENABLED
case XML_DOCB_DOCUMENT_NODE:
#endif
- case XML_ELEMENT_NODE:
+ case XML_ELEMENT_NODE:
case XML_ATTRIBUTE_NODE:
case XML_PI_NODE:
case XML_COMMENT_NODE:
@@ -12194,7 +12404,7 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
break;
}
} else if (cur->type == type) {
- if (type == XML_NAMESPACE_DECL)
+ if (cur->type == XML_NAMESPACE_DECL)
XP_TEST_HIT_NS
else
XP_TEST_HIT
@@ -12215,7 +12425,14 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
if (axis == AXIS_ATTRIBUTE) {
if (cur->type == XML_ATTRIBUTE_NODE)
{
- XP_TEST_HIT
+ if (prefix == NULL)
+ {
+ XP_TEST_HIT
+ } else if ((cur->ns != NULL) &&
+ (xmlStrEqual(URI, cur->ns->href)))
+ {
+ XP_TEST_HIT
+ }
}
} else if (axis == AXIS_NAMESPACE) {
if (cur->type == XML_NAMESPACE_DECL)
@@ -12241,6 +12458,16 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
break;
}
case NODE_TEST_NAME:
+ if (axis == AXIS_ATTRIBUTE) {
+ if (cur->type != XML_ATTRIBUTE_NODE)
+ break;
+ } else if (axis == AXIS_NAMESPACE) {
+ if (cur->type != XML_NAMESPACE_DECL)
+ break;
+ } else {
+ if (cur->type != XML_ELEMENT_NODE)
+ break;
+ }
switch (cur->type) {
case XML_ELEMENT_NODE:
if (xmlStrEqual(name, cur->name)) {
@@ -12295,11 +12522,11 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
}
break;
} /* switch(test) */
- } while (cur != NULL);
+ } while ((cur != NULL) && (ctxt->error == XPATH_EXPRESSION_OK));
goto apply_predicates;
-axis_range_end: /* ----------------------------------------------------- */
+axis_range_end: /* ----------------------------------------------------- */
/*
* We have a "/foo[n]", and position() = n was reached.
* Note that we can have as well "/foo/::parent::foo[1]", so
@@ -12336,13 +12563,16 @@ first_hit: /* ---------------------------------------------------------- */
#endif
apply_predicates: /* --------------------------------------------------- */
+ if (ctxt->error != XPATH_EXPRESSION_OK)
+ goto error;
+
/*
* Apply predicates.
- */
+ */
if ((predOp != NULL) && (seq->nodeNr > 0)) {
/*
* E.g. when we have a "/foo[some expression][n]".
- */
+ */
/*
* QUESTION TODO: The old predicate evaluation took into
* account location-sets.
@@ -12351,7 +12581,7 @@ apply_predicates: /* --------------------------------------------------- */
* All what I learned now from the evaluation semantics
* does not indicate that a location-set will be processed
* here, so this looks OK.
- */
+ */
/*
* Iterate over all predicates, starting with the outermost
* predicate.
@@ -12367,7 +12597,7 @@ apply_predicates: /* --------------------------------------------------- */
*
* For the moment, I'll try to solve this with a recursive
* function: xmlXPathCompOpEvalPredicate().
- */
+ */
size = seq->nodeNr;
if (hasPredicateRange != 0)
newSize = xmlXPathCompOpEvalPositionalPredicate(ctxt,
@@ -12422,7 +12652,7 @@ apply_predicates: /* --------------------------------------------------- */
} else {
outSeq = mergeAndClear(outSeq, seq, 0);
}
- }
+ }
}
error:
@@ -12447,10 +12677,11 @@ error:
outSeq = seq;
else
outSeq = xmlXPathNodeSetCreate(NULL);
+ /* XXX what if xmlXPathNodeSetCreate returned NULL here? */
}
if ((seq != NULL) && (seq != outSeq)) {
xmlXPathFreeNodeSet(seq);
- }
+ }
/*
* Hand over the result. Better to push the set also in
* case of errors.
@@ -12590,7 +12821,7 @@ xmlXPathCompOpEvalFirst(xmlXPathParserContextPtr ctxt,
return (total);
#ifdef XP_OPTIMIZED_FILTER_FIRST
case XPATH_OP_FILTER:
- total =+ xmlXPathCompOpEvalFilterFirst(ctxt, op, first);
+ total += xmlXPathCompOpEvalFilterFirst(ctxt, op, first);
return (total);
#endif
default:
@@ -12734,9 +12965,9 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
xmlXPathStepOpPtr op, xmlNodePtr * first)
{
int total = 0;
- xmlXPathCompExprPtr comp;
+ xmlXPathCompExprPtr comp;
xmlXPathObjectPtr res;
- xmlXPathObjectPtr obj;
+ xmlXPathObjectPtr obj;
xmlNodeSetPtr oldset;
xmlNodePtr oldnode;
xmlDocPtr oldDoc;
@@ -12751,7 +12982,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
(comp->steps[op->ch1].op == XPATH_OP_SORT) &&
(comp->steps[op->ch2].op == XPATH_OP_SORT)) {
int f = comp->steps[op->ch2].ch1;
-
+
if ((f != -1) &&
(comp->steps[f].op == XPATH_OP_FUNCTION) &&
(comp->steps[f].value5 == NULL) &&
@@ -12760,7 +12991,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
(xmlStrEqual
(comp->steps[f].value4, BAD_CAST "last"))) {
xmlNodePtr last = NULL;
-
+
total +=
xmlXPathCompOpEvalLast(ctxt,
&comp->steps[op->ch1],
@@ -12787,7 +13018,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
return (total);
}
}
-
+
if (op->ch1 != -1)
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
CHECK_ERROR0;
@@ -12795,7 +13026,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
return (total);
if (ctxt->value == NULL)
return (total);
-
+
#ifdef LIBXML_XPTR_ENABLED
oldnode = ctxt->context->node;
/*
@@ -12805,7 +13036,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
xmlXPathObjectPtr tmp = NULL;
xmlLocationSetPtr newlocset = NULL;
xmlLocationSetPtr oldlocset;
-
+
/*
* Extract the old locset, and then evaluate the result of the
* expression for all the element in the locset. use it to grow
@@ -12815,7 +13046,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
obj = valuePop(ctxt);
oldlocset = obj->user;
ctxt->context->node = NULL;
-
+
if ((oldlocset == NULL) || (oldlocset->locNr == 0)) {
ctxt->context->contextSize = 0;
ctxt->context->proximityPosition = 0;
@@ -12830,7 +13061,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
return (total);
}
newlocset = xmlXPtrLocationSetCreate(NULL);
-
+
for (i = 0; i < oldlocset->locNr; i++) {
/*
* Run the evaluation with a node list made of a
@@ -12843,9 +13074,11 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
tmp = xmlXPathCacheNewNodeSet(ctxt->context,
ctxt->context->node);
} else {
- xmlXPathNodeSetAddUnique(tmp->nodesetval,
- ctxt->context->node);
- }
+ if (xmlXPathNodeSetAddUnique(tmp->nodesetval,
+ ctxt->context->node) < 0) {
+ ctxt->error = XPATH_MEMORY_ERROR;
+ }
+ }
valuePush(ctxt, tmp);
if (op->ch2 != -1)
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
@@ -12871,14 +13104,14 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
}
if (ctxt->value == tmp) {
valuePop(ctxt);
- xmlXPathNodeSetClear(tmp->nodesetval, 1);
+ xmlXPathNodeSetClear(tmp->nodesetval, 1);
/*
* REVISIT TODO: Don't create a temporary nodeset
* for everly iteration.
*/
/* OLD: xmlXPathFreeObject(res); */
} else
- tmp = NULL;
+ tmp = NULL;
ctxt->context->node = NULL;
/*
* Only put the first node in the result, then leave.
@@ -12903,7 +13136,7 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
return (total);
}
#endif /* LIBXML_XPTR_ENABLED */
-
+
/*
* Extract the old set, and then evaluate the result of the
* expression for all the element in the set. use it to grow
@@ -12912,11 +13145,11 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
CHECK_TYPE0(XPATH_NODESET);
obj = valuePop(ctxt);
oldset = obj->nodesetval;
-
+
oldnode = ctxt->context->node;
oldDoc = ctxt->context->doc;
ctxt->context->node = NULL;
-
+
if ((oldset == NULL) || (oldset->nodeNr == 0)) {
ctxt->context->contextSize = 0;
ctxt->context->proximityPosition = 0;
@@ -12940,9 +13173,10 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
* Initialize the new set.
* Also set the xpath document in case things like
* key() evaluation are attempted on the predicate
- */
+ */
newset = xmlXPathNodeSetCreate(NULL);
-
+ /* XXX what if xmlXPathNodeSetCreate returned NULL? */
+
for (i = 0; i < oldset->nodeNr; i++) {
/*
* Run the evaluation with a node list made of
@@ -12956,8 +13190,10 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
tmp = xmlXPathCacheNewNodeSet(ctxt->context,
ctxt->context->node);
} else {
- xmlXPathNodeSetAddUnique(tmp->nodesetval,
- ctxt->context->node);
+ if (xmlXPathNodeSetAddUnique(tmp->nodesetval,
+ ctxt->context->node) < 0) {
+ ctxt->error = XPATH_MEMORY_ERROR;
+ }
}
valuePush(ctxt, tmp);
ctxt->context->contextSize = oldset->nodeNr;
@@ -12968,15 +13204,16 @@ xmlXPathCompOpEvalFilterFirst(xmlXPathParserContextPtr ctxt,
xmlXPathFreeNodeSet(newset);
xmlXPathFreeObject(obj);
return(0);
- }
+ }
/*
* The result of the evaluation needs to be tested to
* decide whether the filter succeeded or not
*/
res = valuePop(ctxt);
if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
- xmlXPathNodeSetAdd(newset, oldset->nodeTab[i]);
- }
+ if (xmlXPathNodeSetAdd(newset, oldset->nodeTab[i]) < 0)
+ ctxt->error = XPATH_MEMORY_ERROR;
+ }
/*
* Cleanup
*/
@@ -13112,7 +13349,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
CHECK_ERROR0;
if (op->value)
- equal = xmlXPathEqualValues(ctxt);
+ equal = xmlXPathEqualValues(ctxt);
else
equal = xmlXPathNotEqualValues(ctxt);
valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, equal));
@@ -13265,8 +13502,9 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
URI = xmlXPathNsLookup(ctxt->context, op->value5);
if (URI == NULL) {
xmlGenericError(xmlGenericErrorContext,
- "xmlXPathCompOpEval: variable %s bound to undefined prefix %s\n",
- op->value4, op->value5);
+ "xmlXPathCompOpEval: variable %s bound to undefined prefix %s\n",
+ (char *) op->value4, (char *)op->value5);
+ ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
return (total);
}
val = xmlXPathVariableLookupNS(ctxt->context,
@@ -13283,23 +13521,33 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
xmlXPathFunction func;
const xmlChar *oldFunc, *oldFuncURI;
int i;
+ int frame;
- if (op->ch1 != -1)
+ frame = xmlXPathSetFrame(ctxt);
+ if (op->ch1 != -1) {
total +=
xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
- if (ctxt->valueNr < op->value) {
+ if (ctxt->error != XPATH_EXPRESSION_OK) {
+ xmlXPathPopFrame(ctxt, frame);
+ return (total);
+ }
+ }
+ if (ctxt->valueNr < ctxt->valueFrame + op->value) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathCompOpEval: parameter error\n");
ctxt->error = XPATH_INVALID_OPERAND;
+ xmlXPathPopFrame(ctxt, frame);
return (total);
}
- for (i = 0; i < op->value; i++)
+ for (i = 0; i < op->value; i++) {
if (ctxt->valueTab[(ctxt->valueNr - 1) - i] == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathCompOpEval: parameter error\n");
ctxt->error = XPATH_INVALID_OPERAND;
+ xmlXPathPopFrame(ctxt, frame);
return (total);
}
+ }
if (op->cache != NULL)
XML_CAST_FPTR(func) = op->cache;
else {
@@ -13313,8 +13561,10 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
URI = xmlXPathNsLookup(ctxt->context, op->value5);
if (URI == NULL) {
xmlGenericError(xmlGenericErrorContext,
- "xmlXPathCompOpEval: function %s bound to undefined prefix %s\n",
- op->value4, op->value5);
+ "xmlXPathCompOpEval: function %s bound to undefined prefix %s\n",
+ (char *)op->value4, (char *)op->value5);
+ xmlXPathPopFrame(ctxt, frame);
+ ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
return (total);
}
func = xmlXPathFunctionLookupNS(ctxt->context,
@@ -13322,8 +13572,8 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
}
if (func == NULL) {
xmlGenericError(xmlGenericErrorContext,
- "xmlXPathCompOpEval: function %s not found\n",
- op->value4);
+ "xmlXPathCompOpEval: function %s not found\n",
+ (char *)op->value4);
XP_ERROR0(XPATH_UNKNOWN_FUNC_ERROR);
}
op->cache = XML_CAST_FPTR(func);
@@ -13336,6 +13586,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
func(ctxt, op->value);
ctxt->context->function = oldFunc;
ctxt->context->functionURI = oldFuncURI;
+ xmlXPathPopFrame(ctxt, frame);
return (total);
}
case XPATH_OP_ARG:
@@ -13343,17 +13594,20 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
bak = ctxt->context->node;
pp = ctxt->context->proximityPosition;
cs = ctxt->context->contextSize;
- if (op->ch1 != -1)
+ if (op->ch1 != -1) {
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
- ctxt->context->contextSize = cs;
- ctxt->context->proximityPosition = pp;
- ctxt->context->node = bak;
- ctxt->context->doc = bakd;
- CHECK_ERROR0;
+ ctxt->context->contextSize = cs;
+ ctxt->context->proximityPosition = pp;
+ ctxt->context->node = bak;
+ ctxt->context->doc = bakd;
+ CHECK_ERROR0;
+ }
if (op->ch2 != -1) {
total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
- ctxt->context->doc = bakd;
- ctxt->context->node = bak;
+ ctxt->context->contextSize = cs;
+ ctxt->context->proximityPosition = pp;
+ ctxt->context->node = bak;
+ ctxt->context->doc = bakd;
CHECK_ERROR0;
}
return (total);
@@ -13521,7 +13775,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
tmp = xmlXPathCacheNewNodeSet(ctxt->context,
ctxt->context->node);
valuePush(ctxt, tmp);
-
+
if (op->ch2 != -1)
total +=
xmlXPathCompOpEval(ctxt,
@@ -13630,7 +13884,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
* nC 2
*
* removed the first node in the node-set, then
- * the context position of the
+ * the context position of the
*/
for (i = 0; i < oldset->nodeNr; i++) {
/*
@@ -13645,8 +13899,10 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
tmp = xmlXPathCacheNewNodeSet(ctxt->context,
ctxt->context->node);
} else {
- xmlXPathNodeSetAddUnique(tmp->nodesetval,
- ctxt->context->node);
+ if (xmlXPathNodeSetAddUnique(tmp->nodesetval,
+ ctxt->context->node) < 0) {
+ ctxt->error = XPATH_MEMORY_ERROR;
+ }
}
valuePush(ctxt, tmp);
ctxt->context->contextSize = oldset->nodeNr;
@@ -13676,7 +13932,9 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
*/
res = valuePop(ctxt);
if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
- xmlXPathNodeSetAdd(newset, oldset->nodeTab[i]);
+ if (xmlXPathNodeSetAdd(newset, oldset->nodeTab[i])
+ < 0)
+ ctxt->error = XPATH_MEMORY_ERROR;
}
/*
@@ -13687,7 +13945,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
}
if (ctxt->value == tmp) {
valuePop(ctxt);
- xmlXPathNodeSetClear(tmp->nodesetval, 1);
+ xmlXPathNodeSetClear(tmp->nodesetval, 1);
/*
* Don't free the temporary nodeset
* in order to avoid massive recreation inside this
@@ -13790,7 +14048,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
res = valuePop(ctxt);
if (res->type == XPATH_LOCATIONSET) {
- xmlLocationSetPtr rloc =
+ xmlLocationSetPtr rloc =
(xmlLocationSetPtr)res->user;
for (j=0; j<rloc->locNr; j++) {
range = xmlXPtrNewRange(
@@ -13892,6 +14150,7 @@ xmlXPathCompOpEval(xmlXPathParserContextPtr ctxt, xmlXPathStepOpPtr op)
}
xmlGenericError(xmlGenericErrorContext,
"XPath: unknown precompiled operation %d\n", op->op);
+ ctxt->error = XPATH_INVALID_OPERAND;
return (total);
}
@@ -13952,7 +14211,7 @@ start:
xmlXPathCompOpEval(ctxt, op);
if (ctxt->error != XPATH_EXPRESSION_OK)
return(-1);
-
+
resObj = valuePop(ctxt);
if (resObj == NULL)
return(-1);
@@ -13973,7 +14232,7 @@ start:
* to true if the number is equal to the context position
* and will be converted to false otherwise;"
*/
- res = xmlXPathEvaluatePredicateResult(ctxt, resObj);
+ res = xmlXPathEvaluatePredicateResult(ctxt, resObj);
} else {
res = xmlXPathCastToBoolean(resObj);
}
@@ -13996,13 +14255,13 @@ xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp,
xmlXPathObjectPtr *resultSeq, int toBool)
{
int max_depth, min_depth;
- int from_root;
+ int from_root;
int ret, depth;
int eval_all_nodes;
xmlNodePtr cur = NULL, limit = NULL;
xmlStreamCtxtPtr patstream = NULL;
-
- int nb_nodes = 0;
+
+ int nb_nodes = 0;
if ((ctxt == NULL) || (comp == NULL))
return(-1);
@@ -14028,7 +14287,7 @@ xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp,
if (*resultSeq == NULL)
return(-1);
}
-
+
/*
* handle the special cases of "/" amd "." being matched
*/
@@ -14038,7 +14297,7 @@ xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp,
if (toBool)
return(1);
xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval,
- (xmlNodePtr) ctxt->doc);
+ (xmlNodePtr) ctxt->doc);
} else {
/* Select "self::node()" */
if (toBool)
@@ -14125,13 +14384,17 @@ next_node:
ret = xmlStreamPushNode(patstream, NULL, NULL, cur->type);
else
break;
-
+
if (ret < 0) {
/* NOP. */
} else if (ret == 1) {
if (toBool)
goto return_1;
- xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, cur);
+ if (xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, cur)
+ < 0) {
+ ctxt->lastError.domain = XML_FROM_XPATH;
+ ctxt->lastError.code = XML_ERR_NO_MEMORY;
+ }
}
if ((cur->children == NULL) || (depth >= max_depth)) {
ret = xmlStreamPop(patstream);
@@ -14147,9 +14410,10 @@ next_node:
}
scan_children:
+ if (cur->type == XML_NAMESPACE_DECL) break;
if ((cur->children != NULL) && (depth < max_depth)) {
/*
- * Do not descend on entities declarations
+ * Do not descend on entities declarations
*/
if (cur->children->type != XML_ENTITY_DECL) {
cur = cur->children;
@@ -14171,7 +14435,7 @@ scan_children:
(cur->type != XML_DTD_NODE))
goto next_node;
}
-
+
do {
cur = cur->parent;
depth--;
@@ -14230,7 +14494,7 @@ xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
if (ctxt->valueTab == NULL) {
/* Allocate the value stack */
- ctxt->valueTab = (xmlXPathObjectPtr *)
+ ctxt->valueTab = (xmlXPathObjectPtr *)
xmlMalloc(10 * sizeof(xmlXPathObjectPtr));
if (ctxt->valueTab == NULL) {
xmlXPathPErrMemory(ctxt, "creating evaluation context\n");
@@ -14239,6 +14503,7 @@ xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
ctxt->valueNr = 0;
ctxt->valueMax = 10;
ctxt->value = NULL;
+ ctxt->valueFrame = 0;
}
#ifdef XPATH_STREAMING
if (ctxt->comp->stream) {
@@ -14253,7 +14518,7 @@ xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
if (res != -1)
return(res);
} else {
- xmlXPathObjectPtr resObj = NULL;
+ xmlXPathObjectPtr resObj = NULL;
/*
* Evaluation to a sequence.
@@ -14266,7 +14531,7 @@ xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
return(0);
}
if (resObj != NULL)
- xmlXPathReleaseObject(ctxt->context, resObj);
+ xmlXPathReleaseObject(ctxt->context, resObj);
}
/*
* QUESTION TODO: This falls back to normal XPath evaluation
@@ -14291,7 +14556,7 @@ xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
/************************************************************************
* *
- * Public interfaces *
+ * Public interfaces *
* *
************************************************************************/
@@ -14307,7 +14572,7 @@ xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
* context node in the context node list (as returned by the position
* function) and will be converted to false otherwise; if the result
* is not a number, then the result will be converted as if by a call
- * to the boolean function.
+ * to the boolean function.
*
* Returns 1 if predicate is true, 0 otherwise
*/
@@ -14345,12 +14610,12 @@ xmlXPathEvalPredicate(xmlXPathContextPtr ctxt, xmlXPathObjectPtr res) {
* context node in the context node list (as returned by the position
* function) and will be converted to false otherwise; if the result
* is not a number, then the result will be converted as if by a call
- * to the boolean function.
+ * to the boolean function.
*
* Returns 1 if predicate is true, 0 otherwise
*/
int
-xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
+xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
xmlXPathObjectPtr res) {
if ((ctxt == NULL) || (res == NULL)) return(0);
switch (res->type) {
@@ -14423,7 +14688,7 @@ xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
tmp = xmlStrchr(str, ':');
if ((tmp != NULL) &&
((ctxt == NULL) || (ctxt->nsNr == 0) || (tmp[1] == ':')))
- return(NULL);
+ return(NULL);
if (ctxt != NULL) {
dict = ctxt->dict;
@@ -14439,7 +14704,7 @@ xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
namespaces[i++] = ns->prefix;
}
namespaces[i++] = NULL;
- namespaces[i++] = NULL;
+ namespaces[i] = NULL;
}
}
@@ -14447,7 +14712,7 @@ xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
&namespaces[0]);
if (namespaces != NULL) {
xmlFree((xmlChar **)namespaces);
- }
+ }
if ((stream != NULL) && (xmlPatternStreamable(stream) == 1)) {
comp = xmlXPathNewCompExpr();
if (comp == NULL) {
@@ -14466,57 +14731,64 @@ xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
}
#endif /* XPATH_STREAMING */
-static int
-xmlXPathCanRewriteDosExpression(xmlChar *expr)
-{
- if (expr == NULL)
- return(0);
- do {
- if ((*expr == '/') && (*(++expr) == '/'))
- return(1);
- } while (*expr++);
- return(0);
-}
static void
-xmlXPathRewriteDOSExpression(xmlXPathCompExprPtr comp, xmlXPathStepOpPtr op)
+xmlXPathOptimizeExpression(xmlXPathCompExprPtr comp, xmlXPathStepOpPtr op)
{
/*
* Try to rewrite "descendant-or-self::node()/foo" to an optimized
* internal representation.
*/
- if (op->ch1 != -1) {
- if ((op->op == XPATH_OP_COLLECT /* 11 */) &&
- ((xmlXPathAxisVal) op->value == AXIS_CHILD /* 4 */) &&
- ((xmlXPathTestVal) op->value2 == NODE_TEST_NAME /* 5 */) &&
- ((xmlXPathTypeVal) op->value3 == NODE_TYPE_NODE /* 0 */))
- {
- /*
- * This is a "child::foo"
- */
- xmlXPathStepOpPtr prevop = &comp->steps[op->ch1];
-
- if ((prevop->op == XPATH_OP_COLLECT /* 11 */) &&
- (prevop->ch1 != -1) &&
- ((xmlXPathAxisVal) prevop->value ==
- AXIS_DESCENDANT_OR_SELF) &&
- (prevop->ch2 == -1) &&
- ((xmlXPathTestVal) prevop->value2 == NODE_TEST_TYPE) &&
- ((xmlXPathTypeVal) prevop->value3 == NODE_TYPE_NODE) &&
- (comp->steps[prevop->ch1].op == XPATH_OP_ROOT))
- {
- /*
- * This is a "/descendant-or-self::node()" without predicates.
- * Eliminate it.
- */
- op->ch1 = prevop->ch1;
- op->rewriteType = XP_REWRITE_DOS_CHILD_ELEM;
- }
+
+ if ((op->op == XPATH_OP_COLLECT /* 11 */) &&
+ (op->ch1 != -1) &&
+ (op->ch2 == -1 /* no predicate */))
+ {
+ xmlXPathStepOpPtr prevop = &comp->steps[op->ch1];
+
+ if ((prevop->op == XPATH_OP_COLLECT /* 11 */) &&
+ ((xmlXPathAxisVal) prevop->value ==
+ AXIS_DESCENDANT_OR_SELF) &&
+ (prevop->ch2 == -1) &&
+ ((xmlXPathTestVal) prevop->value2 == NODE_TEST_TYPE) &&
+ ((xmlXPathTypeVal) prevop->value3 == NODE_TYPE_NODE))
+ {
+ /*
+ * This is a "descendant-or-self::node()" without predicates.
+ * Try to eliminate it.
+ */
+
+ switch ((xmlXPathAxisVal) op->value) {
+ case AXIS_CHILD:
+ case AXIS_DESCENDANT:
+ /*
+ * Convert "descendant-or-self::node()/child::" or
+ * "descendant-or-self::node()/descendant::" to
+ * "descendant::"
+ */
+ op->ch1 = prevop->ch1;
+ op->value = AXIS_DESCENDANT;
+ break;
+ case AXIS_SELF:
+ case AXIS_DESCENDANT_OR_SELF:
+ /*
+ * Convert "descendant-or-self::node()/self::" or
+ * "descendant-or-self::node()/descendant-or-self::" to
+ * to "descendant-or-self::"
+ */
+ op->ch1 = prevop->ch1;
+ op->value = AXIS_DESCENDANT_OR_SELF;
+ break;
+ default:
+ break;
+ }
}
- if (op->ch1 != -1)
- xmlXPathRewriteDOSExpression(comp, &comp->steps[op->ch1]);
}
+
+ /* Recurse */
+ if (op->ch1 != -1)
+ xmlXPathOptimizeExpression(comp, &comp->steps[op->ch1]);
if (op->ch2 != -1)
- xmlXPathRewriteDOSExpression(comp, &comp->steps[op->ch2]);
+ xmlXPathOptimizeExpression(comp, &comp->steps[op->ch2]);
}
/**
@@ -14543,6 +14815,8 @@ xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
xmlXPathInit();
pctxt = xmlXPathNewParserContext(str, ctxt);
+ if (pctxt == NULL)
+ return NULL;
xmlXPathCompileExpr(pctxt, 1);
if( pctxt->error != XPATH_EXPRESSION_OK )
@@ -14552,7 +14826,7 @@ xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
}
if (*pctxt->cur != 0) {
- /*
+ /*
* aleksey: in some cases this line prints *second* error message
* (see bug #78858) and probably this should be fixed.
* However, we are not sure that all error messages are printed
@@ -14571,13 +14845,9 @@ xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
#ifdef DEBUG_EVAL_COUNTS
comp->string = xmlStrdup(str);
comp->nb = 0;
-#endif
- if ((comp->expr != NULL) &&
- (comp->nbStep > 2) &&
- (comp->last >= 0) &&
- (xmlXPathCanRewriteDosExpression(comp->expr) == 1))
- {
- xmlXPathRewriteDOSExpression(comp, &comp->steps[comp->last]);
+#endif
+ if ((comp->nbStep > 1) && (comp->last >= 0)) {
+ xmlXPathOptimizeExpression(comp, &comp->steps[comp->last]);
}
}
return(comp);
@@ -14616,7 +14886,7 @@ xmlXPathCompiledEvalInternal(xmlXPathCompExprPtr comp,
xmlXPathObjectPtr *resObj,
int toBool)
{
- xmlXPathParserContextPtr pctxt;
+ xmlXPathParserContextPtr pctxt;
#ifndef LIBXML_THREAD_ENABLED
static int reentance = 0;
#endif
@@ -14645,15 +14915,15 @@ xmlXPathCompiledEvalInternal(xmlXPathCompExprPtr comp,
res = xmlXPathRunEval(pctxt, toBool);
if (resObj) {
- if (pctxt->value == NULL) {
+ if (pctxt->value == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathCompiledEval: evaluation failed\n");
- *resObj = NULL;
+ *resObj = NULL;
} else {
*resObj = valuePop(pctxt);
}
}
-
+
/*
* Pop all remaining objects from the stack.
*/
@@ -14664,8 +14934,7 @@ xmlXPathCompiledEvalInternal(xmlXPathCompExprPtr comp,
do {
tmp = valuePop(pctxt);
if (tmp != NULL) {
- if (tmp != NULL)
- stack++;
+ stack++;
xmlXPathReleaseObject(ctxt, tmp);
}
} while (tmp != NULL);
@@ -14677,11 +14946,11 @@ xmlXPathCompiledEvalInternal(xmlXPathCompExprPtr comp,
stack);
}
}
-
+
if ((pctxt->error != XPATH_EXPRESSION_OK) && (resObj) && (*resObj)) {
xmlXPathFreeObject(*resObj);
*resObj = NULL;
- }
+ }
pctxt->comp = NULL;
xmlXPathFreeParserContext(pctxt);
#ifndef LIBXML_THREAD_ENABLED
@@ -14742,7 +15011,7 @@ xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) {
#endif
if (ctxt == NULL) return;
-
+
#ifdef XPATH_STREAMING
comp = xmlXPathTryStreamCompile(ctxt->context, ctxt->base);
if (comp != NULL) {
@@ -14755,22 +15024,17 @@ xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) {
#endif
{
xmlXPathCompileExpr(ctxt, 1);
- /*
- * In this scenario the expression string will sit in ctxt->base.
- */
if ((ctxt->error == XPATH_EXPRESSION_OK) &&
(ctxt->comp != NULL) &&
- (ctxt->base != NULL) &&
- (ctxt->comp->nbStep > 2) &&
- (ctxt->comp->last >= 0) &&
- (xmlXPathCanRewriteDosExpression((xmlChar *) ctxt->base) == 1))
+ (ctxt->comp->nbStep > 1) &&
+ (ctxt->comp->last >= 0))
{
- xmlXPathRewriteDOSExpression(ctxt->comp,
+ xmlXPathOptimizeExpression(ctxt->comp,
&ctxt->comp->steps[ctxt->comp->last]);
}
}
CHECK_ERROR;
- xmlXPathRunEval(ctxt, 0);
+ xmlXPathRunEval(ctxt, 0);
}
/**
@@ -14794,13 +15058,15 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) {
xmlXPathInit();
ctxt = xmlXPathNewParserContext(str, ctx);
+ if (ctxt == NULL)
+ return NULL;
xmlXPathEvalExpr(ctxt);
if (ctxt->value == NULL) {
xmlGenericError(xmlGenericErrorContext,
"xmlXPathEval: evaluation failed\n");
res = NULL;
- } else if ((*ctxt->cur != 0) && (ctxt->comp != NULL)
+ } else if ((*ctxt->cur != 0) && (ctxt->comp != NULL)
#ifdef XPATH_STREAMING
&& (ctxt->comp->stream == NULL)
#endif
@@ -14834,6 +15100,49 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) {
}
/**
+ * xmlXPathSetContextNode:
+ * @node: the node to to use as the context node
+ * @ctx: the XPath context
+ *
+ * Sets 'node' as the context node. The node must be in the same
+ * document as that associated with the context.
+ *
+ * Returns -1 in case of error or 0 if successful
+ */
+int
+xmlXPathSetContextNode(xmlNodePtr node, xmlXPathContextPtr ctx) {
+ if ((node == NULL) || (ctx == NULL))
+ return(-1);
+
+ if (node->doc == ctx->doc) {
+ ctx->node = node;
+ return(0);
+ }
+ return(-1);
+}
+
+/**
+ * xmlXPathNodeEval:
+ * @node: the node to to use as the context node
+ * @str: the XPath expression
+ * @ctx: the XPath context
+ *
+ * Evaluate the XPath Location Path in the given context. The node 'node'
+ * is set as the context node. The context node is not restored.
+ *
+ * Returns the xmlXPathObjectPtr resulting from the evaluation or NULL.
+ * the caller has to free the object.
+ */
+xmlXPathObjectPtr
+xmlXPathNodeEval(xmlNodePtr node, const xmlChar *str, xmlXPathContextPtr ctx) {
+ if (str == NULL)
+ return(NULL);
+ if (xmlXPathSetContextNode(node, ctx) < 0)
+ return(NULL);
+ return(xmlXPathEval(str, ctx));
+}
+
+/**
* xmlXPathEvalExpression:
* @str: the XPath expression
* @ctxt: the XPath context
@@ -14854,6 +15163,8 @@ xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) {
xmlXPathInit();
pctxt = xmlXPathNewParserContext(str, ctxt);
+ if (pctxt == NULL)
+ return NULL;
xmlXPathEvalExpr(pctxt);
if ((*pctxt->cur != 0) || (pctxt->error != XPATH_EXPRESSION_OK)) {
@@ -14911,21 +15222,21 @@ xmlXPathEvalExpression(const xmlChar *str, xmlXPathContextPtr ctxt) {
* If $escape-reserved is false, the behavior differs in that characters
* referred to in [RFC 2396] as reserved characters are not escaped. These
* characters are ";" | "/" | "?" | ":" | "@" | "&" | "=" | "+" | "$" | ",".
- *
+ *
* [RFC 2396] does not define whether escaped URIs should use lower case or
* upper case for hexadecimal digits. To ensure that escaped URIs can be
* compared using string comparison functions, this function must always use
* the upper-case letters A-F.
- *
+ *
* Generally, $escape-reserved should be set to true when escaping a string
* that is to form a single part of a URI, and to false when escaping an
* entire URI or URI reference.
- *
- * In the case of non-ascii characters, the string is encoded according to
+ *
+ * In the case of non-ascii characters, the string is encoded according to
* utf-8 and then converted according to RFC 2396.
*
* Examples
- * xf:escape-uri ("gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles#ocean"), true())
+ * xf:escape-uri ("gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles#ocean"), true())
* returns "gopher%3A%2F%2Fspinaltap.micro.umn.edu%2F00%2FWeather%2FCalifornia%2FLos%20Angeles%23ocean"
* xf:escape-uri ("gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles#ocean"), false())
* returns "gopher://spinaltap.micro.umn.edu/00/Weather/California/Los%20Angeles%23ocean"
@@ -14935,31 +15246,31 @@ static void
xmlXPathEscapeUriFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr str;
int escape_reserved;
- xmlBufferPtr target;
+ xmlBufPtr target;
xmlChar *cptr;
xmlChar escape[4];
-
+
CHECK_ARITY(2);
-
+
escape_reserved = xmlXPathPopBoolean(ctxt);
-
+
CAST_TO_STRING;
str = valuePop(ctxt);
-
- target = xmlBufferCreate();
-
+
+ target = xmlBufCreate();
+
escape[0] = '%';
escape[3] = 0;
-
+
if (target) {
for (cptr = str->stringval; *cptr; cptr++) {
if ((*cptr >= 'A' && *cptr <= 'Z') ||
(*cptr >= 'a' && *cptr <= 'z') ||
(*cptr >= '0' && *cptr <= '9') ||
- *cptr == '-' || *cptr == '_' || *cptr == '.' ||
+ *cptr == '-' || *cptr == '_' || *cptr == '.' ||
*cptr == '!' || *cptr == '~' || *cptr == '*' ||
*cptr == '\''|| *cptr == '(' || *cptr == ')' ||
- (*cptr == '%' &&
+ (*cptr == '%' &&
((cptr[1] >= 'A' && cptr[1] <= 'F') ||
(cptr[1] >= 'a' && cptr[1] <= 'f') ||
(cptr[1] >= '0' && cptr[1] <= '9')) &&
@@ -14971,7 +15282,7 @@ xmlXPathEscapeUriFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*cptr == ':' || *cptr == '@' || *cptr == '&' ||
*cptr == '=' || *cptr == '+' || *cptr == '$' ||
*cptr == ','))) {
- xmlBufferAdd(target, cptr, 1);
+ xmlBufAdd(target, cptr, 1);
} else {
if ((*cptr >> 4) < 10)
escape[1] = '0' + (*cptr >> 4);
@@ -14981,14 +15292,14 @@ xmlXPathEscapeUriFunction(xmlXPathParserContextPtr ctxt, int nargs) {
escape[2] = '0' + (*cptr & 0xF);
else
escape[2] = 'A' - 10 + (*cptr & 0xF);
-
- xmlBufferAdd(target, &escape[0], 3);
+
+ xmlBufAdd(target, &escape[0], 3);
}
}
}
valuePush(ctxt, xmlXPathCacheNewString(ctxt->context,
- xmlBufferContent(target)));
- xmlBufferFree(target);
+ xmlBufContent(target)));
+ xmlBufFree(target);
xmlXPathReleaseObject(ctxt->context, str);
}
diff --git a/gnulib-local/lib/libxml/xpath.in.h b/gnulib-local/lib/libxml/xpath.in.h
index 89008fc..d96776c 100644
--- a/gnulib-local/lib/libxml/xpath.in.h
+++ b/gnulib-local/lib/libxml/xpath.in.h
@@ -33,7 +33,7 @@
extern "C" {
#endif
#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED */
-
+
#ifdef LIBXML_XPATH_ENABLED
typedef struct _xmlXPathContext xmlXPathContext;
@@ -68,7 +68,9 @@ typedef enum {
XPATH_UNDEF_PREFIX_ERROR,
XPATH_ENCODING_ERROR,
XPATH_INVALID_CHAR_ERROR,
- XPATH_INVALID_CTXT
+ XPATH_INVALID_CTXT,
+ XPATH_STACK_ERROR,
+ XPATH_FORBID_VARIABLE_ERROR
} xmlXPathError;
/*
@@ -271,13 +273,16 @@ typedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt,
*
* Expression evaluation occurs with respect to a context.
* he context consists of:
- * - a node (the context node)
- * - a node list (the context node list)
- * - a set of variable bindings
- * - a function library
- * - the set of namespace declarations in scope for the expression
+ * - a node (the context node)
+ * - a node list (the context node list)
+ * - a set of variable bindings
+ * - a function library
+ * - the set of namespace declarations in scope for the expression
* Following the switch to hash tables, this need to be trimmed up at
* the next binary incompatible release.
+ * The node may be modified when the context is passed to libxml2
+ * for an XPath evaluation so you may need to initialize it again
+ * before the next call.
*/
struct _xmlXPathContext {
@@ -310,7 +315,7 @@ struct _xmlXPathContext {
int proximityPosition; /* the proximity position */
/* extra stuff for XPointer */
- int xptr; /* it this an XPointer context */
+ int xptr; /* is this an XPointer context? */
xmlNodePtr here; /* for here() */
xmlNodePtr origin; /* for origin() */
@@ -332,7 +337,7 @@ struct _xmlXPathContext {
/* temporary namespace lists kept for walking the namespace axis */
xmlNsPtr *tmpNsList; /* Array of namespaces */
- int tmpNsNr; /* number of namespace in scope */
+ int tmpNsNr; /* number of namespaces in scope */
/* error reporting mechanism */
void *userData; /* user specific data block */
@@ -340,8 +345,8 @@ struct _xmlXPathContext {
xmlError lastError; /* the last error */
xmlNodePtr debugNode; /* the source node XSLT */
- /* dictionnary */
- xmlDictPtr dict; /* dictionnary if any */
+ /* dictionary */
+ xmlDictPtr dict; /* dictionary if any */
int flags; /* flags to control compilation */
@@ -377,6 +382,8 @@ struct _xmlXPathParserContext {
xmlXPathCompExprPtr comp; /* the precompiled expression */
int xptr; /* it this an XPointer expression */
xmlNodePtr ancestor; /* used for walking preceding axis */
+
+ int valueFrame; /* used to limit Pop on the stack */
};
/************************************************************************
@@ -414,7 +421,7 @@ XMLPUBVAR double xmlXPathNINF;
* @index is out of range (0 to length-1)
*/
#define xmlXPathNodeSetItem(ns, index) \
- ((((ns) != NULL) && \
+ ((((ns) != NULL) && \
((index) >= 0) && ((index) < (ns)->nodeNr)) ? \
(ns)->nodeTab[(index)] \
: NULL)
@@ -430,64 +437,64 @@ XMLPUBVAR double xmlXPathNINF;
(((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL))
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathFreeObject (xmlXPathObjectPtr obj);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathNodeSetCreate (xmlNodePtr val);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathFreeNodeSetList (xmlXPathObjectPtr obj);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathFreeNodeSet (xmlNodeSetPtr obj);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathObjectCopy (xmlXPathObjectPtr val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathCmpNodes (xmlNodePtr node1,
xmlNodePtr node2);
/**
* Conversion functions to basic types.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathCastNumberToBoolean (double val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathCastStringToBoolean (const xmlChar * val);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathCastToBoolean (xmlXPathObjectPtr val);
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double XMLCALL
xmlXPathCastBooleanToNumber (int val);
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double XMLCALL
xmlXPathCastStringToNumber (const xmlChar * val);
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double XMLCALL
xmlXPathCastNodeToNumber (xmlNodePtr node);
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double XMLCALL
xmlXPathCastNodeSetToNumber (xmlNodeSetPtr ns);
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double XMLCALL
xmlXPathCastToNumber (xmlXPathObjectPtr val);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlXPathCastBooleanToString (int val);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlXPathCastNumberToString (double val);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlXPathCastNodeToString (xmlNodePtr node);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlXPathCastNodeSetToString (xmlNodeSetPtr ns);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlXPathCastToString (xmlXPathObjectPtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathConvertBoolean (xmlXPathObjectPtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathConvertNumber (xmlXPathObjectPtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathConvertString (xmlXPathObjectPtr val);
/**
* Context handling.
*/
-XMLPUBFUN xmlXPathContextPtr XMLCALL
+XMLPUBFUN xmlXPathContextPtr XMLCALL
xmlXPathNewContext (xmlDocPtr doc);
XMLPUBFUN void XMLCALL
xmlXPathFreeContext (xmlXPathContextPtr ctxt);
@@ -499,36 +506,43 @@ XMLPUBFUN int XMLCALL
/**
* Evaluation functions.
*/
-XMLPUBFUN long XMLCALL
+XMLPUBFUN long XMLCALL
xmlXPathOrderDocElems (xmlDocPtr doc);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN int XMLCALL
+ xmlXPathSetContextNode (xmlNodePtr node,
+ xmlXPathContextPtr ctx);
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
+ xmlXPathNodeEval (xmlNodePtr node,
+ const xmlChar *str,
+ xmlXPathContextPtr ctx);
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathEval (const xmlChar *str,
xmlXPathContextPtr ctx);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathEvalExpression (const xmlChar *str,
xmlXPathContextPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathEvalPredicate (xmlXPathContextPtr ctxt,
xmlXPathObjectPtr res);
/**
* Separate compilation/evaluation entry points.
*/
-XMLPUBFUN xmlXPathCompExprPtr XMLCALL
+XMLPUBFUN xmlXPathCompExprPtr XMLCALL
xmlXPathCompile (const xmlChar *str);
-XMLPUBFUN xmlXPathCompExprPtr XMLCALL
+XMLPUBFUN xmlXPathCompExprPtr XMLCALL
xmlXPathCtxtCompile (xmlXPathContextPtr ctxt,
- const xmlChar *str);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+ const xmlChar *str);
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathCompiledEval (xmlXPathCompExprPtr comp,
xmlXPathContextPtr ctx);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp,
xmlXPathContextPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathFreeCompExpr (xmlXPathCompExprPtr comp);
#endif /* LIBXML_XPATH_ENABLED */
#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathInit (void);
XMLPUBFUN int XMLCALL
xmlXPathIsNaN (double val);
diff --git a/gnulib-local/lib/libxml/xpathInternals.in.h b/gnulib-local/lib/libxml/xpathInternals.in.h
index dcd5243..70c9db9 100644
--- a/gnulib-local/lib/libxml/xpathInternals.in.h
+++ b/gnulib-local/lib/libxml/xpathInternals.in.h
@@ -100,16 +100,16 @@ extern "C" {
*/
#define xmlXPathGetContextNode(ctxt) ((ctxt)->context->node)
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathPopBoolean (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN double XMLCALL
- xmlXPathPopNumber (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
- xmlXPathPopString (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
- xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN void * XMLCALL
- xmlXPathPopExternal (xmlXPathParserContextPtr ctxt);
+XMLPUBFUN double XMLCALL
+ xmlXPathPopNumber (xmlXPathParserContextPtr ctxt);
+XMLPUBFUN xmlChar * XMLCALL
+ xmlXPathPopString (xmlXPathParserContextPtr ctxt);
+XMLPUBFUN xmlNodeSetPtr XMLCALL
+ xmlXPathPopNodeSet (xmlXPathParserContextPtr ctxt);
+XMLPUBFUN void * XMLCALL
+ xmlXPathPopExternal (xmlXPathParserContextPtr ctxt);
/**
* xmlXPathReturnBoolean:
@@ -296,7 +296,9 @@ XMLPUBFUN void * XMLCALL
#define CHECK_ARITY(x) \
if (ctxt == NULL) return; \
if (nargs != (x)) \
- XP_ERROR(XPATH_INVALID_ARITY);
+ XP_ERROR(XPATH_INVALID_ARITY); \
+ if (ctxt->valueNr < ctxt->valueFrame + (x)) \
+ XP_ERROR(XPATH_STACK_ERROR);
/**
* CAST_TO_STRING:
@@ -329,7 +331,7 @@ XMLPUBFUN void * XMLCALL
* Variable Lookup forwarding.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathRegisterVariableLookup (xmlXPathContextPtr ctxt,
xmlXPathVariableLookupFunc f,
void *data);
@@ -338,7 +340,7 @@ XMLPUBFUN void XMLCALL
* Function Lookup forwarding.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathRegisterFuncLookup (xmlXPathContextPtr ctxt,
xmlXPathFuncLookupFunc f,
void *funcCtxt);
@@ -346,7 +348,7 @@ XMLPUBFUN void XMLCALL
/*
* Error reporting.
*/
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPatherror (xmlXPathParserContextPtr ctxt,
const char *file,
int line,
@@ -357,11 +359,11 @@ XMLPUBFUN void XMLCALL
int error);
#ifdef LIBXML_DEBUG_ENABLED
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathDebugDumpObject (FILE *output,
xmlXPathObjectPtr cur,
int depth);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathDebugDumpCompExpr(FILE *output,
xmlXPathCompExprPtr comp,
int depth);
@@ -369,48 +371,48 @@ XMLPUBFUN void XMLCALL
/**
* NodeSet handling.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathNodeSetContains (xmlNodeSetPtr cur,
xmlNodePtr val);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathDifference (xmlNodeSetPtr nodes1,
xmlNodeSetPtr nodes2);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathIntersection (xmlNodeSetPtr nodes1,
xmlNodeSetPtr nodes2);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathDistinctSorted (xmlNodeSetPtr nodes);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathDistinct (xmlNodeSetPtr nodes);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathHasSameNodes (xmlNodeSetPtr nodes1,
xmlNodeSetPtr nodes2);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathNodeLeadingSorted (xmlNodeSetPtr nodes,
xmlNodePtr node);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathLeadingSorted (xmlNodeSetPtr nodes1,
xmlNodeSetPtr nodes2);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathNodeLeading (xmlNodeSetPtr nodes,
xmlNodePtr node);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathLeading (xmlNodeSetPtr nodes1,
xmlNodeSetPtr nodes2);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathNodeTrailingSorted (xmlNodeSetPtr nodes,
xmlNodePtr node);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathTrailingSorted (xmlNodeSetPtr nodes1,
xmlNodeSetPtr nodes2);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathNodeTrailing (xmlNodeSetPtr nodes,
xmlNodePtr node);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
+XMLPUBFUN xmlNodeSetPtr XMLCALL
xmlXPathTrailing (xmlNodeSetPtr nodes1,
xmlNodeSetPtr nodes2);
@@ -419,51 +421,51 @@ XMLPUBFUN xmlNodeSetPtr XMLCALL
* Extending a context.
*/
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathRegisterNs (xmlXPathContextPtr ctxt,
const xmlChar *prefix,
const xmlChar *ns_uri);
-XMLPUBFUN const xmlChar * XMLCALL
+XMLPUBFUN const xmlChar * XMLCALL
xmlXPathNsLookup (xmlXPathContextPtr ctxt,
const xmlChar *prefix);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathRegisteredNsCleanup (xmlXPathContextPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathRegisterFunc (xmlXPathContextPtr ctxt,
const xmlChar *name,
xmlXPathFunction f);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathRegisterFuncNS (xmlXPathContextPtr ctxt,
const xmlChar *name,
const xmlChar *ns_uri,
xmlXPathFunction f);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathRegisterVariable (xmlXPathContextPtr ctxt,
const xmlChar *name,
xmlXPathObjectPtr value);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathRegisterVariableNS (xmlXPathContextPtr ctxt,
const xmlChar *name,
const xmlChar *ns_uri,
xmlXPathObjectPtr value);
-XMLPUBFUN xmlXPathFunction XMLCALL
+XMLPUBFUN xmlXPathFunction XMLCALL
xmlXPathFunctionLookup (xmlXPathContextPtr ctxt,
const xmlChar *name);
-XMLPUBFUN xmlXPathFunction XMLCALL
+XMLPUBFUN xmlXPathFunction XMLCALL
xmlXPathFunctionLookupNS (xmlXPathContextPtr ctxt,
const xmlChar *name,
const xmlChar *ns_uri);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathRegisteredFuncsCleanup (xmlXPathContextPtr ctxt);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathVariableLookup (xmlXPathContextPtr ctxt,
const xmlChar *name);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathVariableLookupNS (xmlXPathContextPtr ctxt,
const xmlChar *name,
const xmlChar *ns_uri);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);
/**
@@ -471,79 +473,79 @@ XMLPUBFUN void XMLCALL
*/
XMLPUBFUN xmlXPathParserContextPtr XMLCALL
xmlXPathNewParserContext (const xmlChar *str,
- xmlXPathContextPtr ctxt);
-XMLPUBFUN void XMLCALL
+ xmlXPathContextPtr ctxt);
+XMLPUBFUN void XMLCALL
xmlXPathFreeParserContext (xmlXPathParserContextPtr ctxt);
/* TODO: remap to xmlXPathValuePop and Push. */
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
valuePop (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN int XMLCALL
+XMLPUBFUN int XMLCALL
valuePush (xmlXPathParserContextPtr ctxt,
- xmlXPathObjectPtr value);
+ xmlXPathObjectPtr value);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathNewString (const xmlChar *val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathNewCString (const char *val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathWrapString (xmlChar *val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathWrapCString (char * val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathNewFloat (double val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathNewBoolean (int val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathNewNodeSet (xmlNodePtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathNewValueTree (xmlNodePtr val);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathNodeSetAdd (xmlNodeSetPtr cur,
xmlNodePtr val);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN int XMLCALL
xmlXPathNodeSetAddUnique (xmlNodeSetPtr cur,
xmlNodePtr val);
-XMLPUBFUN void XMLCALL
- xmlXPathNodeSetAddNs (xmlNodeSetPtr cur,
- xmlNodePtr node,
+XMLPUBFUN int XMLCALL
+ xmlXPathNodeSetAddNs (xmlNodeSetPtr cur,
+ xmlNodePtr node,
xmlNsPtr ns);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathNodeSetSort (xmlNodeSetPtr set);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathRoot (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathEvalExpr (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlXPathParseName (xmlXPathParserContextPtr ctxt);
-XMLPUBFUN xmlChar * XMLCALL
+XMLPUBFUN xmlChar * XMLCALL
xmlXPathParseNCName (xmlXPathParserContextPtr ctxt);
/*
* Existing functions.
*/
-XMLPUBFUN double XMLCALL
+XMLPUBFUN double XMLCALL
xmlXPathStringEvalNumber (const xmlChar *str);
-XMLPUBFUN int XMLCALL
- xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt,
+XMLPUBFUN int XMLCALL
+ xmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt,
xmlXPathObjectPtr res);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPathRegisterAllFunctions (xmlXPathContextPtr ctxt);
-XMLPUBFUN xmlNodeSetPtr XMLCALL
- xmlXPathNodeSetMerge (xmlNodeSetPtr val1,
+XMLPUBFUN xmlNodeSetPtr XMLCALL
+ xmlXPathNodeSetMerge (xmlNodeSetPtr val1,
xmlNodeSetPtr val2);
-XMLPUBFUN void XMLCALL
- xmlXPathNodeSetDel (xmlNodeSetPtr cur,
+XMLPUBFUN void XMLCALL
+ xmlXPathNodeSetDel (xmlNodeSetPtr cur,
xmlNodePtr val);
-XMLPUBFUN void XMLCALL
- xmlXPathNodeSetRemove (xmlNodeSetPtr cur,
+XMLPUBFUN void XMLCALL
+ xmlXPathNodeSetRemove (xmlNodeSetPtr cur,
int val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathNewNodeSetList (xmlNodeSetPtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathWrapNodeSet (xmlNodeSetPtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPathWrapExternal (void *val);
XMLPUBFUN int XMLCALL xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);
@@ -621,7 +623,7 @@ XMLPUBFUN void XMLCALL xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, in
* Really internal functions
*/
XMLPUBFUN void XMLCALL xmlXPathNodeSetFreeNs(xmlNsPtr ns);
-
+
#ifdef __cplusplus
}
#endif
diff --git a/gnulib-local/lib/libxml/xpointer.c b/gnulib-local/lib/libxml/xpointer.c
index 5298fa5..4b4ac2e 100644
--- a/gnulib-local/lib/libxml/xpointer.c
+++ b/gnulib-local/lib/libxml/xpointer.c
@@ -7,7 +7,7 @@
*
* Added support for the element() scheme described in:
* W3C Proposed Recommendation 13 November 2002
- * http://www.w3.org/TR/2002/PR-xptr-element-20021113/
+ * http://www.w3.org/TR/2002/PR-xptr-element-20021113/
*
* See Copyright for the status of this software.
*
@@ -47,19 +47,19 @@
#endif
#endif
-#define TODO \
+#define TODO \
xmlGenericError(xmlGenericErrorContext, \
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
-#define STRANGE \
+#define STRANGE \
xmlGenericError(xmlGenericErrorContext, \
"Internal error at %s:%d\n", \
__FILE__, __LINE__);
/************************************************************************
* *
- * Some factorized error routines *
+ * Some factorized error routines *
* *
************************************************************************/
@@ -134,7 +134,7 @@ xmlNodePtr xmlXPtrAdvanceNode(xmlNodePtr cur, int *level);
static int
xmlXPtrGetArity(xmlNodePtr cur) {
int i;
- if (cur == NULL)
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
return(-1);
cur = cur->children;
for (i = 0;cur != NULL;cur = cur->next) {
@@ -157,7 +157,7 @@ xmlXPtrGetArity(xmlNodePtr cur) {
static int
xmlXPtrGetIndex(xmlNodePtr cur) {
int i;
- if (cur == NULL)
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
return(-1);
for (i = 1;cur != NULL;cur = cur->prev) {
if ((cur->type == XML_ELEMENT_NODE) ||
@@ -179,11 +179,11 @@ xmlXPtrGetIndex(xmlNodePtr cur) {
static xmlNodePtr
xmlXPtrGetNthChild(xmlNodePtr cur, int no) {
int i;
- if (cur == NULL)
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
return(cur);
cur = cur->children;
for (i = 0;i <= no;cur = cur->next) {
- if (cur == NULL)
+ if (cur == NULL)
return(cur);
if ((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_DOCUMENT_NODE) ||
@@ -553,7 +553,7 @@ xmlXPtrNewRangeNodeObject(xmlNodePtr start, xmlXPathObjectPtr end) {
break;
case XPATH_NODESET:
/*
- * Empty set ...
+ * Empty set ...
*/
if (end->nodesetval->nodeNr <= 0)
return(NULL);
@@ -731,7 +731,7 @@ xmlXPtrLocationSetDel(xmlLocationSetPtr cur, xmlXPathObjectPtr val) {
if (i >= cur->locNr) {
#ifdef DEBUG
- xmlGenericError(xmlGenericErrorContext,
+ xmlGenericError(xmlGenericErrorContext,
"xmlXPtrLocationSetDel: Range wasn't found in RangeList\n");
#endif
return;
@@ -903,7 +903,7 @@ static void xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name);
#define NXT(val) ctxt->cur[(val)]
#define CUR_PTR ctxt->cur
-#define SKIP_BLANKS \
+#define SKIP_BLANKS \
while (IS_BLANK_CH(*(ctxt->cur))) NEXT
#define CURRENT (*ctxt->cur)
@@ -945,7 +945,7 @@ xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int indx) {
* xmlXPtrEvalXPtrPart:
* @ctxt: the XPointer Parser context
* @name: the preparsed Scheme for the XPtrPart
- *
+ *
* XPtrPart ::= 'xpointer' '(' XPtrExpr ')'
* | Scheme '(' SchemeSpecificExpr ')'
*
@@ -953,7 +953,7 @@ xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int indx) {
*
* SchemeSpecificExpr ::= StringWithBalancedParens
*
- * StringWithBalancedParens ::=
+ * StringWithBalancedParens ::=
* [^()]* ('(' StringWithBalancedParens ')' [^()]*)*
* [VC: Parenthesis escaping]
*
@@ -971,7 +971,7 @@ xmlXPtrGetChildNo(xmlXPathParserContextPtr ctxt, int indx) {
*
* Parse and evaluate an XPtrPart. Basically it generates the unescaped
* string and if the scheme is 'xpointer' it will call the XPath interpreter.
- *
+ *
* TODO: there is no new scheme registration mechanism
*/
@@ -1007,21 +1007,14 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
NEXT;
break;
}
- *cur++ = CUR;
} else if (CUR == '(') {
level++;
- *cur++ = CUR;
} else if (CUR == '^') {
- NEXT;
- if ((CUR == ')') || (CUR == '(') || (CUR == '^')) {
- *cur++ = CUR;
- } else {
- *cur++ = '^';
- *cur++ = CUR;
- }
- } else {
- *cur++ = CUR;
+ if ((NXT(1) == ')') || (NXT(1) == '(') || (NXT(1) == '^')) {
+ NEXT;
+ }
}
+ *cur++ = CUR;
NEXT;
}
*cur = 0;
@@ -1104,7 +1097,7 @@ xmlXPtrEvalXPtrPart(xmlXPathParserContextPtr ctxt, xmlChar *name) {
xmlFree(name);
XP_ERROR(XPATH_MEMORY_ERROR);
}
-
+
xmlXPathRegisterNs(ctxt->context, prefix, URI);
CUR_PTR = left;
xmlFree(URI);
@@ -1152,10 +1145,12 @@ xmlXPtrEvalFullXPtr(xmlXPathParserContextPtr ctxt, xmlChar *name) {
if (name == NULL)
XP_ERROR(XPATH_EXPR_ERROR);
while (name != NULL) {
+ ctxt->error = XPATH_EXPRESSION_OK;
xmlXPtrEvalXPtrPart(ctxt, name);
/* in case of syntax error, break here */
- if (ctxt->error != XPATH_EXPRESSION_OK)
+ if ((ctxt->error != XPATH_EXPRESSION_OK) &&
+ (ctxt->error != XML_XPTR_UNKNOWN_SCHEME))
return;
/*
@@ -1234,7 +1229,7 @@ xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) {
while (CUR == '/') {
int child = 0;
NEXT;
-
+
while ((CUR >= '0') && (CUR <= '9')) {
child = child * 10 + (CUR - '0');
NEXT;
@@ -1258,7 +1253,7 @@ static void
xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
if (ctxt->valueTab == NULL) {
/* Allocate the value stack */
- ctxt->valueTab = (xmlXPathObjectPtr *)
+ ctxt->valueTab = (xmlXPathObjectPtr *)
xmlMalloc(10 * sizeof(xmlXPathObjectPtr));
if (ctxt->valueTab == NULL) {
xmlXPtrErrMemory("allocating evaluation context");
@@ -1267,6 +1262,7 @@ xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
ctxt->valueNr = 0;
ctxt->valueMax = 10;
ctxt->value = NULL;
+ ctxt->valueFrame = 0;
}
SKIP_BLANKS;
if (CUR == '/') {
@@ -1299,12 +1295,19 @@ xmlXPtrEvalXPointer(xmlXPathParserContextPtr ctxt) {
* *
************************************************************************/
+static
void xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs);
+static
void xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs);
+static
void xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs);
+static
void xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt, int nargs);
+static
void xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs);
+static
void xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs);
+static
void xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs);
/**
@@ -1372,6 +1375,8 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
return(NULL);
ctxt = xmlXPathNewParserContext(str, ctx);
+ if (ctxt == NULL)
+ return(NULL);
ctxt->xptr = 1;
xmlXPtrEvalXPointer(ctxt);
@@ -1393,13 +1398,13 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
/*
* Evaluation may push a root nodeset which is unused
*/
- xmlNodeSetPtr set;
+ xmlNodeSetPtr set;
set = tmp->nodesetval;
if ((set->nodeNr != 1) ||
(set->nodeTab[0] != (xmlNodePtr) ctx->doc))
stack++;
} else
- stack++;
+ stack++;
}
xmlXPathFreeObject(tmp);
}
@@ -1413,7 +1418,7 @@ xmlXPtrEval(const xmlChar *str, xmlXPathContextPtr ctx) {
xmlXPathFreeObject(res);
res = NULL;
}
-
+
xmlXPathFreeParserContext(ctxt);
return(res);
}
@@ -1441,11 +1446,13 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
return(NULL);
start = (xmlNodePtr) range->user;
- if (start == NULL)
+ if ((start == NULL) || (start->type == XML_NAMESPACE_DECL))
return(NULL);
end = range->user2;
if (end == NULL)
return(xmlCopyNode(start, 1));
+ if (end->type == XML_NAMESPACE_DECL)
+ return(NULL);
cur = start;
index1 = range->index;
@@ -1475,7 +1482,7 @@ xmlXPtrBuildRangeNodeList(xmlXPathObjectPtr range) {
/* prune and return full set */
if (last != NULL)
xmlAddNextSibling(last, tmp);
- else
+ else
xmlAddChild(parent, tmp);
return(list);
} else {
@@ -1729,16 +1736,16 @@ xmlXPtrNbLocChildren(xmlNodePtr node) {
* @ctxt: the XPointer Parser context
* @nargs: the number of args
*
- * Function implementing here() operation
+ * Function implementing here() operation
* as described in 5.4.3
*/
-void
+static void
xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt, int nargs) {
CHECK_ARITY(0);
if (ctxt->context->here == NULL)
XP_ERROR(XPTR_SYNTAX_ERROR);
-
+
valuePush(ctxt, xmlXPtrNewLocationSetNodes(ctxt->context->here, NULL));
}
@@ -1747,16 +1754,16 @@ xmlXPtrHereFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* @ctxt: the XPointer Parser context
* @nargs: the number of args
*
- * Function implementing origin() operation
+ * Function implementing origin() operation
* as described in 5.4.3
*/
-void
+static void
xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs) {
CHECK_ARITY(0);
if (ctxt->context->origin == NULL)
XP_ERROR(XPTR_SYNTAX_ERROR);
-
+
valuePush(ctxt, xmlXPtrNewLocationSetNodes(ctxt->context->origin, NULL));
}
@@ -1765,7 +1772,7 @@ xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* @ctxt: the XPointer Parser context
* @nargs: the number of args
*
- * Function implementing start-point() operation
+ * Function implementing start-point() operation
* as described in 5.4.3
* ----------------
* location-set start-point(location-set)
@@ -1783,7 +1790,7 @@ xmlXPtrOriginFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* ----------------
*
*/
-void
+static void
xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr tmp, obj, point;
xmlLocationSetPtr newset = NULL;
@@ -1802,6 +1809,8 @@ xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*/
tmp = xmlXPtrNewLocationSetNodeSet(obj->nodesetval);
xmlXPathFreeObject(obj);
+ if (tmp == NULL)
+ XP_ERROR(XPATH_MEMORY_ERROR)
obj = tmp;
}
@@ -1857,7 +1866,7 @@ xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* @ctxt: the XPointer Parser context
* @nargs: the number of args
*
- * Function implementing end-point() operation
+ * Function implementing end-point() operation
* as described in 5.4.3
* ----------------------------
* location-set end-point(location-set)
@@ -1877,7 +1886,7 @@ xmlXPtrStartPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* syntax error.
* ----------------------------
*/
-void
+static void
xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
xmlXPathObjectPtr tmp, obj, point;
xmlLocationSetPtr newset = NULL;
@@ -1896,10 +1905,16 @@ xmlXPtrEndPointFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*/
tmp = xmlXPtrNewLocationSetNodeSet(obj->nodesetval);
xmlXPathFreeObject(obj);
+ if (tmp == NULL)
+ XP_ERROR(XPATH_MEMORY_ERROR)
obj = tmp;
}
newset = xmlXPtrLocationSetCreate(NULL);
+ if (newset == NULL) {
+ xmlXPathFreeObject(obj);
+ XP_ERROR(XPATH_MEMORY_ERROR);
+ }
oldset = (xmlLocationSetPtr) obj->user;
if (oldset != NULL) {
int i;
@@ -1993,7 +2008,7 @@ xmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
case XML_NOTATION_NODE:
case XML_HTML_DOCUMENT_NODE: {
int indx = xmlXPtrGetIndex(node);
-
+
node = node->parent;
return(xmlXPtrNewRange(node, indx - 1,
node, indx + 1));
@@ -2022,7 +2037,7 @@ xmlXPtrCoveringRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
* location-set, a range location representing the covering range of
* x is added to the result location-set.
*/
-void
+static void
xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
int i;
xmlXPathObjectPtr set;
@@ -2044,6 +2059,8 @@ xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*/
tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
xmlXPathFreeObject(set);
+ if (tmp == NULL)
+ XP_ERROR(XPATH_MEMORY_ERROR)
set = tmp;
}
oldset = (xmlLocationSetPtr) set->user;
@@ -2052,6 +2069,10 @@ xmlXPtrRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* The loop is to compute the covering range for each item and add it
*/
newset = xmlXPtrLocationSetCreate(NULL);
+ if (newset == NULL) {
+ xmlXPathFreeObject(set);
+ XP_ERROR(XPATH_MEMORY_ERROR);
+ }
for (i = 0;i < oldset->locNr;i++) {
xmlXPtrLocationSetAdd(newset,
xmlXPtrCoveringRange(ctxt, oldset->locTab[i]));
@@ -2168,7 +2189,7 @@ xmlXPtrInsideRange(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr loc) {
* location children of x.
*
*/
-void
+static void
xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
int i;
xmlXPathObjectPtr set;
@@ -2190,6 +2211,8 @@ xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*/
tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
xmlXPathFreeObject(set);
+ if (tmp == NULL)
+ XP_ERROR(XPATH_MEMORY_ERROR)
set = tmp;
}
oldset = (xmlLocationSetPtr) set->user;
@@ -2198,6 +2221,10 @@ xmlXPtrRangeInsideFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* The loop is to compute the covering range for each item and add it
*/
newset = xmlXPtrLocationSetCreate(NULL);
+ if (newset == NULL) {
+ xmlXPathFreeObject(set);
+ XP_ERROR(XPATH_MEMORY_ERROR);
+ }
for (i = 0;i < oldset->locNr;i++) {
xmlXPtrLocationSetAdd(newset,
xmlXPtrInsideRange(ctxt, oldset->locTab[i]));
@@ -2240,7 +2267,7 @@ xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs) {
cur = ctxt->cur;
newset = xmlXPtrLocationSetCreate(NULL);
-
+
for (i = 0; i < oldset->nodeNr; i++) {
ctxt->cur = cur;
@@ -2274,7 +2301,7 @@ xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs) {
res = valuePop(ctxt);
xmlXPathFreeObject(res);
}
-
+
ctxt->context->node = NULL;
}
@@ -2294,14 +2321,14 @@ xmlXPtrRangeToFunction(xmlXPathParserContextPtr ctxt, int nargs) {
* @level: incremented/decremented to show level in tree
*
* Advance to the next element or text node in document order
- * TODO: add a stack for entering/exiting entities
+ * TODO: add a stack for entering/exiting entities
*
* Returns -1 in case of failure, 0 otherwise
*/
xmlNodePtr
xmlXPtrAdvanceNode(xmlNodePtr cur, int *level) {
next:
- if (cur == NULL)
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
return(NULL);
if (cur->children != NULL) {
cur = cur->children ;
@@ -2359,7 +2386,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
if ((node == NULL) || (indx == NULL))
return(-1);
cur = *node;
- if (cur == NULL)
+ if ((cur == NULL) || (cur->type == XML_NAMESPACE_DECL))
return(-1);
pos = *indx;
@@ -2397,7 +2424,7 @@ xmlXPtrAdvanceChar(xmlNodePtr *node, int *indx, int bytes) {
return(0);
}
/*
- * We should have a text (or cdata) node ...
+ * We should have a text (or cdata) node ...
*/
len = 0;
if ((cur->type != XML_ELEMENT_NODE) &&
@@ -2450,13 +2477,12 @@ xmlXPtrMatchString(const xmlChar *string, xmlNodePtr start, int startindex,
if (string == NULL)
return(-1);
- if (start == NULL)
+ if ((start == NULL) || (start->type == XML_NAMESPACE_DECL))
return(-1);
- if ((end == NULL) || (endindex == NULL))
+ if ((end == NULL) || (*end == NULL) ||
+ ((*end)->type == XML_NAMESPACE_DECL) || (endindex == NULL))
return(-1);
cur = start;
- if (cur == NULL)
- return(-1);
pos = startindex - 1;
stringlen = xmlStrlen(string);
@@ -2535,13 +2561,12 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
if (string == NULL)
return(-1);
- if ((start == NULL) || (startindex == NULL))
+ if ((start == NULL) || (*start == NULL) ||
+ ((*start)->type == XML_NAMESPACE_DECL) || (startindex == NULL))
return(-1);
if ((end == NULL) || (endindex == NULL))
return(-1);
cur = *start;
- if (cur == NULL)
- return(-1);
pos = *startindex - 1;
first = string[0];
@@ -2574,7 +2599,7 @@ xmlXPtrSearchString(const xmlChar *string, xmlNodePtr *start, int *startindex,
/*
* An empty string is considered to match before each
* character of the string-value and after the final
- * character.
+ * character.
*/
#ifdef DEBUG_RANGES
xmlGenericError(xmlGenericErrorContext,
@@ -2615,20 +2640,17 @@ xmlXPtrGetLastChar(xmlNodePtr *node, int *indx) {
xmlNodePtr cur;
int pos, len = 0;
- if ((node == NULL) || (indx == NULL))
+ if ((node == NULL) || (*node == NULL) ||
+ ((*node)->type == XML_NAMESPACE_DECL) || (indx == NULL))
return(-1);
cur = *node;
pos = *indx;
- if (cur == NULL)
- return(-1);
-
if ((cur->type == XML_ELEMENT_NODE) ||
(cur->type == XML_DOCUMENT_NODE) ||
(cur->type == XML_HTML_DOCUMENT_NODE)) {
if (pos > 0) {
cur = xmlXPtrGetNthChild(cur, pos);
- pos = 0;
}
}
while (cur != NULL) {
@@ -2727,7 +2749,7 @@ xmlXPtrGetEndPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *indx) {
* @nargs: the number of args
*
* Function implementing the string-range() function
- * range as described in 5.4.2
+ * range as described in 5.4.2
*
* ------------------------------
* [Definition: For each location in the location-set argument,
@@ -2757,7 +2779,7 @@ xmlXPtrGetEndPoint(xmlXPathObjectPtr obj, xmlNodePtr *node, int *indx) {
* all be character points.
* ------------------------------
*/
-void
+static void
xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
int i, startindex, endindex = 0, fendindex;
xmlNodePtr start, end = 0, fend;
@@ -2796,6 +2818,10 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
set = valuePop(ctxt);
newset = xmlXPtrLocationSetCreate(NULL);
+ if (newset == NULL) {
+ xmlXPathFreeObject(set);
+ XP_ERROR(XPATH_MEMORY_ERROR);
+ }
if (set->nodesetval == NULL) {
goto error;
}
@@ -2807,6 +2833,8 @@ xmlXPtrStringRangeFunction(xmlXPathParserContextPtr ctxt, int nargs) {
*/
tmp = xmlXPtrNewLocationSetNodeSet(set->nodesetval);
xmlXPathFreeObject(set);
+ if (tmp == NULL)
+ XP_ERROR(XPATH_MEMORY_ERROR)
set = tmp;
}
oldset = (xmlLocationSetPtr) set->user;
@@ -2891,7 +2919,7 @@ error:
* @ctxt: the XPointer Parser context
*
* [8] Predicate ::= '[' PredicateExpr ']'
- * [9] PredicateExpr ::= Expr
+ * [9] PredicateExpr ::= Expr
*
* Evaluate a predicate as in xmlXPathEvalPredicate() but for
* a Location Set instead of a node set
@@ -2940,7 +2968,7 @@ xmlXPtrEvalRangePredicate(xmlXPathParserContextPtr ctxt) {
*/
cur = ctxt->cur;
newset = xmlXPtrLocationSetCreate(NULL);
-
+
for (i = 0; i < oldset->locNr; i++) {
ctxt->cur = cur;
@@ -2976,7 +3004,7 @@ xmlXPtrEvalRangePredicate(xmlXPathParserContextPtr ctxt) {
res = valuePop(ctxt);
xmlXPathFreeObject(res);
}
-
+
ctxt->context->node = NULL;
}
diff --git a/gnulib-local/lib/libxml/xpointer.in.h b/gnulib-local/lib/libxml/xpointer.in.h
index dde1dfb..b99112b 100644
--- a/gnulib-local/lib/libxml/xpointer.in.h
+++ b/gnulib-local/lib/libxml/xpointer.in.h
@@ -7,7 +7,7 @@
*
* Added support for the element() scheme described in:
* W3C Proposed Recommendation 13 November 2002
- * http://www.w3.org/TR/2002/PR-xptr-element-20021113/
+ * http://www.w3.org/TR/2002/PR-xptr-element-20021113/
*
* Copy: See Copyright for the status of this software.
*
@@ -43,68 +43,68 @@ struct _xmlLocationSet {
* Handling of location sets.
*/
-XMLPUBFUN xmlLocationSetPtr XMLCALL
+XMLPUBFUN xmlLocationSetPtr XMLCALL
xmlXPtrLocationSetCreate (xmlXPathObjectPtr val);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPtrFreeLocationSet (xmlLocationSetPtr obj);
-XMLPUBFUN xmlLocationSetPtr XMLCALL
+XMLPUBFUN xmlLocationSetPtr XMLCALL
xmlXPtrLocationSetMerge (xmlLocationSetPtr val1,
xmlLocationSetPtr val2);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRange (xmlNodePtr start,
int startindex,
xmlNodePtr end,
int endindex);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangePoints (xmlXPathObjectPtr start,
xmlXPathObjectPtr end);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodePoint (xmlNodePtr start,
xmlXPathObjectPtr end);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangePointNode (xmlXPathObjectPtr start,
xmlNodePtr end);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodes (xmlNodePtr start,
xmlNodePtr end);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewLocationSetNodes (xmlNodePtr start,
xmlNodePtr end);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewRangeNodeObject (xmlNodePtr start,
xmlXPathObjectPtr end);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrNewCollapsedRange (xmlNodePtr start);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPtrLocationSetAdd (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrWrapLocationSet (xmlLocationSetPtr val);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPtrLocationSetDel (xmlLocationSetPtr cur,
xmlXPathObjectPtr val);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPtrLocationSetRemove (xmlLocationSetPtr cur,
int val);
/*
* Functions.
*/
-XMLPUBFUN xmlXPathContextPtr XMLCALL
+XMLPUBFUN xmlXPathContextPtr XMLCALL
xmlXPtrNewContext (xmlDocPtr doc,
xmlNodePtr here,
xmlNodePtr origin);
-XMLPUBFUN xmlXPathObjectPtr XMLCALL
+XMLPUBFUN xmlXPathObjectPtr XMLCALL
xmlXPtrEval (const xmlChar *str,
xmlXPathContextPtr ctx);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPtrRangeToFunction (xmlXPathParserContextPtr ctxt,
- int nargs);
-XMLPUBFUN xmlNodePtr XMLCALL
+ int nargs);
+XMLPUBFUN xmlNodePtr XMLCALL
xmlXPtrBuildNodeList (xmlXPathObjectPtr obj);
-XMLPUBFUN void XMLCALL
+XMLPUBFUN void XMLCALL
xmlXPtrEvalRangePredicate (xmlXPathParserContextPtr ctxt);
#ifdef __cplusplus
}
diff --git a/gnulib-local/modules/libxml b/gnulib-local/modules/libxml
index 880a859..152326b 100644
--- a/gnulib-local/modules/libxml
+++ b/gnulib-local/modules/libxml
@@ -13,6 +13,8 @@ lib/libxml/SAX.c
lib/libxml/SAX2.c
lib/libxml/SAX2.in.h
lib/libxml/SAX.in.h
+lib/libxml/buf.c
+lib/libxml/buf.h
lib/libxml/c14n.c
lib/libxml/c14n.in.h
lib/libxml/catalog.c
@@ -24,6 +26,7 @@ lib/libxml/debugXML.in.h
lib/libxml/dict.c
lib/libxml/dict.in.h
lib/libxml/elfgcchack.h
+lib/libxml/enc.h
lib/libxml/encoding.c
lib/libxml/encoding.in.h
lib/libxml/entities.c
@@ -49,13 +52,18 @@ lib/libxml/pattern.c
lib/libxml/pattern.in.h
lib/libxml/relaxng.c
lib/libxml/relaxng.in.h
+lib/libxml/save.h
lib/libxml/schemasInternals.in.h
lib/libxml/schematron.c
lib/libxml/schematron.in.h
lib/libxml/threads.c
lib/libxml/threads.in.h
+lib/libxml/timsort.h
lib/libxml/tree.c
lib/libxml/tree.in.h
+lib/libxml/triodef.h
+lib/libxml/trionan.c
+lib/libxml/trionan.h
lib/libxml/uri.c
lib/libxml/uri.in.h
lib/libxml/valid.c
@@ -121,11 +129,14 @@ libxml_rpl_la_SOURCES = \
libxml/HTMLtree.c \
libxml/SAX.c \
libxml/SAX2.c \
+ libxml/buf.h \
+ libxml/buf.c \
libxml/c14n.c \
libxml/catalog.c \
libxml/chvalid.c \
libxml/debugXML.c \
libxml/dict.c \
+ libxml/enc.h \
libxml/encoding.c \
libxml/entities.c \
libxml/error.c \
@@ -139,9 +150,14 @@ libxml_rpl_la_SOURCES = \
libxml/parserInternals.c \
libxml/pattern.c \
libxml/relaxng.c \
+ libxml/save.h \
libxml/schematron.c \
libxml/threads.c \
+ libxml/timsort.h \
libxml/tree.c \
+ libxml/triodef.h \
+ libxml/trionan.h \
+ libxml/trionan.c \
libxml/uri.c \
libxml/valid.c \
libxml/xinclude.c \