tweaks: rename a variable, reshuffle an assignment, and change a code
parent
b63c90bf6b
commit
dd429d9c00
15
src/files.c
15
src/files.c
|
@ -378,9 +378,8 @@ bool open_buffer(const char *filename, bool new_buffer)
|
||||||
#endif
|
#endif
|
||||||
struct stat fileinfo;
|
struct stat fileinfo;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int rc;
|
int descriptor = 0;
|
||||||
/* rc == -2 means that we have a new file. -1 means that the
|
/* Code 0 means new file, -1 means failure, and else it's the fd. */
|
||||||
* open() failed. 0 means that the open() succeeded. */
|
|
||||||
|
|
||||||
/* Display newlines in filenames as ^J. */
|
/* Display newlines in filenames as ^J. */
|
||||||
as_an_at = FALSE;
|
as_an_at = FALSE;
|
||||||
|
@ -438,15 +437,15 @@ bool open_buffer(const char *filename, bool new_buffer)
|
||||||
|
|
||||||
/* If the filename isn't blank, and we are not in NOREAD_MODE,
|
/* If the filename isn't blank, and we are not in NOREAD_MODE,
|
||||||
* open the file. Otherwise, treat it as a new file. */
|
* open the file. Otherwise, treat it as a new file. */
|
||||||
rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
|
if (filename[0] != '\0' && !ISSET(NOREAD_MODE))
|
||||||
open_file(realname, new_buffer, &f) : -2;
|
descriptor = open_file(realname, new_buffer, &f);
|
||||||
|
|
||||||
/* If we have a non-new file, read it in. Then, if the buffer has
|
/* If we have a non-new file, read it in. Then, if the buffer has
|
||||||
* no stat, update the stat, if applicable. */
|
* no stat, update the stat, if applicable. */
|
||||||
if (rc > 0) {
|
if (descriptor > 0) {
|
||||||
install_handler_for_Ctrl_C();
|
install_handler_for_Ctrl_C();
|
||||||
|
|
||||||
read_file(f, rc, realname, !new_buffer);
|
read_file(f, descriptor, realname, !new_buffer);
|
||||||
|
|
||||||
restore_handler_for_Ctrl_C();
|
restore_handler_for_Ctrl_C();
|
||||||
|
|
||||||
|
@ -458,7 +457,7 @@ bool open_buffer(const char *filename, bool new_buffer)
|
||||||
|
|
||||||
/* If we have a file, and we've loaded it into a new buffer, set
|
/* If we have a file, and we've loaded it into a new buffer, set
|
||||||
* the filename and put the cursor at the start of the buffer. */
|
* the filename and put the cursor at the start of the buffer. */
|
||||||
if (rc != -1 && new_buffer) {
|
if (descriptor >= 0 && new_buffer) {
|
||||||
openfile->filename = mallocstrcpy(openfile->filename, realname);
|
openfile->filename = mallocstrcpy(openfile->filename, realname);
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
openfile->lock_filename = thelocksname;
|
openfile->lock_filename = thelocksname;
|
||||||
|
|
Loading…
Reference in New Issue