Tom Ryder wrote:

> Hi Bram, thanks for looking at the issue.
> 
> On Wed, Jun 12, 2019 at 07:34:36PM +0200, Bram Moolenaar wrote:
> >I would guess that localtime() always sets the variables, while 
> >localtime_r() is not guaranteed to do that.  But it does NOT say that 
> >calling tzset() before localtime_r() is required to get correct 
> >results.
> 
> That is true.  I am reporting the issue with a patch that worked for me, 
> and quoting from what seemed to me to be the relevant part of the spec.
> 
> I don't know if this is the best way to restore the behaviour I want.  
> Similar to the example code in the patch, I had been setting and 
> restoring the $TZ variable within Vim to set the time zone for a call to 
> strftime(), in order to get UTC timestamps. Restoring the previous time 
> zone afterwards worked correctly until the localtime_r patch.  After 
> that patch, it no longer worked.  With a call to tzset() added before 
> those calls, per my patch, it works again.
> 
> >Perhaps tzset() should only be called once, or perhaps only when the 
> >$TZ variable was changed?  
> 
> The latter idea seems good to me.  Perhaps even a new function 
> settimezone() could be added, or a new optional parameter for 
> strftime()?

My current setup doesn't even have $TZ set.  Thus calling tzset() every
time would just add overhead.

Can you make a patch that adds a function to call localtime_r() and
keeps the current value of $TZ, and calls tzset() only when it changes?

-- 
"Hit any key to continue" is very confusing when you have two keyboards.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/201906131840.x5DIeRqB017561%40masaka.moolenaar.net.
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui