* Copyright (c) 1990 The Regents of the University of California.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
"@(#) Copyright (c) 1990 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)pc.c 5.6 (Berkeley) 2/6/91";
* Pc - front end for Pascal compiler.
char *mcrt0
= _PATH_MCRT0
;
char *gcrt0
= _PATH_GCRT0
;
char *tmpdir
= _PATH_TMP
;
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", _PATH_CRT0, 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(_PATH_CAT
, "cat", _PATH_HOWPC
);
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");
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') {
# if defined(vax) || defined(tahoe)
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]))
# if defined(vax) || defined(tahoe)
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
++] = _PATH_PCEXTERN
;
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", _PATH_CRT0, 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)