summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-11-18 05:43:11 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-11-18 05:43:11 +0000
commite72dc28c8f6f33daa2b69b80b6322e338e999561 (patch)
tree7ff57260234239ac324f4159209b87add3f31f64 /util.c
parentb5d92ff461a53c003570dfb3f7104a54ab2cc3d8 (diff)
downloadperl-e72dc28c8f6f33daa2b69b80b6322e338e999561.tar.gz
use PL_mess_sv only during global destruction (fixes problems with
overlapping invocations of form()/warn()/die()/croak() trampling on each other's messages) p4raw-id: //depot/perl@2249
Diffstat (limited to 'util.c')
-rw-r--r--util.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/util.c b/util.c
index 4698e901d0..56016f83ed 100644
--- a/util.c
+++ b/util.c
@@ -1187,39 +1187,40 @@ savepvn(char *sv, register I32 len)
STATIC SV *
mess_alloc(void)
{
+ dTHR;
SV *sv;
XPVMG *any;
+ if (!PL_dirty)
+ return sv_2mortal(newSVpvn("",0));
+
/* Create as PVMG now, to avoid any upgrading later */
New(905, sv, 1, SV);
Newz(905, any, 1, XPVMG);
SvFLAGS(sv) = SVt_PVMG;
SvANY(sv) = (void*)any;
SvREFCNT(sv) = 1 << 30; /* practically infinite */
+ PL_mess_sv = sv;
return sv;
}
char *
form(const char* pat, ...)
{
+ SV *sv = mess_alloc();
va_list args;
va_start(args, pat);
- if (!PL_mess_sv)
- PL_mess_sv = mess_alloc();
- sv_vsetpvfn(PL_mess_sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
+ sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*));
va_end(args);
- return SvPVX(PL_mess_sv);
+ return SvPVX(sv);
}
char *
mess(const char *pat, va_list *args)
{
- SV *sv;
+ SV *sv = mess_alloc();
static char dgd[] = " during global destruction.\n";
- if (!PL_mess_sv)
- PL_mess_sv = mess_alloc();
- sv = PL_mess_sv;
sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*));
if (!SvCUR(sv) || *(SvEND(sv) - 1) != '\n') {
dTHR;