blob: b5564fdbc0cc77a55f5da5945210244bb1dd99b9 [file] [log] [blame]
Patrick Williamsc124f4f2015-09-15 14:41:29 -05001From 0ecf83f259db09cb38cb37c9b22e72be185afa8f Mon Sep 17 00:00:00 2001
2From: Hugo van der Sanden <hv@crypt.org>
3Date: Thu, 11 Jun 2015 12:25:40 +0100
4Subject: fix -Cnn parsing
5
6Commit 22ff313068 for [perl #123814] inadvertently changed the logic when
7parsing a numeric parameter to the -C option, such that the successfully
8parsed number was not saved as the option value if it parsed to the end
9of the argument.
10
11Bug: https://rt.perl.org/Ticket/Display.html?id=125381
12Bug-Debian: https://bugs.debian.org/788636
13Origin: upstream, http://perl5.git.perl.org/perl.git/commit/89d84ff965
14Patch-Name: fixes/perl-Cnn.diff
15---
16 t/run/switchC.t | 7 ++++++-
17 util.c | 17 ++++++++---------
18 2 files changed, 14 insertions(+), 10 deletions(-)
19
20diff --git a/t/run/switchC.t b/t/run/switchC.t
21index f6aa868..4f63c3b 100644
22--- a/t/run/switchC.t
23+++ b/t/run/switchC.t
24@@ -11,7 +11,7 @@ BEGIN {
25 skip_all_if_miniperl('-C and $ENV{PERL_UNICODE} are disabled on miniperl');
26 }
27
28-plan(tests => 13);
29+plan(tests => 14);
30
31 my $r;
32
33@@ -25,6 +25,11 @@ $r = runperl( switches => [ '-CO', '-w' ],
34 stderr => 1 );
35 like( $r, qr/^$b(?:\r?\n)?$/s, '-CO: no warning on UTF-8 output' );
36
37+$r = runperl( switches => [ '-C2', '-w' ],
38+ prog => 'print chr(256)',
39+ stderr => 1 );
40+like( $r, qr/^$b(?:\r?\n)?$/s, '-C2: no warning on UTF-8 output' );
41+
42 SKIP: {
43 if (exists $ENV{PERL_UNICODE} &&
44 ($ENV{PERL_UNICODE} eq "" || $ENV{PERL_UNICODE} =~ /[SO]/)) {
45diff --git a/util.c b/util.c
46index 8cf62f5..ee23314 100644
47--- a/util.c
48+++ b/util.c
49@@ -4420,16 +4420,15 @@ Perl_parse_unicode_opts(pTHX_ const char **popt)
50 if (isDIGIT(*p)) {
51 const char* endptr;
52 UV uv;
53- if (grok_atoUV(p, &uv, &endptr)
54- && uv <= U32_MAX
55- && (p = endptr)
56- && *p && *p != '\n' && *p != '\r'
57- ) {
58+ if (grok_atoUV(p, &uv, &endptr) && uv <= U32_MAX) {
59 opt = (U32)uv;
60- if (isSPACE(*p))
61- goto the_end_of_the_opts_parser;
62- else
63- Perl_croak(aTHX_ "Unknown Unicode option letter '%c'", *p);
64+ p = endptr;
65+ if (p && *p && *p != '\n' && *p != '\r') {
66+ if (isSPACE(*p))
67+ goto the_end_of_the_opts_parser;
68+ else
69+ Perl_croak(aTHX_ "Unknown Unicode option letter '%c'", *p);
70+ }
71 }
72 }
73 else {