MAD-only code in S_swallow_bom() duplicated the actions of sv_setpvn()
Nicholas Clark [Tue, 20 Oct 2009 07:11:07 +0000 (08:11 +0100)]
Remove it. All its writes were byte-for-byte identical with the memory they
overwrote. The bugs it attempts to fix are real, but caused by the design and
implementation of other parts of this routine and S_utf16_textfilter().

toke.c

diff --git a/toke.c b/toke.c
index c7ec476..610cc24 100644 (file)
--- a/toke.c
+++ b/toke.c
@@ -12714,18 +12714,9 @@ S_swallow_bom(pTHX_ U8 *s)
                                       PL_bufend - (char*)s - 1,
                                       &newlen);
                sv_setpvn(PL_linestr, (const char*)news, newlen);
-#ifdef PERL_MAD
-               s = (U8*)SvPVX(PL_linestr);
-               Copy(news, s, newlen, U8);
-               s[newlen] = '\0';
-#endif
                Safefree(news);
                SvUTF8_on(PL_linestr);
                s = (U8*)SvPVX(PL_linestr);
-#ifdef PERL_MAD
-               /* FIXME - is this a general bug fix?  */
-               s[newlen] = '\0';
-#endif
                PL_bufend = SvPVX(PL_linestr) + newlen;
            }
 #else