Mercurial > hg > octave-terminal
changeset 1608:65572455466f
[project @ 1995-11-02 13:06:41 by jwe]
author | jwe |
---|---|
date | Thu, 02 Nov 1995 13:06:41 +0000 |
parents | 795527e9db19 |
children | d0a45cb55b59 |
files | src/octave.cc |
diffstat | 1 files changed, 23 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/octave.cc +++ b/src/octave.cc @@ -45,6 +45,8 @@ #include <pwd.h> +#include <readline/tilde.h> + #include "getopt.h" #include "lo-error.h" @@ -352,13 +354,16 @@ } void -parse_and_execute (const char *s, int print, int verbose) +parse_and_execute (const char *s, int print, int verbose, + const char *warn_for) { begin_unwind_frame ("parse_and_execute_2"); unwind_protect_int (reading_script_file); + unwind_protect_ptr (curr_fcn_file_full_name); reading_script_file = 1; + curr_fcn_file_full_name = s; FILE *f = get_input_from_file (s, 0); if (f) @@ -383,6 +388,8 @@ if (verbose) cout << "done." << endl; } + else if (warn_for) + error ("%s: unable to open file `%s'", warn_for, s); run_unwind_frame ("parse_and_execute_2"); } @@ -401,7 +408,19 @@ { const char *file = args(0).string_value (); - parse_and_execute (file, 1); + if (! error_state) + { + file = tilde_expand (file); + + parse_and_execute (file, 1, 0, "source"); + + if (error_state) + error ("source: error sourcing file `%s'", file); + + delete [] file; + } + else + error ("source: expecting file name as argument"); } else print_usage ("source"); @@ -698,6 +717,7 @@ { reading_script_file = 1; curr_fcn_file_name = argv[optind]; + curr_fcn_file_full_name = curr_fcn_file_name; FILE *infile = get_input_from_file (curr_fcn_file_name); @@ -708,7 +728,7 @@ bind_builtin_variable ("program_invocation_name", curr_fcn_file_name); - char *tmp = strrchr (curr_fcn_file_name, '/'); + const char *tmp = strrchr (curr_fcn_file_name, '/'); tmp = tmp ? tmp+1 : curr_fcn_file_name; bind_builtin_variable ("program_name", tmp);