Mercurial > hg > octave-lojdl
changeset 5975:e64059303a6f
[project @ 2006-08-29 16:37:39 by jwe]
author | jwe |
---|---|
date | Tue, 29 Aug 2006 16:37:40 +0000 |
parents | 51684d05b4bf |
children | b1a1c10bf2fd |
files | src/ChangeLog src/load-path.cc src/parse.h src/parse.y |
diffstat | 4 files changed, 43 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2006-08-29 John W. Eaton <jwe@octave.org> + + * load-path.cc (execute_pkg_add_or_del): + Source PKG_ADD or PKG_DEL in base workspace. + * parse.y (source_file): New optional arg, context. + * parse.h (source_file): Fix decl. + 2006-08-25 John W. Eaton <jwe@octave.org> * version.h (OCTAVE_VERSION): Now 2.9.8+.
--- a/src/load-path.cc +++ b/src/load-path.cc @@ -1211,7 +1211,7 @@ file_stat fs = file_stat (file); if (fs.exists ()) - source_file (file); + source_file (file, "base"); unwind_protect::run_frame ("execute_pkg_add_or_del"); }
--- a/src/parse.h +++ b/src/parse.h @@ -109,7 +109,8 @@ load_fcn_from_file (symbol_record *sym_rec, bool exec_script); extern void -source_file (const std::string file_name); +source_file (const std::string& file_name, + const std::string& context = std::string ()); extern octave_value_list feval (const std::string& name,
--- a/src/parse.y +++ b/src/parse.y @@ -3527,7 +3527,7 @@ } void -source_file (const std::string file_name) +source_file (const std::string& file_name, const std::string& context) { std::string file_full_name = file_ops::tilde_expand (file_name); @@ -3539,11 +3539,26 @@ curr_fcn_file_name = file_name; curr_fcn_file_full_name = file_full_name; - parse_fcn_file (file_full_name, true, true); - - if (error_state) - error ("source: error sourcing file `%s'", - file_full_name.c_str ()); + if (! context.empty ()) + { + unwind_protect_ptr (curr_sym_tab); + + if (context == "caller") + curr_sym_tab = curr_caller_sym_tab; + else if (context == "base") + curr_sym_tab = top_level_sym_tab; + else + error ("source: context must be \"caller\" or \"base\""); + } + + if (! error_state) + { + parse_fcn_file (file_full_name, true, true); + + if (error_state) + error ("source: error sourcing file `%s'", + file_full_name.c_str ()); + } unwind_protect::run_frame ("source_file"); } @@ -3629,12 +3644,22 @@ int nargin = args.length (); - if (nargin == 1) + if (nargin == 1 || nargin == 2) { std::string file_name = args(0).string_value (); if (! error_state) - source_file (file_name); + { + std::string context; + + if (nargin == 2) + context = args(1).string_value (); + + if (! error_state) + source_file (file_name, context); + else + error ("source: expecting context to be character string"); + } else error ("source: expecting file name as argument"); }