8000 Modernize zic's test for valid timezone abbreviations. · prmdeveloper/postgres@8ea71fd · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 8ea71fd

Browse files
committed
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.
1 parent 8e16592 commit 8ea71fd

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

src/timezone/zic.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2796,30 +2796,15 @@ newabbr(const char *string)
27962796
const char *cp;
27972797
char *wp;
27982798

2799-
/*
2800-
* Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics optionally
2801-
* followed by a + or - and a number from 1 to 14.
2802-
*/
28032799
cp = string;
28042800
wp = NULL;
2805-
while (isascii((unsigned char) *cp) &&
2806-
isalpha((unsigned char) *cp))
2801+
while (isalpha((unsigned char) *cp) || ('0' <= *cp && *cp <= '9')
2802+
|| *cp == '-' || *cp == '+')
28072803
++cp;
2808-
if (cp - string == 0)
2809-
wp = _("time zone abbreviation lacks alphabetic at start");
2810-
if (noise && cp - string > 3)
2811-
wp = _("time zone abbreviation has more than 3 alphabetics");
2804+
if (noise && cp - string < 3)
2805+
wp = _("time zone abbreviation has fewer than 3 characters");
28122806
if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
2813-
wp = _("time zone abbreviation has too many alphabetics");
2814-
if (wp == NULL && (*cp == '+' || *cp == '-'))
2815-
{
2816-
++cp;
2817-
if (isascii((unsigned char) *cp) &&
2818-
isdigit((unsigned char) *cp))
2819-
if (*cp++ == '1' &&
2820-
*cp >= '0' && *cp <= '4')
2821-
++cp;
2822-
}
2807+
wp = _("time zone abbreviation has too many characters");
28232808
if (*cp != '\0')
28242809
wp = _("time zone abbreviation differs from POSIX standard");
28252810
if (wp != NULL)

0 commit comments

Comments
 (0)
0