diff options
author | DJ Delorie <dj@redhat.com> | 2019-03-27 17:44:51 -0400 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2019-04-01 14:19:16 -0400 |
commit | e0e4c321c3145b6ac0e8f6e894f87790cf9437ce (patch) | |
tree | 097f4b5ebbd34f57a945f24e6182b96d104b3165 /time/strptime_l.c | |
parent | alpha: Improve sysdeps/alpha/divqu.S and sysdeps/alpha/remqu.S (diff) | |
download | glibc-e0e4c321c3145b6ac0e8f6e894f87790cf9437ce.tar.gz glibc-e0e4c321c3145b6ac0e8f6e894f87790cf9437ce.tar.bz2 glibc-e0e4c321c3145b6ac0e8f6e894f87790cf9437ce.zip |
Fix strptime era handling, add more strftime tests [BZ #24394]
Test the transition points between all the currently listed Japanese
era name changes. This includes testing the transition between the
first year date and the second year date. This test will help test
the upcoming Japanese era name change.
Also fixes a fencepost error where the era name isn't properly parsed
by strptime in the last (partial) year of the era.
Example: if an era change happens in Feb 1990, and again in Aug 1995,
that's 5.5 years long, but the 0.5 year wasn't accounted for.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Diffstat (limited to 'time/strptime_l.c')
-rw-r--r-- | time/strptime_l.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/time/strptime_l.c b/time/strptime_l.c index e19b9a15dd..7436a168b7 100644 --- a/time/strptime_l.c +++ b/time/strptime_l.c @@ -907,10 +907,15 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, { int delta = ((tm->tm_year - era->offset) * era->absolute_direction); + /* The difference between two sets of years + does not include the final year itself, + therefore add 1 to the difference to + account for that final year. */ match = (delta >= 0 && delta < (((int64_t) era->stop_date[0] - (int64_t) era->start_date[0]) - * era->absolute_direction)); + * era->absolute_direction + + 1)); } if (! match) return NULL; @@ -928,10 +933,12 @@ __strptime_internal (const char *rp, const char *fmt, struct tm *tmp, { int delta = ((tm->tm_year - era->offset) * era->absolute_direction); + /* See comment above about year difference + 1. */ if (delta >= 0 && delta < (((int64_t) era->stop_date[0] - (int64_t) era->start_date[0]) - * era->absolute_direction)) + * era->absolute_direction + + 1)) { s.decided = loc; break; |