diff --git a/.gitignore b/.gitignore index f469d21..c426b13 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ a.out maketab proctab.c -ytab.c -ytab.h *.o diff --git a/ChangeLog b/ChangeLog index 4e95699..6ce9417 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2020-07-30 Arnold D. Robbins + + By fiat, we use bison for $(YACC). Trying to accommodate + different versions didn't work. + + * makefile: Significant cleanup. Replace all ytab* references + with awkgram.tab.* and simplify definition of YACC. + * .gitignore: Remove ytab* references. + * b.c, lex.c, maketab.c, parse.c, run.c: Replace include of ytab.h + with awkgram.tab.h. + * lib.c, main.c, tran.c: Remove include of ytab.h, wasn't needed. + 2020-01-20 Arnold D. Robbins * run.c (openfile): Set the close-on-exec flag for file diff --git a/b.c b/b.c index a338d43..776a806 100644 --- a/b.c +++ b/b.c @@ -32,7 +32,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.tab.h" #define MAXLIN 22 diff --git a/lex.c b/lex.c index 2cd7672..73cdddb 100644 --- a/lex.c +++ b/lex.c @@ -27,7 +27,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.tab.h" extern YYSTYPE yylval; extern bool infunc; diff --git a/lib.c b/lib.c index ab3ae53..92f28f5 100644 --- a/lib.c +++ b/lib.c @@ -31,7 +31,6 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" char EMPTY[] = { '\0' }; FILE *infile = NULL; diff --git a/main.c b/main.c index a3e0022..602942e 100644 --- a/main.c +++ b/main.c @@ -32,7 +32,6 @@ const char *version = "version 20200702"; #include #include #include "awk.h" -#include "ytab.h" extern char **environ; extern int nfields; diff --git a/makefile b/makefile index d7d4bd2..5133698 100644 --- a/makefile +++ b/makefile @@ -34,54 +34,43 @@ CFLAGS = -O2 HOSTCC = gcc -g -Wall -pedantic -Wcast-qual CC = $(HOSTCC) # change this is cross-compiling. -# yacc options. pick one; this varies a lot by system. -#YFLAGS = -d -S +# By fiat, to make our lives easier, yacc is now defined to be bison. +# If you want something else, you're on your own. YACC = bison -d -#YACC = yacc -d -# -S uses sprintf in yacc parser instead of sprint OFILES = b.o main.o parse.o proctab.o tran.o lib.o run.o lex.o -SOURCE = awk.h ytab.c ytab.h proto.h awkgram.y lex.c b.c main.c \ +SOURCE = awk.h awkgram.tab.c awkgram.tab.h proto.h awkgram.y lex.c b.c main.c \ maketab.c parse.c lib.c run.c tran.c proctab.c LISTING = awk.h proto.h awkgram.y lex.c b.c main.c maketab.c parse.c \ lib.c run.c tran.c -SHIP = README LICENSE FIXES $(SOURCE) ytab[ch].bak makefile \ +SHIP = README LICENSE FIXES $(SOURCE) awkgram.tab.[ch].bak makefile \ awk.1 -a.out: ytab.o $(OFILES) - $(CC) $(CFLAGS) ytab.o $(OFILES) $(ALLOC) -lm +a.out: awkgram.tab.o $(OFILES) + $(CC) $(CFLAGS) awkgram.tab.o $(OFILES) $(ALLOC) -lm -$(OFILES): awk.h ytab.h proto.h +$(OFILES): awk.h awkgram.tab.h proto.h -# Clear dependency for parallel build: (make -j) -# Depending if we used yacc or bison we can be generating different names -# ({awkgram,y}.tab.{c,h}) so try to move both. We could be using -p to -# specify the output prefix, but older yacc's don't support it. -ytab.c ytab.h: awk.h proto.h awkgram.y +awkgram.tab.c awkgram.tab.h: awk.h proto.h awkgram.y $(YACC) $(YFLAGS) awkgram.y - -@for i in c h; do for j in awkgram y; do \ - if [ -f "$$j.tab.$$i" ]; then mv $$j.tab.$$i ytab.$$i; fi; \ - done; done - -ytab.h: ytab.c proctab.c: maketab - ./maketab ytab.h >proctab.c + ./maketab awkgram.tab.h >proctab.c -maketab: ytab.h maketab.c +maketab: awkgram.tab.h maketab.c $(HOSTCC) $(CFLAGS) maketab.c -o maketab bundle: - @cp ytab.h ytabh.bak - @cp ytab.c ytabc.bak + @cp awkgram.tab.h awkgram.tab.h.bak + @cp awkgram.tab.c awkgram.tab.c.bak @bundle $(SHIP) tar: - @cp ytab.h ytabh.bak - @cp ytab.c ytabc.bak + @cp awkgram.tab.h awkgram.tab.h.bak + @cp awkgram.tab.c awkgram.tab.c.bak @bundle $(SHIP) >awk.shar @tar cf awk.tar $(SHIP) gzip awk.tar @@ -110,7 +99,7 @@ clean: testclean rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda # proctab.c cleaner: testclean - rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda proctab.c ytab* + rm -f a.out *.o *.obj maketab maketab.exe *.bb *.bbg *.da *.gcov *.gcno *.gcda proctab.c awkgram.tab.* # This is a bit of a band-aid until we can invest some more time # in the test suite. @@ -119,4 +108,4 @@ testclean: glop glop1 glop2 lilly.diff tempbig tempsmall time # For the habits of GNU maintainers: -distclean: clean +distclean: cleaner diff --git a/maketab.c b/maketab.c index 2384d51..433541e 100644 --- a/maketab.c +++ b/maketab.c @@ -25,14 +25,14 @@ THIS SOFTWARE. /* * this program makes the table to link function names * and type indices that is used by execute() in run.c. - * it finds the indices in ytab.h, produced by yacc. + * it finds the indices in awkgram.tab.h, produced by bison. */ #include #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.tab.h" struct xx { int token; @@ -122,7 +122,7 @@ int main(int argc, char *argv[]) printf("#include \n"); printf("#include \"awk.h\"\n"); - printf("#include \"ytab.h\"\n\n"); + printf("#include \"awkgram.tab.h\"\n\n"); if (argc != 2) { fprintf(stderr, "usage: maketab YTAB_H\n"); diff --git a/parse.c b/parse.c index b13e0c4..1466c38 100644 --- a/parse.c +++ b/parse.c @@ -27,7 +27,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.tab.h" Node *nodealloc(int n) { diff --git a/run.c b/run.c index bb6b7fe..1fef8cd 100644 --- a/run.c +++ b/run.c @@ -38,7 +38,7 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" +#include "awkgram.tab.h" static void stdinit(void); static void flush_all(void); diff --git a/tran.c b/tran.c index f0a0a09..2617b85 100644 --- a/tran.c +++ b/tran.c @@ -29,7 +29,6 @@ THIS SOFTWARE. #include #include #include "awk.h" -#include "ytab.h" #define FULLTAB 2 /* rehash when table gets this x full */ #define GROWTAB 4 /* grow table by this factor */