From ec889f3a4d67ceb8b9b54693ed4a5449d224fe29 Mon Sep 17 00:00:00 2001 From: Gurusamy Sarathy Date: Tue, 25 May 1999 03:00:00 +0000 Subject: [PATCH] avoid enumerating @INC contents in diagnostic if @INC was never searched p4raw-id: //depot/perl@3466 --- pod/perldiag.pod | 16 +++++++++------- pp_ctl.c | 37 +++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 23 deletions(-) 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; -- 2.7.4