Fix behaviour of localtime(), gmtime() and mktime().
* In case the locale backend could not be loaded, these functions (and their reentrant counterparts) just returned an error. So we reactivate parts of the BSD-/Olson-implementation in localtime_fading_out.c in order to use them as fallback. * Cleanup localtime_fading_out.c (remove a lot of unused cruft).
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
SubDir HAIKU_TOP src system libroot posix time ;
|
||||
|
||||
# for localtime.c strftime.c
|
||||
SubDirCcFlags -DNOID -DTZDIR='get_timezones_directory()' -DUSG_COMPAT
|
||||
-DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DPCTS=1 -DSTD_INSPIRED ;
|
||||
SubDirCcFlags -DNOID -DUSG_COMPAT -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone
|
||||
-DPCTS=1 -DSTD_INSPIRED ;
|
||||
|
||||
UsePrivateHeaders
|
||||
libroot
|
||||
|
||||
@@ -21,8 +21,8 @@ using BPrivate::Libroot::gLocaleBackend;
|
||||
using BPrivate::Libroot::LocaleBackend;
|
||||
|
||||
|
||||
static char sStandardTZName[64] = { "???" };
|
||||
static char sDaylightSavingTZName[64] = { "???" };
|
||||
static char sStandardTZName[64] = { "GMT" };
|
||||
static char sDaylightSavingTZName[64] = { "GMT" };
|
||||
|
||||
|
||||
char* tzname[2] = {
|
||||
@@ -33,6 +33,12 @@ long timezone = 0;
|
||||
int daylight = 0;
|
||||
|
||||
|
||||
// These two functions are used as a fallback when the locale backend could not
|
||||
// be loaded. They are implemented in localtime_fading_out.c.
|
||||
extern "C" struct tm* __gmtime_r_fallback(const time_t* timep, struct tm* tmp);
|
||||
extern "C" time_t __mktime_fallback(struct tm* tmp);
|
||||
|
||||
|
||||
extern "C" void
|
||||
tzset(void)
|
||||
{
|
||||
@@ -73,8 +79,9 @@ localtime_r(const time_t* inTime, struct tm* tmOut)
|
||||
return tmOut;
|
||||
}
|
||||
|
||||
__set_errno(ENOSYS);
|
||||
return NULL;
|
||||
// without a locale backend, there are no timezones, so we fall back to
|
||||
// using a basic gmtime_r implementation.
|
||||
return __gmtime_r_fallback(inTime, tmOut);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,8 +112,9 @@ gmtime_r(const time_t* inTime, struct tm* tmOut)
|
||||
return tmOut;
|
||||
}
|
||||
|
||||
__set_errno(ENOSYS);
|
||||
return NULL;
|
||||
// without a locale backend, we fall back to using a basic gmtime_r
|
||||
// implementation.
|
||||
return __gmtime_r_fallback(inTime, tmOut);
|
||||
}
|
||||
|
||||
|
||||
@@ -131,6 +139,7 @@ mktime(struct tm* inTm)
|
||||
return timeOut;
|
||||
}
|
||||
|
||||
__set_errno(ENOSYS);
|
||||
return -1;
|
||||
// without a locale backend, we fall back to using a basic gmtime_r
|
||||
// implementation.
|
||||
return __mktime_fallback(inTm);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user