diff options
author | Nicholas Clark <nick@ccl4.org> | 2007-02-17 12:39:17 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2007-02-17 12:39:17 +0000 |
commit | 8b850bd54aa90bd3cc2546352bef5140216ffbb6 (patch) | |
tree | 8870859d8b4d7eec735d443179da6fa32571ded9 /perlio.c | |
parent | 3feb66e7ea0f57a1105b8fea88e024b00c92a8a0 (diff) | |
download | perl-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.c | 40 |
1 files changed, 20 insertions, 20 deletions
@@ -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; } |