Skip Menu |
 

This queue is for tickets about the Fortran-Format CPAN distribution.

Report information
The Basics
Id: 69780
Status: new
Priority: 0/
Queue: Fortran-Format

People
Owner: Nobody in particular
Requestors: jini.zh [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.90
Fixed in: (no value)

Attachments


Subject: No support for reading D and E formats
Download (untitled) / with headers
text/plain 1.4k
Just as in #47484, there is no sub to read D and E formats: perl -MFortran::Format -le 'print Fortran::Format->new("E5.1")->read("1.1E1", 1)' Can't locate object method "read_once" via package "Fortran::Format::Edit::E" at /usr/local/share/perl/5.12.3/Fortran/Format.pm line 769, <$fh> line 1. Expected output: 11 The fix: diff --git a/Format.pm b/Format.pm index 06e2efa..82e0c65 100644 --- a/Format.pm +++ b/Format.pm @@ -1001,6 +1001,39 @@ sub write_once { $s || "*" x $width; } +sub read_once { + my ($self) = @_; + return undef unless $self->writer->want_more; + my $s = $self->writer->read($self->{width}); + my $f; + + my ($num, $exp) = $s =~ /^ *([+-]?[\d ]*\.?[\d ]*)((?:[ed][+-]?|[+-])[\d ]+)?$/i; + if (defined $num and $num =~ /\d/) { + unless ($num =~ /\./) { + substr $num, length($num) - $self->{precision}, 0, '.'; + } + if (!defined $exp) { + $s = $num; + } elsif ($exp =~ /[ed]/i) { + $s = $num . $exp; + } else { + $s = $num . $self->exp_char . $exp; + } + if ($self->writer->bz) { + $s =~ s/ /0/g; + } else { + $s =~ s/ //g; + } + $f = $s / 10**($self->writer->scale); + } elsif ($s =~ /^[ .]*$/) { + $f = 0; + } else { + die 'invalid ', $self->exp_char, " number'$s'\n"; + } + $self->writer->put($f); + 1; +}; + sub exp_char { "D" }
From: jini.zh [...] gmail.com
Download (untitled) / with headers
text/plain 115b
Sorry, just noticed that bugreport system eats whitespaces in the beginning of lines. I'll attach the fix in a file
Subject: fortran-format-e-read_once.patch
diff --git a/Format.pm b/Format.pm index 06e2efa..82e0c65 100644 --- a/Format.pm +++ b/Format.pm @@ -1001,6 +1001,39 @@ sub write_once { $s || "*" x $width; } +sub read_once { + my ($self) = @_; + return undef unless $self->writer->want_more; + my $s = $self->writer->read($self->{width}); + my $f; + + my ($num, $exp) = $s =~ /^ *([+-]?[\d ]*\.?[\d ]*)((?:[ed][+-]?|[+-])[\d ]+)?$/i; + if (defined $num and $num =~ /\d/) { + unless ($num =~ /\./) { + substr $num, length($num) - $self->{precision}, 0, '.'; + } + if (!defined $exp) { + $s = $num; + } elsif ($exp =~ /[ed]/i) { + $s = $num . $exp; + } else { + $s = $num . $self->exp_char . $exp; + } + if ($self->writer->bz) { + $s =~ s/ /0/g; + } else { + $s =~ s/ //g; + } + $f = $s / 10**($self->writer->scale); + } elsif ($s =~ /^[ .]*$/) { + $f = 0; + } else { + die 'invalid ', $self->exp_char, " number'$s'\n"; + } + $self->writer->put($f); + 1; +}; + sub exp_char { "D" }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.