diff options
author | wlestes <wlestes> | 2002-08-27 18:07:19 +0000 |
---|---|---|
committer | wlestes <wlestes> | 2002-08-27 18:07:19 +0000 |
commit | 2309e9d544b00bd246bc998f5c7ff021e613a689 (patch) | |
tree | adc16a831b4730ce23fa66eccf7bc29fbe4cca42 /sym.c | |
parent | f1e5b59ed26c9f83c7b2106f606dfc4d9cf53e12 (diff) | |
download | flex-2309e9d544b00bd246bc998f5c7ff021e613a689.tar.gz |
ran the indent target; commit the results
Diffstat (limited to 'sym.c')
-rw-r--r-- | sym.c | 215 |
1 files changed, 105 insertions, 110 deletions
@@ -39,13 +39,12 @@ * ccltab - character class text symbol table */ -struct hash_entry - { +struct hash_entry { struct hash_entry *prev, *next; - char *name; - char *str_val; - int int_val; - } ; + char *name; + char *str_val; + int int_val; +}; typedef struct hash_entry **hash_table; @@ -53,17 +52,19 @@ typedef struct hash_entry **hash_table; #define START_COND_HASH_SIZE 101 #define CCL_HASH_SIZE 101 -static struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; +static struct hash_entry *ndtbl[NAME_TABLE_HASH_SIZE]; static struct hash_entry *sctbl[START_COND_HASH_SIZE]; static struct hash_entry *ccltab[CCL_HASH_SIZE]; /* declare functions that have forward references */ -static int addsym PROTO((register char[], char*, int, hash_table, int)); -static struct hash_entry *findsym PROTO(( register const char *sym, - hash_table table, int table_size)); -static int hashfunct PROTO((register const char*, int)); +static int addsym PROTO ((register char[], char *, int, hash_table, int)); +static struct hash_entry *findsym PROTO ((register const char *sym, + hash_table table, + + int table_size)); +static int hashfunct PROTO ((register const char *, int)); /* addsym - add symbol and definitions to symbol table @@ -71,40 +72,37 @@ static int hashfunct PROTO((register const char*, int)); * -1 is returned if the symbol already exists, and the change not made. */ -static int addsym( sym, str_def, int_def, table, table_size ) -register char sym[]; -char *str_def; -int int_def; -hash_table table; -int table_size; - { - int hash_val = hashfunct( sym, table_size ); +static int addsym (sym, str_def, int_def, table, table_size) + register char sym[]; + char *str_def; + int int_def; + hash_table table; + int table_size; +{ + int hash_val = hashfunct (sym, table_size); register struct hash_entry *sym_entry = table[hash_val]; register struct hash_entry *new_entry; register struct hash_entry *successor; - while ( sym_entry ) - { - if ( ! strcmp( sym, sym_entry->name ) ) - { /* entry already exists */ + while (sym_entry) { + if (!strcmp (sym, sym_entry->name)) { /* entry already exists */ return -1; - } + } sym_entry = sym_entry->next; - } + } /* create new entry */ new_entry = (struct hash_entry *) - flex_alloc( sizeof( struct hash_entry ) ); + flex_alloc (sizeof (struct hash_entry)); - if ( new_entry == NULL ) - flexfatal( _( "symbol table memory allocation failed" ) ); + if (new_entry == NULL) + flexfatal (_("symbol table memory allocation failed")); - if ( (successor = table[hash_val]) != 0 ) - { + if ((successor = table[hash_val]) != 0) { new_entry->next = successor; successor->prev = new_entry; - } + } else new_entry->next = NULL; @@ -116,23 +114,22 @@ int table_size; table[hash_val] = new_entry; return 0; - } +} /* cclinstal - save the text of a character class */ -void cclinstal( ccltxt, cclnum ) -Char ccltxt[]; -int cclnum; - { +void cclinstal (ccltxt, cclnum) + Char ccltxt[]; + int cclnum; +{ /* We don't bother checking the return status because we are not * called unless the symbol is new. */ - (void) addsym( (char *) copy_unsigned_string( ccltxt ), - (char *) 0, cclnum, - ccltab, CCL_HASH_SIZE ); - } + (void) addsym ((char *) copy_unsigned_string (ccltxt), + (char *) 0, cclnum, ccltab, CCL_HASH_SIZE); +} /* ccllookup - lookup the number associated with character class text @@ -140,73 +137,71 @@ int cclnum; * Returns 0 if there's no CCL associated with the text. */ -int ccllookup( ccltxt ) -Char ccltxt[]; - { - return findsym( (char *) ccltxt, ccltab, CCL_HASH_SIZE )->int_val; - } +int ccllookup (ccltxt) + Char ccltxt[]; +{ + return findsym ((char *) ccltxt, ccltab, CCL_HASH_SIZE)->int_val; +} /* findsym - find symbol in symbol table */ -static struct hash_entry *findsym( sym, table, table_size ) -register const char *sym; -hash_table table; -int table_size; - { - static struct hash_entry empty_entry = - { +static struct hash_entry *findsym (sym, table, table_size) + register const char *sym; + hash_table table; + int table_size; +{ + static struct hash_entry empty_entry = { (struct hash_entry *) 0, (struct hash_entry *) 0, (char *) 0, (char *) 0, 0, - } ; + }; register struct hash_entry *sym_entry = - table[hashfunct( sym, table_size )]; - while ( sym_entry ) - { - if ( ! strcmp( sym, sym_entry->name ) ) + table[hashfunct (sym, table_size)]; + + while (sym_entry) { + if (!strcmp (sym, sym_entry->name)) return sym_entry; sym_entry = sym_entry->next; - } + } return &empty_entry; - } +} /* hashfunct - compute the hash value for "str" and hash size "hash_size" */ -static int hashfunct( str, hash_size ) -register const char *str; -int hash_size; - { +static int hashfunct (str, hash_size) + register const char *str; + int hash_size; +{ register int hashval; register int locstr; hashval = 0; locstr = 0; - while ( str[locstr] ) - { + while (str[locstr]) { hashval = (hashval << 1) + (unsigned char) str[locstr++]; hashval %= hash_size; - } + } return hashval; - } +} /* ndinstal - install a name definition */ -void ndinstal( name, definition ) -const char *name; -Char definition[]; - { +void ndinstal (name, definition) + const char *name; + Char definition[]; +{ - if ( addsym( copy_string( name ), - (char *) copy_unsigned_string( definition ), 0, - ndtbl, NAME_TABLE_HASH_SIZE ) ) - synerr( _( "name defined twice" ) ); - } + if (addsym (copy_string (name), + (char *) copy_unsigned_string (definition), 0, + ndtbl, NAME_TABLE_HASH_SIZE)) + synerr (_("name defined twice")); +} /* ndlookup - lookup a name definition @@ -214,27 +209,27 @@ Char definition[]; * Returns a nil pointer if the name definition does not exist. */ -Char *ndlookup( nd ) -const char *nd; - { - return (Char *) findsym( nd, ndtbl, NAME_TABLE_HASH_SIZE )->str_val; - } +Char *ndlookup (nd) + const char *nd; +{ + return (Char *) findsym (nd, ndtbl, NAME_TABLE_HASH_SIZE)->str_val; +} /* scextend - increase the maximum number of start conditions */ -void scextend() - { +void scextend () +{ current_max_scs += MAX_SCS_INCREMENT; ++num_reallocs; - scset = reallocate_integer_array( scset, current_max_scs ); - scbol = reallocate_integer_array( scbol, current_max_scs ); - scxclu = reallocate_integer_array( scxclu, current_max_scs ); - sceof = reallocate_integer_array( sceof, current_max_scs ); - scname = reallocate_char_ptr_array( scname, current_max_scs ); - } + scset = reallocate_integer_array (scset, current_max_scs); + scbol = reallocate_integer_array (scbol, current_max_scs); + scxclu = reallocate_integer_array (scxclu, current_max_scs); + sceof = reallocate_integer_array (sceof, current_max_scs); + scname = reallocate_char_ptr_array (scname, current_max_scs); +} /* scinstal - make a start condition @@ -243,30 +238,30 @@ void scextend() * The start condition is "exclusive" if xcluflg is true. */ -void scinstal( str, xcluflg ) -const char *str; -int xcluflg; - { +void scinstal (str, xcluflg) + const char *str; + int xcluflg; +{ /* Generate start condition definition, for use in BEGIN et al. */ - action_define( str, lastsc ); + action_define (str, lastsc); - if ( ++lastsc >= current_max_scs ) - scextend(); + if (++lastsc >= current_max_scs) + scextend (); - scname[lastsc] = copy_string( str ); + scname[lastsc] = copy_string (str); - if ( addsym( scname[lastsc], (char *) 0, lastsc, - sctbl, START_COND_HASH_SIZE ) ) - format_pinpoint_message( - _( "start condition %s declared twice" ), - str ); + if (addsym (scname[lastsc], (char *) 0, lastsc, + sctbl, START_COND_HASH_SIZE)) + format_pinpoint_message (_ + ("start condition %s declared twice"), +str); - scset[lastsc] = mkstate( SYM_EPSILON ); - scbol[lastsc] = mkstate( SYM_EPSILON ); + scset[lastsc] = mkstate (SYM_EPSILON); + scbol[lastsc] = mkstate (SYM_EPSILON); scxclu[lastsc] = xcluflg; sceof[lastsc] = false; - } +} /* sclookup - lookup the number associated with a start condition @@ -274,8 +269,8 @@ int xcluflg; * Returns 0 if no such start condition. */ -int sclookup( str ) -const char *str; - { - return findsym( str, sctbl, START_COND_HASH_SIZE )->int_val; - } +int sclookup (str) + const char *str; +{ + return findsym (str, sctbl, START_COND_HASH_SIZE)->int_val; +} |