summaryrefslogtreecommitdiff
path: root/handy.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-12-14 10:39:14 -0700
committerKarl Williamson <khw@cpan.org>2014-12-30 21:30:09 -0700
commit75763b3aeee4912655f280922a10857e88d74104 (patch)
tree0e067c7a0338ff9b17edad6f451128553109c2de /handy.h
parent75697d6e4ef98ece405210de48e7529d01b619bf (diff)
downloadperl-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.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/handy.h b/handy.h
index f2bd6a8c76..1256ea1e49 100644
--- a/handy.h
+++ b/handy.h
@@ -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. */