In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/e07286ed3e670b1b54d58add2acfdf6985372bf6?hp=ba77e4cc9d1ceebf472c9c5c18b2377ee47062e6>

- Log -----------------------------------------------------------------
commit e07286ed3e670b1b54d58add2acfdf6985372bf6
Author: Nicholas Clark <[email protected]>
Date:   Thu Oct 22 20:17:54 2009 +0100

    In S_utf16_textfilter() replace sv_chop() with code, as we move 1 byte at 
most.
-----------------------------------------------------------------------

Summary of changes:
 toke.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/toke.c b/toke.c
index f105505..d83ac6a 100644
--- a/toke.c
+++ b/toke.c
@@ -12871,7 +12871,15 @@ S_utf16_textfilter(pTHX_ int idx, SV *sv, int maxlen)
        SvCUR_set(utf8_buffer, have + newlen);
        *end = '\0';
 
-       sv_chop(utf16_buffer, SvPVX(utf16_buffer) + chars * 2);
+       /* No need to keep this SV "well-formed" with a '\0' after the end, as
+          it's private to us, and utf16_to_utf8{,reversed} take a
+          (pointer,length) pair, rather than a NUL-terminated string.  */
+       if(SvCUR(utf16_buffer) & 1) {
+           *SvPVX(utf16_buffer) = SvEND(utf16_buffer)[-1];
+           SvCUR_set(utf16_buffer, 1);
+       } else {
+           SvCUR_set(utf16_buffer, 0);
+       }
     }
     DEBUG_P(PerlIO_printf(Perl_debug_log,
                          "utf16_textfilter: returns, status=%"IVdf" 
utf16=%"UVuf" utf8=%"UVuf"\n",

--
Perl5 Master Repository

Reply via email to