This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: Transliteration operator(tr//)on EBCDIC platform
authorSADAHIRO Tomoyuki <BQW10602@nifty.com>
Fri, 12 Aug 2005 00:20:39 +0000 (09:20 +0900)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Thu, 18 Aug 2005 08:58:54 +0000 (08:58 +0000)
Message-Id: <20050812001541.EA69.BQW10602@nifty.com>

p4raw-id: //depot/perl@25303

t/op/tr.t
toke.c

index b3661a4..2a3d29c 100755 (executable)
--- a/t/op/tr.t
+++ b/t/op/tr.t
@@ -295,18 +295,15 @@ is($a, "X");
 # (i-j, r-s, I-J, R-S), [\x89-\x91] [\xc9-\xd1] has to match them,
 # from Karsten Sperling.
 
-# Not working in EBCDIC as of 12674.
 $c = ($a = "\x89\x8a\x8b\x8c\x8d\x8f\x90\x91") =~ tr/\x89-\x91/X/;
 is($c, 8);
 is($a, "XXXXXXXX");
-   
-# Not working in EBCDIC as of 12674.
+
 $c = ($a = "\xc9\xca\xcb\xcc\xcd\xcf\xd0\xd1") =~ tr/\xc9-\xd1/X/;
 is($c, 8);
 is($a, "XXXXXXXX");
 
-
-SKIP: {   
+SKIP: {
     skip "not EBCDIC", 4 unless $Is_EBCDIC;
 
     $c = ($a = "\x89\x8a\x8b\x8c\x8d\x8f\x90\x91") =~ tr/i-j/X/;
diff --git a/toke.c b/toke.c
index 19bac4f..1b16de0 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -1368,6 +1368,9 @@ S_scan_const(pTHX_ char *start)
     I32  has_utf8 = FALSE;                     /* Output constant is UTF8 */
     I32  this_utf8 = UTF;                      /* The source string is assumed to be UTF8 */
     UV uv;
+#ifdef EBCDIC
+    UV literal_endpoint = 0;
+#endif
 
     const char *leaveit =      /* set of acceptably-backslashed characters */
        PL_lex_inpat
@@ -1417,8 +1420,9 @@ S_scan_const(pTHX_ char *start)
                 }
 
 #ifdef EBCDIC
-               if ((isLOWER(min) && isLOWER(max)) ||
-                   (isUPPER(min) && isUPPER(max))) {
+               if (literal_endpoint == 2 &&
+                   ((isLOWER(min) && isLOWER(max)) ||
+                    (isUPPER(min) && isUPPER(max)))) {
                    if (isLOWER(min)) {
                        for (i = min; i <= max; i++)
                            if (isLOWER(i))
@@ -1437,6 +1441,9 @@ S_scan_const(pTHX_ char *start)
                /* mark the range as done, and continue */
                dorange = FALSE;
                didrange = TRUE;
+#ifdef EBCDIC
+               literal_endpoint = 0;
+#endif
                continue;
            }
 
@@ -1455,6 +1462,9 @@ S_scan_const(pTHX_ char *start)
            }
            else {
                didrange = FALSE;
+#ifdef EBCDIC
+               literal_endpoint = 0;
+#endif
            }
        }
 
@@ -1788,6 +1798,10 @@ S_scan_const(pTHX_ char *start)
            s++;
            continue;
        } /* end if (backslash) */
+#ifdef EBCDIC
+       else
+           literal_endpoint++;
+#endif
 
     default_action:
        /* If we started with encoded form, or already know we want it