mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
* 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:
parent
23e0ba42d2
commit
7b546af901
@ -365,19 +365,26 @@ gnc_timegm (struct tm *tm)
|
||||
char *put_str;
|
||||
char *old_tz;
|
||||
|
||||
old_tz = g_strdup (getenv ("TZ"));
|
||||
putenv ("TZ=UTC");
|
||||
old_tz = getenv ("TZ");
|
||||
|
||||
/* 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);
|
||||
|
||||
put_str = g_strdup_printf ("TZ=%s", old_tz ? old_tz : "");
|
||||
putenv (put_str);
|
||||
|
||||
/* We can't free put_str since it is used directly.
|
||||
* This is a memory leak, but how to solve it? *?
|
||||
/* g_free (put_str); */
|
||||
g_free (old_tz);
|
||||
|
||||
if(old_tz)
|
||||
{
|
||||
/* FIXME: there's no way to report this error to the caller. */
|
||||
if(gnc_setenv("TZ", old_tz, 1) != 0)
|
||||
g_error ("gnc_timegm couldn't switch the TZ back.");
|
||||
}
|
||||
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;
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user