Subject: lib/29958: editline's readline wrapper misses a rl_variable_bind function and an
To: None <lib-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: None <Peter.Bex@student.kun.nl>
List: netbsd-bugs
Date: 04/12/2005 21:38:00
>Number:         29958
>Category:       lib
>Synopsis:       native readline misses rl_variable_bind and rl_attempted_completion_over
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Apr 12 21:38:00 +0000 2005
>Originator:     Peter Bex
>Release:        NetBSD 2.0
>Organization:
>Environment:
	
	
System: NetBSD frohike.nvie.com 2.0 NetBSD 2.0 (FROHIKE) #0: Wed Dec 22 10:00:59 CET 2004 sjamaan@frohike.nvie.com:/usr/src/sys/arch/i386/compile/FROHIKE i386
Architecture: i386
Machine: i386
>Description:
	The readline wrapper for editline should export the
	rl_attempted_completion_over variable and use it in the same way
	readline uses it (that is, do not call editline's own completion
	function if the variable is nonzero, even if the custom function
	does not provide any completions).

	Also, the rl_variable_bind is rather trivial to implement IMHO and
	it isn't there.
>How-To-Repeat:
	N/A
>Fix:

Patches:

Index: readline/readline.h
===================================================================
RCS file: /cvsroot/src/lib/libedit/readline/readline.h,v
retrieving revision 1.12
diff -u -r1.12 readline.h
--- readline/readline.h	8 Sep 2004 18:15:37 -0000	1.12
+++ readline/readline.h	12 Apr 2005 20:20:13 -0000
@@ -102,6 +102,7 @@
 extern char		*rl_completer_quote_characters;
 extern Function		*rl_completion_entry_function;
 extern CPPFunction	*rl_attempted_completion_function;
+extern int		 rl_attempted_completion_over;
 extern int		rl_completion_type;
 extern int		rl_completion_query_items;
 extern char		*rl_special_prefixes;
@@ -174,6 +175,7 @@
 void		 rl_deprep_terminal(void);
 int		 rl_read_init_file(const char *);
 int		 rl_parse_and_bind(const char *);
+int		 rl_variable_bind(const char *, const char *);
 void		 rl_stuff_char(int);
 int		 rl_add_defun(const char *, Function *, int);
 

Index: readline.c
===================================================================
RCS file: /cvsroot/src/lib/libedit/readline.c,v
retrieving revision 1.50
diff -u -r1.50 readline.c
--- readline.c	2 Apr 2005 06:28:10 -0000	1.50
+++ readline.c	12 Apr 2005 20:20:05 -0000
@@ -1762,9 +1762,13 @@
 		    (end - len), end);
 	} else
 		matches = 0;
-	if (!rl_attempted_completion_function || !matches)
+	if (!rl_attempted_completion_function ||
+	     (!rl_attempted_completion_over && !matches))
 		matches = completion_matches(temp, (CPFunction *)complet_func);
 
+	if (rl_attempted_completion_over)
+		rl_attempted_completion_over = 0;
+
 	if (matches) {
 		int i, retval = CC_REFRESH;
 		int matches_num, maxlen, match_len, match_display=1;
@@ -2096,6 +2100,16 @@
 	return (argc ? 1 : 0);
 }
 
+int
+rl_variable_bind(const char *var, const char *value)
+{
+	/*
+	 * The proper return value is undocument, but this is what the
+	 * readline source seems to do.
+	 */
+	return ((el_set(e, EL_BIND, "", var, value) == -1) ? 1 : 0);
+}
+
 void
 rl_stuff_char(int c)
 {

>Unformatted: