diff options
author | Karl Williamson <khw@cpan.org> | 2014-12-14 10:39:14 -0700 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2014-12-30 21:30:09 -0700 |
commit | 75763b3aeee4912655f280922a10857e88d74104 (patch) | |
tree | 0e067c7a0338ff9b17edad6f451128553109c2de /handy.h | |
parent | 75697d6e4ef98ece405210de48e7529d01b619bf (diff) | |
download | perl-75763b3aeee4912655f280922a10857e88d74104.tar.gz |
handy.h Cast to unsigned before doing xor
It occurred to me that these macros could have an xor applied to a
signed value if the argument is signed, whereas the xor is expecting
unsigned.
Diffstat (limited to 'handy.h')
-rw-r--r-- | handy.h | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -1719,16 +1719,16 @@ EXTCONST U32 PL_charclass[]; * The conversion works both ways, so toCTRL('D') is 4, and toCTRL(4) is D, * etc. */ #ifndef EBCDIC -# define toCTRL(c) (__ASSERT_(FITS_IN_8_BITS(c)) toUPPER(c) ^ 64) +# define toCTRL(c) (__ASSERT_(FITS_IN_8_BITS(c)) toUPPER(((U8)(c))) ^ 64) #else -# define toCTRL(c) (__ASSERT_(FITS_IN_8_BITS(c)) \ - ((isPRINT_A(c)) \ - ? (UNLIKELY((c) == '?') \ - ? QUESTION_MARK_CTRL \ - : (NATIVE_TO_LATIN1(toUPPER(c)) ^ 64)) \ - : (UNLIKELY((c) == QUESTION_MARK_CTRL) \ - ? '?' \ - : (LATIN1_TO_NATIVE((c) ^ 64))))) +# define toCTRL(c) (__ASSERT_(FITS_IN_8_BITS(c)) \ + ((isPRINT_A(c)) \ + ? (UNLIKELY((c) == '?') \ + ? QUESTION_MARK_CTRL \ + : (NATIVE_TO_LATIN1(toUPPER((U8) (c))) ^ 64)) \ + : (UNLIKELY((c) == QUESTION_MARK_CTRL) \ + ? '?' \ + : (LATIN1_TO_NATIVE(((U8) (c)) ^ 64))))) #endif /* Line numbers are unsigned, 32 bits. */ |