On Thu, Feb 17, 2005 at 09:24:53PM -0000, dgeorge @no-spam cas. org wrote:
> This is a bug report for perl from dgeorge@no-spam
> generated with the help of perlbug 1.35 running under perl v5.8.4.
> use bytes;
The bytes pragma was important under the not-so-great way utf8 was
handled in perl5.6.x. IMO, in the 5.8.x series, there is almost no good
reason to use it.
On Thu, Feb 17, 2005 at 09:24:53PM -0000, dgeorge @no-spam cas. org wrote:
> use strict;
> use bytes;
> use XML::DOM;
>
> # XML document
> my $xml = "<doc>\xe2\x80\x98WOW\xe2\x80\x99</doc>";
>
> # XML parser
> my $parser = new XML::DOM::Parser;
>
> # Document Object Model
> my $dom = $parser->parse($xml, ProtocolEncoding => 'UTF-8');
>
> # Element content
> my $content = $dom->getDocumentElement()->getFirstChild()->getNodeValue();
>
> # Print length of $content(should be 9 and is 9)
> print 'Length of $content = ', unpack("H*", $content), ' is ', length($content), "\n";
>
> # Print length of $1(should be 3 1 1 1 3 and is 1 1 1 1 3)
> $content =~ s/([\x00-\x7f]|[\xc0-\xdf].|[\xe0-\xef]..|[\xf0-\xf7]...|[\xf8-\xfb]....|[\xfc-\xfd].....)/print 'Length of $1 = ', unpack("H*", $1), ' is ', length($1), "\n"/eg;
Fixed in bleedperl by the change below
--
In my day, we used to edit the inodes by hand. With magnets.
Change 25088 by davem@no-spam on 2005/07/07 00:11:00
[perl #34171] bytes pragma error in substitution operator
Affected files ...
... //depot/perl/pp_ctl.c#464 edit
... //depot/perl/t/op/subst.t#43 edit
Differences ...
==== //depot/perl/pp_ctl.c#464 (text) ====
@@no-spam -204,7 +204,7 @@no-spam
}
rxres_restore(&cx->sb_rxres, rx);
- RX_MATCH_UTF8_set(rx, SvUTF8(cx->sb_targ));
+ RX_MATCH_UTF8_set(rx, DO_UTF8(cx->sb_targ));
if (cx->sb_iters++) {
const I32 saviters = cx->sb_iters;
==== //depot/perl/t/op/subst.t#43 (xtext) ====
@@no-spam -7,7 +7,7 @@no-spam
}
require './test.pl';
-plan( tests => 130 );
+plan( tests => 131 );
$x = 'foo';
$_ = "x";
@@no-spam -539,3 +539,17 @@no-spam
$name =~ s/hr//e;
}
is($name, "cis", q[#22351 bug with 'e' substitution modifier]);
+
+
+# [perl #34171] $1 didn't honour 'use bytes' in s//e
+{
+ my $s="\x{100}";
+ my $x;
+ {
+ use bytes;
+ $s=~ s/(..)/$x=$1/e
+ }
+ is(length($x), 2, '[perl #34171]');
+}
+
+