mirror of
git://git.sv.gnu.org/nano.git
synced 2024-12-25 20:06:52 +03:00
Prepend fixes for O_CREAT & append compatibililty by David Benbennick
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1191 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
This commit is contained in:
parent
0417a7b7f2
commit
2542274250
@ -11,6 +11,7 @@ CVS code -
|
||||
- Preliminary prepend code. This may be a bad idea, but I've
|
||||
been wanting it for awhile now and we'll see how bad it messes
|
||||
everything up. Changes to files.c:do_writeout(), write_file().
|
||||
Fixes for O_CREAT & append compatibililty by David Benbennick.
|
||||
- configure.ac:
|
||||
- Define NDEBUG to silence asserts (David Benbennick).
|
||||
- files.c:
|
||||
|
13
files.c
13
files.c
@ -1243,7 +1243,7 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
||||
/* Use O_EXCL if tmp == 1. This is now copied from joe, because
|
||||
wiggy says so *shrug*. */
|
||||
if (append)
|
||||
fd = open(realname, O_WRONLY | O_APPEND, (S_IRUSR|S_IWUSR));
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_APPEND, (S_IRUSR|S_IWUSR));
|
||||
else if (tmp)
|
||||
fd = open(realname, O_WRONLY | O_CREAT | O_EXCL, (S_IRUSR|S_IWUSR));
|
||||
else
|
||||
@ -1350,8 +1350,9 @@ int write_file(char *name, int tmp, int append, int nonamechange)
|
||||
statusbar(_("Could not reopen %s: %s"), buf, strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
if ((fd2 = open(realname, O_RDONLY)) == -1) {
|
||||
statusbar(_("Could open %s for prepend: %s"), realname, strerror(errno));
|
||||
if ((fd2 = open(realname, O_RDONLY | O_CREAT)) == -1) {
|
||||
statusbar(_("Could not open %s for prepend: %s"), realname,
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -1510,11 +1511,9 @@ int do_writeout(char *path, int exiting, int append)
|
||||
TOGGLE(MAC_FILE);
|
||||
return(do_writeout(answer, exiting, append));
|
||||
} else if (i == NANO_PREPEND_KEY)
|
||||
return(do_writeout(answer, exiting, 2));
|
||||
else if (i == NANO_APPEND_KEY && append != 1)
|
||||
return(do_writeout(answer, exiting, 1));
|
||||
return(do_writeout(answer, exiting, append==2 ? 0 : 2));
|
||||
else if (i == NANO_APPEND_KEY)
|
||||
return(do_writeout(answer, exiting, 0));
|
||||
return(do_writeout(answer, exiting, append==1 ? 0 : 1));
|
||||
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, _("filename is %s"), answer);
|
||||
|
Loading…
Reference in New Issue
Block a user