Mercurial > hg > octave-lyh
comparison src/help.cc @ 1288:4acabfbdd381
[project @ 1995-04-28 20:23:04 by jwe]
author | jwe |
---|---|
date | Fri, 28 Apr 1995 20:31:13 +0000 |
parents | fcdf6c5d0302 |
children | 34295bf6aac6 |
comparison
equal
deleted
inserted
replaced
1287:3f49454bc68c | 1288:4acabfbdd381 |
---|---|
771 if (! *argv || ! **argv) | 771 if (! *argv || ! **argv) |
772 continue; | 772 continue; |
773 | 773 |
774 char *id = strsave (*argv); | 774 char *id = strsave (*argv); |
775 char *elts = 0; | 775 char *elts = 0; |
776 char *ptr = strchr (id, '.'); | 776 if (id[strlen (id) - 1] != '.') |
777 if (ptr) | |
778 { | 777 { |
779 *ptr = '\0'; | 778 char *ptr = strchr (id, '.'); |
780 | |
781 elts = ptr + 1; | |
782 ptr = strrchr (elts, '.'); | |
783 if (ptr) | 779 if (ptr) |
784 *ptr = '\0'; | 780 { |
785 else | 781 *ptr = '\0'; |
786 elts = 0; | 782 elts = ptr + 1; |
783 } | |
787 } | 784 } |
788 | 785 |
789 symbol_record *sym_rec = lookup_by_name (id, 0); | 786 symbol_record *sym_rec = lookup_by_name (id, 0); |
790 | 787 |
791 if (sym_rec) | 788 if (sym_rec) |
809 else if (sym_rec->is_user_variable () | 806 else if (sym_rec->is_user_variable () |
810 || sym_rec->is_builtin_variable ()) | 807 || sym_rec->is_builtin_variable ()) |
811 { | 808 { |
812 tree_fvc *defn = sym_rec->def (); | 809 tree_fvc *defn = sym_rec->def (); |
813 | 810 |
814 assert (defn->is_constant ()); | 811 assert (defn && defn->is_constant ()); |
815 | 812 |
816 tree_constant *tmp = (tree_constant *) defn; | 813 tree_constant *tmp = (tree_constant *) defn; |
817 | 814 |
818 int var_ok = 1; | 815 int var_ok = 1; |
819 if (tmp && tmp->is_map ()) | 816 if (tmp && tmp->is_map ()) |
820 { | 817 { |
821 if (elts && *elts) | 818 if (elts && *elts) |
822 { | 819 { |
823 tree_constant ult; | 820 tree_constant ult = |
824 ult = tmp->lookup_map_element (elts, 0, 1); | 821 tmp->lookup_map_element (elts, 0, 1); |
825 | 822 |
826 if (! ult.is_defined ()) | 823 if (! ult.is_defined ()) |
827 var_ok = 0; | 824 var_ok = 0; |
828 } | 825 } |
829 } | 826 } |
830 | 827 |
831 if (nargout == 0 && ! quiet) | 828 if (nargout == 0 && ! quiet) |
832 { | 829 { |
833 output_buf << *argv; | 830 if (var_ok) |
834 if (sym_rec->is_user_variable ()) | 831 { |
835 output_buf << " is a user-defined variable\n"; | 832 output_buf << *argv; |
833 if (sym_rec->is_user_variable ()) | |
834 output_buf << " is a user-defined variable\n"; | |
835 else | |
836 output_buf << " is a built-in variable\n"; | |
837 } | |
836 else | 838 else |
837 output_buf << " is a built-in variable\n"; | 839 { |
840 if (elts && *elts) | |
841 output_buf << "type: structure `" << id | |
842 << "' has no member `" << elts << "'\n"; | |
843 else | |
844 output_buf << "type: `" << id | |
845 << "' has unknown type!"; | |
846 } | |
838 } | 847 } |
839 | |
840 if (! tmp->is_map ()) | 848 if (! tmp->is_map ()) |
841 { | 849 { |
842 tmp->print_code (output_buf); | 850 tmp->print_code (output_buf); |
843 | 851 |
844 if (nargout == 0) | 852 if (nargout == 0) |
860 maybe_page_output (output_buf); | 868 maybe_page_output (output_buf); |
861 else | 869 else |
862 { | 870 { |
863 char *s = output_buf.str (); | 871 char *s = output_buf.str (); |
864 retval = s; | 872 retval = s; |
865 delete s; | 873 delete [] s; |
866 } | 874 } |
867 } | 875 } |
868 else | 876 else |
869 print_usage ("type"); | 877 print_usage ("type"); |
870 | 878 |