public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
From: Takashi Yano <tyan0@sourceware.org>
To: newlib-cvs@sourceware.org
Subject: [newlib-cygwin] newlib: nl_langinfo: Fix a bug of time stuff.
Date: Fri, 24 Nov 2023 10:37:38 +0000 (GMT)	[thread overview]
Message-ID: <20231124103738.8EF083858D3C@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0e961f582a315fd6f13b8e924f58af6057558348

commit 0e961f582a315fd6f13b8e924f58af6057558348
Author: Takashi Yano <takashi.yano@nifty.ne.jp>
Date:   Thu Nov 23 20:00:55 2023 +0900

    newlib: nl_langinfo: Fix a bug of time stuff.
    
    Previously, e.g. nl_langinfo(_NL_TIME_WMONTH_1) returns "February"
    due to the bug. Similarly, nl_langinfo(_NL_TIME_WWDAY_1) returns
    "Mon". This occurs because wide char month and weekday arrays are
    pointed off-by-one (e.g. the array wmon[12] is reffered as wmon[1-12]
    rather than wmon[0-11]). This patch fixes that.
    
    Fixes: d47d5b850bed ("Extend locale support to maintain wide char values of native strings")
    Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
    Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>

Diff:
---
 newlib/libc/locale/nl_langinfo.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/newlib/libc/locale/nl_langinfo.c b/newlib/libc/locale/nl_langinfo.c
index aaa1aef86..c34a7d131 100644
--- a/newlib/libc/locale/nl_langinfo.c
+++ b/newlib/libc/locale/nl_langinfo.c
@@ -78,6 +78,7 @@ static struct _nl_item_t
   _NLITEM (ctype, woutdigits[8]),
   _NLITEM (ctype, woutdigits[9]),
   _NLITEM (time, codeset),
+  _NLITEM (time, wmon[0]),
   _NLITEM (time, wmon[1]),
   _NLITEM (time, wmon[2]),
   _NLITEM (time, wmon[3]),
@@ -89,7 +90,7 @@ static struct _nl_item_t
   _NLITEM (time, wmon[9]),
   _NLITEM (time, wmon[10]),
   _NLITEM (time, wmon[11]),
-  _NLITEM (time, wmon[12]),
+  _NLITEM (time, wmonth[0]),
   _NLITEM (time, wmonth[1]),
   _NLITEM (time, wmonth[2]),
   _NLITEM (time, wmonth[3]),
@@ -101,21 +102,20 @@ static struct _nl_item_t
   _NLITEM (time, wmonth[9]),
   _NLITEM (time, wmonth[10]),
   _NLITEM (time, wmonth[11]),
-  _NLITEM (time, wmonth[12]),
+  _NLITEM (time, wwday[0]),
   _NLITEM (time, wwday[1]),
   _NLITEM (time, wwday[2]),
   _NLITEM (time, wwday[3]),
   _NLITEM (time, wwday[4]),
   _NLITEM (time, wwday[5]),
   _NLITEM (time, wwday[6]),
-  _NLITEM (time, wwday[7]),
+  _NLITEM (time, wweekday[0]),
   _NLITEM (time, wweekday[1]),
   _NLITEM (time, wweekday[2]),
   _NLITEM (time, wweekday[3]),
   _NLITEM (time, wweekday[4]),
   _NLITEM (time, wweekday[5]),
   _NLITEM (time, wweekday[6]),
-  _NLITEM (time, wweekday[7]),
   _NLITEM (time, wX_fmt),
   _NLITEM (time, wx_fmt),
   _NLITEM (time, wc_fmt),

                 reply	other threads:[~2023-11-24 10:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231124103738.8EF083858D3C@sourceware.org \
    --to=tyan0@sourceware.org \
    --cc=newlib-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).