NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lib/57376: libedit tab completion escapes spaces



The following reply was made to PR lib/57376; it has been noted by GNATS.

From: RVP <rvp%SDF.ORG@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: lib/57376: libedit tab completion escapes spaces
Date: Mon, 24 Apr 2023 13:59:27 +0000 (UTC)

 On Mon, 24 Apr 2023, jorge.giner%hotmail.com@localhost wrote:
 
 > The problem is:
 >
 > I install a rl_completion_entry_function. When libedit calls that function when the user presses TAB to autocoplete the editing line, I return a string for the completion, but somehow libedit is not respecting the string I pass, but escapes spaces and quotes (I think it is supposing that it is a filename, but it shoulnd't).
 >
 
 I'm not a readline expert, but, setting a custom
 `rl_attempted_completion_function` like this works:
 
 ```
 diff -urN bas55-1.19.orig/src/getlin.c bas55-1.19/src/getlin.c
 --- bas55-1.19.orig/src/getlin.c	2018-02-22 21:44:11.000000000 +0000
 +++ bas55-1.19/src/getlin.c	2023-04-24 13:51:44.596005000 +0000
 @@ -25,6 +25,7 @@
   extern char *rl_line_buffer;
   extern int rl_point;
   extern int rl_end;
 +extern char **(*rl_attempted_completion_function)(const char *, int, int);
   extern char *(*rl_completion_entry_function)(const char *, int);
   extern char *rl_filename_completion_function(const char *, int);
   extern void add_history(const char *);
 @@ -334,9 +335,18 @@
   	s_question_mode = set;
   }
 
 +static char** complete_basic_line_wrapper(char* text, int start, int end)
 +{
 +	char** pp = malloc(2 * sizeof (char* ));
 +	pp[0] = complete_basic_line(text);
 +	pp[1] = NULL;
 +	return pp;
 +}
 +
   void get_line_init(void)
   {
   	// using_history();
 +	rl_attempted_completion_function = complete_basic_line_wrapper;
   	get_line_set_question_mode(0);
   }
 
 ```
 
 HTH,
 
 -RVP
 


Home | Main Index | Thread Index | Old Index