From: Gurusamy Sarathy Date: Tue, 25 May 1999 03:00:00 +0000 (+0000) Subject: avoid enumerating @INC contents in diagnostic if @INC was never X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ec889f3a4d67ceb8b9b54693ed4a5449d224fe29;p=p5sagit%2Fp5-mst-13.2.git avoid enumerating @INC contents in diagnostic if @INC was never searched p4raw-id: //depot/perl@3466 --- diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 72b4192..688e847 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -756,13 +756,15 @@ but there is no function to autoload. Most probable causes are a misprint in a function/method name or a failure to C the file, say, by doing C. -=item Can't locate %s in @INC - -(F) You said to do (or require, or use) a file that couldn't be found -in any of the libraries mentioned in @INC. Perhaps you need to set the -PERL5LIB or PERL5OPT environment variable to say where the extra library -is, or maybe the script needs to add the library name to @INC. Or maybe -you just misspelled the name of the file. See L. +=item Can't locate %s + +(F) You said to C (or C, or C) a file that couldn't be +found. Perl looks for the file in all the locations mentioned in @INC, +unless the file name included the full path to the file. Perhaps you need +to set the PERL5LIB or PERL5OPT environment variable to say where the extra +library is, or maybe the script needs to add the library name to @INC. Or +maybe you just misspelled the name of the file. See L +and L. =item Can't locate object method "%s" via package "%s" diff --git a/pp_ctl.c b/pp_ctl.c index 0b524e2..3e4db3b 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2899,23 +2899,28 @@ PP(pp_require) SvREFCNT_dec(namesv); if (!tryrsfp) { if (PL_op->op_type == OP_REQUIRE) { - SV *msg = sv_2mortal(newSVpvf("Can't locate %s in @INC", name)); - SV *dirmsgsv = NEWSV(0, 0); - AV *ar = GvAVn(PL_incgv); - I32 i; - if (instr(SvPVX(msg), ".h ")) - sv_catpv(msg, " (change .h to .ph maybe?)"); - if (instr(SvPVX(msg), ".ph ")) - sv_catpv(msg, " (did you run h2ph?)"); - sv_catpv(msg, " (@INC contains:"); - for (i = 0; i <= AvFILL(ar); i++) { - char *dir = SvPVx(*av_fetch(ar, i, TRUE), n_a); - sv_setpvf(dirmsgsv, " %s", dir); - sv_catsv(msg, dirmsgsv); + char *msgstr = name; + if (namesv) { /* did we lookup @INC? */ + SV *msg = sv_2mortal(newSVpv(msgstr,0)); + SV *dirmsgsv = NEWSV(0, 0); + AV *ar = GvAVn(PL_incgv); + I32 i; + sv_catpvn(msg, " in @INC", 8); + if (instr(SvPVX(msg), ".h ")) + sv_catpv(msg, " (change .h to .ph maybe?)"); + if (instr(SvPVX(msg), ".ph ")) + sv_catpv(msg, " (did you run h2ph?)"); + sv_catpv(msg, " (@INC contains:"); + for (i = 0; i <= AvFILL(ar); i++) { + char *dir = SvPVx(*av_fetch(ar, i, TRUE), n_a); + sv_setpvf(dirmsgsv, " %s", dir); + sv_catsv(msg, dirmsgsv); + } + sv_catpvn(msg, ")", 1); + SvREFCNT_dec(dirmsgsv); + msgstr = SvPV_nolen(msg); } - sv_catpvn(msg, ")", 1); - SvREFCNT_dec(dirmsgsv); - DIE("%_", msg); + DIE("Can't locate %s", msgstr); } RETPUSHUNDEF;