*** ./src/help.cc.orig3 2006-01-11 10:33:44.000000000 +0100 --- ./src/help.cc 2006-01-11 22:12:56.872026875 +0100 *************** *** 407,413 **** string_vector ffl = octave_fcn_file_name_cache::list_no_suffix (); int ffl_len = ffl.length (); ! int total_len = key_len + fbi_len + glb_len + top_len + lcl_len + ffl_len; string_vector list (total_len); --- 407,416 ---- string_vector ffl = octave_fcn_file_name_cache::list_no_suffix (); int ffl_len = ffl.length (); ! string_vector afl = autoloaded_functions (); ! int afl_len = afl.length (); ! ! int total_len = key_len + fbi_len + glb_len + top_len + lcl_len + ffl_len + afl_len; string_vector list (total_len); *************** *** 433,438 **** --- 436,444 ---- for (i = 0; i < ffl_len; i++) list[j++] = ffl[i]; + for (i = 0; i < afl_len; i++) + list[j++] = afl[i]; + return list; } *************** *** 542,547 **** --- 548,564 ---- names.list_in_columns (octave_stdout); } } + + string_vector autoloaded = autoloaded_functions (); + + if (! autoloaded.empty ()) + { + octave_stdout << "\n*** autoloaded functions:\n\n"; + + autoloaded.qsort (); + + autoloaded.list_in_columns (octave_stdout); + } } static int *************** *** 1138,1145 **** size_t pos = 0; if (looks_like_texinfo (h, pos)) ! { ! // Get the parsed help string. pos = 0; OSSTREAM os; display_help_text (os, h); --- 1155,1162 ---- size_t pos = 0; if (looks_like_texinfo (h, pos)) ! { ! // Get the parsed help string. pos = 0; OSSTREAM os; display_help_text (os, h); *************** *** 1232,1238 **** if (lower.find_first_of ('-') == 0 || lower.substr (0, 5) == "usage") { ! pos = new_pos + 1; continue; } --- 1249,1255 ---- if (lower.find_first_of ('-') == 0 || lower.substr (0, 5) == "usage") { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1247,1253 **** if (line_pos == NPOS) { ! pos = new_pos + 1; continue; } --- 1264,1270 ---- if (line_pos == NPOS) { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1257,1263 **** if (line_pos == NPOS) { ! pos = new_pos + 1; continue; } --- 1274,1280 ---- if (line_pos == NPOS) { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1273,1279 **** if (line_pos == NPOS) { ! pos = new_pos + 1; continue; } --- 1290,1296 ---- if (line_pos == NPOS) { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1304,1310 **** if (line_pos == NPOS) { ! pos = new_pos + 1; continue; } --- 1321,1327 ---- if (line_pos == NPOS) { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1315,1321 **** if (line_pos == NPOS) { ! pos = new_pos + 1; continue; } --- 1332,1338 ---- if (line_pos == NPOS) { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1328,1334 **** if (line_pos == NPOS) { ! pos = new_pos + 1; continue; } --- 1345,1351 ---- if (line_pos == NPOS) { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1345,1351 **** if (line_pos == NPOS) { ! pos = new_pos + 1; continue; } --- 1362,1368 ---- if (line_pos == NPOS) { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1361,1367 **** if (line_pos == NPOS) { ! pos = new_pos + 1; continue; } --- 1378,1384 ---- if (line_pos == NPOS) { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1380,1386 **** if (line_pos == NPOS) { ! pos = new_pos + 1; continue; } --- 1397,1403 ---- if (line_pos == NPOS) { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1392,1398 **** || line.find_first_not_of ("\n\t ", line_pos) == NPOS || line.substr (line_pos, 2) == "!/") { ! pos = new_pos + 1; continue; } --- 1409,1415 ---- || line.find_first_not_of ("\n\t ", line_pos) == NPOS || line.substr (line_pos, 2) == "!/") { ! pos = (new_pos == NPOS ? NPOS : new_pos + 1); continue; } *************** *** 1571,1585 **** std::string name = ptr->name; std::string h = ptr->help; ! std::string s; ! if (first_sentence_only) ! s = first_help_sentence (h); ! else ! s = h; ! ! transform (s.begin (), s.end (), s.begin (), tolower); ! ! if (s.length () > 0 && s.find (txt) != NPOS) { if (nargout) { --- 1588,1594 ---- std::string name = ptr->name; std::string h = ptr->help; ! if (name.find (txt) != NPOS) { if (nargout) { *************** *** 1589,1594 **** --- 1598,1625 ---- else print_lookfor (name, first_help_sentence (h)); } + else + { + std::string s; + + if (first_sentence_only) + s = first_help_sentence (h); + else + s = h; + + transform (s.begin (), s.end (), s.begin (), tolower); + + if (s.length () > 0 && s.find (txt) != NPOS) + { + if (nargout) + { + ret[0].append (name); + ret[1].append (first_help_sentence (h)); + } + else + print_lookfor (name, first_help_sentence (h)); + } + } OCTAVE_QUIT; *************** *** 1601,1615 **** std::string name = ptr->name; std::string h = ptr->help; ! std::string s; ! if (first_sentence_only) ! s = first_help_sentence (h); ! else ! s = h; ! ! transform (s.begin (), s.end (), s.begin (), tolower); ! ! if (s.length () > 0 && s.find (txt) != NPOS) { if (nargout) { --- 1632,1638 ---- std::string name = ptr->name; std::string h = ptr->help; ! if (name.find (txt) != NPOS) { if (nargout) { *************** *** 1619,1624 **** --- 1642,1668 ---- else print_lookfor (name, first_help_sentence (h)); } + else + { + std::string s; + if (first_sentence_only) + s = first_help_sentence (h); + else + s = h; + + transform (s.begin (), s.end (), s.begin (), tolower); + + if (s.length () > 0 && s.find (txt) != NPOS) + { + if (nargout) + { + ret[0].append (name); + ret[1].append (first_help_sentence (h)); + } + else + print_lookfor (name, first_help_sentence (h)); + } + } OCTAVE_QUIT; *************** *** 1639,1653 **** if (sr && sr->is_defined ()) { std::string h = sr->help (); - std::string s; - if (first_sentence_only) - s = first_help_sentence (h); - else - s = h; - - transform (s.begin (), s.end (), s.begin (), tolower); ! if (s.length () > 0 && s.find (txt) != NPOS) { if (nargout) { --- 1683,1690 ---- if (sr && sr->is_defined ()) { std::string h = sr->help (); ! if (name.find (txt) != NPOS) { if (nargout) { *************** *** 1657,1662 **** --- 1694,1721 ---- else print_lookfor (name, first_help_sentence (h)); } + else + { + std::string s; + + if (first_sentence_only) + s = first_help_sentence (h); + else + s = h; + + transform (s.begin (), s.end (), s.begin (), tolower); + + if (s.length () > 0 && s.find (txt) != NPOS) + { + if (nargout) + { + ret[0].append (name); + ret[1].append (first_help_sentence (h)); + } + else + print_lookfor (name, first_help_sentence (h)); + } + } } } *************** *** 1697,1720 **** std::string file_name = Vload_path_dir_path.find_first_of (tmp); - if (file_name == dirs[i] + tmp(0) || file_name == dirs[i] + tmp(1)) { bool symbol_found; ! std::string h ! = get_help_from_file (file_name, symbol_found); ! std::string s; ! if (first_sentence_only) ! s = first_help_sentence (h); else ! s = h; ! transform (s.begin (), s.end (), s.begin (), tolower); ! ! if (s.length () > 0 && s.find (txt) != NPOS) { if (nargout) { --- 1756,1779 ---- std::string file_name = Vload_path_dir_path.find_first_of (tmp); if (file_name == dirs[i] + tmp(0) || file_name == dirs[i] + tmp(1)) { bool symbol_found; ! std::string h; ! if (file_name == dirs[i] + tmp(0)) ! { ! // oct-file. Must load to get help ! sr = lookup_by_name (name, false); ! if (sr && sr->is_defined ()) ! h = sr->help (); ! } else ! h = get_help_from_file (file_name, symbol_found); ! if (name.find (txt) != NPOS) { if (nargout) { *************** *** 1724,1736 **** else print_lookfor (name, first_help_sentence (h)); } } } } } } - if (nargout != 0) { retval (1) = ret[1]; --- 1783,1873 ---- else print_lookfor (name, first_help_sentence (h)); } + else + { + std::string s; + if (first_sentence_only) + s = first_help_sentence (h); + else + s = h; + + transform (s.begin (), s.end (), s.begin (), tolower); + + if (s.length () > 0 && s.find (txt) != NPOS) + { + if (nargout) + { + ret[0].append (name); + ret[1].append (first_help_sentence (h)); + } + else + print_lookfor (name, first_help_sentence (h)); + } + } + } + } + + // Check if this function has autoloaded functions attached to it + std::string file_name = Vload_path_dir_path.find_first_of (names(j)); + string_vector autoload_fcns = reverse_lookup_autoload (file_name); + + if (! autoload_fcns.empty ()) + { + for (int k = 0; k < autoload_fcns.length (); k++) + { + std::string aname = autoload_fcns (k); + + // Check if already in symbol table + sr = fbi_sym_tab->lookup (aname); + + if (!sr) + { + // Must load to get help + sr = lookup_by_name (name, false); + + std::string h; + if (sr && sr->is_defined ()) + h = sr->help (); + + if (aname.find (txt) != NPOS) + { + if (nargout) + { + ret[0].append (aname); + ret[1].append (first_help_sentence (h)); + } + else + print_lookfor (aname, first_help_sentence (h)); + } + else + { + std::string s; + if (first_sentence_only) + s = first_help_sentence (h); + else + s = h; + + transform (s.begin (), s.end (), s.begin (), + tolower); + + if (s.length () > 0 && s.find (txt) != NPOS) + { + if (nargout) + { + ret[0].append (aname); + ret[1].append (first_help_sentence (h)); + } + else + print_lookfor (aname, first_help_sentence (h)); + } + } + } } } } } } if (nargout != 0) { retval (1) = ret[1]; *** ./src/parse.h.orig3 2006-01-11 10:35:05.000000000 +0100 --- ./src/parse.h 2006-01-11 11:37:48.000000000 +0100 *************** *** 98,103 **** --- 98,107 ---- extern std::string lookup_autoload (const std::string& nm); + extern string_vector autoloaded_functions (void); + + extern string_vector reverse_lookup_autoload (const std::string& nm); + extern bool load_fcn_from_file (const std::string& nm, bool exec_script); *** ./src/parse.y.orig3 2006-01-11 10:35:13.000000000 +0100 --- ./src/parse.y 2006-01-11 15:39:51.000000000 +0100 *************** *** 3379,3384 **** --- 3379,3412 ---- octave_env::getcwd ()); } + string_vector + autoloaded_functions (void) + { + string_vector names (autoload_map.size()); + + octave_idx_type i = 0; + std::map::const_iterator p; + for (p = std::map::iterator (autoload_map.begin ()); + p != std::map::iterator (autoload_map.end ()); p++) + names[i++] = p->first; + + return names; + } + + string_vector + reverse_lookup_autoload (const std::string& nm) + { + string_vector names; + + std::map::const_iterator p; + for (p = std::map::iterator (autoload_map.begin ()); + p != std::map::iterator (autoload_map.end ()); p++) + if (nm == p->second) + names.append (p->first); + + return names; + } + bool load_fcn_from_file (const std::string& nm, bool exec_script) {