From cb08a2e4c25aeedce0f1ac0df7745a2a773c1d5c Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Mon, 12 Jan 2015 18:12:00 -0500 Subject: [PATCH] fix bug with tab completion -- rl_completion_entry_function has 2 entries (and null terminator) if there's only 1 match. --- bin/debugger.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bin/debugger.cpp b/bin/debugger.cpp index 3549aa5..98e63c8 100644 --- a/bin/debugger.cpp +++ b/bin/debugger.cpp @@ -1158,9 +1158,10 @@ namespace { if (count == 1) { - char **buffer = (char **)malloc(2 * sizeof(char *)); - buffer[0] = strdup(begin->first.c_str()); - buffer[1] = NULL; + char **buffer = (char **)malloc(3 * sizeof(char *)); + buffer[0] = strdup(begin->first.c_str()); // longest substring match + buffer[1] = strdup(begin->first.c_str()); // the match + buffer[2] = NULL; return buffer; } @@ -1212,6 +1213,8 @@ namespace { } // this is here to prevent filename tab completion, for now. + // state is 0 for first call, non-zero for subsequent calls. It + // should return 1 match per invocation, NULL if no more matches. char *mpw_completion_entry_function(const char *text, int state) { return NULL;