1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-28 00:21:53 +03:00

adding repeated parsing and validating tests make the new DOM tree

* Makefile.am: adding repeated parsing and validating tests
* SAX2.c parser.c tree.c include/libxml/parser.h: make the new
  DOM tree building interfaces use the dictionary from the
  parsing context to build the element and attributes names
  as well as formatting spaces and short text nodes
* include/libxml/dict.h dict.c: added some reference counting
  for xmlDictPtr because they can be shared by documents and
  a parser context.
* xmlreader.c: a bit of cleanup, remove the specific tree freeing
  functions and use the standard ones now.
* xmllint.c: add --nodict
* python/libxml.c: fix a stupid bug so that ns() works on
  attribute nodes.
Daniel
This commit is contained in:
Daniel Veillard
2003-09-24 21:23:56 +00:00
parent 16fa96c5d0
commit e96a2a4bf0
11 changed files with 258 additions and 125 deletions

View File

@ -11925,6 +11925,18 @@ xmlCleanupParser(void) {
* *
************************************************************************/
/**
* DICT_FREE:
* @str: a string
*
* Free a string if it is not owned by the "dict" dictionnary in the
* current scope
*/
#define DICT_FREE(str) \
if ((str) && ((!dict) || \
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
xmlFree((char *)(str));
/**
* xmlCtxtReset:
* @ctxt: an XML parser context
@ -11935,6 +11947,7 @@ void
xmlCtxtReset(xmlParserCtxtPtr ctxt)
{
xmlParserInputPtr input;
xmlDictPtr dict = ctxt->dict;
while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */
xmlFreeInputStream(input);
@ -11953,8 +11966,20 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
ctxt->nameNr = 0;
ctxt->name = NULL;
DICT_FREE(ctxt->version);
ctxt->version = NULL;
DICT_FREE(ctxt->encoding);
ctxt->encoding = NULL;
DICT_FREE(ctxt->directory);
ctxt->directory = NULL;
DICT_FREE(ctxt->extSubURI);
ctxt->extSubURI = NULL;
DICT_FREE(ctxt->extSubSystem);
ctxt->extSubSystem = NULL;
if (ctxt->myDoc != NULL)
xmlFreeDoc(ctxt->myDoc);
ctxt->myDoc = NULL;
ctxt->standalone = -1;
ctxt->hasExternalSubset = 0;
ctxt->hasPErefs = 0;
@ -11962,9 +11987,7 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
ctxt->external = 0;
ctxt->instate = XML_PARSER_START;
ctxt->token = 0;
ctxt->directory = NULL;
ctxt->myDoc = NULL;
ctxt->wellFormed = 1;
ctxt->nsWellFormed = 1;
ctxt->valid = 1;
@ -12064,6 +12087,12 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
ctxt->sax->initialized = 1;
options -= XML_PARSE_SAX1;
}
if (options & XML_PARSE_NODICT) {
ctxt->dictNames = 0;
options -= XML_PARSE_NODICT;
} else {
ctxt->dictNames = 1;
}
return (options);
}
@ -12096,11 +12125,25 @@ xmlDoRead(xmlParserCtxtPtr ctxt, const char *encoding, int options, int reuse)
ret = ctxt->myDoc;
else {
ret = NULL;
xmlFreeDoc(ctxt->myDoc);
ctxt->myDoc = NULL;
if (ctxt->myDoc != NULL) {
ctxt->myDoc->dict = NULL;
xmlFreeDoc(ctxt->myDoc);
}
}
if (!reuse)
ctxt->myDoc = NULL;
if (!reuse) {
if ((ctxt->dictNames) &&
(ret != NULL) &&
(ret->dict == ctxt->dict))
ctxt->dict = NULL;
xmlFreeParserCtxt(ctxt);
} else {
/* Must duplicate the reference to the dictionary */
if ((ctxt->dictNames) &&
(ret != NULL) &&
(ret->dict == ctxt->dict))
xmlDictReference(ctxt->dict);
}
return (ret);
}