Skip to content

Commit

Permalink
oops; fixed botched implementation from last commit
Browse files Browse the repository at this point in the history
'\x' is two characters, not one.
  • Loading branch information
Carl Masak committed Apr 18, 2010
1 parent 131525a commit f958381
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions t/perl6regex/01-regex.t
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions test-regex
Expand Up @@ -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
Expand Down

0 comments on commit f958381

Please sign in to comment.