aboutsummaryrefslogtreecommitdiffstats
path: root/lib/readline
diff options
context:
space:
mode:
Diffstat (limited to 'lib/readline')
-rw-r--r--lib/readline/Makefile.in61
-rw-r--r--lib/readline/STANDALONE34
-rw-r--r--lib/readline/bind.c62
-rw-r--r--lib/readline/callback.c2
-rw-r--r--lib/readline/complete.c219
-rw-r--r--lib/readline/display.c118
-rw-r--r--lib/readline/doc/Makefile113
-rw-r--r--lib/readline/doc/hist.texinfo19
-rw-r--r--lib/readline/doc/manvers.texinfo6
-rw-r--r--lib/readline/doc/rlman.texinfo19
-rw-r--r--lib/readline/doc/rltech.texinfo163
-rw-r--r--lib/readline/doc/rluser.texinfo50
-rw-r--r--lib/readline/examples/rl.c7
-rw-r--r--lib/readline/funmap.c2
-rw-r--r--lib/readline/histexpand.c22
-rw-r--r--lib/readline/histfile.c12
-rw-r--r--lib/readline/histlib.h1
-rw-r--r--lib/readline/history.c2
-rw-r--r--lib/readline/history.h91
-rw-r--r--lib/readline/input.c66
-rw-r--r--lib/readline/isearch.c32
-rw-r--r--lib/readline/keymaps.c2
-rw-r--r--lib/readline/keymaps.h21
-rw-r--r--lib/readline/kill.c13
-rw-r--r--lib/readline/parens.c2
-rw-r--r--lib/readline/posixjmp.h10
-rw-r--r--lib/readline/readline.c85
-rw-r--r--lib/readline/readline.h471
-rw-r--r--lib/readline/rlconf.h4
-rw-r--r--lib/readline/rlstdc.h79
-rw-r--r--lib/readline/rltty.c11
-rw-r--r--lib/readline/savestring.c33
-rw-r--r--lib/readline/search.c5
-rw-r--r--lib/readline/shell.c43
-rw-r--r--lib/readline/signals.c247
-rw-r--r--lib/readline/terminal.c10
-rw-r--r--lib/readline/tilde.c42
-rw-r--r--lib/readline/util.c3
-rw-r--r--lib/readline/vi_mode.c40
39 files changed, 1513 insertions, 709 deletions
diff --git a/lib/readline/Makefile.in b/lib/readline/Makefile.in
index 31eddd6..c0439ae 100644
--- a/lib/readline/Makefile.in
+++ b/lib/readline/Makefile.in
@@ -16,11 +16,12 @@ INSTALL_DATA = @INSTALL_DATA@
CC = @CC@
RANLIB = @RANLIB@
AR = @AR@
+ARFLAGS = @ARFLAGS@
RM = rm -f
CP = cp
MV = mv
-SHELL = /bin/sh
+SHELL = @MAKE_SHELL@
# Programs to make tags files.
ETAGS = etags -tw
@@ -39,6 +40,7 @@ INCLUDES = -I. -I$(BUILD_DIR) -I$(topdir) -I$(topdir)/lib
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(APP_CFLAGS) $(CPPFLAGS) ${INCLUDES} $(LOCAL_CFLAGS) $(CFLAGS)
.c.o:
+ ${RM} $@
$(CC) -c $(CCFLAGS) $<
# The name of the main library target.
@@ -54,14 +56,14 @@ CSOURCES = $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c \
$(srcdir)/callback.c $(srcdir)/terminal.c $(srcdir)/xmalloc.c \
$(srcdir)/history.c $(srcdir)/histsearch.c $(srcdir)/histexpand.c \
$(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \
- $(srcdir)/shell.c $(srcdir)/tilde.c
+ $(srcdir)/shell.c $(srcdir)/tilde.c $(srcdir)/savestring.c
# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
posixstat.h posixdir.h posixjmp.h tilde.h rlconf.h rltty.h \
- ansi_stdlib.h tcap.h
+ ansi_stdlib.h rlstdc.h tcap.h
-HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o
+HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o savestring.o
TILDEOBJ = tilde.o
OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \
rltty.o complete.o bind.o isearch.o display.o signals.o \
@@ -88,12 +90,12 @@ all: libreadline.a libhistory.a
libreadline.a: $(OBJECTS)
$(RM) $@
- $(AR) cr $@ $(OBJECTS)
+ $(AR) $(ARFLAGS) $@ $(OBJECTS)
-test -n "$(RANLIB)" && $(RANLIB) $@
libhistory.a: $(HISTOBJ) xmalloc.o
$(RM) $@
- $(AR) cr $@ $(HISTOBJ) xmalloc.o
+ $(AR) $(ARFLAGS) $@ $(HISTOBJ) xmalloc.o
-test -n "$(RANLIB)" && $(RANLIB) $@
documentation: force
@@ -130,87 +132,87 @@ distclean maintainer-clean: clean
bind.o: ansi_stdlib.h posixstat.h
bind.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
bind.o: readline.h keymaps.h chardefs.h tilde.h
-bind.o: history.h
+bind.o: history.h rlstdc.h
callback.o: rlconf.h
callback.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
-callback.o: readline.h keymaps.h chardefs.h tilde.h
+callback.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
complete.o: ansi_stdlib.h posixdir.h posixstat.h
complete.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
-complete.o: readline.h keymaps.h chardefs.h tilde.h
+complete.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
display.o: ansi_stdlib.h posixstat.h
display.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
display.o: tcap.h
display.o: readline.h keymaps.h chardefs.h tilde.h
-display.o: history.h
+display.o: history.h rlstdc.h
funmap.o: readline.h keymaps.h chardefs.h tilde.h
-funmap.o: rlconf.h ansi_stdlib.h
+funmap.o: rlconf.h ansi_stdlib.h rlstdc.h
funmap.o: ${BUILD_DIR}/config.h
histexpand.o: ansi_stdlib.h
-histexpand.o: history.h histlib.h
+histexpand.o: history.h histlib.h rlstdc.h
histexpand.o: ${BUILD_DIR}/config.h
histfile.o: ansi_stdlib.h
-histfile.o: history.h histlib.h
+histfile.o: history.h histlib.h rlstdc.h
histfile.o: ${BUILD_DIR}/config.h
history.o: ansi_stdlib.h
-history.o: history.h histlib.h
+history.o: history.h histlib.h rlstdc.h
history.o: ${BUILD_DIR}/config.h
histsearch.o: ansi_stdlib.h
-histsearch.o: history.h histlib.h
+histsearch.o: history.h histlib.h rlstdc.h
histsearch.o: ${BUILD_DIR}/config.h
input.o: ansi_stdlib.h
input.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
-input.o: readline.h keymaps.h chardefs.h tilde.h
+input.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
isearch.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
isearch.o: readline.h keymaps.h chardefs.h tilde.h
-isearch.o: ansi_stdlib.h history.h
+isearch.o: ansi_stdlib.h history.h rlstdc.h
keymaps.o: emacs_keymap.c vi_keymap.c
keymaps.o: keymaps.h chardefs.h rlconf.h ansi_stdlib.h
keymaps.o: readline.h keymaps.h chardefs.h tilde.h
-keymaps.o: ${BUILD_DIR}/config.h
+keymaps.o: ${BUILD_DIR}/config.h rlstdc.h
kill.o: ansi_stdlib.h
kill.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
kill.o: readline.h keymaps.h chardefs.h tilde.h
-kill.o: history.h
+kill.o: history.h rlstdc.h
macro.o: ansi_stdlib.h
macro.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
macro.o: readline.h keymaps.h chardefs.h tilde.h
-macro.o: history.h
+macro.o: history.h rlstdc.h
nls.o: ansi_stdlib.h
nls.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
parens.o: rlconf.h
parens.o: ${BUILD_DIR}/config.h
-parens.o: readline.h keymaps.h chardefs.h tilde.h
+parens.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
readline.o: readline.h keymaps.h chardefs.h tilde.h
readline.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
-readline.o: history.h
+readline.o: history.h rlstdc.h
readline.o: posixstat.h ansi_stdlib.h posixjmp.h
rltty.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
rltty.o: rltty.h
-rltty.o: readline.h keymaps.h chardefs.h tilde.h
+rltty.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
search.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
search.o: readline.h keymaps.h chardefs.h tilde.h
-search.o: ansi_stdlib.h history.h
+search.o: ansi_stdlib.h history.h rlstdc.h
shell.o: ${BUILD_DIR}/config.h ansi_stdlib.h
signals.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
signals.o: readline.h keymaps.h chardefs.h tilde.h
-signals.o: history.h
+signals.o: history.h rlstdc.h
terminal.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
terminal.o: tcap.h
terminal.o: readline.h keymaps.h chardefs.h tilde.h
-terminal.o: history.h
+terminal.o: history.h rlstdc.h
tilde.o: ansi_stdlib.h
tilde.o: ${BUILD_DIR}/config.h
tilde.o: tilde.h
undo.o: ansi_stdlib.h
undo.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
undo.o: readline.h keymaps.h chardefs.h tilde.h
-undo.o: history.h
+undo.o: history.h rlstdc.h
util.o: posixjmp.h ansi_stdlib.h
util.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
-util.o: readline.h keymaps.h chardefs.h tilde.h
+util.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
vi_mode.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
vi_mode.o: readline.h keymaps.h chardefs.h tilde.h
-vi_mode.o: history.h ansi_stdlib.h
+vi_mode.o: history.h ansi_stdlib.h rlstdc.h
xmalloc.o: ${BUILD_DIR}/config.h
xmalloc.o: ansi_stdlib.h
@@ -233,6 +235,7 @@ nls.o: nls.c
parens.o: parens.c
readline.o: readline.c
rltty.o: rltty.c
+savestring.o: savestring.c
search.o: search.c
shell.o: shell.c
signals.o: signals.c
diff --git a/lib/readline/STANDALONE b/lib/readline/STANDALONE
index f999e8d..c6b5cbd 100644
--- a/lib/readline/STANDALONE
+++ b/lib/readline/STANDALONE
@@ -1,32 +1,2 @@
-This is a description of C preprocessor defines that readline accepts.
-Most are passed in from the parent `make'; e.g. from the bash source
-directory.
-
-NO_SYS_FILE <sys/file.h> is not present
-HAVE_UNISTD_H <unistd.h> exists
-HAVE_STDLIB_H <stdlib.h> exists
-HAVE_VARARGS_H <varargs.h> exists and is usable
-HAVE_STRING_H <string.h> exists
-HAVE_ALLOCA_H <alloca.h> exists and is needed for alloca()
-HAVE_ALLOCA alloca(3) or a define for it exists
-PRAGMA_ALLOCA use of alloca() requires a #pragma, as in AIX 3.x
-VOID_SIGHANDLER signal handlers are void functions
-HAVE_DIRENT_H <dirent.h> exists and is usable
-HAVE_SYS_PTEM_H <sys/ptem.h> exists
-HAVE_SYS_PTE_H <sys/pte.h> exists
-HAVE_SYS_STREAM_H <sys/stream.h> exists
-HAVE_SYS_SELECT_H <sys/select.h> exists
-
-System-specific options:
-
-GWINSZ_IN_SYS_IOCTL need to include <sys/ioctl.h> for TIOCGWINSZ
-HAVE_GETPW_DECLS the getpw* functions are declared in <pwd.h> and cannot
- be redeclared without compiler errors
-HAVE_STRCASECMP the strcasecmp and strncasecmp functions are available
-
-USG Running a variant of System V
-USGr3 Running System V.3
-XENIX_22 Xenix 2.2
-Linux Linux
-CRAY running a recent version of Cray UNICOS
-SunOS4 Running SunOS 4.x
+This is not to be built as a standalone library to be installed in some
+public place; get the full readline distribution instead.
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index 300530a..f446dc8 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -83,6 +83,7 @@ extern int rl_complete_with_tilde_expansion;
extern int rl_completion_query_items;
extern int rl_inhibit_completion;
extern char *_rl_comment_begin;
+extern unsigned char *_rl_isearch_terminators;
extern int rl_explicit_arg;
extern int rl_editing_mode;
@@ -207,13 +208,17 @@ rl_unbind_function_in_map (func, map)
Function *func;
Keymap map;
{
- register int i;
+ register int i, rval;
- for (i = 0; i < KEYMAP_SIZE; i++)
+ for (i = rval = 0; i < KEYMAP_SIZE; i++)
{
if (map[i].type == ISFUNC && map[i].function == func)
- map[i].function = (Function *)NULL;
+ {
+ map[i].function = (Function *)NULL;
+ rval = 1;
+ }
}
+ return rval;
}
int
@@ -222,7 +227,6 @@ rl_unbind_command_in_map (command, map)
Keymap map;
{
Function *func;
- register int i;
func = rl_named_function (command);
if (func == 0)
@@ -663,7 +667,11 @@ _rl_read_file (filename, sizep)
i = read (file, buffer, file_size);
close (file);
+#if 0
if (i < file_size)
+#else
+ if (i < 0)
+#endif
{
free (buffer);
return ((char *)NULL);
@@ -727,6 +735,8 @@ _rl_read_init_file (filename, include_level)
openname = tilde_expand (filename);
buffer = _rl_read_file (openname, &file_size);
+ free (openname);
+
if (buffer == 0)
return (errno);
@@ -1338,7 +1348,34 @@ rl_variable_bind (name, value)
else
_rl_bell_preference = AUDIBLE_BELL;
}
+ else if (_rl_stricmp (name, "isearch-terminators") == 0)
+ {
+ /* Isolate the value and translate it into a character string. */
+ int beg, end;
+ char *v;
+ v = savestring (value);
+ FREE (_rl_isearch_terminators);
+ if (v[0] == '"' || v[0] == '\'')
+ {
+ int delim = v[0];
+ for (beg = end = 1; v[end] && v[end] != delim; end++)
+ ;
+ }
+ else
+ {
+ for (beg = end = 0; whitespace (v[end]) == 0; end++)
+ ;
+ }
+
+ v[end] = '\0';
+ /* The value starts at v + beg. Translate it into a character string. */
+ _rl_isearch_terminators = (unsigned char *)xmalloc (2 * strlen (v) + 1);
+ rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
+ _rl_isearch_terminators[end] = '\0';
+ free (v);
+ }
+
/* For the time being, unknown variable names are simply ignored. */
return 0;
}
@@ -1492,7 +1529,7 @@ _rl_get_keyname (key)
int key;
{
char *keyname;
- int i, c, v;
+ int i, c;
keyname = (char *)xmalloc (8);
@@ -1897,6 +1934,21 @@ rl_variable_dumper (print_readably)
fprintf (rl_outstream, "set keymap %s\n", kname ? kname : "none");
else
fprintf (rl_outstream, "keymap is set to `%s'\n", kname ? kname : "none");
+
+ /* isearch-terminators */
+ if (_rl_isearch_terminators)
+ {
+ char *disp;
+
+ disp = _rl_untranslate_macro_value (_rl_isearch_terminators);
+
+ if (print_readably)
+ fprintf (rl_outstream, "set isearch-terminators \"%s\"\n", disp);
+ else
+ fprintf (rl_outstream, "isearch-terminators is set to \"%s\"\n", disp);
+
+ free (disp);
+ }
}
/* Print all of the current variables and their values to
diff --git a/lib/readline/callback.c b/lib/readline/callback.c
index 34dbc72..6915be4 100644
--- a/lib/readline/callback.c
+++ b/lib/readline/callback.c
@@ -36,7 +36,7 @@
#include "rldefs.h"
#include "readline.h"
-extern void readline_internal_startup ();
+extern void readline_internal_setup ();
extern char *readline_internal_teardown ();
extern int readline_internal_char ();
extern void _rl_init_line_state ();
diff --git a/lib/readline/complete.c b/lib/readline/complete.c
index 985e898..714a2bf 100644
--- a/lib/readline/complete.c
+++ b/lib/readline/complete.c
@@ -85,6 +85,15 @@ extern void _rl_move_vert ();
extern int _rl_vis_botlin;
extern int rl_display_fixed;
+/* If non-zero, then this is the address of a function to call when
+ completing a word would normally display the list of possible matches.
+ This function is called instead of actually doing the display.
+ It takes three arguments: (char **matches, int num_matches, int max_length)
+ where MATCHES is the array of strings that matched, NUM_MATCHES is the
+ number of strings in that array, and MAX_LENGTH is the length of the
+ longest string in that array. */
+VFunction *rl_completion_display_matches_hook = (VFunction *)NULL;
+
/* Forward declarations for functions defined and used in this file. */
char *filename_completion_function ();
char **completion_matches ();
@@ -674,6 +683,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
we are doing filename completion and the application has defined a
filename dequoting function. */
temp = (char *)NULL;
+
if (found_quote && our_func == (Function *)filename_completion_function &&
rl_filename_dequoting_function)
{
@@ -682,7 +692,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
text = temp; /* not freeing text is not a memory leak */
}
- matches = completion_matches (text, our_func);
+ matches = completion_matches (text, (CPFunction *)our_func);
FREE (temp);
return matches;
}
@@ -813,8 +823,7 @@ compute_lcd_of_matches (match_list, matches, text)
}
static int
-postprocess_matches (text, matchesp, matching_filenames)
- char *text;
+postprocess_matches (matchesp, matching_filenames)
char ***matchesp;
int matching_filenames;
{
@@ -845,7 +854,6 @@ postprocess_matches (text, matchesp, matching_filenames)
if (matches == 0 || matches[0] == 0)
{
FREE (matches);
- ding ();
*matchesp = (char **)0;
return 0;
}
@@ -857,7 +865,7 @@ postprocess_matches (text, matchesp, matching_filenames)
if (i > 1 && i < nmatch)
{
t = matches[0];
- compute_lcd_of_matches (matches, i - 1, text);
+ compute_lcd_of_matches (matches, i - 1, t);
FREE (t);
}
}
@@ -867,66 +875,19 @@ postprocess_matches (text, matchesp, matching_filenames)
return (1);
}
-static void
-display_matches (matches)
+/* A convenience function for displaying a list of strings in
+ columnar format on readline's output stream. MATCHES is the list
+ of strings, in argv format, LEN is the number of strings in MATCHES,
+ and MAX is the length of the longest string in MATCHES. */
+void
+rl_display_match_list (matches, len, max)
char **matches;
+ int len, max;
{
- int len, count, limit, max, printed_len;
+ int count, limit, printed_len;
int i, j, k, l;
char *temp;
- /* Move to the last visible line of a possibly-multiple-line command. */
- _rl_move_vert (_rl_vis_botlin);
-
- /* Handle simple case first. What if there is only one answer? */
- if (matches[1] == 0)
- {
- temp = printable_part (matches[0]);
- crlf ();
- print_filename (temp, matches[0]);
- crlf ();
-#if 0
- rl_on_new_line ();
-#else
- rl_forced_update_display ();
- rl_display_fixed = 1;
-#endif
- return;
- }
-
- /* There is more than one answer. Find out how many there are,
- and find the maximum printed length of a single entry. */
- for (max = 0, i = 1; matches[i]; i++)
- {
- temp = printable_part (matches[i]);
- len = strlen (temp);
-
- if (len > max)
- max = len;
- }
-
- len = i - 1;
-
- /* If there are many items, then ask the user if she really wants to
- see them all. */
- if (len >= rl_completion_query_items)
- {
- crlf ();
- fprintf (rl_outstream, "Display all %d possibilities? (y or n)", len);
- fflush (rl_outstream);
- if (get_y_or_n () == 0)
- {
- crlf ();
-#if 0
- rl_on_new_line ();
-#else
- rl_forced_update_display ();
- rl_display_fixed = 1;
-#endif
- return;
- }
- }
-
/* How many items of MAX length can we fit in the screen window? */
max += 2;
limit = screenwidth / max;
@@ -993,13 +954,85 @@ display_matches (matches)
}
crlf ();
}
+}
+
+/* Display MATCHES, a list of matching filenames in argv format. This
+ handles the simple case -- a single match -- first. If there is more
+ than one match, we compute the number of strings in the list and the
+ length of the longest string, which will be needed by the display
+ function. If the application wants to handle displaying the list of
+ matches itself, it sets RL_COMPLETION_DISPLAY_MATCHES_HOOK to the
+ address of a function, and we just call it. If we're handling the
+ display ourselves, we just call rl_display_match_list. We also check
+ that the list of matches doesn't exceed the user-settable threshold,
+ and ask the user if he wants to see the list if there are more matches
+ than RL_COMPLETION_QUERY_ITEMS. */
+static void
+display_matches (matches)
+ char **matches;
+{
+ int len, max, i;
+ char *temp;
+
+ /* Move to the last visible line of a possibly-multiple-line command. */
+ _rl_move_vert (_rl_vis_botlin);
+
+ /* Handle simple case first. What if there is only one answer? */
+ if (matches[1] == 0)
+ {
+ temp = printable_part (matches[0]);
+ crlf ();
+ print_filename (temp, matches[0]);
+ crlf ();
+
+ rl_forced_update_display ();
+ rl_display_fixed = 1;
+
+ return;
+ }
+
+ /* There is more than one answer. Find out how many there are,
+ and find the maximum printed length of a single entry. */
+ for (max = 0, i = 1; matches[i]; i++)
+ {
+ temp = printable_part (matches[i]);
+ len = strlen (temp);
+
+ if (len > max)
+ max = len;
+ }
+
+ len = i - 1;
+
+ /* If the caller has defined a display hook, then call that now. */
+ if (rl_completion_display_matches_hook)
+ {
+ (*rl_completion_display_matches_hook) (matches, len, max);
+ return;
+ }
+
+ /* If there are many items, then ask the user if she really wants to
+ see them all. */
+ if (len >= rl_completion_query_items)
+ {
+ crlf ();
+ fprintf (rl_outstream, "Display all %d possibilities? (y or n)", len);
+ fflush (rl_outstream);
+ if (get_y_or_n () == 0)
+ {
+ crlf ();
+
+ rl_forced_update_display ();
+ rl_display_fixed = 1;
+
+ return;
+ }
+ }
+
+ rl_display_match_list (matches, len, max);
-#if 0
- rl_on_new_line ();
-#else
rl_forced_update_display ();
rl_display_fixed = 1;
-#endif
}
static char *
@@ -1026,11 +1059,8 @@ make_quoted_replacement (match, mtype, qc)
rl_filename_quoting_desired;
if (should_quote)
-#if defined (SHELL)
- should_quote = should_quote && (!qc || !*qc || *qc == '"' || *qc == '\'');
-#else /* !SHELL */
- should_quote = should_quote && (!qc || !*qc);
-#endif /* !SHELL */
+ should_quote = should_quote && (!qc || !*qc ||
+ (rl_completer_quote_characters && strchr (rl_completer_quote_characters, *qc)));
if (should_quote)
{
@@ -1168,6 +1198,17 @@ insert_all_matches (matches, point, qc)
rl_end_undo_group ();
}
+static void
+free_match_list (matches)
+ char **matches;
+{
+ register int i;
+
+ for (i = 0; matches[i]; i++)
+ free (matches[i]);
+ free (matches);
+}
+
/* Complete the word at or before point.
WHAT_TO_DO says what to do with the completion.
`?' means list the possible completions.
@@ -1210,27 +1251,34 @@ rl_complete_internal (what_to_do)
text = rl_copy_text (start, end);
matches = gen_completion_matches (text, start, end, our_func, found_quote, quote_char);
+ free (text);
if (matches == 0)
{
ding ();
FREE (saved_line_buffer);
- free (text);
return (0);
}
+#if 0
/* If we are matching filenames, our_func will have been set to
filename_completion_function */
i = our_func == (Function *)filename_completion_function;
- if (postprocess_matches (text, &matches, i) == 0)
+#else
+ /* If we are matching filenames, the attempted completion function will
+ have set rl_filename_completion_desired to a non-zero value. The basic
+ filename_completion_function does this. */
+ i = rl_filename_completion_desired;
+#endif
+
+ if (postprocess_matches (&matches, i) == 0)
{
+ ding ();
FREE (saved_line_buffer);
- free (text);
+ completion_changed_buffer = 0;
return (0);
}
- free (text);
-
switch (what_to_do)
{
case TAB:
@@ -1277,9 +1325,7 @@ rl_complete_internal (what_to_do)
return 1;
}
- for (i = 0; matches[i]; i++)
- free (matches[i]);
- free (matches);
+ free_match_list (matches);
/* Check to see if the line has changed through all of this manipulation. */
if (saved_line_buffer)
@@ -1358,10 +1404,10 @@ completion_matches (text, entry_function)
character (usually `~'). */
char *
username_completion_function (text, state)
- int state;
char *text;
+ int state;
{
-#if defined (__GO32__) || defined (__WIN32__)
+#if defined (__GO32__) || defined (__WIN32__) || defined (__OPENNT)
return (char *)NULL;
#else /* !__GO32__ */
static char *username = (char *)NULL;
@@ -1415,8 +1461,8 @@ username_completion_function (text, state)
completion for a command. */
char *
filename_completion_function (text, state)
- int state;
char *text;
+ int state;
{
static DIR *directory = (DIR *)NULL;
static char *filename = (char *)NULL;
@@ -1574,7 +1620,7 @@ filename_completion_function (text, state)
strcpy (temp, users_dirname);
}
- strcpy (temp + dirlen, entry->d_name); /* strcat (temp, entry->d_name); */
+ strcpy (temp + dirlen, entry->d_name);
}
else
temp = savestring (entry->d_name);
@@ -1649,10 +1695,17 @@ rl_menu_complete (count, ignore)
matches = gen_completion_matches (orig_text, orig_start, orig_end,
our_func, found_quote, quote_char);
+#if 0
/* If we are matching filenames, our_func will have been set to
filename_completion_function */
matching_filenames = our_func == (Function *)filename_completion_function;
- if (matches == 0 || postprocess_matches (orig_text, &matches, matching_filenames) == 0)
+#else
+ /* If we are matching filenames, the attempted completion function will
+ have set rl_filename_completion_desired to a non-zero value. The basic
+ filename_completion_function does this. */
+ matching_filenames = rl_filename_completion_desired;
+#endif
+ if (matches == 0 || postprocess_matches (&matches, matching_filenames) == 0)
{
ding ();
FREE (matches);
@@ -1686,7 +1739,7 @@ rl_menu_complete (count, ignore)
if (match_list_index < 0)
match_list_index += match_list_size;
- if (match_list_index == 0)
+ if (match_list_index == 0 && match_list_size > 1)
{
ding ();
insert_match (orig_text, orig_start, MULT_MATCH, &quote_char);
diff --git a/lib/readline/display.c b/lib/readline/display.c
index f7ec69b..25aba64 100644
--- a/lib/readline/display.c
+++ b/lib/readline/display.c
@@ -280,7 +280,7 @@ rl_expand_prompt (prompt)
if (local_prompt_prefix)
free (local_prompt_prefix);
local_prompt = local_prompt_prefix = (char *)0;
- last_invisible = 0;
+ last_invisible = visible_length = 0;
if (prompt == 0 || *prompt == 0)
return (0);
@@ -373,6 +373,13 @@ rl_redisplay ()
if (local_len > 0)
{
+ temp = local_len + out + 2;
+ if (temp >= line_size)
+ {
+ line_size = (temp + 1024) - (temp % 1024);
+ visible_line = xrealloc (visible_line, line_size);
+ line = invisible_line = xrealloc (invisible_line, line_size);
+ }
strncpy (line + out, local_prompt, local_len);
out += local_len;
}
@@ -399,6 +406,13 @@ rl_redisplay ()
}
pmtlen = strlen (prompt_this_line);
+ temp = pmtlen + out + 2;
+ if (temp >= line_size)
+ {
+ line_size = (temp + 1024) - (temp % 1024);
+ visible_line = xrealloc (visible_line, line_size);
+ line = invisible_line = xrealloc (invisible_line, line_size);
+ }
strncpy (line + out, prompt_this_line, pmtlen);
out += pmtlen;
line[out] = '\0';
@@ -407,12 +421,12 @@ rl_redisplay ()
#define CHECK_LPOS() \
do { \
- lpos++; \
- if (lpos >= screenwidth) \
- { \
- inv_lbreaks[++newlines] = out; \
- lpos = 0; \
- } \
+ lpos++; \
+ if (lpos >= screenwidth) \
+ { \
+ inv_lbreaks[++newlines] = out; \
+ lpos = 0; \
+ } \
} while (0)
/* inv_lbreaks[i] is where line i starts in the buffer. */
@@ -481,7 +495,12 @@ rl_redisplay ()
else if (c == '\t')
{
register int temp, newout;
+
+#if 0
newout = (out | (int)7) + 1;
+#else
+ newout = out + 8 - lpos % 8;
+#endif
temp = newout - out;
if (lpos + temp >= screenwidth)
{
@@ -501,11 +520,11 @@ rl_redisplay ()
}
#endif
else if (c == '\n' && _rl_horizontal_scroll_mode == 0 && term_up && *term_up)
- {
- line[out++] = '\0'; /* XXX - sentinel */
- inv_lbreaks[++newlines] = out;
- lpos = 0;
- }
+ {
+ line[out++] = '\0'; /* XXX - sentinel */
+ inv_lbreaks[++newlines] = out;
+ lpos = 0;
+ }
else if (CTRL_CHAR (c) || c == RUBOUT)
{
line[out++] = '^';
@@ -616,11 +635,11 @@ rl_redisplay ()
{
_rl_move_vert (cursor_linenum);
/* If we moved up to the line with the prompt using term_up,
- the physical cursor position on the screen stays the same,
- but the buffer position needs to be adjusted to account
- for invisible characters. */
+ the physical cursor position on the screen stays the same,
+ but the buffer position needs to be adjusted to account
+ for invisible characters. */
if (cursor_linenum == 0 && wrap_offset)
- _rl_last_c_pos += wrap_offset;
+ _rl_last_c_pos += wrap_offset;
}
/* We have to reprint the prompt if it contains invisible
@@ -673,16 +692,16 @@ rl_redisplay ()
ndisp = c_pos - wrap_offset;
nleft = visible_length + wrap_offset;
/* Where the new cursor position will be on the screen. This can be
- longer than SCREENWIDTH; if it is, lmargin will be adjusted. */
+ longer than SCREENWIDTH; if it is, lmargin will be adjusted. */
phys_c_pos = c_pos - (last_lmargin ? last_lmargin : wrap_offset);
t = screenwidth / 3;
/* If the number of characters had already exceeded the screenwidth,
- last_lmargin will be > 0. */
+ last_lmargin will be > 0. */
/* If the number of characters to be displayed is more than the screen
- width, compute the starting offset so that the cursor is about
- two-thirds of the way across the screen. */
+ width, compute the starting offset so that the cursor is about
+ two-thirds of the way across the screen. */
if (phys_c_pos > screenwidth - 2)
{
lmargin = c_pos - (2 * t);
@@ -694,7 +713,7 @@ rl_redisplay ()
lmargin = nleft;
}
else if (ndisp < screenwidth - 2) /* XXX - was -1 */
- lmargin = 0;
+ lmargin = 0;
else if (phys_c_pos < 1)
{
/* If we are moving back towards the beginning of the line and
@@ -704,7 +723,7 @@ rl_redisplay ()
lmargin = nleft;
}
else
- lmargin = last_lmargin;
+ lmargin = last_lmargin;
/* If the first character on the screen isn't the first character
in the display line, indicate this with a special character. */
@@ -712,12 +731,12 @@ rl_redisplay ()
line[lmargin] = '<';
/* If SCREENWIDTH characters starting at LMARGIN do not encompass
- the whole line, indicate that with a special characters at the
- right edge of the screen. If LMARGIN is 0, we need to take the
- wrap offset into account. */
+ the whole line, indicate that with a special character at the
+ right edge of the screen. If LMARGIN is 0, we need to take the
+ wrap offset into account. */
t = lmargin + M_OFFSET (lmargin, wrap_offset) + screenwidth;
if (t < out)
- line[t - 1] = '>';
+ line[t - 1] = '>';
if (!rl_display_fixed || forced_display || lmargin != last_lmargin)
{
@@ -782,7 +801,7 @@ new: eddie> Oh, my little buggy says to me, as lurgid as
\new first difference
All are character pointers for the sake of speed. Special cases for
- no differences, as well as for end of line additions must be handeled.
+ no differences, as well as for end of line additions must be handled.
Could be made even smarter, but this works well enough */
static void
@@ -810,7 +829,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
_rl_last_c_pos = 1; /* XXX */
_rl_last_v_pos++;
if (old[0] && new[0])
- old[0] = new[0];
+ old[0] = new[0];
}
/* Find first difference. */
@@ -895,10 +914,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
lendiff needs to be adjusted. */
if (current_line == 0 && !_rl_horizontal_scroll_mode &&
current_invis_chars != visible_wrap_offset)
- {
- temp = visible_wrap_offset - current_invis_chars;
- lendiff += temp;
- }
+ lendiff += visible_wrap_offset - current_invis_chars;
/* Insert (diff (len (old), len (new)) ch. */
temp = ne - nfd;
@@ -927,7 +943,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
/* At the end of a line the characters do not have to
be "inserted". They can just be placed on the screen. */
/* However, this screws up the rest of this block, which
- assumes you've done the insert because you can. */
+ assumes you've done the insert because you can. */
_rl_output_some_chars (nfd, lendiff);
_rl_last_c_pos += lendiff;
}
@@ -987,10 +1003,13 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
_rl_last_c_pos += temp;
}
lendiff = (oe - old) - (ne - new);
- if (_rl_term_autowrap && current_line < inv_botlin)
- space_to_eol (lendiff);
- else
- _rl_clear_to_eol (lendiff);
+ if (lendiff)
+ {
+ if (_rl_term_autowrap && current_line < inv_botlin)
+ space_to_eol (lendiff);
+ else
+ _rl_clear_to_eol (lendiff);
+ }
}
}
}
@@ -1019,7 +1038,7 @@ rl_forced_update_display ()
register char *temp = visible_line;
while (*temp)
- *temp++ = '\0';
+ *temp++ = '\0';
}
rl_on_new_line ();
forced_display++;
@@ -1080,7 +1099,7 @@ _rl_move_cursor_relative (new, data)
putc (data[i], rl_outstream);
#endif /* HACK_TERMCAP_MOTION */
}
- else if (_rl_last_c_pos != new)
+ else if (_rl_last_c_pos > new)
_rl_backspace (_rl_last_c_pos - new);
_rl_last_c_pos = new;
}
@@ -1245,7 +1264,7 @@ static int saved_last_invisible;
static int saved_visible_length;
void
-_rl_save_prompt ()
+rl_save_prompt ()
{
saved_local_prompt = local_prompt;
saved_local_prefix = local_prompt_prefix;
@@ -1257,7 +1276,7 @@ _rl_save_prompt ()
}
void
-_rl_restore_prompt ()
+rl_restore_prompt ()
{
if (local_prompt)
free (local_prompt);
@@ -1277,14 +1296,14 @@ _rl_make_prompt_for_search (pchar)
int len;
char *pmt;
- _rl_save_prompt ();
+ rl_save_prompt ();
if (saved_local_prompt == 0)
{
len = (rl_prompt && *rl_prompt) ? strlen (rl_prompt) : 0;
pmt = xmalloc (len + 2);
if (len)
- strcpy (pmt, rl_prompt);
+ strcpy (pmt, rl_prompt);
pmt[len] = pchar;
pmt[len+1] = '\0';
}
@@ -1293,7 +1312,7 @@ _rl_make_prompt_for_search (pchar)
len = *saved_local_prompt ? strlen (saved_local_prompt) : 0;
pmt = xmalloc (len + 2);
if (len)
- strcpy (pmt, saved_local_prompt);
+ strcpy (pmt, saved_local_prompt);
pmt[len] = pchar;
pmt[len+1] = '\0';
local_prompt = savestring (pmt);
@@ -1540,6 +1559,15 @@ _rl_clean_up_for_exit ()
_rl_move_vert (_rl_vis_botlin);
_rl_vis_botlin = 0;
fflush (rl_outstream);
- rl_restart_output ();
+ rl_restart_output (1, 0);
}
}
+
+void
+_rl_erase_entire_line ()
+{
+ cr ();
+ _rl_clear_to_eol (0);
+ cr ();
+ fflush (rl_outstream);
+}
diff --git a/lib/readline/doc/Makefile b/lib/readline/doc/Makefile
index 58d4dd7..b58ab56 100644
--- a/lib/readline/doc/Makefile
+++ b/lib/readline/doc/Makefile
@@ -1,40 +1,75 @@
+# Generated automatically from Makefile.in by configure.
# This makefile for Readline library documentation is in -*- text -*- mode.
# Emacs likes it that way.
+top_srcdir = .
+srcdir = .
+VPATH = .
+
+prefix = /usr/local
+infodir = ${prefix}/info
+
+mandir = ${prefix}/man
+man3dir = $(mandir)/man3
+
+SHELL = /bin/sh
RM = rm -f
+TEXINPUTDIR = $(srcdir)
+
MAKEINFO = makeinfo
-TEXI2DVI = texi2dvi
-TEXI2HTML = texi2html
+TEXI2DVI = $(srcdir)/texi2dvi
+TEXI2HTML = $(srcdir)/texi2html
QUIETPS = #set this to -q to shut up dvips
DVIPS = dvips -D 300 $(QUIETPS) -o $@ # tricky
-INSTALL_DATA = cp
-infodir = /usr/local/info
+INSTALL = /usr/bin/install -c
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_DATA = ${INSTALL} -m 644
-RLSRC = rlman.texinfo rluser.texinfo rltech.texinfo
-HISTSRC = hist.texinfo hsuser.texinfo hstech.texinfo
+RLSRC = $(srcdir)/rlman.texinfo $(srcdir)/rluser.texinfo \
+ $(srcdir)/rltech.texinfo $(srcdir)/manvers.texinfo
+HISTSRC = $(srcdir)/hist.texinfo $(srcdir)/hsuser.texinfo \
+ $(srcdir)/hstech.texinfo $(srcdir)/manvers.texinfo
+
+# This should be a program that converts troff to an ascii-readable format
+NROFF = groff -Tascii
+
+# This should be a program that converts troff to postscript
+GROFF = groff
DVIOBJ = readline.dvi history.dvi
INFOOBJ = readline.info history.info
PSOBJ = readline.ps history.ps
HTMLOBJ = readline.html history.html
+HTMLTOC = readline_toc.html history_toc.html
+TEXTOBJ = readline.0
+
+INTERMEDIATE_OBJ = rlman.dvi hist.dvi
-all: info dvi html ps
-nodvi: info html
+CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ) $(HTMLTOC) $(TEXTOBJ)
+
+.SUFFIXES: .0 .3 .ps .txt .dvi
+
+.3.0:
+ $(RM) $@
+ -${NROFF} -man $< > $@
+
+all: info dvi html ps #text
+nodvi: info html #text
readline.dvi: $(RLSRC)
- $(TEXI2DVI) rlman.texinfo
+ TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rlman.texinfo
mv rlman.dvi readline.dvi
readline.info: $(RLSRC)
- $(MAKEINFO) --no-split -o $@ rlman.texinfo
+ $(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rlman.texinfo
history.dvi: ${HISTSRC}
- $(TEXI2DVI) hist.texinfo
+ TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/hist.texinfo
mv hist.dvi history.dvi
history.info: ${HISTSRC}
- $(MAKEINFO) --no-split -o $@ hist.texinfo
+ $(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/hist.texinfo
readline.ps: readline.dvi
$(RM) $@
@@ -45,32 +80,60 @@ history.ps: history.dvi
$(DVIPS) history.dvi
readline.html: ${RLSRC}
- $(TEXI2HTML) rlman.texinfo
- sed -e 's:rlman.html:readline.html:' -e 's:rlman_toc.html:readline_toc.html:' rlman.html > readline.html
- sed -e 's:rlman.html:readline.html:' -e 's:rlman_toc.html:readline_toc.html:' rlman_toc.html > readline_toc.html
- $(RM) rlman.html rlman_toc.html
+ $(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rlman.texinfo
+ sed -e 's:rlman.html:readline.html:' rlman.html > readline.html
+ $(RM) rlman.html
history.html: ${HISTSRC}
- $(TEXI2HTML) hist.texinfo
- sed -e 's:hist.html:history.html:' -e 's:hist_toc.html:history_toc.html:' hist.html > history.html
- sed -e 's:hist.html:history.html:' -e 's:hist_toc.html:history_toc.html:' hist_toc.html > history_toc.html
- $(RM) hist.html hist_toc.html
+ $(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/hist.texinfo
+ sed -e 's:hist.html:history.html:' hist.html > history.html
+ $(RM) hist.html
info: $(INFOOBJ)
dvi: $(DVIOBJ)
ps: $(PSOBJ)
html: $(HTMLOBJ)
+text: $(TEXTOBJ)
+
+readline.0: readline.3
clean:
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
*.fns *.kys *.tps *.vrs *.o core
distclean: clean
+ $(RM) $(CREATED_DOCS)
+ $(RM) $(INTERMEDIATE_OBJ)
+ $(RM) Makefile
+
mostlyclean: clean
maintainer-clean: clean
- $(RM) *.dvi *.info *.info-* *.ps *.html
-
-install: info
- ${INSTALL_DATA} readline.info $(infodir)/readline.info
- ${INSTALL_DATA} history.info $(infodir)/history.info
+ $(RM) $(CREATED_DOCS)
+ $(RM) $(INTERMEDIATE_OBJ)
+ $(RM) Makefile
+
+installdirs: $(top_srcdir)/support/mkdirs
+ -$(SHELL) $(top_srcdir)/support/mkdirs $(infodir) $(man3dir)
+
+install: installdirs
+ if test -f readline.info; then \
+ ${INSTALL_DATA} readline.info $(infodir)/readline.info; \
+ else \
+ ${INSTALL_DATA} $(srcdir)/readline.info $(infodir)/readline.info; \
+ fi
+ if test -f history.info; then \
+ ${INSTALL_DATA} history.info $(infodir)/history.info; \
+ else \
+ ${INSTALL_DATA} $(srcdir)/history.info $(infodir)/history.info; \
+ fi
+ if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
+ install-info --dir-file=$(infodir)/dir $(infodir)/readline.info ; \
+ install-info --dir-file=$(infodir)/dir $(infodir)/history.info ; \
+ else true; fi
+ -${INSTALL_DATA} $(srcdir)/readline.3 $(man3dir)/readline.3
+
+uninstall:
+ $(RM) $(infodir)/readline.info
+ $(RM) $(infodir)/history.info
+ $(RM) $(man3dir)/readline.3
diff --git a/lib/readline/doc/hist.texinfo b/lib/readline/doc/hist.texinfo
index be8742f..31a0ba0 100644
--- a/lib/readline/doc/hist.texinfo
+++ b/lib/readline/doc/hist.texinfo
@@ -6,26 +6,19 @@
@setchapternewpage odd
-@ignore
-last change: Thu Apr 2 14:38:22 EST 1998
-@end ignore
-
-@set EDITION 2.2
-@set VERSION 2.2
-@set UPDATED 2 April 1998
-@set UPDATE-MONTH April 1998
+@include manvers.texinfo
+@ifinfo
@dircategory Libraries
@direntry
* History: (history). The GNU history library API
@end direntry
-@ifinfo
This document describes the GNU History library, a programming tool that
provides a consistent user interface for recalling lines of previously
typed input.
-Copyright (C) 1988, 1991, 1993, 1995, 1996, 1998 Free Software Foundation, Inc.
+Copyright (C) 1988-1999 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -46,7 +39,7 @@ notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
-by the Foundation.
+by the Free Software Foundation.
@end ifinfo
@titlepage
@@ -77,10 +70,10 @@ notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
-by the Foundation.
+by the Free Software Foundation.
@vskip 0pt plus 1filll
-Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
+Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
@end titlepage
@ifinfo
diff --git a/lib/readline/doc/manvers.texinfo b/lib/readline/doc/manvers.texinfo
new file mode 100644
index 0000000..63924e3
--- /dev/null
+++ b/lib/readline/doc/manvers.texinfo
@@ -0,0 +1,6 @@
+@set EDITION 4.0
+@set VERSION 4.0
+@set UPDATED 31 December 1998
+@set UPDATE-MONTH December 1998
+
+@set LASTCHANGE Thu Dec 31 10:17:05 EST 1998
diff --git a/lib/readline/doc/rlman.texinfo b/lib/readline/doc/rlman.texinfo
index dd6478a..41bafbf 100644
--- a/lib/readline/doc/rlman.texinfo
+++ b/lib/readline/doc/rlman.texinfo
@@ -6,26 +6,19 @@
@synindex vr fn
@setchapternewpage odd
-@ignore
-last change: Thu Apr 2 14:39:03 EST 1998
-@end ignore
-
-@set EDITION 2.2
-@set VERSION 2.2
-@set UPDATED 2 April 1998
-@set UPDATE-MONTH April 1998
+@include manvers.texinfo
+@ifinfo
@dircategory Libraries
@direntry
* Readline: (readline). The GNU readline library API
@end direntry
-@ifinfo
This document describes the GNU Readline Library, a utility which aids
in the consistency of user interface across discrete programs that need
to provide a command line interface.
-Copyright (C) 1988, 1991, 1993, 1996, 1998 Free Software Foundation, Inc.
+Copyright (C) 1988-1999 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -46,7 +39,7 @@ notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
-by the Foundation.
+by the Free Software Foundation.
@end ifinfo
@titlepage
@@ -77,10 +70,10 @@ notice identical to this one.
Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
-by the Foundation.
+by the Free Software Foundation.
@vskip 0pt plus 1filll
-Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc.
+Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
@end titlepage
@ifinfo
diff --git a/lib/readline/doc/rltech.texinfo b/lib/readline/doc/rltech.texinfo
index bce5087..ea8d7f8 100644
--- a/lib/readline/doc/rltech.texinfo
+++ b/lib/readline/doc/rltech.texinfo
@@ -8,7 +8,7 @@ This document describes the GNU Readline Library, a utility for aiding
in the consitency of user interface across discrete programs that need
to provide a command line interface.
-Copyright (C) 1988, 1994, 1996 Free Software Foundation, Inc.
+Copyright (C) 1988, 1994, 1996, 1998, 1999 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@@ -47,7 +47,9 @@ in your own programs, this section is for you.
* Readline Variables:: Variables accessible to custom
functions.
* Readline Convenience Functions:: Functions which Readline supplies to
- aid in writing your own
+ aid in writing your own custom
+ functions.
+* Readline Signal Handling:: How Readline behaves when it receives signals.
* Custom Completers:: Supplanting or supplementing Readline's
completion functions.
@end menu
@@ -268,6 +270,13 @@ Setting this to a value makes it the next keystroke read. This is a
way to stuff a single character into the input stream.
@end deftypevar
+@deftypevar int rl_erase_empty_line
+Setting this to a non-zero value causes Readline to completely erase
+the current line, including any prompt, any time a newline is typed as
+the only character on an otherwise-empty line. The cursor is moved to
+the beginning of the newly-blank line.
+@end deftypevar
+
@deftypevar {char *} rl_prompt
The prompt Readline uses. This is set from the argument to
@code{readline ()}, and should not be assigned to directly.
@@ -300,6 +309,12 @@ If non-zero, this is the address of a function to call just
before @code{readline} prints the first prompt.
@end deftypevar
+@deftypevar {Function *} rl_pre_input_hook
+If non-zero, this is the address of a function to call after
+the first prompt has been printed and just before @code{readline}
+starts reading input characters.
+@end deftypevar
+
@deftypevar {Function *} rl_event_hook
If non-zero, this is the address of a function to call periodically
when readline is waiting for terminal input.
@@ -619,6 +634,16 @@ is also used to display numeric arguments and search strings.
Clear the message in the echo area.
@end deftypefun
+@deftypefun void rl_save_prompt ()
+Save the local Readline prompt display state in preparation for
+displaying a new message in the message area with @code{rl_message}.
+@end deftypefun
+
+@deftypefun void rl_restore_prompt ()
+Restore the local Readline prompt display state saved by the most
+recent call to @code{rl_save_prompt}.
+@end deftypefun
+
@node Modifying Text
@subsection Modifying Text
@@ -689,6 +714,16 @@ Return 1 if @var{c} is a numeric character.
Ring the terminal bell, obeying the setting of @code{bell-style}.
@end deftypefun
+@deftypefun void rl_display_match_list (char **matches, int len, int max)
+A convenience function for displaying a list of strings in
+columnar format on Readline's output stream. @code{matches} is the list
+of strings, in argv format, such as a list of completion matches.
+@code{len} is the number of strings in @code{matches}, and @code{max}
+is the length of the longest string in @code{matches}. This function uses
+the setting of @code{print-completions-horizontally} to select how the
+matches are displayed (@pxref{Readline Init File Syntax}).
+@end deftypefun
+
The following are implemented as macros, defined in @code{chartypes.h}.
@deftypefun int uppercase_p (int c)
@@ -814,6 +849,116 @@ invert_case_line (count, key)
@}
@end example
+@node Readline Signal Handling
+@section Readline Signal Handling
+
+Signals are asynchronous events sent to a process by the Unix kernel,
+sometimes on behalf of another process. They are intended to indicate
+exceptional events, like a user pressing the interrupt key on his
+terminal, or a network connection being broken. There is a class of
+signals that can be sent to the process currently reading input from
+the keyboard. Since Readline changes the terminal attributes when it
+is called, it needs to perform special processing when a signal is
+received to restore the terminal to a sane state, or provide application
+writers with functions to do so manually.
+
+Readline contains an internal signal handler that is installed for a
+number of signals (@code{SIGINT}, @code{SIGQUIT}, @code{SIGTERM},
+@code{SIGALRM}, @code{SIGTSTP}, @code{SIGTTIN}, and @code{SIGTTOU}).
+When one of these signals is received, the signal handler
+will reset the terminal attributes to those that were in effect before
+@code{readline ()} was called, reset the signal handling to what it was
+before @code{readline ()} was called, and resend the signal to the calling
+application.
+If and when the calling application's signal handler returns, Readline
+will reinitialize the terminal and continue to accept input.
+When a @code{SIGINT} is received, the Readline signal handler performs
+some additional work, which will cause any partially-entered line to be
+aborted (see the description of @code{rl_free_line_state ()}).
+
+There is an additional Readline signal handler, for @code{SIGWINCH}, which
+the kernel sends to a process whenever the terminal's size changes (for
+example, if a user resizes an @code{xterm}). The Readline @code{SIGWINCH}
+handler updates Readline's internal screen size state, and then calls any
+@code{SIGWINCH} signal handler the calling application has installed.
+Readline calls the application's @code{SIGWINCH} signal handler without
+resetting the terminal to its original state. If the application's signal
+handler does more than update its idea of the terminal size and return (for
+example, a @code{longjmp} back to a main processing loop), it @emph{must}
+call @code{rl_cleanup_after_signal ()} (described below), to restore the
+terminal state.
+
+Readline provides two variables that allow application writers to
+control whether or not it will catch certain signals and act on them
+when they are received. It is important that applications change the
+values of these variables only when calling @code{readline ()}, not in
+a signal handler, so Readline's internal signal state is not corrupted.
+
+@deftypevar int rl_catch_signals
+If this variable is non-zero, Readline will install signal handlers for
+@code{SIGINT}, @code{SIGQUIT}, @code{SIGTERM}, @code{SIGALRM},
+@code{SIGTSTP}, @code{SIGTTIN}, and @code{SIGTTOU}.
+
+The default value of @code{rl_catch_signals} is 1.
+@end deftypevar
+
+@deftypevar int rl_catch_sigwinch
+If this variable is non-zero, Readline will install a signal handler for
+@code{SIGWINCH}.
+
+The default value of @code{rl_catch_sigwinch} is 1.
+@end deftypevar
+
+If an application does not wish to have Readline catch any signals, or
+to handle signals other than those Readline catches (@code{SIGHUP},
+for example),
+Readline provides convenience functions to do the necessary terminal
+and internal state cleanup upon receipt of a signal.
+
+@deftypefun void rl_cleanup_after_signal (void)
+This function will reset the state of the terminal to what it was before
+@code{readline ()} was called, and remove the Readline signal handlers for
+all signals, depending on the values of @code{rl_catch_signals} and
+@code{rl_catch_sigwinch}.
+@end deftypefun
+
+@deftypefun void rl_free_line_state (void)
+This will free any partial state associated with the current input line
+(undo information, any partial history entry, any partially-entered
+keyboard macro, and any partially-entered numeric argument). This
+should be called before @code{rl_cleanup_after_signal ()}. The
+Readline signal handler for @code{SIGINT} calls this to abort the
+current input line.
+@end deftypefun
+
+@deftypefun void rl_reset_after_signal (void)
+This will reinitialize the terminal and reinstall any Readline signal
+handlers, depending on the values of @code{rl_catch_signals} and
+@code{rl_catch_sigwinch}.
+@end deftypefun
+
+If an application does not wish Readline to catch @code{SIGWINCH}, it may
+call @code{rl_resize_terminal ()} to force Readline to update its idea of
+the terminal size when a @code{SIGWINCH} is received.
+
+@deftypefun void rl_resize_terminal (void)
+Update Readline's internal screen size.
+@end deftypefun
+
+The following functions install and remove Readline's signal handlers.
+
+@deftypefun int rl_set_signals (void)
+Install Readline's signal handler for @code{SIGINT}, @code{SIGQUIT},
+@code{SIGTERM}, @code{SIGALRM}, @code{SIGTSTP}, @code{SIGTTIN},
+@code{SIGTTOU}, and @code{SIGWINCH}, depending on the values of
+@code{rl_catch_signals} and @code{rl_catch_sigwinch}.
+@end deftypefun
+
+@deftypefun int rl_clear_signals (void)
+Remove all of the Readline signal handlers installed by
+@code{rl_set_signals ()}.
+@end deftypefun
+
@node Custom Completers
@section Custom Completers
@@ -1108,6 +1253,20 @@ string (the current directory name) as an argument. It could be used
to expand symbolic links or shell variables in pathnames.
@end deftypevar
+@deftypevar {VFunction *} rl_completion_display_matches_hook
+If non-zero, then this is the address of a function to call when
+completing a word would normally display the list of possible matches.
+This function is called in lieu of Readline displaying the list.
+It takes three arguments:
+(@code{char **}@var{matches}, @code{int} @var{num_matches}, @code{int} @var{max_length})
+where @var{matches} is the array of matching strings,
+@var{num_matches} is the number of strings in that array, and
+@var{max_length} is the length of the longest string in that array.
+Readline provides a convenience function, @code{rl_display_match_list},
+that takes care of doing the display to Readline's output stream. That
+function may be called from this hook.
+@end deftypevar
+
@node A Short Completion Example
@subsection A Short Completion Example
diff --git a/lib/readline/doc/rluser.texinfo b/lib/readline/doc/rluser.texinfo
index b2fd060..755f7ca 100644
--- a/lib/readline/doc/rluser.texinfo
+++ b/lib/readline/doc/rluser.texinfo
@@ -97,7 +97,7 @@ regardless of the location of the cursor within the line.
* Readline Killing Commands:: How to delete text, and how to get it back!
* Readline Arguments:: Giving numeric arguments to commands.
* Searching:: Searching through previous lines.
- @end menu
+@end menu
@node Readline Bare Essentials
@subsection Readline Bare Essentials
@@ -252,8 +252,10 @@ As each character of the search string is typed, Readline displays
the next entry from the history matching the string typed so far.
An incremental search requires only as many characters as needed to
find the desired history entry.
-The @key{ESC} character is used to terminate an incremental search.
-@key{C-j} will also terminate the search.
+The characters present in the value of the @var{isearch-terminators} variable
+are used to terminate an incremental search.
+If that variable has not been assigned a value, the @key{ESC} and
+@key{C-J} characters will terminate an incremental search.
@key{C-g} will abort an incremental search and restore the original line.
When the search is terminated, the history entry containing the
search string becomes the current line.
@@ -396,6 +398,22 @@ horizontally on a single screen line when they are longer than the width
of the screen, instead of wrapping onto a new screen line. By default,
this variable is set to @samp{off}.
+@item input-meta
+@vindex input-meta
+@vindex meta-flag
+If set to @samp{on}, Readline will enable eight-bit input (it
+will not strip the eighth bit from the characters it reads),
+regardless of what the terminal claims it can support. The
+default value is @samp{off}. The name @code{meta-flag} is a
+synonym for this variable.
+
+@item isearch-terminators
+@vindex isearch-terminators
+The string of characters that should terminate an incremental search without
+subsequently executing the character as a command (@pxref{Searching}).
+If this variable has not been given a value, the characters @key{ESC} and
+@key{C-J} will terminate an incremental search.
+
@item keymap
@vindex keymap
Sets Readline's idea of the current keymap for key binding commands.
@@ -422,15 +440,6 @@ This variable, when set to @samp{on}, causes Readline to display an
asterisk (@samp{*}) at the start of history lines which have been modified.
This variable is @samp{off} by default.
-@item input-meta
-@vindex input-meta
-@vindex meta-flag
-If set to @samp{on}, Readline will enable eight-bit input (it
-will not strip the eighth bit from the characters it reads),
-regardless of what the terminal claims it can support. The
-default value is @samp{off}. The name @code{meta-flag} is a
-synonym for this variable.
-
@item output-meta
@vindex output-meta
If set to @samp{on}, Readline will display characters with the
@@ -876,6 +885,11 @@ return @code{EOF}.
Delete the character behind the cursor. A numeric argument means
to kill the characters instead of deleting them.
+@item forward-backward-delete-char ()
+Delete the character under the cursor, unless the cursor is at the
+end of the line, in which case the character behind the cursor is
+deleted. By default, this is not bound to a key.
+
@item quoted-insert (C-q, C-v)
Add the next character typed to the line verbatim. This is
how to insert key sequences like @key{C-q}, for example.
@@ -1039,6 +1053,13 @@ through the list.
This command is intended to be bound to @code{TAB}, but is unbound
by default.
+@item delete-char-or-list ()
+Deletes the character under the cursor if not at the beginning or
+end of the line (like @code{delete-char}).
+If at the end of the line, behaves identically to
+@code{possible-completions}.
+This command is unbound by default.
+
@ifset BashFeatures
@item complete-filename (M-/)
Attempt filename completion on the text before point.
@@ -1141,7 +1162,12 @@ Incremental undo, separately remembered for each line.
Undo all changes made to this line. This is like executing the @code{undo}
command enough times to get back to the beginning.
+@ifset BashFeatures
+@item tilde-expand (M-&)
+@end ifset
+@ifclear BashFeatures
@item tilde-expand (M-~)
+@end ifclear
Perform tilde expansion on the current word.
@item set-mark (C-@@)
diff --git a/lib/readline/examples/rl.c b/lib/readline/examples/rl.c
index 6c2f343..17a6343 100644
--- a/lib/readline/examples/rl.c
+++ b/lib/readline/examples/rl.c
@@ -12,7 +12,7 @@
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
-#include <config.h>
+# include <config.h>
#endif
#include <stdio.h>
@@ -24,7 +24,9 @@
extern int optind;
extern char *optarg;
+#if !defined (strchr) && !defined (__STDC__)
extern char *strrchr();
+#endif
static char *progname;
static char *deftext;
@@ -40,6 +42,7 @@ set_deftext ()
}
}
+static void
usage()
{
fprintf (stderr, "%s: usage: %s [-p prompt] [-u unit] [-d default]\n",
@@ -52,7 +55,7 @@ main (argc, argv)
{
char *temp, *prompt;
struct stat sb;
- int done, opt, fd;
+ int opt, fd;
FILE *ifp;
progname = strrchr(argv[0], '/');
diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c
index 3946e0f..f6b8628 100644
--- a/lib/readline/funmap.c
+++ b/lib/readline/funmap.c
@@ -71,6 +71,7 @@ static FUNMAP default_funmap[] = {
{ "copy-forward-word", rl_copy_forward_word },
{ "copy-region-as-kill", rl_copy_region_to_kill },
{ "delete-char", rl_delete },
+ { "delete-char-or-list", rl_delete_or_show_completions },
{ "delete-horizontal-space", rl_delete_horizontal_space },
{ "digit-argument", rl_digit_argument },
{ "do-lowercase-version", rl_do_lowercase_version },
@@ -83,6 +84,7 @@ static FUNMAP default_funmap[] = {
{ "end-of-history", rl_end_of_history },
{ "end-of-line", rl_end_of_line },
{ "exchange-point-and-mark", rl_exchange_point_and_mark },
+ { "forward-backward-delete-char", rl_rubout_or_delete },
{ "forward-char", rl_forward },
{ "forward-search-history", rl_forward_search_history },
{ "forward-word", rl_forward_word },
diff --git a/lib/readline/histexpand.c b/lib/readline/histexpand.c
index 0dc179a..392e6d3 100644
--- a/lib/readline/histexpand.c
+++ b/lib/readline/histexpand.c
@@ -365,6 +365,10 @@ hist_error(s, start, current, errtype)
emsg = "unrecognized history modifier";
elen = 29;
break;
+ case NO_PREV_SUBST:
+ emsg = "no previous substitution";
+ elen = 24;
+ break;
default:
emsg = "unknown expansion error";
elen = 23;
@@ -654,15 +658,6 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
}
}
- /* If there is no lhs, the substitution can't succeed. */
- if (subst_lhs_len == 0)
- {
- *ret_string = hist_error (string, starting_index, i, SUBST_FAILED);
- free (result);
- free (temp);
- return -1;
- }
-
FREE (subst_rhs);
subst_rhs = get_subst_pattern (string, &i, delimiter, 1, &subst_rhs_len);
@@ -674,6 +669,15 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
else
i += 2;
+ /* If there is no lhs, the substitution can't succeed. */
+ if (subst_lhs_len == 0)
+ {
+ *ret_string = hist_error (string, starting_index, i, NO_PREV_SUBST);
+ free (result);
+ free (temp);
+ return -1;
+ }
+
l_temp = strlen (temp);
/* Ignore impossible cases. */
if (subst_lhs_len > l_temp)
diff --git a/lib/readline/histfile.c b/lib/readline/histfile.c
index 81dda57..3325b7f 100644
--- a/lib/readline/histfile.c
+++ b/lib/readline/histfile.c
@@ -155,7 +155,11 @@ read_history_range (filename, from, to)
}
buffer = xmalloc (file_size + 1);
+#if 0
if (read (file, buffer, file_size) != file_size)
+#else
+ if (read (file, buffer, file_size) < 0)
+#endif
{
error_and_exit:
if (file >= 0)
@@ -217,7 +221,7 @@ read_history_range (filename, from, to)
int
history_truncate_file (fname, lines)
char *fname;
- register int lines;
+ int lines;
{
register int i;
int file, chars_read;
@@ -276,6 +280,12 @@ history_truncate_file (fname, lines)
if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
{
write (file, buffer + i, file_size - i);
+
+#if defined (__BEOS__)
+ /* BeOS ignores O_TRUNC. */
+ ftruncate (file, file_size - i);
+#endif
+
close (file);
}
diff --git a/lib/readline/histlib.h b/lib/readline/histlib.h
index 10a40d7..422cf59 100644
--- a/lib/readline/histlib.h
+++ b/lib/readline/histlib.h
@@ -69,6 +69,7 @@ extern char *strchr ();
#define BAD_WORD_SPEC 1
#define SUBST_FAILED 2
#define BAD_MODIFIER 3
+#define NO_PREV_SUBST 4
/* Possible definitions for history starting point specification. */
#define ANCHORED_SEARCH 1
diff --git a/lib/readline/history.c b/lib/readline/history.c
index 24c5a49..d56ffac 100644
--- a/lib/readline/history.c
+++ b/lib/readline/history.c
@@ -278,7 +278,7 @@ HIST_ENTRY *
replace_history_entry (which, line, data)
int which;
char *line;
- char *data;
+ histdata_t data;
{
HIST_ENTRY *temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
HIST_ENTRY *old_value;
diff --git a/lib/readline/history.h b/lib/readline/history.h
index e49a341..8ecce72 100644
--- a/lib/readline/history.h
+++ b/lib/readline/history.h
@@ -22,6 +22,16 @@
#ifndef _HISTORY_H_
#define _HISTORY_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if defined READLINE_LIBRARY
+# include "rlstdc.h"
+#else
+# include <readline/rlstdc.h>
+#endif
+
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
@@ -30,10 +40,16 @@ typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif
+#ifdef __STDC__
+typedef void *histdata_t;
+#else
+typedef char *histdata_t;
+#endif
+
/* The structure used to store a history entry. */
typedef struct _hist_entry {
char *line;
- char *data;
+ histdata_t data;
} HIST_ENTRY;
/* A structure used to pass the current state of the history stuff around. */
@@ -52,81 +68,81 @@ typedef struct _hist_state {
/* Begin a session in which the history functions might be used. This
just initializes the interactive variables. */
-extern void using_history ();
+extern void using_history __P((void));
/* Return the current HISTORY_STATE of the history. */
-extern HISTORY_STATE *history_get_history_state ();
+extern HISTORY_STATE *history_get_history_state __P((void));
/* Set the state of the current history array to STATE. */
-extern void history_set_history_state ();
+extern void history_set_history_state __P((HISTORY_STATE *));
/* Manage the history list. */
/* Place STRING at the end of the history list.
The associated data field (if any) is set to NULL. */
-extern void add_history ();
+extern void add_history __P((char *));
/* A reasonably useless function, only here for completeness. WHICH
is the magic number that tells us which element to delete. The
elements are numbered from 0. */
-extern HIST_ENTRY *remove_history ();
+extern HIST_ENTRY *remove_history __P((int));
/* Make the history entry at WHICH have LINE and DATA. This returns
the old entry so you can dispose of the data. In the case of an
invalid WHICH, a NULL pointer is returned. */
-extern HIST_ENTRY *replace_history_entry ();
+extern HIST_ENTRY *replace_history_entry __P((int, char *, histdata_t));
/* Clear the history list and start over. */
-extern void clear_history ();
+extern void clear_history __P((void));
/* Stifle the history list, remembering only MAX number of entries. */
-extern void stifle_history ();
+extern void stifle_history __P((int));
/* Stop stifling the history. This returns the previous amount the
history was stifled by. The value is positive if the history was
stifled, negative if it wasn't. */
-extern int unstifle_history ();
+extern int unstifle_history __P((void));
/* Return 1 if the history is stifled, 0 if it is not. */
-extern int history_is_stifled ();
+extern int history_is_stifled __P((void));
/* Information about the history list. */
/* Return a NULL terminated array of HIST_ENTRY which is the current input
history. Element 0 of this list is the beginning of time. If there
is no history, return NULL. */
-extern HIST_ENTRY **history_list ();
+extern HIST_ENTRY **history_list __P((void));
/* Returns the number which says what history element we are now
looking at. */
-extern int where_history ();
+extern int where_history __P((void));
/* Return the history entry at the current position, as determined by
history_offset. If there is no entry there, return a NULL pointer. */
-HIST_ENTRY *current_history ();
+HIST_ENTRY *current_history __P((void));
/* Return the history entry which is logically at OFFSET in the history
array. OFFSET is relative to history_base. */
-extern HIST_ENTRY *history_get ();
+extern HIST_ENTRY *history_get __P((int));
/* Return the number of bytes that the primary history entries are using.
This just adds up the lengths of the_history->lines. */
-extern int history_total_bytes ();
+extern int history_total_bytes __P((void));
/* Moving around the history list. */
/* Set the position in the history list to POS. */
-int history_set_pos ();
+int history_set_pos __P((int));
/* Back up history_offset to the previous history entry, and return
a pointer to that entry. If there is no previous entry, return
a NULL pointer. */
-extern HIST_ENTRY *previous_history ();
+extern HIST_ENTRY *previous_history __P((void));
/* Move history_offset forward to the next item in the input_history,
and return the a pointer to that entry. If there is no next entry,
return a NULL pointer. */
-extern HIST_ENTRY *next_history ();
+extern HIST_ENTRY *next_history __P((void));
/* Searching the history list. */
@@ -136,44 +152,45 @@ extern HIST_ENTRY *next_history ();
current_history () is the history entry, and the value of this function
is the offset in the line of that history entry that the string was
found in. Otherwise, nothing is changed, and a -1 is returned. */
-extern int history_search ();
+extern int history_search __P((char *, int));
/* Search the history for STRING, starting at history_offset.
- The search is anchored: matching lines must begin with string. */
-extern int history_search_prefix ();
+ The search is anchored: matching lines must begin with string.
+ DIRECTION is as in history_search(). */
+extern int history_search_prefix __P((char *, int));
/* Search for STRING in the history list, starting at POS, an
absolute index into the list. DIR, if negative, says to search
backwards from POS, else forwards.
Returns the absolute index of the history element where STRING
was found, or -1 otherwise. */
-extern int history_search_pos ();
+extern int history_search_pos __P((char *, int, int));
/* Managing the history file. */
/* Add the contents of FILENAME to the history list, a line at a time.
If FILENAME is NULL, then read from ~/.history. Returns 0 if
successful, or errno if not. */
-extern int read_history ();
+extern int read_history __P((char *));
/* Read a range of lines from FILENAME, adding them to the history list.
Start reading at the FROM'th line and end at the TO'th. If FROM
is zero, start at the beginning. If TO is less than FROM, read
until the end of the file. If FILENAME is NULL, then read from
~/.history. Returns 0 if successful, or errno if not. */
-extern int read_history_range ();
+extern int read_history_range __P((char *, int, int));
/* Write the current history to FILENAME. If FILENAME is NULL,
then write the history list to ~/.history. Values returned
are as in read_history (). */
-extern int write_history ();
+extern int write_history __P((char *));
/* Append NELEMENT entries to FILENAME. The entries appended are from
the end of the list minus NELEMENTs up to the end of the list. */
-int append_history ();
+int append_history __P((int, char *));
/* Truncate the history file, leaving only the last NLINES lines. */
-extern int history_truncate_file ();
+extern int history_truncate_file __P((char *, int));
/* History expansion. */
@@ -189,20 +206,24 @@ extern int history_truncate_file ();
If an error ocurred in expansion, then OUTPUT contains a descriptive
error message. */
-extern int history_expand ();
+extern int history_expand __P((char *, char **));
/* Extract a string segment consisting of the FIRST through LAST
arguments present in STRING. Arguments are broken up as in
the shell. */
-extern char *history_arg_extract ();
+extern char *history_arg_extract __P((int, int, char *));
/* Return the text of the history event beginning at the current
- offset into STRING. */
-extern char *get_history_event ();
+ offset into STRING. Pass STRING with *INDEX equal to the
+ history_expansion_char that begins this specification.
+ DELIMITING_QUOTE is a character that is allowed to end the string
+ specification for what to search for in addition to the normal
+ characters `:', ` ', `\t', `\n', and sometimes `?'. */
+extern char *get_history_event __P((char *, int *, int));
/* Return an array of tokens, much as the shell might. The tokens are
parsed out of STRING. */
-extern char **history_tokenize ();
+extern char **history_tokenize __P((char *));
/* Exported history variables. */
extern int history_base;
@@ -220,4 +241,8 @@ extern int history_quotes_inhibit_expansion;
application and not expanded. */
extern Function *history_inhibit_expansion_function;
+#ifdef __cplusplus
+}
+#endif
+
#endif /* !_HISTORY_H_ */
diff --git a/lib/readline/input.c b/lib/readline/input.c
index 7e3c0fe..3b48483 100644
--- a/lib/readline/input.c
+++ b/lib/readline/input.c
@@ -124,38 +124,13 @@ _rl_any_typein ()
return any_typein;
}
-/* Add KEY to the buffer of characters to be read. */
-int
-rl_stuff_char (key)
- int key;
-{
- if (key == EOF)
- {
- key = NEWLINE;
- rl_pending_input = EOF;
- }
- ibuffer[push_index++] = key;
- if (push_index >= ibuffer_len)
- push_index = 0;
- return push_index;
-}
-
-/* Make C be the next command to be executed. */
-int
-rl_execute_next (c)
- int c;
-{
- rl_pending_input = c;
- return 0;
-}
-
-/* Return the amount of space available in the
- buffer for stuffing characters. */
+/* Return the amount of space available in the buffer for stuffing
+ characters. */
static int
ibuffer_space ()
{
if (pop_index > push_index)
- return (pop_index - push_index);
+ return (pop_index - push_index - 1);
else
return (ibuffer_len - (push_index - pop_index));
}
@@ -341,6 +316,36 @@ _rl_insert_typein (c)
free (string);
}
+/* Add KEY to the buffer of characters to be read. Returns 1 if the
+ character was stuffed correctly; 0 otherwise. */
+int
+rl_stuff_char (key)
+ int key;
+{
+ if (ibuffer_space () == 0)
+ return 0;
+
+ if (key == EOF)
+ {
+ key = NEWLINE;
+ rl_pending_input = EOF;
+ }
+ ibuffer[push_index++] = key;
+ if (push_index >= ibuffer_len)
+ push_index = 0;
+
+ return 1;
+}
+
+/* Make C be the next command to be executed. */
+int
+rl_execute_next (c)
+ int c;
+{
+ rl_pending_input = c;
+ return 0;
+}
+
/* **************************************************************** */
/* */
/* Character Input */
@@ -409,6 +414,11 @@ rl_getc (stream)
if (result == 0)
return (EOF);
+#if defined (__BEOS__)
+ if (errno == EINTR)
+ continue;
+#endif
+
#if defined (EWOULDBLOCK)
if (errno == EWOULDBLOCK)
{
diff --git a/lib/readline/isearch.c b/lib/readline/isearch.c
index 7decf95..67279e1 100644
--- a/lib/readline/isearch.c
+++ b/lib/readline/isearch.c
@@ -48,6 +48,9 @@
#include "readline.h"
#include "history.h"
+/* Variables exported to other files in the readline library. */
+unsigned char *_rl_isearch_terminators = (unsigned char *)NULL;
+
/* Variables imported from other files in the readline library. */
extern Keymap _rl_keymap;
extern HIST_ENTRY *saved_line_for_history;
@@ -55,9 +58,6 @@ extern int rl_line_buffer_len;
extern int rl_point, rl_end;
extern char *rl_line_buffer;
-extern void _rl_save_prompt ();
-extern void _rl_restore_prompt ();
-
extern int rl_execute_next ();
extern void rl_extend_line_buffer ();
@@ -178,12 +178,20 @@ rl_search_history (direction, invoking_key)
/* Non-zero if we are doing a reverse search. */
int reverse;
+ /* The list of characters which terminate the search, but are not
+ subsequently executed. If the variable isearch-terminators has
+ been set, we use that value, otherwise we use ESC and C-J. */
+ unsigned char *isearch_terminators;
+
orig_point = rl_point;
last_found_line = orig_line = where_history ();
reverse = direction < 0;
hlist = history_list ();
allocated_line = (char *)NULL;
+ isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
+ : (unsigned char *)"\033\012";
+
/* Create an arrary of pointers to the lines that we want to search. */
maybe_replace_line ();
i = 0;
@@ -211,7 +219,7 @@ rl_search_history (direction, invoking_key)
/* The line where we start the search. */
i = orig_line;
- _rl_save_prompt ();
+ rl_save_prompt ();
/* Initialize search parameters. */
search_string = xmalloc (search_string_size = 128);
@@ -246,10 +254,18 @@ rl_search_history (direction, invoking_key)
c = !reverse ? -1 : -2;
}
+#if 0
/* Let NEWLINE (^J) terminate the search for people who don't like
using ESC. ^M can still be used to terminate the search and
immediately execute the command. */
if (c == ESC || c == NEWLINE)
+#else
+ /* The characters in isearch_terminators (set from the user-settable
+ variable isearch-terminators) are used to terminate the search but
+ not subsequently execute the character as a command. The default
+ value is "\033\012" (ESC and C-J). */
+ if (strchr (isearch_terminators, c))
+#endif
{
/* ESC still terminates the search, but if there is pending
input or if input arrives within 0.1 seconds (on systems
@@ -291,7 +307,7 @@ rl_search_history (direction, invoking_key)
strcpy (rl_line_buffer, lines[orig_line]);
rl_point = orig_point;
rl_end = strlen (rl_line_buffer);
- _rl_restore_prompt();
+ rl_restore_prompt();
rl_clear_message ();
if (allocated_line)
free (allocated_line);
@@ -409,15 +425,15 @@ rl_search_history (direction, invoking_key)
/* First put back the original state. */
strcpy (rl_line_buffer, lines[orig_line]);
- _rl_restore_prompt ();
+ rl_restore_prompt ();
/* Free the search string. */
free (search_string);
if (last_found_line < orig_line)
- rl_get_previous_history (orig_line - last_found_line);
+ rl_get_previous_history (orig_line - last_found_line, 0);
else
- rl_get_next_history (last_found_line - orig_line);
+ rl_get_next_history (last_found_line - orig_line, 0);
/* If the string was not found, put point at the end of the line. */
if (line_index < 0)
diff --git a/lib/readline/keymaps.c b/lib/readline/keymaps.c
index 9359749..c73666b 100644
--- a/lib/readline/keymaps.c
+++ b/lib/readline/keymaps.c
@@ -124,7 +124,7 @@ rl_make_keymap ()
/* Free the storage associated with MAP. */
void
rl_discard_keymap (map)
- Keymap (map);
+ Keymap map;
{
int i;
diff --git a/lib/readline/keymaps.h b/lib/readline/keymaps.h
index f6143f8..5dff46f 100644
--- a/lib/readline/keymaps.h
+++ b/lib/readline/keymaps.h
@@ -24,8 +24,10 @@
#define _KEYMAPS_H_
#if defined (READLINE_LIBRARY)
+# include "rlstdc.h"
# include "chardefs.h"
#else
+# include <readline/rlstdc.h>
# include <readline/chardefs.h>
#endif
@@ -70,26 +72,29 @@ extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
/* Return a new, empty keymap.
Free it with free() when you are done. */
-extern Keymap rl_make_bare_keymap ();
+extern Keymap rl_make_bare_keymap __P((void));
/* Return a new keymap which is a copy of MAP. */
-extern Keymap rl_copy_keymap ();
+extern Keymap rl_copy_keymap __P((Keymap));
/* Return a new keymap with the printing characters bound to rl_insert,
the lowercase Meta characters bound to run their equivalents, and
the Meta digits bound to produce numeric arguments. */
-extern Keymap rl_make_keymap ();
+extern Keymap rl_make_keymap __P((void));
-extern void rl_discard_keymap ();
+/* Free the storage associated with a keymap. */
+extern void rl_discard_keymap __P((Keymap));
+
+/* These functions actually appear in bind.c */
/* Return the keymap corresponding to a given name. Names look like
- `emacs' or `emacs-meta' or `vi-insert'. */
-extern Keymap rl_get_keymap_by_name ();
+ `emacs' or `emacs-meta' or `vi-insert'. */
+extern Keymap rl_get_keymap_by_name __P((char *));
/* Return the current keymap. */
-extern Keymap rl_get_keymap ();
+extern Keymap rl_get_keymap __P((void));
/* Set the current keymap to MAP. */
-extern void rl_set_keymap ();
+extern void rl_set_keymap __P((Keymap));
#endif /* _KEYMAPS_H_ */
diff --git a/lib/readline/kill.c b/lib/readline/kill.c
index a150e3c..0b4714f 100644
--- a/lib/readline/kill.c
+++ b/lib/readline/kill.c
@@ -572,6 +572,8 @@ rl_yank_last_arg (count, key)
static int explicit_arg_p = 0;
static int count_passed = 1;
static int direction = 1;
+ static int undo_needed = 0;
+ int retval;
if (rl_last_func != rl_yank_last_arg)
{
@@ -582,19 +584,22 @@ rl_yank_last_arg (count, key)
}
else
{
- rl_do_undo ();
+ if (undo_needed)
+ rl_do_undo ();
if (count < 1)
direction = -direction;
history_skip += direction;
if (history_skip < 0)
history_skip = 0;
- count_passed = count;
}
if (explicit_arg_p)
- return (rl_yank_nth_arg_internal (count, key, history_skip));
+ retval = rl_yank_nth_arg_internal (count_passed, key, history_skip);
else
- return (rl_yank_nth_arg_internal ('$', key, history_skip));
+ retval = rl_yank_nth_arg_internal ('$', key, history_skip);
+
+ undo_needed = retval == 0;
+ return retval;
}
/* A special paste command for users of Cygnus's cygwin32. */
diff --git a/lib/readline/parens.c b/lib/readline/parens.c
index 2c7251f..a500c0a 100644
--- a/lib/readline/parens.c
+++ b/lib/readline/parens.c
@@ -102,7 +102,7 @@ rl_insert_close (count, invoking_key)
FD_ZERO (&readfds);
FD_SET (fileno (rl_instream), &readfds);
timer.tv_sec = 0;
- timer.tv_usec = 500;
+ timer.tv_usec = 500000;
orig_point = rl_point;
rl_point = match_point;
diff --git a/lib/readline/posixjmp.h b/lib/readline/posixjmp.h
index 8703d17..1347cc0 100644
--- a/lib/readline/posixjmp.h
+++ b/lib/readline/posixjmp.h
@@ -9,10 +9,12 @@
#if defined (HAVE_POSIX_SIGSETJMP)
# define procenv_t sigjmp_buf
-# undef setjmp
-# define setjmp(x) sigsetjmp((x), 1)
-# undef longjmp
-# define longjmp(x, n) siglongjmp((x), (n))
+# if !defined (__OPENNT)
+# undef setjmp
+# define setjmp(x) sigsetjmp((x), 1)
+# undef longjmp
+# define longjmp(x, n) siglongjmp((x), (n))
+# endif /* !__OPENNT */
#else
# define procenv_t jmp_buf
#endif
diff --git a/lib/readline/readline.c b/lib/readline/readline.c
index 8ff6e98..622811f 100644
--- a/lib/readline/readline.c
+++ b/lib/readline/readline.c
@@ -64,7 +64,7 @@
#include "history.h"
#ifndef RL_LIBRARY_VERSION
-# define RL_LIBRARY_VERSION "2.2-bash"
+# define RL_LIBRARY_VERSION "4.0"
#endif
/* Evaluates its arguments multiple times. */
@@ -83,7 +83,6 @@ extern void _rl_output_character_function ();
#else
extern int _rl_output_character_function ();
#endif
-extern void _rl_get_screen_size ();
extern int _rl_enable_meta;
extern int _rl_term_autowrap;
@@ -100,7 +99,6 @@ extern int alphabetic ();
/* Functions imported from bind.c. */
extern void _rl_bind_if_unbound ();
-extern int rl_set_keymap_from_edit_mode ();
/* Functions imported from input.c. */
extern int _rl_any_typein ();
@@ -118,9 +116,7 @@ extern void _rl_move_vert ();
extern void _rl_update_final ();
extern void _rl_clear_to_eol ();
extern void _rl_clear_screen ();
-
-extern void _rl_save_prompt ();
-extern void _rl_restore_prompt ();
+extern void _rl_erase_entire_line ();
extern void _rl_erase_at_end_of_line ();
extern void _rl_move_cursor_relative ();
@@ -253,9 +249,14 @@ int rl_visible_prompt_length = 0;
int rl_key_sequence_length = 0;
/* If non-zero, then this is the address of a function to call just
- before readline_internal () prints the first prompt. */
+ before readline_internal_setup () prints the first prompt. */
Function *rl_startup_hook = (Function *)NULL;
+/* If non-zero, this is the address of a function to call just before
+ readline_internal_setup () returns and readline_internal starts
+ reading input characters. */
+Function *rl_pre_input_hook = (Function *)NULL;
+
/* What we use internally. You should always refer to RL_LINE_BUFFER. */
static char *the_line;
@@ -286,6 +287,9 @@ char *_rl_comment_begin;
/* Keymap holding the function currently being executed. */
Keymap rl_executing_keymap;
+/* Non-zero means to erase entire line, including prompt, on empty input lines. */
+int rl_erase_empty_line = 0;
+
/* Line buffer and maintenence. */
char *rl_line_buffer = (char *)NULL;
int rl_line_buffer_len = 0;
@@ -388,6 +392,9 @@ readline_internal_setup ()
rl_vi_insertion_mode (1, 0);
#endif /* VI_MODE */
}
+
+ if (rl_pre_input_hook)
+ (*rl_pre_input_hook) ();
}
STATIC_CALLBACK char *
@@ -405,7 +412,7 @@ readline_internal_teardown (eof)
{
temp = savestring (the_line);
rl_revert_line (1, 0);
- entry = replace_history_entry (where_history (), the_line, (HIST_ENTRY *)NULL);
+ entry = replace_history_entry (where_history (), the_line, (histdata_t)NULL);
_rl_free_history_entry (entry);
strcpy (the_line, temp);
@@ -488,6 +495,12 @@ readline_internal_charloop ()
if (rl_done == 0)
(*rl_redisplay_function) ();
+ /* If the application writer has told us to erase the entire line if
+ the only character typed was something bound to rl_newline, do so. */
+ if (rl_erase_empty_line && rl_done && rl_last_func == rl_newline &&
+ rl_point == 0 && rl_end == 0)
+ _rl_erase_entire_line ();
+
#if defined (READLINE_CALLBACKS)
return 0;
#else
@@ -501,7 +514,7 @@ readline_internal_charloop ()
static int
readline_internal_charloop ()
{
- int eof;
+ int eof = 1;
while (rl_done == 0)
eof = readline_internal_char ();
@@ -837,11 +850,19 @@ rl_digit_loop ()
{
int key, c, sawminus, sawdigits;
- _rl_save_prompt ();
+ rl_save_prompt ();
sawminus = sawdigits = 0;
while (1)
{
+ if (rl_numeric_arg > 1000000)
+ {
+ sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
+ ding ();
+ rl_restore_prompt ();
+ rl_clear_message ();
+ return 1;
+ }
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
key = c = rl_read_key ();
@@ -858,7 +879,7 @@ rl_digit_loop ()
else
{
key = rl_read_key ();
- _rl_restore_prompt ();
+ rl_restore_prompt ();
rl_clear_message ();
return (_rl_dispatch (key, _rl_keymap));
}
@@ -881,7 +902,7 @@ rl_digit_loop ()
/* Make M-- command equivalent to M--1 command. */
if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0)
rl_explicit_arg = 1;
- _rl_restore_prompt ();
+ rl_restore_prompt ();
rl_clear_message ();
return (_rl_dispatch (key, _rl_keymap));
}
@@ -1231,7 +1252,8 @@ rl_backward_word (count, key)
/* Clear the current line. Numeric argument to C-l does this. */
int
-rl_refresh_line ()
+rl_refresh_line (ignore1, ignore2)
+ int ignore1, ignore2;
{
int curr_line, nleft;
@@ -1278,7 +1300,7 @@ rl_clear_screen (count, key)
{
if (rl_explicit_arg)
{
- rl_refresh_line ();
+ rl_refresh_line (count, key);
return 0;
}
@@ -1428,6 +1450,11 @@ rl_newline (count, key)
}
#endif /* VI_MODE */
+ /* If we've been asked to erase empty lines, suppress the final update,
+ since _rl_update_final calls crlf(). */
+ if (rl_erase_empty_line && rl_point == 0 && rl_end == 0)
+ return 0;
+
if (readline_echoing_p)
_rl_update_final ();
return 0;
@@ -1507,9 +1534,22 @@ rl_delete (count, key)
}
else
return (rl_delete_text (rl_point, rl_point + 1));
-
}
+/* Delete the character under the cursor, unless the insertion
+ point is at the end of the line, in which case the character
+ behind the cursor is deleted. COUNT is obeyed and may be used
+ to delete forward or backward that many characters. */
+int
+rl_rubout_or_delete (count, key)
+ int count, key;
+{
+ if (rl_end != 0 && rl_point == rl_end)
+ return (rl_rubout (count, key));
+ else
+ return (rl_delete (count, key));
+}
+
/* Delete all spaces and tabs around point. */
int
rl_delete_horizontal_space (count, ignore)
@@ -1533,6 +1573,19 @@ rl_delete_horizontal_space (count, ignore)
return 0;
}
+/* Like the tcsh editing function delete-char-or-list. The eof character
+ is caught before this is invoked, so this really does the same thing as
+ delete-char-or-list-or-eof, as long as it's bound to the eof character. */
+int
+rl_delete_or_show_completions (count, key)
+ int count, key;
+{
+ if (rl_end != 0 && rl_point == rl_end)
+ return (rl_possible_completions (count, key));
+ else
+ return (rl_delete (count, key));
+}
+
#ifndef RL_COMMENT_BEGIN_DEFAULT
#define RL_COMMENT_BEGIN_DEFAULT "#"
#endif
@@ -1859,7 +1912,7 @@ maybe_replace_line ()
/* If the current line has changed, save the changes. */
if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
{
- temp = replace_history_entry (where_history (), the_line, rl_undo_list);
+ temp = replace_history_entry (where_history (), the_line, (histdata_t)rl_undo_list);
free (temp->line);
free (temp);
}
diff --git a/lib/readline/readline.h b/lib/readline/readline.h
index 280ec32..dba1a0f 100644
--- a/lib/readline/readline.h
+++ b/lib/readline/readline.h
@@ -23,10 +23,16 @@
#if !defined (_READLINE_H_)
#define _READLINE_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#if defined (READLINE_LIBRARY)
+# include "rlstdc.h"
# include "keymaps.h"
# include "tilde.h"
#else
+# include <readline/rlstdc.h>
# include <readline/keymaps.h>
# include <readline/tilde.h>
#endif
@@ -60,78 +66,191 @@ typedef struct _funmap {
extern FUNMAP **funmap;
-/* Functions available to bind to key sequences. */
-extern int
- rl_tilde_expand (), rl_set_mark (), rl_exchange_point_and_mark (),
- rl_beg_of_line (), rl_backward (), rl_delete (), rl_end_of_line (),
- rl_forward (), ding (), rl_newline (), rl_kill_line (),
- rl_copy_region_to_kill (), rl_kill_region (), rl_char_search (),
- rl_clear_screen (), rl_get_next_history (), rl_get_previous_history (),
- rl_quoted_insert (), rl_reverse_search_history (), rl_transpose_chars (),
- rl_unix_line_discard (), rl_unix_word_rubout (),
- rl_yank (), rl_rubout (), rl_backward_word (), rl_kill_word (),
- rl_forward_word (), rl_tab_insert (), rl_yank_pop (), rl_yank_nth_arg (),
- rl_backward_kill_word (), rl_backward_kill_line (), rl_transpose_words (),
- rl_complete (), rl_possible_completions (), rl_insert_completions (),
- rl_menu_complete (),
- rl_do_lowercase_version (), rl_kill_full_line (),
- rl_digit_argument (), rl_universal_argument (), rl_abort (),
- rl_undo_command (), rl_revert_line (), rl_beginning_of_history (),
- rl_end_of_history (), rl_forward_search_history (), rl_insert (),
- rl_upcase_word (), rl_downcase_word (), rl_capitalize_word (),
- rl_restart_output (), rl_re_read_init_file (),
- rl_dump_functions (), rl_dump_variables (), rl_dump_macros (),
- rl_delete_horizontal_space (), rl_history_search_forward (),
- rl_history_search_backward (), rl_tty_status (), rl_yank_last_arg (),
- rl_insert_comment (), rl_backward_char_search (),
- rl_copy_forward_word (), rl_copy_backward_word ();
-
-/* Not available unless readline is compiled -DPAREN_MATCHING. */
-extern int rl_insert_close ();
-
-/* Not available unless READLINE_CALLBACKS is defined. */
-extern void rl_callback_handler_install ();
-extern void rl_callback_read_char ();
-extern void rl_callback_handler_remove ();
+/* **************************************************************** */
+/* */
+/* Functions available to bind to key sequences */
+/* */
+/* **************************************************************** */
+/* Bindable commands for numeric arguments. */
+extern int rl_digit_argument __P((int, int));
+extern int rl_universal_argument __P((int, int));
+
+/* Bindable commands for moving the cursor. */
+extern int rl_forward __P((int, int));
+extern int rl_backward __P((int, int));
+extern int rl_beg_of_line __P((int, int));
+extern int rl_end_of_line __P((int, int));
+extern int rl_forward_word __P((int, int));
+extern int rl_backward_word __P((int, int));
+extern int rl_refresh_line __P((int, int));
+extern int rl_clear_screen __P((int, int));
+extern int rl_arrow_keys __P((int, int));
+
+/* Bindable commands for inserting and deleting text. */
+extern int rl_insert __P((int, int));
+extern int rl_quoted_insert __P((int, int));
+extern int rl_tab_insert __P((int, int));
+extern int rl_newline __P((int, int));
+extern int rl_do_lowercase_version __P((int, int));
+extern int rl_rubout __P((int, int));
+extern int rl_delete __P((int, int));
+extern int rl_rubout_or_delete __P((int, int));
+extern int rl_delete_horizontal_space __P((int, int));
+extern int rl_delete_or_show_completions __P((int, int));
+extern int rl_insert_comment __P((int, int));
+
+/* Bindable commands for changing case. */
+extern int rl_upcase_word __P((int, int));
+extern int rl_downcase_word __P((int, int));
+extern int rl_capitalize_word __P((int, int));
+
+/* Bindable commands for transposing characters and words. */
+extern int rl_transpose_words __P((int, int));
+extern int rl_transpose_chars __P((int, int));
+
+/* Bindable commands for searching within a line. */
+extern int rl_char_search __P((int, int));
+extern int rl_backward_char_search __P((int, int));
+
+/* Bindable commands for readline's interface to the command history. */
+extern int rl_beginning_of_history __P((int, int));
+extern int rl_end_of_history __P((int, int));
+extern int rl_get_next_history __P((int, int));
+extern int rl_get_previous_history __P((int, int));
+
+/* Bindable commands for managing the mark and region. */
+extern int rl_set_mark __P((int, int));
+extern int rl_exchange_point_and_mark __P((int, int));
+
+/* Bindable commands to set the editing mode (emacs or vi). */
+extern int rl_vi_editing_mode __P((int, int));
+extern int rl_emacs_editing_mode __P((int, int));
+
+/* Bindable commands for managing key bindings. */
+extern int rl_re_read_init_file __P((int, int));
+extern int rl_dump_functions __P((int, int));
+extern int rl_dump_macros __P((int, int));
+extern int rl_dump_variables __P((int, int));
+
+/* Bindable commands for word completion. */
+extern int rl_complete __P((int, int));
+extern int rl_possible_completions __P((int, int));
+extern int rl_insert_completions __P((int, int));
+extern int rl_menu_complete __P((int, int));
+
+/* Bindable commands for killing and yanking text, and managing the kill ring. */
+extern int rl_kill_word __P((int, int));
+extern int rl_backward_kill_word __P((int, int));
+extern int rl_kill_line __P((int, int));
+extern int rl_backward_kill_line __P((int, int));
+extern int rl_kill_full_line __P((int, int));
+extern int rl_unix_word_rubout __P((int, int));
+extern int rl_unix_line_discard __P((int, int));
+extern int rl_copy_region_to_kill __P((int, int));
+extern int rl_kill_region __P((int, int));
+extern int rl_copy_forward_word __P((int, int));
+extern int rl_copy_backward_word __P((int, int));
+extern int rl_yank __P((int, int));
+extern int rl_yank_pop __P((int, int));
+extern int rl_yank_nth_arg __P((int, int));
+extern int rl_yank_last_arg __P((int, int));
/* Not available unless __CYGWIN32__ is defined. */
#ifdef __CYGWIN32__
-extern int rl_paste_from_clipboard ();
+extern int rl_paste_from_clipboard __P((int, int));
#endif
-/* These are *both* defined even when VI_MODE is not. */
-extern int rl_vi_editing_mode (), rl_emacs_editing_mode ();
+/* Bindable commands for incremental searching. */
+extern int rl_reverse_search_history __P((int, int));
+extern int rl_forward_search_history __P((int, int));
+
+/* Bindable keyboard macro commands. */
+extern int rl_start_kbd_macro __P((int, int));
+extern int rl_end_kbd_macro __P((int, int));
+extern int rl_call_last_kbd_macro __P((int, int));
+
+/* Bindable undo commands. */
+extern int rl_revert_line __P((int, int));
+extern int rl_undo_command __P((int, int));
+
+/* Bindable tilde expansion commands. */
+extern int rl_tilde_expand __P((int, int));
+
+/* Bindable terminal control commands. */
+extern int rl_restart_output __P((int, int));
+extern int rl_stop_output __P((int, int));
+
+/* Miscellaneous bindable commands. */
+extern int rl_abort __P((int, int));
+extern int rl_tty_status __P((int, int));
+
+/* Bindable commands for incremental and non-incremental history searching. */
+extern int rl_history_search_forward __P((int, int));
+extern int rl_history_search_backward __P((int, int));
+extern int rl_noninc_forward_search __P((int, int));
+extern int rl_noninc_reverse_search __P((int, int));
+extern int rl_noninc_forward_search_again __P((int, int));
+extern int rl_noninc_reverse_search_again __P((int, int));
+
+/* Not available unless readline is compiled -DPAREN_MATCHING. */
+extern int rl_insert_close __P((int, int));
-/* Non incremental history searching. */
-extern int rl_noninc_forward_search ();
-extern int rl_noninc_reverse_search ();
-extern int rl_noninc_forward_search_again ();
-extern int rl_noninc_reverse_search_again ();
+/* Not available unless READLINE_CALLBACKS is defined. */
+extern void rl_callback_handler_install __P((char *, VFunction *));
+extern void rl_callback_read_char __P((void));
+extern void rl_callback_handler_remove __P((void));
/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
-extern int rl_vi_check ();
-extern int
- rl_vi_undo (), rl_vi_redo (), rl_vi_tilde_expand (),
- rl_vi_movement_mode (), rl_vi_insertion_mode (), rl_vi_arg_digit (),
- rl_vi_prev_word (), rl_vi_next_word (), rl_vi_char_search (),
- rl_vi_eof_maybe (), rl_vi_append_mode (), rl_vi_put (),
- rl_vi_append_eol (), rl_vi_insert_beg (), rl_vi_delete (),
- rl_vi_first_print (), rl_vi_fword (), rl_vi_fWord (), rl_vi_bword (),
- rl_vi_bWord (), rl_vi_eword (), rl_vi_eWord (), rl_vi_end_word (),
- rl_vi_change_case (), rl_vi_match (), rl_vi_bracktype (),
- rl_vi_change_char (), rl_vi_yank_arg (), rl_vi_search (),
- rl_vi_search_again (), rl_vi_subst (), rl_vi_overstrike (),
- rl_vi_overstrike_delete (), rl_vi_replace(), rl_vi_column (),
- rl_vi_delete_to (), rl_vi_change_to (), rl_vi_yank_to (),
- rl_vi_complete (), rl_vi_fetch_history (), rl_vi_set_mark (),
- rl_vi_goto_mark (), rl_vi_back_to_indent ();
-
-/* Keyboard macro commands. */
-extern int rl_start_kbd_macro (), rl_end_kbd_macro ();
-extern int rl_call_last_kbd_macro ();
-extern void rl_push_macro_input ();
-
-extern int rl_arrow_keys(), rl_refresh_line ();
+/* VI-mode bindable commands. */
+extern int rl_vi_redo __P((int, int));
+extern int rl_vi_undo __P((int, int));
+extern int rl_vi_yank_arg __P((int, int));
+extern int rl_vi_fetch_history __P((int, int));
+extern int rl_vi_search_again __P((int, int));
+extern int rl_vi_search __P((int, int));
+extern int rl_vi_complete __P((int, int));
+extern int rl_vi_tilde_expand __P((int, int));
+extern int rl_vi_prev_word __P((int, int));
+extern int rl_vi_next_word __P((int, int));
+extern int rl_vi_end_word __P((int, int));
+extern int rl_vi_insert_beg __P((int, int));
+extern int rl_vi_append_mode __P((int, int));
+extern int rl_vi_append_eol __P((int, int));
+extern int rl_vi_eof_maybe __P((int, int));
+extern int rl_vi_insertion_mode __P((int, int));
+extern int rl_vi_movement_mode __P((int, int));
+extern int rl_vi_arg_digit __P((int, int));
+extern int rl_vi_change_case __P((int, int));
+extern int rl_vi_put __P((int, int));
+extern int rl_vi_column __P((int, int));
+extern int rl_vi_delete_to __P((int, int));
+extern int rl_vi_change_to __P((int, int));
+extern int rl_vi_yank_to __P((int, int));
+extern int rl_vi_delete __P((int, int));
+extern int rl_vi_back_to_indent __P((int, int));
+extern int rl_vi_first_print __P((int, int));
+extern int rl_vi_char_search __P((int, int));
+extern int rl_vi_match __P((int, int));
+extern int rl_vi_change_char __P((int, int));
+extern int rl_vi_subst __P((int, int));
+extern int rl_vi_overstrike __P((int, int));
+extern int rl_vi_overstrike_delete __P((int, int));
+extern int rl_vi_replace __P((int, int));
+extern int rl_vi_set_mark __P((int, int));
+extern int rl_vi_goto_mark __P((int, int));
+
+/* VI-mode utility functions. */
+extern int rl_vi_check __P((void));
+extern int rl_vi_domove __P((int, int *));
+extern int rl_vi_bracktype __P((int));
+
+/* VI-mode pseudo-bindable commands, used as utility functions. */
+extern int rl_vi_fWord __P((int, int));
+extern int rl_vi_bWord __P((int, int));
+extern int rl_vi_eWord __P((int, int));
+extern int rl_vi_fword __P((int, int));
+extern int rl_vi_bword __P((int, int));
+extern int rl_vi_eword __P((int, int));
/* **************************************************************** */
/* */
@@ -141,57 +260,80 @@ extern int rl_arrow_keys(), rl_refresh_line ();
/* Readline functions. */
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
-extern char *readline ();
-
-/* These functions are from bind.c. */
-/* rl_add_defun (char *name, Function *function, int key)
- Add NAME to the list of named functions. Make FUNCTION
- be the function that gets called.
- If KEY is not -1, then bind it. */
-extern int rl_add_defun ();
-
-extern Keymap rl_make_bare_keymap ();
-extern Keymap rl_copy_keymap ();
-extern Keymap rl_make_keymap ();
-extern void rl_discard_keymap ();
-extern Keymap rl_get_keymap (), rl_get_keymap_by_name ();
-extern void rl_set_keymap ();
-extern char *rl_get_keymap_name ();
-
-extern int rl_bind_key (), rl_bind_key_in_map ();
-extern int rl_unbind_key (), rl_unbind_key_in_map ();
-extern int rl_unbind_function_in_map (), rl_unbind_command_in_map ();
-extern int rl_set_key ();
-extern int rl_generic_bind ();
-extern int rl_parse_and_bind ();
-/* Backwards compatibility, use rl_generic_bind instead. */
-extern int rl_macro_bind (), rl_variable_bind ();
+extern char *readline __P((char *));
-extern int rl_read_init_file ();
+extern int rl_initialize __P((void));
-extern Function *rl_named_function (), *rl_function_of_keyseq ();
-extern char **rl_invoking_keyseqs (), **rl_invoking_keyseqs_in_map ();
-extern void rl_function_dumper ();
-extern void rl_variable_dumper ();
-extern void rl_macro_dumper ();
-extern void rl_list_funmap_names ();
+extern int rl_discard_argument __P((void));
-/* Undocumented in the texinfo manual; not really useful to programs. */
-extern int rl_translate_keyseq ();
-extern void rl_initialize_funmap ();
+/* Utility functions to bind keys to readline commands. */
+extern int rl_add_defun __P((char *, Function *, int));
+extern int rl_bind_key __P((int, Function *));
+extern int rl_bind_key_in_map __P((int, Function *, Keymap));
+extern int rl_unbind_key __P((int));
+extern int rl_unbind_key_in_map __P((int, Keymap));
+extern int rl_unbind_function_in_map __P((Function *, Keymap));
+extern int rl_unbind_command_in_map __P((char *, Keymap));
+extern int rl_set_key __P((char *, Function *, Keymap));
+extern int rl_generic_bind __P((int, char *, char *, Keymap));
+extern int rl_variable_bind __P((char *, char *));
-/* Functions for undoing. */
-extern int rl_begin_undo_group (), rl_end_undo_group ();
-extern void rl_add_undo (), free_undo_list ();
-extern int rl_do_undo ();
-extern int rl_modifying ();
+/* Backwards compatibility, use rl_generic_bind instead. */
+extern int rl_macro_bind __P((char *, char *, Keymap));
+
+/* Undocumented in the texinfo manual; not really useful to programs. */
+extern int rl_translate_keyseq __P((char *, char *, int *));
+extern char *rl_untranslate_keyseq __P((int));
+
+extern Function *rl_named_function __P((char *));
+extern Function *rl_function_of_keyseq __P((char *, Keymap, int *));
+
+extern void rl_list_funmap_names __P((void));
+extern char **rl_invoking_keyseqs_in_map __P((Function *, Keymap));
+extern char **rl_invoking_keyseqs __P((Function *));
+
+extern void rl_function_dumper __P((int));
+extern void rl_macro_dumper __P((int));
+extern void rl_variable_dumper __P((int));
+
+extern int rl_read_init_file __P((char *));
+extern int rl_parse_and_bind __P((char *));
+
+/* Functions for manipulating keymaps. */
+extern Keymap rl_make_bare_keymap __P((void));
+extern Keymap rl_copy_keymap __P((Keymap));
+extern Keymap rl_make_keymap __P((void));
+extern void rl_discard_keymap __P((Keymap));
+
+extern Keymap rl_get_keymap_by_name __P((char *));
+extern char *rl_get_keymap_name __P((Keymap));
+extern void rl_set_keymap __P((Keymap));
+extern Keymap rl_get_keymap __P((void));
+extern void rl_set_keymap_from_edit_mode __P((void));
+extern char *rl_get_keymap_name_from_edit_mode __P((void));
+
+/* Functions for manipulating the funmap, which maps command names to functions. */
+extern int rl_add_funmap_entry __P((char *, Function *));
+extern void rl_initialize_funmap __P((void));
+extern char **rl_funmap_names __P((void));
+
+/* Utility functions for managing keyboard macros. */
+extern void rl_push_macro_input __P((char *));
+
+/* Functions for undoing, from undo.c */
+extern void rl_add_undo __P((enum undo_code, int, int, char *));
+extern void free_undo_list __P((void));
+extern int rl_do_undo __P((void));
+extern int rl_begin_undo_group __P((void));
+extern int rl_end_undo_group __P((void));
+extern int rl_modifying __P((int, int));
/* Functions for redisplay. */
-extern void rl_redisplay ();
-extern int rl_forced_update_display ();
-extern int rl_clear_message ();
-extern int rl_reset_line_state ();
-extern int rl_on_new_line ();
+extern void rl_redisplay __P((void));
+extern int rl_on_new_line __P((void));
+extern int rl_forced_update_display __P((void));
+extern int rl_clear_message __P((void));
+extern int rl_reset_line_state __P((void));
#if defined (__STDC__) && defined (USE_VARARGS) && defined (PREFER_STDARG)
extern int rl_message (const char *, ...);
@@ -200,36 +342,59 @@ extern int rl_message ();
#endif
/* Undocumented in texinfo manual. */
-extern int rl_character_len ();
-extern int rl_show_char ();
-extern int crlf ();
-
-/* Modifying text. */
-extern int rl_insert_text (), rl_delete_text ();
-extern int rl_kill_text ();
-extern char *rl_copy_text ();
-
-/* `Public' utility functions. */
-extern int rl_reset_terminal ();
-extern int rl_stuff_char ();
-extern int rl_read_key (), rl_getc ();
+extern int rl_show_char __P((int));
+extern int rl_character_len __P((int, int));
+extern int crlf __P((void));
-extern int rl_initialize ();
+/* Save and restore internal prompt redisplay information. */
+extern void rl_save_prompt __P((void));
+extern void rl_restore_prompt __P((void));
+/* Modifying text. */
+extern int rl_insert_text __P((char *));
+extern int rl_delete_text __P((int, int));
+extern int rl_kill_text __P((int, int));
+extern char *rl_copy_text __P((int, int));
+
+/* Terminal and tty mode management. */
+extern void rl_prep_terminal __P((int));
+extern void rl_deprep_terminal __P((void));
+extern void rltty_set_default_bindings __P((Keymap));
+
+extern int rl_reset_terminal __P((char *));
+extern void rl_resize_terminal __P((void));
+
+/* `Public' utility functions . */
+extern void rl_extend_line_buffer __P((int));
+extern int ding __P((void));
+
+/* Functions for character input. */
+extern int rl_stuff_char __P((int));
+extern int rl_execute_next __P((int));
+extern int rl_read_key __P((void));
+extern int rl_getc __P((FILE *));
+
+/* Readline signal handling, from signals.c */
+extern int rl_set_signals __P((void));
+extern int rl_clear_signals __P((void));
+extern void rl_cleanup_after_signal __P((void));
+extern void rl_reset_after_signal __P((void));
+extern void rl_free_line_state __P((void));
+
/* Undocumented. */
-extern int rl_expand_prompt ();
-extern int rl_set_signals (), rl_clear_signals ();
-extern int maybe_save_line (), maybe_unsave_line (), maybe_replace_line ();
+extern int rl_expand_prompt __P((char *));
+
+extern int maybe_save_line __P((void));
+extern int maybe_unsave_line __P((void));
+extern int maybe_replace_line __P((void));
/* Completion functions. */
-/* These functions are from complete.c. */
-extern int rl_complete_internal ();
+extern int rl_complete_internal __P((int));
+extern void rl_display_match_list __P((char **, int, int));
-/* Return an array of strings which are the result of repeatadly calling
- FUNC with TEXT. */
-extern char **completion_matches ();
-extern char *username_completion_function ();
-extern char *filename_completion_function ();
+extern char **completion_matches __P((char *, CPFunction *));
+extern char *username_completion_function __P((char *, int));
+extern char *filename_completion_function __P((char *, int));
/* **************************************************************** */
/* */
@@ -254,10 +419,14 @@ extern char *rl_line_buffer;
/* The location of point, and end. */
extern int rl_point, rl_end;
+/* The mark, or saved cursor position. */
extern int rl_mark;
+/* Flag to indicate that readline has finished with the current input
+ line and should return it. */
extern int rl_done;
+/* If set to a character value, that will be the next keystroke read. */
extern int rl_pending_input;
/* Non-zero if we called this function from _rl_dispatch(). It's present
@@ -275,6 +444,11 @@ extern FILE *rl_instream, *rl_outstream;
before readline_internal () prints the first prompt. */
extern Function *rl_startup_hook;
+/* If non-zero, this is the address of a function to call just before
+ readline_internal_setup () returns and readline_internal starts
+ reading input characters. */
+extern Function *rl_pre_input_hook;
+
/* The address of a function to call periodically while Readline is
awaiting character input, or NULL, for no event handling. */
extern Function *rl_event_hook;
@@ -288,6 +462,24 @@ extern VFunction *rl_deprep_term_function;
extern Keymap rl_executing_keymap;
extern Keymap rl_binding_keymap;
+/* Display variables. */
+/* If non-zero, readline will erase the entire line, including any prompt,
+ if the only thing typed on an otherwise-blank line is something bound to
+ rl_newline. */
+extern int rl_erase_empty_line;
+
+/* Variables to control readline signal handling. */
+/* If non-zero, readline will install its own signal handlers for
+ SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
+extern int rl_catch_signals;
+
+/* If non-zero, readline will install a signal handler for SIGWINCH
+ that also attempts to call any calling application's SIGWINCH signal
+ handler. Note that the terminal is not cleaned up before the
+ application's signal handler is called; use rl_cleanup_after_signal()
+ to do that. */
+extern int rl_catch_sigwinch;
+
/* Completion variables. */
/* Pointer to the generator function for completion_matches ().
NULL means to use filename_entry_function (), the default filename
@@ -346,6 +538,15 @@ extern Function *rl_directory_completion_hook;
/* Backwards compatibility with previous versions of readline. */
#define rl_symbolic_link_hook rl_directory_completion_hook
+/* If non-zero, then this is the address of a function to call when
+ completing a word would normally display the list of possible matches.
+ This function is called instead of actually doing the display.
+ It takes three arguments: (char **matches, int num_matches, int max_length)
+ where MATCHES is the array of strings that matched, NUM_MATCHES is the
+ number of strings in that array, and MAX_LENGTH is the length of the
+ longest string in that array. */
+extern VFunction *rl_completion_display_matches_hook;
+
/* Non-zero means that the results of the matches are to be treated
as filenames. This is ALWAYS zero on entry, and can only be changed
within a completion entry finder function. */
@@ -413,4 +614,8 @@ extern int rl_inhibit_completion;
extern char *savestring (); /* XXX backwards compatibility */
#endif
+#ifdef __cplusplus
+}
+#endif
+
#endif /* _READLINE_H_ */
diff --git a/lib/readline/rlconf.h b/lib/readline/rlconf.h
index 8f07db1..1356fd8 100644
--- a/lib/readline/rlconf.h
+++ b/lib/readline/rlconf.h
@@ -56,8 +56,6 @@
/* Define this if you want code that allows readline to be used in an
X `callback' style. */
-#if !defined (SHELL)
-# define READLINE_CALLBACKS
-#endif
+#define READLINE_CALLBACKS
#endif /* _RLCONF_H_ */
diff --git a/lib/readline/rlstdc.h b/lib/readline/rlstdc.h
new file mode 100644
index 0000000..f1590c6
--- /dev/null
+++ b/lib/readline/rlstdc.h
@@ -0,0 +1,79 @@
+/* stdc.h -- macros to make source compile on both ANSI C and K&R C
+ compilers. */
+
+/* Copyright (C) 1993 Free Software Foundation, Inc.
+
+ This file is part of GNU Bash, the Bourne Again SHell.
+
+ Bash is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 1, or (at your option)
+ any later version.
+
+ Bash is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Bash; see the file COPYING. If not, write to the Free
+ Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+#if !defined (_STDC_H_)
+#define _STDC_H_
+
+/* Adapted from BSD /usr/include/sys/cdefs.h. */
+
+/* A function can be defined using prototypes and compile on both ANSI C
+ and traditional C compilers with something like this:
+ extern char *func __P((char *, char *, int)); */
+
+#if defined (__STDC__)
+
+# if !defined (__P)
+# define __P(protos) protos
+# endif
+# define __STRING(x) #x
+
+# if !defined (__GNUC__)
+# define inline
+# endif
+
+#else /* !__STDC__ */
+
+# if !defined (__P)
+# define __P(protos) ()
+# endif
+# define __STRING(x) "x"
+
+#if defined (__GNUC__) /* gcc with -traditional */
+# if !defined (const)
+# define const __const
+# endif
+# if !defined (inline)
+# define inline __inline
+# endif
+# if !defined (signed)
+# define signed __signed
+# endif
+# if !defined (volatile)
+# define volatile __volatile
+# endif
+#else /* !__GNUC__ */
+# if !defined (const)
+# define const
+# endif
+# if !defined (inline)
+# define inline
+# endif
+# if !defined (signed)
+# define signed
+# endif
+# if !defined (volatile)
+# define volatile
+# endif
+#endif /* !__GNUC__ */
+
+#endif /* !__STDC__ */
+
+#endif /* !_STDC_H_ */
diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c
index 8312963..a5ef938 100644
--- a/lib/readline/rltty.c
+++ b/lib/readline/rltty.c
@@ -37,9 +37,9 @@
#include "rldefs.h"
-#if !defined (SHELL) && defined (GWINSZ_IN_SYS_IOCTL)
+#if defined (GWINSZ_IN_SYS_IOCTL)
# include <sys/ioctl.h>
-#endif /* !SHELL && GWINSZ_IN_SYS_IOCTL */
+#endif /* GWINSZ_IN_SYS_IOCTL */
#include "rltty.h"
#include "readline.h"
@@ -144,7 +144,7 @@ static int terminal_prepped;
static int ksrflow;
#endif
-#if !defined (SHELL) && defined (TIOCGWINSZ)
+#if defined (TIOCGWINSZ)
/* Dummy call to force a backgrounded readline to stop before it tries
to get the tty settings. */
static void
@@ -156,9 +156,7 @@ set_winsize (tty)
if (ioctl (tty, TIOCGWINSZ, &w) == 0)
(void) ioctl (tty, TIOCSWINSZ, &w);
}
-#else /* SHELL || !TIOCGWINSZ */
-# define set_winsize(tty)
-#endif /* SHELL || !TIOCGWINSZ */
+#endif /* TIOCGWINSZ */
#if defined (NEW_TTY_DRIVER)
@@ -389,6 +387,7 @@ get_tty_settings (tty, tiop)
TIOTYPE *tiop;
{
int ioctl_ret;
+
set_winsize (tty);
while (1)
diff --git a/lib/readline/savestring.c b/lib/readline/savestring.c
new file mode 100644
index 0000000..3f53a87
--- /dev/null
+++ b/lib/readline/savestring.c
@@ -0,0 +1,33 @@
+/* savestring.c */
+
+/* Copyright (C) 1998 Free Software Foundation, Inc.
+
+ This file is part of the GNU Readline Library, a library for
+ reading lines of text with interactive input and history editing.
+
+ The GNU Readline Library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU General Public License
+ as published by the Free Software Foundation; either version 1, or
+ (at your option) any later version.
+
+ The GNU Readline Library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ The GNU General Public License is often shipped with GNU software, and
+ is generally kept in a file called COPYING or LICENSE. If you do not
+ have a copy of the license, write to the Free Software Foundation,
+ 675 Mass Ave, Cambridge, MA 02139, USA. */
+
+extern char *strcpy ();
+extern char *xmalloc ();
+
+/* Backwards compatibility, now that savestring has been removed from
+ all `public' readline header files. */
+char *
+savestring (s)
+ char *s;
+{
+ return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s)));
+}
diff --git a/lib/readline/search.c b/lib/readline/search.c
index 3024ee5..6c76e1a 100644
--- a/lib/readline/search.c
+++ b/lib/readline/search.c
@@ -61,7 +61,6 @@ extern Function *rl_last_func;
/* Functions imported from the rest of the library. */
extern int _rl_free_history_entry ();
extern char *_rl_make_prompt_for_search ();
-extern void _rl_restore_prompt ();
extern void rl_extend_line_buffer ();
static char *noninc_search_string = (char *) NULL;
@@ -172,7 +171,7 @@ noninc_search (dir, pchar)
rl_message (p, 0, 0);
free (p);
-#define SEARCH_RETURN _rl_restore_prompt (); return
+#define SEARCH_RETURN rl_restore_prompt (); return
/* Read the search string. */
while (c = rl_read_key ())
@@ -241,7 +240,7 @@ noninc_search (dir, pchar)
noninc_search_string = savestring (rl_line_buffer);
}
- _rl_restore_prompt ();
+ rl_restore_prompt ();
noninc_dosearch (noninc_search_string, dir);
}
diff --git a/lib/readline/shell.c b/lib/readline/shell.c
index 553f3c1..091ec08 100644
--- a/lib/readline/shell.c
+++ b/lib/readline/shell.c
@@ -26,10 +26,9 @@
# include <config.h>
#endif
+#include <sys/types.h>
+
#if defined (HAVE_UNISTD_H)
-# ifdef _MINIX
-# include <sys/types.h>
-# endif
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
@@ -45,22 +44,16 @@
# include <strings.h>
#endif /* !HAVE_STRING_H */
-extern char *xmalloc (), *xrealloc ();
+#include <pwd.h>
-#if !defined (SHELL)
+#if !defined (HAVE_GETPW_DECLS)
+extern struct passwd *getpwuid ();
+#endif /* !HAVE_GETPW_DECLS */
-#ifdef savestring
-#undef savestring
-#endif
+extern char *xmalloc ();
-/* Backwards compatibility, now that savestring has been removed from
- all `public' readline header files. */
-char *
-savestring (s)
- char *s;
-{
- return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s)));
-}
+/* All of these functions are resolved from bash if we are linking readline
+ as part of bash. */
/* Does shell-like quoting using single quotes. */
char *
@@ -126,13 +119,15 @@ get_env_value (varname)
return ((char *)getenv (varname));
}
-#else /* SHELL */
-extern char *get_string_value ();
-
char *
-get_env_value (varname)
- char *varname;
+get_home_dir ()
{
- return get_string_value (varname);
-}
-#endif /* SHELL */
+ char *home_dir;
+ struct passwd *entry;
+
+ home_dir = (char *)NULL;
+ entry = getpwuid (getuid ());
+ if (entry)
+ home_dir = entry->pw_dir;
+ return (home_dir);
+}
diff --git a/lib/readline/signals.c b/lib/readline/signals.c
index e19c22d..3a34432 100644
--- a/lib/readline/signals.c
+++ b/lib/readline/signals.c
@@ -49,18 +49,6 @@
#include "readline.h"
#include "history.h"
-extern int readline_echoing_p;
-extern int rl_pending_input;
-extern int _rl_meta_flag;
-
-extern void free_undo_list ();
-extern void _rl_get_screen_size ();
-extern void _rl_redisplay_after_sigwinch ();
-extern void _rl_clean_up_for_exit ();
-extern void _rl_kill_kbd_macro ();
-extern void _rl_init_argument ();
-extern void rl_deprep_terminal (), rl_prep_terminal ();
-
#if !defined (RETSIGTYPE)
# if defined (VOID_SIGHANDLER)
# define RETSIGTYPE void
@@ -79,40 +67,52 @@ extern void rl_deprep_terminal (), rl_prep_terminal ();
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
typedef RETSIGTYPE SigHandler ();
+extern int readline_echoing_p;
+extern int rl_pending_input;
+extern int _rl_meta_flag;
+
+extern void free_undo_list ();
+extern void _rl_get_screen_size ();
+extern void _rl_redisplay_after_sigwinch ();
+extern void _rl_clean_up_for_exit ();
+extern void _rl_kill_kbd_macro ();
+extern void _rl_init_argument ();
+extern void rl_deprep_terminal (), rl_prep_terminal ();
+
static SigHandler *rl_set_sighandler ();
+/* Exported variables for use by applications. */
+
+/* If non-zero, readline will install its own signal handlers for
+ SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
+int rl_catch_signals = 1;
+
+/* If non-zero, readline will install a signal handler for SIGWINCH. */
+#ifdef SIGWINCH
+int rl_catch_sigwinch = 1;
+#endif
+
+static int signals_set_flag;
+static int sigwinch_set_flag;
+
/* **************************************************************** */
/* */
/* Signal Handling */
/* */
/* **************************************************************** */
-/* If we're not being compiled as part of bash, initialize handlers for
- and catch the job control signals (SIGTTIN, SIGTTOU, SIGTSTP) and
- SIGTERM. */
-#if !defined (SHELL)
-# define HANDLE_JOB_SIGNALS
-# define HANDLE_SIGTERM
-#endif /* !SHELL */
-
#if defined (HAVE_POSIX_SIGNALS)
typedef struct sigaction sighandler_cxt;
# define rl_sigaction(s, nh, oh) sigaction(s, nh, oh)
#else
-typedef struct { SigHandler *sa_handler; } sighandler_cxt;
+typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt;
# define sigemptyset(m)
#endif /* !HAVE_POSIX_SIGNALS */
-static sighandler_cxt old_int, old_alrm;
-
-#if defined (HANDLE_JOB_SIGNALS)
+static sighandler_cxt old_int, old_term, old_alrm, old_quit;
+#if defined (SIGTSTP)
static sighandler_cxt old_tstp, old_ttou, old_ttin;
-#endif /* HANDLE_JOB_SIGNALS */
-
-#if defined (HANDLE_SIGTERM)
-static sighandler_cxt old_term;
#endif
-
#if defined (SIGWINCH)
static sighandler_cxt old_winch;
#endif
@@ -143,18 +143,8 @@ rl_signal_handler (sig)
switch (sig)
{
case SIGINT:
- {
- register HIST_ENTRY *entry;
-
- free_undo_list ();
-
- entry = current_history ();
- if (entry)
- entry->data = (char *)NULL;
- }
- _rl_kill_kbd_macro ();
- rl_clear_message ();
- _rl_init_argument ();
+ rl_free_line_state ();
+ /* FALLTHROUGH */
#if defined (SIGTSTP)
case SIGTSTP:
@@ -163,10 +153,8 @@ rl_signal_handler (sig)
#endif /* SIGTSTP */
case SIGALRM:
case SIGTERM:
- _rl_clean_up_for_exit ();
- (*rl_deprep_term_function) ();
- rl_clear_signals ();
- rl_pending_input = 0;
+ case SIGQUIT:
+ rl_cleanup_after_signal ();
#if defined (HAVE_POSIX_SIGNALS)
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
@@ -188,8 +176,7 @@ rl_signal_handler (sig)
# endif /* HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
- (*rl_prep_term_function) (_rl_meta_flag);
- rl_set_signals ();
+ rl_reset_after_signal ();
}
SIGHANDLER_RETURN;
@@ -197,7 +184,7 @@ rl_signal_handler (sig)
#if defined (SIGWINCH)
static RETSIGTYPE
-rl_handle_sigwinch (sig)
+rl_sigwinch_handler (sig)
int sig;
{
SigHandler *oh;
@@ -209,14 +196,10 @@ rl_handle_sigwinch (sig)
disposition set by the calling application. We need this state
because we call the application's SIGWINCH handler after updating
our own idea of the screen size. */
- rl_set_sighandler (SIGWINCH, rl_handle_sigwinch, &dummy_winch);
+ rl_set_sighandler (SIGWINCH, rl_sigwinch_handler, &dummy_winch);
#endif
- if (readline_echoing_p)
- {
- _rl_get_screen_size (fileno (rl_instream), 1);
- _rl_redisplay_after_sigwinch ();
- }
+ rl_resize_terminal ();
/* If another sigwinch handler has been installed, call it. */
oh = (SigHandler *)old_winch.sa_handler;
@@ -263,62 +246,66 @@ rl_set_sighandler (sig, handler, ohandler)
return (ohandler->sa_handler);
}
-int
-rl_set_signals ()
+static void
+rl_maybe_set_sighandler (sig, handler, ohandler)
+ int sig;
+ SigHandler *handler;
+ sighandler_cxt *ohandler;
{
sighandler_cxt dummy;
SigHandler *oh;
-#if defined (HAVE_POSIX_SIGNALS)
sigemptyset (&dummy.sa_mask);
-#endif
-
- oh = rl_set_sighandler (SIGINT, rl_signal_handler, &old_int);
+ oh = rl_set_sighandler (sig, handler, ohandler);
if (oh == (SigHandler *)SIG_IGN)
- rl_sigaction (SIGINT, &old_int, &dummy);
+ rl_sigaction (sig, ohandler, &dummy);
+}
- oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
- if (oh == (SigHandler *)SIG_IGN)
- rl_sigaction (SIGALRM, &old_alrm, &dummy);
+int
+rl_set_signals ()
+{
+ sighandler_cxt dummy;
+ SigHandler *oh;
+
+ if (rl_catch_signals && signals_set_flag == 0)
+ {
+ rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int);
+ rl_maybe_set_sighandler (SIGTERM, rl_signal_handler, &old_term);
+ rl_maybe_set_sighandler (SIGQUIT, rl_signal_handler, &old_quit);
+
+ oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
+ if (oh == (SigHandler *)SIG_IGN)
+ rl_sigaction (SIGALRM, &old_alrm, &dummy);
#if defined (HAVE_POSIX_SIGNALS) && defined (SA_RESTART)
- /* If the application using readline has already installed a signal
- handler with SA_RESTART, SIGALRM will cause reads to be restarted
- automatically, so readline should just get out of the way. Since
- we tested for SIG_IGN above, we can just test for SIG_DFL here. */
- if (oh != (SigHandler *)SIG_DFL && (old_alrm.sa_flags & SA_RESTART))
- rl_sigaction (SIGALRM, &old_alrm, &dummy);
+ /* If the application using readline has already installed a signal
+ handler with SA_RESTART, SIGALRM will cause reads to be restarted
+ automatically, so readline should just get out of the way. Since
+ we tested for SIG_IGN above, we can just test for SIG_DFL here. */
+ if (oh != (SigHandler *)SIG_DFL && (old_alrm.sa_flags & SA_RESTART))
+ rl_sigaction (SIGALRM, &old_alrm, &dummy);
#endif /* HAVE_POSIX_SIGNALS */
-#if defined (HANDLE_JOB_SIGNALS)
-
#if defined (SIGTSTP)
- oh = rl_set_sighandler (SIGTSTP, rl_signal_handler, &old_tstp);
- if (oh == (SigHandler *)SIG_IGN)
- rl_sigaction (SIGTSTP, &old_tstp, &dummy);
-#else
- oh = (SigHandler *)NULL;
+ rl_maybe_set_sighandler (SIGTSTP, rl_signal_handler, &old_tstp);
#endif /* SIGTSTP */
#if defined (SIGTTOU)
- rl_set_sighandler (SIGTTOU, rl_signal_handler, &old_ttou);
- rl_set_sighandler (SIGTTIN, rl_signal_handler, &old_ttin);
-
- if (oh == (SigHandler *)SIG_IGN)
- {
- rl_set_sighandler (SIGTTOU, SIG_IGN, &dummy);
- rl_set_sighandler (SIGTTIN, SIG_IGN, &dummy);
- }
+ rl_maybe_set_sighandler (SIGTTOU, rl_signal_handler, &old_ttou);
#endif /* SIGTTOU */
-#endif /* HANDLE_JOB_SIGNALS */
+#if defined (SIGTTIN)
+ rl_maybe_set_sighandler (SIGTTIN, rl_signal_handler, &old_ttin);
+#endif /* SIGTTIN */
-#if defined (HANDLE_SIGTERM)
- /* Handle SIGTERM if we're not being compiled as part of bash. */
- rl_set_sighandler (SIGTERM, rl_signal_handler, &old_term);
-#endif /* HANDLE_SIGTERM */
+ signals_set_flag = 1;
+ }
#if defined (SIGWINCH)
- rl_set_sighandler (SIGWINCH, rl_handle_sigwinch, &old_winch);
+ if (rl_catch_sigwinch && sigwinch_set_flag == 0)
+ {
+ rl_maybe_set_sighandler (SIGWINCH, rl_sigwinch_handler, &old_winch);
+ sigwinch_set_flag = 1;
+ }
#endif /* SIGWINCH */
return 0;
@@ -329,35 +316,79 @@ rl_clear_signals ()
{
sighandler_cxt dummy;
-#if defined (HAVE_POSIX_SIGNALS)
- sigemptyset (&dummy.sa_mask);
-#endif
-
- rl_sigaction (SIGINT, &old_int, &dummy);
- rl_sigaction (SIGALRM, &old_alrm, &dummy);
+ if (rl_catch_signals && signals_set_flag == 1)
+ {
+ sigemptyset (&dummy.sa_mask);
-#if defined (HANDLE_JOB_SIGNALS)
+ rl_sigaction (SIGINT, &old_int, &dummy);
+ rl_sigaction (SIGTERM, &old_term, &dummy);
+ rl_sigaction (SIGQUIT, &old_quit, &dummy);
+ rl_sigaction (SIGALRM, &old_alrm, &dummy);
#if defined (SIGTSTP)
- rl_sigaction (SIGTSTP, &old_tstp, &dummy);
-#endif
+ rl_sigaction (SIGTSTP, &old_tstp, &dummy);
+#endif /* SIGTSTP */
#if defined (SIGTTOU)
- rl_sigaction (SIGTTOU, &old_ttou, &dummy);
- rl_sigaction (SIGTTIN, &old_ttin, &dummy);
+ rl_sigaction (SIGTTOU, &old_ttou, &dummy);
#endif /* SIGTTOU */
-#endif /* HANDLE_JOB_SIGNALS */
+#if defined (SIGTTIN)
+ rl_sigaction (SIGTTIN, &old_ttin, &dummy);
+#endif /* SIGTTIN */
-#if defined (HANDLE_SIGTERM)
- rl_sigaction (SIGTERM, &old_term, &dummy);
-#endif /* HANDLE_SIGTERM */
+ signals_set_flag = 0;
+ }
#if defined (SIGWINCH)
- sigemptyset (&dummy.sa_mask);
- rl_sigaction (SIGWINCH, &old_winch, &dummy);
+ if (rl_catch_sigwinch && sigwinch_set_flag == 1)
+ {
+ sigemptyset (&dummy.sa_mask);
+ rl_sigaction (SIGWINCH, &old_winch, &dummy);
+ sigwinch_set_flag = 0;
+ }
#endif
return 0;
}
+
+/* Clean up the terminal and readline state after catching a signal, before
+ resending it to the calling application. */
+void
+rl_cleanup_after_signal ()
+{
+ _rl_clean_up_for_exit ();
+ (*rl_deprep_term_function) ();
+ rl_clear_signals ();
+ rl_pending_input = 0;
+}
+
+/* Reset the terminal and readline state after a signal handler returns. */
+void
+rl_reset_after_signal ()
+{
+ (*rl_prep_term_function) (_rl_meta_flag);
+ rl_set_signals ();
+}
+
+/* Free up the readline variable line state for the current line (undo list,
+ any partial history entry, any keyboard macros in progress, and any
+ numeric arguments in process) after catching a signal, before calling
+ rl_cleanup_after_signal(). */
+void
+rl_free_line_state ()
+{
+ register HIST_ENTRY *entry;
+
+ free_undo_list ();
+
+ entry = current_history ();
+ if (entry)
+ entry->data = (char *)NULL;
+
+ _rl_kill_kbd_macro ();
+ rl_clear_message ();
+ _rl_init_argument ();
+}
+
#endif /* HANDLE_SIGNALS */
diff --git a/lib/readline/terminal.c b/lib/readline/terminal.c
index c286696..c22ec51 100644
--- a/lib/readline/terminal.c
+++ b/lib/readline/terminal.c
@@ -232,6 +232,16 @@ _rl_set_screen_size (rows, cols)
screenchars = screenwidth * screenheight;
}
+void
+rl_resize_terminal ()
+{
+ if (readline_echoing_p)
+ {
+ _rl_get_screen_size (fileno (rl_instream), 1);
+ _rl_redisplay_after_sigwinch ();
+ }
+}
+
struct _tc_string {
char *tc_var;
char **tc_value;
diff --git a/lib/readline/tilde.c b/lib/readline/tilde.c
index 3741f97..d1853bd 100644
--- a/lib/readline/tilde.c
+++ b/lib/readline/tilde.c
@@ -47,10 +47,6 @@
#include "tilde.h"
-#ifdef SHELL
-#include "shell.h"
-#endif
-
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid (), *getpwnam ();
#endif /* !HAVE_GETPW_DECLS */
@@ -77,6 +73,12 @@ static char *xmalloc (), *xrealloc ();
extern char *xmalloc (), *xrealloc ();
#endif /* TEST || STATIC_MALLOC */
+/* If being compiled as part of bash, these will be satisfied from
+ variables.o. If being compiled as part of readline, they will
+ be satisfied from shell.o. */
+extern char *get_home_dir ();
+extern char *get_env_value ();
+
/* The default value of tilde_additional_prefixes. This is set to
whitespace preceding a tilde so that simple programs which do not
perform any word separation get desired behaviour. */
@@ -171,15 +173,6 @@ tilde_find_suffix (string)
return (i);
}
-#if !defined (SHELL)
-static char *
-get_string_value (varname)
- char *varname;
-{
- return ((char *)getenv (varname));
-}
-#endif
-
/* Return a new string which is the result of tilde expanding STRING. */
char *
tilde_expand (string)
@@ -284,27 +277,6 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
return ret;
}
-static char *
-get_home_dir ()
-{
- char *home_dir;
-
-#ifdef SHELL
- home_dir = (char *)NULL;
- if (current_user.home_dir == 0)
- get_current_user_info ();
- home_dir = current_user.home_dir;
-#else
- struct passwd *entry;
-
- home_dir = (char *)NULL;
- entry = getpwuid (getuid ());
- if (entry)
- home_dir = entry->pw_dir;
-#endif
- return (home_dir);
-}
-
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
tilde. If there is no expansion, call tilde_expansion_failure_hook.
This always returns a newly-allocated string, never static storage. */
@@ -328,7 +300,7 @@ tilde_expand_word (filename)
if (filename[1] == '\0' || filename[1] == '/')
{
/* Prefix $HOME to the rest of the string. */
- expansion = get_string_value ("HOME");
+ expansion = get_env_value ("HOME");
/* If there is no HOME variable, look up the directory in
the password database. */
diff --git a/lib/readline/util.c b/lib/readline/util.c
index fde012e..1dc3b66 100644
--- a/lib/readline/util.c
+++ b/lib/readline/util.c
@@ -64,6 +64,7 @@ extern int _rl_defining_kbd_macro;
extern char *_rl_executing_macro;
/* Pseudo-global functions imported from other library files. */
+extern void _rl_replace_text ();
extern void _rl_pop_executing_macro ();
extern void _rl_set_the_line ();
extern void _rl_init_argument ();
@@ -124,7 +125,7 @@ rl_tty_status (count, key)
{
#if defined (TIOCSTAT)
ioctl (1, TIOCSTAT, (char *)0);
- rl_refresh_line ();
+ rl_refresh_line (count, key);
#else
ding ();
#endif
diff --git a/lib/readline/vi_mode.c b/lib/readline/vi_mode.c
index 2f62ec3..d4868bf 100644
--- a/lib/readline/vi_mode.c
+++ b/lib/readline/vi_mode.c
@@ -77,7 +77,7 @@
extern char *xmalloc (), *xrealloc ();
/* Variables imported from readline.c */
-extern int rl_point, rl_end, rl_mark, rl_done;
+extern int rl_point, rl_end, rl_mark;
extern FILE *rl_instream;
extern int rl_line_buffer_len, rl_explicit_arg, rl_numeric_arg;
extern Keymap _rl_keymap;
@@ -352,9 +352,9 @@ rl_vi_prev_word (count, key)
}
if (_rl_uppercase_p (key))
- rl_vi_bWord (count);
+ rl_vi_bWord (count, key);
else
- rl_vi_bword (count);
+ rl_vi_bword (count, key);
return (0);
}
@@ -374,9 +374,9 @@ rl_vi_next_word (count, key)
}
if (_rl_uppercase_p (key))
- rl_vi_fWord (count);
+ rl_vi_fWord (count, key);
else
- rl_vi_fword (count);
+ rl_vi_fword (count, key);
return (0);
}
@@ -392,16 +392,16 @@ rl_vi_end_word (count, key)
}
if (_rl_uppercase_p (key))
- rl_vi_eWord (count);
+ rl_vi_eWord (count, key);
else
- rl_vi_eword (count);
+ rl_vi_eword (count, key);
return (0);
}
/* Move forward a word the way that 'W' does. */
int
-rl_vi_fWord (count)
- int count;
+rl_vi_fWord (count, ignore)
+ int count, ignore;
{
while (count-- && rl_point < (rl_end - 1))
{
@@ -417,8 +417,8 @@ rl_vi_fWord (count)
}
int
-rl_vi_bWord (count)
- int count;
+rl_vi_bWord (count, ignore)
+ int count, ignore;
{
while (count-- && rl_point > 0)
{
@@ -441,8 +441,8 @@ rl_vi_bWord (count)
}
int
-rl_vi_eWord (count)
- int count;
+rl_vi_eWord (count, ignore)
+ int count, ignore;
{
while (count-- && rl_point < (rl_end - 1))
{
@@ -471,8 +471,8 @@ rl_vi_eWord (count)
}
int
-rl_vi_fword (count)
- int count;
+rl_vi_fword (count, ignore)
+ int count, ignore;
{
while (count-- && rl_point < (rl_end - 1))
{
@@ -497,8 +497,8 @@ rl_vi_fword (count)
}
int
-rl_vi_bword (count)
- int count;
+rl_vi_bword (count, ignore)
+ int count, ignore;
{
while (count-- && rl_point > 0)
{
@@ -536,8 +536,8 @@ rl_vi_bword (count)
}
int
-rl_vi_eword (count)
- int count;
+rl_vi_eword (count, ignore)
+ int count, ignore;
{
while (count-- && rl_point < rl_end - 1)
{
@@ -729,7 +729,7 @@ rl_vi_put (count, key)
if (!_rl_uppercase_p (key) && (rl_point + 1 <= rl_end))
rl_point++;
- rl_yank ();
+ rl_yank (1, key);
rl_backward (1, key);
return (0);
}