Thu Sep 1 23:13:16 2011 UTC ()
Clarify the history and add proper attribution.


(fair)
diff -r1.2 -r1.3 src/lib/libutil/strpct.3

cvs diff -r1.2 -r1.3 src/lib/libutil/strpct.3 (expand / switch to unified diff)

--- src/lib/libutil/strpct.3 2011/08/28 17:21:28 1.2
+++ src/lib/libutil/strpct.3 2011/09/01 23:13:16 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1.\" $NetBSD: strpct.3,v 1.2 2011/08/28 17:21:28 wiz Exp $ 1.\" $NetBSD: strpct.3,v 1.3 2011/09/01 23:13:16 fair Exp $
2.\" 2.\"
3.\" Copyright (c) 2011 The NetBSD Foundation, Inc. 3.\" Copyright (c) 2011 The NetBSD Foundation, Inc.
4.\" All rights reserved. 4.\" All rights reserved.
5.\" 5.\"
6.\" This file was contributed to The NetBSD Foundation by Christos Zoulas. 6.\" This file was contributed to The NetBSD Foundation by Christos Zoulas.
7.\" 7.\"
8.\" Redistribution and use in source and binary forms, with or without 8.\" Redistribution and use in source and binary forms, with or without
9.\" modification, are permitted provided that the following conditions 9.\" modification, are permitted provided that the following conditions
10.\" are met: 10.\" are met:
11.\" 1. Redistributions of source code must retain the above copyright 11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer. 12.\" notice, this list of conditions and the following disclaimer.
13.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" 2. Redistributions in binary form must reproduce the above copyright
14.\" notice, this list of conditions and the following disclaimer in the 14.\" notice, this list of conditions and the following disclaimer in the
@@ -16,68 +16,73 @@ @@ -16,68 +16,73 @@
16.\" 16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 17.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
18.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 20.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
21.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27.\" POSSIBILITY OF SUCH DAMAGE. 27.\" POSSIBILITY OF SUCH DAMAGE.
28.\" 28.\"
29.Dd August 28, 2011 29.Dd September 1, 2011
30.Dt STRPCT 3 30.Dt STRPCT 3
31.Os 31.Os
32.Sh NAME 32.Sh NAME
33.Nm strpct 33.Nm strpct
34.Nd decimal percent formatter 34.Nd decimal percent formatter
35.Sh LIBRARY 35.Sh LIBRARY
36.Lb libutil 36.Lb libutil
37.Sh SYNOPSIS 37.Sh SYNOPSIS
38.In util.h 38.In util.h
39.Ft char * 39.Ft char *
40.Fn strpct "char *buf" "size_t bufsiz" "uintmax_t numerator" "uintmax_t denominator" "size_t precision" 40.Fn strpct "char *buf" "size_t bufsiz" "uintmax_t numerator" "uintmax_t denominator" "size_t precision"
41.Sh DESCRIPTION 41.Sh DESCRIPTION
42The 42The
43.Fn strpct 43.Fn strpct
44function formats the fraction represented by 44function formats the fraction represented by
45.Fa numerator 45.Fa numerator
46and 46and
47.Fa denominator 47.Fa denominator
48into a percentage representation with given number of digits of 48into a percentage representation with given number of digits of
49.Fa precision . 49.Fa precision
 50without using floating point arithmetic.
50.Sh RETURN VALUES 51.Sh RETURN VALUES
51.Fn strpct 52.Fn strpct
52always returns a pointer to a NUL-terminated formatted string which 53always returns a pointer to a NUL-terminated formatted string which
53is placed in 54is placed in
54.Fa buf 55.Fa buf
55and is up to 56and is up to
56.Fa buflen 57.Fa buflen
57characters. 58characters.
58If there was an overflow, the formatted string will reflect that precision 59If there was an overflow, the formatted string will reflect that precision
59loss. 60loss.
60.Sh EXAMPLES 61.Sh EXAMPLES
61.Bd -literal -offset indent 62.Bd -literal -offset indent
62strpct(buf, buflen, 1, 16, 3); 63strpct(buf, buflen, 1, 16, 3);
63\(rA "6.250" 64\(rA "6.250"
64strpct(buf, buflen, 1, 2, 0); 65strpct(buf, buflen, 1, 2, 0);
65\(rA "50" 66\(rA "50"
66.Ed 67.Ed
67.Sh HISTORY 68.Sh HISTORY
68.Fn strpct 69.Fn strpct
69was originally implemented in 70was originally implemented in
70.Xr csh 1 . 71.Xr csh 1
 72for
 73.Nx 1.3 .
71It printed into a static buffer, was not locale aware, handled 74It printed into a static buffer, was not locale aware, handled
72.Ft unsigned long 75.Ft unsigned long
73numbers, and printed a 76numbers, and printed a
74.Dq % 77.Dq %
75at the end of the number. 78at the end of the number.
76Other programs such as 79Other programs such as
77.Xr df 1 80.Xr df 1
78and 81and
79.Xr time 1 82.Xr time 1
80started using it. 83started using it.
81.Fn strpct 84.Fn strpct
82appeared in 85appeared separately in libutil for
83.Nx 6.0 . 86.Nx 6.0 .
 87.Sh AUTHORS
 88.An Erik E. Fair Aq fair@netbsd.org