blob: d74351078da3ef6eb85f64fdf8fd910899f9fe99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include "EXTERN.h"
#define PERL_IN_EBCDIC_C
#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) {
Perl_die(aTHX_ "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
Perl_die(aTHX_ "invalid control request: '\\%03o'\n", ch & 0xFF);
}
}
|