Commit 7583a59b authored by Daniel Veillard's avatar Daniel Veillard

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
parent 449d7398
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>
* doc/libxml-doc.el: Felix Natter provided anew version working
......
......@@ -1593,6 +1593,10 @@ xmlSAXHandler xmlDefaultSAXHandler = {
void
xmlDefaultSAXHandlerInit(void)
{
static int xmlSAXInitialized = 0;
if (xmlSAXInitialized)
return;
xmlDefaultSAXHandler.internalSubset = internalSubset;
xmlDefaultSAXHandler.externalSubset = externalSubset;
xmlDefaultSAXHandler.isStandalone = isStandalone;
......@@ -1623,6 +1627,8 @@ xmlDefaultSAXHandlerInit(void)
xmlDefaultSAXHandler.warning = xmlParserWarning;
xmlDefaultSAXHandler.error = xmlParserError;
xmlDefaultSAXHandler.fatalError = xmlParserError;
xmlSAXInitialized = 1;
}
#ifdef LIBXML_HTML_ENABLED
......@@ -1667,6 +1673,10 @@ xmlSAXHandler htmlDefaultSAXHandler = {
void
htmlDefaultSAXHandlerInit(void)
{
static int htmlSAXInitialized = 0;
if (htmlSAXInitialized)
return;
htmlDefaultSAXHandler.internalSubset = internalSubset;
htmlDefaultSAXHandler.externalSubset = NULL;
htmlDefaultSAXHandler.isStandalone = NULL;
......@@ -1694,6 +1704,8 @@ htmlDefaultSAXHandlerInit(void)
htmlDefaultSAXHandler.warning = xmlParserWarning;
htmlDefaultSAXHandler.error = xmlParserError;
htmlDefaultSAXHandler.fatalError = xmlParserError;
htmlSAXInitialized = 1;
}
#endif /* LIBXML_HTML_ENABLED */
......@@ -1739,6 +1751,10 @@ xmlSAXHandler docbDefaultSAXHandler = {
void
docbDefaultSAXHandlerInit(void)
{
static int docbSAXInitialized = 0;
if (docbSAXInitialized)
return;
docbDefaultSAXHandler.internalSubset = internalSubset;
docbDefaultSAXHandler.externalSubset = NULL;
docbDefaultSAXHandler.isStandalone = isStandalone;
......@@ -1766,6 +1782,8 @@ docbDefaultSAXHandlerInit(void)
docbDefaultSAXHandler.warning = xmlParserWarning;
docbDefaultSAXHandler.error = xmlParserError;
docbDefaultSAXHandler.fatalError = xmlParserError;
docbSAXInitialized = 1;
}
#endif /* LIBXML_DOCB_ENABLED */
......@@ -620,31 +620,35 @@ esac
])
# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
# the libltdl convenience library, adds --enable-ltdl-convenience to
# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor
# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed
# to be `${top_builddir}/libltdl'. Make sure you start DIR with
# '${top_builddir}/' (note the single quotes!) if your package is not
# flat, and, if you're not using automake, define top_builddir as
# appropriate in the Makefiles.
# the libltdl convenience library and INCLTDL to the include flags for
# the libltdl header and adds --enable-ltdl-convenience to the
# configure arguments. Note that LIBLTDL and INCLTDL are not
# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called. If DIR is not
# provided, it is assumed to be `libltdl'. LIBLTDL will be prefixed
# with '${top_builddir}/' and INCLTDL will be prefixed 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.
AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
case "$enable_ltdl_convenience" in
no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
"") enable_ltdl_convenience=yes
ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
esac
LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la
INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
])
# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
# the libltdl installable library, and adds --enable-ltdl-install to
# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor
# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed
# to be `${top_builddir}/libltdl'. Make sure you start DIR with
# '${top_builddir}/' (note the single quotes!) if your package is not
# flat, and, if you're not using automake, define top_builddir as
# appropriate in the Makefiles.
# the libltdl installable library and INCLTDL to the include flags for
# the libltdl header and adds --enable-ltdl-install to the configure
# arguments. Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
# AC_CONFIG_SUBDIRS called. If DIR is not provided and an installed
# libltdl is not found, it is assumed to be `libltdl'. LIBLTDL will
# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
# 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.
AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
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
ac_configure_args="$ac_configure_args --enable-ltdl-install"
LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la
INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl'])
LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
else
ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
LIBLTDL="-lltdl"
......
......@@ -6428,6 +6428,8 @@ xmlParseCDSect(xmlParserCtxtPtr ctxt) {
if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) {
if (ctxt->sax->cdataBlock != NULL)
ctxt->sax->cdataBlock(ctxt->userData, buf, len);
else if (ctxt->sax->characters != NULL)
ctxt->sax->characters(ctxt->userData, buf, len);
}
xmlFree(buf);
}
......
......@@ -44,6 +44,7 @@ static int debug = 0;
static int valid = 0;
static int expr = 0;
static int tree = 0;
static int nocdata = 0;
static xmlDocPtr document = NULL;
/*
......@@ -157,20 +158,27 @@ int main(int argc, char **argv) {
if ((!strcmp(argv[i], "-xptr")) || (!strcmp(argv[i], "--xptr")))
xptr++;
#endif
if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
else if ((!strcmp(argv[i], "-debug")) || (!strcmp(argv[i], "--debug")))
debug++;
if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid")))
else if ((!strcmp(argv[i], "-valid")) || (!strcmp(argv[i], "--valid")))
valid++;
if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr")))
else if ((!strcmp(argv[i], "-expr")) || (!strcmp(argv[i], "--expr")))
expr++;
if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--tree")))
else if ((!strcmp(argv[i], "-tree")) || (!strcmp(argv[i], "--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];
if ((!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--file")))
else if ((!strcmp(argv[i], "-f")) || (!strcmp(argv[i], "--file")))
usefile++;
}
if (valid != 0) xmlDoValidityCheckingDefaultValue = 1;
if (nocdata != 0) {
xmlDefaultSAXHandlerInit();
xmlDefaultSAXHandler.cdataBlock = NULL;
}
if (document == NULL) {
if (filename == NULL)
document = xmlParseDoc(buffer);
......@@ -200,6 +208,7 @@ int main(int argc, char **argv) {
#endif
printf("\t--expr : debug XPath expressions only\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-i filename : read the document from filename\n");
printf("\t--file : or\n");
......
......@@ -7614,7 +7614,9 @@ xmlXPathNodeCollectAndTest(xmlXPathParserContextPtr ctxt,
(cur->type == XML_PI_NODE) ||
(cur->type == XML_COMMENT_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
n++;
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment