Mercurial > hg > octave-lojdl
changeset 2534:c0770352f562
[project @ 1996-11-19 19:06:29 by jwe]
author | jwe |
---|---|
date | Tue, 19 Nov 1996 19:06:30 +0000 |
parents | 987e934bbb8c |
children | caa21ce81913 |
files | src/ChangeLog src/help.cc |
diffstat | 2 files changed, 37 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ Tue Nov 19 12:01:13 1996 John W. Eaton <jwe@bevo.che.wisc.edu> + * help.cc (Ftype): If a function is defined from a file and + transformed text has not been requested, just print the contents + of the file. + * parse.y (fold): New functions for constant folding for binary and unary expressions. Keep track of original text even when transformations occur.
--- 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 ())