diff options
author | Nicholas Clark <nick@ccl4.org> | 2005-12-27 12:02:57 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2005-12-27 12:02:57 +0000 |
commit | b8f04b1b779ce1dfdaee8f5444dc413afe3e9866 (patch) | |
tree | 6228bf3ab19282736d1fcd9fd6d61873ed041354 /pp_ctl.c | |
parent | e16fcd08233370584746d45f250e423bd2f11ec2 (diff) | |
download | perl-b8f04b1b779ce1dfdaee8f5444dc413afe3e9866.tar.gz |
Refactor the require failure message generation to use 1 less temporary
SV, and to build as much text as possible with newSVpvf
p4raw-id: //depot/perl@26500
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 23 |
1 files changed, 11 insertions, 12 deletions
@@ -3340,23 +3340,22 @@ PP(pp_require) msgstr = SvPV_nolen_const(msg); } else { if (namesv) { /* did we lookup @INC? */ - SV * const msg = sv_2mortal(newSVpv(msgstr,0)); - SV * const dirmsgsv = NEWSV(0, 0); AV * const ar = GvAVn(PL_incgv); I32 i; - sv_catpvn(msg, " in @INC", 8); - if (instr(SvPVX_const(msg), ".h ")) - sv_catpv(msg, " (change .h to .ph maybe?)"); - if (instr(SvPVX_const(msg), ".ph ")) - sv_catpv(msg, " (did you run h2ph?)"); - sv_catpv(msg, " (@INC contains:"); + SV * const msg = sv_2mortal(Perl_newSVpvf(aTHX_ + "%s in @INC%s%s (@INC contains:", + msgstr, + (instr(msgstr, ".h ") + ? " (change .h to .ph maybe?)" : ""), + (instr(msgstr, ".ph ") + ? " (did you run h2ph?)" : "") + )); + for (i = 0; i <= AvFILL(ar); i++) { - const char *dir = SvPVx_nolen_const(*av_fetch(ar, i, TRUE)); - Perl_sv_setpvf(aTHX_ dirmsgsv, " %s", dir); - sv_catsv(msg, dirmsgsv); + sv_catpvn(msg, " ", 1); + sv_catsv(msg, *av_fetch(ar, i, TRUE)); } sv_catpvn(msg, ")", 1); - SvREFCNT_dec(dirmsgsv); msgstr = SvPV_nolen_const(msg); } } |