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:
Oliver Tappe
2013-06-23 16:43:23 +02:00
parent b4dc51b39a
commit 51bce887cd
3 changed files with 33 additions and 1258 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
SubDir HAIKU_TOP src system libroot posix time ; SubDir HAIKU_TOP src system libroot posix time ;
# for localtime.c strftime.c # for localtime.c strftime.c
SubDirCcFlags -DNOID -DTZDIR='get_timezones_directory()' -DUSG_COMPAT SubDirCcFlags -DNOID -DUSG_COMPAT -DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone
-DTM_GMTOFF=tm_gmtoff -DTM_ZONE=tm_zone -DPCTS=1 -DSTD_INSPIRED ; -DPCTS=1 -DSTD_INSPIRED ;
UsePrivateHeaders UsePrivateHeaders
libroot libroot
+17 -8
View File
@@ -21,8 +21,8 @@ using BPrivate::Libroot::gLocaleBackend;
using BPrivate::Libroot::LocaleBackend; using BPrivate::Libroot::LocaleBackend;
static char sStandardTZName[64] = { "???" }; static char sStandardTZName[64] = { "GMT" };
static char sDaylightSavingTZName[64] = { "???" }; static char sDaylightSavingTZName[64] = { "GMT" };
char* tzname[2] = { char* tzname[2] = {
@@ -33,6 +33,12 @@ long timezone = 0;
int daylight = 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 extern "C" void
tzset(void) tzset(void)
{ {
@@ -73,8 +79,9 @@ localtime_r(const time_t* inTime, struct tm* tmOut)
return tmOut; return tmOut;
} }
__set_errno(ENOSYS); // without a locale backend, there are no timezones, so we fall back to
return NULL; // 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; return tmOut;
} }
__set_errno(ENOSYS); // without a locale backend, we fall back to using a basic gmtime_r
return NULL; // implementation.
return __gmtime_r_fallback(inTime, tmOut);
} }
@@ -131,6 +139,7 @@ mktime(struct tm* inTm)
return timeOut; return timeOut;
} }
__set_errno(ENOSYS); // without a locale backend, we fall back to using a basic gmtime_r
return -1; // implementation.
return __mktime_fallback(inTm);
} }
File diff suppressed because it is too large Load Diff