public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] newlib: ln_langinfo: Fix a bug of time stuff.
@ 2023-11-23 11:17 Takashi Yano
  2023-11-23 14:47 ` Takashi Yano
  2023-11-23 15:51 ` Corinna Vinschen
  0 siblings, 2 replies; 4+ messages in thread
From: Takashi Yano @ 2023-11-23 11:17 UTC (permalink / raw)
  To: newlib; +Cc: Takashi Yano

Previsouly, e.g. nl_langinfo(_NL_TIME_WMONT_1) returns "February"
due to the bug. Similarly, nl_langinfo(_LN_TIME_WWDAY_1) returns
"Mon". This patch fixes that.

Reviewed-by:
Signed-off-by: <takashi.yano@nifty.ne.jp>
---
 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),
-- 
2.39.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] newlib: ln_langinfo: Fix a bug of time stuff.
  2023-11-23 11:17 [PATCH] newlib: ln_langinfo: Fix a bug of time stuff Takashi Yano
@ 2023-11-23 14:47 ` Takashi Yano
  2023-11-23 15:51 ` Corinna Vinschen
  1 sibling, 0 replies; 4+ messages in thread
From: Takashi Yano @ 2023-11-23 14:47 UTC (permalink / raw)
  To: newlib

[PATCH] newlib: ln_langinfo: Fix a bug of time stuff.
                ^^ nl

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] newlib: ln_langinfo: Fix a bug of time stuff.
  2023-11-23 11:17 [PATCH] newlib: ln_langinfo: Fix a bug of time stuff Takashi Yano
  2023-11-23 14:47 ` Takashi Yano
@ 2023-11-23 15:51 ` Corinna Vinschen
  2023-11-24 10:38   ` Takashi Yano
  1 sibling, 1 reply; 4+ messages in thread
From: Corinna Vinschen @ 2023-11-23 15:51 UTC (permalink / raw)
  To: newlib

Hi Takashi,

thanks for catching.  The patch is ok, just the commit message
is a bit lacking:

On Nov 23 20:17, Takashi Yano wrote:
> Previsouly, e.g. nl_langinfo(_NL_TIME_WMONT_1) returns "February"
                                _NL_TIME_WMONTH_1
> due to the bug. Similarly, nl_langinfo(_LN_TIME_WWDAY_1) returns
                                         _NL_TIME_WWDAY_1
> "Mon". This patch fixes that.

It would be nice to add a description of the actual bug, i. e., the fact
that the bug is an off-by-one pointing into the wide char month and
weekday arrays.

Also

  Fixes: d47d5b850bed3 ("Extend locale support to maintain wide char values of native strings")

Please backport to cygwin-3_4-branch as well.


Thanks,
Corinna

> 
> Reviewed-by:
> Signed-off-by: <takashi.yano@nifty.ne.jp>
> ---
>  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),
> -- 
> 2.39.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] newlib: ln_langinfo: Fix a bug of time stuff.
  2023-11-23 15:51 ` Corinna Vinschen
@ 2023-11-24 10:38   ` Takashi Yano
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Yano @ 2023-11-24 10:38 UTC (permalink / raw)
  To: newlib

Hi Corinna,

On Thu, 23 Nov 2023 16:51:58 +0100
Corinna Vinschen wrote:
> Hi Takashi,
> 
> thanks for catching.  The patch is ok, just the commit message
> is a bit lacking:
> 
> On Nov 23 20:17, Takashi Yano wrote:
> > Previsouly, e.g. nl_langinfo(_NL_TIME_WMONT_1) returns "February"
>                                 _NL_TIME_WMONTH_1
> > due to the bug. Similarly, nl_langinfo(_LN_TIME_WWDAY_1) returns
>                                          _NL_TIME_WWDAY_1
> > "Mon". This patch fixes that.
> 
> It would be nice to add a description of the actual bug, i. e., the fact
> that the bug is an off-by-one pointing into the wide char month and
> weekday arrays.
> 
> Also
> 
>   Fixes: d47d5b850bed3 ("Extend locale support to maintain wide char values of native strings")
> 
> Please backport to cygwin-3_4-branch as well.

Thanks for reviewing. Pushed.

-- 
Takashi Yano <takashi.yano@nifty.ne.jp>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-11-24 10:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-23 11:17 [PATCH] newlib: ln_langinfo: Fix a bug of time stuff Takashi Yano
2023-11-23 14:47 ` Takashi Yano
2023-11-23 15:51 ` Corinna Vinschen
2023-11-24 10:38   ` Takashi Yano

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).