Index | Thread | Search

From:
"Ted Unangst" <tedu@tedunangst.com>
Subject:
column alignment in size
To:
tech@openbsd.org
Date:
Sat, 26 Apr 2025 21:09:52 -0400

Download raw body.

Thread
It frustrates me every time I build a kernel and the numbers at the end
are all out of alignment. I don't think we're going to get the kernel
to fit in seven digits, so the next best thing is to make more space.

text    data    bss     dec     hex
17784530        308240  1163264 19256034        125d2e2

text            data    bss     dec             hex
17782862        304448  1163264 19250574        125bd8e

Index: nm.c
===================================================================
RCS file: /home/cvs/src/usr.bin/nm/nm.c,v
diff -u -p -r1.56 nm.c
--- nm.c	21 May 2024 05:00:48 -0000	1.56
+++ nm.c	26 Apr 2025 02:30:22 -0000
@@ -678,12 +678,18 @@ show_file(int count, int warn_fmt, const
 	if (issize) {
 		static int first = 1;
 
+		total = text + data + bss;
 		if (first) {
+			const char *texttabs = "\t";
+			const char *dectabs = "\t";
 			first = 0;
-			printf("text\tdata\tbss\tdec\thex\n");
+			if (text > 9999999)
+				texttabs = "\t\t";
+			if (total > 9999999)
+				dectabs = "\t\t";
+			printf("text%sdata\tbss\tdec%shex\n", texttabs, dectabs);
 		}
 
-		total = text + data + bss;
 		printf("%lu\t%lu\t%lu\t%lu\t%lx",
 		    text, data, bss, total, total);
 		if (count > 1)