From: Andrew W. N. <and...@gm...> - 2009-02-11 17:34:02
|
Attached patch avoids using of the global variable 'timezone' (from the time.h) in favor of struct tm.tm_gmtoff field (if available). Reason: portability. The FreeBSD, for example, has global symbol 'timezone', but it bound not to the variable, but to the function: char *timezone(int, int); therefore, current unpatched code is compiliable, but, obviously, cannot work correctly because address (or part of address on the 64bit systemt) of the function is used instead of timezone shift. Why I preferred to check tm_gmtoff and fallback to the timezone variable instead of checking both and use timezone variable at the first and fallback to the tm_gmtoff only as second? Just because writting of the autoconf test, which could to test, whether symbol is the variable indeed is non-trivial task, at least I don't know how to write such. :-( Using of the localtime_r() in favor of localtime(), and protecting non-threadsafe localtime() by G_LOCK() is made for thread safety. It is a library and, threfore, extra paranoia cannot harm. -- Andrew W. Nosenko <and...@gm...> |