From: Chris Allegretta Date: Wed, 9 Dec 2009 16:51:43 +0000 (+0000) Subject: 2009-12-09 Chris Allegretta X-Git-Tag: v2.2.1~3 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=2c7b506fbc50b2cf12eeab3b9df27a7454612246;p=nano.git 2009-12-09 Chris Allegretta * 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. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4460 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index da71c6fa..721eeb4b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-12-09 Chris Allegretta + * 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 * global.c (shortcut_init): Many fixes for keybindings code oversights, including restore page up/down and GotoDir to browser, diff --git a/src/files.c b/src/files.c index f18ce246..9b29a58e 100644 --- a/src/files.c +++ b/src/files.c @@ -146,7 +146,7 @@ void open_buffer(const char *filename, bool undoable) /* 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 = @@ -196,7 +196,7 @@ void replace_buffer(const char *filename) /* 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; @@ -390,9 +390,9 @@ filestruct *read_line(char *buf, filestruct *prevnode, bool /* 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. */ @@ -514,7 +514,7 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable) if (ferror(f)) nperror(filename); fclose(f); - if (fd > 0) { + if (fd > 0 && checkwritable) { close(fd); writable = is_file_writable(filename); } diff --git a/src/nano.c b/src/nano.c index feaabd6e..8e5d60ce 100644 --- a/src/nano.c +++ b/src/nano.c @@ -1079,7 +1079,7 @@ void finish_stdin_pager(void) 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")); diff --git a/src/proto.h b/src/proto.h index a78bacd8..6ba08459 100644 --- a/src/proto.h +++ b/src/proto.h @@ -271,7 +271,7 @@ bool close_buffer(void); #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( diff --git a/src/text.c b/src/text.c index 56541dd7..1d657d58 100644 --- a/src/text.c +++ b/src/text.c @@ -816,7 +816,7 @@ bool execute_command(const char *command) if (f == NULL) nperror("fdopen"); - read_file(f, 0, "stdin", TRUE); + read_file(f, 0, "stdin", TRUE, FALSE); if (wait(NULL) == -1) nperror("wait");