summaryrefslogtreecommitdiff
path: root/mg.c
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2011-07-20 14:39:20 +0100
committerDavid Mitchell <davem@iabyn.com>2011-07-20 15:55:06 +0100
commit64eff8b72e154607aa99f7713bd4d05c443be47f (patch)
tree19864af98f615e53b47dd052e2a866cb63bba30f /mg.c
parentad5e438df86ffad2a70e2a2a5f142bdf5eb7da7b (diff)
downloadperl-64eff8b72e154607aa99f7713bd4d05c443be47f.tar.gz
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)
Diffstat (limited to 'mg.c')
-rw-r--r--mg.c8
1 files changed, 8 insertions, 0 deletions
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)