From: Peter Scott Date: Fri, 28 Mar 2003 16:34:47 +0000 (-0800) Subject: Text::Abbrev warnings safe X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=df26a7db8f2a7fec12d403bcefa0501353e16991;p=p5sagit%2Fp5-mst-13.2.git Text::Abbrev warnings safe Message-id: <5.2.0.9.2.20030328161002.00b45f08@shell2.webquarry.com> p4raw-id: //depot/perl@19114 --- diff --git a/lib/Text/Abbrev.pm b/lib/Text/Abbrev.pm index 08143fe..d7feedc 100644 --- a/lib/Text/Abbrev.pm +++ b/lib/Text/Abbrev.pm @@ -43,6 +43,7 @@ The values are the original list elements. 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; diff --git a/lib/Text/Abbrev.t b/lib/Text/Abbrev.t index fb5a984..38d4a39 100644 --- a/lib/Text/Abbrev.t +++ b/lib/Text/Abbrev.t @@ -1,6 +1,6 @@ #!./perl -print "1..7\n"; +print "1..8\n"; BEGIN { chdir 't' if -d 't'; @@ -49,3 +49,11 @@ abbrev \%y, @z; $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++;