1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

trying to fix #56948, this led to an XPath fix, improvements of SAX

* SAX.c parser.c testXPath.c xpath.c: trying to fix #56948, this
  led to an XPath fix, improvements of SAX initialization, and
  an added option --nocdata to testXPath
Daniel
This commit is contained in:
Daniel Veillard
2001-07-08 13:15:55 +00:00
parent 449d73988a
commit 7583a59b5a
6 changed files with 66 additions and 25 deletions

View File

@ -1,3 +1,9 @@
Sun Jul 8 15:11:05 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* SAX.c parser.c testXPath.c xpath.c: trying to fix #56948, this
led to an XPath fix, improvements of SAX initialization, and
an added option --nocdata to testXPath
Sat Jul 7 21:09:55 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr> Sat Jul 7 21:09:55 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* doc/libxml-doc.el: Felix Natter provided anew version working * doc/libxml-doc.el: Felix Natter provided anew version working

18
SAX.c
View File

@ -1593,6 +1593,10 @@ xmlSAXHandler xmlDefaultSAXHandler = {
void void
xmlDefaultSAXHandlerInit(void) xmlDefaultSAXHandlerInit(void)
{ {
static int xmlSAXInitialized = 0;
if (xmlSAXInitialized)
return;
xmlDefaultSAXHandler.internalSubset = internalSubset; xmlDefaultSAXHandler.internalSubset = internalSubset;
xmlDefaultSAXHandler.externalSubset = externalSubset; xmlDefaultSAXHandler.externalSubset = externalSubset;
xmlDefaultSAXHandler.isStandalone = isStandalone; xmlDefaultSAXHandler.isStandalone = isStandalone;
@ -1623,6 +1627,8 @@ xmlDefaultSAXHandlerInit(void)
xmlDefaultSAXHandler.warning = xmlParserWarning; xmlDefaultSAXHandler.warning = xmlParserWarning;
xmlDefaultSAXHandler.error = xmlParserError; xmlDefaultSAXHandler.error = xmlParserError;
xmlDefaultSAXHandler.fatalError = xmlParserError; xmlDefaultSAXHandler.fatalError = xmlParserError;
xmlSAXInitialized = 1;
} }
#ifdef LIBXML_HTML_ENABLED #ifdef LIBXML_HTML_ENABLED
@ -1667,6 +1673,10 @@ xmlSAXHandler htmlDefaultSAXHandler = {
void void
htmlDefaultSAXHandlerInit(void) htmlDefaultSAXHandlerInit(void)
{ {
static int htmlSAXInitialized = 0;
if (htmlSAXInitialized)
return;
htmlDefaultSAXHandler.internalSubset = internalSubset; htmlDefaultSAXHandler.internalSubset = internalSubset;
htmlDefaultSAXHandler.externalSubset = NULL; htmlDefaultSAXHandler.externalSubset = NULL;
htmlDefaultSAXHandler.isStandalone = NULL; htmlDefaultSAXHandler.isStandalone = NULL;
@ -1694,6 +1704,8 @@ htmlDefaultSAXHandlerInit(void)
htmlDefaultSAXHandler.warning = xmlParserWarning; htmlDefaultSAXHandler.warning = xmlParserWarning;
htmlDefaultSAXHandler.error = xmlParserError; htmlDefaultSAXHandler.error = xmlParserError;
htmlDefaultSAXHandler.fatalError = xmlParserError; htmlDefaultSAXHandler.fatalError = xmlParserError;
htmlSAXInitialized = 1;
} }
#endif /* LIBXML_HTML_ENABLED */ #endif /* LIBXML_HTML_ENABLED */
@ -1739,6 +1751,10 @@ xmlSAXHandler docbDefaultSAXHandler = {
void void
docbDefaultSAXHandlerInit(void) docbDefaultSAXHandlerInit(void)
{ {
static int docbSAXInitialized = 0;
if (docbSAXInitialized)
return;
docbDefaultSAXHandler.internalSubset = internalSubset; docbDefaultSAXHandler.internalSubset = internalSubset;
docbDefaultSAXHandler.externalSubset = NULL; docbDefaultSAXHandler.externalSubset = NULL;
docbDefaultSAXHandler.isStandalone = isStandalone; docbDefaultSAXHandler.isStandalone = isStandalone;
@ -1766,6 +1782,8 @@ docbDefaultSAXHandlerInit(void)
docbDefaultSAXHandler.warning = xmlParserWarning; docbDefaultSAXHandler.warning = xmlParserWarning;
docbDefaultSAXHandler.error = xmlParserError; docbDefaultSAXHandler.error = xmlParserError;
docbDefaultSAXHandler.fatalError = xmlParserError; docbDefaultSAXHandler.fatalError = xmlParserError;
docbSAXInitialized = 1;
} }
#endif /* LIBXML_DOCB_ENABLED */ #endif /* LIBXML_DOCB_ENABLED */

40
aclocal.m4 vendored
View File

@ -620,31 +620,35 @@ esac
]) ])
# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for # AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
# the libltdl convenience library, adds --enable-ltdl-convenience to # the libltdl convenience library and INCLTDL to the include flags for
# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor # the libltdl header and adds --enable-ltdl-convenience to the
# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed # configure arguments. Note that LIBLTDL and INCLTDL are not
# to be `${top_builddir}/libltdl'. Make sure you start DIR with # AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not
# '${top_builddir}/' (note the single quotes!) if your package is not # provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed
# flat, and, if you're not using automake, define top_builddir as # with '${top_builddir}/' and INCLTDL will be prefixed with
# appropriate in the Makefiles. # '${top_srcdir}/' (note the single quotes!). If your package is not
# flat and you're not using automake, define top_builddir and
# top_srcdir appropriately in the Makefiles.
AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
case "$enable_ltdl_convenience" in case "$enable_ltdl_convenience" in
no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
"") enable_ltdl_convenience=yes "") enable_ltdl_convenience=yes
ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
esac esac
LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
]) ])
# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for # AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
# the libltdl installable library, and adds --enable-ltdl-install to # the libltdl installable library and INCLTDL to the include flags for
# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor # the libltdl header and adds --enable-ltdl-install to the configure
# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed # arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
# to be `${top_builddir}/libltdl'. Make sure you start DIR with # AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed
# '${top_builddir}/' (note the single quotes!) if your package is not # libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will
# flat, and, if you're not using automake, define top_builddir as # be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
# appropriate in the Makefiles. # with '${top_srcdir}/' (note the single quotes!). If your package is
# not flat and you're not using automake, define top_builddir and
# top_srcdir appropriately in the Makefiles.
# In the future, this macro may have to be called after AC_PROG_LIBTOOL. # In the future, this macro may have to be called after AC_PROG_LIBTOOL.
AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
AC_CHECK_LIB(ltdl, main, AC_CHECK_LIB(ltdl, main,
@ -657,8 +661,8 @@ AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
]) ])
if test x"$enable_ltdl_install" = x"yes"; then if test x"$enable_ltdl_install" = x"yes"; then
ac_configure_args="$ac_configure_args --enable-ltdl-install" ac_configure_args="$ac_configure_args --enable-ltdl-install"
LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
else else
ac_configure_args="$ac_configure_args --enable-ltdl-install=no" ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
LIBLTDL="-lltdl" LIBLTDL="-lltdl"

View File

@ -6428,6 +6428,8 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) { if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
if (ctxt->sax->cdataBlock != NULL) if (ctxt->sax->cdataBlock != NULL)
ctxt->sax->cdataBlock(ctxt->userData, buf, len); ctxt->sax->cdataBlock(ctxt->userData, buf, len);
else if (ctxt->sax->characters != NULL)
ctxt->sax->characters(ctxt->userData, buf, len);
} }
xmlFree(buf); xmlFree(buf);
} }

View File

@ -44,6 +44,7 @@ static int debug = 0;
static int valid = 0; static int valid = 0;
static int expr = 0; static int expr = 0;
static int tree = 0; static int tree = 0;
static int nocdata = 0;
static xmlDocPtr document = NULL; static xmlDocPtr document = NULL;
/* /*
@ -157,20 +158,27 @@ int main(int argc, char **argv) {
if ((!strcmp(argv[i], "-xptr")) || (!strcmp(argv[i], "--xptr"))) if ((!strcmp(argv[i], "-xptr")) || (!strcmp(argv[i], "--xptr")))
xptr++; xptr++;
#endif #endif
if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug"))) else if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
debug++; debug++;
if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid"))) else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid")))
valid++; valid++;
if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr"))) else if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr")))
expr++; expr++;
if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--tree"))) else if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--tree")))
tree++; tree++;
if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input"))) else if ((!strcmp(argv[i], "-nocdata")) ||
(!strcmp(argv[i], "--nocdata")))
nocdata++;
else if ((!strcmp(argv[i], "-i")) || (!strcmp(argv[i], "--input")))
filename = argv[++i]; filename = argv[++i];
if ((!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--file"))) else if ((!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--file")))
usefile++; usefile++;
} }
if (valid != 0) xmlDoValidityCheckingDefaultValue = 1; if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
if (nocdata != 0) {
xmlDefaultSAXHandlerInit();
xmlDefaultSAXHandler.cdataBlock = NULL;
}
if (document == NULL) { if (document == NULL) {
if (filename == NULL) if (filename == NULL)
document = xmlParseDoc(buffer); document = xmlParseDoc(buffer);
@ -200,6 +208,7 @@ int main(int argc, char **argv) {
#endif #endif
printf("\t--expr : debug XPath expressions only\n"); printf("\t--expr : debug XPath expressions only\n");
printf("\t--tree : show the compiled XPath tree\n"); printf("\t--tree : show the compiled XPath tree\n");
printf("\t--nocdata : do not generate CDATA nodes\n");
printf("\t--input filename : or\n"); printf("\t--input filename : or\n");
printf("\t-i filename : read the document from filename\n"); printf("\t-i filename : read the document from filename\n");
printf("\t--file : or\n"); printf("\t--file : or\n");

View File

@ -7614,7 +7614,9 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
(cur->type == XML_PI_NODE) || (cur->type == XML_PI_NODE) ||
(cur->type == XML_COMMENT_NODE) || (cur->type == XML_COMMENT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE) || (cur->type == XML_CDATA_SECTION_NODE) ||
(cur->type == XML_TEXT_NODE)))) { (cur->type == XML_TEXT_NODE))) ||
((type == NODE_TYPE_TEXT) &&
(cur->type == XML_CDATA_SECTION_NODE))) {
#ifdef DEBUG_STEP #ifdef DEBUG_STEP
n++; n++;
#endif #endif