Commit graph

9 commits

Author SHA1 Message Date
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Xin LI 08300d8494 expand_number: Tighten check of unit.
The current code silently ignores characters after the unit as long
the unit themselves were recognized. This commit makes expand_number(3)
to fail with EINVAL if buf did not terminate after the unit character.

Historically, the function accepts and ignores "B" as a SI unit, this
behavior is preserved and e.g. KB, MB are still accepted as aliases of
K and M, document this behavior in the manual page.

While I am there, also write a few test cases to validate the behavior.

Reviewed-by:	emaste
MFC-after:	2 weeks
Differential Revision: https://reviews.freebsd.org/D40482
2023-06-12 21:08:32 -07:00
John Baldwin 72a52ef8c4 expand_number(3) parses suffixes, not prefixes.
While here, tidy the opening sentence a bit.

MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D20791
2019-07-20 16:03:54 +00:00
Eitan Adler 69b2d025a0 Indicate that expand_number is case-insensitive.
Reviewed by:	-scsi
2013-11-12 00:56:22 +00:00
Dag-Erling Smørgrav a2e0c5ae31 Further simplify the code, and update the manpage.
Submitted by:	Christoph Mallon <christoph.mallon@gmx.de>
2010-08-15 18:32:06 +00:00
John Birrell 26fc37307b Constify the first argument to expand_number() so that it can
be called with a const without the compiler grisling.
2007-11-18 02:20:02 +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
Pawel Jakub Dawidek bd35b57de2 Implement expand_number(3), which is the opposite of humanize_number(3), ie.
a number in human-readable form is converted to int64_t, for example:
123b -> 123
10k -> 10240
16G -> 17179869184

First version submitted by:	Eric Anderson <anderson@freebsd.org>
Approved by:	re (bmah)
2007-09-01 06:19:11 +00:00