summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2006-05-20 17:29:52 +0000
committerNicholas Clark <nick@ccl4.org>2006-05-20 17:29:52 +0000
commit11bcd5dad4f9d911a9454f9d858c2dd0d14ddf2a (patch)
tree24e3ac38c69f46172a4cf4ac1aeabe4488829631 /perlio.c
parentd5ec2987912a76b3059b7bd1d06cf02b4d0dae0c (diff)
downloadperl-11bcd5dad4f9d911a9454f9d858c2dd0d14ddf2a.tar.gz
Abolish cop_io (the simple way) by storing the value in cop_hints_hash.
Todo - store the in and out values under 2 keys, and avoid the need to create a temporary mortal SV while checking it. p4raw-id: //depot/perl@28258
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/perlio.c b/perlio.c
index f883fe908c..d76a96f708 100644
--- a/perlio.c
+++ b/perlio.c
@@ -1408,20 +1408,23 @@ Perl_PerlIO_fileno(pTHX_ PerlIO *f)
Perl_PerlIO_or_Base(f, Fileno, fileno, -1, (aTHX_ f));
}
-static const char *
-PerlIO_context_layers(pTHX_ const char *mode)
+const char *
+Perl_PerlIO_context_layers(pTHX_ const char *mode)
{
dVAR;
const char *type = NULL;
/*
* Need to supply default layer info from open.pm
*/
- if (PL_curcop) {
- SV * const layers = PL_curcop->cop_io;
- if (layers) {
+ if (PL_curcop && PL_curcop->cop_hints & HINT_LEXICAL_IO) {
+ SV * const layers
+ = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash, 0,
+ "open", 4, 0, 0);
+ assert(layers);
+ if (SvOK(layers)) {
STRLEN len;
type = SvPV_const(layers, len);
- if (type && mode[0] != 'r') {
+ if (type && mode && mode[0] != 'r') {
/*
* Skip to write part, which is separated by a '\0'
*/
@@ -1491,7 +1494,7 @@ PerlIO_resolve_layers(pTHX_ const char *layers,
}
}
if (!layers || !*layers)
- layers = PerlIO_context_layers(aTHX_ mode);
+ layers = Perl_PerlIO_context_layers(aTHX_ mode);
if (layers && *layers) {
PerlIO_list_t *av;
if (incdef) {
@@ -1528,7 +1531,7 @@ PerlIO_openn(pTHX_ const char *layers, const char *mode, int fd,
if (!f && narg == 1 && *args == &PL_sv_undef) {
if ((f = PerlIO_tmpfile())) {
if (!layers || !*layers)
- layers = PerlIO_context_layers(aTHX_ mode);
+ layers = Perl_PerlIO_context_layers(aTHX_ mode);
if (layers && *layers)
PerlIO_apply_layers(aTHX_ f, mode, layers);
}