nixpkgs/pkgs/development/libraries/libical/respect-env-tzdir.patch
William A. Kennington III 5e790f0e17 libical: 1.0.0 -> 1.0.1
2015-03-26 17:29:57 -07:00

30 lines
989 B
Diff

diff --git a/src/libical/icaltz-util.c b/src/libical/icaltz-util.c
index fe984c9..22ba0a1 100644
--- a/src/libical/icaltz-util.c
+++ b/src/libical/icaltz-util.c
@@ -107,7 +107,7 @@ typedef struct
char charcnt[4];
} tzinfo;
-static char *search_paths [] = {"/usr/share/zoneinfo","/usr/lib/zoneinfo","/etc/zoneinfo","/usr/share/lib/zoneinfo"};
+static char *search_paths [] = {"/etc/zoneinfo"};
static char *zdir = NULL;
#define NUM_SEARCH_PATHS (sizeof (search_paths)/ sizeof (search_paths [0]))
@@ -194,6 +194,16 @@ set_zonedir (void)
const char *fname = ZONES_TAB_SYSTEM_FILENAME;
unsigned int i;
+ const char *env_tzdir = strdup (getenv ("TZDIR"));
+ if (env_tzdir) {
+ sprintf (file_path, "%s/%s", env_tzdir, fname);
+ if (!access (file_path, F_OK|R_OK)) {
+ zdir = env_tzdir;
+ return;
+ }
+ free (env_tzdir);
+ }
+
for (i = 0; i < NUM_SEARCH_PATHS; i++) {
sprintf (file_path, "%s/%s", search_paths [i], fname);
if (!access (file_path, F_OK|R_OK)) {