nano

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

commit 3db02389f4bf45863b9c096a9efc477680f94a48
parent cc81436f8193c57fafd5e79896b11964886a563f
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Sun,  5 Jun 2005 19:18:11 +0000

in safe_tempfile(), open a newly created temporary file in "r+b" mode
instead of "w+b" mode, since the latter truncates the file if it already
exists, and we don't need to do that since it's an error if the file
already exists


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2593 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

Diffstat:
Msrc/files.c | 4++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/files.c b/src/files.c @@ -1134,7 +1134,7 @@ char *check_writable_directory(const char *path) /* This function calls mkstemp(($TMPDIR|P_tmpdir|/tmp/)"nano.XXXXXX"). * On success, it returns the malloc()ed filename and corresponding FILE - * stream, opened in "w+b" mode. On error, it returns NULL for the + * stream, opened in "r+b" mode. On error, it returns NULL for the * filename and leaves the FILE stream unchanged. */ char *safe_tempfile(FILE **f) { @@ -1165,7 +1165,7 @@ char *safe_tempfile(FILE **f) filedesc = mkstemp(full_tempdir); if (filedesc != -1) - *f = fdopen(filedesc, "w+b"); + *f = fdopen(filedesc, "r+b"); else { free(full_tempdir); full_tempdir = NULL;