From 1105f4f278e8e43008d236fc51e77c8ae363fcf6 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Mon, 22 Dec 2008 07:00:01 +0100 Subject: [PATCH] libxbps: add humanize_number. --HG-- extra : convert_revision : 145c77f32b58f9013a677ebac3f8ed030a1c07a9 --- lib/Makefile | 2 +- lib/humanize_number.c | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 31335460969..13f597cec04 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -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) diff --git a/lib/humanize_number.c b/lib/humanize_number.c index 9166b067733..87dde9d1ff4 100644 --- a/lib/humanize_number.c +++ b/lib/humanize_number.c @@ -30,12 +30,6 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#include -#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 #include #include @@ -43,6 +37,13 @@ __RCSID("$NetBSD: humanize_number.c,v 1.14 2008/04/28 20:22:59 martin Exp $"); #include #include +#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 */