[LIBXSLT] Update to v1.1.29. CORE-11557
authorAmine Khaldi <amine.khaldi@reactos.org>
Sat, 9 Jul 2016 18:30:47 +0000 (18:30 +0000)
committerAmine Khaldi <amine.khaldi@reactos.org>
Sat, 9 Jul 2016 18:30:47 +0000 (18:30 +0000)
svn path=/trunk/; revision=71876

21 files changed:
reactos/dll/3rdparty/libxslt/Makefile.am
reactos/dll/3rdparty/libxslt/Makefile.in
reactos/dll/3rdparty/libxslt/attributes.c
reactos/dll/3rdparty/libxslt/extensions.c
reactos/dll/3rdparty/libxslt/functions.c
reactos/dll/3rdparty/libxslt/imports.c
reactos/dll/3rdparty/libxslt/keys.c
reactos/dll/3rdparty/libxslt/namespaces.c
reactos/dll/3rdparty/libxslt/numbers.c
reactos/dll/3rdparty/libxslt/pattern.c
reactos/dll/3rdparty/libxslt/preproc.c
reactos/dll/3rdparty/libxslt/transform.c
reactos/dll/3rdparty/libxslt/variables.c
reactos/dll/3rdparty/libxslt/xslt.c
reactos/dll/3rdparty/libxslt/xsltconfig.h.in
reactos/dll/3rdparty/libxslt/xsltutils.c
reactos/media/doc/3rd Party Files.txt
reactos/sdk/include/reactos/libs/libxslt/xsltInternals.h
reactos/sdk/include/reactos/libs/libxslt/xsltconfig.h
reactos/sdk/include/reactos/libs/libxslt/xsltlocale.h
reactos/sdk/include/reactos/libs/libxslt/xsltutils.h

index d4619d2..d9fed68 100644 (file)
@@ -25,9 +25,10 @@ xsltinc_HEADERS =                    \
        transform.h                     \
        security.h                      \
        xsltInternals.h                 \
-       xsltconfig.h                    \
        xsltexports.h                   \
        xsltlocale.h
+nodist_xsltinc_HEADERS =               \
+       xsltconfig.h
 
 libxslt_la_SOURCES =                   \
        attrvt.c                        \
@@ -50,9 +51,10 @@ libxslt_la_SOURCES =                         \
        transform.c                     \
        security.c                      \
        win32config.h                   \
-       xsltwin32config.h               \
        xsltwin32config.h.in            \
        libxslt.h
+nodist_libxslt_la_SOURCES =            \
+       xsltwin32config.h
 
 if USE_VERSION_SCRIPT
 LIBXSLT_VERSION_SCRIPT = $(VERSION_SCRIPT_FLAGS)$(srcdir)/libxslt.syms
index e0a998b..bca66a3 100644 (file)
@@ -1,9 +1,8 @@
-# Makefile.in generated by automake 1.11.6 from Makefile.am.
+# Makefile.in generated by automake 1.15 from Makefile.am.
 # @configure_input@
 
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-# Foundation, Inc.
+# Copyright (C) 1994-2014 Free Software Foundation, Inc.
+
 # This Makefile.in is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
 
 VPATH = @srcdir@
-am__make_dryrun = \
-  { \
-    am__dry=no; \
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
     case $$MAKEFLAGS in \
       *\\[\ \  ]*) \
-        echo 'am--echo: ; @echo "AM"  OK' | $(MAKE) -f - 2>/dev/null \
-          | grep '^AM OK$$' >/dev/null || am__dry=yes;; \
-      *) \
-        for am__flg in $$MAKEFLAGS; do \
-          case $$am__flg in \
-            *=*|--*) ;; \
-            *n*) am__dry=yes; break;; \
-          esac; \
-        done;; \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs  ]*//g"`;; \
     esac; \
-    test $$am__dry = yes; \
-  }
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
 pkgdatadir = $(datadir)/@PACKAGE@
 pkgincludedir = $(includedir)/@PACKAGE@
 pkglibdir = $(libdir)/@PACKAGE@
@@ -53,13 +90,12 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 subdir = libxslt
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
-       $(srcdir)/xsltconfig.h.in $(srcdir)/xsltwin32config.h.in \
-       $(xsltinc_HEADERS)
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/configure.in
 am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
        $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(xsltinc_HEADERS) \
+       $(am__DIST_COMMON)
 mkinstalldirs = $(install_sh) -d
 CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES = xsltconfig.h xsltwin32config.h
@@ -92,7 +128,7 @@ am__uninstall_files_from_dir = { \
          $(am__cd) "$$dir" && rm -f $$files; }; \
   }
 am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" \
-       "$(DESTDIR)$(xsltincdir)"
+       "$(DESTDIR)$(xsltincdir)" "$(DESTDIR)$(xsltincdir)"
 LTLIBRARIES = $(lib_LTLIBRARIES)
 am__DEPENDENCIES_1 =
 libxslt_la_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
@@ -100,13 +136,28 @@ am_libxslt_la_OBJECTS = attrvt.lo xslt.lo xsltlocale.lo xsltutils.lo \
        pattern.lo templates.lo variables.lo keys.lo numbers.lo \
        extensions.lo extra.lo functions.lo namespaces.lo imports.lo \
        attributes.lo documents.lo preproc.lo transform.lo security.lo
-libxslt_la_OBJECTS = $(am_libxslt_la_OBJECTS)
+nodist_libxslt_la_OBJECTS =
+libxslt_la_OBJECTS = $(am_libxslt_la_OBJECTS) \
+       $(nodist_libxslt_la_OBJECTS)
 AM_V_lt = $(am__v_lt_@AM_V@)
 am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
 am__v_lt_0 = --silent
+am__v_lt_1 = 
 libxslt_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(libxslt_la_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 = 
 DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
 depcomp = $(SHELL) $(top_srcdir)/depcomp
 am__depfiles_maybe = depfiles
@@ -119,21 +170,17 @@ LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(AM_CFLAGS) $(CFLAGS)
 AM_V_CC = $(am__v_CC_@AM_V@)
 am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
-am__v_CC_0 = @echo "  CC    " $@;
-AM_V_at = $(am__v_at_@AM_V@)
-am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
-am__v_at_0 = @
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
 CCLD = $(CC)
 LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
        $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
        $(AM_LDFLAGS) $(LDFLAGS) -o $@
 AM_V_CCLD = $(am__v_CCLD_@AM_V@)
 am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
-am__v_CCLD_0 = @echo "  CCLD  " $@;
-AM_V_GEN = $(am__v_GEN_@AM_V@)
-am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
-am__v_GEN_0 = @echo "  GEN   " $@;
-SOURCES = $(libxslt_la_SOURCES)
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(libxslt_la_SOURCES) $(nodist_libxslt_la_SOURCES)
 DIST_SOURCES = $(libxslt_la_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
@@ -143,9 +190,28 @@ am__can_run_installinfo = \
 man3dir = $(mandir)/man3
 NROFF = nroff
 MANS = $(man_MANS)
-HEADERS = $(xsltinc_HEADERS)
+HEADERS = $(nodist_xsltinc_HEADERS) $(xsltinc_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
 ETAGS = etags
 CTAGS = ctags
+am__DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/xsltconfig.h.in \
+       $(srcdir)/xsltwin32config.h.in $(top_srcdir)/depcomp
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
@@ -161,6 +227,7 @@ CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
+CRYPTO_TESTDIR = @CRYPTO_TESTDIR@
 CYGPATH_W = @CYGPATH_W@
 DEFS = @DEFS@
 DEPDIR = @DEPDIR@
@@ -215,6 +282,7 @@ LIBXSLT_VERSION_NUMBER = @LIBXSLT_VERSION_NUMBER@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
 MAKEINFO = @MAKEINFO@
 MANIFEST_TOOL = @MANIFEST_TOOL@
 MKDIR_P = @MKDIR_P@
@@ -346,10 +414,12 @@ xsltinc_HEADERS = \
        transform.h                     \
        security.h                      \
        xsltInternals.h                 \
-       xsltconfig.h                    \
        xsltexports.h                   \
        xsltlocale.h
 
+nodist_xsltinc_HEADERS = \
+       xsltconfig.h
+
 libxslt_la_SOURCES = \
        attrvt.c                        \
        xslt.c                          \
@@ -371,10 +441,12 @@ libxslt_la_SOURCES = \
        transform.c                     \
        security.c                      \
        win32config.h                   \
-       xsltwin32config.h               \
        xsltwin32config.h.in            \
        libxslt.h
 
+nodist_libxslt_la_SOURCES = \
+       xsltwin32config.h
+
 @USE_VERSION_SCRIPT_FALSE@LIBXSLT_VERSION_SCRIPT = 
 @USE_VERSION_SCRIPT_TRUE@LIBXSLT_VERSION_SCRIPT = $(VERSION_SCRIPT_FLAGS)$(srcdir)/libxslt.syms
 libxslt_la_LIBADD = $(LIBXML_LIBS) $(EXTRA_LIBS)
@@ -401,7 +473,6 @@ $(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
        echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libxslt/Makefile'; \
        $(am__cd) $(top_srcdir) && \
          $(AUTOMAKE) --gnu libxslt/Makefile
-.PRECIOUS: Makefile
 Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
        @case '$?' in \
          *config.status*) \
@@ -423,6 +494,7 @@ xsltconfig.h: $(top_builddir)/config.status $(srcdir)/xsltconfig.h.in
        cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 xsltwin32config.h: $(top_builddir)/config.status $(srcdir)/xsltwin32config.h.in
        cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+
 install-libLTLIBRARIES: $(lib_LTLIBRARIES)
        @$(NORMAL_INSTALL)
        @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
@@ -449,12 +521,15 @@ uninstall-libLTLIBRARIES:
 
 clean-libLTLIBRARIES:
        -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
-       @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
-         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
-         test "$$dir" != "$$p" || dir=.; \
-         echo "rm -f \"$${dir}/so_locations\""; \
-         rm -f "$${dir}/so_locations"; \
-       done
+       @list='$(lib_LTLIBRARIES)'; \
+       locs=`for p in $$list; do echo $$p; done | \
+             sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+             sort -u`; \
+       test -z "$$locs" || { \
+         echo rm -f $${locs}; \
+         rm -f $${locs}; \
+       }
+
 libxslt.la: $(libxslt_la_OBJECTS) $(libxslt_la_DEPENDENCIES) $(EXTRA_libxslt_la_DEPENDENCIES) 
        $(AM_V_CCLD)$(libxslt_la_LINK) -rpath $(libdir) $(libxslt_la_OBJECTS) $(libxslt_la_LIBADD) $(LIBS)
 
@@ -489,14 +564,14 @@ distclean-compile:
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c $<
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
 
 .c.obj:
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
 @am__fastdepCC_TRUE@   $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c `$(CYGPATH_W) '$<'`
+@am__fastdepCC_FALSE@  $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
 
 .c.lo:
 @am__fastdepCC_TRUE@   $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -553,6 +628,27 @@ uninstall-man3:
        } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^3][0-9a-z]*$$,3,;x' \
              -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
        dir='$(DESTDIR)$(man3dir)'; $(am__uninstall_files_from_dir)
+install-nodist_xsltincHEADERS: $(nodist_xsltinc_HEADERS)
+       @$(NORMAL_INSTALL)
+       @list='$(nodist_xsltinc_HEADERS)'; test -n "$(xsltincdir)" || list=; \
+       if test -n "$$list"; then \
+         echo " $(MKDIR_P) '$(DESTDIR)$(xsltincdir)'"; \
+         $(MKDIR_P) "$(DESTDIR)$(xsltincdir)" || exit 1; \
+       fi; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; \
+       done | $(am__base_list) | \
+       while read files; do \
+         echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(xsltincdir)'"; \
+         $(INSTALL_HEADER) $$files "$(DESTDIR)$(xsltincdir)" || exit $$?; \
+       done
+
+uninstall-nodist_xsltincHEADERS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(nodist_xsltinc_HEADERS)'; test -n "$(xsltincdir)" || list=; \
+       files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+       dir='$(DESTDIR)$(xsltincdir)'; $(am__uninstall_files_from_dir)
 install-xsltincHEADERS: $(xsltinc_HEADERS)
        @$(NORMAL_INSTALL)
        @list='$(xsltinc_HEADERS)'; test -n "$(xsltincdir)" || list=; \
@@ -575,26 +671,15 @@ uninstall-xsltincHEADERS:
        files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
        dir='$(DESTDIR)$(xsltincdir)'; $(am__uninstall_files_from_dir)
 
-ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
-       list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-             END { if (nonempty) { for (i in files) print i; }; }'`; \
-       mkid -fID $$unique
-tags: TAGS
-
-TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-               $(TAGS_FILES) $(LISP)
+ID: $(am__tagged_files)
+       $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
        set x; \
        here=`pwd`; \
-       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-             END { if (nonempty) { for (i in files) print i; }; }'`; \
+       $(am__define_uniq_tagged_files); \
        shift; \
        if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
          test -n "$$unique" || unique=$$empty_fix; \
@@ -606,15 +691,11 @@ TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
              $$unique; \
          fi; \
        fi
-ctags: CTAGS
-CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
-               $(TAGS_FILES) $(LISP)
-       list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
-       unique=`for i in $$list; do \
-           if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-         done | \
-         $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
-             END { if (nonempty) { for (i in files) print i; }; }'`; \
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+       $(am__define_uniq_tagged_files); \
        test -z "$(CTAGS_ARGS)$$unique" \
          || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
             $$unique
@@ -623,24 +704,26 @@ GTAGS:
        here=`$(am__cd) $(top_builddir) && pwd` \
          && $(am__cd) $(top_srcdir) \
          && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+       list='$(am__tagged_files)'; \
+       case "$(srcdir)" in \
+         [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+         *) sdir=$(subdir)/$(srcdir) ;; \
+       esac; \
+       for i in $$list; do \
+         if test -f "$$i"; then \
+           echo "$(subdir)/$$i"; \
+         else \
+           echo "$$sdir/$$i"; \
+         fi; \
+       done >> $(top_builddir)/cscope.files
 
 distclean-tags:
        -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
 
 distdir: $(DISTFILES)
-       @list='$(MANS)'; if test -n "$$list"; then \
-         list=`for p in $$list; do \
-           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
-           if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
-         if test -n "$$list" && \
-           grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
-           echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
-           grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/         /' >&2; \
-           echo "       to fix them, install help2man, remove and regenerate the man pages;" >&2; \
-           echo "       typically \`make maintainer-clean' will remove them" >&2; \
-           exit 1; \
-         else :; fi; \
-       else :; fi
        @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
        topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
        list='$(DISTFILES)'; \
@@ -674,7 +757,7 @@ check-am: all-am
 check: check-am
 all-am: Makefile $(LTLIBRARIES) $(MANS) $(HEADERS)
 installdirs:
-       for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(xsltincdir)"; do \
+       for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(man3dir)" "$(DESTDIR)$(xsltincdir)" "$(DESTDIR)$(xsltincdir)"; do \
          test -z "$$dir" || $(MKDIR_P) "$$dir"; \
        done
 install: install-am
@@ -730,7 +813,8 @@ info: info-am
 
 info-am:
 
-install-data-am: install-man install-xsltincHEADERS
+install-data-am: install-man install-nodist_xsltincHEADERS \
+       install-xsltincHEADERS
 
 install-dvi: install-dvi-am
 
@@ -778,27 +862,31 @@ ps: ps-am
 ps-am:
 
 uninstall-am: uninstall-libLTLIBRARIES uninstall-man \
-       uninstall-xsltincHEADERS
+       uninstall-nodist_xsltincHEADERS uninstall-xsltincHEADERS
 
 uninstall-man: uninstall-man3
 
 .MAKE: install-am install-exec-am install-strip
 
-.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
-       clean-libLTLIBRARIES clean-libtool ctags distclean \
-       distclean-compile distclean-generic distclean-libtool \
-       distclean-tags distdir dvi dvi-am html html-am info info-am \
-       install install-am install-data install-data-am install-dvi \
-       install-dvi-am install-exec install-exec-am install-exec-hook \
-       install-html install-html-am install-info install-info-am \
-       install-libLTLIBRARIES install-man install-man3 install-pdf \
-       install-pdf-am install-ps install-ps-am install-strip \
-       install-xsltincHEADERS installcheck installcheck-am \
-       installdirs maintainer-clean maintainer-clean-generic \
-       mostlyclean mostlyclean-compile mostlyclean-generic \
-       mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
-       uninstall-am uninstall-libLTLIBRARIES uninstall-man \
-       uninstall-man3 uninstall-xsltincHEADERS
+.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \
+       clean-libLTLIBRARIES clean-libtool cscopelist-am ctags \
+       ctags-am distclean distclean-compile distclean-generic \
+       distclean-libtool distclean-tags distdir dvi dvi-am html \
+       html-am info info-am install install-am install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-exec-hook install-html install-html-am \
+       install-info install-info-am install-libLTLIBRARIES \
+       install-man install-man3 install-nodist_xsltincHEADERS \
+       install-pdf install-pdf-am install-ps install-ps-am \
+       install-strip install-xsltincHEADERS installcheck \
+       installcheck-am installdirs maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-am uninstall uninstall-am uninstall-libLTLIBRARIES \
+       uninstall-man uninstall-man3 uninstall-nodist_xsltincHEADERS \
+       uninstall-xsltincHEADERS
+
+.PRECIOUS: Makefile
 
 
 xsltproc: all
index 4ce2ea5..c038a3c 100644 (file)
@@ -259,9 +259,11 @@ xsltParseStylesheetAttributeSet(xsltStylesheetPtr style, xmlNodePtr cur) {
        return;
 
     value = xmlGetNsProp(cur, (const xmlChar *)"name", NULL);
-    if (value == NULL) {
+    if ((value == NULL) || (*value == 0)) {
        xsltGenericError(xsltGenericErrorContext,
             "xsl:attribute-set : name is missing\n");
+        if (value)
+           xmlFree(value);
        return;
     }
 
@@ -444,19 +446,27 @@ xsltGetSAS(xsltStylesheetPtr style, const xmlChar *name, const xmlChar *ns) {
 }
 
 /**
- * xsltResolveSASCallback,:
+ * xsltResolveSASCallbackInt:
  * @style:  the XSLT stylesheet
  *
  * resolve the references in an attribute set.
  */
 static void
-xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
+xsltResolveSASCallbackInt(xsltAttrElemPtr values, xsltStylesheetPtr style,
                       const xmlChar *name, const xmlChar *ns,
-                      ATTRIBUTE_UNUSED const xmlChar *ignored) {
+                      int depth) {
     xsltAttrElemPtr tmp;
     xsltAttrElemPtr refs;
 
     tmp = values;
+    if ((name == NULL) || (name[0] == 0))
+        return;
+    if (depth > 100) {
+       xsltGenericError(xsltGenericErrorContext,
+       "xsl:attribute-set : use-attribute-sets recursion detected on %s\n",
+                        name);
+       return;
+    }
     while (tmp != NULL) {
        if (tmp->set != NULL) {
            /*
@@ -481,7 +491,7 @@ xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
                    /*
                     * recurse first for cleanup
                     */
-                   xsltResolveSASCallback(refs, style, name, ns, NULL);
+                   xsltResolveSASCallbackInt(refs, style, name, ns, depth + 1);
                    /*
                     * Then merge
                     */
@@ -498,6 +508,19 @@ xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
     }
 }
 
+/**
+ * xsltResolveSASCallback,:
+ * @style:  the XSLT stylesheet
+ *
+ * resolve the references in an attribute set.
+ */
+static void
+xsltResolveSASCallback(xsltAttrElemPtr values, xsltStylesheetPtr style,
+                      const xmlChar *name, const xmlChar *ns,
+                      ATTRIBUTE_UNUSED const xmlChar *ignored) {
+    xsltResolveSASCallbackInt(values, style, name, ns, 1);
+}
+
 /**
  * xsltMergeSASCallback,:
  * @style:  the XSLT stylesheet
index 5235fea..4c0763f 100644 (file)
@@ -350,8 +350,11 @@ xsltExtModuleRegisterDynamic(const xmlChar * URI)
         i++;
     }
 
-    if (*(i - 1) == '_')
+    /* Strip underscores from end of string. */
+    while (i > ext_name && *(i - 1) == '_') {
+        i--;
         *i = '\0';
+    }
 
     /* determine module directory */
     ext_directory = (xmlChar *) getenv("LIBXSLT_PLUGINS_PATH");
@@ -1605,7 +1608,7 @@ xsltRegisterExtModuleElement(const xmlChar * name, const xmlChar * URI,
                              xsltPreComputeFunction precomp,
                              xsltTransformFunction transform)
 {
-    int ret;
+    int ret = 0;
 
     xsltExtElementPtr ext;
 
@@ -1631,7 +1634,7 @@ xsltRegisterExtModuleElement(const xmlChar * name, const xmlChar * URI,
 done:
     xmlMutexUnlock(xsltExtMutex);
 
-    return (0);
+    return (ret);
 }
 
 /**
index 6e32380..41a58d3 100644 (file)
@@ -152,7 +152,6 @@ xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI)
     resObj = xmlXPtrEval(fragment, xptrctxt);
     xmlXPathFreeContext(xptrctxt);
 #endif
-    xmlFree(fragment);
 
     if (resObj == NULL)
        goto out_fragment;
@@ -176,6 +175,7 @@ xsltDocumentFunctionLoadDocument(xmlXPathParserContextPtr ctxt, xmlChar* URI)
     }
 
     valuePush(ctxt, resObj);
+    xmlFree(fragment);
     return;
 
 out_object:
@@ -183,6 +183,7 @@ out_object:
 
 out_fragment:
     valuePush(ctxt, xmlXPathNewNodeSet(NULL));
+    xmlFree(fragment);
 }
 
 /**
@@ -637,7 +638,6 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
     xmlXPathObjectPtr obj = NULL;
     long val;
     xmlChar str[30];
-    xmlDocPtr doc;
 
     if (nargs == 0) {
        cur = ctxt->context->node;
@@ -670,30 +670,15 @@ xsltGenerateIdFunction(xmlXPathParserContextPtr ctxt, int nargs){
        ctxt->error = XPATH_INVALID_ARITY;
        return;
     }
-    /*
-     * Okay this is ugly but should work, use the NodePtr address
-     * to forge the ID
-     */
-    if (cur->type != XML_NAMESPACE_DECL)
-        doc = cur->doc;
-    else {
-        xmlNsPtr ns = (xmlNsPtr) cur;
-
-        if (ns->context != NULL)
-            doc = ns->context;
-        else
-            doc = ctxt->context->doc;
-
-    }
 
     if (obj)
         xmlXPathFreeObject(obj);
 
     val = (long)((char *)cur - (char *)&base_address);
     if (val >= 0) {
-      sprintf((char *)str, "idp%ld", val);
+      snprintf((char *)str, sizeof(str), "idp%ld", val);
     } else {
-      sprintf((char *)str, "idm%ld", -val);
+      snprintf((char *)str, sizeof(str), "idm%ld", -val);
     }
     valuePush(ctxt, xmlXPathNewString(str));
 }
index 3d254b7..ac659f0 100644 (file)
@@ -363,17 +363,12 @@ xsltFindTemplate(xsltTransformContextPtr ctxt, const xmlChar *name,
        return(NULL);
     style = ctxt->style;
     while (style != NULL) {
-       cur = style->templates;
-       while (cur != NULL) {
-           if (xmlStrEqual(name, cur->name)) {
-               if (((nameURI == NULL) && (cur->nameURI == NULL)) ||
-                   ((nameURI != NULL) && (cur->nameURI != NULL) &&
-                    (xmlStrEqual(nameURI, cur->nameURI)))) {
-                   return(cur);
-               }
-           }
-           cur = cur->next;
-       }
+        if (style->namedTemplates != NULL) {
+            cur = (xsltTemplatePtr)
+                xmlHashLookup2(style->namedTemplates, name, nameURI);
+            if (cur != NULL)
+                return(cur);
+        }
 
        style = xsltNextImport(style);
     }
index dc1ab6d..e3a929c 100644 (file)
@@ -741,6 +741,7 @@ fprintf(stderr, "xsltInitCtxtKey %s : %d\n", keyDef->name, ctxt->keyInitLevel);
        cur = matchList->nodeTab[i];
        if (! IS_XSLT_REAL_NODE(cur))
            continue;
+        ctxt->node = cur;
        xpctxt->node = cur;
        /*
        * Process the 'use' of the xsl:key.
index 8d265c0..1ee3b9f 100644 (file)
@@ -752,8 +752,10 @@ xsltCopyNamespaceList(xsltTransformContextPtr ctxt, xmlNodePtr node,
            /* TODO apply cascading */
            URI = (const xmlChar *) xmlHashLookup(ctxt->style->nsAliases,
                                                  cur->href);
-           if (URI == UNDEFINED_DEFAULT_NS)
+           if (URI == UNDEFINED_DEFAULT_NS) {
+               cur = cur->next;
                continue;
+           }
            if (URI != NULL) {
                q = xmlNewNs(node, URI, cur->prefix);
            } else {
index 55bea60..790300d 100644 (file)
@@ -210,7 +210,8 @@ xsltNumberFormatDecimal(xmlBufferPtr buffer,
 }
 
 static void
-xsltNumberFormatAlpha(xmlBufferPtr buffer,
+xsltNumberFormatAlpha(xsltNumberDataPtr data,
+                     xmlBufferPtr buffer,
                      double number,
                      int is_upper)
 {
@@ -220,6 +221,26 @@ xsltNumberFormatAlpha(xmlBufferPtr buffer,
     char *alpha_list;
     double alpha_size = (double)(sizeof(alpha_upper_list) - 1);
 
+    /*
+     * XSLT 1.0 isn't clear on how to handle zero, but XSLT 2.0 says:
+     *
+     *     For all format tokens other than the first kind above (one that
+     *     consists of decimal digits), there may be implementation-defined
+     *     lower and upper bounds on the range of numbers that can be
+     *     formatted using this format token; indeed, for some numbering
+     *     sequences there may be intrinsic limits. [...] Numbers that fall
+     *     outside this range must be formatted using the format token 1.
+     *
+     * The "a" token has an intrinsic lower limit of 1.
+     */
+    if (number < 1.0) {
+        xsltNumberFormatDecimal(buffer, number, '0', 1,
+                                data->digitsPerGroup,
+                                data->groupingCharacter,
+                                data->groupingCharacterLen);
+        return;
+    }
+
     /* Build buffer from back */
     pointer = &temp_string[sizeof(temp_string)];
     *(--pointer) = 0;
@@ -229,17 +250,30 @@ xsltNumberFormatAlpha(xmlBufferPtr buffer,
        number--;
        *(--pointer) = alpha_list[((int)fmod(number, alpha_size))];
        number /= alpha_size;
-       if (fabs(number) < 1.0)
+       if (number < 1.0)
            break; /* for */
     }
     xmlBufferCCat(buffer, pointer);
 }
 
 static void
-xsltNumberFormatRoman(xmlBufferPtr buffer,
+xsltNumberFormatRoman(xsltNumberDataPtr data,
+                     xmlBufferPtr buffer,
                      double number,
                      int is_upper)
 {
+    /*
+     * See discussion in xsltNumberFormatAlpha. Also use a reasonable upper
+     * bound to avoid denial of service.
+     */
+    if (number < 1.0 || number > 5000.0) {
+        xsltNumberFormatDecimal(buffer, number, '0', 1,
+                                data->digitsPerGroup,
+                                data->groupingCharacter,
+                                data->groupingCharacterLen);
+        return;
+    }
+
     /*
      * Based on an example by Jim Walsh
      */
@@ -423,6 +457,23 @@ xsltNumberFormatInsertNumbers(xsltNumberDataPtr data,
     for (i = 0; i < numbers_max; i++) {
        /* Insert number */
        number = numbers[(numbers_max - 1) - i];
+        /* Round to nearest like XSLT 2.0 */
+        number = floor(number + 0.5);
+        /*
+         * XSLT 1.0 isn't clear on how to handle negative numbers, but XSLT
+         * 2.0 says:
+         *
+         *     It is a non-recoverable dynamic error if any undiscarded item
+         *     in the atomized sequence supplied as the value of the value
+         *     attribute of xsl:number cannot be converted to an integer, or
+         *     if the resulting integer is less than 0 (zero).
+         */
+        if (number < 0.0) {
+            xsltTransformError(NULL, NULL, NULL,
+                    "xsl-number : negative value\n");
+            /* Recover by treating negative values as zero. */
+            number = 0.0;
+        }
        if (i < tokens->nTokens) {
          /*
           * The "n"th format token will be used to format the "n"th
@@ -466,28 +517,16 @@ xsltNumberFormatInsertNumbers(xsltNumberDataPtr data,
 
                switch (token->token) {
                case 'A':
-                   xsltNumberFormatAlpha(buffer,
-                                         number,
-                                         TRUE);
-
+                   xsltNumberFormatAlpha(data, buffer, number, TRUE);
                    break;
                case 'a':
-                   xsltNumberFormatAlpha(buffer,
-                                         number,
-                                         FALSE);
-
+                   xsltNumberFormatAlpha(data, buffer, number, FALSE);
                    break;
                case 'I':
-                   xsltNumberFormatRoman(buffer,
-                                         number,
-                                         TRUE);
-
+                   xsltNumberFormatRoman(data, buffer, number, TRUE);
                    break;
                case 'i':
-                   xsltNumberFormatRoman(buffer,
-                                         number,
-                                         FALSE);
-
+                   xsltNumberFormatRoman(data, buffer, number, FALSE);
                    break;
                default:
                    if (IS_DIGIT_ZERO(token->token)) {
@@ -514,14 +553,49 @@ xsltNumberFormatInsertNumbers(xsltNumberDataPtr data,
 
 }
 
+static int
+xsltTestCompMatchCount(xsltTransformContextPtr context,
+                       xmlNodePtr node,
+                       xsltCompMatchPtr countPat,
+                       xmlNodePtr cur)
+{
+    if (countPat != NULL) {
+        return xsltTestCompMatchList(context, node, countPat);
+    }
+    else {
+        /*
+         * 7.7 Numbering
+         *
+         * If count attribute is not specified, then it defaults to the
+         * pattern that matches any node with the same node type as the
+         * current node and, if the current node has an expanded-name, with
+         * the same expanded-name as the current node.
+         */
+        if (node->type != cur->type)
+            return 0;
+        if (node->type == XML_NAMESPACE_DECL)
+            /*
+             * Namespace nodes have no preceding siblings and no parents
+             * that are namespace nodes. This means that node == cur.
+             */
+            return 1;
+        /* TODO: Skip node types without expanded names like text nodes. */
+        if (!xmlStrEqual(node->name, cur->name))
+            return 0;
+        if (node->ns == cur->ns)
+            return 1;
+        if ((node->ns == NULL) || (cur->ns == NULL))
+            return 0;
+        return (xmlStrEqual(node->ns->href, cur->ns->href));
+    }
+}
+
 static int
 xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
                            xmlNodePtr node,
                            xsltCompMatchPtr countPat,
                            xsltCompMatchPtr fromPat,
-                           double *array,
-                           xmlDocPtr doc,
-                           xmlNodePtr elem)
+                           double *array)
 {
     int amount = 0;
     int cnt = 0;
@@ -547,21 +621,8 @@ xsltNumberFormatGetAnyLevel(xsltTransformContextPtr context,
 
     while (cur != NULL) {
        /* process current node */
-       if (countPat == NULL) {
-           if ((node->type == cur->type) &&
-               /* FIXME: must use expanded-name instead of local name */
-               xmlStrEqual(node->name, cur->name)) {
-                   if ((node->ns == cur->ns) ||
-                       ((node->ns != NULL) &&
-                        (cur->ns != NULL) &&
-                        (xmlStrEqual(node->ns->href,
-                            cur->ns->href) )))
-                       cnt++;
-           }
-       } else {
-           if (xsltTestCompMatchList(context, cur, countPat))
-               cnt++;
-       }
+       if (xsltTestCompMatchCount(context, cur, countPat, node))
+           cnt++;
        if ((fromPat != NULL) &&
            xsltTestCompMatchList(context, cur, fromPat)) {
            break; /* while */
@@ -598,9 +659,7 @@ xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
                                 xsltCompMatchPtr countPat,
                                 xsltCompMatchPtr fromPat,
                                 double *array,
-                                int max,
-                                xmlDocPtr doc,
-                                xmlNodePtr elem)
+                                int max)
 {
     int amount = 0;
     int cnt;
@@ -620,30 +679,18 @@ xsltNumberFormatGetMultipleLevel(xsltTransformContextPtr context,
                xsltTestCompMatchList(context, ancestor, fromPat))
                break; /* for */
 
-           if ((countPat == NULL && node->type == ancestor->type &&
-               xmlStrEqual(node->name, ancestor->name)) ||
-               xsltTestCompMatchList(context, ancestor, countPat)) {
+           if (xsltTestCompMatchCount(context, ancestor, countPat, node)) {
                /* count(preceding-sibling::*) */
-               cnt = 0;
-               for (preceding = ancestor;
+               cnt = 1;
+               for (preceding =
+                        xmlXPathNextPrecedingSibling(parser, ancestor);
                     preceding != NULL;
                     preceding =
                        xmlXPathNextPrecedingSibling(parser, preceding)) {
-                   if (countPat == NULL) {
-                       if ((preceding->type == ancestor->type) &&
-                           xmlStrEqual(preceding->name, ancestor->name)){
-                           if ((preceding->ns == ancestor->ns) ||
-                               ((preceding->ns != NULL) &&
-                                (ancestor->ns != NULL) &&
-                                (xmlStrEqual(preceding->ns->href,
-                                    ancestor->ns->href) )))
-                               cnt++;
-                       }
-                   } else {
-                       if (xsltTestCompMatchList(context, preceding,
-                                                 countPat))
-                           cnt++;
-                   }
+
+                   if (xsltTestCompMatchCount(context, preceding, countPat,
+                                               node))
+                       cnt++;
                }
                array[amount++] = (double)cnt;
                if (amount >= max)
@@ -700,24 +747,29 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
     int amount, i;
     double number;
     xsltFormat tokens;
-    int tempformat = 0;
 
-    if ((data->format == NULL) && (data->has_format != 0)) {
-       data->format = xsltEvalAttrValueTemplate(ctxt, data->node,
+    if (data->format != NULL) {
+        xsltNumberFormatTokenize(data->format, &tokens);
+    }
+    else {
+        xmlChar *format;
+
+       /* The format needs to be recomputed each time */
+        if (data->has_format == 0)
+            return;
+       format = xsltEvalAttrValueTemplate(ctxt, data->node,
                                             (const xmlChar *) "format",
                                             XSLT_NAMESPACE);
-       tempformat = 1;
-    }
-    if (data->format == NULL) {
-       return;
+        if (format == NULL)
+            return;
+        xsltNumberFormatTokenize(format, &tokens);
+       xmlFree(format);
     }
 
     output = xmlBufferCreate();
     if (output == NULL)
        goto XSLT_NUMBER_FORMAT_END;
 
-    xsltNumberFormatTokenize(data->format, &tokens);
-
     /*
      * Evaluate the XPath expression to find the value(s)
      */
@@ -742,9 +794,7 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
                                                      data->countPat,
                                                      data->fromPat,
                                                      &number,
-                                                     1,
-                                                     data->doc,
-                                                     data->node);
+                                                     1);
            if (amount == 1) {
                xsltNumberFormatInsertNumbers(data,
                                              &number,
@@ -760,9 +810,7 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
                                                      data->countPat,
                                                      data->fromPat,
                                                      numarray,
-                                                     max,
-                                                     data->doc,
-                                                     data->node);
+                                                     max);
            if (amount > 0) {
                xsltNumberFormatInsertNumbers(data,
                                              numarray,
@@ -775,9 +823,7 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
                                                 node,
                                                 data->countPat,
                                                 data->fromPat,
-                                                &number,
-                                                data->doc,
-                                                data->node);
+                                                &number);
            if (amount > 0) {
                xsltNumberFormatInsertNumbers(data,
                                              &number,
@@ -790,6 +836,9 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
     /* Insert number as text node */
     xsltCopyTextString(ctxt, ctxt->insert, xmlBufferContent(output), 0);
 
+    xmlBufferFree(output);
+
+XSLT_NUMBER_FORMAT_END:
     if (tokens.start != NULL)
        xmlFree(tokens.start);
     if (tokens.end != NULL)
@@ -798,14 +847,6 @@ xsltNumberFormat(xsltTransformContextPtr ctxt,
        if (tokens.tokens[i].separator != NULL)
            xmlFree(tokens.tokens[i].separator);
     }
-
-XSLT_NUMBER_FORMAT_END:
-    if (tempformat == 1) {
-       /* The format need to be recomputed each time */
-       data->format = NULL;
-    }
-    if (output != NULL)
-       xmlBufferFree(output);
 }
 
 static int
index 1a1ac3d..62dfe0a 100644 (file)
@@ -432,11 +432,14 @@ xsltReverseCompMatch(xsltParserContextPtr ctxt, xsltCompMatchPtr comp) {
     xsltCompMatchAdd(ctxt, comp, XSLT_OP_END, NULL, NULL, 0);
 
     /*
-     * detect consecutive XSLT_OP_PREDICATE indicating a direct
-     * matching should be done.
+     * Detect consecutive XSLT_OP_PREDICATE and predicates on ops which
+     * haven't been optimized yet indicating a direct matching should be done.
      */
     for (i = 0;i < comp->nbStep - 1;i++) {
-        if ((comp->steps[i].op == XSLT_OP_PREDICATE) &&
+        xsltOp op = comp->steps[i].op;
+
+        if ((op != XSLT_OP_ELEM) &&
+            (op != XSLT_OP_ALL) &&
            (comp->steps[i + 1].op == XSLT_OP_PREDICATE)) {
 
            comp->direct = 1;
@@ -601,6 +604,280 @@ xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
     return(0);
 }
 
+/**
+ * xsltTestPredicateMatch:
+ * @ctxt: a XSLT process context
+ * @comp: the precompiled pattern
+ * @node: a node
+ * @step: the predicate step
+ * @sel:  the previous step
+ *
+ * Test whether the node matches the predicate
+ *
+ * Returns 1 if it matches, 0 if it doesn't and -1 in case of failure
+ */
+static int
+xsltTestPredicateMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
+                       xmlNodePtr node, xsltStepOpPtr step,
+                       xsltStepOpPtr sel) {
+    xmlNodePtr oldNode;
+    xmlDocPtr doc;
+    int oldCS, oldCP;
+    int pos = 0, len = 0;
+    int isRVT;
+    int match;
+
+    if (step->value == NULL)
+        return(0);
+    if (step->comp == NULL)
+        return(0);
+
+    doc = node->doc;
+    if (XSLT_IS_RES_TREE_FRAG(doc))
+        isRVT = 1;
+    else
+        isRVT = 0;
+
+    /*
+     * Recompute contextSize and proximityPosition.
+     *
+     * TODO: Make this work for additional ops. Currently, only XSLT_OP_ELEM
+     * and XSLT_OP_ALL are supported.
+     */
+    oldCS = ctxt->xpathCtxt->contextSize;
+    oldCP = ctxt->xpathCtxt->proximityPosition;
+    if ((sel != NULL) &&
+        (sel->op == XSLT_OP_ELEM) &&
+        (sel->value != NULL) &&
+        (node->type == XML_ELEMENT_NODE) &&
+        (node->parent != NULL)) {
+        xmlNodePtr previous;
+        int nocache = 0;
+
+        previous = (xmlNodePtr)
+            XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
+        if ((previous != NULL) &&
+            (previous->parent == node->parent)) {
+            /*
+             * just walk back to adjust the index
+             */
+            int indx = 0;
+            xmlNodePtr sibling = node;
+
+            while (sibling != NULL) {
+                if (sibling == previous)
+                    break;
+                if ((sibling->type == XML_ELEMENT_NODE) &&
+                    (previous->name != NULL) &&
+                    (sibling->name != NULL) &&
+                    (previous->name[0] == sibling->name[0]) &&
+                    (xmlStrEqual(previous->name, sibling->name)))
+                {
+                    if ((sel->value2 == NULL) ||
+                        ((sibling->ns != NULL) &&
+                         (xmlStrEqual(sel->value2, sibling->ns->href))))
+                        indx++;
+                }
+                sibling = sibling->prev;
+            }
+            if (sibling == NULL) {
+                /* hum going backward in document order ... */
+                indx = 0;
+                sibling = node;
+                while (sibling != NULL) {
+                    if (sibling == previous)
+                        break;
+                    if ((sibling->type == XML_ELEMENT_NODE) &&
+                        (previous->name != NULL) &&
+                        (sibling->name != NULL) &&
+                        (previous->name[0] == sibling->name[0]) &&
+                        (xmlStrEqual(previous->name, sibling->name)))
+                    {
+                        if ((sel->value2 == NULL) ||
+                            ((sibling->ns != NULL) &&
+                            (xmlStrEqual(sel->value2,
+                            sibling->ns->href))))
+                        {
+                            indx--;
+                        }
+                    }
+                    sibling = sibling->next;
+                }
+            }
+            if (sibling != NULL) {
+                pos = XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) + indx;
+                /*
+                 * If the node is in a Value Tree we need to
+                 * save len, but cannot cache the node!
+                 * (bugs 153137 and 158840)
+                 */
+                if (node->doc != NULL) {
+                    len = XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival);
+                    if (!isRVT) {
+                        XSLT_RUNTIME_EXTRA(ctxt,
+                            sel->previousExtra, ptr) = node;
+                        XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos;
+                    }
+                }
+            } else
+                pos = 0;
+        } else {
+            /*
+             * recompute the index
+             */
+            xmlNodePtr parent = node->parent;
+            xmlNodePtr siblings = NULL;
+
+            if (parent) siblings = parent->children;
+
+            while (siblings != NULL) {
+                if (siblings->type == XML_ELEMENT_NODE) {
+                    if (siblings == node) {
+                        len++;
+                        pos = len;
+                    } else if ((node->name != NULL) &&
+                               (siblings->name != NULL) &&
+                        (node->name[0] == siblings->name[0]) &&
+                        (xmlStrEqual(node->name, siblings->name))) {
+                        if ((sel->value2 == NULL) ||
+                            ((siblings->ns != NULL) &&
+                             (xmlStrEqual(sel->value2, siblings->ns->href))))
+                            len++;
+                    }
+                }
+                siblings = siblings->next;
+            }
+            if ((parent == NULL) || (node->doc == NULL))
+                nocache = 1;
+            else {
+                while (parent->parent != NULL)
+                    parent = parent->parent;
+                if (((parent->type != XML_DOCUMENT_NODE) &&
+                     (parent->type != XML_HTML_DOCUMENT_NODE)) ||
+                     (parent != (xmlNodePtr) node->doc))
+                    nocache = 1;
+            }
+        }
+        if (pos != 0) {
+            ctxt->xpathCtxt->contextSize = len;
+            ctxt->xpathCtxt->proximityPosition = pos;
+            /*
+             * If the node is in a Value Tree we cannot
+             * cache it !
+             */
+            if ((!isRVT) && (node->doc != NULL) &&
+                (nocache == 0)) {
+                XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node;
+                XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos;
+                XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = len;
+            }
+        }
+    } else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) &&
+               (node->type == XML_ELEMENT_NODE)) {
+        xmlNodePtr previous;
+        int nocache = 0;
+
+        previous = (xmlNodePtr)
+            XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
+        if ((previous != NULL) &&
+            (previous->parent == node->parent)) {
+            /*
+             * just walk back to adjust the index
+             */
+            int indx = 0;
+            xmlNodePtr sibling = node;
+
+            while (sibling != NULL) {
+                if (sibling == previous)
+                    break;
+                if (sibling->type == XML_ELEMENT_NODE)
+                    indx++;
+                sibling = sibling->prev;
+            }
+            if (sibling == NULL) {
+                /* hum going backward in document order ... */
+                indx = 0;
+                sibling = node;
+                while (sibling != NULL) {
+                    if (sibling == previous)
+                        break;
+                    if (sibling->type == XML_ELEMENT_NODE)
+                        indx--;
+                    sibling = sibling->next;
+                }
+            }
+            if (sibling != NULL) {
+                pos = XSLT_RUNTIME_EXTRA(ctxt,
+                    sel->indexExtra, ival) + indx;
+                /*
+                 * If the node is in a Value Tree we cannot
+                 * cache it !
+                 */
+                if ((node->doc != NULL) && !isRVT) {
+                    len = XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival);
+                    XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node;
+                    XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos;
+                }
+            } else
+                pos = 0;
+        } else {
+            /*
+             * recompute the index
+             */
+            xmlNodePtr parent = node->parent;
+            xmlNodePtr siblings = NULL;
+
+            if (parent) siblings = parent->children;
+
+            while (siblings != NULL) {
+                if (siblings->type == XML_ELEMENT_NODE) {
+                    len++;
+                    if (siblings == node) {
+                        pos = len;
+                    }
+                }
+                siblings = siblings->next;
+            }
+            if ((parent == NULL) || (node->doc == NULL))
+                nocache = 1;
+            else {
+                while (parent->parent != NULL)
+                    parent = parent->parent;
+                if (((parent->type != XML_DOCUMENT_NODE) &&
+                     (parent->type != XML_HTML_DOCUMENT_NODE)) ||
+                     (parent != (xmlNodePtr) node->doc))
+                    nocache = 1;
+            }
+        }
+        if (pos != 0) {
+            ctxt->xpathCtxt->contextSize = len;
+            ctxt->xpathCtxt->proximityPosition = pos;
+            /*
+             * If the node is in a Value Tree we cannot
+             * cache it !
+             */
+            if ((node->doc != NULL) && (nocache == 0) && !isRVT) {
+                XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = node;
+                XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = pos;
+                XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) = len;
+            }
+        }
+    }
+
+    oldNode = ctxt->node;
+    ctxt->node = node;
+
+    match = xsltEvalXPathPredicate(ctxt, step->comp, comp->nsList, comp->nsNr);
+
+    if (pos != 0) {
+        ctxt->xpathCtxt->contextSize = oldCS;
+        ctxt->xpathCtxt->proximityPosition = oldCP;
+    }
+    ctxt->node = oldNode;
+
+    return match;
+}
+
 /**
  * xsltTestCompMatch:
  * @ctxt:  a XSLT process context
@@ -615,9 +892,10 @@ xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
  */
 static int
 xsltTestCompMatch(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
-                 xmlNodePtr node, const xmlChar *mode,
+                 xmlNodePtr matchNode, const xmlChar *mode,
                  const xmlChar *modeURI) {
     int i;
+    xmlNodePtr node = matchNode;
     xsltStepOpPtr step, sel = NULL;
     xsltStepStates states = {0, 0, NULL}; /* // may require backtrack */
 
@@ -835,14 +1113,9 @@ restart:
                    goto rollback;
                break;
            case XSLT_OP_PREDICATE: {
-               xmlNodePtr oldNode;
-               xmlDocPtr doc;
-               int oldCS, oldCP;
-               int pos = 0, len = 0;
-               int isRVT;
-
                /*
-                * when there is cascading XSLT_OP_PREDICATE, then use a
+                * When there is cascading XSLT_OP_PREDICATE or a predicate
+                * after an op which hasn't been optimized yet, then use a
                 * direct computation approach. It's not done directly
                 * at the beginning of the routine to filter out as much
                 * as possible this costly computation.
@@ -852,278 +1125,14 @@ restart:
                        /* Free the rollback states */
                        xmlFree(states.states);
                    }
-                   return(xsltTestCompMatchDirect(ctxt, comp, node,
+                   return(xsltTestCompMatchDirect(ctxt, comp, matchNode,
                                                   comp->nsList, comp->nsNr));
                }
 
-               doc = node->doc;
-               if (XSLT_IS_RES_TREE_FRAG(doc))
-                   isRVT = 1;
-               else
-                   isRVT = 0;
-
-               /*
-                * Depending on the last selection, one may need to
-                * recompute contextSize and proximityPosition.
-                */
-               oldCS = ctxt->xpathCtxt->contextSize;
-               oldCP = ctxt->xpathCtxt->proximityPosition;
-               if ((sel != NULL) &&
-                   (sel->op == XSLT_OP_ELEM) &&
-                   (sel->value != NULL) &&
-                   (node->type == XML_ELEMENT_NODE) &&
-                   (node->parent != NULL)) {
-                   xmlNodePtr previous;
-                   int nocache = 0;
-
-                   previous = (xmlNodePtr)
-                       XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
-                   if ((previous != NULL) &&
-                       (previous->parent == node->parent)) {
-                       /*
-                        * just walk back to adjust the index
-                        */
-                       int indx = 0;
-                       xmlNodePtr sibling = node;
-
-                       while (sibling != NULL) {
-                           if (sibling == previous)
-                               break;
-                           if ((sibling->type == XML_ELEMENT_NODE) &&
-                               (previous->name != NULL) &&
-                               (sibling->name != NULL) &&
-                               (previous->name[0] == sibling->name[0]) &&
-                               (xmlStrEqual(previous->name, sibling->name)))
-                           {
-                               if ((sel->value2 == NULL) ||
-                                   ((sibling->ns != NULL) &&
-                                    (xmlStrEqual(sel->value2,
-                                                 sibling->ns->href))))
-                                   indx++;
-                           }
-                           sibling = sibling->prev;
-                       }
-                       if (sibling == NULL) {
-                           /* hum going backward in document order ... */
-                           indx = 0;
-                           sibling = node;
-                           while (sibling != NULL) {
-                               if (sibling == previous)
-                                   break;
-                               if ((sibling->type == XML_ELEMENT_NODE) &&
-                                   (previous->name != NULL) &&
-                                   (sibling->name != NULL) &&
-                                   (previous->name[0] == sibling->name[0]) &&
-                                   (xmlStrEqual(previous->name, sibling->name)))
-                               {
-                                   if ((sel->value2 == NULL) ||
-                                       ((sibling->ns != NULL) &&
-                                       (xmlStrEqual(sel->value2,
-                                       sibling->ns->href))))
-                                   {
-                                       indx--;
-                                   }
-                               }
-                               sibling = sibling->next;
-                           }
-                       }
-                       if (sibling != NULL) {
-                           pos = XSLT_RUNTIME_EXTRA(ctxt,
-                                sel->indexExtra, ival) + indx;
-                           /*
-                            * If the node is in a Value Tree we need to
-                            * save len, but cannot cache the node!
-                            * (bugs 153137 and 158840)
-                            */
-                           if (node->doc != NULL) {
-                               len = XSLT_RUNTIME_EXTRA(ctxt,
-                                       sel->lenExtra, ival);
-                               if (!isRVT) {
-                                   XSLT_RUNTIME_EXTRA(ctxt,
-                                       sel->previousExtra, ptr) = node;
-                                   XSLT_RUNTIME_EXTRA(ctxt,
-                                       sel->indexExtra, ival) = pos;
-                               }
-                           }
-                       } else
-                           pos = 0;
-                   } else {
-                       /*
-                        * recompute the index
-                        */
-                       xmlNodePtr parent = node->parent;
-                       xmlNodePtr siblings = NULL;
-
-                        if (parent) siblings = parent->children;
-
-                       while (siblings != NULL) {
-                           if (siblings->type == XML_ELEMENT_NODE) {
-                               if (siblings == node) {
-                                   len++;
-                                   pos = len;
-                               } else if ((node->name != NULL) &&
-                                          (siblings->name != NULL) &&
-                                   (node->name[0] == siblings->name[0]) &&
-                                   (xmlStrEqual(node->name, siblings->name))) {
-                                   if ((sel->value2 == NULL) ||
-                                       ((siblings->ns != NULL) &&
-                                        (xmlStrEqual(sel->value2,
-                                                     siblings->ns->href))))
-                                       len++;
-                               }
-                           }
-                           siblings = siblings->next;
-                       }
-                       if ((parent == NULL) || (node->doc == NULL))
-                           nocache = 1;
-                       else {
-                           while (parent->parent != NULL)
-                               parent = parent->parent;
-                           if (((parent->type != XML_DOCUMENT_NODE) &&
-                                (parent->type != XML_HTML_DOCUMENT_NODE)) ||
-                                (parent != (xmlNodePtr) node->doc))
-                               nocache = 1;
-                       }
-                   }
-                   if (pos != 0) {
-                       ctxt->xpathCtxt->contextSize = len;
-                       ctxt->xpathCtxt->proximityPosition = pos;
-                       /*
-                        * If the node is in a Value Tree we cannot
-                        * cache it !
-                        */
-                       if ((!isRVT) && (node->doc != NULL) &&
-                           (nocache == 0)) {
-                           XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) =
-                               node;
-                           XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) =
-                               pos;
-                           XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) =
-                               len;
-                       }
-                   }
-               } else if ((sel != NULL) && (sel->op == XSLT_OP_ALL) &&
-                          (node->type == XML_ELEMENT_NODE)) {
-                   xmlNodePtr previous;
-                   int nocache = 0;
-
-                   previous = (xmlNodePtr)
-                       XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr);
-                   if ((previous != NULL) &&
-                       (previous->parent == node->parent)) {
-                       /*
-                        * just walk back to adjust the index
-                        */
-                       int indx = 0;
-                       xmlNodePtr sibling = node;
-
-                       while (sibling != NULL) {
-                           if (sibling == previous)
-                               break;
-                           if (sibling->type == XML_ELEMENT_NODE)
-                               indx++;
-                           sibling = sibling->prev;
-                       }
-                       if (sibling == NULL) {
-                           /* hum going backward in document order ... */
-                           indx = 0;
-                           sibling = node;
-                           while (sibling != NULL) {
-                               if (sibling == previous)
-                                   break;
-                               if (sibling->type == XML_ELEMENT_NODE)
-                                   indx--;
-                               sibling = sibling->next;
-                           }
-                       }
-                       if (sibling != NULL) {
-                           pos = XSLT_RUNTIME_EXTRA(ctxt,
-                                sel->indexExtra, ival) + indx;
-                           /*
-                            * If the node is in a Value Tree we cannot
-                            * cache it !
-                            */
-                           if ((node->doc != NULL) && !isRVT) {
-                               len = XSLT_RUNTIME_EXTRA(ctxt,
-                                       sel->lenExtra, ival);
-                               XSLT_RUNTIME_EXTRA(ctxt,
-                                       sel->previousExtra, ptr) = node;
-                               XSLT_RUNTIME_EXTRA(ctxt,
-                                       sel->indexExtra, ival) = pos;
-                           }
-                       } else
-                           pos = 0;
-                   } else {
-                       /*
-                        * recompute the index
-                        */
-                       xmlNodePtr parent = node->parent;
-                       xmlNodePtr siblings = NULL;
-
-                        if (parent) siblings = parent->children;
-
-                       while (siblings != NULL) {
-                           if (siblings->type == XML_ELEMENT_NODE) {
-                               len++;
-                               if (siblings == node) {
-                                   pos = len;
-                               }
-                           }
-                           siblings = siblings->next;
-                       }
-                       if ((parent == NULL) || (node->doc == NULL))
-                           nocache = 1;
-                       else {
-                           while (parent->parent != NULL)
-                               parent = parent->parent;
-                           if (((parent->type != XML_DOCUMENT_NODE) &&
-                                (parent->type != XML_HTML_DOCUMENT_NODE)) ||
-                                (parent != (xmlNodePtr) node->doc))
-                               nocache = 1;
-                       }
-                   }
-                   if (pos != 0) {
-                       ctxt->xpathCtxt->contextSize = len;
-                       ctxt->xpathCtxt->proximityPosition = pos;
-                       /*
-                        * If the node is in a Value Tree we cannot
-                        * cache it !
-                        */
-                       if ((node->doc != NULL) && (nocache == 0) && !isRVT) {
-                           XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) =
-                               node;
-                           XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) =
-                               pos;
-                           XSLT_RUNTIME_EXTRA(ctxt, sel->lenExtra, ival) =
-                               len;
-                       }
-                   }
-               }
-               oldNode = ctxt->node;
-               ctxt->node = node;
-
-               if (step->value == NULL)
-                   goto wrong_index;
-               if (step->comp == NULL)
-                   goto wrong_index;
-
-               if (!xsltEvalXPathPredicate(ctxt, step->comp, comp->nsList,
-                                           comp->nsNr))
-                   goto wrong_index;
+               if (!xsltTestPredicateMatch(ctxt, comp, node, step, sel))
+                   goto rollback;
 
-               if (pos != 0) {
-                   ctxt->xpathCtxt->contextSize = oldCS;
-                   ctxt->xpathCtxt->proximityPosition = oldCP;
-               }
-               ctxt->node = oldNode;
                break;
-wrong_index:
-               if (pos != 0) {
-                   ctxt->xpathCtxt->contextSize = oldCS;
-                   ctxt->xpathCtxt->proximityPosition = oldCP;
-               }
-               ctxt->node = oldNode;
-               goto rollback;
            }
             case XSLT_OP_PI:
                if (node->type != XML_PI_NODE)
@@ -1405,6 +1414,7 @@ xsltCompileIdKeyPattern(xsltParserContextPtr ctxt, xmlChar *name,
        if (CUR != ',') {
            xsltTransformError(NULL, NULL, NULL,
                    "xsltCompileIdKeyPattern : , expected\n");
+           xmlFree(lit);
            ctxt->error = 1;
            return;
        }
@@ -2061,9 +2071,34 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
     const xmlChar *name = NULL;
     float priority;              /* the priority */
 
-    if ((style == NULL) || (cur == NULL) || (cur->match == NULL))
+    if ((style == NULL) || (cur == NULL))
        return(-1);
 
+    /* Register named template */
+    if (cur->name != NULL) {
+        if (style->namedTemplates == NULL) {
+            style->namedTemplates = xmlHashCreate(10);
+            if (style->namedTemplates == NULL)
+                return(-1);
+        }
+        else {
+            void *dup = xmlHashLookup2(style->namedTemplates, cur->name,
+                                       cur->nameURI);
+            if (dup != NULL) {
+                xsltTransformError(NULL, style, cur->elem,
+                                   "xsl:template: error duplicate name '%s'\n",
+                                   cur->name);
+                style->errors++;
+                return(-1);
+            }
+        }
+
+        xmlHashAddEntry2(style->namedTemplates, cur->name, cur->nameURI, cur);
+    }
+
+    if (cur->match == NULL)
+       return(0);
+
     priority = cur->priority;
     pat = xsltCompilePatternInternal(cur->match, style->doc, cur->elem,
                    style, NULL, 1);
@@ -2533,5 +2568,7 @@ xsltFreeTemplateHashes(xsltStylesheetPtr style) {
         xsltFreeCompMatchList(style->piMatch);
     if (style->commentMatch != NULL)
         xsltFreeCompMatchList(style->commentMatch);
+    if (style->namedTemplates != NULL)
+        xmlHashFree(style->namedTemplates, NULL);
 }
 
index 5675f63..d47aa29 100644 (file)
@@ -925,6 +925,8 @@ xsltElementComp(xsltStylesheetPtr style, xmlNodePtr inst) {
 #ifdef XSLT_REFACTORED
                    comp->nsPrefix = prefix;
                    comp->name = name;
+#else
+                    (void)name; /* Suppress unused variable warning. */
 #endif
                } else if (prefix != NULL) {
                    xsltTransformError(NULL, style, inst,
@@ -1050,6 +1052,8 @@ xsltAttributeComp(xsltStylesheetPtr style, xmlNodePtr inst) {
 #ifdef XSLT_REFACTORED
                        comp->nsPrefix = prefix;
                        comp->name = name;
+#else
+                        (void)name; /* Suppress unused variable warning. */
 #endif
                    } else {
                        xsltTransformError(NULL, style, inst,
@@ -1277,7 +1281,8 @@ xsltGetQNameProperty(xsltStylesheetPtr style, xmlNodePtr inst,
            if (prop == NULL) {
                style->errors++;
            } else {
-               *localName = prop;
+               if (localName)
+                   *localName = prop;
                if (hasProp)
                    *hasProp = 1;
                if (URI != NULL) {
@@ -2221,7 +2226,8 @@ xsltStylePreCompute(xsltStylesheetPtr style, xmlNodePtr inst) {
        } else if (IS_XSLT_NAME(inst, "attribute")) {
            xmlNodePtr parent = inst->parent;
 
-           if ((parent == NULL) || (parent->ns == NULL) ||
+           if ((parent == NULL) ||
+               (parent->type != XML_ELEMENT_NODE) || (parent->ns == NULL) ||
                ((parent->ns != inst->ns) &&
                 (!xmlStrEqual(parent->ns->href, inst->ns->href))) ||
                (!xmlStrEqual(parent->name, BAD_CAST "attribute-set"))) {
index b6d9984..45ceaf1 100644 (file)
@@ -305,6 +305,104 @@ profCallgraphAdd(xsltTemplatePtr templ, xsltTemplatePtr parent)
     }
 }
 
+/**
+ * xsltPreCompEval:
+ * @ctxt: transform context
+ * @node: context node
+ * @comp: precompiled expression
+ *
+ * Evaluate a precompiled XPath expression.
+ */
+static xmlXPathObjectPtr
+xsltPreCompEval(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                xsltStylePreCompPtr comp) {
+    xmlXPathObjectPtr res;
+    xmlXPathContextPtr xpctxt;
+    xmlNodePtr oldXPContextNode;
+    xmlNsPtr *oldXPNamespaces;
+    int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
+
+    xpctxt = ctxt->xpathCtxt;
+    oldXPContextNode = xpctxt->node;
+    oldXPProximityPosition = xpctxt->proximityPosition;
+    oldXPContextSize = xpctxt->contextSize;
+    oldXPNsNr = xpctxt->nsNr;
+    oldXPNamespaces = xpctxt->namespaces;
+
+    xpctxt->node = node;
+#ifdef XSLT_REFACTORED
+    if (comp->inScopeNs != NULL) {
+        xpctxt->namespaces = comp->inScopeNs->list;
+        xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+    } else {
+        xpctxt->namespaces = NULL;
+        xpctxt->nsNr = 0;
+    }
+#else
+    xpctxt->namespaces = comp->nsList;
+    xpctxt->nsNr = comp->nsNr;
+#endif
+
+    res = xmlXPathCompiledEval(comp->comp, xpctxt);
+
+    xpctxt->node = oldXPContextNode;
+    xpctxt->proximityPosition = oldXPProximityPosition;
+    xpctxt->contextSize = oldXPContextSize;
+    xpctxt->nsNr = oldXPNsNr;
+    xpctxt->namespaces = oldXPNamespaces;
+
+    return(res);
+}
+
+/**
+ * xsltPreCompEvalToBoolean:
+ * @ctxt: transform context
+ * @node: context node
+ * @comp: precompiled expression
+ *
+ * Evaluate a precompiled XPath expression as boolean.
+ */
+static int
+xsltPreCompEvalToBoolean(xsltTransformContextPtr ctxt, xmlNodePtr node,
+                         xsltStylePreCompPtr comp) {
+    int res;
+    xmlXPathContextPtr xpctxt;
+    xmlNodePtr oldXPContextNode;
+    xmlNsPtr *oldXPNamespaces;
+    int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
+
+    xpctxt = ctxt->xpathCtxt;
+    oldXPContextNode = xpctxt->node;
+    oldXPProximityPosition = xpctxt->proximityPosition;
+    oldXPContextSize = xpctxt->contextSize;
+    oldXPNsNr = xpctxt->nsNr;
+    oldXPNamespaces = xpctxt->namespaces;
+
+    xpctxt->node = node;
+#ifdef XSLT_REFACTORED
+    if (comp->inScopeNs != NULL) {
+        xpctxt->namespaces = comp->inScopeNs->list;
+        xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+    } else {
+        xpctxt->namespaces = NULL;
+        xpctxt->nsNr = 0;
+    }
+#else
+    xpctxt->namespaces = comp->nsList;
+    xpctxt->nsNr = comp->nsNr;
+#endif
+
+    res = xmlXPathCompiledEvalToBoolean(comp->comp, xpctxt);
+
+    xpctxt->node = oldXPContextNode;
+    xpctxt->proximityPosition = oldXPProximityPosition;
+    xpctxt->contextSize = oldXPContextSize;
+    xpctxt->nsNr = oldXPNsNr;
+    xpctxt->namespaces = oldXPNamespaces;
+
+    return(res);
+}
+
 /************************************************************************
  *                                                                     *
  *                     XInclude default settings                       *
@@ -798,9 +896,9 @@ xsltCopyTextString(xsltTransformContextPtr ctxt, xmlNodePtr target,
        }
        copy = xmlNewTextLen(string, len);
     }
+    if (copy != NULL && target != NULL)
+       copy = xsltAddChild(target, copy);
     if (copy != NULL) {
-       if (target != NULL)
-           copy = xsltAddChild(target, copy);
        ctxt->lasttext = copy->content;
        ctxt->lasttsize = len;
        ctxt->lasttuse = len;
@@ -1189,6 +1287,11 @@ xsltShallowCopyElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
     if (copy != NULL) {
        copy->doc = ctxt->output;
        copy = xsltAddChild(insert, copy);
+        if (copy == NULL) {
+             xsltTransformError(ctxt, NULL, node,
+                "xsltShallowCopyElem: copy failed\n");
+             return (copy);
+        }
 
        if (node->type == XML_ELEMENT_NODE) {
            /*
@@ -1522,6 +1625,11 @@ xsltCopyTreeInternal(xsltTransformContextPtr ctxt,
     if (copy != NULL) {
        copy->doc = ctxt->output;
        copy = xsltAddChild(insert, copy);
+        if (copy == NULL) {
+            xsltTransformError(ctxt, NULL, invocNode,
+            "xsltCopyTreeInternal: Copying of '%s' failed.\n", node->name);
+            return (copy);
+        }
        /*
         * The node may have been coalesced into another text node.
         */
@@ -3573,8 +3681,7 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
            xmlDictReference(res->dict);
        } else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
            xsltTransformError(ctxt, NULL, inst,
-            "xsltDocumentElem: unsupported method xhtml\n",
-                            style->method);
+            "xsltDocumentElem: unsupported method xhtml\n");
            ctxt->type = XSLT_OUTPUT_HTML;
            res = htmlNewDocNoDtD(doctypeSystem, doctypePublic);
            if (res == NULL)
@@ -3594,8 +3701,8 @@ xsltDocumentElem(xsltTransformContextPtr ctxt, xmlNodePtr node,
 #endif
        } else {
            xsltTransformError(ctxt, NULL, inst,
-                            "xsltDocumentElem: unsupported method %s\n",
-                            style->method);
+                            "xsltDocumentElem: unsupported method (%s)\n",
+                            method);
            goto error;
        }
     } else {
@@ -4001,6 +4108,11 @@ xsltElement(xsltTransformContextPtr ctxt, xmlNodePtr node,
        return;
     }
     copy = xsltAddChild(ctxt->insert, copy);
+    if (copy == NULL) {
+        xsltTransformError(ctxt, NULL, inst,
+            "xsl:element : xsltAddChild failed\n");
+        return;
+    }
 
     /*
     * Namespace
@@ -4254,11 +4366,6 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
     xmlXPathObjectPtr res = NULL;
     xmlNodeSetPtr list = NULL;
     int i;
-    xmlDocPtr oldXPContextDoc;
-    xmlNsPtr *oldXPNamespaces;
-    xmlNodePtr oldXPContextNode;
-    int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
-    xmlXPathContextPtr xpctxt;
 
     if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
        return;
@@ -4294,42 +4401,7 @@ xsltCopyOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
     /*
     * Evaluate the "select" expression.
     */
-    xpctxt = ctxt->xpathCtxt;
-    oldXPContextDoc = xpctxt->doc;
-    oldXPContextNode = xpctxt->node;
-    oldXPProximityPosition = xpctxt->proximityPosition;
-    oldXPContextSize = xpctxt->contextSize;
-    oldXPNsNr = xpctxt->nsNr;
-    oldXPNamespaces = xpctxt->namespaces;
-
-    xpctxt->node = node;
-    if (comp != NULL) {
-
-#ifdef XSLT_REFACTORED
-       if (comp->inScopeNs != NULL) {
-           xpctxt->namespaces = comp->inScopeNs->list;
-           xpctxt->nsNr = comp->inScopeNs->xpathNumber;
-       } else {
-           xpctxt->namespaces = NULL;
-           xpctxt->nsNr = 0;
-       }
-#else
-       xpctxt->namespaces = comp->nsList;
-       xpctxt->nsNr = comp->nsNr;
-#endif
-    } else {
-       xpctxt->namespaces = NULL;
-       xpctxt->nsNr = 0;
-    }
-
-    res = xmlXPathCompiledEval(comp->comp, xpctxt);
-
-    xpctxt->doc = oldXPContextDoc;
-    xpctxt->node = oldXPContextNode;
-    xpctxt->contextSize = oldXPContextSize;
-    xpctxt->proximityPosition = oldXPProximityPosition;
-    xpctxt->nsNr = oldXPNsNr;
-    xpctxt->namespaces = oldXPNamespaces;
+    res = xsltPreCompEval(ctxt, node, comp);
 
     if (res != NULL) {
        if (res->type == XPATH_NODESET) {
@@ -4439,11 +4511,6 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
 #endif
     xmlXPathObjectPtr res = NULL;
     xmlChar *value = NULL;
-    xmlDocPtr oldXPContextDoc;
-    xmlNsPtr *oldXPNamespaces;
-    xmlNodePtr oldXPContextNode;
-    int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
-    xmlXPathContextPtr xpctxt;
 
     if ((ctxt == NULL) || (node == NULL) || (inst == NULL))
        return;
@@ -4460,42 +4527,7 @@ xsltValueOf(xsltTransformContextPtr ctxt, xmlNodePtr node,
         "xsltValueOf: select %s\n", comp->select));
 #endif
 
-    xpctxt = ctxt->xpathCtxt;
-    oldXPContextDoc = xpctxt->doc;
-    oldXPContextNode = xpctxt->node;
-    oldXPProximityPosition = xpctxt->proximityPosition;
-    oldXPContextSize = xpctxt->contextSize;
-    oldXPNsNr = xpctxt->nsNr;
-    oldXPNamespaces = xpctxt->namespaces;
-
-    xpctxt->node = node;
-    if (comp != NULL) {
-
-#ifdef XSLT_REFACTORED
-       if (comp->inScopeNs != NULL) {
-           xpctxt->namespaces = comp->inScopeNs->list;
-           xpctxt->nsNr = comp->inScopeNs->xpathNumber;
-       } else {
-           xpctxt->namespaces = NULL;
-           xpctxt->nsNr = 0;
-       }
-#else
-       xpctxt->namespaces = comp->nsList;
-       xpctxt->nsNr = comp->nsNr;
-#endif
-    } else {
-       xpctxt->namespaces = NULL;
-       xpctxt->nsNr = 0;
-    }
-
-    res = xmlXPathCompiledEval(comp->comp, xpctxt);
-
-    xpctxt->doc = oldXPContextDoc;
-    xpctxt->node = oldXPContextNode;
-    xpctxt->contextSize = oldXPContextSize;
-    xpctxt->proximityPosition = oldXPProximityPosition;
-    xpctxt->nsNr = oldXPNsNr;
-    xpctxt->namespaces = oldXPNamespaces;
+    res = xsltPreCompEval(ctxt, node, comp);
 
     /*
     * Cast the XPath object to string.
@@ -4551,6 +4583,10 @@ xsltNumber(xsltTransformContextPtr ctxt, xmlNodePtr node,
 #else
     xsltStylePreCompPtr comp = castedComp;
 #endif
+    xmlXPathContextPtr xpctxt;
+    xmlNsPtr *oldXPNamespaces;
+    int oldXPNsNr;
+
     if (comp == NULL) {
        xsltTransformError(ctxt, NULL, inst,
             "xsl:number : compilation failed\n");
@@ -4563,7 +4599,27 @@ xsltNumber(xsltTransformContextPtr ctxt, xmlNodePtr node,
     comp->numdata.doc = inst->doc;
     comp->numdata.node = inst;
 
+    xpctxt = ctxt->xpathCtxt;
+    oldXPNsNr = xpctxt->nsNr;
+    oldXPNamespaces = xpctxt->namespaces;
+
+#ifdef XSLT_REFACTORED
+    if (comp->inScopeNs != NULL) {
+        xpctxt->namespaces = comp->inScopeNs->list;
+        xpctxt->nsNr = comp->inScopeNs->xpathNumber;
+    } else {
+        xpctxt->namespaces = NULL;
+        xpctxt->nsNr = 0;
+    }
+#else
+    xpctxt->namespaces = comp->nsList;
+    xpctxt->nsNr = comp->nsNr;
+#endif
+
     xsltNumberFormat(ctxt, &comp->numdata, node);
+
+    xpctxt->nsNr = oldXPNsNr;
+    xpctxt->namespaces = oldXPNamespaces;
 }
 
 /**
@@ -4757,12 +4813,11 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
     xmlNodePtr cur, delNode = NULL, oldContextNode;
     xmlNodeSetPtr list = NULL, oldList;
     xsltStackElemPtr withParams = NULL;
-    int oldXPProximityPosition, oldXPContextSize, oldXPNsNr;
+    int oldXPProximityPosition, oldXPContextSize;
     const xmlChar *oldMode, *oldModeURI;
     xmlDocPtr oldXPDoc;
     xsltDocumentPtr oldDocInfo;
     xmlXPathContextPtr xpctxt;
-    xmlNsPtr *oldXPNamespaces;
 
     if (comp == NULL) {
        xsltTransformError(ctxt, NULL, inst,
@@ -4796,8 +4851,6 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
     oldXPContextSize = xpctxt->contextSize;
     oldXPProximityPosition = xpctxt->proximityPosition;
     oldXPDoc = xpctxt->doc;
-    oldXPNsNr = xpctxt->nsNr;
-    oldXPNamespaces = xpctxt->namespaces;
 
     /*
     * Set up contexts.
@@ -4818,26 +4871,8 @@ xsltApplyTemplates(xsltTransformContextPtr ctxt, xmlNodePtr node,
             "xsltApplyTemplates: select %s\n", comp->select));
 #endif
 
-       /*
-       * Set up XPath.
-       */
-       xpctxt->node = node; /* Set the "context node" */
-#ifdef XSLT_REFACTORED
-       if (comp->inScopeNs != NULL) {
-           xpctxt->namespaces = comp->inScopeNs->list;
-           xpctxt->nsNr = comp->inScopeNs->xpathNumber;
-       } else {
-           xpctxt->namespaces = NULL;
-           xpctxt->nsNr = 0;
-       }
-#else
-       xpctxt->namespaces = comp->nsList;
-       xpctxt->nsNr = comp->nsNr;
-#endif
-       res = xmlXPathCompiledEval(comp->comp, xpctxt);
+       res = xsltPreCompEval(ctxt, node, comp);
 
-       xpctxt->contextSize = oldXPContextSize;
-       xpctxt->proximityPosition = oldXPProximityPosition;
        if (res != NULL) {
            if (res->type == XPATH_NODESET) {
                list = res->nodesetval; /* consume the node set */
@@ -5120,8 +5155,6 @@ error:
     /*
     * Restore context states.
     */
-    xpctxt->nsNr = oldXPNsNr;
-    xpctxt->namespaces = oldXPNamespaces;
     xpctxt->doc = oldXPDoc;
     xpctxt->contextSize = oldXPContextSize;
     xpctxt->proximityPosition = oldXPProximityPosition;
@@ -5177,12 +5210,6 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
 
     {
        int testRes = 0, res = 0;
-       xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
-       xmlDocPtr oldXPContextDoc = xpctxt->doc;
-       int oldXPProximityPosition = xpctxt->proximityPosition;
-       int oldXPContextSize = xpctxt->contextSize;
-       xmlNsPtr *oldXPNamespaces = xpctxt->namespaces;
-       int oldXPNsNr = xpctxt->nsNr;
 
 #ifdef XSLT_REFACTORED
        xsltStyleItemWhenPtr wcomp = NULL;
@@ -5219,27 +5246,8 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
                "xsltChoose: test %s\n", wcomp->test));
 #endif
 
-           xpctxt->node = contextNode;
-           xpctxt->doc = oldXPContextDoc;
-           xpctxt->proximityPosition = oldXPProximityPosition;
-           xpctxt->contextSize = oldXPContextSize;
-
-#ifdef XSLT_REFACTORED
-           if (wcomp->inScopeNs != NULL) {
-               xpctxt->namespaces = wcomp->inScopeNs->list;
-               xpctxt->nsNr = wcomp->inScopeNs->xpathNumber;
-           } else {
-               xpctxt->namespaces = NULL;
-               xpctxt->nsNr = 0;
-           }
-#else
-           xpctxt->namespaces = wcomp->nsList;
-           xpctxt->nsNr = wcomp->nsNr;
-#endif
-
-
 #ifdef XSLT_FAST_IF
-           res = xmlXPathCompiledEvalToBoolean(wcomp->comp, xpctxt);
+           res = xsltPreCompEvalToBoolean(ctxt, contextNode, wcomp);
 
            if (res == -1) {
                ctxt->state = XSLT_STATE_STOPPED;
@@ -5249,7 +5257,7 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
 
 #else /* XSLT_FAST_IF */
 
-           res = xmlXPathCompiledEval(wcomp->comp, xpctxt);
+           res = xsltPreCompEval(ctxt, cotextNode, wcomp);
 
            if (res != NULL) {
                if (res->type != XPATH_BOOLEAN)
@@ -5298,22 +5306,10 @@ xsltChoose(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
 #endif
            goto test_is_true;
        }
-       xpctxt->node = contextNode;
-       xpctxt->doc = oldXPContextDoc;
-       xpctxt->proximityPosition = oldXPProximityPosition;
-       xpctxt->contextSize = oldXPContextSize;
-       xpctxt->namespaces = oldXPNamespaces;
-       xpctxt->nsNr = oldXPNsNr;
        goto exit;
 
 test_is_true:
 
-       xpctxt->node = contextNode;
-       xpctxt->doc = oldXPContextDoc;
-       xpctxt->proximityPosition = oldXPProximityPosition;
-       xpctxt->contextSize = oldXPContextSize;
-       xpctxt->namespaces = oldXPNamespaces;
-       xpctxt->nsNr = oldXPNsNr;
        goto process_sequence;
     }
 
@@ -5367,38 +5363,9 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
 
 #ifdef XSLT_FAST_IF
     {
-       xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
-       xmlDocPtr oldXPContextDoc = xpctxt->doc;
-       xmlNsPtr *oldXPNamespaces = xpctxt->namespaces;
-       xmlNodePtr oldXPContextNode = xpctxt->node;
-       int oldXPProximityPosition = xpctxt->proximityPosition;
-       int oldXPContextSize = xpctxt->contextSize;
-       int oldXPNsNr = xpctxt->nsNr;
        xmlDocPtr oldLocalFragmentTop = ctxt->localRVT;
 
-       xpctxt->node = contextNode;
-       if (comp != NULL) {
-
-#ifdef XSLT_REFACTORED
-           if (comp->inScopeNs != NULL) {
-               xpctxt->namespaces = comp->inScopeNs->list;
-               xpctxt->nsNr = comp->inScopeNs->xpathNumber;
-           } else {
-               xpctxt->namespaces = NULL;
-               xpctxt->nsNr = 0;
-           }
-#else
-           xpctxt->namespaces = comp->nsList;
-           xpctxt->nsNr = comp->nsNr;
-#endif
-       } else {
-           xpctxt->namespaces = NULL;
-           xpctxt->nsNr = 0;
-       }
-       /*
-       * This XPath function is optimized for boolean results.
-       */
-       res = xmlXPathCompiledEvalToBoolean(comp->comp, xpctxt);
+       res = xsltPreCompEvalToBoolean(ctxt, contextNode, comp);
 
        /*
        * Cleanup fragments created during evaluation of the
@@ -5406,13 +5373,6 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
        */
        if (oldLocalFragmentTop != ctxt->localRVT)
            xsltReleaseLocalRVTs(ctxt, oldLocalFragmentTop);
-
-       xpctxt->doc = oldXPContextDoc;
-       xpctxt->node = oldXPContextNode;
-       xpctxt->contextSize = oldXPContextSize;
-       xpctxt->proximityPosition = oldXPProximityPosition;
-       xpctxt->nsNr = oldXPNsNr;
-       xpctxt->namespaces = oldXPNamespaces;
     }
 
 #ifdef WITH_XSLT_DEBUG_PROCESS
@@ -5434,51 +5394,10 @@ xsltIf(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
 
 #else /* XSLT_FAST_IF */
     {
-       xmlXPathObjectPtr xpobj = NULL;
        /*
        * OLD CODE:
        */
-       {
-           xmlXPathContextPtr xpctxt = ctxt->xpathCtxt;
-           xmlDocPtr oldXPContextDoc = xpctxt->doc;
-           xmlNsPtr *oldXPNamespaces = xpctxt->namespaces;
-           xmlNodePtr oldXPContextNode = xpctxt->node;
-           int oldXPProximityPosition = xpctxt->proximityPosition;
-           int oldXPContextSize = xpctxt->contextSize;
-           int oldXPNsNr = xpctxt->nsNr;
-
-           xpctxt->node = contextNode;
-           if (comp != NULL) {
-
-#ifdef XSLT_REFACTORED
-               if (comp->inScopeNs != NULL) {
-                   xpctxt->namespaces = comp->inScopeNs->list;
-                   xpctxt->nsNr = comp->inScopeNs->xpathNumber;
-               } else {
-                   xpctxt->namespaces = NULL;
-                   xpctxt->nsNr = 0;
-               }
-#else
-               xpctxt->namespaces = comp->nsList;
-               xpctxt->nsNr = comp->nsNr;
-#endif
-           } else {
-               xpctxt->namespaces = NULL;
-               xpctxt->nsNr = 0;
-           }
-
-           /*
-           * This XPath function is optimized for boolean results.
-           */
-           xpobj = xmlXPathCompiledEval(comp->comp, xpctxt);
-
-           xpctxt->doc = oldXPContextDoc;
-           xpctxt->node = oldXPContextNode;
-           xpctxt->contextSize = oldXPContextSize;
-           xpctxt->proximityPosition = oldXPProximityPosition;
-           xpctxt->nsNr = oldXPNsNr;
-           xpctxt->namespaces = oldXPNamespaces;
-       }
+       xmlXPathObjectPtr xpobj = xsltPreCompEval(ctxt, contextNode, comp);
        if (xpobj != NULL) {
            if (xpobj->type != XPATH_BOOLEAN)
                xpobj = xmlXPathConvertBoolean(xpobj);
@@ -5585,27 +5504,11 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
     oldXPDoc = xpctxt->doc;
     oldXPProximityPosition = xpctxt->proximityPosition;
     oldXPContextSize = xpctxt->contextSize;
-    /*
-    * Set up XPath.
-    */
-    xpctxt->node = contextNode;
-#ifdef XSLT_REFACTORED
-    if (comp->inScopeNs != NULL) {
-       xpctxt->namespaces = comp->inScopeNs->list;
-       xpctxt->nsNr = comp->inScopeNs->xpathNumber;
-    } else {
-       xpctxt->namespaces = NULL;
-       xpctxt->nsNr = 0;
-    }
-#else
-    xpctxt->namespaces = comp->nsList;
-    xpctxt->nsNr = comp->nsNr;
-#endif
 
     /*
     * Evaluate the 'select' expression.
     */
-    res = xmlXPathCompiledEval(comp->comp, ctxt->xpathCtxt);
+    res = xsltPreCompEval(ctxt, contextNode, comp);
 
     if (res != NULL) {
        if (res->type == XPATH_NODESET)
@@ -5635,13 +5538,6 @@ xsltForEach(xsltTransformContextPtr ctxt, xmlNodePtr contextNode,
        "xsltForEach: select evaluates to %d nodes\n", list->nodeNr));
 #endif
 
-    /*
-    * Restore XPath states for the "current node".
-    */
-    xpctxt->contextSize = oldXPContextSize;
-    xpctxt->proximityPosition = oldXPProximityPosition;
-    xpctxt->node = contextNode;
-
     /*
     * Set the list; this has to be done already here for xsltDoSortFunction().
     */
@@ -6043,8 +5939,7 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
 #endif
         } else if (xmlStrEqual(method, (const xmlChar *) "xhtml")) {
            xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
-               "xsltApplyStylesheetInternal: unsupported method xhtml, using html\n",
-               style->method);
+               "xsltApplyStylesheetInternal: unsupported method xhtml, using html\n");
             ctxt->type = XSLT_OUTPUT_HTML;
             res = htmlNewDoc(doctypeSystem, doctypePublic);
             if (res == NULL)
@@ -6070,8 +5965,8 @@ xsltApplyStylesheetInternal(xsltStylesheetPtr style, xmlDocPtr doc,
 #endif
         } else {
            xsltTransformError(ctxt, NULL, (xmlNodePtr) doc,
-               "xsltApplyStylesheetInternal: unsupported method %s\n",
-               style->method);
+               "xsltApplyStylesheetInternal: unsupported method (%s)\n",
+               method);
             goto error;
         }
     } else {
index 677d28f..fcd201d 100644 (file)
@@ -1424,21 +1424,35 @@ xsltProcessUserParamInternal(xsltTransformContextPtr ctxt,
     /*
      * Name lookup
      */
-
-    name = xsltSplitQName(ctxt->dict, name, &prefix);
     href = NULL;
-    if (prefix != NULL) {
-       xmlNsPtr ns;
 
-       ns = xmlSearchNs(style->doc, xmlDocGetRootElement(style->doc),
-                        prefix);
-       if (ns == NULL) {
-           xsltTransformError(ctxt, style, NULL,
-           "user param : no namespace bound to prefix %s\n", prefix);
-           href = NULL;
-       } else {
-           href = ns->href;
-       }
+    if (name[0] == '{') {
+        int len = 0;
+
+        while ((name[len] != 0) && (name[len] != '}')) len++;
+        if (name[len] == 0) {
+           xsltTransformError(ctxt, style, NULL,
+           "user param : malformed parameter name : %s\n", name);
+        } else {
+           href = xmlDictLookup(ctxt->dict, &name[1], len-1);
+           name = xmlDictLookup(ctxt->dict, &name[len + 1], -1);
+       }
+    }
+    else {
+        name = xsltSplitQName(ctxt->dict, name, &prefix);
+        if (prefix != NULL) {
+            xmlNsPtr ns;
+
+            ns = xmlSearchNs(style->doc, xmlDocGetRootElement(style->doc),
+                             prefix);
+            if (ns == NULL) {
+                xsltTransformError(ctxt, style, NULL,
+                "user param : no namespace bound to prefix %s\n", prefix);
+                href = NULL;
+            } else {
+                href = ns->href;
+            }
+        }
     }
 
     if (name == NULL)
index c299af9..d076c25 100644 (file)
@@ -3525,7 +3525,7 @@ xsltPrecomputeStylesheet(xsltStylesheetPtr style, xmlNodePtr cur)
            }
        } else if (cur->type == XML_TEXT_NODE) {
            if (IS_BLANK_NODE(cur)) {
-               if (xmlNodeGetSpacePreserve(cur) != 1) {
+               if (xmlNodeGetSpacePreserve(cur->parent) != 1) {
                    deleteNode = cur;
                }
            } else if ((cur->content != NULL) && (internalize) &&
@@ -5354,7 +5354,6 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
     prop = xmlGetNsProp(template, (const xmlChar *)"name", NULL);
     if (prop != NULL) {
         const xmlChar *URI;
-       xsltTemplatePtr cur;
 
        /*
        * TODO: Don't use xsltGetQNameURI().
@@ -5377,19 +5376,6 @@ xsltParseStylesheetTemplate(xsltStylesheetPtr style, xmlNodePtr template) {
                ret->nameURI = xmlDictLookup(style->dict, BAD_CAST URI, -1);
            else
                ret->nameURI = NULL;
-           cur = ret->next;
-           while (cur != NULL) {
-               if ((URI != NULL && xmlStrEqual(cur->name, ret->name) &&
-                               xmlStrEqual(cur->nameURI, URI) ) ||
-                   (URI == NULL && cur->nameURI == NULL &&
-                               xmlStrEqual(cur->name, ret->name))) {
-                   xsltTransformError(NULL, style, template,
-                       "xsl:template: error duplicate name '%s'\n", ret->name);
-                   style->errors++;
-                   goto error;
-               }
-               cur = cur->next;
-           }
        }
     }
 
index b4cac6d..6e4e328 100644 (file)
@@ -152,6 +152,17 @@ extern "C" {
 #define ATTRIBUTE_UNUSED
 #endif
 
+/**
+ * LIBXSLT_ATTR_FORMAT:
+ *
+ * This macro is used to indicate to GCC the parameters are printf-like
+ */
+#ifdef __GNUC__
+#define LIBXSLT_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
+#else
+#define LIBXSLT_ATTR_FORMAT(fmt,args)
+#endif
+
 /**
  * LIBXSLT_PUBLIC:
  *
index 0f904f6..53facee 100644 (file)
@@ -495,7 +495,7 @@ xsltMessage(xsltTransformContextPtr ctxt, xmlNodePtr node, xmlNodePtr inst) {
  *
  * Default handler for out of context error messages.
  */
-static void
+static void LIBXSLT_ATTR_FORMAT(2,3)
 xsltGenericErrorDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
     va_list args;
 
@@ -541,7 +541,7 @@ xsltSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler) {
  *
  * Default handler for out of context error messages.
  */
-static void
+static void LIBXSLT_ATTR_FORMAT(2,3)
 xsltGenericDebugDefaultFunc(void *ctx ATTRIBUTE_UNUSED, const char *msg, ...) {
     va_list args;
 
@@ -1939,7 +1939,7 @@ xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
     int nb, i,j,k,l;
     int max;
     int total;
-    long totalt;
+    unsigned long totalt;
     xsltTemplatePtr *templates;
     xsltStylesheetPtr style;
     xsltTemplatePtr templ1,templ2;
@@ -2052,7 +2052,7 @@ xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
 
     for (i = 0; i < nb; i++) {
         char ix_str[20], timep_str[20], times_str[20], timec_str[20], called_str[20];
-        int t;
+        unsigned long t;
 
         templ1 = templates[i];
         /* callers */
@@ -2063,9 +2063,9 @@ xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
                 break;
             }
             t=templ2?templ2->time:totalt;
-            sprintf(times_str,"%8.3f",(float)t/XSLT_TIMESTAMP_TICS_PER_SEC);
-            sprintf(timec_str,"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_SEC);
-            sprintf(called_str,"%6d/%d",
+            snprintf(times_str,sizeof(times_str),"%8.3f",(float)t/XSLT_TIMESTAMP_TICS_PER_SEC);
+            snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_SEC);
+            snprintf(called_str,sizeof(called_str),"%6d/%d",
                 templ1->templCountTab[j], /* number of times caller calls 'this' */
                 templ1->nbCalls);         /* total number of calls to 'this' */
 
@@ -2074,10 +2074,10 @@ xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
                 (templ2?(templ2->name?(char *)templ2->name:pretty_templ_match(templ2)):"-"),k);
         }
         /* this */
-        sprintf(ix_str,"[%d]",i);
-        sprintf(timep_str,"%6.2f",(float)templ1->time*100.0/totalt);
-        sprintf(times_str,"%8.3f",(float)templ1->time/XSLT_TIMESTAMP_TICS_PER_SEC);
-        sprintf(timec_str,"%8.3f",(float)childt[i]/XSLT_TIMESTAMP_TICS_PER_SEC);
+        snprintf(ix_str,sizeof(ix_str),"[%d]",i);
+        snprintf(timep_str,sizeof(timep_str),"%6.2f",(float)templ1->time*100.0/totalt);
+        snprintf(times_str,sizeof(times_str),"%8.3f",(float)templ1->time/XSLT_TIMESTAMP_TICS_PER_SEC);
+        snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[i]/XSLT_TIMESTAMP_TICS_PER_SEC);
         fprintf(output, "%-5s %-6s %-8s %-8s %6d     %s [%d]\n",
             ix_str, timep_str,times_str,timec_str,
             templ1->nbCalls,
@@ -2099,9 +2099,9 @@ xsltSaveProfiling(xsltTransformContextPtr ctxt, FILE *output) {
             templ2 = templates[k];
             for (l = 0; l < templ2->templNr; l++) {
                 if (templ2->templCalledTab[l] == templ1) {
-                    sprintf(times_str,"%8.3f",(float)templ2->time/XSLT_TIMESTAMP_TICS_PER_SEC);
-                    sprintf(timec_str,"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_SEC);
-                    sprintf(called_str,"%6d/%d",
+                    snprintf(times_str,sizeof(times_str),"%8.3f",(float)templ2->time/XSLT_TIMESTAMP_TICS_PER_SEC);
+                    snprintf(timec_str,sizeof(timec_str),"%8.3f",(float)childt[k]/XSLT_TIMESTAMP_TICS_PER_SEC);
+                    snprintf(called_str,sizeof(called_str),"%6d/%d",
                         templ2->templCountTab[l], /* number of times 'this' calls callee */
                         total);                   /* total number of calls from 'this' */
                     fprintf(output, "             %-8s %-8s %-12s     %s [%d]\n",
@@ -2221,19 +2221,19 @@ xsltGetProfileInformation(xsltTransformContextPtr ctxt)
 
     for (i = 0; i < nb; i++) {
         child = xmlNewChild(root, NULL, BAD_CAST "template", NULL);
-        sprintf(buf, "%d", i + 1);
+        snprintf(buf, sizeof(buf), "%d", i + 1);
         xmlSetProp(child, BAD_CAST "rank", BAD_CAST buf);
         xmlSetProp(child, BAD_CAST "match", BAD_CAST templates[i]->match);
         xmlSetProp(child, BAD_CAST "name", BAD_CAST templates[i]->name);
         xmlSetProp(child, BAD_CAST "mode", BAD_CAST templates[i]->mode);
 
-        sprintf(buf, "%d", templates[i]->nbCalls);
+        snprintf(buf, sizeof(buf), "%d", templates[i]->nbCalls);
         xmlSetProp(child, BAD_CAST "calls", BAD_CAST buf);
 
-        sprintf(buf, "%ld", templates[i]->time);
+        snprintf(buf, sizeof(buf), "%ld", templates[i]->time);
         xmlSetProp(child, BAD_CAST "time", BAD_CAST buf);
 
-        sprintf(buf, "%ld", templates[i]->time / templates[i]->nbCalls);
+        snprintf(buf, sizeof(buf), "%ld", templates[i]->time / templates[i]->nbCalls);
         xmlSetProp(child, BAD_CAST "average", BAD_CAST buf);
     };
 
index bba0ad8..cd26045 100644 (file)
@@ -47,7 +47,7 @@ Used Version: 2.9.4
 Website: http://xmlsoft.org | ftp://xmlsoft.org/libxml2/
 
 Title: Libxslt
-Used Version: 1.1.28
+Used Version: 1.1.29
 Website: http://xmlsoft.org
 
 Title: ZLib
index 95e8fe6..7123ace 100644 (file)
@@ -1639,6 +1639,8 @@ struct _xsltStylesheet {
      * Forwards-compatible processing
      */
     int forwards_compatible;
+
+    xmlHashTablePtr namedTemplates; /* hash table of named templates */
 };
 
 typedef struct _xsltTransformCache xsltTransformCache;
index a57b255..0b82bf7 100644 (file)
@@ -20,28 +20,28 @@ extern "C" {
  *
  * the version string like "1.2.3"
  */
-#define LIBXSLT_DOTTED_VERSION "1.1.28"
+#define LIBXSLT_DOTTED_VERSION "1.1.29"
 
 /**
  * LIBXSLT_VERSION:
  *
  * the version number: 1.2.3 value is 10203
  */
-#define LIBXSLT_VERSION 10128
+#define LIBXSLT_VERSION 10129
 
 /**
  * LIBXSLT_VERSION_STRING:
  *
  * the version number string, 1.2.3 value is "10203"
  */
-#define LIBXSLT_VERSION_STRING "10128"
+#define LIBXSLT_VERSION_STRING "10129"
 
 /**
  * LIBXSLT_VERSION_EXTRA:
  *
  * extra version information, used to show a CVS compilation
  */
-#define        LIBXSLT_VERSION_EXTRA "-GITv1.1.27-16-g9382efe"
+#define        LIBXSLT_VERSION_EXTRA ""
 
 /**
  * WITH_XSLT_DEBUG:
@@ -152,6 +152,17 @@ extern "C" {
 #define ATTRIBUTE_UNUSED
 #endif
 
+/**
+ * LIBXSLT_ATTR_FORMAT:
+ *
+ * This macro is used to indicate to GCC the parameters are printf-like
+ */
+#ifdef __GNUC__
+#define LIBXSLT_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))
+#else
+#define LIBXSLT_ATTR_FORMAT(fmt,args)
+#endif
+
 /**
  * LIBXSLT_PUBLIC:
  *
index f156ea3..39b2210 100644 (file)
@@ -12,6 +12,7 @@
 #define __XML_XSLTLOCALE_H__
 
 #include <libxml/xmlstring.h>
+#include "xsltexports.h"
 
 #ifdef XSLT_LOCALE_XLOCALE
 
@@ -53,10 +54,18 @@ typedef xmlChar xsltLocaleChar;
 
 #endif
 
-xsltLocale xsltNewLocale(const xmlChar *langName);
-void xsltFreeLocale(xsltLocale locale);
-xsltLocaleChar *xsltStrxfrm(xsltLocale locale, const xmlChar *string);
-int xsltLocaleStrcmp(xsltLocale locale, const xsltLocaleChar *str1, const xsltLocaleChar *str2);
-void xsltFreeLocales(void);
+XSLTPUBFUN xsltLocale XSLTCALL
+       xsltNewLocale                   (const xmlChar *langName);
+XSLTPUBFUN void XSLTCALL
+       xsltFreeLocale                  (xsltLocale locale);
+XSLTPUBFUN xsltLocaleChar * XSLTCALL
+       xsltStrxfrm                     (xsltLocale locale,
+                                        const xmlChar *string);
+XSLTPUBFUN int XSLTCALL
+       xsltLocaleStrcmp                (xsltLocale locale,
+                                        const xsltLocaleChar *str1,
+                                        const xsltLocaleChar *str2);
+XSLTPUBFUN void XSLTCALL
+       xsltFreeLocales                 (void);
 
 #endif /* __XML_XSLTLOCALE_H__ */
index a86f844..789865a 100644 (file)
@@ -165,7 +165,7 @@ XSLTPUBFUN void XSLTCALL
                                                 xsltStylesheetPtr style,
                                                 xmlNodePtr node,
                                                 const char *msg,
-                                                ...);
+                                                ...) LIBXSLT_ATTR_FORMAT(4,5);
 
 XSLTPUBFUN int XSLTCALL
                xsltSetCtxtParseOptions         (xsltTransformContextPtr ctxt,