write_file()
- Don't free backupname before displaying it in a statusbar error
message. (DLR, found by Bill Marcum)
+ - If we can't save the backup file for some reason, at least
+ save the original file, if possible, since that's better than
+ saving nothing. (DLR, suggested by Jordi)
- rcfile.c:
parse_argument()
- Rename variable ptr_bak to ptr_save, for consistency. (DLR)
statusbar(_("Error reading %s: %s"), realname,
strerror(errno));
beep();
+ /* If we can't open the original file, we won't be able
+ * to save it, so get out. */
goto cleanup_and_exit;
}
}
_("Too many backup files?"));
free(backuptemp);
free(backupname);
- fclose(f);
- goto cleanup_and_exit;
+ /* If we can't write to the backup, go on, since only
+ * saving the original file is better than saving
+ * nothing. */
+ goto skip_backup;
} else {
free(backupname);
backupname = backuptemp;
free(backupname);
if (backup_file != NULL)
fclose(backup_file);
- fclose(f);
- goto cleanup_and_exit;
+ /* If we can't write to the backup, go on, since only saving
+ * the original file is better than saving nothing. */
+ goto skip_backup;
}
#ifdef DEBUG
} else
statusbar(_("Error writing %s: %s"), backupname,
strerror(errno));
- free(backupname);
- goto cleanup_and_exit;
+ /* If we can't read from or write to the backup, go on,
+ * since only saving the original file is better than saving
+ * nothing. */
}
free(backupname);
}
+
+ skip_backup:
#endif /* !NANO_TINY */
/* If NOFOLLOW_SYMLINKS is set and the file is a link, we aren't