# HG changeset patch # User jwe # Date 1200358250 0 # Node ID 4ff9611147ba96cf976bcc63c203dc837f8bf5f8 # Parent f350da7556003695370f457dfb18798aafe4cfc7 [project @ 2008-01-15 00:50:50 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2008-01-14 John W. Eaton + + * load-path.cc (load_path::do_initialize): Start with sys_path empty. + (maybe_add_path_elts): Omit path_sep_str if path is empty. + + * symtab.h (symbol_table::do_pop_context): Remove symbol_records + which have no more context. + (symbol_table::symbol_record::pop_context, + (symbol_table::symbol_record::symbol_record_rep::pop_context): + Return size of value_stack, or 1 if variable is persistent or global. + 2008-01-14 Kai Habel * graphics.h.in (class patch::properties): New properties: diff --git a/src/load-path.cc b/src/load-path.cc --- a/src/load-path.cc +++ b/src/load-path.cc @@ -408,13 +408,18 @@ std::string tpath = genpath (dir); if (! tpath.empty ()) - path += dir_path::path_sep_str + tpath; + { + if (path.empty ()) + path = tpath; + else + path += dir_path::path_sep_str + tpath; + } } void load_path::do_initialize (bool set_initial_path) { - sys_path = dir_path::path_sep_str; + sys_path = ""; if (set_initial_path) { @@ -438,7 +443,7 @@ if (! tpath.empty ()) xpath += dir_path::path_sep_str + tpath; - if (sys_path != dir_path::path_sep_str) + if (! sys_path.empty ()) xpath += sys_path; do_set (xpath, false); diff --git a/src/symtab.h b/src/symtab.h --- a/src/symtab.h +++ b/src/symtab.h @@ -93,7 +93,11 @@ void push_context (void) { value_stack.push (octave_value ()); } - void pop_context (void) { value_stack.pop (); } + size_t pop_context (void) + { + value_stack.pop (); + return value_stack.size (); + } void clear (void) { @@ -254,10 +258,23 @@ rep->push_context (); } - void pop_context (void) + // If pop_context returns 0, we are out of values and this element + // of the symbol table should be deleted. This can happen for + // functions like + // + // function foo (n) + // if (n > 0) + // foo (n-1); + // else + // eval ("x = 1"); + // endif + // endfunction + // + // Here, X should only exist in the final stack frame. + + size_t pop_context (void) { - if (! (is_persistent () || is_global ())) - rep->pop_context (); + return (is_persistent () || is_global ()) ? 1 : rep->pop_context (); } void clear (void) { rep->clear (); } @@ -1618,8 +1635,13 @@ void do_pop_context (void) { - for (table_iterator p = table.begin (); p != table.end (); p++) - p->second.pop_context (); + for (table_iterator p = table.begin (); p != table.end (); ) + { + if (p->second.pop_context () == 0) + table.erase (p++); + else + p++; + } } void do_clear_variables (void)