[glib: 2/8] gtimezone: support POSIX 1003.1-2001 quoted TZ abbreviations
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/8] gtimezone: support POSIX 1003.1-2001 quoted TZ abbreviations
- Date: Fri, 17 Jul 2020 13:54:59 +0000 (UTC)
commit bc78f0ad2711bc87609acbda927a1cc38ca49516
Author: Paul Eggert <eggert cs ucla edu>
Date: Thu Jul 16 12:41:49 2020 -0700
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
glib/gtimezone.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index 358b52aa40..296af3dd01 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]