From 30762ac4848a71fd2fb8fe259925e135e557ed0f Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Mon, 6 Jun 2016 18:04:59 +0100 Subject: [PATCH] cpp: ANSIfy so it passes fcc ok --- Applications/cpp/cpp.c | 75 ++++++++++++--------------------------- Applications/cpp/hash.c | 15 ++------ Applications/cpp/main.c | 55 ++++++++-------------------- Applications/cpp/token1.h | 8 ++--- Applications/cpp/token2.h | 8 ++--- 5 files changed, 44 insertions(+), 117 deletions(-) diff --git a/Applications/cpp/cpp.c b/Applications/cpp/cpp.c index a6e73377..d32c288b 100644 --- a/Applications/cpp/cpp.c +++ b/Applications/cpp/cpp.c @@ -114,8 +114,7 @@ static int_type get_exp_value P((void)); static void gen_substrings P((char *, char *, int, int)); static char * insert_substrings P((char *, struct arg_store *, int)); -int -gettok() +int gettok(void) { int ch; @@ -184,13 +183,11 @@ gettok() } } -static int -gettok_nosub() +static int gettok_nosub(void) { int rv; dont_subst++; rv=get_onetok(SKIP_SPACE); dont_subst--; return rv; } static int -get_onetok(keep) -int keep; +get_onetok(int keep) { char * p; int state; @@ -449,8 +446,7 @@ break_break: return ch; } -static int -pgetc() +static int pgetc(void) { int ch, ch1; @@ -507,8 +503,7 @@ pgetc() } /* This function handles the first and second translation phases of Ansi-C */ -static int -chget() +static int chget(void) { int ch, ch1; for(;;) { @@ -544,8 +539,7 @@ chget() } } -static void -unchget(ch) +static void unchget(int ch) { #if CPP_DEBUG fprintf(stderr, "\b", ch); @@ -560,8 +554,7 @@ unchget(ch) if( ch == '\n' ) c_lineno--; } -static int -chget_raw() +static int chget_raw(void) #if CPP_DEBUG { int ch; @@ -581,8 +574,7 @@ static int last_fi = 0; return ch; } -static int -realchget() +static int realchget(void) #endif { int ch; @@ -634,8 +626,7 @@ realchget() } } -static int -do_preproc() +static int do_preproc(void) { int val, no_match=0; @@ -702,8 +693,7 @@ do_preproc() return 0; } -static int -do_proc_copy_hashline() +static int do_proc_copy_hashline(void) { int off, ch; @@ -725,8 +715,7 @@ do_proc_copy_hashline() return TK_COPY; } -static void -do_proc_include() +static void do_proc_include(void) { int ch, ch1; char * p; @@ -771,8 +760,7 @@ do_proc_include() return; } -static void -do_proc_define() +static void do_proc_define(void) { int ch, ch1; struct define_item * ptr, * old_value = 0; @@ -887,8 +875,7 @@ do_proc_define() while(ch != '\n') ch = pgetc(); } -static void -do_proc_undef() +static void do_proc_undef(void) { int ch; struct define_item * ptr; @@ -913,9 +900,7 @@ do_proc_undef() } } -static int -do_proc_if(type) -int type; +static int do_proc_if(int type) { int ch = 0; if(if_false && if_hidden) @@ -982,8 +967,7 @@ int type; return 0; } -static void -do_proc_else() +static void do_proc_else(void) { if( if_hidden == 0 ) { @@ -998,8 +982,7 @@ do_proc_else() do_proc_tail(); } -static void -do_proc_endif() +static void do_proc_endif(void) { if( if_hidden ) if_hidden--; @@ -1018,8 +1001,7 @@ do_proc_endif() do_proc_tail(); } -static void -do_proc_tail() +static void do_proc_tail(void) { int ch, flg=1; while((ch = pgetc()) != '\n') if(ch > ' ') @@ -1030,8 +1012,7 @@ do_proc_tail() } } -static int -get_if_expression() +static int get_if_expression(void) { int value = get_expression(0); @@ -1041,9 +1022,7 @@ get_if_expression() return value; } -static int_type -get_expression(prio) -int prio; +static int_type get_expression(int prio) { int_type lvalue; int_type rvalue; @@ -1175,8 +1154,7 @@ int prio; return lvalue; } -static int_type -get_exp_value() +static int_type get_exp_value(void) { int_type value = 0; int sign = 1; @@ -1254,12 +1232,7 @@ get_exp_value() return sign<0 ? -value: value; } -void -gen_substrings(macname, data_str, arg_count, is_vararg) -char * macname; -char * data_str; -int arg_count; -int is_vararg; +void gen_substrings(char *macname, char *data_str, int arg_count, int is_vararg) { char * mac_text = 0; struct arg_store *arg_list; @@ -1380,11 +1353,7 @@ int is_vararg; #endif } -static char * -insert_substrings(data_str, arg_list, arg_count) -char * data_str; -struct arg_store *arg_list; -int arg_count; +static char *insert_substrings(char *data_str, struct arg_store *arg_list, int arg_count) { int ac, ch; char * p, * s; diff --git a/Applications/cpp/hash.c b/Applications/cpp/hash.c index 6013c54b..e9b122af 100644 --- a/Applications/cpp/hash.c +++ b/Applications/cpp/hash.c @@ -30,10 +30,7 @@ int hashsize = 0xFF; /* 2^X -1 */ int hashcount = 0; static int hashvalue P((int namespace, char * word)); -void * -read_entry(namespace, word) -int namespace; -char * word; +void *read_entry(int namespace, char *word) { int hash_val; struct hashentry * hashline; @@ -52,11 +49,7 @@ char * word; return 0; } -char * -set_entry(namespace, word, value) -int namespace; -char * word; -void * value; +char *set_entry(int namespace, char *word, void *value) { int hash_val, i; struct hashentry * hashline, *prev; @@ -103,9 +96,7 @@ void * value; return hashline->word; } -static int hashvalue(namespace, word) -int namespace; -char * word; +static int hashvalue(int namespace, char *word) { int val = namespace; char *p = word; diff --git a/Applications/cpp/main.c b/Applications/cpp/main.c index 78db160c..848d55e7 100644 --- a/Applications/cpp/main.c +++ b/Applications/cpp/main.c @@ -37,10 +37,7 @@ int exit_code = 0; char * outfile = 0; FILE * ofd = 0; -int -main(argc, argv) -int argc; -char ** argv; +int main(int argc, char *argv[]) { int ar, i; char * p; @@ -139,6 +136,7 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile"; if (!curfile) cfatal(Usage); +#if 0 /* Define date and time macros. */ if (dialect != DI_KNR) { time_t now; @@ -154,6 +152,7 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile"; sprintf(buf, "__DATE__=\"%.3s %.2s %.4s\"", timep + 4, timep + 8, timep + 20); define_macro(buf); } +#endif if (outfile) ofd = fopen(outfile, "w"); else ofd = stdout; @@ -169,9 +168,7 @@ static char Usage[] = "Usage: cpp -E -0 -Dxxx -Uxxx -Ixxx infile -o outfile"; exit(exit_code); } -void -undefine_macro(name) -char * name; +void undefine_macro(char * name) { struct define_item * ptr; @@ -182,9 +179,7 @@ char * name; } } -void -define_macro(name) -char * name; +void define_macro(char *name) { char * p; char * value; @@ -206,11 +201,7 @@ char * name; ptr->next = 0; } -FILE * -open_include(fname, mode, checkrel) -char * fname; -char * mode; -int checkrel; +FILE *open_include(char *fname, char *mode, int checkrel) { FILE * fd = 0; int i; @@ -246,10 +237,7 @@ int checkrel; static int outpos = 0; -void -cmsg(mtype, str) -char * mtype; -char * str; +void cmsg(char *mtype, char *str) { if (c_fname && (*c_fname || c_lineno)) fprintf(stderr, "%s:%d: ", c_fname, c_lineno); @@ -260,39 +248,30 @@ char * str; fprintf(stderr, "%s\n", str); } -void -cfatal(str) -char * str; +void cfatal(char *str) { cmsg("CPP-FATAL error", str); exit(255); } -void -cerror(str) -char * str; +void cerror(char * str) { exit_code = 1; cmsg("error", str); } -void -cwarn(str) -char * str; +void cwarn(char * str) { cmsg("warning", str); } -void -pr_indent(count) -int count; +void pr_indent(int count) { if(count>10) count=10; while(count>0) {fprintf(ofd, "\t"); count--; } } -void -hash_line() +void hash_line(void) { if( strcmp(last_name, c_fname) != 0 ) last_line = -1; if( c_lineno != last_line || last_line <= 0 ) @@ -321,8 +300,7 @@ hash_line() } } -void -print_toks_cpp() +void print_toks_cpp(void) { int i; int indent=0; @@ -382,8 +360,7 @@ print_toks_cpp() outpos = 0; } -void -print_toks_raw() +void print_toks_raw(void) { int i; long val; @@ -438,9 +415,7 @@ print_toks_raw() } } -char * -token_txn(token) -int token; +char *token_txn(int token) { char * s = "UNKNOWN"; static char buf[17]; diff --git a/Applications/cpp/token1.h b/Applications/cpp/token1.h index 2e2b9eba..1d458e0b 100644 --- a/Applications/cpp/token1.h +++ b/Applications/cpp/token1.h @@ -12,9 +12,7 @@ __inline #endif static unsigned int -hash1 (str, len) - register const char *str; - register unsigned int len; +hash1 (const char *str, unsigned int len) { static unsigned char asso_values[] = { @@ -52,9 +50,7 @@ hash1 (str, len) __inline #endif struct token_trans * -is_ctok (str, len) - register const char *str; - register unsigned int len; +is_ctok (const char *str, unsigned int len) { static struct token_trans wordlist[] = { diff --git a/Applications/cpp/token2.h b/Applications/cpp/token2.h index 62e69b1c..aab94aaa 100644 --- a/Applications/cpp/token2.h +++ b/Applications/cpp/token2.h @@ -12,9 +12,7 @@ __inline #endif static unsigned int -hash2 (str, len) - register const char *str; - register unsigned int len; +hash2 (const char *str, unsigned int len) { static unsigned char asso_values[] = { @@ -64,9 +62,7 @@ hash2 (str, len) __inline #endif struct token_trans * -is_ckey (str, len) - register const char *str; - register unsigned int len; +is_ckey (const char *str, unsigned int len) { static struct token_trans wordlist[] = { -- 2.34.1