Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libutil Do not assume int64_t is printable with %qd - on...



details:   https://anonhg.NetBSD.org/src/rev/bfb0feec0205
branches:  trunk
changeset: 535217:bfb0feec0205
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Aug 12 09:06:59 2002 +0000

description:
Do not assume int64_t is printable with %qd - on 64 bit ports it isn't.
Use %lld instead and cast the args to (long long) explicitly.

I'm not sure about our policy vs. the C99 format string macros in
basesrc - should we use those here?

diffstat:

 lib/libutil/humanize_number.c |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (30 lines):

diff -r d6fa5edf9a04 -r bfb0feec0205 lib/libutil/humanize_number.c
--- a/lib/libutil/humanize_number.c     Mon Aug 12 07:59:31 2002 +0000
+++ b/lib/libutil/humanize_number.c     Mon Aug 12 09:06:59 2002 +0000
@@ -39,7 +39,7 @@
 #ifndef __lint
 __COPYRIGHT("@(#) Copyright (c) 2002\n\
        The NetBSD Foundation, inc. All rights reserved.\n");
-__RCSID("$NetBSD: humanize_number.c,v 1.1 2002/08/08 16:50:39 abs Exp $");
+__RCSID("$NetBSD: humanize_number.c,v 1.2 2002/08/12 09:06:59 martin Exp $");
 #endif /* !__lint */
 
 #include <assert.h>
@@ -117,14 +117,14 @@
                        s1++;
                        s2 = 0;
                }
-               r = snprintf(buf, len, "%qd%s%qd%s%c%s", sign * s1, 
-                   localeconv()->decimal_point, s2,
+               r = snprintf(buf, len, "%lld%s%lld%s%c%s", (long long)(sign * s1), 
+                   localeconv()->decimal_point, (long long)s2,
                    (i == 0 && !(flags & HN_B) ) || flags & HN_NOSPACE ?
                    "" : " ", (i == 0 && (flags & HN_B)) ? 'B' :
                    prefixes[i], suffix);
                
        } else
-       r = snprintf(buf, len, "%qd%s%c%s", sign * ((bytes + 50) / 100), 
+       r = snprintf(buf, len, "%lld%s%c%s", (long long)(sign * ((bytes + 50) / 100)), 
            i == 0 || flags & HN_NOSPACE ? "" : " ", (i == 0 &&
            (flags & HN_B)) ? 'B' : prefixes[i], suffix);
 



Home | Main Index | Thread Index | Old Index