summaryrefslogtreecommitdiff
path: root/SAX2.c
diff options
context:
space:
mode:
authorMike Hommey <glandium@debian.org>2005-09-05 17:10:35 +0000
committerMike Hommey <glandium@debian.org>2005-09-05 17:10:35 +0000
commita464d9993e2acd5b8e1089b218ba74c6fcf215c5 (patch)
tree72fe00eb59147367a1d660b90d08172357e0dffc /SAX2.c
parent112cb5bb5475afec1c1cbf1d6728ce4880d0fee8 (diff)
downloadlibxml2-a464d9993e2acd5b8e1089b218ba74c6fcf215c5.tar.gz
Load /usr/tmp/tmp.CMoFff/libxml2-2.6.21 intoupstream/2.6.21
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'SAX2.c')
-rw-r--r--SAX2.c69
1 files changed, 47 insertions, 22 deletions
diff --git a/SAX2.c b/SAX2.c
index 16e361f..9f7edf6 100644
--- a/SAX2.c
+++ b/SAX2.c
@@ -227,7 +227,7 @@ const xmlChar *
xmlSAX2GetSystemId(void *ctx)
{
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
- if ((ctx == NULL) || (ctxt->input == NULL)) return(0);
+ if ((ctx == NULL) || (ctxt->input == NULL)) return(NULL);
return((const xmlChar *) ctxt->input->filename);
}
@@ -1022,7 +1022,7 @@ xmlSAX2EndDocument(void *ctx)
}
}
-#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED)
+#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED)
/**
* xmlSAX2AttributeInternal:
* @ctx: the user data (XML parser context)
@@ -1316,11 +1316,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
* when validating, the ID registration is done at the attribute
* validation level. Otherwise we have to do specific handling here.
*/
- if (xmlIsID(ctxt->myDoc, ctxt->node, ret))
- xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
- else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret))
- xmlAddRef(&ctxt->vctxt, ctxt->myDoc, value, ret);
- else if (xmlStrEqual(fullname, BAD_CAST "xml:id")) {
+ if (xmlStrEqual(fullname, BAD_CAST "xml:id")) {
/*
* Add the xml:id value
*
@@ -1332,7 +1328,10 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
(const char *) value, NULL);
}
xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
- }
+ } else if (xmlIsID(ctxt->myDoc, ctxt->node, ret))
+ xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
+ else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret))
+ xmlAddRef(&ctxt->vctxt, ctxt->myDoc, value, ret);
}
error:
@@ -1777,6 +1776,7 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
xmlErrMemory(ctxt, "xmlSAX2Characters");
return(NULL);
}
+ memset(ret, 0, sizeof(xmlNode));
/*
* intern the formatting blanks found between tags, or the
* very short strings
@@ -1784,7 +1784,14 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
if (ctxt->dictNames) {
xmlChar cur = str[len];
- if ((len <= 3) && ((cur == '"') || (cur == '\'') ||
+ if ((len < (int) (2 * sizeof(void *))) &&
+ (ctxt->options & XML_PARSE_COMPACT)) {
+ /* store the string in the node overrithing properties and nsDef */
+ xmlChar *tmp = (xmlChar *) &(ret->properties);
+ memcpy(tmp, str, len);
+ tmp[len] = 0;
+ intern = tmp;
+ } else if ((len <= 3) && ((cur == '"') || (cur == '\'') ||
((cur == '<') && (str[len + 1] != '!')))) {
intern = xmlDictLookup(ctxt->dict, str, len);
} else if (IS_BLANK_CH(*str) && (len < 60) && (cur == '<') &&
@@ -1798,7 +1805,6 @@ xmlSAX2TextNode(xmlParserCtxtPtr ctxt, const xmlChar *str, int len) {
}
}
skip:
- memset(ret, 0, sizeof(xmlNode));
ret->type = XML_TEXT_NODE;
ret->name = xmlStringText;
@@ -2040,16 +2046,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
* when validating, the ID registration is done at the attribute
* validation level. Otherwise we have to do specific handling here.
*/
- if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
- /* might be worth duplicate entry points and not copy */
- if (dup == NULL)
- dup = xmlStrndup(value, valueend - value);
- xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
- } else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) {
- if (dup == NULL)
- dup = xmlStrndup(value, valueend - value);
- xmlAddRef(&ctxt->vctxt, ctxt->myDoc, dup, ret);
- } else if ((prefix == ctxt->str_xml) &&
+ if ((prefix == ctxt->str_xml) &&
(localname[0] == 'i') && (localname[1] == 'd') &&
(localname[2] == 0)) {
/*
@@ -2067,6 +2064,15 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
}
#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 */
+ if (dup == NULL)
+ dup = xmlStrndup(value, valueend - value);
+ xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
+ } else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) {
+ if (dup == NULL)
+ dup = xmlStrndup(value, valueend - value);
+ xmlAddRef(&ctxt->vctxt, ctxt->myDoc, dup, ret);
}
}
if (dup != NULL)
@@ -2407,8 +2413,11 @@ xmlSAX2Characters(void *ctx, const xmlChar *ch, int len)
* We try to minimaze realloc() uses and avoid copying
* and recomputing length over and over.
*/
- if ((ctxt->nodemem == ctxt->nodelen + 1) &&
- (xmlDictOwns(ctxt->dict, lastChild->content))) {
+ if (lastChild->content == (xmlChar *)&(lastChild->properties)) {
+ lastChild->content = xmlStrdup(lastChild->content);
+ lastChild->properties = NULL;
+ } else if ((ctxt->nodemem == ctxt->nodelen + 1) &&
+ (xmlDictOwns(ctxt->dict, lastChild->content))) {
lastChild->content = xmlStrdup(lastChild->content);
}
if (ctxt->nodelen + len >= ctxt->nodemem) {
@@ -2496,6 +2505,14 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
if (ret == NULL) return;
parent = ctxt->node;
+ if (ctxt->linenumbers) {
+ if (ctxt->input != NULL) {
+ if (ctxt->input->line < 65535)
+ ret->line = (short) ctxt->input->line;
+ else
+ ret->line = 65535;
+ }
+ }
if (ctxt->inSubset == 1) {
xmlAddChild((xmlNodePtr) ctxt->myDoc->intSubset, ret);
return;
@@ -2548,6 +2565,14 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
#endif
ret = xmlNewDocComment(ctxt->myDoc, value);
if (ret == NULL) return;
+ if (ctxt->linenumbers) {
+ if (ctxt->input != NULL) {
+ if (ctxt->input->line < 65535)
+ ret->line = (short) ctxt->input->line;
+ else
+ ret->line = 65535;
+ }
+ }
if (ctxt->inSubset == 1) {
xmlAddChild((xmlNodePtr) ctxt->myDoc->intSubset, ret);