mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-14 20:01:04 +03:00
Old but effective optimization patch:
- parser.c parserInternals.c: applied Bjorn Reese optimization patch Daniel
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
Sat Jan 6 22:05:09 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
|
* parser.c parserInternals.c: applied Bjorn Reese optimization
|
||||||
|
patch
|
||||||
|
|
||||||
|
Sat Jan 6 19:13:27 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
|
* Makefile.am: applied patch fro make check from Martin Vidner
|
||||||
|
|
||||||
Thu Jan 4 19:07:49 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
Thu Jan 4 19:07:49 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
|
||||||
|
|
||||||
* configure.in: preparing 2.2.11
|
* configure.in: preparing 2.2.11
|
||||||
|
22
Makefile.am
22
Makefile.am
@ -95,14 +95,14 @@ HTMLtests : testHTML
|
|||||||
if [ ! -d $$i ] ; then \
|
if [ ! -d $$i ] ; then \
|
||||||
if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
|
if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
|
||||||
echo New test file $$name ; \
|
echo New test file $$name ; \
|
||||||
testHTML $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \
|
$(top_builddir)/testHTML $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \
|
||||||
else \
|
else \
|
||||||
echo Testing $$name ; \
|
echo Testing $$name ; \
|
||||||
testHTML $$i > result.$$name 2> error.$$name ; \
|
$(top_builddir)/testHTML $$i > result.$$name 2> error.$$name ; \
|
||||||
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
||||||
diff $(srcdir)/result/HTML/$$name result.$$name ; \
|
diff $(srcdir)/result/HTML/$$name result.$$name ; \
|
||||||
diff -b $(srcdir)/result/HTML/$$name.err error.$$name ; \
|
diff -b $(srcdir)/result/HTML/$$name.err error.$$name ; \
|
||||||
testHTML result.$$name > result2.$$name 2>error.$$name ; \
|
$(top_builddir)/testHTML result.$$name > result2.$$name 2>error.$$name ; \
|
||||||
diff result.$$name result2.$$name ; \
|
diff result.$$name result2.$$name ; \
|
||||||
rm result.$$name result2.$$name error.$$name ; \
|
rm result.$$name result2.$$name error.$$name ; \
|
||||||
fi ; fi ; done)
|
fi ; fi ; done)
|
||||||
@ -114,16 +114,16 @@ HTMLtests : testHTML
|
|||||||
if [ ! -d $$i ] ; then \
|
if [ ! -d $$i ] ; then \
|
||||||
if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
|
if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
|
||||||
echo New test file $$name ; \
|
echo New test file $$name ; \
|
||||||
testHTML $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \
|
$(top_builddir)/testHTML $$i > $(srcdir)/result/HTML/$$name 2>$(srcdir)/result/HTML/$$name.err ; \
|
||||||
else \
|
else \
|
||||||
echo Testing $$name ; \
|
echo Testing $$name ; \
|
||||||
testHTML --push $$i > result.$$name 2> error.$$name ; \
|
$(top_builddir)/testHTML --push $$i > result.$$name 2> error.$$name ; \
|
||||||
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
||||||
diff $(srcdir)/result/HTML/$$name result.$$name ; \
|
diff $(srcdir)/result/HTML/$$name result.$$name ; \
|
||||||
cut -b 1-15 $(srcdir)/result/HTML/$$name.err > errorcut.$$name; \
|
cut -b 1-15 $(srcdir)/result/HTML/$$name.err > errorcut.$$name; \
|
||||||
cut -b 1-15 error.$$name > errorcut2.$$name; \
|
cut -b 1-15 error.$$name > errorcut2.$$name; \
|
||||||
diff -b errorcut.$$name errorcut2.$$name ; \
|
diff -b errorcut.$$name errorcut2.$$name ; \
|
||||||
testHTML --push result.$$name > result2.$$name 2>error.$$name ; \
|
$(top_builddir)/testHTML --push result.$$name > result2.$$name 2>error.$$name ; \
|
||||||
diff result.$$name result2.$$name ; \
|
diff result.$$name result2.$$name ; \
|
||||||
rm result.$$name result2.$$name error.$$name errorcut.$$name errorcut2.$$name ; \
|
rm result.$$name result2.$$name error.$$name errorcut.$$name errorcut2.$$name ; \
|
||||||
fi ; fi ; done)
|
fi ; fi ; done)
|
||||||
@ -135,10 +135,10 @@ HTMLtests : testHTML
|
|||||||
if [ ! -d $$i ] ; then \
|
if [ ! -d $$i ] ; then \
|
||||||
if [ ! -f $(srcdir)/result/HTML/$$name.sax ] ; then \
|
if [ ! -f $(srcdir)/result/HTML/$$name.sax ] ; then \
|
||||||
echo New test file $$name ; \
|
echo New test file $$name ; \
|
||||||
testHTML --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \
|
$(top_builddir)/testHTML --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \
|
||||||
else \
|
else \
|
||||||
echo Testing $$name ; \
|
echo Testing $$name ; \
|
||||||
testHTML --sax $$i > result.$$name.sax ; \
|
$(top_builddir)/testHTML --sax $$i > result.$$name.sax ; \
|
||||||
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
||||||
diff $(srcdir)/result/HTML/$$name.sax result.$$name.sax ; \
|
diff $(srcdir)/result/HTML/$$name.sax result.$$name.sax ; \
|
||||||
rm result.$$name.sax ; \
|
rm result.$$name.sax ; \
|
||||||
@ -151,10 +151,10 @@ HTMLtests : testHTML
|
|||||||
if [ ! -d $$i ] ; then \
|
if [ ! -d $$i ] ; then \
|
||||||
if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
|
if [ ! -f $(srcdir)/result/HTML/$$name ] ; then \
|
||||||
echo New test file $$name ; \
|
echo New test file $$name ; \
|
||||||
testHTML --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \
|
$(top_builddir)/testHTML --sax $$i > $(srcdir)/result/HTML/$$name.sax ; \
|
||||||
else \
|
else \
|
||||||
echo Testing $$name ; \
|
echo Testing $$name ; \
|
||||||
testHTML --push --sax $$i > result.$$name.sax ; \
|
$(top_builddir)/testHTML --push --sax $$i > result.$$name.sax ; \
|
||||||
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
grep "MORY ALLO" .memdump | grep -v "MEMORY ALLOCATED : 0";\
|
||||||
diff $(srcdir)/result/HTML/$$name.sax result.$$name.sax ; \
|
diff $(srcdir)/result/HTML/$$name.sax result.$$name.sax ; \
|
||||||
rm result.$$name.sax ; \
|
rm result.$$name.sax ; \
|
||||||
@ -162,6 +162,7 @@ HTMLtests : testHTML
|
|||||||
|
|
||||||
|
|
||||||
XMLtests : xmllint
|
XMLtests : xmllint
|
||||||
|
@(rm -f .memdump ; touch .memdump)
|
||||||
@echo "##"
|
@echo "##"
|
||||||
@echo "## XML regression tests"
|
@echo "## XML regression tests"
|
||||||
@echo "##"
|
@echo "##"
|
||||||
@ -199,6 +200,7 @@ XMLtests : xmllint
|
|||||||
fi ; fi ; done)
|
fi ; fi ; done)
|
||||||
|
|
||||||
XMLenttests : xmllint
|
XMLenttests : xmllint
|
||||||
|
@(rm -f .memdump ; touch .memdump)
|
||||||
@echo "##"
|
@echo "##"
|
||||||
@echo "## XML entity subst regression tests"
|
@echo "## XML entity subst regression tests"
|
||||||
@echo "##"
|
@echo "##"
|
||||||
|
124
parser.c
124
parser.c
@ -2092,75 +2092,77 @@ xmlParseAttValue(xmlParserCtxtPtr ctxt) {
|
|||||||
buf[len++] = *current++;
|
buf[len++] = *current++;
|
||||||
}
|
}
|
||||||
ctxt->token = 0;
|
ctxt->token = 0;
|
||||||
} else if ((c == '&') && (NXT(1) == '#')) {
|
|
||||||
int val = xmlParseCharRef(ctxt);
|
|
||||||
if (val == '&') {
|
|
||||||
/*
|
|
||||||
* The reparsing will be done in xmlStringGetNodeList()
|
|
||||||
* called by the attribute() function in SAX.c
|
|
||||||
*/
|
|
||||||
static xmlChar buffer[6] = "&";
|
|
||||||
|
|
||||||
if (len > buf_size - 10) {
|
|
||||||
growBuffer(buf);
|
|
||||||
}
|
|
||||||
current = &buffer[0];
|
|
||||||
while (*current != 0) { /* non input consuming */
|
|
||||||
buf[len++] = *current++;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
len += xmlCopyChar(0, &buf[len], val);
|
|
||||||
}
|
|
||||||
} else if (c == '&') {
|
} else if (c == '&') {
|
||||||
ent = xmlParseEntityRef(ctxt);
|
if (NXT(1) == '#') {
|
||||||
if ((ent != NULL) &&
|
int val = xmlParseCharRef(ctxt);
|
||||||
(ctxt->replaceEntities != 0)) {
|
if (val == '&') {
|
||||||
xmlChar *rep;
|
/*
|
||||||
|
* The reparsing will be done in xmlStringGetNodeList()
|
||||||
|
* called by the attribute() function in SAX.c
|
||||||
|
*/
|
||||||
|
static xmlChar buffer[6] = "&";
|
||||||
|
|
||||||
if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {
|
if (len > buf_size - 10) {
|
||||||
rep = xmlStringDecodeEntities(ctxt, ent->content,
|
growBuffer(buf);
|
||||||
XML_SUBSTITUTE_REF, 0, 0, 0);
|
}
|
||||||
if (rep != NULL) {
|
current = &buffer[0];
|
||||||
current = rep;
|
while (*current != 0) { /* non input consuming */
|
||||||
while (*current != 0) { /* non input consuming */
|
buf[len++] = *current++;
|
||||||
buf[len++] = *current++;
|
|
||||||
if (len > buf_size - 10) {
|
|
||||||
growBuffer(buf);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xmlFree(rep);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (ent->content != NULL)
|
len += xmlCopyChar(0, &buf[len], val);
|
||||||
buf[len++] = ent->content[0];
|
|
||||||
}
|
}
|
||||||
} else if (ent != NULL) {
|
} else {
|
||||||
int i = xmlStrlen(ent->name);
|
ent = xmlParseEntityRef(ctxt);
|
||||||
const xmlChar *cur = ent->name;
|
if ((ent != NULL) &&
|
||||||
|
(ctxt->replaceEntities != 0)) {
|
||||||
/*
|
|
||||||
* This may look absurd but is needed to detect
|
|
||||||
* entities problems
|
|
||||||
*/
|
|
||||||
if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
|
|
||||||
(ent->content != NULL)) {
|
|
||||||
xmlChar *rep;
|
xmlChar *rep;
|
||||||
rep = xmlStringDecodeEntities(ctxt, ent->content,
|
|
||||||
XML_SUBSTITUTE_REF, 0, 0, 0);
|
|
||||||
if (rep != NULL)
|
|
||||||
xmlFree(rep);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
if (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) {
|
||||||
* Just output the reference
|
rep = xmlStringDecodeEntities(ctxt, ent->content,
|
||||||
*/
|
XML_SUBSTITUTE_REF, 0, 0, 0);
|
||||||
buf[len++] = '&';
|
if (rep != NULL) {
|
||||||
if (len > buf_size - i - 10) {
|
current = rep;
|
||||||
growBuffer(buf);
|
while (*current != 0) { /* non input consuming */
|
||||||
|
buf[len++] = *current++;
|
||||||
|
if (len > buf_size - 10) {
|
||||||
|
growBuffer(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xmlFree(rep);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ent->content != NULL)
|
||||||
|
buf[len++] = ent->content[0];
|
||||||
|
}
|
||||||
|
} else if (ent != NULL) {
|
||||||
|
int i = xmlStrlen(ent->name);
|
||||||
|
const xmlChar *cur = ent->name;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This may look absurd but is needed to detect
|
||||||
|
* entities problems
|
||||||
|
*/
|
||||||
|
if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
|
||||||
|
(ent->content != NULL)) {
|
||||||
|
xmlChar *rep;
|
||||||
|
rep = xmlStringDecodeEntities(ctxt, ent->content,
|
||||||
|
XML_SUBSTITUTE_REF, 0, 0, 0);
|
||||||
|
if (rep != NULL)
|
||||||
|
xmlFree(rep);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Just output the reference
|
||||||
|
*/
|
||||||
|
buf[len++] = '&';
|
||||||
|
if (len > buf_size - i - 10) {
|
||||||
|
growBuffer(buf);
|
||||||
|
}
|
||||||
|
for (;i > 0;i--)
|
||||||
|
buf[len++] = *cur++;
|
||||||
|
buf[len++] = ';';
|
||||||
}
|
}
|
||||||
for (;i > 0;i--)
|
|
||||||
buf[len++] = *cur++;
|
|
||||||
buf[len++] = ';';
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((c == 0x20) || (c == 0xD) || (c == 0xA) || (c == 0x9)) {
|
if ((c == 0x20) || (c == 0xD) || (c == 0xA) || (c == 0x9)) {
|
||||||
|
@ -428,15 +428,30 @@ xmlIsBlank(int c) {
|
|||||||
*
|
*
|
||||||
* Returns 0 if not, non-zero otherwise
|
* Returns 0 if not, non-zero otherwise
|
||||||
*/
|
*/
|
||||||
|
static int xmlBaseArray[] = {
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0000 - 0x000F */
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0010 - 0x001F */
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0020 - 0x002F */
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0030 - 0x003F */
|
||||||
|
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x0040 - 0x004F */
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 0x0050 - 0x005F */
|
||||||
|
0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x0060 - 0x006F */
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, /* 0x0070 - 0x007F */
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0080 - 0x008F */
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x0090 - 0x009F */
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00A0 - 0x00AF */
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00B0 - 0x00BF */
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00C0 - 0x00CF */
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00D0 - 0x00DF */
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00E0 - 0x00EF */
|
||||||
|
1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x00F0 - 0x00FF */
|
||||||
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
xmlIsBaseChar(int c) {
|
xmlIsBaseChar(int c) {
|
||||||
return(
|
return(
|
||||||
(((c) >= 0x0041) && ((c) <= 0x005A)) ||
|
(((c) < 0x0100) ? xmlBaseArray[c] :
|
||||||
(((c) >= 0x0061) && ((c) <= 0x007A)) ||
|
( /* accelerator */
|
||||||
(((c) >= 0x00C0) && ((c) <= 0x00D6)) ||
|
|
||||||
(((c) >= 0x00D8) && ((c) <= 0x00F6)) ||
|
|
||||||
(((c) >= 0x00F8) && ((c) <= 0x00FF)) ||
|
|
||||||
(((c) >= 0x100) && ( /* accelerator */
|
|
||||||
(((c) >= 0x0100) && ((c) <= 0x0131)) ||
|
(((c) >= 0x0100) && ((c) <= 0x0131)) ||
|
||||||
(((c) >= 0x0134) && ((c) <= 0x013E)) ||
|
(((c) >= 0x0134) && ((c) <= 0x013E)) ||
|
||||||
(((c) >= 0x0141) && ((c) <= 0x0148)) ||
|
(((c) >= 0x0141) && ((c) <= 0x0148)) ||
|
||||||
@ -794,13 +809,16 @@ xmlIsCombining(int c) {
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xmlIsExtender(int c) {
|
xmlIsExtender(int c) {
|
||||||
return(
|
switch (c) {
|
||||||
((c) == 0xb7) || ((c) == 0x2d0) || ((c) == 0x2d1) ||
|
case 0x00B7: case 0x02D0: case 0x02D1: case 0x0387:
|
||||||
((c) == 0x387) || ((c) == 0x640) || ((c) == 0xe46) ||
|
case 0x0640: case 0x0E46: case 0x0EC6: case 0x3005:
|
||||||
((c) == 0xec6) || ((c) == 0x3005) ||
|
case 0x3031: case 0x3032: case 0x3033: case 0x3034:
|
||||||
(((c) >= 0x3031) && ((c) <= 0x3035)) ||
|
case 0x3035: case 0x309D: case 0x309E: case 0x30FC:
|
||||||
(((c) >= 0x309b) && ((c) <= 0x309e)) ||
|
case 0x30FE:
|
||||||
(((c) >= 0x30fc) && ((c) <= 0x30fe)));
|
return 1;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -814,7 +832,7 @@ xmlIsExtender(int c) {
|
|||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
xmlIsIdeographic(int c) {
|
xmlIsIdeographic(int c) {
|
||||||
return(
|
return(((c) < 0x0100) ? 0 :
|
||||||
(((c) >= 0x4e00) && ((c) <= 0x9fa5)) ||
|
(((c) >= 0x4e00) && ((c) <= 0x9fa5)) ||
|
||||||
(((c) >= 0xf900) && ((c) <= 0xfa2d)) ||
|
(((c) >= 0xf900) && ((c) <= 0xfa2d)) ||
|
||||||
(((c) >= 0x3021) && ((c) <= 0x3029)) ||
|
(((c) >= 0x3021) && ((c) <= 0x3029)) ||
|
||||||
|
Reference in New Issue
Block a user