const char *rsave;
bool left_utf;
bool right_utf;
+ bool do_warn_above_ff = ckWARN_d(WARN_DEPRECATED);
STRLEN needlen = 0;
PERL_ARGS_ASSERT_DO_VOP;
rulen -= ulen;
duc = luc & ruc;
dc = (char*)uvchr_to_utf8((U8*)dc, duc);
+ if (do_warn_above_ff && (luc > 0xff || ruc > 0xff)) {
+ Perl_warner(aTHX_ packWARN(WARN_DEPRECATED),
+ deprecated_above_ff_msg, PL_op_desc[optype]);
+ /* Warn only once per operation */
+ do_warn_above_ff = FALSE;
+ }
}
if (sv == left || sv == right)
(void)sv_usepvn(sv, dcorig, needlen);
rulen -= ulen;
duc = luc ^ ruc;
dc = (char*)uvchr_to_utf8((U8*)dc, duc);
+ if (do_warn_above_ff && (luc > 0xff || ruc > 0xff)) {
+ Perl_warner(aTHX_ packWARN(WARN_DEPRECATED),
+ deprecated_above_ff_msg, PL_op_desc[optype]);
+ do_warn_above_ff = FALSE;
+ }
}
goto mop_up_utf;
case OP_BIT_OR:
rulen -= ulen;
duc = luc | ruc;
dc = (char*)uvchr_to_utf8((U8*)dc, duc);
+ if (do_warn_above_ff && (luc > 0xff || ruc > 0xff)) {
+ Perl_warner(aTHX_ packWARN(WARN_DEPRECATED),
+ deprecated_above_ff_msg, PL_op_desc[optype]);
+ do_warn_above_ff = FALSE;
+ }
}
mop_up_utf:
if (rulen)
#define MDEREF_MASK 0x7F
#define MDEREF_SHIFT 7
+#if defined(PERL_IN_DOOP_C) || defined(PERL_IN_PP_C)
+static const char * const deprecated_above_ff_msg
+ = "Use of strings with code points over 0xFF as arguments to "
+ "%s operator is deprecated";
+#endif
+
/*
* ex: set ts=8 sts=4 sw=4 et:
C<IV_MAX> is typically 2**31 -1 on 32-bit platforms, and 2**63-1 on
64-bit ones.
+=head2 Doing bitwise operations on strings containing code points above
+0xFF is deprecated
+
+The string bitwise operators treat their operands as strings of bytes,
+and values beyond 0xFF are nonsensical in this context. To operate on
+encoded bytes, first encode the strings. To operate on code points'
+numeric values, use C<split> and C<map ord>. In the future, this
+warning will be replaced by an exception.
+
=head1 Performance Enhancements
XXX Changes which enhance performance without changing behaviour go here.
its behavior may change or even be removed in any future release of perl.
See the explanation under L<perlvar/$_>.
+=item Use of strings with code points over 0xFF as arguments to %s
+operator is deprecated
+
+(D deprecated) You tried to use one of the string bitwise operators
+(C<&> or C<|> or C<^> or C<~>) on a string containing a code point over
+0xFF. The string bitwise operators treat their operands as strings of
+bytes, and values beyond 0xFF are nonsensical in this context.
+
=item Use of tainted arguments in %s is deprecated
(W taint, deprecated) You have supplied C<system()> or C<exec()> with multiple
U8 *result;
U8 *p;
+ Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
+ deprecated_above_ff_msg, PL_op_desc[PL_op->op_type]);
Newx(result, targlen + 1, U8);
p = result;
while (tmps < send) {
chop ;
EXPECT
########
+# NAME deprecation of logical bit operations with above ff code points
+$_ = "\xFF" & "\x{100}"; # Above ff second
+$_ = "\xFF" | "\x{101}";
+$_ = "\xFF" ^ "\x{102}";
+$_ = "\x{100}" & "\x{FF}"; # Above ff first
+$_ = "\x{101}" | "\x{FF}";
+$_ = "\x{102}" ^ "\x{FF}";
+$_ = "\x{100}" & "\x{103}"; # both above ff has just one message raised
+$_ = "\x{101}" | "\x{104}";
+$_ = "\x{102}" ^ "\x{105}";
+no warnings 'deprecated';
+$_ = "\xFF" & "\x{100}";
+$_ = "\xFF" | "\x{101}";
+$_ = "\xFF" ^ "\x{101}";
+$_ = "\x{100}" & "\x{FF}";
+$_ = "\x{101}" | "\x{FF}";
+$_ = "\x{102}" ^ "\x{FF}";
+$_ = "\x{100}" & "\x{103}";
+$_ = "\x{101}" | "\x{104}";
+$_ = "\x{102}" ^ "\x{105}";
+EXPECT
+Use of strings with code points over 0xFF as arguments to bitwise and (&) operator is deprecated at - line 1.
+Use of strings with code points over 0xFF as arguments to bitwise or (|) operator is deprecated at - line 2.
+Use of strings with code points over 0xFF as arguments to bitwise xor (^) operator is deprecated at - line 3.
+Use of strings with code points over 0xFF as arguments to bitwise and (&) operator is deprecated at - line 4.
+Use of strings with code points over 0xFF as arguments to bitwise or (|) operator is deprecated at - line 5.
+Use of strings with code points over 0xFF as arguments to bitwise xor (^) operator is deprecated at - line 6.
+Use of strings with code points over 0xFF as arguments to bitwise and (&) operator is deprecated at - line 7.
+Use of strings with code points over 0xFF as arguments to bitwise or (|) operator is deprecated at - line 8.
+Use of strings with code points over 0xFF as arguments to bitwise xor (^) operator is deprecated at - line 9.
$_ = "\x80 \xff" ;
reverse ;
EXPECT
+########
+# NAME deprecation of complement with above ff code points
+$_ = ~ "\xff";
+$_ = ~ "\x{100}";
+EXPECT
+OPTION regex
+Use of strings with code points over 0xFF as arguments to 1's complement \(~\) operator is deprecated at - line \d+.
+Use of code point 0xFF+EFF is deprecated; the permissible max is 0x7F+ at - line \d+.
# [perl #23765]
{
my $a = pack("C", 0xbf);
+ no warnings 'deprecated';
substr($a, -1) &= chr(0xfeff);
is($a, "\xbf");
}