develooper Front page | perl.perl5.porters | Postings from October 2005

Re: Transliteration operator(tr//)on EBCDIC platform

Thread Previous | Thread Next
From:
SADAHIRO Tomoyuki
Date:
October 1, 2005 18:05
Subject:
Re: Transliteration operator(tr//)on EBCDIC platform
Message ID:
20051002095701.4F8B.BQW10602@nifty.com

On Fri, 30 Sep 2005 14:13:46 +0530, Sastry <ravisastryk@gmail.com> wrote
> Hi Sadahiro
> The two test cases that were failing get passed if I use the
> NATIVE_TO_ASCII() instead of NAIVE_TO_UTF()
> , but surprisingly there are other two test cases that are failing now
> They are
> a)
> ($a = v300.196.172.300.196.172.400.198.144) =~
> 	tr/\xac\xc4\x{12c}\x{190}/\xad\x{12d}\xc5\x{191}/;
> is($a, v197.301.173.197.301.173.401.198.144,    'all together now!');
> b)
> ($a = "\xfc\xfd\xfe\xff\x{100}") =~ tr/\x{1000}\x00-\xff/X/c;
> is($a, "\xfc\xfd\xfe\xffX");
> 
> The verbose output after enabling the DEBUG statements is
> -------------------------------------------------------------------------------------------------
> SWASHNEW utf8  # comment
> 00d6		005b
> 0044		012d
> 012c		0045
> 0190		0191

According to your info, this output should corresponds to
  tr/\xac\xc4\x{12c}\x{190}/\xad\x{12d}\xc5\x{191}/;

As \xac in EBCDIC CP-1047 corresponds to U+00D0 but not U+00D6,
the first column of the first line should be 00d0 but not 00d6.
I don't know why so. If it was \xec instead of \xac, 00d6 could
be reasonable.

> SWASHNEW utf8  # comment
> 0100		0058
> 0101	0fff	XXXX
> 1001	7fffffff	XXXX
>  8 89

According to your info, this output should corresponds to
  tr/\x{1000}\x00-\xff/X/c;
The output from SWASHNEW for this is as expected.
It is remarkable that this test is to be newly added.

If the patch is guilty, the perl without the patch should pass
the following test where no character range is used.
If the perl *without* the patch does not pass the test,
perl may have retained another/other snags elsewhere.

($a = "\xfc\xfd\xfe\xff\x{100}") =~ tr/\x{1000}\xfc\xfd\xfe\xff/X/c;
is($a, "\xfc\xfd\xfe\xffX");

> Please see if there can be a generic change which does not effect the
> other tests!

If you want "no failure" rather than "progress", the "best" fix
is just to skip the failing test (not as "todo").
It is very reasonable because perlop.pod clearly mentions that
character ranges are unportable except the range begins from and
ends at either alphabets of equal case (a-e, A-E), or digits (0-4).

Regards,
SADAHIRO Tomoyuki


diff -ur perl~/t/op/tr.t perl/t/op/tr.t
--- perl~/t/op/tr.t	Thu Aug 18 18:27:25 2005
+++ perl/t/op/tr.t	Sun Oct 02 09:37:13 2005
@@ -259,13 +259,15 @@
 
 # UTF8 range tests from Inaba Hiroto
 
+SKIP: {
+    skip "EBCDIC", 2 if $Is_EBCDIC;
 # Not working in EBCDIC as of 12674.
 ($a = v300.196.172.302.197.172) =~ tr/\x{12c}-\x{130}/\xc0-\xc4/;
 is($a, v192.196.172.194.197.172,    'UTF range');
 
 ($a = v300.196.172.302.197.172) =~ tr/\xc4-\xc8/\x{12c}-\x{130}/;
 is($a, v300.300.172.302.301.172);
-
+}
 
 # UTF8 range tests from Karsten Sperling (patch #9008 required)
 




Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About