diff options
author | Nicholas Clark <nick@ccl4.org> | 2009-08-08 15:28:31 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2009-08-08 17:56:51 +0100 |
commit | bb85b28a6da36a76a3909c40a8a5f0a80a04163c (patch) | |
tree | 6d1aeb91b84e1110681721f34f35b409694f2cc2 /gv.c | |
parent | 85dca89a8f321bc581a3d365d95ab0c56368ed78 (diff) | |
download | perl-bb85b28a6da36a76a3909c40a8a5f0a80a04163c.tar.gz |
Merge gv_IOadd() into gv_add_by_type().
Diffstat (limited to 'gv.c')
-rw-r--r-- | gv.c | 55 |
1 files changed, 23 insertions, 32 deletions
@@ -45,15 +45,34 @@ Perl_gv_add_by_type(pTHX_ GV *gv, svtype type) { SV **where; - PERL_ARGS_ASSERT_GV_ADD_BY_TYPE; - - if (!gv || SvTYPE((const SV *)gv) != SVt_PVGV) - Perl_croak(aTHX_ "Bad symbol for %s", type == SVt_PVAV ? "array" : type == SVt_PVHV ? "hash" : "scalar"); + if (!gv || SvTYPE((const SV *)gv) != SVt_PVGV) { + const char *what; + if (type == SVt_PVIO) { + /* + * if it walks like a dirhandle, then let's assume that + * this is a dirhandle. + */ + what = 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"; + /* diag_listed_as: Bad symbol for filehandle */ + } else if (type == SVt_PVHV) { + what = "hash"; + } else { + what = type == SVt_PVAV ? "array" : "scalar"; + } + Perl_croak(aTHX_ "Bad symbol for %s", what); + } if (type == SVt_PVHV) { where = (SV **)&GvHV(gv); } else if (type == SVt_PVAV) { where = (SV **)&GvAV(gv); + } else if (type == SVt_PVIO) { + where = (SV **)&GvIOp(gv); } else { where = &GvSV(gv); } @@ -64,34 +83,6 @@ Perl_gv_add_by_type(pTHX_ GV *gv, svtype type) } GV * -Perl_gv_IOadd(pTHX_ register GV *gv) -{ - dVAR; - - if (!gv || SvTYPE((const SV *)gv) != SVt_PVGV) { - - /* - * if it walks like a dirhandle, then let's assume that - * this is a dirhandle. - */ - const char * const 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"; - /* diag_listed_as: Bad symbol for filehandle */ - Perl_croak(aTHX_ "Bad symbol for %s", fh); - } - - if (!GvIOp(gv)) { - GvIOp(gv) = newIO(); - } - return gv; -} - -GV * Perl_gv_fetchfile(pTHX_ const char *name) { PERL_ARGS_ASSERT_GV_FETCHFILE; |