Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/modstat fix output format for long module name.
details: https://anonhg.NetBSD.org/src/rev/08377c86eefe
branches: trunk
changeset: 765711:08377c86eefe
user: nonaka <nonaka%NetBSD.org@localhost>
date: Fri Jun 03 15:34:46 2011 +0000
description:
fix output format for long module name.
diffstat:
sbin/modstat/main.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diffs (55 lines):
diff -r ef810b32f1d8 -r 08377c86eefe sbin/modstat/main.c
--- a/sbin/modstat/main.c Fri Jun 03 13:31:25 2011 +0000
+++ b/sbin/modstat/main.c Fri Jun 03 15:34:46 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.11 2010/12/13 20:48:45 pooka Exp $ */
+/* $NetBSD: main.c,v 1.12 2011/06/03 15:34:46 nonaka Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.11 2010/12/13 20:48:45 pooka Exp $");
+__RCSID("$NetBSD: main.c,v 1.12 2011/06/03 15:34:46 nonaka Exp $");
#endif /* !lint */
#include <sys/module.h>
@@ -71,6 +71,7 @@
const char *name;
char sbuf[32];
int ch;
+ size_t maxnamelen = 16, i;
name = NULL;
@@ -106,10 +107,15 @@
len = iov.iov_len;
}
- printf("%-16s %-10s %-10s %-5s %-8s %s\n",
- "NAME", "CLASS", "SOURCE", "REFS", "SIZE", "REQUIRES");
len = iov.iov_len / sizeof(modstat_t);
qsort(iov.iov_base, len, sizeof(modstat_t), modstatcmp);
+ for (i = 0, ms = iov.iov_base; i < len; i++, ms++) {
+ size_t namelen = strlen(ms->ms_name);
+ if (maxnamelen < namelen)
+ maxnamelen = namelen;
+ }
+ printf("%-*s %-10s %-10s %-5s %-8s %s\n",
+ maxnamelen, "NAME", "CLASS", "SOURCE", "REFS", "SIZE", "REQUIRES");
for (ms = iov.iov_base; len != 0; ms++, len--) {
const char *class;
const char *source;
@@ -136,8 +142,8 @@
else
source = "UNKNOWN";
- printf("%-16s %-10s %-10s %-5d %-8s %s\n",
- ms->ms_name, class, source, ms->ms_refcnt, sbuf,
+ printf("%-*s %-10s %-10s %-5d %-8s %s\n",
+ maxnamelen, ms->ms_name, class, source, ms->ms_refcnt, sbuf,
ms->ms_required);
}
Home |
Main Index |
Thread Index |
Old Index