From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/10333 Path: news.gmane.org!not-for-mail From: Julien Ramseier Newsgroups: gmane.linux.lib.musl.general Subject: [PATCH] strftime: fix %y format Date: Mon, 25 Jul 2016 21:56:25 +0200 Message-ID: <9F9B8A2F-E99E-4F88-94BF-26BF4A737DDE@gmail.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 9.2 \(3112\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1469476607 32386 80.91.229.3 (25 Jul 2016 19:56:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 25 Jul 2016 19:56:47 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-10346-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jul 25 21:56:46 2016 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1bRlza-00037W-42 for gllmg-musl@m.gmane.org; Mon, 25 Jul 2016 21:56:46 +0200 Original-Received: (qmail 15411 invoked by uid 550); 25 Jul 2016 19:56:42 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 15376 invoked from network); 25 Jul 2016 19:56:38 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-transfer-encoding:subject:message-id:date:to :mime-version; bh=EI3oOUBS1lyTByZ4ofnXFEFokSLajDei7DT4qKNSThU=; b=hL+nR2dbD/C2Dc3mTHm7yGCOArxPv5YS/ykokuZUT7x55zZDWG/aENk3cdJndShcSb jhF1xIwUWpNjyLzyobg5cuqQKlkM67HJ8iK+yQh3WdjCSxzk4rqGH3fDmIppHxbd0muU 9UTYcxjMqaHgTgktew6sdrPC2Td/lyvDl5tmcoOZXQu6BuHnOUBwrXHW/Z9O09Zw5x/+ Av/AdvanTf5IRdRH4NC0jnUWKwabxfcnGRmk/3Jjg1rWJ2A8ycI+qeG3VWN2le4tTltz au8+yVWrwszBcfAftyQJ4OfqKzpEb/iHlPvZXT6hJv8sOXofZPEpZB6A6pkqAgfNrPF8 6AXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:content-transfer-encoding:subject :message-id:date:to:mime-version; bh=EI3oOUBS1lyTByZ4ofnXFEFokSLajDei7DT4qKNSThU=; b=fQjG1g1gnzXfHVrqdefOhBuC9gUfpxedIDFRuhtTgb3Aj2niTxh3RIyqHkIXQjcZpc xzHPR/qIbL5dTlRAfJf7JNFXxmDDNvLbfluW3NzgIlqGP234exeiWi+ZYP2UoXVZWc7A ygfGXVvCHO+a/MeDbiCwj/CdRH+WTI/Dj1gqho83iCO1RjchX9FQeQsqVerCaNCcdtYC dRJPwNo3vn0ExvwMvMs4jY502FwYdD3VFribzg+fKthTzqhLun6aponfMZ0Jq5QhJFFK /k7efvABPXfLfz9cl46YKBkpS/nm1UzWWKtsFYGVvFI630kZ4eHgZIQUjDJRhYYbfEZu WK4A== X-Gm-Message-State: AEkoous90MgmLGNcmFlhYi5J58ozfRGaGlIe2HdmT4RnY7nLut2DOxUaORSo9PpDW6Ynww== X-Received: by 10.194.58.112 with SMTP id p16mr17452966wjq.24.1469476586973; Mon, 25 Jul 2016 12:56:26 -0700 (PDT) X-Mailer: Apple Mail (2.3112) Xref: news.gmane.org gmane.linux.lib.musl.general:10333 Archived-At: The following patch fixes the '%y' format in strftime/wcsftime when using negative tm_year values. Results: tm_year year before after ----------------------------------------- -2901 -1001 "-1" "01" -2900 -1000 "00" "00" -2899 -999 "-99" "99" -901 999 "-1" "99" -900 1000 "00" "00" -899 1001 "-99" "01" -1 1899 "-1" "99" 0 1900 "00" "00" 1 1901 "01" "01" --- src/time/strftime.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/time/strftime.c b/src/time/strftime.c index f1ccc4d..a303920 100644 --- a/src/time/strftime.c +++ b/src/time/strftime.c @@ -166,7 +166,8 @@ const char *__strftime_fmt_1(char (*s)[100], size_t = *l, int f, const struct tm * item =3D T_FMT; goto nl_strftime; case 'y': - val =3D tm->tm_year % 100; + val =3D (tm->tm_year + 1900LL) % 100; + if (val < 0) val =3D -val; goto number; case 'Y': val =3D tm->tm_year + 1900LL; -- 2.9.2