From 8f37b9ba2b4d87f2c0c644e0cdf7bf4649a8368f Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Tue, 30 Jan 2018 17:29:44 +1300 Subject: [PATCH] HoneyCursor: Handle finding entry < current entry Previously this would overwrite its own argument while running: cursor.find_entry_lt(cursor.current_key) --- xapian-core/backends/honey/honey_cursor.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/xapian-core/backends/honey/honey_cursor.h b/xapian-core/backends/honey/honey_cursor.h index dbc125f95..fd8b86a73 100644 --- a/xapian-core/backends/honey/honey_cursor.h +++ b/xapian-core/backends/honey/honey_cursor.h @@ -458,7 +458,15 @@ class HoneyCursor { std::cerr << "find_entry_lt(" << esc << ") @" << fh.get_pos() << std::endl; } // FIXME: use index - if (is_at_end || key <= current_key) { + int cmp = -1; + if (is_at_end || (cmp = key.compare(current_key)) <= 0) { + if (cmp == 0 && rare(&key == ¤t_key)) { + // Avoid bug with this (which should step back one entry): + // cursor.find_entry_lt(cursor.current_key); + std::string copy = current_key; + find_entry_lt(copy); + return; + } rewind(); } -- 2.11.4.GIT