Mercurial > hg > octave-lyh
diff src/help.cc @ 2534:c0770352f562
[project @ 1996-11-19 19:06:29 by jwe]
author | jwe |
---|---|
date | Tue, 19 Nov 1996 19:06:30 +0000 |
parents | 0e5eb97cb137 |
children | f7e3d23f0a8f |
line wrap: on
line diff
--- a/src/help.cc +++ b/src/help.cc @@ -31,6 +31,7 @@ #include <string> #include <iostream.h> +#include <fstream.h> #include <strstream.h> #ifdef HAVE_UNISTD_H @@ -782,12 +783,39 @@ { tree_fvc *defn = sym_rec->def (); - if (nargout == 0 && ! quiet) - output_buf << argv[i] << " is a user-defined function\n"; + string fn = defn->fcn_file_name (); + string ff = fcn_file_in_path (fn); + + if (pr_orig_txt && ! ff.empty ()) + { + ifstream fs (ff.c_str (), ios::in); + + if (fs) + { + if (nargout == 0 && ! quiet) + output_buf << argv[i] + << " is the function defined from:\n" + << ff << "\n\n"; + + char ch; - tree_print_code tpc (output_buf, "", pr_orig_txt); + while (fs.get (ch)) + output_buf << ch; + } + else + output_buf << "unable to open `" << ff + << "' for reading!\n"; + } + else + { + if (nargout == 0 && ! quiet) + output_buf << argv[i] + << " is a user-defined function:\n\n"; - defn->accept (tpc); + tree_print_code tpc (output_buf, "", pr_orig_txt); + + defn->accept (tpc); + } } // XXX FIXME XXX -- this code should be shared with @@ -836,7 +864,7 @@ << "' has no member `" << elts << "'\n"; else output_buf << "type: `" << id - << "' has unknown type!"; + << "' has unknown type!\n"; } } if (! tmp->is_map ())