Mercurial > hg > octave-terminal
changeset 2517:0c5e671499ed
[project @ 1996-11-14 20:24:02 by jwe]
author | jwe |
---|---|
date | Thu, 14 Nov 1996 20:24:03 +0000 |
parents | 70cad7ffd946 |
children | 64de62e8e73d |
files | src/ChangeLog src/mk-oct-links.in src/toplev.cc src/variables.cc |
diffstat | 4 files changed, 28 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,10 @@ Thu Nov 14 00:06:19 1996 John W. Eaton <jwe@bevo.che.wisc.edu> + * variables.cc (parse_fcn_file): Add unwind-protect for file + pointer, so the file is always closed. + (get_help_from_file): Likewise. + * toplev.cc (parse_and_execute): Likewise. + * Makefile.in (install-oct): Depend on mk-oct-links. (mk-oct-links): New target.
--- a/src/mk-oct-links.in +++ b/src/mk-oct-links.in @@ -7,7 +7,7 @@ # installed. The remaining arguments should be the list of source # files that were used to create the .oct files. -LN_S="@LN_S@" +LN_S="%LN_S%" links_dir=$1 shift
--- a/src/toplev.cc +++ b/src/toplev.cc @@ -163,6 +163,13 @@ run_unwind_frame ("parse_and_execute"); } +static void +safe_fclose (void *f) +{ + if (f) + fclose ((FILE *) f); +} + void parse_and_execute (const string& s, int print, int verbose, const char *warn_for) @@ -179,6 +186,8 @@ if (f) { + add_unwind_protect (safe_fclose, (void *) f); + unwind_protect_int (input_line_number); unwind_protect_int (current_input_column); @@ -194,8 +203,6 @@ parse_and_execute (f, print); - fclose (f); - if (verbose) cout << "done." << endl; }
--- a/src/variables.cc +++ b/src/variables.cc @@ -590,6 +590,13 @@ octave_command_history.ignore_entries (! Vsaving_history); } +static void +safe_fclose (void *f) +{ + if (f) + fclose ((FILE *) f); +} + static int parse_fcn_file (int exec_script, const string& ff) { @@ -616,6 +623,8 @@ FILE *ffile = get_input_from_file (ff, 0); + add_unwind_protect (safe_fclose, (void *) ffile); + if (ffile) { // Check to see if this file defines a function or is just a @@ -689,7 +698,6 @@ script_file_executed = 1; } - fclose (ffile); } run_unwind_frame ("parse_fcn_file"); @@ -787,8 +795,11 @@ if (fptr) { + add_unwind_protect (safe_fclose, (void *) fptr); + retval = gobble_leading_white_space (fptr, true, true); - fclose (fptr); + + run_unwind_protect (); } }