emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting TZ in set_time_zone_rule


From: Paul Eggert
Subject: Re: Setting TZ in set_time_zone_rule
Date: Fri, 30 Nov 2012 12:47:14 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

On 11/30/12 10:52, Eli Zaretskii wrote:

>> set_time_zone_rule (0) needs to unset TZ.
> 
> Do we ever call it that way?

Yes, if TZ is unset in the environment.

>>>>> Also, is unsetenv("TZ") the same as putenv("TZ=") ?
>>> Yes.
>>
>> Doesn't the former unset TZ, and the latter set TZ to the empty string?
> 
> The implementation I saw unset TZ in both cases.

Which implementation is that?  It does not conform to POSIX.
At any rate, we can't rely on that behavior.

I just thought of another problem: setenv has a memory leak,
by design: it leaks the memory holding the previous value of
the environment variable.  So I guess we should use putenv
after all.  We can use the gnulib putenv module for hosts that
lack putenv.  We'll also need unsetenv (but not setenv).

I'll look into drafting a patch along these lines this weekend.
The code is a bit of a mess in this area, unfortunately.
Among other things, the current uses of setenv and putenv
assume that they always succeed, but they can fail just as
malloc can fail, due to lack of memory.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]