factoring of more error handling code, serious size reduction and more

* parser.c include/libxml/xmlerror.h: factoring of more
  error handling code, serious size reduction and more lisibility
  of the resulting code.
* parserInternals.c parser.c include/libxml/parserInternals.h
  include/libxml/parser.h: changing the way VC:Proper Group/PE Nesting
  checks are done, use a counter for entities. Entities where freed and
  reallocated at the same address failing the check.
* tree.c: avoid a warning
* result/valid/* result/VC/*: this slightly changes some validation
  error messages.
Daniel
This commit is contained in:
Daniel Veillard 2003-09-14 19:56:14 +00:00
parent 4e52f2f430
commit bdbe0d4e78
15 changed files with 468 additions and 661 deletions

View File

@ -1,3 +1,16 @@
Sun Sep 14 21:43:32 CEST 2003 Daniel Veillard <daniel@veillard.com>
* parser.c include/libxml/xmlerror.h: factoring of more
error handling code, serious size reduction and more lisibility
of the resulting code.
* parserInternals.c parser.c include/libxml/parserInternals.h
include/libxml/parser.h: changing the way VC:Proper Group/PE Nesting
checks are done, use a counter for entities. Entities where freed and
reallocated at the same address failing the check.
* tree.c: avoid a warning
* result/valid/* result/VC/*: this slightly changes some validation
error messages.
Sun Sep 14 11:03:27 PDT 2003 William Brack <wbrack@mmm.com.hk>
* valid.c: fixed bug 121759 - early declaration of

View File

@ -68,6 +68,7 @@ struct _xmlParserInput {
const xmlChar *encoding; /* the encoding string for entity */
const xmlChar *version; /* the version string for entity */
int standalone; /* Was that entity marked standalone */
int id; /* an unique identifier for the entity */
};
/**

View File

@ -313,11 +313,11 @@ XMLPUBFUN void XMLCALL
XMLPUBFUN xmlElementContentPtr XMLCALL
xmlParseElementMixedContentDecl
(xmlParserCtxtPtr ctxt,
xmlParserInputPtr inputchk);
int inputchk);
XMLPUBFUN xmlElementContentPtr XMLCALL
xmlParseElementChildrenContentDecl
(xmlParserCtxtPtr ctxt,
xmlParserInputPtr inputchk);
int inputchk);
XMLPUBFUN int XMLCALL
xmlParseElementContentDecl(xmlParserCtxtPtr ctxt,
const xmlChar *name,

View File

@ -140,7 +140,8 @@ typedef enum {
XML_NS_ERR_UNDEFINED_NAMESPACE,
XML_NS_ERR_QNAME,
XML_NS_ERR_ATTRIBUTE_REDEFINED,
XML_ERR_CONDSEC_INVALID_KEYWORD
XML_ERR_CONDSEC_INVALID_KEYWORD,
XML_ERR_VERSION_MISSING
} xmlParserErrors;
/**

702
parser.c

File diff suppressed because it is too large Load Diff

View File

@ -1973,6 +1973,7 @@ xmlFreeInputStream(xmlParserInputPtr input) {
xmlParserInputPtr
xmlNewInputStream(xmlParserCtxtPtr ctxt) {
xmlParserInputPtr input;
static int id = 0;
input = (xmlParserInputPtr) xmlMalloc(sizeof(xmlParserInput));
if (input == NULL) {
@ -1989,6 +1990,11 @@ 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.
*/
input->id = id++;
return(input);
}

View File

@ -573,53 +573,41 @@ Class xmlDoc(xmlNode)
# functions from module xpointer
xpointerNewContext()
Class xpathContext()
# accessors
contextDoc()
contextNode()
contextPosition()
contextSize()
function()
functionURI()
setContextDoc()
setContextNode()
# functions from module python
registerXPathFunction()
# functions from module xpath
xpathEval()
xpathEvalExpression()
xpathFreeContext()
# functions from module xpathInternals
xpathNewParserContext()
xpathNsLookup()
xpathRegisterAllFunctions()
xpathRegisterNs()
xpathRegisteredFuncsCleanup()
xpathRegisteredNsCleanup()
xpathRegisteredVariablesCleanup()
xpathVariableLookup()
xpathVariableLookupNS()
# functions from module xpointer
xpointerEval()
Class xmlAttribute(xmlNode)
Class xmlTextReaderLocator()
# functions from module xmlreader
BaseURI()
LineNumber()
Class xmlNs(xmlNode)
# functions from module tree
copyNamespace()
copyNamespaceList()
freeNs()
freeNsList()
newChild()
newDocNode()
newDocNodeEatName()
newDocRawNode()
newNodeEatName()
newNsProp()
newNsPropEatName()
newTextChild()
setNs()
setNsProp()
unsetNsProp()
# functions from module xpathInternals
xpathNodeSetFreeNs()
Class xmlDtd(xmlNode)
# functions from module debugXML
debugDumpDTD()
# functions from module tree
copyDtd()
freeDtd()
# functions from module valid
dtdAttrDesc()
dtdElementDesc()
dtdQAttrDesc()
dtdQElementDesc()
Class catalog()
# functions from module catalog
@ -633,6 +621,106 @@ Class catalog()
resolvePublic()
resolveSystem()
resolveURI()
Class xmlElement(xmlNode)
Class xmlAttr(xmlNode)
# functions from module debugXML
debugDumpAttr()
debugDumpAttrList()
# functions from module tree
copyProp()
copyPropList()
freeProp()
freePropList()
removeProp()
# functions from module valid
removeID()
removeRef()
Class xmlTextReader(xmlTextReaderCore)
# functions from module xmlreader
AttributeCount()
BaseUri()
Close()
CurrentDoc()
CurrentNode()
Depth()
Expand()
GetAttribute()
GetAttributeNo()
GetAttributeNs()
GetParserProp()
GetRemainder()
HasAttributes()
HasValue()
IsDefault()
IsEmptyElement()
IsValid()
LocalName()
LookupNamespace()
MoveToAttribute()
MoveToAttributeNo()
MoveToAttributeNs()
MoveToElement()
MoveToFirstAttribute()
MoveToNextAttribute()
Name()
NamespaceUri()
Next()
NodeType()
Normalization()
Prefix()
QuoteChar()
Read()
ReadAttributeValue()
ReadInnerXml()
ReadOuterXml()
ReadState()
ReadString()
RelaxNGSetSchema()
RelaxNGValidate()
SetParserProp()
Value()
XmlLang()
Class xmlReg()
# functions from module xmlregexp
regexpExec()
regexpFreeRegexp()
regexpIsDeterminist()
regexpPrint()
Class xmlEntity(xmlNode)
# functions from module parserInternals
handleEntity()
Class relaxNgSchema()
# functions from module relaxng
relaxNGDump()
relaxNGDumpTree()
relaxNGFree()
relaxNGNewValidCtxt()
# functions from module xmlreader
RelaxNGSetSchema()
Class relaxNgValidCtxt()
# functions from module relaxng
relaxNGValidateDoc()
relaxNGValidateFullElement()
relaxNGValidatePopElement()
relaxNGValidatePushCData()
relaxNGValidatePushElement()
Class xpathParserContext()
# accessors
context()
@ -778,6 +866,62 @@ Class parserCtxt(parserCtxtCore)
stringLenDecodeEntities()
Class xmlDtd(xmlNode)
# functions from module debugXML
debugDumpDTD()
# functions from module tree
copyDtd()
freeDtd()
# functions from module valid
dtdAttrDesc()
dtdElementDesc()
dtdQAttrDesc()
dtdQElementDesc()
Class xmlNs(xmlNode)
# functions from module tree
copyNamespace()
copyNamespaceList()
freeNs()
freeNsList()
newChild()
newDocNode()
newDocNodeEatName()
newDocRawNode()
newNodeEatName()
newNsProp()
newNsPropEatName()
newTextChild()
setNs()
setNsProp()
unsetNsProp()
# functions from module xpathInternals
xpathNodeSetFreeNs()
Class inputBuffer(ioReadWrapper)
# functions from module xmlIO
freeParserInputBuffer()
grow()
push()
read()
# functions from module xmlreader
newTextReader()
Class relaxNgParserCtxt()
# functions from module relaxng
relaxNGFreeParserCtxt()
relaxNGParse()
Class outputBuffer(ioWriteWrapper)
# functions from module HTMLtree
@ -796,98 +940,11 @@ Class outputBuffer(ioWriteWrapper)
flush()
write()
writeString()
Class xmlElement(xmlNode)
Class relaxNgSchema()
# functions from module relaxng
relaxNGDump()
relaxNGDumpTree()
relaxNGFree()
relaxNGNewValidCtxt()
Class xmlTextReaderLocator()
# functions from module xmlreader
RelaxNGSetSchema()
Class xmlEntity(xmlNode)
# functions from module parserInternals
handleEntity()
Class xmlTextReader(xmlTextReaderCore)
# functions from module xmlreader
AttributeCount()
BaseUri()
Close()
CurrentDoc()
CurrentNode()
Depth()
Expand()
GetAttribute()
GetAttributeNo()
GetAttributeNs()
GetParserProp()
GetRemainder()
HasAttributes()
HasValue()
IsDefault()
IsEmptyElement()
IsValid()
LocalName()
LookupNamespace()
MoveToAttribute()
MoveToAttributeNo()
MoveToAttributeNs()
MoveToElement()
MoveToFirstAttribute()
MoveToNextAttribute()
Name()
NamespaceUri()
Next()
NodeType()
Normalization()
Prefix()
QuoteChar()
Read()
ReadAttributeValue()
ReadInnerXml()
ReadOuterXml()
ReadState()
ReadString()
RelaxNGSetSchema()
RelaxNGValidate()
SetParserProp()
Value()
XmlLang()
Class xmlAttr(xmlNode)
# functions from module debugXML
debugDumpAttr()
debugDumpAttrList()
# functions from module tree
copyProp()
copyPropList()
freeProp()
freePropList()
removeProp()
# functions from module valid
removeID()
removeRef()
Class xmlReg()
# functions from module xmlregexp
regexpExec()
regexpFreeRegexp()
regexpIsDeterminist()
regexpPrint()
BaseURI()
LineNumber()
Class URI()
# accessors
authority()
@ -914,60 +971,3 @@ Class URI()
parseURIReference()
printURI()
saveUri()
Class relaxNgParserCtxt()
# functions from module relaxng
relaxNGFreeParserCtxt()
relaxNGParse()
Class xpathContext()
# accessors
contextDoc()
contextNode()
contextPosition()
contextSize()
function()
functionURI()
setContextDoc()
setContextNode()
# functions from module python
registerXPathFunction()
# functions from module xpath
xpathEval()
xpathEvalExpression()
xpathFreeContext()
# functions from module xpathInternals
xpathNewParserContext()
xpathNsLookup()
xpathRegisterAllFunctions()
xpathRegisterNs()
xpathRegisteredFuncsCleanup()
xpathRegisteredNsCleanup()
xpathRegisteredVariablesCleanup()
xpathVariableLookup()
xpathVariableLookupNS()
# functions from module xpointer
xpointerEval()
Class inputBuffer(ioReadWrapper)
# functions from module xmlIO
freeParserInputBuffer()
grow()
push()
read()
# functions from module xmlreader
newTextReader()
Class relaxNgValidCtxt()
# functions from module relaxng
relaxNGValidateDoc()
relaxNGValidateFullElement()
relaxNGValidatePopElement()
relaxNGValidatePushCData()
relaxNGValidatePushElement()

View File

@ -1,4 +1,4 @@
./test/VC/PENesting:1: error: xmlParseStartTag: invalid element name
./test/VC/PENesting:1: error: StartTag: invalid element name
<!ENTITY % pe1 "EMPTY> <!ELEMENT e2 EMPTY>">
^
./test/VC/PENesting:1: error: Extra content at the end of the document

View File

@ -1,4 +1,4 @@
./test/VC/PENesting2:1: error: xmlParseStartTag: invalid element name
./test/VC/PENesting2:1: error: StartTag: invalid element name
<!ENTITY % p1 "(A|B">
^
./test/VC/PENesting2:1: error: Extra content at the end of the document

View File

@ -1,4 +1,4 @@
./test/valid/t4.dtd:1: error: xmlParseStartTag: invalid element name
./test/valid/t4.dtd:1: error: StartTag: invalid element name
<!ENTITY % percent "&#x25;">
^
./test/valid/t4.dtd:1: error: Extra content at the end of the document

View File

@ -1,4 +1,4 @@
./test/valid/t4a.dtd:1: error: xmlParseStartTag: invalid element name
./test/valid/t4a.dtd:1: error: StartTag: invalid element name
<!ENTITY % percent "&#x25;">
^
./test/valid/t4a.dtd:1: error: Extra content at the end of the document

View File

@ -1,4 +1,4 @@
./test/valid/t6.dtd:1: error: xmlParseStartTag: invalid element name
./test/valid/t6.dtd:1: error: StartTag: invalid element name
<!ENTITY % xdef "def">
^
./test/valid/t6.dtd:1: error: Extra content at the end of the document

View File

@ -1,4 +1,4 @@
Entity: line 1: error: xmlParseInternalSubset: error detected in Markup declaration
Entity: line 1: error: internal error: xmlParseInternalSubset: error detected in Markup declaration
%defroot;
^
Entity: line 1:

View File

@ -1,4 +1,4 @@
Entity: line 1: error: xmlParseInternalSubset: error detected in Markup declaration
Entity: line 1: error: internal error: xmlParseInternalSubset: error detected in Markup declaration
%defroot;
^
Entity: line 1:

4
tree.c
View File

@ -5303,8 +5303,8 @@ xmlSearchNs(xmlDocPtr doc, xmlNodePtr node, const xmlChar *nameSpace) {
* Returns 1 if true, 0 if false and -1 in case of error.
*/
static int
xmlNsInScope(xmlDocPtr doc, xmlNodePtr node, xmlNodePtr ancestor,
const xmlChar * prefix)
xmlNsInScope(xmlDocPtr doc ATTRIBUTE_UNUSED, xmlNodePtr node,
xmlNodePtr ancestor, const xmlChar * prefix)
{
xmlNsPtr tst;