Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(FL) Fix readline crash when using autocomplete with colored-completion-prefix turned on in Bash #2991

Merged
merged 2 commits into from
Nov 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/cmdledit.g
Original file line number Diff line number Diff line change
Expand Up @@ -967,8 +967,9 @@ GAPInfo.CommandLineEditFunctions.Functions.Completion := function(l)
if (not IsBound(cf.tabcompnam) and cf.tabcount = 2) or
(IsBound(cf.tabcompnam) and cf.tabcount in [2,4]) then
if Length(cand) > 0 then
# we prepend the partial word which was completed
return GAPInfo.CommandLineEditFunctions.Functions.DisplayMatches(
Set(cand));
Concatenation([word], Set(cand)));
else
# ring the bell
return GAPInfo.CommandLineEditFunctions.Functions.RingBell();
Expand Down
12 changes: 7 additions & 5 deletions src/sysfiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -2117,15 +2117,17 @@ int GAP_rl_func(int count, int key)
if (hook == 1) {
/* display matches */
if (!IS_LIST(data)) return 0;
dlen = LEN_LIST(data);
char **strs = (char**)malloc((dlen+1) * sizeof(char*));
/* -1, because first is word to be completed */
dlen = LEN_LIST(data)-1;
/* +2, must be in 'argv' format, terminated by 0 */
char **strs = (char**)calloc(dlen+2, sizeof(char*));
max = 0;
for (i=1; i <= dlen; i++) {
if (!IsStringConv(ELM_LIST(data, i))) {
for (i=0; i <= dlen; i++) {
if (!IsStringConv(ELM_LIST(data, i+1))) {
free(strs);
return 0;
}
strs[i] = CSTR_STRING(ELM_LIST(data, i));
strs[i] = CSTR_STRING(ELM_LIST(data, i+1));
if (max < strlen(strs[i])) max = strlen(strs[i]);
}
rl_display_match_list(strs, dlen, max);
Expand Down
1 change: 1 addition & 0 deletions src/system.c
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,7 @@ void InitSystem (
InitSysFiles();

#ifdef HAVE_LIBREADLINE
rl_readline_name = "GAP";
rl_initialize ();
#endif

Expand Down