Make autouse -w-safe
authorIlya Zakharevich <ilya@math.berkeley.edu>
Mon, 2 Mar 1998 21:36:02 +0000 (16:36 -0500)
committerMalcolm Beattie <mbeattie@sable.ox.ac.uk>
Thu, 5 Mar 1998 19:04:34 +0000 (19:04 +0000)
p4raw-id: //depot/perl@781

lib/autouse.pm
op.c
sv.c

index ab95a19..4445c6c 100644 (file)
@@ -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<autouse> 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 (file)
--- 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 (file)
--- 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);