In perl.git, the branch maint-5.10 has been updated <http://perl5.git.perl.org/perl.git/commitdiff/10651633c958ecc4c75e4c2d4e90d79fc13b5af7?hp=608924c75840bd55c3c81ec424195ba671f6d575>
- Log ----------------------------------------------------------------- commit 10651633c958ecc4c75e4c2d4e90d79fc13b5af7 Author: Nicholas Clark <[email protected]> Date: Sun Jul 26 11:01:15 2009 +0100 Tidy code added in 4ba71d51f72efb2af8dc9748dd62219261f2e1fd. (cherry picked from commit bd0ab00df494c0f393ee5623b3a949ae9e0ae15e) M toke.c commit 7e7258ba84b97a032496810189d1ffcbf19ce89c Author: Father Chrysostomos <[email protected]> Date: Sun Jul 26 10:27:42 2009 +0100 Allow -C on the #! line when it is identical to -C on the command line. Change from dieing whenever -C is seen on the #! line, to dieing only when it differs from that on the command line, or was not specified on the command line. (cherry picked from commit 4ba71d51f72efb2af8dc9748dd62219261f2e1fd) M pod/perldiag.pod M pod/perlrun.pod M t/run/switchC.t M toke.c commit d9f011600d4e807192e04e42c923a95bc237ff6d Author: David Mitchell <[email protected]> Date: Sun Jul 26 02:19:20 2009 +0100 dup saved_curcop in PL_parser Commit 7c4baf47da introduced the saved_curcop field of PL_parser, but omitted to copy the entry during interpreter cloning. This may fix bugs [RT #58468], [RT #59498] (cherry picked from commit f0c5aa00eeb992584d6996af147c4c51fe7a6540) M sv.c ----------------------------------------------------------------------- Summary of changes: pod/perldiag.pod | 11 +++++++++-- pod/perlrun.pod | 6 +++--- sv.c | 11 +++++++++++ t/run/switchC.t | 6 +++++- toke.c | 9 ++++++++- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 69cdbd8..1129a05 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -4202,8 +4202,15 @@ system call to call, silly dilly. =item Too late for "-%s" option (X) The #! line (or local equivalent) in a Perl script contains the -B<-M>, B<-m> or B<-C> option. This is an error because those options -are not intended for use inside scripts. Use the C<use> pragma instead. +B<-M>, B<-m> or B<-C> option. + +In the case of B<-M> and B<-m>, this is an error because those options are +not intended for use inside scripts. Use the C<use> pragma instead. + +The B<-C> option only works if it is specified on the command line as well +(with the same sequence of letters or numbers following). Either specify +this option on the command line, or, if your system supports it, make your +script executable and run it directly instead of passing it to perl. =item Too late to run %s block diff --git a/pod/perlrun.pod b/pod/perlrun.pod index 1925861..ec33d32 100644 --- a/pod/perlrun.pod +++ b/pod/perlrun.pod @@ -343,10 +343,10 @@ that enabled the use of Unicode-aware "wide system call" Win32 APIs. This feature was practically unused, however, and the command line switch was therefore "recycled".) -B<Note:> Since perl 5.10.0, the -C option can no longer be used -on the #! line. It wasn't working there anyway, since the standard streams +B<Note:> Since perl 5.10.1, if the -C option is used on the #! line, it +must be specified on the command line as well, since the standard streams are already set up at this point in the execution of the perl interpreter. -You can use binmode() instead to get the desired behaviour. +You can also use binmode() to set the encoding of an I/O stream. =item B<-c> X<-c> diff --git a/sv.c b/sv.c index cde1f00..a251b21 100644 --- a/sv.c +++ b/sv.c @@ -10169,6 +10169,10 @@ Perl_parser_dup(pTHX_ const yy_parser *proto, CLONE_PARAMS* param) Copy(proto->nexttype, parser->nexttype, 5, I32); parser->nexttoke = proto->nexttoke; #endif + + /* XXX should clone saved_curcop here, but we aren't passed + * proto_perl; so do it in perl_clone_using instead */ + return parser; } @@ -11839,6 +11843,13 @@ perl_clone_using(PerlInterpreter *proto_perl, UV flags, PL_parser = proto_perl->Iparser ? parser_dup(proto_perl->Iparser, param): NULL; + /* XXX this only works if the saved cop has already been cloned */ + if (proto_perl->Iparser) { + PL_parser->saved_curcop = (COP*)any_dup( + proto_perl->Iparser->saved_curcop, + proto_perl); + } + PL_subline = proto_perl->Isubline; PL_subname = sv_dup_inc(proto_perl->Isubname, param); diff --git a/t/run/switchC.t b/t/run/switchC.t index 41dba49..9e52ad3 100644 --- a/t/run/switchC.t +++ b/t/run/switchC.t @@ -13,7 +13,7 @@ BEGIN { BEGIN { require "./test.pl"; } -plan(tests => 6); +plan(tests => 7); my $r; @@ -59,3 +59,7 @@ $r = runperl( switches => [ '-CA', '-w' ], args => [ chr(256) ] ); like( $r, qr/^256(?:\r?\n)?$/s, '-CA: @ARGV' ); +$r = runperl( switches => [ '-CS', '-w' ], + prog => "#!perl -CS\nprint chr(256)", + stderr => 1, ); +like( $r, qr/^$b(?:\r?\n)?$/s, '#!perl -C' ); diff --git a/toke.c b/toke.c index c66a964..933fcb3 100644 --- a/toke.c +++ b/toke.c @@ -3997,7 +3997,14 @@ Perl_yylex(pTHX) const char *d1 = d; do { - if (*d1 == 'M' || *d1 == 'm' || *d1 == 'C') { + bool baduni = FALSE; + if (*d1 == 'C') { + const char *d2 = d1 + 1; + if (parse_unicode_opts((const char **)&d2) + != PL_unicode) + baduni = TRUE; + } + if (baduni || *d1 == 'M' || *d1 == 'm') { const char * const m = d1; while (*d1 && !isSPACE(*d1)) d1++; -- Perl5 Master Repository
