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
Этот коммит содержится в:
родитель
5b25e07744
Коммит
2c7b506fbc
@ -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,
|
||||
|
10
src/files.c
10
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);
|
||||
}
|
||||
|
@ -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"));
|
||||
|
@ -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(
|
||||
|
@ -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");
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user