Change 19114 by [EMAIL PROTECTED] on 2003/04/01 15:56:27

        Subject: [PATCH] Text::Abbrev warnings safe
        From: Peter Scott <[EMAIL PROTECTED]>
        Date: Fri, 28 Mar 2003 16:34:47 -0800
        Message-id: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/lib/Text/Abbrev.pm#9 edit
... //depot/perl/lib/Text/Abbrev.t#2 edit

Differences ...

==== //depot/perl/lib/Text/Abbrev.pm#9 (text) ====
Index: perl/lib/Text/Abbrev.pm
--- perl/lib/Text/Abbrev.pm#8~8013~     Wed Dec  6 08:09:09 2000
+++ perl/lib/Text/Abbrev.pm     Tue Apr  1 07:56:27 2003
@@ -43,6 +43,7 @@
 sub abbrev {
     my ($word, $hashref, $glob, %table, $returnvoid);
 
+    @_ or return;   # So we don't autovivify onto @_ and trigger warning
     if (ref($_[0])) {           # hash reference preferably
       $hashref = shift;
       $returnvoid = 1;

==== //depot/perl/lib/Text/Abbrev.t#2 (text) ====
Index: perl/lib/Text/Abbrev.t
--- perl/lib/Text/Abbrev.t#1~10672~     Sun Jun 17 15:09:28 2001
+++ perl/lib/Text/Abbrev.t      Tue Apr  1 07:56:27 2003
@@ -1,6 +1,6 @@
 #!./perl
 
-print "1..7\n";
+print "1..8\n";
 
 BEGIN {
     chdir 't' if -d 't';
@@ -49,3 +49,11 @@
 
 $s = join ':', sort keys %y;
 print (($r eq $s)?"ok $test\n":"not ok $test\n"); $test++;
+
+
+# warnings safe with zero arguments
+my $notok;
+$^W = 1;
+$SIG{__WARN__} = sub { $notok++ };
+abbrev();
+print ($notok ? "not ok $test\n" : "ok $test\n"); $test++;
End of Patch.

Reply via email to