From: David Lawrence Ramsey Date: Fri, 8 Jul 2005 21:12:39 +0000 (+0000) Subject: still more breakage fixes X-Git-Tag: v1.3.9~209 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=76c25f582a04ec1321e7999b2a3fd81c43960590;p=nano.git still more breakage fixes git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2837 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index f9be1ce9..779e7427 100644 --- a/ChangeLog +++ b/ChangeLog @@ -20,6 +20,11 @@ CVS code - switch_to_prev_buffer(), rename open_nextfile_void() switch_to_next_buffer(), remove load_file(), and remove load_open_file(). (DLR) +- files.c: + open_file() + - Assert that filename isn't NULL, and don't do anything special + if it's blank, as the the former case shouldn't occur, and the + latter case is now handled elsewhere. (DLR) - global.c: shortcut_init() - Simplify wording of nano_gotoline_msg. (Jordi) diff --git a/src/files.c b/src/files.c index 2d07ea3d..7fe590a0 100644 --- a/src/files.c +++ b/src/files.c @@ -157,6 +157,8 @@ void open_buffer(const char *filename) /* rc == -2 means that we have a new file. -1 means that the * open() failed. 0 means that the open() succeeded. */ + assert(filename != NULL); + #ifndef DISABLE_OPERATINGDIR if (check_operating_dir(filename, FALSE)) { statusbar(_("Can't insert file from outside of %s"), @@ -165,8 +167,9 @@ void open_buffer(const char *filename) } #endif - /* Open the file. */ - rc = open_file(filename, new_buffer, &f); + /* If the filename isn't blank, open the file. */ + if (filename[0] != '\0') + rc = open_file(filename, new_buffer, &f); /* If we're loading into a new buffer, add a new openfile entry. */ if (new_buffer) @@ -534,10 +537,9 @@ int open_file(const char *filename, bool newfie, FILE **f) int fd; struct stat fileinfo; - assert(f != NULL); + assert(filename != NULL && f != NULL); - if (filename == NULL || filename[0] == '\0' || - stat(filename, &fileinfo) == -1) { + if (stat(filename, &fileinfo) == -1) { if (newfie) { statusbar(_("New File")); return -2;