Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/dist/nawk use awkgram.h, generate constified printname[] and...
details: https://anonhg.NetBSD.org/src/rev/5a482acec47d
branches: trunk
changeset: 503422:5a482acec47d
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Mon Feb 05 19:07:15 2001 +0000
description:
use awkgram.h, generate constified printname[] and tokname()
diffstat:
dist/nawk/maketab.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diffs (50 lines):
diff -r 3169dd5a9d04 -r 5a482acec47d dist/nawk/maketab.c
--- a/dist/nawk/maketab.c Mon Feb 05 19:06:02 2001 +0000
+++ b/dist/nawk/maketab.c Mon Feb 05 19:07:15 2001 +0000
@@ -32,7 +32,7 @@
#include <string.h>
#include <stdlib.h>
#include "awk.h"
-#include "ytab.h"
+#include "awkgram.h"
struct xx
{ int token;
@@ -120,15 +120,15 @@
printf("#include <stdio.h>\n");
printf("#include \"awk.h\"\n");
- printf("#include \"ytab.h\"\n\n");
+ printf("#include \"awkgram.h\"\n\n");
for (i = SIZE; --i >= 0; )
names[i] = "";
- if ((fp = fopen("ytab.h", "r")) == NULL) {
- fprintf(stderr, "maketab can't open ytab.h!\n");
+ if ((fp = fopen("awkgram.h", "r")) == NULL) {
+ fprintf(stderr, "maketab can't open awkgram.h!\n");
exit(1);
}
- printf("static char *printname[%d] = {\n", SIZE);
+ printf("static const char * const printname[%d] = {\n", SIZE);
i = 0;
while (fgets(buf, sizeof buf, fp) != NULL) {
n = sscanf(buf, "%1c %s %s %d", &c, def, name, &tok);
@@ -140,7 +140,7 @@
}
names[tok-FIRSTTOKEN] = (char *) malloc(strlen(name)+1);
strcpy(names[tok-FIRSTTOKEN], name);
- printf("\t(char *) \"%s\",\t/* %d */\n", name, tok);
+ printf("\t\"%s\",\t/* %d */\n", name, tok);
i++;
}
printf("};\n\n");
@@ -155,7 +155,7 @@
printf("\t%s,\t/* %s */\n", table[i], names[i]);
printf("};\n\n");
- printf("char *tokname(int n)\n"); /* print a tokname() function */
+ printf("const char *tokname(int n)\n"); /* print a tokname() function */
printf("{\n");
printf(" static char buf[100];\n\n");
printf(" if (n < FIRSTTOKEN || n > LASTTOKEN) {\n");
Home |
Main Index |
Thread Index |
Old Index