diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index b01e8181cc1..6f1e3d50386 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.104 2024/04/23 13:34:50 jsg Exp $ */ +/* $OpenBSD: file.c,v 1.105 2026/03/03 15:17:29 op Exp $ */ /* This file is in the public domain. */ @@ -565,6 +565,11 @@ static int makebackup = TRUE; int filesave(int f, int n) { + if ((curbp->b_flag & BFCHG) == 0) { + ewprintf("(No changes need to be saved)"); + return (TRUE); + } + if (curbp->b_fname[0] == '\0') return (filewrite(f, n)); else @@ -572,8 +577,7 @@ filesave(int f, int n) } /* - * Save the contents of the buffer argument into its associated file. Do - * nothing if there have been no changes (is this a bug, or a feature?). + * Save the contents of the buffer argument into its associated file. * Error if there is no remembered file name. If this is the first write * since the read or visit, then a backup copy of the file is made. * Allow user to select whether or not to make backup files by looking at @@ -585,12 +589,6 @@ buffsave(struct buffer *bp) int s; FILE *ffp; - /* return, no changes */ - if ((bp->b_flag & BFCHG) == 0) { - ewprintf("(No changes need to be saved)"); - return (TRUE); - } - /* must have a name */ if (bp->b_fname[0] == '\0') { dobeep();