This commit was generated by cvs2svn to compensate for changes in r75406,

which included commits to RCS files with non-trunk default branches.
This commit is contained in:
Andrey A. Chernov 2001-04-11 02:33:07 +00:00
commit 3be056262b
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=75407
67 changed files with 5571 additions and 2570 deletions

View File

@ -337,3 +337,129 @@ doc/Makefile.in
configure.in
- changed LIBVERSION to 4.1-beta5
3/17/2000
---------
[readline-4.1 released]
3/23
----
Makefile.in
- remove the `-t' argument to ranlib in the install recipe; some
ranlibs don't have it and attempt to create a file named `-t'
3/27
----
support/shlib-install
- install shared libraries unwritable by anyone on HP-UX
- changed symlinks to relative pathnames on all platforms
shlib/Makefile.in
- added missing `includedir' assignment, substituted by configure
Makefile.in
- added missing @SET_MAKE@ so configure can set $MAKE appropriately
configure.in
- add call to AC_PROG_MAKE_SET
8/30
----
shlib/Makefile.in
- change the soname bound into the shared libraries, so it includes
only the major version number. If it includes the minor version,
programs depending on it must be rebuilt (which may or may not be
a bad thing)
9/6
---
examples/rlfe.c
- add -l option to log input and output (-a option appends to logfile)
- add -n option to set readline application name
- add -v, -h options for version and help information
- change a few things because getopt() is now used to parse arguments
9/12
----
support/shlib-install
- fix up the libname on HPUX 11
10/18
-----
configure.in
- changed library version to 4.2-alpha
10/30
-----
configure.in
- add -fsigned-char to LOCAL_CFLAGS for Linux running on the IBM
S/390
Makefile.in
- added new file, rltypedefs.h, installed by default with `make install'
11/2
----
compat.c
- new file, with backwards-compatibility function definitions
Makefile.in,shlib/Makefile.in
- make sure that compat.o/compat.so are built and linked apppropriately
support/shobj-conf
- picked up bash version, which means that shared libs built on
linux and BSD/OS 4.x will have an soname that does not include
the minor version number
11/13
-----
examples/rlfe.c
- rlfe can perform filename completion for relative pathnames in the
inferior process's context if the OS supports /proc/PID/cwd (linux
does it OK, Solaris is slightly warped, none of the BSDs have it)
11/17/2000
----------
[readline-4.2-alpha released]
11/27
-----
Makefile.in,shlib/Makefile.in
- added dependencies for rltypedefs.h
shlib/Makefile.in
- changed dependencies on histlib.h to $(topdir)/histlib.h
1/22
----
configure.in
- changed release version to 4.2-beta
2/2
---
examples/Makefile.in
- build histexamp as part of the examples
2/5
---
doc/Makefile.in
- don't remove the dvi, postscript, html, info, and text `objects'
on a `make distclean', only on a `make maintainer-clean'
3/6
---
doc/history.{0,3}, doc/history_3.ps
- new manual page for history library
doc/Makefile.in
- rules to install and uninstall history.3 in ${man3dir}
- rules to build history.0 and history_3.ps
4/2
---
configure.in
- changed LIBVERSION to `4.2'
4/5
---
[readline-4.2 frozen]

View File

@ -1,3 +1,156 @@
This document details the changes between this version, readline-4.2,
and the previous version, readline-4.1.
1. Changes to Readline
a. When setting the terminal attributes on systems using `struct termio',
readline waits for output to drain before changing the attributes.
b. A fix was made to the history word tokenization code to avoid attempts to
dereference a null pointer.
c. Readline now defaults rl_terminal_name to $TERM if the calling application
has left it unset, and tries to initialize with the resultant value.
d. Instead of calling (*rl_getc_function)() directly to get input in certain
places, readline now calls rl_read_key() consistently.
e. Fixed a bug in the completion code that allowed a backslash to quote a
single quote inside a single-quoted string.
f. rl_prompt is no longer assigned directly from the argument to readline(),
but uses memory allocated by readline. This allows constant strings to
be passed to readline without problems arising when the prompt processing
code wants to modify the string.
g. Fixed a bug that caused non-interactive history searches to return the
wrong line when performing multiple searches backward for the same string.
h. Many variables, function arguments, and function return values are now
declared `const' where appropriate, to improve behavior when linking with
C++ code.
i. The control character detection code now works better on systems where
`char' is unsigned by default.
j. The vi-mode numeric argument is now capped at 999999, just like emacs mode.
k. The Function, CPFunction, CPPFunction, and VFunction typedefs have been
replaced with a set of specific prototyped typedefs, though they are
still in the readline header files for backwards compatibility.
m. Nearly all of the (undocumented) internal global variables in the library
now have an _rl_ prefix -- there were a number that did not, like
screenheight, screenwidth, alphabetic, etc.
n. The ding() convenience function has been renamed to rl_ding(), though the
old function is still defined for backwards compatibility.
o. The completion convenience functions filename_completion_function,
username_completion_function, and completion_matches now have an rl_
prefix, though the old names are still defined for backwards compatibility.
p. The functions shared by readline and bash (linkage is satisfied from bash
when compiling with bash, and internally otherwise) now have an sh_ prefix.
q. Changed the shared library creation procedure on Linux and BSD/OS 4.x so
that the `soname' contains only the major version number rather than the
major and minor numbers.
r. Fixed a redisplay bug that occurred when the prompt spanned more than one
physical line and contained invisible characters.
s. Added a missing `includedir' variable to the Makefile.
t. When installing the shared libraries, make sure symbolic links are relative.
u. Added configure test so that it can set `${MAKE}' appropriately.
v. Fixed a bug in rl_forward that could cause the point to be set to before
the beginning of the line in vi mode.
w. Fixed a bug in the callback read-char interface to make it work when a
readline function pushes some input onto the input stream with
rl_execute_next (like the incremental search functions).
x. Fixed a file descriptor leak in the history file manipulation code that
was tripped when attempting to truncate a non-regular file (like
/dev/null).
y. Changes to make all of the exported readline functions declared in
readline.h have an rl_ prefix (rltty_set_default_bindings is now
rl_tty_set_default_bindings, crlf is now rl_crlf, etc.)
z. The formatted documentation included in the base readline distribution
is no longer removed on a `make distclean'.
aa. Some changes were made to avoid gcc warnings with -Wall.
bb. rl_get_keymap_by_name now finds keymaps case-insensitively, so
`set keymap EMACS' works.
cc. The history file writing and truncation functions now return a useful
status on error.
dd. Fixed a bug that could cause applications to dereference a NULL pointer
if a NULL second argument was passed to history_expand().
ee. If a hook function assigned to rl_event_hook sets rl_done to a non-zero
value, rl_read_key() now immediately returns '\n' (which is assumed to
be bound to accept-line).
2. New Features in Readline
a. The blink timeout for paren matching is now settable by applications,
via the rl_set_paren_blink_timeout() function.
b. _rl_executing_macro has been renamed to rl_executing_macro, which means
it's now part of the public interface.
c. Readline has a new variable, rl_readline_state, which is a bitmap that
encapsulates the current state of the library; intended for use by
callbacks and hook functions.
d. rlfe has a new -l option to log input and output (-a appends to logfile),
a new -n option to set the readline application name, and -v and -h
options for version and help information.
e. rlfe can now perform filename completion for the inferior process if the
OS has a /proc/<PID>/cwd that can be read with readlink(2) to get the
inferior's current working directory.
f. A new file, rltypedefs.h, contains the new typedefs for function pointers
and is installed by `make install'.
g. New application-callable function rl_set_prompt(const char *prompt):
expands its prompt string argument and sets rl_prompt to the result.
h. New application-callable function rl_set_screen_size(int rows, int cols):
public method for applications to set readline's idea of the screen
dimensions.
i. The history example program (examples/histexamp.c) is now built as one
of the examples.
j. The documentation has been updated to cover nearly all of the public
functions and variables declared in readline.h.
k. New function, rl_get_screen_size (int *rows, int *columns), returns
readline's idea of the screen dimensions.
l. The timeout in rl_gather_tyi (readline keyboard input polling function)
is now settable via a function (rl_set_keyboard_input_timeout()).
m. Renamed the max_input_history variable to history_max_entries; the old
variable is maintained for backwards compatibility.
n. The list of characters that separate words for the history tokenizer is
now settable with a variable: history_word_delimiters. The default
value is as before.
o. There is a new history.3 manual page documenting the history library.
-------------------------------------------------------------------------------
This document details the changes between this version, readline-4.1,
and the previous version, readline-4.0.

View File

@ -32,11 +32,13 @@ rlprivate.h f
rlshell.h f
rlstdc.h f
rltty.h f
rltypedefs.h f
rlwinsize.h f
tcap.h f
tilde.h f
xmalloc.h f
bind.c f
compat.c f
complete.c f
display.c f
emacs_keymap.c f
@ -85,6 +87,7 @@ doc/hist.texinfo f
doc/hstech.texinfo f
doc/hsuser.texinfo f
doc/readline.3 f
doc/history.3 f
doc/texi2dvi f
doc/texi2html f
examples/Makefile.in f
@ -111,3 +114,6 @@ doc/readline.html f
doc/history.html f
doc/rluserman.html f
doc/readline.0 f
doc/history.0 f
doc/readline_3.ps f
doc/history_3.ps f

View File

@ -35,6 +35,7 @@ RM = rm -f
CP = cp
MV = mv
@SET_MAKE@
SHELL = @MAKE_SHELL@
prefix = @prefix@
@ -65,7 +66,14 @@ TERMCAP_LIB = @TERMCAP_LIB@
# For libraries which include headers from other libraries.
INCLUDES = -I. -I$(srcdir) -I$(includedir)
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES) $(LOCAL_CFLAGS) $(CFLAGS)
XCCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES)
CCFLAGS = $(XCCFLAGS) $(LOCAL_CFLAGS) $(CFLAGS)
# could add -Werror here
GCC_LINT_FLAGS = -ansi -Wall -Wshadow -Wpointer-arith -Wcast-qual \
-Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wno-implicit
GCC_LINT_CFLAGS = $(XCCFLAGS) $(GCC_LINT_FLAGS) @CFLAGS@ @LOCAL_CFLAGS@
.c.o:
${RM} $@
@ -85,19 +93,21 @@ 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)/savestring.c $(srcdir)/tilde.c
$(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \
$(srcdir)/compat.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 rlstdc.h xmalloc.h rlprivate.h rlshell.h
ansi_stdlib.h tcap.h rlstdc.h xmalloc.h rlprivate.h rlshell.h \
rltypedefs.h
HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.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 \
util.o kill.o undo.o macro.o input.o callback.o terminal.o \
nls.o xmalloc.o $(HISTOBJ) $(TILDEOBJ)
nls.o compat.o xmalloc.o $(HISTOBJ) $(TILDEOBJ)
# The texinfo files which document this library.
DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo
@ -111,7 +121,7 @@ CREATED_CONFIGURE = config.status config.h config.cache config.log \
CREATED_TAGS = TAGS tags
INSTALLED_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h \
rlstdc.h rlconf.h
rlstdc.h rlconf.h rltypedefs.h
##########################################################################
@ -134,6 +144,9 @@ libhistory.a: $(HISTOBJ) xmalloc.o
readline: $(OBJECTS) readline.h rldefs.h chardefs.h ./libreadline.a
$(CC) $(CCFLAGS) -o $@ ./examples/rl.c ./libreadline.a ${TERMCAP_LIB}
lint: force
$(MAKE) $(MFLAGS) CCFLAGS='$(GCC_LINT_CFLAGS)' static
Makefile makefile: config.status $(srcdir)/Makefile.in
CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
@ -183,10 +196,10 @@ maybe-uninstall-headers: uninstall-headers
install: installdirs $(STATIC_LIBS) install-headers
-$(MV) $(libdir)/libreadline.a $(libdir)/libreadline.old
$(INSTALL_DATA) libreadline.a $(libdir)/libreadline.a
-test -n "$(RANLIB)" && $(RANLIB) -t $(libdir)/libreadline.a
-test -n "$(RANLIB)" && $(RANLIB) $(libdir)/libreadline.a
-$(MV) $(libdir)/libhistory.a $(libdir)/libhistory.old
$(INSTALL_DATA) libhistory.a $(libdir)/libhistory.a
-test -n "$(RANLIB)" && $(RANLIB) -t $(libdir)/libhistory.a
-test -n "$(RANLIB)" && $(RANLIB) $(libdir)/libhistory.a
-( if test -d doc ; then \
cd doc && \
${MAKE} ${MFLAGS} infodir=$(infodir) $@; \
@ -253,90 +266,91 @@ dist: force
# Dependencies
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 rlstdc.h
bind.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
bind.o: history.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 rlstdc.h
callback.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
compat.o: 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 rlstdc.h
complete.o: readline.h keymaps.h rltypedefs.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: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
display.o: history.h rlstdc.h
funmap.o: readline.h keymaps.h chardefs.h tilde.h
funmap.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.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 rlstdc.h
histexpand.o: history.h histlib.h rlstdc.h rltypedefs.h
histexpand.o: ${BUILD_DIR}/config.h
histfile.o: ansi_stdlib.h
histfile.o: history.h histlib.h rlstdc.h
histfile.o: history.h histlib.h rlstdc.h rltypedefs.h
histfile.o: ${BUILD_DIR}/config.h
history.o: ansi_stdlib.h
history.o: history.h histlib.h rlstdc.h
history.o: history.h histlib.h rlstdc.h rltypedefs.h
history.o: ${BUILD_DIR}/config.h
histsearch.o: ansi_stdlib.h
histsearch.o: history.h histlib.h rlstdc.h
histsearch.o: history.h histlib.h rlstdc.h rltypedefs.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 rlstdc.h
input.o: readline.h keymaps.h rltypedefs.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: readline.h keymaps.h rltypedefs.h chardefs.h tilde.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: keymaps.h rltypedefs.h chardefs.h rlconf.h ansi_stdlib.h
keymaps.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.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: readline.h keymaps.h rltypedefs.h chardefs.h tilde.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: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
macro.o: history.h rlstdc.h
nls.o: ansi_stdlib.h
nls.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
nls.o: readline.h keymaps.h chardefs.h tilde.h
nls.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
nls.o: history.h rlstdc.h
parens.o: rlconf.h
parens.o: ${BUILD_DIR}/config.h
parens.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
readline.o: readline.h keymaps.h chardefs.h tilde.h
parens.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
readline.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
readline.o: rldefs.h ${BUILD_DIR}/config.h rlconf.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 rlstdc.h
rltty.o: readline.h keymaps.h rltypedefs.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: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
search.o: ansi_stdlib.h history.h rlstdc.h
shell.o: ${BUILD_DIR}/config.h
shell.o: 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: readline.h keymaps.h rltypedefs.h chardefs.h tilde.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: readline.h keymaps.h rltypedefs.h chardefs.h tilde.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: readline.h keymaps.h rltypedefs.h chardefs.h tilde.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 rlstdc.h
util.o: readline.h keymaps.h rltypedefs.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: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
vi_mode.o: history.h ansi_stdlib.h rlstdc.h
xmalloc.o: ${BUILD_DIR}/config.h
xmalloc.o: ansi_stdlib.h
@ -396,6 +410,7 @@ keymaps.o: $(srcdir)/keymaps.c
parens.o: $(srcdir)/parens.c
search.o: $(srcdir)/search.c
rltty.o: $(srcdir)/rltty.c
compat.o: $(srcdir)/compat.c
complete.o: $(srcdir)/complete.c
bind.o: $(srcdir)/bind.c
isearch.o: $(srcdir)/isearch.c
@ -425,6 +440,7 @@ keymaps.o: keymaps.c
parens.o: parens.c
search.o: search.c
rltty.o: rltty.c
compat.o: compat.c
complete.o: complete.c
bind.o: bind.c
isearch.o: isearch.c

View File

@ -1,7 +1,7 @@
Introduction
============
This is the Gnu Readline library, version 4.1.
This is the Gnu Readline library, version 4.2.
The Readline library provides a set of functions for use by applications
that allow users to edit command lines as they are typed in. Both
@ -37,6 +37,9 @@ to customize and control the build process.
The file rlconf.h contains C preprocessor defines that enable and disable
certain Readline features.
The special make target `everything' will build the static and shared
libraries (if the target platform supports them) and the examples.
Examples
========
@ -64,8 +67,8 @@ your platform.
If you need to update support/shobj-conf, you will need to create
a `stanza' for your operating system and compiler. The script uses
the value of host_os and ${CC} as determined by configure. For
instance, FreeBSD 2.2.5 with any version of gcc is identified as
`freebsd2.2.5-gcc*'.
instance, FreeBSD 4.2 using the ELF object file format with any
version of gcc is identified as `freebsdelf4.2-gcc*'.
In the stanza for your operating system-compiler pair, you will need to
define several variables. They are:
@ -144,7 +147,7 @@ Bug reports for Readline should be sent to:
When reporting a bug, please include the following information:
* the version number and release status of Readline (e.g., 4.0-release)
* the version number and release status of Readline (e.g., 4.2-release)
* the machine and OS that it is running on
* a list of the compilation flags or the contents of `config.h', if
appropriate

View File

@ -1065,17 +1065,19 @@ fi
])
AC_DEFUN(BASH_CHECK_GETPW_FUNCS,
[AC_MSG_CHECKING(whether programs are able to redeclare getpw functions)
AC_CACHE_VAL(bash_cv_can_redecl_getpw,
[AC_TRY_COMPILE([#include <sys/types.h>
[AC_MSG_CHECKING(whether getpw functions are declared in pwd.h)
AC_CACHE_VAL(bash_cv_getpw_declared,
[AC_EGREP_CPP(getpwuid,
[
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <pwd.h>
extern struct passwd *getpwent();
extern struct passwd *getpwuid();
extern struct passwd *getpwnam();],
[struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");],
bash_cv_can_redecl_getpw=yes,bash_cv_can_redecl_getpw=no)])
AC_MSG_RESULT($bash_cv_can_redecl_getpw)
if test $bash_cv_can_redecl_getpw = no; then
],
bash_cv_getpw_declared=yes,bash_cv_getpw_declared=no)])
AC_MSG_RESULT($bash_cv_getpw_declared)
if test $bash_cv_getpw_declared = yes; then
AC_DEFINE(HAVE_GETPW_DECLS)
fi
])
@ -1350,12 +1352,15 @@ dnl causes system calls to be restarted after the signal is caught
dnl
AC_DEFUN(BASH_SYS_RESTARTABLE_SYSCALLS,
[AC_REQUIRE([BASH_SIGNAL_CHECK])
AC_CACHE_CHECK(for restartable system calls with posix sigaction,
AC_CACHE_CHECK(whether posix sigaction restarts system calls by default,
bash_cv_sys_restartable_syscalls,
[AC_TRY_RUN(
[/* Exit 0 (true) if wait returns something other than -1,
i.e. the pid of the child, which means that wait was restarted
after getting the signal. */
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h>
#include <signal.h>
static int caught = 0;
@ -1425,3 +1430,34 @@ if test $bash_cv_struct_timeval = yes; then
AC_DEFINE(HAVE_TIMEVAL)
fi
])
AC_DEFUN(BASH_CHECK_RTSIGS,
[AC_MSG_CHECKING(for unusable real-time signals due to large values)
AC_CACHE_VAL(bash_cv_unusable_rtsigs,
[AC_TRY_RUN([
#include <sys/types.h>
#include <signal.h>
#ifndef NSIG
# define NSIG 64
#endif
main ()
{
int n_sigs = 2 * NSIG;
#ifdef SIGRTMIN
int rtmin = SIGRTMIN;
#else
int rtmin = 0;
#endif
exit(rtmin < n_sigs);
}], bash_cv_unusable_rtsigs=yes, bash_cv_unusable_rtsigs=no,
[AC_MSG_WARN(cannot check real-time signals if cross compiling -- defaulting to yes)
bash_cv_unusable_rtsigs=yes]
)])
AC_MSG_RESULT($bash_cv_unusable_rtsigs)
if test $bash_cv_unusable_rtsigs = yes; then
AC_DEFINE(UNUSABLE_RT_SIGNALS)
fi
])

View File

@ -27,6 +27,9 @@
extern int atoi ();
extern long int atol ();
extern double atof ();
extern double strtod ();
/* Memory allocation functions. */
extern char *malloc ();
extern char *realloc ();

View File

@ -68,9 +68,9 @@ extern char *strchr (), *strrchr ();
/* Variables exported by this file. */
Keymap rl_binding_keymap;
static int _rl_read_init_file __P((char *, int));
static int _rl_read_init_file __P((const char *, int));
static int glean_key_from_name __P((char *));
static int substring_member_of_array __P((char *, char **));
static int substring_member_of_array __P((char *, const char **));
static int currently_reading_init_file;
@ -83,13 +83,13 @@ static int _rl_prefer_visible_bell = 1;
/* */
/* **************************************************************** */
/* rl_add_defun (char *name, Function *function, int key)
/* rl_add_defun (char *name, rl_command_func_t *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. */
int
rl_add_defun (name, function, key)
char *name;
Function *function;
const char *name;
rl_command_func_t *function;
int key;
{
if (key != -1)
@ -102,7 +102,7 @@ rl_add_defun (name, function, key)
int
rl_bind_key (key, function)
int key;
Function *function;
rl_command_func_t *function;
{
if (key < 0)
return (key);
@ -133,7 +133,7 @@ rl_bind_key (key, function)
int
rl_bind_key_in_map (key, function, map)
int key;
Function *function;
rl_command_func_t *function;
Keymap map;
{
int result;
@ -152,7 +152,7 @@ int
rl_unbind_key (key)
int key;
{
return (rl_bind_key (key, (Function *)NULL));
return (rl_bind_key (key, (rl_command_func_t *)NULL));
}
/* Make KEY do nothing in MAP.
@ -162,13 +162,13 @@ rl_unbind_key_in_map (key, map)
int key;
Keymap map;
{
return (rl_bind_key_in_map (key, (Function *)NULL, map));
return (rl_bind_key_in_map (key, (rl_command_func_t *)NULL, map));
}
/* Unbind all keys bound to FUNCTION in MAP. */
int
rl_unbind_function_in_map (func, map)
Function *func;
rl_command_func_t *func;
Keymap map;
{
register int i, rval;
@ -177,7 +177,7 @@ rl_unbind_function_in_map (func, map)
{
if (map[i].type == ISFUNC && map[i].function == func)
{
map[i].function = (Function *)NULL;
map[i].function = (rl_command_func_t *)NULL;
rval = 1;
}
}
@ -186,10 +186,10 @@ rl_unbind_function_in_map (func, map)
int
rl_unbind_command_in_map (command, map)
char *command;
const char *command;
Keymap map;
{
Function *func;
rl_command_func_t *func;
func = rl_named_function (command);
if (func == 0)
@ -202,8 +202,8 @@ rl_unbind_command_in_map (command, map)
place to do bindings is in MAP. */
int
rl_set_key (keyseq, function, map)
char *keyseq;
Function *function;
const char *keyseq;
rl_command_func_t *function;
Keymap map;
{
return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map));
@ -214,7 +214,7 @@ rl_set_key (keyseq, function, map)
necessary. The initial place to do bindings is in MAP. */
int
rl_macro_bind (keyseq, macro, map)
char *keyseq, *macro;
const char *keyseq, *macro;
Keymap map;
{
char *macro_keys;
@ -239,7 +239,8 @@ rl_macro_bind (keyseq, macro, map)
int
rl_generic_bind (type, keyseq, data, map)
int type;
char *keyseq, *data;
const char *keyseq;
char *data;
Keymap map;
{
char *keys;
@ -309,7 +310,8 @@ rl_generic_bind (type, keyseq, data, map)
non-zero if there was an error parsing SEQ. */
int
rl_translate_keyseq (seq, array, len)
char *seq, *array;
const char *seq;
char *array;
int *len;
{
register int i, c, l, temp;
@ -513,9 +515,9 @@ _rl_untranslate_macro_value (seq)
/* Return a pointer to the function that STRING represents.
If STRING doesn't have a matching function, then a NULL pointer
is returned. */
Function *
rl_command_func_t *
rl_named_function (string)
char *string;
const char *string;
{
register int i;
@ -524,7 +526,7 @@ rl_named_function (string)
for (i = 0; funmap[i]; i++)
if (_rl_stricmp (funmap[i]->name, string) == 0)
return (funmap[i]->function);
return ((Function *)NULL);
return ((rl_command_func_t *)NULL);
}
/* Return the function (or macro) definition which would be invoked via
@ -532,9 +534,9 @@ rl_named_function (string)
used. TYPE, if non-NULL, is a pointer to an int which will receive the
type of the object pointed to. One of ISFUNC (function), ISKMAP (keymap),
or ISMACR (macro). */
Function *
rl_command_func_t *
rl_function_of_keyseq (keyseq, map, type)
char *keyseq;
const char *keyseq;
Keymap map;
int *type;
{
@ -585,14 +587,14 @@ rl_function_of_keyseq (keyseq, map, type)
return (map[ic].function);
}
}
return ((Function *) NULL);
return ((rl_command_func_t *) NULL);
}
/* The last key bindings file read. */
static char *last_readline_init_file = (char *)NULL;
/* The file we're currently reading key bindings from. */
static char *current_readline_init_file;
static const char *current_readline_init_file;
static int current_readline_init_include_level;
static int current_readline_init_lineno;
@ -659,7 +661,7 @@ rl_re_read_init_file (count, ignore)
int count, ignore;
{
int r;
r = rl_read_init_file ((char *)NULL);
r = rl_read_init_file ((const char *)NULL);
rl_set_keymap_from_edit_mode ();
return r;
}
@ -673,14 +675,14 @@ rl_re_read_init_file (count, ignore)
otherwise errno is returned. */
int
rl_read_init_file (filename)
char *filename;
const char *filename;
{
/* Default the filename. */
if (filename == 0)
{
filename = last_readline_init_file;
if (filename == 0)
filename = get_env_value ("INPUTRC");
filename = sh_get_env_value ("INPUTRC");
if (filename == 0)
filename = DEFAULT_INPUTRC;
}
@ -698,7 +700,7 @@ rl_read_init_file (filename)
static int
_rl_read_init_file (filename, include_level)
char *filename;
const char *filename;
int include_level;
{
register int i;
@ -733,7 +735,7 @@ _rl_read_init_file (filename, include_level)
/* Find the end of this line. */
for (i = 0; line + i != end && line[i] != '\n'; i++);
#if defined (__CYGWIN32__)
#if defined (__CYGWIN__)
/* ``Be liberal in what you accept.'' */
if (line[i] == '\n' && line[i-1] == '\r')
line[i - 1] = '\0';
@ -780,10 +782,21 @@ _rl_init_file_error (msg)
/* */
/* **************************************************************** */
typedef int _rl_parser_func_t __P((char *));
/* Things that mean `Control'. */
const char *_rl_possible_control_prefixes[] = {
"Control-", "C-", "CTRL-", (const char *)NULL
};
const char *_rl_possible_meta_prefixes[] = {
"Meta", "M-", (const char *)NULL
};
/* Conditionals. */
/* Calling programs set this to have their argv[0]. */
char *rl_readline_name = "other";
const char *rl_readline_name = "other";
/* Stack of previous values of parsing_conditionalized_out. */
static unsigned char *if_stack = (unsigned char *)NULL;
@ -905,7 +918,8 @@ static int
parser_include (args)
char *args;
{
char *old_init_file, *e;
const char *old_init_file;
char *e;
int old_line_number, old_include_level, r;
if (_rl_parsing_conditionalized_out)
@ -918,7 +932,7 @@ parser_include (args)
e = strchr (args, '\n');
if (e)
*e = '\0';
r = _rl_read_init_file (args, old_include_level + 1);
r = _rl_read_init_file ((const char *)args, old_include_level + 1);
current_readline_init_file = old_init_file;
current_readline_init_lineno = old_line_number;
@ -929,14 +943,14 @@ parser_include (args)
/* Associate textual names with actual functions. */
static struct {
char *name;
Function *function;
const char *name;
_rl_parser_func_t *function;
} parser_directives [] = {
{ "if", parser_if },
{ "endif", parser_endif },
{ "else", parser_else },
{ "include", parser_include },
{ (char *)0x0, (Function *)0x0 }
{ (char *)0x0, (_rl_parser_func_t *)0x0 }
};
/* Handle a parser directive. STATEMENT is the line of the directive
@ -1180,10 +1194,10 @@ rl_parse_and_bind (string)
key = glean_key_from_name (kname);
/* Add in control and meta bits. */
if (substring_member_of_array (string, possible_control_prefixes))
if (substring_member_of_array (string, _rl_possible_control_prefixes))
key = CTRL (_rl_to_upper (key));
if (substring_member_of_array (string, possible_meta_prefixes))
if (substring_member_of_array (string, _rl_possible_meta_prefixes))
key = META (key);
/* Temporary. Handle old-style keyname with macro-binding. */
@ -1221,7 +1235,7 @@ rl_parse_and_bind (string)
#define V_SPECIAL 0x1
static struct {
char *name;
const char *name;
int *value;
int flags;
} boolean_varlist [] = {
@ -1265,7 +1279,7 @@ static void
hack_special_boolean_var (i)
int i;
{
char *name;
const char *name;
name = boolean_varlist[i].name;
@ -1280,6 +1294,8 @@ hack_special_boolean_var (i)
}
}
typedef int _rl_sv_func_t __P((const char *));
/* These *must* correspond to the array indices for the appropriate
string variable. (Though they're not used right now.) */
#define V_BELLSTYLE 0
@ -1292,17 +1308,17 @@ hack_special_boolean_var (i)
#define V_INT 2
/* Forward declarations */
static int sv_bell_style __P((char *));
static int sv_combegin __P((char *));
static int sv_compquery __P((char *));
static int sv_editmode __P((char *));
static int sv_isrchterm __P((char *));
static int sv_keymap __P((char *));
static int sv_bell_style __P((const char *));
static int sv_combegin __P((const char *));
static int sv_compquery __P((const char *));
static int sv_editmode __P((const char *));
static int sv_isrchterm __P((const char *));
static int sv_keymap __P((const char *));
static struct {
char *name;
const char *name;
int flags;
Function *set_func;
_rl_sv_func_t *set_func;
} string_varlist[] = {
{ "bell-style", V_STRING, sv_bell_style },
{ "comment-begin", V_STRING, sv_combegin },
@ -1339,7 +1355,7 @@ bool_to_int (value)
int
rl_variable_bind (name, value)
char *name, *value;
const char *name, *value;
{
register int i;
int v;
@ -1367,7 +1383,7 @@ rl_variable_bind (name, value)
static int
sv_editmode (value)
char *value;
const char *value;
{
if (_rl_strnicmp (value, "vi", 2) == 0)
{
@ -1388,7 +1404,7 @@ sv_editmode (value)
static int
sv_combegin (value)
char *value;
const char *value;
{
if (value && *value)
{
@ -1401,7 +1417,7 @@ sv_combegin (value)
static int
sv_compquery (value)
char *value;
const char *value;
{
int nval = 100;
@ -1417,7 +1433,7 @@ sv_compquery (value)
static int
sv_keymap (value)
char *value;
const char *value;
{
Keymap kmap;
@ -1434,7 +1450,7 @@ sv_keymap (value)
static int
sv_bell_style (value)
char *value;
const char *value;
{
if (value == 0 || *value == '\0')
_SET_BELL (AUDIBLE_BELL);
@ -1451,7 +1467,7 @@ sv_bell_style (value)
static int
sv_isrchterm (value)
char *value;
const char *value;
{
int beg, end, delim;
char *v;
@ -1489,7 +1505,7 @@ sv_isrchterm (value)
For example, `Space' returns ' '. */
typedef struct {
char *name;
const char *name;
int value;
} assoc_list;
@ -1523,7 +1539,7 @@ glean_key_from_name (name)
/* Auxiliary functions to manage keymaps. */
static struct {
char *name;
const char *name;
Keymap map;
} keymap_names[] = {
{ "emacs", emacs_standard_keymap },
@ -1541,12 +1557,12 @@ static struct {
Keymap
rl_get_keymap_by_name (name)
char *name;
const char *name;
{
register int i;
for (i = 0; keymap_names[i].name; i++)
if (strcmp (name, keymap_names[i].name) == 0)
if (_rl_stricmp (name, keymap_names[i].name) == 0)
return (keymap_names[i].map);
return ((Keymap) NULL);
}
@ -1558,7 +1574,7 @@ rl_get_keymap_name (map)
register int i;
for (i = 0; keymap_names[i].name; i++)
if (map == keymap_names[i].map)
return (keymap_names[i].name);
return ((char *)keymap_names[i].name);
return ((char *)NULL);
}
@ -1616,7 +1632,7 @@ void
rl_list_funmap_names ()
{
register int i;
char **funmap_names;
const char **funmap_names;
funmap_names = rl_funmap_names ();
@ -1706,7 +1722,7 @@ _rl_get_keyname (key)
sequences that are used to invoke FUNCTION in MAP. */
char **
rl_invoking_keyseqs_in_map (function, map)
Function *function;
rl_command_func_t *function;
Keymap map;
{
register int key;
@ -1806,7 +1822,7 @@ rl_invoking_keyseqs_in_map (function, map)
sequences that can be used to invoke FUNCTION using the current keymap. */
char **
rl_invoking_keyseqs (function)
Function *function;
rl_command_func_t *function;
{
return (rl_invoking_keyseqs_in_map (function, _rl_keymap));
}
@ -1819,8 +1835,8 @@ rl_function_dumper (print_readably)
int print_readably;
{
register int i;
char **names;
char *name;
const char **names;
const char *name;
names = rl_funmap_names ();
@ -1828,7 +1844,7 @@ rl_function_dumper (print_readably)
for (i = 0; name = names[i]; i++)
{
Function *function;
rl_command_func_t *function;
char **invokers;
function = rl_named_function (name);
@ -1985,7 +2001,7 @@ rl_variable_dumper (print_readably)
int print_readably;
{
int i;
char *kname;
const char *kname;
for (i = 0; boolean_varlist[i].name; i++)
{
@ -2073,10 +2089,10 @@ rl_dump_variables (count, key)
/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. */
void
_rl_bind_if_unbound (keyseq, default_func)
char *keyseq;
Function *default_func;
const char *keyseq;
rl_command_func_t *default_func;
{
Function *func;
rl_command_func_t *func;
if (keyseq)
{
@ -2089,7 +2105,8 @@ _rl_bind_if_unbound (keyseq, default_func)
/* Return non-zero if any members of ARRAY are a substring in STRING. */
static int
substring_member_of_array (string, array)
char *string, **array;
char *string;
const char **array;
{
while (*array)
{

View File

@ -52,7 +52,7 @@
text read in at each end of line. The terminal is kept prepped and
signals handled all the time, except during calls to the user's function. */
VFunction *rl_linefunc; /* user callback function */
rl_vcpfunc_t *rl_linefunc; /* user callback function */
static int in_handler; /* terminal_prepped and signals set? */
/* Make sure the terminal is set up, initialize readline, and prompt. */
@ -78,11 +78,10 @@ _rl_callback_newline ()
/* Install a readline handler, set up the terminal, and issue the prompt. */
void
rl_callback_handler_install (prompt, linefunc)
char *prompt;
VFunction *linefunc;
const char *prompt;
rl_vcpfunc_t *linefunc;
{
rl_prompt = prompt;
rl_visible_prompt_length = rl_prompt ? rl_expand_prompt (rl_prompt) : 0;
rl_set_prompt (prompt);
rl_linefunc = linefunc;
_rl_callback_newline ();
}
@ -102,24 +101,33 @@ rl_callback_read_char ()
eof = readline_internal_char ();
if (rl_done)
/* We loop in case some function has pushed input back with rl_execute_next. */
for (;;)
{
line = readline_internal_teardown (eof);
if (rl_done)
{
line = readline_internal_teardown (eof);
(*rl_deprep_term_function) ();
(*rl_deprep_term_function) ();
#if defined (HANDLE_SIGNALS)
rl_clear_signals ();
rl_clear_signals ();
#endif
in_handler = 0;
(*rl_linefunc) (line);
in_handler = 0;
(*rl_linefunc) (line);
/* If the user did not clear out the line, do it for him. */
if (rl_line_buffer[0])
_rl_init_line_state ();
/* If the user did not clear out the line, do it for him. */
if (rl_line_buffer[0])
_rl_init_line_state ();
/* Redisplay the prompt if readline_handler_{install,remove} not called. */
if (in_handler == 0 && rl_linefunc)
_rl_callback_newline ();
/* Redisplay the prompt if readline_handler_{install,remove}
not called. */
if (in_handler == 0 && rl_linefunc)
_rl_callback_newline ();
}
if (rl_pending_input)
eof = readline_internal_char ();
else
break;
}
}

View File

@ -51,7 +51,7 @@
#define meta_character_bit 0x080 /* x0000000, must be on. */
#define largest_char 255 /* Largest character value. */
#define CTRL_CHAR(c) ((c) < control_character_threshold && (c) >= 0)
#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
#define CTRL(c) ((c) & control_character_mask)

View File

@ -0,0 +1,113 @@
/* compat.c -- backwards compatibility functions. */
/* Copyright (C) 2000 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 2, 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,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <stdio.h>
#include "rlstdc.h"
#include "rltypedefs.h"
extern void rl_free_undo_list __P((void));
extern int rl_maybe_save_line __P((void));
extern int rl_maybe_unsave_line __P((void));
extern int rl_maybe_replace_line __P((void));
extern int rl_crlf __P((void));
extern int rl_ding __P((void));
extern int rl_alphabetic __P((int));
extern char **rl_completion_matches __P((const char *, rl_compentry_func_t *));
extern char *rl_username_completion_function __P((const char *, int));
extern char *rl_filename_completion_function __P((const char *, int));
/* Provide backwards-compatible entry points for old function names. */
void
free_undo_list ()
{
rl_free_undo_list ();
}
int
maybe_replace_line ()
{
return rl_maybe_replace_line ();
}
int
maybe_save_line ()
{
return rl_maybe_save_line ();
}
int
maybe_unsave_line ()
{
return rl_maybe_unsave_line ();
}
int
ding ()
{
return rl_ding ();
}
int
crlf ()
{
return rl_crlf ();
}
int
alphabetic (c)
int c;
{
return rl_alphabetic (c);
}
char **
completion_matches (s, f)
const char *s;
rl_compentry_func_t *f;
{
return rl_completion_matches (s, f);
}
char *
username_completion_function (s, i)
const char *s;
int i;
{
return rl_username_completion_function (s, i);
}
char *
filename_completion_function (s, i)
const char *s;
int i;
{
return rl_filename_completion_function (s, i);
}

View File

@ -1,4 +1,4 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* config.h.in. Maintained by hand. */
/* Define if on MINIX. */
#undef _MINIX
@ -124,7 +124,6 @@
#undef HAVE_POSIX_SIGSETJMP
/* config.h.bot */
/* modify settings or make new ones based on what autoconf tells us. */
/* Ultrix botches type-ahead when switching from canonical to

View File

@ -1,7 +1,9 @@
#! /bin/sh
# From configure.in for Readline 4.1, version 2.22, from autoconf version 2.13
LIBVERSION=4.1
# From configure.in for Readline 4.2, version 2.26, from autoconf version 2.13
LIBVERSION=4.2
@ -657,7 +659,7 @@ else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
fi
echo $ac_n "checking host system type""... $ac_c" 1>&6
echo "configure:661: checking host system type" >&5
echo "configure:663: checking host system type" >&5
host_alias=$host
case "$host_alias" in
@ -695,10 +697,37 @@ fi
# We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
echo "configure:702: checking whether ${MAKE-make} sets \${MAKE}" >&5
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftestmake <<\EOF
all:
@echo 'ac_maketemp="${MAKE}"'
EOF
# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=`
if test -n "$ac_maketemp"; then
eval ac_cv_prog_make_${ac_make}_set=yes
else
eval ac_cv_prog_make_${ac_make}_set=no
fi
rm -f conftestmake
fi
if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then
echo "$ac_t""yes" 1>&6
SET_MAKE=
else
echo "$ac_t""no" 1>&6
SET_MAKE="MAKE=${MAKE-make}"
fi
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:702: checking for $ac_word" >&5
echo "configure:731: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -728,7 +757,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:732: checking for $ac_word" >&5
echo "configure:761: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -779,7 +808,7 @@ fi
# Extract the first word of "cl", so it can be a program name with args.
set dummy cl; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:783: checking for $ac_word" >&5
echo "configure:812: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -811,7 +840,7 @@ fi
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
echo "configure:815: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
echo "configure:844: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
@ -822,12 +851,12 @@ cross_compiling=$ac_cv_prog_cc_cross
cat > conftest.$ac_ext << EOF
#line 826 "configure"
#line 855 "configure"
#include "confdefs.h"
main(){return(0);}
EOF
if { (eval echo configure:831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:860: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
ac_cv_prog_cc_works=yes
# If we can't run a trivial program, we are probably using a cross compiler.
if (./conftest; exit) 2>/dev/null; then
@ -853,12 +882,12 @@ if test $ac_cv_prog_cc_works = no; then
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
fi
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
echo "configure:857: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "configure:886: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
cross_compiling=$ac_cv_prog_cc_cross
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
echo "configure:862: checking whether we are using GNU C" >&5
echo "configure:891: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -867,7 +896,7 @@ else
yes;
#endif
EOF
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:871: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:900: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@ -886,7 +915,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
echo "configure:890: checking whether ${CC-cc} accepts -g" >&5
echo "configure:919: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -918,7 +947,7 @@ else
fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
echo "configure:922: checking how to run the C preprocessor" >&5
echo "configure:951: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@ -933,13 +962,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <<EOF
#line 937 "configure"
#line 966 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:943: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:972: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -950,13 +979,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF
#line 954 "configure"
#line 983 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:960: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:989: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -967,13 +996,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -nologo -E"
cat > conftest.$ac_ext <<EOF
#line 971 "configure"
#line 1000 "configure"
#include "confdefs.h"
#include <assert.h>
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:977: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1006: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
:
@ -999,17 +1028,17 @@ echo "$ac_t""$CPP" 1>&6
ac_safe=`echo "minix/config.h" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for minix/config.h""... $ac_c" 1>&6
echo "configure:1003: checking for minix/config.h" >&5
echo "configure:1032: checking for minix/config.h" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1008 "configure"
#line 1037 "configure"
#include "confdefs.h"
#include <minix/config.h>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1013: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1042: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1052,13 +1081,13 @@ test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
if test $ac_cv_prog_gcc = yes; then
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
echo "configure:1056: checking whether ${CC-cc} needs -traditional" >&5
echo "configure:1085: checking whether ${CC-cc} needs -traditional" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
ac_pattern="Autoconf.*'x'"
cat > conftest.$ac_ext <<EOF
#line 1062 "configure"
#line 1091 "configure"
#include "confdefs.h"
#include <sgtty.h>
Autoconf TIOCGETP
@ -1076,7 +1105,7 @@ rm -f conftest*
if test $ac_cv_prog_gcc_traditional = no; then
cat > conftest.$ac_ext <<EOF
#line 1080 "configure"
#line 1109 "configure"
#include "confdefs.h"
#include <termio.h>
Autoconf TCGETA
@ -1109,7 +1138,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:1113: checking for a BSD compatible install" >&5
echo "configure:1142: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1164,7 +1193,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
# Extract the first word of "ar", so it can be a program name with args.
set dummy ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1168: checking for $ac_word" >&5
echo "configure:1197: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1194,7 +1223,7 @@ test -n "$ARFLAGS" || ARFLAGS="cr"
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:1198: checking for $ac_word" >&5
echo "configure:1227: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1226,12 +1255,12 @@ MAKE_SHELL=/bin/sh
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
echo "configure:1230: checking return type of signal handlers" >&5
echo "configure:1259: checking return type of signal handlers" >&5
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1235 "configure"
#line 1264 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@ -1248,7 +1277,7 @@ int main() {
int i;
; return 0; }
EOF
if { (eval echo configure:1252: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1281: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
ac_cv_type_signal=void
else
@ -1268,12 +1297,12 @@ EOF
echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
echo "configure:1272: checking whether stat file-mode macros are broken" >&5
echo "configure:1301: checking whether stat file-mode macros are broken" >&5
if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1277 "configure"
#line 1306 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/stat.h>
@ -1328,12 +1357,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
echo "configure:1332: checking for $ac_hdr that defines DIR" >&5
echo "configure:1361: checking for $ac_hdr that defines DIR" >&5
if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1337 "configure"
#line 1366 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <$ac_hdr>
@ -1341,7 +1370,7 @@ int main() {
DIR *dirp = 0;
; return 0; }
EOF
if { (eval echo configure:1345: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:1374: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
eval "ac_cv_header_dirent_$ac_safe=yes"
else
@ -1366,7 +1395,7 @@ done
# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
if test $ac_header_dirent = dirent.h; then
echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
echo "configure:1370: checking for opendir in -ldir" >&5
echo "configure:1399: checking for opendir in -ldir" >&5
ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1374,7 +1403,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldir $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1378 "configure"
#line 1407 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -1385,7 +1414,7 @@ int main() {
opendir()
; return 0; }
EOF
if { (eval echo configure:1389: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1418: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -1407,7 +1436,7 @@ fi
else
echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
echo "configure:1411: checking for opendir in -lx" >&5
echo "configure:1440: checking for opendir in -lx" >&5
ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -1415,7 +1444,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lx $LIBS"
cat > conftest.$ac_ext <<EOF
#line 1419 "configure"
#line 1448 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -1426,7 +1455,7 @@ int main() {
opendir()
; return 0; }
EOF
if { (eval echo configure:1430: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -1453,12 +1482,12 @@ for ac_func in lstat memmove putenv select setenv setlocale \
strcasecmp tcgetattr
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:1457: checking for $ac_func" >&5
echo "configure:1486: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1462 "configure"
#line 1491 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@ -1481,7 +1510,7 @@ $ac_func();
; return 0; }
EOF
if { (eval echo configure:1485: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1514: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@ -1507,7 +1536,7 @@ done
echo $ac_n "checking for working strcoll""... $ac_c" 1>&6
echo "configure:1511: checking for working strcoll" >&5
echo "configure:1540: checking for working strcoll" >&5
if eval "test \"`echo '$''{'ac_cv_func_strcoll_works'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1515,7 +1544,7 @@ else
ac_cv_func_strcoll_works=no
else
cat > conftest.$ac_ext <<EOF
#line 1519 "configure"
#line 1548 "configure"
#include "confdefs.h"
#include <string.h>
main ()
@ -1525,7 +1554,7 @@ main ()
strcoll ("123", "456") >= 0);
}
EOF
if { (eval echo configure:1529: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1558: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_strcoll_works=yes
else
@ -1554,17 +1583,17 @@ for ac_hdr in unistd.h stdlib.h varargs.h stdarg.h string.h \
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
echo "configure:1558: checking for $ac_hdr" >&5
echo "configure:1587: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1563 "configure"
#line 1592 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
{ (eval echo configure:1568: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
{ (eval echo configure:1597: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@ -1593,13 +1622,13 @@ done
echo $ac_n "checking for type of signal functions""... $ac_c" 1>&6
echo "configure:1597: checking for type of signal functions" >&5
echo "configure:1626: checking for type of signal functions" >&5
if eval "test \"`echo '$''{'bash_cv_signal_vintage'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1603 "configure"
#line 1632 "configure"
#include "confdefs.h"
#include <signal.h>
int main() {
@ -1612,7 +1641,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:1616: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1645: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
bash_cv_signal_vintage=posix
else
@ -1621,7 +1650,7 @@ else
rm -rf conftest*
cat > conftest.$ac_ext <<EOF
#line 1625 "configure"
#line 1654 "configure"
#include "confdefs.h"
#include <signal.h>
int main() {
@ -1631,7 +1660,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:1635: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1664: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
bash_cv_signal_vintage=4.2bsd
else
@ -1640,7 +1669,7 @@ else
rm -rf conftest*
cat > conftest.$ac_ext <<EOF
#line 1644 "configure"
#line 1673 "configure"
#include "confdefs.h"
#include <signal.h>
@ -1653,7 +1682,7 @@ int main() {
; return 0; }
EOF
if { (eval echo configure:1657: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1686: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
bash_cv_signal_vintage=svr3
else
@ -1694,7 +1723,7 @@ fi
echo $ac_n "checking if signal handlers must be reinstalled when invoked""... $ac_c" 1>&6
echo "configure:1698: checking if signal handlers must be reinstalled when invoked" >&5
echo "configure:1727: checking if signal handlers must be reinstalled when invoked" >&5
if eval "test \"`echo '$''{'bash_cv_must_reinstall_sighandlers'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1704,7 +1733,7 @@ else
else
cat > conftest.$ac_ext <<EOF
#line 1708 "configure"
#line 1737 "configure"
#include "confdefs.h"
#include <signal.h>
@ -1751,7 +1780,7 @@ main()
}
EOF
if { (eval echo configure:1755: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1784: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_must_reinstall_sighandlers=no
else
@ -1776,7 +1805,7 @@ fi
echo $ac_n "checking for presence of POSIX-style sigsetjmp/siglongjmp""... $ac_c" 1>&6
echo "configure:1780: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5
echo "configure:1809: checking for presence of POSIX-style sigsetjmp/siglongjmp" >&5
if eval "test \"`echo '$''{'bash_cv_func_sigsetjmp'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1786,7 +1815,7 @@ else
else
cat > conftest.$ac_ext <<EOF
#line 1790 "configure"
#line 1819 "configure"
#include "confdefs.h"
#ifdef HAVE_UNISTD_H
@ -1827,7 +1856,7 @@ exit(1);
#endif
}
EOF
if { (eval echo configure:1831: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:1860: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_func_sigsetjmp=present
else
@ -1850,12 +1879,12 @@ EOF
fi
echo $ac_n "checking for lstat""... $ac_c" 1>&6
echo "configure:1854: checking for lstat" >&5
echo "configure:1883: checking for lstat" >&5
if eval "test \"`echo '$''{'bash_cv_func_lstat'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1859 "configure"
#line 1888 "configure"
#include "confdefs.h"
#include <sys/types.h>
@ -1865,7 +1894,7 @@ int main() {
lstat(".",(struct stat *)0);
; return 0; }
EOF
if { (eval echo configure:1869: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:1898: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
bash_cv_func_lstat=yes
else
@ -1885,37 +1914,36 @@ EOF
fi
echo $ac_n "checking whether programs are able to redeclare getpw functions""... $ac_c" 1>&6
echo "configure:1890: checking whether programs are able to redeclare getpw functions" >&5
if eval "test \"`echo '$''{'bash_cv_can_redecl_getpw'+set}'`\" = set"; then
echo $ac_n "checking whether getpw functions are declared in pwd.h""... $ac_c" 1>&6
echo "configure:1919: checking whether getpw functions are declared in pwd.h" >&5
if eval "test \"`echo '$''{'bash_cv_getpw_declared'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 1895 "configure"
#line 1924 "configure"
#include "confdefs.h"
#include <sys/types.h>
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <pwd.h>
extern struct passwd *getpwent();
extern struct passwd *getpwuid();
extern struct passwd *getpwnam();
int main() {
struct passwd *z; z = getpwent(); z = getpwuid(0); z = getpwnam("root");
; return 0; }
EOF
if { (eval echo configure:1906: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
egrep "getpwuid" >/dev/null 2>&1; then
rm -rf conftest*
bash_cv_can_redecl_getpw=yes
bash_cv_getpw_declared=yes
else
echo "configure: failed program was:" >&5
cat conftest.$ac_ext >&5
rm -rf conftest*
bash_cv_can_redecl_getpw=no
bash_cv_getpw_declared=no
fi
rm -f conftest*
fi
echo "$ac_t""$bash_cv_can_redecl_getpw" 1>&6
if test $bash_cv_can_redecl_getpw = no; then
echo "$ac_t""$bash_cv_getpw_declared" 1>&6
if test $bash_cv_getpw_declared = yes; then
cat >> confdefs.h <<\EOF
#define HAVE_GETPW_DECLS 1
EOF
@ -1924,7 +1952,7 @@ fi
echo $ac_n "checking whether or not strcoll and strcmp differ""... $ac_c" 1>&6
echo "configure:1928: checking whether or not strcoll and strcmp differ" >&5
echo "configure:1956: checking whether or not strcoll and strcmp differ" >&5
if eval "test \"`echo '$''{'bash_cv_func_strcoll_broken'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -1934,7 +1962,7 @@ else
else
cat > conftest.$ac_ext <<EOF
#line 1938 "configure"
#line 1966 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -1973,7 +2001,7 @@ char *v[];
}
EOF
if { (eval echo configure:1977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
if { (eval echo configure:2005: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
bash_cv_func_strcoll_broken=yes
else
@ -1997,12 +2025,12 @@ fi
echo $ac_n "checking whether signal handlers are of type void""... $ac_c" 1>&6
echo "configure:2001: checking whether signal handlers are of type void" >&5
echo "configure:2029: checking whether signal handlers are of type void" >&5
if eval "test \"`echo '$''{'bash_cv_void_sighandler'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2006 "configure"
#line 2034 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <signal.h>
@ -2017,7 +2045,7 @@ int main() {
int i;
; return 0; }
EOF
if { (eval echo configure:2021: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2049: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_void_sighandler=yes
else
@ -2037,12 +2065,12 @@ EOF
fi
echo $ac_n "checking for TIOCGWINSZ in sys/ioctl.h""... $ac_c" 1>&6
echo "configure:2041: checking for TIOCGWINSZ in sys/ioctl.h" >&5
echo "configure:2069: checking for TIOCGWINSZ in sys/ioctl.h" >&5
if eval "test \"`echo '$''{'bash_cv_tiocgwinsz_in_ioctl'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2046 "configure"
#line 2074 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@ -2050,7 +2078,7 @@ int main() {
int x = TIOCGWINSZ;
; return 0; }
EOF
if { (eval echo configure:2054: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2082: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_tiocgwinsz_in_ioctl=yes
else
@ -2071,12 +2099,12 @@ EOF
fi
echo $ac_n "checking for TIOCSTAT in sys/ioctl.h""... $ac_c" 1>&6
echo "configure:2075: checking for TIOCSTAT in sys/ioctl.h" >&5
echo "configure:2103: checking for TIOCSTAT in sys/ioctl.h" >&5
if eval "test \"`echo '$''{'bash_cv_tiocstat_in_ioctl'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2080 "configure"
#line 2108 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@ -2084,7 +2112,7 @@ int main() {
int x = TIOCSTAT;
; return 0; }
EOF
if { (eval echo configure:2088: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2116: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_tiocstat_in_ioctl=yes
else
@ -2105,12 +2133,12 @@ EOF
fi
echo $ac_n "checking for FIONREAD in sys/ioctl.h""... $ac_c" 1>&6
echo "configure:2109: checking for FIONREAD in sys/ioctl.h" >&5
echo "configure:2137: checking for FIONREAD in sys/ioctl.h" >&5
if eval "test \"`echo '$''{'bash_cv_fionread_in_ioctl'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2114 "configure"
#line 2142 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@ -2118,7 +2146,7 @@ int main() {
int x = FIONREAD;
; return 0; }
EOF
if { (eval echo configure:2122: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2150: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_fionread_in_ioctl=yes
else
@ -2139,19 +2167,19 @@ EOF
fi
echo $ac_n "checking for speed_t in sys/types.h""... $ac_c" 1>&6
echo "configure:2143: checking for speed_t in sys/types.h" >&5
echo "configure:2171: checking for speed_t in sys/types.h" >&5
if eval "test \"`echo '$''{'bash_cv_speed_t_in_sys_types'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2148 "configure"
#line 2176 "configure"
#include "confdefs.h"
#include <sys/types.h>
int main() {
speed_t x;
; return 0; }
EOF
if { (eval echo configure:2155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2183: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_speed_t_in_sys_types=yes
else
@ -2172,12 +2200,12 @@ EOF
fi
echo $ac_n "checking for struct winsize in sys/ioctl.h and termios.h""... $ac_c" 1>&6
echo "configure:2176: checking for struct winsize in sys/ioctl.h and termios.h" >&5
echo "configure:2204: checking for struct winsize in sys/ioctl.h and termios.h" >&5
if eval "test \"`echo '$''{'bash_cv_struct_winsize_header'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2181 "configure"
#line 2209 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <sys/ioctl.h>
@ -2185,7 +2213,7 @@ int main() {
struct winsize x;
; return 0; }
EOF
if { (eval echo configure:2189: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2217: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_struct_winsize_header=ioctl_h
else
@ -2193,7 +2221,7 @@ else
cat conftest.$ac_ext >&5
rm -rf conftest*
cat > conftest.$ac_ext <<EOF
#line 2197 "configure"
#line 2225 "configure"
#include "confdefs.h"
#include <sys/types.h>
#include <termios.h>
@ -2201,7 +2229,7 @@ int main() {
struct winsize x;
; return 0; }
EOF
if { (eval echo configure:2205: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2233: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_struct_winsize_header=termios_h
else
@ -2234,12 +2262,12 @@ fi
echo $ac_n "checking if struct dirent has a d_ino member""... $ac_c" 1>&6
echo "configure:2238: checking if struct dirent has a d_ino member" >&5
echo "configure:2266: checking if struct dirent has a d_ino member" >&5
if eval "test \"`echo '$''{'bash_cv_dirent_has_dino'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2243 "configure"
#line 2271 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -2268,7 +2296,7 @@ struct dirent d; int z; z = d.d_ino;
; return 0; }
EOF
if { (eval echo configure:2272: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2300: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_dirent_has_dino=yes
else
@ -2290,12 +2318,12 @@ fi
echo $ac_n "checking if struct dirent has a d_fileno member""... $ac_c" 1>&6
echo "configure:2294: checking if struct dirent has a d_fileno member" >&5
echo "configure:2322: checking if struct dirent has a d_fileno member" >&5
if eval "test \"`echo '$''{'bash_cv_dirent_has_d_fileno'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
#line 2299 "configure"
#line 2327 "configure"
#include "confdefs.h"
#include <stdio.h>
@ -2324,7 +2352,7 @@ struct dirent d; int z; z = d.d_fileno;
; return 0; }
EOF
if { (eval echo configure:2328: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
if { (eval echo configure:2356: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
rm -rf conftest*
bash_cv_dirent_has_d_fileno=yes
else
@ -2353,14 +2381,14 @@ if test "X$bash_cv_termcap_lib" = "X"; then
_bash_needmsg=yes
else
echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6
echo "configure:2357: checking which library has the termcap functions" >&5
echo "configure:2385: checking which library has the termcap functions" >&5
_bash_needmsg=
fi
if eval "test \"`echo '$''{'bash_cv_termcap_lib'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
echo $ac_n "checking for tgetent in -ltermcap""... $ac_c" 1>&6
echo "configure:2364: checking for tgetent in -ltermcap" >&5
echo "configure:2392: checking for tgetent in -ltermcap" >&5
ac_lib_var=`echo termcap'_'tgetent | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -2368,7 +2396,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ltermcap $LIBS"
cat > conftest.$ac_ext <<EOF
#line 2372 "configure"
#line 2400 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -2379,7 +2407,7 @@ int main() {
tgetent()
; return 0; }
EOF
if { (eval echo configure:2383: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2411: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -2398,7 +2426,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for tgetent in -lcurses""... $ac_c" 1>&6
echo "configure:2402: checking for tgetent in -lcurses" >&5
echo "configure:2430: checking for tgetent in -lcurses" >&5
ac_lib_var=`echo curses'_'tgetent | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -2406,7 +2434,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lcurses $LIBS"
cat > conftest.$ac_ext <<EOF
#line 2410 "configure"
#line 2438 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -2417,7 +2445,7 @@ int main() {
tgetent()
; return 0; }
EOF
if { (eval echo configure:2421: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2449: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -2436,7 +2464,7 @@ if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for tgetent in -lncurses""... $ac_c" 1>&6
echo "configure:2440: checking for tgetent in -lncurses" >&5
echo "configure:2468: checking for tgetent in -lncurses" >&5
ac_lib_var=`echo ncurses'_'tgetent | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@ -2444,7 +2472,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lncurses $LIBS"
cat > conftest.$ac_ext <<EOF
#line 2448 "configure"
#line 2476 "configure"
#include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
@ -2455,7 +2483,7 @@ int main() {
tgetent()
; return 0; }
EOF
if { (eval echo configure:2459: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
if { (eval echo configure:2487: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@ -2484,7 +2512,7 @@ fi
if test "X$_bash_needmsg" = "Xyes"; then
echo $ac_n "checking which library has the termcap functions""... $ac_c" 1>&6
echo "configure:2488: checking which library has the termcap functions" >&5
echo "configure:2516: checking which library has the termcap functions" >&5
fi
echo "$ac_t""using $bash_cv_termcap_lib" 1>&6
if test $bash_cv_termcap_lib = gnutermcap && test -z "$prefer_curses"; then
@ -2508,6 +2536,7 @@ fi
case "$host_cpu" in
*cray*) LOCAL_CFLAGS=-DCRAY ;;
*s390*) LOCAL_CFLAGS=-fsigned-char ;;
esac
case "$host_os" in
@ -2521,7 +2550,7 @@ esac
#
if test -f ${srcdir}/support/shobj-conf; then
echo $ac_n "checking configuration for building shared libraries""... $ac_c" 1>&6
echo "configure:2525: checking configuration for building shared libraries" >&5
echo "configure:2554: checking configuration for building shared libraries" >&5
eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
@ -2705,6 +2734,7 @@ s%@host_alias@%$host_alias%g
s%@host_cpu@%$host_cpu%g
s%@host_vendor@%$host_vendor%g
s%@host_os@%$host_os%g
s%@SET_MAKE@%$SET_MAKE%g
s%@CC@%$CC%g
s%@CPP@%$CPP%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g

View File

@ -4,8 +4,8 @@ dnl
dnl report bugs to chet@po.cwru.edu
dnl
dnl Process this file with autoconf to produce a configure script.
AC_REVISION([for Readline 4.1, version 2.22, from autoconf version] AC_ACVERSION)
LIBVERSION=4.1
AC_REVISION([for Readline 4.2, version 2.26, from autoconf version] AC_ACVERSION)
LIBVERSION=4.2
AC_INIT(readline.h)
AC_CONFIG_HEADER(config.h)
@ -31,6 +31,7 @@ fi
# We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
AC_PROG_MAKE_SET
AC_PROG_CC
dnl AC_AIX
AC_MINIX
@ -91,6 +92,7 @@ fi
case "$host_cpu" in
*cray*) LOCAL_CFLAGS=-DCRAY ;;
*s390*) LOCAL_CFLAGS=-fsigned-char ;;
esac
case "$host_os" in

View File

@ -63,13 +63,13 @@ GROFF = groff
DVIOBJ = readline.dvi history.dvi rluserman.dvi
INFOOBJ = readline.info history.info rluserman.info
PSOBJ = readline.ps history.ps rluserman.ps
PSOBJ = readline.ps history.ps rluserman.ps readline_3.ps history_3.ps
HTMLOBJ = readline.html history.html rluserman.html
TEXTOBJ = readline.0
TEXTOBJ = readline.0 history.0
INTERMEDIATE_OBJ = rlman.dvi hist.dvi rluserman.dvi
CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ) $(TEXTOBJ)
DIST_DOCS = $(DVIOBJ) $(PSOBJ) $(HTMLOBJ) $(INFOOBJ) $(TEXTOBJ)
.SUFFIXES: .0 .3 .ps .txt .dvi
@ -133,19 +133,28 @@ text: $(TEXTOBJ)
readline.0: readline.3
readline_3.ps: readline.3
${RM} $@
${GROFF} -man < $(srcdir)/readline.3 > $@
history.0: history.3
history_3.ps: history.3
${RM} $@
${GROFF} -man < $(srcdir)/history.3 > $@
clean:
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
*.fns *.kys *.tps *.vrs *.bt *.bts *.o core
distclean: clean
$(RM) $(CREATED_DOCS)
$(RM) $(INTERMEDIATE_OBJ)
$(RM) Makefile
mostlyclean: clean
maintainer-clean: clean
$(RM) $(CREATED_DOCS)
$(RM) $(DIST_DOCS)
$(RM) $(INTERMEDIATE_OBJ)
$(RM) Makefile
@ -173,9 +182,11 @@ install: installdirs
install-info --dir-file=$(infodir)/dir $(infodir)/history.info ; \
else true; fi
-${INSTALL_DATA} $(srcdir)/readline.3 $(man3dir)/readline.3
-${INSTALL_DATA} $(srcdir)/history.3 $(man3dir)/history.3
uninstall:
$(RM) $(infodir)/readline.info
$(RM) $(infodir)/rluserman.info
$(RM) $(infodir)/history.info
$(RM) $(man3dir)/readline.3
$(RM) $(man3dir)/history.3

View File

@ -18,7 +18,7 @@ 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-1999 Free Software Foundation, Inc.
Copyright (C) 1988-2001 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@ -73,7 +73,7 @@ except that this permission notice may be stated in a translation approved
by the Free Software Foundation.
@vskip 0pt plus 1filll
Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
Copyright @copyright{} 1988-2001 Free Software Foundation, Inc.
@end titlepage
@ifinfo

View File

@ -0,0 +1,639 @@
.\"
.\" MAN PAGE COMMENTS to
.\"
.\" Chet Ramey
.\" Information Network Services
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
.\" Last Change: Tue Mar 6 12:50:54 EST 2001
.\"
.TH HISTORY 3 "2001 Mar 6" "GNU History 4.2"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
.\"
.de FN
\fI\|\\$1\|\fP
..
.ds lp \fR\|(\fP
.ds rp \fR\|)\fP
.\" FnN return-value fun-name N arguments
.de Fn1
\fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3\fP\\*(rp
.br
..
.de Fn2
.if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4\fP\\*(rp
.if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4\fP\\*(rp
.br
..
.de Fn3
.if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4,\|\\$5\fP\|\\*(rp
.if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4, \\$5\fP\\*(rp
.br
..
.de Vb
\fI\\$1\fP \fB\\$2\fP
.br
..
.SH NAME
history \- GNU History Library
.SH COPYRIGHT
.if t The GNU History Library is Copyright \(co 1989-2001 by the Free Software Foundation, Inc.
.if n The GNU History Library is Copyright (C) 1989-2001 by the Free Software Foundation, Inc.
.SH DESCRIPTION
Many programs read input from the user a line at a time. The GNU
History library is able to keep track of those lines, associate arbitrary
data with each line, and utilize information from previous lines in
composing new ones.
.PP
.SH "HISTORY EXPANSION"
.PP
The history library supports a history expansion feature that
is identical to the history expansion in
.BR bash.
This section describes what syntax features are available.
.PP
History expansions introduce words from the history list into
the input stream, making it easy to repeat commands, insert the
arguments to a previous command into the current input line, or
fix errors in previous commands quickly.
.PP
History expansion is usually performed immediately after a complete line
is read.
It takes place in two parts.
The first is to determine which line from the history list
to use during substitution.
The second is to select portions of that line for inclusion into
the current one.
The line selected from the history is the \fIevent\fP,
and the portions of that line that are acted upon are \fIwords\fP.
Various \fImodifiers\fP are available to manipulate the selected words.
The line is broken into words in the same fashion as \fBbash\fP
does when reading input,
so that several words that would otherwise be separated
are considered one word when surrounded by quotes (see the
description of \fBhistory_tokenize()\fP below).
History expansions are introduced by the appearance of the
history expansion character, which is \^\fB!\fP\^ by default.
Only backslash (\^\fB\e\fP\^) and single quotes can quote
the history expansion character.
.SS Event Designators
.PP
An event designator is a reference to a command line entry in the
history list.
.PP
.PD 0
.TP
.B !
Start a history substitution, except when followed by a
.BR blank ,
newline, = or (.
.TP
.B !\fIn\fR
Refer to command line
.IR n .
.TP
.B !\-\fIn\fR
Refer to the current command line minus
.IR n .
.TP
.B !!
Refer to the previous command. This is a synonym for `!\-1'.
.TP
.B !\fIstring\fR
Refer to the most recent command starting with
.IR string .
.TP
.B !?\fIstring\fR\fB[?]\fR
Refer to the most recent command containing
.IR string .
The trailing \fB?\fP may be omitted if
.I string
is followed immediately by a newline.
.TP
.B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
Quick substitution. Repeat the last command, replacing
.I string1
with
.IR string2 .
Equivalent to
``!!:s/\fIstring1\fP/\fIstring2\fP/''
(see \fBModifiers\fP below).
.TP
.B !#
The entire command line typed so far.
.PD
.SS Word Designators
.PP
Word designators are used to select desired words from the event.
A
.B :
separates the event specification from the word designator.
It may be omitted if the word designator begins with a
.BR ^ ,
.BR $ ,
.BR * ,
.BR \- ,
or
.BR % .
Words are numbered from the beginning of the line,
with the first word being denoted by 0 (zero).
Words are inserted into the current line separated by single spaces.
.PP
.PD 0
.TP
.B 0 (zero)
The zeroth word. For the shell, this is the command
word.
.TP
.I n
The \fIn\fRth word.
.TP
.B ^
The first argument. That is, word 1.
.TP
.B $
The last argument.
.TP
.B %
The word matched by the most recent `?\fIstring\fR?' search.
.TP
.I x\fB\-\fPy
A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
.TP
.B *
All of the words but the zeroth. This is a synonym
for `\fI1\-$\fP'. It is not an error to use
.B *
if there is just one
word in the event; the empty string is returned in that case.
.TP
.B x*
Abbreviates \fIx\-$\fP.
.TP
.B x\-
Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
.PD
.PP
If a word designator is supplied without an event specification, the
previous command is used as the event.
.SS Modifiers
.PP
After the optional word designator, there may appear a sequence of
one or more of the following modifiers, each preceded by a `:'.
.PP
.PD 0
.PP
.TP
.B h
Remove a trailing file name component, leaving only the head.
.TP
.B t
Remove all leading file name components, leaving the tail.
.TP
.B r
Remove a trailing suffix of the form \fI.xxx\fP, leaving the
basename.
.TP
.B e
Remove all but the trailing suffix.
.TP
.B p
Print the new command but do not execute it.
.TP
.B q
Quote the substituted words, escaping further substitutions.
.TP
.B x
Quote the substituted words as with
.BR q ,
but break into words at
.B blanks
and newlines.
.TP
.B s/\fIold\fP/\fInew\fP/
Substitute
.I new
for the first occurrence of
.I old
in the event line. Any delimiter can be used in place of /. The
final delimiter is optional if it is the last character of the
event line. The delimiter may be quoted in
.I old
and
.I new
with a single backslash. If & appears in
.IR new ,
it is replaced by
.IR old .
A single backslash will quote the &. If
.I old
is null, it is set to the last
.I old
substituted, or, if no previous history substitutions took place,
the last
.I string
in a
.B !?\fIstring\fR\fB[?]\fR
search.
.TP
.B &
Repeat the previous substitution.
.TP
.B g
Cause changes to be applied over the entire event line. This is
used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
or `\fB:&\fP'. If used with
`\fB:s\fP', any delimiter can be used
in place of /, and the final delimiter is optional
if it is the last character of the event line.
.PD
.SH "PROGRAMMING WITH HISTORY FUNCTIONS"
This section describes how to use the History library in other programs.
.SS Introduction to History
.PP
The programmer using the History library has available functions
for remembering lines on a history list, associating arbitrary data
with a line, removing lines from the list, searching through the list
for a line containing an arbitrary text string, and referencing any line
in the list directly. In addition, a history \fIexpansion\fP function
is available which provides for a consistent user interface across
different programs.
.PP
The user using programs written with the History library has the
benefit of a consistent user interface with a set of well-known
commands for manipulating the text of previous lines and using that text
in new commands. The basic history manipulation commands are
identical to
the history substitution provided by \fBbash\fP.
.PP
If the programmer desires, he can use the Readline library, which
includes some history manipulation by default, and has the added
advantage of command line editing.
.PP
Before declaring any functions using any functionality the History
library provides in other code, an application writer should include
the file
.FN <readline/history.h>
in any file that uses the
History library's features. It supplies extern declarations for all
of the library's public functions and variables, and declares all of
the public data structures.
.SS History Storage
.PP
The history list is an array of history entries. A history entry is
declared as follows:
.PP
.Vb "typedef void *" histdata_t;
.PP
.nf
typedef struct _hist_entry {
char *line;
histdata_t data;
} HIST_ENTRY;
.fi
.PP
The history list itself might therefore be declared as
.PP
.Vb "HIST_ENTRY **" the_history_list;
.PP
The state of the History library is encapsulated into a single structure:
.PP
.nf
/*
* A structure used to pass around the current state of the history.
*/
typedef struct _hist_state {
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
int offset; /* The location pointer within this array. */
int length; /* Number of elements within this array. */
int size; /* Number of slots allocated to this array. */
int flags;
} HISTORY_STATE;
.fi
.PP
If the flags member includes \fBHS_STIFLED\fP, the history has been
stifled.
.SH "History Functions"
.PP
This section describes the calling sequence for the various functions
exported by the GNU History library.
.SS Initializing History and State Management
This section describes functions used to initialize and manage
the state of the History library when you want to use the history
functions in your program.
.Fn1 void using_history void
Begin a session in which the history functions might be used. This
initializes the interactive variables.
.Fn1 "HISTORY_STATE *" history_get_history_state void
Return a structure describing the current state of the input history.
.Fn1 void history_set_history_state "HISTORY_STATE *state"
Set the state of the history list according to \fIstate\fP.
.SS History List Management
These functions manage individual entries on the history list, or set
parameters managing the list itself.
.Fn1 void add_history "const char *string"
Place \fIstring\fP at the end of the history list. The associated data
field (if any) is set to \fBNULL\fP.
.Fn1 "HIST_ENTRY *" remove_history "int which"
Remove history entry at offset \fIwhich\fP from the history. The
removed element is returned so you can free the line, data,
and containing structure.
.Fn3 "HIST_ENTRY *" replace_history_entry "int which" "const char *line" "histdata_t data"
Make the history entry at offset \fIwhich\fP have \fIline\fP and \fIdata\fP.
This returns the old entry so you can dispose of the data. In the case
of an invalid \fIwhich\fP, a \fBNULL\fP pointer is returned.
.Fn1 void clear_history "void"
Clear the history list by deleting all the entries.
.Fn1 void stifle_history "int max"
Stifle the history list, remembering only the last \fImax\fP entries.
.Fn1 int unstifle_history "void"
Stop stifling the history. This returns the previous amount the
history was stifled. The value is positive if the history was
stifled, negative if it wasn't.
.Fn1 int history_is_stifled "void"
Returns non-zero if the history is stifled, zero if it is not.
.SS Information About the History List
These functions return information about the entire history list or
individual list entries.
.Fn1 "HIST_ENTRY **" history_list "void"
Return a \fBNULL\fP terminated array of \fIHIST_ENTRY *\fP which is the
current input history. Element 0 of this list is the beginning of time.
If there is no history, return \fBNULL\fP.
.Fn1 int where_history "void"
Returns the offset of the current history element.
.Fn1 "HIST_ENTRY *" current_history "void"
Return the history entry at the current position, as determined by
\fBwhere_history()\fP. If there is no entry there, return a \fBNULL\fP
pointer.
.Fn1 "HIST_ENTRY *" history_get "int offset"
Return the history entry at position \fIoffset\fP, starting from
\fBhistory_base\fP.
If there is no entry there, or if \fIoffset\fP
is greater than the history length, return a \fBNULL\fP pointer.
.Fn1 int history_total_bytes "void"
Return the number of bytes that the primary history entries are using.
This function returns the sum of the lengths of all the lines in the
history.
.SS Moving Around the History List
These functions allow the current index into the history list to be
set or changed.
.Fn1 int history_set_pos "int pos"
Set the current history offset to \fIpos\fP, an absolute index
into the list.
Returns 1 on success, 0 if \fIpos\fP is less than zero or greater
than the number of history entries.
.Fn1 "HIST_ENTRY *" previous_history "void"
Back up the current history offset to the previous history entry, and
return a pointer to that entry. If there is no previous entry, return
a \fBNULL\fP pointer.
.Fn1 "HIST_ENTRY *" next_history "void"
Move the current history offset forward to the next history entry, and
return the a pointer to that entry. If there is no next entry, return
a \fBNULL\fP pointer.
.SS Searching the History List
These functions allow searching of the history list for entries containing
a specific string. Searching may be performed both forward and backward
from the current history position. The search may be \fIanchored\fP,
meaning that the string must match at the beginning of the history entry.
.Fn2 int history_search "const char *string" "int direction"
Search the history for \fIstring\fP, starting at the current history offset.
If \fIdirection\fP is less than 0, then the search is through
previous entries, otherwise through subsequent entries.
If \fIstring\fP is found, then
the current history index is set to that history entry, and the value
returned is the offset in the line of the entry where
\fIstring\fP was found. Otherwise, nothing is changed, and a -1 is
returned.
.Fn2 int history_search_prefix "const char *string" "int direction"
Search the history for \fIstring\fP, starting at the current history
offset. The search is anchored: matching lines must begin with
\fIstring\fP. If \fIdirection\fP is less than 0, then the search is
through previous entries, otherwise through subsequent entries.
If \fIstring\fP is found, then the
current history index is set to that entry, and the return value is 0.
Otherwise, nothing is changed, and a -1 is returned.
.Fn3 int history_search_pos "const char *string" "int direction" "int pos"
Search for \fIstring\fP in the history list, starting at \fIpos\fP, an
absolute index into the list. If \fIdirection\fP is negative, the search
proceeds backward from \fIpos\fP, otherwise forward. Returns the absolute
index of the history element where \fIstring\fP was found, or -1 otherwise.
.SS Managing the History File
The History library can read the history from and write it to a file.
This section documents the functions for managing a history file.
.Fn1 int read_history "const char *filename"
Add the contents of \fIfilename\fP to the history list, a line at a time.
If \fIfilename\fP is \fBNULL\fP, then read from \fI~/.history\fP.
Returns 0 if successful, or \fBerrno\fP if not.
.Fn3 int read_history_range "const char *filename" "int from" "int to"
Read a range of lines from \fIfilename\fP, adding them to the history list.
Start reading at line \fIfrom\fP and end at \fIto\fP.
If \fIfrom\fP is zero, start at the beginning. If \fIto\fP is less than
\fIfrom\fP, then read until the end of the file. If \fIfilename\fP is
\fBNULL\fP, then read from \fI~/.history\fP. Returns 0 if successful,
or \fBerrno\fP if not.
.Fn1 int write_history "const char *filename"
Write the current history to \fIfilename\fP, overwriting \fIfilename\fP
if necessary.
If \fIfilename\fP is \fBNULL\fP, then write the history list to \fI~/.history\fP.
Returns 0 on success, or \fBerrno\fP on a read or write error.
.Fn2 int append_history "int nelements" "const char *filename"
Append the last \fInelements\fP of the history list to \fIfilename\fP.
If \fIfilename\fP is \fBNULL\fP, then append to \fI~/.history\fP.
Returns 0 on success, or \fBerrno\fP on a read or write error.
.Fn2 int history_truncate_file "const char *filename" "int nlines"
Truncate the history file \fIfilename\fP, leaving only the last
\fInlines\fP lines.
If \fIfilename\fP is \fBNULL\fP, then \fI~/.history\fP is truncated.
Returns 0 on success, or \fBerrno\fP on failure.
.SS History Expansion
These functions implement history expansion.
.Fn2 int history_expand "char *string" "char **output"
Expand \fIstring\fP, placing the result into \fIoutput\fP, a pointer
to a string. Returns:
.RS
.PD 0
.TP
0
If no expansions took place (or, if the only change in
the text was the removal of escape characters preceding the history expansion
character);
.TP
1
if expansions did take place;
.TP
-1
if there was an error in expansion;
.TP
2
if the returned line should be displayed, but not executed,
as with the \fB:p\fP modifier.
.PD
.RE
If an error ocurred in expansion, then \fIoutput\fP contains a descriptive
error message.
.Fn3 "char *" get_history_event "const char *string" "int *cindex" "int qchar"
Returns the text of the history event beginning at \fIstring\fP +
\fI*cindex\fP. \fI*cindex\fP is modified to point to after the event
specifier. At function entry, \fIcindex\fP points to the index into
\fIstring\fP where the history event specification begins. \fIqchar\fP
is a character that is allowed to end the event specification in addition
to the ``normal'' terminating characters.
.Fn1 "char **" history_tokenize "const char *string"
Return an array of tokens parsed out of \fIstring\fP, much as the
shell might.
The tokens are split on the characters in the
\fBhistory_word_delimiters\fP variable,
and shell quoting conventions are obeyed.
.Fn3 "char *" history_arg_extract "int first" "int last" "const char *string"
Extract a string segment consisting of the \fIfirst\fP through \fIlast\fP
arguments present in \fIstring\fP. Arguments are split using
\fBhistory_tokenize()\fP.
.SS History Variables
This section describes the externally-visible variables exported by
the GNU History Library.
.Vb int history_base
The logical offset of the first entry in the history list.
.Vb int history_length
The number of entries currently stored in the history list.
.Vb int history_max_entries
The maximum number of history entries. This must be changed using
\fBstifle_history()\fP.
.Vb char history_expansion_char
The character that introduces a history event. The default is \fB!\fP.
Setting this to 0 inhibits history expansion.
.Vb char history_subst_char
The character that invokes word substitution if found at the start of
a line. The default is \fB^\fP.
.Vb char history_comment_char
During tokenization, if this character is seen as the first character
of a word, then it and all subsequent characters up to a newline are
ignored, suppressing history expansion for the remainder of the line.
This is disabled by default.
.Vb "char *" history_word_delimiters
The characters that separate tokens for \fBhistory_tokenize()\fP.
The default value is \fB"\ \et\en()<>;&|"\fP.
.Vb "char *" history_no_expand_chars
The list of characters which inhibit history expansion if found immediately
following \fBhistory_expansion_char\fP. The default is space, tab, newline,
\fB\er\fP, and \fB=\fP.
.Vb "char *" history_search_delimiter_chars
The list of additional characters which can delimit a history search
string, in addition to space, tab, \fI:\fP and \fI?\fP in the case of
a substring search. The default is empty.
.Vb int history_quotes_inhibit_expansion
If non-zero, single-quoted words are not scanned for the history expansion
character. The default value is 0.
.Vb "rl_linebuf_func_t *" history_inhibit_expansion_function
This should be set to the address of a function that takes two arguments:
a \fBchar *\fP (\fIstring\fP)
and an \fBint\fP index into that string (\fIi\fP).
It should return a non-zero value if the history expansion starting at
\fIstring[i]\fP should not be performed; zero if the expansion should
be done.
It is intended for use by applications like \fBbash\fP that use the history
expansion character for additional purposes.
By default, this variable is set to \fBNULL\fP.
.SH FILES
.PD 0
.TP
.FN ~/.history
Default filename for reading and writing saved history
.PD
.SH "SEE ALSO"
.PD 0
.TP
\fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
.TP
\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
.TP
\fIbash\fP(1)
.TP
\fIreadline\fP(3)
.PD
.SH AUTHORS
Brian Fox, Free Software Foundation
.br
bfox@gnu.org
.PP
Chet Ramey, Case Western Reserve University
.br
chet@ins.CWRU.Edu
.SH BUG REPORTS
If you find a bug in the
.B history
library, you should report it. But first, you should
make sure that it really is a bug, and that it appears in the latest
version of the
.B history
library that you have.
.PP
Once you have determined that a bug actually exists, mail a
bug report to \fIbug\-readline\fP@\fIgnu.org\fP.
If you have a fix, you are welcome to mail that
as well! Suggestions and `philosophical' bug reports may be mailed
to \fPbug-readline\fP@\fIgnu.org\fP or posted to the Usenet
newsgroup
.BR gnu.bash.bug .
.PP
Comments and bug reports concerning
this manual page should be directed to
.IR chet@ins.CWRU.Edu .

View File

@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
Copyright (C) 1988, 1991, 1994, 1996 Free Software Foundation, Inc.
Copyright (C) 1988-2001 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@ -27,9 +27,9 @@ into another language, under the above conditions for modified versions.
@chapter Programming with GNU History
This chapter describes how to interface programs that you write
with the GNU History Library.
with the @sc{gnu} History Library.
It should be considered a technical guide.
For information on the interactive use of GNU History, @pxref{Using
For information on the interactive use of @sc{gnu} History, @pxref{Using
History Interactively}.
@menu
@ -43,10 +43,10 @@ History Interactively}.
@node Introduction to History
@section Introduction to History
Many programs read input from the user a line at a time. The GNU History
library is able to keep track of those lines, associate arbitrary data with
each line, and utilize information from previous lines in composing new
ones.
Many programs read input from the user a line at a time. The @sc{gnu}
History library is able to keep track of those lines, associate arbitrary
data with each line, and utilize information from previous lines in
composing new ones.
The programmer using the History library has available functions
for remembering lines on a history list, associating arbitrary data
@ -80,9 +80,11 @@ The history list is an array of history entries. A history entry is
declared as follows:
@example
typedef void *histdata_t;
typedef struct _hist_entry @{
char *line;
char *data;
histdata_t data;
@} HIST_ENTRY;
@end example
@ -95,12 +97,14 @@ HIST_ENTRY **the_history_list;
The state of the History library is encapsulated into a single structure:
@example
/* A structure used to pass the current state of the history stuff around. */
/*
* A structure used to pass around the current state of the history.
*/
typedef struct _hist_state @{
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
int offset; /* The location pointer within this array. */
int length; /* Number of elements within this array. */
int size; /* Number of slots allocated to this array. */
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
int offset; /* The location pointer within this array. */
int length; /* Number of elements within this array. */
int size; /* Number of slots allocated to this array. */
int flags;
@} HISTORY_STATE;
@end example
@ -112,7 +116,7 @@ stifled.
@section History Functions
This section describes the calling sequence for the various functions
present in GNU History.
exported by the @sc{gnu} History library.
@menu
* Initializing History and State Management:: Functions to call when you
@ -139,12 +143,12 @@ This section describes functions used to initialize and manage
the state of the History library when you want to use the history
functions in your program.
@deftypefun void using_history ()
@deftypefun void using_history (void)
Begin a session in which the history functions might be used. This
initializes the interactive variables.
@end deftypefun
@deftypefun {HISTORY_STATE *} history_get_history_state ()
@deftypefun {HISTORY_STATE *} history_get_history_state (void)
Return a structure describing the current state of the input history.
@end deftypefun
@ -158,7 +162,7 @@ Set the state of the history list according to @var{state}.
These functions manage individual entries on the history list, or set
parameters managing the list itself.
@deftypefun void add_history (char *string)
@deftypefun void add_history (const char *string)
Place @var{string} at the end of the history list. The associated data
field (if any) is set to @code{NULL}.
@end deftypefun
@ -169,13 +173,13 @@ removed element is returned so you can free the line, data,
and containing structure.
@end deftypefun
@deftypefun {HIST_ENTRY *} replace_history_entry (int which, char *line, char *data)
@deftypefun {HIST_ENTRY *} replace_history_entry (int which, const char *line, histdata_t data)
Make the history entry at offset @var{which} have @var{line} and @var{data}.
This returns the old entry so you can dispose of the data. In the case
of an invalid @var{which}, a @code{NULL} pointer is returned.
@end deftypefun
@deftypefun void clear_history ()
@deftypefun void clear_history (void)
Clear the history list by deleting all the entries.
@end deftypefun
@ -183,13 +187,13 @@ Clear the history list by deleting all the entries.
Stifle the history list, remembering only the last @var{max} entries.
@end deftypefun
@deftypefun int unstifle_history ()
@deftypefun int unstifle_history (void)
Stop stifling the history. This returns the previous amount the
history was stifled. The value is positive if the history was
stifled, negative if it wasn't.
@end deftypefun
@deftypefun int history_is_stifled ()
@deftypefun int history_is_stifled (void)
Returns non-zero if the history is stifled, zero if it is not.
@end deftypefun
@ -199,29 +203,30 @@ Returns non-zero if the history is stifled, zero if it is not.
These functions return information about the entire history list or
individual list entries.
@deftypefun {HIST_ENTRY **} history_list ()
Return a @code{NULL} terminated array of @code{HIST_ENTRY} which is the
@deftypefun {HIST_ENTRY **} history_list (void)
Return a @code{NULL} terminated array of @code{HIST_ENTRY *} which is the
current input history. Element 0 of this list is the beginning of time.
If there is no history, return @code{NULL}.
@end deftypefun
@deftypefun int where_history ()
@deftypefun int where_history (void)
Returns the offset of the current history element.
@end deftypefun
@deftypefun {HIST_ENTRY *} current_history ()
@deftypefun {HIST_ENTRY *} current_history (void)
Return the history entry at the current position, as determined by
@code{where_history ()}. If there is no entry there, return a @code{NULL}
@code{where_history()}. If there is no entry there, return a @code{NULL}
pointer.
@end deftypefun
@deftypefun {HIST_ENTRY *} history_get (int offset)
Return the history entry at position @var{offset}, starting from
@code{history_base}. If there is no entry there, or if @var{offset}
@code{history_base} (@pxref{History Variables}).
If there is no entry there, or if @var{offset}
is greater than the history length, return a @code{NULL} pointer.
@end deftypefun
@deftypefun int history_total_bytes ()
@deftypefun int history_total_bytes (void)
Return the number of bytes that the primary history entries are using.
This function returns the sum of the lengths of all the lines in the
history.
@ -234,17 +239,19 @@ These functions allow the current index into the history list to be
set or changed.
@deftypefun int history_set_pos (int pos)
Set the position in the history list to @var{pos}, an absolute index
Set the current history offset to @var{pos}, an absolute index
into the list.
Returns 1 on success, 0 if @var{pos} is less than zero or greater
than the number of history entries.
@end deftypefun
@deftypefun {HIST_ENTRY *} previous_history ()
@deftypefun {HIST_ENTRY *} previous_history (void)
Back up the current history offset to the previous history entry, and
return a pointer to that entry. If there is no previous entry, return
a @code{NULL} pointer.
@end deftypefun
@deftypefun {HIST_ENTRY *} next_history ()
@deftypefun {HIST_ENTRY *} next_history (void)
Move the current history offset forward to the next history entry, and
return the a pointer to that entry. If there is no next entry, return
a @code{NULL} pointer.
@ -260,26 +267,28 @@ from the current history position. The search may be @dfn{anchored},
meaning that the string must match at the beginning of the history entry.
@cindex anchored search
@deftypefun int history_search (char *string, int direction)
Search the history for @var{string}, starting at the current history
offset. If @var{direction} < 0, then the search is through previous entries,
else through subsequent. If @var{string} is found, then
@deftypefun int history_search (const char *string, int direction)
Search the history for @var{string}, starting at the current history offset.
If @var{direction} is less than 0, then the search is through
previous entries, otherwise through subsequent entries.
If @var{string} is found, then
the current history index is set to that history entry, and the value
returned is the offset in the line of the entry where
@var{string} was found. Otherwise, nothing is changed, and a -1 is
returned.
@end deftypefun
@deftypefun int history_search_prefix (char *string, int direction)
@deftypefun int history_search_prefix (const char *string, int direction)
Search the history for @var{string}, starting at the current history
offset. The search is anchored: matching lines must begin with
@var{string}. If @var{direction} < 0, then the search is through previous
entries, else through subsequent. If @var{string} is found, then the
@var{string}. If @var{direction} is less than 0, then the search is
through previous entries, otherwise through subsequent entries.
If @var{string} is found, then the
current history index is set to that entry, and the return value is 0.
Otherwise, nothing is changed, and a -1 is returned.
@end deftypefun
@deftypefun int history_search_pos (char *string, int direction, int pos)
@deftypefun int history_search_pos (const char *string, int direction, int pos)
Search for @var{string} in the history list, starting at @var{pos}, an
absolute index into the list. If @var{direction} is negative, the search
proceeds backward from @var{pos}, otherwise forward. Returns the absolute
@ -292,41 +301,46 @@ index of the history element where @var{string} was found, or -1 otherwise.
The History library can read the history from and write it to a file.
This section documents the functions for managing a history file.
@deftypefun int read_history (char *filename)
Add the contents of @var{filename} to the history list, a line at a
time. If @var{filename} is @code{NULL}, then read from
@file{~/.history}. Returns 0 if successful, or errno if not.
@deftypefun int read_history (const char *filename)
Add the contents of @var{filename} to the history list, a line at a time.
If @var{filename} is @code{NULL}, then read from @file{~/.history}.
Returns 0 if successful, or @code{errno} if not.
@end deftypefun
@deftypefun int read_history_range (char *filename, int from, int to)
@deftypefun int read_history_range (const char *filename, int from, int to)
Read a range of lines from @var{filename}, adding them to the history list.
Start reading at line @var{from} and end at @var{to}. If
@var{from} is zero, start at the beginning. If @var{to} is less than
Start reading at line @var{from} and end at @var{to}.
If @var{from} is zero, start at the beginning. If @var{to} is less than
@var{from}, then read until the end of the file. If @var{filename} is
@code{NULL}, then read from @file{~/.history}. Returns 0 if successful,
or @code{errno} if not.
@end deftypefun
@deftypefun int write_history (char *filename)
@deftypefun int write_history (const char *filename)
Write the current history to @var{filename}, overwriting @var{filename}
if necessary. If @var{filename} is
@code{NULL}, then write the history list to @file{~/.history}. Values
returned are as in @code{read_history ()}.
if necessary.
If @var{filename} is @code{NULL}, then write the history list to
@file{~/.history}.
Returns 0 on success, or @code{errno} on a read or write error.
@end deftypefun
@deftypefun int append_history (int nelements, char *filename)
@deftypefun int append_history (int nelements, const char *filename)
Append the last @var{nelements} of the history list to @var{filename}.
If @var{filename} is @code{NULL}, then append to @file{~/.history}.
Returns 0 on success, or @code{errno} on a read or write error.
@end deftypefun
@deftypefun int history_truncate_file (char *filename, int nlines)
@deftypefun int history_truncate_file (const char *filename, int nlines)
Truncate the history file @var{filename}, leaving only the last
@var{nlines} lines.
If @var{filename} is @code{NULL}, then @file{~/.history} is truncated.
Returns 0 on success, or @code{errno} on failure.
@end deftypefun
@node History Expansion
@subsection History Expansion
These functions implement @code{csh}-like history expansion.
These functions implement history expansion.
@deftypefun int history_expand (char *string, char **output)
Expand @var{string}, placing the result into @var{output}, a pointer
@ -334,7 +348,7 @@ to a string (@pxref{History Interaction}). Returns:
@table @code
@item 0
If no expansions took place (or, if the only change in
the text was the de-slashifying of the history expansion
the text was the removal of escape characters preceding the history expansion
character);
@item 1
if expansions did take place;
@ -349,12 +363,7 @@ If an error ocurred in expansion, then @var{output} contains a descriptive
error message.
@end deftypefun
@deftypefun {char *} history_arg_extract (int first, int last, char *string)
Extract a string segment consisting of the @var{first} through @var{last}
arguments present in @var{string}. Arguments are broken up as in Bash.
@end deftypefun
@deftypefun {char *} get_history_event (char *string, int *cindex, int qchar)
@deftypefun {char *} get_history_event (const char *string, int *cindex, int qchar)
Returns the text of the history event beginning at @var{string} +
@var{*cindex}. @var{*cindex} is modified to point to after the event
specifier. At function entry, @var{cindex} points to the index into
@ -363,18 +372,24 @@ is a character that is allowed to end the event specification in addition
to the ``normal'' terminating characters.
@end deftypefun
@deftypefun {char **} history_tokenize (char *string)
@deftypefun {char **} history_tokenize (const char *string)
Return an array of tokens parsed out of @var{string}, much as the
shell might. The tokens are split on white space and on the
characters @code{()<>;&|$}, and shell quoting conventions are
obeyed.
shell might. The tokens are split on the characters in the
@var{history_word_delimiters} variable,
and shell quoting conventions are obeyed.
@end deftypefun
@deftypefun {char *} history_arg_extract (int first, int last, const char *string)
Extract a string segment consisting of the @var{first} through @var{last}
arguments present in @var{string}. Arguments are split using
@code{history_tokenize}.
@end deftypefun
@node History Variables
@section History Variables
This section describes the externally visible variables exported by
the GNU History Library.
This section describes the externally-visible variables exported by
the @sc{gnu} History Library.
@deftypevar int history_base
The logical offset of the first entry in the history list.
@ -384,13 +399,14 @@ The logical offset of the first entry in the history list.
The number of entries currently stored in the history list.
@end deftypevar
@deftypevar int max_input_history
@deftypevar int history_max_entries
The maximum number of history entries. This must be changed using
@code{stifle_history ()}.
@code{stifle_history()}.
@end deftypevar
@deftypevar char history_expansion_char
The character that starts a history event. The default is @samp{!}.
The character that introduces a history event. The default is @samp{!}.
Setting this to 0 inhibits history expansion.
@end deftypevar
@deftypevar char history_subst_char
@ -405,15 +421,20 @@ ignored, suppressing history expansion for the remainder of the line.
This is disabled by default.
@end deftypevar
@deftypevar {char *} history_word_delimiters
The characters that separate tokens for \fBhistory_tokenize()\fP.
The default value is @code{" \t\n()<>;&|"}.
@end deftypevar
@deftypevar {char *} history_no_expand_chars
The list of characters which inhibit history expansion if found immediately
following @var{history_expansion_char}. The default is whitespace and
@samp{=}.
following @var{history_expansion_char}. The default is space, tab, newline,
carriage return, and @samp{=}.
@end deftypevar
@deftypevar {char *} history_search_delimiter_chars
The list of additional characters which can delimit a history search
string, in addition to whitespace, @samp{:} and @samp{?} in the case of
string, in addition to space, TAB, @samp{:} and @samp{?} in the case of
a substring search. The default is empty.
@end deftypevar
@ -422,24 +443,30 @@ If non-zero, single-quoted words are not scanned for the history expansion
character. The default value is 0.
@end deftypevar
@deftypevar {Function *} history_inhibit_expansion_function
@deftypevar {rl_linebuf_func_t *} history_inhibit_expansion_function
This should be set to the address of a function that takes two arguments:
a @code{char *} (@var{string}) and an integer index into that string (@var{i}).
a @code{char *} (@var{string})
and an @code{int} index into that string (@var{i}).
It should return a non-zero value if the history expansion starting at
@var{string[i]} should not be performed; zero if the expansion should
be done.
It is intended for use by applications like Bash that use the history
expansion character for additional purposes.
By default, this variable is set to NULL.
By default, this variable is set to @code{NULL}.
@end deftypevar
@node History Programming Example
@section History Programming Example
The following program demonstrates simple use of the GNU History Library.
The following program demonstrates simple use of the @sc{gnu} History Library.
@smallexample
main ()
#include <stdio.h>
#include <readline/history.h>
main (argc, argv)
int argc;
char **argv;
@{
char line[1024], *t;
int len, done = 0;

View File

@ -38,9 +38,9 @@ For information on using the @sc{gnu} History Library in other programs,
see the @sc{gnu} Readline Library Manual.
@end ifset
@ifclear BashFeatures
This chapter describes how to use the GNU History Library interactively,
This chapter describes how to use the @sc{gnu} History Library interactively,
from a user's standpoint. It should be considered a user's guide. For
information on using the GNU History Library in your own programs,
information on using the @sc{gnu} History Library in your own programs,
@pxref{Programming with GNU History}.
@end ifclear
@ -65,36 +65,36 @@ information on using the GNU History Library in your own programs,
@cindex command history
@cindex history list
When the @samp{-o history} option to the @code{set} builtin
When the @option{-o history} option to the @code{set} builtin
is enabled (@pxref{The Set Builtin}),
the shell provides access to the @var{command history},
the shell provides access to the @dfn{command history},
the list of commands previously typed.
The value of the @code{HISTSIZE} shell variable is used as the
The value of the @env{HISTSIZE} shell variable is used as the
number of commands to save in a history list.
The text of the last @code{$HISTSIZE}
The text of the last @env{$HISTSIZE}
commands (default 500) is saved.
The shell stores each command in the history list prior to
parameter and variable expansion
but after history expansion is performed, subject to the
values of the shell variables
@code{HISTIGNORE} and @code{HISTCONTROL}.
@env{HISTIGNORE} and @env{HISTCONTROL}.
When the shell starts up, the history is initialized from the
file named by the @code{HISTFILE} variable (default @file{~/.bash_history}).
The file named by the value of @code{HISTFILE} is truncated, if
file named by the @env{HISTFILE} variable (default @file{~/.bash_history}).
The file named by the value of @env{HISTFILE} is truncated, if
necessary, to contain no more than the number of lines specified by
the value of the @code{HISTFILESIZE} variable.
the value of the @env{HISTFILESIZE} variable.
When an interactive shell exits, the last
@code{$HISTSIZE} lines are copied from the history list to the file
named by @code{$HISTFILE}.
@env{$HISTSIZE} lines are copied from the history list to the file
named by @env{$HISTFILE}.
If the @code{histappend} shell option is set (@pxref{Bash Builtins}),
the lines are appended to the history file,
otherwise the history file is overwritten.
If @code{HISTFILE}
If @env{HISTFILE}
is unset, or if the history file is unwritable, the history is
not saved. After saving the history, the history file is truncated
to contain no more than @code{$HISTFILESIZE}
lines. If @code{HISTFILESIZE} is not set, no truncation is performed.
to contain no more than @env{$HISTFILESIZE}
lines. If @env{HISTFILESIZE} is not set, no truncation is performed.
The builtin command @code{fc} may be used to list or edit and re-execute
a portion of the history list.
@ -105,7 +105,7 @@ are available in each editing mode that provide access to the
history list (@pxref{Commands For History}).
The shell allows control over which commands are saved on the history
list. The @code{HISTCONTROL} and @code{HISTIGNORE}
list. The @env{HISTCONTROL} and @env{HISTIGNORE}
variables may be set to cause the shell to save only a subset of the
commands entered.
The @code{cmdhist}
@ -141,15 +141,15 @@ command beginning with that string) or as a number (an index into the
history list, where a negative number is used as an offset from the
current command number). If @var{last} is not specified it is set to
@var{first}. If @var{first} is not specified it is set to the previous
command for editing and @minus{}16 for listing. If the @samp{-l} flag is
given, the commands are listed on standard output. The @samp{-n} flag
suppresses the command numbers when listing. The @samp{-r} flag
command for editing and @minus{}16 for listing. If the @option{-l} flag is
given, the commands are listed on standard output. The @option{-n} flag
suppresses the command numbers when listing. The @option{-r} flag
reverses the order of the listing. Otherwise, the editor given by
@var{ename} is invoked on a file containing those commands. If
@var{ename} is not given, the value of the following variable expansion
is used: @code{$@{FCEDIT:-$@{EDITOR:-vi@}@}}. This says to use the
value of the @code{FCEDIT} variable if set, or the value of the
@code{EDITOR} variable if that is set, or @code{vi} if neither is set.
value of the @env{FCEDIT} variable if set, or the value of the
@env{EDITOR} variable if that is set, or @code{vi} if neither is set.
When editing is complete, the edited commands are echoed and executed.
In the second form, @var{command} is re-executed after each instance
@ -170,7 +170,7 @@ history -ps @var{arg}
@end example
With no options, display the history list with line numbers.
Lines prefixed with with a @samp{*} have been modified.
Lines prefixed with a @samp{*} have been modified.
An argument of @var{n} lists only the last @var{n} lines.
Options, if supplied, have the following meanings:
@ -211,10 +211,10 @@ the history list as a single entry.
@end table
When any of the @samp{-w}, @samp{-r}, @samp{-a}, or @samp{-n} options is
When any of the @option{-w}, @option{-r}, @option{-a}, or @option{-n} options is
used, if @var{filename}
is given, then it is used as the history file. If not, then
the value of the @code{HISTFILE} variable is used.
the value of the @env{HISTFILE} variable is used.
@end table
@end ifset
@ -260,9 +260,9 @@ editing buffer for further modification.
If Readline is being used, and the @code{histreedit}
shell option is enabled, a failed history expansion will be
reloaded into the Readline editing buffer for correction.
The @samp{-p} option to the @code{history} builtin command
The @option{-p} option to the @code{history} builtin command
may be used to see what a history expansion will do before using it.
The @samp{-s} option to the @code{history} builtin may be used to
The @option{-s} option to the @code{history} builtin may be used to
add commands to the end of the history list without actually executing
them, so that they are available for subsequent recall.
This is most useful in conjunction with Readline.

View File

@ -1,6 +1,6 @@
@set EDITION 4.1
@set VERSION 4.1
@set UPDATED 2000 January 19
@set UPDATE-MONTH January 2000
@set EDITION 4.2-beta
@set VERSION 4.2-beta
@set UPDATED 2001 Mar 12
@set UPDATE-MONTH Mar 2001
@set LASTCHANGE Wed Jan 19 12:16:30 EST 2000
@set LASTCHANGE Mon Mar 12 05:36:44 EST 2001

View File

@ -18,7 +18,7 @@ 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-1999 Free Software Foundation, Inc.
Copyright (C) 1988-2001 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@ -73,7 +73,7 @@ except that this permission notice may be stated in a translation approved
by the Free Software Foundation.
@vskip 0pt plus 1filll
Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
Copyright @copyright{} 1988-2001 Free Software Foundation, Inc.
@end titlepage
@ifinfo

File diff suppressed because it is too large Load Diff

View File

@ -10,7 +10,7 @@ use these features. There is a document entitled "readline.texinfo"
which contains both end-user and programmer documentation for the
GNU Readline Library.
Copyright (C) 1988-1999 Free Software Foundation, Inc.
Copyright (C) 1988-2000 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
@ -72,11 +72,11 @@ used by several different programs, including Bash.
The following paragraphs describe the notation used to represent
keystrokes.
The text @key{C-k} is read as `Control-K' and describes the character
The text @kbd{C-k} is read as `Control-K' and describes the character
produced when the @key{k} key is pressed while the Control key
is depressed.
The text @key{M-k} is read as `Meta-K' and describes the character
The text @kbd{M-k} is read as `Meta-K' and describes the character
produced when the Meta key (if you have one) is depressed, and the @key{k}
key is pressed.
The Meta key is labeled @key{ALT} on many keyboards.
@ -89,11 +89,11 @@ Compose key for typing accented characters.
If you do not have a Meta or @key{ALT} key, or another key working as
a Meta key, the identical keystroke can be generated by typing @key{ESC}
@i{first}, and then typing @key{k}.
@emph{first}, and then typing @key{k}.
Either process is known as @dfn{metafying} the @key{k} key.
The text @key{M-C-k} is read as `Meta-Control-k' and describes the
character produced by @dfn{metafying} @key{C-k}.
The text @kbd{M-C-k} is read as `Meta-Control-k' and describes the
character produced by @dfn{metafying} @kbd{C-k}.
In addition, several keys have their own names. Specifically,
@key{DEL}, @key{ESC}, @key{LFD}, @key{SPC}, @key{RET}, and @key{TAB} all
@ -115,8 +115,8 @@ as you type it in, allowing you to just fix your typo, and not forcing
you to retype the majority of the line. Using these editing commands,
you move the cursor to the place that needs correction, and delete or
insert the text of the corrections. Then, when you are satisfied with
the line, you simply press @key{RETURN}. You do not have to be at the
end of the line to press @key{RETURN}; the entire line is accepted
the line, you simply press @key{RET}. You do not have to be at the
end of the line to press @key{RET}; the entire line is accepted
regardless of the location of the cursor within the line.
@menu
@ -140,9 +140,9 @@ erase character to back up and delete the mistyped character.
Sometimes you may mistype a character, and
not notice the error until you have typed several other characters. In
that case, you can type @key{C-b} to move the cursor to the left, and then
that case, you can type @kbd{C-b} to move the cursor to the left, and then
correct your mistake. Afterwards, you can move the cursor to the right
with @key{C-f}.
with @kbd{C-f}.
When you add text in the middle of a line, you will notice that characters
to the right of the cursor are `pushed over' to make room for the text
@ -152,17 +152,17 @@ blank space created by the removal of the text. A list of the bare
essentials for editing the text of an input line follows.
@table @asis
@item @key{C-b}
@item @kbd{C-b}
Move back one character.
@item @key{C-f}
@item @kbd{C-f}
Move forward one character.
@item @key{DEL} or @key{Backspace}
Delete the character to the left of the cursor.
@item @key{C-d}
@item @kbd{C-d}
Delete the character underneath the cursor.
@item @w{Printing characters}
Insert the character into the line at the cursor.
@item @key{C-_} or @key{C-x C-u}
@item @kbd{C-_} or @kbd{C-x C-u}
Undo the last editing command. You can undo all the way back to an
empty line.
@end table
@ -170,7 +170,7 @@ empty line.
@noindent
(Depending on your configuration, the @key{Backspace} key be set to
delete the character to the left of the cursor and the @key{DEL} key set
to delete the character underneath the cursor, like @key{C-d}, rather
to delete the character underneath the cursor, like @kbd{C-d}, rather
than the character to the left of the cursor.)
@node Readline Movement Commands
@ -179,11 +179,11 @@ than the character to the left of the cursor.)
The above table describes the most basic keystrokes that you need
in order to do editing of the input line. For your convenience, many
other commands have been added in addition to @key{C-b}, @key{C-f},
@key{C-d}, and @key{DEL}. Here are some commands for moving more rapidly
other commands have been added in addition to @kbd{C-b}, @kbd{C-f},
@kbd{C-d}, and @key{DEL}. Here are some commands for moving more rapidly
about the line.
@table @key
@table @kbd
@item C-a
Move to the start of the line.
@item C-e
@ -196,7 +196,7 @@ Move backward a word.
Clear the screen, reprinting the current line at the top.
@end table
Notice how @key{C-f} moves forward a character, while @key{M-f} moves
Notice how @kbd{C-f} moves forward a character, while @kbd{M-f} moves
forward a word. It is a loose convention that control keystrokes
operate on characters while meta keystrokes operate on words.
@ -225,36 +225,36 @@ another line.
Here is the list of commands for killing text.
@table @key
@table @kbd
@item C-k
Kill the text from the current cursor position to the end of the line.
@item M-d
Kill from the cursor to the end of the current word, or, if between
words, to the end of the next word.
Word boundaries are the same as those used by @key{M-f}.
Word boundaries are the same as those used by @kbd{M-f}.
@item M-DEL
@item M-@key{DEL}
Kill from the cursor the start of the previous word, or, if between
words, to the start of the previous word.
Word boundaries are the same as those used by @key{M-b}.
Word boundaries are the same as those used by @kbd{M-b}.
@item C-w
Kill from the cursor to the previous whitespace. This is different than
@key{M-DEL} because the word boundaries differ.
@kbd{M-@key{DEL}} because the word boundaries differ.
@end table
Here is how to @dfn{yank} the text back into the line. Yanking
means to copy the most-recently-killed text from the kill buffer.
@table @key
@table @kbd
@item C-y
Yank the most recently killed text back into the buffer at the cursor.
@item M-y
Rotate the kill-ring, and yank the new top. You can only do this if
the prior command is @key{C-y} or @key{M-y}.
the prior command is @kbd{C-y} or @kbd{M-y}.
@end table
@node Readline Arguments
@ -272,7 +272,8 @@ digits before the command. If the first `digit' typed is a minus
sign (@samp{-}), then the sign of the argument will be negative. Once
you have typed one meta digit to get the argument started, you can type
the remainder of the digits, and then the command. For example, to give
the @key{C-d} command an argument of 10, you could type @samp{M-1 0 C-d}.
the @kbd{C-d} command an argument of 10, you could type @samp{M-1 0 C-d},
which will delete the next ten characters on the input line.
@node Searching
@subsection Searching for Commands in the History
@ -282,7 +283,7 @@ Readline provides commands for searching through the command history
(@pxref{Bash History Facilities})
@end ifset
for lines containing a specified string.
There are two search modes: @var{incremental} and @var{non-incremental}.
There are two search modes: @dfn{incremental} and @dfn{non-incremental}.
Incremental searches begin before the user has finished typing the
search string.
@ -291,23 +292,25 @@ 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.
To search backward in the history for a particular string, type
@key{C-r}. Typing @key{C-s} searches forward through the history.
@kbd{C-r}. Typing @kbd{C-s} searches forward through the history.
The characters present in the value of the @code{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.
@kbd{C-J} characters will terminate an incremental search.
@kbd{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.
To find other matching entries in the history list, type @key{C-r} or
@key{C-s} as appropriate.
To find other matching entries in the history list, type @kbd{C-r} or
@kbd{C-s} as appropriate.
This will search backward or forward in the history for the next
entry matching the search string typed so far.
Any other key sequence bound to a Readline command will terminate
the search and execute that command.
For instance, a @key{RET} will terminate the search and accept
the line, thereby executing the command from the history list.
A movement command will terminate the search, make the last line found
the current line, and begin editing.
Non-incremental searches read the entire search string before starting
to search for matching history lines. The search string may be
@ -324,10 +327,10 @@ Any user can customize programs that use Readline by putting
commands in an @dfn{inputrc} file, conventionally in his home directory.
The name of this
@ifset BashFeatures
file is taken from the value of the shell variable @code{INPUTRC}. If
file is taken from the value of the shell variable @env{INPUTRC}. If
@end ifset
@ifclear BashFeatures
file is taken from the value of the environment variable @code{INPUTRC}. If
file is taken from the value of the environment variable @env{INPUTRC}. If
@end ifclear
that variable is unset, the default is @file{~/.inputrc}.
@ -359,7 +362,15 @@ denote variable settings and key bindings.
@item Variable Settings
You can modify the run-time behavior of Readline by
altering the values of variables in Readline
using the @code{set} command within the init file. Here is how to
using the @code{set} command within the init file.
The syntax is simple:
@example
set @var{variable} @var{value}
@end example
@noindent
Here, for example, is how to
change from the default Emacs-like key binding to use
@code{vi} line editing commands:
@ -367,6 +378,9 @@ change from the default Emacs-like key binding to use
set editing-mode vi
@end example
Variable names and values, where appropriate, are recognized without regard
to case.
@ifset BashFeatures
The @w{@code{bind -V}} command lists the current Readline variable names
and values. @xref{Bash Builtins}.
@ -375,6 +389,7 @@ and values. @xref{Bash Builtins}.
A great deal of run-time behavior is changeable with the following
variables.
@cindex variables, readline
@table @code
@item bell-style
@ -402,13 +417,14 @@ The number of possible completions that determines when the user is
asked whether he wants to see the list of possibilities. If the
number of possible completions is greater than this value,
Readline will ask the user whether or not he wishes to view
them; otherwise, they are simply listed. The default limit is
@code{100}.
them; otherwise, they are simply listed.
This variable must be set to an integer value greater than or equal to 0.
The default limit is @code{100}.
@item convert-meta
@vindex convert-meta
If set to @samp{on}, Readline will convert characters with the
eighth bit set to an ASCII key sequence by stripping the eighth
eighth bit set to an @sc{ascii} key sequence by stripping the eighth
bit and prefixing an @key{ESC} character, converting them to a
meta-prefixed key sequence. The default value is @samp{on}.
@ -448,7 +464,7 @@ this variable is set to @samp{off}.
@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),
will not clear the eighth bit in 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.
@ -458,7 +474,7 @@ synonym for this variable.
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.
@kbd{C-J} will terminate an incremental search.
@item keymap
@vindex keymap
@ -469,6 +485,7 @@ Acceptable @code{keymap} names are
@code{emacs-meta},
@code{emacs-ctlx},
@code{vi},
@code{vi-move},
@code{vi-command}, and
@code{vi-insert}.
@code{vi} is equivalent to @code{vi-command}; @code{emacs} is
@ -520,11 +537,15 @@ want to change. The following sections contain tables of the command
name, the default keybinding, if any, and a short description of what
the command does.
Once you know the name of the command, simply place the name of the key
Once you know the name of the command, simply place on a line
in the init file the name of the key
you wish to bind the command to, a colon, and then the name of the
command on a line in the init file. The name of the key
can be expressed in different ways, depending on which is most
comfortable for you.
command. The name of the key
can be expressed in different ways, depending on what you find most
comfortable.
In addition to command names, readline allows keys to be bound
to a string that is inserted when the key is pressed (a @var{macro}).
@ifset BashFeatures
The @w{@code{bind -p}} command displays Readline function names and
@ -541,11 +562,28 @@ Meta-Rubout: backward-kill-word
Control-o: "> output"
@end example
In the above example, @key{C-u} is bound to the function
@code{universal-argument}, and @key{C-o} is bound to run the macro
In the above example, @kbd{C-u} is bound to the function
@code{universal-argument},
@kbd{M-DEL} is bound to the function @code{backward-kill-word}, and
@kbd{C-o} is bound to run the macro
expressed on the right hand side (that is, to insert the text
@samp{> output} into the line).
A number of symbolic character names are recognized while
processing this key binding syntax:
@var{DEL},
@var{ESC},
@var{ESCAPE},
@var{LFD},
@var{NEWLINE},
@var{RET},
@var{RETURN},
@var{RUBOUT},
@var{SPACE},
@var{SPC},
and
@var{TAB}.
@item @w{"@var{keyseq}": @var{function-name} or @var{macro}}
@var{keyseq} differs from @var{keyname} above in that strings
denoting an entire key sequence can be specified, by placing
@ -559,9 +597,9 @@ special character names are not recognized.
"\e[11~": "Function Key 1"
@end example
In the above example, @key{C-u} is bound to the function
In the above example, @kbd{C-u} is again bound to the function
@code{universal-argument} (just as it was in the first example),
@samp{@key{C-x} @key{C-r}} is bound to the function @code{re-read-init-file},
@samp{@kbd{C-x} @kbd{C-r}} is bound to the function @code{re-read-init-file},
and @samp{@key{ESC} @key{[} @key{1} @key{1} @key{~}} is bound to insert
the text @samp{Function Key 1}.
@ -606,10 +644,10 @@ horizontal tab
@item \v
vertical tab
@item \@var{nnn}
the character whose @code{ASCII} code is the octal value @var{nnn}
the character whose @sc{ascii} code is the octal value @var{nnn}
(one to three digits)
@item \x@var{nnn}
the character whose @code{ASCII} code is the hexadecimal value @var{nnn}
the character whose @sc{ascii} code is the hexadecimal value @var{nnn}
(one to three digits)
@end table
@ -619,7 +657,7 @@ Unquoted text is assumed to be a function name.
In the macro body, the backslash escapes described above are expanded.
Backslash will quote any other character in the macro text,
including @samp{"} and @samp{'}.
For example, the following binding will make @samp{C-x \}
For example, the following binding will make @samp{@kbd{C-x} \}
insert a single @samp{\} into the line:
@example
"\C-x\\": "\\"
@ -663,7 +701,8 @@ for instance.
@item application
The @var{application} construct is used to include
application-specific settings. Each program using the Readline
library sets the @var{application name}, and you can test for it.
library sets the @var{application name}, and you can test for
a particular value.
This could be used to bind key sequences to functions useful for
a specific program. For instance, the following command adds a
key sequence that quotes the current or previous word in Bash:
@ -686,6 +725,7 @@ the test fails.
@item $include
This directive takes a single filename as an argument and reads commands
and bindings from that file.
For example, the following directive reads from @file{/etc/inputrc}:
@example
$include /etc/inputrc
@end example
@ -694,7 +734,7 @@ $include /etc/inputrc
@node Sample Init File
@subsection Sample Init File
Here is an example of an inputrc file. This illustrates key
Here is an example of an @var{inputrc} file. This illustrates key
binding, variable assignment, and conditional syntax.
@example
@ -819,12 +859,12 @@ You can list your key bindings by executing
@w{@code{bind -P}} or, for a more terse format, suitable for an
@var{inputrc} file, @w{@code{bind -p}}. (@xref{Bash Builtins}.)
@end ifset
Command names without an accompanying key sequence are unbound by default.
In the following descriptions, @var{point} refers to the current cursor
position, and @var{mark} refers to a cursor position saved by the
In the following descriptions, @dfn{point} refers to the current cursor
position, and @dfn{mark} refers to a cursor position saved by the
@code{set-mark} command.
The text between the point and mark is referred to as the @var{region}.
The text between the point and mark is referred to as the @dfn{region}.
@node Commands For Moving
@subsection Commands For Moving
@ -862,25 +902,29 @@ Refresh the current line. By default, this is unbound.
@subsection Commands For Manipulating The History
@ftable @code
@item accept-line (Newline, Return)
@item accept-line (Newline or Return)
@ifset BashFeatures
Accept the line regardless of where the cursor is. If this line is
Accept the line regardless of where the cursor is.
If this line is
non-empty, add it to the history list according to the setting of
the @code{HISTCONTROL} and @code{HISTIGNORE} variables.
If this line was a history line, then restore the history line to its
original state.
the @env{HISTCONTROL} and @env{HISTIGNORE} variables.
If this line is a modified history line, then restore the history line
to its original state.
@end ifset
@ifclear BashFeatures
Accept the line regardless of where the cursor is. If this line is
non-empty, add it to the history list. If this line was a history
line, then restore the history line to its original state.
Accept the line regardless of where the cursor is.
If this line is
non-empty, it may be added to the history list for future recall with
@code{add_history()}.
If this line is a modified history line, the history line is restored
to its original state.
@end ifclear
@item previous-history (C-p)
Move `up' through the history list.
Move `back' through the history list, fetching the previous command.
@item next-history (C-n)
Move `down' through the history list.
Move `forward' through the history list, fetching the next command.
@item beginning-of-history (M-<)
Move to the first line in the history.
@ -920,12 +964,13 @@ is a non-incremental search. By default, this command is unbound.
@item yank-nth-arg (M-C-y)
Insert the first argument to the previous command (usually
the second word on the previous line). With an argument @var{n},
the second word on the previous line) at point.
With an argument @var{n},
insert the @var{n}th word from the previous command (the words
in the previous command begin with word 0). A negative argument
inserts the @var{n}th word from the end of the previous command.
@item yank-last-arg (M-., M-_)
@item yank-last-arg (M-. or M-_)
Insert last argument to the previous command (the last word of the
previous history entry). With an
argument, behave exactly like @code{yank-nth-arg}.
@ -939,10 +984,10 @@ list, inserting the last argument of each line in turn.
@ftable @code
@item delete-char (C-d)
Delete the character under the cursor. If the cursor is at the
Delete the character at point. If point is at the
beginning of the line, there are no characters in the line, and
the last character typed was not bound to @code{delete-char}, then
return @code{EOF}.
return @sc{eof}.
@item backward-delete-char (Rubout)
Delete the character behind the cursor. A numeric argument means
@ -953,16 +998,16 @@ 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)
@item quoted-insert (C-q or C-v)
Add the next character typed to the line verbatim. This is
how to insert key sequences like @key{C-q}, for example.
how to insert key sequences like @kbd{C-q}, for example.
@ifclear BashFeatures
@item tab-insert (M-TAB)
@item tab-insert (M-@key{TAB})
Insert a tab character.
@end ifclear
@item self-insert (a, b, A, 1, !, ...)
@item self-insert (a, b, A, 1, !, @dots{})
Insert yourself.
@item transpose-chars (C-t)
@ -1006,7 +1051,7 @@ Kill backward to the beginning of the line.
Kill backward from the cursor to the beginning of the current line.
@item kill-whole-line ()
Kill all characters on the current line, no matter point is.
Kill all characters on the current line, no matter where point is.
By default, this is unbound.
@item kill-word (M-d)
@ -1014,7 +1059,7 @@ Kill from point to the end of the current word, or if between
words, to the end of the next word.
Word boundaries are the same as @code{forward-word}.
@item backward-kill-word (M-DEL)
@item backward-kill-word (M-@key{DEL})
Kill the word behind point.
Word boundaries are the same as @code{backward-word}.
@ -1044,21 +1089,20 @@ The word boundaries are the same as @code{forward-word}.
By default, this command is unbound.
@item yank (C-y)
Yank the top of the kill ring into the buffer at the current
cursor position.
Yank the top of the kill ring into the buffer at point.
@item yank-pop (M-y)
Rotate the kill-ring, and yank the new top. You can only do this if
the prior command is yank or yank-pop.
the prior command is @code{yank} or @code{yank-pop}.
@end ftable
@node Numeric Arguments
@subsection Specifying Numeric Arguments
@ftable @code
@item digit-argument (M-0, M-1, ... M--)
@item digit-argument (@kbd{M-0}, @kbd{M-1}, @dots{} @kbd{M--})
Add this digit to the argument already accumulating, or start a new
argument. @key{M--} starts a negative argument.
argument. @kbd{M--} starts a negative argument.
@item universal-argument ()
This is another way to specify an argument.
@ -1079,13 +1123,9 @@ By default, this is not bound to a key.
@subsection Letting Readline Type For You
@ftable @code
@item complete (TAB)
Attempt to do completion on the text before the cursor. This is
application-specific. Generally, if you are typing a filename
argument, you can do filename completion; if you are typing a command,
you can do command completion; if you are typing in a symbol to GDB, you
can do symbol name completion; if you are typing in a variable to Bash,
you can do variable name completion, and so on.
@item complete (@key{TAB})
Attempt to perform completion on the text before point.
The actual completion performed is application-specific.
@ifset BashFeatures
Bash attempts completion treating the text as a variable (if the
text begins with @samp{$}), username (if the text begins with
@ -1093,9 +1133,12 @@ text begins with @samp{$}), username (if the text begins with
command (including aliases and functions) in turn. If none
of these produces a match, filename completion is attempted.
@end ifset
@ifclear BashFeatures
The default is filename completion.
@end ifclear
@item possible-completions (M-?)
List the possible completions of the text before the cursor.
List the possible completions of the text before point.
@item insert-completions (M-*)
Insert all completions of the text before point that would have
@ -1106,12 +1149,13 @@ Similar to @code{complete}, but replaces the word to be completed
with a single match from the list of possible completions.
Repeated execution of @code{menu-complete} steps through the list
of possible completions, inserting each match in turn.
At the end of the list of completions, the bell is rung and the
original text is restored.
At the end of the list of completions, the bell is rung
(subject to the setting of @code{bell-style})
and the original text is restored.
An argument of @var{n} moves @var{n} positions forward in the list
of matches; a negative argument may be used to move backward
through the list.
This command is intended to be bound to @code{TAB}, but is unbound
This command is intended to be bound to @key{TAB}, but is unbound
by default.
@item delete-char-or-list ()
@ -1164,7 +1208,7 @@ in that order.
List the possible completions of the text before point,
treating it as a command name.
@item dynamic-complete-history (M-TAB)
@item dynamic-complete-history (M-@key{TAB})
Attempt completion on the text before point, comparing
the text against lines from the history list for possible
completion matches.
@ -1211,12 +1255,12 @@ ring the terminal's bell (subject to the setting of
If the metafied character @var{x} is lowercase, run the command
that is bound to the corresponding uppercase character.
@item prefix-meta (ESC)
Make the next character typed be metafied. This is for keyboards
without a meta key. Typing @samp{ESC f} is equivalent to typing
@samp{M-f}.
@item prefix-meta (@key{ESC})
Metafy the next character typed. This is for keyboards
without a meta key. Typing @samp{@key{ESC} f} is equivalent to typing
@kbd{M-f}.
@item undo (C-_, C-x C-u)
@item undo (C-_ or C-x C-u)
Incremental undo, separately remembered for each line.
@item revert-line (M-r)
@ -1232,7 +1276,7 @@ command enough times to get back to the beginning.
Perform tilde expansion on the current word.
@item set-mark (C-@@)
Set the mark to the current point. If a
Set the mark to the point. If a
numeric argument is supplied, the mark is set to that position.
@item exchange-point-and-mark (C-x C-x)
@ -1271,7 +1315,7 @@ of an @var{inputrc} file. This command is unbound by default.
@item dump-macros ()
Print all of the Readline key sequences bound to macros and the
strings they ouput. If a numeric argument is supplied,
strings they output. If a numeric argument is supplied,
the output is formatted in such a way that it can be made part
of an @var{inputrc} file. This command is unbound by default.
@ -1305,7 +1349,7 @@ Perform alias expansion on the current line (@pxref{Aliases}).
@item history-and-alias-expand-line ()
Perform history and alias expansion on the current line.
@item insert-last-argument (M-., M-_)
@item insert-last-argument (M-. or M-_)
A synonym for @code{yank-last-arg}.
@item operate-and-get-next (C-o)
@ -1328,7 +1372,7 @@ been executed.
While the Readline library does not have a full set of @code{vi}
editing functions, it does contain enough to allow simple editing
of the line. The Readline @code{vi} mode behaves as specified in
the @sc{POSIX} 1003.2 standard.
the @sc{posix} 1003.2 standard.
@ifset BashFeatures
In order to switch interactively between @code{emacs} and @code{vi}
@ -1337,7 +1381,8 @@ commands (@pxref{The Set Builtin}).
@end ifset
@ifclear BashFeatures
In order to switch interactively between @code{emacs} and @code{vi}
editing modes, use the command M-C-j (toggle-editing-mode).
editing modes, use the command @kbd{M-C-j} (bound to emacs-editing-mode
when in @code{vi} mode and to vi-editing-mode in @code{emacs} mode).
@end ifclear
The Readline default is @code{emacs} mode.
@ -1374,20 +1419,20 @@ described above (@pxref{Commands For Completion}) is performed.
First, the actions specified by the compspec are used.
Only matches which are prefixed by the word being completed are
returned.
When the @samp{-f} or @samp{-d} option is used for filename or
directory name completion, the shell variable @code{FIGNORE} is
When the @option{-f} or @option{-d} option is used for filename or
directory name completion, the shell variable @env{FIGNORE} is
used to filter the matches.
@xref{Bash Variables}, for a description of @code{FIGNORE}.
@xref{Bash Variables}, for a description of @env{FIGNORE}.
Any completions specified by a filename expansion pattern to the
@samp{-G} option are generated next.
@option{-G} option are generated next.
The words generated by the pattern need not match the word being completed.
The @code{GLOBIGNORE} shell variable is not used to filter the matches,
but the @code{FIGNORE} shell variable is used.
The @env{GLOBIGNORE} shell variable is not used to filter the matches,
but the @env{FIGNORE} shell variable is used.
Next, the string specified as the argument to the @samp{-W} option
Next, the string specified as the argument to the @option{-W} option
is considered.
The string is first split using the characters in the @code{IFS}
The string is first split using the characters in the @env{IFS}
special variable as delimiters.
Shell quoting is honored.
Each word is then expanded using
@ -1400,12 +1445,12 @@ The results of the expansion are prefix-matched against the word being
completed, and the matching words become the possible completions.
After these matches have been generated, any shell function or command
specified with the @samp{-F} and @samp{-C} options is invoked.
When the command or function is invoked, the @code{COMP_LINE} and
@code{COMP_POINT} variables are assigned values as described above
specified with the @option{-F} and @option{-C} options is invoked.
When the command or function is invoked, the @env{COMP_LINE} and
@env{COMP_POINT} variables are assigned values as described above
(@pxref{Bash Variables}).
If a shell function is being invoked, the @code{COMP_WORDS} and
@code{COMP_CWORD} variables are also set.
If a shell function is being invoked, the @env{COMP_WORDS} and
@env{COMP_CWORD} variables are also set.
When the function or command is invoked, the first argument is the
name of the command whose arguments are being completed, the
second argument is the word being completed, and the third argument
@ -1414,21 +1459,21 @@ No filtering of the generated completions against the word being completed
is performed; the function or command has complete freedom in generating
the matches.
Any function specified with @samp{-F} is invoked first.
Any function specified with @option{-F} is invoked first.
The function may use any of the shell facilities, including the
@code{compgen} builtin described below
(@pxref{Programmable Completion Builtins}), to generate the matches.
It must put the possible completions in the @code{COMPREPLY} array
It must put the possible completions in the @env{COMPREPLY} array
variable.
Next, any command specified with the @samp{-C} option is invoked
Next, any command specified with the @option{-C} option is invoked
in an environment equivalent to command substitution.
It should print a list of completions, one per line, to
the standard output.
Backslash may be used to escape a newline, if necessary.
After all of the possible completions are generated, any filter
specified with the @samp{-X} option is applied to the list.
specified with the @option{-X} option is applied to the list.
The filter is a pattern as used for pathname expansion; a @samp{&}
in the pattern is replaced with the text of the word being completed.
A literal @samp{&} may be escaped with a backslash; the backslash
@ -1437,15 +1482,22 @@ Any completion that matches the pattern will be removed from the list.
A leading @samp{!} negates the pattern; in this case any completion
not matching the pattern will be removed.
Finally, any prefix and suffix specified with the @samp{-P} and @samp{-S}
Finally, any prefix and suffix specified with the @option{-P} and @option{-S}
options are added to each member of the completion list, and the result is
returned to the Readline completion code as the list of possible
completions.
If a compspec is found, whatever it generates is returned to the completion
code as the full set of possible completions.
The default Bash completions are not attempted, and the Readline
default of filename completion is disabled.
If the previously-applied actions do not generate any matches, and the
@option{-o dirnames} option was supplied to @code{complete} when the
compspec was defined, directory name completion is attempted.
By default, if a compspec is found, whatever it generates is returned to
the completion code as the full set of possible completions.
The default Bash completions are not attempted, and the Readline default
of filename completion is disabled.
If the @option{-o default} option was supplied to @code{complete} when the
compspec was defined, Readline's default completion will be performed
if the compspec generates no matches.
@node Programmable Completion Builtins
@section Programmable Completion Builtins
@ -1464,9 +1516,9 @@ facilities.
Generate possible completion matches for @var{word} according to
the @var{option}s, which may be any option accepted by the
@code{complete}
builtin with the exception of @samp{-p} and @samp{-r}, and write
builtin with the exception of @option{-p} and @option{-r}, and write
the matches to the standard output.
When using the @samp{-F} or @samp{-C} options, the various shell variables
When using the @option{-F} or @option{-C} options, the various shell variables
set by the programmable completion facilities, while available, will not
have useful values.
@ -1482,17 +1534,17 @@ matches were generated.
@item complete
@btindex complete
@example
@code{complete [-abcdefjkvu] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
@code{complete [-abcdefjkvu] [-o @var{comp-option}] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}]
[-P @var{prefix}] [-S @var{suffix}] [-X @var{filterpat}] [-F @var{function}]
[-C @var{command}] @var{name} [@var{name} @dots{}]}
@code{complete -pr [@var{name} @dots{}]}
@end example
Specify how arguments to each @var{name} should be completed.
If the @samp{-p} option is supplied, or if no options are supplied, existing
If the @option{-p} option is supplied, or if no options are supplied, existing
completion specifications are printed in a way that allows them to be
reused as input.
The @samp{-r} option removes a completion specification for
The @option{-r} option removes a completion specification for
each @var{name}, or, if no @var{name}s are supplied, all
completion specifications.
@ -1500,19 +1552,40 @@ The process of applying these completion specifications when word completion
is attempted is described above (@pxref{Programmable Completion}).
Other options, if specified, have the following meanings.
The arguments to the @samp{-G}, @samp{-W}, and @samp{-X} options
(and, if necessary, the @samp{-P} and @samp{-S} options)
The arguments to the @option{-G}, @option{-W}, and @option{-X} options
(and, if necessary, the @option{-P} and @option{-S} options)
should be quoted to protect them from expansion before the
@code{complete} builtin is invoked.
@table @code
@item -o @var{comp-option}
The @var{comp-option} controls several aspects of the compspec's behavior
beyond the simple generation of completions.
@var{comp-option} may be one of:
@table @code
@item default
Use readline's default completion if the compspec generates no matches.
@item dirnames
Perform directory name completion if the compspec generates no matches.
@item filenames
Tell Readline that the compspec generates filenames, so it can perform any
filename\-specific processing (like adding a slash to directory names or
suppressing trailing spaces). This option is intended to be used with
shell functions specified with @option{-F}.
@end table
@item -A @var{action}
The @var{action} may be one of the following to generate a list of possible
completions:
@table @code
@item alias
Alias names. May also be specified as @samp{-a}.
Alias names. May also be specified as @option{-a}.
@item arrayvar
Array variable names.
@ -1521,13 +1594,13 @@ Array variable names.
Readline key binding names (@pxref{Bindable Readline Commands}).
@item builtin
Names of shell builtin commands. May also be specified as @samp{-b}.
Names of shell builtin commands. May also be specified as @option{-b}.
@item command
Command names. May also be specified as @samp{-c}.
Command names. May also be specified as @option{-c}.
@item directory
Directory names. May also be specified as @samp{-d}.
Directory names. May also be specified as @option{-d}.
@item disabled
Names of disabled shell builtins.
@ -1536,10 +1609,10 @@ Names of disabled shell builtins.
Names of enabled shell builtins.
@item export
Names of exported shell variables. May also be specified as @samp{-e}.
Names of exported shell variables. May also be specified as @option{-e}.
@item file
File names. May also be specified as @samp{-f}.
File names. May also be specified as @option{-f}.
@item function
Names of shell functions.
@ -1549,19 +1622,19 @@ Help topics as accepted by the @code{help} builtin (@pxref{Bash Builtins}).
@item hostname
Hostnames, as taken from the file specified by the
@code{HOSTFILE} shell variable (@pxref{Bash Variables}).
@env{HOSTFILE} shell variable (@pxref{Bash Variables}).
@item job
Job names, if job control is active. May also be specified as @samp{-j}.
Job names, if job control is active. May also be specified as @option{-j}.
@item keyword
Shell reserved words. May also be specified as @samp{-k}.
Shell reserved words. May also be specified as @option{-k}.
@item running
Names of running jobs, if job control is active.
@item setopt
Valid arguments for the @samp{-o} option to the @code{set} builtin
Valid arguments for the @option{-o} option to the @code{set} builtin
(@pxref{The Set Builtin}).
@item shopt
@ -1575,10 +1648,10 @@ Signal names.
Names of stopped jobs, if job control is active.
@item user
User names. May also be specified as @samp{-u}.
User names. May also be specified as @option{-u}.
@item variable
Names of all shell variables. May also be specified as @samp{-v}.
Names of all shell variables. May also be specified as @option{-v}.
@end table
@item -G @var{globpat}
@ -1587,7 +1660,7 @@ the possible completions.
@item -W @var{wordlist}
The @var{wordlist} is split using the characters in the
@code{IFS} special variable as delimiters, and each resultant word
@env{IFS} special variable as delimiters, and each resultant word
is expanded.
The possible completions are the members of the resultant list which
match the word being completed.
@ -1600,7 +1673,7 @@ used as the possible completions.
The shell function @var{function} is executed in the current shell
environment.
When it finishes, the possible completions are retrieved from the value
of the @code{COMPREPLY} array variable.
of the @env{COMPREPLY} array variable.
@item -X @var{filterpat}
@var{filterpat} is a pattern as used for filename expansion.
@ -1620,7 +1693,7 @@ after all other options have been applied.
@end table
The return value is true unless an invalid option is supplied, an option
other than @samp{-p} or @samp{-r} is supplied without a @var{name}
other than @option{-p} or @option{-r} is supplied without a @var{name}
argument, an attempt is made to remove a completion specification for
a @var{name} for which no specification exists, or
an error occurs adding a completion specification.

View File

@ -10,14 +10,14 @@
@ifinfo
@dircategory Libraries
@direntry
* Readline: (readline). The GNU readline library API
* RLuserman: (rluserman). The GNU readline library User's Manual.
@end direntry
This document describes the end user interface of 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-1999 Free Software Foundation, Inc.
Copyright (C) 1988-2001 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@ -72,7 +72,7 @@ except that this permission notice may be stated in a translation approved
by the Free Software Foundation.
@vskip 0pt plus 1filll
Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
Copyright @copyright{} 1988-2001 Free Software Foundation, Inc.
@end titlepage
@ifinfo

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
RL_LIBRARY_VERSION = @LIBVERSION@
SHELL = @MAKE_SHELL@
RM = rm -f
@ -28,7 +29,7 @@ BUILD_DIR = .
DEFS = @DEFS@
CC = @CC@
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DREADLINE_LIBRARY
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DREADLINE_LIBRARY -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
CPPFLAGS = @CPPFLAGS@
INCLUDES = -I$(srcdir) -I$(top_srcdir) -I..
@ -45,10 +46,11 @@ TERMCAP_LIB = @TERMCAP_LIB@
${RM} $@
$(CC) $(CCFLAGS) -c $<
EXECUTABLES = fileman rltest rl rlversion
OBJECTS = fileman.o rltest.o rl.o rlversion.o
EXECUTABLES = fileman rltest rl rlversion histexamp
OBJECTS = fileman.o rltest.o rl.o rlversion.o histexamp.o
all: $(EXECUTABLES)
everything: all rlfe
rl: rl.o
$(CC) $(LDFLAGS) -o $@ rl.o -lreadline $(TERMCAP_LIB)
@ -62,9 +64,13 @@ rltest: rltest.o
rlversion: rlversion.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rlversion.o -lreadline $(TERMCAP_LIB)
histexamp: histexamp.o $(HISTORY_LIB)
$(CC) $(LDFLAGS) -o $@ histexamp.o -lhistory $(TERMCAP_LIB)
clean mostlyclean:
$(RM) $(OBJECTS)
$(RM) $(EXECUTABLES) *.exe
$(RM) rlfe.o rlfe
distclean maintainer-clean: clean
$(RM) Makefile
@ -73,6 +79,13 @@ fileman.o: fileman.c
rltest.o: rltest.c
rl.o: rl.c
rlversion.o: rlversion.c
histexamp.o: histexamp.c
fileman.o: $(top_srcdir)/readline.h
rltest.o: $(top_srcdir)/readline.h
rl.o: $(top_srcdir)/readline.h
rlversion.o: $(top_srcdir)/readline.h
histexamp.o: $(top_srcdir)/history.h
# Stuff for Per Bothner's `rlfe' program

View File

@ -153,6 +153,8 @@ process_line(char *line)
} else {
fprintf(stderr, "|%s|\n", line);
}
free (line);
}
int

View File

@ -41,15 +41,22 @@
extern char *xmalloc ();
/* The names of functions that actually do the manipulation. */
int com_list (), com_view (), com_rename (), com_stat (), com_pwd ();
int com_delete (), com_help (), com_cd (), com_quit ();
int com_list __P((char *));
int com_view __P((char *));
int com_rename __P((char *));
int com_stat __P((char *));
int com_pwd __P((char *));
int com_delete __P((char *));
int com_help __P((char *));
int com_cd __P((char *));
int com_quit __P((char *));
/* A structure which contains information on the commands this program
can understand. */
typedef struct {
char *name; /* User printable name of the function. */
Function *func; /* Function to call to do the job. */
rl_icpfunc_t *func; /* Function to call to do the job. */
char *doc; /* Documentation for this function. */
} COMMAND;
@ -65,7 +72,7 @@ COMMAND commands[] = {
{ "rename", com_rename, "Rename FILE to NEWNAME" },
{ "stat", com_stat, "Print out statistics on FILE" },
{ "view", com_view, "View the contents of FILE" },
{ (char *)NULL, (Function *)NULL, (char *)NULL }
{ (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL }
};
/* Forward declarations. */
@ -205,8 +212,8 @@ stripwhite (string)
/* */
/* **************************************************************** */
char *command_generator ();
char **fileman_completion ();
char *command_generator __P((const char *, int));
char **fileman_completion __P((const char *, int, int));
/* Tell the GNU Readline library how to complete. We want to try to complete
on command names if this is the first word in the line, or on filenames
@ -217,7 +224,7 @@ initialize_readline ()
rl_readline_name = "FileMan";
/* Tell the completer that we want a crack first. */
rl_attempted_completion_function = (CPPFunction *)fileman_completion;
rl_attempted_completion_function = fileman_completion;
}
/* Attempt to complete on the contents of TEXT. START and END bound the
@ -227,7 +234,7 @@ initialize_readline ()
or NULL if there aren't any. */
char **
fileman_completion (text, start, end)
char *text;
const char *text;
int start, end;
{
char **matches;
@ -238,7 +245,7 @@ fileman_completion (text, start, end)
to complete. Otherwise it is the name of a file in the current
directory. */
if (start == 0)
matches = completion_matches (text, command_generator);
matches = rl_completion_matches (text, command_generator);
return (matches);
}
@ -248,7 +255,7 @@ fileman_completion (text, start, end)
start at the top of the list. */
char *
command_generator (text, state)
char *text;
const char *text;
int state;
{
static int list_index, len;

View File

@ -1,4 +1,14 @@
main ()
#include <stdio.h>
#ifdef READLINE_LIBRARY
# include "history.h"
#else
# include <readline/history.h>
#endif
main (argc, argv)
int argc;
char **argv;
{
char line[1024], *t;
int len, done = 0;

View File

@ -3,10 +3,9 @@
#include <stdio.h>
#include <readline/readline.h>
/* **************************************************************** */
/* */
* How to Emulate gets () */
/* How to Emulate gets () */
/* */
/* **************************************************************** */
@ -82,13 +81,12 @@ invert_case_line (count, key)
for (; start != end; start += direction)
{
if (uppercase_p (rl_line_buffer[start]))
rl_line_buffer[start] = to_lower (rl_line_buffer[start]);
else if (lowercase_p (rl_line_buffer[start]))
rl_line_buffer[start] = to_upper (rl_line_buffer[start]);
if (_rl_uppercase_p (rl_line_buffer[start]))
rl_line_buffer[start] = _rl_to_lower (rl_line_buffer[start]);
else if (_rl_lowercase_p (rl_line_buffer[start]))
rl_line_buffer[start] = _rl_to_upper (rl_line_buffer[start]);
}
/* Move point to on top of the last character changed. */
rl_point = end - direction;
}

View File

@ -38,7 +38,7 @@ set_deftext ()
{
rl_insert_text (deftext);
deftext = (char *)NULL;
rl_startup_hook = (Function *)NULL;
rl_startup_hook = (rl_hook_func_t *)NULL;
}
return 0;
}
@ -126,6 +126,6 @@ main (argc, argv)
if (temp == 0)
exit (1);
puts (temp);
printf ("%s\n", temp);
exit (0);
}

View File

@ -64,6 +64,8 @@
#include <unistd.h>
#include <sys/ioctl.h>
#include <termios.h>
#include <limits.h>
#include <dirent.h>
#ifdef READLINE_LIBRARY
# include "readline.h"
@ -81,6 +83,7 @@
#endif
#ifndef HAVE_MEMMOVE
#ifndef memmove
# if __GNUC__ > 1
# define memmove(d, s, n) __builtin_memcpy(d, s, n)
# else
@ -89,8 +92,19 @@
#else
# define memmove(d, s, n) memcpy(d, s, n)
#endif
#endif
#define APPLICATION_NAME "Fep"
#define APPLICATION_NAME "Rlfe"
#ifndef errno
extern int errno;
#endif
extern int optind;
extern char *optarg;
static char *progname;
static char *progversion;
static int in_from_inferior_fd;
static int out_to_inferior_fd;
@ -110,13 +124,15 @@ char echo_suppress_buffer[ECHO_SUPPRESS_MAX];
int echo_suppress_start = 0;
int echo_suppress_limit = 0;
#define DEBUG
/* #define DEBUG */
static FILE *logfile = NULL;
#ifdef DEBUG
FILE *logfile = NULL;
#define DPRINT0(FMT) (fprintf(logfile, FMT), fflush(logfile))
#define DPRINT1(FMT, V1) (fprintf(logfile, FMT, V1), fflush(logfile))
#define DPRINT2(FMT, V1, V2) (fprintf(logfile, FMT, V1, V2), fflush(logfile))
FILE *debugfile = NULL;
#define DPRINT0(FMT) (fprintf(debugfile, FMT), fflush(debugfile))
#define DPRINT1(FMT, V1) (fprintf(debugfile, FMT, V1), fflush(debugfile))
#define DPRINT2(FMT, V1, V2) (fprintf(debugfile, FMT, V1, V2), fflush(debugfile))
#else
#define DPRINT0(FMT) /* Do nothing */
#define DPRINT1(FMT, V1) /* Do nothing */
@ -125,6 +141,10 @@ FILE *logfile = NULL;
struct termios orig_term;
static int rlfe_directory_completion_hook __P((char **));
static int rlfe_directory_rewrite_hook __P((char **));
static char *rlfe_filename_completion_function __P((const char *, int));
/* Pid of child process. */
static pid_t child = -1;
@ -370,13 +390,20 @@ my_rl_getc (FILE *dummy)
return ch;
}
static void
usage()
{
fprintf (stderr, "%s: usage: %s [-l filename] [-a] [-n appname] [-hv] [command [arguments...]]\n",
progname, progname);
}
int
main(int argc, char** argv)
{
char *path;
int i;
int i, append;
int master;
char *name;
char *name, *logfname, *appname;
int in_from_tty_fd;
struct sigaction act;
struct winsize ws;
@ -387,12 +414,58 @@ main(int argc, char** argv)
char *prompt = empty_string;
int ioctl_err = 0;
if ((progname = strrchr (argv[0], '/')) == 0)
progname = argv[0];
else
progname++;
progversion = RL_LIBRARY_VERSION;
append = 0;
appname = APPLICATION_NAME;
logfname = (char *)NULL;
while ((i = getopt (argc, argv, "ahl:n:v")) != EOF)
{
switch (i)
{
case 'l':
logfname = optarg;
break;
case 'n':
appname = optarg;
break;
case 'a':
append = 1;
break;
case 'h':
usage ();
exit (0);
case 'v':
fprintf (stderr, "%s version %s\n", progname, progversion);
exit (0);
default:
usage ();
exit (2);
}
}
argc -= optind;
argv += optind;
if (logfname)
{
logfile = fopen (logfname, append ? "a" : "w");
if (logfile == 0)
fprintf (stderr, "%s: warning: could not open log file %s: %s\n",
progname, logfname, strerror (errno));
}
rl_readline_name = appname;
#ifdef DEBUG
logfile = fopen("LOG", "w");
debugfile = fopen("LOG", "w");
#endif
rl_readline_name = APPLICATION_NAME;
if ((master = get_master_pty(&name)) < 0)
{
perror("ptypair: could not open master pty");
@ -486,10 +559,10 @@ main(int argc, char** argv)
/* now start the shell */
{
static char* command_args[] = { COMMAND_ARGS, NULL };
if (argc <= 1)
if (argc < 1)
execvp(COMMAND, command_args);
else
execvp(argv[1], &argv[1]);
execvp(argv[0], &argv[0]);
}
/* should never be reached */
@ -535,6 +608,13 @@ main(int argc, char** argv)
rl_deprep_term_function = null_deprep_terminal;
rl_callback_handler_install (prompt, line_handler);
#if 1
rl_directory_completion_hook = rlfe_directory_completion_hook;
rl_completion_entry_function = rlfe_filename_completion_function;
#else
rl_directory_rewrite_hook = rlfe_directory_rewrite_hook;
#endif
in_from_tty_fd = STDIN_FILENO;
FD_ZERO (&in_set);
maxfd = in_from_inferior_fd > in_from_tty_fd ? in_from_inferior_fd
@ -644,6 +724,47 @@ main(int argc, char** argv)
}
old_count = buf_count;
/* Do some minimal carriage return translation and backspace
processing before logging the input line. */
if (logfile)
{
#ifndef __GNUC__
char *b;
#else
char b[count + 1];
#endif
int i, j;
#ifndef __GNUC__
b = malloc (count + 1);
if (b) {
#endif
for (i = 0; i < count; i++)
b[i] = buf[buf_count + i];
b[i] = '\0';
for (i = j = 0; i <= count; i++)
{
if (b[i] == '\r')
{
if (b[i+1] != '\n')
b[j++] = '\n';
}
else if (b[i] == '\b')
{
if (i)
j--;
}
else
b[j++] = b[i];
}
fprintf (logfile, "%s", b);
#ifndef __GNUC__
free (b);
}
#endif
}
/* Look for any pending echo that we need to suppress. */
while (echo_suppress_start < echo_suppress_limit
&& count > 0
@ -683,3 +804,239 @@ main(int argc, char** argv)
}
}
}
/*
*
* FILENAME COMPLETION FOR RLFE
*
*/
#ifndef PATH_MAX
# define PATH_MAX 1024
#endif
#define DIRSEP '/'
#define ISDIRSEP(x) ((x) == '/')
#define PATHSEP(x) (ISDIRSEP(x) || (x) == 0)
#define DOT_OR_DOTDOT(x) \
((x)[0] == '.' && (PATHSEP((x)[1]) || \
((x)[1] == '.' && PATHSEP((x)[2]))))
#define FREE(x) if (x) free(x)
#define STRDUP(s, x) do { \
s = strdup (x);\
if (s == 0) \
return ((char *)NULL); \
} while (0)
static int
get_inferior_cwd (path, psize)
char *path;
size_t psize;
{
int n;
static char procfsbuf[PATH_MAX] = { '\0' };
if (procfsbuf[0] == '\0')
sprintf (procfsbuf, "/proc/%d/cwd", (int)child);
n = readlink (procfsbuf, path, psize);
if (n < 0)
return n;
if (n > psize)
return -1;
path[n] = '\0';
return n;
}
static int
rlfe_directory_rewrite_hook (dirnamep)
char **dirnamep;
{
char *ldirname, cwd[PATH_MAX], *retdir, *ld;
int n, ldlen;
ldirname = *dirnamep;
if (*ldirname == '/')
return 0;
n = get_inferior_cwd (cwd, sizeof(cwd) - 1);
if (n < 0)
return 0;
if (n == 0) /* current directory */
{
cwd[0] = '.';
cwd[1] = '\0';
n = 1;
}
/* Minimally canonicalize ldirname by removing leading `./' */
for (ld = ldirname; *ld; )
{
if (ISDIRSEP (ld[0]))
ld++;
else if (ld[0] == '.' && PATHSEP(ld[1]))
ld++;
else
break;
}
ldlen = (ld && *ld) ? strlen (ld) : 0;
retdir = (char *)malloc (n + ldlen + 3);
if (retdir == 0)
return 0;
if (ldlen)
sprintf (retdir, "%s/%s", cwd, ld);
else
strcpy (retdir, cwd);
free (ldirname);
*dirnamep = retdir;
DPRINT1("rl_directory_rewrite_hook returns %s\n", retdir);
return 1;
}
/* Translate *DIRNAMEP to be relative to the inferior's CWD. Leave a trailing
slash on the result. */
static int
rlfe_directory_completion_hook (dirnamep)
char **dirnamep;
{
char *ldirname, *retdir;
int n, ldlen;
ldirname = *dirnamep;
if (*ldirname == '/')
return 0;
n = rlfe_directory_rewrite_hook (dirnamep);
if (n == 0)
return 0;
ldirname = *dirnamep;
ldlen = (ldirname && *ldirname) ? strlen (ldirname) : 0;
if (ldlen == 0 || ldirname[ldlen - 1] != '/')
{
retdir = (char *)malloc (ldlen + 3);
if (retdir == 0)
return 0;
if (ldlen)
strcpy (retdir, ldirname);
else
retdir[ldlen++] = '.';
retdir[ldlen] = '/';
retdir[ldlen+1] = '\0';
free (ldirname);
*dirnamep = retdir;
}
DPRINT1("rl_directory_completion_hook returns %s\n", retdir);
return 1;
}
static char *
rlfe_filename_completion_function (text, state)
const char *text;
int state;
{
static DIR *directory;
static char *filename = (char *)NULL;
static char *dirname = (char *)NULL, *ud = (char *)NULL;
static int flen, udlen;
char *temp;
struct dirent *dentry;
if (state == 0)
{
if (directory)
{
closedir (directory);
directory = 0;
}
FREE (dirname);
FREE (filename);
FREE (ud);
if (text && *text)
STRDUP (filename, text);
else
{
filename = malloc(1);
if (filename == 0)
return ((char *)NULL);
filename[0] = '\0';
}
dirname = (text && *text) ? strdup (text) : strdup (".");
if (dirname == 0)
return ((char *)NULL);
temp = strrchr (dirname, '/');
if (temp)
{
strcpy (filename, ++temp);
*temp = '\0';
}
else
{
dirname[0] = '.';
dirname[1] = '\0';
}
STRDUP (ud, dirname);
udlen = strlen (ud);
rlfe_directory_completion_hook (&dirname);
directory = opendir (dirname);
flen = strlen (filename);
rl_filename_completion_desired = 1;
}
dentry = 0;
while (directory && (dentry = readdir (directory)))
{
if (flen == 0)
{
if (DOT_OR_DOTDOT(dentry->d_name) == 0)
break;
}
else
{
if ((dentry->d_name[0] == filename[0]) &&
(strlen (dentry->d_name) >= flen) &&
(strncmp (filename, dentry->d_name, flen) == 0))
break;
}
}
if (dentry == 0)
{
if (directory)
{
closedir (directory);
directory = 0;
}
FREE (dirname);
FREE (filename);
FREE (ud);
dirname = filename = ud = 0;
return ((char *)NULL);
}
if (ud == 0 || (ud[0] == '.' && ud[1] == '\0'))
temp = strdup (dentry->d_name);
else
{
temp = malloc (1 + udlen + strlen (dentry->d_name));
strcpy (temp, ud);
strcpy (temp + udlen, dentry->d_name);
}
return (temp);
}

View File

@ -46,7 +46,7 @@ typedef int QSFUNC (const void *, const void *);
typedef int QSFUNC ();
#endif
extern int _rl_qsort_string_compare ();
extern int _rl_qsort_string_compare __P((char **, char **));
FUNMAP **funmap;
static int funmap_size;
@ -108,7 +108,7 @@ static FUNMAP default_funmap[] = {
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
#ifdef __CYGWIN32__
#ifdef __CYGWIN__
{ "paste-from-clipboard", rl_paste_from_clipboard },
#endif
{ "possible-completions", rl_possible_completions },
@ -142,7 +142,6 @@ static FUNMAP default_funmap[] = {
{ "vi-arg-digit", rl_vi_arg_digit },
{ "vi-back-to-indent", rl_vi_back_to_indent },
{ "vi-bWord", rl_vi_bWord },
{ "vi-bracktype", rl_vi_bracktype },
{ "vi-bword", rl_vi_bword },
{ "vi-change-case", rl_vi_change_case },
{ "vi-change-char", rl_vi_change_char },
@ -182,13 +181,13 @@ static FUNMAP default_funmap[] = {
{ "vi-yank-to", rl_vi_yank_to },
#endif /* VI_MODE */
{(char *)NULL, (Function *)NULL }
{(char *)NULL, (rl_command_func_t *)NULL }
};
int
rl_add_funmap_entry (name, function)
char *name;
Function *function;
const char *name;
rl_command_func_t *function;
{
if (funmap_entry + 2 >= funmap_size)
{
@ -225,21 +224,21 @@ rl_initialize_funmap ()
/* Produce a NULL terminated array of known function names. The array
is sorted. The array itself is allocated, but not the strings inside.
You should free () the array when you done, but not the pointrs. */
char **
const char **
rl_funmap_names ()
{
char **result;
const char **result;
int result_size, result_index;
/* Make sure that the function map has been initialized. */
rl_initialize_funmap ();
for (result_index = result_size = 0, result = (char **)NULL; funmap[result_index]; result_index++)
for (result_index = result_size = 0, result = (const char **)NULL; funmap[result_index]; result_index++)
{
if (result_index + 2 > result_size)
{
result_size += 20;
result = (char **)xrealloc (result, result_size * sizeof (char *));
result = (const char **)xrealloc (result, result_size * sizeof (char *));
}
result[result_index] = funmap[result_index]->name;
@ -249,12 +248,3 @@ rl_funmap_names ()
qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
return (result);
}
/* Things that mean `Control'. */
char *possible_control_prefixes[] = {
"Control-", "C-", "CTRL-", (char *)NULL
};
char *possible_meta_prefixes[] = {
"Meta", "M-", (char *)NULL
};

View File

@ -56,6 +56,8 @@
#define HISTORY_WORD_DELIMITERS " \t\n;&()|<>"
#define HISTORY_QUOTE_CHARACTERS "\"'`"
typedef int _hist_search_func_t __P((const char *, int));
static char error_pointer;
static char *subst_lhs;
@ -91,9 +93,12 @@ char *history_no_expand_chars = " \t\n\r=";
The default is 0. */
int history_quotes_inhibit_expansion = 0;
/* Used to split words by history_tokenize_internal. */
char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
/* If set, this points to a function that is called to verify that a
particular history expansion should be performed. */
Function *history_inhibit_expansion_function;
rl_linebuf_func_t *history_inhibit_expansion_function;
/* **************************************************************** */
/* */
@ -122,7 +127,7 @@ static char *search_match;
line = get_history_event ("!echo:p", &index, 0); */
char *
get_history_event (string, caller_index, delimiting_quote)
char *string;
const char *string;
int *caller_index;
int delimiting_quote;
{
@ -130,7 +135,7 @@ get_history_event (string, caller_index, delimiting_quote)
register char c;
HIST_ENTRY *entry;
int which, sign, local_index, substring_okay;
Function *search_func;
_hist_search_func_t *search_func;
char *temp;
/* The event can be specified in a number of ways.
@ -340,7 +345,8 @@ hist_error(s, start, current, errtype)
char *s;
int start, current, errtype;
{
char *temp, *emsg;
char *temp;
const char *emsg;
int ll, elen;
ll = current - start;
@ -622,7 +628,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
case '&':
case 's':
{
char *new_event, *t;
char *new_event;
int delimiter, failed, si, l_temp;
if (c == 's')
@ -741,7 +747,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
char *x;
if (want_quotes == 'q')
x = single_quote (temp);
x = sh_single_quote (temp);
else if (want_quotes == 'x')
x = quote_breaks (temp);
else
@ -816,6 +822,9 @@ history_expand (hstring, output)
/* Used when adding the string. */
char *temp;
if (output == 0)
return 0;
/* Setting the history expansion character to 0 inhibits all
history expansion. */
if (history_expansion_char == 0)
@ -865,7 +874,7 @@ history_expand (hstring, output)
history expansion performed on it.
Skip the rest of the line and break out of the loop. */
if (history_comment_char && string[i] == history_comment_char &&
(i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS)))
(i == 0 || member (string[i - 1], history_word_delimiters)))
{
while (string[i])
i++;
@ -963,7 +972,7 @@ history_expand (hstring, output)
}
case -2: /* history_comment_char */
if (i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS))
if (i == 0 || member (string[i - 1], history_word_delimiters))
{
temp = xmalloc (l - i + 1);
strcpy (temp, string + i);
@ -1151,7 +1160,7 @@ get_history_word_specifier (spec, from, caller_index)
char *
history_arg_extract (first, last, string)
int first, last;
char *string;
const char *string;
{
register int i, len;
char *result;
@ -1217,13 +1226,18 @@ history_arg_extract (first, last, string)
*INDP. */
static char **
history_tokenize_internal (string, wind, indp)
char *string;
const char *string;
int wind, *indp;
{
char **result;
register int i, start, result_index, size;
int len, delimiter;
/* If we're searching for a string that's not part of a word (e.g., " "),
make sure we set *INDP to a reasonable value. */
if (indp && wind != -1)
*indp = -1;
/* Get a token, and stuff it into RESULT. The tokens are split
exactly where the shell would split them. */
for (i = result_index = size = 0, result = (char **)NULL; string[i]; )
@ -1298,7 +1312,7 @@ history_tokenize_internal (string, wind, indp)
continue;
}
if (!delimiter && (member (string[i], HISTORY_WORD_DELIMITERS)))
if (!delimiter && (member (string[i], history_word_delimiters)))
break;
if (!delimiter && member (string[i], HISTORY_QUOTE_CHARACTERS))
@ -1328,7 +1342,7 @@ history_tokenize_internal (string, wind, indp)
parsed out of STRING. */
char **
history_tokenize (string)
char *string;
const char *string;
{
return (history_tokenize_internal (string, -1, (int *)NULL));
}
@ -1345,7 +1359,7 @@ history_find_word (line, ind)
int i, wind;
words = history_tokenize_internal (line, ind, &wind);
if (wind == -1)
if (wind == -1 || words == 0)
return ((char *)NULL);
s = words[wind];
for (i = 0; i < wind; i++)

View File

@ -84,9 +84,10 @@ extern int errno;
filename to read_history (), or write_history (). */
static char *
history_filename (filename)
char *filename;
const char *filename;
{
char *return_val, *home;
char *return_val;
const char *home;
int home_len;
return_val = filename ? savestring (filename) : (char *)NULL;
@ -94,7 +95,7 @@ history_filename (filename)
if (return_val)
return (return_val);
home = get_env_value ("HOME");
home = sh_get_env_value ("HOME");
if (home == 0)
{
@ -121,7 +122,7 @@ history_filename (filename)
successful, or errno if not. */
int
read_history (filename)
char *filename;
const char *filename;
{
return (read_history_range (filename, 0, -1));
}
@ -133,7 +134,7 @@ read_history (filename)
~/.history. Returns 0 if successful, or errno if not. */
int
read_history_range (filename, from, to)
char *filename;
const char *filename;
int from, to;
{
register int line_start, line_end;
@ -221,14 +222,15 @@ read_history_range (filename, from, to)
}
/* Truncate the history file FNAME, leaving only LINES trailing lines.
If FNAME is NULL, then use ~/.history. */
If FNAME is NULL, then use ~/.history. Returns 0 on success, errno
on failure. */
int
history_truncate_file (fname, lines)
char *fname;
const char *fname;
int lines;
{
register int i;
int file, chars_read;
int file, chars_read, rv;
char *buffer, *filename;
struct stat finfo;
size_t file_size;
@ -236,13 +238,27 @@ history_truncate_file (fname, lines)
buffer = (char *)NULL;
filename = history_filename (fname);
file = open (filename, O_RDONLY|O_BINARY, 0666);
if (file == -1 || fstat (file, &finfo) == -1)
goto truncate_exit;
rv = 0;
/* Don't try to truncate non-regular files. */
if (S_ISREG(finfo.st_mode) == 0)
goto truncate_exit;
if (file == -1 || fstat (file, &finfo) == -1)
{
rv = errno;
if (file != -1)
close (file);
goto truncate_exit;
}
if (S_ISREG (finfo.st_mode) == 0)
{
close (file);
#ifdef EFTYPE
rv = EFTYPE;
#else
rv = EINVAL;
#endif
goto truncate_exit;
}
file_size = (size_t)finfo.st_size;
@ -251,7 +267,11 @@ history_truncate_file (fname, lines)
{
close (file);
#if defined (EFBIG)
errno = EFBIG;
rv = errno = EFBIG;
#elif defined (EOVERFLOW)
rv = errno = EOVERFLOW;
#else
rv = errno = EINVAL;
#endif
goto truncate_exit;
}
@ -261,7 +281,10 @@ history_truncate_file (fname, lines)
close (file);
if (chars_read <= 0)
goto truncate_exit;
{
rv = (chars_read < 0) ? errno : 0;
goto truncate_exit;
}
/* Count backwards from the end of buffer until we have passed
LINES lines. */
@ -302,7 +325,7 @@ history_truncate_file (fname, lines)
FREE (buffer);
free (filename);
return 0;
return rv;
}
/* Workhorse function for writing history. Writes NELEMENT entries
@ -310,15 +333,16 @@ history_truncate_file (fname, lines)
wish to replace FILENAME with the entries. */
static int
history_do_write (filename, nelements, overwrite)
char *filename;
const char *filename;
int nelements, overwrite;
{
register int i;
char *output;
int file, mode;
int file, mode, rv;
mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
output = history_filename (filename);
rv = 0;
if ((file = open (output, mode, 0600)) == -1)
{
@ -352,7 +376,8 @@ history_do_write (filename, nelements, overwrite)
buffer[j++] = '\n';
}
write (file, buffer, buffer_size);
if (write (file, buffer, buffer_size) < 0)
rv = errno;
free (buffer);
}
@ -360,7 +385,7 @@ history_do_write (filename, nelements, overwrite)
FREE (output);
return (0);
return (rv);
}
/* Append NELEMENT entries to FILENAME. The entries appended are from
@ -368,7 +393,7 @@ history_do_write (filename, nelements, overwrite)
int
append_history (nelements, filename)
int nelements;
char *filename;
const char *filename;
{
return (history_do_write (filename, nelements, HISTORY_APPEND));
}
@ -378,7 +403,7 @@ append_history (nelements, filename)
are as in read_history ().*/
int
write_history (filename)
char *filename;
const char *filename;
{
return (history_do_write (filename, history_length, HISTORY_OVERWRITE));
}

View File

@ -22,15 +22,6 @@
#if !defined (_HISTLIB_H_)
#define _HISTLIB_H_
/* Function pointers can be declared as (Function *)foo. */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif /* _FUNCTION_DEF */
#if !defined (STREQ)
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
#define STREQN(a, b, n) (((n) == 0) ? (1) \

View File

@ -0,0 +1,639 @@
.\"
.\" MAN PAGE COMMENTS to
.\"
.\" Chet Ramey
.\" Information Network Services
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
.\" Last Change: Tue Mar 6 12:50:54 EST 2001
.\"
.TH HISTORY 3 "2001 Mar 6" "GNU History 4.2"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
.\"
.de FN
\fI\|\\$1\|\fP
..
.ds lp \fR\|(\fP
.ds rp \fR\|)\fP
.\" FnN return-value fun-name N arguments
.de Fn1
\fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3\fP\\*(rp
.br
..
.de Fn2
.if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4\fP\\*(rp
.if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4\fP\\*(rp
.br
..
.de Fn3
.if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4,\|\\$5\fP\|\\*(rp
.if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4, \\$5\fP\\*(rp
.br
..
.de Vb
\fI\\$1\fP \fB\\$2\fP
.br
..
.SH NAME
history \- GNU History Library
.SH COPYRIGHT
.if t The GNU History Library is Copyright \(co 1989-2001 by the Free Software Foundation, Inc.
.if n The GNU History Library is Copyright (C) 1989-2001 by the Free Software Foundation, Inc.
.SH DESCRIPTION
Many programs read input from the user a line at a time. The GNU
History library is able to keep track of those lines, associate arbitrary
data with each line, and utilize information from previous lines in
composing new ones.
.PP
.SH "HISTORY EXPANSION"
.PP
The history library supports a history expansion feature that
is identical to the history expansion in
.BR bash.
This section describes what syntax features are available.
.PP
History expansions introduce words from the history list into
the input stream, making it easy to repeat commands, insert the
arguments to a previous command into the current input line, or
fix errors in previous commands quickly.
.PP
History expansion is usually performed immediately after a complete line
is read.
It takes place in two parts.
The first is to determine which line from the history list
to use during substitution.
The second is to select portions of that line for inclusion into
the current one.
The line selected from the history is the \fIevent\fP,
and the portions of that line that are acted upon are \fIwords\fP.
Various \fImodifiers\fP are available to manipulate the selected words.
The line is broken into words in the same fashion as \fBbash\fP
does when reading input,
so that several words that would otherwise be separated
are considered one word when surrounded by quotes (see the
description of \fBhistory_tokenize()\fP below).
History expansions are introduced by the appearance of the
history expansion character, which is \^\fB!\fP\^ by default.
Only backslash (\^\fB\e\fP\^) and single quotes can quote
the history expansion character.
.SS Event Designators
.PP
An event designator is a reference to a command line entry in the
history list.
.PP
.PD 0
.TP
.B !
Start a history substitution, except when followed by a
.BR blank ,
newline, = or (.
.TP
.B !\fIn\fR
Refer to command line
.IR n .
.TP
.B !\-\fIn\fR
Refer to the current command line minus
.IR n .
.TP
.B !!
Refer to the previous command. This is a synonym for `!\-1'.
.TP
.B !\fIstring\fR
Refer to the most recent command starting with
.IR string .
.TP
.B !?\fIstring\fR\fB[?]\fR
Refer to the most recent command containing
.IR string .
The trailing \fB?\fP may be omitted if
.I string
is followed immediately by a newline.
.TP
.B \d\s+2^\s-2\u\fIstring1\fP\d\s+2^\s-2\u\fIstring2\fP\d\s+2^\s-2\u
Quick substitution. Repeat the last command, replacing
.I string1
with
.IR string2 .
Equivalent to
``!!:s/\fIstring1\fP/\fIstring2\fP/''
(see \fBModifiers\fP below).
.TP
.B !#
The entire command line typed so far.
.PD
.SS Word Designators
.PP
Word designators are used to select desired words from the event.
A
.B :
separates the event specification from the word designator.
It may be omitted if the word designator begins with a
.BR ^ ,
.BR $ ,
.BR * ,
.BR \- ,
or
.BR % .
Words are numbered from the beginning of the line,
with the first word being denoted by 0 (zero).
Words are inserted into the current line separated by single spaces.
.PP
.PD 0
.TP
.B 0 (zero)
The zeroth word. For the shell, this is the command
word.
.TP
.I n
The \fIn\fRth word.
.TP
.B ^
The first argument. That is, word 1.
.TP
.B $
The last argument.
.TP
.B %
The word matched by the most recent `?\fIstring\fR?' search.
.TP
.I x\fB\-\fPy
A range of words; `\-\fIy\fR' abbreviates `0\-\fIy\fR'.
.TP
.B *
All of the words but the zeroth. This is a synonym
for `\fI1\-$\fP'. It is not an error to use
.B *
if there is just one
word in the event; the empty string is returned in that case.
.TP
.B x*
Abbreviates \fIx\-$\fP.
.TP
.B x\-
Abbreviates \fIx\-$\fP like \fBx*\fP, but omits the last word.
.PD
.PP
If a word designator is supplied without an event specification, the
previous command is used as the event.
.SS Modifiers
.PP
After the optional word designator, there may appear a sequence of
one or more of the following modifiers, each preceded by a `:'.
.PP
.PD 0
.PP
.TP
.B h
Remove a trailing file name component, leaving only the head.
.TP
.B t
Remove all leading file name components, leaving the tail.
.TP
.B r
Remove a trailing suffix of the form \fI.xxx\fP, leaving the
basename.
.TP
.B e
Remove all but the trailing suffix.
.TP
.B p
Print the new command but do not execute it.
.TP
.B q
Quote the substituted words, escaping further substitutions.
.TP
.B x
Quote the substituted words as with
.BR q ,
but break into words at
.B blanks
and newlines.
.TP
.B s/\fIold\fP/\fInew\fP/
Substitute
.I new
for the first occurrence of
.I old
in the event line. Any delimiter can be used in place of /. The
final delimiter is optional if it is the last character of the
event line. The delimiter may be quoted in
.I old
and
.I new
with a single backslash. If & appears in
.IR new ,
it is replaced by
.IR old .
A single backslash will quote the &. If
.I old
is null, it is set to the last
.I old
substituted, or, if no previous history substitutions took place,
the last
.I string
in a
.B !?\fIstring\fR\fB[?]\fR
search.
.TP
.B &
Repeat the previous substitution.
.TP
.B g
Cause changes to be applied over the entire event line. This is
used in conjunction with `\fB:s\fP' (e.g., `\fB:gs/\fIold\fP/\fInew\fP/\fR')
or `\fB:&\fP'. If used with
`\fB:s\fP', any delimiter can be used
in place of /, and the final delimiter is optional
if it is the last character of the event line.
.PD
.SH "PROGRAMMING WITH HISTORY FUNCTIONS"
This section describes how to use the History library in other programs.
.SS Introduction to History
.PP
The programmer using the History library has available functions
for remembering lines on a history list, associating arbitrary data
with a line, removing lines from the list, searching through the list
for a line containing an arbitrary text string, and referencing any line
in the list directly. In addition, a history \fIexpansion\fP function
is available which provides for a consistent user interface across
different programs.
.PP
The user using programs written with the History library has the
benefit of a consistent user interface with a set of well-known
commands for manipulating the text of previous lines and using that text
in new commands. The basic history manipulation commands are
identical to
the history substitution provided by \fBbash\fP.
.PP
If the programmer desires, he can use the Readline library, which
includes some history manipulation by default, and has the added
advantage of command line editing.
.PP
Before declaring any functions using any functionality the History
library provides in other code, an application writer should include
the file
.FN <readline/history.h>
in any file that uses the
History library's features. It supplies extern declarations for all
of the library's public functions and variables, and declares all of
the public data structures.
.SS History Storage
.PP
The history list is an array of history entries. A history entry is
declared as follows:
.PP
.Vb "typedef void *" histdata_t;
.PP
.nf
typedef struct _hist_entry {
char *line;
histdata_t data;
} HIST_ENTRY;
.fi
.PP
The history list itself might therefore be declared as
.PP
.Vb "HIST_ENTRY **" the_history_list;
.PP
The state of the History library is encapsulated into a single structure:
.PP
.nf
/*
* A structure used to pass around the current state of the history.
*/
typedef struct _hist_state {
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
int offset; /* The location pointer within this array. */
int length; /* Number of elements within this array. */
int size; /* Number of slots allocated to this array. */
int flags;
} HISTORY_STATE;
.fi
.PP
If the flags member includes \fBHS_STIFLED\fP, the history has been
stifled.
.SH "History Functions"
.PP
This section describes the calling sequence for the various functions
exported by the GNU History library.
.SS Initializing History and State Management
This section describes functions used to initialize and manage
the state of the History library when you want to use the history
functions in your program.
.Fn1 void using_history void
Begin a session in which the history functions might be used. This
initializes the interactive variables.
.Fn1 "HISTORY_STATE *" history_get_history_state void
Return a structure describing the current state of the input history.
.Fn1 void history_set_history_state "HISTORY_STATE *state"
Set the state of the history list according to \fIstate\fP.
.SS History List Management
These functions manage individual entries on the history list, or set
parameters managing the list itself.
.Fn1 void add_history "const char *string"
Place \fIstring\fP at the end of the history list. The associated data
field (if any) is set to \fBNULL\fP.
.Fn1 "HIST_ENTRY *" remove_history "int which"
Remove history entry at offset \fIwhich\fP from the history. The
removed element is returned so you can free the line, data,
and containing structure.
.Fn3 "HIST_ENTRY *" replace_history_entry "int which" "const char *line" "histdata_t data"
Make the history entry at offset \fIwhich\fP have \fIline\fP and \fIdata\fP.
This returns the old entry so you can dispose of the data. In the case
of an invalid \fIwhich\fP, a \fBNULL\fP pointer is returned.
.Fn1 void clear_history "void"
Clear the history list by deleting all the entries.
.Fn1 void stifle_history "int max"
Stifle the history list, remembering only the last \fImax\fP entries.
.Fn1 int unstifle_history "void"
Stop stifling the history. This returns the previous amount the
history was stifled. The value is positive if the history was
stifled, negative if it wasn't.
.Fn1 int history_is_stifled "void"
Returns non-zero if the history is stifled, zero if it is not.
.SS Information About the History List
These functions return information about the entire history list or
individual list entries.
.Fn1 "HIST_ENTRY **" history_list "void"
Return a \fBNULL\fP terminated array of \fIHIST_ENTRY *\fP which is the
current input history. Element 0 of this list is the beginning of time.
If there is no history, return \fBNULL\fP.
.Fn1 int where_history "void"
Returns the offset of the current history element.
.Fn1 "HIST_ENTRY *" current_history "void"
Return the history entry at the current position, as determined by
\fBwhere_history()\fP. If there is no entry there, return a \fBNULL\fP
pointer.
.Fn1 "HIST_ENTRY *" history_get "int offset"
Return the history entry at position \fIoffset\fP, starting from
\fBhistory_base\fP.
If there is no entry there, or if \fIoffset\fP
is greater than the history length, return a \fBNULL\fP pointer.
.Fn1 int history_total_bytes "void"
Return the number of bytes that the primary history entries are using.
This function returns the sum of the lengths of all the lines in the
history.
.SS Moving Around the History List
These functions allow the current index into the history list to be
set or changed.
.Fn1 int history_set_pos "int pos"
Set the current history offset to \fIpos\fP, an absolute index
into the list.
Returns 1 on success, 0 if \fIpos\fP is less than zero or greater
than the number of history entries.
.Fn1 "HIST_ENTRY *" previous_history "void"
Back up the current history offset to the previous history entry, and
return a pointer to that entry. If there is no previous entry, return
a \fBNULL\fP pointer.
.Fn1 "HIST_ENTRY *" next_history "void"
Move the current history offset forward to the next history entry, and
return the a pointer to that entry. If there is no next entry, return
a \fBNULL\fP pointer.
.SS Searching the History List
These functions allow searching of the history list for entries containing
a specific string. Searching may be performed both forward and backward
from the current history position. The search may be \fIanchored\fP,
meaning that the string must match at the beginning of the history entry.
.Fn2 int history_search "const char *string" "int direction"
Search the history for \fIstring\fP, starting at the current history offset.
If \fIdirection\fP is less than 0, then the search is through
previous entries, otherwise through subsequent entries.
If \fIstring\fP is found, then
the current history index is set to that history entry, and the value
returned is the offset in the line of the entry where
\fIstring\fP was found. Otherwise, nothing is changed, and a -1 is
returned.
.Fn2 int history_search_prefix "const char *string" "int direction"
Search the history for \fIstring\fP, starting at the current history
offset. The search is anchored: matching lines must begin with
\fIstring\fP. If \fIdirection\fP is less than 0, then the search is
through previous entries, otherwise through subsequent entries.
If \fIstring\fP is found, then the
current history index is set to that entry, and the return value is 0.
Otherwise, nothing is changed, and a -1 is returned.
.Fn3 int history_search_pos "const char *string" "int direction" "int pos"
Search for \fIstring\fP in the history list, starting at \fIpos\fP, an
absolute index into the list. If \fIdirection\fP is negative, the search
proceeds backward from \fIpos\fP, otherwise forward. Returns the absolute
index of the history element where \fIstring\fP was found, or -1 otherwise.
.SS Managing the History File
The History library can read the history from and write it to a file.
This section documents the functions for managing a history file.
.Fn1 int read_history "const char *filename"
Add the contents of \fIfilename\fP to the history list, a line at a time.
If \fIfilename\fP is \fBNULL\fP, then read from \fI~/.history\fP.
Returns 0 if successful, or \fBerrno\fP if not.
.Fn3 int read_history_range "const char *filename" "int from" "int to"
Read a range of lines from \fIfilename\fP, adding them to the history list.
Start reading at line \fIfrom\fP and end at \fIto\fP.
If \fIfrom\fP is zero, start at the beginning. If \fIto\fP is less than
\fIfrom\fP, then read until the end of the file. If \fIfilename\fP is
\fBNULL\fP, then read from \fI~/.history\fP. Returns 0 if successful,
or \fBerrno\fP if not.
.Fn1 int write_history "const char *filename"
Write the current history to \fIfilename\fP, overwriting \fIfilename\fP
if necessary.
If \fIfilename\fP is \fBNULL\fP, then write the history list to \fI~/.history\fP.
Returns 0 on success, or \fBerrno\fP on a read or write error.
.Fn2 int append_history "int nelements" "const char *filename"
Append the last \fInelements\fP of the history list to \fIfilename\fP.
If \fIfilename\fP is \fBNULL\fP, then append to \fI~/.history\fP.
Returns 0 on success, or \fBerrno\fP on a read or write error.
.Fn2 int history_truncate_file "const char *filename" "int nlines"
Truncate the history file \fIfilename\fP, leaving only the last
\fInlines\fP lines.
If \fIfilename\fP is \fBNULL\fP, then \fI~/.history\fP is truncated.
Returns 0 on success, or \fBerrno\fP on failure.
.SS History Expansion
These functions implement history expansion.
.Fn2 int history_expand "char *string" "char **output"
Expand \fIstring\fP, placing the result into \fIoutput\fP, a pointer
to a string. Returns:
.RS
.PD 0
.TP
0
If no expansions took place (or, if the only change in
the text was the removal of escape characters preceding the history expansion
character);
.TP
1
if expansions did take place;
.TP
-1
if there was an error in expansion;
.TP
2
if the returned line should be displayed, but not executed,
as with the \fB:p\fP modifier.
.PD
.RE
If an error ocurred in expansion, then \fIoutput\fP contains a descriptive
error message.
.Fn3 "char *" get_history_event "const char *string" "int *cindex" "int qchar"
Returns the text of the history event beginning at \fIstring\fP +
\fI*cindex\fP. \fI*cindex\fP is modified to point to after the event
specifier. At function entry, \fIcindex\fP points to the index into
\fIstring\fP where the history event specification begins. \fIqchar\fP
is a character that is allowed to end the event specification in addition
to the ``normal'' terminating characters.
.Fn1 "char **" history_tokenize "const char *string"
Return an array of tokens parsed out of \fIstring\fP, much as the
shell might.
The tokens are split on the characters in the
\fBhistory_word_delimiters\fP variable,
and shell quoting conventions are obeyed.
.Fn3 "char *" history_arg_extract "int first" "int last" "const char *string"
Extract a string segment consisting of the \fIfirst\fP through \fIlast\fP
arguments present in \fIstring\fP. Arguments are split using
\fBhistory_tokenize()\fP.
.SS History Variables
This section describes the externally-visible variables exported by
the GNU History Library.
.Vb int history_base
The logical offset of the first entry in the history list.
.Vb int history_length
The number of entries currently stored in the history list.
.Vb int history_max_entries
The maximum number of history entries. This must be changed using
\fBstifle_history()\fP.
.Vb char history_expansion_char
The character that introduces a history event. The default is \fB!\fP.
Setting this to 0 inhibits history expansion.
.Vb char history_subst_char
The character that invokes word substitution if found at the start of
a line. The default is \fB^\fP.
.Vb char history_comment_char
During tokenization, if this character is seen as the first character
of a word, then it and all subsequent characters up to a newline are
ignored, suppressing history expansion for the remainder of the line.
This is disabled by default.
.Vb "char *" history_word_delimiters
The characters that separate tokens for \fBhistory_tokenize()\fP.
The default value is \fB"\ \et\en()<>;&|"\fP.
.Vb "char *" history_no_expand_chars
The list of characters which inhibit history expansion if found immediately
following \fBhistory_expansion_char\fP. The default is space, tab, newline,
\fB\er\fP, and \fB=\fP.
.Vb "char *" history_search_delimiter_chars
The list of additional characters which can delimit a history search
string, in addition to space, tab, \fI:\fP and \fI?\fP in the case of
a substring search. The default is empty.
.Vb int history_quotes_inhibit_expansion
If non-zero, single-quoted words are not scanned for the history expansion
character. The default value is 0.
.Vb "rl_linebuf_func_t *" history_inhibit_expansion_function
This should be set to the address of a function that takes two arguments:
a \fBchar *\fP (\fIstring\fP)
and an \fBint\fP index into that string (\fIi\fP).
It should return a non-zero value if the history expansion starting at
\fIstring[i]\fP should not be performed; zero if the expansion should
be done.
It is intended for use by applications like \fBbash\fP that use the history
expansion character for additional purposes.
By default, this variable is set to \fBNULL\fP.
.SH FILES
.PD 0
.TP
.FN ~/.history
Default filename for reading and writing saved history
.PD
.SH "SEE ALSO"
.PD 0
.TP
\fIThe Gnu Readline Library\fP, Brian Fox and Chet Ramey
.TP
\fIThe Gnu History Library\fP, Brian Fox and Chet Ramey
.TP
\fIbash\fP(1)
.TP
\fIreadline\fP(3)
.PD
.SH AUTHORS
Brian Fox, Free Software Foundation
.br
bfox@gnu.org
.PP
Chet Ramey, Case Western Reserve University
.br
chet@ins.CWRU.Edu
.SH BUG REPORTS
If you find a bug in the
.B history
library, you should report it. But first, you should
make sure that it really is a bug, and that it appears in the latest
version of the
.B history
library that you have.
.PP
Once you have determined that a bug actually exists, mail a
bug report to \fIbug\-readline\fP@\fIgnu.org\fP.
If you have a fix, you are welcome to mail that
as well! Suggestions and `philosophical' bug reports may be mailed
to \fPbug-readline\fP@\fIgnu.org\fP or posted to the Usenet
newsgroup
.BR gnu.bash.bug .
.PP
Comments and bug reports concerning
this manual page should be directed to
.IR chet@ins.CWRU.Edu .

View File

@ -73,7 +73,8 @@ static int history_stifled;
/* If HISTORY_STIFLED is non-zero, then this is the maximum number of
entries to remember. */
int max_input_history;
int history_max_entries;
int max_input_history; /* backwards compatibility */
/* The current location of the interactive history pointer. Just makes
life easier for outside callers. */
@ -134,9 +135,7 @@ history_total_bytes ()
{
register int i, result;
result = 0;
for (i = 0; the_history && the_history[i]; i++)
for (i = result = 0; the_history && the_history[i]; i++)
result += strlen (the_history[i]->line);
return (result);
@ -217,16 +216,16 @@ history_get (offset)
is set to NULL. */
void
add_history (string)
char *string;
const char *string;
{
HIST_ENTRY *temp;
if (history_stifled && (history_length == max_input_history))
if (history_stifled && (history_length == history_max_entries))
{
register int i;
/* If the history is stifled, and history_length is zero,
and it equals max_input_history, we don't save items. */
and it equals history_max_entries, we don't save items. */
if (history_length == 0)
return;
@ -277,15 +276,15 @@ add_history (string)
HIST_ENTRY *
replace_history_entry (which, line, data)
int which;
char *line;
const char *line;
histdata_t data;
{
HIST_ENTRY *temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
HIST_ENTRY *old_value;
HIST_ENTRY *temp, *old_value;
if (which >= history_length)
return ((HIST_ENTRY *)NULL);
temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
old_value = the_history[which];
temp->line = savestring (line);
@ -303,12 +302,12 @@ remove_history (which)
int which;
{
HIST_ENTRY *return_value;
register int i;
if (which >= history_length || !history_length)
return_value = (HIST_ENTRY *)NULL;
else
{
register int i;
return_value = the_history[which];
for (i = which; i < history_length; i++)
@ -325,13 +324,13 @@ void
stifle_history (max)
int max;
{
register int i, j;
if (max < 0)
max = 0;
if (history_length > max)
{
register int i, j;
/* This loses because we cannot free the data. */
for (i = 0, j = history_length - max; i < j; i++)
{
@ -347,7 +346,7 @@ stifle_history (max)
}
history_stifled = 1;
max_input_history = max;
max_input_history = history_max_entries = max;
}
/* Stop stifling the history. This returns the previous amount the
@ -359,10 +358,10 @@ unstifle_history ()
if (history_stifled)
{
history_stifled = 0;
return (-max_input_history);
return (-history_max_entries);
}
return (max_input_history);
return (history_max_entries);
}
int

View File

@ -28,16 +28,10 @@ extern "C" {
#if defined READLINE_LIBRARY
# include "rlstdc.h"
# include "rltypedefs.h"
#else
# include <readline/rlstdc.h>
#endif
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
# include <readline/rltypedefs.h>
#endif
#ifdef __STDC__
@ -80,7 +74,7 @@ extern void history_set_history_state __P((HISTORY_STATE *));
/* Place STRING at the end of the history list.
The associated data field (if any) is set to NULL. */
extern void add_history __P((char *));
extern void add_history __P((const char *));
/* A reasonably useless function, only here for completeness. WHICH
is the magic number that tells us which element to delete. The
@ -90,7 +84,7 @@ 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 __P((int, char *, histdata_t));
extern HIST_ENTRY *replace_history_entry __P((int, const char *, histdata_t));
/* Clear the history list and start over. */
extern void clear_history __P((void));
@ -152,45 +146,45 @@ extern HIST_ENTRY *next_history __P((void));
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 __P((char *, int));
extern int history_search __P((const char *, int));
/* Search the history for STRING, starting at history_offset.
The search is anchored: matching lines must begin with string.
DIRECTION is as in history_search(). */
extern int history_search_prefix __P((char *, int));
extern int history_search_prefix __P((const 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 __P((char *, int, int));
extern int history_search_pos __P((const 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 __P((char *));
extern int read_history __P((const 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 __P((char *, int, int));
extern int read_history_range __P((const 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 __P((char *));
extern int write_history __P((const 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. */
extern int append_history __P((int, char *));
extern int append_history __P((int, const char *));
/* Truncate the history file, leaving only the last NLINES lines. */
extern int history_truncate_file __P((char *, int));
extern int history_truncate_file __P((const char *, int));
/* History expansion. */
@ -211,7 +205,7 @@ 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 __P((int, int, char *));
extern char *history_arg_extract __P((int, int, const char *));
/* Return the text of the history event beginning at the current
offset into STRING. Pass STRING with *INDEX equal to the
@ -219,27 +213,31 @@ extern char *history_arg_extract __P((int, int, char *));
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));
extern char *get_history_event __P((const char *, int *, int));
/* Return an array of tokens, much as the shell might. The tokens are
parsed out of STRING. */
extern char **history_tokenize __P((char *));
extern char **history_tokenize __P((const char *));
/* Exported history variables. */
extern int history_base;
extern int history_length;
extern int max_input_history;
extern int history_max_entries;
extern char history_expansion_char;
extern char history_subst_char;
extern char *history_word_delimiters;
extern char history_comment_char;
extern char *history_no_expand_chars;
extern char *history_search_delimiter_chars;
extern int history_quotes_inhibit_expansion;
/* Backwards compatibility */
extern int max_input_history;
/* If set, this function is called to decide whether or not a particular
history expansion should be treated as a special case for the calling
application and not expanded. */
extern Function *history_inhibit_expansion_function;
extern rl_linebuf_func_t *history_inhibit_expansion_function;
#ifdef __cplusplus
}

View File

@ -63,7 +63,7 @@ char *history_search_delimiter_chars = (char *)NULL;
static int
history_search_internal (string, direction, anchored)
char *string;
const char *string;
int direction, anchored;
{
register int i, reverse;
@ -159,7 +159,7 @@ history_search_internal (string, direction, anchored)
/* Do a non-anchored search for STRING through the history in DIRECTION. */
int
history_search (string, direction)
char *string;
const char *string;
int direction;
{
return (history_search_internal (string, direction, NON_ANCHORED_SEARCH));
@ -168,7 +168,7 @@ history_search (string, direction)
/* Do an anchored search for string through the history in DIRECTION. */
int
history_search_prefix (string, direction)
char *string;
const char *string;
int direction;
{
return (history_search_internal (string, direction, ANCHORED_SEARCH));
@ -179,7 +179,7 @@ history_search_prefix (string, direction)
which point to begin searching. */
int
history_search_pos (string, dir, pos)
char *string;
const char *string;
int dir, pos;
{
int ret, old;

View File

@ -78,9 +78,11 @@ extern int errno;
/* Non-null means it is a pointer to a function to run while waiting for
character input. */
Function *rl_event_hook = (Function *)NULL;
rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL;
Function *rl_getc_function = rl_getc;
rl_getc_func_t *rl_getc_function = rl_getc;
static int _keyboard_input_timeout = 100000; /* 0.1 seconds; it's in usec */
/* **************************************************************** */
/* */
@ -169,7 +171,7 @@ rl_gather_tyi ()
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
timeout.tv_sec = 0;
timeout.tv_usec = 100000; /* 0.1 seconds */
timeout.tv_usec = _keyboard_input_timeout;
if (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) <= 0)
return; /* Nothing to read. */
#endif
@ -222,6 +224,18 @@ rl_gather_tyi ()
}
}
int
rl_set_keyboard_input_timeout (u)
int u;
{
int o;
o = _keyboard_input_timeout;
if (u > 0)
_keyboard_input_timeout = u;
return (o);
}
/* Is there input available to be read on the readline input file
descriptor? Only works if the system has select(2) or FIONREAD. */
int
@ -244,7 +258,7 @@ _rl_input_available ()
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
timeout.tv_sec = 0;
timeout.tv_usec = 100000; /* 0.1 seconds */
timeout.tv_usec = _keyboard_input_timeout;
return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
#endif
@ -293,6 +307,7 @@ rl_stuff_char (key)
{
key = NEWLINE;
rl_pending_input = EOF;
RL_SETSTATE (RL_STATE_INPUTPENDING);
}
ibuffer[push_index++] = key;
if (push_index >= ibuffer_len)
@ -307,6 +322,16 @@ rl_execute_next (c)
int c;
{
rl_pending_input = c;
RL_SETSTATE (RL_STATE_INPUTPENDING);
return 0;
}
/* Clear any pending input pushed with rl_execute_next() */
int
rl_clear_pending_input ()
{
rl_pending_input = 0;
RL_UNSETSTATE (RL_STATE_INPUTPENDING);
return 0;
}
@ -327,7 +352,7 @@ rl_read_key ()
if (rl_pending_input)
{
c = rl_pending_input;
rl_pending_input = 0;
rl_clear_pending_input ();
}
else
{
@ -341,6 +366,8 @@ rl_read_key ()
while (rl_event_hook && rl_get_char (&c) == 0)
{
(*rl_event_hook) ();
if (rl_done) /* XXX - experimental */
return ('\n');
rl_gather_tyi ();
}
}
@ -392,7 +419,7 @@ rl_getc (stream)
if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
{
if (unset_nodelay_mode (fileno (stream)) < 0)
if (sh_unset_nodelay_mode (fileno (stream)) < 0)
return (EOF);
continue;
}

View File

@ -55,7 +55,7 @@
unsigned char *_rl_isearch_terminators = (unsigned char *)NULL;
/* Variables imported from other files in the readline library. */
extern HIST_ENTRY *saved_line_for_history;
extern HIST_ENTRY *_rl_saved_line_for_history;
/* Forward declarations */
static int rl_search_history __P((int, int));
@ -64,6 +64,8 @@ static int rl_search_history __P((int, int));
identical lines many times in a row. */
static char *prev_line_found;
static unsigned char *default_isearch_terminators = "\033\012";
/* Search backwards through the history looking for a string which is typed
interactively. Start with the current line. */
int
@ -176,6 +178,7 @@ rl_search_history (direction, invoking_key)
been set, we use that value, otherwise we use ESC and C-J. */
unsigned char *isearch_terminators;
RL_SETSTATE(RL_STATE_ISEARCH);
orig_point = rl_point;
last_found_line = orig_line = where_history ();
reverse = direction < 0;
@ -183,10 +186,10 @@ rl_search_history (direction, invoking_key)
allocated_line = (char *)NULL;
isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
: (unsigned char *)"\033\012";
: default_isearch_terminators;
/* Create an arrary of pointers to the lines that we want to search. */
maybe_replace_line ();
rl_maybe_replace_line ();
i = 0;
if (hlist)
for (i = 0; hlist[i]; i++);
@ -197,8 +200,8 @@ rl_search_history (direction, invoking_key)
for (i = 0; i < hlen; i++)
lines[i] = hlist[i]->line;
if (saved_line_for_history)
lines[i] = saved_line_for_history->line;
if (_rl_saved_line_for_history)
lines[i] = _rl_saved_line_for_history->line;
else
{
/* Keep track of this so we can free it. */
@ -232,10 +235,12 @@ rl_search_history (direction, invoking_key)
found = failed = 0;
for (;;)
{
Function *f = (Function *)NULL;
rl_command_func_t *f = (rl_command_func_t *)NULL;
/* Read a key and decide how to proceed. */
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (_rl_keymap[c].type == ISFUNC)
{
@ -273,6 +278,8 @@ rl_search_history (direction, invoking_key)
if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('G'))
{
/* This sets rl_pending_input to c; it will be picked up the next
time rl_read_key is called. */
rl_execute_next (c);
break;
}
@ -287,7 +294,7 @@ rl_search_history (direction, invoking_key)
else if (line_index != sline_len)
++line_index;
else
ding ();
rl_ding ();
break;
/* switch directions */
@ -305,13 +312,14 @@ rl_search_history (direction, invoking_key)
if (allocated_line)
free (allocated_line);
free (lines);
RL_UNSETSTATE(RL_STATE_ISEARCH);
return 0;
#if 0
/* delete character from search string. */
case -3:
if (search_string_index == 0)
ding ();
rl_ding ();
else
{
search_string[--search_string_index] = '\0';
@ -384,7 +392,7 @@ rl_search_history (direction, invoking_key)
if (failed)
{
/* We cannot find the search string. Ding the bell. */
ding ();
rl_ding ();
i = last_found_line;
continue; /* XXX - was break */
}
@ -438,5 +446,7 @@ rl_search_history (direction, invoking_key)
free (allocated_line);
free (lines);
RL_UNSETSTATE(RL_STATE_ISEARCH);
return 0;
}

View File

@ -61,7 +61,7 @@ rl_make_bare_keymap ()
for (i = 0; i < KEYMAP_SIZE; i++)
{
keymap[i].type = ISFUNC;
keymap[i].function = (Function *)NULL;
keymap[i].function = (rl_command_func_t *)NULL;
}
for (i = 'A'; i < ('Z' + 1); i++)

View File

@ -30,17 +30,11 @@ extern "C" {
#if defined (READLINE_LIBRARY)
# include "rlstdc.h"
# include "chardefs.h"
# include "rltypedefs.h"
#else
# include <readline/rlstdc.h>
# include <readline/chardefs.h>
#endif
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
# include <readline/rltypedefs.h>
#endif
/* A keymap contains one entry for each key in the ASCII set.
@ -50,7 +44,7 @@ typedef char **CPPFunction ();
TYPE says which kind of thing FUNCTION is. */
typedef struct _keymap_entry {
char type;
Function *function;
rl_command_func_t *function;
} KEYMAP_ENTRY;
/* This must be large enough to hold bindings for all of the characters
@ -59,7 +53,7 @@ typedef struct _keymap_entry {
#define KEYMAP_SIZE 256
/* I wanted to make the above structure contain a union of:
union { Function *function; struct _keymap_entry *keymap; } value;
union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
but this made it impossible for me to create a static array.
Maybe I need C lessons. */
@ -93,7 +87,7 @@ extern void rl_discard_keymap __P((Keymap));
/* 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 __P((char *));
extern Keymap rl_get_keymap_by_name __P((const char *));
/* Return the current keymap. */
extern Keymap rl_get_keymap __P((void));

View File

@ -264,7 +264,7 @@ rl_backward_kill_line (direction, ignore)
else
{
if (!rl_point)
ding ();
rl_ding ();
else
{
rl_beg_of_line (1, ignore);
@ -299,7 +299,7 @@ rl_unix_word_rubout (count, key)
int orig_point;
if (rl_point == 0)
ding ();
rl_ding ();
else
{
orig_point = rl_point;
@ -331,7 +331,7 @@ rl_unix_line_discard (count, key)
int count, key;
{
if (rl_point == 0)
ding ();
rl_ding ();
else
{
rl_kill_text (rl_point, 0);
@ -512,14 +512,14 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
if (entry == 0)
{
ding ();
rl_ding ();
return -1;
}
arg = history_arg_extract (count, count, entry->line);
if (!arg || !*arg)
{
ding ();
rl_ding ();
return -1;
}
@ -592,7 +592,7 @@ rl_yank_last_arg (count, key)
}
/* A special paste command for users of Cygnus's cygwin32. */
#if defined (__CYGWIN32__)
#if defined (__CYGWIN__)
#include <windows.h>
int
@ -625,4 +625,4 @@ rl_paste_from_clipboard (count, key)
}
return (0);
}
#endif /* __CYGWIN32__ */
#endif /* __CYGWIN__ */

View File

@ -57,12 +57,12 @@
/* */
/* **************************************************************** */
/* Non-zero means to save keys that we dispatch on in a kbd macro. */
int _rl_defining_kbd_macro = 0;
/* The currently executing macro string. If this is non-zero,
then it is a malloc ()'ed string where input is coming from. */
char *_rl_executing_macro = (char *)NULL;
char *rl_executing_macro = (char *)NULL;
/* Non-zero means to save keys that we dispatch on in a kbd macro. */
int _rl_defining_kbd_macro = 0;
/* The offset in the above string to the next character to be read. */
static int executing_macro_index;
@ -95,8 +95,9 @@ _rl_with_macro_input (string)
char *string;
{
_rl_push_executing_macro ();
_rl_executing_macro = string;
rl_executing_macro = string;
executing_macro_index = 0;
RL_SETSTATE(RL_STATE_MACROINPUT);
}
/* Return the next character available from a macro, or 0 if
@ -104,16 +105,16 @@ _rl_with_macro_input (string)
int
_rl_next_macro_key ()
{
if (_rl_executing_macro == 0)
if (rl_executing_macro == 0)
return (0);
if (_rl_executing_macro[executing_macro_index] == 0)
if (rl_executing_macro[executing_macro_index] == 0)
{
_rl_pop_executing_macro ();
return (_rl_next_macro_key ());
}
return (_rl_executing_macro[executing_macro_index++]);
return (rl_executing_macro[executing_macro_index++]);
}
/* Save the currently executing macro on a stack of saved macros. */
@ -125,7 +126,7 @@ _rl_push_executing_macro ()
saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro));
saver->next = macro_list;
saver->sindex = executing_macro_index;
saver->string = _rl_executing_macro;
saver->string = rl_executing_macro;
macro_list = saver;
}
@ -137,20 +138,21 @@ _rl_pop_executing_macro ()
{
struct saved_macro *macro;
if (_rl_executing_macro)
free (_rl_executing_macro);
_rl_executing_macro = (char *)NULL;
FREE (rl_executing_macro);
rl_executing_macro = (char *)NULL;
executing_macro_index = 0;
if (macro_list)
{
macro = macro_list;
_rl_executing_macro = macro_list->string;
rl_executing_macro = macro_list->string;
executing_macro_index = macro_list->sindex;
macro_list = macro_list->next;
free (macro);
}
if (rl_executing_macro == 0)
RL_UNSETSTATE(RL_STATE_MACROINPUT);
}
/* Add a character to the macro being built. */
@ -180,14 +182,12 @@ _rl_kill_kbd_macro ()
}
current_macro_size = current_macro_index = 0;
if (_rl_executing_macro)
{
free (_rl_executing_macro);
_rl_executing_macro = (char *) NULL;
}
FREE (rl_executing_macro);
rl_executing_macro = (char *) NULL;
executing_macro_index = 0;
_rl_defining_kbd_macro = 0;
RL_UNSETSTATE(RL_STATE_MACRODEF);
}
/* Begin defining a keyboard macro.
@ -215,6 +215,7 @@ rl_start_kbd_macro (ignore1, ignore2)
current_macro_index = 0;
_rl_defining_kbd_macro = 1;
RL_SETSTATE(RL_STATE_MACRODEF);
return 0;
}
@ -235,6 +236,7 @@ rl_end_kbd_macro (count, ignore)
current_macro[current_macro_index] = '\0';
_rl_defining_kbd_macro = 0;
RL_UNSETSTATE(RL_STATE_MACRODEF);
return (rl_call_last_kbd_macro (--count, 0));
}
@ -250,7 +252,7 @@ rl_call_last_kbd_macro (count, ignore)
if (_rl_defining_kbd_macro)
{
ding (); /* no recursive macros */
rl_ding (); /* no recursive macros */
current_macro[--current_macro_index] = '\0'; /* erase this char */
return 0;
}

View File

@ -105,9 +105,9 @@ _rl_init_eightbit ()
/* We don't have setlocale. Finesse it. Check the environment for the
appropriate variables and set eight-bit mode if they have the right
values. */
lspec = get_env_value ("LC_ALL");
if (lspec == 0) lspec = get_env_value ("LC_CTYPE");
if (lspec == 0) lspec = get_env_value ("LANG");
lspec = sh_get_env_value ("LC_ALL");
if (lspec == 0) lspec = sh_get_env_value ("LC_CTYPE");
if (lspec == 0) lspec = sh_get_env_value ("LANG");
if (lspec == 0 || (t = normalize_codeset (lspec)) == 0)
return (0);
for (i = 0; t && legal_lang_values[i]; i++)

View File

@ -64,6 +64,8 @@ int rl_blink_matching_paren = 1;
int rl_blink_matching_paren = 0;
#endif /* !HAVE_SELECT */
static int _paren_blink_usec = 500000;
/* Change emacs_standard_keymap to have bindings for paren matching when
ON_OR_OFF is 1, change them back to self_insert when ON_OR_OFF == 0. */
void
@ -84,6 +86,18 @@ _rl_enable_paren_matching (on_or_off)
}
}
int
rl_set_paren_blink_timeout (u)
int u;
{
int o;
o = _paren_blink_usec;
if (u > 0)
_paren_blink_usec = u;
return (o);
}
int
rl_insert_close (count, invoking_key)
int count, invoking_key;
@ -109,7 +123,7 @@ rl_insert_close (count, invoking_key)
FD_ZERO (&readfds);
FD_SET (fileno (rl_instream), &readfds);
timer.tv_sec = 0;
timer.tv_usec = 500000;
timer.tv_usec = _paren_blink_usec;
orig_point = rl_point;
rl_point = match_point;

View File

@ -67,7 +67,7 @@
#include "xmalloc.h"
#ifndef RL_LIBRARY_VERSION
# define RL_LIBRARY_VERSION "4.1"
# define RL_LIBRARY_VERSION "4.2"
#endif
/* Evaluates its arguments multiple times. */
@ -90,8 +90,9 @@ static void readline_default_bindings __P((void));
/* */
/* **************************************************************** */
char *rl_library_version = RL_LIBRARY_VERSION;
const char *rl_library_version = RL_LIBRARY_VERSION;
/* True if this is `real' readline as opposed to some stub substitute. */
int rl_gnu_readline_p = 1;
/* A pointer to the keymap that is currently in use.
@ -121,8 +122,13 @@ int rl_arg_sign = 1;
/* Non-zero means we have been called at least once before. */
static int rl_initialized;
#if 0
/* If non-zero, this program is running in an EMACS buffer. */
static int running_in_emacs;
#endif
/* Flags word encapsulating the current readline state. */
int rl_readline_state = RL_STATE_NONE;
/* The current offset in the current input line. */
int rl_point;
@ -137,7 +143,7 @@ int rl_end;
int rl_done;
/* The last function executed by readline. */
Function *rl_last_func = (Function *)NULL;
rl_command_func_t *rl_last_func = (rl_command_func_t *)NULL;
/* Top level environment for readline_internal (). */
procenv_t readline_top_level;
@ -153,7 +159,7 @@ FILE *rl_outstream = (FILE *)NULL;
int readline_echoing_p = 1;
/* Current prompt. */
char *rl_prompt;
char *rl_prompt = (char *)NULL;
int rl_visible_prompt_length = 0;
/* Set to non-zero by calling application if it has already printed rl_prompt
@ -165,12 +171,12 @@ int rl_key_sequence_length = 0;
/* If non-zero, then this is the address of a function to call just
before readline_internal_setup () prints the first prompt. */
Function *rl_startup_hook = (Function *)NULL;
rl_hook_func_t *rl_startup_hook = (rl_hook_func_t *)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;
rl_hook_func_t *rl_pre_input_hook = (rl_hook_func_t *)NULL;
/* What we use internally. You should always refer to RL_LINE_BUFFER. */
static char *the_line;
@ -183,7 +189,7 @@ int _rl_eof_char = CTRL ('D');
int rl_pending_input = 0;
/* Pointer to a useful terminal name. */
char *rl_terminal_name = (char *)NULL;
const char *rl_terminal_name = (const char *)NULL;
/* Non-zero means to always use horizontal scrolling in line display. */
int _rl_horizontal_scroll_mode = 0;
@ -243,24 +249,37 @@ int _rl_output_meta_chars = 0;
/* Non-zero means treat 0200 bit in terminal input as Meta bit. */
int _rl_meta_flag = 0; /* Forward declaration */
/* Set up the prompt and expand it. Called from readline() and
rl_callback_handler_install (). */
int
rl_set_prompt (prompt)
const char *prompt;
{
FREE (rl_prompt);
rl_prompt = prompt ? savestring (prompt) : (char *)NULL;
rl_visible_prompt_length = (rl_prompt && *rl_prompt)
? rl_expand_prompt (rl_prompt)
: 0;
return 0;
}
/* Read a line of input. Prompt with PROMPT. An empty PROMPT means
none. A return value of NULL means that EOF was encountered. */
char *
readline (prompt)
char *prompt;
const char *prompt;
{
char *value;
rl_prompt = prompt;
/* If we are at EOF return a NULL string. */
if (rl_pending_input == EOF)
{
rl_pending_input = 0;
rl_clear_pending_input ();
return ((char *)NULL);
}
rl_visible_prompt_length = rl_expand_prompt (rl_prompt);
rl_set_prompt (prompt);
rl_initialize ();
(*rl_prep_term_function) (_rl_meta_flag);
@ -348,7 +367,7 @@ readline_internal_teardown (eof)
/* At any rate, it is highly likely that this line has an undo list. Get
rid of it now. */
if (rl_undo_list)
free_undo_list ();
rl_free_undo_list ();
return (eof ? (char *)NULL : savestring (the_line));
}
@ -384,7 +403,9 @@ readline_internal_charloop ()
rl_key_sequence_length = 0;
}
RL_SETSTATE(RL_STATE_READCMD);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_READCMD);
/* EOF typed to a non-blank line is a <NL>. */
if (c == EOF && rl_end)
@ -395,6 +416,7 @@ readline_internal_charloop ()
if (((c == _rl_eof_char && lastc != c) || c == EOF) && !rl_end)
{
#if defined (READLINE_CALLBACKS)
RL_SETSTATE(RL_STATE_DONE);
return (rl_done = 1);
#else
eof_found = 1;
@ -491,7 +513,7 @@ _rl_dispatch (key, map)
{
int r, newkey;
char *macro;
Function *func;
rl_command_func_t *func;
if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
{
@ -505,7 +527,7 @@ _rl_dispatch (key, map)
return (_rl_dispatch (key, map));
}
else
ding ();
rl_ding ();
return 0;
}
@ -517,7 +539,7 @@ _rl_dispatch (key, map)
{
case ISFUNC:
func = map[key].function;
if (func != (Function *)NULL)
if (func)
{
/* Special case rl_do_lowercase_version (). */
if (func == rl_do_lowercase_version)
@ -530,13 +552,15 @@ _rl_dispatch (key, map)
#endif
rl_dispatching = 1;
RL_SETSTATE(RL_STATE_DISPATCHING);
r = (*map[key].function)(rl_numeric_arg * rl_arg_sign, key);
RL_UNSETSTATE(RL_STATE_DISPATCHING);
rl_dispatching = 0;
/* If we have input pending, then the last command was a prefix
command. Don't change the state of rl_last_func. Otherwise,
remember the last command executed in this variable. */
if (!rl_pending_input && map[key].function != rl_digit_argument)
if (rl_pending_input == 0 && map[key].function != rl_digit_argument)
rl_last_func = map[key].function;
}
else
@ -547,10 +571,18 @@ _rl_dispatch (key, map)
break;
case ISKMAP:
if (map[key].function != (Function *)NULL)
if (map[key].function != 0)
{
rl_key_sequence_length++;
if (key == ESC)
RL_SETSTATE(RL_STATE_METANEXT);
RL_SETSTATE(RL_STATE_MOREINPUT);
newkey = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (key == ESC)
RL_UNSETSTATE(RL_STATE_METANEXT);
r = _rl_dispatch (newkey, FUNCTION_TO_KEYMAP (map, key));
}
else
@ -561,7 +593,7 @@ _rl_dispatch (key, map)
break;
case ISMACR:
if (map[key].function != (Function *)NULL)
if (map[key].function != 0)
{
macro = savestring ((char *)map[key].function);
_rl_with_macro_input (macro);
@ -591,8 +623,11 @@ rl_initialize ()
terminal and data structures. */
if (!rl_initialized)
{
RL_SETSTATE(RL_STATE_INITIALIZING);
readline_initialize_everything ();
RL_UNSETSTATE(RL_STATE_INITIALIZING);
rl_initialized++;
RL_SETSTATE(RL_STATE_INITIALIZED);
}
/* Initalize the current line information. */
@ -600,6 +635,7 @@ rl_initialize ()
/* We aren't done yet. We haven't even gotten started yet! */
rl_done = 0;
RL_UNSETSTATE(RL_STATE_DONE);
/* Tell the history routines what is going on. */
start_using_history ();
@ -608,7 +644,7 @@ rl_initialize ()
rl_reset_line_state ();
/* No such function typed yet. */
rl_last_func = (Function *)NULL;
rl_last_func = (rl_command_func_t *)NULL;
/* Parsing of key-bindings begins in an enabled state. */
_rl_parsing_conditionalized_out = 0;
@ -658,8 +694,10 @@ readline_initialize_everything ()
#endif
#endif
/* Find out if we are running in Emacs. */
running_in_emacs = get_env_value ("EMACS") != (char *)0;
#if 0
/* Find out if we are running in Emacs -- UNUSED. */
running_in_emacs = sh_get_env_value ("EMACS") != (char *)0;
#endif
/* Set up input and output if they are not already set up. */
if (!rl_instream)
@ -679,7 +717,9 @@ readline_initialize_everything ()
rl_line_buffer = xmalloc (rl_line_buffer_len = DEFAULT_BUFFER_SIZE);
/* Initialize the terminal interface. */
_rl_init_terminal_io ((char *)NULL);
if (rl_terminal_name == 0)
rl_terminal_name = sh_get_env_value ("TERM");
_rl_init_terminal_io (rl_terminal_name);
/* Bind tty characters to readline functions. */
readline_default_bindings ();
@ -696,8 +736,8 @@ readline_initialize_everything ()
/* XXX */
if (_rl_horizontal_scroll_mode && _rl_term_autowrap)
{
screenwidth--;
screenchars -= screenheight;
_rl_screenwidth--;
_rl_screenchars -= _rl_screenheight;
}
/* Override the effect of any `set keymap' assignments in the
@ -723,13 +763,13 @@ readline_initialize_everything ()
static void
readline_default_bindings ()
{
rltty_set_default_bindings (_rl_keymap);
rl_tty_set_default_bindings (_rl_keymap);
}
static void
bind_arrow_keys_internal ()
{
Function *f;
rl_command_func_t *f;
#if defined (__MSDOS__)
f = rl_function_of_keyseq ("\033[0A", _rl_keymap, (int *)NULL);
@ -797,19 +837,23 @@ rl_digit_loop ()
rl_save_prompt ();
RL_SETSTATE(RL_STATE_NUMERICARG);
sawminus = sawdigits = 0;
while (1)
{
if (rl_numeric_arg > 1000000)
{
sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
ding ();
rl_ding ();
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return 1;
}
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
RL_SETSTATE(RL_STATE_MOREINPUT);
key = c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
/* If we see a key bound to `universal-argument' after seeing digits,
it ends the argument but is otherwise ignored. */
@ -823,9 +867,12 @@ rl_digit_loop ()
}
else
{
RL_SETSTATE(RL_STATE_MOREINPUT);
key = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (_rl_dispatch (key, _rl_keymap));
}
}
@ -849,10 +896,12 @@ rl_digit_loop ()
rl_explicit_arg = 1;
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (_rl_dispatch (key, _rl_keymap));
}
}
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return 0;
}
@ -861,7 +910,7 @@ int
rl_digit_argument (ignore, key)
int ignore, key;
{
rl_pending_input = key;
rl_execute_next (key);
return (rl_digit_loop ());
}
@ -869,7 +918,7 @@ rl_digit_argument (ignore, key)
int
rl_discard_argument ()
{
ding ();
rl_ding ();
rl_clear_message ();
_rl_init_argument ();
return 0;
@ -906,7 +955,7 @@ rl_universal_argument (count, key)
function. */
int
rl_insert_text (string)
char *string;
const char *string;
{
register int i, l = strlen (string);
@ -999,7 +1048,7 @@ _rl_fix_point (fix_mark_too)
void
_rl_replace_text (text, start, end)
char *text;
const char *text;
int start, end;
{
rl_begin_undo_group ();
@ -1053,7 +1102,7 @@ rl_forward (count, key)
{
int end = rl_point + count;
#if defined (VI_MODE)
int lend = rl_end - (rl_editing_mode == vi_mode);
int lend = rl_end > 0 ? rl_end - (rl_editing_mode == vi_mode) : rl_end;
#else
int lend = rl_end;
#endif
@ -1061,7 +1110,7 @@ rl_forward (count, key)
if (end > lend)
{
rl_point = lend;
ding ();
rl_ding ();
}
else
rl_point = end;
@ -1085,7 +1134,7 @@ rl_backward (count, key)
if (rl_point < count)
{
rl_point = 0;
ding ();
rl_ding ();
}
else
rl_point -= count;
@ -1132,12 +1181,12 @@ rl_forward_word (count, key)
/* If we are not in a word, move forward until we are in one.
Then, move forward until we hit a non-alphabetic character. */
c = the_line[rl_point];
if (alphabetic (c) == 0)
if (rl_alphabetic (c) == 0)
{
while (++rl_point < rl_end)
{
c = the_line[rl_point];
if (alphabetic (c))
if (rl_alphabetic (c))
break;
}
}
@ -1146,7 +1195,7 @@ rl_forward_word (count, key)
while (++rl_point < rl_end)
{
c = the_line[rl_point];
if (alphabetic (c) == 0)
if (rl_alphabetic (c) == 0)
break;
}
--count;
@ -1176,12 +1225,12 @@ rl_backward_word (count, key)
just before point. */
c = the_line[rl_point - 1];
if (alphabetic (c) == 0)
if (rl_alphabetic (c) == 0)
{
while (--rl_point)
{
c = the_line[rl_point - 1];
if (alphabetic (c))
if (rl_alphabetic (c))
break;
}
}
@ -1189,7 +1238,7 @@ rl_backward_word (count, key)
while (rl_point)
{
c = the_line[rl_point - 1];
if (alphabetic (c) == 0)
if (rl_alphabetic (c) == 0)
break;
else
--rl_point;
@ -1245,7 +1294,9 @@ rl_arrow_keys (count, c)
{
int ch;
RL_SETSTATE(RL_STATE_MOREINPUT);
ch = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
switch (_rl_to_upper (ch))
{
@ -1266,7 +1317,7 @@ rl_arrow_keys (count, c)
break;
default:
ding ();
rl_ding ();
}
return 0;
}
@ -1352,7 +1403,11 @@ rl_quoted_insert (count, key)
#if defined (HANDLE_SIGNALS)
_rl_disable_tty_signals ();
#endif
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
#if defined (HANDLE_SIGNALS)
_rl_restore_tty_signals ();
#endif
@ -1376,6 +1431,7 @@ rl_newline (count, key)
int count, key;
{
rl_done = 1;
RL_SETSTATE(RL_STATE_DONE);
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
@ -1386,7 +1442,7 @@ 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(). */
since _rl_update_final calls rl_crlf(). */
if (rl_erase_empty_line && rl_point == 0 && rl_end == 0)
return 0;
@ -1419,7 +1475,7 @@ rl_rubout (count, key)
if (!rl_point)
{
ding ();
rl_ding ();
return -1;
}
@ -1455,7 +1511,7 @@ rl_delete (count, key)
if (rl_point == rl_end)
{
ding ();
rl_ding ();
return -1;
}
@ -1611,11 +1667,11 @@ rl_change_case (count, op)
case CapCase:
the_line[start] = (inword == 0) ? _rl_to_upper (c) : _rl_to_lower (c);
inword = alphabetic (the_line[start]);
inword = rl_alphabetic (the_line[start]);
break;
default:
ding ();
rl_ding ();
return -1;
}
}
@ -1654,7 +1710,7 @@ rl_transpose_words (count, key)
/* Do some check to make sure that there really are two words. */
if ((w1_beg == w2_beg) || (w2_beg < w1_end))
{
ding ();
rl_ding ();
rl_point = orig_point;
return -1;
}
@ -1702,7 +1758,7 @@ rl_transpose_chars (count, key)
if (!rl_point || rl_end < 2)
{
ding ();
rl_ding ();
return -1;
}
@ -1746,7 +1802,7 @@ _rl_char_search_internal (count, dir, schar)
{
if ((dir < 0 && pos <= 0) || (dir > 0 && pos >= rl_end))
{
ding ();
rl_ding ();
return -1;
}
@ -1777,7 +1833,10 @@ _rl_char_search (count, fdir, bdir)
{
int c;
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (count < 0)
return (_rl_char_search_internal (-count, bdir, c));
else
@ -1810,17 +1869,17 @@ rl_backward_char_search (count, key)
/* While we are editing the history, this is the saved
version of the original line. */
HIST_ENTRY *saved_line_for_history = (HIST_ENTRY *)NULL;
HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
/* Set the history pointer back to the last entry in the history. */
static void
start_using_history ()
{
using_history ();
if (saved_line_for_history)
_rl_free_history_entry (saved_line_for_history);
if (_rl_saved_line_for_history)
_rl_free_history_entry (_rl_saved_line_for_history);
saved_line_for_history = (HIST_ENTRY *)NULL;
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Free the contents (and containing structure) of a HIST_ENTRY. */
@ -1837,7 +1896,7 @@ _rl_free_history_entry (entry)
/* Perhaps put back the current line if it has changed. */
int
maybe_replace_line ()
rl_maybe_replace_line ()
{
HIST_ENTRY *temp;
@ -1852,43 +1911,54 @@ maybe_replace_line ()
return 0;
}
/* Put back the saved_line_for_history if there is one. */
/* Restore the _rl_saved_line_for_history if there is one. */
int
maybe_unsave_line ()
rl_maybe_unsave_line ()
{
int line_len;
if (saved_line_for_history)
if (_rl_saved_line_for_history)
{
line_len = strlen (saved_line_for_history->line);
line_len = strlen (_rl_saved_line_for_history->line);
if (line_len >= rl_line_buffer_len)
rl_extend_line_buffer (line_len);
strcpy (the_line, saved_line_for_history->line);
rl_undo_list = (UNDO_LIST *)saved_line_for_history->data;
_rl_free_history_entry (saved_line_for_history);
saved_line_for_history = (HIST_ENTRY *)NULL;
strcpy (the_line, _rl_saved_line_for_history->line);
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
rl_end = rl_point = strlen (the_line);
}
else
ding ();
rl_ding ();
return 0;
}
/* Save the current line in saved_line_for_history. */
/* Save the current line in _rl_saved_line_for_history. */
int
maybe_save_line ()
rl_maybe_save_line ()
{
if (saved_line_for_history == 0)
if (_rl_saved_line_for_history == 0)
{
saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
saved_line_for_history->line = savestring (the_line);
saved_line_for_history->data = (char *)rl_undo_list;
_rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
_rl_saved_line_for_history->line = savestring (the_line);
_rl_saved_line_for_history->data = (char *)rl_undo_list;
}
return 0;
}
int
_rl_free_saved_history_line ()
{
if (_rl_saved_line_for_history)
{
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
return 0;
}
/* **************************************************************** */
/* */
/* History Commands */
@ -1908,9 +1978,9 @@ int
rl_end_of_history (count, key)
int count, key;
{
maybe_replace_line ();
rl_maybe_replace_line ();
using_history ();
maybe_unsave_line ();
rl_maybe_unsave_line ();
return 0;
}
@ -1928,7 +1998,7 @@ rl_get_next_history (count, key)
if (count == 0)
return 0;
maybe_replace_line ();
rl_maybe_replace_line ();
temp = (HIST_ENTRY *)NULL;
while (count)
@ -1940,7 +2010,7 @@ rl_get_next_history (count, key)
}
if (temp == 0)
maybe_unsave_line ();
rl_maybe_unsave_line ();
else
{
line_len = strlen (temp->line);
@ -1975,10 +2045,10 @@ rl_get_previous_history (count, key)
return 0;
/* If we don't have a line saved, then save this one. */
maybe_save_line ();
rl_maybe_save_line ();
/* If the current line has changed, save the changes. */
maybe_replace_line ();
rl_maybe_replace_line ();
temp = old_temp = (HIST_ENTRY *)NULL;
while (count)
@ -1997,7 +2067,7 @@ rl_get_previous_history (count, key)
temp = old_temp;
if (temp == 0)
ding ();
rl_ding ();
else
{
line_len = strlen (temp->line);
@ -2053,7 +2123,7 @@ rl_exchange_point_and_mark (count, key)
if (rl_mark == -1)
{
ding ();
rl_ding ();
return -1;
}
else

View File

@ -30,6 +30,8 @@
# include "config.h"
#endif
#include "rlstdc.h"
#if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
# define TERMIOS_TTY_DRIVER
#else
@ -71,7 +73,8 @@ extern char *strchr (), *strrchr ();
#define _rl_stricmp strcasecmp
#define _rl_strnicmp strncasecmp
#else
extern int _rl_stricmp (), _rl_strnicmp ();
extern int _rl_stricmp __P((char *, char *);
extern int _rl_strnicmp __P((char *, char *));
#endif
#if !defined (emacs_mode)
@ -87,14 +90,14 @@ extern int _rl_stricmp (), _rl_strnicmp ();
This is not what is wanted. */
#if defined (CRAY)
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)((int)map[key].function)
# define KEYMAP_TO_FUNCTION(data) (Function *)((int)(data))
# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)((int)(data))
#else
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)(map[key].function)
# define KEYMAP_TO_FUNCTION(data) (Function *)(data)
# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)(data)
#endif
#ifndef savestring
extern char *xmalloc ();
extern char *xmalloc __P((int));
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#endif

View File

@ -35,7 +35,7 @@
*************************************************************************/
/* terminal.c */
extern char *rl_get_termcap __P((char *));
extern char *rl_get_termcap __P((const char *));
/*************************************************************************
* *
@ -51,12 +51,8 @@ extern int rl_visible_stats;
/* readline.c */
extern int rl_line_buffer_len;
extern int rl_numeric_arg;
extern int rl_arg_sign;
extern int rl_explicit_arg;
extern int rl_editing_mode;
extern int rl_visible_prompt_length;
extern Function *rl_last_func;
extern int readline_echoing_p;
extern int rl_key_sequence_length;
@ -91,7 +87,7 @@ extern void _rl_set_screen_size __P((int, int));
extern int _rl_fix_last_undo_of_type __P((int, int, int));
/* util.c */
extern char *_rl_savestring __P((char *));
extern char *_rl_savestring __P((const char *));
/*************************************************************************
* *
@ -118,11 +114,11 @@ extern int readline_internal_char __P((void));
#endif /* READLINE_CALLBACKS */
/* bind.c */
extern void _rl_bind_if_unbound __P((char *, Function *));
extern void _rl_bind_if_unbound __P((const char *, rl_command_func_t *));
/* display.c */
extern char *_rl_strip_prompt __P((char *));
extern void _rl_move_cursor_relative __P((int, char *));
extern void _rl_move_cursor_relative __P((int, const char *));
extern void _rl_move_vert __P((int));
extern void _rl_save_prompt __P((void));
extern void _rl_restore_prompt __P((void));
@ -134,7 +130,7 @@ extern void _rl_update_final __P((void));
extern void _rl_redisplay_after_sigwinch __P((void));
extern void _rl_clean_up_for_exit __P((void));
extern void _rl_erase_entire_line __P((void));
extern int _rl_currentb_display_line __P((void));
extern int _rl_current_display_line __P((void));
/* input.c */
extern int _rl_any_typein __P((void));
@ -161,9 +157,10 @@ extern void _rl_set_the_line __P((void));
extern int _rl_dispatch __P((int, Keymap));
extern int _rl_init_argument __P((void));
extern void _rl_fix_point __P((int));
extern void _rl_replace_text __P((char *, int, int));
extern void _rl_replace_text __P((const char *, int, int));
extern int _rl_char_search_internal __P((int, int, int));
extern int _rl_set_mark_at_pos __P((int));
extern int _rl_free_saved_history_line __P((void));
/* rltty.c */
extern int _rl_disable_tty_signals __P((void));
@ -171,21 +168,22 @@ extern int _rl_restore_tty_signals __P((void));
/* terminal.c */
extern void _rl_get_screen_size __P((int, int));
extern int _rl_init_terminal_io __P((char *));
extern int _rl_init_terminal_io __P((const char *));
#ifdef _MINIX
extern void _rl_output_character_function __P((int));
#else
extern int _rl_output_character_function __P((int));
#endif
extern void _rl_output_some_chars __P((char *, int));
extern void _rl_output_some_chars __P((const char *, int));
extern int _rl_backspace __P((int));
extern void _rl_enable_meta_key __P((void));
extern void _rl_control_keypad __P((int));
/* util.c */
extern int alphabetic __P((int));
extern int rl_alphabetic __P((int));
extern int _rl_abort_internal __P((void));
extern char *_rl_strindex __P((char *, char *));
extern char *_rl_strindex __P((const char *, const char *));
extern char *_rl_strpbrk __P((const char *, const char *));
extern int _rl_qsort_string_compare __P((char **, char **));
extern int (_rl_uppercase_p) __P((int));
extern int (_rl_lowercase_p) __P((int));
@ -206,6 +204,10 @@ extern void _rl_vi_done_inserting __P((void));
* Undocumented private variables *
*************************************************************************/
/* bind.c */
extern const char *_rl_possible_control_prefixes[];
extern const char *_rl_possible_meta_prefixes[];
/* complete.c */
extern int _rl_complete_show_all;
extern int _rl_complete_mark_directories;
@ -218,10 +220,6 @@ extern int _rl_last_c_pos;
extern int _rl_suppress_redisplay;
extern char *rl_display_prompt;
/* funmap.c */
extern char *possible_control_prefixes[];
extern char *possible_meta_prefixes[];
/* isearch.c */
extern unsigned char *_rl_isearch_terminators;
@ -248,20 +246,20 @@ extern procenv_t readline_top_level;
/* terminal.c */
extern int _rl_enable_keypad;
extern int _rl_enable_meta;
extern char *term_clreol;
extern char *term_clrpag;
extern char *term_im;
extern char *term_ic;
extern char *term_ei;
extern char *term_DC;
extern char *term_up;
extern char *term_dc;
extern char *term_cr;
extern char *term_IC;
extern int screenheight;
extern int screenwidth;
extern int screenchars;
extern int terminal_can_insert;
extern char *_rl_term_clreol;
extern char *_rl_term_clrpag;
extern char *_rl_term_im;
extern char *_rl_term_ic;
extern char *_rl_term_ei;
extern char *_rl_term_DC;
extern char *_rl_term_up;
extern char *_rl_term_dc;
extern char *_rl_term_cr;
extern char *_rl_term_IC;
extern int _rl_screenheight;
extern int _rl_screenwidth;
extern int _rl_screenchars;
extern int _rl_terminal_can_insert;
extern int _rl_term_autowrap;
/* undo.c */

View File

@ -25,10 +25,10 @@
#include "rlstdc.h"
extern char *single_quote __P((char *));
extern void set_lines_and_columns __P((int, int));
extern char *get_env_value __P((char *));
extern char *get_home_dir __P((void));
extern int unset_nodelay_mode __P((int));
extern char *sh_single_quote __P((char *));
extern void sh_set_lines_and_columns __P((int, int));
extern char *sh_get_env_value __P((const char *));
extern char *sh_get_home_dir __P((void));
extern int sh_unset_nodelay_mode __P((int));
#endif /* _RL_SHELL_H_ */

View File

@ -36,4 +36,16 @@
# endif
#endif
#if !defined (__STDC__) && !defined (__cplusplus)
# if defined (__GNUC__) /* gcc with -traditional */
# if !defined (const)
# define const __const
# endif /* !const */
# else /* !__GNUC__ */
# if !defined (const)
# define const
# endif /* !const */
# endif /* !__GNUC__ */
#endif /* !__STDC__ && !__cplusplus */
#endif /* !_RL_STDC_H_ */

View File

@ -49,8 +49,8 @@
extern int errno;
#endif /* !errno */
VFunction *rl_prep_term_function = rl_prep_terminal;
VFunction *rl_deprep_term_function = rl_deprep_terminal;
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
/* **************************************************************** */
/* */
@ -190,7 +190,7 @@ save_tty_chars (tiop)
_rl_tty_chars.t_intr = tiop->tchars.t_intrc;
_rl_tty_chars.t_quit = tiop->tchars.t_quitc;
_rl_tty_chars.t_start = tiop->tchars.t_startc;
_rl_tty_chars.t_stop = tiop->tchars.t_stopc
_rl_tty_chars.t_stop = tiop->tchars.t_stopc;
_rl_tty_chars.t_eof = tiop->tchars.t_eofc;
_rl_tty_chars.t_eol = '\n';
_rl_tty_chars.t_eol2 = tiop->tchars.t_brkc;
@ -218,22 +218,23 @@ get_tty_settings (tty, tiop)
tiop->flags = tiop->lflag = 0;
ioctl (tty, TIOCGETP, &(tiop->sgttyb));
if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
return -1;
tiop->flags |= SGTTY_SET;
#if defined (TIOCLGET)
ioctl (tty, TIOCLGET, &(tiop->lflag));
tiop->flags |= LFLAG_SET;
if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0)
tiop->flags |= LFLAG_SET;
#endif
#if defined (TIOCGETC)
ioctl (tty, TIOCGETC, &(tiop->tchars));
tiop->flags |= TCHARS_SET;
if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0)
tiop->flags |= TCHARS_SET;
#endif
#if defined (TIOCGLTC)
ioctl (tty, TIOCGLTC, &(tiop->ltchars));
tiop->flags |= LTCHARS_SET;
if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0)
tiop->flags |= LTCHARS_SET;
#endif
return 0;
@ -279,23 +280,23 @@ set_tty_settings (tty, tiop)
}
static void
prepare_terminal_settings (meta_flag, otio, tiop)
prepare_terminal_settings (meta_flag, oldtio, tiop)
int meta_flag;
TIOTYPE otio, *tiop;
TIOTYPE oldtio, *tiop;
{
readline_echoing_p = (otio.sgttyb.sg_flags & ECHO);
readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
/* Copy the original settings to the structure we're going to use for
our settings. */
tiop->sgttyb = otio.sgttyb;
tiop->lflag = otio.lflag;
tiop->sgttyb = oldtio.sgttyb;
tiop->lflag = oldtio.lflag;
#if defined (TIOCGETC)
tiop->tchars = otio.tchars;
tiop->tchars = oldtio.tchars;
#endif
#if defined (TIOCGLTC)
tiop->ltchars = otio.ltchars;
tiop->ltchars = oldtio.ltchars;
#endif
tiop->flags = otio.flags;
tiop->flags = oldtio.flags;
/* First, the basic settings to put us into character-at-a-time, no-echo
input mode. */
@ -308,8 +309,8 @@ prepare_terminal_settings (meta_flag, otio, tiop)
#if !defined (ANYP)
# define ANYP (EVENP | ODDP)
#endif
if (((otio.sgttyb.sg_flags & ANYP) == ANYP) ||
((otio.sgttyb.sg_flags & ANYP) == 0))
if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
((oldtio.sgttyb.sg_flags & ANYP) == 0))
{
tiop->sgttyb.sg_flags |= ANYP;
@ -328,13 +329,13 @@ prepare_terminal_settings (meta_flag, otio, tiop)
tiop->tchars.t_startc = -1; /* C-q */
/* If there is an XON character, bind it to restart the output. */
if (otio.tchars.t_startc != -1)
rl_bind_key (otio.tchars.t_startc, rl_restart_output);
if (oldtio.tchars.t_startc != -1)
rl_bind_key (oldtio.tchars.t_startc, rl_restart_output);
# endif /* USE_XON_XOFF */
/* If there is an EOF char, bind _rl_eof_char to it. */
if (otio.tchars.t_eofc != -1)
_rl_eof_char = otio.tchars.t_eofc;
if (oldtio.tchars.t_eofc != -1)
_rl_eof_char = oldtio.tchars.t_eofc;
# if defined (NO_KILL_INTR)
/* Get rid of terminal-generated SIGQUIT and SIGINT. */
@ -373,7 +374,7 @@ prepare_terminal_settings (meta_flag, otio, tiop)
# define TIOTYPE struct termio
# define DRAIN_OUTPUT(fd)
# define GETATTR(tty, tiop) (ioctl (tty, TCGETA, tiop))
# define SETATTR(tty, tiop) (ioctl (tty, TCSETA, tiop))
# define SETATTR(tty, tiop) (ioctl (tty, TCSETAW, tiop))
#endif /* !TERMIOS_TTY_DRIVER */
static TIOTYPE otio;
@ -545,16 +546,16 @@ set_tty_settings (tty, tiop)
}
static void
prepare_terminal_settings (meta_flag, otio, tiop)
prepare_terminal_settings (meta_flag, oldtio, tiop)
int meta_flag;
TIOTYPE otio, *tiop;
TIOTYPE oldtio, *tiop;
{
readline_echoing_p = (otio.c_lflag & ECHO);
readline_echoing_p = (oldtio.c_lflag & ECHO);
tiop->c_lflag &= ~(ICANON | ECHO);
if ((unsigned char) otio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
_rl_eof_char = otio.c_cc[VEOF];
if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
_rl_eof_char = oldtio.c_cc[VEOF];
#if defined (USE_XON_XOFF)
#if defined (IXANY)
@ -585,7 +586,7 @@ prepare_terminal_settings (meta_flag, otio, tiop)
if (OUTPUT_BEING_FLUSHED (tiop))
{
tiop->c_lflag &= ~FLUSHO;
otio.c_lflag &= ~FLUSHO;
oldtio.c_lflag &= ~FLUSHO;
}
#endif
@ -645,6 +646,7 @@ rl_prep_terminal (meta_flag)
fflush (rl_outstream);
terminal_prepped = 1;
RL_SETSTATE(RL_STATE_TERMPREPPED);
release_sigint ();
}
@ -675,6 +677,7 @@ rl_deprep_terminal ()
}
terminal_prepped = 0;
RL_UNSETSTATE(RL_STATE_TERMPREPPED);
release_sigint ();
}
@ -751,6 +754,9 @@ rl_stop_output (count, key)
/* Default Key Bindings */
/* */
/* **************************************************************** */
/* Set the system's default editing characters to their readline equivalents
in KMAP. Should be static, now that we have rl_tty_set_default_bindings. */
void
rltty_set_default_bindings (kmap)
Keymap kmap;
@ -815,6 +821,15 @@ rltty_set_default_bindings (kmap)
#endif /* !NEW_TTY_DRIVER */
}
/* New public way to set the system default editing chars to their readline
equivalents. */
void
rl_tty_set_default_bindings (kmap)
Keymap kmap;
{
rltty_set_default_bindings (kmap);
}
#if defined (HANDLE_SIGNALS)
#if defined (NEW_TTY_DRIVER)

View File

@ -0,0 +1,88 @@
/* rltypedefs.h -- Type declarations for readline functions. */
/* Copyright (C) 2000 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 2, 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,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _RL_TYPEDEFS_H_
#define _RL_TYPEDEFS_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Old-style */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif /* _FUNCTION_DEF */
/* New style. */
#if !defined (_RL_FUNCTION_TYPEDEF)
# define _RL_FUNCTION_TYPEDEF
/* Bindable functions */
typedef int rl_command_func_t __P((int, int));
/* Typedefs for the completion system */
typedef char *rl_compentry_func_t __P((const char *, int));
typedef char **rl_completion_func_t __P((const char *, int, int));
typedef char *rl_quote_func_t __P((char *, int, char *));
typedef char *rl_dequote_func_t __P((char *, int));
typedef int rl_compignore_func_t __P((char **));
typedef void rl_compdisp_func_t __P((char **, int, int));
/* Type for input and pre-read hook functions like rl_event_hook */
typedef int rl_hook_func_t __P((void));
/* Input function type */
typedef int rl_getc_func_t __P((FILE *));
/* Generic function that takes a character buffer (which could be the readline
line buffer) and an index into it (which could be rl_point) and returns
an int. */
typedef int rl_linebuf_func_t __P((char *, int));
/* `Generic' function pointer typedefs */
typedef int rl_intfunc_t __P((int));
#define rl_ivoidfunc_t rl_hook_func_t
typedef int rl_icpfunc_t __P((char *));
typedef int rl_icppfunc_t __P((char **));
typedef void rl_voidfunc_t __P((void));
typedef void rl_vintfunc_t __P((int));
typedef void rl_vcpfunc_t __P((char *));
typedef void rl_vcppfunc_t __P((char **));
#endif /* _RL_FUNCTION_TYPEDEF */
#ifdef __cplusplus
}
#endif
#endif /* _RL_TYPEDEFS_H_ */

View File

@ -51,7 +51,7 @@
#endif
#define abs(x) (((x) >= 0) ? (x) : -(x))
extern HIST_ENTRY *saved_line_for_history;
extern HIST_ENTRY *_rl_saved_line_for_history;
/* Functions imported from the rest of the library. */
extern int _rl_free_history_entry __P((HIST_ENTRY *));
@ -83,9 +83,9 @@ make_history_line_current (entry)
rl_undo_list = (UNDO_LIST *)entry->data;
rl_end = line_len;
if (saved_line_for_history)
_rl_free_history_entry (saved_line_for_history);
saved_line_for_history = (HIST_ENTRY *)NULL;
if (_rl_saved_line_for_history)
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Search the history list for STRING starting at absolute history position
@ -100,13 +100,19 @@ noninc_search_from_pos (string, pos, dir)
{
int ret, old;
old = where_history ();
history_set_pos (pos);
if (pos < 0)
return -1;
old = where_history ();
if (history_set_pos (pos) == 0)
return -1;
RL_SETSTATE(RL_STATE_SEARCH);
if (*string == '^')
ret = history_search_prefix (string + 1, dir);
else
ret = history_search (string, dir);
RL_UNSETSTATE(RL_STATE_SEARCH);
if (ret != -1)
ret = where_history ();
@ -128,7 +134,7 @@ noninc_dosearch (string, dir)
if (string == 0 || *string == '\0' || noninc_history_pos < 0)
{
ding ();
rl_ding ();
return;
}
@ -136,10 +142,10 @@ noninc_dosearch (string, dir)
if (pos == -1)
{
/* Search failed, current history position unchanged. */
maybe_unsave_line ();
rl_maybe_unsave_line ();
rl_clear_message ();
rl_point = 0;
ding ();
rl_ding ();
return;
}
@ -172,7 +178,7 @@ noninc_search (dir, pchar)
int saved_point, c;
char *p;
maybe_save_line ();
rl_maybe_save_line ();
saved_point = rl_point;
/* Use the line buffer to read the search string. */
@ -183,18 +189,26 @@ noninc_search (dir, pchar)
rl_message (p, 0, 0);
free (p);
#define SEARCH_RETURN rl_restore_prompt (); return
#define SEARCH_RETURN rl_restore_prompt (); RL_UNSETSTATE(RL_STATE_NSEARCH); return
RL_SETSTATE(RL_STATE_NSEARCH);
/* Read the search string. */
while (c = rl_read_key ())
while (1)
{
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (c == 0)
break;
switch (c)
{
case CTRL('H'):
case RUBOUT:
if (rl_point == 0)
{
maybe_unsave_line ();
rl_maybe_unsave_line ();
rl_clear_message ();
rl_point = saved_point;
SEARCH_RETURN;
@ -218,10 +232,10 @@ noninc_search (dir, pchar)
case CTRL('C'):
case CTRL('G'):
maybe_unsave_line ();
rl_maybe_unsave_line ();
rl_clear_message ();
rl_point = saved_point;
ding ();
rl_ding ();
SEARCH_RETURN;
default:
@ -239,7 +253,7 @@ noninc_search (dir, pchar)
{
if (!noninc_search_string)
{
ding ();
rl_ding ();
SEARCH_RETURN;
}
}
@ -253,6 +267,7 @@ noninc_search (dir, pchar)
rl_restore_prompt ();
noninc_dosearch (noninc_search_string, dir);
RL_UNSETSTATE(RL_STATE_NSEARCH);
}
/* Search forward through the history list for a string. If the vi-mode
@ -283,7 +298,7 @@ rl_noninc_forward_search_again (count, key)
{
if (!noninc_search_string)
{
ding ();
rl_ding ();
return (-1);
}
noninc_dosearch (noninc_search_string, 1);
@ -298,7 +313,7 @@ rl_noninc_reverse_search_again (count, key)
{
if (!noninc_search_string)
{
ding ();
rl_ding ();
return (-1);
}
noninc_dosearch (noninc_search_string, -1);
@ -312,7 +327,7 @@ rl_history_search_internal (count, dir)
HIST_ENTRY *temp;
int ret, oldpos;
maybe_save_line ();
rl_maybe_save_line ();
temp = (HIST_ENTRY *)NULL;
/* Search COUNT times through the history for a line whose prefix
@ -341,8 +356,8 @@ rl_history_search_internal (count, dir)
/* If we didn't find anything at all, return. */
if (temp == 0)
{
maybe_unsave_line ();
ding ();
rl_maybe_unsave_line ();
rl_ding ();
/* If you don't want the saved history line (last match) to show up
in the line buffer after the search fails, change the #if 0 to
#if 1 */
@ -353,7 +368,7 @@ rl_history_search_internal (count, dir)
rl_line_buffer[rl_end] = '\0';
}
#else
rl_point = rl_history_search_len; /* maybe_unsave_line changes it */
rl_point = rl_history_search_len; /* rl_maybe_unsave_line changes it */
#endif
return 1;
}
@ -382,6 +397,7 @@ rl_history_search_reinit ()
strncpy (history_search_string + 1, rl_line_buffer, rl_point);
history_search_string[rl_point + 1] = '\0';
}
_rl_free_saved_history_line ();
}
/* Search forward in the history for the string of characters

View File

@ -36,6 +36,7 @@ ARFLAGS = @ARFLAGS@
RM = rm -f
CP = cp
MV = mv
LN = ln
SHELL = @MAKE_SHELL@
@ -43,6 +44,7 @@ host_os = @host_os@
prefix = @prefix@
exec_prefix = @exec_prefix@
includedir = @includedir@
libdir = @libdir@
CFLAGS = @CFLAGS@
@ -108,7 +110,8 @@ CSOURCES = $(topdir)/readline.c $(topdir)/funmap.c $(topdir)/keymaps.c \
$(topdir)/callback.c $(topdir)/terminal.c $(topdir)/xmalloc.c \
$(topdir)/history.c $(topdir)/histsearch.c $(topdir)/histexpand.c \
$(topdir)/histfile.c $(topdir)/nls.c $(topdir)/search.c \
$(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c
$(topdir)/shell.c $(topdir)/savestring.c $(topdir)/compat.c \
$(topdir)/tilde.c
# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
@ -120,7 +123,7 @@ SHARED_TILDEOBJ = tilde.so
SHARED_OBJ = readline.so vi_mode.so funmap.so keymaps.so parens.so search.so \
rltty.so complete.so bind.so isearch.so display.so signals.so \
util.so kill.so undo.so macro.so input.so callback.so terminal.so \
nls.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ)
nls.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ) compat.so
##########################################################################
@ -173,90 +176,108 @@ force:
bind.so: $(topdir)/ansi_stdlib.h $(topdir)/posixstat.h
bind.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
bind.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
bind.so: $(topdir)/rltypedefs.h
bind.so: $(topdir)/tilde.h $(topdir)/history.h
compat.so: $(topdir)/rlstdc.h
callback.so: $(topdir)/rlconf.h
callback.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h
callback.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
callback.so: $(topdir)/rltypedefs.h
callback.so: $(topdir)/tilde.h
complete.so: $(topdir)/ansi_stdlib.h posixdir.h $(topdir)/posixstat.h
complete.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
complete.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
complete.so: $(topdir)/rltypedefs.h
complete.so: $(topdir)/tilde.h
display.so: $(topdir)/ansi_stdlib.h $(topdir)/posixstat.h
display.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
display.so: $(topdir)/tcap.h
display.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
display.so: $(topdir)/rltypedefs.h
display.so: $(topdir)/tilde.h $(topdir)/history.h
funmap.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
funmap.so: $(topdir)/rltypedefs.h
funmap.so: $(topdir)/rlconf.h $(topdir)/ansi_stdlib.h
funmap.so: ${BUILD_DIR}/config.h $(topdir)/tilde.h
histexpand.so: $(topdir)/ansi_stdlib.h
histexpand.so: $(topdir)/history.h histlib.h
histexpand.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
histexpand.so: ${BUILD_DIR}/config.h
histfile.so: $(topdir)/ansi_stdlib.h
histfile.so: $(topdir)/history.h histlib.h
histfile.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
histfile.so: ${BUILD_DIR}/config.h
history.so: $(topdir)/ansi_stdlib.h
history.so: $(topdir)/history.h histlib.h
history.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
history.so: ${BUILD_DIR}/config.h
histsearch.so: $(topdir)/ansi_stdlib.h
histsearch.so: $(topdir)/history.h histlib.h
histsearch.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
histsearch.so: ${BUILD_DIR}/config.h
input.so: $(topdir)/ansi_stdlib.h
input.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
input.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
input.so: $(topdir)/rltypedefs.h
input.so: $(topdir)/tilde.h
isearch.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
isearch.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
isearch.so: $(topdir)/rltypedefs.h
isearch.so: $(topdir)/ansi_stdlib.h $(topdir)/history.h $(topdir)/tilde.h
keymaps.so: emacs_keymap.c vi_keymap.c
keymaps.so: $(topdir)/keymaps.h $(topdir)/chardefs.h $(topdir)/rlconf.h
keymaps.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
keymaps.so: $(topdir)/rltypedefs.h
keymaps.so: ${BUILD_DIR}/config.h $(topdir)/ansi_stdlib.h $(topdir)/tilde.h
kill.so: $(topdir)/ansi_stdlib.h
kill.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
kill.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
kill.so: $(topdir)/tilde.h $(topdir)/history.h
kill.so: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rltypedefs.h
macro.so: $(topdir)/ansi_stdlib.h
macro.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
macro.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
macro.so: $(topdir)/tilde.h $(topdir)/history.h
macro.so: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rltypedefs.h
nls.so: $(topdir)/ansi_stdlib.h
nls.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
nls.o: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
nls.o: $(topdir)/rltypedefs.h
nls.o: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rlstdc.h
parens.so: $(topdir)/rlconf.h ${BUILD_DIR}/config.h
parens.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
parens.so: $(topdir)/rltypedefs.h
parens.so: $(topdir)/tilde.h
readline.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
readline.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
readline.so: $(topdir)/rltypedefs.h
readline.so: $(topdir)/history.h $(topdir)/tilde.h
readline.so: $(topdir)/posixstat.h $(topdir)/ansi_stdlib.h $(topdir)/posixjmp.h
rltty.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
rltty.so: $(topdir)/rltty.h $(topdir)/tilde.h
rltty.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
rltty.so: $(topdir)/rltypedefs.h
search.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
search.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
search.so: $(topdir)/ansi_stdlib.h $(topdir)/history.h $(topdir)/tilde.h
search.so: $(topdir)/rltypedefs.h
signals.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
signals.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
signals.so: $(topdir)/history.h $(topdir)/tilde.h
signals.so: $(topdir)/rltypedefs.h
terminal.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
terminal.so: $(topdir)/tcap.h
terminal.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
terminal.so: $(topdir)/tilde.h $(topdir)/history.h
terminal.so: $(topdir)/rltypedefs.h
tilde.so: $(topdir)/ansi_stdlib.h ${BUILD_DIR}/config.h $(topdir)/tilde.h
undo.so: $(topdir)/ansi_stdlib.h
undo.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
undo.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
undo.so: $(topdir)/rltypedefs.h
undo.so: $(topdir)/tilde.h $(topdir)/history.h
util.so: $(topdir)/posixjmp.h $(topdir)/ansi_stdlib.h
util.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
util.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
util.so: $(topdir)/tilde.h
util.so: $(topdir)/rltypedefs.h $(topdir)/tilde.h
vi_mode.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
vi_mode.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
vi_mode.so: $(topdir)/history.h $(topdir)/ansi_stdlib.h $(topdir)/tilde.h
vi_mode.so: $(topdir)/rltypedefs.h
xmalloc.so: ${BUILD_DIR}/config.h
xmalloc.so: $(topdir)/ansi_stdlib.h
@ -315,6 +336,7 @@ keymaps.so: $(topdir)/keymaps.c
parens.so: $(topdir)/parens.c
search.so: $(topdir)/search.c
rltty.so: $(topdir)/rltty.c
compat.so: $(topdir)/compat.c
complete.so: $(topdir)/complete.c
bind.so: $(topdir)/bind.c
isearch.so: $(topdir)/isearch.c
@ -344,6 +366,7 @@ keymaps.so: keymaps.c
parens.so: parens.c
search.so: search.c
rltty.so: rltty.c
comapt.so: compat.c
complete.so: complete.c
bind.so: bind.c
isearch.so: isearch.c

View File

@ -61,7 +61,7 @@
# define SIGHANDLER_RETURN return (0)
#endif
/* This typedef is equivalant to the one for Function; it allows us
/* This typedef is equivalent to the one for Function; it allows us
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
typedef RETSIGTYPE SigHandler ();
@ -119,6 +119,8 @@ rl_signal_handler (sig)
# endif /* !HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
RL_SETSTATE(RL_STATE_SIGHANDLER);
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
/* Since the signal will not be blocked while we are in the signal
handler, ignore it until rl_clear_signals resets the catcher. */
@ -169,6 +171,7 @@ rl_signal_handler (sig)
rl_reset_after_signal ();
}
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
SIGHANDLER_RETURN;
}
@ -189,6 +192,7 @@ rl_sigwinch_handler (sig)
rl_set_sighandler (SIGWINCH, rl_sigwinch_handler, &dummy_winch);
#endif
RL_SETSTATE(RL_STATE_SIGHANDLER);
rl_resize_terminal ();
/* If another sigwinch handler has been installed, call it. */
@ -196,6 +200,7 @@ rl_sigwinch_handler (sig)
if (oh && oh != (SigHandler *)SIG_IGN && oh != (SigHandler *)SIG_DFL)
(*oh) (sig);
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
SIGHANDLER_RETURN;
}
#endif /* SIGWINCH */
@ -358,7 +363,7 @@ rl_cleanup_after_signal ()
_rl_clean_up_for_exit ();
(*rl_deprep_term_function) ();
rl_clear_signals ();
rl_pending_input = 0;
rl_clear_pending_input ();
}
/* Reset the terminal and readline state after a signal handler returns. */
@ -378,7 +383,7 @@ rl_free_line_state ()
{
register HIST_ENTRY *entry;
free_undo_list ();
rl_free_undo_list ();
entry = current_history ();
if (entry)

View File

@ -168,10 +168,17 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
*:Windows:NT:*:SP*)
echo intel-pc-opennt
exit 0 ;;
*:NonStop-UX:*:*)
echo mips-compaq-nonstopux
exit 0 ;;
# end cases added for Bash
alpha:OSF1:*:*)
if test $UNAME_RELEASE = "V4.0"; then
# TEST CHANGED FOR BASH to handle `letter version' releases
UNAME_MAJOR=`echo "$UNAME_RELEASE" | sed -e 's/^.\([0-9]\).*/\1/'`
if test X"$UNAME_MAJOR" != X"" && test $UNAME_MAJOR = 4 ; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
elif test X"$UNAME_MAJOR" != X"" && test $UNAME_MAJOR -gt 4 ; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
fi
# A Vn.n version is a released version.
# A Tn.n version is a released field test version.
@ -703,7 +710,7 @@ EOF
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
i*:CYGWIN*:*)
echo ${UNAME_MACHINE}-pc-cygwin32
echo ${UNAME_MACHINE}-pc-cygwin
exit 0 ;;
i*:MINGW*:*)
echo ${UNAME_MACHINE}-pc-mingw32
@ -1058,6 +1065,12 @@ EOF
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
Power*:Darwin:*:*)
echo powerpc-apple-darwin${UNAME_RELEASE}
exit 0 ;;
*:Darwin:*:*)
echo ${UNAME_MACHINE}-apple-darwin${UNAME_RELEASE}
exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2

View File

@ -173,7 +173,7 @@ case $basic_machine in
| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
| mips64vr5000 | miprs64vr5000el | mcore \
| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
| thumb | d10v)
| thumb | d10v | s390)
basic_machine=$basic_machine-unknown
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65)
@ -676,6 +676,10 @@ case $basic_machine in
rtpc | rtpc-*)
basic_machine=romp-ibm
;;
s390-*)
basic_machine=s390-ibm
os=-linux
;;
sa29200)
basic_machine=a29k-amd
os=-udi
@ -946,13 +950,13 @@ case $os in
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -rhapsody* | -openstep* | -oskit*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
# BEGIN CASES ADDED FOR Bash
-qnx* | -powerux* | -superux* )
-qnx* | -powerux* | -superux* | -darwin* | -nonstopux*)
;;
# END CASES ADDED FOR Bash
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \

View File

@ -66,7 +66,7 @@ fi
# HP-UX requires that a shared library have execute permission
case "$host_os" in
hpux*) if [ -z "$uninstall" ]; then
chmod 755 ${INSTALLDIR}/${LIBNAME}
chmod 555 ${INSTALLDIR}/${LIBNAME}
fi ;;
*) ;;
esac
@ -84,6 +84,9 @@ case "$LIBNAME" in
;;
esac
INSTALL_LINK1='cd $INSTALLDIR ; ln -s $LIBNAME $LINK1'
INSTALL_LINK2='cd $INSTALLDIR ; ln -s $LIBNAME $LINK2'
#
# Create symlinks to the installed library. This section is incomplete.
#
@ -92,13 +95,13 @@ case "$host_os" in
# libname.so.M -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK2
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK2
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
fi
# libname.so -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
fi
;;
@ -106,7 +109,7 @@ solaris2*|aix4.[2-9]*|osf*|irix[56]*)
# libname.so -> libname.so.M
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
fi
;;
@ -117,19 +120,19 @@ freebsd3*)
# libname.so -> libname.so.M
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
fi
else
# libname.so.M -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK2
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK2
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
fi
# libname.so -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
fi
fi
;;
@ -138,7 +141,8 @@ hpux1*)
# libname.sl -> libname.M
${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LINK1}.sl
# ${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}.sl
${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}
fi
;;

View File

@ -43,7 +43,7 @@ while [ $# -gt 0 ]; do
done
case "${host_os}-${SHOBJ_CC}" in
sunos4*-gcc*)
sunos4*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD=/usr/bin/ld
SHOBJ_LDFLAGS='-assert pure-text'
@ -59,7 +59,7 @@ sunos4*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
sunos5*-gcc*|solaris2*-gcc*)
sunos5*-*gcc*|solaris2*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-i -Wl,-h,$@'
@ -97,7 +97,7 @@ freebsd2* | netbsd* | openbsd*)
# ;;
# FreeBSD-3.x ELF
freebsd3*)
freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
@ -113,13 +113,13 @@ freebsd3*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
fi
;;
linux*)
# All versions of Linux or the semi-mythical GNU Hurd.
linux*|gnu*)
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir) -Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
@ -158,10 +158,11 @@ bsdi4*)
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
osf*-gcc*)
osf*-*gcc*)
# Fix to use gcc linker driver from bfischer@TechFak.Uni-Bielefeld.DE
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
@ -178,7 +179,7 @@ osf*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
aix4.[2-9]*-gcc*) # lightly tested by jik@cisco.com
aix4.[2-9]*-*gcc*) # lightly tested by jik@cisco.com
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='ld'
SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
@ -203,7 +204,7 @@ aix4.[2-9]*)
#
# THE FOLLOWING ARE UNTESTED -- and some may not support the dlopen interface
#
irix[56]*-gcc*)
irix[56]*-*gcc*)
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
@ -216,14 +217,15 @@ irix[56]*)
SHOBJ_CFLAGS='-K PIC'
SHOBJ_LD=ld
# SHOBJ_LDFLAGS='-call_shared -hidden_symbol -no_unresolved -soname $@'
# Change from David Kaelbling <drk@sgi.com>
# Change from David Kaelbling <drk@sgi.com>. If you have problems,
# remove the `-no_unresolved'
SHOBJ_LDFLAGS='-shared -no_unresolved -soname $@'
SHLIB_XLDFLAGS='-rpath $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux9*-gcc*)
hpux9*-*gcc*)
# must use gcc; the bundled cc cannot compile PIC code
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
@ -239,7 +241,7 @@ hpux9*)
SHLIB_STATUS=unsupported
;;
hpux10*-gcc*)
hpux10*-*gcc*)
# must use gcc; the bundled cc cannot compile PIC code
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
@ -253,14 +255,27 @@ hpux10*-gcc*)
hpux10*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=unsupported
# If you are using the HP ANSI C compiler, you can uncomment and use
# this code
# SHOBJ_STATUS=unsupported
# SHLIB_STATUS=unsupported
#
# SHOBJ_CFLAGS='+z'
# SHOBJ_LD='ld'
# SHOBJ_LDFLAGS='-b'
#
# SHLIB_XLDFLAGS=''
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux11*-gcc*)
hpux11*-*gcc*)
# must use gcc; the bundled cc cannot compile PIC code
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
# SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,-B,symbolic -Wl,+s -Wl,+std -Wl,+h,$@'
SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s -Wl,+h,$@'
SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s -Wl,+h,$@'
SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
SHLIB_LIBSUFF='sl'
@ -270,9 +285,23 @@ hpux11*-gcc*)
hpux11*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=unsupported
# If you are using the HP ANSI C compiler, you can uncomment and use
# this code
# SHOBJ_STATUS=unsupported
# SHLIB_STATUS=unsupported
#
# SHOBJ_CFLAGS='+z'
# SHOBJ_LD='ld'
# SHOBJ_LDFLAGS='-b'
#
# SHLIB_XLDFLAGS=''
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv4*-gcc*)
sysv4*-*gcc*)
SHOBJ_CFLAGS=-shared
SHOBJ_LDFLAGS='-shared -h $@'
SHOBJ_LD='${CC}'
@ -288,7 +317,7 @@ sysv4*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sco3.2v5*-gcc*)
sco3.2v5*-*gcc*)
SHOBJ_CFLAGS='-fpic' # DEFAULTS TO ELF
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
@ -304,7 +333,7 @@ sco3.2v5*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5uw7*-gcc*)
sysv5uw7*-*gcc*)
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
@ -320,7 +349,7 @@ sysv5uw7*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
dgux*-gcc*)
dgux*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
@ -344,7 +373,7 @@ msdos*)
#
# Rely on correct gcc configuration for everything else
#
*-gcc*)
*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'

View File

@ -50,16 +50,13 @@
#if defined (TEST) || defined (STATIC_MALLOC)
static char *xmalloc (), *xrealloc ();
#else
# if defined __STDC__
extern char *xmalloc (int);
extern char *xrealloc (void *, int);
# else
extern char *xmalloc (), *xrealloc ();
# endif /* !__STDC__ */
extern char *xmalloc __P((int));
extern char *xrealloc __P((void *, int));
#endif /* TEST || STATIC_MALLOC */
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid (), *getpwnam ();
extern struct passwd *getpwuid __P((uid_t));
extern struct passwd *getpwnam __P((const char *));
#endif /* !HAVE_GETPW_DECLS */
#if !defined (savestring)
@ -80,42 +77,42 @@ extern char *strcpy ();
/* 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 __P((void));
extern char *get_env_value __P((char *));
extern char *sh_get_home_dir __P((void));
extern char *sh_get_env_value __P((const char *));
/* 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. */
static char *default_prefixes[] =
{ " ~", "\t~", (char *)NULL };
static const char *default_prefixes[] =
{ " ~", "\t~", (const char *)NULL };
/* The default value of tilde_additional_suffixes. This is set to
whitespace or newline so that simple programs which do not
perform any word separation get desired behaviour. */
static char *default_suffixes[] =
{ " ", "\n", (char *)NULL };
static const char *default_suffixes[] =
{ " ", "\n", (const char *)NULL };
/* If non-null, this contains the address of a function that the application
wants called before trying the standard tilde expansions. The function
is called with the text sans tilde, and returns a malloc()'ed string
which is the expansion, or a NULL pointer if the expansion fails. */
CPFunction *tilde_expansion_preexpansion_hook = (CPFunction *)NULL;
tilde_hook_func_t *tilde_expansion_preexpansion_hook = (tilde_hook_func_t *)NULL;
/* If non-null, this contains the address of a function to call if the
standard meaning for expanding a tilde fails. The function is called
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
which is the expansion, or a NULL pointer if there is no expansion. */
CPFunction *tilde_expansion_failure_hook = (CPFunction *)NULL;
tilde_hook_func_t *tilde_expansion_failure_hook = (tilde_hook_func_t *)NULL;
/* When non-null, this is a NULL terminated array of strings which
are duplicates for a tilde prefix. Bash uses this to expand
`=~' and `:~'. */
char **tilde_additional_prefixes = default_prefixes;
char **tilde_additional_prefixes = (char **)default_prefixes;
/* When non-null, this is a NULL terminated array of strings which match
the end of a username, instead of just "/". Bash sets this to
`:' and `=~'. */
char **tilde_additional_suffixes = default_suffixes;
char **tilde_additional_suffixes = (char **)default_suffixes;
/* Find the start of a tilde expansion in STRING, and return the index of
the tilde which starts the expansion. Place the length of the text
@ -186,7 +183,7 @@ tilde_find_suffix (string)
/* Return a new string which is the result of tilde expanding STRING. */
char *
tilde_expand (string)
char *string;
const char *string;
{
char *result;
int result_size, result_index;
@ -235,9 +232,9 @@ tilde_expand (string)
free (tilde_word);
len = strlen (expansion);
#ifdef __CYGWIN32__
#ifdef __CYGWIN__
/* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when
$HOME for `user' is /. On cygwin, // denotes a network drive. */
$HOME for `user' is /. On cygwin, // denotes a network drive. */
if (len > 1 || *expansion != '/' || *string != '/')
#endif
{
@ -303,7 +300,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
This always returns a newly-allocated string, never static storage. */
char *
tilde_expand_word (filename)
char *filename;
const char *filename;
{
char *dirname, *expansion, *username;
int user_len;
@ -321,12 +318,12 @@ tilde_expand_word (filename)
if (filename[1] == '\0' || filename[1] == '/')
{
/* Prefix $HOME to the rest of the string. */
expansion = get_env_value ("HOME");
expansion = sh_get_env_value ("HOME");
/* If there is no HOME variable, look up the directory in
the password database. */
if (expansion == 0)
expansion = get_home_dir ();
expansion = sh_get_home_dir ();
return (glue_prefix_and_suffix (expansion, filename, 1));
}

View File

@ -40,26 +40,31 @@ extern "C" {
# endif
#endif
/* Function pointers can be declared as (Function *)foo. */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif /* _FUNCTION_DEF */
#if !defined (__STDC__) && !defined (__cplusplus)
# if defined (__GNUC__) /* gcc with -traditional */
# if !defined (const)
# define const __const
# endif /* !const */
# else /* !__GNUC__ */
# if !defined (const)
# define const
# endif /* !const */
# endif /* !__GNUC__ */
#endif /* !__STDC__ && !__cplusplus */
typedef char *tilde_hook_func_t __P((char *));
/* If non-null, this contains the address of a function that the application
wants called before trying the standard tilde expansions. The function
is called with the text sans tilde, and returns a malloc()'ed string
which is the expansion, or a NULL pointer if the expansion fails. */
extern CPFunction *tilde_expansion_preexpansion_hook;
extern tilde_hook_func_t *tilde_expansion_preexpansion_hook;
/* If non-null, this contains the address of a function to call if the
standard meaning for expanding a tilde fails. The function is called
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
which is the expansion, or a NULL pointer if there is no expansion. */
extern CPFunction *tilde_expansion_failure_hook;
extern tilde_hook_func_t *tilde_expansion_failure_hook;
/* When non-null, this is a NULL terminated array of strings which
are duplicates for a tilde prefix. Bash uses this to expand
@ -72,11 +77,11 @@ extern char **tilde_additional_prefixes;
extern char **tilde_additional_suffixes;
/* Return a new string which is the result of tilde expanding STRING. */
extern char *tilde_expand __P((char *));
extern char *tilde_expand __P((const char *));
/* Do the work of tilde expansion on FILENAME. FILENAME starts with a
tilde. If there is no expansion, call tilde_expansion_failure_hook. */
extern char *tilde_expand_word __P((char *));
extern char *tilde_expand_word __P((const char *));
#ifdef __cplusplus
}

View File

@ -86,7 +86,7 @@ rl_add_undo (what, start, end, text)
/* Free the existing undo list. */
void
free_undo_list ()
rl_free_undo_list ()
{
while (rl_undo_list)
{
@ -107,17 +107,18 @@ int
rl_do_undo ()
{
UNDO_LIST *release;
int waiting_for_begin = 0;
int start, end;
int waiting_for_begin, start, end;
#define TRANS(i) ((i) == -1 ? rl_point : ((i) == -2 ? rl_end : (i)))
start = end = waiting_for_begin = 0;
do
{
if (!rl_undo_list)
return (0);
_rl_doing_an_undo = 1;
RL_SETSTATE(RL_STATE_UNDOING);
/* To better support vi-mode, a start or end value of -1 means
rl_point, and a value of -2 means rl_end. */
@ -152,11 +153,12 @@ rl_do_undo ()
if (waiting_for_begin)
waiting_for_begin--;
else
ding ();
rl_ding ();
break;
}
_rl_doing_an_undo = 0;
RL_UNSETSTATE(RL_STATE_UNDOING);
release = rl_undo_list;
rl_undo_list = rl_undo_list->next;
@ -231,7 +233,7 @@ rl_revert_line (count, key)
int count, key;
{
if (!rl_undo_list)
ding ();
rl_ding ();
else
{
while (rl_undo_list)
@ -254,7 +256,7 @@ rl_undo_command (count, key)
count--;
else
{
ding ();
rl_ding ();
break;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,7 @@
static int _rl_vi_doing_insert;
/* Command keys which do movement for xxx_to commands. */
static char *vi_motion = " hl^$0ftFt;,%wbeWBE|";
static const char *vi_motion = " hl^$0ftFt;,%wbeWBE|";
/* Keymap used for vi replace characters. Created dynamically since
rarely used. */
@ -109,7 +109,7 @@ static int _rl_vi_last_key_before_insert;
static int vi_redoing;
/* Text modification commands. These are the `redoable' commands. */
static char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
static const char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
/* Arrays for the saved marks. */
static int vi_mark_chars[27];
@ -274,7 +274,7 @@ rl_vi_search (count, key)
break;
default:
ding ();
rl_ding ();
break;
}
return (0);
@ -330,7 +330,7 @@ rl_vi_prev_word (count, key)
if (rl_point == 0)
{
ding ();
rl_ding ();
return (0);
}
@ -352,7 +352,7 @@ rl_vi_next_word (count, key)
if (rl_point >= (rl_end - 1))
{
ding ();
rl_ding ();
return (0);
}
@ -370,7 +370,7 @@ rl_vi_end_word (count, key)
{
if (count < 0)
{
ding ();
rl_ding ();
return -1;
}
@ -744,7 +744,9 @@ rl_vi_domove (key, nextkey)
int old_end;
rl_mark = rl_point;
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
*nextkey = c;
if (!member (c, vi_motion))
@ -755,7 +757,9 @@ rl_vi_domove (key, nextkey)
rl_numeric_arg = _rl_digit_value (c);
rl_digit_loop1 ();
rl_numeric_arg *= save;
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key (); /* real command */
RL_UNSETSTATE(RL_STATE_MOREINPUT);
*nextkey = c;
}
else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
@ -825,16 +829,28 @@ rl_vi_domove (key, nextkey)
}
/* A simplified loop for vi. Don't dispatch key at end.
Don't recognize minus sign? */
Don't recognize minus sign?
Should this do rl_save_prompt/rl_restore_prompt? */
static int
rl_digit_loop1 ()
{
int key, c;
RL_SETSTATE(RL_STATE_NUMERICARG);
while (1)
{
if (rl_numeric_arg > 1000000)
{
rl_explicit_arg = rl_numeric_arg = 0;
rl_ding ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return 1;
}
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg, 0);
RL_SETSTATE(RL_STATE_MOREINPUT);
key = c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (_rl_keymap[c].type == ISFUNC &&
_rl_keymap[c].function == rl_universal_argument)
@ -859,6 +875,8 @@ rl_digit_loop1 ()
break;
}
}
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (0);
}
@ -875,7 +893,7 @@ rl_vi_delete_to (count, key)
if (rl_vi_domove (key, &c))
{
ding ();
rl_ding ();
return -1;
}
@ -903,7 +921,7 @@ rl_vi_change_to (count, key)
if (rl_vi_domove (key, &c))
{
ding ();
rl_ding ();
return -1;
}
@ -953,7 +971,7 @@ rl_vi_yank_to (count, key)
if (rl_vi_domove (key, &c))
{
ding ();
rl_ding ();
return -1;
}
@ -979,7 +997,7 @@ rl_vi_delete (count, key)
if (rl_end == 0)
{
ding ();
rl_ding ();
return -1;
}
@ -1026,7 +1044,11 @@ rl_vi_char_search (count, key)
if (vi_redoing)
target = _rl_vi_last_search_char;
else
_rl_vi_last_search_char = target = (*rl_getc_function) (rl_instream);
{
RL_SETSTATE(RL_STATE_MOREINPUT);
_rl_vi_last_search_char = target = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
}
switch (key)
{
@ -1068,7 +1090,7 @@ rl_vi_match (ignore, key)
if (brack <= 0)
{
rl_point = pos;
ding ();
rl_ding ();
return -1;
}
}
@ -1089,7 +1111,7 @@ rl_vi_match (ignore, key)
}
else
{
ding ();
rl_ding ();
return -1;
}
}
@ -1108,7 +1130,7 @@ rl_vi_match (ignore, key)
}
else
{
ding ();
rl_ding ();
return -1;
}
}
@ -1142,7 +1164,11 @@ rl_vi_change_char (count, key)
if (vi_redoing)
c = _rl_vi_last_replacement;
else
_rl_vi_last_replacement = c = (*rl_getc_function) (rl_instream);
{
RL_SETSTATE(RL_STATE_MOREINPUT);
_rl_vi_last_replacement = c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
}
if (c == '\033' || c == CTRL ('C'))
return -1;
@ -1238,7 +1264,7 @@ rl_vi_overstrike_delete (count, key)
{
if (vi_replace_count == 0)
{
ding ();
rl_ding ();
break;
}
s = rl_point;
@ -1308,7 +1334,7 @@ rl_vi_possible_completions()
}
else if (rl_line_buffer[rl_point - 1] == ';')
{
ding ();
rl_ding ();
return (0);
}
@ -1326,10 +1352,13 @@ rl_vi_set_mark (count, key)
{
int ch;
RL_SETSTATE(RL_STATE_MOREINPUT);
ch = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (_rl_lowercase_p (ch) == 0)
{
ding ();
rl_ding ();
return -1;
}
ch -= 'a';
@ -1343,7 +1372,10 @@ rl_vi_goto_mark (count, key)
{
int ch;
RL_SETSTATE(RL_STATE_MOREINPUT);
ch = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (ch == '`')
{
rl_point = rl_mark;
@ -1351,14 +1383,14 @@ rl_vi_goto_mark (count, key)
}
else if (_rl_lowercase_p (ch) == 0)
{
ding ();
rl_ding ();
return -1;
}
ch -= 'a';
if (vi_mark_chars[ch] == -1)
{
ding ();
rl_ding ();
return -1;
}
rl_point = vi_mark_chars[ch];