From 966b0a7e0ac5a1e7997a6c2ce3f2ee415e90da31 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 12 Nov 2016 17:40:26 -0800 Subject: [PATCH] strftime: tune %q * lib/strftime.c (__strftime_internal): Assume tp->tm_mon is in range. --- ChangeLog | 3 +++ lib/strftime.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a748d7a02f..2a61a471e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2016-11-12 Paul Eggert + strftime: tune %q + * lib/strftime.c (__strftime_internal): Assume tp->tm_mon is in range. + Merge strftime.c changes from glibc This incorporates: 2007-10-16 [BZ #5184] Add tzset_called argument diff --git a/lib/strftime.c b/lib/strftime.c index 00870f63aa..b906e3cae6 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -1159,7 +1159,7 @@ __strftime_internal (STREAM_OR_CHAR_T *s, STRFTIME_ARG (size_t maxsize) #endif case L_('q'): /* GNU extension. */ - DO_SIGNED_NUMBER (1, tp->tm_mon < -3, tp->tm_mon / 3 + 1U); + DO_SIGNED_NUMBER (1, false, ((tp->tm_mon * 11) >> 5) + 1); break; case L_('R'): -- 2.39.5