This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

PATCH: remove another libiberty warning


C specifies the return type of tolower and friends as int.  On systems
that define a _tolower macro, the type of the expanded expression is
determined by the type of the incoming argument.  Rather than using an
unsigned loop index variable, which produces warnings due to each side
of the ternary expression being signed and unsigned, it seems easier
to change the type to int.  This allows a cast to be removed, too.

(Now down to zero libiberty warnings on the systems I am using).

Okay for mainline?

2005-07-22  Ben Elliston  <bje@gnu.org>

        * regex.c (regcomp): Change type of `i' from unsigned to int.

Index: regex.c
===================================================================
RCS file: /cvs/gcc/gcc/libiberty/regex.c,v
retrieving revision 1.22
diff -u -p -r1.22 regex.c
--- regex.c     15 Jul 2005 01:45:25 -0000      1.22
+++ regex.c     22 Jul 2005 03:40:41 -0000
@@ -7923,7 +7923,7 @@ regcomp (regex_t *preg, const char *patt
 
   if (cflags & REG_ICASE)
     {
-      unsigned i;
+      int i;
 
       preg->translate
        = (RE_TRANSLATE_TYPE) malloc (CHAR_SET_SIZE
@@ -7933,7 +7933,7 @@ regcomp (regex_t *preg, const char *patt
 
       /* Map uppercase characters to corresponding lowercase ones.  */
       for (i = 0; i < CHAR_SET_SIZE; i++)
-        preg->translate[i] = ISUPPER (i) ? TOLOWER (i) : (int) i;
+        preg->translate[i] = ISUPPER (i) ? TOLOWER (i) : i;
     }
   else
     preg->translate = NULL;

Attachment: pgp00000.pgp
Description: PGP signature


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