From: Doug MacEachern Date: Mon, 30 Jul 2001 17:38:50 +0000 (-0700) Subject: Re: [PATCH pp_ctl.c] proposed Windows safe-guard X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=18fc948826e2e527e52b790d8ec042fac21d6b8a;p=p5sagit%2Fp5-mst-13.2.git Re: [PATCH pp_ctl.c] proposed Windows safe-guard Message-ID: p4raw-id: //depot/perl@11537 --- diff --git a/op.c b/op.c index 62309a1..3d5d92b 100644 --- a/op.c +++ b/op.c @@ -3217,6 +3217,9 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *id, OP *arg) OP *pack; OP *imop; OP *veop; + char *packname = Nullch; + STRLEN packlen; + SV *packsv; if (id->op_type != OP_CONST) Perl_croak(aTHX_ "Module name must be constant"); @@ -3274,6 +3277,12 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *id, OP *arg) newSVOP(OP_METHOD_NAMED, 0, meth))); } + if (ckWARN(WARN_MISC) && imop && SvPOK(packsv = ((SVOP*)id)->op_sv)) { + /* BEGIN will free the ops, so we need to make a copy */ + packlen = SvCUR(packsv); + packname = savepvn(SvPVX(packsv), packlen); + } + /* Fake up the BEGIN {}, which does its thing immediately. */ newATTRSUB(floor, newSVOP(OP_CONST, 0, newSVpvn("BEGIN", 5)), @@ -3285,6 +3294,15 @@ Perl_utilize(pTHX_ int aver, I32 floor, OP *version, OP *id, OP *arg) newSTATEOP(0, Nullch, veop)), newSTATEOP(0, Nullch, imop) )); + if (packname) { + if (ckWARN(WARN_MISC) && !gv_stashpvn(packname, packlen, FALSE)) { + Perl_warner(aTHX_ WARN_MISC, + "Package `%s' not found " + "(did you use the incorrect case?)", packname); + } + safefree(packname); + } + PL_hints |= HINT_BLOCK_SCOPE; PL_copline = NOLINE; PL_expect = XSTATE; diff --git a/t/TestInit.pm b/t/TestInit.pm index be69c24..a2a074e 100644 --- a/t/TestInit.pm +++ b/t/TestInit.pm @@ -13,6 +13,8 @@ # PS this is not POD because this should be a very minimalist module in # case of funaemental perl breakage. +package TestInit; + chdir 't' if -d 't'; @INC = '../lib'; $0 =~ s/\.dp$//; # for the test.deparse make target