summaryrefslogtreecommitdiff
path: root/handy.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2014-05-12 18:29:41 -0600
committerKarl Williamson <khw@cpan.org>2014-05-31 11:57:00 -0600
commit0ed2b00b2bd6a650391433ad8733983692df43d5 (patch)
tree58fcb6e37392ef5f52aaccb965f7c087749f0e68 /handy.h
parentdd9bc2b0af8e838ed989897601a0ee36eeed092f (diff)
downloadperl-0ed2b00b2bd6a650391433ad8733983692df43d5.tar.gz
Fix definition of toCTRL() for EBCDIC
The definition was incorrect. When going from control to printable name, we need to go from Latin1 -> Native, so that e.g., a 65 gets turned into the native 'A'
Diffstat (limited to 'handy.h')
-rw-r--r--handy.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/handy.h b/handy.h
index 13f8d22311..740ebe526d 100644
--- a/handy.h
+++ b/handy.h
@@ -1653,11 +1653,13 @@ EXTCONST U32 PL_charclass[];
#ifndef EBCDIC
# define toCTRL(c) (toUPPER(c) ^ 64)
#else
-# define toCTRL(c) ((c) == '?' \
- ? LATIN1_TO_NATIVE(0x9F) \
- : (c) == LATIN1_TO_NATIVE(0x9F) \
- ? '?' \
- : (NATIVE_TO_LATIN1(toUPPER(c)) ^ 64))
+# define toCTRL(c) ((isPRINT_A(c)) \
+ ? UNLIKELY((c) == '?') \
+ ? QUESTION_MARK_CTRL \
+ : (NATIVE_TO_LATIN1(toUPPER(c)) ^ 64) \
+ : UNLIKELY((c) == QUESTION_MARK_CTRL) \
+ ? ((c) == '?') \
+ : (LATIN1_TO_NATIVE((c) ^ 64)))
#endif
/* Line numbers are unsigned, 32 bits. */