}
OP *
-die_where(char *message)
+die_where(char *message, STRLEN msglen)
{
dSP;
STRLEN n_a;
if (message) {
if (PL_in_eval & 4) {
SV **svp;
- STRLEN klen = strlen(message);
- svp = hv_fetch(ERRHV, message, klen, TRUE);
+ svp = hv_fetch(ERRHV, message, msglen, TRUE);
if (svp) {
if (!SvIOK(*svp)) {
static char prefix[] = "\t(in cleanup) ";
(void)SvIOK_only(*svp);
if (!SvPOK(err))
sv_setpv(err,"");
- SvGROW(err, SvCUR(err)+sizeof(prefix)+klen);
+ SvGROW(err, SvCUR(err)+sizeof(prefix)+msglen);
sv_catpvn(err, prefix, sizeof(prefix)-1);
- sv_catpvn(err, message, klen);
+ sv_catpvn(err, message, msglen);
if (ckWARN(WARN_UNSAFE)) {
- STRLEN start = SvCUR(err)-klen-sizeof(prefix)+1;
+ STRLEN start = SvCUR(err)-msglen-sizeof(prefix)+1;
warner(WARN_UNSAFE, SvPVX(err)+start);
}
}
}
}
else
- sv_setpv(ERRSV, message);
+ sv_setpvn(ERRSV, message, msglen);
}
else
- message = SvPVx(ERRSV, n_a);
+ message = SvPVx(ERRSV, msglen);
while ((cxix = dopoptoeval(cxstack_ix)) < 0 && PL_curstackinfo->si_prev) {
dounwind(-1);
POPBLOCK(cx,PL_curpm);
if (CxTYPE(cx) != CXt_EVAL) {
- PerlIO_printf(PerlIO_stderr(), "panic: die %s", message);
+ PerlIO_write(PerlIO_stderr(), "panic: die ", 11);
+ PerlIO_write(PerlIO_stderr(), message, msglen);
my_exit(1);
}
POPEVAL(cx);
}
}
if (!message)
- message = SvPVx(ERRSV, n_a);
+ message = SvPVx(ERRSV, msglen);
{
#ifdef USE_SFIO
/* SFIO can really mess with your errno */
int e = errno;
#endif
- PerlIO_puts(PerlIO_stderr(), message);
+ PerlIO_write(PerlIO_stderr(), message, msglen);
(void)PerlIO_flush(PerlIO_stderr());
#ifdef USE_SFIO
errno = e;
PP(pp_warn)
{
djSP; dMARK;
+ SV *tmpsv;
char *tmps;
- STRLEN n_a;
+ STRLEN len;
if (SP - MARK != 1) {
dTARGET;
do_join(TARG, &PL_sv_no, MARK, SP);
- tmps = SvPV(TARG, n_a);
+ tmpsv = TARG;
SP = MARK + 1;
}
else {
- tmps = SvPV(TOPs, n_a);
+ tmpsv = TOPs;
}
- if (!tmps || !*tmps) {
+ tmps = SvPV(tmpsv, len);
+ if (!tmps || !len) {
SV *error = ERRSV;
(void)SvUPGRADE(error, SVt_PV);
if (SvPOK(error) && SvCUR(error))
sv_catpv(error, "\t...caught");
- tmps = SvPV(error, n_a);
+ tmpsv = error;
+ tmps = SvPV(tmpsv, len);
}
- if (!tmps || !*tmps)
- tmps = "Warning: something's wrong";
- warn("%s", tmps);
+ if (!tmps || !len)
+ tmpsv = sv_2mortal(newSVpvn("Warning: something's wrong", 26));
+
+ warn("%_", tmpsv);
RETSETYES;
}
{
djSP; dMARK;
char *tmps;
- SV *tmpsv = Nullsv;
- char *pat = "%s";
- STRLEN n_a;
+ SV *tmpsv;
+ STRLEN len;
+ bool multiarg = 0;
if (SP - MARK != 1) {
dTARGET;
do_join(TARG, &PL_sv_no, MARK, SP);
- tmps = SvPV(TARG, n_a);
+ tmpsv = TARG;
+ tmps = SvPV(tmpsv, len);
+ multiarg = 1;
SP = MARK + 1;
}
else {
tmpsv = TOPs;
- tmps = SvROK(tmpsv) ? Nullch : SvPV(tmpsv, n_a);
+ tmps = SvROK(tmpsv) ? Nullch : SvPV(tmpsv, len);
}
- if (!tmps || !*tmps) {
+ if (!tmps || !len) {
SV *error = ERRSV;
(void)SvUPGRADE(error, SVt_PV);
- if(tmpsv ? SvROK(tmpsv) : SvROK(error)) {
- if(tmpsv)
+ if (multiarg ? SvROK(error) : SvROK(tmpsv)) {
+ if (!multiarg)
SvSetSV(error,tmpsv);
- else if(sv_isobject(error)) {
+ else if (sv_isobject(error)) {
HV *stash = SvSTASH(SvRV(error));
GV *gv = gv_fetchmethod(stash, "PROPAGATE");
if (gv) {
sv_setsv(error,*PL_stack_sp--);
}
}
- pat = Nullch;
+ DIE(Nullch);
}
else {
if (SvPOK(error) && SvCUR(error))
sv_catpv(error, "\t...propagated");
- tmps = SvPV(error, n_a);
+ tmpsv = error;
+ tmps = SvPV(tmpsv, len);
}
}
- if (!tmps || !*tmps)
- tmps = "Died";
- DIE(pat, tmps);
+ if (!tmps || !len)
+ tmpsv = sv_2mortal(newSVpvn("Died", 4));
+
+ DIE("%_", tmpsv);
}
/* I/O. */
int delim, I32* retlen));
VIRTUAL void deprecate _((char* s));
VIRTUAL OP* die _((const char* pat,...));
-VIRTUAL OP* die_where _((char* message));
+VIRTUAL OP* die_where _((char* message, STRLEN msglen));
VIRTUAL void dounwind _((I32 cxix));
VIRTUAL bool do_aexec _((SV* really, SV** mark, SV** sp));
VIRTUAL int do_binmode _((PerlIO *fp, int iotype, int flag));
#ifdef USE_LOCALE_COLLATE
VIRTUAL char* mem_collxfrm _((const char* s, STRLEN len, STRLEN* xlen));
#endif
-VIRTUAL char* mess _((const char* pat, va_list* args));
+VIRTUAL SV* mess _((const char* pat, va_list* args));
VIRTUAL int mg_clear _((SV* sv));
VIRTUAL int mg_copy _((SV* sv, SV* nsv, const char* key, I32 klen));
VIRTUAL MAGIC* mg_find _((SV* sv, int type));
STRLEN l1 = strlen(pat1);
STRLEN l2 = strlen(pat2);
char buf[512];
+ SV *msv;
char *message;
if (l1 > 510)
buf[l1 + l2] = '\n';
buf[l1 + l2 + 1] = '\0';
va_start(args, pat2);
- message = mess(buf, &args);
+ msv = mess(buf, &args);
va_end(args);
- l1 = strlen(message);
+ message = SvPV(msv,l1);
if (l1 > 512)
l1 = 512;
Copy(message, buf, l1 , char);
$SIG{__DIE__} = sub { print ref($_[0]) ? ("ok ",$_[0]->[0]++,"\n") : @_ } ;
-$err = "ok 1\n";
+$err = "#[\000]\nok 1\n";
eval {
die $err;
};
return SvPVX(sv);
}
-char *
+SV *
mess(const char *pat, va_list *args)
{
SV *sv = mess_alloc();
sv_catpv(sv, ".\n");
}
}
- return SvPVX(sv);
+ return sv;
}
OP *
HV *stash;
GV *gv;
CV *cv;
+ SV *msv;
+ STRLEN msglen;
DEBUG_S(PerlIO_printf(PerlIO_stderr(),
"%p: die: curstack = %p, mainstack = %p\n",
thr, PL_curstack, PL_mainstack));
va_start(args, pat);
- message = pat ? mess(pat, &args) : Nullch;
+ if (pat) {
+ msv = mess(pat, &args);
+ message = SvPV(msv,msglen);
+ }
+ else {
+ message = Nullch;
+ }
va_end(args);
DEBUG_S(PerlIO_printf(PerlIO_stderr(),
ENTER;
if (message) {
- msg = newSVpv(message, 0);
+ msg = newSVpvn(message, msglen);
SvREADONLY_on(msg);
SAVEFREESV(msg);
}
}
}
- PL_restartop = die_where(message);
+ PL_restartop = die_where(message, msglen);
DEBUG_S(PerlIO_printf(PerlIO_stderr(),
"%p: die: restartop = %p, was_in_eval = %d, top_env = %p\n",
thr, PL_restartop, was_in_eval, PL_top_env));
HV *stash;
GV *gv;
CV *cv;
+ SV *msv;
+ STRLEN msglen;
va_start(args, pat);
- message = mess(pat, &args);
+ msv = mess(pat, &args);
+ message = SvPV(msv,msglen);
va_end(args);
DEBUG_S(PerlIO_printf(PerlIO_stderr(), "croak: 0x%lx %s", (unsigned long) thr, message));
if (PL_diehook) {
SV *msg;
ENTER;
- msg = newSVpv(message, 0);
+ msg = newSVpvn(message, msglen);
SvREADONLY_on(msg);
SAVEFREESV(msg);
}
}
if (PL_in_eval) {
- PL_restartop = die_where(message);
+ PL_restartop = die_where(message, msglen);
JMPENV_JUMP(3);
}
{
/* SFIO can really mess with your errno */
int e = errno;
#endif
- PerlIO_puts(PerlIO_stderr(), message);
+ PerlIO_write(PerlIO_stderr(), message, msglen);
(void)PerlIO_flush(PerlIO_stderr());
#ifdef USE_SFIO
errno = e;
HV *stash;
GV *gv;
CV *cv;
+ SV *msv;
+ STRLEN msglen;
va_start(args, pat);
- message = mess(pat, &args);
+ msv = mess(pat, &args);
+ message = SvPV(msv, msglen);
va_end(args);
if (PL_warnhook) {
SV *msg;
ENTER;
- msg = newSVpv(message, 0);
+ msg = newSVpvn(message, msglen);
SvREADONLY_on(msg);
SAVEFREESV(msg);
return;
}
}
- PerlIO_puts(PerlIO_stderr(),message);
+ PerlIO_write(PerlIO_stderr(), message, msglen);
#ifdef LEAKTEST
DEBUG_L(*message == '!'
? (xstat(message[1]=='!'
HV *stash;
GV *gv;
CV *cv;
+ SV *msv;
+ STRLEN msglen;
va_start(args, pat);
- message = mess(pat, &args);
+ msv = mess(pat, &args);
+ message = SvPV(msv, msglen);
va_end(args);
if (ckDEAD(err)) {
SV *msg;
ENTER;
- msg = newSVpv(message, 0);
+ msg = newSVpvn(message, msglen);
SvREADONLY_on(msg);
SAVEFREESV(msg);
}
}
if (PL_in_eval) {
- PL_restartop = die_where(message);
+ PL_restartop = die_where(message, msglen);
JMPENV_JUMP(3);
}
- PerlIO_puts(PerlIO_stderr(),message);
+ PerlIO_write(PerlIO_stderr(), message, msglen);
(void)PerlIO_flush(PerlIO_stderr());
my_failure_exit();
SV *msg;
ENTER;
- msg = newSVpv(message, 0);
+ msg = newSVpvn(message, msglen);
SvREADONLY_on(msg);
SAVEFREESV(msg);
return;
}
}
- PerlIO_puts(PerlIO_stderr(),message);
+ PerlIO_write(PerlIO_stderr(), message, msglen);
#ifdef LEAKTEST
DEBUG_L(xstat());
#endif