}
/* Read the current entry in the open_files structure and set up the
- * currently open file using that entry's information. */
+ * currently open file buffer using that entry's information. */
void load_open_file(void)
{
assert(open_files != NULL);
titlebar(NULL);
}
-/* Open either the next or previous file. */
+/* Open either the next or previous file buffer. */
void open_prevnext_file(bool next)
{
add_open_file(TRUE);
assert(open_files != NULL);
- /* If only one file is open, indicate it on the statusbar and get
- * out. */
+ /* If only one file buffer is open, indicate it on the statusbar and
+ * get out. */
if (open_files == open_files->next) {
- statusbar(_("No more open files"));
+ statusbar(_("No more open file buffers"));
return;
}
/* Delete an entry from the open_files filestruct. After deletion of an
* entry, the next entry is opened. Return TRUE on success or FALSE if
- * there are no more open files. */
+ * there are no more open file buffers. */
bool close_open_file(void)
{
assert(open_files != NULL);
vfprintf(stderr, msg, ap);
va_end(ap);
- /* save the currently loaded file if it's been modified */
+ /* Save the current file buffer if it's been modified. */
if (ISSET(MODIFIED))
die_save_file(filename);
#ifdef ENABLE_MULTIBUFFER
- /* then save all of the other modified loaded files, if any */
+ /* Save all of the other modified file buffers, if any. */
if (open_files != NULL) {
- openfilestruct *tmp;
+ openfilestruct *tmp = open_files;
- tmp = open_files;
-
- while (open_files->prev != NULL)
- open_files = open_files->prev;
-
- while (open_files->next != NULL) {
+ while (tmp != open_files->next) {
+ open_files = open_files->next;
- /* if we already saved the file above (i.e, if it was the
- currently loaded file), don't save it again */
- if (tmp != open_files) {
- /* make sure open_files->fileage and fileage, and
- open_files->filebot and filebot, are in sync; they
- might not be if lines have been cut from the top or
- bottom of the file */
+ /* Save the current file buffer if it's been modified. */
+ if (open_files->flags & MODIFIED) {
+ /* Set fileage and filebot to match the current file
+ * buffer, and then write it to disk. */
fileage = open_files->fileage;
filebot = open_files->filebot;
- /* save the file if it's been modified */
- if (open_files->flags & MODIFIED)
- die_save_file(open_files->filename);
+ die_save_file(open_files->filename);
}
- open_files = open_files->next;
}
}
#endif
- exit(1); /* We have a problem: exit w/ errorlevel(1) */
+ /* Get out. */
+ exit(1);
}
void die_save_file(const char *die_filename)
if (i == 0 || (i == 1 && do_writeout(TRUE) > 0)) {
#ifdef ENABLE_MULTIBUFFER
- /* Exit only if there are no more open buffers. */
+ /* Exit only if there are no more open file buffers. */
if (!close_open_file())
#endif
finish();