This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
pp_formline: no need to *t = '\0' until end
authorDavid Mitchell <davem@iabyn.com>
Sun, 29 May 2011 12:34:31 +0000 (13:34 +0100)
committerDavid Mitchell <davem@iabyn.com>
Sun, 29 May 2011 19:21:53 +0000 (20:21 +0100)
We don't care whether PL_formtarget has a trailling \0 until we return;
so remove the bits where we add one in between.

pp_ctl.c

index 0225685..acab077 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -609,7 +609,6 @@ PP(pp_formline)
            if (targ_is_utf8 && !item_is_utf8) {
                char *s;
                SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
-               *t = '\0';
 
                /* this is an unrolled sv_catpvn_utf8_upgrade(),
                 * but with the addition of s/~/ /g */
@@ -630,7 +629,6 @@ PP(pp_formline)
            }
            if (!targ_is_utf8 && item_is_utf8) {
                SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
-               *t = '\0';
                sv_utf8_upgrade_flags_grow(PL_formtarget, 0, fudge + 1);
                t = SvEND(PL_formtarget);
                targ_is_utf8 = TRUE;
@@ -816,7 +814,6 @@ PP(pp_formline)
                if (item_is_utf8) {
                    if (!targ_is_utf8) {
                        SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
-                       *t = '\0';
                        sv_utf8_upgrade_flags_grow(PL_formtarget, 0,
                                                                    fudge + 1);
                        t = SvEND(PL_formtarget);
@@ -849,7 +846,6 @@ PP(pp_formline)
                }
                if (targ_is_utf8 && !item_is_utf8) {
                    SvCUR_set(PL_formtarget, t - SvPVX_const(PL_formtarget));
-                   *t = '\0';
                    sv_catpvn_utf8_upgrade(PL_formtarget, s, arg, nsv);
                    for (; t < SvEND(PL_formtarget); t++) {
 #ifdef EBCDIC