Mercurial > hg > octave-lyh
changeset 742:9004af8c7a33
[project @ 1994-09-30 14:50:32 by jwe]
author | jwe |
---|---|
date | Fri, 30 Sep 1994 14:53:08 +0000 |
parents | 2d2f3c07cedd |
children | a778feb295b4 |
files | src/help.cc src/parse.h src/variables.cc |
diffstat | 3 files changed, 86 insertions(+), 66 deletions(-) [+] |
line wrap: on
line diff
--- a/src/help.cc +++ b/src/help.cc @@ -342,6 +342,76 @@ delete [] symbols; } +static char * +print_symbol_type (ostrstream& output_buf, symbol_record *sym_rec, + char *name, int print) +{ + char *retval = 0; + + if (sym_rec->is_user_function ()) + { + tree_fvc *defn = sym_rec->def (); + char *fn = defn->fcn_file_name (); + if (fn) + { + char *ff = fcn_file_in_path (fn); + ff = ff ? ff : fn; + + if (print) + output_buf << name + << " is the function defined from:\n" + << ff << "\n"; + else + retval = ff; + } + else + { + if (print) + output_buf << name << " is a user-defined function\n"; + else + retval = "user-defined function"; + } + } + else if (sym_rec->is_text_function ()) + { + if (print) + output_buf << name << " is a builtin text-function\n"; + else + retval = "builtin text-function"; + } + else if (sym_rec->is_builtin_function ()) + { + if (print) + output_buf << name << " is a builtin function\n"; + else + retval = "builtin function"; + } + else if (sym_rec->is_user_variable ()) + { + if (print) + output_buf << name << " is a user-defined variable\n"; + else + retval = "user-defined variable"; + } + else if (sym_rec->is_builtin_variable ()) + { + if (print) + output_buf << name << " is a builtin variable\n"; + else + retval = "builtin variable"; + } + else + { + if (print) + output_buf << "which: `" << name + << "' has unknown type\n"; + else + retval = "unknown type"; + } + + return retval; +} + static void display_symtab_names (ostrstream& output_buf, char **names, int count, const char *desc) @@ -594,8 +664,8 @@ char *h = sym_rec->help (); if (h && *h) { - output_buf << "\n*** " << *argv << ":\n\n" - << h << "\n"; + print_symbol_type (output_buf, sym_rec, *argv, 1); + output_buf << "\n" << h << "\n"; continue; } } @@ -742,66 +812,11 @@ if (sym_rec) { - if (sym_rec->is_user_function ()) - { - tree_fvc *defn = sym_rec->def (); - char *fn = defn->fcn_file_name (); - if (fn) - { - char *ff = fcn_file_in_path (fn); - ff = ff ? ff : fn; - - if (nargout == 0) - output_buf << *argv - << " is the function defined from:\n" - << ff << "\n"; - else - retval(i) = ff; - } - else - { - if (nargout == 0) - output_buf << *argv << " is a user-defined function\n"; - else - retval(i) = "user-defined function"; - } - } - else if (sym_rec->is_text_function ()) - { - if (nargout == 0) - output_buf << *argv << " is a builtin text-function\n"; - else - retval(i) = "builtin text-function"; - } - else if (sym_rec->is_builtin_function ()) - { - if (nargout == 0) - output_buf << *argv << " is a builtin function\n"; - else - retval(i) = "builtin function"; - } - else if (sym_rec->is_user_variable ()) - { - if (nargout == 0) - output_buf << *argv << " is a user-defined variable\n"; - else - retval(i) = "user-defined variable"; - } - else if (sym_rec->is_builtin_variable ()) - { - if (nargout == 0) - output_buf << *argv << " is a builtin variable\n"; - else - retval(i) = "builtin variable"; - } - else - { - if (nargout == 0) - output_buf << "which: `" << *argv - << "' has unknown type\n"; - else - retval(i) = "unknown type"; - } + int print = (nargout == 0); + char *tmp = print_symbol_type (output_buf, sym_rec, + *argv, print); + if (! print) + retval(i) = tmp; } else {
--- a/src/parse.h +++ b/src/parse.h @@ -94,6 +94,10 @@ // Nonzero means we're looking at the style part of a plot command. extern int in_plot_style; +// Nonzero means we're looking at an indirect reference to a structure +// element. +extern int looking_at_indirect_ref; + #endif /*
--- a/src/variables.cc +++ b/src/variables.cc @@ -1145,11 +1145,12 @@ int nargin = args.length (); - Octave_object tmp_args = args; + Octave_object tmp_args; + for (int i = nargin; i > 0; i--) + tmp_args(i) = args(i-1); + tmp_args(0) = "-long"; - tmp_args(nargin) = "-long"; - - int argc = nargin + 1; + int argc = tmp_args.length () + 1; char **argv = make_argv (tmp_args, "whos"); if (error_state)