Index: octave/src/symtab.cc =================================================================== RCS file: /cvs/octave/src/symtab.cc,v retrieving revision 1.99 diff -c -p -r1.99 symtab.cc *** a/octave/src/symtab.cc 18 Dec 2003 15:35:09 -0000 1.99 --- b/octave/src/symtab.cc 19 Apr 2004 02:53:08 -0000 *************** Software Foundation, 59 Temple Place - S *** 47,52 **** --- 47,55 ---- #include "utils.h" #include "variables.h" + #include "parse.h" + #include + unsigned long int symbol_table::symtab_count = 0; // Should variables be allowed to hide functions of the same name? A *************** matches_patterns (const std::string& nam *** 833,838 **** --- 836,904 ---- } Array + symbol_table::subsymbol_list (const string_vector& pats, + unsigned int type, unsigned int scope) const + { + int count = 0; + + int n = size (); + + Array subsymbols (n); + int pats_length = pats.length (); + + if (n == 0) + return subsymbols; + + // Look for separators like .({ + for (int j = 0; j < pats_length; j++) + { + std::string var_name = pats (j); + + size_t pos = var_name.find_first_of (".({"); + + if ((pos != NPOS) && (pos > 0)) + { + std::string first_name = var_name.substr(0,pos); + + for (unsigned int i = 0; i < table_size; i++) + { + symbol_record *ptr = table[i].next (); + + while (ptr) + { + assert (count < n); + + unsigned int my_scope = ptr->is_linked_to_global () + 1; // Tricky... + + unsigned int my_type = ptr->type (); + + std::string my_name = ptr->name (); + + if ((type & my_type) && (scope & my_scope) && (first_name == my_name)) + { + symbol_record *ptr = new symbol_record (); + octave_value value; + int parse_status; + + value = eval_string (var_name, true, parse_status); + + ptr->define (value); + ptr->rename (var_name); + subsymbols(count++) = ptr; + } + + ptr = ptr->next (); + } + } + } + } + + subsymbols.resize (count); + + return subsymbols; + } + + Array symbol_table::symbol_list (const string_vector& pats, unsigned int type, unsigned int scope) const { *************** symbol_table::symbol_list (const string_ *** 859,866 **** std::string my_name = ptr->name (); ! if ((type & my_type) && (scope & my_scope) ! && matches_patterns (my_name, pats)) symbols(count++) = ptr; ptr = ptr->next (); --- 925,931 ---- std::string my_name = ptr->name (); ! if ((type & my_type) && (scope & my_scope) && (matches_patterns (my_name, pats))) symbols(count++) = ptr; ptr = ptr->next (); *************** symbol_table::maybe_list (const char *he *** 917,935 **** if (show_verbose) { ! Array symbols = symbol_list (argv, type, scope); ! int len = symbols.length (); if (len > 0) { os << "\n" << header << "\n\n" << "prot type rows cols name\n" << "==== ==== ==== ==== ====\n"; symbols.qsort (maybe_list_cmp_fcn); ! for (int i = 0; i < len; i++) symbols(i)->print_symbol_info_line (os); status = 1; --- 982,1013 ---- if (show_verbose) { ! // XXX FIXME XXX Should separate argv to lists with and without dots ! Array _symbols = symbol_list (argv, type, scope); ! Array _subsymbols = subsymbol_list (argv, type, scope); ! ! int sym_len = _symbols.length (), subsym_len = _subsymbols.length (), len = sym_len + subsym_len; ! Array symbols (len); ! //int len = symbols.length (); if (len > 0) { + // Joining symbolic tables + int i; + + for (i = 0; i < sym_len; i++) + symbols(i) = _symbols(i); + + symbols(i+sym_len) = _subsymbols(i); + os << "\n" << header << "\n\n" << "prot type rows cols name\n" << "==== ==== ==== ==== ====\n"; symbols.qsort (maybe_list_cmp_fcn); ! for (i = 0; i < len; i++) symbols(i)->print_symbol_info_line (os); status = 1; Index: octave/src/symtab.h =================================================================== RCS file: /cvs/octave/src/symtab.h,v retrieving revision 1.66 diff -c -p -r1.66 symtab.h *** a/octave/src/symtab.h 13 Feb 2003 21:03:04 -0000 1.66 --- b/octave/src/symtab.h 19 Apr 2004 02:53:08 -0000 *************** public: *** 454,459 **** --- 454,464 ---- int size (void) const; Array + subsymbol_list (const string_vector& pats = string_vector (), + unsigned int type = SYMTAB_ALL_TYPES, + unsigned int scope = SYMTAB_ALL_SCOPES) const; + + Array symbol_list (const string_vector& pats = string_vector (), unsigned int type = SYMTAB_ALL_TYPES, unsigned int scope = SYMTAB_ALL_SCOPES) const;