Permalink
Browse files

oops; fixed botched implementation from last commit

'\x' is two characters, not one.
  • Loading branch information...
1 parent 131525a commit f9583814381b4f5321cc886aa8d8c3bd040b7821 @masak committed Apr 18, 2010
Showing with 5 additions and 5 deletions.
  1. +3 −3 t/perl6regex/01-regex.t
  2. +2 −2 test-regex
@@ -76,11 +76,11 @@ sub match_perl6regex($pattern, $target) {
sub replace_x($s is copy) {
while defined (my $start = $s.index("\\x")) {
- my $end = $start + 1;
+ my $end = $start + 2;
++$end while $s.substr($end, 1) ~~ /<[0..9a..fA..F]>/;
- my $n = $s.substr($start + 1, $end - $start - 1);
+ my $n = $s.substr($start + 2, $end - $start - 2);
$s = $s.substr(0, $start) ~ chr(:16($n)) ~ $s.substr($end);
- };
+ }
$s
}
View
@@ -14,9 +14,9 @@ say $match ?? $match.dump_str('mob', ' ', '') !! "No match\n";
sub replace_x($s is copy) {
while defined (my $start = $s.index("\\x")) {
- my $end = $start + 1;
+ my $end = $start + 2;
++$end while $s.substr($end, 1) ~~ /<[0..9a..fA..F]>/;
- my $n = $s.substr($start + 1, $end - $start - 1);
+ my $n = $s.substr($start + 2, $end - $start - 2);
$s = $s.substr(0, $start) ~ chr(:16($n)) ~ $s.substr($end);
}
$s

0 comments on commit f958381

Please sign in to comment.