]> Cypherpunks repositories - gostls13.git/commitdiff
regexp/syntax: update perl script to preserve \s behavior
authorIan Lance Taylor <iant@golang.org>
Thu, 29 Mar 2018 22:00:47 +0000 (15:00 -0700)
committerIan Lance Taylor <iant@golang.org>
Thu, 29 Mar 2018 22:31:57 +0000 (22:31 +0000)
Incorporate https://code-review.googlesource.com/#/c/re2/+/3050/ from
the re2 repository. Description of that change:

    Preserve the original behaviour of \s.

    Prior to Perl 5.18, \s did not match vertical tab. Bake that into
    make_perl_groups.pl as an override so that perl_groups.cc retains
    its current definitions when rebuilt with newer versions of Perl.

This fixes make_perl_groups.pl to generate an unchanged perl_groups.go
with perl versions 5.18 and later.

Fixes #22057

Change-Id: I9a56e9660092ed6c1ff1045b4a3847de355441a7
Reviewed-on: https://go-review.googlesource.com/103517
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/regexp/syntax/make_perl_groups.pl

index dc6d232a76cecf4f363c4962199b8f7fd490f3f9..80a2c9ae6b9af5c57d8872dbe5448af1c13ce2dc 100755 (executable)
        "\\w",
 );
 
+%overrides = (
+       # Prior to Perl 5.18, \s did not match vertical tab.
+       # RE2 preserves that original behaviour.
+       "\\s:11" => 0,
+);
+
 sub ComputeClass($) {
   my @ranges;
   my ($class) = @_;
@@ -41,7 +47,7 @@ sub ComputeClass($) {
   my $start = -1;
   for (my $i=0; $i<=129; $i++) {
     if ($i == 129) { $i = 256; }
-    if ($i <= 128 && chr($i) =~ $regexp) {
+    if ($i <= 128 && ($overrides{"$class:$i"} // chr($i) =~ $regexp)) {
       if ($start < 0) {
         $start = $i;
       }