Article View: mod.computers.gould
Article #5size(1) was broken
From: "David G. Rossiter"
Date: Wed, 20 Nov 1985 21:23
Date: Wed, 20 Nov 1985 21:23
80 lines
2054 bytes
2054 bytes
Reference:/usr/src/bin/size/size.c
Problem:
The size(1) command didn't work right: it always returned an error status of -1.
Solution:
Here's the context diff:
*** size.c.old Wed Nov 20 16:15:28 1985
--- size.c Wed Nov 20 15:52:37 1985
***************
*** 4,9 ****
--- 4,11 ----
* size
*/
+ /* return the correct status on exit -- dgr cucs 19851120 */
+
#include <stdio.h>
#include <a.out.h>
***************
*** 15,20 ****
--- 17,23 ----
struct exec buf;
long sum;
int gorp,i;
+ int err = 0;
FILE *f;
if (argc==1) {
***************
*** 27,32 ****
--- 30,36 ----
++argv;
if ((f = fopen(*argv, "r"))==NULL) {
printf("size: %s not found\n", *argv);
+ err++;
continue;
}
if (fread((char *)&buf, sizeof(buf), 1, f) != 1 ||
***************
*** 33,38 ****
--- 37,43 ----
N_BADMAG(buf)) {
printf("size: %s not an object file\n", *argv);
fclose(f);
+ err++;
continue;
}
if (header == 0) {
***************
*** 47,50 ****
--- 52,56 ----
printf("\n");
fclose(f);
}
+ exit(err);
}
------- and here's an ed(1) script to effect the change:
49a
exit(err);
.
35a
err++;
.
29a
err++;
.
17a
int err = 0;
.
6a
/* return the correct status on exit -- dgr cucs 19851120 */
.
------- then 'make all ; make install' in /usr/src/bin/size
Technical Details
Message-ID:
<8511202123.AA03386@gvax.cs.cornell.edu>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!ucbvax!gouldbugsShow Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site ucbvax.BERKELEY.EDU
Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!ucbvax!gouldbugs
From: rossiter@GVAX.CS.CORNELL.EDU ("David G. Rossiter")
Newsgroups: mod.computers.gould
Subject: size(1) was broken
Message-ID: <8511202123.AA03386@gvax.cs.cornell.edu>
Date: Wed, 20-Nov-85 16:23:43 EST
Article-I.D.: gvax.8511202123.AA03386
Posted: Wed Nov 20 16:23:43 1985
Date-Received: Mon, 25-Nov-85 07:35:41 EST
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The ARPA Internet
Lines: 80
Approved: gouldbugs@brl.arpa