Hi tech, Is anyone interested in this diff? The function declarations of lex(1) are ansified, as done in yacc(1) years ago. I've tested it on OpenBSD/i386 4.9 on a number of lex source files in src/usr.bin. Comments?
- Michael Index: ccl.c =================================================================== RCS file: /usr/src/cvs/src/usr.bin/lex/ccl.c,v retrieving revision 1.6 diff -u -r1.6 ccl.c --- ccl.c 4 Jun 2003 17:34:44 -0000 1.6 +++ ccl.c 27 Sep 2011 03:21:44 -0000 @@ -39,9 +39,8 @@ /* ccladd - add a single character to a ccl */ -void ccladd( cclp, ch ) -int cclp; -int ch; +void +ccladd(int cclp, int ch) { int ind, len, newpos, i; @@ -75,7 +74,8 @@ /* cclinit - return an empty ccl */ -int cclinit() +int +cclinit(void) { if ( ++lastccl >= current_maxccls ) { @@ -109,8 +109,8 @@ /* cclnegate - negate the given ccl */ -void cclnegate( cclp ) -int cclp; +void +cclnegate(int cclp) { cclng[cclp] = 1; } @@ -123,9 +123,8 @@ * has a non-zero value in the cset array. */ -void list_character_set( file, cset ) -FILE *file; -int cset[]; +void +list_character_set(FILE *file, int *cset) { int i; Index: dfa.c =================================================================== RCS file: /usr/src/cvs/src/usr.bin/lex/dfa.c,v retrieving revision 1.6 diff -u -r1.6 dfa.c --- dfa.c 4 Jun 2003 17:34:44 -0000 1.6 +++ dfa.c 27 Sep 2011 03:57:26 -0000 @@ -55,9 +55,8 @@ * indexed by equivalence class. */ -void check_for_backing_up( ds, state ) -int ds; -int state[]; +void +check_for_backing_up(int ds, int *state) { if ( (reject && ! dfaacc[ds].dfaacc_set) || (! reject && ! dfaacc[ds].dfaacc_state) ) @@ -105,10 +104,8 @@ * accset[1 .. nacc] is the list of accepting numbers for the DFA state. */ -void check_trailing_context( nfa_states, num_states, accset, nacc ) -int *nfa_states, num_states; -int *accset; -int nacc; +void +check_trailing_context(int *nfa_states, int num_states, int *accset, int nacc) { int i, j; @@ -150,9 +147,8 @@ * and writes a report to the given file. */ -void dump_associated_rules( file, ds ) -FILE *file; -int ds; +void +dump_associated_rules(FILE *file, int ds) { int i, j; int num_associated_rules = 0; @@ -202,9 +198,8 @@ * is done to the given file. */ -void dump_transitions( file, state ) -FILE *file; -int state[]; +void +dump_transitions(FILE *file, int *state) { int i, ec; int out_char_set[CSIZE]; @@ -251,8 +246,8 @@ * hashval is the hash value for the dfa corresponding to the state set. */ -int *epsclosure( t, ns_addr, accset, nacc_addr, hv_addr ) -int *t, *ns_addr, accset[], *nacc_addr, *hv_addr; +int * +epsclosure(int *t, int *ns_addr, int *accset, int *nacc_addr, int *hv_addr) { int stkpos, ns, tsp; int numstates = *ns_addr, nacc, hashval, transsym, nfaccnum; @@ -373,7 +368,8 @@ /* increase_max_dfas - increase the maximum number of DFAs */ -void increase_max_dfas() +void +increase_max_dfas(void) { current_max_dfas += MAX_DFAS_INCREMENT; @@ -399,7 +395,8 @@ * dfa starts out in state #1. */ -void ntod() +void +ntod(void) { int *accset, ds, nacc, newds; int sym, hashval, numstates, dsize; @@ -797,8 +794,9 @@ * On return, the dfa state number is in newds. */ -int snstods( sns, numstates, accset, nacc, hashval, newds_addr ) -int sns[], numstates, accset[], nacc, hashval, *newds_addr; +int +snstods(int *sns, int numstates, int *accset, int nacc, int hashval, + int *newds_addr) { int didsort = 0; int i, j; @@ -929,8 +927,8 @@ * int transsym, int nset[current_max_dfa_size] ); */ -int symfollowset( ds, dsize, transsym, nset ) -int ds[], dsize, transsym, nset[]; +int +symfollowset(int *ds, int dsize, int transsym, int *nset) { int ns, tsp, sym, i, j, lenccl, ch, numstates, ccllist; @@ -1017,9 +1015,8 @@ * int symlist[numecs], int duplist[numecs] ); */ -void sympartition( ds, numstates, symlist, duplist ) -int ds[], numstates; -int symlist[], duplist[]; +void +sympartition(int *ds, int numstates, int *symlist, int *duplist) { int tch, i, j, k, ns, dupfwd[CSIZE + 1], lenccl, cclp, ich; Index: ecs.c =================================================================== RCS file: /usr/src/cvs/src/usr.bin/lex/ecs.c,v retrieving revision 1.6 diff -u -r1.6 ecs.c --- ecs.c 4 Jun 2003 17:34:44 -0000 1.6 +++ ecs.c 27 Sep 2011 03:34:37 -0000 @@ -39,7 +39,8 @@ /* ccl2ecl - convert character classes to set of equivalence classes */ -void ccl2ecl() +void +ccl2ecl(void) { int i, ich, newlen, cclp, ccls, cclmec; @@ -80,8 +81,8 @@ * Returned is the number of classes. */ -int cre8ecs( fwd, bck, num ) -int fwd[], bck[], num; +int +cre8ecs(int *fwd, int *bck, int num) { int i, j, numcl; @@ -119,9 +120,8 @@ * NUL_mapping is the value which NUL (0) should be mapped to. */ -void mkeccl( ccls, lenccl, fwd, bck, llsiz, NUL_mapping ) -Char ccls[]; -int lenccl, fwd[], bck[], llsiz, NUL_mapping; +void +mkeccl(Char *ccls, int lenccl, int *fwd, int *bck, int llsiz, int NUL_mapping) { int cclp, oldec, newec; int cclm, i, j; @@ -214,8 +214,8 @@ /* mkechar - create equivalence class for single character */ -void mkechar( tch, fwd, bck ) -int tch, fwd[], bck[]; +void +mkechar(int tch, int *fwd, int *bck) { /* If until now the character has been a proper subset of * an equivalence class, break it away to create a new ec Index: gen.c =================================================================== RCS file: /usr/src/cvs/src/usr.bin/lex/gen.c,v retrieving revision 1.11 diff -u -r1.11 gen.c --- gen.c 3 Feb 2004 21:20:17 -0000 1.11 +++ gen.c 27 Sep 2011 04:06:50 -0000 @@ -66,7 +66,8 @@ /* Indent to the current level. */ -void do_indent() +void +do_indent(void) { int i = indent_level * 8; @@ -86,7 +87,8 @@ /* Generate the code to keep backing-up information. */ -void gen_backing_up() +void +gen_backing_up(void) { if ( reject || num_backing_up == 0 ) return; @@ -107,7 +109,8 @@ /* Generate the code to perform the backing up. */ -void gen_bu_action() +void +gen_bu_action(void) { if ( reject || num_backing_up == 0 ) return; @@ -136,7 +139,8 @@ /* genctbl - generates full speed compressed transition table */ -void genctbl() +void +genctbl(void) { int i; int end_of_buffer_action = num_rules + 1; @@ -232,7 +236,8 @@ /* Generate equivalence-class tables. */ -void genecs() +void +genecs(void) { int i, j; int numrows; @@ -274,7 +279,8 @@ /* Generate the code to find the action number. */ -void gen_find_action() +void +gen_find_action(void) { if ( fullspd ) indent_puts( "yy_act = yy_current_state[-1].yy_nxt;" ); @@ -413,7 +419,8 @@ /* genftbl - generate full transition table */ -void genftbl() +void +genftbl(void) { int i; int end_of_buffer_action = num_rules + 1; @@ -447,8 +454,8 @@ /* Generate the code to find the next compressed-table state. */ -void gen_next_compressed_state( char_map ) -char *char_map; +void +gen_next_compressed_state(char *char_map) { indent_put2s( "register YY_CHAR yy_c = %s;", char_map ); @@ -493,7 +500,8 @@ /* Generate the code to find the next match. */ -void gen_next_match() +void +gen_next_match(void) { /* NOTE - changes in here should be reflected in gen_next_state() and * gen_NUL_trans(). @@ -602,8 +610,8 @@ /* Generate the code to find the next state. */ -void gen_next_state( worry_about_NULs ) -int worry_about_NULs; +void +gen_next_state(int worry_about_NULs) { /* NOTE - changes in here should be reflected in gen_next_match() */ char char_map[256]; @@ -669,7 +677,8 @@ /* Generate the code to make a NUL transition. */ -void gen_NUL_trans() +void +gen_NUL_trans(void) { /* NOTE - changes in here should be reflected in gen_next_match() */ /* Only generate a definition for "yy_cp" if we'll generate code * that uses it. Otherwise lint and the like complain. @@ -756,7 +765,8 @@ /* Generate the code to find the start state. */ -void gen_start_state() +void +gen_start_state(void) { if ( fullspd ) { @@ -789,7 +799,8 @@ /* gentabs - generate data statements for the transition tables */ -void gentabs() +void +gentabs(void) { int i, j, k, *accset, nacc, *acc_array, total_states; int end_of_buffer_action = num_rules + 1; @@ -1039,8 +1050,8 @@ * current indentation level, adding a final newline. */ -void indent_put2s( fmt, arg ) -char fmt[], arg[]; +void +indent_put2s(char *fmt, char *arg) { do_indent(); out_str( fmt, arg ); @@ -1052,8 +1063,8 @@ * newline. */ -void indent_puts( str ) -char str[]; +void +indent_puts(char *str) { do_indent(); outn( str ); @@ -1063,7 +1074,8 @@ /* make_tables - generate transition tables and finishes generating output file */ -void make_tables() +void +make_tables(void) { int i; int did_eof_rule = false; Index: main.c =================================================================== RCS file: /usr/src/cvs/src/usr.bin/lex/main.c,v retrieving revision 1.12 diff -u -r1.12 main.c --- main.c 8 Jun 2011 20:22:02 -0000 1.12 +++ main.c 27 Sep 2011 04:00:04 -0000 @@ -130,9 +130,8 @@ static char *skelname = NULL; -int main( argc, argv ) -int argc; -char **argv; +int +main(int argc, char **argv) { int i; @@ -173,7 +172,8 @@ /* check_options - check user-specified options */ -void check_options() +void +check_options(void) { int i; @@ -349,9 +349,8 @@ * This routine does not return. */ -void flexend( exit_status ) -int exit_status; - +void +flexend(int exit_status) { int tblsiz; int unlink(); @@ -581,9 +580,8 @@ /* flexinit - initialize flex */ -void flexinit( argc, argv ) -int argc; -char **argv; +void +flexinit(int argc, char **argv) { int i, sawcmpflag; char *arg; @@ -850,7 +848,8 @@ /* readin - read in the rules section of the input file(s) */ -void readin() +void +readin(void) { static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; static char yy_nostdinit[] = @@ -1055,7 +1054,8 @@ /* set_up_initial_allocations - allocate memory for internal tables */ -void set_up_initial_allocations() +void +set_up_initial_allocations(void) { current_mns = INITIAL_MNS; firstst = allocate_integer_array( current_mns ); @@ -1110,7 +1110,8 @@ } -void usage() +void +usage(void) { FILE *f = stdout; Index: nfa.c =================================================================== RCS file: /usr/src/cvs/src/usr.bin/lex/nfa.c,v retrieving revision 1.9 diff -u -r1.9 nfa.c --- nfa.c 4 Jun 2003 17:34:44 -0000 1.9 +++ nfa.c 27 Sep 2011 03:45:26 -0000 @@ -49,8 +49,8 @@ * accepting_number becomes mach's accepting number. */ -void add_accept( mach, accepting_number ) -int mach, accepting_number; +void +add_accept(int mach, int accepting_number) { /* Hang the accepting number off an epsilon state. if it is associated * with a state that has a non-epsilon out-transition, then the state @@ -81,8 +81,8 @@ * num - the number of copies of singl to be present in newsng */ -int copysingl( singl, num ) -int singl, num; +int +copysingl(int singl, int num) { int copy, i; @@ -97,9 +97,8 @@ /* dumpnfa - debugging routine to write out an nfa */ -void dumpnfa( state1 ) -int state1; - +void +dumpnfa(int state1) { int sym, tsp1, tsp2, anum, ns; @@ -152,8 +151,8 @@ * states accessible by the arrays firstst and lastst */ -int dupmachine( mach ) -int mach; +int +dupmachine(int mach) { int i, init, state_offset; int state = 0; @@ -202,8 +201,8 @@ * context has variable length. */ -void finish_rule( mach, variable_trail_rule, headcnt, trailcnt ) -int mach, variable_trail_rule, headcnt, trailcnt; +void +finish_rule(int mach, int variable_trail_rule, int headcnt, int trailcnt) { char action_text[MAXLINE]; @@ -299,8 +298,8 @@ * FIRST is set to new by the operation. last is unmolested. */ -int link_machines( first, last ) -int first, last; +int +link_machines(int first, int last) { if ( first == NIL ) return last; @@ -327,8 +326,8 @@ * The "beginning" states are the epsilon closure of the first state */ -void mark_beginning_as_normal( mach ) -int mach; +void +mark_beginning_as_normal(int mach) { switch ( state_type[mach] ) { @@ -373,8 +372,8 @@ * more mkbranch's. Compare with mkor() */ -int mkbranch( first, second ) -int first, second; +int +mkbranch(int first, int second) { int eps; @@ -401,8 +400,8 @@ * new - a new state which matches the closure of "state" */ -int mkclos( state ) -int state; +int +mkclos(int state) { return mkopt( mkposcl( state ) ); } @@ -422,8 +421,8 @@ * 2. mach is destroyed by the call */ -int mkopt( mach ) -int mach; +int +mkopt(int mach) { int eps; @@ -460,8 +459,8 @@ * the number of epsilon states needed */ -int mkor( first, second ) -int first, second; +int +mkor(int first, int second) { int eps, orend; @@ -520,8 +519,8 @@ * new - a machine matching the positive closure of "state" */ -int mkposcl( state ) -int state; +int +mkposcl(int state) { int eps; @@ -552,8 +551,8 @@ * if "ub" is INFINITY then "new" matches "lb" or more occurrences of "mach" */ -int mkrep( mach, lb, ub ) -int mach, lb, ub; +int +mkrep(int mach, int lb, int ub) { int base_mach, tail, copy, i; @@ -599,8 +598,8 @@ * that it admittedly is) */ -int mkstate( sym ) -int sym; +int +mkstate(int sym) { if ( ++lastnfa >= current_mns ) { @@ -677,8 +676,8 @@ * stateto - the state to which the transition is to be made */ -void mkxtion( statefrom, stateto ) -int statefrom, stateto; +void +mkxtion(int statefrom, int stateto) { if ( trans1[statefrom] == NO_TRANSITION ) trans1[statefrom] = stateto; @@ -696,7 +695,8 @@ /* new_rule - initialize for a new rule */ -void new_rule() +void +new_rule(void) { if ( ++num_rules >= current_max_rules ) { Index: sym.c =================================================================== RCS file: /usr/src/cvs/src/usr.bin/lex/sym.c,v retrieving revision 1.6 diff -u -r1.6 sym.c --- sym.c 4 Jun 2003 17:34:44 -0000 1.6 +++ sym.c 27 Sep 2011 03:39:33 -0000 @@ -55,12 +55,8 @@ * -1 is returned if the symbol already exists, and the change not made. */ -int addsym( sym, str_def, int_def, table, table_size ) -char sym[]; -char *str_def; -int int_def; -hash_table table; -int table_size; +int +addsym(char *sym, char *str_def, int int_def, hash_table table, int table_size) { int hash_val = hashfunct( sym, table_size ); struct hash_entry *sym_entry = table[hash_val]; @@ -105,9 +101,8 @@ /* cclinstal - save the text of a character class */ -void cclinstal( ccltxt, cclnum ) -Char ccltxt[]; -int cclnum; +void +cclinstal(Char *ccltxt, int cclnum) { /* We don't bother checking the return status because we are not * called unless the symbol is new. @@ -125,8 +120,8 @@ * Returns 0 if there's no CCL associated with the text. */ -int ccllookup( ccltxt ) -Char ccltxt[]; +int +ccllookup(Char *ccltxt) { return findsym( (char *) ccltxt, ccltab, CCL_HASH_SIZE )->int_val; } @@ -134,10 +129,8 @@ /* findsym - find symbol in symbol table */ -struct hash_entry *findsym( sym, table, table_size ) -char sym[]; -hash_table table; -int table_size; +struct hash_entry * +findsym(char *sym, hash_table table, int table_size) { static struct hash_entry empty_entry = { @@ -160,9 +153,8 @@ /* hashfunct - compute the hash value for "str" and hash size "hash_size" */ -int hashfunct( str, hash_size ) -char str[]; -int hash_size; +int +hashfunct(char *str, int hash_size) { int hashval; int locstr; @@ -182,9 +174,8 @@ /* ndinstal - install a name definition */ -void ndinstal( name, definition ) -char name[]; -Char definition[]; +void +ndinstal(char *name, Char *definition) { char *copy_string(); Char *copy_unsigned_string(); @@ -201,8 +192,8 @@ * Returns a nil pointer if the name definition does not exist. */ -Char *ndlookup( nd ) -char nd[]; +Char * +ndlookup(char *nd) { return (Char *) findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE )->str_val; } @@ -210,7 +201,8 @@ /* scextend - increase the maximum number of start conditions */ -void scextend() +void +scextend(void) { current_max_scs += MAX_SCS_INCREMENT; @@ -230,9 +222,8 @@ * The start condition is "exclusive" if xcluflg is true. */ -void scinstal( str, xcluflg ) -char str[]; -int xcluflg; +void +scinstal(char *str, int xcluflg) { char *copy_string(); @@ -262,8 +253,8 @@ * Returns 0 if no such start condition. */ -int sclookup( str ) -char str[]; +int +sclookup(char *str) { return findsym( str, sctbl, START_COND_HASH_SIZE )->int_val; } Index: tblcmp.c =================================================================== RCS file: /usr/src/cvs/src/usr.bin/lex/tblcmp.c,v retrieving revision 1.6 diff -u -r1.6 tblcmp.c --- tblcmp.c 4 Jun 2003 17:34:44 -0000 1.6 +++ tblcmp.c 27 Sep 2011 03:51:14 -0000 @@ -82,8 +82,8 @@ * cost only one difference. */ -void bldtbl( state, statenum, totaltrans, comstate, comfreq ) -int state[], statenum, totaltrans, comstate, comfreq; +void +bldtbl(int *state, int statenum, int totaltrans, int comstate, int comfreq) { int extptr, extrct[2][CSIZE + 1]; int mindiff, minprot, i, d; @@ -232,7 +232,8 @@ * classes. */ -void cmptmps() +void +cmptmps(void) { int tmpstorage[CSIZE + 1]; int *tmp = tmpstorage, i, j; @@ -305,7 +306,8 @@ /* expand_nxt_chk - expand the next check arrays */ -void expand_nxt_chk() +void +expand_nxt_chk(void) { int old_max = current_max_xpairs; @@ -340,8 +342,8 @@ * and an action number will be added in [-1]. */ -int find_table_space( state, numtrans ) -int *state, numtrans; +int +find_table_space(int *state, int numtrans) { /* Firstfree is the position of the first possible occurrence of two * consecutive unused records in the chk and nxt arrays. @@ -439,7 +441,8 @@ * Initializes "firstfree" to be one beyond the end of the table. Initializes * all "chk" entries to be zero. */ -void inittbl() +void +inittbl(void) { int i; @@ -471,7 +474,8 @@ /* mkdeftbl - make the default, "jam" table entries */ -void mkdeftbl() +void +mkdeftbl(void) { int i; @@ -521,9 +525,8 @@ * state array. */ -void mkentry( state, numchars, statenum, deflink, totaltrans ) -int *state; -int numchars, statenum, deflink, totaltrans; +void +mkentry(int *state, int numchars, int statenum, int deflink, int totaltrans) { int minec, maxec, i, baseaddr; int tblbase, tbllast; @@ -649,8 +652,8 @@ * has only one out-transition */ -void mk1tbl( state, sym, onenxt, onedef ) -int state, sym, onenxt, onedef; +void +mk1tbl(int state, int sym, int onenxt, int onedef) { if ( firstfree < sym ) firstfree = sym; @@ -676,8 +679,8 @@ /* mkprot - create new proto entry */ -void mkprot( state, statenum, comstate ) -int state[], statenum, comstate; +void +mkprot(int *state, int statenum, int comstate) { int i, slot, tblbase; @@ -715,8 +718,8 @@ * to it */ -void mktemplate( state, statenum, comstate ) -int state[], statenum, comstate; +void +mktemplate(int *state, int statenum, int comstate) { int i, numdiff, tmpbase, tmp[CSIZE + 1]; Char transset[CSIZE + 1]; @@ -768,8 +771,8 @@ /* mv2front - move proto queue element to front of queue */ -void mv2front( qelm ) -int qelm; +void +mv2front(int qelm) { if ( firstprot != qelm ) { @@ -796,8 +799,8 @@ * Transnum is the number of out-transitions for the state. */ -void place_state( state, statenum, transnum ) -int *state, statenum, transnum; +void +place_state(int *state, int statenum, int transnum) { int i; int *state_ptr; @@ -840,8 +843,8 @@ * no room, we process the sucker right now. */ -void stack1( statenum, sym, nextstate, deflink ) -int statenum, sym, nextstate, deflink; +void +stack1(int statenum, int sym, int nextstate, int deflink) { if ( onesp >= ONE_STACK_SIZE - 1 ) mk1tbl( statenum, sym, nextstate, deflink ); @@ -871,8 +874,8 @@ * number is "numecs" minus the number of "SAME_TRANS" entries in "ext". */ -int tbldiff( state, pr, ext ) -int state[], pr, ext[]; +int +tbldiff(int *state, int pr, int *ext) { int i, *sp = state, *ep = ext, *protp; int numdiff = 0;