From: Ilya Zakharevich Date: Mon, 2 Mar 1998 21:36:02 +0000 (-0500) Subject: Make autouse -w-safe X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2f34f9d4825ac9262ece854fc4c50479f4838ff8;p=p5sagit%2Fp5-mst-13.2.git Make autouse -w-safe p4raw-id: //depot/perl@781 --- diff --git a/lib/autouse.pm b/lib/autouse.pm index ab95a19..4445c6c 100644 --- a/lib/autouse.pm +++ b/lib/autouse.pm @@ -146,15 +146,6 @@ The first line ensures that the errors in your argument specification are found early. When you ship your application you should comment out the first line, since it makes the second one useless. -=head1 BUGS - -If Module::func3() is autoused, and the module is loaded between the -C directive and a call to Module::func3(), warnings about -redefinition would appear if warnings are enabled. - -If Module::func3() is autoused, warnings are disabled when loading the -module via autoused functions. - =head1 AUTHOR Ilya Zakharevich (ilya@math.ohio-state.edu) diff --git a/op.c b/op.c index e30e874..28e05f1 100644 --- a/op.c +++ b/op.c @@ -3332,7 +3332,10 @@ newSUB(I32 floor, OP *o, OP *proto, OP *block) if (curstack == sortstack && sortcop == CvSTART(cv)) croak("Can't redefine active sort subroutine %s", name); const_sv = cv_const_sv(cv); - if (const_sv || dowarn) { + if (const_sv || dowarn && !(CvGV(cv) && GvSTASH(CvGV(cv)) + && HvNAME(GvSTASH(CvGV(cv))) + && strEQ(HvNAME(GvSTASH(CvGV(cv))), + "autouse"))) { line_t oldline = curcop->cop_line; curcop->cop_line = copline; warn(const_sv ? "Constant subroutine %s redefined" @@ -3527,7 +3530,9 @@ newXS(char *name, void (*subaddr) (CV *), char *filename) } else if (CvROOT(cv) || CvXSUB(cv) || GvASSUMECV(gv)) { /* already defined (or promised) */ - if (dowarn) { + if (dowarn && !(CvGV(cv) && GvSTASH(CvGV(cv)) + && HvNAME(GvSTASH(CvGV(cv))) + && strEQ(HvNAME(GvSTASH(CvGV(cv))), "autouse"))) { line_t oldline = curcop->cop_line; curcop->cop_line = copline; warn("Subroutine %s redefined",name); diff --git a/sv.c b/sv.c index d4edad4..b5bec9d 100644 --- a/sv.c +++ b/sv.c @@ -2063,9 +2063,14 @@ sv_setsv(SV *dstr, register SV *sstr) if (cv_const_sv(cv)) warn("Constant subroutine %s redefined", GvENAME((GV*)dstr)); - else if (dowarn) - warn("Subroutine %s redefined", - GvENAME((GV*)dstr)); + else if (dowarn) { + if (!(CvGV(cv) && GvSTASH(CvGV(cv)) + && HvNAME(GvSTASH(CvGV(cv))) + && strEQ(HvNAME(GvSTASH(CvGV(cv))), + "autouse"))) + warn("Subroutine %s redefined", + GvENAME((GV*)dstr)); + } } cv_ckproto(cv, (GV*)dstr, SvPOK(sref) ? SvPVX(sref) : Nullch);