From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12405 invoked from network); 12 Sep 2002 14:32:48 -0000 Received: from unknown (HELO monty-python.gnu.org) (199.232.76.173) by sources.redhat.com with SMTP; 12 Sep 2002 14:32:48 -0000 Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 17pV0m-0007Ar-00; Thu, 12 Sep 2002 10:32:04 -0400 Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 17pV01-00071s-00 for help-gnats@gnu.org; Thu, 12 Sep 2002 10:31:17 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 17pUzz-00071g-00 for help-gnats@gnu.org; Thu, 12 Sep 2002 10:31:17 -0400 Received: from cluster2.netman.dk ([193.88.72.48]) by monty-python.gnu.org with esmtp (Exim 4.10) id 17pUzz-00071c-00 for help-gnats@gnu.org; Thu, 12 Sep 2002 10:31:15 -0400 Received: (from lh@localhost) by cluster2.netman.dk (8.11.4/8.11.4) id g8CEScR1442659; Thu, 12 Sep 2002 16:28:38 +0200 (MEST) From: Lars Henriksen To: help-gnats@gnu.org Cc: Milan Zamazal , Yngve Svendsen , "Carl E. Lindberg" Subject: Wrong dates in PRs if no %z support in strftime(3) Message-ID: <20020912142837.GA1438328@cluster2.netman.dk> References: <87g0d85psm.fsf@blackbird.zamazal.org> <5.0.0.25.2.20010530174652.00b23a10@mail.trd.clustra.com> <5.1.0.14.2.20010511013313.00ba72d8@iwww.clustra.com> <5.1.0.14.2.20010511013313.00ba72d8@iwww.clustra.com> <5.0.0.25.2.20010530174652.00b23a10@mail.trd.clustra.com> <5.1.0.14.2.20010612221913.00ba0828@10.10.1.1> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5.1.0.14.2.20010612221913.00ba0828@10.10.1.1> User-Agent: Mutt/1.4i Sender: help-gnats-admin@gnu.org Errors-To: help-gnats-admin@gnu.org X-BeenThere: help-gnats@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: General discussion about GNU GNATS List-Archive: Date: Thu, 12 Sep 2002 15:07:00 -0000 X-SW-Source: 2002-q3/txt/msg00076.txt.bz2 On Tue, Jun 12, 2001 at 10:25:02PM +0200, Yngve Svendsen wrote: > At 17:19 12.06.2001 +0200, Yngve Svendsen wrote: > >At 17:15 10.06.2001 +0200, Milan Zamazal wrote: > >>>>>>> "YS" == Yngve Svendsen writes: > >> > >> YS> Sorry, but it seems the configure check for %z support isn't > >> YS> working right. > >> > >>You're right. strftime is going to become my nightmare. :-| I tried to > >>fix it and also added a patch by Carl enabling numeric time zones also > >>on systems not supporting `%z'. Please try whether it works or not. > > > >Unfortunately, the nightmare continues. "make all" results in the > >following on a Solaris 7 system: > > [snip] > > On some systems, Solaris among them, isdigit() requires an explicit cast to > int. The very simple patch below fixes the problem and makes the current > GNATS 4 compile on both Solaris and Linux. > > I have compiled and done some testing, and as far as I can tell, all is now > well on systems that don't support %z. Not quite. There is a bug in gnats_strftime() that affects systems without %z support. The problem is the brokentime pointer passed to gnats_strftime(). It points to static data that may be overwritten by calls to (among others) gmtime(). Exactly this happens in the support routine minutes_gmt_offset(), whereupon brokentime is passed on to strftime(). Patch follows. I have submitted a gnats PR as well. Lars Henriksen Index: misc.c =================================================================== RCS file: /cvsroot/gnats/gnats/gnats/misc.c,v retrieving revision 1.36 diff -u -r1.36 misc.c --- misc.c 6 Jan 2002 16:13:20 -0000 1.36 +++ misc.c 12 Sep 2002 14:16:12 -0000 @@ -568,6 +568,11 @@ char *fixed_template = (char*)xmalloc (strlen(template)+FORMAT_PADDING); const char *in = template; char *out = fixed_template; + /* Because brokentime points to static data (allocated + * by localtime()), it cannot be passed to a subroutine + * and then later be relied on to point to the same data. */ + struct tm bktime = *brokentime; + int result; while (*in != '\0') { @@ -602,12 +607,9 @@ } } *out = '\0'; - - { - int result = strftime (s, size, fixed_template, brokentime); - free (fixed_template); - return result; - } + result = strftime (s, size, fixed_template, &bktime); + free (fixed_template); + return result; } } _______________________________________________ Help-gnats mailing list Help-gnats@gnu.org http://mail.gnu.org/mailman/listinfo/help-gnats