Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ddd87d5

Browse files
committed
Add an ugly workaround for a bug in some recent libedit versions.
Debian unstable is shipping a broken version of libedit: it de-escapes words before passing them to the application's tab completion function, preventing us from recognizing backslash commands. Fortunately, we have enough information available to dig the original text out of rl_line_buffer, so ignore the string argument and do that. I view this as a temporary workaround to get the affected buildfarm members back to green in the wake of 7c01504. I hope we can get rid of it once somebody fixes Debian's libedit; hence, no back-patch, at least for now. Discussion: https://postgr.es/m/20200103110128.GA28967@msg.df7cb.de
1 parent 04334fd commit ddd87d5

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/bin/psql/tab-complete.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1447,7 +1447,13 @@ psql_completion(const char *text, int start, int end)
14471447
NULL
14481448
};
14491449

1450-
(void) end; /* "end" is not used */
1450+
/*
1451+
* Temporary workaround for a bug in recent (2019) libedit: it incorrectly
1452+
* de-escapes the input "text", causing us to fail to recognize backslash
1453+
* commands. So get the string to look at from rl_line_buffer instead.
1454+
*/
1455+
char *text_copy = pnstrdup(rl_line_buffer + start, end - start);
1456+
text = text_copy;
14511457

14521458
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
14531459
rl_completion_append_character = ' ';
@@ -3859,6 +3865,7 @@ psql_completion(const char *text, int start, int end)
38593865
/* free storage */
38603866
free(previous_words);
38613867
free(words_buffer);
3868+
free(text_copy);
38623869

38633870
/* Return our Grand List O' Matches */
38643871
return matches;

0 commit comments

Comments
 (0)