From bd7c2ecf075c567443aeb3f5e010566403652444 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sat, 28 Feb 2004 10:43:20 +0000 Subject: fixed invinite loop, patch from Mathias Gumz --- util/fbrun/FbRun.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc index 47e35bf..e32e101 100644 --- a/util/fbrun/FbRun.cc +++ b/util/fbrun/FbRun.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: FbRun.cc,v 1.24 2004/02/25 18:37:47 fluxgen Exp $ +// $Id: FbRun.cc,v 1.25 2004/02/28 10:43:20 fluxgen Exp $ #include "FbRun.hh" @@ -314,14 +314,15 @@ void FbRun::lastHistoryItem() { } void FbRun::tabCompleteHistory() { - if (m_current_history_item == 0) { + if (m_current_history_item == 0 || m_history.empty() ) { XBell(m_display, 0); } else { + unsigned int nr= 0; int history_item = m_current_history_item - 1; string prefix = text().substr(0, cursorPosition()); - while (history_item != m_current_history_item ) { - if (history_item == -1 ) - history_item+= m_history.size(); + while (history_item != m_current_history_item && nr++ < m_history.size()) { + if (history_item <= -1 ) + history_item= m_history.size() - 1; if (m_history[history_item].find(prefix) == 0) { m_current_history_item = history_item; setText(m_history[m_current_history_item]); -- cgit v0.11.2