From: Rafael Garcia-Suarez Date: Thu, 6 Mar 2003 21:59:02 +0000 (+0000) Subject: Make the -A switch work without an assertion name. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=930366bdf79887ad214c728d5d80b0adf3c4181c;p=p5sagit%2Fp5-mst-13.2.git Make the -A switch work without an assertion name. by Salvador FandiƱo. p4raw-id: //depot/perl@18843 --- diff --git a/perl.c b/perl.c index 869c666..b6386b9 100644 --- a/perl.c +++ b/perl.c @@ -2332,17 +2332,17 @@ Perl_moreswitches(pTHX_ char *s) return s; case 'A': forbid_setid("-A"); + if (!PL_preambleav) + PL_preambleav = newAV(); if (*++s) { - SV *sv=newSVpv("use assertions::activate split(/,/,q{",0); + SV *sv = newSVpvn("use assertions::activate split(/,/,q{",37); sv_catpv(sv,s); sv_catpv(sv,"})"); s+=strlen(s); - if(!PL_preambleav) - PL_preambleav = newAV(); av_push(PL_preambleav, sv); } else - Perl_croak(aTHX_ "No space allowed after -A"); + av_push(PL_preambleav, newSVpvn("use assertions::activate",24)); return s; case 'M': forbid_setid("-M"); /* XXX ? */ diff --git a/t/run/switch_A.t b/t/run/switch_A.t index e042c1d..5a71b40 100755 --- a/t/run/switch_A.t +++ b/t/run/switch_A.t @@ -7,7 +7,7 @@ BEGIN { } BEGIN { - plan(4); + plan(5); } #1 @@ -29,3 +29,8 @@ fresh_perl_is('sub cm : assertion { "ok" }; use assertions Bye; print cm()', fresh_perl_is('sub cm : assertion { "ok" }; use assertions Hello; print cm()', '0', { switches => ['-ANoH..o'] }, '-ANoH..o'); + +#5 +fresh_perl_is('sub cm : assertion { "ok" }; use assertions Hello; print cm()', + 'ok', + { switches => ['-A'] }, '-A');