Mercurial > octave
diff src/symtab.cc @ 2791:ef422e6f6138
[project @ 1997-03-05 04:53:36 by jwe]
author | jwe |
---|---|
date | Wed, 05 Mar 1997 04:55:42 +0000 |
parents | ecc1a12678de |
children | 9aeba8e006a4 |
line wrap: on
line diff
--- a/src/symtab.cc Wed Mar 05 02:47:55 1997 +0000 +++ b/src/symtab.cc Wed Mar 05 04:55:42 1997 +0000 @@ -266,7 +266,8 @@ void symbol_record::rename (const string& new_name) { - nm = new_name; + if (! read_only_error ("rename")) + nm = new_name; } int @@ -388,7 +389,7 @@ int symbol_record::define (tree_constant *t) { - if (is_variable () && read_only_error ()) + if (is_variable () && read_only_error ("redefine")) return 0; tree_fvc *saved_def = 0; @@ -433,7 +434,7 @@ int symbol_record::define (tree_builtin *t, int text_fcn) { - if (read_only_error ()) + if (read_only_error ("redefine")) return 0; if (is_variable ()) @@ -462,7 +463,7 @@ int symbol_record::define (tree_function *t, int text_fcn) { - if (read_only_error ()) + if (read_only_error ("redefine")) return 0; if (is_variable ()) @@ -490,7 +491,7 @@ int symbol_record::define_as_fcn (const octave_value& v) { - if (is_variable () && read_only_error ()) + if (is_variable () && read_only_error ("redefine")) return 0; if (is_variable ()) @@ -682,21 +683,21 @@ } int -symbol_record::read_only_error (void) +symbol_record::read_only_error (const char *action) { if (is_read_only ()) { if (is_variable ()) { - ::error ("can't redefine read-only constant `%s'", nm.c_str ()); + ::error ("can't %s read-only constant `%s'", action, nm.c_str ()); } else if (is_function ()) { - ::error ("can't redefine read-only function `%s'", nm.c_str ()); + ::error ("can't %s read-only function `%s'", action, nm.c_str ()); } else { - ::error ("can't redefine read-only symbol `%s'", nm.c_str ()); + ::error ("can't %s read-only symbol `%s'", action, nm.c_str ()); } return 1; @@ -914,13 +915,19 @@ { if (ptr->name () == old_name) { - prev->chain (ptr->next ()); - - index = hash (new_name) & HASH_MASK; - table[index].chain (ptr); ptr->rename (new_name); - return; + if (! error_state) + { + prev->chain (ptr->next ()); + + index = hash (new_name) & HASH_MASK; + table[index].chain (ptr); + + return; + } + + break; } prev = ptr;