Forgetting the case of an empty filename for replace_buffer(),

and not bothering to put the pointer at the top.


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5269 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Benno Schulenberg 2015-06-27 15:03:45 +00:00
parent f0bb50306c
commit ecffb85656
2 changed files with 13 additions and 18 deletions

View File

@ -2,6 +2,10 @@
* src/text.c (do_undo, add_undo): Skip undoing a backspace *only* when * src/text.c (do_undo, add_undo): Skip undoing a backspace *only* when
it really tried to delete the final, magic newline. it really tried to delete the final, magic newline.
* src/nano.h, src/text.c: Rename three flags for clarity. * src/nano.h, src/text.c: Rename three flags for clarity.
* src/files.c (replace_buffer): This function is only ever called with
a temporary file as parameter, so forget the case of an empty filename.
Also, don't bother putting the pointer at the top of the buffer, as the
first action after this function is to restore the cursor position.
2015-06-23 Benno Schulenberg <bensberg@justemail.net> 2015-06-23 Benno Schulenberg <bensberg@justemail.net>
* src/winio.c (edit_draw): Verify that there exists multidata for the * src/winio.c (edit_draw): Verify that there exists multidata for the

View File

@ -405,35 +405,26 @@ void open_buffer(const char *filename, bool undoable)
} }
#ifndef DISABLE_SPELLER #ifndef DISABLE_SPELLER
/* If it's not "", filename is a file to open. We blow away the text of /* Blow away the text of the current buffer, and then open and read
* the current buffer, and then open and read the file, if * the specified file into its place. */
* applicable. Note that we skip the operating directory test when
* doing this. */
void replace_buffer(const char *filename) void replace_buffer(const char *filename)
{ {
FILE *f; FILE *f;
int rc; int descriptor;
/* rc == -2 means that we have a new file. -1 means that the
* open() failed. 0 means that the open() succeeded. */
assert(filename != NULL); assert(filename != NULL && filename[0] != '\0');
/* If the filename isn't blank, open the file. Otherwise, treat it /* Open the file quietly. */
* as a new file. */ descriptor = open_file(filename, TRUE, FALSE, &f);
rc = (filename[0] != '\0') ? open_file(filename, TRUE, FALSE, &f) : -2;
/* Reinitialize the text of the current buffer. */ /* Reinitialize the text of the current buffer. */
free_filestruct(openfile->fileage); free_filestruct(openfile->fileage);
initialize_buffer_text(); initialize_buffer_text();
/* If we have a non-new file, read it in. */ /* If opening the file succeeded, read it in. */
if (rc > 0) if (descriptor > 0)
read_file(f, rc, filename, FALSE, TRUE); read_file(f, descriptor, filename, FALSE, TRUE);
/* Move back to the beginning of the first line of the buffer. */
openfile->current = openfile->fileage;
openfile->current_x = 0;
openfile->placewewant = 0;
} }
#endif /* !DISABLE_SPELLER */ #endif /* !DISABLE_SPELLER */