mirror of
https://github.com/darlinghq/darling-libxml2.git
synced 2025-01-26 04:24:30 +00:00
included a new function to reuse a Push parser context, based on Graham
* parser.c include/libxml/parser.h: included a new function to reuse a Push parser context, based on Graham Bennett original code * valid.c: in HTML, a name in an input is not an ID * TODO: bug list update Daniel
This commit is contained in:
parent
ae9733aeaf
commit
9ba8e389a2
@ -1,3 +1,11 @@
|
||||
Tue Oct 28 22:28:50 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* parser.c include/libxml/parser.h: included a new function
|
||||
to reuse a Push parser context, based on Graham Bennett original
|
||||
code
|
||||
* valid.c: in HTML, a name in an input is not an ID
|
||||
* TODO: bug list update
|
||||
|
||||
Tue Oct 28 19:54:37 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* xpath.c: applied patch from nico@xtradyne.com for #125030
|
||||
|
3
TODO
3
TODO
@ -1,8 +1,5 @@
|
||||
125030 xmlXPathCompile() allows invalid xpath expressions to pass
|
||||
124907 HTML parse buffer problem when parsing larse in-memory docs
|
||||
124866 Python error catch for Relax-NG
|
||||
124110 DTD validation && wrong namespace
|
||||
124044 Segfault python bindings for reader
|
||||
123564 xmllint --html --format
|
||||
|
||||
TODO for the XML parser and stuff:
|
||||
|
@ -1107,6 +1107,12 @@ typedef enum {
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlCtxtReset (xmlParserCtxtPtr ctxt);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCtxtResetPush (xmlParserCtxtPtr ctxt,
|
||||
const char *chunk,
|
||||
int size,
|
||||
const char *filename,
|
||||
const char *encoding);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlCtxtUseOptions (xmlParserCtxtPtr ctxt,
|
||||
int options);
|
||||
|
101
parser.c
101
parser.c
@ -12121,6 +12121,107 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
|
||||
xmlResetError(&ctxt->lastError);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCtxtResetPush:
|
||||
* @ctxt: an XML parser context
|
||||
* @chunk: a pointer to an array of chars
|
||||
* @size: number of chars in the array
|
||||
* @filename: an optional file name or URI
|
||||
* @encoding: the document encoding, or NULL
|
||||
*
|
||||
* Reset a parser context
|
||||
*/
|
||||
int
|
||||
xmlCtxtResetPush(xmlParserCtxtPtr ctxt, const char *chunk,
|
||||
int size, const char *filename, const char *encoding)
|
||||
{
|
||||
xmlParserInputPtr inputStream;
|
||||
xmlParserInputBufferPtr buf;
|
||||
xmlCharEncoding enc = XML_CHAR_ENCODING_NONE;
|
||||
|
||||
if ((encoding == NULL) && (chunk != NULL) && (size >= 4))
|
||||
enc = xmlDetectCharEncoding((const xmlChar *) chunk, size);
|
||||
|
||||
buf = xmlAllocParserInputBuffer(enc);
|
||||
if (buf == NULL)
|
||||
return(1);
|
||||
|
||||
if (ctxt == NULL) {
|
||||
xmlFreeParserInputBuffer(buf);
|
||||
return(1);
|
||||
}
|
||||
|
||||
xmlCtxtReset(ctxt);
|
||||
|
||||
if (ctxt->pushTab == NULL) {
|
||||
ctxt->pushTab = (void **) xmlMalloc(ctxt->nameMax * 3 *
|
||||
sizeof(xmlChar *));
|
||||
if (ctxt->pushTab == NULL) {
|
||||
xmlErrMemory(ctxt, NULL);
|
||||
xmlFreeParserInputBuffer(buf);
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
|
||||
if (filename == NULL) {
|
||||
ctxt->directory = NULL;
|
||||
} else {
|
||||
ctxt->directory = xmlParserGetDirectory(filename);
|
||||
}
|
||||
|
||||
inputStream = xmlNewInputStream(ctxt);
|
||||
if (inputStream == NULL) {
|
||||
xmlFreeParserInputBuffer(buf);
|
||||
return(1);
|
||||
}
|
||||
|
||||
if (filename == NULL)
|
||||
inputStream->filename = NULL;
|
||||
else
|
||||
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];
|
||||
|
||||
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;
|
||||
|
||||
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];
|
||||
#ifdef DEBUG_PUSH
|
||||
xmlGenericError(xmlGenericErrorContext, "PP: pushed %d\n", size);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (encoding != NULL) {
|
||||
xmlCharEncodingHandlerPtr hdlr;
|
||||
|
||||
hdlr = xmlFindCharEncodingHandler(encoding);
|
||||
if (hdlr != NULL) {
|
||||
xmlSwitchToEncoding(ctxt, hdlr);
|
||||
} else {
|
||||
xmlFatalErrMsgStr(ctxt, XML_ERR_UNSUPPORTED_ENCODING,
|
||||
"Unsupported encoding %s\n", BAD_CAST encoding);
|
||||
}
|
||||
} else if (enc != XML_CHAR_ENCODING_NONE) {
|
||||
xmlSwitchEncoding(ctxt, enc);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* xmlCtxtUseOptions:
|
||||
* @ctxt: an XML parser context
|
||||
|
5
valid.c
5
valid.c
@ -2498,8 +2498,9 @@ xmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) {
|
||||
if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
|
||||
return(0);
|
||||
} else if (doc->type == XML_HTML_DOCUMENT_NODE) {
|
||||
if ((xmlStrEqual(BAD_CAST "id", attr->name)) ||
|
||||
(xmlStrEqual(BAD_CAST "name", attr->name)))
|
||||
if (((xmlStrEqual(BAD_CAST "id", attr->name)) ||
|
||||
(xmlStrEqual(BAD_CAST "name", attr->name))) &&
|
||||
((elem != NULL) && (!xmlStrEqual(elem->name, BAD_CAST "input"))))
|
||||
return(1);
|
||||
return(0);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user