diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 25 |
1 files changed, 16 insertions, 9 deletions
@@ -3890,34 +3890,41 @@ Perl_my_atof(pTHX_ const char* s) void Perl_report_evil_fh(pTHX_ GV *gv, IO *io, I32 op) { - bool closed = io && IoTYPE(io) == ' '; - char *vile = closed ? "closed" : "unopened"; - I32 warn = closed ? WARN_CLOSED : WARN_UNOPENED; + char *vile; + I32 warn; char *func = op == OP_READLINE ? "readline" : op == OP_LEAVEWRITE ? "write" : PL_op_desc[op]; char *pars = OP_IS_FILETEST(op) ? "" : "()"; char *type = OP_IS_SOCKET(op) ? "socket" : "filehandle"; + char *name = NULL; if (isGV(gv)) { SV *sv = sv_newmortal(); - char *name; gv_efullname4(sv, gv, Nullch, FALSE); name = SvPVX(sv); + } - Perl_warner(aTHX_ warn, "%s%s on %s %s %s", - func, pars, vile, type, name); + if (io && IoTYPE(io) == ' ') { + vile = "closed"; + warn = WARN_CLOSED; + } else { + vile = "unopened"; + warn = WARN_UNOPENED; + } + if (name) { + Perl_warner(aTHX_ warn, + "%s%s on %s %s %s", func, pars, vile, type, name); if (io && IoDIRP(io)) Perl_warner(aTHX_ warn, "\t(Are you trying to call %s%s on dirhandle %s?)\n", func, pars, name); } else { - Perl_warner(aTHX_ warn, "%s%s on %s %s", - func, pars, vile, type); - + Perl_warner(aTHX_ warn, + "%s%s on %s %s", func, pars, vile, type); if (io && IoDIRP(io)) Perl_warner(aTHX_ warn, "\t(Are you trying to call %s%s on dirhandle?)\n", |