summaryrefslogtreecommitdiff
path: root/ebcdic.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>1998-08-01 15:03:02 +0300
committerGurusamy Sarathy <gsar@cpan.org>1998-08-02 05:20:12 +0000
commit9d116dd7c895b17badf4ad422ae44da0c4df7bc2 (patch)
tree6e0cd77e3539952c892983238473264f672472b9 /ebcdic.c
parente6df7ed16ebd06f5315f3016c00996876580109c (diff)
downloadperl-9d116dd7c895b17badf4ad422ae44da0c4df7bc2.tar.gz
support OE/MVS
Message-Id: <199808010903.MAA09371@alpha.hut.fi> Subject: [PATCH] 5.005_01: OE MVS p4raw-id: //depot/maint-5.005/perl@1697
Diffstat (limited to 'ebcdic.c')
-rw-r--r--ebcdic.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/ebcdic.c b/ebcdic.c
new file mode 100644
index 0000000000..890bd086d2
--- /dev/null
+++ b/ebcdic.c
@@ -0,0 +1,32 @@
+#include "EXTERN.h"
+#include "perl.h"
+
+/* in ASCII order, not that it matters */
+static const char controllablechars[] = "?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
+
+int
+ebcdic_control(int ch)
+{
+ if (ch > 'a') {
+ char *ctlp;
+
+ if (islower(ch))
+ ch = toupper(ch);
+
+ if ((ctlp = strchr(controllablechars, ch)) == 0) {
+ die("unrecognised control character '%c'\n", ch);
+ }
+
+ if (ctlp == controllablechars)
+ return('\177'); /* DEL */
+ else
+ return((unsigned char)(ctlp - controllablechars - 1));
+ } else { /* Want uncontrol */
+ if (ch == '\177' || ch == -1)
+ return('?');
+ else if (0 < ch && ch < (sizeof(controllablechars) - 1))
+ return(controllablechars[ch+1]);
+ else
+ die("invalid control request: '\\%03o'\n", ch & 0xFF);
+ }
+}