Commit bc78f0ad authored by Paul Eggert's avatar Paul Eggert

gtimezone: support POSIX 1003.1-2001 quoted TZ abbreviations

TZ strings like '<-03>3' were introduced in POSIX 1003.1-2001 and
are currently specified in:
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_03
parent 21b00035
......@@ -1366,14 +1366,24 @@ parse_identifier_boundary (gchar **pos, TimeZoneDate *target)
static gboolean
set_tz_name (gchar **pos, gchar *buffer, guint size)
{
gboolean quoted = **pos == '<';
gchar *name_pos = *pos;
guint len;
/* Name is ASCII alpha (Is this necessarily true?) */
while (g_ascii_isalpha (**pos))
++(*pos);
if (quoted)
{
name_pos++;
do
++(*pos);
while (g_ascii_isalnum (**pos) || **pos == '-' || **pos == '+');
if (**pos != '>')
return FALSE;
}
else
while (g_ascii_isalpha (**pos))
++(*pos);
/* Name should be three or more alphabetic characters */
/* Name should be three or more characters */
if (*pos - name_pos < 3)
return FALSE;
......@@ -1381,6 +1391,7 @@ set_tz_name (gchar **pos, gchar *buffer, guint size)
/* name_pos isn't 0-terminated, so we have to limit the length expressly */
len = *pos - name_pos > size - 1 ? size - 1 : *pos - name_pos;
strncpy (buffer, name_pos, len);
*pos += quoted;
return TRUE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment