Re: [xslt] Fail build of OpenBSD



This works on linux at least:

Daniel Veillard wrote:
> 
> On Sat, Aug 18, 2001 at 09:59:20AM -0500, Charlie Bozeman wrote:
> > I had the same problem in cygwin; I just changed timezone to _timezone
> > to get it to compile.
> [...]
> > This is a little inefficient so a portable solution using a variable
> > that holds the offset (_timzone or timezone) would be welcome.
> 
>   Hum, I really don't think that efficiency is important in that
> part, I don't see this being the critical path for any stylesheet.
> Portability seems quite more important, send patches, it would be great
> if others could test it.
> 
> Daniel
> 
> --
> Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
> veillard@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
> http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
> 
> _______________________________________________
> xslt mailing list
> xslt@gnome.org
> http://mail.gnome.org/mailman/listinfo/xslt
--- extra.c-sav	Wed Aug 15 20:36:08 2001
+++ extra.c	Sat Aug 18 14:29:59 2001
@@ -169,6 +169,8 @@
     time_t gmt, lmt;
     struct tm gmt_tm;
     struct tm *local_tm;
+    struct tm *gmt_tm_ptr;
+    time_t tzSecs;
  
     if (nargs != 1) {
        xsltPrintErrorContext(xsltXPathGetTransformContext(ctxt), NULL, NULL);
@@ -226,16 +228,18 @@
 
 
     /*
-     * FIXME: it's been too long since I did manual memory management.
-     * (I swore never to do it again.) Does this introduce a memory leak?
+     * determine the timezone offset (in seconds) by getting the
+     * difference between the current local time and gm time
      */
-    local_tm = localtime(&gmt);
+    lmt        = time(NULL);
+    local_tm   = localtime(&lmt);
+    gmt_tm_ptr = gmtime(&lmt);
+    tzSecs     = mktime(gmt_tm_ptr) - lmt;
 
     /*
-     * Calling localtime() has the side-effect of setting timezone.
      * After we know the timezone, we can adjust for it
      */
-    lmt = gmt - timezone;
+    lmt = gmt - tzSecs;
 
     /*
      * FIXME: it's been too long since I did manual memory management.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]