projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
BSD 4_4 release
[unix-history]
/
usr
/
src
/
old
/
pcc
/
cc
/
cc.c
diff --git
a/usr/src/old/pcc/cc/cc.c
b/usr/src/old/pcc/cc/cc.c
index
dff3081
..
7666319
100644
(file)
--- a/
usr/src/old/pcc/cc/cc.c
+++ b/
usr/src/old/pcc/cc/cc.c
@@
-1,29
+1,30
@@
-/* USE <wait.h> */
-static char sccsid[] = "@(#)cc.c 3.3 %G%";
+static char sccsid[] = "@(#)cc.c 4.21 6/30/90";
/*
* cc - front end for C compiler
*/
/*
* cc - front end for C compiler
*/
-#include <sys/
types
.h>
+#include <sys/
param
.h>
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
-#include <dir.h>
+#include <sys/dir.h>
+#include "pathnames.h"
-char *cpp = "/usr/new/cpp";
-char *ccom = "/usr/new/ccom";
-char *c2 = "/usr/new/c2";
-char *as = "/usr/new/as";
-char *ld = "/usr/new/ld";
-char *crt0 = "/usr/new/crt0.o";
+char *cpp = _PATH_CPP;
+char *ccom = _PATH_CCOM;
+char *sccom = _PATH_SCCOM;
+char *c2 = _PATH_C2;
+char *as = _PATH_AS;
+char *ld = _PATH_LD;
+char *crt0 = _PATH_CRT0;
-char tmp0[
30]; /* big enough for /tmp/ctm%05.5d */
+char tmp0[
MAXPATHLEN];
char *tmp1, *tmp2, *tmp3, *tmp4, *tmp5;
char *outfile;
char *savestr(), *strspl(), *setsuf();
int idexit();
char **av, **clist, **llist, **plist;
char *tmp1, *tmp2, *tmp3, *tmp4, *tmp5;
char *outfile;
char *savestr(), *strspl(), *setsuf();
int idexit();
char **av, **clist, **llist, **plist;
-int cflag, eflag,
gflag,
oflag, pflag, sflag, wflag, Rflag, exflag, proflag;
-int
cps8
;
+int cflag, eflag, oflag, pflag, sflag, wflag, Rflag, exflag, proflag;
+int
fflag, gflag, Gflag, Mflag, debug
;
char *dflag;
int exfail;
char *chpass;
char *dflag;
int exfail;
char *chpass;
@@
-48,15
+49,6
@@
main(argc, argv)
for (i = 1; i < argc; i++) {
if (*argv[i] == '-') switch (argv[i][1]) {
for (i = 1; i < argc; i++) {
if (*argv[i] == '-') switch (argv[i][1]) {
- case '8':
- cps8++;
- cpp = "/usr/bin/8cpp";
- ccom = "/usr/lib/8ccom";
- c2 = "/usr/bin/8c2";
- as = "/usr/bin/8as";
- ld = "/usr/bin/8ld";
- crt0 = "/usr/lib/8crt0";
- continue;
case 'S':
sflag++;
cflag++;
case 'S':
sflag++;
cflag++;
@@
-67,7
+59,6
@@
main(argc, argv)
switch (getsuf(outfile)) {
case 'c':
switch (getsuf(outfile)) {
case 'c':
- case 'o':
error("-o would overwrite %s",
outfile);
exit(8);
error("-o would overwrite %s",
outfile);
exit(8);
@@
-82,9
+73,19
@@
main(argc, argv)
continue;
case 'p':
proflag++;
continue;
case 'p':
proflag++;
+ crt0 = _PATH_MCRT0;
+ if (argv[i][2] == 'g')
+ crt0 = _PATH_GCRT0;
+ continue;
+ case 'f':
+ fflag++;
continue;
case 'g':
continue;
case 'g':
- gflag++;
+ if (argv[i][2] == 'o') {
+ Gflag++; /* old format for -go */
+ } else {
+ gflag++; /* new format for -g */
+ }
continue;
case 'w':
wflag++;
continue;
case 'w':
wflag++;
@@
-100,12
+101,20
@@
main(argc, argv)
case 'c':
cflag++;
continue;
case 'c':
cflag++;
continue;
+ case 'M':
+ exflag++;
+ pflag++;
+ Mflag++;
+ /* and fall through */
case 'D':
case 'I':
case 'U':
case 'C':
plist[np++] = argv[i];
continue;
case 'D':
case 'I':
case 'U':
case 'C':
plist[np++] = argv[i];
continue;
+ case 'L':
+ llist[nl++] = argv[i];
+ continue;
case 't':
if (chpass)
error("-t overwrites earlier option", 0);
case 't':
if (chpass)
error("-t overwrites earlier option", 0);
@@
-118,9
+127,13
@@
main(argc, argv)
error("-B overwrites earlier option", 0);
npassname = argv[i]+2;
if (npassname[0]==0)
error("-B overwrites earlier option", 0);
npassname = argv[i]+2;
if (npassname[0]==0)
-
npassname = "/usr/c/o"
;
+
error("-B requires an argument", 0)
;
continue;
case 'd':
continue;
case 'd':
+ if (argv[i][2] == '\0') {
+ debug++;
+ continue;
+ }
dflag = argv[i];
continue;
}
dflag = argv[i];
continue;
}
@@
-136,7
+149,7
@@
main(argc, argv)
nxo++;
}
}
nxo++;
}
}
- if (gflag) {
+ if (gflag
|| Gflag
) {
if (oflag)
fprintf(stderr, "cc: warning: -g disables -O\n");
oflag = 0;
if (oflag)
fprintf(stderr, "cc: warning: -g disables -O\n");
oflag = 0;
@@
-144,13
+157,16
@@
main(argc, argv)
if (npassname && chpass ==0)
chpass = "012p";
if (chpass && npassname==0)
if (npassname && chpass ==0)
chpass = "012p";
if (chpass && npassname==0)
- npassname =
"/usr/new/new"
;
+ npassname =
_PATH_USRNEW
;
if (chpass)
for (t=chpass; *t; t++) {
switch (*t) {
case '0':
if (chpass)
for (t=chpass; *t; t++) {
switch (*t) {
case '0':
- ccom = strspl(npassname, "ccom");
+ if (fflag)
+ sccom = strspl(npassname, "sccom");
+ else
+ ccom = strspl(npassname, "ccom");
continue;
case '2':
c2 = strspl(npassname, "c2");
continue;
case '2':
c2 = strspl(npassname, "c2");
@@
-160,16
+176,16
@@
main(argc, argv)
continue;
}
}
continue;
}
}
- if (proflag)
- crt0 = cps8 ? "/usr/lib/8mcrt0.o" : "/usr/new/mcrt0.o";
if (nc==0)
goto nocom;
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
signal(SIGINT, idexit);
if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
signal(SIGTERM, idexit);
if (nc==0)
goto nocom;
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
signal(SIGINT, idexit);
if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
signal(SIGTERM, idexit);
+ if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
+ signal(SIGHUP, idexit);
if (pflag==0)
if (pflag==0)
-
sprintf(tmp0, "/tmp/ctm%05.5d"
, getpid());
+
(void)sprintf(tmp0, "%s/ctm%05.5d", _PATH_TMP
, getpid());
tmp1 = strspl(tmp0, "1");
tmp2 = strspl(tmp0, "2");
tmp3 = strspl(tmp0, "3");
tmp1 = strspl(tmp0, "1");
tmp2 = strspl(tmp0, "2");
tmp3 = strspl(tmp0, "3");
@@
-178,41
+194,54
@@
main(argc, argv)
if (oflag)
tmp5 = strspl(tmp0, "5");
for (i=0; i<nc; i++) {
if (oflag)
tmp5 = strspl(tmp0, "5");
for (i=0; i<nc; i++) {
- if (nc > 1) {
+ if (nc > 1
&& !Mflag
) {
printf("%s:\n", clist[i]);
fflush(stdout);
}
printf("%s:\n", clist[i]);
fflush(stdout);
}
- if (getsuf(clist[i]) == 's') {
+ if (
!Mflag &&
getsuf(clist[i]) == 's') {
assource = clist[i];
goto assemble;
} else
assource = tmp3;
if (pflag)
tmp4 = setsuf(clist[i], 'i');
assource = clist[i];
goto assemble;
} else
assource = tmp3;
if (pflag)
tmp4 = setsuf(clist[i], 'i');
- av[0] = "cpp"; av[1] = clist[i]; av[2] = exflag ? "-" : tmp4;
- na = 3;
+ av[0] = "cpp"; av[1] = clist[i];
+ na = 2;
+ if (!exflag)
+ av[na++] = tmp4;
for (j = 0; j < np; j++)
av[na++] = plist[j];
av[na++] = 0;
if (callsys(cpp, av)) {
exfail++;
eflag++;
for (j = 0; j < np; j++)
av[na++] = plist[j];
av[na++] = 0;
if (callsys(cpp, av)) {
exfail++;
eflag++;
+ cflag++;
+ continue;
}
}
- if (pflag
|| exfail
) {
+ if (pflag) {
cflag++;
continue;
}
cflag++;
continue;
}
- if (sflag)
- assource = tmp3 = setsuf(clist[i], 's');
- av[0] = "ccom"; av[1] = tmp4; av[2] = oflag?tmp5:tmp3; na = 3;
+ if (sflag) {
+ if (nc==1 && outfile)
+ tmp3 = outfile;
+ else
+ tmp3 = setsuf(clist[i], 's');
+ assource = tmp3;
+ }
+ av[0] = fflag ? "sccom" : "ccom";
+ av[1] = tmp4; av[2] = oflag?tmp5:tmp3; na = 3;
if (proflag)
av[na++] = "-XP";
if (proflag)
av[na++] = "-XP";
- if (gflag)
+ if (gflag)
{
av[na++] = "-Xg";
av[na++] = "-Xg";
+ } else if (Gflag) {
+ av[na++] = "-XG";
+ }
if (wflag)
av[na++] = "-w";
av[na] = 0;
if (wflag)
av[na++] = "-w";
av[na] = 0;
- if (callsys(ccom, av)) {
+ if (callsys(
fflag ? sccom :
ccom, av)) {
cflag++;
eflag++;
continue;
cflag++;
eflag++;
continue;
@@
-229,7
+258,11
@@
main(argc, argv)
continue;
assemble:
cunlink(tmp1); cunlink(tmp2); cunlink(tmp4);
continue;
assemble:
cunlink(tmp1); cunlink(tmp2); cunlink(tmp4);
- av[0] = "as"; av[1] = "-o"; av[2] = setsuf(clist[i], 'o');
+ av[0] = "as"; av[1] = "-o";
+ if (cflag && nc==1 && outfile)
+ av[2] = outfile;
+ else
+ av[2] = setsuf(clist[i], 'o');
na = 3;
if (Rflag)
av[na++] = "-R";
na = 3;
if (Rflag)
av[na++] = "-R";
@@
-253,9
+286,10
@@
nocom:
}
while (i < nl)
av[na++] = llist[i++];
}
while (i < nl)
av[na++] = llist[i++];
- if (gflag)
- av[na++] = "-lg";
- av[na++] = "-lc";
+ if (proflag)
+ av[na++] = "-lc_p";
+ else
+ av[na++] = "-lc";
av[na++] = 0;
eflag |= callsys(ld, av);
if (nc==1 && nxo==1 && eflag==0)
av[na++] = 0;
eflag |= callsys(ld, av);
if (nc==1 && nxo==1 && eflag==0)
@@
-313,7
+347,7
@@
char as[];
else
c++;
s -= 3;
else
c++;
s -= 3;
- if (c <=
DIRSIZ
&& c > 2 && *s++ == '.')
+ if (c <=
MAXNAMLEN
&& c > 2 && *s++ == '.')
return (*s);
return (0);
}
return (*s);
return (0);
}
@@
-336,7
+370,14
@@
callsys(f, v)
char *f, **v;
{
int t, status;
char *f, **v;
{
int t, status;
+ char **cpp;
+ if (debug) {
+ fprintf(stderr, "%s:", f);
+ for (cpp = v; *cpp != 0; cpp++)
+ fprintf(stderr, " %s", *cpp);
+ fprintf(stderr, "\n");
+ }
t = vfork();
if (t == -1) {
printf("No more processes\n");
t = vfork();
if (t == -1) {
printf("No more processes\n");