This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make ‘Escape literal pattern white space’ a default warning
authorFather Chrysostomos <sprout@cpan.org>
Mon, 27 May 2013 06:53:40 +0000 (23:53 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Mon, 27 May 2013 07:50:03 +0000 (00:50 -0700)
All deprecated warnings are supposed to be default warnings.

regcomp.c
t/re/reg_mesg.t

index b5dc85e..ab86f4f 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11021,7 +11021,7 @@ tryagain:
 
                     if (! SIZE_ONLY
                         && RExC_flags & RXf_PMf_EXTENDED
-                        && ckWARN(WARN_DEPRECATED)
+                        && ckWARN_d(WARN_DEPRECATED)
                         && is_PATWS_non_low(p, UTF))
                     {
                         vWARN_dep(p + ((UTF) ? UTF8SKIP(p) : 1),
index ca5c8df..2a3bd8d 100644 (file)
@@ -313,6 +313,16 @@ foreach my $ref (\@warning, \@experimental_regex_sets, \@deprecated) {
                                     eval "no warnings '$warning_type'; $regex;" }
                                 ),
                     "... and turning off '$warning_type' warnings suppressed it");
+                    # Test that whether the warning is on by default is
+                    # correct.  Experimental and deprecated warnings are;
+                    # others are not.  This test relies on the fact that we
+                    # are outside the scope of any ‘use warnings’.
+                    local $^W;
+                    my $on = 'on' x ($warning_type ne 'regexp');
+                    ok !!$on ==
+                        capture_warnings(sub { $_ = "x"; eval $regex }),
+                      "... and the warning is " . ($on||'off')
+                       . " by default";
                 }
             }
         }