From 5a74150c78737daf2764570835b59b45141f3775 Mon Sep 17 00:00:00 2001 From: Mike Fiore Date: Mon, 7 Dec 2015 15:53:41 -0600 Subject: fix bug where Mode could parse incorrect sweep index --- Mode/Mode.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Mode/Mode.cpp b/Mode/Mode.cpp index f6223d8..70a3f49 100644 --- a/Mode/Mode.cpp +++ b/Mode/Mode.cpp @@ -193,10 +193,12 @@ uint32_t Mode::getIndex(DataType type) { return 0; } logInfo("read %d bytes [%s]", ret, buf); + bytes_read = file.size - read_offset - 1; + logInfo("read %d total bytes", bytes_read); // read_size - 1 is the last byte in the buffer for (current = read_size - 1; current >= 0; current--) { - if ((buf[current] == '\n' && current != read_size - 1) || current == 0) { + if ((buf[current] == '\n' && current != read_size - 1) || (current == 0 && bytes_read >= file.size)) { int test = current; logInfo("found potential %d, %c", read_offset + current, buf[test + 1]); if (buf[test + 1] == search) { -- cgit v1.2.3