Mercurial > hg > octave-lyh
comparison src/help.cc @ 10315:57a59eae83cc
untabify src C++ source files
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 11 Feb 2010 12:41:46 -0500 |
parents | 0522a65bcd56 |
children | 8f27f368aba2 |
comparison
equal
deleted
inserted
replaced
10314:07ebe522dac2 | 10315:57a59eae83cc |
---|---|
624 return (p2 != std::string::npos); | 624 return (p2 != std::string::npos); |
625 } | 625 } |
626 | 626 |
627 static bool | 627 static bool |
628 raw_help_from_symbol_table (const std::string& nm, std::string& h, | 628 raw_help_from_symbol_table (const std::string& nm, std::string& h, |
629 std::string& w, bool& symbol_found) | 629 std::string& w, bool& symbol_found) |
630 { | 630 { |
631 bool retval = false; | 631 bool retval = false; |
632 | 632 |
633 octave_value val = symbol_table::find_function (nm); | 633 octave_value val = symbol_table::find_function (nm); |
634 | 634 |
635 if (val.is_defined ()) | 635 if (val.is_defined ()) |
636 { | 636 { |
637 octave_function *fcn = val.function_value (); | 637 octave_function *fcn = val.function_value (); |
638 | 638 |
639 if (fcn) | 639 if (fcn) |
640 { | 640 { |
641 symbol_found = true; | 641 symbol_found = true; |
642 | 642 |
643 h = fcn->doc_string (); | 643 h = fcn->doc_string (); |
644 | 644 |
645 retval = true; | 645 retval = true; |
646 | 646 |
647 w = fcn->fcn_file_name (); | 647 w = fcn->fcn_file_name (); |
648 | 648 |
649 if (w.empty ()) | 649 if (w.empty ()) |
650 w = fcn->is_user_function () | 650 w = fcn->is_user_function () |
651 ? "command-line function" : "built-in function"; | 651 ? "command-line function" : "built-in function"; |
652 } | 652 } |
653 } | 653 } |
654 | 654 |
655 return retval; | 655 return retval; |
656 } | 656 } |
657 | 657 |
658 static bool | 658 static bool |
659 raw_help_from_file (const std::string& nm, std::string& h, | 659 raw_help_from_file (const std::string& nm, std::string& h, |
660 std::string& file, bool& symbol_found) | 660 std::string& file, bool& symbol_found) |
661 { | 661 { |
662 bool retval = false; | 662 bool retval = false; |
663 | 663 |
664 // FIXME -- this is a bit of a kluge... | 664 // FIXME -- this is a bit of a kluge... |
665 unwind_protect frame; | 665 unwind_protect frame; |
674 return retval; | 674 return retval; |
675 } | 675 } |
676 | 676 |
677 static bool | 677 static bool |
678 raw_help_from_map (const std::string& nm, std::string& h, | 678 raw_help_from_map (const std::string& nm, std::string& h, |
679 const map_type& map, bool& symbol_found) | 679 const map_type& map, bool& symbol_found) |
680 { | 680 { |
681 map_iter idx = map.find (nm); | 681 map_iter idx = map.find (nm); |
682 symbol_found = (idx != map.end ()); | 682 symbol_found = (idx != map.end ()); |
683 h = (symbol_found) ? idx->second : ""; | 683 h = (symbol_found) ? idx->second : ""; |
684 return symbol_found; | 684 return symbol_found; |
699 return h; | 699 return h; |
700 } | 700 } |
701 | 701 |
702 static void | 702 static void |
703 do_get_help_text (const std::string& name, std::string& text, | 703 do_get_help_text (const std::string& name, std::string& text, |
704 std::string& format) | 704 std::string& format) |
705 { | 705 { |
706 bool symbol_found = false; | 706 bool symbol_found = false; |
707 text = raw_help (name, symbol_found); | 707 text = raw_help (name, symbol_found); |
708 | 708 |
709 format = "Not found"; | 709 format = "Not found"; |
749 if (args.length () == 1) | 749 if (args.length () == 1) |
750 { | 750 { |
751 const std::string name = args (0).string_value (); | 751 const std::string name = args (0).string_value (); |
752 | 752 |
753 if (! error_state) | 753 if (! error_state) |
754 { | 754 { |
755 std::string text; | 755 std::string text; |
756 std::string format; | 756 std::string format; |
757 | 757 |
758 do_get_help_text (name, text, format); | 758 do_get_help_text (name, text, format); |
759 | 759 |
760 retval(1) = format; | 760 retval(1) = format; |
761 retval(0) = text; | 761 retval(0) = text; |
762 } | 762 } |
763 else | 763 else |
764 error ("get_help_text: invalid input"); | 764 error ("get_help_text: invalid input"); |
765 } | 765 } |
766 else | 766 else |
767 print_usage (); | 767 print_usage (); |
768 | 768 |
769 return retval; | 769 return retval; |
770 } | 770 } |
771 | 771 |
772 static void | 772 static void |
773 do_get_help_text_from_file (const std::string& fname, std::string& text, | 773 do_get_help_text_from_file (const std::string& fname, std::string& text, |
774 std::string& format) | 774 std::string& format) |
775 { | 775 { |
776 bool symbol_found = false; | 776 bool symbol_found = false; |
777 | 777 |
778 std::string f; | 778 std::string f; |
779 | 779 |
823 if (args.length () == 1) | 823 if (args.length () == 1) |
824 { | 824 { |
825 const std::string fname = args(0).string_value (); | 825 const std::string fname = args(0).string_value (); |
826 | 826 |
827 if (! error_state) | 827 if (! error_state) |
828 { | 828 { |
829 std::string text; | 829 std::string text; |
830 std::string format; | 830 std::string format; |
831 | 831 |
832 do_get_help_text_from_file (fname, text, format); | 832 do_get_help_text_from_file (fname, text, format); |
833 | 833 |
834 retval(1) = format; | 834 retval(1) = format; |
835 retval(0) = text; | 835 retval(0) = text; |
836 } | 836 } |
837 else | 837 else |
838 error ("get_help_text_from_file: invalid input"); | 838 error ("get_help_text_from_file: invalid input"); |
839 } | 839 } |
840 else | 840 else |
841 print_usage (); | 841 print_usage (); |
842 | 842 |
843 return retval; | 843 return retval; |
959 if (! error_state) | 959 if (! error_state) |
960 { | 960 { |
961 int argc = argv.length (); | 961 int argc = argv.length (); |
962 | 962 |
963 if (argc > 1) | 963 if (argc > 1) |
964 { | 964 { |
965 Octave_map m (dim_vector (1, argc-1)); | 965 Octave_map m (dim_vector (1, argc-1)); |
966 | 966 |
967 Cell names (1, argc-1); | 967 Cell names (1, argc-1); |
968 Cell files (1, argc-1); | 968 Cell files (1, argc-1); |
969 Cell types (1, argc-1); | 969 Cell types (1, argc-1); |
970 | 970 |
971 for (int i = 1; i < argc; i++) | 971 for (int i = 1; i < argc; i++) |
972 { | 972 { |
973 std::string name = argv[i]; | 973 std::string name = argv[i]; |
974 | 974 |
975 std::string type; | 975 std::string type; |
976 | 976 |
977 std::string file = do_which (name, type); | 977 std::string file = do_which (name, type); |
978 | 978 |
979 names(i-1) = name; | 979 names(i-1) = name; |
980 files(i-1) = file; | 980 files(i-1) = file; |
981 types(i-1) = type; | 981 types(i-1) = type; |
982 } | 982 } |
983 | 983 |
984 m.assign ("name", names); | 984 m.assign ("name", names); |
985 m.assign ("file", files); | 985 m.assign ("file", files); |
986 m.assign ("type", types); | 986 m.assign ("type", types); |
987 | 987 |
988 retval = m; | 988 retval = m; |
989 } | 989 } |
990 else | 990 else |
991 print_usage (); | 991 print_usage (); |
992 } | 992 } |
993 | 993 |
994 return retval; | 994 return retval; |
995 } | 995 } |
996 | 996 |
1037 else | 1037 else |
1038 { | 1038 { |
1039 std::string dir = args (0).string_value (); | 1039 std::string dir = args (0).string_value (); |
1040 | 1040 |
1041 if (! error_state) | 1041 if (! error_state) |
1042 { | 1042 { |
1043 string_vector fl = load_path::files (dir, true); | 1043 string_vector fl = load_path::files (dir, true); |
1044 | 1044 |
1045 if (! error_state) | 1045 if (! error_state) |
1046 { | 1046 { |
1047 // Return a sorted list with unique entries (in case of | 1047 // Return a sorted list with unique entries (in case of |
1048 // .m and .oct versions of the same function in a given | 1048 // .m and .oct versions of the same function in a given |
1049 // directory, for example). | 1049 // directory, for example). |
1050 fl.sort (true); | 1050 fl.sort (true); |
1051 | 1051 |
1052 retval = Cell (fl); | 1052 retval = Cell (fl); |
1053 } | 1053 } |
1054 } | 1054 } |
1055 else | 1055 else |
1056 error ("__list_functions__: input must be a string"); | 1056 error ("__list_functions__: input must be a string"); |
1057 } | 1057 } |
1058 | 1058 |
1059 return retval; | 1059 return retval; |