mailing list of musl libc
 help / color / mirror / code / Atom feed
* 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

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