summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-10-31 14:27:32 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-10-31 14:27:32 +0000
commit9fe371da3bdc2d1a5eae907101756f87eb5d2168 (patch)
tree9d2373bc198f117ba47d3d19d2f10a22256a6075
parent59ebecca9217f071f332a0b40ebe7b6f0eb82571 (diff)
downloadperl-9fe371da3bdc2d1a5eae907101756f87eb5d2168.tar.gz
Fix [perl #37533] open pragma ignored for all 3-arg opens
Also, correct the documentation in open.pm that stated that open() did not override open.pm-given default encodings. p4raw-id: //depot/perl@25925
-rw-r--r--lib/open.pm8
-rw-r--r--perlio.c4
2 files changed, 6 insertions, 6 deletions
diff --git a/lib/open.pm b/lib/open.pm
index 35657623fa..24488e6716 100644
--- a/lib/open.pm
+++ b/lib/open.pm
@@ -2,7 +2,7 @@ package open;
use warnings;
$open::hint_bits = 0x20000; # HINT_LOCALIZE_HH
-our $VERSION = '1.04_01';
+our $VERSION = '1.05';
require 5.008001; # for PerlIO::get_layers()
@@ -216,8 +216,8 @@ details and the list of supported locales.
Note that C<:utf8> PerlIO layer must always be specified exactly like
that, it is not subject to the loose matching of encoding names.
-When open() is given an explicit list of layers they are appended to
-the list declared using this pragma.
+When open() is given an explicit list of layers (with the three-arg
+syntax), they override the list declared using this pragma.
The C<:std> subpragma on its own has no effect, but if combined with
the C<:utf8> or C<:encoding> subpragmas, it converts the standard
@@ -229,7 +229,7 @@ chosen to be in C<< :encoding(koi8r) >>, a C<:std> will cause only the
STDOUT and STDERR to be in C<koi8r>. The C<:locale> subpragma
implicitly turns on C<:std>.
-The logic of C<:locale> is described in full in L</encoding>,
+The logic of C<:locale> is described in full in L<encoding>,
but in short it is first trying nl_langinfo(CODESET) and then
guessing from the LC_ALL and LANG locale environment variables.
diff --git a/perlio.c b/perlio.c
index e9ea0c3a19..23df5e8374 100644
--- a/perlio.c
+++ b/perlio.c
@@ -1461,7 +1461,7 @@ PerlIO_resolve_layers(pTHX_ const char *layers,
*/
}
}
- if (!layers)
+ if (!layers || !*layers)
layers = PerlIO_context_layers(aTHX_ mode);
if (layers && *layers) {
PerlIO_list_t *av;
@@ -1497,7 +1497,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)
+ if (!layers || !*layers)
layers = PerlIO_context_layers(aTHX_ mode);
if (layers && *layers)
PerlIO_apply_layers(aTHX_ f, mode, layers);