]> Savannah Git Hosting - gnulib.git/commitdiff
strftime: fix newly-introduced bug on Solaris
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 25 Jul 2015 23:37:17 +0000 (16:37 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 26 Jul 2015 01:20:13 +0000 (18:20 -0700)
* lib/strftime.c (strftime_case_): Set the local variable 'zone'
consistently at the start, rather than doing some of the setup at
the start and some in the %Z format spec.  This is cleaner, and
works better with time_rz on platforms like Solaris where struct
tm lacks a tm_zone member, as when !HAVE_TM_GMTOFF %z's calls to
mktime_z and localtime_rz can mess up the tzname cache.

ChangeLog
lib/strftime.c

index 230c646c6e9f9082359ef4e9e92c95b2c885488c..9787fdaaf0295747c4ca0af142baf91b562d71e7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2015-07-25  Paul Eggert  <eggert@cs.ucla.edu>
 
+       strftime: fix newly-introduced bug on Solaris
+       * lib/strftime.c (strftime_case_): Set the local variable 'zone'
+       consistently at the start, rather than doing some of the setup at
+       the start and some in the %Z format spec.  This is cleaner, and
+       works better with time_rz on platforms like Solaris where struct
+       tm lacks a tm_zone member, as when !HAVE_TM_GMTOFF %z's calls to
+       mktime_z and localtime_rz can mess up the tzname cache.
+
        test-strftime: test for Solaris bug
        * modules/strftime-tests (Depends-on): Add strerror.
        * tests/test-strftime.c: Include <errno.h>.
index 3cc8477a598b542f3e2ed03f320057d4e68e708b..c7cec2621c973286bb9b3a95eacaa79d2f879555 100644 (file)
@@ -481,7 +481,12 @@ strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s,
       tzset ();
 # endif
     }
+  /* The tzset() call might have changed the value.  */
+  if (!(zone && *zone) && tp->tm_isdst >= 0)
+    zone = tzname[tp->tm_isdst != 0];
 #endif
+  if (! zone)
+    zone = "";
 
   if (hour12 > 12)
     hour12 -= 12;
@@ -1304,14 +1309,6 @@ strftime_case_ (bool upcase, STREAM_OR_CHAR_T *s,
               to_lowcase = true;
             }
 
-#if HAVE_TZNAME
-          /* The tzset() call might have changed the value.  */
-          if (!(zone && *zone) && tp->tm_isdst >= 0)
-            zone = tzname[tp->tm_isdst != 0];
-#endif
-          if (! zone)
-            zone = "";
-
 #ifdef COMPILE_WIDE
           {
             /* The zone string is always given in multibyte form.  We have