🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.bugs.4bsd
Article #1620

Re: Nasty 4.3 change to cc(1)

#1620
From: Chris Torek
Date: Wed, 06 Aug 1986 00:43
46 lines
2065 bytes
In article <377@curly.ucla-cs.ARPA>, das@LOCUS.UCLA.EDU writes:
>... Under 4.3,
> 	cc -c -o blah blah.c
>produces one object file, named blah, not blah.o!!!! ... I think
>the change is a mistake, since it breaks existing software and
>there's no compelling reason I can see to prefer the new meaning
>of -o over the old.  Justifications?

I have no real idea why the change was installed; most likely
Berkeley got a request for it and saw no good reason *not* to
implement it.  I remember a few years ago being surprised that
`cc -c -o x.o c.c' did not work this way.  It is, however, trivial
to change it back.  In /usr/src/bin/cc.c, find the four lines

		if (cflag && nc==1 && outfile)
			av[2] = outfile;
		else
			av[2] = setsuf(clist[i], 'o');

and remove the first three.

Alternatively, use a shell script to filter out `-o' whenever there
is at least one `-c':

#! /bin/sh
#
# cc - front end for /bin/cc to remove `extra' -o arguments (untested).
#
# Could use some speed improvement.  Note that this does not handle
# whitespace in file names properly.
#
realcc=/bin/cc
fullargs=; nooargs=; cflag=false; noo=true
for i do
	case "$i" in
	-c)	cflag=true; nooargs="$nooargs $i"; noo=true;;
	-o)	noo=false;;
	*)	if $noo; then nooargs="$nooargs $i"; fi; noo=true;;
	esac
	fullargs="$fullargs $i"
done
if $cflag; then exec $realcc $nooargs; else exec $realcc $fullargs; fi
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@mimsy.umd.edu
Technical Details
Message-ID: <2743@umcp-cs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!umcp-cs!chris
References: <377@curly.ucla-cs.ARPA>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!umcp-cs!chris
From: chris@umcp-cs.UUCP (Chris Torek)
Newsgroups: net.bugs.4bsd
Subject: Re: Nasty 4.3 change to cc(1)
Message-ID: <2743@umcp-cs.UUCP>
Date: Tue, 5-Aug-86 20:43:39 EDT
Article-I.D.: umcp-cs.2743
Posted: Tue Aug  5 20:43:39 1986
Date-Received: Wed, 6-Aug-86 02:45:40 EDT
References: <377@curly.ucla-cs.ARPA>
Organization: Computer Sci. Dept, U of Maryland, College Park, MD
Lines: 46