MAYBE_TAINT_LINE(io, sv);
RETURN;
}
- if (SvUTF8(sv)) {
- U8 *s = (U8*)SvPVX(sv) + offset;
- STRLEN len = SvCUR(sv) - offset;
- U8 *f;
-
- if (ckWARN(WARN_UTF8) &&
- !Perl_is_utf8_string_loc(aTHX_ s, len, &f))
- /* Emulate :encoding(utf8) warning in the same case. */
- Perl_warner(aTHX_ packWARN(WARN_UTF8),
- "utf8 \"\\x%02X\" does not map to Unicode",
- f < (U8*)SvEND(sv) ? *f : 0);
- }
MAYBE_TAINT_LINE(io, sv);
IoLINES(io)++;
IoFLAGS(io) |= IOf_NOLINE;
(void)POPs; /* Unmatched wildcard? Chuck it... */
continue;
}
+ } else if (SvUTF8(sv)) { /* OP_READLINE, OP_RCATLINE */
+ U8 *s = (U8*)SvPVX(sv) + offset;
+ STRLEN len = SvCUR(sv) - offset;
+ U8 *f;
+
+ if (ckWARN(WARN_UTF8) &&
+ !Perl_is_utf8_string_loc(aTHX_ s, len, &f))
+ /* Emulate :encoding(utf8) warning in the same case. */
+ Perl_warner(aTHX_ packWARN(WARN_UTF8),
+ "utf8 \"\\x%02X\" does not map to Unicode",
+ f < (U8*)SvEND(sv) ? *f : 0);
}
if (gimme == G_ARRAY) {
if (SvLEN(sv) - SvCUR(sv) > 20) {
require "./test.pl";
-plan(tests => 52);
+plan(tests => 53);
$| = 1;
# <FH> on a :utf8 stream should complain immediately with -w
# if it finds bad UTF-8 (:encoding(utf8) works this way)
use warnings 'utf8';
+ undef $@;
local $SIG{__WARN__} = sub { $@ = shift };
open F, ">a";
binmode F;
print F "foo", chr(0xE4), "\n";
+ print F "foo", chr(0xF6), "\n";
close F;
open F, "<:utf8", "a";
+ undef $@;
my $line = <F>;
- like( $@, qr/utf8 "\\xE4" does not map to Unicode/ );
+ like( $@, qr/utf8 "\\xE4" does not map to Unicode .+ <F> line 1/,
+ "<:utf8 readline must warn about bad utf8");
+ undef $@;
+ $line .= <F>;
+ like( $@, qr/utf8 "\\xF6" does not map to Unicode .+ <F> line 2/,
+ "<:utf8 rcatline must warn about bad utf8");
close F;
}