strptime: swapped the order of the constants to make musl's implementation Haiku-compatible
Change-Id: Iecfe13dcf8e8216e274ed1f194e1c891042f6bd1 Reviewed-on: https://review.haiku-os.org/c/haiku/+/5635 Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org> Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com> Reviewed-by: Niels Sascha Reedijk <niels.reedijk@gmail.com>
This commit is contained in:
parent
c68590fd4d
commit
244a9826b8
@ -34,12 +34,23 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
|
||||
switch (*f++) {
|
||||
case 'a': case 'A':
|
||||
dest = &tm->tm_wday;
|
||||
// Haiku defines this constants the opposite way musl/Glibc does (first the full
|
||||
// version, then the abbreviated version). This results in strptime failing to
|
||||
// match the patterns. Keep this to make musl's strptime Haiku-compatible.
|
||||
#ifdef __HAIKU__
|
||||
min = DAY_1;
|
||||
#else
|
||||
min = ABDAY_1;
|
||||
#endif
|
||||
range = 7;
|
||||
goto symbolic_range;
|
||||
case 'b': case 'B': case 'h':
|
||||
dest = &tm->tm_mon;
|
||||
#ifdef __HAIKU__ // To make musl's strptime Haiku-compatible
|
||||
min = MON_1;
|
||||
#else
|
||||
min = ABMON_1;
|
||||
#endif
|
||||
range = 12;
|
||||
goto symbolic_range;
|
||||
case 'c':
|
||||
@ -183,7 +194,11 @@ char *strptime(const char *restrict s, const char *restrict f, struct tm *restri
|
||||
*dest -= adj;
|
||||
goto update;
|
||||
symbolic_range:
|
||||
#ifdef __HAIKU__ // To make musl's strptime Haiku-compatible
|
||||
for (i=0; i<=2*range-1; i++) {
|
||||
#else
|
||||
for (i=2*range-1; i>=0; i--) {
|
||||
#endif
|
||||
ex = nl_langinfo(min+i);
|
||||
len = strlen(ex);
|
||||
if (strncasecmp(s, ex, len)) continue;
|
||||
|
Loading…
Reference in New Issue
Block a user