# HG changeset patch # User jwe # Date 848430390 0 # Node ID c0770352f56293b6fcc63a734dfb28b949238569 # Parent 987e934bbb8ca48a2901278c6de5954e5ed0d13d [project @ 1996-11-19 19:06:29 by jwe] diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ Tue Nov 19 12:01:13 1996 John W. Eaton + * 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. diff --git a/src/help.cc b/src/help.cc --- a/src/help.cc +++ b/src/help.cc @@ -31,6 +31,7 @@ #include #include +#include #include #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 ())