summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-09-10 11:58:53 +0000
committerUlrich Drepper <drepper@redhat.com>1998-09-10 11:58:53 +0000
commit90865aa8d319b1bd736690717c6fcc23b7a29e98 (patch)
treedb9e3601dddee40e5c49d7569721334ecf51b451
parentadac8450947aa7963df1ff143fa64e6579a0f620 (diff)
downloadglibc-90865aa8d319b1bd736690717c6fcc23b7a29e98.tar.gz
glibc-90865aa8d319b1bd736690717c6fcc23b7a29e98.tar.xz
glibc-90865aa8d319b1bd736690717c6fcc23b7a29e98.zip
Update.
1998-09-10 11:53  Ulrich Drepper  <drepper@cygnus.com>

	* timezone/Makefile: Add rules to generate Asia/Tokyo zoneinfo files
	for test.
	* timezone/tst-timezone.c (tests): Fix typo in last patch.

	* time/tzfile.c (__tzfile_read): Handle case when there are no
	transitions.  Set __timezone based on computed offset.
	* time/tzset.c (tzset_internal): Set __timezone before returning.

	* time/tzset.c (tzset_internal): Optimize handling of local string
	copy.

1998-09-10  Andreas Jaeger  <aj@arthur.rhein-neckar.de>

	* timezone/tst-timezone.c (tests): Add test for Asia/Tokyo (see PR
	libc/776).

	* sysdeps/powerpc/bits/fenv.h: Add parens.
-rw-r--r--ChangeLog20
-rw-r--r--time/tzfile.c25
-rw-r--r--time/tzset.c44
-rw-r--r--timezone/Makefile4
-rw-r--r--timezone/tst-timezone.c1
5 files changed, 55 insertions, 39 deletions
diff --git a/ChangeLog b/ChangeLog
index a81a49ab40..8e1fa8b3fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,26 @@
+1998-09-10 11:53  Ulrich Drepper  <drepper@cygnus.com>
+
+	* timezone/Makefile: Add rules to generate Asia/Tokyo zoneinfo files
+	for test.
+	* timezone/tst-timezone.c (tests): Fix typo in last patch.
+
+	* time/tzfile.c (__tzfile_read): Handle case when there are no
+	transitions.  Set __timezone based on computed offset.
+	* time/tzset.c (tzset_internal): Set __timezone before returning.
+
+	* time/tzset.c (tzset_internal): Optimize handling of local string
+	copy.
+
+1998-09-10  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+	* timezone/tst-timezone.c (tests): Add test for Asia/Tokyo (see PR
+	libc/776).
+
 1998-09-09  Benjamin Kosnik  <bkoz@tintin.cygnus.com>
 
 	* math/libm-test.c (exp10_test): Adapt epsilons for powerpc.
 	(csqrt_test): Likewise.
-	* sysdeps/powerpc/bits/fenv.h: Add parens. .
+	* sysdeps/powerpc/bits/fenv.h: Add parens.
 
 1998-09-09 18:48  Ulrich Drepper  <drepper@cygnus.com>
 
diff --git a/time/tzfile.c b/time/tzfile.c
index eca09e2bbb..a7753d2f73 100644
--- a/time/tzfile.c
+++ b/time/tzfile.c
@@ -281,15 +281,21 @@ __tzfile_read (const char *file)
 
   compute_tzname_max (chars);
 
-  rule_stdoff = rule_dstoff = 0;
-  for (i = 0; i < num_transitions; ++i)
+  if (num_transitions == 0)
+    /* Use the first rule (which should also be the only one.  */
+    rule_stdoff = rule_dstoff = types[0].offset;
+  else
     {
-      if (!rule_stdoff && !types[type_idxs[i]].isdst)
-	rule_stdoff = types[type_idxs[i]].offset;
-      if (!rule_dstoff && types[type_idxs[i]].isdst)
-	rule_dstoff = types[type_idxs[i]].offset;
-      if (rule_stdoff && rule_dstoff)
-	break;
+      rule_stdoff = rule_dstoff = 0;
+      for (i = 0; i < num_transitions; ++i)
+	{
+	  if (!rule_stdoff && !types[type_idxs[i]].isdst)
+	    rule_stdoff = types[type_idxs[i]].offset;
+	  if (!rule_dstoff && types[type_idxs[i]].isdst)
+	    rule_dstoff = types[type_idxs[i]].offset;
+	  if (rule_stdoff && rule_dstoff)
+	    break;
+	}
     }
 
   __daylight = rule_stdoff != rule_dstoff;
@@ -381,6 +387,9 @@ __tzfile_default (const char *std, const char *dst,
   __tzname[0] = (char *) std;
   __tzname[1] = (char *) dst;
 
+  /* Set the timezone.  */
+  __timezone = -types[0].offset;
+
   compute_tzname_max (stdlen + dstlen);
 }
 
diff --git a/time/tzset.c b/time/tzset.c
index d4e3037260..c35017c960 100644
--- a/time/tzset.c
+++ b/time/tzset.c
@@ -207,21 +207,11 @@ tzset_internal (always)
   tz_rules[0].name = tz_rules[1].name = "";
 
   /* Get the standard timezone name.  */
-  tzbuf = malloc (strlen (tz) + 1);
-  if (! tzbuf)
-    {
-      /* Clear the old tz name so we will try again.  */
-      free (old_tz);
-      old_tz = NULL;
-      return;
-    }
+  tzbuf = strdupa (tz);
 
   if (sscanf (tz, "%[^0-9,+-]", tzbuf) != 1 ||
       (l = strlen (tzbuf)) < 3)
-    {
-      free (tzbuf);
-      return;
-    }
+    return;
 
   tz_rules[0].name = __tzstring (tzbuf);
 
@@ -229,10 +219,7 @@ tzset_internal (always)
 
   /* Figure out the standard offset from UTC.  */
   if (*tz == '\0' || (*tz != '+' && *tz != '-' && !isdigit (*tz)))
-    {
-      free (tzbuf);
-      return;
-    }
+    return;
 
   if (*tz == '-' || *tz == '+')
     tz_rules[0].offset = *tz++ == '-' ? 1L : -1L;
@@ -241,7 +228,6 @@ tzset_internal (always)
   switch (sscanf (tz, "%hu:%hu:%hu", &hh, &mm, &ss))
     {
     default:
-      free (tzbuf);
       return;
     case 1:
       mm = 0;
@@ -311,7 +297,6 @@ tzset_internal (always)
 	    {
 	      free (old_tz);
 	      old_tz = NULL;
-	      free (tzbuf);
 	      return;
 	    }
 	}
@@ -321,13 +306,10 @@ tzset_internal (always)
       /* There is no DST.  */
       tz_rules[1].name = tz_rules[0].name;
       tz_rules[1].offset = tz_rules[0].offset;
-      free (tzbuf);
-      return;
+      goto out;
     }
 
  done_names:
-  free (tzbuf);
-
   /* Figure out the standard <-> DST rules.  */
   for (whichrule = 0; whichrule < 2; ++whichrule)
     {
@@ -343,12 +325,12 @@ tzset_internal (always)
 	  char *end;
 	  tzr->type = *tz == 'J' ? J1 : J0;
 	  if (tzr->type == J1 && !isdigit (*++tz))
-	    return;
+	    goto out;
 	  tzr->d = (unsigned short int) strtoul (tz, &end, 10);
 	  if (end == tz || tzr->d > 365)
-	    return;
+	    goto out;
 	  else if (tzr->type == J1 && tzr->d == 0)
-	    return;
+	    goto out;
 	  tz = end;
 	}
       else if (*tz == 'M')
@@ -359,7 +341,7 @@ tzset_internal (always)
 		      &tzr->m, &tzr->n, &tzr->d, &n) != 3 ||
 	      tzr->m < 1 || tzr->m > 12 ||
 	      tzr->n < 1 || tzr->n > 5 || tzr->d > 6)
-	    return;
+	    goto out;
 	  tz += n;
 	}
       else if (*tz == '\0')
@@ -380,16 +362,16 @@ tzset_internal (always)
 	    }
 	}
       else
-	return;
+	goto out;
 
       if (*tz != '\0' && *tz != '/' && *tz != ',')
-	return;
+	goto out;
       else if (*tz == '/')
 	{
 	  /* Get the time of day of the change.  */
 	  ++tz;
 	  if (*tz == '\0')
-	    return;
+	    goto out;
 	  switch (sscanf (tz, "%hu:%hu:%hu", &hh, &mm, &ss))
 	    {
 	    default:
@@ -416,6 +398,10 @@ tzset_internal (always)
 
       tzr->computed_for = -1;
     }
+
+ out:
+  /* We know the offset now, set `__timezone'.  */
+  __timezone = -tz_rules[0].offset;
 }
 
 /* Maximum length of a timezone name.  __tz_compute keeps this up to date
diff --git a/timezone/Makefile b/timezone/Makefile
index 23d50b1730..c0a9bc166e 100644
--- a/timezone/Makefile
+++ b/timezone/Makefile
@@ -178,7 +178,7 @@ $(objpfx)test-tz.out: $(addprefix $(testdata)/, America/New_York Etc/UTC UTC)
 $(objpfx)tst-timezone.out: $(addprefix $(testdata)/, \
 				       Europe/Berlin Universal \
 				       Australia/Melbourne \
-				       America/Sao_Paulo)
+				       America/Sao_Paulo Asia/Tokyo)
 
 test-tz-ENV = TZDIR=$(testdata)
 tst-timezone-ENV = TZDIR=$(testdata)
@@ -202,6 +202,8 @@ $(testdata)/Australia/Melbourne: australasia $(objpfx)zic $(leapseconds) \
 $(testdata)/America/Sao_Paulo: southamerica $(objpfx)zic $(leapseconds) \
 			       yearistype
 	$(build-testdata)
+$(testdata)/Asia/Tokyo: asia $(objpfx)zic $(leapseconds) yearistype
+	$(build-testdata)
 
 
 $(objpfx)tzselect: tzselect.ksh $(common-objpfx)config.make
diff --git a/timezone/tst-timezone.c b/timezone/tst-timezone.c
index d05632d272..3585a9c60b 100644
--- a/timezone/tst-timezone.c
+++ b/timezone/tst-timezone.c
@@ -40,6 +40,7 @@ static const struct test_times tests[] =
   { "Australia/Melbourne", 1, -36000, { "EST", "EST" }},
   { "America/Sao_Paulo", 1, 10800, {"EST", "EDT" }},
   { "America/Los_Angeles", 1, 28800, {"PST", "PDT" }},
+  { "Asia/Tokyo", 0, -32400, {"JST", "JST" }},
   { NULL, 0, 0 }
 };