about summary refs log tree commit diff
path: root/time
diff options
context:
space:
mode:
Diffstat (limited to 'time')
-rw-r--r--time/Makefile6
-rw-r--r--time/tst-tzname.c50
-rw-r--r--time/tzfile.c6
3 files changed, 61 insertions, 1 deletions
diff --git a/time/Makefile b/time/Makefile
index 912b0e0ade..e052c0765d 100644
--- a/time/Makefile
+++ b/time/Makefile
@@ -37,7 +37,8 @@ aux :=	    era alt_digit lc-time-cleanup
 tests	:= test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
 	   tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
 	   tst-mktime3 tst-strptime2 bug-asctime bug-asctime_r bug-mktime1 \
-	   tst-strptime3 bug-getdate1 tst-strptime-whitespace tst-ftime
+	   tst-strptime3 bug-getdate1 tst-strptime-whitespace tst-ftime \
+	   tst-tzname
 
 include ../Rules
 
@@ -63,4 +64,7 @@ CFLAGS-test_time.c = -Wno-format
 tst-getdate-ENV= DATEMSK=datemsk TZDIR=${common-objpfx}timezone/testdata
 test_time-ARGS= EST5EDT CST
 
+tst-tzname-ENV = TZDIR=${common-objpfx}timezone/testdata
+CPPFLAGS-tst-tzname.c = -DTZDEFRULES='"$(posixrules-file)"'
+
 bug-getdate1-ARGS = ${objpfx}bug-getdate1-fmt
diff --git a/time/tst-tzname.c b/time/tst-tzname.c
new file mode 100644
index 0000000000..ea7ec927b2
--- /dev/null
+++ b/time/tst-tzname.c
@@ -0,0 +1,50 @@
+/* Test that tzset sets tzname correctly (BZ #19253).
+   Copyright (C) 2015 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+static int
+do_test (void)
+{
+  int result = 0;
+
+  setenv ("TZ", TZDEFRULES, 1);
+  tzset ();
+  const char *stdtz = strdup (tzname[0]);
+  setenv ("TZ", "STD-1DST", 1);
+  tzset ();
+  if (strcmp (tzname[0], "STD") != 0)
+    {
+      printf ("FAIL: TZ=STD-1DST, tzname[0] = %s\n", tzname[0]);
+      result = 1;
+    }
+  setenv ("TZ", TZDEFRULES, 1);
+  tzset ();
+  if (strcmp (tzname[0], stdtz) != 0)
+    {
+      printf ("FAIL: TZ=%s, tzname[0] = %s\n", TZDEFRULES, tzname[0]);
+      result = 1;
+    }
+  return result;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
diff --git a/time/tzfile.c b/time/tzfile.c
index 992806dc6b..9049878399 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -628,6 +628,12 @@ __tzfile_default (const char *std, const char *dst,
   __timezone = -types[0].offset;
 
   compute_tzname_max (stdlen + dstlen);
+
+  /* Invalidate the tzfile attribute cache to force rereading
+     TZDEFRULES the next time it is used.  */
+  tzfile_dev = 0;
+  tzfile_ino = 0;
+  tzfile_mtime = 0;
 }
 
 void