changed date.c to use gmtime_r if available (bug 129983) fixed a namespace
authorWilliam M. Brack <wbrack@src.gnome.org>
Fri, 15 Oct 2004 05:46:56 +0000 (05:46 +0000)
committerWilliam M. Brack <wbrack@src.gnome.org>
Fri, 15 Oct 2004 05:46:56 +0000 (05:46 +0000)
* configure.in, config.h.in, libexslt/date.c: changed date.c to use
  gmtime_r if available (bug 129983)
* libexslt/functions.c: fixed a namespace problem concerning a
  function with a namespace-qualified name (bug 155197)

ChangeLog
config.h.in
configure.in
libexslt/date.c
libexslt/functions.c

index b1ed2e0..178780b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Thu Oct 14 22:43:22 PDT 2004 William Brack <wbrack@mmm.com.hk>
+
+       * configure.in, config.h.in, libexslt/date.c: changed date.c to use
+         gmtime_r if available (bug 129983)
+       * libexslt/functions.c: fixed a namespace problem concerning a
+         function with a namespace-qualified name (bug 155197)
+
 Tue Oct 12 03:54:44 CEST 2004 Daniel Veillard <daniel@veillard.com>
 
        * libxslt/namespaces.c: fixed a bug in namespace lookup exhibited
index 279d248..1b61d2b 100644 (file)
@@ -33,8 +33,8 @@
 /* Define to 1 if you have the `gettimeofday' function. */
 #undef HAVE_GETTIMEOFDAY
 
-/* Define to 1 if you have the `gmtime' function. */
-#undef HAVE_GMTIME
+/* Define to 1 if you have the `gmtime_r' function. */
+#undef HAVE_GMTIME_R
 
 /* Define to 1 if you have the <ieeefp.h> header file. */
 #undef HAVE_IEEEFP_H
index aa38f8f..e7f5408 100644 (file)
@@ -118,11 +118,12 @@ AC_CHECK_FUNC(floor, , AC_CHECK_LIB(m, floor,
 AC_CHECK_FUNC(fabs, , AC_CHECK_LIB(m, fabs,
   [M_LIBS="-lm"; AC_DEFINE(HAVE_FABS)]))
 AC_CHECK_FUNCS(gettimeofday)
-AC_CHECK_FUNCS(mktime localtime localtime_r asctime time gmtime ftime)
+AC_CHECK_FUNCS(mktime localtime localtime_r asctime time gmtime_r ftime)
 
 dnl Checking the standard string functions availability
 AC_CHECK_FUNCS(printf sprintf fprintf snprintf vfprintf vsprintf vsnprintf sscanf,,
                NEED_TRIO=1)
+
 dnl
 dnl Check for trio string functions
 dnl
index 29cbdfe..1f4cc25 100644 (file)
@@ -119,7 +119,8 @@ struct _exsltDateVal {
 
 #if defined(HAVE_TIME_H)                                       \
     && (defined(HAVE_LOCALTIME) || defined(HAVE_LOCALTIME_R))  \
-    && defined(HAVE_TIME) && defined(HAVE_GMTIME)
+    && (defined(HAVE_GMTIME) || defined(HAVE_GMTIME_R))                \
+    && defined(HAVE_TIME)
 #define WITH_TIME
 #endif
 
@@ -748,6 +749,9 @@ exsltDateCurrent (void)
 #if HAVE_LOCALTIME_R
     struct tm localTmS;
 #endif
+#if HAVE_GMTIME_R
+    struct tm gmTmS;
+#endif
     exsltDateValPtr ret;
 
     ret = exsltDateCreateDate(XS_DATETIME);
@@ -775,7 +779,12 @@ exsltDateCurrent (void)
     ret->value.date.sec  = (double) localTm->tm_sec;
 
     /* determine the time zone offset from local to gm time */
+#if HAVE_GMTIME_R
+    gmtime_r(&secs, &gmTmS);
+    gmTm = &gmTmS;
+#else
     gmTm = gmtime(&secs);
+#endif
     ret->value.date.tz_flag = 0;
     ret->value.date.tzo = (((ret->value.date.day * 1440) +
                             (ret->value.date.hour * 60) +
index d4ab48c..bed952d 100644 (file)
@@ -41,6 +41,8 @@ typedef struct _exsltFuncResultPreComp exsltFuncResultPreComp;
 struct _exsltFuncResultPreComp {
     xsltElemPreComp comp;
     xmlXPathCompExprPtr select;
+    xmlNsPtr *nsList;
+    int nsNr;
 };
 
 /* Used for callback function in exsltInitFunc */
@@ -247,6 +249,8 @@ exsltFreeFuncResultPreComp (exsltFuncResultPreComp *comp) {
 
     if (comp->select != NULL)
        xmlXPathFreeCompExpr (comp->select);
+    if (comp->nsList != NULL)
+        xmlFree(comp->nsList);
     xmlFree(comp);
 }
 
@@ -526,7 +530,16 @@ exsltFuncResultComp (xsltStylesheetPtr style, xmlNodePtr inst,
        ret->select = xmlXPathCompile (select);
        xmlFree(select);
     }
-
+    /*
+     * Precompute the namespace list
+     */
+    ret->nsList = xmlGetNsList(inst->doc, inst);
+    if (ret->nsList != NULL) {
+        int i = 0;
+        while (ret->nsList[i] != NULL)
+           i++;
+       ret->nsNr = i;
+    }
     return ((xsltElemPreCompPtr) ret);
 }
 
@@ -536,6 +549,8 @@ exsltFuncResultElem (xsltTransformContextPtr ctxt,
                     exsltFuncResultPreComp *comp) {
     exsltFuncData *data;
     xmlXPathObjectPtr ret;
+    xmlNsPtr *oldNsList;
+    int oldNsNr;
 
     /* It is an error if instantiating the content of the
      * func:function element results in the instantiation of more than
@@ -569,7 +584,13 @@ exsltFuncResultElem (xsltTransformContextPtr ctxt,
            data->error = 1;
            return;
        }
+       oldNsList = ctxt->xpathCtxt->namespaces;
+       oldNsNr = ctxt->xpathCtxt->nsNr;
+       ctxt->xpathCtxt->namespaces = comp->nsList;
+       ctxt->xpathCtxt->nsNr = comp->nsNr;
        ret = xmlXPathCompiledEval(comp->select, ctxt->xpathCtxt);
+       ctxt->xpathCtxt->nsNr = oldNsNr;
+       ctxt->xpathCtxt->namespaces = oldNsList;
        if (ret == NULL) {
            xsltGenericError(xsltGenericErrorContext,
                             "exsltFuncResultElem: ret == NULL\n");