[tz] [PROPOSED PATCH] Don't warn about abbreviations like '-05'

Paul Eggert eggert at cs.ucla.edu
Wed Jul 15 17:53:38 UTC 2015


* NEWS, zic.8: Document this.
* zic.c (newabbr): Allow abbreviations that (when quoted) conform
to POSIX.1-2001 or later.
---
 NEWS  |  4 ++++
 zic.8 |  2 ++
 zic.c | 20 ++++----------------
 3 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/NEWS b/NEWS
index 041983c..498e77b 100644
--- a/NEWS
+++ b/NEWS
@@ -19,6 +19,10 @@ Unreleased, experimental changes
     installed data files for Europe/Simferopol and Europe/Tallinn.
     It does not affect timestamps.  (Thanks to Howard Hinnant.)
 
+  Changes affecting code
+
+    zic no longer warns about valid time zone abbreviations like '-05'.
+
 
 Release 2015e - 2015-06-13 10:56:02 -0700
 
diff --git a/zic.8 b/zic.8
index cf78ae3..968cc6f 100644
--- a/zic.8
+++ b/zic.8
@@ -376,6 +376,8 @@ of the time zone abbreviation goes.
 Alternately,
 a slash (/)
 separates standard and daylight abbreviations.
+To conform to POSIX, a time zone abbreviation should contain only
+alphanumeric ASCII characters, "+" and "\*-".
 .TP
 .B UNTILYEAR [MONTH [DAY [TIME]]]
 The time at which the UT offset or the rule(s) change for a location.
diff --git a/zic.c b/zic.c
index f51fc48..6fac4e3 100644
--- a/zic.c
+++ b/zic.c
@@ -2893,27 +2893,15 @@ newabbr(const char *const string)
 		register const char *	cp;
 		const char *		mp;
 
-		/*
-		** Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics
-		** optionally followed by a + or - and a number from 1 to 14.
-		*/
 		cp = string;
 		mp = NULL;
-		while (is_alpha(*cp))
+		while (is_alpha(*cp) || ('0' <= *cp && *cp <= '9')
+		       || *cp == '-' || *cp == '+')
 				++cp;
-		if (cp - string == 0)
-mp = _("time zone abbreviation lacks alphabetic at start");
 		if (noise && cp - string < 3)
-mp = _("time zone abbreviation has fewer than 3 alphabetics");
+		  mp = _("time zone abbreviation has fewer than 3 characters");
 		if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
-mp = _("time zone abbreviation has too many alphabetics");
-		if (mp == NULL && (*cp == '+' || *cp == '-')) {
-			++cp;
-			if (is_digit(*cp))
-					if (*cp++ == '1' &&
-						*cp >= '0' && *cp <= '4')
-							++cp;
-		}
+		  mp = _("time zone abbreviation has too many characters");
 		if (*cp != '\0')
 mp = _("time zone abbreviation differs from POSIX standard");
 		if (mp != NULL)
-- 
2.1.0



More information about the tz mailing list