From: Rafael Garcia-Suarez Date: Mon, 31 Oct 2005 14:27:32 +0000 (+0000) Subject: Fix [perl #37533] open pragma ignored for all 3-arg opens X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9fe371da3bdc2d1a5eae907101756f87eb5d2168;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/lib/open.pm b/lib/open.pm index 3565762..24488e6 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. The C<:locale> subpragma implicitly turns on C<:std>. -The logic of C<:locale> is described in full in L, +The logic of C<:locale> is described in full in L, 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 e9ea0c3..23df5e8 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);