From 9a16999f0e1a5a692866ebe4eab8dbfd2457eef5 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 13 Sep 2018 19:06:05 +0200 Subject: [PATCH] Remove GNU Readline rl_complete() prototype, for now We should add a configure option --enable-readline-compat, or sth, so rl_complete2() (removed in this commit) becomes the new rl_complete(), and the current rl_complete() becomes el_complete(). The current implementation of rl_complete2() was is incomplete and also not working properly. To eliminate any confusion on the matter this patch removes it. To restore functionality we should, at the very least, merge with complete() and possibly also refactor rl_find_token() to share code with the legacy el_find_word(). Signed-off-by: Joachim Nilsson --- include/editline.h | 5 ----- src/complete.c | 56 ---------------------------------------------- 2 files changed, 61 deletions(-) diff --git a/include/editline.h b/include/editline.h index cbabbe6..eb1a569 100644 --- a/include/editline.h +++ b/include/editline.h @@ -114,15 +114,10 @@ extern void add_history (const char *line); extern int read_history (const char *filename); extern int write_history (const char *filename); -//extern int rl_complete2 (int ignore, int invoking_key); - extern rl_completion_func_t *rl_attempted_completion_function; extern rl_complete_func_t *rl_set_complete_func (rl_complete_func_t *func); extern rl_list_possib_func_t *rl_set_list_possib_func (rl_list_possib_func_t *func); -// TODO: See comment for src/complete.c:rl_complete2() -//#define rl_complete(a, b) _Generic((a), int: rl_complete2, default: rl_complete)(a, b) - /* Alternate interface to plain readline(), for event loops */ extern void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler); extern void rl_callback_read_char (void); diff --git a/src/complete.c b/src/complete.c index 8540c83..1b05384 100644 --- a/src/complete.c +++ b/src/complete.c @@ -339,62 +339,6 @@ char **rl_completion_matches(const char *token, rl_compentry_func_t *generator) return array; } -// -// TODO: Add configure option --enable-readline-compat, or sth, -// so that rl_complete2() becomes the new rl_complete(), -// and the current rl_complete() becomes el_complete() -// -// Currently rl_complete() to is incomplete (heh ;) and also very -// incorrect. At the very least we should merge with complete() -// and possibly also refacto rl_find_token() to share code with -// the legacy el_find_word(). -// -#if 0 -/* - * Implements the actual FSF readline rl_complete() API - * - * "isolates the word to be completed and calls rl_completion_matches() - * to generate a list of possible completions" - */ -int rl_complete2(int ignore, int invoking_key) -{ - char *token, *word, **words = NULL; - size_t len; - - token = rl_find_token(&len); - if (!token) - return 0; /* Nothing inserted */ - - word = strndup(token, len); - - rl_attempted_completion_over = 0; - if (rl_attempted_completion_function) { - int start = token - rl_line_buffer; - int end = start + len; - - words = rl_attempted_completion_function(word, start, end); - } - - if (!rl_attempted_completion_over && !words) - words = rl_completion_matches(word, NULL); - - if (words && words[0]) { - int i = 1; - - free(word); - word = words[0]; - - while (words[i]) - free(words[i++]); - free(words); - - return word; - } - - return el_filename_complete(word, match); -} -#endif // Disabled atm. - static char *complete(char *token, int *match) { size_t len = 0;