1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-25 23:21:26 +03:00

Dodji pointed out a bug in xmlGetNodePath() applied patch from Albert Chin

* tree.c: Dodji pointed out a bug in xmlGetNodePath()
* xmlcatalog.c: applied patch from Albert Chin to add a
  --no-super-update option to xmlcatalog see #145461
  and another patch also from Albert Chin to not crash
  on -sgml --del without args see #145462
* Makefile.am: applied another patch from Albert Chin to
  fix a problem with diff on Solaris #145511
* xmlstring.c: fix xmlCheckUTF8() according to the suggestion
  in bug #148115
* python/libxml.py: apply fix from Marc-Antoine Parent about
  the errors in libxml(2).py on the node wrapper #135547
Daniel
This commit is contained in:
Daniel Veillard 2004-08-14 21:46:31 +00:00
parent 7a2c2eedf4
commit 1f8658a76f
7 changed files with 293 additions and 261 deletions

View File

@ -1,3 +1,17 @@
Sat Aug 14 23:50:10 CEST 2004 Daniel Veillard <daniel@veillard.com>
* tree.c: Dodji pointed out a bug in xmlGetNodePath()
* xmlcatalog.c: applied patch from Albert Chin to add a
--no-super-update option to xmlcatalog see #145461
and another patch also from Albert Chin to not crash
on -sgml --del without args see #145462
* Makefile.am: applied another patch from Albert Chin to
fix a problem with diff on Solaris #145511
* xmlstring.c: fix xmlCheckUTF8() according to the suggestion
in bug #148115
* python/libxml.py: apply fix from Marc-Antoine Parent about
the errors in libxml(2).py on the node wrapper #135547
Sat Aug 14 13:18:57 CEST 2004 Daniel Veillard <daniel@veillard.com>
* Makefile.am: added a dumb rule to able to compile tst.c

View File

@ -470,7 +470,7 @@ XIncludetests : xmllint$(EXEEXT)
$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude $$i > $(srcdir)/result/XInclude/$$name 2> $(srcdir)/result/XInclude/$$name.err ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
else \
log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude $$i > result.$$name 2>error.$$name | grep -v 'failed to load external entity' ; \
log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude $$i > result.$$name 2>error.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/XInclude/$$name result.$$name ; \
diff $(srcdir)/result/XInclude/$$name.err error.$$name` ; \
@ -487,7 +487,7 @@ XIncludetests : xmllint$(EXEEXT)
$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i > $(srcdir)/result/XInclude/$$name.rdr ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
else \
log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i > result.$$name 2>error.$$name | grep -v 'failed to load external entity' ; \
log=`$(CHECKER) $(top_builddir)/xmllint --nowarning --xinclude --stream --debug $$i > result.$$name 2>error.$$name ; \
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
diff $(srcdir)/result/XInclude/$$name.err error.$$name ; \
diff $(srcdir)/result/XInclude/$$name.rdr result.$$name` ; \

View File

@ -488,19 +488,19 @@ class xmlCoreBreadthFirstItertor:
#
def nodeWrap(o):
# TODO try to cast to the most appropriate node class
name = libxml2mod.name(o)
name = libxml2mod.type(o)
if name == "element" or name == "text":
return xmlNode(_obj=o)
if name == "attribute":
return xmlAttr(_obj=o)
if name[0:8] == "document":
return xmlDoc(_obj=o)
if name[0:8] == "namespace":
if name == "namespace":
return xmlNs(_obj=o)
if name == "elem_decl":
return xmlElement(_obj=o)
if name == "attribute_decl":
return xmlAtribute(_obj=o)
return xmlAttribute(_obj=o)
if name == "entity_decl":
return xmlEntity(_obj=o)
if name == "dtd":

View File

@ -636,6 +636,56 @@ 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 catalog()
# functions from module catalog
add()
catalogIsEmpty()
convertSGMLCatalog()
dump()
remove()
resolve()
resolvePublic()
resolveSystem()
resolveURI()
Class xmlElement(xmlNode)
Class xmlAttr(xmlNode)
@ -654,12 +704,95 @@ Class xmlAttr(xmlNode)
# 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()
NewDoc()
NewFd()
NewFile()
NewMemory()
NewWalker()
Next()
NextSibling()
NodeType()
Normalization()
Prefix()
Preserve()
QuoteChar()
Read()
ReadAttributeValue()
ReadInnerXml()
ReadOuterXml()
ReadState()
ReadString()
RelaxNGSetSchema()
RelaxNGValidate()
SetParserProp()
String()
Value()
XmlLang()
Class xmlReg()
# functions from module xmlregexp
regexpExec()
regexpIsDeterminist()
regexpPrint()
Class xmlEntity(xmlNode)
# functions from module parserInternals
handleEntity()
Class relaxNgSchema()
# functions from module relaxng
relaxNGDump()
relaxNGDumpTree()
relaxNGNewValidCtxt()
# functions from module xmlreader
RelaxNGSetSchema()
Class Error()
# accessors
code()
domain()
file()
level()
line()
message()
# functions from module xmlerror
copyError()
resetError()
Class relaxNgValidCtxt()
# functions from module relaxng
@ -668,6 +801,73 @@ Class relaxNgValidCtxt()
relaxNGValidatePopElement()
relaxNGValidatePushCData()
relaxNGValidatePushElement()
Class xpathParserContext()
# accessors
context()
# functions from module xpathInternals
xpathAddValues()
xpathBooleanFunction()
xpathCeilingFunction()
xpathCompareValues()
xpathConcatFunction()
xpathContainsFunction()
xpathCountFunction()
xpathDivValues()
xpathEqualValues()
xpathErr()
xpathEvalExpr()
xpathFalseFunction()
xpathFloorFunction()
xpathFreeParserContext()
xpathIdFunction()
xpathLangFunction()
xpathLastFunction()
xpathLocalNameFunction()
xpathModValues()
xpathMultValues()
xpathNamespaceURIFunction()
xpathNextAncestor()
xpathNextAncestorOrSelf()
xpathNextAttribute()
xpathNextChild()
xpathNextDescendant()
xpathNextDescendantOrSelf()
xpathNextFollowing()
xpathNextFollowingSibling()
xpathNextNamespace()
xpathNextParent()
xpathNextPreceding()
xpathNextPrecedingSibling()
xpathNextSelf()
xpathNormalizeFunction()
xpathNotEqualValues()
xpathNotFunction()
xpathNumberFunction()
xpathParseNCName()
xpathParseName()
xpathPopBoolean()
xpathPopNumber()
xpathPopString()
xpathPositionFunction()
xpathRoot()
xpathRoundFunction()
xpathStartsWithFunction()
xpathStringFunction()
xpathStringLengthFunction()
xpathSubValues()
xpathSubstringAfterFunction()
xpathSubstringBeforeFunction()
xpathSubstringFunction()
xpathSumFunction()
xpathTranslateFunction()
xpathTrueFunction()
xpathValueFlipSign()
xpatherror()
# functions from module xpointer
xpointerEvalRangePredicate()
xpointerRangeToFunction()
Class parserCtxt(parserCtxtCore)
@ -775,90 +975,6 @@ Class xmlDtd(xmlNode)
dtdElementDesc()
dtdQAttrDesc()
dtdQElementDesc()
Class relaxNgParserCtxt()
# functions from module relaxng
relaxNGParse()
relaxParserSetFlag()
Class xpathParserContext()
# accessors
context()
# functions from module xpathInternals
xpathAddValues()
xpathBooleanFunction()
xpathCeilingFunction()
xpathCompareValues()
xpathConcatFunction()
xpathContainsFunction()
xpathCountFunction()
xpathDivValues()
xpathEqualValues()
xpathErr()
xpathEvalExpr()
xpathFalseFunction()
xpathFloorFunction()
xpathFreeParserContext()
xpathIdFunction()
xpathLangFunction()
xpathLastFunction()
xpathLocalNameFunction()
xpathModValues()
xpathMultValues()
xpathNamespaceURIFunction()
xpathNextAncestor()
xpathNextAncestorOrSelf()
xpathNextAttribute()
xpathNextChild()
xpathNextDescendant()
xpathNextDescendantOrSelf()
xpathNextFollowing()
xpathNextFollowingSibling()
xpathNextNamespace()
xpathNextParent()
xpathNextPreceding()
xpathNextPrecedingSibling()
xpathNextSelf()
xpathNormalizeFunction()
xpathNotEqualValues()
xpathNotFunction()
xpathNumberFunction()
xpathParseNCName()
xpathParseName()
xpathPopBoolean()
xpathPopNumber()
xpathPopString()
xpathPositionFunction()
xpathRoot()
xpathRoundFunction()
xpathStartsWithFunction()
xpathStringFunction()
xpathStringLengthFunction()
xpathSubValues()
xpathSubstringAfterFunction()
xpathSubstringBeforeFunction()
xpathSubstringFunction()
xpathSumFunction()
xpathTranslateFunction()
xpathTrueFunction()
xpathValueFlipSign()
xpatherror()
# functions from module xpointer
xpointerEvalRangePredicate()
xpointerRangeToFunction()
Class catalog()
# functions from module catalog
add()
catalogIsEmpty()
convertSGMLCatalog()
dump()
remove()
resolve()
resolvePublic()
resolveSystem()
resolveURI()
Class xmlNs(xmlNode)
@ -882,6 +998,40 @@ Class xmlNs(xmlNode)
# functions from module xpathInternals
xpathNodeSetFreeNs()
Class inputBuffer(ioReadWrapper)
# functions from module xmlIO
grow()
push()
read()
# functions from module xmlreader
newTextReader()
Class relaxNgParserCtxt()
# functions from module relaxng
relaxNGParse()
relaxParserSetFlag()
Class outputBuffer(ioWriteWrapper)
# functions from module HTMLtree
htmlDocContentDumpFormatOutput()
htmlDocContentDumpOutput()
htmlNodeDumpFormatOutput()
htmlNodeDumpOutput()
# functions from module tree
nodeDumpOutput()
saveFileTo()
saveFormatFileTo()
# functions from module xmlIO
write()
writeString()
Class xmlTextReaderLocator()
# functions from module xmlreader
@ -912,153 +1062,3 @@ Class URI()
parseURIReference()
printURI()
saveUri()
Class xmlAttribute(xmlNode)
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 xmlElement(xmlNode)
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()
NewDoc()
NewFd()
NewFile()
NewMemory()
NewWalker()
Next()
NextSibling()
NodeType()
Normalization()
Prefix()
Preserve()
QuoteChar()
Read()
ReadAttributeValue()
ReadInnerXml()
ReadOuterXml()
ReadState()
ReadString()
RelaxNGSetSchema()
RelaxNGValidate()
SetParserProp()
String()
Value()
XmlLang()
Class xmlEntity(xmlNode)
# functions from module parserInternals
handleEntity()
Class Error()
# accessors
code()
domain()
file()
level()
line()
message()
# functions from module xmlerror
copyError()
resetError()
Class relaxNgSchema()
# functions from module relaxng
relaxNGDump()
relaxNGDumpTree()
relaxNGNewValidCtxt()
# functions from module xmlreader
RelaxNGSetSchema()
Class inputBuffer(ioReadWrapper)
# functions from module xmlIO
grow()
push()
read()
# functions from module xmlreader
newTextReader()
Class outputBuffer(ioWriteWrapper)
# functions from module HTMLtree
htmlDocContentDumpFormatOutput()
htmlDocContentDumpOutput()
htmlNodeDumpFormatOutput()
htmlNodeDumpOutput()
# functions from module tree
nodeDumpOutput()
saveFileTo()
saveFormatFileTo()
# functions from module xmlIO
write()
writeString()

4
tree.c
View File

@ -4284,8 +4284,8 @@ xmlGetNodePath(xmlNodePtr node)
if (occur == 0) {
tmp = cur->next;
while (tmp != NULL && occur == 0) {
if ((cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE))
if ((tmp->type == XML_TEXT_NODE) ||
(tmp->type == XML_CDATA_SECTION_NODE))
occur++;
tmp = tmp->next;
}

View File

@ -37,6 +37,7 @@ static int create = 0;
static int add = 0;
static int del = 0;
static int convert = 0;
static int no_super_update = 0;
static int verbose = 0;
static char *filename = NULL;
@ -306,17 +307,20 @@ static void usershell(void) {
* *
************************************************************************/
static void usage(const char *name) {
printf("Usage : %s [options] catalogfile entities...\n", name);
printf("\tParse the catalog file and query it for the entities\n");
printf("\t--sgml : handle SGML Super catalogs for --add and --del\n");
printf("\t--shell : run a shell allowing interactive queries\n");
printf("\t--create : create a new catalog\n");
printf("\t--add 'type' 'orig' 'replace' : add an entry\n");
printf("\t--del 'values' : remove values\n");
printf("\t--noout: avoid dumping the result on stdout\n");
printf("\t used with add or del, it saves the catalog changes\n");
printf("\t and with --sgml it also updates the super catalog\n");
printf("\t-v --verbose : provide debug informations\n");
printf("\
Usage : %s [options] catalogfile entities...\n\
\tParse the catalog file and query it for the entities\n\
\t--sgml : handle SGML Super catalogs for --add and --del\n\
\t--shell : run a shell allowing interactive queries\n\
\t--create : create a new catalog\n\
\t--add 'type' 'orig' 'replace' : add an XML entry\n\
\t--add 'entry' : add an SGML entry\n\
\t--del 'values' : remove values\n\
\t--noout: avoid dumping the result on stdout\n\
\t used with --add or --del, it saves the catalog changes\n\
\t and with --sgml it automatically updates the super catalog\n\
\t--no-super-update: do not update the SGML super catalog\n\
\t-v --verbose : provide debug informations\n", name);
}
int main(int argc, char **argv) {
int i;
@ -357,6 +361,9 @@ int main(int argc, char **argv) {
} else if ((!strcmp(argv[i], "-convert")) ||
(!strcmp(argv[i], "--convert"))) {
convert++;
} else if ((!strcmp(argv[i], "-no-super-update")) ||
(!strcmp(argv[i], "--no-super-update"))) {
no_super_update++;
} else if ((!strcmp(argv[i], "-add")) ||
(!strcmp(argv[i], "--add"))) {
if (sgml)
@ -386,6 +393,14 @@ int main(int argc, char **argv) {
} else if ((!strcmp(argv[i], "-del")) ||
(!strcmp(argv[i], "--del"))) {
i += 1;
/* No catalog entry specified */
if (i == argc || (sgml && i + 1 == argc)) {
fprintf(stderr, "No catalog entry specified to remove from\n");
usage (argv[0]);
return(1);
}
continue;
} else if (argv[i][0] == '-')
continue;
@ -424,14 +439,17 @@ int main(int argc, char **argv) {
(!strcmp(argv[i], "--add"))) {
if (catal == NULL)
catal = xmlNewCatalog(1);
super = xmlLoadSGMLSuperCatalog(XML_SGML_DEFAULT_CATALOG);
if (super == NULL)
super = xmlNewCatalog(1);
xmlACatalogAdd(catal, BAD_CAST "CATALOG",
BAD_CAST argv[i + 2], NULL);
xmlACatalogAdd(super, BAD_CAST "CATALOG",
BAD_CAST argv[i + 1], NULL);
if (!no_super_update) {
super = xmlLoadSGMLSuperCatalog(XML_SGML_DEFAULT_CATALOG);
if (super == NULL)
super = xmlNewCatalog(1);
xmlACatalogAdd(super, BAD_CAST "CATALOG",
BAD_CAST argv[i + 1], NULL);
}
} else {
if (catal != NULL)
ret = xmlACatalogRemove(catal, BAD_CAST argv[i + 2]);
@ -442,7 +460,7 @@ int main(int argc, char **argv) {
argv[i + 1]);
exit_value = 1;
}
if ((noout) && (catal != NULL) &&
if ((!no_super_update) && (noout) && (catal != NULL) &&
(xmlCatalogIsEmpty(catal))) {
super = xmlLoadSGMLSuperCatalog(
XML_SGML_DEFAULT_CATALOG);
@ -475,7 +493,7 @@ int main(int argc, char **argv) {
fclose(out);
}
}
if (super != NULL) {
if (!no_super_update && super != NULL) {
if (xmlCatalogIsEmpty(super)) {
remove(XML_SGML_DEFAULT_CATALOG);
} else {

View File

@ -766,7 +766,7 @@ xmlCheckUTF8(const unsigned char *utf)
for (ix = 0; (c = utf[ix]);) {
if (c & 0x80) {
if ((utf[ix + 1] & 0xc0) != 0x80)
if ((c & 0xc0) != 0x80 || (utf[ix + 1] & 0xc0) != 0x80)
return(0);
if ((c & 0xe0) == 0xe0) {
if ((utf[ix + 2] & 0xc0) != 0x80)