zic warnings about odd time zone abbreviations
Here are changes to zic.c to produce warnings about non-POSIX time zone abbreviations. I've also included changes to the "solar" files to use a POSIX-compliant "zzz" abbreviation (rather than the non-compliant "??") for the zone whose name we don't know. --ado ------- Makefile ------- *** /tmp/geta10569 Tue May 24 13:21:00 2005 --- /tmp/getb10569 Tue May 24 13:21:00 2005 *************** *** 1,4 **** ! # @(#)Makefile 7.108 # Change the line below for your time zone (after finding the zone you want in # the time zone files, or adding it to a time zone file). --- 1,4 ---- ! # @(#)Makefile 7.109 # Change the line below for your time zone (after finding the zone you want in # the time zone files, or adding it to a time zone file). *************** *** 111,117 **** # -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1 # if you do not want run time warnings about formats that may cause # year 2000 grief ! # GCC_DEBUG_FLAGS = -Dlint -g -O -fno-common \ -Wall -Wcast-qual -Wconversion -Wmissing-prototypes \ -Wnested-externs -Wpointer-arith -Wshadow \ --- 111,119 ---- # -DNO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU=1 # if you do not want run time warnings about formats that may cause # year 2000 grief ! # -DZIC_MAX_ABBR_LEN_WO_WARN=3 ! # (or some other number) to set the maximum time zone abbreviation length ! # that zic will accept without a warning (the default is 6) GCC_DEBUG_FLAGS = -Dlint -g -O -fno-common \ -Wall -Wcast-qual -Wconversion -Wmissing-prototypes \ -Wnested-externs -Wpointer-arith -Wshadow \ ------- zic.c ------- *** /tmp/geta10785 Tue May 24 13:32:28 2005 --- /tmp/getb10785 Tue May 24 13:32:29 2005 *************** *** 1,4 **** ! static char elsieid[] = "@(#)zic.c 7.122"; /* ** Regardless of the type of time_t, we do our work using this type. --- 1,4 ---- ! static char elsieid[] = "@(#)zic.c 7.123"; /* ** Regardless of the type of time_t, we do our work using this type. *************** *** 10,15 **** --- 10,21 ---- #include "locale.h" #include "tzfile.h" + #define GRANDPARENTED "Local time zone must be set--see zic manual page" + + #ifndef ZIC_MAX_ABBR_LEN_WO_WARN + #define ZIC_MAX_ABBR_LEN_WO_WARN 6 + #endif /* !defined ZIC_MAX_ABBR_LEN_WO_WARN */ + #if HAVE_SYS_STAT_H #include "sys/stat.h" #endif *************** *** 2196,2201 **** --- 2202,2242 ---- { register int i; + if (strcmp(string, GRANDPARENTED) != 0) { + register const char * cp; + register char * wp; + + /* + ** Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics + ** optionally followed by a + or - and a number from 1 to 14. + */ + cp = string; + wp = NULL; + while (isascii(*cp) && isalpha(*cp)) + ++cp; + if (cp - string == 0) + wp = _("time zone abbreviation lacks alphabetic at start"); + if (noise && cp - string > 3) + wp = _("time zone abbreviation has more than 3 alphabetics"); + if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN) + wp = _("time zone abbreviation has too many alphabetics"); + if (wp == NULL && (*cp == '+' || *cp == '-')) { + ++cp; + if (isascii(*cp) && isdigit(*cp)) + if (*cp++ == '1' && *cp >= '0' && *cp <= '4') + ++cp; + } + if (*cp != '\0') + wp = _("time zone abbreviation differs from POSIX standard"); + if (wp != NULL) { + wp = ecpyalloc(wp); + wp = ecatalloc(wp, " ("); + wp = ecatalloc(wp, string); + wp = ecatalloc(wp, ")"); + warning(wp); + ifree(wp); + } + } i = strlen(string) + 1; if (charcnt + i > TZ_MAX_CHARS) { error(_("too many, or too long, time zone abbreviations")); ------- solar87 ------- *** /tmp/geta10623 Tue May 24 13:21:32 2005 --- /tmp/getb10623 Tue May 24 13:21:32 2005 *************** *** 1,4 **** ! # @(#)solar87 7.3 # So much for footnotes about Saudi Arabia. # Apparent noon times below are for Riyadh; your mileage will vary. --- 1,4 ---- ! # @(#)solar87 7.4 # So much for footnotes about Saudi Arabia. # Apparent noon times below are for Riyadh; your mileage will vary. *************** *** 381,388 **** # Before and after 1987, we'll operate on local mean solar time. # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] ! Zone Asia/Riyadh87 3:07:04 - ?? 1987 ! 3:07:04 sol87 ?? 1988 ! 3:07:04 - ?? # For backward compatibility... Link Asia/Riyadh87 Mideast/Riyadh87 --- 381,388 ---- # Before and after 1987, we'll operate on local mean solar time. # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] ! Zone Asia/Riyadh87 3:07:04 - zzz 1987 ! 3:07:04 sol87 zzz 1988 ! 3:07:04 - zzz # For backward compatibility... Link Asia/Riyadh87 Mideast/Riyadh87 ------- solar88 ------- *** /tmp/geta10642 Tue May 24 13:21:36 2005 --- /tmp/getb10642 Tue May 24 13:21:36 2005 *************** *** 1,4 **** ! # @(#)solar88 7.3 # Apparent noon times below are for Riyadh; they're a bit off for other places. # Times were computed using formulas in the U.S. Naval Observatory's --- 1,4 ---- ! # @(#)solar88 7.4 # Apparent noon times below are for Riyadh; they're a bit off for other places. # Times were computed using formulas in the U.S. Naval Observatory's *************** *** 381,388 **** # Before and after 1988, we'll operate on local mean solar time. # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] ! Zone Asia/Riyadh88 3:07:04 - ?? 1988 ! 3:07:04 sol88 ?? 1989 ! 3:07:04 - ?? # For backward compatibility... Link Asia/Riyadh88 Mideast/Riyadh88 --- 381,388 ---- # Before and after 1988, we'll operate on local mean solar time. # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] ! Zone Asia/Riyadh88 3:07:04 - zzz 1988 ! 3:07:04 sol88 zzz 1989 ! 3:07:04 - zzz # For backward compatibility... Link Asia/Riyadh88 Mideast/Riyadh88 ------- solar89 ------- *** /tmp/geta10661 Tue May 24 13:21:44 2005 --- /tmp/getb10661 Tue May 24 13:21:44 2005 *************** *** 1,4 **** ! # @(#)solar89 7.4 # Apparent noon times below are for Riyadh; they're a bit off for other places. # Times were computed using a formula provided by the U. S. Naval Observatory: --- 1,4 ---- ! # @(#)solar89 7.5 # Apparent noon times below are for Riyadh; they're a bit off for other places. # Times were computed using a formula provided by the U. S. Naval Observatory: *************** *** 386,393 **** # Before and after 1989, we'll operate on local mean solar time. # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] ! Zone Asia/Riyadh89 3:07:04 - ?? 1989 ! 3:07:04 sol89 ?? 1990 ! 3:07:04 - ?? # For backward compatibility... Link Asia/Riyadh89 Mideast/Riyadh89 --- 386,393 ---- # Before and after 1989, we'll operate on local mean solar time. # Zone NAME GMTOFF RULES/SAVE FORMAT [UNTIL] ! Zone Asia/Riyadh89 3:07:04 - zzz 1989 ! 3:07:04 sol89 zzz 1990 ! 3:07:04 - zzz # For backward compatibility... Link Asia/Riyadh89 Mideast/Riyadh89
Date: Tue, 24 May 2005 13:33:56 -0400 (EDT) From: Arthur David Olson <olsona@lecserver.nci.nih.gov> Message-ID: <200505241733.j4OHXudh010801@lecserver.nci.nih.gov> | Here are changes to zic.c to produce warnings about non-POSIX time zone | abbreviations. That's fine, but doesn't address the real problem (admins putting weirdness in their zone source files was never really the issue), it is users putting "bad stuff" in their private zone files or TZ env vars that might be important - warnings don't help, run time enforcement of at least safety, if not sanity, is needed. kre
participants (2)
-
Arthur David Olson -
Robert Elz