aboutsummaryrefslogtreecommitdiffstats
path: root/skeletons/GeneralizedTime.c
diff options
context:
space:
mode:
authorvlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2004-08-12 07:47:03 +0000
committervlm <vlm@59561ff5-6e30-0410-9f3c-9617f08c8826>2004-08-12 07:47:03 +0000
commitd36922829e023ba658caf575026c2e77bb45e58d (patch)
tree892568321e81e4f7dd4abf4358b7fecfa59bf7c2 /skeletons/GeneralizedTime.c
parent348a37ad8774b356f121a52c78c2e08085bb1791 (diff)
portability
git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@104 59561ff5-6e30-0410-9f3c-9617f08c8826
Diffstat (limited to 'skeletons/GeneralizedTime.c')
-rw-r--r--skeletons/GeneralizedTime.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/skeletons/GeneralizedTime.c b/skeletons/GeneralizedTime.c
index f17b4393..4d1b3908 100644
--- a/skeletons/GeneralizedTime.c
+++ b/skeletons/GeneralizedTime.c
@@ -36,15 +36,19 @@ static struct tm *gmtime_r(time_t *tloc, struct tm *result) {
static time_t timegm(struct tm *tm) {
time_t tloc;
char *tz;
+ char *buf;
tz = getenv("TZ");
- setenv("TZ", "", 1);
+ _putenv("TZ=UTC");
tzset();
tloc = mktime(tm);
- if (tz)
- setenv("TZ", tz, 1);
- else
- unsetenv("TZ");
+ if (tz) {
+ buf = alloca(strlen(tz) + 4);
+ sprintf(buf, "TZ=%s", tz);
+ } else {
+ buf = "TZ=";
+ }
+ _putenv(buf);
tzset();
return tloc;
}