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 *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
|
||||||
|
Loading…
Reference in New Issue
Block a user