diff options
Diffstat (limited to 'sym.c')
-rw-r--r-- | sym.c | 93 |
1 files changed, 59 insertions, 34 deletions
@@ -59,12 +59,11 @@ 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, +static int addsym (register char[], char *, int, hash_table, int); +static struct hash_entry *findsym (register const char *sym, hash_table table, - - int table_size)); -static int hashfunct PROTO ((register const char *, int)); + int table_size); +static int hashfunct (register const char *, int); /* addsym - add symbol and definitions to symbol table @@ -72,12 +71,12 @@ 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; +static int addsym ( + 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]; @@ -119,9 +118,9 @@ static int addsym (sym, str_def, int_def, table, table_size) /* 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. @@ -137,8 +136,8 @@ void cclinstal (ccltxt, cclnum) * 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; } @@ -146,10 +145,10 @@ int ccllookup (ccltxt) /* 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 *findsym ( + register const char *sym, + hash_table table, + int table_size) { static struct hash_entry empty_entry = { (struct hash_entry *) 0, (struct hash_entry *) 0, @@ -170,9 +169,9 @@ static struct hash_entry *findsym (sym, table, table_size) /* 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 ( + register const char *str, + int hash_size) { register int hashval; register int locstr; @@ -191,9 +190,9 @@ static int hashfunct (str, hash_size) /* ndinstal - install a name definition */ -void ndinstal (name, definition) - const char *name; - Char definition[]; +void ndinstal ( + const char *name, + Char definition[]) { if (addsym (copy_string (name), @@ -208,8 +207,8 @@ void ndinstal (name, definition) * Returns a nil pointer if the name definition does not exist. */ -Char *ndlookup (nd) - const char *nd; +Char *ndlookup ( + const char *nd) { return (Char *) findsym (nd, ndtbl, NAME_TABLE_HASH_SIZE)->str_val; } @@ -217,7 +216,7 @@ Char *ndlookup (nd) /* scextend - increase the maximum number of start conditions */ -void scextend () +void scextend (void) { current_max_scs += MAX_SCS_INCREMENT; @@ -237,9 +236,9 @@ void scextend () * The start condition is "exclusive" if xcluflg is true. */ -void scinstal (str, xcluflg) - const char *str; - int xcluflg; +void scinstal ( + const char *str, + int xcluflg) { if (++lastsc >= current_max_scs) @@ -265,8 +264,34 @@ str); * Returns 0 if no such start condition. */ -int sclookup (str) - const char *str; +int sclookup ( + const char *str) { return findsym (str, sctbl, START_COND_HASH_SIZE)->int_val; } + + +#if 0 +/* m4_define - idefine an M4 name definition */ + +void m4_define (const char *name, Char definition[]) +{ + setsym(copy_string(name), (char *)copy_unsigned_string(definition), 0, + m4table, M4_TABLE_HASH_SIZE); +} + +void m4_define_warn (const char *name, Char definition[], const char *message) +{ + if (addsym(copy_string(name), (char *)copy_unsigned_string(definition), 0, + m4table, M4_TABLE_HASH_SIZE)) + { + warn(message); + } +} + + +Char *m4_lookup (const char *name) +{ + return (Char *) findsym (nd, ndtbl, NAME_TABLE_HASH_SIZE)->str_val; +} +#endif |