- catalog.[ch]: fixes and add xmlLoadCatalogs()
- DOCBparser.c: small cleanup
- xmllint.c: added a --catalogs option to load catalogs from
$SGML_CATALOG_FILES
- tree.c: cleanup
- configure.in: iconv library fixup, ICONV_LIBS
Daniel
diff --git a/ChangeLog b/ChangeLog
index 127ca33..65f7117 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue May 22 17:00:36 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+ * catalog.[ch]: fixes and add xmlLoadCatalogs()
+ * DOCBparser.c: small cleanup
+ * xmllint.c: added a --catalogs option to load catalogs from
+ $SGML_CATALOG_FILES
+ * tree.c: cleanup
+ * configure.in: iconv library fixup, ICONV_LIBS
+
Mon May 21 16:05:22 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* catalog.c: handling of CATALOG entries. detection of recursion,
diff --git a/DOCBparser.c b/DOCBparser.c
index 779e7ab..fe498d1 100644
--- a/DOCBparser.c
+++ b/DOCBparser.c
@@ -3392,18 +3392,6 @@
*/
if (RAW != '[') {
return;
-
- /*
- * We should be at the end of the DOCTYPE declaration.
- */
- if (CUR != '>') {
- if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
- ctxt->sax->error(ctxt->userData,
- "DOCTYPE unproperly terminated\n");
- ctxt->wellFormed = 0;
- /* We shouldn't try to resynchronize ... */
- }
- NEXT;
}
/*
diff --git a/catalog.c b/catalog.c
index 7793d21..f4b6188 100644
--- a/catalog.c
+++ b/catalog.c
@@ -65,10 +65,9 @@
static xmlHashTablePtr xmlDefaultCatalog;
/* Catalog stack */
-const char * catalTab[10]; /* stack of catals */
-const char * catal; /* Current catal stream */
-int catalNr = 0; /* Number of current catal streams */
-int catalMax = 10; /* Max number of catal streams */
+static const char * catalTab[10]; /* stack of catals */
+static int catalNr = 0; /* Number of current catal streams */
+static int catalMax = 10; /* Max number of catal streams */
/************************************************************************
* *
@@ -478,8 +477,8 @@
* xmlLoadCatalog:
* @filename: a file path
*
- * Load the catalog and makes its definition effective for the default
- * external entity loader.
+ * Load the catalog and makes its definitions effective for the default
+ * external entity loader. It will recuse in CATALOG entries.
* TODO: this function is not thread safe, catalog initialization should
* be done once at startup
*
@@ -506,7 +505,8 @@
* Prevent loops
*/
for (i = 0;i < catalNr;i++) {
- if (xmlStrEqual(catalTab[i], filename)) {
+ if (xmlStrEqual((const xmlChar *)catalTab[i],
+ (const xmlChar *)filename)) {
xmlGenericError(xmlGenericErrorContext,
"xmlLoadCatalog: %s seems to induce a loop\n",
filename);
@@ -548,6 +548,39 @@
return(ret);
}
+/*
+ * xmlLoadCatalogs:
+ * @paths: a list of file path separated by ':' or spaces
+ *
+ * Load the catalogs and makes their definitions effective for the default
+ * external entity loader.
+ * TODO: this function is not thread safe, catalog initialization should
+ * be done once at startup
+ */
+void
+xmlLoadCatalogs(const char *pathss) {
+ const char *cur;
+ const char *paths;
+ xmlChar *path;
+
+ cur = pathss;
+ while ((cur != NULL) && (*cur != 0)) {
+ while (IS_BLANK(*cur)) cur++;
+ if (*cur != 0) {
+ paths = cur;
+ while ((*cur != 0) && (*cur != ':') && (!IS_BLANK(*cur)))
+ cur++;
+ path = xmlStrndup((const xmlChar *)paths, cur - paths);
+ if (path != NULL) {
+ xmlLoadCatalog((const char *) path);
+ xmlFree(path);
+ }
+ }
+ while (*cur == ':')
+ cur++;
+ }
+}
+
/**
* xmlCatalogCleanup:
*
diff --git a/catalog.h b/catalog.h
index eb77845..25ef5eb 100644
--- a/catalog.h
+++ b/catalog.h
@@ -22,6 +22,7 @@
#endif
int xmlLoadCatalog (const char *URL);
+void xmlLoadCatalogs (const char *paths);
void xmlCatalogCleanup (void);
void xmlCatalogDump (FILE *out);
const xmlChar * xmlCatalogGetSystem (const xmlChar *sysID);
diff --git a/configure.in b/configure.in
index a67bdc4..e1005a7 100644
--- a/configure.in
+++ b/configure.in
@@ -154,7 +154,6 @@
XML_LIBDIR='-L${libdir}'
XML_INCLUDEDIR='-I${includedir}/libxml -I${includedir}'
-XML_LIBS="-lxml2 $Z_LIBS -lm $LIBS"
dnl
dnl Extra flags
@@ -238,6 +237,7 @@
dnl
dnl specific tests to setup DV's devel environment with debug etc ...
+dnl (-Wunreachable-code)
dnl
if test "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/XML" ; then
if test "${with_mem_debug}" = "" ; then
@@ -376,7 +376,7 @@
else
AC_CHECK_HEADER(iconv.h,
AC_CHECK_FUNC(iconv, ,
- AC_CHECK_LIB(iconv, iconv, XML_LIBS="$XML_LIBS -liconv")))
+ AC_CHECK_LIB(iconv, iconv, ICONV_LIBS="-liconv")))
if test "$have_iconv" != "" ; then
echo Iconv support not found
WITH_ICONV=0
@@ -384,6 +384,7 @@
WITH_ICONV=1
fi
fi
+XML_LIBS="-lxml2 $Z_LIBS $ICONV_LIBS -lm $LIBS"
AC_SUBST(WITH_ICONV)
AC_ARG_WITH(debug, [ --with-debug Add the debugging module (on)])
@@ -412,6 +413,7 @@
AC_SUBST(XML_LIBDIR)
AC_SUBST(XML_LIBS)
+AC_SUBST(ICONV_LIBS)
AC_SUBST(XML_INCLUDEDIR)
AC_SUBST(HTML_DIR)
AC_SUBST(HAVE_ISNAN)
diff --git a/include/libxml/catalog.h b/include/libxml/catalog.h
index eb77845..25ef5eb 100644
--- a/include/libxml/catalog.h
+++ b/include/libxml/catalog.h
@@ -22,6 +22,7 @@
#endif
int xmlLoadCatalog (const char *URL);
+void xmlLoadCatalogs (const char *paths);
void xmlCatalogCleanup (void);
void xmlCatalogDump (FILE *out);
const xmlChar * xmlCatalogGetSystem (const xmlChar *sysID);
diff --git a/tree.c b/tree.c
index f30419b..f90c3d4 100644
--- a/tree.c
+++ b/tree.c
@@ -6271,10 +6271,10 @@
xmlSaveFileEnc(const char *filename, xmlDocPtr cur, const char *encoding) {
xmlOutputBufferPtr buf;
xmlCharEncodingHandlerPtr handler = NULL;
+ xmlCharEncoding enc;
int ret;
if (encoding != NULL) {
- xmlCharEncoding enc;
enc = xmlParseCharEncoding(encoding);
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
@@ -6284,9 +6284,8 @@
}
if (enc != XML_CHAR_ENCODING_UTF8) {
handler = xmlFindCharEncodingHandler(encoding);
- if (handler == NULL) {
+ if (handler == NULL)
return(-1);
- }
}
}
diff --git a/xmllint.c b/xmllint.c
index eaab6dd..41b9982 100644
--- a/xmllint.c
+++ b/xmllint.c
@@ -62,6 +62,9 @@
#ifdef LIBXML_XINCLUDE_ENABLED
#include <libxml/xinclude.h>
#endif
+#ifdef LIBXML_CATALOG_ENABLED
+#include <libxml/catalog.h>
+#endif
#ifdef LIBXML_DEBUG_ENABLED
static int debug = 0;
@@ -849,6 +852,19 @@
xmlParserDebugEntities = 1;
}
#endif
+#ifdef LIBXML_CATALOG_ENABLED
+ else if ((!strcmp(argv[i], "-catalogs")) ||
+ (!strcmp(argv[i], "--catalogs"))) {
+ const char *catalogs;
+
+ catalogs = getenv("SGML_CATALOG_FILES");
+ if (catalogs == NULL) {
+ fprintf(stderr, "Variable $SGML_CATALOG_FILES not set\n");
+ } else {
+ xmlLoadCatalogs(catalogs);
+ }
+ }
+#endif
else if ((!strcmp(argv[i], "-encode")) ||
(!strcmp(argv[i], "--encode"))) {
i++;
@@ -947,6 +963,9 @@
printf("\t--noblanks : drop (ignorable?) blanks spaces\n");
printf("\t--testIO : test user I/O support\n");
printf("\t--encode encoding : output in the given encoding\n");
+#ifdef LIBXML_CATALOG_ENABLED
+ printf("\t--catalogs : use the catalogs from $SGML_CATALOG_FILES\n");
+#endif
printf("\t--auto : generate a small doc on the fly\n");
#ifdef LIBXML_XINCLUDE_ENABLED
printf("\t--xinclude : do XInclude processing\n");
diff --git a/xpath.c b/xpath.c
index 3fc88aa..6667836 100644
--- a/xpath.c
+++ b/xpath.c
@@ -161,7 +161,7 @@
*/
double
xmlXPathDivideBy(double f, double fzero) {
- float ret;
+ double ret;
#ifdef HAVE_SIGNAL
#ifdef SIGFPE
#ifdef SIG_IGN
@@ -3079,7 +3079,6 @@
xmlXPathFreeObject(arg1);
xmlXPathFreeObject(arg2);
return(ret);
- return(0);
}
/**