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
Bell 32V development
[unix-history]
/
usr
/
src
/
cmd
/
cc.c
diff --git
a/usr/src/cmd/cc.c
b/usr/src/cmd/cc.c
index
017a03c
..
a09c294
100644
(file)
--- a/
usr/src/cmd/cc.c
+++ b/
usr/src/cmd/cc.c
@@
-2,9
+2,9
@@
# include <stdio.h>
# include <ctype.h>
# include <signal.h>
# include <stdio.h>
# include <ctype.h>
# include <signal.h>
+/* C command */
-/* cc command */
-
+# define SBSIZE 10000
# define MAXINC 10
# define MAXFIL 100
# define MAXLIB 100
# define MAXINC 10
# define MAXFIL 100
# define MAXLIB 100
@@
-16,6
+16,7
@@
char *tmp3;
char *tmp4;
char *tmp5;
char *outfile;
char *tmp4;
char *tmp5;
char *outfile;
+char *copy(),*setsuf();
# define CHSPACE 1000
char ts[CHSPACE+50];
char *tsa = ts;
# define CHSPACE 1000
char ts[CHSPACE+50];
char *tsa = ts;
@@
-23,29
+24,27
@@
char *tsp = ts;
char *av[50];
char *clist[MAXFIL];
char *llist[MAXLIB];
char *av[50];
char *clist[MAXFIL];
char *llist[MAXLIB];
+char *alist[20];
+int dflag;
int pflag;
int sflag;
int cflag;
int eflag;
int pflag;
int sflag;
int cflag;
int eflag;
+int gflag;
int exflag;
int oflag;
int proflag;
int noflflag;
int exflag;
int oflag;
int proflag;
int noflflag;
+int exfail;
char *chpass ;
char *npassname ;
char *chpass ;
char *npassname ;
-char pass0[20] = "/lib/c0";
-char pass1[20] = "/lib/c1";
+char pass0[40] = "/lib/ccom";
char pass2[20] = "/lib/c2";
char passp[20] = "/lib/cpp";
char *pref = "/lib/crt0.o";
char pass2[20] = "/lib/c2";
char passp[20] = "/lib/cpp";
char *pref = "/lib/crt0.o";
-char *copy();
-char *setsuf();
-char *strcat();
-char *strcpy();
main(argc, argv)
main(argc, argv)
-char *argv[];
-{
+char *argv[]; {
char *t;
char *savetsp;
char *assource;
char *t;
char *savetsp;
char *assource;
@@
-54,7
+53,6
@@
char *argv[];
int idexit();
i = nc = nl = f20 = nxo = 0;
int idexit();
i = nc = nl = f20 = nxo = 0;
- setbuf(stdout, (char *)NULL);
pv = ptemp;
while(++i < argc) {
if(*argv[i] == '-') switch (argv[i][1]) {
pv = ptemp;
while(++i < argc) {
if(*argv[i] == '-') switch (argv[i][1]) {
@@
-67,7
+65,7
@@
char *argv[];
case 'o':
if (++i < argc) {
outfile = argv[i];
case 'o':
if (++i < argc) {
outfile = argv[i];
- if ((
c=getsuf(outfile))=='c'||c
=='o') {
+ if ((
t=getsuf(outfile))=='c'||t
=='o') {
error("Would overwrite %s", outfile);
exit(8);
}
error("Would overwrite %s", outfile);
exit(8);
}
@@
-79,10
+77,15
@@
char *argv[];
case 'p':
proflag++;
break;
case 'p':
proflag++;
break;
+ case 'g':
+ gflag++;
+ break;
case 'E':
exflag++;
case 'P':
pflag++;
case 'E':
exflag++;
case 'P':
pflag++;
+ if (argv[i][1]=='P')
+ fprintf(stderr, "(Warning): -P option obsolete\n");
*pv++ = argv[i];
case 'c':
cflag++;
*pv++ = argv[i];
case 'c':
cflag++;
@@
-91,9
+94,9
@@
char *argv[];
case 'f':
noflflag++;
if (npassname || chpass)
case 'f':
noflflag++;
if (npassname || chpass)
- error("-f overwrites earlier option",
(char *)NULL
);
+ error("-f overwrites earlier option",
0
);
npassname = "/lib/f";
npassname = "/lib/f";
- chpass = "1";
+ chpass = "1
2
";
break;
case '2':
break;
case '2':
@@
-109,14
+112,15
@@
char *argv[];
case 'U':
case 'C':
*pv++ = argv[i];
case 'U':
case 'C':
*pv++ = argv[i];
- if (pv >= ptemp+MAXOPT) {
- error("Too many DIUC options", (char *)NULL);
+ if (pv >= ptemp+MAXOPT)
+ {
+ error("Too many DIUC options", 0);
--pv;
--pv;
- }
+
}
break;
case 't':
if (chpass)
break;
case 't':
if (chpass)
- error("-t overwrites earlier option",
(char *)NULL
);
+ error("-t overwrites earlier option",
0
);
chpass = argv[i]+2;
if (chpass[0]==0)
chpass = "012p";
chpass = argv[i]+2;
if (chpass[0]==0)
chpass = "012p";
@@
-124,48
+128,53
@@
char *argv[];
case 'B':
if (npassname)
case 'B':
if (npassname)
- error("-B overwrites earlier option",
(char *)NULL
);
+ error("-B overwrites earlier option",
0
);
npassname = argv[i]+2;
if (npassname[0]==0)
npassname = argv[i]+2;
if (npassname[0]==0)
- npassname = "/usr/
src/cmd/
c/o";
+ npassname = "/usr/c/o";
break;
break;
- }
- else {
-passa:
+
+ case 'd':
+ dflag++;
+ strcpyn(alist, argv[i], 19);
+ break;
+ } else {
+ passa:
t = argv[i];
if((c=getsuf(t))=='c' || c=='s'|| exflag) {
clist[nc++] = t;
t = argv[i];
if((c=getsuf(t))=='c' || c=='s'|| exflag) {
clist[nc++] = t;
- if (nc>=MAXFIL) {
- error("Too many source files", (char *)NULL);
+ if (nc>=MAXFIL)
+ {
+ error("Too many source files",0);
exit(1);
exit(1);
- }
+
}
t = setsuf(t, 'o');
}
if (nodup(llist, t)) {
llist[nl++] = t;
t = setsuf(t, 'o');
}
if (nodup(llist, t)) {
llist[nl++] = t;
- if (nl >= MAXLIB) {
- error("Too many object/library files", (char *)NULL);
+ if (nl >= MAXLIB)
+ {
+ error("Too many object/library files",0);
exit(1);
exit(1);
- }
+
}
if (getsuf(t)=='o')
nxo++;
}
}
}
if (getsuf(t)=='o')
nxo++;
}
}
}
+ if (gflag) oflag = 0;
if (npassname && chpass ==0)
chpass = "012p";
if (chpass && npassname==0)
if (npassname && chpass ==0)
chpass = "012p";
if (chpass && npassname==0)
- npassname = "/usr/
src/cmd/
c/";
+ npassname = "/usr/c/";
if (chpass)
if (chpass)
- for (t=chpass; *t; t++) {
- switch (*t) {
+ for (t=chpass; *t; t++)
+ {
+ switch (*t)
+ {
case '0':
strcpy (pass0, npassname);
case '0':
strcpy (pass0, npassname);
- strcat (pass0, "c0");
- continue;
- case '1':
- strcpy (pass1, npassname);
- strcat (pass1, "c1");
+ strcat (pass0, "ccom");
continue;
case '2':
strcpy (pass2, npassname);
continue;
case '2':
strcpy (pass2, npassname);
@@
-185,19
+194,16
@@
passa:
goto nocom;
if (pflag==0) {
tmp0 = copy("/tmp/ctm0a");
goto nocom;
if (pflag==0) {
tmp0 = copy("/tmp/ctm0a");
- while (access(tmp0, 0)==0)
- tmp0[9]++;
- while((creat(tmp0, 0400))<0) {
- if (tmp0[9]=='z') {
- error("cc: cannot create temp", NULL);
- exit(1);
- }
+ while((c=fopen(tmp0, "r")) != NULL) {
+ fclose(c);
tmp0[9]++;
}
tmp0[9]++;
}
+ while((creat(tmp0, 0400))<0)
+ tmp0[9]++;
}
}
- if (signal(SIGINT, SIG_IGN) != SIG_IGN)
+ if (signal(SIGINT, SIG_IGN) != SIG_IGN)
/* interrupt */
signal(SIGINT, idexit);
signal(SIGINT, idexit);
- if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
+ if (signal(SIGTERM, SIG_IGN) != SIG_IGN)
/* terminate */
signal(SIGTERM, idexit);
(tmp1 = copy(tmp0))[8] = '1';
(tmp2 = copy(tmp0))[8] = '2';
signal(SIGTERM, idexit);
(tmp1 = copy(tmp0))[8] = '1';
(tmp2 = copy(tmp0))[8] = '2';
@@
-213,8
+219,7
@@
passa:
if (getsuf(clist[i])=='s') {
assource = clist[i];
goto assemble;
if (getsuf(clist[i])=='s') {
assource = clist[i];
goto assemble;
- }
- else
+ } else
assource = tmp3;
if (pflag)
tmp4 = setsuf(clist[i], 'i');
assource = tmp3;
if (pflag)
tmp4 = setsuf(clist[i], 'i');
@@
-226,41
+231,33
@@
passa:
for(pv=ptemp; pv <pvt; pv++)
av[na++] = *pv;
av[na++]=0;
for(pv=ptemp; pv <pvt; pv++)
av[na++] = *pv;
av[na++]=0;
- if (callsys(passp, av)) {
- cflag++;
- eflag++;
- continue;
- }
- av[1] = tmp4;
+ if (callsys(passp, av))
+ {exfail++; eflag++;}
+ av[1] =tmp4;
tsp = savetsp;
tsp = savetsp;
- av[0]= "c0";
- if (pflag) {
+ av[0]= "ccom";
+ if (pflag || exfail)
+ {
cflag++;
continue;
cflag++;
continue;
- }
- av[2] = tmp1;
- av[3] = tmp2;
+ }
+ if(sflag)
+ assource = tmp3 = setsuf(clist[i], 's');
+ av[2] = tmp3;
+ if(oflag)
+ av[2] = tmp5;
if (proflag) {
if (proflag) {
- av[4] = "-P";
- av[5] = 0;
- }
- else
+ av[3] = "-XP";
av[4] = 0;
av[4] = 0;
- if (callsys(pass0, av)) {
- cflag++;
- eflag++;
- continue;
+ } else
+ av[3] = 0;
+ if (gflag) {
+ int i;
+ i = av[3] ? 4 : 3;
+ av[i++] = "-Xg";
+ av[i] = 0;
}
}
- av[0] = "c1";
- av[1] = tmp1;
- av[2] = tmp2;
- if (sflag)
- assource = tmp3 = setsuf(clist[i], 's');
- av[3] = tmp3;
- if (oflag)
- av[3] = tmp5;
- av[4] = 0;
- if(callsys(pass1, av)) {
+ if (callsys(pass0, av)) {
cflag++;
eflag++;
continue;
cflag++;
eflag++;
continue;
@@
-273,19
+270,21
@@
passa:
if (callsys(pass2, av)) {
unlink(tmp3);
tmp3 = assource = tmp5;
if (callsys(pass2, av)) {
unlink(tmp3);
tmp3 = assource = tmp5;
- }
- else
+ } else
unlink(tmp5);
}
if (sflag)
continue;
unlink(tmp5);
}
if (sflag)
continue;
-assemble:
+
assemble:
av[0] = "as";
av[0] = "as";
- av[1] = "-u";
- av[2] = "-o";
- av[3] = setsuf(clist[i], 'o');
- av[4] = assource;
- av[5] = 0;
+ av[1] = "-o";
+ av[2] = setsuf(clist[i], 'o');
+ av[3] = assource;
+ if (dflag) {
+ av[4] = alist;
+ av[5] = 0;
+ } else
+ av[4] = 0;
cunlink(tmp1);
cunlink(tmp2);
cunlink(tmp4);
cunlink(tmp1);
cunlink(tmp2);
cunlink(tmp4);
@@
-302,20
+301,19
@@
nocom:
av[1] = "-X";
av[2] = pref;
j = 3;
av[1] = "-X";
av[2] = pref;
j = 3;
- if (noflflag) {
- j = 4;
- av[3] = "-lfpsim";
- }
if (outfile) {
av[j++] = "-o";
av[j++] = outfile;
}
while(i<nl)
av[j++] = llist[i++];
if (outfile) {
av[j++] = "-o";
av[j++] = outfile;
}
while(i<nl)
av[j++] = llist[i++];
+ if (gflag)
+ av[j++] = "-lg";
if(f20)
av[j++] = "-l2";
else {
if(f20)
av[j++] = "-l2";
else {
- av[j++] = "-lc";
+ av[j++] = "/lib/libc.a";
+ av[j++] = "-l";
}
av[j++] = 0;
eflag |= callsys("/bin/ld", av);
}
av[j++] = 0;
eflag |= callsys("/bin/ld", av);
@@
-346,10
+344,10
@@
dexit()
}
error(s, x)
}
error(s, x)
-char *s, *x;
{
{
- fprintf(exflag?stderr:stdout, s, x);
+ fprintf(exflag?stderr:stdout
, s, x);
putc('\n', exflag? stderr : stdout);
putc('\n', exflag? stderr : stdout);
+ exfail++;
cflag++;
eflag++;
}
cflag++;
eflag++;
}
@@
-379,7
+377,7
@@
char as[];
char *
setsuf(as, ch)
char *
setsuf(as, ch)
-char
*as
;
+char
as[]
;
{
register char *s, *s1;
{
register char *s, *s1;
@@
-392,8
+390,7
@@
char *as;
}
callsys(f, v)
}
callsys(f, v)
-char f[], *v[];
-{
+char f[], *v[]; {
int t, status;
if ((t=fork())==0) {
int t, status;
if ((t=fork())==0) {
@@
-405,13
+402,13
@@
char f[], *v[];
printf("Try again\n");
return(100);
}
printf("Try again\n");
return(100);
}
- while(t!=wait(&status))
- ;
- if (t = status&0377) {
-
if (t!=SIGINT)
{
+ while(t!=wait(&status))
;
+ if ((t=(status&0377)) != 0 && t!=14) {
+ if (t!=2) /* interrupt */
+
{
printf("Fatal error in %s\n", f);
eflag = 8;
printf("Fatal error in %s\n", f);
eflag = 8;
- }
+
}
dexit();
}
return((status>>8) & 0377);
dexit();
}
return((status>>8) & 0377);
@@
-419,22
+416,22
@@
char f[], *v[];
char *
copy(as)
char *
copy(as)
-char
*as
;
+char
as[]
;
{
{
- char *malloc();
register char *otsp, *s;
register char *otsp, *s;
+ int i;
otsp = tsp;
s = as;
otsp = tsp;
s = as;
- while (*tsp++ = *s++)
- ;
- if (tsp > tsa+CHSPACE) {
- tsp = tsa = malloc(CHSPACE+50);
- if (tsp==NULL) {
- error("no space for file names", (char *)NULL);
- dexit();
+ while(*tsp++ = *s++);
+ if (tsp >tsa+CHSPACE)
+ {
+ tsp = tsa = i = calloc(CHSPACE+50,1);
+ if (i== -1){
+ error("no space for file names");
+ dexit(8);
+ }
}
}
- }
return(otsp);
}
return(otsp);
}
@@
-461,7
+458,7
@@
char **l, *os;
cunlink(f)
char *f;
{
cunlink(f)
char *f;
{
- if (f==
NULL
)
- return;
-
unlink(f
);
+ if (f==
0
)
+ return
(0)
;
+
return(unlink(f)
);
}
}