In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/88c342510b9c95c4cb80bbda6821c61591e48c37?hp=fa846618beb21a71cb1ceb57e52434d2841df75d>

- Log -----------------------------------------------------------------
commit 88c342510b9c95c4cb80bbda6821c61591e48c37
Author: Father Chrysostomos <spr...@cpan.org>
Date:   Sun Jan 12 16:47:31 2014 -0800

    Make getc unset the utf8 flag on its retval
    
    The same scalar (the target) is used to return the value each time the
    same getc operator is called.  It was turning on the utf8 flag when
    necessary, but not turning it off.
    
    (I suspect recv has the same bug.  I haven’t confirmed.)
-----------------------------------------------------------------------

Summary of changes:
 pp_sys.c    |  1 +
 t/io/utf8.t | 14 +++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/pp_sys.c b/pp_sys.c
index b5d84d3..3cd542c 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -1335,6 +1335,7 @@ PP(pp_getc)
        }
        SvUTF8_on(TARG);
     }
+    else SvUTF8_off(TARG);
     PUSHTARG;
     RETURN;
 }
diff --git a/t/io/utf8.t b/t/io/utf8.t
index 1a0396b..c8f37dd 100644
--- a/t/io/utf8.t
+++ b/t/io/utf8.t
@@ -10,7 +10,7 @@ BEGIN {
 no utf8; # needed for use utf8 not griping about the raw octets
 
 
-plan(tests => 61);
+plan(tests => 63);
 
 $| = 1;
 
@@ -387,3 +387,15 @@ is($failed, undef);
          "<:utf8 readline (fixed) must warn about bad utf8");
     close F;
 }
+
+# getc should reset the utf8 flag and not be affected by previous
+# return values
+SKIP: {
+    skip "no PerlIO::scalar on miniperl", 2, if is_miniperl();
+    open my $fh, "<",      \($buf = chr 255);
+    open my $uh, "<:utf8", \($uuf = "\xc4\x80");
+    for([$uh,chr 256], [$fh,chr 255]) {
+       is getc $$_[0], $$_[1],
+         'getc returning non-utf8 after utf8';
+    }
+}

--
Perl5 Master Repository

Reply via email to