From: William M. Brack Date: Fri, 15 Oct 2004 05:46:56 +0000 (+0000) Subject: changed date.c to use gmtime_r if available (bug 129983) fixed a namespace X-Git-Tag: v1.1.28~366 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d28f2ec4ee791dd12e0a7097d6093fab7b7501b;p=platform%2Fupstream%2Flibxslt.git changed date.c to use gmtime_r if available (bug 129983) fixed a namespace * 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) --- diff --git a/ChangeLog b/ChangeLog index b1ed2e0..178780b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Thu Oct 14 22:43:22 PDT 2004 William Brack + + * 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 * libxslt/namespaces.c: fixed a bug in namespace lookup exhibited diff --git a/config.h.in b/config.h.in index 279d248..1b61d2b 100644 --- a/config.h.in +++ b/config.h.in @@ -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 header file. */ #undef HAVE_IEEEFP_H diff --git a/configure.in b/configure.in index aa38f8f..e7f5408 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/libexslt/date.c b/libexslt/date.c index 29cbdfe..1f4cc25 100644 --- a/libexslt/date.c +++ b/libexslt/date.c @@ -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) + diff --git a/libexslt/functions.c b/libexslt/functions.c index d4ab48c..bed952d 100644 --- a/libexslt/functions.c +++ b/libexslt/functions.c @@ -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");