nano

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

commit 2c7b506fbc50b2cf12eeab3b9df27a7454612246
parent 5b25e0774448ff18476a765fb8407491e711b8b5
Author: Chris Allegretta <chrisa@asty.org>
Date:   Wed,  9 Dec 2009 16:51:43 +0000

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.



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

Diffstat:
MChangeLog | 5+++++
Msrc/files.c | 10+++++-----
Msrc/nano.c | 2+-
Msrc/proto.h | 2+-
Msrc/text.c | 2+-
5 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,8 @@ +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, diff --git 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 @@ -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 @@ -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 @@ -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");