From 461f1cb3d9e32f76550fe5c1376236ff258f65b9 Mon Sep 17 00:00:00 2001 From: Chris Allegretta Date: Thu, 21 Mar 2002 05:00:06 +0000 Subject: [PATCH] - files.c:read_file() - Abort if we read a file of 0 lines (num_lines == 0), fixes BUG #70 git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_1_0_branch/nano@1135 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- BUGS | 2 +- ChangeLog | 8 +++++--- files.c | 10 +++++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/BUGS b/BUGS index 26ac5c08..cc188c68 100644 --- a/BUGS +++ b/BUGS @@ -134,7 +134,7 @@ Trevor Cordes) (68) [FIXED]. - Home and End control keys (^A, ^E) do not always work in filename prompt (bug found by Ian Turner) (69) [FIXED]. - +- Trying to insert a file of 0 bytes will hang nano (70) [FIXED]. ** Open BUGS ** $Id$ diff --git a/ChangeLog b/ChangeLog index 10f05b04..5861eca3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,17 +1,19 @@ CVS code - +- files.c: + read_file() + - Abort if we read a file of 0 lines (num_lines == 0), fixes BUG #70. - winio.c: nanogetstr() - Add NANO_HOME_KEY and NANO_END_KEY to the home and end key code (fixes BUG #69). bottombars(), onekey() - Make bottom list dynamic with screen size (Guus Sliepen & Chris). + do_credits() + - Add Thomas Dickey. - utils.c: strcasestr() - Renamed to stristr since strcasestr has not been confirmed to be detected properly on various Linux systems. -- winio.c: - do_credits() - - Add Thomas Dickey. - THANKS: - Added missing entry for Eivind Kjørstad. - po/no.po: diff --git a/files.c b/files.c index 7c3b437d..7b156f54 100644 --- a/files.c +++ b/files.c @@ -180,7 +180,15 @@ int read_file(int fd, char *filename) num_lines++; buf[0] = 0; } - /* Did we even GET a file? */ + + /* Did we try to insert a file of 0 bytes? */ + if (num_lines == 0) + { + statusbar(_("Read %d lines"), 0); + return 1; + } + + /* Did we even GET a file if we don't already have one? */ if (totsize == 0 || fileptr == NULL) { new_file(); statusbar(_("Read %d lines"), num_lines); -- 2.39.5