summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--perl.c13
-rw-r--r--perl.h15
-rw-r--r--t/run/switchC.t17
-rw-r--r--util.c2
4 files changed, 31 insertions, 16 deletions
diff --git a/perl.c b/perl.c
index e603ffc18e..70cd770e13 100644
--- a/perl.c
+++ b/perl.c
@@ -1357,14 +1357,15 @@ print \" \\@INC:\\n @INC\\n\";");
* PL_utf8locale is conditionally turned on by
* locale.c:Perl_init_i18nl10n() if the environment
* look like the user wants to use UTF-8. */
- if (PL_unicode) { /* Requires init_predump_symbols(). */
- IO* io;
- PerlIO* fp;
- SV* sv;
-
+ if (PL_unicode) {
+ /* Requires init_predump_symbols(). */
if (!(PL_unicode & PERL_UNICODE_LOCALE_FLAG) || PL_utf8locale) {
+ IO* io;
+ PerlIO* fp;
+ SV* sv;
+
/* Turn on UTF-8-ness on STDIN, STDOUT, STDERR
- * and the default open discipline. */
+ * and the default open disciplines. */
if ((PL_unicode & PERL_UNICODE_STDIN_FLAG) &&
PL_stdingv && (io = GvIO(PL_stdingv)) &&
(fp = IoIFP(io)))
diff --git a/perl.h b/perl.h
index 462f0e32c8..88f011bdce 100644
--- a/perl.h
+++ b/perl.h
@@ -4175,15 +4175,22 @@ extern void moncontrol(int);
#define PERL_UNICODE_STDIN_FLAG 0x0001
#define PERL_UNICODE_STDOUT_FLAG 0x0002
#define PERL_UNICODE_STDERR_FLAG 0x0004
-#define PERL_UNICODE_STD_FLAG 0x0007
#define PERL_UNICODE_IN_FLAG 0x0008
#define PERL_UNICODE_OUT_FLAG 0x0010
-#define PERL_UNICODE_INOUT_FLAG 0x0018
-#define PERL_UNICODE_ARGV_FLAG 0x0020 /* For @ARGV? */
+#define PERL_UNICODE_ARGV_FLAG 0x0020
#define PERL_UNICODE_LOCALE_FLAG 0x0040
#define PERL_UNICODE_WIDESYSCALLS_FLAG 0x0080 /* for Sarathy */
-#define PERL_UNICODE_DEFAULT_FLAGS \
+#define PERL_UNICODE_STD_FLAG \
+ (PERL_UNICODE_STDIN_FLAG | \
+ PERL_UNICODE_STDOUT_FLAG | \
+ PERL_UNICODE_STDERR_FLAG)
+
+#define PERL_UNICODE_INOUT_FLAG \
+ (PERL_UNICODE_IN_FLAG | \
+ PERL_UNICODE_OUT_FLAG)
+
+#define PERL_UNICODE_DEFAULT_FLAGS \
(PERL_UNICODE_STD_FLAG | \
PERL_UNICODE_INOUT_FLAG | \
PERL_UNICODE_LOCALE_FLAG)
diff --git a/t/run/switchC.t b/t/run/switchC.t
index 9283fa879b..ba17cb91c1 100644
--- a/t/run/switchC.t
+++ b/t/run/switchC.t
@@ -25,11 +25,18 @@ $r = runperl( switches => [ '-CO', '-w' ],
stderr => 1 );
is( $r, "\xC4\x80", '-CO: no warning on UTF-8 output' );
-$r = runperl( switches => [ '-CI', '-w' ],
- prog => 'print ord(<STDIN>)',
- stderr => 1,
- stdin => chr(256) );
-is( $r, 256, '-CI: read in UTF-8 output' );
+SKIP: {
+ for my $l (qw(LC_ALL LC_CTYPE LANG)) {
+ skip("cannot easily test under UTF-8 locale", 1)
+ if $ENV{$l} =~ /utf-?8/i;
+ }
+ $r = runperl( switches => [ '-CI', '-w' ],
+ prog => 'print ord(<STDIN>)',
+ stderr => 1,
+ verbose => 1,
+ stdin => "\xC4\x80" );
+ is( $r, 256, '-CI: read in UTF-8 input' );
+}
$r = runperl( switches => [ '-CE', '-w' ],
prog => 'warn chr(256), qq(\n)',
diff --git a/util.c b/util.c
index e74fe719c4..e980707c42 100644
--- a/util.c
+++ b/util.c
@@ -4355,7 +4355,7 @@ Perl_parse_unicode_opts(pTHX_ char **popt)
opt = PERL_UNICODE_DEFAULT_FLAGS;
if (opt & ~PERL_UNICODE_ALL_FLAGS)
- Perl_croak(aTHX_ "Unknown Unicode option value 0x%"UVuf,
+ Perl_croak(aTHX_ "Unknown Unicode option value %"UVuf,
(UV) (opt & ~PERL_UNICODE_ALL_FLAGS));
*popt = p;