Source-Changes-HG archive

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

[src/trunk]: src Cosmetic changes.



details:   https://anonhg.NetBSD.org/src/rev/be734d969c9d
branches:  trunk
changeset: 535335:be734d969c9d
user:      enami <enami%NetBSD.org@localhost>
date:      Thu Aug 15 04:47:12 2002 +0000

description:
Cosmetic changes.

diffstat:

 include/util.h                |  11 ++++++-----
 lib/libutil/humanize_number.c |  40 ++++++++++++++++++++++------------------
 2 files changed, 28 insertions(+), 23 deletions(-)

diffs (144 lines):

diff -r 010a8f84f1e2 -r be734d969c9d include/util.h
--- a/include/util.h    Thu Aug 15 04:22:02 2002 +0000
+++ b/include/util.h    Thu Aug 15 04:47:12 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: util.h,v 1.24 2002/08/08 16:50:35 abs Exp $    */
+/*     $NetBSD: util.h,v 1.25 2002/08/15 04:47:12 enami Exp $  */
 
 /*-
  * Copyright (c) 1995
@@ -34,7 +34,7 @@
  */
 
 #ifndef _UTIL_H_
-#define _UTIL_H_
+#define        _UTIL_H_
 
 #include <sys/cdefs.h>
 #include <sys/ttycom.h>
@@ -46,7 +46,7 @@
 #include <utmpx.h>
 
 #define        PIDLOCK_NONBLOCK        1
-#define PIDLOCK_USEHOSTNAME    2
+#define        PIDLOCK_USEHOSTNAME     2
 
 #define        FPARSELN_UNESCESC       0x01
 #define        FPARSELN_UNESCCONT      0x02
@@ -74,7 +74,8 @@
 const char     *getbootfile(void);
 int            getmaxpartitions(void);
 int            getrawpartition(void);
-int            humanize_number(char *, size_t, int64_t, const char *, int, int);
+int            humanize_number(char *, size_t, int64_t, const char *, int,
+                   int);
 void           login(const struct utmp *);
 void           loginx(const struct utmpx *);
 int            login_tty(int);
@@ -84,7 +85,7 @@
 void           logwtmpx(const char *, const char *, const char *, int, int);
 int            opendisk(const char *, int, char *, size_t, int);
 int            openpty(int *, int *, char *, struct termios *,
-                       struct winsize *);
+                   struct winsize *);
 int            pidfile(const char *);
 int            pidlock(const char *, int, pid_t *, const char *);
 int            pw_abort(void);
diff -r 010a8f84f1e2 -r be734d969c9d lib/libutil/humanize_number.c
--- a/lib/libutil/humanize_number.c     Thu Aug 15 04:22:02 2002 +0000
+++ b/lib/libutil/humanize_number.c     Thu Aug 15 04:47:12 2002 +0000
@@ -1,3 +1,5 @@
+/*     $NetBSD: humanize_number.c,v 1.3 2002/08/15 04:47:13 enami Exp $        */
+
 /*
  * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -39,7 +41,7 @@
 #ifndef __lint
 __COPYRIGHT("@(#) Copyright (c) 2002\n\
        The NetBSD Foundation, inc. All rights reserved.\n");
-__RCSID("$NetBSD: humanize_number.c,v 1.2 2002/08/12 09:06:59 martin Exp $");
+__RCSID("$NetBSD: humanize_number.c,v 1.3 2002/08/15 04:47:13 enami Exp $");
 #endif /* !__lint */
 
 #include <assert.h>
@@ -51,10 +53,10 @@
 
 int
 humanize_number(char *buf, size_t len, int64_t bytes,
-        const char *suffix, int scale, int flags) {
+    const char *suffix, int scale, int flags)
+{
+       static const char prefixes[] = " KMGTPE";
 
-       static const char prefixes[] = " KMGTPE";
-       
        int     i, r;
        int64_t divisor, max, s1, s2, sign;
        size_t  baselen, suffixlen;
@@ -64,10 +66,10 @@
 
        if (scale >= sizeof(prefixes) && scale != HN_AUTOSCALE &&
            scale != HN_GETSCALE)
-               return -1;
+               return (-1);
 
        if (buf == NULL || suffix == NULL)
-               return -1;
+               return (-1);
 
        if (len > 0)
                buf[0] = '\0';
@@ -94,10 +96,10 @@
 
        max = 100;
        for (i = 0; i < len - suffixlen - baselen + ((flags & HN_NOSPACE) ?
-             1 : 0) ; i++)
+           1 : 0); i++)
                max *= 10;
 
-       if ((scale & HN_AUTOSCALE) || (scale & HN_GETSCALE) ) {
+       if ((scale & HN_AUTOSCALE) || (scale & HN_GETSCALE)) {
                for (i = 0; bytes >= max && i < sizeof(prefixes); i++)
                        bytes /= divisor;
        } else {
@@ -106,27 +108,29 @@
        }
 
        if (scale & HN_GETSCALE)
-               return i;
+               return (i);
 
        if (bytes < 1000 && flags & HN_DECIMAL) {
-               if (len < (baselen + 2  + ( (flags & HN_NOSPACE) || (i == 0 &&
+               if (len < (baselen + 2 + ((flags & HN_NOSPACE) || (i == 0 &&
                    !(flags & HN_B)) ? 0 : 1)))
                        return (-1);
                s1 = bytes / 100;
-               if ((s2 = (( (bytes % 100 ) + 5 ) /  10 ) ) == 10 ) {
+               if ((s2 = (((bytes % 100) + 5) / 10)) == 10) {
                        s1++;
                        s2 = 0;
                }
-               r = snprintf(buf, len, "%lld%s%lld%s%c%s", (long long)(sign * s1), 
+               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)) || flags & HN_NOSPACE ?
                    "" : " ", (i == 0 && (flags & HN_B)) ? 'B' :
                    prefixes[i], suffix);
-               
+
        } else
-       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);
+               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);
 
-       return r;
+       return (r);
 }



Home | Main Index | Thread Index | Old Index