Modernize zic's test for valid timezone abbreviations.

We really need to sync all of our IANA-derived timezone code with upstream,
but that's going to be a large patch and I certainly don't care to shove
such a thing into stable branches immediately before a release.  As a
stopgap, copy just the tzcode2016c logic that checks validity of timezone
abbreviations.  This prevents getting multiple "time zone abbreviation
differs from POSIX standard" bleats with tzdata 2014b and later.
REL9_1_STABLE
Tom Lane 10 years ago
parent e5fd35cc54
commit 528f112b04
  1. 25
      src/timezone/zic.c

@ -2771,30 +2771,15 @@ newabbr(const char *string)
const char *cp; const char *cp;
char *wp; 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; cp = string;
wp = NULL; wp = NULL;
while (isascii((unsigned char) *cp) && while (isalpha((unsigned char) *cp) || ('0' <= *cp && *cp <= '9')
isalpha((unsigned char) *cp)) || *cp == '-' || *cp == '+')
++cp; ++cp;
if (cp - string == 0) if (noise && cp - string < 3)
wp = _("time zone abbreviation lacks alphabetic at start"); wp = _("time zone abbreviation has fewer than 3 characters");
if (noise && cp - string > 3)
wp = _("time zone abbreviation has more than 3 alphabetics");
if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN) if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
wp = _("time zone abbreviation has too many alphabetics"); wp = _("time zone abbreviation has too many characters");
if (wp == NULL && (*cp == '+' || *cp == '-'))
{
++cp;
if (isascii((unsigned char) *cp) &&
isdigit((unsigned char) *cp))
if (*cp++ == '1' &&
*cp >= '0' && *cp <= '4')
++cp;
}
if (*cp != '\0') if (*cp != '\0')
wp = _("time zone abbreviation differs from POSIX standard"); wp = _("time zone abbreviation differs from POSIX standard");
if (wp != NULL) if (wp != NULL)

Loading…
Cancel
Save