diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2016-03-26 15:58:44 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2016-03-26 15:59:21 -0400 |
commit | a330da405285c57e3a46c5fe12d1f555340e9e15 (patch) | |
tree | 11c5b620c311e83eb5e73a8ed4a57f39a88d4c6e /src | |
parent | de371e68a598868b412f2b5b4211f912a519c491 (diff) | |
download | postgresql-a330da405285c57e3a46c5fe12d1f555340e9e15.tar.gz postgresql-a330da405285c57e3a46c5fe12d1f555340e9e15.zip |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/timezone/zic.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/src/timezone/zic.c b/src/timezone/zic.c index 1a7ec68d7c0..9fc20c6bac7 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -2792,30 +2792,15 @@ newabbr(const char *string) const char *cp; 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((unsigned char) *cp) && - isalpha((unsigned char) *cp)) + while (isalpha((unsigned char) *cp) || ('0' <= *cp && *cp <= '9') + || *cp == '-' || *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 (noise && cp - string < 3) + wp = _("time zone abbreviation has fewer than 3 characters"); 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((unsigned char) *cp) && - isdigit((unsigned char) *cp)) - if (*cp++ == '1' && - *cp >= '0' && *cp <= '4') - ++cp; - } + wp = _("time zone abbreviation has too many characters"); if (*cp != '\0') wp = _("time zone abbreviation differs from POSIX standard"); if (wp != NULL) |