[glib/glib-2-30] gtimezone: consider a leading : in TZ environment variable
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib/glib-2-30] gtimezone: consider a leading : in TZ environment variable
- Date: Sun, 11 Mar 2012 22:23:19 +0000 (UTC)
commit 649e3880b7970fcaef5bbd2bfda62d99194860a7
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Thu Nov 17 00:52:59 2011 +0100
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
glib/gtimezone.c | 12 +++++++++++-
1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/glib/gtimezone.c b/glib/gtimezone.c
index 780a388..178c945 100644
--- a/glib/gtimezone.c
+++ b/glib/gtimezone.c
@@ -366,6 +366,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;
@@ -374,7 +378,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");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]