Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with printf #2134

Closed
p5pRT opened this issue Jun 26, 2000 · 5 comments
Closed

problem with printf #2134

p5pRT opened this issue Jun 26, 2000 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 26, 2000

Migrated from rt.perl.org#3427 (status was 'resolved')

Searchable as RT3427$

@p5pRT
Copy link
Author

p5pRT commented Jun 26, 2000

From wis@sequent.com

Hello,

Left justification of fixed point numbers (%-f) doesn't
work in 5.004 for at least two platforms (SunOS/Solaris
and HP-UX).

See attached test script and sample outputs.

Regards,

-wis
--
Wis Macomson
wis@​sequent.com

----- test script -----
#!/usr/local/bin/perl

$u = 1 ;
$v = 100 ;
$w = 1000 ;
$x = 1.2345 ;
$y = 6789.0 ;

print `uname -svr` ;
print "perl ver $]\n" ;

printf("format = %%15.5f : %15.5f\t%15.5f\n",$x,$y) ;
printf("format = %%-15.5f​: %-15.5f\t%-15.5f\n",$x,$y) ;

printf("format = %%15.5e : %15.5e\t%15.5e\n",$x,$y) ;
printf("format = %%-15.5e​: %-15.5e\t%-15.5e\n",$x,$y) ;
----- end test -----

----- results -----
DYNIX/ptx 4.0 V4.4.7
perl ver 5.003
format = %15.5f : 1.23450 6789.00000
format = %-15.5f​: 1.23450 6789.00000
format = %15.5e : 1.23450e+00 6.78900e+03
format = %-15.5e​: 1.23450e+00 6.78900e+03

HP-UX B.10.20 A
perl ver 5.00401
format = %15.5f : 1.23450 6789.00000
format = %-15.5f​: 1.23450 6789.00000
format = %15.5e : 1.23450e+00 6.78900e+03
format = %-15.5e​: 1.23450e+00 6.78900e+03

SunOS 5.5.1 Generic_103640-12
perl ver 5.00401
format = %15.5f : 1.23450 6789.00000
format = %-15.5f​: 1.23450 6789.00000
format = %15.5e : 1.23450e+00 6.78900e+03
format = %-15.5e​: 1.23450e+00 6.78900e+03
----- end results -----

@p5pRT
Copy link
Author

p5pRT commented Jun 27, 2000

From [Unknown Contact. See original ticket]

Wis Macomson <wis@​sequent.com> wrote

Left justification of fixed point numbers (%-f) doesn't
work in 5.004 for at least two platforms (SunOS/Solaris
and HP-UX).

Upgrade to a current Perl.

Older versions of Perl (before 5.005) used the underlying C library
routines to implement s?printf. So they reflect any bugs/quirks/features
of the underlying platform. Current Perl versions have their own
s?printf code, avoiding these problems.

Mike Guy

@p5pRT
Copy link
Author

p5pRT commented Jun 27, 2000

From [Unknown Contact. See original ticket]

At 10​:01 -0700 2000-06-26, Wis Macomson wrote​:

Left justification of fixed point numbers (%-f) doesn't
work in 5.004 for at least two platforms (SunOS/Solaris
and HP-UX).
...
DYNIX/ptx 4.0 V4.4.7
perl ver 5.003
...
HP-UX B.10.20 A
perl ver 5.00401
...
SunOS 5.5.1 Generic_103640-12
perl ver 5.00401

Those are rather old perls​: 5.003 dates from 1996, 5.004_01 from
1997. If you really want to stick with 5.004, you _may_ get better
results from the latest maintenance release, 5.004_05, the source for
which you can find at
<http​://www.cpan.com/authors/Chip_Salzenberg/perl5.004_05.tar.gz>.
[Is there a good reason, o CPAN maintainer and/or pumpking, why this
isn't accessible in <http​://www.cpan.com/src/5.0/maint/>? The
mailing list archive thread at
<http​://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/1999-04/msg02376.html>
casts no light.]

That said, 5.004_05 probably _won't_ help​: after continual and
continuing problems with using systems' inconsistent, insecure, and
buggy C library implementations of printf, perl 5.005 implemented its
own version so as to be able (largely) to ignore the system
implementation. As a result, if you upgrade to perl 5.005_03
(available in at the maintenance URL above), or to the current
release, perl 5.6.0 (available at
<http​://www.cpan.org/src/stable.tar.gz>), you should find that the
problem is fixed. If it's not, please use the perlbug program to let
us know​: I note that perl's regression tests don't actually check
that left justification of numbers works correctly. Patch for this
to follow.

@p5pRT
Copy link
Author

p5pRT commented Jun 27, 2000

From [Unknown Contact. See original ticket]

Dominic Dunlop <domo@​computer.org> wrote

That said, 5.004_05 probably _won't_ help

Actually it does seem to fix the problem, at least on SunOS4.1.3 which
also shows it.

Tho' if you're upgrading, you might as well get up to date.

Mike Guy

@p5pRT
Copy link
Author

p5pRT commented Jun 27, 2000

From @jhi

<http​://www.cpan.com/authors/Chip_Salzenberg/perl5.004_05.tar.gz>.
[Is there a good reason, o CPAN maintainer and/or pumpking, why this
isn't accessible in <http​://www.cpan.com/src/5.0/maint/>?

There was no good reason why it was not there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant