# HG changeset patch # User jwe # Date 848003043 0 # Node ID 0c5e671499ed37441b11e9f3364d4f9e08686810 # Parent 70cad7ffd946ea4d15f0c0951cf50b2374197d41 [project @ 1996-11-14 20:24:02 by jwe] diff -r 70cad7ffd946 -r 0c5e671499ed src/ChangeLog --- a/src/ChangeLog Thu Nov 14 18:46:18 1996 +0000 +++ b/src/ChangeLog Thu Nov 14 20:24:03 1996 +0000 @@ -1,5 +1,10 @@ Thu Nov 14 00:06:19 1996 John W. Eaton + * 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. diff -r 70cad7ffd946 -r 0c5e671499ed src/mk-oct-links.in --- a/src/mk-oct-links.in Thu Nov 14 18:46:18 1996 +0000 +++ b/src/mk-oct-links.in Thu Nov 14 20:24:03 1996 +0000 @@ -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 diff -r 70cad7ffd946 -r 0c5e671499ed src/toplev.cc --- a/src/toplev.cc Thu Nov 14 18:46:18 1996 +0000 +++ b/src/toplev.cc Thu Nov 14 20:24:03 1996 +0000 @@ -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; } diff -r 70cad7ffd946 -r 0c5e671499ed src/variables.cc --- a/src/variables.cc Thu Nov 14 18:46:18 1996 +0000 +++ b/src/variables.cc Thu Nov 14 20:24:03 1996 +0000 @@ -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 (); } }