From bc22b3c876c10d66d1a481c52252deb0c830a9fb Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Thu, 7 Oct 2021 12:38:04 +0200 Subject: [PATCH] files: clear original filename when the user toggles Append or Prepend When the current filename is equal to the filename of the buffer, then clear the filename, because the chances that the user wants to append or prepend a file to itself are practically nil. This fulfills https://savannah.gnu.org/bugs/?61243. --- src/files.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/files.c b/src/files.c index 484852a9..f2d435a9 100644 --- a/src/files.c +++ b/src/files.c @@ -2194,9 +2194,13 @@ int do_writeout(bool exiting, bool withprompt) TOGGLE(MAKE_BACKUP); continue; } else if (func == prepend_void) { + if (strcmp(answer, openfile->filename) == 0) + given[0] = '\0'; method = (method == PREPEND) ? OVERWRITE : PREPEND; continue; } else if (func == append_void) { + if (strcmp(answer, openfile->filename) == 0) + given[0] = '\0'; method = (method == APPEND) ? OVERWRITE : APPEND; continue; }