summaryrefslogtreecommitdiff
path: root/gv.c
diff options
context:
space:
mode:
authorSteve Peters <steve@fisharerojo.org>2006-01-03 14:58:21 +0000
committerSteve Peters <steve@fisharerojo.org>2006-01-03 14:58:21 +0000
commit8b5be85c6c6a87e2cf6fc80a9ccc8056a4d1bbf9 (patch)
tree6777f1c5f04dd177de845dfe15845afca8dacb98 /gv.c
parent58103a2e295c15d87c7ce0bd8dd83d7e110adac4 (diff)
downloadperl-8b5be85c6c6a87e2cf6fc80a9ccc8056a4d1bbf9.tar.gz
Bad symbols that are pretending to be dirhandles, should say they
are dirhandles in their error messages. p4raw-id: //depot/perl@26602
Diffstat (limited to 'gv.c')
-rw-r--r--gv.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/gv.c b/gv.c
index d960c660d4..06982bdd9d 100644
--- a/gv.c
+++ b/gv.c
@@ -73,8 +73,21 @@ Perl_gv_HVadd(pTHX_ register GV *gv)
GV *
Perl_gv_IOadd(pTHX_ register GV *gv)
{
- if (!gv || SvTYPE((SV*)gv) != SVt_PVGV)
- Perl_croak(aTHX_ "Bad symbol for filehandle");
+ if (!gv || SvTYPE((SV*)gv) != SVt_PVGV) {
+
+ /*
+ * if it walks like a dirhandle, then let's assume that
+ * this is a dirhandle.
+ */
+ const char *fh = PL_op->op_type == OP_READDIR ||
+ PL_op->op_type == OP_TELLDIR ||
+ PL_op->op_type == OP_SEEKDIR ||
+ PL_op->op_type == OP_REWINDDIR ||
+ PL_op->op_type == OP_CLOSEDIR ?
+ "dirhandle" : "filehandle";
+ Perl_croak(aTHX_ "Bad symbol for %s", fh);
+ }
+
if (!GvIOp(gv)) {
#ifdef GV_UNIQUE_CHECK
if (GvUNIQUE(gv)) {