{
const int saveerrno = errno;
sv_setnv(sv, (NV)errno);
- sv_setpv(sv, (const char *)(errno ? Strerror(errno) : ""));
+ sv_setpv(sv, errno ? Strerror(errno) : "");
errno = saveerrno;
}
#endif
sv_setpvn(sv, WARN_NONEstring, WARNsize) ;
}
else if (PL_compiling.cop_warnings == pWARN_STD) {
- sv_setpvn(sv,
- (const char *)
- ((PL_dowarn & G_WARN_ON) ?
- WARN_ALLstring : WARN_NONEstring),
- WARNsize);
+ sv_setpvn(
+ sv,
+ (PL_dowarn & G_WARN_ON) ? WARN_ALLstring : WARN_NONEstring,
+ WARNsize
+ );
}
else if (PL_compiling.cop_warnings == pWARN_ALL) {
/* Get the bit mask for $warnings::Bits{all}, because
i = t1 - s1;
s = rx->subbeg + s1;
assert(rx->subbeg);
+ assert(rx->sublen >= s1);
getrx:
if (i >= 0) {
TAINT_NOT;
sv_setpvn(sv, s, i);
PL_tainted = oldtainted;
- if (RX_MATCH_UTF8(rx) && is_utf8_string((U8*)s, i))
+ if ( (rx->reganch & ROPT_CANY_SEEN)
+ ? (RX_MATCH_UTF8(rx)
+ && (!i || is_utf8_string((U8*)s, i)))
+ : (RX_MATCH_UTF8(rx)) )
+ {
SvUTF8_on(sv);
+ }
else
SvUTF8_off(sv);
if (PL_tainting) {
sv_setpv(sv, os2error(Perl_rc));
else
#endif
- sv_setpv(sv, (const char *)(errno ? Strerror(errno) : ""));
+ sv_setpv(sv, errno ? Strerror(errno) : "");
errno = saveerrno;
}
#endif
{
dVAR;
STRLEN len = 0, klen;
- const char *s = SvOK(sv) ? SvPV_const(sv,len) : (const char *)"";
+ const char *s = SvOK(sv) ? SvPV_const(sv,len) : "";
const char * const ptr = MgPV_const(mg,klen);
my_setenv(ptr, s);
SV** svp = NULL;
if (strEQ(s,"__DIE__"))
svp = &PL_diehook;
- else if (strEQ(s,"__WARN__"))
+ else if (strEQ(s,"__WARN__") && PL_warnhook != PERL_WARNHOOK_FATAL)
svp = &PL_warnhook;
- else
- Perl_croak(aTHX_ "No such hook: %s", s);
if (svp && *svp) {
- SV * const to_dec = *svp;
+ SV *const to_dec = *svp;
*svp = NULL;
- SvREFCNT_dec(to_dec);
+ SvREFCNT_dec(to_dec);
}
}
else {
exit(1);
#endif
#endif
- if (PL_signals & PERL_SIGNALS_UNSAFE_FLAG)
+ if (
+#ifdef SIGILL
+ sig == SIGILL ||
+#endif
+#ifdef SIGBUS
+ sig == SIGBUS ||
+#endif
+#ifdef SIGSEGV
+ sig == SIGSEGV ||
+#endif
+ (PL_signals & PERL_SIGNALS_UNSAFE_FLAG))
/* Call the perl level handler now--
* with risk we may be in malloc() etc. */
(*PL_sighandlerp)(sig);
Perl_croak(aTHX_ "No such hook: %s", s);
i = 0;
if (*svp) {
- to_dec = *svp;
+ if (*svp != PERL_WARNHOOK_FATAL)
+ to_dec = *svp;
*svp = NULL;
}
}
Perl_magic_nextpack(pTHX_ SV *sv, MAGIC *mg, SV *key)
{
dVAR; dSP;
- const char * const meth = (const char *)(SvOK(key) ? "NEXTKEY" : "FIRSTKEY");
+ const char * const meth = SvOK(key) ? "NEXTKEY" : "FIRSTKEY";
ENTER;
SAVETMPS;
accumulate |= ptr[i] ;
any_fatals |= (ptr[i] & 0xAA) ;
}
- if (!accumulate)
- PL_compiling.cop_warnings = pWARN_NONE;
+ if (!accumulate) {
+ if (!specialWARN(PL_compiling.cop_warnings))
+ PerlMemShared_free(PL_compiling.cop_warnings);
+ PL_compiling.cop_warnings = pWARN_NONE;
+ }
/* Yuck. I can't see how to abstract this: */
else if (isWARN_on(((STRLEN *)SvPV_nolen_const(sv)) - 1,
WARN_ALL) && !any_fatals) {
+ if (!specialWARN(PL_compiling.cop_warnings))
+ PerlMemShared_free(PL_compiling.cop_warnings);
PL_compiling.cop_warnings = pWARN_ALL;
PL_dowarn |= G_WARN_ONCE ;
}