summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorFather Chrysostomos <sprout@cpan.org>2012-01-12 16:41:59 -0800
committerFather Chrysostomos <sprout@cpan.org>2012-01-13 21:24:53 -0800
commit65d99836546f370bdc29ff2d99a22de1f5fc3bbf (patch)
tree271dd0e60f0042b8740d372a19c7e8f6bbe583b4 /util.c
parent8c85651df5beaed71753a27d7c04151c9a751875 (diff)
downloadperl-65d99836546f370bdc29ff2d99a22de1f5fc3bbf.tar.gz
Squash repetititive code in util.c:report_evil_fh
Diffstat (limited to 'util.c')
-rw-r--r--util.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/util.c b/util.c
index a6c0590514..bdfdfdc30b 100644
--- a/util.c
+++ b/util.c
@@ -3908,26 +3908,18 @@ Perl_report_evil_fh(pTHX_ const GV *gv)
(const char *)
(OP_IS_SOCKET(op) || (io && IoTYPE(io) == IoTYPE_SOCKET)
? "socket" : "filehandle");
- if (name && SvPOK(name) && *SvPV_nolen(name)) {
- Perl_warner(aTHX_ packWARN(warn_type),
- "%s%s on %s %s %"SVf, func, pars, vile, type, SVfARG(name));
- if (io && IoDIRP(io) && !(IoFLAGS(io) & IOf_FAKE_DIRP))
+ const bool have_name = name && SvPOK(name) && *SvPV_nolen(name);
+ Perl_warner(aTHX_ packWARN(warn_type),
+ "%s%s on %s %s%s%"SVf, func, pars, vile, type,
+ have_name ? " " : "",
+ SVfARG(have_name ? name : &PL_sv_no));
+ if (io && IoDIRP(io) && !(IoFLAGS(io) & IOf_FAKE_DIRP))
Perl_warner(
aTHX_ packWARN(warn_type),
- "\t(Are you trying to call %s%s on dirhandle %"SVf"?)\n",
- func, pars, SVfARG(name)
+ "\t(Are you trying to call %s%s on dirhandle%s%"SVf"?)\n",
+ func, pars, have_name ? " " : "",
+ SVfARG(have_name ? name : &PL_sv_no)
);
- }
- else {
- Perl_warner(aTHX_ packWARN(warn_type),
- "%s%s on %s %s", func, pars, vile, type);
- if (io && IoDIRP(io) && !(IoFLAGS(io) & IOf_FAKE_DIRP))
- Perl_warner(
- aTHX_ packWARN(warn_type),
- "\t(Are you trying to call %s%s on dirhandle?)\n",
- func, pars
- );
- }
}
}