This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
toupper/lower: avoid sign warnings
authorDavid Mitchell <davem@iabyn.com>
Tue, 16 Dec 2014 12:20:25 +0000 (12:20 +0000)
committerDavid Mitchell <davem@iabyn.com>
Tue, 16 Dec 2014 12:20:25 +0000 (12:20 +0000)
Perl's toLOWER_LC() etc macros are specified as having U8 arg and return,
while the underlying macro may call the OS's tolower() function which is
int. Stop the compiler warning about mismatched sign in conditional by
casting the result of the OS function.

handy.h

diff --git a/handy.h b/handy.h
index f23f35d..1e6b15d 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -1351,7 +1351,7 @@ EXTCONST U32 PL_charclass[];
                                                 ? (c)                          \
                                                 : (IN_UTF8_CTYPE_LOCALE)       \
                                                   ? PL_latin1_lc[ (U8) (c) ]   \
-                                                : function((cast)(c)))
+                                                : (cast)function((cast)(c)))
 
 /* Note that the result can be larger than a byte in a UTF-8 locale.  It
  * returns a single value, so can't adequately return the upper case of LATIN
@@ -1362,7 +1362,7 @@ EXTCONST U32 PL_charclass[];
                     (! FITS_IN_8_BITS(c)                                       \
                     ? (c)                                                      \
                     : ((! IN_UTF8_CTYPE_LOCALE)                                \
-                      ? function((cast)(c))                                    \
+                      ? (cast)function((cast)(c))                                    \
                       : ((((U8)(c)) == MICRO_SIGN)                             \
                         ? GREEK_CAPITAL_LETTER_MU                              \
                         : ((((U8)(c)) == LATIN_SMALL_LETTER_Y_WITH_DIAERESIS)  \