In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/270d3c5d82d37f92a0a41fc872cd9c9dfd2c1547?hp=d7e3f70f30811328d2f6ae57e5892deccf64d0b2>

- Log -----------------------------------------------------------------
commit 270d3c5d82d37f92a0a41fc872cd9c9dfd2c1547
Author: Karl Williamson <k...@cpan.org>
Date:   Thu Jun 1 12:37:01 2017 -0600

    t/op/vec.t: White space only.
    
    Adds an indentation level following the previous commit's adding a
    surrounding block

M       t/op/vec.t

commit 315f3fc17abdd3264f6327001ab5b6e90fb7307a
Author: Karl Williamson <k...@cpan.org>
Date:   Thu Jun 1 12:20:52 2017 -0600

    Deprecate vec() with above-FF code points.
    
    This will make this consistent with the bitwise operators.

M       doop.c
M       pod/perldelta.pod
M       pod/perldiag.pod
M       pod/perlfunc.pod
M       t/lib/warnings/doop
M       t/op/vec.t
-----------------------------------------------------------------------

Summary of changes:
 doop.c              | 13 ++++++++++---
 pod/perldelta.pod   |  7 +++++++
 pod/perldiag.pod    |  8 ++++++++
 pod/perlfunc.pod    |  5 +++--
 t/lib/warnings/doop |  8 ++++++++
 t/op/vec.t          | 23 +++++++++++++----------
 6 files changed, 49 insertions(+), 15 deletions(-)

diff --git a/doop.c b/doop.c
index 18bc067d93..0dd4bdf603 100644
--- a/doop.c
+++ b/doop.c
@@ -763,9 +763,16 @@ Perl_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
        Perl_croak(aTHX_ "Illegal number of bits in vec");
 
     if (SvUTF8(sv)) {
-       (void) Perl_sv_utf8_downgrade(aTHX_ sv, TRUE);
-        /* PVX may have changed */
-        s = (unsigned char *) SvPV_flags(sv, srclen, svpv_flags);
+       if (Perl_sv_utf8_downgrade(aTHX_ sv, TRUE)) {
+            /* PVX may have changed */
+            s = (unsigned char *) SvPV_flags(sv, srclen, svpv_flags);
+        }
+        else {
+            Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
+                                "Use of strings with code points over 0xFF as"
+                                " arguments to vec is deprecated. This will"
+                                " be a fatal error in Perl 5.32");
+        }
     }
 
     if (size < 8) {
diff --git a/pod/perldelta.pod b/pod/perldelta.pod
index 7add58fae6..d05083b96a 100644
--- a/pod/perldelta.pod
+++ b/pod/perldelta.pod
@@ -63,6 +63,13 @@ This has been deprecated since Perl 5.24.
 
 XXX Any deprecated features, syntax, modules etc. should be listed here.
 
+=head2 Use of L<C<vec>|perlfunc/vec EXPR,OFFSET,BITS> on strings with code
+points above 0xFF is deprecated.
+
+Use of these is nonsensical, as C<vec> is a bit-oriented operation,
+which operates on the underlying UTF-8 representation these strings must
+be in, and will likely give unexpected results.
+
 =head2 Some uses of unescaped C<"{"> are no longer fatal
 
 Perl 5.26.0 fatalized some uses of an unescaped left brace, but an
diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index 8f24318f6f..6108989109 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -7098,6 +7098,14 @@ bytes, and values beyond 0xFF are nonsensical in this 
context.
 
 Such usage will be a fatal error in Perl 5.28.
 
+=item Use of strings with code points over 0xFF as arguments to C<vec>
+is deprecated. This will be a fatal error in Perl 5.32
+
+(D deprecated) You tried to use L<C<vec>|perlfunc/vec EXPR,OFFSET,BITS>
+on a string containing a code point over 0xFF, which is nonsensical here.
+
+Such usage will be a fatal error in Perl 5.32.
+
 =item Use of tainted arguments in %s is deprecated
 
 (W taint, deprecated) You have supplied C<system()> or C<exec()> with multiple
diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 1fb479d2e2..bb0383f2d6 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -9571,8 +9571,9 @@ If the string happens to be encoded as UTF-8 internally 
(and thus has
 the UTF8 flag set), L<C<vec>|/vec EXPR,OFFSET,BITS> tries to convert it
 to use a one-byte-per-character internal representation. However, if the
 string contains characters with values of 256 or higher, that conversion
-will fail. In that situation, C<vec> will operate on the underlying buffer
-regardless, in its internal UTF-8 representation.
+will fail, and a deprecation message will be raised.  In that situation,
+C<vec> will operate on the underlying buffer regardless, in its internal
+UTF-8 representation.  In Perl 5.32, this will be a fatal error.
 
 Strings created with L<C<vec>|/vec EXPR,OFFSET,BITS> can also be
 manipulated with the logical
diff --git a/t/lib/warnings/doop b/t/lib/warnings/doop
index a62bc23b0f..d5624ce2f1 100644
--- a/t/lib/warnings/doop
+++ b/t/lib/warnings/doop
@@ -35,3 +35,11 @@ Use of strings with code points over 0xFF as arguments to 
bitwise xor (^) operat
 Use of strings with code points over 0xFF as arguments to bitwise and (&) 
operator is deprecated. This will be a fatal error in Perl 5.28 at - line 7.
 Use of strings with code points over 0xFF as arguments to bitwise or (|) 
operator is deprecated. This will be a fatal error in Perl 5.28 at - line 8.
 Use of strings with code points over 0xFF as arguments to bitwise xor (^) 
operator is deprecated. This will be a fatal error in Perl 5.28 at - line 9.
+########
+# NAME vec with above ff code points is deprecated
+my $foo = "\x{100}" . "\xff\xfe";
+eval { vec($foo, 1, 8) };
+no warnings 'deprecated';
+eval { vec($foo, 1, 8) };
+EXPECT
+Use of strings with code points over 0xFF as arguments to vec is deprecated. 
This will be a fatal error in Perl 5.32 at - line 2.
diff --git a/t/op/vec.t b/t/op/vec.t
index 5fa1879686..d3bb57dcd7 100644
--- a/t/op/vec.t
+++ b/t/op/vec.t
@@ -64,16 +64,19 @@ $foo = "\x{100}" . "\xff\xfe";
 $x = substr $foo, 1;
 is(vec($x, 0, 8), 255);
 $@ = undef;
-eval { vec($foo, 1, 8) };
-ok(! $@);
-$@ = undef;
-eval { vec($foo, 1, 8) = 13 };
-ok(! $@);
-if ($::IS_EBCDIC) {
-    is($foo, "\x8c\x0d\xff\x8a\x69"); 
-}
-else {
-    is($foo, "\xc4\x0d\xc3\xbf\xc3\xbe");
+{
+    no warnings 'deprecated';
+    eval { vec($foo, 1, 8) };
+    ok(! $@);
+    $@ = undef;
+    eval { vec($foo, 1, 8) = 13 };
+    ok(! $@);
+    if ($::IS_EBCDIC) {
+        is($foo, "\x8c\x0d\xff\x8a\x69");
+    }
+    else {
+        is($foo, "\xc4\x0d\xc3\xbf\xc3\xbe");
+    }
 }
 $foo = "\x{100}" . "\xff\xfe";
 $x = substr $foo, 1;

--
Perl5 Master Repository

Reply via email to