This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
display_format used as a class method without arguments was broken,
[perl5.git] / lib / Math / Complex.pm
index ece2aad..e7a071a 100644 (file)
@@ -7,10 +7,10 @@
 
 package Math::Complex;
 
-$VERSION = "1.30";
-
 our($VERSION, @ISA, @EXPORT, %EXPORT_TAGS, $Inf);
 
+$VERSION = 1.31;
+
 BEGIN {
     unless ($^O eq 'unicosmk') {
         my $e = $!;
@@ -1253,23 +1253,15 @@ sub display_format {
                my %obj = %{$self->{display_format}};
                @display_format{keys %obj} = values %obj;
            }
-           if (@_ == 1) {
-               $display_format{style} = shift;
-           } else {
-               my %new = @_;
-               @display_format{keys %new} = values %new;
-           }
-       } else {                                # Called as a class method
-           if (@_ = 1) {
-               $display_format{style} = $self;
-           } else {
-               my %new = @_;
-               @display_format{keys %new} = values %new;
-           }
-           undef $self;
+       }
+       if (@_ == 1) {
+           $display_format{style} = shift;
+       } else {
+           my %new = @_;
+           @display_format{keys %new} = values %new;
        }
 
-       if (defined $self) {
+       if (ref $self) { # Called as an object method
            $self->{display_format} = { %display_format };
            return
                wantarray ?
@@ -1277,6 +1269,7 @@ sub display_format {
                    $self->{display_format}->{style};
        }
 
+        # Called as a class method
        %DISPLAY_FORMAT = %display_format;
        return
            wantarray ?