mirror of
https://github.com/darlinghq/darling-libxml2.git
synced 2025-03-04 17:18:10 +00:00
- speedup of IS_CHAR like macros, significant overall improvement
- More interfaces for new I/O functions: xmlNewIOInputStream, xmlParserInputBufferCreateIO, xmlCreateIOParserCtxt - added I/O test to xmllint Daniel
This commit is contained in:
parent
fc708e2b7c
commit
5e873c4627
11
ChangeLog
11
ChangeLog
@ -1,3 +1,14 @@
|
||||
Wed Apr 12 15:47:22 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
|
||||
* xmlIO.[ch] parser.[ch]: More interfaces for new I/O functions
|
||||
xmlNewIOInputStream, xmlParserInputBufferCreateIO,
|
||||
xmlCreateIOParserCtxt
|
||||
* parser.c parserInternals.h: speedup of IS_CHAR like macros,
|
||||
significant overall improvement
|
||||
* xmllint.c: added I/O test to xmllint
|
||||
* testSAX.c: added a speed test
|
||||
* doc/* : updated/regenerated
|
||||
|
||||
Sat Apr 8 14:54:54 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
|
||||
|
||||
* xpath.c uri.h parserInternals.h: cosmetic changes from
|
||||
|
1288
doc/html/index.sgml
1288
doc/html/index.sgml
File diff suppressed because it is too large
Load Diff
@ -44,7 +44,17 @@ mail</a>:</p>
|
||||
Use <strong>xmlDocGetRootElement(doc)</strong> to get the root element of
|
||||
a document. Alternatively if you are sure to not reference Dtds nor have
|
||||
PIs or comments before or after the root element s/->root/->children/g
|
||||
will probably do it.</li>
|
||||
will probably do it.
|
||||
<p><strong>Note</strong>: libxml2 final version now export a version
|
||||
number as the LIBXML_VERSION preprocessor token. In most case the changes
|
||||
required for 1/ and 2/ can be dealt with using the following construct (if
|
||||
you don't use root identifier for other purposes):</p>
|
||||
<pre>#if defined(LIBXML_VERSION) && LIBXML_VERSION >= 20000
|
||||
#define root children
|
||||
#define childs children
|
||||
#endif
|
||||
</pre>
|
||||
</li>
|
||||
<li>The white space issue, this one is more complex, unless special case of
|
||||
validating parsing, the line breaks and spaces usually used for indenting
|
||||
and formatting the document content becomes significant. So they are
|
||||
@ -69,11 +79,11 @@ mail</a>:</p>
|
||||
</li>
|
||||
<li>The include path has changed to $prefix/libxml/ and the includes
|
||||
themselves uses this new prefix in includes instructions... If you are
|
||||
using (as expected) the
|
||||
using (as expected) the
|
||||
<pre>xml-config --cflags</pre>
|
||||
<p>output to generate you compile commands this will probably work out of
|
||||
the box</p>
|
||||
<p> </p>
|
||||
<p></p>
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
@ -85,6 +95,6 @@ upgrade, it may cost a lot on the long term ...</p>
|
||||
|
||||
<p><a href="mailto:Daniel.Veillard@w3.org">Daniel Veillard</a></p>
|
||||
|
||||
<p>$Id: upgrade.html,v 1.2 2000/03/06 07:41:49 veillard Exp $</p>
|
||||
<p>$Id: upgrade.html,v 1.3 2000/04/03 19:48:13 veillard Exp $</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -428,6 +428,21 @@ int xmlParseChunk (xmlParserCtxtPtr ctxt,
|
||||
int size,
|
||||
int terminate);
|
||||
|
||||
/**
|
||||
* Special I/O mode
|
||||
*/
|
||||
|
||||
xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputBufferPtr input,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
/**
|
||||
* Node infos
|
||||
*/
|
||||
|
@ -53,6 +53,7 @@ extern "C" {
|
||||
(((c) >= 0x00C0) && ((c) <= 0x00D6)) || \
|
||||
(((c) >= 0x00D8) && ((c) <= 0x00F6)) || \
|
||||
(((c) >= 0x00F8) && ((c) <= 0x00FF)) || \
|
||||
(((c) >= 0x100) && ( /* accelerator */ \
|
||||
(((c) >= 0x0100) && ((c) <= 0x0131)) || \
|
||||
(((c) >= 0x0134) && ((c) <= 0x013E)) || \
|
||||
(((c) >= 0x0141) && ((c) <= 0x0148)) || \
|
||||
@ -97,6 +98,7 @@ extern "C" {
|
||||
(((c) >= 0x06D0) && ((c) <= 0x06D3)) || \
|
||||
((c) == 0x06D5) || \
|
||||
(((c) >= 0x06E5) && ((c) <= 0x06E6)) || \
|
||||
(((c) > 0x905) && ( /* accelerator */ \
|
||||
(((c) >= 0x0905) && ((c) <= 0x0939)) || \
|
||||
((c) == 0x093D) || \
|
||||
(((c) >= 0x0958) && ((c) <= 0x0961)) || \
|
||||
@ -187,6 +189,7 @@ extern "C" {
|
||||
(((c) >= 0x0EC0) && ((c) <= 0x0EC4)) || \
|
||||
(((c) >= 0x0F40) && ((c) <= 0x0F47)) || \
|
||||
(((c) >= 0x0F49) && ((c) <= 0x0F69)) || \
|
||||
(((c) > 0x10A0) && ( /* accelerator */ \
|
||||
(((c) >= 0x10A0) && ((c) <= 0x10C5)) || \
|
||||
(((c) >= 0x10D0) && ((c) <= 0x10F6)) || \
|
||||
((c) == 0x1100) || \
|
||||
@ -249,13 +252,14 @@ extern "C" {
|
||||
(((c) >= 0x3041) && ((c) <= 0x3094)) || \
|
||||
(((c) >= 0x30A1) && ((c) <= 0x30FA)) || \
|
||||
(((c) >= 0x3105) && ((c) <= 0x312C)) || \
|
||||
(((c) >= 0xAC00) && ((c) <= 0xD7A3)))
|
||||
(((c) >= 0xAC00) && ((c) <= 0xD7A3))) /* accelerators */ ))))))
|
||||
|
||||
/*
|
||||
* [88] Digit ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_DIGIT(c) \
|
||||
((((c) >= 0x0030) && ((c) <= 0x0039)) || \
|
||||
(((c) >= 0x660) && ( /* accelerator */ \
|
||||
(((c) >= 0x0660) && ((c) <= 0x0669)) || \
|
||||
(((c) >= 0x06F0) && ((c) <= 0x06F9)) || \
|
||||
(((c) >= 0x0966) && ((c) <= 0x096F)) || \
|
||||
@ -269,13 +273,14 @@ extern "C" {
|
||||
(((c) >= 0x0D66) && ((c) <= 0x0D6F)) || \
|
||||
(((c) >= 0x0E50) && ((c) <= 0x0E59)) || \
|
||||
(((c) >= 0x0ED0) && ((c) <= 0x0ED9)) || \
|
||||
(((c) >= 0x0F20) && ((c) <= 0x0F29)))
|
||||
(((c) >= 0x0F20) && ((c) <= 0x0F29))) /* accelerator */ ))
|
||||
|
||||
/*
|
||||
* [87] CombiningChar ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_COMBINING(c) \
|
||||
((((c) >= 0x0300) && ((c) <= 0x0345)) || \
|
||||
((((c) >= 0x300) && ( /* accelerator */ \
|
||||
(((c) >= 0x0300) && ((c) <= 0x0345)) || \
|
||||
(((c) >= 0x0360) && ((c) <= 0x0361)) || \
|
||||
(((c) >= 0x0483) && ((c) <= 0x0486)) || \
|
||||
(((c) >= 0x0591) && ((c) <= 0x05A1)) || \
|
||||
@ -291,6 +296,7 @@ extern "C" {
|
||||
(((c) >= 0x06E0) && ((c) <= 0x06E4)) || \
|
||||
(((c) >= 0x06E7) && ((c) <= 0x06E8)) || \
|
||||
(((c) >= 0x06EA) && ((c) <= 0x06ED)) || \
|
||||
(((c) > 0x0901) && ( /* accelerator */ \
|
||||
(((c) >= 0x0901) && ((c) <= 0x0903)) || \
|
||||
((c) == 0x093C) || \
|
||||
(((c) >= 0x093E) && ((c) <= 0x094C)) || \
|
||||
@ -306,6 +312,7 @@ extern "C" {
|
||||
(((c) >= 0x09CB) && ((c) <= 0x09CD)) || \
|
||||
((c) == 0x09D7) || \
|
||||
(((c) >= 0x09E2) && ((c) <= 0x09E3)) || \
|
||||
(((c) > 0x0A02) && ( /* accelerator */ \
|
||||
((c) == 0x0A02) || \
|
||||
((c) == 0x0A3C) || \
|
||||
((c) == 0x0A3E) || \
|
||||
@ -345,6 +352,7 @@ extern "C" {
|
||||
(((c) >= 0x0D46) && ((c) <= 0x0D48)) || \
|
||||
(((c) >= 0x0D4A) && ((c) <= 0x0D4D)) || \
|
||||
((c) == 0x0D57) || \
|
||||
(((c) > 0x0E31) && ( /* accelerator */ \
|
||||
((c) == 0x0E31) || \
|
||||
(((c) >= 0x0E34) && ((c) <= 0x0E3A)) || \
|
||||
(((c) >= 0x0E47) && ((c) <= 0x0E4E)) || \
|
||||
@ -369,7 +377,7 @@ extern "C" {
|
||||
((c) == 0x20E1) || \
|
||||
(((c) >= 0x302A) && ((c) <= 0x302F)) || \
|
||||
((c) == 0x3099) || \
|
||||
((c) == 0x309A))
|
||||
((c) == 0x309A)) /* accelerator */ ))))))))
|
||||
|
||||
/*
|
||||
* [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 |
|
||||
|
@ -52,6 +52,11 @@ xmlParserInputBufferPtr
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFd (int fd,
|
||||
xmlCharEncoding enc);
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncoding enc);
|
||||
int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
|
||||
int len);
|
||||
int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
|
||||
|
118
parser.c
118
parser.c
@ -921,11 +921,13 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) {
|
||||
|
||||
input = (xmlParserInputPtr) xmlMalloc(sizeof(xmlParserInput));
|
||||
if (input == NULL) {
|
||||
ctxt->errNo = XML_ERR_NO_MEMORY;
|
||||
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
||||
ctxt->sax->error(ctxt->userData,
|
||||
"malloc: couldn't allocate a new input stream\n");
|
||||
ctxt->errNo = XML_ERR_NO_MEMORY;
|
||||
if (ctxt != NULL) {
|
||||
ctxt->errNo = XML_ERR_NO_MEMORY;
|
||||
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
|
||||
ctxt->sax->error(ctxt->userData,
|
||||
"malloc: couldn't allocate a new input stream\n");
|
||||
ctxt->errNo = XML_ERR_NO_MEMORY;
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
memset(input, 0, sizeof(xmlParserInput));
|
||||
@ -935,6 +937,37 @@ xmlNewInputStream(xmlParserCtxtPtr ctxt) {
|
||||
return(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlNewIOInputStream:
|
||||
* @ctxt: an XML parser context
|
||||
* @input: an I/O Input
|
||||
* @enc: the charset encoding if known
|
||||
*
|
||||
* Create a new input stream structure encapsulating the @input into
|
||||
* a stream suitable for the parser.
|
||||
*
|
||||
* Returns the new input stream or NULL
|
||||
*/
|
||||
xmlParserInputPtr
|
||||
xmlNewIOInputStream(xmlParserCtxtPtr ctxt, xmlParserInputBufferPtr input,
|
||||
xmlCharEncoding enc) {
|
||||
xmlParserInputPtr inputStream;
|
||||
|
||||
inputStream = xmlNewInputStream(ctxt);
|
||||
if (inputStream == NULL) {
|
||||
return(NULL);
|
||||
}
|
||||
inputStream->filename = NULL;
|
||||
inputStream->buf = input;
|
||||
inputStream->base = inputStream->buf->buffer->content;
|
||||
inputStream->cur = inputStream->buf->buffer->content;
|
||||
if (enc != XML_CHAR_ENCODING_NONE) {
|
||||
xmlSwitchEncoding(ctxt, enc);
|
||||
}
|
||||
|
||||
return(inputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlNewEntityInputStream:
|
||||
* @ctxt: an XML parser context
|
||||
@ -3403,16 +3436,18 @@ xmlParseName(xmlParserCtxtPtr ctxt) {
|
||||
|
||||
GROW;
|
||||
c = CUR_CHAR(l);
|
||||
if (!IS_LETTER(c) && (c != '_') &&
|
||||
(c != ':')) {
|
||||
if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */
|
||||
(!IS_LETTER(c) && (c != '_') &&
|
||||
(c != ':'))) {
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
while ((IS_LETTER(c)) || (IS_DIGIT(c)) ||
|
||||
(c == '.') || (c == '-') ||
|
||||
(c == '_') || (c == ':') ||
|
||||
(IS_COMBINING(c)) ||
|
||||
(IS_EXTENDER(c))) {
|
||||
while ((c != ' ') && (c != '>') && (c != '/') && /* accelerators */
|
||||
((IS_LETTER(c)) || (IS_DIGIT(c)) ||
|
||||
(c == '.') || (c == '-') ||
|
||||
(c == '_') || (c == ':') ||
|
||||
(IS_COMBINING(c)) ||
|
||||
(IS_EXTENDER(c)))) {
|
||||
COPY_BUF(l,buf,len,c);
|
||||
NEXTL(l);
|
||||
c = CUR_CHAR(l);
|
||||
@ -4041,8 +4076,9 @@ xmlParseCharData(xmlParserCtxtPtr ctxt, int cdata) {
|
||||
|
||||
SHRINK;
|
||||
cur = CUR_CHAR(l);
|
||||
while ((IS_CHAR(cur)) && ((cur != '<') || (ctxt->token == '<')) &&
|
||||
((cur != '&') || (ctxt->token == '&'))) {
|
||||
while (((cur != '<') || (ctxt->token == '<')) &&
|
||||
((cur != '&') || (ctxt->token == '&')) &&
|
||||
(IS_CHAR(cur))) {
|
||||
if ((cur == ']') && (NXT(1) == ']') &&
|
||||
(NXT(2) == '>')) {
|
||||
if (cdata) break;
|
||||
@ -9524,6 +9560,60 @@ xmlCreatePushParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
|
||||
return(ctxt);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCreateIOParserCtxt:
|
||||
* @sax: a SAX handler
|
||||
* @user_data: The user data returned on SAX callbacks
|
||||
* @ioread: an I/O read function
|
||||
* @ioclose: an I/O close function
|
||||
* @ioctx: an I/O handler
|
||||
* @enc: the charset encoding if known
|
||||
*
|
||||
* Create a parser context for using the XML parser with an existing
|
||||
* I/O stream
|
||||
*
|
||||
* Returns the new parser context or NULL
|
||||
*/
|
||||
xmlParserCtxtPtr
|
||||
xmlCreateIOParserCtxt(xmlSAXHandlerPtr sax, void *user_data,
|
||||
xmlInputReadCallback ioread, xmlInputCloseCallback ioclose,
|
||||
void *ioctx, xmlCharEncoding enc) {
|
||||
xmlParserCtxtPtr ctxt;
|
||||
xmlParserInputPtr inputStream;
|
||||
xmlParserInputBufferPtr buf;
|
||||
|
||||
buf = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, enc);
|
||||
if (buf == NULL) return(NULL);
|
||||
|
||||
ctxt = xmlNewParserCtxt();
|
||||
if (ctxt == NULL) {
|
||||
xmlFree(buf);
|
||||
return(NULL);
|
||||
}
|
||||
if (sax != NULL) {
|
||||
if (ctxt->sax != &xmlDefaultSAXHandler)
|
||||
xmlFree(ctxt->sax);
|
||||
ctxt->sax = (xmlSAXHandlerPtr) xmlMalloc(sizeof(xmlSAXHandler));
|
||||
if (ctxt->sax == NULL) {
|
||||
xmlFree(buf);
|
||||
xmlFree(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
memcpy(ctxt->sax, sax, sizeof(xmlSAXHandler));
|
||||
if (user_data != NULL)
|
||||
ctxt->userData = user_data;
|
||||
}
|
||||
|
||||
inputStream = xmlNewIOInputStream(ctxt, buf, enc);
|
||||
if (inputStream == NULL) {
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
return(NULL);
|
||||
}
|
||||
inputPush(ctxt, inputStream);
|
||||
|
||||
return(ctxt);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCreateDocParserCtxt:
|
||||
* @cur: a pointer to an array of xmlChar
|
||||
|
15
parser.h
15
parser.h
@ -428,6 +428,21 @@ int xmlParseChunk (xmlParserCtxtPtr ctxt,
|
||||
int size,
|
||||
int terminate);
|
||||
|
||||
/**
|
||||
* Special I/O mode
|
||||
*/
|
||||
|
||||
xmlParserCtxtPtr xmlCreateIOParserCtxt (xmlSAXHandlerPtr sax,
|
||||
void *user_data,
|
||||
xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
xmlParserInputPtr xmlNewIOInputStream (xmlParserCtxtPtr ctxt,
|
||||
xmlParserInputBufferPtr input,
|
||||
xmlCharEncoding enc);
|
||||
|
||||
/**
|
||||
* Node infos
|
||||
*/
|
||||
|
@ -53,6 +53,7 @@ extern "C" {
|
||||
(((c) >= 0x00C0) && ((c) <= 0x00D6)) || \
|
||||
(((c) >= 0x00D8) && ((c) <= 0x00F6)) || \
|
||||
(((c) >= 0x00F8) && ((c) <= 0x00FF)) || \
|
||||
(((c) >= 0x100) && ( /* accelerator */ \
|
||||
(((c) >= 0x0100) && ((c) <= 0x0131)) || \
|
||||
(((c) >= 0x0134) && ((c) <= 0x013E)) || \
|
||||
(((c) >= 0x0141) && ((c) <= 0x0148)) || \
|
||||
@ -97,6 +98,7 @@ extern "C" {
|
||||
(((c) >= 0x06D0) && ((c) <= 0x06D3)) || \
|
||||
((c) == 0x06D5) || \
|
||||
(((c) >= 0x06E5) && ((c) <= 0x06E6)) || \
|
||||
(((c) > 0x905) && ( /* accelerator */ \
|
||||
(((c) >= 0x0905) && ((c) <= 0x0939)) || \
|
||||
((c) == 0x093D) || \
|
||||
(((c) >= 0x0958) && ((c) <= 0x0961)) || \
|
||||
@ -187,6 +189,7 @@ extern "C" {
|
||||
(((c) >= 0x0EC0) && ((c) <= 0x0EC4)) || \
|
||||
(((c) >= 0x0F40) && ((c) <= 0x0F47)) || \
|
||||
(((c) >= 0x0F49) && ((c) <= 0x0F69)) || \
|
||||
(((c) > 0x10A0) && ( /* accelerator */ \
|
||||
(((c) >= 0x10A0) && ((c) <= 0x10C5)) || \
|
||||
(((c) >= 0x10D0) && ((c) <= 0x10F6)) || \
|
||||
((c) == 0x1100) || \
|
||||
@ -249,13 +252,14 @@ extern "C" {
|
||||
(((c) >= 0x3041) && ((c) <= 0x3094)) || \
|
||||
(((c) >= 0x30A1) && ((c) <= 0x30FA)) || \
|
||||
(((c) >= 0x3105) && ((c) <= 0x312C)) || \
|
||||
(((c) >= 0xAC00) && ((c) <= 0xD7A3)))
|
||||
(((c) >= 0xAC00) && ((c) <= 0xD7A3))) /* accelerators */ ))))))
|
||||
|
||||
/*
|
||||
* [88] Digit ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_DIGIT(c) \
|
||||
((((c) >= 0x0030) && ((c) <= 0x0039)) || \
|
||||
(((c) >= 0x660) && ( /* accelerator */ \
|
||||
(((c) >= 0x0660) && ((c) <= 0x0669)) || \
|
||||
(((c) >= 0x06F0) && ((c) <= 0x06F9)) || \
|
||||
(((c) >= 0x0966) && ((c) <= 0x096F)) || \
|
||||
@ -269,13 +273,14 @@ extern "C" {
|
||||
(((c) >= 0x0D66) && ((c) <= 0x0D6F)) || \
|
||||
(((c) >= 0x0E50) && ((c) <= 0x0E59)) || \
|
||||
(((c) >= 0x0ED0) && ((c) <= 0x0ED9)) || \
|
||||
(((c) >= 0x0F20) && ((c) <= 0x0F29)))
|
||||
(((c) >= 0x0F20) && ((c) <= 0x0F29))) /* accelerator */ ))
|
||||
|
||||
/*
|
||||
* [87] CombiningChar ::= ... long list see REC ...
|
||||
*/
|
||||
#define IS_COMBINING(c) \
|
||||
((((c) >= 0x0300) && ((c) <= 0x0345)) || \
|
||||
((((c) >= 0x300) && ( /* accelerator */ \
|
||||
(((c) >= 0x0300) && ((c) <= 0x0345)) || \
|
||||
(((c) >= 0x0360) && ((c) <= 0x0361)) || \
|
||||
(((c) >= 0x0483) && ((c) <= 0x0486)) || \
|
||||
(((c) >= 0x0591) && ((c) <= 0x05A1)) || \
|
||||
@ -291,6 +296,7 @@ extern "C" {
|
||||
(((c) >= 0x06E0) && ((c) <= 0x06E4)) || \
|
||||
(((c) >= 0x06E7) && ((c) <= 0x06E8)) || \
|
||||
(((c) >= 0x06EA) && ((c) <= 0x06ED)) || \
|
||||
(((c) > 0x0901) && ( /* accelerator */ \
|
||||
(((c) >= 0x0901) && ((c) <= 0x0903)) || \
|
||||
((c) == 0x093C) || \
|
||||
(((c) >= 0x093E) && ((c) <= 0x094C)) || \
|
||||
@ -306,6 +312,7 @@ extern "C" {
|
||||
(((c) >= 0x09CB) && ((c) <= 0x09CD)) || \
|
||||
((c) == 0x09D7) || \
|
||||
(((c) >= 0x09E2) && ((c) <= 0x09E3)) || \
|
||||
(((c) > 0x0A02) && ( /* accelerator */ \
|
||||
((c) == 0x0A02) || \
|
||||
((c) == 0x0A3C) || \
|
||||
((c) == 0x0A3E) || \
|
||||
@ -345,6 +352,7 @@ extern "C" {
|
||||
(((c) >= 0x0D46) && ((c) <= 0x0D48)) || \
|
||||
(((c) >= 0x0D4A) && ((c) <= 0x0D4D)) || \
|
||||
((c) == 0x0D57) || \
|
||||
(((c) > 0x0E31) && ( /* accelerator */ \
|
||||
((c) == 0x0E31) || \
|
||||
(((c) >= 0x0E34) && ((c) <= 0x0E3A)) || \
|
||||
(((c) >= 0x0E47) && ((c) <= 0x0E4E)) || \
|
||||
@ -369,7 +377,7 @@ extern "C" {
|
||||
((c) == 0x20E1) || \
|
||||
(((c) >= 0x302A) && ((c) <= 0x302F)) || \
|
||||
((c) == 0x3099) || \
|
||||
((c) == 0x309A))
|
||||
((c) == 0x309A)) /* accelerator */ ))))))))
|
||||
|
||||
/*
|
||||
* [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 |
|
||||
|
43
testSAX.c
43
testSAX.c
@ -46,6 +46,7 @@ static int debug = 0;
|
||||
static int copy = 0;
|
||||
static int recovery = 0;
|
||||
static int push = 0;
|
||||
static int speed = 0;
|
||||
|
||||
xmlSAXHandler emptySAXHandlerStruct = {
|
||||
NULL, /* internalSubset */
|
||||
@ -635,20 +636,33 @@ void parseAndPrintFile(char *filename) {
|
||||
fclose(f);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Empty callbacks for checking
|
||||
*/
|
||||
res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename);
|
||||
if (res != 0) {
|
||||
fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
|
||||
}
|
||||
if (!speed) {
|
||||
/*
|
||||
* Empty callbacks for checking
|
||||
*/
|
||||
res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename);
|
||||
if (res != 0) {
|
||||
fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
|
||||
}
|
||||
|
||||
/*
|
||||
* Debug callback
|
||||
*/
|
||||
res = xmlSAXUserParseFile(debugSAXHandler, NULL, filename);
|
||||
if (res != 0) {
|
||||
fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
|
||||
/*
|
||||
* Debug callback
|
||||
*/
|
||||
res = xmlSAXUserParseFile(debugSAXHandler, NULL, filename);
|
||||
if (res != 0) {
|
||||
fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* test 100x the SAX parse
|
||||
*/
|
||||
int i;
|
||||
|
||||
for (i = 0; i<100;i++)
|
||||
res = xmlSAXUserParseFile(emptySAXHandler, NULL, filename);
|
||||
if (res != 0) {
|
||||
fprintf(stdout, "xmlSAXUserParseFile returned error %d\n", res);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -669,6 +683,9 @@ int main(int argc, char **argv) {
|
||||
else if ((!strcmp(argv[i], "-push")) ||
|
||||
(!strcmp(argv[i], "--push")))
|
||||
push++;
|
||||
else if ((!strcmp(argv[i], "-speed")) ||
|
||||
(!strcmp(argv[i], "--speed")))
|
||||
speed++;
|
||||
}
|
||||
for (i = 1; i < argc ; i++) {
|
||||
if (argv[i][0] != '-') {
|
||||
|
29
xmlIO.c
29
xmlIO.c
@ -635,6 +635,35 @@ xmlParserInputBufferCreateFd(int fd, xmlCharEncoding enc) {
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlParserInputBufferCreateIO:
|
||||
* @ioread: an I/O read function
|
||||
* @ioclose: an I/O close function
|
||||
* @ioctx: an I/O handler
|
||||
* @enc: the charset encoding if known
|
||||
*
|
||||
* Create a buffered parser input for the progressive parsing for the input
|
||||
* from a file descriptor
|
||||
*
|
||||
* Returns the new parser input or NULL
|
||||
*/
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateIO(xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose, void *ioctx, xmlCharEncoding enc) {
|
||||
xmlParserInputBufferPtr ret;
|
||||
|
||||
if (ioread == NULL) return(NULL);
|
||||
|
||||
ret = xmlAllocParserInputBuffer(enc);
|
||||
if (ret != NULL) {
|
||||
ret->context = (void *) ioctx;
|
||||
ret->readcallback = ioread;
|
||||
ret->closecallback = ioclose;
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlParserInputBufferPush:
|
||||
* @in: a buffered parser input
|
||||
|
5
xmlIO.h
5
xmlIO.h
@ -52,6 +52,11 @@ xmlParserInputBufferPtr
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFd (int fd,
|
||||
xmlCharEncoding enc);
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateIO (xmlInputReadCallback ioread,
|
||||
xmlInputCloseCallback ioclose,
|
||||
void *ioctx,
|
||||
xmlCharEncoding enc);
|
||||
int xmlParserInputBufferRead (xmlParserInputBufferPtr in,
|
||||
int len);
|
||||
int xmlParserInputBufferGrow (xmlParserInputBufferPtr in,
|
||||
|
40
xmllint.c
40
xmllint.c
@ -67,6 +67,7 @@ static int html = 0;
|
||||
static int htmlout = 0;
|
||||
static int push = 0;
|
||||
static int noblanks = 0;
|
||||
static int testIO = 0;
|
||||
|
||||
extern int xmlDoValidityCheckingDefaultValue;
|
||||
extern int xmlGetWarningsDefaultValue;
|
||||
@ -336,6 +337,19 @@ xmlShellReadline(char *prompt) {
|
||||
#endif
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* I/O Interfaces *
|
||||
* *
|
||||
************************************************************************/
|
||||
|
||||
int myRead(FILE *f, char * buffer, int len) {
|
||||
return(fread(buffer, 1, len, f));
|
||||
}
|
||||
void myClose(FILE *f) {
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
* *
|
||||
* Test processing *
|
||||
@ -375,6 +389,28 @@ void parseAndPrintFile(char *filename) {
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
}
|
||||
}
|
||||
} else if (testIO) {
|
||||
int ret;
|
||||
FILE *f;
|
||||
|
||||
f = fopen(filename, "r");
|
||||
if (f != NULL) {
|
||||
xmlParserCtxtPtr ctxt;
|
||||
|
||||
ctxt = xmlCreateIOParserCtxt(NULL, NULL,
|
||||
(xmlInputReadCallback) myRead,
|
||||
(xmlInputCloseCallback) myClose,
|
||||
f, XML_CHAR_ENCODING_NONE);
|
||||
xmlParseDocument(ctxt);
|
||||
|
||||
ret = ctxt->wellFormed;
|
||||
doc = ctxt->myDoc;
|
||||
xmlFreeParserCtxt(ctxt);
|
||||
if (!ret) {
|
||||
xmlFreeDoc(doc);
|
||||
doc = NULL;
|
||||
}
|
||||
}
|
||||
} else if (recovery) {
|
||||
doc = xmlRecoverFile(filename);
|
||||
} else if (htmlout) {
|
||||
@ -545,6 +581,9 @@ int main(int argc, char **argv) {
|
||||
else if ((!strcmp(argv[i], "-push")) ||
|
||||
(!strcmp(argv[i], "--push")))
|
||||
push++;
|
||||
else if ((!strcmp(argv[i], "-testIO")) ||
|
||||
(!strcmp(argv[i], "--testIO")))
|
||||
testIO++;
|
||||
else if ((!strcmp(argv[i], "-compress")) ||
|
||||
(!strcmp(argv[i], "--compress"))) {
|
||||
compress++;
|
||||
@ -612,6 +651,7 @@ int main(int argc, char **argv) {
|
||||
printf("\t--push : use the push mode of the parser\n");
|
||||
printf("\t--nowarning : do not emit warnings from parser/validator\n");
|
||||
printf("\t--noblanks : drop (ignorable?) blanks spaces\n");
|
||||
printf("\t--testIO : test user I/O support\n");
|
||||
}
|
||||
xmlCleanupParser();
|
||||
xmlMemoryDump();
|
||||
|
Loading…
x
Reference in New Issue
Block a user