From: Jarkko Hietaniemi Date: Sat, 5 Aug 2000 18:40:44 +0000 (+0000) Subject: Essential prototype changes were missing from #6527. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9c0fcd4fd41b57e0b52865323ecb096f33afcdaf;p=p5sagit%2Fp5-mst-13.2.git Essential prototype changes were missing from #6527. Also make report_evil_fh() more bomb-proof. p4raw-id: //depot/perl@6528 --- diff --git a/embed.h b/embed.h index f0bae6f..d40e270 100644 --- a/embed.h +++ b/embed.h @@ -732,7 +732,7 @@ #define vivify_defelem Perl_vivify_defelem #define vivify_ref Perl_vivify_ref #define wait4pid Perl_wait4pid -#define report_closed_fh Perl_report_closed_fh +#define report_evil_fh Perl_report_evil_fh #define report_uninit Perl_report_uninit #define warn Perl_warn #define vwarn Perl_vwarn @@ -2187,7 +2187,7 @@ #define vivify_defelem(a) Perl_vivify_defelem(aTHX_ a) #define vivify_ref(a,b) Perl_vivify_ref(aTHX_ a,b) #define wait4pid(a,b,c) Perl_wait4pid(aTHX_ a,b,c) -#define report_closed_fh(a,b,c,d) Perl_report_closed_fh(aTHX_ a,b,c,d) +#define report_evil_fh(a,b,c) Perl_report_evil_fh(aTHX_ a,b,c) #define report_uninit() Perl_report_uninit(aTHX) #define vwarn(a,b) Perl_vwarn(aTHX_ a,b) #define vwarner(a,b,c) Perl_vwarner(aTHX_ a,b,c) @@ -4286,8 +4286,8 @@ #define vivify_ref Perl_vivify_ref #define Perl_wait4pid CPerlObj::Perl_wait4pid #define wait4pid Perl_wait4pid -#define Perl_report_closed_fh CPerlObj::Perl_report_closed_fh -#define report_closed_fh Perl_report_closed_fh +#define Perl_report_evil_fh CPerlObj::Perl_report_evil_fh +#define report_evil_fh Perl_report_evil_fh #define Perl_report_uninit CPerlObj::Perl_report_uninit #define report_uninit Perl_report_uninit #define Perl_warn CPerlObj::Perl_warn diff --git a/util.c b/util.c index 69dea5c..6eda3fe 100644 --- a/util.c +++ b/util.c @@ -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",