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

Skip to content

Commit 528f112

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 e5fd35c commit 528f112

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
@@ -2771,30 +2771,15 @@ newabbr(const char *string)
27712771
const char *cp;
27722772
char *wp;
27732773

2774-
/*
2775-
* Want one to ZIC_MAX_ABBR_LEN_WO_WARN alphabetics optionally
2776-
* followed by a + or - and a number from 1 to 14.
2777-
*/
27782774
cp = string;
27792775
wp = NULL;
2780-
while (isascii((unsigned char) *cp) &&
2781-
isalpha((unsigned char) *cp))
2776+
while (isalpha((unsigned char) *cp) || ('0' <= *cp && *cp <= '9')
2777+
|| *cp == '-' || *cp == '+')
27822778
++cp;
2783-
if (cp - string == 0)
2784-
wp = _("time zone abbreviation lacks alphabetic at start");
2785-
if (noise && cp - string > 3)
2786-
wp = _("time zone abbreviation has more than 3 alphabetics");
2779+
if (noise && cp - string < 3)
2780+
wp = _("time zone abbreviation has fewer than 3 characters");
27872781
if (cp - string > ZIC_MAX_ABBR_LEN_WO_WARN)
2788-
wp = _("time zone abbreviation has too many alphabetics");
2789-
if (wp == NULL && (*cp == '+' || *cp == '-'))
2790-
{
2791-
++cp;
2792-
if (isascii((unsigned char) *cp) &&
2793-
isdigit((unsigned char) *cp))
2794-
if (*cp++ == '1' &&
2795-
*cp >= '0' && *cp <= '4')
2796-
++cp;
2797-
}
2782+
wp = _("time zone abbreviation has too many characters");
27982783
if (*cp != '\0')
27992784
wp = _("time zone abbreviation differs from POSIX standard");
28002785
if (wp != NULL)

0 commit comments

Comments
 (0)
0