tweaks: reshuffle some lines and adjust some indentation

master
Benno Schulenberg 2021-09-29 11:52:23 +02:00
parent e0334e861d
commit 36b6416a7b
1 changed files with 16 additions and 14 deletions

View File

@ -1791,24 +1791,26 @@ bool write_file(const char *name, FILE *thefile, bool tmp,
/* When the user requested a backup, we do this only if the file exists and /* When the user requested a backup, we do this only if the file exists and
* isn't temporary AND the file has not been modified by someone else since * isn't temporary AND the file has not been modified by someone else since
* we opened it (or we are appending/prepending or writing a selection). */ * we opened it (or we are appending/prepending or writing a selection). */
if (ISSET(MAKE_BACKUP) && is_existing_file && openfile->statinfo && if (ISSET(MAKE_BACKUP) && is_existing_file && !S_ISFIFO(st.st_mode) &&
!S_ISFIFO(st.st_mode) && openfile->statinfo &&
(openfile->statinfo->st_mtime == st.st_mtime || (openfile->statinfo->st_mtime == st.st_mtime ||
method != OVERWRITE || openfile->mark)) { method != OVERWRITE || openfile->mark)) {
if (!make_backup_of(realname)) if (!make_backup_of(realname))
goto cleanup_and_exit; goto cleanup_and_exit;
} }
if (method == PREPEND && is_existing_file && S_ISFIFO(st.st_mode)) { /* When prepending, first copy the existing file to a temporary file. */
if (method == PREPEND) {
FILE *source = NULL;
FILE *target = NULL;
int verdict;
if (is_existing_file && S_ISFIFO(st.st_mode)) {
statusline(ALERT, _("Error writing %s: %s"), realname, "FIFO"); statusline(ALERT, _("Error writing %s: %s"), realname, "FIFO");
goto cleanup_and_exit; goto cleanup_and_exit;
} }
/* When prepending, first copy the existing file to a temporary file. */ source = fopen(realname, "rb");
if (method == PREPEND) {
FILE *source = fopen(realname, "rb");
FILE *target = NULL;
int verdict;
if (source == NULL) { if (source == NULL) {
statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno)); statusline(ALERT, _("Error reading %s: %s"), realname, strerror(errno));