Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/printf Add support for F a and A formats (which go w...



details:   https://anonhg.NetBSD.org/src/rev/75df963506cb
branches:  trunk
changeset: 991656:75df963506cb
user:      kre <kre%NetBSD.org@localhost>
date:      Tue Jul 24 20:49:19 2018 +0000

description:
Add support for F a and A formats (which go with the eEfgG formats
already supported.)

diffstat:

 usr.bin/printf/printf.1 |  30 +++++++++++++++++++++++++++---
 usr.bin/printf/printf.c |   7 +++++--
 2 files changed, 32 insertions(+), 5 deletions(-)

diffs (113 lines):

diff -r 9e6f9cf6d214 -r 75df963506cb usr.bin/printf/printf.1
--- a/usr.bin/printf/printf.1   Tue Jul 24 19:49:33 2018 +0000
+++ b/usr.bin/printf/printf.1   Tue Jul 24 20:49:19 2018 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: printf.1,v 1.28 2018/07/24 19:49:33 kre Exp $
+.\"    $NetBSD: printf.1,v 1.29 2018/07/24 20:49:19 kre Exp $
 .\"
 .\" Copyright (c) 1989, 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"    from: @(#)printf.1      8.1 (Berkeley) 6/6/93
 .\"
-.Dd March 11, 2018
+.Dd July 25, 2018
 .Dt PRINTF 1
 .Os
 .Sh NAME
@@ -169,6 +169,7 @@
 .Cm e ,
 .Cm E ,
 .Cm f ,
+.Cm F ,
 .Cm g ,
 and
 .Cm G
@@ -257,7 +258,7 @@
 .Ar argument
 is printed as a signed decimal (d or i), unsigned octal, unsigned decimal,
 or unsigned hexadecimal (X or x), respectively.
-.It Cm f
+.It Cm fF
 The
 .Ar argument
 is printed in the style
@@ -269,6 +270,17 @@
 the argument.
 If the precision is missing, 6 digits are given; if the precision
 is explicitly 0, no digits and no decimal point are printed.
+If the number is Infinity, or Not a Number (NaN), then
+.Dq inf
+.Pq \&or Dq nan
+is printed for
+.Cm f
+format, and
+.Dq INF
+.Pq \&or Dq NAN
+for
+.Cm F
+format.
 .It Cm eE
 The
 .Ar argument
@@ -282,16 +294,28 @@
 missing, 6 digits are produced.
 An upper-case E is used for an
 .Sq E
+format, and upper-case for Infinity and NaN as for
+.Sq F
 format.
 .It Cm gG
 The
 .Ar argument
 is printed in style
 .Cm f
+.Pq Cm F
 or in style
 .Cm e
 .Pq Cm E
 whichever gives full precision in minimum space.
+.It Cm aA
+The
+.Ar argument
+is treated as a floating point number,
+for which the underlying hexadecimal representation is
+printed.
+See
+.Xr printf 3
+for the details.
 .It Cm b
 Characters from the string
 .Ar argument
diff -r 9e6f9cf6d214 -r 75df963506cb usr.bin/printf/printf.c
--- a/usr.bin/printf/printf.c   Tue Jul 24 19:49:33 2018 +0000
+++ b/usr.bin/printf/printf.c   Tue Jul 24 20:49:19 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: printf.c,v 1.39 2018/07/03 01:56:39 kre Exp $  */
+/*     $NetBSD: printf.c,v 1.40 2018/07/24 20:49:19 kre Exp $  */
 
 /*
  * Copyright (c) 1989, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)printf.c   8.2 (Berkeley) 3/22/95";
 #else
-__RCSID("$NetBSD: printf.c,v 1.39 2018/07/03 01:56:39 kre Exp $");
+__RCSID("$NetBSD: printf.c,v 1.40 2018/07/24 20:49:19 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -293,9 +293,12 @@
                                        goto out;
                                break;
                        }
+                       case 'a':
+                       case 'A':
                        case 'e':
                        case 'E':
                        case 'f':
+                       case 'F':
                        case 'g':
                        case 'G': {
                                double p = getdouble();



Home | Main Index | Thread Index | Old Index