summaryrefslogtreecommitdiffstats
path: root/src/buffer.c
diff options
context:
space:
mode:
authorTimo Savinen <tjsa@iki.fi>2006-10-29 10:10:55 +0000
committerHadrien Dorio <hadrien.dorio@gmail.com>2017-12-16 00:24:06 +0100
commit37db3f05301f54804d7b86b3aa9edaaf0e3e7d23 (patch)
treef9a35dae1a84968325ae8b7faaa53c7ffe669b97 /src/buffer.c
parent8fefc256fbd2aa171423c4b0493e88c2e2390eb6 (diff)
downloadbinary-block-editor-37db3f05301f54804d7b86b3aa9edaaf0e3e7d23.tar.gz
binary-block-editor-37db3f05301f54804d7b86b3aa9edaaf0e3e7d23.zip
0.2.1
Diffstat (limited to 'src/buffer.c')
-rw-r--r--src/buffer.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 3359144..99d0ee6 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -20,7 +20,7 @@
*
*/
-/* $Id: buffer.c,v 1.35 2005/11/14 10:40:47 timo Exp $ */
+/* $Id: buffer.c,v 1.36 2006-10-24 16:50:54 timo Exp $ */
#include "bbe.h"
#include <stdlib.h>
@@ -185,7 +185,7 @@ read_input_stream()
read_count += last_read;
} while (in_stream != NULL && read_count < to_be_read);
- if (read_count < to_be_read) in_buffer.stream_end = buffer_write_pos + read_count - (read_count ? 1 : 0);
+ if (read_count < to_be_read) in_buffer.stream_end = buffer_write_pos + read_count - 1;
return read_count;
}
@@ -217,10 +217,11 @@ block_end_pos()
inline int
get_next_byte()
{
- if(in_buffer.read_pos >= in_buffer.low_pos)
+ if(in_buffer.read_pos >= in_buffer.low_pos)
{
- if(read_input_stream() && in_buffer.block_end == NULL) mark_block_end();
- }
+ read_input_stream();
+ if(in_buffer.block_end == NULL) mark_block_end();
+ }
if(in_buffer.stream_end != NULL)
{
@@ -365,11 +366,18 @@ find_block()
found = 0;
if(end_of_stream() && last_byte()) return 0;
+
+ if(in_buffer.read_pos == NULL) // first read
+ {
+ if(!read_input_stream()) return 0; // zero size input
+ }
+
in_buffer.block_offset = 0;
+
do
{
- if(in_buffer.read_pos >= in_buffer.low_pos || in_buffer.read_pos == NULL) read_input_stream();
+ if(in_buffer.read_pos >= in_buffer.low_pos) read_input_stream();
if(last_byte()) in_buffer.read_pos++;
in_buffer.block_end = NULL;
OpenPOWER on IntegriCloud