summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-01-13 17:04:14 +0000
committerNicholas Clark <nick@ccl4.org>2011-01-13 17:04:14 +0000
commitd1d7a15d2d5a0a628a4646ff58aaf00222c7ed58 (patch)
tree7a05c921d3c6848bcc1aafc7cbb7d03db1964dc1 /util.c
parent9c88a88bf2f605e353ff3a31ee725b1f9f0db556 (diff)
downloadperl-d1d7a15d2d5a0a628a4646ff58aaf00222c7ed58.tar.gz
In Perl_write_to_stderr(), use Perl_magic_methcall() if STDERR is tied.
Add a flag G_WRITING_TO_STDERR to signal that Perl_magic_methcall() needs to localise PL_stderrgv to NULL, and save/free temps, inside its ENTER/LEAVE pair.
Diffstat (limited to 'util.c')
-rw-r--r--util.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/util.c b/util.c
index e9bd74200a..67a5cbe4d1 100644
--- a/util.c
+++ b/util.c
@@ -1411,28 +1411,8 @@ Perl_write_to_stderr(pTHX_ SV* msv)
if (PL_stderrgv && SvREFCNT(PL_stderrgv)
&& (io = GvIO(PL_stderrgv))
&& (mg = SvTIED_mg((const SV *)io, PERL_MAGIC_tiedscalar)))
- {
- dSP;
- ENTER;
- SAVETMPS;
-
- save_re_context();
- SAVESPTR(PL_stderrgv);
- PL_stderrgv = NULL;
-
- PUSHSTACKi(PERLSI_MAGIC);
-
- PUSHMARK(SP);
- EXTEND(SP,2);
- PUSHs(SvTIED_obj(MUTABLE_SV(io), mg));
- PUSHs(msv);
- PUTBACK;
- call_method("PRINT", G_SCALAR | G_DISCARD);
-
- POPSTACK;
- FREETMPS;
- LEAVE;
- }
+ Perl_magic_methcall(aTHX_ MUTABLE_SV(io), mg, "PRINT",
+ G_SCALAR | G_DISCARD | G_WRITING_TO_STDERR, 1, msv);
else {
#ifdef USE_SFIO
/* SFIO can really mess with your errno */