* src/backend/file/sixtp-utils.c (gnc_timegm): switch from putenv

to gnc_setenv and gnc_unsetenv.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5923 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Rob Browning 2001-11-21 02:36:31 +00:00
parent 23e0ba42d2
commit 7b546af901

View File

@ -365,19 +365,26 @@ gnc_timegm (struct tm *tm)
char *put_str; char *put_str;
char *old_tz; char *old_tz;
old_tz = g_strdup (getenv ("TZ")); old_tz = getenv ("TZ");
putenv ("TZ=UTC");
/* FIXME: there's no way to report this error to the caller. */
if(gnc_setenv("TZ", "UTC", 1) != 0)
g_error ("gnc_timegm couldn't switch the TZ.");
result = mktime (tm); result = mktime (tm);
put_str = g_strdup_printf ("TZ=%s", old_tz ? old_tz : ""); if(old_tz)
putenv (put_str); {
/* FIXME: there's no way to report this error to the caller. */
/* We can't free put_str since it is used directly. if(gnc_setenv("TZ", old_tz, 1) != 0)
* This is a memory leak, but how to solve it? *? g_error ("gnc_timegm couldn't switch the TZ back.");
/* g_free (put_str); */ }
g_free (old_tz); else
{
/* FIXME: there's no way to report this error to the caller. */
if(gnc_unsetenv("TZ") != 0)
g_error ("gnc_timegm couldn't restore the TZ to undefined.");
}
return result; return result;
} }
#endif #endif