Change 27368 by rgs@stencil on 2006/03/03 15:45:32 Subject: [PATCH] Re: [perl #38657] -d:Foo=bar broke in 5.8.8 From: Jarkko Hietaniemi Date: Thu, 02 Mar 2006 20:21:26 +0200 Message-ID: <440737A6.4060606@gmail.com> Affected files ... ... //depot/perl/t/lib/Devel/switchd.pm#3 edit ... //depot/perl/t/run/switchd.t#4 edit Change 27359 by rgs@marais on 2006/03/01 22:39:24 Don't put strings with embedded NULs in the environment. This makes things like -d:Foo=bar work again. Affected files ... ... //depot/perl/perl.c#737 edit --- perl.c 2006-03-01 22:18:07.000000000 +0100 +++ perl.c 2006-03-01 22:18:04.000000000 +0100 @@ -3031,7 +3031,9 @@ sv_catpv(sv, start); else { sv_catpvn(sv, start, s-start); - Perl_sv_catpvf(aTHX_ sv, " split(/,/,q%c%s%c)", 0, ++s, 0); + /* Don't use NUL as q// delimiter here, this string goes in the + * environment. */ + Perl_sv_catpvf(aTHX_ sv, " split(/,/,q{%s});", ++s); } s += strlen(s); my_setenv("PERL5DB", SvPV_nolen_const(sv)); --- t/lib/Devel/switchd.pm.dist 2006-03-02 20:02:52.000000000 +0200 +++ t/lib/Devel/switchd.pm 2006-03-02 20:12:59.000000000 +0200 @@ -1,6 +1,8 @@ package Devel::switchd; use strict; BEGIN { } # use strict; BEGIN { ... } to incite [perl #21890] +sub import { print "import<@_>;" } package DB; -sub DB { print join(",", caller), ";" } +sub DB { print "DB<", join(",", caller), ">;" } +sub sub { print "sub<$DB::sub>;"; goto &$DB::sub } 1; --- t/run/switchd.t.dist 2006-03-02 19:59:03.000000000 +0200 +++ t/run/switchd.t 2006-03-02 20:17:18.000000000 +0200 @@ -7,7 +7,9 @@ require "./test.pl"; -plan(tests => 1); +# This test depends on t/lib/Devel/switchd.pm. + +plan(tests => 2); my $r; my @tmpfiles = (); @@ -34,7 +36,14 @@ $r = runperl( switches => [ '-Ilib', '-d:switchd' ], progfile => $filename, + args => ['3'], ); - like($r, qr/^main,swdtest.tmp,9;Foo,swdtest.tmp,5;Foo,swdtest.tmp,6;Foo,swdtest.tmp,6;Bar,swdtest.tmp,2;Bar,swdtest.tmp,2;Bar,swdtest.tmp,2;$/i); + like($r, qr/^sub;import;DB;sub;DB;DB;DB;sub;DB;sub;DB;sub;DB;$/); + $r = runperl( + switches => [ '-Ilib', '-d:switchd=a,42' ], + progfile => $filename, + args => ['4'], + ); + like($r, qr/^sub;import;DB;sub;DB;DB;DB;sub;DB;sub;DB;sub;DB;$/); }