commit b512e253b6e1a19c64166bdeeddda07b24194446
parent 137c4467ef86fd383b982727fb9b355405f84556
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 24 May 2019 12:42:48 +0200
tweaks: drop an unneeded parameter from open_file()
The 'quiet' parameter is only used when opening a help-text tempfile
or a spell-checked tempfile, and these files necessarily exist, so
'quiet' will never be checked for them. But in the weird case that
the help-text tempfile could not be opened, it is not a problem that
"New File" gets printed to the status bar because nano will crash
shortly afterwards. And when the spell-checked tempfile could not
be opened, a "Not Found" message is appropriate, but nano will crash
in this case too.
Diffstat:
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -464,7 +464,7 @@ bool open_buffer(const char *filename, bool new_buffer)
/* If the filename isn't blank, and we are not in NOREAD_MODE,
* open the file. Otherwise, treat it as a new file. */
rc = (filename[0] != '\0' && !ISSET(NOREAD_MODE)) ?
- open_file(realname, new_buffer, inhelp, &f) : -2;
+ open_file(realname, new_buffer, &f) : -2;
/* If we have a non-new file, read it in. Then, if the buffer has
* no stat, update the stat, if applicable. */
@@ -504,7 +504,7 @@ void replace_buffer(const char *filename, undo_type action, bool marked)
int descriptor;
FILE *f;
- descriptor = open_file(filename, FALSE, TRUE, &f);
+ descriptor = open_file(filename, FALSE, &f);
if (descriptor < 0)
return;
@@ -897,7 +897,7 @@ RETSIGTYPE noop(int signal)
* "New File" if newfie is TRUE, and say "File not found" otherwise.
* Return -2 if we say "New File", -1 if the file isn't opened, and the
* obtained fd otherwise. *f is set to the opened file. */
-int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
+int open_file(const char *filename, bool newfie, FILE **f)
{
struct stat fileinfo, fileinfo2;
struct sigaction oldaction, newaction;
@@ -912,8 +912,7 @@ int open_file(const char *filename, bool newfie, bool quiet, FILE **f)
if (stat(full_filename, &fileinfo) == -1) {
if (newfie) {
- if (!quiet)
- statusbar(_("New File"));
+ statusbar(_("New File"));
free(full_filename);
return -2;
}
diff --git a/src/proto.h b/src/proto.h
@@ -277,7 +277,7 @@ void switch_to_next_buffer(void);
bool close_buffer(void);
#endif
void read_file(FILE *f, int fd, const char *filename, bool undoable);
-int open_file(const char *filename, bool newfie, bool quiet, FILE **f);
+int open_file(const char *filename, bool newfie, FILE **f);
char *get_next_filename(const char *name, const char *suffix);
void do_insertfile_void(void);
char *get_full_path(const char *origpath);