unsetenv() patch for TZ

Corinna Vinschen vinschen@redhat.com
Mon Jul 11 19:24:00 GMT 2011


On Jul  8 14:24, Howland Craig D (Craig) wrote:
> The current implementation of _setenv_r() looks to see if the
> environment
> variable being set (or changed) is TZ, calling tzset() when it is so
> that
> the timezone is automatically kept matching the environment without user
> intervention.
>  
> However, _unsetenv_r() does not provide the same feature, likely leading
> to a problem when TZ is unset.
>  
> POSIX says nothing about this feature under setenv() and unsetenv(),
> so it would be possible to make the behavior consistent by either adding
> to unset or removing from set.  However, adding to unset seems far less
> likely to cause backwards-compatibility problems than removing from set.
> 
> The attached patch addresses the issue by adding a tzset() call to
> _unsetenv_r() when TZ is unset.

Thanks for the patch, but I'm wondering if calling tzset() in _setenv_r
is the right thing to do.  I had a look into SUSv4 and it appears that
the only functions which are supposed to change the timezone information
are ctime, localtime, mktime, strftime, and an explicit call to tzset by
the application.

"Appears", because I couldn't find any definitive answer.

Having said that, shouldn't the tzset() call better be removed in
_setenv_r and called in the affected functions?


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat



More information about the Newlib mailing list