History log of /src/lib/libc/gen/humanize_number.c |
Revision | | Date | Author | Comments |
1.19 |
| 20-Jan-2024 |
christos | Catch up with all the lint warnings since exit on warning was disabled. Disable 'missing header declaration' and 'nested extern' warnings for now.
|
1.18 |
| 11-Mar-2019 |
kre | PR lib/54053
When auto scaling, and the buffer is bigger than big enough for the biggest possible number, don't try and calculate the max value that will fit in the buffer - that calc will overflow (guaranteed) and is useless, the value we're formatting cannot possibly be bigger. So simply use the unscaled value (the raw number).
While here, also avoid returning values that are larger than the buffer len ... while it would be nice to be able to find out how big the buffer should be so the data will fit, the interface doesn't really allow that (the buffer length passed in controls the scaling - at least when auto scaling) and the code already does "return -1" when it detects the buffer length is too small, even before it works out how much would have been needed. So, rather than returning a value > len (while truncating the result to fit in len ... all courtesy of snprintf()) return -1 in this case as well.
Also, allow suffix==NULL (meaning "") - there's no reason not to, and requiring users to pass in an explicit "" is not useful.
|
1.17 |
| 13-Apr-2017 |
christos | branches: 1.17.12; Fix out of bounds read for very large numbers (pointed out by Brooks Davis) https://svnweb.freebsd.org/changeset/base/316766
|
1.16 |
| 17-Mar-2012 |
christos | branches: 1.16.14; 1.16.18; PR/44097: Yamamoto Takashi: Prevent overflow.
|
1.15 |
| 13-Mar-2012 |
christos | PR/45989: Martin Husemann: lint invocation does include -w only on i386
- turn lint -w for all the platforms after fixing the lint warnings. - add _DIAGASSERTS() for casts that would assign values to types that would not fit. - change types, add casts - change into ansii prototypes - turn on _DIAGNOSTIC for libc (during current, to be eliminated for release builds)
approved by core@
|
1.14 |
| 28-Apr-2008 |
martin | branches: 1.14.4; 1.14.8; 1.14.24; Remove clause 3 and 4 from TNF licenses
|
1.13 |
| 14-Dec-2007 |
christos | branches: 1.13.4; - add dehumanize_number - decls for humanize_number and dehumanize_number are in stdlib.h
|
1.12 |
| 13-Mar-2007 |
enami | branches: 1.12.4; Fix a bug that humanize_number() produces "1000" where it should be "1.0G" or "1.0M". The bug reported by Greg Troxel.
|
1.11 |
| 08-Jun-2006 |
simonb | branches: 1.11.4; 1.11.6; Use PRId64 instead of a cast to long long and %lld to print an int64_t.
|
1.10 |
| 13-Sep-2005 |
christos | compat core reorg.
|
1.9 |
| 09-Feb-2005 |
kleink | A little libc namespace housekeeping exercise: * Make vfprintf_unlocked() an internal function, c.f. __svfscanf_unlocked(). * Add internal names for arc4random(), endnetpath(), fhstatvfs(), fstatvfs(), mkstemp(), shquote(), statvfs(), taddr2uaddr(), uaddr2taddr(), uuid_create_nil(), uuid_is_nil(), and wcwidth(). * Include namespace.h where supposed to.
|
1.8 |
| 27-Jul-2004 |
enami | - Honor the HN_NOSPACE flag (i.e., don't put a space if specified, and put space if not specified). - There was a test which didn't count the suffixlen. Fix it. - Make the code a bit easier to read.
|
1.7 |
| 12-Jul-2004 |
enami | Print 10450000 as 10M instead of 10.0M (more greater value such as 10500000 is printed as 10M).
|
1.6 |
| 12-Jul-2004 |
enami | No need to set divisor twice.
|
1.5 |
| 26-Dec-2003 |
simonb | Don't ever add a ".0" to a single digit number.
XXX: Should (for example) 1024 be 1.0K or 1K when the HN_DECIMAL flag is passed? Should there be a separate option that says "use the HN_DECIMAL behaviour unless we are exactly equal to the suffix"?
|
1.4 |
| 11-Nov-2002 |
thorpej | Fix signed/unsigned comparison warnings.
|
1.3 |
| 27-Sep-2002 |
drochner | SI prefixes apply to decimal multiplies only. For binary (2^n) multiplies the most "officially looking" is IEC 60027-2, ie "Ki", "Mi", ..., which is not too popular, and which would require more code changes. So stick with the traditional capital "K" for (divisor==1024), and use the SI "k" otherwise (ie (divisor==1000)).
|
1.2 |
| 26-Sep-2002 |
wiz | Kilo abbreviation is a small k (PR 18408).
|
1.1 |
| 22-Aug-2002 |
abs | branches: 1.1.2; Move humanize_number(3) from libutil to libc as per discussion on tech-misc Revert minor number bump on libutil (with note to skip it next update), and bump libc.
|
1.1.2.4 |
| 10-Dec-2002 |
thorpej | Sync with HEAD.
|
1.1.2.3 |
| 18-Oct-2002 |
nathanw | Catch up to -current.
|
1.1.2.2 |
| 27-Aug-2002 |
nathanw | Catch up to -current.
|
1.1.2.1 |
| 22-Aug-2002 |
nathanw | file humanize_number.c was added on branch nathanw_sa on 2002-08-27 23:49:31 +0000
|
1.11.6.1 |
| 06-Jan-2008 |
wrstuden | Catch up to netbsd-4.0 release.
|
1.11.4.1 |
| 25-Nov-2007 |
xtraeme | Pull up following revision(s) (requested by simonb in ticket #992): lib/libc/gen/humanize_number.c: revision 1.12 Fix a bug that humanize_number() produces "1000" where it should be "1.0G" or "1.0M". The bug reported by Greg Troxel.
|
1.12.4.1 |
| 09-Jan-2008 |
matt | sync with HEAD
|
1.13.4.1 |
| 18-May-2008 |
yamt | sync with head.
|
1.14.24.1 |
| 19-Mar-2012 |
riz | Pull up following revision(s) (requested by dholland in ticket #129): lib/libc/gen/humanize_number.c: revision 1.16 PR/44097: Yamamoto Takashi: Prevent overflow.
|
1.14.8.2 |
| 28-Apr-2008 |
martin | Remove clause 3 and 4 from TNF licenses
|
1.14.8.1 |
| 28-Apr-2008 |
martin | file humanize_number.c was added on branch christos-time_t on 2008-04-28 20:23:00 +0000
|
1.14.4.1 |
| 17-Apr-2012 |
yamt | sync with head
|
1.16.18.1 |
| 21-Apr-2017 |
bouyer | Sync with HEAD
|
1.16.14.1 |
| 26-Apr-2017 |
pgoyette | Sync with HEAD
|
1.17.12.1 |
| 10-Jun-2019 |
christos | Sync with HEAD
|