From 351910f1b9f20d28e66d9364a92b1d283ce90b50 Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 28 Jan 1997 07:12:25 +0000 Subject: [PATCH] for total use -t; tsarna@endicor.com --- usr.bin/size/size.1 | 6 +++++- usr.bin/size/size.c | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/usr.bin/size/size.1 b/usr.bin/size/size.1 index 1086a0447f7..2db69a3f0d9 100644 --- a/usr.bin/size/size.1 +++ b/usr.bin/size/size.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: size.1,v 1.3 1996/06/26 05:39:17 deraadt Exp $ +.\" $OpenBSD: size.1,v 1.4 1997/01/28 07:12:25 deraadt Exp $ .\" $NetBSD: size.1,v 1.6 1996/01/14 23:07:11 pk Exp $ .\" .\" Copyright (c) 1990, 1993, 1994 @@ -42,6 +42,7 @@ .Nd display object file segment sizes (text, data and bss) .Sh SYNOPSIS .Nm size +.Op Fl t .Op Fl w .Ar .Sh DESCRIPTION @@ -60,6 +61,9 @@ is specified attempts to report on the file .Pa a.out . .Bl -tag -width flag +.It Fl t +At the end of the output print a total of the +sizes of all the object files processed. .It Fl w Warn about non-object archive members. Normally, diff --git a/usr.bin/size/size.c b/usr.bin/size/size.c index 0704f6bcb8b..70a5fab3e16 100644 --- a/usr.bin/size/size.c +++ b/usr.bin/size/size.c @@ -1,4 +1,4 @@ -/* $OpenBSD: size.c,v 1.5 1997/01/15 23:43:13 millert Exp $ */ +/* $OpenBSD: size.c,v 1.6 1997/01/28 07:12:27 deraadt Exp $ */ /* $NetBSD: size.c,v 1.7 1996/01/14 23:07:12 pk Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)size.c 8.2 (Berkeley) 12/9/93"; #endif -static char rcsid[] = "$OpenBSD: size.c,v 1.5 1997/01/15 23:43:13 millert Exp $"; +static char rcsid[] = "$OpenBSD: size.c,v 1.6 1997/01/28 07:12:27 deraadt Exp $"; #endif /* not lint */ #include @@ -57,7 +57,9 @@ static char rcsid[] = "$OpenBSD: size.c,v 1.5 1997/01/15 23:43:13 millert Exp $" #include #include +unsigned long total_text, total_data, total_bss, total_total; int ignore_bad_archive_entries = 1; +int print_totals = 0; int process_file __P((int, char *)); int show_archive __P((int, char *, FILE *)); @@ -73,11 +75,14 @@ main(argc, argv) { int ch, eval; - while ((ch = getopt(argc, argv, "w")) != -1) + while ((ch = getopt(argc, argv, "wt")) != -1) switch(ch) { case 'w': ignore_bad_archive_entries = 0; break; + case 't': + print_totals = 1; + break; case '?': default: usage(); @@ -92,6 +97,11 @@ main(argc, argv) } while (*++argv); else eval |= process_file(1, "a.out"); + + if (print_totals) + (void)printf("\n%lu\t%lu\t%lu\t%lu\t%lx\tTOTAL\n", + total_text, total_data, total_bss, + total_total, total_total); exit(eval); } @@ -109,7 +119,7 @@ process_file(count, fname) FILE *fp; int retval; char magic[SARMAG]; - + if (!(fp = fopen(fname, "r"))) { warnx("cannot read %s", fname); return(1); @@ -293,6 +303,12 @@ show_objfile(count, name, fp) head.a_bss, total, total); if (count > 1) (void)printf("\t%s", name); + + total_text += head.a_text; + total_data += head.a_data; + total_bss += head.a_bss; + total_total += total; + (void)printf("\n"); return (0); } -- 2.20.1