Commit graph

19 commits

Author SHA1 Message Date
Warner Losh b2c76c41be Remove $FreeBSD$: one-line nroff pattern
Remove /^\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:15 -06:00
Gordon Bergling 816ca3d10f libutil: Fix mandoc warnings
- missing comma before name
- possible typo in section name: Sh CAVEAT instead of CAVEATS
- useless macro: Tn
- blank line in fill mode, using .sp
- no blank before trailing delimiter: Dv NULL?

MFC after:	3 days
2022-08-07 16:30:24 +02:00
Bartek Rutkowski e285e32e56 humanize_number(3): fix math edge case in rounding large numbers
Fix for remainder overflow, when in rare cases adding remainder to divider
exceeded 1 and turned the total to 1000 in final formatting, taking up
the space for the unit character.

The fix continues the division of the original number if the above case
happens -- added the appropriate check to the for loop performing
the division. This lowers the value shown, to make it fit into the buffer
space provided (1.0M for 4+1 character buffer, as used by ls).

Add test case for the reported bug and extend test program to support
providing buffer length (ls -lh uses 5, tests hard-coded 4).

PR:		224498
Submitted by:	Pawel Biernacki <pawel.biernacki@gmail.com>
Reported by:	Masachika Ishizuka <ish@amail.plala.or.jp>
Reviewed by:	cem, kib
Approved by:	cem, kib
MFC after:	1 week
Sponsored by:	Mysterious Code Ltd.
Differential Revision:	D13578
2017-12-28 22:57:34 +00:00
John-Mark Gurney 44f01c419d don't assert on bad args, instead return an error..
Since so many programs don't check return value, always NUL terminate
the buf...

fix rounding when using base 1024 (the bug that started it all)...

add a set of test cases so we can make sure that things don't break
in the future...

Thanks to Clifton Royston for testing and the test program...

Approved by:	re (hrs, glebius)
MFC after:	1 week
2013-10-07 22:22:57 +00:00
Xin LI 7d14df1a2d Add support for IEE/IEC (and now also SI) power of two notions of
prefixes (Ki, Mi, Gi...) for humanize_number(3).

Note that applications has to pass HN_IEC_PREFIXES to use this
feature for backward compatibility reasons.

Reviewed by:	arundel
MFC after:	2 weeks
2011-04-12 22:48:03 +00:00
Glen Barber 5f2e9efbf9 s/buffer/buf as is used in the code.
Submitted by:	arundel (via doc@)
MFC after:	3 days
2011-03-21 23:59:20 +00:00
Joel Dahl f20b6c8575 The NetBSD Foundation has granted permission to remove clause 3 and 4 from
their software.

Obtained from:	NetBSD
2010-03-02 17:06:40 +00:00
David E. O'Brien 61881b5283 Adjust history.
Approved by:	re(ken)
2007-09-28 15:31:44 +00:00
Pawel Jakub Dawidek c2fc8cebdd Point expand_number(3) at humanize_number(3) and nive versa.
Suggested by:	trhodes
Approved by:	re (kensmith)
2007-09-05 14:25:16 +00:00
Ruslan Ermilov a73a3ab56b Markup fixes. 2006-09-17 21:27:35 +00:00
Warner Losh d5fbc8f429 Note the convention that humanize_number follows.
Add 'engineering' numbers to table.
2006-07-15 20:53:36 +00:00
Xin LI 13c273c81a Remove duplicated "bytes".
Submitted by:	Wojciech A. Koszek [dunstan freebsd czest pl]
PR:		79747
2005-04-10 12:15:25 +00:00
Pawel Jakub Dawidek 69560edc13 Backout manual page updates.
Requested by:	ru
2004-09-26 12:08:31 +00:00
Pawel Jakub Dawidek bd52c9ac59 Take the lastest fixes from NetBSD.
Obtained from:	NetBSD
2004-09-25 14:11:34 +00:00
Pawel Jakub Dawidek 8914c29937 There is no such manual page in FreeBSD. 2004-09-16 18:32:58 +00:00
Ruslan Ermilov fd13236829 Markup fixes. 2004-07-07 20:25:54 +00:00
Pawel Jakub Dawidek e27d191348 Humanize_number(3) is a part of libutil. 2004-05-25 20:11:50 +00:00
Tom Rhodes d268591bf7 You want to include libutil.h, not util.h.
Some minor sentence tweaking.
2004-05-25 18:53:54 +00:00
Pawel Jakub Dawidek 23d1a17825 Add humanize_number(3) to libutil for formating numbers into a human
readable form.

Obtained from:	NetBSD
2004-05-24 22:19:27 +00:00