Merge pull request #32 from enh/master

maketab: support build systems with read-only source.
This commit is contained in:
onetrueawk 2019-03-03 15:11:28 -05:00 committed by GitHub
commit 2d9034a01a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 3 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
a.out
maketab
proctab.c
ytab.c
ytab.h
*.o

View File

@ -67,7 +67,7 @@ y%.c y%.h: awk.h proto.h awkgram.y
ytab.h: ytab.c
proctab.c: maketab
./maketab >proctab.c
./maketab ytab.h >proctab.c
maketab: ytab.h maketab.c
$(CC) $(CFLAGS) maketab.c -o maketab

View File

@ -125,8 +125,12 @@ int main(int argc, char *argv[])
for (i = SIZE; --i >= 0; )
names[i] = "";
if ((fp = fopen("ytab.h", "r")) == NULL) {
fprintf(stderr, "maketab can't open ytab.h!\n");
if (argc != 2) {
fprintf(stderr, "usage: maketab YTAB_H\n");
exit(1);
}
if ((fp = fopen(argv[1], "r")) == NULL) {
fprintf(stderr, "maketab can't open %s!\n", argv[1]);
exit(1);
}
printf("static char *printname[%d] = {\n", SIZE);