summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2011-11-17 00:52:59 +0100
committerGiovanni Campagna <gcampagna@src.gnome.org>2012-02-06 17:26:30 +0100
commit1faed130dc227f983f42f23df2a242bd004c4ac8 (patch)
tree2be1b559953bfdb5a98baffebbab2c57a9e00c95
parentb98b63187a24451411c88962bd82553652b198e0 (diff)
downloadglib-1faed130dc227f983f42f23df2a242bd004c4ac8.tar.gz
gtimezone: consider a leading : in TZ environment variable
When set to represent a zoneinfo file, TZ may start with :, therefore glib needs to check it and ignore the first char when building the resulting filename, or it won't be found. Also, the path could be absolute, in which case it is wrong to append /usr/share/timezone https://bugzilla.gnome.org/show_bug.cgi?id=664237
-rw-r--r--glib/gtimezone.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index 2785d2271..8195106e0 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -368,6 +368,10 @@ g_time_zone_new (const gchar *identifier)
{
gchar *filename;
+ /* identifier can be a relative or absolute path name;
+ if relative, it is interpreted starting from /usr/share/timezone
+ while the POSIX standard says it should start with :,
+ glibc allows both syntaxes, so we should too */
if (identifier != NULL)
{
const gchar *tzdir;
@@ -376,7 +380,13 @@ g_time_zone_new (const gchar *identifier)
if (tzdir == NULL)
tzdir = "/usr/share/zoneinfo";
- filename = g_build_filename (tzdir, identifier, NULL);
+ if (*identifier == ':')
+ identifier ++;
+
+ if (g_path_is_absolute (identifier))
+ filename = g_strdup (identifier);
+ else
+ filename = g_build_filename (tzdir, identifier, NULL);
}
else
filename = g_strdup ("/etc/localtime");