This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: mon_grouping bug
On Friday 14 March 2003 21:40, you wrote:
> > The description of the grouping and mon_grouping members says
> > "An element value of CHAR_MAX ends any further grouping (and hence ends
> > the string)".
> >
> > The best solution would probably be the substitution of '\177' by
> > CHAR_MAX in ld-monetary, but I am not sure what the implications
> > are. Therefore I decided not to change any running code but only to add a
> > code path.
>
> Looking at the standard, I think that is indeed the correct change.
> It clearly says CHAR_MAX, so the value must be the same value a program
> compiled using the CHAR_MAX macro sees.
>
> I too am concerned about what effects this might have on existing programs,
> however. It can only be an issue for existing programs on platforms where
> char defaults to unsigned and so CHAR_MAX != 0177. Which platforms are
> these?
Attached is a patch that makes these changes. I have verified that 'make
check' for glibc still works on s390, a platform where char defaults to
unsigned, and that it fixes the LI18NUX test suite bug that I mentioned in my
original post.
2003-03-25 Gerhard Tonn <GerhardTonn at gammatau dot de>
* ld-numeric.c (numeric_read()):
Change 'invalid' value '\377' to '\376' and '\177' to CHAR_MAX as defined
by the standard.
* ld-monetary.c (monetary_finish(), monetary_read()): Likewise.
--- glibc-2.3.1/locale/programs/ld-monetary.c Wed Apr 17 02:44:20 2002
+++ ../glibc-2.3.2/locale/programs/ld-monetary.c Tue Mar 25 10:43:01 2003
@@ -260,7 +260,11 @@
WITH_CUR_LOCALE (error (0, 0, _("%s: field `%s' not defined"),
"LC_MONETARY", "mon_grouping"));
+#ifdef __CHAR_UNSIGNED__
+ monetary->mon_grouping = (char *) "\377";
+#else
monetary->mon_grouping = (char *) "\177";
+#endif
monetary->mon_grouping_len = 1;
}
@@ -832,7 +836,7 @@
grouping = xrealloc (grouping, max);
}
- if (act > 0 && grouping[act - 1] == '\177')
+ if (act > 0 && grouping[act - 1] == CHAR_MAX)
{
lr_error (ldfile, _("\
%s: `-1' must be last entry in `%s' field"),
@@ -844,7 +848,7 @@
if (now->tok == tok_minus1)
{
if (!ignore_content)
- grouping[act++] = '\177';
+ grouping[act++] = CHAR_MAX;
}
else if (now->val.num == 0)
{
@@ -853,7 +857,7 @@
terminates the string. Use something different
which must not be used otherwise. */
if (!ignore_content)
- grouping[act++] = '\377';
+ grouping[act++] = '\376';
}
else if (now->val.num > 126)
lr_error (ldfile, _("\
--- glibc-2.3.1/locale/programs/ld-numeric.c Wed Apr 17 02:44:40 2002
+++ ../glibc-2.3.2/locale/programs/ld-numeric.c Tue Mar 25 10:44:11 2003
@@ -314,7 +314,7 @@
grouping = xrealloc (grouping, max);
}
- if (act > 0 && grouping[act - 1] == '\177')
+ if (act > 0 && grouping[act - 1] == CHAR_MAX)
{
lr_error (ldfile, _("\
%s: `-1' must be last entry in `%s' field"), "LC_NUMERIC", "grouping");
@@ -325,7 +325,7 @@
if (now->tok == tok_minus1)
{
if (!ignore_content)
- grouping[act++] = '\177';
+ grouping[act++] = CHAR_MAX;
}
else if (now->val.num == 0)
{
@@ -334,7 +334,7 @@
terminates the string. Use something different
which must not be used otherwise. */
if (!ignore_content)
- grouping[act++] = '\377';
+ grouping[act++] = '\376';
}
else if (now->val.num > 126)
lr_error (ldfile, _("\