adapted to the system(3L) interface
This commit is contained in:
parent
0e39681621
commit
1afbf0e20f
|
@ -86,8 +86,6 @@ struct.c
|
||||||
struct.str
|
struct.str
|
||||||
switch.c
|
switch.c
|
||||||
switch.str
|
switch.str
|
||||||
system.c
|
|
||||||
system.h
|
|
||||||
tab.c
|
tab.c
|
||||||
tokenname.c
|
tokenname.c
|
||||||
tokenname.h
|
tokenname.h
|
||||||
|
|
|
@ -7,6 +7,11 @@ EM = /usr/em# # where to find the ACK tree
|
||||||
ACK = $(EM)/bin/ack# # old ACK C compiler
|
ACK = $(EM)/bin/ack# # old ACK C compiler
|
||||||
EM_INCLUDES =$(EM)/h# # directory containing EM interface definition
|
EM_INCLUDES =$(EM)/h# # directory containing EM interface definition
|
||||||
|
|
||||||
|
# Libraries
|
||||||
|
SYSLIB = /user1/erikb/em/lib/libsystem.a
|
||||||
|
LIBS = $(SYSLIB)
|
||||||
|
LIB_INCLUDES = /user1/erikb/em/h
|
||||||
|
|
||||||
# Where to install the compiler and its driver
|
# Where to install the compiler and its driver
|
||||||
CEMCOM = $(BIN)/cemcom
|
CEMCOM = $(BIN)/cemcom
|
||||||
DRIVER = $(BIN)/cem
|
DRIVER = $(BIN)/cem
|
||||||
|
@ -22,7 +27,7 @@ GEN = /user0/ceriel/bin/LLgen
|
||||||
GENOPTIONS = -vv
|
GENOPTIONS = -vv
|
||||||
|
|
||||||
# Special #defines during compilation
|
# Special #defines during compilation
|
||||||
CDEFS = $(MAP) -I$(EM_INCLUDES)
|
CDEFS = $(MAP) -I$(EM_INCLUDES) -I$(LIB_INCLUDES)
|
||||||
CFLAGS = $(CDEFS) $(COPTIONS) -O# # we cannot pass the COPTIONS to lint!
|
CFLAGS = $(CDEFS) $(COPTIONS) -O# # we cannot pass the COPTIONS to lint!
|
||||||
|
|
||||||
# Grammar files and their objects
|
# Grammar files and their objects
|
||||||
|
@ -37,7 +42,7 @@ COBJ = main.o idf.o declarator.o decspecs.o struct.o \
|
||||||
input.o domacro.o replace.o init.o options.o \
|
input.o domacro.o replace.o init.o options.o \
|
||||||
scan.o skip.o stack.o type.o ch7mon.o label.o eval.o \
|
scan.o skip.o stack.o type.o ch7mon.o label.o eval.o \
|
||||||
switch.o storage.o ival.o conversion.o \
|
switch.o storage.o ival.o conversion.o \
|
||||||
em.o blocks.o dataflow.o system.o string.o
|
em.o blocks.o dataflow.o string.o
|
||||||
|
|
||||||
# Objects of other generated C files
|
# Objects of other generated C files
|
||||||
GOBJ = char.o symbol2str.o next.o writeem.o
|
GOBJ = char.o symbol2str.o next.o writeem.o
|
||||||
|
@ -54,7 +59,7 @@ GHSRC = botch_free.h dataflow.h debug.h density.h errout.h \
|
||||||
maxincl.h myalloc.h nobitfield.h nopp.h \
|
maxincl.h myalloc.h nobitfield.h nopp.h \
|
||||||
nparams.h numsize.h parbufsize.h pathlength.h predefine.h \
|
nparams.h numsize.h parbufsize.h pathlength.h predefine.h \
|
||||||
proc_intf.h strsize.h target_sizes.h textsize.h use_tmp.h \
|
proc_intf.h strsize.h target_sizes.h textsize.h use_tmp.h \
|
||||||
bufsiz.h str_params.h spec_arith.h
|
str_params.h spec_arith.h
|
||||||
|
|
||||||
# Other generated files, for 'make clean' only
|
# Other generated files, for 'make clean' only
|
||||||
GENERATED = tab tokenfile.g Lpars.h LLfiles LL.output lint.out \
|
GENERATED = tab tokenfile.g Lpars.h LLfiles LL.output lint.out \
|
||||||
|
@ -76,7 +81,7 @@ cc:
|
||||||
make main
|
make main
|
||||||
|
|
||||||
cem: cem.c string.o
|
cem: cem.c string.o
|
||||||
$(CC) -O cem.c string.o -o cem
|
$(CC) -O cem.c string.o $(SYSLIB) -o cem
|
||||||
|
|
||||||
lint.cem: cem.c string.c
|
lint.cem: cem.c string.c
|
||||||
lint -abx cem.c
|
lint -abx cem.c
|
||||||
|
@ -124,7 +129,7 @@ writeem.h: make.emmac emcode.def
|
||||||
OBJ = $(COBJ) $(LOBJ) $(GOBJ)
|
OBJ = $(COBJ) $(LOBJ) $(GOBJ)
|
||||||
|
|
||||||
main: $(OBJ) Makefile
|
main: $(OBJ) Makefile
|
||||||
$(CC) $(COPTIONS) $(LFLAGS) $(OBJ) -o main
|
$(CC) $(COPTIONS) $(LFLAGS) $(OBJ) $(LIBS) -o main
|
||||||
size main
|
size main
|
||||||
|
|
||||||
cfiles: hfiles LLfiles $(GSRC)
|
cfiles: hfiles LLfiles $(GSRC)
|
||||||
|
@ -184,7 +189,7 @@ sim: cfiles
|
||||||
$(SIM) $(SIMFLAGS) `sources $(COBJ)` $(GSRC) $(LSRC)
|
$(SIM) $(SIMFLAGS) `sources $(COBJ)` $(GSRC) $(LSRC)
|
||||||
|
|
||||||
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
|
#AUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTOAUTO
|
||||||
main.o: LLlex.h Lpars.h alloc.h arith.h bufsiz.h debug.h declar.h idf.h input.h inputtype.h level.h maxincl.h myalloc.h nobitfield.h nopp.h spec_arith.h specials.h system.h target_sizes.h tokenname.h type.h use_tmp.h
|
main.o: LLlex.h Lpars.h alloc.h arith.h debug.h declar.h idf.h input.h inputtype.h level.h maxincl.h myalloc.h nobitfield.h nopp.h spec_arith.h specials.h target_sizes.h tokenname.h type.h use_tmp.h
|
||||||
idf.o: LLlex.h Lpars.h align.h alloc.h arith.h assert.h botch_free.h debug.h declar.h decspecs.h def.h idf.h idfsize.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h struct.h type.h
|
idf.o: LLlex.h Lpars.h align.h alloc.h arith.h assert.h botch_free.h debug.h declar.h decspecs.h def.h idf.h idfsize.h label.h level.h nobitfield.h nopp.h sizes.h spec_arith.h specials.h stack.h storage.h struct.h type.h
|
||||||
declarator.o: Lpars.h alloc.h arith.h botch_free.h declar.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h type.h
|
declarator.o: Lpars.h alloc.h arith.h botch_free.h declar.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h type.h
|
||||||
decspecs.o: Lpars.h arith.h decspecs.h def.h level.h nobitfield.h spec_arith.h type.h
|
decspecs.o: Lpars.h arith.h decspecs.h def.h level.h nobitfield.h spec_arith.h type.h
|
||||||
|
@ -194,22 +199,22 @@ ch7.o: Lpars.h arith.h assert.h debug.h def.h expr.h idf.h label.h nobitfield.h
|
||||||
ch7bin.o: Lpars.h arith.h botch_free.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h struct.h type.h
|
ch7bin.o: Lpars.h arith.h botch_free.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h struct.h type.h
|
||||||
cstoper.o: Lpars.h arith.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h target_sizes.h type.h
|
cstoper.o: Lpars.h arith.h expr.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h target_sizes.h type.h
|
||||||
arith.o: Lpars.h alloc.h arith.h botch_free.h expr.h field.h idf.h label.h mes.h nobitfield.h nopp.h spec_arith.h storage.h type.h
|
arith.o: Lpars.h alloc.h arith.h botch_free.h expr.h field.h idf.h label.h mes.h nobitfield.h nopp.h spec_arith.h storage.h type.h
|
||||||
alloc.o: alloc.h assert.h debug.h myalloc.h system.h
|
alloc.o: alloc.h assert.h debug.h myalloc.h
|
||||||
code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h em.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h specials.h stack.h storage.h type.h use_tmp.h writeem.h
|
code.o: LLlex.h Lpars.h alloc.h arith.h assert.h atw.h botch_free.h code.h dataflow.h debug.h declar.h decspecs.h def.h em.h expr.h idf.h label.h level.h mes.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h specials.h stack.h storage.h type.h use_tmp.h writeem.h
|
||||||
dumpidf.o: Lpars.h arith.h debug.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h struct.h type.h
|
dumpidf.o: Lpars.h arith.h debug.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h spec_arith.h stack.h struct.h type.h
|
||||||
error.o: LLlex.h arith.h debug.h em.h errout.h expr.h label.h nopp.h proc_intf.h spec_arith.h string.h system.h tokenname.h use_tmp.h writeem.h
|
error.o: LLlex.h arith.h debug.h em.h errout.h expr.h label.h nopp.h proc_intf.h spec_arith.h string.h tokenname.h use_tmp.h writeem.h
|
||||||
field.o: Lpars.h arith.h assert.h code.h debug.h em.h expr.h field.h idf.h label.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h type.h writeem.h
|
field.o: Lpars.h arith.h assert.h code.h debug.h em.h expr.h field.h idf.h label.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h type.h writeem.h
|
||||||
tokenname.o: LLlex.h Lpars.h arith.h idf.h nopp.h spec_arith.h tokenname.h
|
tokenname.o: LLlex.h Lpars.h arith.h idf.h nopp.h spec_arith.h tokenname.h
|
||||||
LLlex.o: LLlex.h Lpars.h alloc.h arith.h assert.h class.h debug.h def.h idf.h idfsize.h input.h nopp.h numsize.h sizes.h spec_arith.h strsize.h
|
LLlex.o: LLlex.h Lpars.h alloc.h arith.h assert.h class.h debug.h def.h idf.h idfsize.h input.h nopp.h numsize.h sizes.h spec_arith.h strsize.h
|
||||||
LLmessage.o: LLlex.h Lpars.h alloc.h arith.h idf.h nopp.h spec_arith.h
|
LLmessage.o: LLlex.h Lpars.h alloc.h arith.h idf.h nopp.h spec_arith.h
|
||||||
input.o: LLlex.h alloc.h arith.h assert.h bufsiz.h debug.h idepth.h input.h inputtype.h interface.h nopp.h pathlength.h spec_arith.h system.h
|
input.o: LLlex.h alloc.h arith.h assert.h debug.h idepth.h input.h inputtype.h interface.h nopp.h pathlength.h spec_arith.h
|
||||||
domacro.o: LLlex.h Lpars.h alloc.h arith.h assert.h botch_free.h class.h debug.h idf.h idfsize.h ifdepth.h input.h interface.h macro.h nopp.h nparams.h parbufsize.h spec_arith.h storage.h textsize.h
|
domacro.o: LLlex.h Lpars.h alloc.h arith.h assert.h botch_free.h class.h debug.h idf.h idfsize.h ifdepth.h input.h interface.h macro.h nopp.h nparams.h parbufsize.h spec_arith.h storage.h textsize.h
|
||||||
replace.o: LLlex.h alloc.h arith.h assert.h class.h debug.h idf.h input.h interface.h macro.h nopp.h pathlength.h spec_arith.h string.h strsize.h
|
replace.o: LLlex.h alloc.h arith.h assert.h class.h debug.h idf.h input.h interface.h macro.h nopp.h pathlength.h spec_arith.h string.h strsize.h
|
||||||
init.o: alloc.h class.h idf.h interface.h macro.h nopp.h predefine.h string.h system.h
|
init.o: alloc.h class.h idf.h interface.h macro.h nopp.h predefine.h string.h
|
||||||
options.o: align.h arith.h class.h idf.h idfsize.h macro.h maxincl.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h
|
options.o: align.h arith.h class.h idf.h idfsize.h macro.h maxincl.h nobitfield.h nopp.h sizes.h spec_arith.h storage.h
|
||||||
scan.o: class.h idf.h input.h interface.h lapbuf.h macro.h nopp.h nparams.h
|
scan.o: class.h idf.h input.h interface.h lapbuf.h macro.h nopp.h nparams.h
|
||||||
skip.o: LLlex.h arith.h class.h input.h interface.h nopp.h spec_arith.h
|
skip.o: LLlex.h arith.h class.h input.h interface.h nopp.h spec_arith.h
|
||||||
stack.o: Lpars.h alloc.h arith.h botch_free.h debug.h def.h em.h idf.h level.h mes.h nobitfield.h nopp.h proc_intf.h spec_arith.h stack.h storage.h struct.h system.h type.h use_tmp.h writeem.h
|
stack.o: Lpars.h alloc.h arith.h botch_free.h debug.h def.h em.h idf.h level.h mes.h nobitfield.h nopp.h proc_intf.h spec_arith.h stack.h storage.h struct.h type.h use_tmp.h writeem.h
|
||||||
type.o: Lpars.h align.h alloc.h arith.h def.h idf.h nobitfield.h nopp.h sizes.h spec_arith.h type.h
|
type.o: Lpars.h align.h alloc.h arith.h def.h idf.h nobitfield.h nopp.h sizes.h spec_arith.h type.h
|
||||||
ch7mon.o: Lpars.h arith.h botch_free.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h type.h
|
ch7mon.o: Lpars.h arith.h botch_free.h def.h expr.h idf.h label.h nobitfield.h nopp.h spec_arith.h storage.h type.h
|
||||||
label.o: Lpars.h arith.h def.h idf.h label.h level.h nobitfield.h nopp.h spec_arith.h type.h
|
label.o: Lpars.h arith.h def.h idf.h label.h level.h nobitfield.h nopp.h spec_arith.h type.h
|
||||||
|
@ -218,11 +223,10 @@ switch.o: arith.h assert.h botch_free.h code.h debug.h density.h em.h expr.h idf
|
||||||
storage.o: alloc.h assert.h botch_free.h debug.h storage.h
|
storage.o: alloc.h assert.h botch_free.h debug.h storage.h
|
||||||
ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h em.h expr.h field.h idf.h label.h level.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h string.h struct.h type.h writeem.h
|
ival.o: Lpars.h align.h arith.h assert.h class.h debug.h def.h em.h expr.h field.h idf.h label.h level.h nobitfield.h nopp.h proc_intf.h sizes.h spec_arith.h string.h struct.h type.h writeem.h
|
||||||
conversion.o: Lpars.h arith.h em.h nobitfield.h proc_intf.h sizes.h spec_arith.h type.h writeem.h
|
conversion.o: Lpars.h arith.h em.h nobitfield.h proc_intf.h sizes.h spec_arith.h type.h writeem.h
|
||||||
em.o: arith.h bufsiz.h em.h label.h proc_intf.h spec_arith.h system.h writeem.h
|
em.o: arith.h em.h label.h proc_intf.h spec_arith.h writeem.h
|
||||||
blocks.o: arith.h atw.h em.h proc_intf.h sizes.h spec_arith.h writeem.h
|
blocks.o: arith.h atw.h em.h proc_intf.h sizes.h spec_arith.h writeem.h
|
||||||
dataflow.o: dataflow.h
|
dataflow.o: dataflow.h
|
||||||
system.o: inputtype.h system.h
|
string.o: arith.h nopp.h spec_arith.h str_params.h string.h
|
||||||
string.o: arith.h nopp.h spec_arith.h str_params.h string.h system.h
|
|
||||||
tokenfile.o: Lpars.h
|
tokenfile.o: Lpars.h
|
||||||
declar.o: LLlex.h Lpars.h arith.h debug.h declar.h decspecs.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h struct.h type.h
|
declar.o: LLlex.h Lpars.h arith.h debug.h declar.h decspecs.h def.h expr.h field.h idf.h label.h nobitfield.h nopp.h sizes.h spec_arith.h struct.h type.h
|
||||||
statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h em.h expr.h idf.h label.h nobitfield.h nopp.h proc_intf.h spec_arith.h stack.h storage.h type.h writeem.h
|
statement.o: LLlex.h Lpars.h arith.h botch_free.h code.h debug.h def.h em.h expr.h idf.h label.h nobitfield.h nopp.h proc_intf.h spec_arith.h stack.h storage.h type.h writeem.h
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
|
|
||||||
!File: errout.h
|
!File: errout.h
|
||||||
#define ERROUT stderr /* file pointer for writing messages */
|
#define ERROUT STDERR /* file pointer for writing messages */
|
||||||
#define MAXERR_LINE 5 /* maximum number of error messages given
|
#define MAXERR_LINE 5 /* maximum number of error messages given
|
||||||
on the same input line. */
|
on the same input line. */
|
||||||
|
|
||||||
|
@ -134,10 +134,6 @@
|
||||||
#define SSIZE 1024 /* string-buffer size for print routines */
|
#define SSIZE 1024 /* string-buffer size for print routines */
|
||||||
|
|
||||||
|
|
||||||
!File: bufsiz.h
|
|
||||||
#define BUFSIZ 1024 /* system block size */
|
|
||||||
|
|
||||||
|
|
||||||
!File: spec_arith.h
|
!File: spec_arith.h
|
||||||
/* describes internal compiler arithmetics */
|
/* describes internal compiler arithmetics */
|
||||||
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
#undef SPECIAL_ARITHMETICS /* something different from native long */
|
||||||
|
|
|
@ -23,21 +23,19 @@
|
||||||
Salloc(str, sz) : save string in malloc storage
|
Salloc(str, sz) : save string in malloc storage
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <system.h>
|
||||||
#include "myalloc.h" /* UF */
|
#include "myalloc.h" /* UF */
|
||||||
#include "debug.h" /* UF */
|
#include "debug.h" /* UF */
|
||||||
|
|
||||||
#include "alloc.h"
|
#include "alloc.h"
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
#include "system.h"
|
|
||||||
|
|
||||||
#ifdef OWNALLOC
|
#ifdef OWNALLOC
|
||||||
|
char *sys_break();
|
||||||
#define SBRK_ERROR ((char *) -1) /* errors during allocation */
|
|
||||||
|
|
||||||
/* the following variables are used for book-keeping */
|
/* the following variables are used for book-keeping */
|
||||||
static int nfreebytes = 0; /* # free bytes in sys_sbrk-ed space */
|
static int nfreebytes = 0; /* # free bytes in sys_break space */
|
||||||
static char *freeb; /* pointer to first free byte */
|
static char *freeb; /* pointer to first free byte */
|
||||||
static char *lastalloc; /* pointer to last malloced sp */
|
static char *lastalloc; /* pointer to last malloced sp */
|
||||||
static int lastnbytes; /* nr of bytes in last allocated */
|
static int lastnbytes; /* nr of bytes in last allocated */
|
||||||
/* space */
|
/* space */
|
||||||
static char *firstfreeb = 0;
|
static char *firstfreeb = 0;
|
||||||
|
@ -75,11 +73,11 @@ malloc(n)
|
||||||
register nbts = (n <= ALLOCSIZ) ? ALLOCSIZ : n;
|
register nbts = (n <= ALLOCSIZ) ? ALLOCSIZ : n;
|
||||||
|
|
||||||
if (!nfreebytes) {
|
if (!nfreebytes) {
|
||||||
if ((freeb = sys_sbrk(nbts)) == SBRK_ERROR)
|
if ((freeb = sys_break(nbts)) == ILL_BREAK)
|
||||||
fatal("out of memory");
|
fatal("out of memory");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (sys_sbrk(nbts) == SBRK_ERROR)
|
if (sys_break(nbts) == ILL_BREAK)
|
||||||
fatal("out of memory");
|
fatal("out of memory");
|
||||||
}
|
}
|
||||||
nfreebytes += nbts;
|
nfreebytes += nbts;
|
||||||
|
@ -118,7 +116,7 @@ realloc(ptr, n)
|
||||||
nbytes = ALIGN(nbytes);
|
nbytes = ALIGN(nbytes);
|
||||||
if (nfreebytes < nbytes) {
|
if (nfreebytes < nbytes) {
|
||||||
register int nbts = (nbytes < ALLOCSIZ) ? ALLOCSIZ : nbytes;
|
register int nbts = (nbytes < ALLOCSIZ) ? ALLOCSIZ : nbytes;
|
||||||
if (sys_sbrk(nbts) == SBRK_ERROR)
|
if (sys_break(nbts) == ILL_BREAK)
|
||||||
fatal("out of memory");
|
fatal("out of memory");
|
||||||
nfreebytes += nbts;
|
nfreebytes += nbts;
|
||||||
}
|
}
|
||||||
|
@ -136,13 +134,13 @@ free(p)
|
||||||
|
|
||||||
init_mem()
|
init_mem()
|
||||||
{
|
{
|
||||||
firstfreeb = sys_sbrk(0);
|
firstfreeb = sys_break(0);
|
||||||
/* align the first memory unit to ALIGNSIZE ??? */
|
/* align the first memory unit to ALIGNSIZE ??? */
|
||||||
if ((long) firstfreeb % ALIGNSIZE != 0) {
|
if ((long) firstfreeb % ALIGNSIZE != 0) {
|
||||||
register char *fb = firstfreeb;
|
register char *fb = firstfreeb;
|
||||||
|
|
||||||
fb = (char *)ALIGN((long)fb);
|
fb = (char *)ALIGN((long)fb);
|
||||||
firstfreeb = sys_sbrk(fb - firstfreeb);
|
firstfreeb = sys_break(fb - firstfreeb);
|
||||||
firstfreeb = fb;
|
firstfreeb = fb;
|
||||||
ASSERT((long)firstfreeb % ALIGNSIZE == 0);
|
ASSERT((long)firstfreeb % ALIGNSIZE == 0);
|
||||||
}
|
}
|
||||||
|
@ -155,7 +153,7 @@ mem_stat()
|
||||||
|
|
||||||
if (options['m'])
|
if (options['m'])
|
||||||
printf("Total nr of bytes allocated: %d\n",
|
printf("Total nr of bytes allocated: %d\n",
|
||||||
sys_sbrk(0) - firstfreeb);
|
sys_break(0) - firstfreeb);
|
||||||
}
|
}
|
||||||
#endif DEBUG
|
#endif DEBUG
|
||||||
#endif OWNALLOC
|
#endif OWNALLOC
|
||||||
|
|
|
@ -78,7 +78,7 @@ prepend_scopes(dst_file)
|
||||||
struct stack_entry *se = local_level->sl_entry;
|
struct stack_entry *se = local_level->sl_entry;
|
||||||
|
|
||||||
if (C_open(dst_file) == 0)
|
if (C_open(dst_file) == 0)
|
||||||
fatal("cannot create file %s", dst_file);
|
fatal("cannot create %s", dst_file ? dst_file : "stdout");
|
||||||
famous_first_words();
|
famous_first_words();
|
||||||
while (se != 0) {
|
while (se != 0) {
|
||||||
struct idf *idf = se->se_idf;
|
struct idf *idf = se->se_idf;
|
||||||
|
|
|
@ -5,8 +5,7 @@
|
||||||
#define MAX_ARG_CNT 32
|
#define MAX_ARG_CNT 32
|
||||||
|
|
||||||
#include "em.h"
|
#include "em.h"
|
||||||
#include "system.h"
|
#include <system.h>
|
||||||
#include "bufsiz.h"
|
|
||||||
#include "arith.h"
|
#include "arith.h"
|
||||||
#include "label.h"
|
#include "label.h"
|
||||||
|
|
||||||
|
@ -21,17 +20,18 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* supply a kind of buffered output */
|
/* supply a kind of buffered output */
|
||||||
#define flush(x) sys_write(ofd, &obuf[0], x);
|
#define flush(x) sys_write(ofp, &obuf[0], x)
|
||||||
|
|
||||||
static char obuf[BUFSIZ];
|
static char obuf[BUFSIZ];
|
||||||
static char *opp = &obuf[0];
|
static char *opp = &obuf[0];
|
||||||
int ofd = -1;
|
File *ofp = 0;
|
||||||
|
|
||||||
putbyte(b) /* shouldn't putbyte() be a macro ??? (EB) */
|
putbyte(b) /* shouldn't putbyte() be a macro ??? (EB) */
|
||||||
int b;
|
int b;
|
||||||
{
|
{
|
||||||
if (opp >= &obuf[BUFSIZ]) { /* flush if buffer overflows */
|
if (opp >= &obuf[BUFSIZ]) { /* flush if buffer overflows */
|
||||||
flush(BUFSIZ);
|
if (flush(BUFSIZ) == 0)
|
||||||
|
sys_stop(S_ABORT);
|
||||||
opp = &obuf[0];
|
opp = &obuf[0];
|
||||||
}
|
}
|
||||||
*opp++ = (char) b;
|
*opp++ = (char) b;
|
||||||
|
@ -45,24 +45,26 @@ C_open(nm) /* open file for compact code output */
|
||||||
char *nm;
|
char *nm;
|
||||||
{
|
{
|
||||||
if (nm == 0)
|
if (nm == 0)
|
||||||
ofd = 1; /* standard output */
|
ofp = STDOUT; /* standard output */
|
||||||
else
|
else
|
||||||
if ((ofd = sys_creat(nm, CMODE)) < 0)
|
if (sys_open(nm, OP_WRITE, &ofp) == 0)
|
||||||
return 0;
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
C_close()
|
C_close()
|
||||||
{
|
{
|
||||||
flush(opp - &obuf[0]);
|
if (flush(opp - &obuf[0]) == 0)
|
||||||
|
sys_stop(S_ABORT);
|
||||||
opp = obuf; /* reset opp */
|
opp = obuf; /* reset opp */
|
||||||
sys_close(ofd);
|
if (ofp != STDOUT)
|
||||||
ofd = -1;
|
sys_close(ofp);
|
||||||
|
ofp = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
C_busy()
|
C_busy()
|
||||||
{
|
{
|
||||||
return ofd >= 0; /* true if code is being generated */
|
return ofp != 0; /* true if code is being generated */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*** the compact code generating routines ***/
|
/*** the compact code generating routines ***/
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
/* E R R O R A N D D I A G N O S T I C R O U T I N E S */
|
/* E R R O R A N D D I A G N O S T I C R O U T I N E S */
|
||||||
|
|
||||||
|
#include <system.h>
|
||||||
#include "nopp.h"
|
#include "nopp.h"
|
||||||
#include "use_tmp.h"
|
#include "use_tmp.h"
|
||||||
#include "errout.h"
|
#include "errout.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "system.h"
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
#include "tokenname.h"
|
#include "tokenname.h"
|
||||||
|
@ -96,9 +96,9 @@ crash(fmt, args)
|
||||||
_error(CRASH, NILEXPR, fmt, &args);
|
_error(CRASH, NILEXPR, fmt, &args);
|
||||||
C_close();
|
C_close();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
sys_stop(S_ABORT, 0);
|
sys_stop(S_ABORT);
|
||||||
#else DEBUG
|
#else DEBUG
|
||||||
sys_stop(S_EXIT, 1);
|
sys_stop(S_EXIT);
|
||||||
#endif DEBUG
|
#endif DEBUG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ fatal(fmt, args)
|
||||||
#endif USE_TMP
|
#endif USE_TMP
|
||||||
|
|
||||||
_error(FATAL, NILEXPR, fmt, &args);
|
_error(FATAL, NILEXPR, fmt, &args);
|
||||||
sys_stop(S_EXIT, 1);
|
sys_stop(S_EXIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
_error(class, expr, fmt, argv)
|
_error(class, expr, fmt, argv)
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
#include "nopp.h"
|
#include "nopp.h"
|
||||||
|
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
|
#include <system.h>
|
||||||
#include "predefine.h" /* UF */
|
#include "predefine.h" /* UF */
|
||||||
#include "alloc.h"
|
#include "alloc.h"
|
||||||
#include "class.h"
|
#include "class.h"
|
||||||
#include "macro.h"
|
#include "macro.h"
|
||||||
#include "idf.h"
|
#include "idf.h"
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
#include "system.h"
|
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
PRIVATE struct mkey {
|
PRIVATE struct mkey {
|
||||||
|
@ -33,7 +33,7 @@ PRIVATE struct mkey {
|
||||||
EXPORT
|
EXPORT
|
||||||
init_pp()
|
init_pp()
|
||||||
{
|
{
|
||||||
time_type clock;
|
long clock;
|
||||||
static char date[30];
|
static char date[30];
|
||||||
char *ctime();
|
char *ctime();
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ init_pp()
|
||||||
"pdp" are predefined macros.
|
"pdp" are predefined macros.
|
||||||
*/
|
*/
|
||||||
/* __DATE__ */
|
/* __DATE__ */
|
||||||
clock = sys_time((time_type *) 0);
|
clock = sys_time();
|
||||||
strcpy(&date[1], ctime(&clock));
|
strcpy(&date[1], ctime(&clock));
|
||||||
date[26] = '\0'; /* zap nl */
|
date[26] = '\0'; /* zap nl */
|
||||||
date[0] = date[25] = '"';
|
date[0] = date[25] = '"';
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
a fixed length input buffer
|
a fixed length input buffer
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <system.h>
|
||||||
#include "nopp.h"
|
#include "nopp.h"
|
||||||
#include "inputtype.h" /* UF */
|
#include "inputtype.h" /* UF */
|
||||||
#include "interface.h"
|
#include "interface.h"
|
||||||
|
@ -37,8 +38,6 @@
|
||||||
#include "LLlex.h"
|
#include "LLlex.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "alloc.h"
|
#include "alloc.h"
|
||||||
#include "system.h"
|
|
||||||
#include "bufsiz.h"
|
|
||||||
|
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
#include "idepth.h" /* UF */
|
#include "idepth.h" /* UF */
|
||||||
|
@ -51,7 +50,7 @@ EXPORT char *ipp = 0; /* input pointer */
|
||||||
EXPORT int NoUnstack = 0; /* if 1: report EOF */
|
EXPORT int NoUnstack = 0; /* if 1: report EOF */
|
||||||
|
|
||||||
#ifndef READ_IN_ONE
|
#ifndef READ_IN_ONE
|
||||||
PRIVATE int FilDes = -1; /* current input medium */
|
PRIVATE File *FilDes = 0; /* current input medium */
|
||||||
#endif READ_IN_ONE
|
#endif READ_IN_ONE
|
||||||
|
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
|
@ -63,7 +62,7 @@ struct buffer_header {
|
||||||
char *bh_text; /* pointer to buffer containing text */
|
char *bh_text; /* pointer to buffer containing text */
|
||||||
char *bh_ipp; /* current read pointer (= stacked ipp) */
|
char *bh_ipp; /* current read pointer (= stacked ipp) */
|
||||||
char *bh_wdir; /* directory of current file */
|
char *bh_wdir; /* directory of current file */
|
||||||
int bh_fd; /* >= 0 (fd if !READ_IN_ONE) in case of file */
|
File *bh_fp; /* needed for files if !READ_IN_ONE */
|
||||||
};
|
};
|
||||||
|
|
||||||
PRIVATE struct buffer_header instack[IDEPTH]; /* stack of input media */
|
PRIVATE struct buffer_header instack[IDEPTH]; /* stack of input media */
|
||||||
|
@ -91,27 +90,21 @@ readfile(filename, size)
|
||||||
char *filename;
|
char *filename;
|
||||||
long *size;
|
long *size;
|
||||||
{
|
{
|
||||||
int fd; /* filedescriptor for `filename' */
|
File *fp; /* filedescriptor for `filename' */
|
||||||
char *cbuf; /* pointer to buffer to be returned */
|
char *cbuf; /* pointer to buffer to be returned */
|
||||||
register tmp;
|
int tmp;
|
||||||
|
long sys_filesize();
|
||||||
|
|
||||||
if ((fd = sys_open(filename, OP_RDONLY)) < 0) {
|
if (sys_open(filename, OP_READ, &fp) == 0) /* can't open this file */
|
||||||
/* can't open this file */
|
|
||||||
return (char *) 0;
|
return (char *) 0;
|
||||||
}
|
if ((*size = sys_filesize(filename)) == -1L)
|
||||||
|
|
||||||
if ((*size = sys_fsize(fd)) < 0)
|
|
||||||
fatal("(readfile) cannot get size of file");
|
fatal("(readfile) cannot get size of file");
|
||||||
|
|
||||||
/* allocate enough space to store contents of the file */
|
/* allocate enough space to store contents of the file */
|
||||||
cbuf = Malloc(*size + 2);
|
cbuf = Malloc(*size + 2);
|
||||||
|
if (sys_read(fp, cbuf + 1, (int) *size, &tmp) == 0 || tmp != *size)
|
||||||
tmp = sys_read(fd, cbuf + 1, (int) *size); /* read the file */
|
fatal("(readfile) bad read");
|
||||||
if (tmp != *size)
|
|
||||||
fatal("(readfile) bad read count");
|
|
||||||
|
|
||||||
(*size)++; /* keep book of the size! */
|
(*size)++; /* keep book of the size! */
|
||||||
sys_close(fd); /* filedes no longer needed */
|
sys_close(fp); /* filedes no longer needed */
|
||||||
cbuf[0] = '\0'; /* allow pushback of first char */
|
cbuf[0] = '\0'; /* allow pushback of first char */
|
||||||
cbuf[*size] = '\0'; /* invoke loadbuf() at end */
|
cbuf[*size] = '\0'; /* invoke loadbuf() at end */
|
||||||
return cbuf;
|
return cbuf;
|
||||||
|
@ -173,7 +166,7 @@ push_bh()
|
||||||
PRIVATE int
|
PRIVATE int
|
||||||
pop_bh()
|
pop_bh()
|
||||||
{
|
{
|
||||||
int pfd = head->bh_fd;
|
File *pfp = head->bh_fp;
|
||||||
|
|
||||||
if (NoUnstack) {
|
if (NoUnstack) {
|
||||||
lexerror("unexpected EOF");
|
lexerror("unexpected EOF");
|
||||||
|
@ -186,9 +179,9 @@ pop_bh()
|
||||||
|
|
||||||
ipp = (--head)->bh_ipp; /* restore the previous input pointer */
|
ipp = (--head)->bh_ipp; /* restore the previous input pointer */
|
||||||
|
|
||||||
if (pfd >= 0) { /* unstack a file */
|
if (pfp != 0) { /* unstack a file */
|
||||||
#ifndef READ_IN_ONE
|
#ifndef READ_IN_ONE
|
||||||
closefile(pfd);
|
closefile(pfp);
|
||||||
popbuf(); /* free last buffer */
|
popbuf(); /* free last buffer */
|
||||||
#endif READ_IN_ONE
|
#endif READ_IN_ONE
|
||||||
LineNumber = head->bh_lineno;
|
LineNumber = head->bh_lineno;
|
||||||
|
@ -197,7 +190,7 @@ pop_bh()
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef READ_IN_ONE
|
#ifndef READ_IN_ONE
|
||||||
FilDes = head->bh_fd;
|
FilDes = head->bh_fp;
|
||||||
#endif READ_IN_ONE
|
#endif READ_IN_ONE
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -208,32 +201,36 @@ pop_bh()
|
||||||
/* low level IO routines: openfile(), readblock() and closefile()
|
/* low level IO routines: openfile(), readblock() and closefile()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
PRIVATE int
|
PRIVATE File *
|
||||||
openfile(filename)
|
openfile(filename)
|
||||||
char *filename;
|
char *filename;
|
||||||
{
|
{
|
||||||
int fd; /* filedescriptor for `filename' */
|
File *fp;
|
||||||
|
|
||||||
if ((fd = sys_open(filename, OP_RDONLY)) < 0 && sys_errno == EMFILE)
|
if (filename == 0)
|
||||||
fatal("too many files open");
|
return STDIN;
|
||||||
return fd;
|
if (sys_open(filename, OP_READ, &fp) == 0)
|
||||||
|
return (File *)0;
|
||||||
|
return fp;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIVATE
|
PRIVATE
|
||||||
closefile(fd)
|
closefile(fp)
|
||||||
|
File *fp;
|
||||||
{
|
{
|
||||||
sys_close(fd);
|
if (fp != STDIN)
|
||||||
|
sys_close(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
PRIVATE int
|
PRIVATE int
|
||||||
readblock(fd, buf)
|
readblock(fp, buf)
|
||||||
|
File *fp;
|
||||||
char buf[];
|
char buf[];
|
||||||
{
|
{
|
||||||
register n;
|
int n;
|
||||||
|
|
||||||
if ((n = sys_read(fd, &buf[1], BUFSIZ)) < 0) {
|
if (sys_read(fp, &buf[1], BUFSIZ, &n) == 0)
|
||||||
fatal("(readblock) bad read from file");
|
fatal("(readblock) bad read");
|
||||||
}
|
|
||||||
buf[0] = buf[n + 1] = '\0';
|
buf[0] = buf[n + 1] = '\0';
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -249,16 +246,19 @@ InsertFile(filnam, table)
|
||||||
{
|
{
|
||||||
char *mk_filename(), *newfn;
|
char *mk_filename(), *newfn;
|
||||||
char *strcpy();
|
char *strcpy();
|
||||||
|
File *openfile();
|
||||||
|
|
||||||
#ifdef READ_IN_ONE
|
#ifdef READ_IN_ONE
|
||||||
char *readfile(), *text;
|
char *readfile(), *text;
|
||||||
long size;
|
long size;
|
||||||
#else READ_IN_ONE
|
#else READ_IN_ONE
|
||||||
int fd = -1;
|
File *fp = 0;
|
||||||
#endif READ_IN_ONE
|
#endif READ_IN_ONE
|
||||||
|
|
||||||
|
#ifdef READ_IN_ONE
|
||||||
if (!filnam)
|
if (!filnam)
|
||||||
return 0;
|
return 0;
|
||||||
|
#endif READ_IN_ONE
|
||||||
|
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
if (table == 0 || filnam[0] == '/') { /* don't look in the table! */
|
if (table == 0 || filnam[0] == '/') { /* don't look in the table! */
|
||||||
|
@ -266,17 +266,20 @@ InsertFile(filnam, table)
|
||||||
#ifdef READ_IN_ONE
|
#ifdef READ_IN_ONE
|
||||||
text = readfile(filnam, &size);
|
text = readfile(filnam, &size);
|
||||||
#else READ_IN_ONE
|
#else READ_IN_ONE
|
||||||
fd = openfile(filnam);
|
fp = openfile(filnam);
|
||||||
|
if (filnam == 0)
|
||||||
|
filnam = "standard input";
|
||||||
#endif READ_IN_ONE
|
#endif READ_IN_ONE
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
ASSERT(filnam != 0);
|
||||||
while (*table) { /* look in the directory table */
|
while (*table) { /* look in the directory table */
|
||||||
newfn = mk_filename(*table++, filnam);
|
newfn = mk_filename(*table++, filnam);
|
||||||
#ifdef READ_IN_ONE
|
#ifdef READ_IN_ONE
|
||||||
if (text = readfile(newfn, &size))
|
if (text = readfile(newfn, &size))
|
||||||
#else READ_IN_ONE
|
#else READ_IN_ONE
|
||||||
if ((fd = openfile(newfn)) >= 0)
|
if ((fp = openfile(newfn)) != 0)
|
||||||
#endif READ_IN_ONE
|
#endif READ_IN_ONE
|
||||||
{
|
{
|
||||||
/* free filnam ??? */
|
/* free filnam ??? */
|
||||||
|
@ -290,7 +293,7 @@ InsertFile(filnam, table)
|
||||||
#ifdef READ_IN_ONE
|
#ifdef READ_IN_ONE
|
||||||
if (text)
|
if (text)
|
||||||
#else READ_IN_ONE
|
#else READ_IN_ONE
|
||||||
if (fd >= 0)
|
if (fp != 0)
|
||||||
#endif READ_IN_ONE
|
#endif READ_IN_ONE
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
{
|
{
|
||||||
|
@ -303,11 +306,11 @@ InsertFile(filnam, table)
|
||||||
bh->bh_wdir = *WorkingDir;
|
bh->bh_wdir = *WorkingDir;
|
||||||
#ifdef READ_IN_ONE
|
#ifdef READ_IN_ONE
|
||||||
bh->bh_size = size;
|
bh->bh_size = size;
|
||||||
bh->bh_fd = 0; /* this is a file */
|
bh->bh_fp = STDIN; /* this is a file */
|
||||||
ipp = bh->bh_text = text;
|
ipp = bh->bh_text = text;
|
||||||
#else READ_IN_ONE
|
#else READ_IN_ONE
|
||||||
bh->bh_size = readblock(fd, ipp = bh->bh_text = pushbuf()) + 1;
|
bh->bh_size = readblock(fp, ipp = bh->bh_text = pushbuf()) + 1;
|
||||||
FilDes = bh->bh_fd = fd;
|
FilDes = bh->bh_fp = fp;
|
||||||
#endif READ_IN_ONE
|
#endif READ_IN_ONE
|
||||||
bh->bh_text[0] = '\n'; /* wake up pp if '#' comes first */
|
bh->bh_text[0] = '\n'; /* wake up pp if '#' comes first */
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -318,7 +321,7 @@ InsertFile(filnam, table)
|
||||||
isize = size;
|
isize = size;
|
||||||
ipp = text;
|
ipp = text;
|
||||||
#else READ_IN_ONE
|
#else READ_IN_ONE
|
||||||
isize = readblock(FilDes = fd, ipp = &ibuf[0]) + 1;
|
isize = readblock(FilDes = fp, ipp = &ibuf[0]) + 1;
|
||||||
#endif READ_IN_ONE
|
#endif READ_IN_ONE
|
||||||
ibuf[0] = '\n';
|
ibuf[0] = '\n';
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -340,10 +343,10 @@ InsertText(text, length)
|
||||||
bh->bh_size = (long) length;
|
bh->bh_size = (long) length;
|
||||||
bh->bh_text = text;
|
bh->bh_text = text;
|
||||||
bh->bh_wdir = *WorkingDir;
|
bh->bh_wdir = *WorkingDir;
|
||||||
bh->bh_fd = -1; /* this is no file ! */
|
bh->bh_fp = 0; /* this is not a file ! */
|
||||||
ipp = text + 1;
|
ipp = text + 1;
|
||||||
#ifndef READ_IN_ONE
|
#ifndef READ_IN_ONE
|
||||||
FilDes = -1;
|
FilDes = 0;
|
||||||
#endif READ_IN_ONE
|
#endif READ_IN_ONE
|
||||||
}
|
}
|
||||||
#endif NOPP
|
#endif NOPP
|
||||||
|
@ -376,13 +379,13 @@ loadbuf()
|
||||||
|
|
||||||
#ifndef READ_IN_ONE
|
#ifndef READ_IN_ONE
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
if ( FilDes >= 0
|
if ( FilDes != 0
|
||||||
&& (head->bh_size = readblock(FilDes, head->bh_text)) > 0
|
&& (head->bh_size = readblock(FilDes, head->bh_text)) > 0
|
||||||
) {
|
) {
|
||||||
return ipp = &(head->bh_text[1]), *ipp++;
|
return ipp = &(head->bh_text[1]), *ipp++;
|
||||||
}
|
}
|
||||||
#else NOPP
|
#else NOPP
|
||||||
if (FilDes >= 0 && (isize = readblock(FilDes, &ibuf[0])) > 0)
|
if (FilDes != 0 && (isize = readblock(FilDes, &ibuf[0])) > 0)
|
||||||
return ipp = &ibuf[1], *ipp++;
|
return ipp = &ibuf[1], *ipp++;
|
||||||
#endif NOPP
|
#endif NOPP
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,14 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
/* MAIN PROGRAM */
|
/* MAIN PROGRAM */
|
||||||
|
|
||||||
|
#include <system.h>
|
||||||
#include "nopp.h"
|
#include "nopp.h"
|
||||||
#include "target_sizes.h"
|
#include "target_sizes.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "myalloc.h"
|
#include "myalloc.h"
|
||||||
#include "use_tmp.h"
|
#include "use_tmp.h"
|
||||||
#include "maxincl.h"
|
#include "maxincl.h"
|
||||||
#include "system.h"
|
|
||||||
#include "inputtype.h"
|
#include "inputtype.h"
|
||||||
#include "bufsiz.h"
|
|
||||||
|
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "level.h"
|
#include "level.h"
|
||||||
|
@ -134,10 +133,8 @@ compile(argc, argv)
|
||||||
int pp_only = options['E'] || options['P'];
|
int pp_only = options['E'] || options['P'];
|
||||||
#endif NOPP
|
#endif NOPP
|
||||||
|
|
||||||
source = argv[0];
|
source = strcmp(argv[0], "-") ? argv[0] : 0;
|
||||||
|
|
||||||
switch (argc) {
|
switch (argc) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
if (!pp_only)
|
if (!pp_only)
|
||||||
|
@ -147,7 +144,6 @@ compile(argc, argv)
|
||||||
case 2:
|
case 2:
|
||||||
destination = argv[1];
|
destination = argv[1];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
nmlist = argv[2];
|
nmlist = argv[2];
|
||||||
destination = argv[1];
|
destination = argv[1];
|
||||||
|
@ -160,22 +156,18 @@ compile(argc, argv)
|
||||||
#ifdef USE_TMP
|
#ifdef USE_TMP
|
||||||
tmpfile = mktemp(tmpname);
|
tmpfile = mktemp(tmpname);
|
||||||
#endif USE_TMP
|
#endif USE_TMP
|
||||||
|
if (strcmp(destination, "-") == 0)
|
||||||
if (!InsertFile(source, (char **) 0)) {
|
destination = 0;
|
||||||
/* read the source file */
|
if (!InsertFile(source, (char **) 0)) /* read the source file */
|
||||||
fatal("%s: no source file %s\n", prog_name, source);
|
fatal("%s: no source file %s\n", prog_name,
|
||||||
}
|
source ? source : "stdin");
|
||||||
init();
|
init();
|
||||||
|
/* FileName = source; /* needed ??? */
|
||||||
/* needed ??? */
|
|
||||||
FileName = source;
|
|
||||||
PushLex();
|
PushLex();
|
||||||
|
|
||||||
#ifndef NOPP
|
#ifndef NOPP
|
||||||
if (pp_only) {
|
if (pp_only) /* run the preprocessor as if it is stand-alone */
|
||||||
/* run the preprocessor as if it is stand-alone */
|
|
||||||
preprocess();
|
preprocess();
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
#endif NOPP
|
#endif NOPP
|
||||||
|
|
||||||
|
@ -365,20 +357,25 @@ preprocess()
|
||||||
AppendFile(src, dst)
|
AppendFile(src, dst)
|
||||||
char *src, *dst;
|
char *src, *dst;
|
||||||
{
|
{
|
||||||
int fd_src, fd_dst;
|
File *fp_src, *fp_dst;
|
||||||
char buf[BUFSIZ];
|
char buf[BUFSIZ];
|
||||||
int n;
|
int n;
|
||||||
|
|
||||||
if ((fd_src = sys_open(src, OP_RDONLY)) < 0) {
|
if (sys_open(src, OP_READ, &fp_src) == 0)
|
||||||
fatal("cannot read %s", src);
|
fatal("cannot read %s", src);
|
||||||
|
if (dst) {
|
||||||
|
if (sys_open(dst, OP_APPEND, &fp_dst) == 0)
|
||||||
|
fatal("cannot write to %s", src);
|
||||||
}
|
}
|
||||||
if ((fd_dst = sys_open(dst, OP_APPEND)) < 0) {
|
else
|
||||||
fatal("cannot write to %s", src);
|
fp_dst = STDOUT;
|
||||||
}
|
while (sys_read(fp_src, buf, BUFSIZ, &n) != 0 && n > 0)
|
||||||
while ((n = sys_read(fd_src, buf, BUFSIZ)) > 0) {
|
if (sys_write(fp_dst, buf, n) == 0)
|
||||||
sys_write(fd_dst, buf, n);
|
fatal("(AppendFile) write error");
|
||||||
}
|
if (n != 0)
|
||||||
sys_close(fd_src);
|
fatal("(AppendFile) read error");
|
||||||
sys_close(fd_dst);
|
sys_close(fp_src);
|
||||||
|
if (fp_dst != STDOUT)
|
||||||
|
sys_close(fp_dst);
|
||||||
}
|
}
|
||||||
#endif USE_TMP
|
#endif USE_TMP
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "use_tmp.h"
|
#include "use_tmp.h"
|
||||||
#include "botch_free.h"
|
#include "botch_free.h"
|
||||||
|
|
||||||
#include "system.h"
|
#include <system.h>
|
||||||
#include "alloc.h"
|
#include "alloc.h"
|
||||||
#include "Lpars.h"
|
#include "Lpars.h"
|
||||||
#include "arith.h"
|
#include "arith.h"
|
||||||
|
@ -267,22 +267,19 @@ unstack_world()
|
||||||
list is generated.
|
list is generated.
|
||||||
*/
|
*/
|
||||||
extern char *nmlist; /* BAH! -- main.c */
|
extern char *nmlist; /* BAH! -- main.c */
|
||||||
static int nfd;
|
static File *nfp = 0;
|
||||||
|
|
||||||
open_name_list()
|
open_name_list()
|
||||||
{
|
{
|
||||||
if (nmlist) {
|
if (nmlist && sys_open(nmlist, OP_WRITE, &nfp) == 0)
|
||||||
if ((nfd = sys_creat(nmlist, 0644)) < 0) {
|
fatal("cannot create namelist %s", nmlist);
|
||||||
fatal("cannot create namelist %s", nmlist);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namelist(nm)
|
namelist(nm)
|
||||||
char *nm;
|
char *nm;
|
||||||
{
|
{
|
||||||
if (nmlist) {
|
if (nmlist) {
|
||||||
sys_write(nfd, nm, strlen(nm));
|
sys_write(nfp, nm, strlen(nm));
|
||||||
sys_write(nfd, "\n", 1);
|
sys_write(nfp, "\n", 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +1,20 @@
|
||||||
/* $Header$ */
|
/* $Header$ */
|
||||||
/* STRING MANIPULATION AND PRINT ROUTINES */
|
/* STRING MANIPULATION AND PRINT ROUTINES */
|
||||||
|
|
||||||
|
#include <system.h>
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
#include "nopp.h"
|
#include "nopp.h"
|
||||||
#include "str_params.h"
|
#include "str_params.h"
|
||||||
#include "arith.h"
|
#include "arith.h"
|
||||||
#include "system.h"
|
|
||||||
|
|
||||||
doprnt(fd, fmt, argp)
|
doprnt(fp, fmt, argp)
|
||||||
|
File *fp;
|
||||||
char *fmt;
|
char *fmt;
|
||||||
int argp[];
|
int argp[];
|
||||||
{
|
{
|
||||||
char buf[SSIZE];
|
char buf[SSIZE];
|
||||||
|
|
||||||
sys_write(fd, buf, format(buf, fmt, (char *)argp));
|
sys_write(fp, buf, format(buf, fmt, (char *)argp));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*VARARGS1*/
|
/*VARARGS1*/
|
||||||
|
@ -23,17 +24,18 @@ printf(fmt, args)
|
||||||
{
|
{
|
||||||
char buf[SSIZE];
|
char buf[SSIZE];
|
||||||
|
|
||||||
sys_write(1, buf, format(buf, fmt, &args));
|
sys_write(STDOUT, buf, format(buf, fmt, &args));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*VARARGS1*/
|
/*VARARGS1*/
|
||||||
fprintf(fd, fmt, args)
|
fprintf(fp, fmt, args)
|
||||||
|
File *fp;
|
||||||
char *fmt;
|
char *fmt;
|
||||||
char args;
|
char args;
|
||||||
{
|
{
|
||||||
char buf[SSIZE];
|
char buf[SSIZE];
|
||||||
|
|
||||||
sys_write(fd, buf, format(buf, fmt, &args));
|
sys_write(fp, buf, format(buf, fmt, &args));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*VARARGS1*/
|
/*VARARGS1*/
|
||||||
|
|
Loading…
Reference in a new issue