summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2005-01-15 12:56:23 +0000
committerDaniel Veillard <veillard@src.gnome.org>2005-01-15 12:56:23 +0000
commit49d30890fb4b67aee70ac8bd536bb3730c9d88d1 (patch)
treed0780a931efb83567a8c12eeef335156662575b6
parentb362c7510842db6b893d8a8d6e6f0b84c82fb5c8 (diff)
downloadlibxslt-49d30890fb4b67aee70ac8bd536bb3730c9d88d1.tar.gz
libxslt-49d30890fb4b67aee70ac8bd536bb3730c9d88d1.tar.bz2
libxslt-49d30890fb4b67aee70ac8bd536bb3730c9d88d1.zip
Applied another patch from Joel Reed, fixed a segfault and changed the
* tests/plugins/plugin.* tests/Makefile.am libxslt/extensions.c libxslt/Makefile.am configure.in: Applied another patch from Joel Reed, fixed a segfault and changed the configure code a bit to work in my debug environment. Daniel
-rw-r--r--ChangeLog7
-rw-r--r--configure.in8
-rw-r--r--libxslt/Makefile.am16
-rw-r--r--libxslt/extensions.c89
-rw-r--r--libxslt/xsltwin32config.h2
-rw-r--r--tests/Makefile.am13
-rw-r--r--tests/plugins/plugin.out3
-rw-r--r--tests/plugins/plugin.xml1
-rw-r--r--tests/plugins/plugin.xsl12
9 files changed, 125 insertions, 26 deletions
diff --git a/ChangeLog b/ChangeLog
index e40a500e..7ddae87c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Sat Jan 15 13:54:28 CET 2005 Daniel Veillard <daniel@veillard.com>
+
+ * tests/plugins/plugin.* tests/Makefile.am libxslt/extensions.c
+ libxslt/Makefile.am configure.in: Applied another patch from
+ Joel Reed, fixed a segfault and changed the configure code
+ a bit to work in my debug environment.
+
Tue Jan 11 10:50:33 HKT 2005 William Brack <wbrack@mmm.com.hk>
* configure.in: added python2.4 to the list of accepted
diff --git a/configure.in b/configure.in
index a2183e30..33e36e2a 100644
--- a/configure.in
+++ b/configure.in
@@ -22,6 +22,7 @@ LIBXSLT_VERSION=$LIBXSLT_MAJOR_VERSION.$LIBXSLT_MINOR_VERSION.$LIBXSLT_MICRO_VER
LIBXSLT_VERSION_INFO=`expr $LIBXSLT_MAJOR_VERSION + $LIBXSLT_MINOR_VERSION`:$LIBXSLT_MICRO_VERSION:$LIBXSLT_MINOR_VERSION
LIBXSLT_VERSION_NUMBER=`expr $LIBXSLT_MAJOR_VERSION \* 10000 + $LIBXSLT_MINOR_VERSION \* 100 + $LIBXSLT_MICRO_VERSION`
+LIBXSLT_MAJOR_MINOR_VERSION=$LIBXSLT_MAJOR_VERSION.$LIBXSLT_MINOR_VERSION
if test -f CVS/Entries; then
extra=`grep ChangeLog CVS/Entries | grep -v LIBXSLT | sed -e s\%/ChangeLog/1\.%% -e s\%/.*$%%`
@@ -39,6 +40,7 @@ AC_SUBST(LIBXSLT_VERSION)
AC_SUBST(LIBXSLT_VERSION_INFO)
AC_SUBST(LIBXSLT_VERSION_NUMBER)
AC_SUBST(LIBXSLT_VERSION_EXTRA)
+AC_SUBST(LIBXSLT_MAJOR_MINOR_VERSION)
dnl
dnl libexslt is an extension library
@@ -283,6 +285,7 @@ if [[ "${LOGNAME}" = "veillard" -a "`pwd`" = "/u/veillard/XSLT" ]] || \
if test "$LOGNAME" = "veillard"
then
LIBXML_SRC="/u/veillard/XML"
+ EXTRA_LIBS="$EXTRA_LIBS -ldl"
fi
else
STATIC_BINARIES=
@@ -456,13 +459,14 @@ else
fi
AC_SUBST(WITH_MODULES)
+AM_CONDITIONAL(WITH_MODULES, test "$WITH_MODULES" == "1")
dnl
dnl setup default module path
dnl
module_prefix=$prefix
test "x$module_prefix" = xNONE && module_prefix=$ac_default_prefix
-LIBXSLT_DEFAULT_PLUGINS_PATH="\"$module_prefix/lib/libxslt/$LIBXSLT_MAJOR_VERSION.$LIBXSLT_MINOR_VERSION/\""
+LIBXSLT_DEFAULT_PLUGINS_PATH="\"$module_prefix/lib/libxslt/$LIBXSLT_MAJOR_VERSION.$LIBXSLT_MINOR_VERSION\""
AC_SUBST(LIBXSLT_DEFAULT_PLUGINS_PATH)
dnl
@@ -518,7 +522,7 @@ AC_SUBST(EXSLT_LIBDIR)
AC_SUBST(EXSLT_INCLUDEDIR)
AC_SUBST(EXSLT_LIBS)
-EXTRA_LIBS="$LIBXML_LIBS $M_LIBS"
+EXTRA_LIBS="$EXTRA_LIBS $LIBXML_LIBS $M_LIBS"
AC_SUBST(EXTRA_LIBS)
AC_SUBST(M_LIBS)
diff --git a/libxslt/Makefile.am b/libxslt/Makefile.am
index c0dc1a3b..b42a22f5 100644
--- a/libxslt/Makefile.am
+++ b/libxslt/Makefile.am
@@ -57,5 +57,21 @@ man_MANS = libxslt.3
EXTRA_DIST = $(man_MANS) trio.h triodef.h
+
+# somewhat unconventional pkglibdir, but noinst_LTLIBRARIES
+# never build DSOs (afaik). NOTE: must be defined outside the AM_CONDITIONAL
+pkglibdir=$(shell pwd)/../tests/plugins
+
+if WITH_MODULES
+pkglib_LTLIBRARIES = xmlsoft_org_xslt_testplugin.la
+
+xmlsoft_org_xslt_testplugin_la_CFLAGS = -DMODULE_COMPILE $(LIBXML_CFLAGS) $(LIBXSLT_CFLAGS)
+xmlsoft_org_xslt_testplugin_la_SOURCES = testplugin.c
+xmlsoft_org_xslt_testplugin_la_LDFLAGS = -module -avoid-version $(LIBXML_LIBS) $(LIBXSLT_LIBS)
+
+check-local: install-pkglibLTLIBRARIES
+
+endif
+
xsltproc: all
@(cd ../xsltproc ; $(MAKE))
diff --git a/libxslt/extensions.c b/libxslt/extensions.c
index e703c79b..f1e0cc47 100644
--- a/libxslt/extensions.c
+++ b/libxslt/extensions.c
@@ -298,8 +298,17 @@ typedef void (*exsltRegisterFunction) (void);
* xsltExtModuleRegisterDynamic:
* @URI: the function or element namespace URI
*
- * Looks up an extension module to dynamically load
- * based on the namespace URI
+ * Dynamically loads an extension plugin when available.
+ *
+ * The plugin name is derived from the URI by removing the
+ * initial protocol designation, e.g. "http://", then converting
+ * the characters ".", "-", "/", and "\" into "_", the removing
+ * any trailing "/", then concatenating LIBXML_MODULE_EXTENSION.
+ *
+ * Plugins are loaded from the directory specified by the
+ * environment variable LIBXSLT_PLUGINS_PATH, or if NULL,
+ * by LIBXSLT_DEFAULT_PLUGINS_PATH() which is determined at
+ * compile time.
*
* Returns 0 if successful, -1 in case of error.
*/
@@ -310,10 +319,12 @@ xsltExtModuleRegisterDynamic(const xmlChar * URI)
xmlModulePtr m;
exsltRegisterFunction regfunc;
+ xmlChar *ext_name;
xmlChar module_filename[PATH_MAX];
- const xmlChar *extNameBegin = NULL;
- const xmlChar *extDirectory = NULL;
- int i, rc, seen_before;
+ const xmlChar *ext_directory = NULL;
+ const xmlChar *protocol = NULL;
+ xmlChar *i, *regfunc_name;
+ int rc, seen_before;
/* check for bad inputs */
if (URI == NULL)
@@ -331,43 +342,75 @@ xsltExtModuleRegisterDynamic(const xmlChar * URI)
return (-1);
}
- for (i = xmlStrlen(URI); i != 0 && extNameBegin == NULL; --i) {
- if (URI[i - 1] == '/')
- extNameBegin = URI + i;
+ /* transform extension namespace into a module name */
+ protocol = xmlStrstr(URI, "://");
+ if (protocol == NULL) {
+ ext_name = xmlStrdup(URI);
+ } else {
+ ext_name = xmlStrdup(protocol + 3);
}
-
- if (extNameBegin == NULL || *extNameBegin == '\0')
+ if (ext_name == NULL) {
return (-1);
+ }
+
+ i = ext_name;
+ while ('\0' != *i) {
+ if (('/' == *i) || ('\\' == *i) || ('.' == *i) || ('-' == *i))
+ *i = '_';
+ i++;
+ }
+
+ if (*(i - 1) == '_')
+ *i = '\0';
/* determine module directory */
- extDirectory = getenv(BAD_CAST "LIBXSLT_PLUGINS_PATH");
- if (NULL == extDirectory)
- extDirectory = LIBXSLT_DEFAULT_PLUGINS_PATH();
- if (NULL == extDirectory)
+ ext_directory = getenv(BAD_CAST "LIBXSLT_PLUGINS_PATH");
+ if (NULL == ext_directory)
+ ext_directory = LIBXSLT_DEFAULT_PLUGINS_PATH();
+ if (NULL == ext_directory)
return (-1);
/* build the module filename, and confirm the module exists */
- xmlStrPrintf(module_filename, sizeof(module_filename), "%s%s%s",
- extDirectory, extNameBegin, LIBXML_MODULE_EXTENSION);
- if (1 != xmlCheckFilename(module_filename))
+ xmlStrPrintf(module_filename, sizeof(module_filename), "%s/%s%s",
+ ext_directory, ext_name, LIBXML_MODULE_EXTENSION);
+ if (1 != xmlCheckFilename(module_filename)) {
+ xmlFree(ext_name);
return (-1);
+ }
+ /* attempt to open the module */
m = xmlModuleOpen(module_filename, 0);
- if (NULL == m)
+ if (NULL == m) {
+ xmlFree(ext_name);
return (-1);
+ }
- rc = xmlModuleSymbol(m, "exsltRegisterModule", (void **) &regfunc);
+ /* construct initialization func name */
+ regfunc_name = xmlStrdup(ext_name);
+ regfunc_name = xmlStrcat(regfunc_name, "_init");
+
+ rc = xmlModuleSymbol(m, regfunc_name, (void **) &regfunc);
if (0 == rc) {
+ /* call the module's init function */
(*regfunc) ();
- }
- /* register this module in our hash */
- xmlHashAddEntry(xsltModuleHash, URI, (void *) m);
+ /* register this module in our hash */
+ xmlHashAddEntry(xsltModuleHash, URI, (void *) m);
+ } else {
+ /* if regfunc not found unload the module immediately */
+ xmlModuleClose(m);
+ }
+ xmlFree(ext_name);
+ xmlFree(regfunc_name);
return (NULL == regfunc) ? -1 : 0;
}
#else
-#define xsltExtModuleRegisterDynamic(b) -1
+static int
+xsltExtModuleRegisterDynamic(const xmlChar * ATTRIBUTE_UNUSED URI)
+{
+ return -1;
+}
#endif
/************************************************************************
diff --git a/libxslt/xsltwin32config.h b/libxslt/xsltwin32config.h
index 136dd560..417f6ec2 100644
--- a/libxslt/xsltwin32config.h
+++ b/libxslt/xsltwin32config.h
@@ -44,7 +44,7 @@ extern "C" {
*
* extra version information, used to show a CVS compilation
*/
-#define LIBXML_VERSION_EXTRA "-CVS978"
+#define LIBXML_VERSION_EXTRA "-CVS980"
/**
* WITH_XSLT_DEBUG:
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8fd4e8b5..32e22e3c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -12,6 +12,7 @@ all:
# and (if errors are expected) in *.err
test tests:
@(cur=`pwd` ; for dir in $(SUBDIRS) ; do cd $$dir ; $(MAKE) CHECKER='$(CHECKER)' tests ; cd $$cur ; done)
+ $(MAKE) plugin_tests
valgrind:
@echo '## Running the regression tests under Valgrind'
@@ -23,3 +24,15 @@ full: tests docbook_tests
docbook_tests:
@(cd docbook ; $(MAKE) full)
+if WITH_MODULES
+
+plugin_tests:
+ @echo Running the plugin tests...
+ @(cd plugins && LIBXSLT_PLUGINS_PATH=. $(top_builddir)/../xsltproc/xsltproc plugin.xsl plugin.xml)
+
+else
+
+plugin_tests:
+ @echo Skipping the plugin tests.
+
+endif
diff --git a/tests/plugins/plugin.out b/tests/plugins/plugin.out
new file mode 100644
index 00000000..c5235455
--- /dev/null
+++ b/tests/plugins/plugin.out
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<!--libxslt:testplugin element test worked-->
+SUCCESS
diff --git a/tests/plugins/plugin.xml b/tests/plugins/plugin.xml
new file mode 100644
index 00000000..69d62f2c
--- /dev/null
+++ b/tests/plugins/plugin.xml
@@ -0,0 +1 @@
+<doc/>
diff --git a/tests/plugins/plugin.xsl b/tests/plugins/plugin.xsl
new file mode 100644
index 00000000..0203d230
--- /dev/null
+++ b/tests/plugins/plugin.xsl
@@ -0,0 +1,12 @@
+<?xml version='1.0'?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:libxslt="http://xmlsoft.org/xslt/testplugin"
+ xmlns:test="http://xmlsoft.org/xslt/testplugin"
+ xsl:extension-element-prefixes="libxslt test"
+ version='1.0'>
+<!-- the prefix is registered twice to check single initialization -->
+<xsl:template match="/">
+<libxslt:testplugin/>
+<xsl:value-of select="libxslt:testplugin('SUCCESS')"/>
+</xsl:template>
+</xsl:stylesheet>