Update dependencies and remove obsolete VAXC support
[p5sagit/p5-mst-13.2.git] / ebcdic.c
CommitLineData
9d116dd7 1#include "EXTERN.h"
864dbfa3 2#define PERL_IN_EBCDIC_C
9d116dd7 3#include "perl.h"
4
5/* in ASCII order, not that it matters */
6static const char controllablechars[] = "?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_";
7
8int
9ebcdic_control(int ch)
10{
11 if (ch > 'a') {
12 char *ctlp;
13
14 if (islower(ch))
15 ch = toupper(ch);
16
17 if ((ctlp = strchr(controllablechars, ch)) == 0) {
cea2e8a9 18 Perl_die(aTHX_ "unrecognised control character '%c'\n", ch);
9d116dd7 19 }
20
21 if (ctlp == controllablechars)
22 return('\177'); /* DEL */
23 else
24 return((unsigned char)(ctlp - controllablechars - 1));
25 } else { /* Want uncontrol */
26 if (ch == '\177' || ch == -1)
27 return('?');
da0838f1 28 else if (ch == '\157')
29 return('\177');
30 else if (ch == '\174')
31 return('\000');
32 else if (ch == '^') /* '\137' in 1047, '\260' in 819 */
33 return('\036');
34 else if (ch == '\155')
35 return('\037');
9d116dd7 36 else if (0 < ch && ch < (sizeof(controllablechars) - 1))
37 return(controllablechars[ch+1]);
38 else
cea2e8a9 39 Perl_die(aTHX_ "invalid control request: '\\%03o'\n", ch & 0xFF);
9d116dd7 40 }
41}