summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Ing-Simmons <nik@tiuk.ti.com>2001-03-11 19:39:34 +0000
committerNick Ing-Simmons <nik@tiuk.ti.com>2001-03-11 19:39:34 +0000
commitc7f1f0165ac822994a67426c2d8003c3974e49ef (patch)
tree04bf39f616ce516a7ac5faadf47ae622578082ee
parentffebcc3e6acf9636047196271385e91b0490ae34 (diff)
downloadperl-c7f1f0165ac822994a67426c2d8003c3974e49ef.tar.gz
Audit #ifdef EBCDIC and #ifndef ASCIIish, replace latter with former.
Use ASCII_TO_NATIVE and NATIVE_TO_ASCII to avoid some #ifs. p4raw-id: //depot/perlio@9105
-rw-r--r--regcomp.c27
-rw-r--r--toke.c53
-rw-r--r--utf8.c4
3 files changed, 27 insertions, 57 deletions
diff --git a/regcomp.c b/regcomp.c
index 227737cfb5..05a48d9747 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -2837,19 +2837,11 @@ tryagain:
p++;
break;
case 'e':
-#ifdef ASCIIish
- ender = '\033';
-#else
- ender = '\047';
-#endif
+ ender = ASCII_TO_NATIVE('\033');
p++;
break;
case 'a':
-#ifdef ASCIIish
- ender = '\007';
-#else
- ender = '\057';
-#endif
+ ender = ASCII_TO_NATIVE('\007');
p++;
break;
case 'x':
@@ -3267,13 +3259,8 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
case 't': value = '\t'; break;
case 'f': value = '\f'; break;
case 'b': value = '\b'; break;
-#ifdef ASCIIish
- case 'e': value = '\033'; break;
- case 'a': value = '\007'; break;
-#else
- case 'e': value = '\047'; break;
- case 'a': value = '\057'; break;
-#endif
+ case 'e': value = ASCII_TO_NATIVE('\033');break;
+ case 'a': value = ASCII_TO_NATIVE('\007');break;
case 'x':
if (*RExC_parse == '{') {
e = strchr(RExC_parse++, '}');
@@ -3417,7 +3404,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
if (LOC)
ANYOF_CLASS_SET(ret, ANYOF_ASCII);
else {
-#ifdef ASCIIish
+#ifndef EBCDIC
for (value = 0; value < 128; value++)
ANYOF_BITMAP_SET(ret, value);
#else /* EBCDIC */
@@ -3433,7 +3420,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
if (LOC)
ANYOF_CLASS_SET(ret, ANYOF_NASCII);
else {
-#ifdef ASCIIish
+#ifndef EBCDIC
for (value = 128; value < 256; value++)
ANYOF_BITMAP_SET(ret, value);
#else /* EBCDIC */
@@ -3733,7 +3720,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state)
/* now is the next time */
if (!SIZE_ONLY) {
if (lastvalue < 256 && value < 256) {
-#ifndef ASCIIish /* EBCDIC, for example. */
+#ifdef EBCDIC /* EBCDIC, for example. */
if ((isLOWER(lastvalue) && isLOWER(value)) ||
(isUPPER(lastvalue) && isUPPER(value)))
{
diff --git a/toke.c b/toke.c
index 0d4fc1d018..0bc4a53bb1 100644
--- a/toke.c
+++ b/toke.c
@@ -1265,7 +1265,7 @@ S_scan_const(pTHX_ char *start)
(char)min, (char)max);
}
-#ifndef ASCIIish
+#ifdef EBCDIC
if ((isLOWER(min) && isLOWER(max)) ||
(isUPPER(min) && isUPPER(max))) {
if (isLOWER(min)) {
@@ -1450,13 +1450,11 @@ S_scan_const(pTHX_ char *start)
* There will always enough room in sv since such
* escapes will be longer than any UT-F8 sequence
* they can end up as. */
-
- /* This spot is wrong for EBCDIC. Characters like
- * the lowercase letters and digits are >127 in EBCDIC,
- * so here they would need to be mapped to the Unicode
- * repertoire. --jhi */
- if (uv > 127) {
+ /* We need to map to chars to ASCII before doing the tests
+ to cover EBCDIC
+ */
+ if (NATIVE_TO_ASCII(uv) > 127) {
if (!has_utf8 && uv > 255) {
/* Might need to recode whatever we have
* accumulated so far if it contains any
@@ -1465,11 +1463,11 @@ S_scan_const(pTHX_ char *start)
* (Can't we keep track of that and avoid
* this rescan? --jhi)
*/
- int hicount = 0;
+ int hicount = 0;
char *c;
for (c = SvPVX(sv); c < d; c++) {
- if (UTF8_IS_CONTINUED(*c))
+ if (UTF8_IS_CONTINUED(NATIVE_TO_ASCII(*c)))
hicount++;
}
if (hicount) {
@@ -1485,13 +1483,15 @@ S_scan_const(pTHX_ char *start)
dst = d - 1;
while (src < dst) {
- if (UTF8_IS_CONTINUED(*src)) {
- *dst-- = UTF8_EIGHT_BIT_LO(*src);
- *dst-- = UTF8_EIGHT_BIT_HI(*src--);
+ U8 ch = NATIVE_TO_ASCII(*src);
+ if (UTF8_IS_CONTINUED(ch)) {
+ *dst-- = UTF8_EIGHT_BIT_LO(ch);
+ *dst-- = UTF8_EIGHT_BIT_HI(ch);
}
else {
- *dst-- = *src--;
+ *dst-- = ch;
}
+ src--;
}
}
}
@@ -1566,18 +1566,14 @@ S_scan_const(pTHX_ char *start)
/* \c is a control character */
case 'c':
s++;
-#ifdef EBCDIC
- *d = *s++;
- if (isLOWER(*d))
- *d = toUPPER(*d);
- *d = toCTRL(*d);
- d++;
-#else
{
U8 c = *s++;
+#ifdef EBCDIC
+ if (isLOWER(c))
+ c = toUPPER(c);
+#endif
*d++ = toCTRL(c);
}
-#endif
continue;
/* printf-style backslashes, formfeeds, newlines, etc */
@@ -1596,21 +1592,12 @@ S_scan_const(pTHX_ char *start)
case 't':
*d++ = '\t';
break;
-#ifdef EBCDIC
case 'e':
- *d++ = '\047'; /* CP 1047 */
+ *d++ = ASCII_TO_NATIVE('\033');
break;
case 'a':
- *d++ = '\057'; /* CP 1047 */
- break;
-#else
- case 'e':
- *d++ = '\033';
+ *d++ = ASCII_TO_NATIVE('\007');
break;
- case 'a':
- *d++ = '\007';
- break;
-#endif
} /* end switch */
s++;
@@ -1618,7 +1605,7 @@ S_scan_const(pTHX_ char *start)
} /* end if (backslash) */
default_action:
- if (UTF8_IS_CONTINUED(*s) && (this_utf8 || has_utf8)) {
+ if (UTF8_IS_CONTINUED(NATIVE_TO_ASCII(*s)) && (this_utf8 || has_utf8)) {
STRLEN len = (STRLEN) -1;
UV uv;
if (this_utf8) {
diff --git a/utf8.c b/utf8.c
index 450138af56..7302bb77e2 100644
--- a/utf8.c
+++ b/utf8.c
@@ -253,11 +253,7 @@ Perl_utf8n_to_uvuni(pTHX_ U8* s, STRLEN curlen, STRLEN* retlen, U32 flags)
{
UV uv = *s, ouv;
STRLEN len = 1;
-#ifdef EBCDIC
- bool dowarn = 0;
-#else
bool dowarn = ckWARN_d(WARN_UTF8);
-#endif
STRLEN expectlen = 0;
U32 warning = 0;