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.
This commit is contained in:
Benno Schulenberg 2021-03-23 16:12:48 +01:00
parent 6bf52dcc8d
commit 77da54c6c6
3 changed files with 6 additions and 4 deletions

View File

@ -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 {

View File

@ -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))

View File

@ -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