# HG changeset patch # User Max Brister # Date 1351660445 25200 # Node ID 859c8bf6d1343d2f5c8e6fda47e180fbbfbf2654 # Parent 7b9551c65b7bcfa6d729465f653028ff4c9dedba Fix saved struct with function handle fails to load (bug #33857) * ov-fcn-handle.cc: Add test. * symtab.h (symbol_table::all_variables, symbol_table::do_all_variables): Support excluding storage classes. diff --git a/libinterp/interpfcn/symtab.h b/libinterp/interpfcn/symtab.h --- a/libinterp/interpfcn/symtab.h +++ b/libinterp/interpfcn/symtab.h @@ -1772,15 +1772,18 @@ inst->do_mark_global (name); } + // exclude: Storage classes to exclude, you can OR them together static std::list all_variables (scope_id scope = xcurrent_scope, context_id context = xdefault_context, - bool defined_only = true) + bool defined_only = true, + unsigned int exclude = symbol_record::hidden) { symbol_table *inst = get_instance (scope); return inst - ? inst->do_all_variables (context, defined_only) : std::list (); + ? inst->do_all_variables (context, defined_only, exclude) + : std::list (); } static std::list glob (const std::string& pattern) @@ -2538,7 +2541,8 @@ } std::list - do_all_variables (context_id context, bool defined_only) const + do_all_variables (context_id context, bool defined_only, + unsigned int exclude) const { std::list retval; @@ -2546,7 +2550,8 @@ { const symbol_record& sr = p->second; - if (defined_only && ! sr.is_defined (context)) + if ((defined_only && ! sr.is_defined (context)) + || (sr.xstorage_class () & exclude)) continue; retval.push_back (sr); diff --git a/libinterp/octave-value/ov-fcn-handle.cc b/libinterp/octave-value/ov-fcn-handle.cc --- a/libinterp/octave-value/ov-fcn-handle.cc +++ b/libinterp/octave-value/ov-fcn-handle.cc @@ -1311,6 +1311,7 @@ %! mode = modes{i}; %! nm = tmpnam (); %! unwind_protect +%! f2 (1); # bug #33857 %! save (mode, nm, "f2", "g2", "hm2", "hdld2", "hbi2"); %! clear f2 g2 hm2 hdld2 hbi2 %! load (nm);