From 64eff8b72e154607aa99f7713bd4d05c443be47f Mon Sep 17 00:00:00 2001 From: David Mitchell Date: Wed, 20 Jul 2011 14:39:20 +0100 Subject: make assign to $^A update FmLINES Currently assigning to $^A updates the string in PL_bodytarget, but doesn't update FmLINES(PL_bodytarget). This can cause later writes to get confused about how many lines have been output, and was causing write.t to fail test 418 under miniperl. (Only under miniperl, because skipping some tests under miniperl affected how $^A's content and line count got messed up). Fix this by updating FmLINES(PL_bodytarget) when $^A is set. (Also fixes a TODO test which was failing due to 'local $^A' in earlier tests) --- mg.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'mg.c') diff --git a/mg.c b/mg.c index 036ac80be1..c07c78b4f0 100644 --- a/mg.c +++ b/mg.c @@ -2483,6 +2483,14 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg) break; case '\001': /* ^A */ sv_setsv(PL_bodytarget, sv); + FmLINES(PL_bodytarget) = 0; + if (SvPOK(PL_bodytarget)) { + char *s = SvPVX(PL_bodytarget); + while ( ((s = strchr(s, '\n'))) ) { + FmLINES(PL_bodytarget)++; + s++; + } + } /* mg_set() has temporarily made sv non-magical */ if (PL_tainting) { if ((tmg = mg_find(sv,PERL_MAGIC_taint)) && tmg->mg_len & 1) -- cgit v1.2.1