------- Comment #9 from sfilippone at uniroma2 dot it 2010-09-07 07:20 -------
(In reply to comment #8)
> Created an attachment (id=21673)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=21673&action=view) [edit]
>
Modifying the conftest source gives the following:
[snfi...@josquin libiberty]$ sh cmd.sh
[snfi...@josquin libiberty]$ ./conftest
Failing index 97 a
Reason: islower 2 ISLOWER 0 toupper A TOUPPER a
So the ISLOWER macro is (apparently) giving the wrong result.
---------------------------------------
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#if ((' ' & 0x0FF) == 0x020)
# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#else
# define ISLOWER(c) (('a' <= (c) && (c) <= 'i') ||
('j' <= (c) && (c) <= 'r') || ('s' <= (c) && (c) <= 'z'))
# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
#endif
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int
main ()
{
int i;
for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i))
|| toupper (i) != TOUPPER (i)) {
fprintf(stderr,"Failing index %d %c \n",i,i);
fprintf(stderr,"Reason: islower %d ISLOWER %d toupper %c TOUPPER %c
\n",
islower(i), ISLOWER (i),
toupper (i) , TOUPPER (i));
return 2;
}
return 0;
}
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45482