New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document "perl -Cio" scoping #10798
Comments
From @ntyniThis is a bug report for perl from Niko Tyni <ntyni@debian.org>, While the other -C settings are global, "i" and "o" only affect subsequent The attached suggested patch documents the scoping and adds two tests Reported by Joey Hess in http://bugs.debian.org/373698 Also reported by Frank Krout as [perl #23199], which was closed because Flags: Site configuration information for perl 5.13.6: Configured by niko at Fri Nov 5 14:02:26 EET 2010. Summary of my perl5 (revision 5 version 13 subversion 6) configuration: Locally applied patches: @INC for perl 5.13.6: Environment for perl 5.13.6: |
From @ntyni0001-Document-that-the-Ci-Co-and-CD-options-have-file-sco.patchFrom 7db0e78765d807d179a563e20d73e4e9f2dbb135 Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Fri, 5 Nov 2010 13:59:14 +0200
Subject: [PATCH] Document that the -Ci, -Co, and -CD options have file scope
While the other -C settings are global, "i" and "o" only affect subsequent
open() calls in the current file. Document this and add two tests to
make sure the documented behaviour doesn't change accidentally.
---
pod/perlrun.pod | 10 +++++-----
t/run/switchC.t | 17 ++++++++++++++++-
2 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/pod/perlrun.pod b/pod/perlrun.pod
index f3db450..5f93336 100644
--- a/pod/perlrun.pod
+++ b/pod/perlrun.pod
@@ -301,11 +301,11 @@ STDOUT and STDERR. Repeating letters is just redundant, not cumulative
nor toggling.
The C<io> options mean that any subsequent open() (or similar I/O
-operations) will have the C<:utf8> PerlIO layer implicitly applied
-to them, in other words, UTF-8 is expected from any input stream,
-and UTF-8 is produced to any output stream. This is just the default,
-with explicit layers in open() and with binmode() one can manipulate
-streams as usual.
+operations) in the current file scope will have the C<:utf8> PerlIO layer
+implicitly applied to them, in other words, UTF-8 is expected from any
+input stream, and UTF-8 is produced to any output stream. This is just
+the default, with explicit layers in open() and with binmode() one can
+manipulate streams as usual.
C<-C> on its own (not followed by any number or option list), or the
empty string C<""> for the C<PERL_UNICODE> environment variable, has the
diff --git a/t/run/switchC.t b/t/run/switchC.t
index 65b5eab..b6231ca 100644
--- a/t/run/switchC.t
+++ b/t/run/switchC.t
@@ -18,11 +18,12 @@ BEGIN {
BEGIN { require "./test.pl"; }
-plan(tests => 11);
+plan(tests => 13);
my $r;
my $tmpfile = tempfile();
+my $scriptfile = tempfile();
my $b = pack("C*", unpack("U0C*", pack("U",256)));
@@ -58,6 +59,20 @@ $r = runperl( switches => [ '-Ci', '-w' ],
stderr => 1 );
like( $r, qr/^256(?:\r?\n)?$/s, '-Ci: auto-UTF-8 open for input' );
+open(S, ">$scriptfile") or die("open $scriptfile: $!");
+print S "open(F, q(<$tmpfile)); print ord(<F>); close F";
+close S;
+
+$r = runperl( switches => [ '-Ci', '-w' ],
+ progfile => $scriptfile,
+ stderr => 1 );
+like( $r, qr/^256(?:\r?\n)?$/s, '-Ci: auto-UTF-8 open for input affects the current file' );
+
+$r = runperl( switches => [ '-Ci', '-w' ],
+ prog => "do q($scriptfile)",
+ stderr => 1 );
+unlike( $r, qr/^256(?:\r?\n)?$/s, '-Ci: auto-UTF-8 open for input has file scope' );
+
$r = runperl( switches => [ '-CA', '-w' ],
prog => 'print ord shift',
stderr => 1,
--
1.7.2.3
|
From @cpansproutOn Fri Nov 05 05:20:09 2010, ntyni@debian.org wrote:
Thank you. Applied as 88770b4.
See also [perl #67880]. |
The RT System itself - Status changed from 'new' to 'open' |
@cpansprout - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#78828 (status was 'resolved')
Searchable as RT78828$
The text was updated successfully, but these errors were encountered: