diff options
author | des <des@FreeBSD.org> | 1998-12-18 14:29:51 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 1998-12-18 14:29:51 +0000 |
commit | ab07ab9139e4a2d73f282d0a2561ce56fa53ddea (patch) | |
tree | 55aaa002e948aa824010d09254ee122d28657fc2 /usr.bin | |
parent | 615c9f88c437295dc1b02ba8b680a45fa9386835 (diff) | |
download | FreeBSD-src-ab07ab9139e4a2d73f282d0a2561ce56fa53ddea.zip FreeBSD-src-ab07ab9139e4a2d73f282d0a2561ce56fa53ddea.tar.gz |
Unbreak K&R support, and generate code that works in K&R C as well as
ANSI C no matter what language is specified.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/compile_et/compile_et.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/usr.bin/compile_et/compile_et.c b/usr.bin/compile_et/compile_et.c index 6250d4a..92fd0c2 100644 --- a/usr.bin/compile_et/compile_et.c +++ b/usr.bin/compile_et/compile_et.c @@ -26,7 +26,7 @@ static const char copyright[] = "Copyright 1987,1988 by MIT Student Information Processing Board"; static const char rcsid_compile_et_c[] = - "$Header: /home/ncvs/src/usr.bin/compile_et/compile_et.c,v 1.4 1997/06/30 06:42:41 charnier Exp $"; + "$Header: /home/ncvs/src/usr.bin/compile_et/compile_et.c,v 1.5 1998/12/15 12:20:27 des Exp $"; #endif extern char *gensym(); @@ -73,19 +73,13 @@ static const char *const language_names[] = { 0, }; -static const char * const c_src_prolog[] = { - "static const char * const text[] = {\n", - 0, -}; - -static const char * const krc_src_prolog[] = { +static const char * const noargs_def[] = { "#ifdef __STDC__\n", "#define NOARGS void\n", "#else\n", "#define NOARGS\n", "#define const\n", "#endif\n\n", - "static const char * const text[] = {\n", 0, }; @@ -221,14 +215,12 @@ int main (argc, argv) int argc; char **argv; { fprintf (cfile, warning, c_file); /* prologue */ - if (language == lang_C) - cpp = c_src_prolog; - else if (language == lang_KRC) - cpp = krc_src_prolog; - else - abort (); - while (*cpp) - fputs (*cpp++, cfile); + for (cpp = noargs_def; *cpp; cpp++) { + fputs (*cpp, cfile); + fputs (*cpp, hfile); + } + + fputs("static const char * const text[] = {\n", cfile); /* parse it */ yyparse(); @@ -242,8 +234,8 @@ int main (argc, argv) int argc; char **argv; { table_number, current); fputs("static struct et_list link = { 0, 0 };\n\n", cfile); - fprintf(cfile, "void initialize_%s_error_table (%s) {\n", - table_name, (language == lang_C) ? "void" : "NOARGS"); + fprintf(cfile, "void initialize_%s_error_table (NOARGS) {\n", + table_name); fputs(" if (!link.table) {\n", cfile); fputs(" link.next = _et_list;\n", cfile); fputs(" link.table = &et;\n", cfile); @@ -252,8 +244,8 @@ int main (argc, argv) int argc; char **argv; { fputs("}\n", cfile); fclose(cfile); - fprintf (hfile, "extern void initialize_%s_error_table (%s);\n", - table_name, (language == lang_C) ? "void" : ""); + fprintf (hfile, "extern void initialize_%s_error_table (NOARGS);\n", + table_name); fprintf (hfile, "#define ERROR_TABLE_BASE_%s (%dL)\n", table_name, table_number); /* compatibility... */ |