From 77da54c6c6ad0caaabaebad3fd437c02f701657c Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 23 Mar 2021 16:12:48 +0100 Subject: [PATCH] startup: do not store an error message in the record of another buffer Set the 'format' of a file only when it has been fully read in, so that this field can be used to indicate that any later error message cannot be meant for this buffer. This fixes https://savannah.gnu.org/bugs/?60269. Bug existed since commit 6bf52dcc from yesterday. --- src/definitions.h | 2 +- src/files.c | 6 ++++-- src/winio.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/definitions.h b/src/definitions.h index 3f2ef3e6..8a2beadc 100644 --- a/src/definitions.h +++ b/src/definitions.h @@ -246,7 +246,7 @@ /* Enumeration types. */ typedef enum { - NIX_FILE, DOS_FILE, MAC_FILE + UNSPECIFIED, NIX_FILE, DOS_FILE, MAC_FILE } format_type; typedef enum { diff --git a/src/files.c b/src/files.c index 0b7f62a3..4f135f03 100644 --- a/src/files.c +++ b/src/files.c @@ -83,7 +83,7 @@ void make_new_buffer(void) openfile->mark = NULL; openfile->softmark = FALSE; - openfile->fmt = NIX_FILE; + openfile->fmt = UNSPECIFIED; openfile->undotop = NULL; openfile->current_undo = NULL; @@ -821,9 +821,11 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable) num_lines), num_lines); } #endif - else + else { + openfile->fmt = NIX_FILE; statusline(HUSH, P_("Read %zu line", "Read %zu lines", num_lines), num_lines); + } /* If we inserted less than a screenful, don't center the cursor. */ if (undoable && less_than_a_screenful(was_lineno, was_leftedge)) diff --git a/src/winio.c b/src/winio.c index 0f770ebe..7d852db8 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2230,7 +2230,7 @@ void statusline(message_type importance, const char *msg, ...) va_end(ap); #ifdef ENABLE_MULTIBUFFER - if (!we_are_running && importance == ALERT && openfile && + if (!we_are_running && importance == ALERT && openfile && !openfile->fmt && !openfile->errormessage && openfile->next != openfile) openfile->errormessage = copy_of(compound); #endif