* Copyright (c) 1980 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
"@(#) Copyright (c) 1980 Regents of the University of California.\n\
static char sccsid
[] = "@(#)pc.c 5.1 (Berkeley) 6/5/85";
* Pc - front end for Pascal compiler.
char *pc0
= "/usr/lib/pc0";
char *pc2
= "/usr/lib/pc2";
char *pc3
= "/usr/lib/pc3";
char *crt0
= "/lib/crt0.o";
char *mcrt0
= "/lib/mcrt0.o";
char *gcrt0
= "/usr/lib/gcrt0.o";
char tmp0
[MAXPATHLEN
], tmp1
[MAXPATHLEN
];
char *setsuf(), *savestr();
int Jflag
, Sflag
, Oflag
, Tlflag
, cflag
, gflag
, pflag
, wflag
, tflag
;
char *pc0args
[NARGS
] = { "pc0", "-o", "XXX" };
char *pc1args
[3] = { "pc1", 0, };
char *pc2args
[2] = { "pc2", 0 };
char *c2args
[4] = { "c2", 0, 0, 0 };
/* char *pc3args[NARGS] = { "pc3", 0 }; */
/* char *ldargs[NARGS] = { "ld", "-X", "/lib/crt0.o", 0, }; */
/* as -J -t tmpdir -o objfile srcfile \0 */
char *asargs
[8] = { "as", 0, };
"Cputime limit exceeded",
"Filesize limit exceeded",
* If the number of .p arguments (np) is 1, and the number of .o arguments
* (nxo) is 0, and we successfully create an ``a.out'', then we remove
* the one .ps .o file (onepso).
execl("/bin/cat", "cat", "/usr/lib/how_pc");
if (signal(SIGINT
, SIG_IGN
) != SIG_IGN
) {
for (i
= 0; i
< argc
; i
++) {
pc0args
[pc0argx
++] = "-i";
while (i
+1 < argc
&& argv
[i
+1][0] != '-' &&
getsuf(argv
[i
+1]) != 'p') {
pc0args
[pc0argx
++] = argv
[i
+1];
fprintf(stderr
, "pc: bad -i construction\n");
fprintf(stderr
, "pc: -o must specify file\n");
if (c
== 'o' || c
== 'p' || c
== 'c') {
fprintf(stderr
, "pc: -o would overwrite %s\n",
fprintf(stderr
, "pc: -t but no directory\n");
fprintf(stderr
, "pc: bad -t option\n");
fprintf(stderr
, "pc: bad -t option\n");
pc0
= "/usr/src/ucb/pascal/pc0/a.out";
pc1
= "/usr/src/lib/pcc/fort";
pc2
= "/usr/src/ucb/pascal/utilities/pc2";
pc3
= "/usr/src/ucb/pascal/utilities/pc3";
lpc
= "/usr/src/usr.lib/libpc/libpc";
pc0args
[pc0argx
++] = argp
;
pc0args
[pc0argx
++] = argp
;
pc0args
[pc0argx
++] = argp
;
fprintf(stderr
, "pc: warning: -g overrides -O\n");
sprintf(tmp0
, "%s/%s", tmpdir
, "p0XXXXXX");
sprintf(tmp1
, "%s/%s", tmpdir
, "p1XXXXXX");
for (i
= 0; i
< argc
; i
++) {
if (suffix(argp
) == 's') {
asargs
[asargx
++] = tmpdir
;
tfile
[1] = setsuf(argp
, 'o');
asargs
[asargx
++] = tfile
[1];
if (dosys(as
, asargs
, 0, 0))
pc0args
[pc0argx
++] = "-p";
pc0args
[pc0argx
++] = "-J";
pc0args
[pc0argx
++] = argp
;
if (dosys(pc0
, pc0args
, 0, 0))
if (dosys(pc1
, pc1args
, 0, tfile
[1]))
if (dosys(c2
, c2args
, tfile
[1], tfile
[0]))
tfile
[0] = setsuf(argp
, 's');
if (dosys(pc2
, pc2args
, tfile
[1], tfile
[0]))
asargs
[asargx
++] = tmpdir
;
asargs
[asargx
++] = tfile
[0];
tfile
[1] = setsuf(argp
, 'o');
asargs
[asargx
++] = tfile
[1];
if (dosys(as
, asargs
, 0, 0))
if (errs
|| cflag
|| Sflag
)
/* char *pc3args[NARGS] = { "pc3", 0 }; */
pc3args
[pc3argx
++] = "-w";
pc3args
[pc3argx
++] = "/usr/lib/pcexterns.o";
for (i
= 0; i
< argc
; i
++) {
pc3args
[pc3argx
++] = argp
;
onepso
= pc3args
[pc3argx
++] =
savestr(setsuf(argp
, 'o'));
if (dosys(pc3
, pc3args
, 0, 0) > 1)
/* char *ldargs[NARGS] = { "ld", "-X", "/lib/crt0.o", 0, }; */
for (i
= 0; i
< argc
; i
++) {
ldargs
[ldargx
] = savestr(setsuf(argp
, 'o'));
if (getsuf(ldargs
[ldargx
]) == 'o')
for (j
= 0; j
< ldargx
; j
++)
if (!strcmp(ldargs
[j
], ldargs
[ldargx
]))
while (i
+1 < argc
&& argv
[i
+1][0] != '-' &&
getsuf(argv
[i
+1]) != 'p')
ldargs
[ldargx
++] = argv
[i
];
ldargs
[ldargx
++] = "-lg";
ldargs
[ldargx
++] = "-lm_p";
ldargs
[ldargx
++] = "-lc_p";
ldargs
[ldargx
++] = "-lm";
ldargs
[ldargx
++] = "-lc";
if (dosys(ld
, ldargs
, 0, 0)==0 && np
== 1 && nxo
== 0)
dosys(cmd
, argv
, in
, out
)
char *cmd
, **argv
, *in
, *out
;
for (i
= 0; argv
[i
]; i
++)
* warning: vfork doesn't work here, because the call to signal()
* done by the child process destroys the parent's SIGINT handler.
fprintf(stderr
, "pc: No more processes\n");
if (creat(out
, 0666) != 1) {
while (wait(&status
) != pid
)
if (WIFSIGNALED(status
)) {
if (status
.w_termsig
!= SIGINT
) {
fprintf(stderr
, "%s: %s", cmd
, mesg
[status
.w_termsig
]);
fprintf(stderr
, " (core dumped)");
return (status
.w_retcode
);
savetab
= (char *)malloc(saveleft
);
fprintf(stderr
, "ran out of memory (savestr)\n");
strncpy(savetab
, cp
, len
);
if (cp
[0] == 0 || cp
[1] == 0)