This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

mon_grouping bug


Hi,

running the LSB 1.3 testsuite on a platform that has unsigned char as 
default, gives a failure during the localisation tests. The mon_grouping 
parameter of the LOCALE being tested is defined as 1;2;-1.  After 
installation of the LOCALE the command 'locale -k mon_grouping' returns 
mon_grouping=1;2;127.

This seems to be a bug in the glibc. The following code fragment in 
ld-monetary.c maps the '-1' to 127 which is the value of SCHAR_MAX which is 
equal to CHAR_MAX, if char is signed per default.

if (now->tok == tok_minus1)
                    {
                      if (!ignore_content)
                        grouping[act++] = '\177';
                    }

The following code fragment in locale.c prints '-1' only if the value equals 
CHAR_MAX which is not true on platforms that have unsigned char as default.

 printf ("%d", *val == CHAR_MAX ? -1 : *val);

The following patch would fix the problem.

2003-03-14  Gerhard Tonn  <GerhardTonn at gammatau dot de>

	* locale.c (show_info()):                       
	  Print SCHAR_MAX as -1 as it is already done for CHAR_MAX.

--- locale.c.bak	Fri Mar 14 16:02:59 2003
+++ locale.c	Fri Mar 14 16:07:21 2003
@@ -731,7 +731,7 @@
 	      printf ("%s=", item->name);
 
 	    if (val != NULL)
-	      printf ("%d", *val == CHAR_MAX ? -1 : *val);
+	      printf ("%d", *val == SCHAR_MAX || *val == CHAR_MAX ? -1 : *val);
 	    putchar ('\n');
 	  }
 	  break;
@@ -745,12 +745,12 @@
 
 	    while (cnt > 1)
 	      {
-		printf ("%d;", *val == CHAR_MAX ? -1 : *val);
+		printf ("%d;", *val == SCHAR_MAX || *val == CHAR_MAX ? -1 : *val);
                 --cnt;
 		++val;
 	      }
 
-	    printf ("%d\n", cnt == 0 || *val == CHAR_MAX ? -1 : *val);
+	    printf ("%d\n", cnt == 0 || *val == SCHAR_MAX || *val == CHAR_MAX ? -1 
: *val);
 	  }
 	  break;
 	case word:


--
Regards,
Gerhard


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]