+2009-12-09 Chris Allegretta <chrisa@asty.org>
+ * files.c (read_file) - Add parameter for whether we should even try to check
+ file writability, as the message is useless when we're inserting into an
+ existing buffer. Fixes Savannah bug 28219.
+
2009-12-07 David Lawrence Ramsey <pooka109@gmail.com>
* global.c (shortcut_init): Many fixes for keybindings code oversights, including
restore page up/down and GotoDir to browser,
/* If we have a non-new file, read it in. Then, if the buffer has
* no stat, update the stat, if applicable. */
if (rc > 0) {
- read_file(f, rc, filename, undoable);
+ read_file(f, rc, filename, undoable, new_buffer);
#ifndef NANO_TINY
if (openfile->current_stat == NULL) {
openfile->current_stat =
/* If we have a non-new file, read it in. */
if (rc > 0)
- read_file(f, rc, filename, FALSE);
+ read_file(f, rc, filename, FALSE, TRUE);
/* Move back to the beginning of the first line of the buffer. */
openfile->current = openfile->fileage;
/* Read an open file into the current buffer. f should be set to the
* open file, and filename should be set to the name of the file.
* undoable means do we want to create undo records to try and undo this.
- * Will also attempt to check file writability if fd > 0
+ * Will also attempt to check file writability if fd > 0 and checkwritable == TRUE
*/
-void read_file(FILE *f, int fd, const char *filename, bool undoable)
+void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable)
{
size_t num_lines = 0;
/* The number of lines in the file. */
if (ferror(f))
nperror(filename);
fclose(f);
- if (fd > 0) {
+ if (fd > 0 && checkwritable) {
close(fd);
writable = is_file_writable(filename);
}
if (f == NULL)
nperror("fopen");
- read_file(f, 0, "stdin", TRUE);
+ read_file(f, 0, "stdin", TRUE, FALSE);
ttystdin = open("/dev/tty", O_RDONLY);
if (!ttystdin)
die(_("Couldn't reopen stdin from keyboard, sorry\n"));
#endif
filestruct *read_line(char *buf, filestruct *prevnode, bool
*first_line_ins, size_t buf_len);
-void read_file(FILE *f, int fd, const char *filename, bool undoable);
+void read_file(FILE *f, int fd, const char *filename, bool undoable, bool checkwritable);
int open_file(const char *filename, bool newfie, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile(