commit c5d157dd9d7655c5425bad0f09e7e7923adf411a
parent 3a65c0d1929ae8f7c3465c18696c7a6cb7548cd5
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 31 May 2019 09:15:12 +0200
tweaks: close a buffer differently and elide a parameter
Diffstat:
5 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -462,8 +462,7 @@ bool open_buffer(const char *filename, bool new_buffer)
/* When not overriding an existing lock, discard the buffer. */
if (do_lockfile(realname) < 0) {
#ifdef ENABLE_MULTIBUFFER
- openfile = openfile->prev;
- close_buffer(openfile->next);
+ close_buffer();
#endif
free(realname);
return FALSE;
@@ -645,10 +644,11 @@ void switch_to_next_buffer(void)
switch_to_adjacent_buffer(FORWARD);
}
-/* Remove the given buffer from the circular list of buffers. */
-void close_buffer(openfilestruct *buffer)
+/* Remove the current buffer from the circular list of buffers. */
+void close_buffer(void)
{
- unlink_opennode(buffer);
+ openfile = openfile->prev;
+ unlink_opennode(openfile->next);
/* When just one buffer remains open, show "Exit" in the help lines. */
if (openfile == openfile->next)
diff --git a/src/help.c b/src/help.c
@@ -223,9 +223,8 @@ void do_help(void)
}
}
- /* Switch back to the original buffer and discard the help-text buffer. */
- openfile = openfile->prev;
- close_buffer(openfile->next);
+ /* Discard the help-text buffer. */
+ close_buffer();
/* Restore the settings of all flags. */
memcpy(flags, stash, sizeof(flags));
diff --git a/src/nano.c b/src/nano.c
@@ -1044,7 +1044,9 @@ void close_and_go(void)
openfile->current->lineno, xplustabs() + 1);
#endif
switch_to_next_buffer();
- close_buffer(openfile->prev);
+ openfile = openfile->prev;
+ close_buffer();
+ openfile = openfile->next;
/* Adjust the count in the top bar. */
titlebar(NULL);
} else
diff --git a/src/proto.h b/src/proto.h
@@ -276,7 +276,7 @@ void prepare_for_display(void);
void mention_name_and_linecount(void);
void switch_to_prev_buffer(void);
void switch_to_next_buffer(void);
-void close_buffer(openfilestruct *buffer);
+void close_buffer(void);
#endif
void read_file(FILE *f, int fd, const char *filename, bool undoable);
int open_file(const char *filename, bool newfie, FILE **f);
diff --git a/src/winio.c b/src/winio.c
@@ -3374,8 +3374,7 @@ void total_refresh(void)
titlebar(title);
#ifdef ENABLE_HELP
if (inhelp) {
- openfile = openfile->prev;
- close_buffer(openfile->next);
+ close_buffer();
wrap_help_text_into_buffer();
} else
#endif