summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--MANIFEST1
-rw-r--r--t/uni/readline.t66
-rw-r--r--toke.c2
3 files changed, 68 insertions, 1 deletions
diff --git a/MANIFEST b/MANIFEST
index b46ef3e12a..361e496261 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -5286,6 +5286,7 @@ t/uni/method.t See if Unicode methods work
t/uni/overload.t See if Unicode overloading works
t/uni/package.t See if Unicode in package declarations works
t/uni/parser.t See if Unicode in the parser works in edge cases.
+t/uni/readline.t See if Unicode filehandles in <FH> work
t/uni/select.t See if Unicode filehandles aren't mangled by select()
t/uni/sprintf.t See if Unicode sprintf works
t/uni/stash.t See if Unicode stashes work
diff --git a/t/uni/readline.t b/t/uni/readline.t
new file mode 100644
index 0000000000..ef2106dfd2
--- /dev/null
+++ b/t/uni/readline.t
@@ -0,0 +1,66 @@
+#!./perl
+
+BEGIN {
+ chdir 't';
+ @INC = '../lib';
+ require './test.pl';
+}
+
+plan tests => 7;
+
+use utf8;
+use open qw( :utf8 :std );
+
+# [perl #19566]: sv_gets writes directly to its argument via
+# TARG. Test that we respect SvREADONLY.
+eval { for (\2) { $_ = <Fʜ> } };
+like($@, 'Modification of a read-only value attempted', '[perl #19566]');
+
+# [perl #21628]
+{
+ my $file = tempfile();
+ open Ạ,'+>',$file; $a = 3;
+ is($a .= <Ạ>, 3, '#21628 - $a .= <A> , A eof');
+ close A; $a = 4;
+ is($a .= <Ạ>, 4, '#21628 - $a .= <A> , A closed');
+}
+
+use strict;
+
+open ᕝ, '.' and sysread ᕝ, $_, 1;
+my $err = $! + 0;
+close ᕝ;
+
+SKIP: {
+ skip "you can read directories as plain files", 2 unless( $err );
+
+ $!=0;
+ open ᕝ, '.' and $_=<ᕝ>;
+ ok( $!==$err && !defined($_) => 'readline( DIRECTORY )' );
+ close ᕝ;
+
+ $!=0;
+ { local $/;
+ open ᕝ, '.' and $_=<ᕝ>;
+ ok( $!==$err && !defined($_) => 'readline( DIRECTORY ) slurp mode' );
+ close ᕝ;
+ }
+}
+
+my $obj = bless [], "Ȼლᔆ";
+$obj .= <DATA>;
+like($obj, qr/Ȼლᔆ=ARRAY.*world/u, 'rcatline and refs');
+
+{
+ my $file = tempfile();
+ open my $out_fh, ">", $file;
+ print { $out_fh } "Data\n";
+ close $out_fh;
+
+ open hòฟ, "<", $file;
+ is( scalar(<hòฟ>), "Data\n", "readline() works correctly on UTF-8 filehandles" );
+ close hòฟ;
+}
+
+__DATA__
+world
diff --git a/toke.c b/toke.c
index c995556a76..200b9dc646 100644
--- a/toke.c
+++ b/toke.c
@@ -9548,7 +9548,7 @@ S_scan_inputsymbol(pTHX_ char *start)
/* allow <Pkg'VALUE> or <Pkg::VALUE> */
while (*d && (isALNUM_lazy_if(d,UTF) || *d == '\'' || *d == ':'))
- d++;
+ d += UTF ? UTF8SKIP(d) : 1;
/* If we've tried to read what we allow filehandles to look like, and
there's still text left, then it must be a glob() and not a getline.