mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-02 09:40:15 +00:00
qprefix/bprefix: use uintmax_t for decimal
This commit is contained in:
parent
3b9232217e
commit
eb72a4612d
2
NEWS.md
2
NEWS.md
@ -21,6 +21,8 @@ rearrangements of Notcurses.
|
||||
its third argument. This is the absolute time viz `CLOCK_MONOTONIC` through
|
||||
which the frame ought be displayed. The callback must now effect delay.
|
||||
* Mouse coordinates are now properly translated for any margins.
|
||||
* `qprefix()` and `bprefix()` now take a `uintmax_t` in place of an
|
||||
`unsigned`, to match `ncprefix`.
|
||||
|
||||
* 1.4.1 (2020-05-11)
|
||||
* No user-visible changes (fixed two unit tests).
|
||||
|
@ -61,17 +61,17 @@ namespace ncpp
|
||||
return *_instance == nullptr || _instance->nc == nullptr;
|
||||
}
|
||||
|
||||
static const char* ncmetric (uintmax_t val, unsigned decimal, char *buf, int omitdec, unsigned mult, int uprefix) noexcept
|
||||
static const char* ncmetric (uintmax_t val, uintmax_t decimal, char *buf, int omitdec, unsigned mult, int uprefix) noexcept
|
||||
{
|
||||
return ::ncmetric (val, decimal, buf, omitdec, mult, uprefix);
|
||||
}
|
||||
|
||||
static const char* qprefix (uintmax_t val, unsigned decimal, char *buf, int omitdec) noexcept
|
||||
static const char* qprefix (uintmax_t val, uintmax_t decimal, char *buf, int omitdec) noexcept
|
||||
{
|
||||
return ::qprefix (val, decimal, buf, omitdec);
|
||||
}
|
||||
|
||||
static const char* bprefix (uintmax_t val, unsigned decimal, char *buf, int omitdec) noexcept
|
||||
static const char* bprefix (uintmax_t val, uintmax_t decimal, char *buf, int omitdec) noexcept
|
||||
{
|
||||
return ::bprefix (val, decimal, buf, omitdec);
|
||||
}
|
||||
|
@ -2387,13 +2387,13 @@ API const char* ncmetric(uintmax_t val, uintmax_t decimal, char* buf,
|
||||
|
||||
// Mega, kilo, gigafoo. Use PREFIXSTRLEN + 1.
|
||||
static inline const char*
|
||||
qprefix(uintmax_t val, unsigned decimal, char* buf, int omitdec){
|
||||
qprefix(uintmax_t val, uintmax_t decimal, char* buf, int omitdec){
|
||||
return ncmetric(val, decimal, buf, omitdec, 1000, '\0');
|
||||
}
|
||||
|
||||
// Mibi, kebi, gibibytes. Use BPREFIXSTRLEN + 1.
|
||||
static inline const char*
|
||||
bprefix(uintmax_t val, unsigned decimal, char* buf, int omitdec){
|
||||
bprefix(uintmax_t val, uintmax_t decimal, char* buf, int omitdec){
|
||||
return ncmetric(val, decimal, buf, omitdec, 1024, 'i');
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,7 @@
|
||||
#include "notcurses/notcurses.h"
|
||||
|
||||
const char *ncmetric(uintmax_t val, uintmax_t decimal, char *buf, int omitdec,
|
||||
unsigned mul, int uprefix){
|
||||
const unsigned mult = mul; // FIXME kill
|
||||
unsigned mult, int uprefix){
|
||||
// these two must have the same number of elements
|
||||
const wchar_t prefixes[] = L"KMGTPEZY"; // 10^21-1 encompasses 2^64-1
|
||||
const wchar_t subprefixes[] = L"mµnpfazy"; // 10^24-1
|
||||
|
Loading…
Reference in New Issue
Block a user