libxbps: add humanize_number.
--HG-- extra : convert_revision : 145c77f32b58f9013a677ebac3f8ed030a1c07a9
This commit is contained in:
parent
ce5d9faac3
commit
1105f4f278
2 changed files with 11 additions and 10 deletions
|
@ -11,7 +11,7 @@ LIBXBPS_LDFLAGS = -lprop -shared -Wl,-soname,$(LIBXBPS).$(MAJOR)
|
|||
all: $(LIBXBPS)
|
||||
.PHONY: all
|
||||
|
||||
$(LIBXBPS): sha256.o plist.o
|
||||
$(LIBXBPS): sha256.o plist.o humanize_number.o
|
||||
$(CC) $(LIBXBPS_LDFLAGS) $^ -o $(LIBXBPS_SO)
|
||||
-ln -sf $(LIBXBPS_SO) $(LIBXBPS).$(MAJOR)
|
||||
-ln -sf $(LIBXBPS_SO) $(LIBXBPS)
|
||||
|
|
|
@ -30,12 +30,6 @@
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: humanize_number.c,v 1.14 2008/04/28 20:22:59 martin Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include "namespace.h"
|
||||
#include <assert.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
@ -43,6 +37,13 @@ __RCSID("$NetBSD: humanize_number.c,v 1.14 2008/04/28 20:22:59 martin Exp $");
|
|||
#include <string.h>
|
||||
#include <locale.h>
|
||||
|
||||
#define HN_DECIMAL 0x01
|
||||
#define HN_NOSPACE 0x02
|
||||
#define HN_B 0x04
|
||||
#define HN_DIVISOR_1000 0x08
|
||||
#define HN_GETSCALE 0x10
|
||||
#define HN_AUTOSCALE 0x20
|
||||
|
||||
int
|
||||
humanize_number(char *buf, size_t len, int64_t bytes,
|
||||
const char *suffix, int scale, int flags)
|
||||
|
@ -52,9 +53,9 @@ humanize_number(char *buf, size_t len, int64_t bytes,
|
|||
int64_t divisor, max;
|
||||
size_t baselen;
|
||||
|
||||
_DIAGASSERT(buf != NULL);
|
||||
_DIAGASSERT(suffix != NULL);
|
||||
_DIAGASSERT(scale >= 0);
|
||||
assert(buf != NULL);
|
||||
assert(suffix != NULL);
|
||||
assert(scale >= 0);
|
||||
|
||||
if (flags & HN_DIVISOR_1000) {
|
||||
/* SI for decimal multiplies */
|
||||
|
|
Loading…
Reference in a new issue