From: Jarkko Hietaniemi Date: Sun, 10 Feb 2002 22:10:19 +0000 (+0000) Subject: EBCDIC: the low 256 needs to be shuffled also X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=60a99fa7e5933af72f20cb54c8ec0609b948c270;p=p5sagit%2Fp5-mst-13.2.git EBCDIC: the low 256 needs to be shuffled also in pack/unpack U (this breaks the equivalence of pack U and v-strings, but I think if someone has to give, v-strings are a good victim) p4raw-id: //depot/perl@14630 --- diff --git a/pp_pack.c b/pp_pack.c index 03bf3c8..25cd592 100644 --- a/pp_pack.c +++ b/pp_pack.c @@ -449,7 +449,7 @@ PP(pp_unpack) if (checksum) { while (len-- > 0 && s < strend) { STRLEN alen; - auint = utf8n_to_uvchr((U8*)s, strend - s, &alen, 0); + auint = UNI_TO_NATIVE(utf8n_to_uvchr((U8*)s, strend - s, &alen, 0)); along = alen; s += along; if (checksum > bits_in_uv) @@ -463,7 +463,7 @@ PP(pp_unpack) EXTEND_MORTAL(len); while (len-- > 0 && s < strend) { STRLEN alen; - auint = utf8n_to_uvchr((U8*)s, strend - s, &alen, 0); + auint = UNI_TO_NATIVE(utf8n_to_uvchr((U8*)s, strend - s, &alen, 0)); along = alen; s += along; sv = NEWSV(37, 0); @@ -1558,7 +1558,7 @@ PP(pp_pack) case 'U': while (len-- > 0) { fromstr = NEXTFROM; - auint = SvUV(fromstr); + auint = NATIVE_TO_UNI(SvUV(fromstr)); SvGROW(cat, SvCUR(cat) + UTF8_MAXLEN + 1); SvCUR_set(cat, (char*)uvchr_to_utf8((U8*)SvEND(cat),auint) - SvPVX(cat)); diff --git a/t/op/pack.t b/t/op/pack.t index 38d015b..d1a8032 100755 --- a/t/op/pack.t +++ b/t/op/pack.t @@ -531,8 +531,13 @@ EOP is($z, $expect); } -is("1.20.300.4000", sprintf "%vd", pack("U*",1,20,300,4000)); -is("1.20.300.4000", sprintf "%vd", pack(" U*",1,20,300,4000)); + +SKIP: { + skip("(EBCDIC and) version strings are bad idea", 2) if $Is_EBCDIC; + + is("1.20.300.4000", sprintf "%vd", pack("U*",1,20,300,4000)); + is("1.20.300.4000", sprintf "%vd", pack(" U*",1,20,300,4000)); +} isnt(v1.20.300.4000, sprintf "%vd", pack("C0U*",1,20,300,4000)); my $rslt = $Is_EBCDIC ? "156 67" : "199 162";