* localeconv and char values
@ 2015-09-21 10:21 Julien Ramseier
2015-09-21 14:54 ` Rich Felker
0 siblings, 1 reply; 5+ messages in thread
From: Julien Ramseier @ 2015-09-21 10:21 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 447 bytes --]
Hello,
Currently, all the char fields of the lconv struct returned by localeconv are set to -1.
According to http://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html <http://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html>,
negative values are not valid and CHAR_MAX should be used to indicate non-available values.
If I’m not missing anything, here’s the corresponding patch:
—
Julien
[-- Attachment #2.1: Type: text/html, Size: 847 bytes --]
[-- Attachment #2.2: fix-localeconv-char.diff --]
[-- Type: application/octet-stream, Size: 1214 bytes --]
diff --git a/src/locale/localeconv.c b/src/locale/localeconv.c
index cbc75d7..4cbb9dc 100644
--- a/src/locale/localeconv.c
+++ b/src/locale/localeconv.c
@@ -1,4 +1,5 @@
#include <locale.h>
+#include <limits.h>
static const struct lconv posix_lconv = {
.decimal_point = ".",
@@ -11,20 +12,20 @@ static const struct lconv posix_lconv = {
.mon_grouping = "",
.positive_sign = "",
.negative_sign = "",
- .int_frac_digits = -1,
- .frac_digits = -1,
- .p_cs_precedes = -1,
- .p_sep_by_space = -1,
- .n_cs_precedes = -1,
- .n_sep_by_space = -1,
- .p_sign_posn = -1,
- .n_sign_posn = -1,
- .int_p_cs_precedes = -1,
- .int_p_sep_by_space = -1,
- .int_n_cs_precedes = -1,
- .int_n_sep_by_space = -1,
- .int_p_sign_posn = -1,
- .int_n_sign_posn = -1,
+ .int_frac_digits = CHAR_MAX,
+ .frac_digits = CHAR_MAX,
+ .p_cs_precedes = CHAR_MAX,
+ .p_sep_by_space = CHAR_MAX,
+ .n_cs_precedes = CHAR_MAX,
+ .n_sep_by_space = CHAR_MAX,
+ .p_sign_posn = CHAR_MAX,
+ .n_sign_posn = CHAR_MAX,
+ .int_p_cs_precedes = CHAR_MAX,
+ .int_p_sep_by_space = CHAR_MAX,
+ .int_n_cs_precedes = CHAR_MAX,
+ .int_n_sep_by_space = CHAR_MAX,
+ .int_p_sign_posn = CHAR_MAX,
+ .int_n_sign_posn = CHAR_MAX,
};
struct lconv *localeconv(void)
[-- Attachment #2.3: Type: text/html, Size: 345 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: localeconv and char values
2015-09-21 10:21 localeconv and char values Julien Ramseier
@ 2015-09-21 14:54 ` Rich Felker
2015-09-21 20:23 ` Rich Felker
0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2015-09-21 14:54 UTC (permalink / raw)
To: musl
On Mon, Sep 21, 2015 at 12:21:34PM +0200, Julien Ramseier wrote:
> Hello,
>
> Currently, all the char fields of the lconv struct returned by
> localeconv are set to -1.
>
> According to
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html
> <http://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html>,
> negative values are not valid and CHAR_MAX should be used to
> indicate non-available values.
As far as I can tell, you are right. I don't know how I
overlooked/misread this, except perhaps that using CHAR_MAX is rather
ugly/inappropriate because it assumes CHAR_MAX is not an interesting
character that could be used for these purposes. Thankfully that's
true for ASCII and ASCII supersets (in our case, UTF-8), so it's not a
practical problem.
> If I’m not missing anything, here’s the corresponding patch:
I'll look it over again before committing, but I don't see anything
immediately wrong with it. Thanks!
Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: localeconv and char values
2015-09-21 14:54 ` Rich Felker
@ 2015-09-21 20:23 ` Rich Felker
2015-09-22 7:37 ` Julien Ramseier
0 siblings, 1 reply; 5+ messages in thread
From: Rich Felker @ 2015-09-21 20:23 UTC (permalink / raw)
To: musl
On Mon, Sep 21, 2015 at 10:54:25AM -0400, Rich Felker wrote:
> On Mon, Sep 21, 2015 at 12:21:34PM +0200, Julien Ramseier wrote:
> > Hello,
> >
> > Currently, all the char fields of the lconv struct returned by
> > localeconv are set to -1.
> >
> > According to
> > http://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html
> > <http://pubs.opengroup.org/onlinepubs/9699919799/functions/localeconv.html>,
> > negative values are not valid and CHAR_MAX should be used to
> > indicate non-available values.
>
> As far as I can tell, you are right. I don't know how I
> overlooked/misread this, except perhaps that using CHAR_MAX is rather
> ugly/inappropriate because it assumes CHAR_MAX is not an interesting
> character that could be used for these purposes. Thankfully that's
> true for ASCII and ASCII supersets (in our case, UTF-8), so it's not a
> practical problem.
>
> > If I’m not missing anything, here’s the corresponding patch:
>
> I'll look it over again before committing, but I don't see anything
> immediately wrong with it. Thanks!
BTW as a new contributor would you like to be credited as commit
author (includes name/email) in the git log or just by name in the
commit message (or not at all)?
Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: localeconv and char values
2015-09-21 20:23 ` Rich Felker
@ 2015-09-22 7:37 ` Julien Ramseier
2015-09-24 6:45 ` Rich Felker
0 siblings, 1 reply; 5+ messages in thread
From: Julien Ramseier @ 2015-09-22 7:37 UTC (permalink / raw)
To: musl
[-- Attachment #1: Type: text/plain, Size: 315 bytes --]
> Le 21 sept. 2015 à 22:23, Rich Felker <dalias@libc.org> a écrit :
>
> BTW as a new contributor would you like to be credited as commit
> author (includes name/email) in the git log or just by name in the
> commit message (or not at all)?
What’s easier for you. Not at all is also fine.
--
Julien
[-- Attachment #2: Type: text/html, Size: 2906 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: localeconv and char values
2015-09-22 7:37 ` Julien Ramseier
@ 2015-09-24 6:45 ` Rich Felker
0 siblings, 0 replies; 5+ messages in thread
From: Rich Felker @ 2015-09-24 6:45 UTC (permalink / raw)
To: musl
On Tue, Sep 22, 2015 at 09:37:11AM +0200, Julien Ramseier wrote:
>
> > Le 21 sept. 2015 à 22:23, Rich Felker <dalias@libc.org> a écrit :
> >
> > BTW as a new contributor would you like to be credited as commit
> > author (includes name/email) in the git log or just by name in the
> > commit message (or not at all)?
>
> What’s easier for you. Not at all is also fine.
Committed. Thanks again for finding this!
Rich
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2015-09-24 6:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-21 10:21 localeconv and char values Julien Ramseier
2015-09-21 14:54 ` Rich Felker
2015-09-21 20:23 ` Rich Felker
2015-09-22 7:37 ` Julien Ramseier
2015-09-24 6:45 ` Rich Felker
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).