Mercurial > hg > octave-nkf
diff src/variables.cc @ 2517:0c5e671499ed
[project @ 1996-11-14 20:24:02 by jwe]
author | jwe |
---|---|
date | Thu, 14 Nov 1996 20:24:03 +0000 |
parents | 06595bc7f2d0 |
children | ecc1a12678de |
line wrap: on
line diff
--- 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 (); } }