summaryrefslogtreecommitdiff
path: root/perlio.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2007-02-17 12:39:17 +0000
committerNicholas Clark <nick@ccl4.org>2007-02-17 12:39:17 +0000
commit8b850bd54aa90bd3cc2546352bef5140216ffbb6 (patch)
tree8870859d8b4d7eec735d443179da6fa32571ded9 /perlio.c
parent3feb66e7ea0f57a1105b8fea88e024b00c92a8a0 (diff)
downloadperl-8b850bd54aa90bd3cc2546352bef5140216ffbb6.tar.gz
Split the storage of the layers specificied by open.pm into one hint
for input, and one for output, as this better reflects how they are used. The original "concatenate with \0" plan was really only a compramise to avoid needing to increase every COP by 2 pointers. p4raw-id: //depot/perl@30334
Diffstat (limited to 'perlio.c')
-rw-r--r--perlio.c40
1 files changed, 20 insertions, 20 deletions
diff --git a/perlio.c b/perlio.c
index 95867507a9..30f54ec1c6 100644
--- a/perlio.c
+++ b/perlio.c
@@ -5114,30 +5114,30 @@ const char *
Perl_PerlIO_context_layers(pTHX_ const char *mode)
{
dVAR;
- const char *type = NULL;
+ const char *direction = NULL;
+ SV *layers;
/*
* Need to supply default layer info from open.pm
*/
- 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 && mode[0] != 'r') {
- /*
- * Skip to write part, which is separated by a '\0'
- */
- STRLEN read_len = strlen(type);
- if (read_len < len) {
- type += read_len + 1;
- }
- }
- }
+
+ if (!PL_curcop)
+ return NULL;
+
+ if (mode && mode[0] != 'r') {
+ if (PL_curcop->cop_hints & HINT_LEXICAL_IO_OUT)
+ direction = "open>";
+ } else {
+ if (PL_curcop->cop_hints & HINT_LEXICAL_IO_IN)
+ direction = "open<";
}
- return type;
+ if (!direction)
+ return NULL;
+
+ layers = Perl_refcounted_he_fetch(aTHX_ PL_curcop->cop_hints_hash,
+ 0, direction, 5, 0, 0);
+
+ assert(layers);
+ return SvOK(layers) ? SvPV_nolen_const(layers) : NULL;
}