- 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:
/* 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
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;
}
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);