Mercurial > hg > octave-lyh
comparison src/help.cc @ 3356:d2e12e998a78
[project @ 1999-11-18 06:17:06 by jwe]
author | jwe |
---|---|
date | Thu, 18 Nov 1999 06:17:08 +0000 |
parents | c4983fc7318f |
children | 4f40efa995c1 |
comparison
equal
deleted
inserted
replaced
3355:c4983fc7318f | 3356:d2e12e998a78 |
---|---|
58 #include "ov-usr-fcn.h" | 58 #include "ov-usr-fcn.h" |
59 #include "pager.h" | 59 #include "pager.h" |
60 #include "parse.h" | 60 #include "parse.h" |
61 #include "pathsearch.h" | 61 #include "pathsearch.h" |
62 #include "procstream.h" | 62 #include "procstream.h" |
63 #include "pt-pr-code.h" | |
64 #include "sighandlers.h" | 63 #include "sighandlers.h" |
65 #include "symtab.h" | 64 #include "symtab.h" |
66 #include "syswait.h" | 65 #include "syswait.h" |
67 #include "toplev.h" | 66 #include "toplev.h" |
68 #include "unwind-prot.h" | 67 #include "unwind-prot.h" |
800 bool quiet, bool pr_orig_txt) | 799 bool quiet, bool pr_orig_txt) |
801 { | 800 { |
802 symbol_record *sym_rec = lookup_by_name (name, 0); | 801 symbol_record *sym_rec = lookup_by_name (name, 0); |
803 | 802 |
804 if (sym_rec && sym_rec->is_defined ()) | 803 if (sym_rec && sym_rec->is_defined ()) |
805 { | 804 sym_rec->type (os, pr_type_info, quiet, pr_orig_txt); |
806 if (sym_rec->is_user_function ()) | |
807 { | |
808 octave_value tmp = sym_rec->def (); | |
809 | |
810 octave_function *defn = tmp.function_value (); | |
811 | |
812 string fn = defn ? defn->fcn_file_name () : string (); | |
813 | |
814 if (pr_orig_txt && ! fn.empty ()) | |
815 { | |
816 ifstream fs (fn.c_str (), ios::in); | |
817 | |
818 if (fs) | |
819 { | |
820 if (pr_type_info && ! quiet) | |
821 os << name << " is the function defined from: " | |
822 << fn << "\n\n"; | |
823 | |
824 char ch; | |
825 | |
826 while (fs.get (ch)) | |
827 os << ch; | |
828 } | |
829 else | |
830 os << "unable to open `" << fn << "' for reading!\n"; | |
831 } | |
832 else | |
833 { | |
834 if (pr_type_info && ! quiet) | |
835 os << name << " is a user-defined function:\n\n"; | |
836 | |
837 tree_print_code tpc (os, "", pr_orig_txt); | |
838 | |
839 defn->accept (tpc); | |
840 } | |
841 } | |
842 | |
843 // XXX FIXME XXX -- this code should be shared with | |
844 // Fwhich. | |
845 | |
846 else if (sym_rec->is_text_function ()) | |
847 os << name << " is a built-in text-function\n"; | |
848 else if (sym_rec->is_builtin_function ()) | |
849 os << name << " is a built-in function\n"; | |
850 else if (sym_rec->is_user_variable () | |
851 || sym_rec->is_builtin_variable () | |
852 || sym_rec->is_builtin_constant ()) | |
853 { | |
854 octave_value defn = sym_rec->def (); | |
855 | |
856 int var_ok = 1; | |
857 | |
858 if (! error_state) | |
859 { | |
860 if (pr_type_info && ! quiet) | |
861 { | |
862 if (var_ok) | |
863 { | |
864 os << name; | |
865 | |
866 if (sym_rec->is_user_variable ()) | |
867 os << " is a user-defined variable\n"; | |
868 else if (sym_rec->is_builtin_variable ()) | |
869 os << " is a built-in variable\n"; | |
870 else if (sym_rec->is_builtin_constant ()) | |
871 os << " is a built-in constant\n"; | |
872 else | |
873 panic_impossible (); | |
874 } | |
875 else | |
876 os << "type: `" << name << "' has unknown type!\n"; | |
877 } | |
878 | |
879 defn.print_raw (os, true); | |
880 | |
881 if (pr_type_info) | |
882 os << "\n"; | |
883 } | |
884 } | |
885 else | |
886 error ("type: `%s' has unknown type!", name.c_str ()); | |
887 } | |
888 else | 805 else |
889 { | 806 { |
890 string ff = fcn_file_in_path (name); | 807 string ff = fcn_file_in_path (name); |
891 | 808 |
892 if (! ff.empty ()) | 809 if (! ff.empty ()) |