From 0039161fd1eda8af79f30af33ee5b36bababf4ac Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Mon, 9 Jul 2012 13:00:28 -0700 Subject: [PATCH] Remove & from redef warnings for lex subs This is just for consistency with package subs. --- op.c | 16 ++++++++++++---- t/cmd/lexsub.t | 1 - 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/op.c b/op.c index 705374b..da93b14 100644 --- a/op.c +++ b/op.c @@ -6976,11 +6976,19 @@ Perl_newMYSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) goto done; } else { - const line_t oldline = CopLINE(PL_curcop); - if (PL_parser && PL_parser->copline != NOLINE) + /* redundant check that avoids creating the extra SV + most of the time: */ + if (const_sv || ckWARN(WARN_REDEFINE)) { + const line_t oldline = CopLINE(PL_curcop); + SV *noamp = sv_2mortal(newSVpvn_utf8( + PadnamePV(name)+1,PadnameLEN(name)-1, + PadnameUTF8(name) + )); + if (PL_parser && PL_parser->copline != NOLINE) CopLINE_set(PL_curcop, PL_parser->copline); - report_redefined_cv(name, cv, &const_sv); - CopLINE_set(PL_curcop, oldline); + report_redefined_cv(noamp, cv, &const_sv); + CopLINE_set(PL_curcop, oldline); + } #ifdef PERL_MAD if (!PL_minus_c) /* keep old one around for madskills */ #endif diff --git a/t/cmd/lexsub.t b/t/cmd/lexsub.t index ffabbd1..84abff0 100644 --- a/t/cmd/lexsub.t +++ b/t/cmd/lexsub.t @@ -269,7 +269,6 @@ sub make_anon_with_state_sub{ state $w; local $SIG{__WARN__} = sub { $w .= shift }; eval "#line 56 pygpyf\nsub redef {}"; -on; is $w, "Subroutine redef redefined at pygpyf line 56.\n", "sub redefinition warnings from state subs"; } -- 2.7.4