This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #123991] report an error if we can't parse the number after -C
authorTony Cook <tony@develop-help.com>
Thu, 26 Nov 2015 00:18:52 +0000 (11:18 +1100)
committerTony Cook <tony@develop-help.com>
Mon, 7 Dec 2015 02:48:08 +0000 (13:48 +1100)
pod/perldiag.pod
t/run/switchC.t
util.c

index 5174373..803f3a0 100644 (file)
@@ -2657,6 +2657,11 @@ provides a list context to its subscript, which can do weird things
 if you're expecting only one subscript.  When called in list context,
 it also returns the key in addition to the value.
 
+=item Invalid number '%s' for -C option.
+
+(F) You supplied number to the -C option that either has extra leading
+zeroes or overflows perl's unsigned integer representation.
+
 =item %s() is deprecated on :utf8 handles
 
 (W deprecated) The sysread(), recv(), syswrite() and send() operators
index 4f63c3b..6583010 100644 (file)
@@ -11,7 +11,7 @@ BEGIN {
     skip_all_if_miniperl('-C and $ENV{PERL_UNICODE} are disabled on miniperl');
 }
 
-plan(tests => 14);
+plan(tests => 15);
 
 my $r;
 
@@ -111,3 +111,9 @@ SKIP: {
     like( $r, qr/^Too late for "-CS" option at -e line 1\.$/s,
           '#!perl -C but not command line' );
 }
+
+$r = runperl ( switches => [ '-C00' ],
+               prog    => '1',
+               stderr   => 1, );
+like($r, qr/^Invalid number '00' for -C option\.$/s,
+     "perl -C00 [perl #123991]");
diff --git a/util.c b/util.c
index aeec4c0..17b62dd 100644 (file)
--- a/util.c
+++ b/util.c
@@ -4538,6 +4538,9 @@ Perl_parse_unicode_opts(pTHX_ const char **popt)
                         Perl_croak(aTHX_ "Unknown Unicode option letter '%c'", *p);
                 }
             }
+            else {
+                Perl_croak(aTHX_ "Invalid number '%s' for -C option.\n", p);
+            }
         }
         else {
            for (; *p; p++) {