Mercurial > octave
diff src/symtab.cc @ 572:94fd73d1a0bc
[project @ 1994-07-28 05:35:47 by jwe]
author | jwe |
---|---|
date | Thu, 28 Jul 1994 05:35:47 +0000 |
parents | c3268005bf98 |
children | 4057f845c1ee |
line wrap: on
line diff
--- a/src/symtab.cc Wed Jul 27 16:02:13 1994 +0000 +++ b/src/symtab.cc Thu Jul 28 05:35:47 1994 +0000 @@ -257,19 +257,19 @@ return definition ? definition->help () : 0; } -void -symbol_record::rename (const char *n) -{ - delete [] nm; - nm = strsave (n); -} - tree_fvc * symbol_record::def (void) const { return definition ? definition->def () : 0; } +void +symbol_record::rename (const char *new_name) +{ + delete [] nm; + nm = strsave (new_name); +} + int symbol_record::is_function (void) const { @@ -919,6 +919,34 @@ } void +symbol_table::rename (const char *old_name, const char *new_name) +{ + int index = hash (old_name) & HASH_MASK; + + symbol_record *prev = &table[index]; + symbol_record *ptr = prev->next (); + + while (ptr) + { + if (strcmp (ptr->name (), old_name) == 0) + { + prev->chain (ptr->next ()); + + index = hash (new_name) & HASH_MASK; + table[index].chain (ptr); + ptr->rename (new_name); + + return; + } + + prev = ptr; + ptr = ptr->next (); + } + + panic_impossible (); +} + +void symbol_table::clear (int clear_user_functions) { for (int i = 0; i < HASH_TABLE_SIZE; i++)