nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 0f98466e2fdee6834a5f906e41d21d9ad54015f1
parent 40c067133a4cafcd57d447c3b080eb036712433a
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 16 Oct 2019 16:05:40 +0200

tweaks: adjust the indentation after the previous change

Also, don't bother assigning the stream pointer of the existing file
to variable 'f', as it gets overwritten right away by the pointer of
the temp file.

Diffstat:
Msrc/files.c | 34++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -1724,13 +1724,11 @@ bool write_file(const char *name, FILE *stream, bool tmp, int fd_source; FILE *f_source = NULL; - f = fopen(realname, "rb"); - - if (f == NULL) { - statusline(ALERT, _("Error reading %s: %s"), realname, - strerror(errno)); - goto cleanup_and_exit; - } + if (fopen(realname, "rb") == NULL) { + statusline(ALERT, _("Error reading %s: %s"), realname, + strerror(errno)); + goto cleanup_and_exit; + } tempname = safe_tempfile(&f); @@ -1740,19 +1738,19 @@ bool write_file(const char *name, FILE *stream, bool tmp, goto cleanup_and_exit; } - fd_source = open(realname, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR); + fd_source = open(realname, O_RDONLY | O_CREAT, S_IRUSR | S_IWUSR); - if (fd_source != -1) { - f_source = fdopen(fd_source, "rb"); - if (f_source == NULL) { - statusline(ALERT, _("Error reading %s: %s"), realname, - strerror(errno)); - close(fd_source); - fclose(f); - unlink(tempname); - goto cleanup_and_exit; - } + if (fd_source != -1) { + f_source = fdopen(fd_source, "rb"); + if (f_source == NULL) { + statusline(ALERT, _("Error reading %s: %s"), realname, + strerror(errno)); + close(fd_source); + fclose(f); + unlink(tempname); + goto cleanup_and_exit; } + } if (f_source == NULL || copy_file(f_source, f, TRUE) != 0) { statusline(ALERT, _("Error writing temp file: %s"),