Mercurial > octave-nkf
comparison src/help.cc @ 3141:292ff0bf484b
[project @ 1998-02-03 08:11:07 by jwe]
author | jwe |
---|---|
date | Tue, 03 Feb 1998 08:11:22 +0000 |
parents | 5708b8bb4f06 |
children | 4696773a14b1 |
comparison
equal
deleted
inserted
replaced
3140:990ea337e950 | 3141:292ff0bf484b |
---|---|
451 | 451 |
452 ff = ff.length () > 0 ? ff : fn; | 452 ff = ff.length () > 0 ? ff : fn; |
453 | 453 |
454 if (print) | 454 if (print) |
455 os << name | 455 os << name |
456 << " is the function defined from:\n" | 456 << " is the function defined from: " |
457 << ff << "\n"; | 457 << ff << "\n"; |
458 else | 458 else |
459 retval = ff; | 459 retval = ff; |
460 } | 460 } |
461 else | 461 else |
722 | 722 |
723 string h = get_help_from_file (path); | 723 string h = get_help_from_file (path); |
724 | 724 |
725 if (! h.empty ()) | 725 if (! h.empty ()) |
726 { | 726 { |
727 octave_stdout << argv[i] << " is the file:\n" | 727 octave_stdout << argv[i] << " is the file: " |
728 << path << "\n\n" << h << "\n"; | 728 << path << "\n\n" << h << "\n"; |
729 | 729 |
730 continue; | 730 continue; |
731 } | 731 } |
732 | 732 |
829 } | 829 } |
830 } | 830 } |
831 | 831 |
832 symbol_record *sym_rec = lookup_by_name (id, 0); | 832 symbol_record *sym_rec = lookup_by_name (id, 0); |
833 | 833 |
834 if (sym_rec) | 834 if (sym_rec && sym_rec->is_defined ()) |
835 { | 835 { |
836 if (sym_rec->is_user_function ()) | 836 if (sym_rec->is_user_function ()) |
837 { | 837 { |
838 octave_value tmp = sym_rec->def (); | 838 octave_value tmp = sym_rec->def (); |
839 | 839 |
849 | 849 |
850 if (fs) | 850 if (fs) |
851 { | 851 { |
852 if (nargout == 0 && ! quiet) | 852 if (nargout == 0 && ! quiet) |
853 output_buf << argv[i] | 853 output_buf << argv[i] |
854 << " is the function defined from:\n" | 854 << " is the function defined from: " |
855 << ff << "\n\n"; | 855 << ff << "\n\n"; |
856 | 856 |
857 char ch; | 857 char ch; |
858 | 858 |
859 while (fs.get (ch)) | 859 while (fs.get (ch)) |
925 } | 925 } |
926 else | 926 else |
927 output_buf << "type: `" << argv[i] << "' has unknown type!\n"; | 927 output_buf << "type: `" << argv[i] << "' has unknown type!\n"; |
928 } | 928 } |
929 else | 929 else |
930 output_buf << "type: `" << argv[i] << "' undefined\n"; | 930 { |
931 string ff = fcn_file_in_path (argv[i]); | |
932 | |
933 if (! ff.empty ()) | |
934 { | |
935 ifstream fs (ff.c_str (), ios::in); | |
936 | |
937 if (fs) | |
938 { | |
939 if (nargout == 0 && ! quiet) | |
940 output_buf << argv[i] << " is the script file: " | |
941 << ff << "\n\n"; | |
942 | |
943 char ch; | |
944 | |
945 while (fs.get (ch)) | |
946 output_buf << ch; | |
947 } | |
948 else | |
949 output_buf << "unable to open `" << ff | |
950 << "' for reading!\n"; | |
951 } | |
952 else | |
953 output_buf << "type: `" << argv[i] << "' undefined\n"; | |
954 } | |
931 } | 955 } |
932 | 956 |
933 output_buf << ends; | 957 output_buf << ends; |
934 | 958 |
935 char *s = output_buf.str (); | 959 char *s = output_buf.str (); |
969 | 993 |
970 for (int i = 1; i < argc; i++) | 994 for (int i = 1; i < argc; i++) |
971 { | 995 { |
972 symbol_record *sym_rec = lookup_by_name (argv[i], 0); | 996 symbol_record *sym_rec = lookup_by_name (argv[i], 0); |
973 | 997 |
974 if (sym_rec) | 998 if (sym_rec && sym_rec->is_defined ()) |
975 { | 999 { |
976 int print = (nargout == 0); | 1000 int print = (nargout == 0); |
977 | 1001 |
978 string tmp = print_symbol_type (octave_stdout, sym_rec, | 1002 string tmp = print_symbol_type (octave_stdout, sym_rec, |
979 argv[i], print); | 1003 argv[i], print); |
980 if (! print) | 1004 if (! print) |
981 retval(i) = tmp; | 1005 retval(i) = tmp; |
982 } | 1006 } |
983 else | 1007 else |
984 { | 1008 { |
985 if (nargout == 0) | 1009 string path = fcn_file_in_path (argv[i]); |
986 octave_stdout << "which: `" << argv[i] << "' is undefined\n"; | 1010 |
1011 if (! path.empty ()) | |
1012 { | |
1013 if (nargout == 0) | |
1014 octave_stdout << "which: `" << argv[i] | |
1015 << "' is the script file: " | |
1016 << path << "\n"; | |
1017 else | |
1018 retval(i) = path; | |
1019 } | |
987 else | 1020 else |
988 retval(i) = "undefined"; | 1021 { |
1022 if (nargout == 0) | |
1023 octave_stdout << "which: `" << argv[i] | |
1024 << "' is undefined\n"; | |
1025 else | |
1026 retval(i) = "undefined"; | |
1027 } | |
989 } | 1028 } |
990 } | 1029 } |
991 } | 1030 } |
992 else | 1031 else |
993 print_usage ("which"); | 1032 print_usage ("which"); |