From 6b874e13aa1a6e7d97eb1678147e8965bccf3332 Mon Sep 17 00:00:00 2001 From: Roland Illig Date: Sat, 6 Aug 2005 18:19:14 +0000 Subject: [PATCH] * view.c (view_growbuf_read_until): On short reads, try to read one more byte to check whether we're already at the end of file. This makes the ">=" disappear earlier. --- src/ChangeLog | 3 +++ src/view.c | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 0fdc7a5d2..771e4b1e5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -2,6 +2,9 @@ * textconf.c: Include ecs_char in the list of type characteristics that are printed. + * view.c (view_growbuf_read_until): On short reads, try to read + one more byte to check whether we're already at the end of file. + This makes the ">=" disappear earlier. 2005-08-05 Pavel Tsekov diff --git a/src/view.c b/src/view.c index 29168f778..ea5590e35 100644 --- a/src/view.c +++ b/src/view.c @@ -376,13 +376,15 @@ view_growbuf_read_until (WView *view, offset_type ofs) ssize_t nread; byte *p; size_t bytesfree; + gboolean short_read; assert (view->growbuf_in_use); if (view->growbuf_finished) return; - while (view_growbuf_filesize (view) < ofs) { + short_read = FALSE; + while (view_growbuf_filesize (view) < ofs || short_read) { if (view->growbuf_blocks == 0 || view->growbuf_lastindex == VIEW_PAGE_SIZE) { /* Append a new block to the growing buffer */ byte *newblock = g_try_malloc (VIEW_PAGE_SIZE); @@ -421,6 +423,7 @@ view_growbuf_read_until (WView *view, offset_type ofs) return; } } + short_read = (nread < bytesfree); view->growbuf_lastindex += nread; } }