Change 14025 by ams@lustre on 2002/01/02 18:34:26

           Subject: [PATCH] Bad prototype detection changed from error to warning
           From: Sam Tregar <[EMAIL PROTECTED]>
           Date: Wed, 2 Jan 2002 14:04:26 -0500 (EST)
           Message-Id: <[EMAIL PROTECTED]>

Affected files ...

.... //depot/perl/pod/perldiag.pod#255 edit
.... //depot/perl/t/comp/proto.t#33 edit
.... //depot/perl/toke.c#404 edit

Differences ...

==== //depot/perl/pod/perldiag.pod#255 (text) ====
Index: perl/pod/perldiag.pod
--- perl/pod/perldiag.pod.~1~   Wed Jan  2 11:45:05 2002
+++ perl/pod/perldiag.pod       Wed Jan  2 11:45:05 2002
@@ -1605,6 +1605,11 @@
 version of Perl appears to have been built without this support.  Talk
 to your Perl administrator.
 
+=item Illegal character in prototype for %s : %s
+
+(S) An illegal character was found in a prototype declaration.  Legal
+characters in prototypes are $, @, %, *, ;, [, ], &, and \.
+
 =item Illegal division by zero
 
 (F) You tried to divide a number by 0.  Either something was wrong in
@@ -1871,10 +1876,10 @@
 
 =item Malformed prototype for %s: %s
 
-(F) You declared or tried to use a function with a malformed
-prototype.  The syntax of function prototypes is given a brief
-compile-time check for obvious errors like invalid characters.  A more
-rigorous check is run when the function is called.
+(F) You tried to use a function with a malformed prototype.  The
+syntax of function prototypes is given a brief compile-time check for
+obvious errors like invalid characters.  A more rigorous check is run
+when the function is called.
 
 =item Malformed UTF-8 character (%s)
 

==== //depot/perl/t/comp/proto.t#33 (xtext) ====
Index: perl/t/comp/proto.t
--- perl/t/comp/proto.t.~1~     Wed Jan  2 11:45:05 2002
+++ perl/t/comp/proto.t Wed Jan  2 11:45:05 2002
@@ -16,7 +16,7 @@
 
 use strict;
 
-print "1..134\n";
+print "1..135\n";
 
 my $i = 1;
 
@@ -528,20 +528,29 @@
     print "ok ", $i++, "\n";
 }
 
-# check that obviously bad prototypes are getting rejected
-eval 'sub badproto (@bar) { 1; }';
-print "not " unless $@ =~ /^Malformed prototype for main::badproto : \@bar/;
-print "ok ", $i++, "\n";
+# check that obviously bad prototypes are getting warnings
+{
+  my $warn = "";
+  local $SIG{__WARN__} = sub { $warn .= join("",@_) };
+  
+  eval 'sub badproto (@bar) { 1; }';
+  print "not " unless $warn =~ /Illegal character in prototype for main::badproto : 
+\@bar/;
+  print "ok ", $i++, "\n";
 
-eval 'sub badproto2 (bar) { 1; }';
-print "not " unless $@ =~ /^Malformed prototype for main::badproto2 : bar/;
-print "ok ", $i++, "\n";
+  eval 'sub badproto2 (bar) { 1; }';
+  print "not " unless $warn =~ /Illegal character in prototype for main::badproto2 : 
+bar/;
+  print "ok ", $i++, "\n";
+  
+  eval 'sub badproto3 (&$bar$@) { 1; }';
+  print "not " unless $warn =~ /Illegal character in prototype for main::badproto3 : 
+&\$bar\$\@/;
+  print "ok ", $i++, "\n";
+  
+  eval 'sub badproto4 (@ $b ar) { 1; }';
+  print "not " unless $warn =~ /Illegal character in prototype for main::badproto4 : 
+\@\$bar/;
+  print "ok ", $i++, "\n";
+}
 
-eval 'sub badproto3 (&$bar$@) { 1; }';
-print "not " unless $@ =~ /^Malformed prototype for main::badproto3 : &\$bar\$\@/;
+# make sure whitespace in prototypes works
+eval "sub good (\$\t\$\n\$) { 1; }";
+print "not " if $@;
 print "ok ", $i++, "\n";
-
-eval 'sub badproto4 (@ $b ar) { 1; }';
-print "not " unless $@ =~ /^Malformed prototype for main::badproto4 : \@\$bar/;
-print "ok ", $i++, "\n";
-

==== //depot/perl/toke.c#404 (text) ====
Index: perl/toke.c
--- perl/toke.c.~1~     Wed Jan  2 11:45:05 2002
+++ perl/toke.c Wed Jan  2 11:45:05 2002
@@ -4957,15 +4957,17 @@
                    tmp = 0;
                    bad_proto = FALSE;
                    for (p = d; *p; ++p) {
-                       if (!strchr("$@%*;[]&\\ ", *p))
-                           bad_proto = TRUE;
-                       if (!isSPACE(*p))
+                       if (!isSPACE(*p)) {
                            d[tmp++] = *p;
+                           if (!strchr("$@%*;[]&\\", *p))
+                               bad_proto = TRUE;
+                       }
                    }
                    d[tmp] = '\0';
                    if (bad_proto)
-                       Perl_croak(aTHX_ "Malformed prototype for %s : %s",
-                                  SvPVX(PL_subname), d);
+                       Perl_warn(aTHX_
+                                 "Illegal character in prototype for %s : %s",
+                                 SvPVX(PL_subname), d);
                    SvCUR(PL_lex_stuff) = tmp;
                    have_proto = TRUE;
 
End of Patch.

Reply via email to