mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-28 00:21:53 +03:00
added a new API to split a QName without generating any memory allocation
* tree.c include/libxml/tree.h: added a new API to split a QName without generating any memory allocation * valid.c: fixed another problem with namespaces on element in mixed content case * python/tests/reader2.py: updated the testcase with Bjorn Reese fix to reader for unsignificant white space * parser.c HTMLparser.c: cleanup. Daniel
This commit is contained in:
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Sun Aug 3 21:02:30 EDT 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* tree.c include/libxml/tree.h: added a new API to split a
|
||||||
|
QName without generating any memory allocation
|
||||||
|
* valid.c: fixed another problem with namespaces on element
|
||||||
|
in mixed content case
|
||||||
|
* python/tests/reader2.py: updated the testcase with
|
||||||
|
Bjorn Reese fix to reader for unsignificant white space
|
||||||
|
* parser.c HTMLparser.c: cleanup.
|
||||||
|
|
||||||
Sun Aug 3 20:55:40 EDT 2003 Daniel Veillard <daniel@veillard.com>
|
Sun Aug 3 20:55:40 EDT 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* catalog.c: trying to fix #118754 of possible recursion in the
|
* catalog.c: trying to fix #118754 of possible recursion in the
|
||||||
|
@ -4331,7 +4331,7 @@ htmlCreateDocParserCtxt(xmlChar *cur, const char *encoding ATTRIBUTE_UNUSED) {
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
|
htmlParseLookupSequence(htmlParserCtxtPtr ctxt, xmlChar first,
|
||||||
xmlChar next, xmlChar third, int comment) {
|
xmlChar next, xmlChar third, int comment) {
|
||||||
int base, len;
|
int base, len;
|
||||||
htmlParserInputPtr in;
|
htmlParserInputPtr in;
|
||||||
const xmlChar *buf;
|
const xmlChar *buf;
|
||||||
|
@ -556,6 +556,9 @@ xmlChar * xmlBuildQName (const xmlChar *ncname,
|
|||||||
int len);
|
int len);
|
||||||
xmlChar * xmlSplitQName2 (const xmlChar *name,
|
xmlChar * xmlSplitQName2 (const xmlChar *name,
|
||||||
xmlChar **prefix);
|
xmlChar **prefix);
|
||||||
|
const xmlChar * xmlSplitQName3 (const xmlChar *name,
|
||||||
|
int *len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handling Buffers.
|
* Handling Buffers.
|
||||||
*/
|
*/
|
||||||
|
2
parser.c
2
parser.c
@ -1789,7 +1789,7 @@ xmlSplitQName(xmlParserCtxtPtr ctxt, const xmlChar *name, xmlChar **prefix) {
|
|||||||
c = *cur;
|
c = *cur;
|
||||||
*prefix = ret;
|
*prefix = ret;
|
||||||
if (c == 0) {
|
if (c == 0) {
|
||||||
return(xmlStrndup("", 0));
|
return(xmlStrndup(BAD_CAST "", 0));
|
||||||
}
|
}
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
|
@ -63,17 +63,17 @@ s = """
|
|||||||
"""
|
"""
|
||||||
expect="""10,test
|
expect="""10,test
|
||||||
1,test
|
1,test
|
||||||
3,#text
|
14,#text
|
||||||
1,x
|
1,x
|
||||||
1,c
|
1,c
|
||||||
3,#text
|
3,#text
|
||||||
15,c
|
15,c
|
||||||
15,x
|
15,x
|
||||||
3,#text
|
14,#text
|
||||||
1,b
|
1,b
|
||||||
3,#text
|
3,#text
|
||||||
15,b
|
15,b
|
||||||
3,#text
|
14,#text
|
||||||
15,test
|
15,test
|
||||||
"""
|
"""
|
||||||
res=""
|
res=""
|
||||||
@ -113,11 +113,11 @@ s = """<!DOCTYPE test [
|
|||||||
tst_ent = """<x>hello</x>"""
|
tst_ent = """<x>hello</x>"""
|
||||||
expect="""10 test
|
expect="""10 test
|
||||||
1 test
|
1 test
|
||||||
3 #text
|
14 #text
|
||||||
1 x
|
1 x
|
||||||
3 #text
|
3 #text
|
||||||
15 x
|
15 x
|
||||||
3 #text
|
14 #text
|
||||||
15 test
|
15 test
|
||||||
"""
|
"""
|
||||||
res=""
|
res=""
|
||||||
@ -165,19 +165,19 @@ s = """<!DOCTYPE test [
|
|||||||
</test>"""
|
</test>"""
|
||||||
expect="""10 test 0
|
expect="""10 test 0
|
||||||
1 test 0
|
1 test 0
|
||||||
3 #text 1
|
14 #text 1
|
||||||
1 x 1
|
1 x 1
|
||||||
1 y 2
|
1 y 2
|
||||||
3 #text 3
|
3 #text 3
|
||||||
15 y 2
|
15 y 2
|
||||||
15 x 1
|
15 x 1
|
||||||
3 #text 1
|
14 #text 1
|
||||||
1 x 1
|
1 x 1
|
||||||
1 y 2
|
1 y 2
|
||||||
3 #text 3
|
3 #text 3
|
||||||
15 y 2
|
15 y 2
|
||||||
15 x 1
|
15 x 1
|
||||||
3 #text 1
|
14 #text 1
|
||||||
15 test 0
|
15 test 0
|
||||||
"""
|
"""
|
||||||
res=""
|
res=""
|
||||||
@ -218,11 +218,11 @@ s = """<!DOCTYPE test [
|
|||||||
</test>"""
|
</test>"""
|
||||||
expect="""10 test 0
|
expect="""10 test 0
|
||||||
1 test 0
|
1 test 0
|
||||||
3 #text 1
|
14 #text 1
|
||||||
5 x 1
|
5 x 1
|
||||||
3 #text 1
|
14 #text 1
|
||||||
5 x 1
|
5 x 1
|
||||||
3 #text 1
|
14 #text 1
|
||||||
15 test 0
|
15 test 0
|
||||||
"""
|
"""
|
||||||
res=""
|
res=""
|
||||||
|
37
tree.c
37
tree.c
@ -236,6 +236,43 @@ xmlSplitQName2(const xmlChar *name, xmlChar **prefix) {
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlSplitQName3:
|
||||||
|
* @name: the full QName
|
||||||
|
* @len: an int *
|
||||||
|
*
|
||||||
|
* parse an XML qualified name string,i
|
||||||
|
*
|
||||||
|
* returns NULL if it is not a Qualified Name, otherwise, update len
|
||||||
|
* with the lenght in byte of the prefix and return a pointer
|
||||||
|
*/
|
||||||
|
|
||||||
|
const xmlChar *
|
||||||
|
xmlSplitQName3(const xmlChar *name, int *len) {
|
||||||
|
int l = 0;
|
||||||
|
|
||||||
|
if (name == NULL) return(NULL);
|
||||||
|
if (len == NULL) return(NULL);
|
||||||
|
|
||||||
|
/* nasty but valid */
|
||||||
|
if (name[0] == ':')
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* we are not trying to validate but just to cut, and yes it will
|
||||||
|
* work even if this is as set of UTF-8 encoded chars
|
||||||
|
*/
|
||||||
|
while ((name[l] != 0) && (name[l] != ':'))
|
||||||
|
l++;
|
||||||
|
|
||||||
|
if (name[l] == 0)
|
||||||
|
return(NULL);
|
||||||
|
|
||||||
|
*len = l;
|
||||||
|
|
||||||
|
return(&name[l+1]);
|
||||||
|
}
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* Check Name, NCName and QName strings *
|
* Check Name, NCName and QName strings *
|
||||||
|
65
valid.c
65
valid.c
@ -5059,24 +5059,55 @@ done:
|
|||||||
static int
|
static int
|
||||||
xmlValidateCheckMixed(xmlValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
|
xmlValidateCheckMixed(xmlValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
|
||||||
xmlElementContentPtr cont, const xmlChar *qname) {
|
xmlElementContentPtr cont, const xmlChar *qname) {
|
||||||
while (cont != NULL) {
|
const xmlChar *name;
|
||||||
if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) {
|
int plen;
|
||||||
if (xmlStrEqual(cont->name, qname))
|
name = xmlSplitQName3(qname, &plen);
|
||||||
return(1);
|
|
||||||
} else if ((cont->type == XML_ELEMENT_CONTENT_OR) &&
|
if (name == NULL) {
|
||||||
(cont->c1 != NULL) &&
|
while (cont != NULL) {
|
||||||
(cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){
|
if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) {
|
||||||
if (xmlStrEqual(cont->c1->name, qname))
|
if ((cont->prefix == NULL) && (xmlStrEqual(cont->name, qname)))
|
||||||
return(1);
|
return(1);
|
||||||
} else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
|
} else if ((cont->type == XML_ELEMENT_CONTENT_OR) &&
|
||||||
(cont->c1 == NULL) ||
|
(cont->c1 != NULL) &&
|
||||||
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){
|
(cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){
|
||||||
/* Internal error !!! */
|
if ((cont->c1->prefix == NULL) &&
|
||||||
xmlGenericError(xmlGenericErrorContext,
|
(xmlStrEqual(cont->c1->name, qname)))
|
||||||
"Internal: MIXED struct bad\n");
|
return(1);
|
||||||
break;
|
} else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
|
||||||
|
(cont->c1 == NULL) ||
|
||||||
|
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){
|
||||||
|
/* Internal error !!! */
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Internal: MIXED struct bad\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cont = cont->c2;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
while (cont != NULL) {
|
||||||
|
if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) {
|
||||||
|
if ((cont->prefix != NULL) &&
|
||||||
|
(xmlStrncmp(cont->prefix, qname, plen) == 0) &&
|
||||||
|
(xmlStrEqual(cont->name, name)))
|
||||||
|
return(1);
|
||||||
|
} else if ((cont->type == XML_ELEMENT_CONTENT_OR) &&
|
||||||
|
(cont->c1 != NULL) &&
|
||||||
|
(cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){
|
||||||
|
if ((cont->c1->prefix != NULL) &&
|
||||||
|
(xmlStrncmp(cont->c1->prefix, qname, plen) == 0) &&
|
||||||
|
(xmlStrEqual(cont->c1->name, name)))
|
||||||
|
return(1);
|
||||||
|
} else if ((cont->type != XML_ELEMENT_CONTENT_OR) ||
|
||||||
|
(cont->c1 == NULL) ||
|
||||||
|
(cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){
|
||||||
|
/* Internal error !!! */
|
||||||
|
xmlGenericError(xmlGenericErrorContext,
|
||||||
|
"Internal: MIXED struct bad\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
cont = cont->c2;
|
||||||
}
|
}
|
||||||
cont = cont->c2;
|
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user