[PROPOSED 1/5] New Makefile macro BACKWARD
* NEWS: Document this. * Makefile (BACKWARD): New macro. (YDATA, INSTALLARGS): Use it. --- Makefile | 10 +++++++++- NEWS | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c62d46f..6373920 100644 --- a/Makefile +++ b/Makefile @@ -92,6 +92,13 @@ LIBDIR= $(TOPDIR)/lib REDO= posix_right +# For backward-compatibility links for old zone names, use +# BACKWARD= backward pacificnew +# To omit these links, use +# BACKWARD= + +BACKWARD= backward pacificnew + # If you want out-of-scope and often-wrong data from the file 'backzone', use # PACKRATDATA= backzone # To omit this data, use @@ -384,7 +391,7 @@ WEB_PAGES= tz-art.htm tz-how-to.html tz-link.htm DOCS= $(MANS) date.1 $(MANTXTS) $(WEB_PAGES) PRIMARY_YDATA= africa antarctica asia australasia \ europe northamerica southamerica -YDATA= $(PRIMARY_YDATA) pacificnew etcetera backward +YDATA= $(PRIMARY_YDATA) etcetera $(BACKWARD) NDATA= systemv factory TDATA= $(YDATA) $(NDATA) ZONETABLES= zone1970.tab zone.tab @@ -482,6 +489,7 @@ leapseconds: $(LEAP_DEPS) # Arguments to pass to submakes of install_data. # They can be overridden by later submake arguments. INSTALLARGS = \ + BACKWARD=$(BACKWARD) \ DESTDIR=$(DESTDIR) \ LEAPSECONDS='$(LEAPSECONDS)' \ PACKRATDATA='$(PACKRATDATA)' \ diff --git a/NEWS b/NEWS index 4e8091b..dcd49eb 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,10 @@ Unreleased, experimental changes in civil timekeeping. (Thanks to Robert Elz and Bradley White for noticing glitches in the code that uncovered this problem.) + 'make BACKWARD=' now suppresses backward-compatibility names + like 'US/Pacific' that are defined in the 'backward' and + 'pacificnew' files. + Several minor changes have been made to the code to make it a bit easier to port to MS-Windows. (Thanks to Kees Dekker for reporting the problems.) -- 2.9.4
This does not change the zic output; it merely clarifies the input. It also simplifies a future change that I have in mind. * asia (RussiaAsia): Remove confusing discrepancy with Russia rule. (Armenia): New rules for 2011 only, when Armenia disagreed with Russia. (Asia/Yerevan): Use them. --- asia | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/asia b/asia index f027071..e26ef1b 100644 --- a/asia +++ b/asia @@ -75,8 +75,8 @@ Rule E-EurAsia 1996 max - Oct lastSun 0:00 0 - Rule RussiaAsia 1981 1984 - Apr 1 0:00 1:00 S Rule RussiaAsia 1981 1983 - Oct 1 0:00 0 - Rule RussiaAsia 1984 1995 - Sep lastSun 2:00s 0 - -Rule RussiaAsia 1985 2011 - Mar lastSun 2:00s 1:00 S -Rule RussiaAsia 1996 2011 - Oct lastSun 2:00s 0 - +Rule RussiaAsia 1985 2010 - Mar lastSun 2:00s 1:00 S +Rule RussiaAsia 1996 2010 - Oct lastSun 2:00s 0 - # Afghanistan # Zone NAME GMTOFF RULES FORMAT [UNTIL] @@ -109,13 +109,17 @@ Zone Asia/Kabul 4:36:48 - LMT 1890 # or # (brief) # http://www.worldtimezone.com/dst_news/dst_news_armenia03.html +# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S +Rule Armenia 2011 only - Mar lastSun 2:00s 1:00 S +Rule Armenia 2011 only - Oct lastSun 2:00s 0 - # Zone NAME GMTOFF RULES FORMAT [UNTIL] Zone Asia/Yerevan 2:58:00 - LMT 1924 May 2 3:00 - +03 1957 Mar 4:00 RussiaAsia +04/+05 1991 Mar 31 2:00s 3:00 RussiaAsia +03/+04 1995 Sep 24 2:00s 4:00 - +04 1997 - 4:00 RussiaAsia +04/+05 + 4:00 RussiaAsia +04/+05 2011 + 4:00 Armenia +04/+05 # Azerbaijan -- 2.9.4
* NEWS, zic.8: Describe how zic supports abbreviations like "Sun". --- NEWS | 3 +++ zic.8 | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index dcd49eb..1af7b69 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,9 @@ Unreleased, experimental changes bit easier to port to MS-Windows. (Thanks to Kees Dekker for reporting the problems.) + Changes to documentation and commentary + + The zic man page now documents abbreviation rules. Release 2017b - 2017-03-17 07:30:38 -0700 diff --git a/zic.8 b/zic.8 index c59ccfc..6fee96d 100644 --- a/zic.8 +++ b/zic.8 @@ -148,7 +148,8 @@ Non-blank lines are expected to be of one of three types: rule lines, zone lines, and link lines. .PP Names (such as month names) must be in English and are case insensitive. -Abbreviations, if used, must be unambiguous in context. +A name can be abbreviated by omitting all but an initial prefix; any +abbreviation must be unambiguous in context. .PP A rule line has the form .nf @@ -221,7 +222,13 @@ Sun<=25 last Sunday on or before the 25th .fi .in -.5i .sp -Names of days of the week may be abbreviated or spelled out in full. +A weekday name (e.g., +.BR "Sunday" ) +or a weekday name preceded by +.q "last" +(e.g., +.BR "lastSunday" ) +may be abbreviated or spelled out in full. Note that there must be no spaces within the .B ON field. -- 2.9.4
For these static functions, modern GCC is smart enough to purity on its own. * localtime.c (getzname, getqzname): * zic.c (memcheck, ciequal, itsabbr, byword): Remove ATTRIBUTE_PURE. --- localtime.c | 4 ++-- zic.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/localtime.c b/localtime.c index a951cab..8f103aa 100644 --- a/localtime.c +++ b/localtime.c @@ -737,7 +737,7 @@ static const int year_lengths[2] = { ** character. */ -static const char * ATTRIBUTE_PURE +static const char * getzname(register const char *strp) { register char c; @@ -757,7 +757,7 @@ getzname(register const char *strp) ** We don't do any checking here; checking is done later in common-case code. */ -static const char * ATTRIBUTE_PURE +static const char * getqzname(register const char *strp, const int delim) { register int c; diff --git a/zic.c b/zic.c index 486631b..f57d346 100644 --- a/zic.c +++ b/zic.c @@ -415,7 +415,7 @@ strdup(char const *str) } #endif -static ATTRIBUTE_PURE void * +static void * memcheck(void *ptr) { if (ptr == NULL) @@ -2878,7 +2878,7 @@ lowerit(char a) } /* case-insensitive equality */ -static ATTRIBUTE_PURE bool +static bool ciequal(register const char *ap, register const char *bp) { while (lowerit(*ap) == lowerit(*bp++)) @@ -2887,7 +2887,7 @@ ciequal(register const char *ap, register const char *bp) return false; } -static ATTRIBUTE_PURE bool +static bool itsabbr(register const char *abbr, register const char *word) { if (lowerit(*abbr) != lowerit(*word)) @@ -2901,7 +2901,7 @@ itsabbr(register const char *abbr, register const char *word) return true; } -static ATTRIBUTE_PURE const struct lookup * +static const struct lookup * byword(const char *word, const struct lookup *table) { register const struct lookup * foundlp; -- 2.9.4
For example, when the context is weekdays, the old, buggy code rejected both "Sa" and "Su" as ambiguous abbreviations. * NEWS: Document this. * zic.c (ciprefix): New function. (byword): Use it to fix bug in abbreviation determination. Warn if an unambiguous abbreviation is not portable to pre-2017c zic. --- NEWS | 7 +++++++ zic.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 1af7b69..d22d561 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,13 @@ Unreleased, experimental changes in civil timekeeping. (Thanks to Robert Elz and Bradley White for noticing glitches in the code that uncovered this problem.) + zic now allows unambiguous abbreviations like "Sa" and "Su" for + weekdays; formerly it rejected them due to a bug. Conversely, zic + no longer considers non-prefixes to be abbreviations; for example, + it no longer accepts "lF" as an abbreviation for "lastFriday". + Also, zic warns about the undocumented usage with a "last-" + prefix, e.g., "last-Fri". + 'make BACKWARD=' now suppresses backward-compatibility names like 'US/Pacific' that are defined in the 'backward' and 'pacificnew' files. diff --git a/zic.c b/zic.c index f57d346..c2737e1 100644 --- a/zic.c +++ b/zic.c @@ -2901,6 +2901,19 @@ itsabbr(register const char *abbr, register const char *word) return true; } +/* Return true if ABBR is an initial prefix of WORD, ignoring ASCII case. */ + +static bool +ciprefix(char const *abbr, char const *word) +{ + do + if (!*abbr) + return true; + while (lowerit(*abbr++) == lowerit(*word++)); + + return false; +} + static const struct lookup * byword(const char *word, const struct lookup *table) { @@ -2909,6 +2922,20 @@ byword(const char *word, const struct lookup *table) if (word == NULL || table == NULL) return NULL; + + /* If TABLE is LASTS and the word starts with "last" followed + by a non-'-', skip the "last" and look in WDAY_NAMES instead. + Warn about any usage of the undocumented prefix "last-". */ + if (table == lasts && ciprefix("last", word) && word[4]) { + if (word[4] == '-') + warning(_("\"%s\" is undocumented; use \"last%s\" instead"), + word, word + 5); + else { + word += 4; + table = wday_names; + } + } + /* ** Look for exact match. */ @@ -2920,11 +2947,25 @@ byword(const char *word, const struct lookup *table) */ foundlp = NULL; for (lp = table; lp->l_word != NULL; ++lp) - if (itsabbr(word, lp->l_word)) { + if (ciprefix(word, lp->l_word)) { if (foundlp == NULL) foundlp = lp; else return NULL; /* multiple inexact matches */ } + + /* Warn about any backward-compatibility issue with pre-2017c zic. */ + if (foundlp) { + bool pre_2017c_match = false; + for (lp = table; lp->l_word; lp++) + if (itsabbr(word, lp->l_word)) { + if (pre_2017c_match) { + warning(_("\"%s\" is ambiguous in pre-2017c zic"), word); + break; + } + pre_2017c_match = true; + } + } + return foundlp; } -- 2.9.4
participants (1)
-
Paul Eggert