/* -*-C-*-
-$Id: term.c,v 1.9 1993/08/31 18:54:33 gjr Exp $
+$Id: term.c,v 1.10 1993/11/08 20:58:12 cph Exp $
Copyright (c) 1990-1993 Massachusetts Institute of Technology
extern void EXFUN (Reset_Memory, (void));
static void EXFUN (edwin_auto_save, (void));
-static SCHEME_OBJECT edwin_auto_save_position;
+static void EXFUN (delete_temp_files, (void));
#define BYTES_TO_BLOCKS(n) (((n) + 1023) / 1024)
#define MIN_HEAP_DELTA 50
#ifdef INIT_EXIT_SCHEME
INIT_EXIT_SCHEME ();
#endif
- edwin_auto_save_position = SHARP_T;
}
\f
static void
EXIT_HOOK (code, value, abnormal_p);
#endif
edwin_auto_save ();
+ delete_temp_files ();
#if WINNT
if (code != TERM_HALT) outf_flush_fatal(); /*dont salute*/
winnt_deallocate_registers();
static void
DEFUN_VOID (edwin_auto_save)
{
- /* edwin_auto_save_position remembers what is left to be done after
- this save. That way, if the save aborts due to an error and we
- end up back here, we continue saving, skipping the entries
- already saved as well as the entry that caused the error. */
- if (edwin_auto_save_position == SHARP_T)
- {
- if (Valid_Fixed_Obj_Vector ())
- edwin_auto_save_position = (Get_Fixed_Obj_Slot (FIXOBJ_EDWIN_AUTO_SAVE));
- else
- edwin_auto_save_position = SHARP_F;
- }
- while (PAIR_P (edwin_auto_save_position))
+ static SCHEME_OBJECT position;
+ static struct interpreter_state_s new_state;
+
+ position =
+ ((Valid_Fixed_Obj_Vector ())
+ ? (Get_Fixed_Obj_Slot (FIXOBJ_EDWIN_AUTO_SAVE))
+ : EMPTY_LIST);
+ while (PAIR_P (position))
{
- SCHEME_OBJECT entry = (PAIR_CAR (edwin_auto_save_position));
- edwin_auto_save_position = (PAIR_CDR (edwin_auto_save_position));
+ SCHEME_OBJECT entry = (PAIR_CAR (position));
+ position = (PAIR_CDR (position));
if ((PAIR_P (entry))
&& (GROUP_P (PAIR_CAR (entry)))
&& (STRING_P (PAIR_CDR (entry)))
unsigned char * end = (start + (STRING_LENGTH (text)));
unsigned char * gap_start = (start + (GROUP_GAP_START (group)));
unsigned char * gap_end = (start + (GROUP_GAP_END (group)));
- Tchannel channel;
if ((start < gap_start) || (gap_end < end))
{
- outf_error ("Auto-saving file \"%s\"\n", namestring);
- outf_flush_error ();
- channel = (OS_open_output_file (namestring));
- if (start < gap_start)
- OS_channel_write (channel, start, (gap_start - start));
- if (gap_end < end)
- OS_channel_write (channel, gap_end, (end - gap_end));
- OS_channel_close (channel);
+ bind_interpreter_state (&new_state);
+ if ((setjmp (interpreter_catch_env)) == 0)
+ {
+ Tchannel channel;
+ outf_error ("Auto-saving file \"%s\"\n", namestring);
+ outf_flush_error ();
+ channel = (OS_open_output_file (namestring));
+ if (start < gap_start)
+ OS_channel_write (channel, start, (gap_start - start));
+ if (gap_end < end)
+ OS_channel_write (channel, gap_end, (end - gap_end));
+ OS_channel_close (channel);
+ }
+ unbind_interpreter_state (&new_state);
}
}
}
}
+
+static void
+DEFUN_VOID (delete_temp_files)
+{
+ static SCHEME_OBJECT position;
+ static struct interpreter_state_s new_state;
+
+ position =
+ ((Valid_Fixed_Obj_Vector ())
+ ? (Get_Fixed_Obj_Slot (FIXOBJ_FILES_TO_DELETE))
+ : EMPTY_LIST);
+ while (PAIR_P (position))
+ {
+ SCHEME_OBJECT entry = (PAIR_CAR (position));
+ position = (PAIR_CDR (position));
+ if (STRING_P (entry))
+ {
+ bind_interpreter_state (&new_state);
+ if ((setjmp (interpreter_catch_env)) == 0)
+ OS_file_remove ((char *) (STRING_LOC (entry, 0)));
+ unbind_interpreter_state (&new_state);
+ }
+ }
+}