diff options
author | Mike Blumenkrantz <zmike@osg.samsung.com> | 2016-03-24 17:37:27 -0400 |
---|---|---|
committer | Mike Blumenkrantz <zmike@osg.samsung.com> | 2016-03-24 17:37:50 -0400 |
commit | 5edd64c849ec45aa04d45a1c634775c71108e04b (patch) | |
tree | 4481b9b67c5adf2fa3df2fd89d16f714d70113fe /src/lib/embryo/embryo_time.c | |
parent | ab4bfcf250ce5e6c8897b66ff632b6b20debf6ec (diff) |
embryo: don't mess with env vars in tzdate if no tz is passed
Diffstat (limited to 'src/lib/embryo/embryo_time.c')
-rw-r--r-- | src/lib/embryo/embryo_time.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/lib/embryo/embryo_time.c b/src/lib/embryo/embryo_time.c index e8b481e350..ce167cb4ff 100644 --- a/src/lib/embryo/embryo_time.c +++ b/src/lib/embryo/embryo_time.c | |||
@@ -107,7 +107,7 @@ _embryo_time_tzdate(Embryo_Program *ep, Embryo_Cell *params) | |||
107 | tzenv = getenv("TZ"); | 107 | tzenv = getenv("TZ"); |
108 | if (tzenv) | 108 | if (tzenv) |
109 | strncpy(prevtz, tzenv, sizeof(prevtz) - 1); | 109 | strncpy(prevtz, tzenv, sizeof(prevtz) - 1); |
110 | if (tz) | 110 | if (tz && tz[0]) |
111 | { | 111 | { |
112 | setenv("TZ", tz, 1); | 112 | setenv("TZ", tz, 1); |
113 | tzset(); | 113 | tzset(); |
@@ -115,11 +115,14 @@ _embryo_time_tzdate(Embryo_Program *ep, Embryo_Cell *params) | |||
115 | gettimeofday(&timev, NULL); | 115 | gettimeofday(&timev, NULL); |
116 | tt = (time_t)(timev.tv_sec); | 116 | tt = (time_t)(timev.tv_sec); |
117 | tm = localtime(&tt); | 117 | tm = localtime(&tt); |
118 | if (prevtz[0]) | 118 | if (tz && tz[0]) |
119 | setenv("TZ", prevtz, 1); | 119 | { |
120 | else | 120 | if (prevtz[0]) |
121 | unsetenv("TZ"); | 121 | setenv("TZ", prevtz, 1); |
122 | tzset(); | 122 | else |
123 | unsetenv("TZ"); | ||
124 | tzset(); | ||
125 | } | ||
123 | if (tm) | 126 | if (tm) |
124 | { | 127 | { |
125 | Embryo_Cell *cptr; | 128 | Embryo_Cell *cptr; |