Make the -A switch work without an assertion name.
Rafael Garcia-Suarez [Thu, 6 Mar 2003 21:59:02 +0000 (21:59 +0000)]
by Salvador FandiƱo.

p4raw-id: //depot/perl@18843

perl.c
t/run/switch_A.t

diff --git a/perl.c b/perl.c
index 869c666..b6386b9 100644 (file)
--- 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 ? */
index e042c1d..5a71b40 100755 (executable)
@@ -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');