Mercurial > octave-nkf
comparison src/help.cc @ 5738:126d7f1945ee
[project @ 2006-04-05 03:04:08 by jwe]
author | jwe |
---|---|
date | Wed, 05 Apr 2006 03:04:08 +0000 |
parents | 62734ddaf17b |
children | 7ba9ad1fec11 |
comparison
equal
deleted
inserted
replaced
5737:c70bfdf5b2c5 | 5738:126d7f1945ee |
---|---|
1121 // texinfo. Using regex might make this function much simpler. | 1121 // texinfo. Using regex might make this function much simpler. |
1122 | 1122 |
1123 std::string | 1123 std::string |
1124 first_help_sentence (const std::string& h, bool short_sentence = true) | 1124 first_help_sentence (const std::string& h, bool short_sentence = true) |
1125 { | 1125 { |
1126 std::string retval; | |
1127 | |
1126 size_t pos = 0; | 1128 size_t pos = 0; |
1127 | 1129 |
1128 if (looks_like_texinfo (h, pos)) | 1130 if (looks_like_texinfo (h, pos)) |
1129 { | 1131 { |
1130 // Get the parsed help string. | 1132 // Get the parsed help string. |
1153 | 1155 |
1154 break; | 1156 break; |
1155 } | 1157 } |
1156 | 1158 |
1157 if (pos == NPOS) | 1159 if (pos == NPOS) |
1158 return std::string (); | 1160 return retval; |
1159 | 1161 |
1160 // At start of real text. Get first line with the sentence | 1162 // At start of real text. Get first line with the sentence |
1161 size_t new_pos = h2.find_first_of ('\n', pos); | 1163 size_t new_pos = h2.find_first_of ('\n', pos); |
1162 std::string line = h2.substr (pos, new_pos-pos); | 1164 std::string line = h2.substr (pos, new_pos-pos); |
1163 size_t dot_pos; | 1165 size_t dot_pos; |
1187 else | 1189 else |
1188 line = line + " " + next; | 1190 line = line + " " + next; |
1189 } | 1191 } |
1190 | 1192 |
1191 if (dot_pos == NPOS) | 1193 if (dot_pos == NPOS) |
1192 return line; | 1194 retval = line; |
1193 else | 1195 else |
1194 return line.substr (0, dot_pos + 1); | 1196 retval = line.substr (0, dot_pos + 1); |
1195 } | 1197 } |
1196 else | 1198 else |
1197 { | 1199 { |
1198 std::string _upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | 1200 std::string _upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; |
1199 std::string _lower = "abcdefghijklmnopqrstuvwxyz"; | 1201 std::string _lower = "abcdefghijklmnopqrstuvwxyz"; |
1388 pos = pos + line_pos; | 1390 pos = pos + line_pos; |
1389 break; | 1391 break; |
1390 } | 1392 } |
1391 | 1393 |
1392 if (pos == NPOS) | 1394 if (pos == NPOS) |
1393 return std::string (); | 1395 return retval; |
1394 | 1396 |
1395 // At start of real text. Get first line with the sentence | 1397 // At start of real text. Get first line with the sentence |
1396 size_t new_pos = h.find_first_of ('\n', pos); | 1398 size_t new_pos = h.find_first_of ('\n', pos); |
1397 std::string line = h.substr (pos, new_pos-pos); | 1399 std::string line = h.substr (pos, new_pos-pos); |
1398 size_t dot_pos; | 1400 size_t dot_pos; |
1423 else | 1425 else |
1424 line = line + " " + next; | 1426 line = line + " " + next; |
1425 } | 1427 } |
1426 | 1428 |
1427 if (dot_pos == NPOS) | 1429 if (dot_pos == NPOS) |
1428 return line; | 1430 retval = line; |
1429 else | 1431 else |
1430 return line.substr (0, dot_pos + 1); | 1432 retval = line.substr (0, dot_pos + 1); |
1431 } | 1433 } |
1434 | |
1435 return retval; | |
1432 } | 1436 } |
1433 | 1437 |
1434 static void | 1438 static void |
1435 print_lookfor (const std::string& name, const std::string& line) | 1439 print_lookfor (const std::string& name, const std::string& line) |
1436 { | 1440 { |
1649 std::string name = names (i); | 1653 std::string name = names (i); |
1650 | 1654 |
1651 OCTAVE_QUIT; | 1655 OCTAVE_QUIT; |
1652 | 1656 |
1653 symbol_record *sr = lookup_by_name (name, 0); | 1657 symbol_record *sr = lookup_by_name (name, 0); |
1654 if (sr && sr->is_defined ()) | 1658 if (sr && sr->is_defined () |
1659 && sr->type_name () != "overloaded function") | |
1655 { | 1660 { |
1656 std::string h = sr->help (); | 1661 std::string h = sr->help (); |
1657 | 1662 |
1658 if (name.find (txt) != NPOS) | 1663 if (name.find (txt) != NPOS) |
1659 { | 1664 { |
1792 sr = fbi_sym_tab->lookup (aname); | 1797 sr = fbi_sym_tab->lookup (aname); |
1793 | 1798 |
1794 if (!sr) | 1799 if (!sr) |
1795 { | 1800 { |
1796 // Must load to get help | 1801 // Must load to get help |
1797 sr = lookup_by_name (name, false); | 1802 sr = lookup_by_name (aname, false); |
1798 | 1803 |
1799 std::string h; | 1804 std::string h; |
1800 if (sr && sr->is_defined ()) | 1805 if (sr && sr->is_defined ()) |
1801 h = sr->help (); | 1806 h = sr->help (); |
1802 | 1807 |