Change 34260 by [EMAIL PROTECTED] on 2008/09/04 05:17:21
Integrate:
[ 34128]
In Perl_sv_utf8_upgrade_flags(), don't assume that the SV is well
formed with a trailing '\0'. And do assume that bytes_to_utf8() does.
[ 34234]
Fix #30660: Repeated spaces on shebang line stops option parsing
From a patch and test sent by Renée Bäcker in
<[EMAIL PROTECTED]>
Affected files ...
... //depot/maint-5.10/perl/perl.c#15 integrate
... //depot/maint-5.10/perl/sv.c#21 integrate
... //depot/maint-5.10/perl/t/run/switches.t#4 integrate
Differences ...
==== //depot/maint-5.10/perl/perl.c#15 (text) ====
Index: perl/perl.c
--- perl/perl.c#14~33972~ 2008-05-31 16:40:24.000000000 -0700
+++ perl/perl.c 2008-09-03 22:17:21.000000000 -0700
@@ -3389,8 +3389,10 @@
return s;
case '*':
case ' ':
- if (s[1] == '-') /* Additional switches on #! line. */
- return s+2;
+ while( *s == ' ' )
+ ++s;
+ if (s[0] == '-') /* Additional switches on #! line. */
+ return s+1;
break;
case '-':
case 0:
==== //depot/maint-5.10/perl/sv.c#21 (text) ====
Index: perl/sv.c
--- perl/sv.c#20~33972~ 2008-05-31 16:40:24.000000000 -0700
+++ perl/sv.c 2008-09-03 22:17:21.000000000 -0700
@@ -3059,13 +3059,21 @@
const U8 ch = *t++;
/* Check for hi bit */
if (!NATIVE_IS_INVARIANT(ch)) {
- STRLEN len = SvCUR(sv) + 1; /* Plus the \0 */
+ STRLEN len = SvCUR(sv);
+ /* *Currently* bytes_to_utf8() adds a '\0' after every string
+ it converts. This isn't documented. It's not clear if it's
+ a bad thing to be doing, and should be changed to do exactly
+ what the documentation says. If so, this code will have to
+ be changed.
+ As is, we mustn't rely on our incoming SV being well formed
+ and having a trailing '\0', as certain code in pp_formline
+ can send us partially built SVs. */
U8 * const recoded = bytes_to_utf8((U8*)s, &len);
SvPV_free(sv); /* No longer using what was there before. */
SvPV_set(sv, (char*)recoded);
- SvCUR_set(sv, len - 1);
- SvLEN_set(sv, len); /* No longer know the real size. */
+ SvCUR_set(sv, len);
+ SvLEN_set(sv, len + 1); /* No longer know the real size. */
break;
}
}
==== //depot/maint-5.10/perl/t/run/switches.t#4 (text) ====
Index: perl/t/run/switches.t
--- perl/t/run/switches.t#3~33953~ 2008-05-30 16:12:33.000000000 -0700
+++ perl/t/run/switches.t 2008-09-03 22:17:21.000000000 -0700
@@ -11,7 +11,7 @@
BEGIN { require "./test.pl"; }
-plan(tests => 68);
+plan(tests => 69);
use Config;
@@ -352,3 +352,19 @@
stdin => 'zomtek',
);
is( $r, "affe\n", '-E works outside of the block created by -n' );
+
+# RT #30660
+
+$filename = tempfile();
+SKIP: {
+ open my $f, ">$filename" or skip( "Can't write temp file $filename: $!" );
+ print $f <<'SWTEST';
+#!perl -w -iok
+print "$^I\n";
+SWTEST
+ close $f or die "Could not close: $!";
+ $r = runperl(
+ progfile => $filename,
+ );
+ like( $r, qr/ok/, 'Spaces on the #! line (#30660)' );
+}
End of Patch.