summaryrefslogtreecommitdiff
path: root/pp_ctl.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2010-06-29 19:57:51 +0100
committerNicholas Clark <nick@ccl4.org>2010-06-29 20:00:11 +0100
commitc9d5e35e7efda8acf195b970afb943d0d7481bb4 (patch)
tree549734fd44bd7f79ce07866350f231e157606089 /pp_ctl.c
parentc4ea5f2e1a5dbe46fdaf471d38ffdacf3ce1508e (diff)
downloadperl-c9d5e35e7efda8acf195b970afb943d0d7481bb4.tar.gz
In pp_require, improve the code generating the exception when no file is found.
Make more use of DIE()'s ability to take a *printf formatter and argument list, hence avoiding most use of SVs as temporary buffers, and building up SVs section by section.
Diffstat (limited to 'pp_ctl.c')
-rw-r--r--pp_ctl.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/pp_ctl.c b/pp_ctl.c
index 8134187dd1..7d041bdfe9 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3634,34 +3634,32 @@ PP(pp_require)
SvREFCNT_dec(namesv);
if (!tryrsfp) {
if (PL_op->op_type == OP_REQUIRE) {
- const char *msgstr = name;
if(errno == EMFILE) {
- SV * const msg
- = sv_2mortal(Perl_newSVpvf(aTHX_ "%s: %s", msgstr,
- Strerror(errno)));
- msgstr = SvPV_nolen_const(msg);
+ /* diag_listed_as: Can't locate %s */
+ DIE(aTHX_ "Can't locate %s: %s", name, Strerror(errno));
} else {
if (namesv) { /* did we lookup @INC? */
AV * const ar = GvAVn(PL_incgv);
I32 i;
- SV * const msg = sv_2mortal(Perl_newSVpvf(aTHX_
- "%s in @INC%s%s (@INC contains:",
- msgstr,
+ SV *const inc = newSVpvs_flags("", SVs_TEMP);
+ for (i = 0; i <= AvFILL(ar); i++) {
+ sv_catpvs(inc, " ");
+ sv_catsv(inc, *av_fetch(ar, i, TRUE));
+ }
+
+ /* diag_listed_as: Can't locate %s */
+ DIE(aTHX_
+ "Can't locate %s in @INC%s%s (@INC contains:%" SVf ")",
+ name,
(memEQ(name + len - 2, ".h", 3)
? " (change .h to .ph maybe?) (did you run h2ph?)" : ""),
(memEQ(name + len - 3, ".ph", 4)
- ? " (did you run h2ph?)" : "")
- ));
-
- for (i = 0; i <= AvFILL(ar); i++) {
- sv_catpvs(msg, " ");
- sv_catsv(msg, *av_fetch(ar, i, TRUE));
- }
- sv_catpvs(msg, ")");
- msgstr = SvPV_nolen_const(msg);
- }
+ ? " (did you run h2ph?)" : ""),
+ inc
+ );
+ }
}
- DIE(aTHX_ "Can't locate %s", msgstr);
+ DIE(aTHX_ "Can't locate %s", name);
}
RETPUSHUNDEF;