blob: 9bdf41b47d6be968251ad005f9038ddf775f041c [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
Brad Bishopd7bf8c12018-02-25 22:55:05 -050015Upstream-Status: Pending
Patrick Williamsc124f4f2015-09-15 14:41:29 -050016---
17 t/run/switchC.t | 7 ++++++-
18 util.c | 17 ++++++++---------
19 2 files changed, 14 insertions(+), 10 deletions(-)
20
21diff --git a/t/run/switchC.t b/t/run/switchC.t
22index f6aa868..4f63c3b 100644
23--- a/t/run/switchC.t
24+++ b/t/run/switchC.t
25@@ -11,7 +11,7 @@ BEGIN {
26 skip_all_if_miniperl('-C and $ENV{PERL_UNICODE} are disabled on miniperl');
27 }
28
29-plan(tests => 13);
30+plan(tests => 14);
31
32 my $r;
33
34@@ -25,6 +25,11 @@ $r = runperl( switches => [ '-CO', '-w' ],
35 stderr => 1 );
36 like( $r, qr/^$b(?:\r?\n)?$/s, '-CO: no warning on UTF-8 output' );
37
38+$r = runperl( switches => [ '-C2', '-w' ],
39+ prog => 'print chr(256)',
40+ stderr => 1 );
41+like( $r, qr/^$b(?:\r?\n)?$/s, '-C2: no warning on UTF-8 output' );
42+
43 SKIP: {
44 if (exists $ENV{PERL_UNICODE} &&
45 ($ENV{PERL_UNICODE} eq "" || $ENV{PERL_UNICODE} =~ /[SO]/)) {
46diff --git a/util.c b/util.c
47index 8cf62f5..ee23314 100644
48--- a/util.c
49+++ b/util.c
50@@ -4420,16 +4420,15 @@ Perl_parse_unicode_opts(pTHX_ const char **popt)
51 if (isDIGIT(*p)) {
52 const char* endptr;
53 UV uv;
54- if (grok_atoUV(p, &uv, &endptr)
55- && uv <= U32_MAX
56- && (p = endptr)
57- && *p && *p != '\n' && *p != '\r'
58- ) {
59+ if (grok_atoUV(p, &uv, &endptr) && uv <= U32_MAX) {
60 opt = (U32)uv;
61- if (isSPACE(*p))
62- goto the_end_of_the_opts_parser;
63- else
64- Perl_croak(aTHX_ "Unknown Unicode option letter '%c'", *p);
65+ p = endptr;
66+ if (p && *p && *p != '\n' && *p != '\r') {
67+ if (isSPACE(*p))
68+ goto the_end_of_the_opts_parser;
69+ else
70+ Perl_croak(aTHX_ "Unknown Unicode option letter '%c'", *p);
71+ }
72 }
73 }
74 else {