1998-09-09 07:00:04 +00:00
|
|
|
#include "EXTERN.h"
|
2000-06-25 11:04:01 +00:00
|
|
|
#define PERL_IN_EBCDIC_C
|
1998-09-09 07:00:04 +00:00
|
|
|
#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) {
|
2000-06-25 11:04:01 +00:00
|
|
|
Perl_die(aTHX_ "unrecognised control character '%c'\n", ch);
|
1998-09-09 07:00:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ctlp == controllablechars)
|
|
|
|
return('\177'); /* DEL */
|
|
|
|
else
|
|
|
|
return((unsigned char)(ctlp - controllablechars - 1));
|
|
|
|
} else { /* Want uncontrol */
|
|
|
|
if (ch == '\177' || ch == -1)
|
|
|
|
return('?');
|
2000-06-25 11:04:01 +00:00
|
|
|
else if (ch == '\157')
|
|
|
|
return('\177');
|
|
|
|
else if (ch == '\174')
|
|
|
|
return('\000');
|
|
|
|
else if (ch == '^') /* '\137' in 1047, '\260' in 819 */
|
|
|
|
return('\036');
|
|
|
|
else if (ch == '\155')
|
|
|
|
return('\037');
|
1998-09-09 07:00:04 +00:00
|
|
|
else if (0 < ch && ch < (sizeof(controllablechars) - 1))
|
|
|
|
return(controllablechars[ch+1]);
|
|
|
|
else
|
2000-06-25 11:04:01 +00:00
|
|
|
Perl_die(aTHX_ "invalid control request: '\\%03o'\n", ch & 0xFF);
|
1998-09-09 07:00:04 +00:00
|
|
|
}
|
|
|
|
}
|