Import readline 8.0

This imports readline 8.0.

readline/ChangeLog.gdb
2019-08-12  Tom Tromey  <tom@tromey.com>

	* Imported readline 8.0.
This commit is contained in:
Tom Tromey 2019-08-12 10:24:03 -06:00
parent ca2589f3bb
commit cb41b9e70e
77 changed files with 4056 additions and 2156 deletions

View File

@ -1304,3 +1304,50 @@ configure.ac
---- ----
configure.ac,Makefile.in,examples/Makefile.in configure.ac,Makefile.in,examples/Makefile.in
- remove references to purify - remove references to purify
11/21
-----
configure.ac,config.h.in
- fnmatch: check for libc function, define HAVE_FNMATCH if found. Now
used by vi-mode history search functions
7/12
----
Makefile.in,examples/Makefile.in
- add support for building with address sanitizer, using new target
`asan'
4/23/2018
---------
configure.ac
- TERMCAP_PKG_CONFIG_LIB: new variable, defined from TERMCAP_LIB,
defaults to termcap
readline.pc.in
- change Requires.private to use TERMCAP_PKG_CONFIG_LIB instead of
hardcoded `tinfo'. Report and fix from Thomas Petazzoni
<thomas.petazzoni@bootlin.com>
5/4
---
Makefile.in
- new targets to install and uninstall the `readline.pc' pkgconfig
file
- install-{static,shared}: add install-pc to the list of prereqs
- uninstall{,-shared}: add uninstall-pc to list of prereqs. Change
from Thomas Petazzoni <thomas.petazzoni@bootlin.com>
configure.ac,Makefile.in
- add new configure option to optionally disable installing the
source code examples. From Thomas Petazzoni <thomas.petazzoni@bootlin.com>
5/23
----
Makefile.in
- install-pc: make sure we install readline.pc into an existing
pkgconfig directory. Report from ilove zfs <ilovezfs@icloud.com>
5/24
----
Makefile.in
- installdirs: create $(pkgconfigdir) if it doesn't exist

View File

@ -1,3 +1,145 @@
This document details the changes between this version, readline-8.0, and the
previous version, readline-7.0.
1. Changes to Readline
a. Added a guard to prevent nested macros from causing an infinite expansion
loop.
b. Instead of allocating enough history list entries to hold the maximum list
size, cap the number allocated initially.
c. Added a strategy to avoid allocating huge amounts of memory if a block of
history entries without timestamps occurs after a block with timestamps.
d. Added support for keyboard timeouts when an ESC character is the last
character in a macro.
e. There are several performance improvements when in a UTF-8 locale.
f. Readline does a better job of preserving the original set of blocked
signals when using pselect() to wait for input.
g. Fixed a bug that caused multibyte characters in macros to be mishandled.
h. Fixed several bugs in the code that calculates line breaks when expanding
prompts that span several lines, contain multibyte characters, and contain
invisible character seqeuences.
i. Fixed several bugs in cursor positioning when displaying lines with prompts
containing invisible characters and multibyte characters.
j. When performing case-insensitive completion, Readline no longer sorts the
list of matches unless directed to do so.
k. Fixed a problem with key sequences ending with a backslash.
l. Fixed out-of-bounds and free memory read errors found via fuzzing.
m. Fixed several cases where the mark was set to an invalid value.
n. Fixed a problem with the case-changing operators in the case where the
lower and upper case versions of a character do not have the same number
of bytes.
o. Handle incremental and non-incremental search character reads returning EOF.
p. Handle the case where a failing readline command at the end of a multi-key
sequence could be misinterpreted.
q. The history library now prints a meaningful error message if the history
file isn't a regular file.
r. Fixed a problem with vi-mode redo (`.') on a command when trying to replace
a multibyte character.
s. The key binding code now attempts to remove a keymap if a key unbinding
leaves it empty.
t. Fixed a line-wrapping issue that caused problems for some terminal
emulators.
u. If there is a key bound to the tty's VDISCARD special character, readline
disables VDISCARD while it is active.
v. Fixed a problem with exiting bracketed paste mode on terminals that assume
the bracketed paste mode character sequence contains visible characters.
w. Fixed a bug that could cause a key binding command to refer to an
uninitialized variable.
x. Added more UTF-8-specific versions of multibyte functions, and optimized
existing functions if the current locale uses UTF-8 encoding.
y. Fixed a problem with bracketed-paste inserting more than one character and
interacting with other readline functions.
z. Fixed a bug that caused the history library to attempt to append a history
line to a non-existent history entry.
aa. If using bracketed paste mode, output a newline after the \r that is the
last character of the mode disable string to avoid overwriting output.
bb. Fixes to the vi-mode `b', `B', `w', `W', `e', and `E' commands to better
handle multibyte characters.
cc. Fixed a redisplay problem that caused an extra newline to be generated on
accept-line when the line length is exactly the screenwidth.
dd. Fixed a bug with adding multibyte characters to an incremental search
string.
ee. Fixed a bug with redoing text insertions in vi mode.
ff. Fixed a bug with pasting text into an incremental search string if bracketed
paste mode is enabled. ESC cannot be one of the incremental search
terminator characters for this to work.
gg. Fixed a bug with anchored search patterns when performing searches in vi
mode.
2. New Features in Readline
a. Non-incremental vi-mode search (`N', `n') can search for a shell pattern, as
Posix specifies (uses fnmatch(3) if available).
b. There are new `next-screen-line' and `previous-screen-line' bindable
commands, which move the cursor to the same column in the next, or previous,
physical line, respectively.
c. There are default key bindings for control-arrow-key key combinations.
d. A negative argument (-N) to `quoted-insert' means to insert the next N
characters using quoted-insert.
e. New public function: rl_check_signals(), which allows applications to
respond to signals that readline catches while waiting for input using
a custom read function.
f. There is new support for conditionally testing the readline version in an
inputrc file, with a full set of arithmetic comparison operators available.
g. There is a simple variable comparison facility available for use within an
inputrc file. Allowable operators are equality and inequality; string
variables may be compared to a value; boolean variables must be compared to
either `on' or `off'; variable names are separated from the operator by
whitespace.
h. The history expansion library now understands command and process
substitution and extended globbing and allows them to appear anywhere in a
word.
i. The history library has a new variable that allows applications to set the
initial quoting state, so quoting state can be inherited from a previous
line.
j. Readline now allows application-defined keymap names; there is a new public
function, rl_set_keymap_name(), to do that.
k. The "Insert" keypad key, if available, now puts readline into overwrite
mode.
-------------------------------------------------------------------------------
This document details the changes between this version, readline-7.0, and the This document details the changes between this version, readline-7.0, and the
previous version, readline-6.3. previous version, readline-6.3.

View File

@ -1,3 +1,7 @@
2019-08-12 Tom Tromey <tom@tromey.com>
* Imported readline 8.0.
2019-08-12 Tom Tromey <tom@tromey.com> 2019-08-12 Tom Tromey <tom@tromey.com>
* Makefile.in (xfree.o): Don't depend on readline.h. * Makefile.in (xfree.o): Don't depend on readline.h.

View File

@ -1,7 +1,7 @@
Basic Installation Basic Installation
================== ==================
These are installation instructions for Readline-7.0. These are installation instructions for Readline-8.0.
The simplest way to compile readline is: The simplest way to compile readline is:

View File

@ -118,6 +118,7 @@ examples/rl-fgets.c f
examples/rlbasic.c f examples/rlbasic.c f
examples/rlcat.c f examples/rlcat.c f
examples/rlevent.c f examples/rlevent.c f
examples/rlkeymaps.c f
examples/rltest.c f examples/rltest.c f
examples/rl-callbacktest.c f examples/rl-callbacktest.c f
examples/rl.c f examples/rl.c f

View File

@ -1,6 +1,6 @@
## -*- text -*- ## ## -*- text -*- ##
# Master Makefile for the GNU readline library. # Master Makefile for the GNU readline library.
# Copyright (C) 1994-2009 Free Software Foundation, Inc. # Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -59,6 +59,7 @@ mandir = @mandir@
includedir = @includedir@ includedir = @includedir@
datadir = @datadir@ datadir = @datadir@
localedir = @localedir@ localedir = @localedir@
pkgconfigdir = ${libdir}/pkgconfig
infodir = @infodir@ infodir = @infodir@
@ -85,7 +86,7 @@ TERMCAP_LIB = @TERMCAP_LIB@
# For libraries which include headers from other libraries. # For libraries which include headers from other libraries.
INCLUDES = -I. -I$(srcdir) INCLUDES = -I. -I$(srcdir)
XCCFLAGS = $(DEFS) $(LOCAL_DEFS) $(INCLUDES) $(CPPFLAGS) XCCFLAGS = $(ASAN_CFLAGS) $(DEFS) $(LOCAL_DEFS) $(INCLUDES) $(CPPFLAGS)
CCFLAGS = $(XCCFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) CCFLAGS = $(XCCFLAGS) $(LOCAL_CFLAGS) $(CFLAGS)
# could add -Werror here # could add -Werror here
@ -94,6 +95,11 @@ GCC_LINT_FLAGS = -ansi -Wall -Wshadow -Wpointer-arith -Wcast-qual \
-Wmissing-prototypes -Wno-implicit -pedantic -Wmissing-prototypes -Wno-implicit -pedantic
GCC_LINT_CFLAGS = $(XCCFLAGS) $(GCC_LINT_FLAGS) @CFLAGS@ @LOCAL_CFLAGS@ GCC_LINT_CFLAGS = $(XCCFLAGS) $(GCC_LINT_FLAGS) @CFLAGS@ @LOCAL_CFLAGS@
ASAN_XCFLAGS = -fsanitize=address -fno-omit-frame-pointer
ASAN_XLDFLAGS = -fsanitize=address
install_examples = @EXAMPLES_INSTALL_TARGET@
.c.o: .c.o:
${RM} $@ ${RM} $@
$(CC) -c $(CCFLAGS) $< $(CC) -c $(CCFLAGS) $<
@ -160,6 +166,9 @@ all: $(TARGETS)
everything: all examples everything: all examples
asan:
${MAKE} ${MFLAGS} ASAN_CFLAGS='${ASAN_XCFLAGS}' ASAN_LDFLAGS='${ASAN_XLDFLAGS}' everything
static: $(STATIC_LIBS) static: $(STATIC_LIBS)
libreadline.a: $(OBJECTS) libreadline.a: $(OBJECTS)
@ -242,7 +251,16 @@ uninstall-headers:
maybe-uninstall-headers: uninstall-headers maybe-uninstall-headers: uninstall-headers
install-static: installdirs $(STATIC_LIBS) install-headers install-doc install-examples install-pc: installdirs
-$(INSTALL_DATA) $(BUILD_DIR)/readline.pc $(DESTDIR)$(pkgconfigdir)/readline.pc
uninstall-pc:
-test -n "$(pkgconfigdir)" && cd $(DESTDIR)$(pkgconfigdir) && \
${RM} readline.pc
maybe-uninstall-pc: uninstall-pc
install-static: installdirs $(STATIC_LIBS) install-headers install-doc ${install_examples} install-pc
-$(MV) $(DESTDIR)$(libdir)/libreadline.a $(DESTDIR)$(libdir)/libreadline.old -$(MV) $(DESTDIR)$(libdir)/libreadline.a $(DESTDIR)$(libdir)/libreadline.old
$(INSTALL_DATA) libreadline.a $(DESTDIR)$(libdir)/libreadline.a $(INSTALL_DATA) libreadline.a $(DESTDIR)$(libdir)/libreadline.a
-test -n "$(RANLIB)" && $(RANLIB) $(DESTDIR)$(libdir)/libreadline.a -test -n "$(RANLIB)" && $(RANLIB) $(DESTDIR)$(libdir)/libreadline.a
@ -253,17 +271,18 @@ install-static: installdirs $(STATIC_LIBS) install-headers install-doc install-e
installdirs: $(srcdir)/support/mkinstalldirs installdirs: $(srcdir)/support/mkinstalldirs
-$(SHELL) $(srcdir)/support/mkinstalldirs $(DESTDIR)$(includedir) \ -$(SHELL) $(srcdir)/support/mkinstalldirs $(DESTDIR)$(includedir) \
$(DESTDIR)$(includedir)/readline $(DESTDIR)$(libdir) \ $(DESTDIR)$(includedir)/readline $(DESTDIR)$(libdir) \
$(DESTDIR)$(infodir) $(DESTDIR)$(man3dir) $(DESTDIR)$(docdir) $(DESTDIR)$(infodir) $(DESTDIR)$(man3dir) $(DESTDIR)$(docdir) \
$(DESTDIR)$(pkgconfigdir)
uninstall: uninstall-headers uninstall-doc uninstall-examples uninstall: uninstall-headers uninstall-doc uninstall-examples uninstall-pc
-test -n "$(DESTDIR)$(libdir)" && cd $(DESTDIR)$(libdir) && \ -test -n "$(DESTDIR)$(libdir)" && cd $(DESTDIR)$(libdir) && \
${RM} libreadline.a libreadline.old libhistory.a libhistory.old $(SHARED_LIBS) ${RM} libreadline.a libreadline.old libhistory.a libhistory.old $(SHARED_LIBS)
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall ) -( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
install-shared: installdirs install-headers shared install-doc install-shared: installdirs install-headers shared install-doc install-pc
( cd shlib ; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install ) ( cd shlib ; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install )
uninstall-shared: maybe-uninstall-headers uninstall-shared: maybe-uninstall-headers maybe-uninstall-pc
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall ) -( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
install-examples: installdirs install-headers install-examples: installdirs install-headers

View File

@ -1,3 +1,48 @@
This is a terse description of the new features added to readline-8.0 since
the release of readline-7.0.
New Features in Readline
a. Non-incremental vi-mode search (`N', `n') can search for a shell pattern, as
Posix specifies (uses fnmatch(3) if available).
b. There are new `next-screen-line' and `previous-screen-line' bindable
commands, which move the cursor to the same column in the next, or previous,
physical line, respectively.
c. There are default key bindings for control-arrow-key key combinations.
d. A negative argument (-N) to `quoted-insert' means to insert the next N
characters using quoted-insert.
e. New public function: rl_check_signals(), which allows applications to
respond to signals that readline catches while waiting for input using
a custom read function.
f. There is new support for conditionally testing the readline version in an
inputrc file, with a full set of arithmetic comparison operators available.
g. There is a simple variable comparison facility available for use within an
inputrc file. Allowable operators are equality and inequality; string
variables may be compared to a value; boolean variables must be compared to
either `on' or `off'; variable names are separated from the operator by
whitespace.
h. The history expansion library now understands command and process
substitution and extended globbing and allows them to appear anywhere in a
word.
i. The history library has a new variable that allows applications to set the
initial quoting state, so quoting state can be inherited from a previous
line.
j. Readline now allows application-defined keymap names; there is a new public
function, rl_set_keymap_name(), to do that.
k. The "Insert" keypad key, if available, now puts readline into overwrite
mode.
-------------------------------------------------------------------------------
This is a terse description of the new features added to readline-7.0 since This is a terse description of the new features added to readline-7.0 since
the release of readline-6.3. the release of readline-6.3.
@ -46,6 +91,34 @@ k. If readline reads a history file that begins with `#' (or the value of
l. Readline now throws an error if it parses a key binding without a terminating l. Readline now throws an error if it parses a key binding without a terminating
`:' or whitespace. `:' or whitespace.
m. The default binding for ^W in vi mode now uses word boundaries specified
by Posix (vi-unix-word-rubout is bindable command name).
n. rl_clear_visible_line: new application-callable function; clears all
screen lines occupied by the current visible readline line.
o. rl_tty_set_echoing: application-callable function that controls whether
or not readline thinks it is echoing terminal output.
p. Handle >| and strings of digits preceding and following redirection
specifications as single tokens when tokenizing the line for history
expansion.
q. Fixed a bug with displaying completions when the prefix display length
is greater than the length of the completions to be displayed.
r. The :p history modifier now applies to the entire line, so any expansion
specifying :p causes the line to be printed instead of expanded.
s. New application-callable function: rl_pending_signal(): returns the signal
number of any signal readline has caught but not yet handled.
t. New application-settable variable: rl_persistent_signal_handlers: if set
to a non-zero value, readline will enable the readline-6.2 signal handler
behavior in callback mode: handlers are installed when
rl_callback_handler_install is called and removed removed when a complete
line has been read.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
This is a terse description of the new features added to readline-6.3 since This is a terse description of the new features added to readline-6.3 since
the release of readline-6.2. the release of readline-6.2.

View File

@ -1,7 +1,7 @@
Introduction Introduction
============ ============
This is the Gnu Readline library, version 7.0. This is the Gnu Readline library, version 8.0.
The Readline library provides a set of functions for use by applications 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 that allow users to edit command lines as they are typed in. Both

107
readline/aclocal.m4 vendored
View File

@ -1,4 +1,4 @@
dnl nl
dnl Bash specific tests dnl Bash specific tests
dnl dnl
dnl Some derived from PDKSH 5.1.3 autoconf tests dnl Some derived from PDKSH 5.1.3 autoconf tests
@ -962,7 +962,8 @@ AC_CACHE_VAL(bash_cv_termcap_lib,
[AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo, [AC_CHECK_LIB(tinfo, tgetent, bash_cv_termcap_lib=libtinfo,
[AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses, [AC_CHECK_LIB(curses, tgetent, bash_cv_termcap_lib=libcurses,
[AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses, [AC_CHECK_LIB(ncurses, tgetent, bash_cv_termcap_lib=libncurses,
bash_cv_termcap_lib=gnutermcap)])])])])]) [AC_CHECK_LIB(ncursesw, tgetent, bash_cv_termcap_lib=libncursesw,
bash_cv_termcap_lib=gnutermcap)])])])])])])
if test "X$_bash_needmsg" = "Xyes"; then if test "X$_bash_needmsg" = "Xyes"; then
AC_MSG_CHECKING(which library has the termcap functions) AC_MSG_CHECKING(which library has the termcap functions)
fi fi
@ -1307,7 +1308,7 @@ AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
typedef RETSIGTYPE sigfunc(); typedef RETSIGTYPE sigfunc();
int nsigint; volatile int nsigint;
#ifdef HAVE_POSIX_SIGNALS #ifdef HAVE_POSIX_SIGNALS
sigfunc * sigfunc *
@ -1357,7 +1358,7 @@ AC_DEFUN(BASH_SYS_JOB_CONTROL_MISSING,
[AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE]) [AC_REQUIRE([BASH_SYS_SIGNAL_VINTAGE])
AC_MSG_CHECKING(for presence of necessary job control definitions) AC_MSG_CHECKING(for presence of necessary job control definitions)
AC_CACHE_VAL(bash_cv_job_control_missing, AC_CACHE_VAL(bash_cv_job_control_missing,
[AC_TRY_RUN([ [AC_TRY_COMPILE([
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_SYS_WAIT_H #ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h> #include <sys/wait.h>
@ -1367,42 +1368,38 @@ AC_CACHE_VAL(bash_cv_job_control_missing,
#endif #endif
#include <signal.h> #include <signal.h>
/* Add more tests in here as appropriate. */ /* add more tests in here as appropriate */
main()
{
/* signal type */ /* signal type */
#if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS) #if !defined (HAVE_POSIX_SIGNALS) && !defined (HAVE_BSD_SIGNALS)
exit(1); #error
#endif #endif
/* signals and tty control. */ /* signals and tty control. */
#if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT) #if !defined (SIGTSTP) || !defined (SIGSTOP) || !defined (SIGCONT)
exit (1); #error
#endif #endif
/* process control */ /* process control */
#if !defined (WNOHANG) || !defined (WUNTRACED) #if !defined (WNOHANG) || !defined (WUNTRACED)
exit(1); #error
#endif #endif
/* Posix systems have tcgetpgrp and waitpid. */ /* Posix systems have tcgetpgrp and waitpid. */
#if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP) #if defined (_POSIX_VERSION) && !defined (HAVE_TCGETPGRP)
exit(1); #error
#endif #endif
#if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID) #if defined (_POSIX_VERSION) && !defined (HAVE_WAITPID)
exit(1); #error
#endif #endif
/* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */ /* Other systems have TIOCSPGRP/TIOCGPRGP and wait3. */
#if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3) #if !defined (_POSIX_VERSION) && !defined (HAVE_WAIT3)
exit(1); #error
#endif #endif
exit(0); ], , bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing
}], bash_cv_job_control_missing=present, bash_cv_job_control_missing=missing,
[AC_MSG_WARN(cannot check job control if cross-compiling -- defaulting to missing)
bash_cv_job_control_missing=missing]
)]) )])
AC_MSG_RESULT($bash_cv_job_control_missing) AC_MSG_RESULT($bash_cv_job_control_missing)
if test $bash_cv_job_control_missing = missing; then if test $bash_cv_job_control_missing = missing; then
@ -1585,9 +1582,7 @@ fi
AC_DEFUN(BASH_CHECK_DEV_STDIN, AC_DEFUN(BASH_CHECK_DEV_STDIN,
[AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available) [AC_MSG_CHECKING(whether /dev/stdin stdout stderr are available)
AC_CACHE_VAL(bash_cv_dev_stdin, AC_CACHE_VAL(bash_cv_dev_stdin,
[if test -d /dev/fd && (exec test -r /dev/stdin < /dev/null) ; then [if (exec test -r /dev/stdin < /dev/null) ; then
bash_cv_dev_stdin=present
elif test -d /proc/self/fd && (exec test -r /dev/stdin < /dev/null) ; then
bash_cv_dev_stdin=present bash_cv_dev_stdin=present
else else
bash_cv_dev_stdin=absent bash_cv_dev_stdin=absent
@ -1798,6 +1793,8 @@ if test "$am_cv_func_iconv" = yes; then
LIBS="$OLDLIBS" LIBS="$OLDLIBS"
fi fi
AC_CHECK_SIZEOF(wchar_t, 4)
]) ])
dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB dnl need: prefix exec_prefix libdir includedir CC TERMCAP_LIB
@ -1856,7 +1853,7 @@ main()
], ],
ac_cv_rl_version=`cat conftest.rlv`, ac_cv_rl_version=`cat conftest.rlv`,
ac_cv_rl_version='0.0', ac_cv_rl_version='0.0',
ac_cv_rl_version='6.3')]) ac_cv_rl_version='8.0')])
CFLAGS="$_save_CFLAGS" CFLAGS="$_save_CFLAGS"
LDFLAGS="$_save_LDFLAGS" LDFLAGS="$_save_LDFLAGS"
@ -4195,3 +4192,71 @@ fi
AC_MSG_RESULT($bash_cv_wexitstatus_offset) AC_MSG_RESULT($bash_cv_wexitstatus_offset)
AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bash_cv_wexitstatus_offset], [Offset of exit status in wait status word]) AC_DEFINE_UNQUOTED([WEXITSTATUS_OFFSET], [$bash_cv_wexitstatus_offset], [Offset of exit status in wait status word])
]) ])
AC_DEFUN([BASH_FUNC_SBRK],
[
AC_CHECK_FUNCS_ONCE([sbrk])
if test X$ac_cv_func_sbrk = Xyes; then
AC_CACHE_CHECK([for working sbrk], [bash_cv_func_sbrk],
[AC_TRY_RUN([
#include <stdlib.h>
#include <unistd.h>
int
main(int c, char **v)
{
void *x;
x = sbrk (4096);
exit ((x == (void *)-1) ? 1 : 0);
}
], bash_cv_func_sbrk=yes, bash_cv_func_snprintf=sbrk,
[AC_MSG_WARN([cannot check working sbrk if cross-compiling])
bash_cv_func_sbrk=yes]
)])
if test $bash_cv_func_sbrk = no; then
ac_cv_func_sbrk=no
fi
fi
if test $ac_cv_func_sbrk = no; then
AC_DEFINE(HAVE_SBRK, 0,
[Define if you have a working sbrk function.])
fi
])
AC_DEFUN(BASH_FUNC_FNMATCH_EQUIV_FALLBACK,
[AC_MSG_CHECKING(whether fnmatch can be used to check bracket equivalence classes)
AC_CACHE_VAL(bash_cv_fnmatch_equiv_fallback,
[AC_TRY_RUN([
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <fnmatch.h>
#include <locale.h>
char *pattern = "[[=a=]]";
/* char *string = "ä"; */
unsigned char string[4] = { '\xc3', '\xa4', '\0' };
int
main (int c, char **v)
{
setlocale (LC_ALL, "de_DE.UTF-8");
if (fnmatch (pattern, (const char *)string, 0) != FNM_NOMATCH)
exit (0);
exit (1);
}
], bash_cv_fnmatch_equiv_fallback=yes, bash_cv_fnmatch_equiv_fallback=no,
[AC_MSG_WARN(cannot check fnmatch if cross compiling -- defaulting to no)
bash_cv_fnmatch_equiv_fallback=no]
)])
AC_MSG_RESULT($bash_cv_fnmatch_equiv_fallback)
if test "$bash_cv_fnmatch_equiv_fallback" = "yes" ; then
bash_cv_fnmatch_equiv_value=1
else
bash_cv_fnmatch_equiv_value=0
fi
AC_DEFINE_UNQUOTED([FNMATCH_EQUIV_FALLBACK], [$bash_cv_fnmatch_equiv_value], [Whether fnmatch can be used for bracket equivalence classes])
])

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* callback.c -- functions to use readline as an X `callback' mechanism. */ /* callback.c -- functions to use readline as an X `callback' mechanism. */
/* Copyright (C) 1987-2015 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -60,7 +60,7 @@ int rl_persistent_signal_handlers = 0;
/* **************************************************************** */ /* **************************************************************** */
/* */ /* */
/* Callback Readline Functions */ /* Callback Readline Functions */
/* */ /* */
/* **************************************************************** */ /* **************************************************************** */
@ -80,7 +80,7 @@ static int in_handler; /* terminal_prepped and signals set? */
/* Make sure the terminal is set up, initialize readline, and prompt. */ /* Make sure the terminal is set up, initialize readline, and prompt. */
static void static void
_rl_callback_newline () _rl_callback_newline (void)
{ {
rl_initialize (); rl_initialize ();
@ -103,9 +103,7 @@ _rl_callback_newline ()
/* Install a readline handler, set up the terminal, and issue the prompt. */ /* Install a readline handler, set up the terminal, and issue the prompt. */
void void
rl_callback_handler_install (prompt, linefunc) rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *linefunc)
const char *prompt;
rl_vcpfunc_t *linefunc;
{ {
rl_set_prompt (prompt); rl_set_prompt (prompt);
RL_SETSTATE (RL_STATE_CALLBACK); RL_SETSTATE (RL_STATE_CALLBACK);
@ -126,7 +124,7 @@ rl_callback_handler_install (prompt, linefunc)
/* Read one character, and dispatch to the handler if it ends the line. */ /* Read one character, and dispatch to the handler if it ends the line. */
void void
rl_callback_read_char () rl_callback_read_char (void)
{ {
char *line; char *line;
int eof, jcode; int eof, jcode;
@ -299,7 +297,7 @@ rl_callback_read_char ()
/* Remove the handler, and make sure the terminal is in its normal state. */ /* Remove the handler, and make sure the terminal is in its normal state. */
void void
rl_callback_handler_remove () rl_callback_handler_remove (void)
{ {
rl_linefunc = NULL; rl_linefunc = NULL;
RL_UNSETSTATE (RL_STATE_CALLBACK); RL_UNSETSTATE (RL_STATE_CALLBACK);
@ -316,8 +314,7 @@ rl_callback_handler_remove ()
} }
_rl_callback_generic_arg * _rl_callback_generic_arg *
_rl_callback_data_alloc (count) _rl_callback_data_alloc (int count)
int count;
{ {
_rl_callback_generic_arg *arg; _rl_callback_generic_arg *arg;
@ -330,15 +327,14 @@ _rl_callback_data_alloc (count)
} }
void void
_rl_callback_data_dispose (arg) _rl_callback_data_dispose (_rl_callback_generic_arg *arg)
_rl_callback_generic_arg *arg;
{ {
xfree (arg); xfree (arg);
} }
/* Make sure that this agrees with cases in rl_callback_read_char */ /* Make sure that this agrees with cases in rl_callback_read_char */
void void
rl_callback_sigcleanup () rl_callback_sigcleanup (void)
{ {
if (RL_ISSTATE (RL_STATE_CALLBACK) == 0) if (RL_ISSTATE (RL_STATE_CALLBACK) == 0)
return; return;

View File

@ -2,7 +2,7 @@
Modified by Chet Ramey for Readline. Modified by Chet Ramey for Readline.
Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015 Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015, 2017
Free Software Foundation, Inc. Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@ -37,6 +37,10 @@
#include "posixstat.h" // stat related macros (S_ISREG, ...) #include "posixstat.h" // stat related macros (S_ISREG, ...)
#include <fcntl.h> // S_ISUID #include <fcntl.h> // S_ISUID
#ifndef S_ISDIR
# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
#endif
// strlen() // strlen()
#if defined (HAVE_STRING_H) #if defined (HAVE_STRING_H)
# include <string.h> # include <string.h>
@ -66,7 +70,8 @@ COLOR_EXT_TYPE *_rl_color_ext_list = 0;
/* Output a color indicator (which may contain nulls). */ /* Output a color indicator (which may contain nulls). */
void void
_rl_put_indicator (const struct bin_str *ind) { _rl_put_indicator (const struct bin_str *ind)
{
fwrite (ind->string, ind->len, 1, rl_outstream); fwrite (ind->string, ind->len, 1, rl_outstream);
} }
@ -183,11 +188,17 @@ _rl_print_color_indicator (const char *f)
{ {
colored_filetype = C_FILE; colored_filetype = C_FILE;
#if defined (S_ISUID)
if ((mode & S_ISUID) != 0 && is_colored (C_SETUID)) if ((mode & S_ISUID) != 0 && is_colored (C_SETUID))
colored_filetype = C_SETUID; colored_filetype = C_SETUID;
else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID)) else
#endif
#if defined (S_ISGID)
if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))
colored_filetype = C_SETGID; colored_filetype = C_SETGID;
else if (is_colored (C_CAP) && 0) //f->has_capability) else
#endif
if (is_colored (C_CAP) && 0) //f->has_capability)
colored_filetype = C_CAP; colored_filetype = C_CAP;
else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC)) else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
colored_filetype = C_EXEC; colored_filetype = C_EXEC;
@ -211,12 +222,16 @@ _rl_print_color_indicator (const char *f)
colored_filetype = C_STICKY; colored_filetype = C_STICKY;
#endif #endif
} }
#if defined (S_ISLNK)
else if (S_ISLNK (mode)) else if (S_ISLNK (mode))
colored_filetype = C_LINK; colored_filetype = C_LINK;
#endif
else if (S_ISFIFO (mode)) else if (S_ISFIFO (mode))
colored_filetype = C_FIFO; colored_filetype = C_FIFO;
#if defined (S_ISSOCK)
else if (S_ISSOCK (mode)) else if (S_ISSOCK (mode))
colored_filetype = C_SOCK; colored_filetype = C_SOCK;
#endif
else if (S_ISBLK (mode)) else if (S_ISBLK (mode))
colored_filetype = C_BLK; colored_filetype = C_BLK;
else if (S_ISCHR (mode)) else if (S_ISCHR (mode))

View File

@ -1,6 +1,6 @@
/* compat.c -- backwards compatibility functions. */ /* compat.c -- backwards compatibility functions. */
/* Copyright (C) 2000-2009 Free Software Foundation, Inc. /* Copyright (C) 2000-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -46,68 +46,61 @@ extern char *rl_filename_completion_function PARAMS((const char *, int));
/* Provide backwards-compatible entry points for old function names. */ /* Provide backwards-compatible entry points for old function names. */
void void
free_undo_list () free_undo_list (void)
{ {
rl_free_undo_list (); rl_free_undo_list ();
} }
int int
maybe_replace_line () maybe_replace_line (void)
{ {
return rl_maybe_replace_line (); return rl_maybe_replace_line ();
} }
int int
maybe_save_line () maybe_save_line (void)
{ {
return rl_maybe_save_line (); return rl_maybe_save_line ();
} }
int int
maybe_unsave_line () maybe_unsave_line (void)
{ {
return rl_maybe_unsave_line (); return rl_maybe_unsave_line ();
} }
int int
ding () ding (void)
{ {
return rl_ding (); return rl_ding ();
} }
int int
crlf () crlf (void)
{ {
return rl_crlf (); return rl_crlf ();
} }
int int
alphabetic (c) alphabetic (int c)
int c;
{ {
return rl_alphabetic (c); return rl_alphabetic (c);
} }
char ** char **
completion_matches (s, f) completion_matches (const char *s, rl_compentry_func_t *f)
const char *s;
rl_compentry_func_t *f;
{ {
return rl_completion_matches (s, f); return rl_completion_matches (s, f);
} }
char * char *
username_completion_function (s, i) username_completion_function (const char *s, int i)
const char *s;
int i;
{ {
return rl_username_completion_function (s, i); return rl_username_completion_function (s, i);
} }
char * char *
filename_completion_function (s, i) filename_completion_function (const char *s, int i)
const char *s;
int i;
{ {
return rl_filename_completion_function (s, i); return rl_filename_completion_function (s, i);
} }

View File

@ -1,6 +1,6 @@
/* complete.c -- filename completion for readline. */ /* complete.c -- filename completion for readline. */
/* Copyright (C) 1987-2015 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -198,15 +198,6 @@ int _rl_completion_prefix_display_length = 0;
matches. If < 0 or > _rl_screenwidth, it is ignored. */ matches. If < 0 or > _rl_screenwidth, it is ignored. */
int _rl_completion_columns = -1; int _rl_completion_columns = -1;
/* Global variables available to applications using readline. */
#if defined (VISIBLE_STATS)
/* Non-zero means add an additional character to each filename displayed
during listing completion iff rl_filename_completion_desired which helps
to indicate the type of file being listed. */
int rl_visible_stats = 0;
#endif /* VISIBLE_STATS */
#if defined (COLOR_SUPPORT) #if defined (COLOR_SUPPORT)
/* Non-zero means to use colors to indicate file type when listing possible /* Non-zero means to use colors to indicate file type when listing possible
completions. The colors used are taken from $LS_COLORS, if set. */ completions. The colors used are taken from $LS_COLORS, if set. */
@ -227,6 +218,15 @@ int _rl_skip_completed_text = 0;
cycle of possible completions instead of the last. */ cycle of possible completions instead of the last. */
int _rl_menu_complete_prefix_first = 0; int _rl_menu_complete_prefix_first = 0;
/* Global variables available to applications using readline. */
#if defined (VISIBLE_STATS)
/* Non-zero means add an additional character to each filename displayed
during listing completion iff rl_filename_completion_desired which helps
to indicate the type of file being listed. */
int rl_visible_stats = 0;
#endif /* VISIBLE_STATS */
/* If non-zero, then this is the address of a function to call when /* If non-zero, then this is the address of a function to call when
completing on a directory name. The function is called with completing on a directory name. The function is called with
the address of a string (the current directory name) as an arg. */ the address of a string (the current directory name) as an arg. */
@ -422,8 +422,7 @@ static int _rl_complete_display_matches_interrupt = 0;
that does the initial simple matching selection algorithm (see that does the initial simple matching selection algorithm (see
rl_completion_matches ()). The default is to do filename completion. */ rl_completion_matches ()). The default is to do filename completion. */
int int
rl_complete (ignore, invoking_key) rl_complete (int ignore, int invoking_key)
int ignore, invoking_key;
{ {
rl_completion_invoking_key = invoking_key; rl_completion_invoking_key = invoking_key;
@ -441,16 +440,14 @@ rl_complete (ignore, invoking_key)
/* List the possible completions. See description of rl_complete (). */ /* List the possible completions. See description of rl_complete (). */
int int
rl_possible_completions (ignore, invoking_key) rl_possible_completions (int ignore, int invoking_key)
int ignore, invoking_key;
{ {
rl_completion_invoking_key = invoking_key; rl_completion_invoking_key = invoking_key;
return (rl_complete_internal ('?')); return (rl_complete_internal ('?'));
} }
int int
rl_insert_completions (ignore, invoking_key) rl_insert_completions (int ignore, int invoking_key)
int ignore, invoking_key;
{ {
rl_completion_invoking_key = invoking_key; rl_completion_invoking_key = invoking_key;
return (rl_complete_internal ('*')); return (rl_complete_internal ('*'));
@ -462,8 +459,7 @@ rl_insert_completions (ignore, invoking_key)
an application-specific completion function to honor the an application-specific completion function to honor the
show-all-if-ambiguous readline variable. */ show-all-if-ambiguous readline variable. */
int int
rl_completion_mode (cfunc) rl_completion_mode (rl_command_func_t *cfunc)
rl_command_func_t *cfunc;
{ {
if (rl_last_func == cfunc && !completion_changed_buffer) if (rl_last_func == cfunc && !completion_changed_buffer)
return '?'; return '?';
@ -483,16 +479,14 @@ rl_completion_mode (cfunc)
/* Reset readline state on a signal or other event. */ /* Reset readline state on a signal or other event. */
void void
_rl_reset_completion_state () _rl_reset_completion_state (void)
{ {
rl_completion_found_quote = 0; rl_completion_found_quote = 0;
rl_completion_quote_character = 0; rl_completion_quote_character = 0;
} }
static void static void
_rl_complete_sigcleanup (sig, ptr) _rl_complete_sigcleanup (int sig, void *ptr)
int sig;
void *ptr;
{ {
if (sig == SIGINT) /* XXX - for now */ if (sig == SIGINT) /* XXX - for now */
{ {
@ -504,8 +498,7 @@ _rl_complete_sigcleanup (sig, ptr)
/* Set default values for readline word completion. These are the variables /* Set default values for readline word completion. These are the variables
that application completion functions can change or inspect. */ that application completion functions can change or inspect. */
static void static void
set_completion_defaults (what_to_do) set_completion_defaults (int what_to_do)
int what_to_do;
{ {
/* Only the completion entry function can change these. */ /* Only the completion entry function can change these. */
rl_filename_completion_desired = 0; rl_filename_completion_desired = 0;
@ -523,8 +516,7 @@ set_completion_defaults (what_to_do)
/* The user must press "y" or "n". Non-zero return means "y" pressed. */ /* The user must press "y" or "n". Non-zero return means "y" pressed. */
static int static int
get_y_or_n (for_pager) get_y_or_n (int for_pager)
int for_pager;
{ {
int c; int c;
@ -557,8 +549,7 @@ get_y_or_n (for_pager)
} }
static int static int
_rl_internal_pager (lines) _rl_internal_pager (int lines)
int lines;
{ {
int i; int i;
@ -575,8 +566,7 @@ _rl_internal_pager (lines)
} }
static int static int
path_isdir (filename) path_isdir (const char *filename)
const char *filename;
{ {
struct stat finfo; struct stat finfo;
@ -593,8 +583,7 @@ path_isdir (filename)
`%' for character special devices `%' for character special devices
`#' for block special devices */ `#' for block special devices */
static int static int
stat_char (filename) stat_char (char *filename)
char *filename;
{ {
struct stat finfo; struct stat finfo;
int character, r; int character, r;
@ -625,7 +614,10 @@ stat_char (filename)
#endif #endif
if (r == -1) if (r == -1)
return (0); {
xfree (f);
return (0);
}
character = 0; character = 0;
if (S_ISDIR (finfo.st_mode)) if (S_ISDIR (finfo.st_mode))
@ -675,29 +667,28 @@ stat_char (filename)
#if defined (COLOR_SUPPORT) #if defined (COLOR_SUPPORT)
static int static int
colored_stat_start (filename) colored_stat_start (const char *filename)
const char *filename;
{ {
_rl_set_normal_color (); _rl_set_normal_color ();
return (_rl_print_color_indicator (filename)); return (_rl_print_color_indicator (filename));
} }
static void static void
colored_stat_end () colored_stat_end (void)
{ {
_rl_prep_non_filename_text (); _rl_prep_non_filename_text ();
_rl_put_indicator (&_rl_color_indicator[C_CLR_TO_EOL]); _rl_put_indicator (&_rl_color_indicator[C_CLR_TO_EOL]);
} }
static int static int
colored_prefix_start () colored_prefix_start (void)
{ {
_rl_set_normal_color (); _rl_set_normal_color ();
return (_rl_print_prefix_color ()); return (_rl_print_prefix_color ());
} }
static void static void
colored_prefix_end () colored_prefix_end (void)
{ {
colored_stat_end (); /* for now */ colored_stat_end (); /* for now */
} }
@ -712,8 +703,7 @@ colored_prefix_end ()
for the previous slash and return the portion following that. If for the previous slash and return the portion following that. If
there's no previous slash, we just return what we were passed. */ there's no previous slash, we just return what we were passed. */
static char * static char *
printable_part (pathname) printable_part (char *pathname)
char *pathname;
{ {
char *temp, *x; char *temp, *x;
@ -747,8 +737,7 @@ printable_part (pathname)
/* Compute width of STRING when displayed on screen by print_filename */ /* Compute width of STRING when displayed on screen by print_filename */
static int static int
fnwidth (string) fnwidth (const char *string)
const char *string;
{ {
int width, pos; int width, pos;
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
@ -800,10 +789,7 @@ fnwidth (string)
#define ELLIPSIS_LEN 3 #define ELLIPSIS_LEN 3
static int static int
fnprint (to_print, prefix_bytes, real_pathname) fnprint (const char *to_print, int prefix_bytes, const char *real_pathname)
const char *to_print;
int prefix_bytes;
const char *real_pathname;
{ {
int printed_len, w; int printed_len, w;
const char *s; const char *s;
@ -818,6 +804,8 @@ fnprint (to_print, prefix_bytes, real_pathname)
print_len = strlen (to_print); print_len = strlen (to_print);
end = to_print + print_len + 1; end = to_print + print_len + 1;
memset (&ps, 0, sizeof (mbstate_t)); memset (&ps, 0, sizeof (mbstate_t));
#else
print_len = strlen (to_print);
#endif #endif
printed_len = common_prefix_len = 0; printed_len = common_prefix_len = 0;
@ -929,9 +917,7 @@ fnprint (to_print, prefix_bytes, real_pathname)
filenames. Return the number of characters we output. */ filenames. Return the number of characters we output. */
static int static int
print_filename (to_print, full_pathname, prefix_bytes) print_filename (char *to_print, char *full_pathname, int prefix_bytes)
char *to_print, *full_pathname;
int prefix_bytes;
{ {
int printed_len, extension_char, slen, tlen; int printed_len, extension_char, slen, tlen;
char *s, c, *new_full_pathname, *dn; char *s, c, *new_full_pathname, *dn;
@ -988,7 +974,6 @@ print_filename (to_print, full_pathname, prefix_bytes)
slen--; slen--;
else else
new_full_pathname[slen] = '/'; new_full_pathname[slen] = '/';
new_full_pathname[slen] = '/';
strcpy (new_full_pathname + slen + 1, to_print); strcpy (new_full_pathname + slen + 1, to_print);
#if defined (VISIBLE_STATS) #if defined (VISIBLE_STATS)
@ -1049,10 +1034,7 @@ print_filename (to_print, full_pathname, prefix_bytes)
} }
static char * static char *
rl_quote_filename (s, rtype, qcp) rl_quote_filename (char *s, int rtype, char *qcp)
char *s;
int rtype;
char *qcp;
{ {
char *r; char *r;
@ -1080,8 +1062,7 @@ rl_quote_filename (s, rtype, qcp)
the value of the delimiter character that caused a word break. */ the value of the delimiter character that caused a word break. */
char char
_rl_find_completion_word (fp, dp) _rl_find_completion_word (int *fp, int *dp)
int *fp, *dp;
{ {
int scan, end, found_quote, delimiter, pass_next, isbrk; int scan, end, found_quote, delimiter, pass_next, isbrk;
char quote_char, *brkchars; char quote_char, *brkchars;
@ -1213,11 +1194,7 @@ _rl_find_completion_word (fp, dp)
} }
static char ** static char **
gen_completion_matches (text, start, end, our_func, found_quote, quote_char) gen_completion_matches (char *text, int start, int end, rl_compentry_func_t *our_func, int found_quote, int quote_char)
char *text;
int start, end;
rl_compentry_func_t *our_func;
int found_quote, quote_char;
{ {
char **matches; char **matches;
@ -1261,8 +1238,7 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
/* Filter out duplicates in MATCHES. This frees up the strings in /* Filter out duplicates in MATCHES. This frees up the strings in
MATCHES. */ MATCHES. */
static char ** static char **
remove_duplicate_matches (matches) remove_duplicate_matches (char **matches)
char **matches;
{ {
char *lowest_common; char *lowest_common;
int i, j, newlen; int i, j, newlen;
@ -1322,10 +1298,7 @@ remove_duplicate_matches (matches)
/* Find the common prefix of the list of matches, and put it into /* Find the common prefix of the list of matches, and put it into
matches[0]. */ matches[0]. */
static int static int
compute_lcd_of_matches (match_list, matches, text) compute_lcd_of_matches (char **match_list, int matches, const char *text)
char **match_list;
int matches;
const char *text;
{ {
register int i, c1, c2, si; register int i, c1, c2, si;
int low; /* Count of max-matched characters. */ int low; /* Count of max-matched characters. */
@ -1451,7 +1424,8 @@ compute_lcd_of_matches (match_list, matches, text)
} }
/* sort the list to get consistent answers. */ /* sort the list to get consistent answers. */
qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare); if (rl_sort_completion_matches)
qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
si = strlen (text); si = strlen (text);
lx = (si <= low) ? si : low; /* check shorter of text and matches */ lx = (si <= low) ? si : low; /* check shorter of text and matches */
@ -1481,9 +1455,7 @@ compute_lcd_of_matches (match_list, matches, text)
} }
static int static int
postprocess_matches (matchesp, matching_filenames) postprocess_matches (char ***matchesp, int matching_filenames)
char ***matchesp;
int matching_filenames;
{ {
char *t, **matches, **temp_matches; char *t, **matches, **temp_matches;
int nmatch, i; int nmatch, i;
@ -1537,7 +1509,7 @@ postprocess_matches (matchesp, matching_filenames)
} }
static int static int
complete_get_screenwidth () complete_get_screenwidth (void)
{ {
int cols; int cols;
char *envcols; char *envcols;
@ -1558,9 +1530,7 @@ complete_get_screenwidth ()
of strings, in argv format, LEN is the number of strings in MATCHES, of strings, in argv format, LEN is the number of strings in MATCHES,
and MAX is the length of the longest string in MATCHES. */ and MAX is the length of the longest string in MATCHES. */
void void
rl_display_match_list (matches, len, max) rl_display_match_list (char **matches, int len, int max)
char **matches;
int len, max;
{ {
int count, limit, printed_len, lines, cols; int count, limit, printed_len, lines, cols;
int i, j, k, l, common_length, sind; int i, j, k, l, common_length, sind;
@ -1717,8 +1687,7 @@ rl_display_match_list (matches, len, max)
and ask the user if he wants to see the list if there are more matches and ask the user if he wants to see the list if there are more matches
than RL_COMPLETION_QUERY_ITEMS. */ than RL_COMPLETION_QUERY_ITEMS. */
static void static void
display_matches (matches) display_matches (char **matches)
char **matches;
{ {
int len, max, i; int len, max, i;
char *temp; char *temp;
@ -1784,11 +1753,9 @@ display_matches (matches)
rl_display_fixed = 1; rl_display_fixed = 1;
} }
/* qc == pointer to quoting character, if any */
static char * static char *
make_quoted_replacement (match, mtype, qc) make_quoted_replacement (char *match, int mtype, char *qc)
char *match;
int mtype;
char *qc; /* Pointer to quoting character, if any */
{ {
int should_quote, do_replace; int should_quote, do_replace;
char *replacement; char *replacement;
@ -1830,10 +1797,7 @@ make_quoted_replacement (match, mtype, qc)
} }
static void static void
insert_match (match, start, mtype, qc) insert_match (char *match, int start, int mtype, char *qc)
char *match;
int start, mtype;
char *qc;
{ {
char *replacement, *r; char *replacement, *r;
char oqc; char oqc;
@ -1890,9 +1854,7 @@ insert_match (match, start, mtype, qc)
value of _rl_complete_mark_symlink_dirs, but may be modified by an value of _rl_complete_mark_symlink_dirs, but may be modified by an
application's completion function). */ application's completion function). */
static int static int
append_to_match (text, delimiter, quote_char, nontrivial_match) append_to_match (char *text, int delimiter, int quote_char, int nontrivial_match)
char *text;
int delimiter, quote_char, nontrivial_match;
{ {
char temp_string[4], *filename, *fn; char temp_string[4], *filename, *fn;
int temp_string_index, s; int temp_string_index, s;
@ -1959,10 +1921,7 @@ append_to_match (text, delimiter, quote_char, nontrivial_match)
} }
static void static void
insert_all_matches (matches, point, qc) insert_all_matches (char **matches, int point, char *qc)
char **matches;
int point;
char *qc;
{ {
int i; int i;
char *rp; char *rp;
@ -1998,8 +1957,7 @@ insert_all_matches (matches, point, qc)
} }
void void
_rl_free_match_list (matches) _rl_free_match_list (char **matches)
char **matches;
{ {
register int i; register int i;
@ -2021,17 +1979,14 @@ _rl_free_match_list (matches)
`@' means to do standard completion, and list all possible completions if `@' means to do standard completion, and list all possible completions if
there is more than one and partial completion is not possible. */ there is more than one and partial completion is not possible. */
int int
rl_complete_internal (what_to_do) rl_complete_internal (int what_to_do)
int what_to_do;
{ {
char **matches; char **matches;
rl_compentry_func_t *our_func; rl_compentry_func_t *our_func;
int start, end, delimiter, found_quote, i, nontrivial_lcd; int start, end, delimiter, found_quote, i, nontrivial_lcd;
char *text, *saved_line_buffer; char *text, *saved_line_buffer;
char quote_char; char quote_char;
#if 1
int tlen, mlen; int tlen, mlen;
#endif
RL_SETSTATE(RL_STATE_COMPLETING); RL_SETSTATE(RL_STATE_COMPLETING);
@ -2206,9 +2161,7 @@ rl_complete_internal (what_to_do)
when there are no more matches. when there are no more matches.
*/ */
char ** char **
rl_completion_matches (text, entry_function) rl_completion_matches (const char *text, rl_compentry_func_t *entry_function)
const char *text;
rl_compentry_func_t *entry_function;
{ {
register int i; register int i;
@ -2276,9 +2229,7 @@ rl_completion_matches (text, entry_function)
TEXT contains a partial username preceded by a random TEXT contains a partial username preceded by a random
character (usually `~'). */ character (usually `~'). */
char * char *
rl_username_completion_function (text, state) rl_username_completion_function (const char *text, int state)
const char *text;
int state;
{ {
#if defined (__WIN32__) || defined (__OPENNT) #if defined (__WIN32__) || defined (__OPENNT)
return (char *)NULL; return (char *)NULL;
@ -2340,11 +2291,7 @@ rl_username_completion_function (text, state)
_rl_completion_case_map is set, make `-' and `_' equivalent. CONVFN is _rl_completion_case_map is set, make `-' and `_' equivalent. CONVFN is
the possibly-converted directory entry; FILENAME is what the user typed. */ the possibly-converted directory entry; FILENAME is what the user typed. */
static int static int
complete_fncmp (convfn, convlen, filename, filename_len) complete_fncmp (const char *convfn, int convlen, const char *filename, int filename_len)
const char *convfn;
int convlen;
const char *filename;
int filename_len;
{ {
register char *s1, *s2; register char *s1, *s2;
int d, len; int d, len;
@ -2472,9 +2419,7 @@ complete_fncmp (convfn, convlen, filename, filename_len)
because of all the pathnames that must be followed when looking up the because of all the pathnames that must be followed when looking up the
completion for a command. */ completion for a command. */
char * char *
rl_filename_completion_function (text, state) rl_filename_completion_function (const char *text, int state)
const char *text;
int state;
{ {
static DIR *directory = (DIR *)NULL; static DIR *directory = (DIR *)NULL;
static char *filename = (char *)NULL; static char *filename = (char *)NULL;
@ -2702,8 +2647,7 @@ rl_filename_completion_function (text, state)
hit the end of the match list, we restore the original unmatched text, hit the end of the match list, we restore the original unmatched text,
ring the bell, and reset the counter to zero. */ ring the bell, and reset the counter to zero. */
int int
rl_old_menu_complete (count, invoking_key) rl_old_menu_complete (int count, int invoking_key)
int count, invoking_key;
{ {
rl_compentry_func_t *our_func; rl_compentry_func_t *our_func;
int matching_filenames, found_quote; int matching_filenames, found_quote;
@ -2824,9 +2768,17 @@ rl_old_menu_complete (count, invoking_key)
return (0); return (0);
} }
/* The current version of menu completion.
The differences between this function and the original are:
1. It honors the maximum number of completions variable (completion-query-items)
2. It appends to the word as usual if there is only one match
3. It displays the common prefix if there is one, and makes it the first menu
choice if the menu-complete-display-prefix option is enabled
*/
int int
rl_menu_complete (count, ignore) rl_menu_complete (int count, int ignore)
int count, ignore;
{ {
rl_compentry_func_t *our_func; rl_compentry_func_t *our_func;
int matching_filenames, found_quote; int matching_filenames, found_quote;
@ -2998,8 +2950,7 @@ rl_menu_complete (count, ignore)
} }
int int
rl_backward_menu_complete (count, key) rl_backward_menu_complete (int count, int key)
int count, key;
{ {
/* Positive arguments to backward-menu-complete translate into negative /* Positive arguments to backward-menu-complete translate into negative
arguments for menu-complete, and vice versa. */ arguments for menu-complete, and vice versa. */

View File

@ -46,6 +46,9 @@
/* Define if you have the fcntl function. */ /* Define if you have the fcntl function. */
#undef HAVE_FCNTL #undef HAVE_FCNTL
/* Define if you have the fnmatch function. */
#undef HAVE_FNMATCH
/* Define if you have the getpwent function. */ /* Define if you have the getpwent function. */
#undef HAVE_GETPWENT #undef HAVE_GETPWENT

309
readline/configure vendored
View File

@ -1,7 +1,7 @@
#! /bin/sh #! /bin/sh
# From configure.ac for Readline 7.0, version 2.81. # From configure.ac for Readline 8.0, version 2.85.
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for readline 7.0. # Generated by GNU Autoconf 2.69 for readline 8.0.
# #
# Report bugs to <bug-readline@gnu.org>. # Report bugs to <bug-readline@gnu.org>.
# #
@ -581,8 +581,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='readline' PACKAGE_NAME='readline'
PACKAGE_TARNAME='readline' PACKAGE_TARNAME='readline'
PACKAGE_VERSION='7.0' PACKAGE_VERSION='8.0'
PACKAGE_STRING='readline 7.0' PACKAGE_STRING='readline 8.0'
PACKAGE_BUGREPORT='bug-readline@gnu.org' PACKAGE_BUGREPORT='bug-readline@gnu.org'
PACKAGE_URL='' PACKAGE_URL=''
@ -624,6 +624,7 @@ ac_includes_default="\
#endif" #endif"
ac_subst_vars='LTLIBOBJS ac_subst_vars='LTLIBOBJS
TERMCAP_PKG_CONFIG_LIB
TERMCAP_LIB TERMCAP_LIB
LIBVERSION LIBVERSION
ARFLAGS ARFLAGS
@ -631,6 +632,7 @@ LOCAL_DEFS
LOCAL_LDFLAGS LOCAL_LDFLAGS
LOCAL_CFLAGS LOCAL_CFLAGS
BUILD_DIR BUILD_DIR
EXAMPLES_INSTALL_TARGET
SHARED_INSTALL_TARGET SHARED_INSTALL_TARGET
STATIC_INSTALL_TARGET STATIC_INSTALL_TARGET
SHARED_TARGET SHARED_TARGET
@ -723,6 +725,7 @@ enable_option_checking
with_curses with_curses
enable_multibyte enable_multibyte
enable_static enable_static
enable_install_examples
enable_largefile enable_largefile
' '
ac_precious_vars='build_alias ac_precious_vars='build_alias
@ -1274,7 +1277,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures readline 7.0 to adapt to many kinds of systems. \`configure' configures readline 8.0 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1339,7 +1342,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of readline 7.0:";; short | recursive ) echo "Configuration of readline 8.0:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1349,6 +1352,8 @@ Optional Features:
--enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-multibyte enable multibyte characters if OS supports them --enable-multibyte enable multibyte characters if OS supports them
--enable-static build static libraries [[default=YES]] --enable-static build static libraries [[default=YES]]
--disable-install-examples
don't install examples [[default=install]]
--disable-largefile omit support for large files --disable-largefile omit support for large files
Optional Packages: Optional Packages:
@ -1433,7 +1438,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
readline configure 7.0 readline configure 8.0
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -1898,11 +1903,194 @@ $as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_decl } # ac_fn_c_check_decl
# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
# --------------------------------------------
# Tries to find the compile-time value of EXPR in a program that includes
# INCLUDES, setting VAR accordingly. Returns whether the value could be
# computed
ac_fn_c_compute_int ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if test "$cross_compiling" = yes; then
# Depending upon the size, compute the lo and hi bounds.
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) >= 0)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_lo=0 ac_mid=0
while :; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) <= $ac_mid)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_hi=$ac_mid; break
else
as_fn_arith $ac_mid + 1 && ac_lo=$as_val
if test $ac_lo -le $ac_mid; then
ac_lo= ac_hi=
break
fi
as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) < 0)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_hi=-1 ac_mid=-1
while :; do
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) >= $ac_mid)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_lo=$ac_mid; break
else
as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
if test $ac_mid -le $ac_hi; then
ac_lo= ac_hi=
break
fi
as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
else
ac_lo= ac_hi=
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
# Binary search between lo and hi bounds.
while test "x$ac_lo" != "x$ac_hi"; do
as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
int
main ()
{
static int test_array [1 - 2 * !(($2) <= $ac_mid)];
test_array [0] = 0;
return test_array [0];
;
return 0;
}
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
ac_hi=$ac_mid
else
as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
done
case $ac_lo in #((
?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
'') ac_retval=1 ;;
esac
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
static long int longval () { return $2; }
static unsigned long int ulongval () { return $2; }
#include <stdio.h>
#include <stdlib.h>
int
main ()
{
FILE *f = fopen ("conftest.val", "w");
if (! f)
return 1;
if (($2) < 0)
{
long int i = longval ();
if (i != ($2))
return 1;
fprintf (f, "%ld", i);
}
else
{
unsigned long int i = ulongval ();
if (i != ($2))
return 1;
fprintf (f, "%lu", i);
}
/* Do not output a trailing newline, as this causes \r\n confusion
on some platforms. */
return ferror (f) || fclose (f) != 0;
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
echo >>conftest.val; read $3 <conftest.val; ac_retval=0
else
ac_retval=1
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
rm -f conftest.val
fi
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_c_compute_int
cat >config.log <<_ACEOF cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by readline $as_me 7.0, which was It was created by readline $as_me 8.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -2289,7 +2477,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
ac_config_headers="$ac_config_headers config.h" ac_config_headers="$ac_config_headers config.h"
LIBVERSION=7.0 LIBVERSION=8.0
# Make sure we can run config.sub. # Make sure we can run config.sub.
$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
@ -2380,6 +2568,7 @@ fi
opt_multibyte=yes opt_multibyte=yes
opt_static_libs=yes opt_static_libs=yes
opt_shared_libs=no opt_shared_libs=no
opt_install_examples=no
# Check whether --enable-multibyte was given. # Check whether --enable-multibyte was given.
if test "${enable_multibyte+set}" = set; then : if test "${enable_multibyte+set}" = set; then :
@ -2391,6 +2580,11 @@ if test "${enable_static+set}" = set; then :
enableval=$enable_static; opt_static_libs=$enableval enableval=$enable_static; opt_static_libs=$enableval
fi fi
# Check whether --enable-install-examples was given.
if test "${enable_install_examples+set}" = set; then :
enableval=$enable_install_examples; opt_install_examples=$enableval
fi
if test $opt_multibyte = no; then if test $opt_multibyte = no; then
$as_echo "#define NO_MULTIBYTE_SUPPORT 1" >>confdefs.h $as_echo "#define NO_MULTIBYTE_SUPPORT 1" >>confdefs.h
@ -4586,7 +4780,7 @@ _ACEOF
fi fi
done done
for ac_func in memmove pselect putenv select setenv setlocale \ for ac_func in fnmatch memmove pselect putenv select setenv setlocale \
strcasecmp strpbrk tcgetattr vsnprintf strcasecmp strpbrk tcgetattr vsnprintf
do : do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
@ -5125,7 +5319,7 @@ else
typedef RETSIGTYPE sigfunc(); typedef RETSIGTYPE sigfunc();
int nsigint; volatile int nsigint;
#ifdef HAVE_POSIX_SIGNALS #ifdef HAVE_POSIX_SIGNALS
sigfunc * sigfunc *
@ -6056,6 +6250,45 @@ fi
$as_echo "$ac_cv_lib_ncurses_tgetent" >&6; } $as_echo "$ac_cv_lib_ncurses_tgetent" >&6; }
if test "x$ac_cv_lib_ncurses_tgetent" = xyes; then : if test "x$ac_cv_lib_ncurses_tgetent" = xyes; then :
bash_cv_termcap_lib=libncurses bash_cv_termcap_lib=libncurses
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for tgetent in -lncursesw" >&5
$as_echo_n "checking for tgetent in -lncursesw... " >&6; }
if ${ac_cv_lib_ncursesw_tgetent+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lncursesw $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char tgetent ();
int
main ()
{
return tgetent ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_ncursesw_tgetent=yes
else
ac_cv_lib_ncursesw_tgetent=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ncursesw_tgetent" >&5
$as_echo "$ac_cv_lib_ncursesw_tgetent" >&6; }
if test "x$ac_cv_lib_ncursesw_tgetent" = xyes; then :
bash_cv_termcap_lib=libncursesw
else else
bash_cv_termcap_lib=gnutermcap bash_cv_termcap_lib=gnutermcap
fi fi
@ -6070,6 +6303,8 @@ fi
fi fi
fi
if test "X$_bash_needmsg" = "Xyes"; then if test "X$_bash_needmsg" = "Xyes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking which library has the termcap functions" >&5
$as_echo_n "checking which library has the termcap functions... " >&6; } $as_echo_n "checking which library has the termcap functions... " >&6; }
@ -6120,6 +6355,14 @@ done
fi fi
case "$TERMCAP_LIB" in
-ltinfo) TERMCAP_PKG_CONFIG_LIB=tinfo ;;
-lcurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;;
-lncurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;;
-ltermcap) TERMCAP_PKG_CONFIG_LIB=termcap ;;
*) TERMCAP_PKG_CONFIG_LIB=termcap ;;
esac
for ac_header in wctype.h for ac_header in wctype.h
do : do :
@ -6517,6 +6760,40 @@ done
LIBS="$OLDLIBS" LIBS="$OLDLIBS"
fi fi
# The cast to long int works around a bug in the HP C Compiler
# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
# This bug is HP SR number 8606223364.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of wchar_t" >&5
$as_echo_n "checking size of wchar_t... " >&6; }
if ${ac_cv_sizeof_wchar_t+:} false; then :
$as_echo_n "(cached) " >&6
else
if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (wchar_t))" "ac_cv_sizeof_wchar_t" "$ac_includes_default"; then :
else
if test "$ac_cv_type_wchar_t" = yes; then
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error 77 "cannot compute sizeof (wchar_t)
See \`config.log' for more details" "$LINENO" 5; }
else
ac_cv_sizeof_wchar_t=0
fi
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_wchar_t" >&5
$as_echo "$ac_cv_sizeof_wchar_t" >&6; }
cat >>confdefs.h <<_ACEOF
#define SIZEOF_WCHAR_T $ac_cv_sizeof_wchar_t
_ACEOF
case "$host_cpu" in case "$host_cpu" in
@ -6589,6 +6866,11 @@ fi
if test "$opt_install_examples" = "yes"; then
EXAMPLES_INSTALL_TARGET=install-examples
fi
case "$build_os" in case "$build_os" in
msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file
*) BUILD_DIR=`pwd` ;; *) BUILD_DIR=`pwd` ;;
@ -6616,6 +6898,7 @@ esac
ac_config_files="$ac_config_files Makefile doc/Makefile examples/Makefile shlib/Makefile readline.pc" ac_config_files="$ac_config_files Makefile doc/Makefile examples/Makefile shlib/Makefile readline.pc"
ac_config_commands="$ac_config_commands default" ac_config_commands="$ac_config_commands default"
@ -7126,7 +7409,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by readline $as_me 7.0, which was This file was extended by readline $as_me 8.0, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -7192,7 +7475,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
readline config.status 7.0 readline config.status 8.0
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View File

@ -5,7 +5,7 @@ dnl report bugs to chet@po.cwru.edu
dnl dnl
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
# Copyright (C) 1987-2016 Free Software Foundation, Inc. # Copyright (C) 1987-2018 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -20,11 +20,11 @@ dnl Process this file with autoconf to produce a configure script.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
AC_REVISION([for Readline 7.0, version 2.81]) AC_REVISION([for Readline 8.0, version 2.85])
m4_include([../config/override.m4]) m4_include([../config/override.m4])
AC_INIT(readline, 7.0, bug-readline@gnu.org) AC_INIT(readline, 8.0, bug-readline@gnu.org)
dnl make sure we are using a recent autoconf version dnl make sure we are using a recent autoconf version
AC_PREREQ(2.50) AC_PREREQ(2.50)
@ -36,7 +36,7 @@ AC_CONFIG_AUX_DIR(`cd $srcdir;pwd`/..)
AC_CONFIG_HEADERS(config.h) AC_CONFIG_HEADERS(config.h)
dnl update the value of RL_READLINE_VERSION in readline.h when this changes dnl update the value of RL_READLINE_VERSION in readline.h when this changes
LIBVERSION=7.0 LIBVERSION=8.0
AC_CANONICAL_HOST AC_CANONICAL_HOST
AC_CANONICAL_BUILD AC_CANONICAL_BUILD
@ -55,10 +55,12 @@ dnl option parsing for optional features
opt_multibyte=yes opt_multibyte=yes
opt_static_libs=yes opt_static_libs=yes
opt_shared_libs=no opt_shared_libs=no
opt_install_examples=no
AC_ARG_ENABLE(multibyte, AC_HELP_STRING([--enable-multibyte], [enable multibyte characters if OS supports them]), opt_multibyte=$enableval) AC_ARG_ENABLE(multibyte, AC_HELP_STRING([--enable-multibyte], [enable multibyte characters if OS supports them]), opt_multibyte=$enableval)
dnl AC_ARG_ENABLE(shared, AC_HELP_STRING([--enable-shared], [build shared libraries [[default=YES]]]), opt_shared_libs=$enableval) dnl AC_ARG_ENABLE(shared, AC_HELP_STRING([--enable-shared], [build shared libraries [[default=YES]]]), opt_shared_libs=$enableval)
AC_ARG_ENABLE(static, AC_HELP_STRING([--enable-static], [build static libraries [[default=YES]]]), opt_static_libs=$enableval) AC_ARG_ENABLE(static, AC_HELP_STRING([--enable-static], [build static libraries [[default=YES]]]), opt_static_libs=$enableval)
AC_ARG_ENABLE(install-examples, AC_HELP_STRING([--disable-install-examples], [don't install examples [[default=install]]]), opt_install_examples=$enableval)
if test $opt_multibyte = no; then if test $opt_multibyte = no; then
AC_DEFINE(NO_MULTIBYTE_SUPPORT) AC_DEFINE(NO_MULTIBYTE_SUPPORT)
@ -136,7 +138,7 @@ AC_HEADER_STAT
AC_HEADER_DIRENT AC_HEADER_DIRENT
AC_CHECK_FUNCS(fcntl kill lstat readlink) AC_CHECK_FUNCS(fcntl kill lstat readlink)
AC_CHECK_FUNCS(memmove pselect putenv select setenv setlocale \ AC_CHECK_FUNCS(fnmatch memmove pselect putenv select setenv setlocale \
strcasecmp strpbrk tcgetattr vsnprintf) strcasecmp strpbrk tcgetattr vsnprintf)
AC_CHECK_FUNCS(isascii isxdigit) AC_CHECK_FUNCS(isascii isxdigit)
AC_CHECK_FUNCS(getpwent getpwnam getpwuid) AC_CHECK_FUNCS(getpwent getpwnam getpwuid)
@ -200,6 +202,14 @@ if test "$TERMCAP_LIB" = "-lncurses"; then
AC_CHECK_HEADERS(ncurses/termcap.h) AC_CHECK_HEADERS(ncurses/termcap.h)
fi fi
case "$TERMCAP_LIB" in
-ltinfo) TERMCAP_PKG_CONFIG_LIB=tinfo ;;
-lcurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;;
-lncurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;;
-ltermcap) TERMCAP_PKG_CONFIG_LIB=termcap ;;
*) TERMCAP_PKG_CONFIG_LIB=termcap ;;
esac
BASH_CHECK_MULTIBYTE BASH_CHECK_MULTIBYTE
case "$host_cpu" in case "$host_cpu" in
@ -270,6 +280,11 @@ AC_SUBST(SHARED_TARGET)
AC_SUBST(STATIC_INSTALL_TARGET) AC_SUBST(STATIC_INSTALL_TARGET)
AC_SUBST(SHARED_INSTALL_TARGET) AC_SUBST(SHARED_INSTALL_TARGET)
if test "$opt_install_examples" = "yes"; then
EXAMPLES_INSTALL_TARGET=install-examples
fi
AC_SUBST(EXAMPLES_INSTALL_TARGET)
case "$build_os" in case "$build_os" in
msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file
*) BUILD_DIR=`pwd` ;; *) BUILD_DIR=`pwd` ;;
@ -296,6 +311,7 @@ AC_SUBST(host_os)
AC_SUBST(LIBVERSION) AC_SUBST(LIBVERSION)
AC_SUBST(TERMCAP_LIB) AC_SUBST(TERMCAP_LIB)
AC_SUBST(TERMCAP_PKG_CONFIG_LIB)
AC_OUTPUT([Makefile doc/Makefile examples/Makefile shlib/Makefile readline.pc], AC_OUTPUT([Makefile doc/Makefile examples/Makefile shlib/Makefile readline.pc],
[ [

File diff suppressed because it is too large Load Diff

View File

@ -6,9 +6,9 @@
.\" Case Western Reserve University .\" Case Western Reserve University
.\" chet.ramey@case.edu .\" chet.ramey@case.edu
.\" .\"
.\" Last Change: Sun May 24 18:01:17 EDT 2015 .\" Last Change: Sun Oct 8 11:43:43 EDT 2017
.\" .\"
.TH HISTORY 3 "2015 May 24" "GNU History 6.3" .TH HISTORY 3 "2017 October 8" "GNU History 6.3"
.\" .\"
.\" File Name macro. This used to be `.PN', for Path Name, .\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much. .\" but Sun doesn't seem to like that very much.
@ -40,8 +40,8 @@
.SH NAME .SH NAME
history \- GNU History Library history \- GNU History Library
.SH COPYRIGHT .SH COPYRIGHT
.if t The GNU History Library is Copyright \(co 1989-2014 by the Free Software Foundation, Inc. .if t The GNU History Library is Copyright \(co 1989-2017 by the Free Software Foundation, Inc.
.if n The GNU History Library is Copyright (C) 1989-2014 by the Free Software Foundation, Inc. .if n The GNU History Library is Copyright (C) 1989-2017 by the Free Software Foundation, Inc.
.SH DESCRIPTION .SH DESCRIPTION
Many programs read input from the user a line at a time. The GNU 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 History library is able to keep track of those lines, associate arbitrary
@ -356,6 +356,9 @@ parameters managing the list itself.
.Fn1 void add_history "const char *string" .Fn1 void add_history "const char *string"
Place \fIstring\fP at the end of the history list. The associated data Place \fIstring\fP at the end of the history list. The associated data
field (if any) is set to \fBNULL\fP. field (if any) is set to \fBNULL\fP.
If the maximum number of history entries has been set using
\fBstifle_history()\fP, and the new number of history entries would exceed
that maximum, the oldest history entry is removed.
.Fn1 void add_history_time "const char *string" .Fn1 void add_history_time "const char *string"
Change the time stamp associated with the most recent history entry to Change the time stamp associated with the most recent history entry to
@ -382,6 +385,7 @@ Clear the history list by deleting all the entries.
.Fn1 void stifle_history "int max" .Fn1 void stifle_history "int max"
Stifle the history list, remembering only the last \fImax\fP entries. Stifle the history list, remembering only the last \fImax\fP entries.
The history list will contain only \fImax\fP entries at a time.
.Fn1 int unstifle_history "void" .Fn1 int unstifle_history "void"
Stop stifling the history. This returns the previously-set Stop stifling the history. This returns the previously-set
@ -411,10 +415,11 @@ Return the history entry at the current position, as determined by
pointer. pointer.
.Fn1 "HIST_ENTRY *" history_get "int offset" .Fn1 "HIST_ENTRY *" history_get "int offset"
Return the history entry at position \fIoffset\fP, starting from Return the history entry at position \fIoffset\fP.
\fBhistory_base\fP. The range of valid values of \fIoffset\fP starts at \fBhistory_base\fP
If there is no entry there, or if \fIoffset\fP and ends at \fBhistory_length\fP \- 1.
is greater than the history length, return a \fBNULL\fP pointer. If there is no entry there, or if \fIoffset\fP is outside the valid
range, return a \fBNULL\fP pointer.
.Fn1 "time_t" history_get_time "HIST_ENTRY *" .Fn1 "time_t" history_get_time "HIST_ENTRY *"
Return the time stamp associated with the history entry passed as the argument. Return the time stamp associated with the history entry passed as the argument.

View File

@ -166,6 +166,9 @@ parameters managing the list itself.
@deftypefun void add_history (const char *string) @deftypefun void add_history (const char *string)
Place @var{string} at the end of the history list. The associated data Place @var{string} at the end of the history list. The associated data
field (if any) is set to @code{NULL}. field (if any) is set to @code{NULL}.
If the maximum number of history entries has been set using
@code{stifle_history()}, and the new number of history entries would exceed
that maximum, the oldest history entry is removed.
@end deftypefun @end deftypefun
@deftypefun void add_history_time (const char *string) @deftypefun void add_history_time (const char *string)
@ -198,6 +201,7 @@ Clear the history list by deleting all the entries.
@deftypefun void stifle_history (int max) @deftypefun void stifle_history (int max)
Stifle the history list, remembering only the last @var{max} entries. Stifle the history list, remembering only the last @var{max} entries.
The history list will contain only @var{max} entries at a time.
@end deftypefun @end deftypefun
@deftypefun int unstifle_history (void) @deftypefun int unstifle_history (void)
@ -234,10 +238,12 @@ pointer.
@end deftypefun @end deftypefun
@deftypefun {HIST_ENTRY *} history_get (int offset) @deftypefun {HIST_ENTRY *} history_get (int offset)
Return the history entry at position @var{offset}, starting from Return the history entry at position @var{offset}.
@code{history_base} (@pxref{History Variables}). The range of valid
If there is no entry there, or if @var{offset} values of @var{offset} starts at @code{history_base} and ends at
is greater than the history length, return a @code{NULL} pointer. @var{history_length} - 1 (@pxref{History Variables}).
If there is no entry there, or if @var{offset} is outside the valid
range, return a @code{NULL} pointer.
@end deftypefun @end deftypefun
@deftypefun time_t history_get_time (HIST_ENTRY *entry) @deftypefun time_t history_get_time (HIST_ENTRY *entry)
@ -397,7 +403,7 @@ to the ``normal'' terminating characters.
Return an array of tokens parsed out of @var{string}, much as the Return an array of tokens parsed out of @var{string}, much as the
shell might. The tokens are split on the characters in the shell might. The tokens are split on the characters in the
@var{history_word_delimiters} variable, @var{history_word_delimiters} variable,
and shell quoting conventions are obeyed. and shell quoting conventions are obeyed as described below.
@end deftypefun @end deftypefun
@deftypefun {char *} history_arg_extract (int first, int last, const char *string) @deftypefun {char *} history_arg_extract (int first, int last, const char *string)
@ -470,8 +476,24 @@ carriage return, and @samp{=}.
@end deftypevar @end deftypevar
@deftypevar int history_quotes_inhibit_expansion @deftypevar int history_quotes_inhibit_expansion
If non-zero, double-quoted words are not scanned for the history expansion If non-zero, the history expansion code implements shell-like quoting:
character or the history comment character. The default value is 0. single-quoted words are not scanned for the history expansion
character or the history comment character, and double-quoted words may
have history expansion performed, since single quotes are not special
within double quotes.
The default value is 0.
@end deftypevar
@deftypevar int history_quoting_state
An application may set this variable to indicate that the current line
being expanded is subject to existing quoting. If set to @samp{'}, the
history expansion function will assume that the line is single-quoted and
inhibit expansion until it reads an unquoted closing single quote; if set
to @samp{"}, history expansion will assume the line is double quoted until
it reads an unquoted closing double quote. If set to zero, the default,
the history expansion function will assume the line is not quoted and
treat quote characters within the line as described above.
This is only effective if @var{history_quotes_inhibit_expansion} is set.
@end deftypevar @end deftypevar
@deftypevar {rl_linebuf_func_t *} history_inhibit_expansion_function @deftypevar {rl_linebuf_func_t *} history_inhibit_expansion_function

View File

@ -1,7 +1,7 @@
@ignore @ignore
This file documents the user interface to the GNU History library. This file documents the user interface to the GNU History library.
Copyright (C) 1988--2016 Free Software Foundation, Inc. Copyright (C) 1988--2018 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey. Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual Permission is granted to make and distribute verbatim copies of this manual
@ -126,7 +126,7 @@ The @code{lithist}
shell option causes the shell to save the command with embedded newlines shell option causes the shell to save the command with embedded newlines
instead of semicolons. instead of semicolons.
The @code{shopt} builtin is used to set these options. The @code{shopt} builtin is used to set these options.
@xref{Bash Builtins}, for a description of @code{shopt}. @xref{The Shopt Builtin}, for a description of @code{shopt}.
@node Bash History Builtins @node Bash History Builtins
@section Bash History Builtins @section Bash History Builtins
@ -151,8 +151,8 @@ Both @var{first} and
@var{last} may be specified as a string (to locate the most recent @var{last} may be specified as a string (to locate the most recent
command beginning with that string) or as a number (an index into the 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 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 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 @var{first}. If @var{first} is not specified, it is set to the previous
command for editing and @minus{}16 for listing. If the @option{-l} flag is 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 given, the commands are listed on standard output. The @option{-n} flag
suppresses the command numbers when listing. The @option{-r} flag suppresses the command numbers when listing. The @option{-r} flag
@ -178,6 +178,7 @@ and typing @samp{r} re-executes the last command (@pxref{Aliases}).
history [@var{n}] history [@var{n}]
history -c history -c
history -d @var{offset} history -d @var{offset}
history -d @var{start}-@var{end}
history [-anrw] [@var{filename}] history [-anrw] [@var{filename}]
history -ps @var{arg} history -ps @var{arg}
@end example @end example
@ -200,8 +201,17 @@ with the other options to replace the history list completely.
@item -d @var{offset} @item -d @var{offset}
Delete the history entry at position @var{offset}. Delete the history entry at position @var{offset}.
@var{offset} should be specified as it appears when the history is If @var{offset} is positive, it should be specified as it appears when
displayed. the history is displayed.
If @var{offset} is negative, it is interpreted as relative to one greater
than the last history position, so negative indices count back from the
end of the history, and an index of @samp{-1} refers to the current
@code{history -d} command.
@item -d @var{start}-@var{end}
Delete the history entries between positions @var{start} and @var{end},
inclusive. Positive and negative values for @var{start} and @var{end}
are interpreted as described above.
@item -a @item -a
Append the new history lines to the history file. Append the new history lines to the history file.
@ -253,7 +263,9 @@ fix errors in previous commands quickly.
@ifset BashFeatures @ifset BashFeatures
History expansion is performed immediately after a complete line History expansion is performed immediately after a complete line
is read, before the shell breaks it into words. is read, before the shell breaks it into words, and is performed
on each line individually. Bash attempts to inform the history
expansion functions about quoting still in effect from previous lines.
@end ifset @end ifset
History expansion takes place in two parts. The first is to determine History expansion takes place in two parts. The first is to determine
@ -267,16 +279,26 @@ that Bash does, so that several words
surrounded by quotes are considered one word. surrounded by quotes are considered one word.
History expansions are introduced by the appearance of the History expansions are introduced by the appearance of the
history expansion character, which is @samp{!} by default. history expansion character, which is @samp{!} by default.
History expansion implements shell-like quoting conventions:
a backslash can be used to remove the special handling for the next character;
single quotes enclose verbatim sequences of characters, and can be used to
inhibit history expansion;
and characters enclosed within double quotes may be subject to history
expansion, since backslash can escape the history expansion character,
but single quotes may not, since they are not treated specially within
double quotes.
@ifset BashFeatures @ifset BashFeatures
Only @samp{\} and @samp{'} may be used to escape the history expansion When using the shell, only @samp{\} and @samp{'} may be used to escape the
character, but the history expansion character is history expansion character, but the history expansion character is
also treated as quoted if it immediately precedes the closing double quote also treated as quoted if it immediately precedes the closing double quote
in a double-quoted string. in a double-quoted string.
@end ifset @end ifset
@ifset BashFeatures @ifset BashFeatures
Several shell options settable with the @code{shopt} Several shell options settable with the @code{shopt}
builtin (@pxref{Bash Builtins}) may be used to tailor builtin (@pxref{The Shopt Builtin}) may be used to tailor
the behavior of history expansion. If the the behavior of history expansion. If the
@code{histverify} shell option is enabled, and Readline @code{histverify} shell option is enabled, and Readline
is being used, history substitutions are not immediately passed to is being used, history substitutions are not immediately passed to

View File

@ -6,9 +6,9 @@
.\" Case Western Reserve University .\" Case Western Reserve University
.\" chet.ramey@case.edu .\" chet.ramey@case.edu
.\" .\"
.\" Last Change: Sun Feb 28 15:42:34 EST 2016 .\" Last Change: Thu Dec 28 14:49:51 EST 2017
.\" .\"
.TH READLINE 3 "2016 February 28" "GNU Readline 7.0" .TH READLINE 3 "2017 December 28" "GNU Readline 7.0"
.\" .\"
.\" File Name macro. This used to be `.PN', for Path Name, .\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much. .\" but Sun doesn't seem to like that very much.
@ -378,13 +378,13 @@ in emacs mode and to
.B # .B #
in vi command mode. in vi command mode.
.TP .TP
.B completion\-display\-width (-1) .B completion\-display\-width (\-1)
The number of screen columns used to display possible matches The number of screen columns used to display possible matches
when performing completion. when performing completion.
The value is ignored if it is less than 0 or greater than the terminal The value is ignored if it is less than 0 or greater than the terminal
screen width. screen width.
A value of 0 will cause matches to be displayed one per line. A value of 0 will cause matches to be displayed one per line.
The default value is -1. The default value is \-1.
.TP .TP
.B completion\-ignore\-case (Off) .B completion\-ignore\-case (Off)
If set to \fBOn\fP, readline performs filename matching and completion If set to \fBOn\fP, readline performs filename matching and completion
@ -438,6 +438,16 @@ can be set to either
or or
.BR vi . .BR vi .
.TP .TP
.B emacs\-mode\-string (@)
If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when emacs editing mode is active. The value is expanded like a
key binding, so the standard set of meta- and control prefixes and
backslash escape sequences is available.
Use the \e1 and \e2 escapes to begin and end sequences of
non-printing characters, which can be used to embed a terminal control
sequence into the mode string.
.TP
.B enable\-bracketed\-paste (Off) .B enable\-bracketed\-paste (Off)
When set to \fBOn\fP, readline will configure the terminal in a way When set to \fBOn\fP, readline will configure the terminal in a way
that will enable it to insert each paste into the editing buffer as a that will enable it to insert each paste into the editing buffer as a
@ -506,15 +516,6 @@ The value of
.B editing\-mode .B editing\-mode
also affects the default keymap. also affects the default keymap.
.TP .TP
.B emacs\-mode\-string (@)
This string is displayed immediately before the last line of the primary
prompt when emacs editing mode is active. The value is expanded like a
key binding, so the standard set of meta- and control prefixes and
backslash escape sequences is available.
Use the \e1 and \e2 escapes to begin and end sequences of
non-printing characters, which can be used to embed a terminal control
sequence into the mode string.
.TP
.B keyseq\-timeout (500) .B keyseq\-timeout (500)
Specifies the duration \fIreadline\fP will wait for a character when reading an Specifies the duration \fIreadline\fP will wait for a character when reading an
ambiguous key sequence (one that can form a complete key sequence using ambiguous key sequence (one that can form a complete key sequence using
@ -592,9 +593,9 @@ a common prefix) cause the matches to be listed immediately instead
of ringing the bell. of ringing the bell.
.TP .TP
.B show\-mode\-in\-prompt (Off) .B show\-mode\-in\-prompt (Off)
If set to \fBOn\fP, add a character to the beginning of the prompt If set to \fBOn\fP, add a string to the beginning of the prompt
indicating the editing mode: emacs, vi command, or vi insertion. indicating the editing mode: emacs, vi command, or vi insertion.
The mode strings are user-settable. The mode strings are user-settable (e.g., \fIemacs\-mode\-string\fP).
.TP .TP
.B skip\-completed\-text (Off) .B skip\-completed\-text (Off)
If set to \fBOn\fP, this alters the default completion behavior when If set to \fBOn\fP, this alters the default completion behavior when
@ -605,7 +606,8 @@ after point in the word being completed, so portions of the word
following the cursor are not duplicated. following the cursor are not duplicated.
.TP .TP
.B vi\-cmd\-mode\-string ((cmd)) .B vi\-cmd\-mode\-string ((cmd))
This string is displayed immediately before the last line of the primary If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when vi editing mode is active and in command mode. prompt when vi editing mode is active and in command mode.
The value is expanded like a The value is expanded like a
key binding, so the standard set of meta- and control prefixes and key binding, so the standard set of meta- and control prefixes and
@ -615,7 +617,8 @@ non-printing characters, which can be used to embed a terminal control
sequence into the mode string. sequence into the mode string.
.TP .TP
.B vi\-ins\-mode\-string ((ins)) .B vi\-ins\-mode\-string ((ins))
This string is displayed immediately before the last line of the primary If the \fIshow\-mode\-in\-prompt\fP variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when vi editing mode is active and in insertion mode. prompt when vi editing mode is active and in insertion mode.
The value is expanded like a The value is expanded like a
key binding, so the standard set of meta- and control prefixes and key binding, so the standard set of meta- and control prefixes and
@ -640,8 +643,9 @@ The
.B $if .B $if
construct allows bindings to be made based on the construct allows bindings to be made based on the
editing mode, the terminal being used, or the application using editing mode, the terminal being used, or the application using
readline. The text of the test extends to the end of the line; readline. The text of the test, after any comparison operator,
no characters are required to isolate it. extends to the end of the line;
unless otherwise noted, no characters are required to isolate it.
.RS .RS
.IP \fBmode\fP .IP \fBmode\fP
The \fBmode=\fP form of the \fB$if\fP directive is used to test The \fBmode=\fP form of the \fB$if\fP directive is used to test
@ -663,6 +667,26 @@ to match both
and and
.IR sun\-cmd , .IR sun\-cmd ,
for instance. for instance.
.IP \fBversion\fP
The \fBversion\fP test may be used to perform comparisons against
specific readline versions.
The \fBversion\fP expands to the current readline version.
The set of comparison operators includes
.BR = ,
(and
.BR == ),
.BR != ,
.BR <= ,
.BR >= ,
.BR < ,
and
.BR > .
The version number supplied on the right side of the operator consists
of a major version number, an optional decimal point, and an optional
minor version (e.g., \fB7.1\fP). If the minor version is omitted, it
is assumed to be \fB0\fP.
The operator may be separated from the string \fBversion\fP
and from the version number argument by whitespace.
.IP \fBapplication\fP .IP \fBapplication\fP
The \fBapplication\fP construct is used to include The \fBapplication\fP construct is used to include
application-specific settings. Each program using the readline application-specific settings. Each program using the readline
@ -680,6 +704,15 @@ key sequence that quotes the current or previous word in \fBbash\fP:
\fB$endif\fP \fB$endif\fP
.fi .fi
.RE .RE
.IP \fIvariable\fP
The \fIvariable\fP construct provides simple equality tests for readline
variables and values.
The permitted comparison operators are \fI=\fP, \fI==\fP, and \fI!=\fP.
The variable name must be separated from the comparison operator by
whitespace; the operator may be separated from the value on the right hand
side by whitespace.
Both string and boolean variables may be tested. Boolean variables must be
tested against the values \fIon\fP and \fIoff\fP.
.RE .RE
.IP \fB$endif\fP .IP \fB$endif\fP
This command, as seen in the previous example, terminates an This command, as seen in the previous example, terminates an
@ -771,6 +804,19 @@ alphanumeric characters (letters and digits).
Move back to the start of the current or previous word. Words are Move back to the start of the current or previous word. Words are
composed of alphanumeric characters (letters and digits). composed of alphanumeric characters (letters and digits).
.TP .TP
.B previous\-screen\-line
Attempt to move point to the same physical screen column on the previous
physical screen line. This will not have the desired effect if the current
Readline line does not take up more than one physical line or if point is not
greater than the length of the prompt plus the screen width.
.TP
.B next\-screen\-line
Attempt to move point to the same physical screen column on the next
physical screen line. This will not have the desired effect if the current
Readline line does not take up more than one physical line or if the length
of the current Readline line is not greater than the length of the prompt
plus the screen width.
.TP
.B clear\-screen (C\-l) .B clear\-screen (C\-l)
Clear the screen leaving the current line at the top of the screen. Clear the screen leaving the current line at the top of the screen.
With an argument, refresh the current line without clearing the With an argument, refresh the current line without clearing the
@ -1103,6 +1149,7 @@ and store the definition.
.B call\-last\-kbd\-macro (C\-x e) .B call\-last\-kbd\-macro (C\-x e)
Re-execute the last keyboard macro defined, by making the characters Re-execute the last keyboard macro defined, by making the characters
in the macro appear as if typed at the keyboard. in the macro appear as if typed at the keyboard.
.TP
.B print\-last\-kbd\-macro () .B print\-last\-kbd\-macro ()
Print the last keyboard macro defined in a format suitable for the Print the last keyboard macro defined in a format suitable for the
\fIinputrc\fP file. \fIinputrc\fP file.
@ -1120,9 +1167,10 @@ Abort the current editing command and
ring the terminal's bell (subject to the setting of ring the terminal's bell (subject to the setting of
.BR bell\-style ). .BR bell\-style ).
.TP .TP
.B do\-uppercase\-version (M\-a, M\-b, M\-\fIx\fP, ...) .B do\-lowercase\-version (M\-A, M\-B, M\-\fIx\fP, ...)
If the metafied character \fIx\fP is lowercase, run the command If the metafied character \fIx\fP is uppercase, run the command
that is bound to the corresponding uppercase character. that is bound to the corresponding metafied lowercase character.
The behavior is undefined if \fIx\fP is already lowercase.
.TP .TP
.B prefix\-meta (ESC) .B prefix\-meta (ESC)
Metafy the next character typed. Metafy the next character typed.

View File

@ -90,6 +90,12 @@ If @code{readline} encounters an @code{EOF} while reading the line, and the
line is empty at that point, then @code{(char *)NULL} is returned. line is empty at that point, then @code{(char *)NULL} is returned.
Otherwise, the line is ended just as if a newline had been typed. Otherwise, the line is ended just as if a newline had been typed.
Readline performs some expansion on the @var{prompt} before it is
displayed on the screen. See the description of @code{rl_expand_prompt}
(@pxref{Redisplay}) for additional details, especially if @var{prompt}
will contain characters that do not consume physical screen space when
displayed.
If you want the user to be able to get at the line later, (with If you want the user to be able to get at the line later, (with
@key{C-p} for example), you must call @code{add_history()} to save the @key{C-p} for example), you must call @code{add_history()} to save the
line away in a @dfn{history} list of such lines. line away in a @dfn{history} list of such lines.
@ -688,6 +694,11 @@ Free all storage associated with @var{keymap}. This calls
@code{rl_discard_keymap} to free subordindate keymaps and macros. @code{rl_discard_keymap} to free subordindate keymaps and macros.
@end deftypefun @end deftypefun
@deftypefun int rl_empty_keymap (Keymap keymap)
Return non-zero if there are no keys bound to functions in @var{keymap};
zero if there are any keys bound.
@end deftypefun
Readline has several internal keymaps. These functions allow you to Readline has several internal keymaps. These functions allow you to
change which keymap is active. change which keymap is active.
@ -709,6 +720,24 @@ Return the name matching @var{keymap}. @var{name} is one which would
be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}). be supplied in a @code{set keymap} inputrc line (@pxref{Readline Init File}).
@end deftypefun @end deftypefun
@deftypefun int rl_set_keymap_name (const char *name, Keymap keymap)
Set the name of @var{keymap}. This name will then be "registered" and
available for use in a @code{set keymap} inputrc directive
@pxref{Readline Init File}).
The @var{name} may not be one of Readline's builtin keymap names;
you may not add a different name for one of Readline's builtin keymaps.
You may replace the name associated with a given keymap by calling this
function more than once with the same @var{keymap} argument.
You may associate a registered @var{name} with a new keymap by calling this
function more than once with the same @var{name} argument.
There is no way to remove a named keymap once the name has been
registered.
Readline will make a copy of @var{name}.
The return value is greater than zero unless @var{name} is one of
Readline's builtin keymap names or @var{keymap} is one of Readline's
builtin keymaps.
@end deftypefun
@node Binding Keys @node Binding Keys
@subsection Binding Keys @subsection Binding Keys
@ -835,6 +864,16 @@ Return the function invoked by @var{keyseq} in keymap @var{map}.
If @var{map} is @code{NULL}, the current keymap is used. If @var{type} is If @var{map} is @code{NULL}, the current keymap is used. If @var{type} is
not @code{NULL}, the type of the object is returned in the @code{int} variable not @code{NULL}, the type of the object is returned in the @code{int} variable
it points to (one of @code{ISFUNC}, @code{ISKMAP}, or @code{ISMACR}). it points to (one of @code{ISFUNC}, @code{ISKMAP}, or @code{ISMACR}).
It takes a "translated" key sequence and should not be used if the key sequence
can include NUL.
@end deftypefun
@deftypefun {rl_command_func_t *} rl_function_of_keyseq_len (const char *keyseq, size_t len, Keymap map, int *type)
Return the function invoked by @var{keyseq} of length @var{len}
in keymap @var{map}. Equivalent to @code{rl_function_of_keyseq} with the
addition of the @var{len} parameter.
It takes a "translated" key sequence and should be used if the key sequence
can include NUL.
@end deftypefun @end deftypefun
@deftypefun {char **} rl_invoking_keyseqs (rl_command_func_t *function) @deftypefun {char **} rl_invoking_keyseqs (rl_command_func_t *function)
@ -1679,6 +1718,19 @@ handlers, depending on the values of @code{rl_catch_signals} and
@code{rl_catch_sigwinch}. @code{rl_catch_sigwinch}.
@end deftypefun @end deftypefun
If an application wants to force Readline to handle any signals that
have arrived while it has been executing, @code{rl_check_signals()}
will call Readline's internal signal handler if there are any pending
signals. This is primarily intended for those applications that use
a custom @code{rl_getc_function} (@pxref{Readline Variables}) and wish
to handle signals received while waiting for input.
@deftypefun void rl_check_signals (void)
If there are any pending signals, call Readline's internal signal handling
functions to process them. @code{rl_pending_signal()} can be used independently
to determine whether or not there are any pending signals.
@end deftypefun
If an application does not wish Readline to catch @code{SIGWINCH}, it may If an application does not wish Readline to catch @code{SIGWINCH}, it may
call @code{rl_resize_terminal()} or @code{rl_set_screen_size()} to force call @code{rl_resize_terminal()} or @code{rl_set_screen_size()} to force
Readline to update its idea of the terminal size when a @code{SIGWINCH} Readline to update its idea of the terminal size when a @code{SIGWINCH}
@ -2094,6 +2146,8 @@ character (@samp{\0}) prevents anything being appended automatically.
This can be changed in application-specific completion functions to This can be changed in application-specific completion functions to
provide the ``most sensible word separator character'' according to provide the ``most sensible word separator character'' according to
an application-specific command line syntax specification. an application-specific command line syntax specification.
It is set to the default before any application-specific completion function
is called, and may only be changed within such a function.
@end deftypevar @end deftypevar
@deftypevar int rl_completion_suppress_append @deftypevar int rl_completion_suppress_append

View File

@ -475,6 +475,7 @@ The default value is @samp{off}.
If set to @samp{on}, and @var{completion-ignore-case} is enabled, Readline If set to @samp{on}, and @var{completion-ignore-case} is enabled, Readline
treats hyphens (@samp{-}) and underscores (@samp{_}) as equivalent when treats hyphens (@samp{-}) and underscores (@samp{_}) as equivalent when
performing case-insensitive filename matching and completion. performing case-insensitive filename matching and completion.
The default value is @samp{off}.
@item completion-prefix-display-length @item completion-prefix-display-length
@vindex completion-prefix-display-length @vindex completion-prefix-display-length
@ -524,7 +525,8 @@ set to either @samp{emacs} or @samp{vi}.
@item emacs-mode-string @item emacs-mode-string
@vindex emacs-mode-string @vindex emacs-mode-string
This string is displayed immediately before the last line of the primary If the @var{show-mode-in-prompt} variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when emacs editing mode is active. The value is expanded like a prompt when emacs editing mode is active. The value is expanded like a
key binding, so the standard set of meta- and control prefixes and key binding, so the standard set of meta- and control prefixes and
backslash escape sequences is available. backslash escape sequences is available.
@ -604,7 +606,7 @@ If this variable has not been given a value, the characters @key{ESC} and
@item keymap @item keymap
@vindex keymap @vindex keymap
Sets Readline's idea of the current keymap for key binding commands. Sets Readline's idea of the current keymap for key binding commands.
Acceptable @code{keymap} names are Built-in @code{keymap} names are
@code{emacs}, @code{emacs},
@code{emacs-standard}, @code{emacs-standard},
@code{emacs-meta}, @code{emacs-meta},
@ -615,6 +617,7 @@ Acceptable @code{keymap} names are
@code{vi-insert}. @code{vi-insert}.
@code{vi} is equivalent to @code{vi-command} (@code{vi-move} is also a @code{vi} is equivalent to @code{vi-command} (@code{vi-move} is also a
synonym); @code{emacs} is equivalent to @code{emacs-standard}. synonym); @code{emacs} is equivalent to @code{emacs-standard}.
Applications may add additional names.
The default value is @code{emacs}. The default value is @code{emacs}.
The value of the @code{editing-mode} variable also affects the The value of the @code{editing-mode} variable also affects the
default keymap. default keymap.
@ -714,9 +717,9 @@ The default value is @samp{off}.
@item show-mode-in-prompt @item show-mode-in-prompt
@vindex show-mode-in-prompt @vindex show-mode-in-prompt
If set to @samp{on}, add a character to the beginning of the prompt If set to @samp{on}, add a string to the beginning of the prompt
indicating the editing mode: emacs, vi command, or vi insertion. indicating the editing mode: emacs, vi command, or vi insertion.
The mode strings are user-settable. The mode strings are user-settable (e.g., @var{emacs-mode-string}).
The default value is @samp{off}. The default value is @samp{off}.
@item skip-completed-text @item skip-completed-text
@ -735,7 +738,8 @@ The default value is @samp{off}.
@item vi-cmd-mode-string @item vi-cmd-mode-string
@vindex vi-cmd-mode-string @vindex vi-cmd-mode-string
This string is displayed immediately before the last line of the primary If the @var{show-mode-in-prompt} variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when vi editing mode is active and in command mode. prompt when vi editing mode is active and in command mode.
The value is expanded like a The value is expanded like a
key binding, so the standard set of meta- and control prefixes and key binding, so the standard set of meta- and control prefixes and
@ -747,7 +751,8 @@ The default is @samp{(cmd)}.
@item vi-ins-mode-string @item vi-ins-mode-string
@vindex vi-ins-mode-string @vindex vi-ins-mode-string
This string is displayed immediately before the last line of the primary If the @var{show-mode-in-prompt} variable is enabled,
this string is displayed immediately before the last line of the primary
prompt when vi editing mode is active and in insertion mode. prompt when vi editing mode is active and in insertion mode.
The value is expanded like a The value is expanded like a
key binding, so the standard set of meta- and control prefixes and key binding, so the standard set of meta- and control prefixes and
@ -799,7 +804,7 @@ Meta-Rubout: backward-kill-word
Control-o: "> output" Control-o: "> output"
@end example @end example
In the above example, @kbd{C-u} is bound to the function In the example above, @kbd{C-u} is bound to the function
@code{universal-argument}, @code{universal-argument},
@kbd{M-DEL} is bound to the function @code{backward-kill-word}, and @kbd{M-DEL} is bound to the function @code{backward-kill-word}, and
@kbd{C-o} is bound to run the macro @kbd{C-o} is bound to run the macro
@ -914,8 +919,9 @@ of tests. There are four parser directives used.
@item $if @item $if
The @code{$if} construct allows bindings to be made based on the The @code{$if} construct allows bindings to be made based on the
editing mode, the terminal being used, or the application using editing mode, the terminal being used, or the application using
Readline. The text of the test extends to the end of the line; Readline. The text of the test, after any comparison operator,
no characters are required to isolate it. extends to the end of the line;
unless otherwise noted, no characters are required to isolate it.
@table @code @table @code
@item mode @item mode
@ -935,6 +941,27 @@ the portion of the terminal name before the first @samp{-}. This
allows @code{sun} to match both @code{sun} and @code{sun-cmd}, allows @code{sun} to match both @code{sun} and @code{sun-cmd},
for instance. for instance.
@item version
The @code{version} test may be used to perform comparisons against
specific Readline versions.
The @code{version} expands to the current Readline version.
The set of comparison operators includes
@samp{=} (and @samp{==}), @samp{!=}, @samp{<=}, @samp{>=}, @samp{<},
and @samp{>}.
The version number supplied on the right side of the operator consists
of a major version number, an optional decimal point, and an optional
minor version (e.g., @samp{7.1}). If the minor version is omitted, it
is assumed to be @samp{0}.
The operator may be separated from the string @code{version} and
from the version number argument by whitespace.
The following example sets a variable if the Readline version being used
is 7.0 or newer:
@example
$if version >= 7.0
set show-mode-in-prompt on
$endif
@end example
@item application @item application
The @var{application} construct is used to include The @var{application} construct is used to include
application-specific settings. Each program using the Readline application-specific settings. Each program using the Readline
@ -949,6 +976,23 @@ $if Bash
"\C-xq": "\eb\"\ef\"" "\C-xq": "\eb\"\ef\""
$endif $endif
@end example @end example
@item variable
The @var{variable} construct provides simple equality tests for Readline
variables and values.
The permitted comparison operators are @samp{=}, @samp{==}, and @samp{!=}.
The variable name must be separated from the comparison operator by
whitespace; the operator may be separated from the value on the right hand
side by whitespace.
Both string and boolean variables may be tested. Boolean variables must be
tested against the values @var{on} and @var{off}.
The following example is equivalent to the @code{mode=emacs} test described
above:
@example
$if editing-mode == emacs
set show-mode-in-prompt on
$endif
@end example
@end table @end table
@item $endif @item $endif
@ -1138,6 +1182,19 @@ Move back to the start of the current or previous word.
Words are delimited by non-quoted shell metacharacters. Words are delimited by non-quoted shell metacharacters.
@end ifset @end ifset
@item previous-screen-line ()
Attempt to move point to the same physical screen column on the previous
physical screen line. This will not have the desired effect if the current
Readline line does not take up more than one physical line or if point is not
greater than the length of the prompt plus the screen width.
@item next-screen-line ()
Attempt to move point to the same physical screen column on the next
physical screen line. This will not have the desired effect if the current
Readline line does not take up more than one physical line or if the length
of the current Readline line is not greater than the length of the prompt
plus the screen width.
@item clear-screen (C-l) @item clear-screen (C-l)
Clear the screen and redraw the current line, Clear the screen and redraw the current line,
leaving the current line at the top of the screen. leaving the current line at the top of the screen.
@ -1216,14 +1273,14 @@ The search string must match at the beginning of a history line.
This is a non-incremental search. This is a non-incremental search.
By default, this command is unbound. By default, this command is unbound.
@item history-substr-search-forward () @item history-substring-search-forward ()
Search forward through the history for the string of characters Search forward through the history for the string of characters
between the start of the current line and the point. between the start of the current line and the point.
The search string may match anywhere in a history line. The search string may match anywhere in a history line.
This is a non-incremental search. This is a non-incremental search.
By default, this command is unbound. By default, this command is unbound.
@item history-substr-search-backward () @item history-substring-search-backward ()
Search backward through the history for the string of characters Search backward through the history for the string of characters
between the start of the current line and the point. between the start of the current line and the point.
The search string may match anywhere in a history line. The search string may match anywhere in a history line.
@ -1297,7 +1354,7 @@ This function is intended to be bound to the "bracketed paste" escape
sequence sent by some terminals, and such a binding is assigned by default. sequence sent by some terminals, and such a binding is assigned by default.
It allows Readline to insert the pasted text as a single unit without treating It allows Readline to insert the pasted text as a single unit without treating
each character as if it had been read from the keyboard. The characters each character as if it had been read from the keyboard. The characters
are inserted as if each one was bound to @code{self-insert}) instead of are inserted as if each one was bound to @code{self-insert} instead of
executing any editing commands. executing any editing commands.
@item transpose-chars (C-t) @item transpose-chars (C-t)
@ -1590,9 +1647,10 @@ Abort the current editing command and
ring the terminal's bell (subject to the setting of ring the terminal's bell (subject to the setting of
@code{bell-style}). @code{bell-style}).
@item do-uppercase-version (M-a, M-b, M-@var{x}, @dots{}) @item do-lowercase-version (M-A, M-B, M-@var{x}, @dots{})
If the metafied character @var{x} is lowercase, run the command If the metafied character @var{x} is upper case, run the command
that is bound to the corresponding uppercase character. that is bound to the corresponding metafied lower case character.
The behavior is undefined if @var{x} is already lower case.
@item prefix-meta (@key{ESC}) @item prefix-meta (@key{ESC})
Metafy the next character typed. This is for keyboards Metafy the next character typed. This is for keyboards
@ -1718,10 +1776,11 @@ A synonym for @code{yank-last-arg}.
@item operate-and-get-next (C-o) @item operate-and-get-next (C-o)
Accept the current line for execution and fetch the next line Accept the current line for execution and fetch the next line
relative to the current line from the history for editing. Any relative to the current line from the history for editing.
argument is ignored. A numeric argument, if supplied, specifies the history entry to use instead
of the current line.
@item edit-and-execute-command (C-xC-e) @item edit-and-execute-command (C-x C-e)
Invoke an editor on the current command line, and execute the result as shell Invoke an editor on the current command line, and execute the result as shell
commands. commands.
Bash attempts to invoke Bash attempts to invoke
@ -1792,6 +1851,9 @@ If no compspec is found for the full pathname, an attempt is made to
find a compspec for the portion following the final slash. find a compspec for the portion following the final slash.
If those searches do not result in a compspec, any compspec defined with If those searches do not result in a compspec, any compspec defined with
the @option{-D} option to @code{complete} is used as the default. the @option{-D} option to @code{complete} is used as the default.
If there is no default compspec, Bash attempts alias expansion
on the command word as a final resort, and attempts to find a compspec
for the command word from any successful expansion
Once a compspec has been found, it is used to generate the list of Once a compspec has been found, it is used to generate the list of
matching words. matching words.
@ -1816,7 +1878,9 @@ Next, the string specified as the argument to the @option{-W} option
is considered. is considered.
The string is first split using the characters in the @env{IFS} The string is first split using the characters in the @env{IFS}
special variable as delimiters. special variable as delimiters.
Shell quoting is honored. Shell quoting is honored within the string, in order to provide a
mechanism for the words to contain shell metacharacters or characters
in the value of @env{IFS}.
Each word is then expanded using Each word is then expanded using
brace expansion, tilde expansion, parameter and variable expansion, brace expansion, tilde expansion, parameter and variable expansion,
command substitution, and arithmetic expansion, command substitution, and arithmetic expansion,
@ -1960,10 +2024,10 @@ matches were generated.
@item complete @item complete
@btindex complete @btindex complete
@example @example
@code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-DE] [-A @var{action}] [-G @var{globpat}] [-W @var{wordlist}] @code{complete [-abcdefgjksuv] [-o @var{comp-option}] [-DEI] [-A @var{action}] [-G @var{globpat}]
[-F @var{function}] [-C @var{command}] [-X @var{filterpat}] [-W @var{wordlist}] [-F @var{function}] [-C @var{command}] [-X @var{filterpat}]
[-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]} [-P @var{prefix}] [-S @var{suffix}] @var{name} [@var{name} @dots{}]}
@code{complete -pr [-DE] [@var{name} @dots{}]} @code{complete -pr [-DEI] [@var{name} @dots{}]}
@end example @end example
Specify how arguments to each @var{name} should be completed. Specify how arguments to each @var{name} should be completed.
@ -1973,16 +2037,24 @@ reused as input.
The @option{-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 each @var{name}, or, if no @var{name}s are supplied, all
completion specifications. completion specifications.
The @option{-D} option indicates that the remaining options and actions should The @option{-D} option indicates that other supplied options and actions should
apply to the ``default'' command completion; that is, completion attempted apply to the ``default'' command completion; that is, completion attempted
on a command for which no completion has previously been defined. on a command for which no completion has previously been defined.
The @option{-E} option indicates that the remaining options and actions should The @option{-E} option indicates that other supplied options and actions should
apply to ``empty'' command completion; that is, completion attempted on a apply to ``empty'' command completion; that is, completion attempted on a
blank line. blank line.
The @option{-I} option indicates that other supplied options and actions should
apply to completion on the inital non-assignment word on the line, or after a
command delimiter such as @samp{;} or @samp{|}, which is usually command
name completion.
If multiple options are supplied, the @option{-D} option takes precedence
over @option{-E}, and both take precedence over @option{-I}.
If any of @option{-D}, @option{-E}, or @option{-I} are supplied, any other
@var{name} arguments are ignored; these completions only apply to the case
specified by the option.
The process of applying these completion specifications when word completion The process of applying these completion specifications when word completion
is attempted is described above (@pxref{Programmable Completion}). The is attempted is described above (@pxref{Programmable Completion}).
@option{-D} option takes precedence over @option{-E}.
Other options, if specified, have the following meanings. Other options, if specified, have the following meanings.
The arguments to the @option{-G}, @option{-W}, and @option{-X} options The arguments to the @option{-G}, @option{-W}, and @option{-X} options
@ -2012,7 +2084,7 @@ Perform directory name completion if the compspec generates no matches.
@item filenames @item filenames
Tell Readline that the compspec generates filenames, so it can perform any Tell Readline that the compspec generates filenames, so it can perform any
filename-specific processing (like adding a slash to directory names filename-specific processing (like adding a slash to directory names,
quoting special characters, or suppressing trailing spaces). quoting special characters, or suppressing trailing spaces).
This option is intended to be used with shell functions specified This option is intended to be used with shell functions specified
with @option{-F}. with @option{-F}.
@ -2167,7 +2239,7 @@ an error occurs adding a completion specification.
@item compopt @item compopt
@btindex compopt @btindex compopt
@example @example
@code{compopt} [-o @var{option}] [-DE] [+o @var{option}] [@var{name}] @code{compopt} [-o @var{option}] [-DEI] [+o @var{option}] [@var{name}]
@end example @end example
Modify completion options for each @var{name} according to the Modify completion options for each @var{name} according to the
@var{option}s, or for the currently-executing completion if no @var{name}s @var{option}s, or for the currently-executing completion if no @var{name}s
@ -2176,14 +2248,19 @@ If no @var{option}s are given, display the completion options for each
@var{name} or the current completion. @var{name} or the current completion.
The possible values of @var{option} are those valid for the @code{complete} The possible values of @var{option} are those valid for the @code{complete}
builtin described above. builtin described above.
The @option{-D} option indicates that the remaining options should The @option{-D} option indicates that other supplied options should
apply to the ``default'' command completion; that is, completion attempted apply to the ``default'' command completion; that is, completion attempted
on a command for which no completion has previously been defined. on a command for which no completion has previously been defined.
The @option{-E} option indicates that the remaining options should The @option{-E} option indicates that other supplied options should
apply to ``empty'' command completion; that is, completion attempted on a apply to ``empty'' command completion; that is, completion attempted on a
blank line. blank line.
The @option{-I} option indicates that other supplied options should
apply to completion on the inital non-assignment word on the line, or after a
command delimiter such as @samp{;} or @samp{|}, which is usually command
name completion.
The @option{-D} option takes precedence over @option{-E}. If multiple options are supplied, the @option{-D} option takes precedence
over @option{-E}, and both take precedence over @option{-I}
The return value is true unless an invalid option is supplied, an attempt The return value is true unless an invalid option is supplied, an attempt
is made to modify the options for a @var{name} for which no completion is made to modify the options for a @var{name} for which no completion
@ -2200,7 +2277,7 @@ a shell function and bind it to a particular command using @code{complete -F}.
The following function provides completions for the @code{cd} builtin. The following function provides completions for the @code{cd} builtin.
It is a reasonably good example of what shell functions must do when It is a reasonably good example of what shell functions must do when
used for completion. This function uses the word passsed as @code{$2} used for completion. This function uses the word passed as @code{$2}
to determine the directory name to complete. You can also use the to determine the directory name to complete. You can also use the
@code{COMP_WORDS} array variable; the current word is indexed by the @code{COMP_WORDS} array variable; the current word is indexed by the
@code{COMP_CWORD} variable. @code{COMP_CWORD} variable.
@ -2230,7 +2307,7 @@ _comp_cd()
local cur _skipdot _cdpath local cur _skipdot _cdpath
local i j k local i j k
# Tilde expansion, with side effect of expanding tilde to full pathname # Tilde expansion, which also expands tilde to full pathname
case "$2" in case "$2" in
\~*) eval cur="$2" ;; \~*) eval cur="$2" ;;
*) cur=$2 ;; *) cur=$2 ;;

View File

@ -1,10 +1,10 @@
@ignore @ignore
Copyright (C) 1988-2016 Free Software Foundation, Inc. Copyright (C) 1988-2018 Free Software Foundation, Inc.
@end ignore @end ignore
@set EDITION 7.0 @set EDITION 8.0
@set VERSION 7.0 @set VERSION 8.0
@set UPDATED 16 July 2016 @set UPDATED 30 November 2018
@set UPDATED-MONTH July 2016 @set UPDATED-MONTH November 2018
@set LASTCHANGE Sat Jul 16 13:43:15 EDT 2016 @set LASTCHANGE Fri Nov 30 22:50:53 EST 2018

View File

@ -1,6 +1,6 @@
/* emacs_keymap.c -- the keymap for emacs_mode in readline (). */ /* emacs_keymap.c -- the keymap for emacs_mode in readline (). */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.

View File

@ -53,8 +53,12 @@ CPPFLAGS = @CPPFLAGS@
INCLUDES = -I$(srcdir) -I$(top_srcdir) -I.. INCLUDES = -I$(srcdir) -I$(top_srcdir) -I..
CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) CCFLAGS = $(ASAN_CFLAGS) $(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(CPPFLAGS) \
LDFLAGS = -g -L.. @LDFLAGS@ $(CFLAGS)
LDFLAGS = -g -L.. @LDFLAGS@ $(ASAN_LDFLAGS)
ASAN_XCFLAGS = -fsanitize=address -fno-omit-frame-pointer
ASAN_XLDFLAGS = -fsanitize=address
READLINE_LIB = ../libreadline.a READLINE_LIB = ../libreadline.a
HISTORY_LIB = ../libhistory.a HISTORY_LIB = ../libhistory.a
@ -67,15 +71,18 @@ TERMCAP_LIB = @TERMCAP_LIB@
SOURCES = excallback.c fileman.c histexamp.c manexamp.c rl-fgets.c rl.c \ SOURCES = excallback.c fileman.c histexamp.c manexamp.c rl-fgets.c rl.c \
rlbasic.c rlcat.c rlevent.c rlptytest.c rltest.c rlversion.c \ rlbasic.c rlcat.c rlevent.c rlptytest.c rltest.c rlversion.c \
rl-callbacktest.c hist_erasedups.c hist_purgecmd.c rltest2.c rl-callbacktest.c hist_erasedups.c hist_purgecmd.c \
rlkeymaps.c
EXECUTABLES = fileman$(EXEEXT) rltest$(EXEEXT) rl$(EXEEXT) rlcat$(EXEEXT) \ EXECUTABLES = fileman$(EXEEXT) rltest$(EXEEXT) rl$(EXEEXT) rlcat$(EXEEXT) \
rlevent$(EXEEXT) rlversion$(EXEEXT) histexamp$(EXEEXT) \ rlevent$(EXEEXT) rlversion$(EXEEXT) histexamp$(EXEEXT) \
rl-callbacktest$(EXEEXT) rlbasic$(EXEEXT) \ rl-callbacktest$(EXEEXT) rlbasic$(EXEEXT) \
hist_erasedups$(EXEEXT) hist_purgecmd$(EXEEXT) hist_erasedups$(EXEEXT) hist_purgecmd$(EXEEXT) \
rlkeymaps$(EXEEXT)
OBJECTS = fileman.o rltest.o rl.o rlevent.o rlcat.o rlversion.o histexamp.o \ OBJECTS = fileman.o rltest.o rl.o rlevent.o rlcat.o rlversion.o histexamp.o \
rl-callbacktest.o rlbasic.o hist_erasedups.o hist_purgecmd.o rltest2.o rl-callbacktest.o rlbasic.o hist_erasedups.o hist_purgecmd.o \
rlkeymaps.o
OTHEREXE = rlptytest$(EXEEXT) OTHEREXE = rlptytest$(EXEEXT)
OTHEROBJ = rlptytest.o OTHEROBJ = rlptytest.o
@ -83,6 +90,9 @@ OTHEROBJ = rlptytest.o
all: $(EXECUTABLES) all: $(EXECUTABLES)
everything: all everything: all
asan:
${MAKE} ${MFLAGS} ASAN_CFLAGS='${ASAN_XCFLAGS}' ASAN_LDFLAGS='${ASAN_XLDFLAGS}' all
check: rlversion$(EXEEXT) check: rlversion$(EXEEXT)
@echo Readline version: `rlversion$(EXEEXT)` @echo Readline version: `rlversion$(EXEEXT)`
@ -113,12 +123,18 @@ rlcat$(EXEEXT): rlcat.o $(READLINE_LIB)
rlevent$(EXEEXT): rlevent.o $(READLINE_LIB) rlevent$(EXEEXT): rlevent.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rlevent.o $(READLINE_LIB) $(TERMCAP_LIB) $(CC) $(LDFLAGS) -o $@ rlevent.o $(READLINE_LIB) $(TERMCAP_LIB)
rlkeymaps$(EXEEXT): rlkeymaps.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rlkeymaps.o $(READLINE_LIB) $(TERMCAP_LIB)
fileman$(EXEEXT): fileman.o $(READLINE_LIB) fileman$(EXEEXT): fileman.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ fileman.o $(READLINE_LIB) $(TERMCAP_LIB) $(CC) $(LDFLAGS) -o $@ fileman.o $(READLINE_LIB) $(TERMCAP_LIB)
rltest$(EXEEXT): rltest.o $(READLINE_LIB) rltest$(EXEEXT): rltest.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rltest.o $(READLINE_LIB) $(TERMCAP_LIB) $(CC) $(LDFLAGS) -o $@ rltest.o $(READLINE_LIB) $(TERMCAP_LIB)
rltest2$(EXEEXT): rltest2.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rltest2.o $(READLINE_LIB) $(TERMCAP_LIB)
rl-callbacktest$(EXEEXT): rl-callbacktest.o $(READLINE_LIB) rl-callbacktest$(EXEEXT): rl-callbacktest.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rl-callbacktest.o $(READLINE_LIB) $(TERMCAP_LIB) $(CC) $(LDFLAGS) -o $@ rl-callbacktest.o $(READLINE_LIB) $(TERMCAP_LIB)
@ -146,18 +162,21 @@ distclean maintainer-clean: clean
fileman.o: fileman.c fileman.o: fileman.c
rltest.o: rltest.c rltest.o: rltest.c
rltest2.o: rltest2.c
rl.o: rl.c rl.o: rl.c
rlversion.o: rlversion.c rlversion.o: rlversion.c
histexamp.o: histexamp.c histexamp.o: histexamp.c
hist_erasedups.o: hist_erasedups.c hist_erasedups.o: hist_erasedups.c
hist_purgecmd.o: hist_purgecmd.c hist_purgecmd.o: hist_purgecmd.c
rlbasic.o: rlbasic.c rlbasic.o: rlbasic.c
rlkeymaps.o: rlkeymaps.c
rlcat.o: rlcat.c rlcat.o: rlcat.c
rlptytest.o: rlptytest.c rlptytest.o: rlptytest.c
rl-callbacktest.o: rl-callbacktest.c rl-callbacktest.o: rl-callbacktest.c
fileman.o: $(top_srcdir)/readline.h fileman.o: $(top_srcdir)/readline.h
rltest.o: $(top_srcdir)/readline.h rltest.o: $(top_srcdir)/readline.h
rltest2.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
rl.o: $(top_srcdir)/readline.h rl.o: $(top_srcdir)/readline.h
rlversion.o: $(top_srcdir)/readline.h rlversion.o: $(top_srcdir)/readline.h
histexamp.o: $(top_srcdir)/history.h histexamp.o: $(top_srcdir)/history.h

View File

@ -38,6 +38,8 @@
#define STREQN(a, b, n) ((n == 0) ? (1) \ #define STREQN(a, b, n) ((n == 0) ? (1) \
: ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)) : ((a)[0] == (b)[0] && strncmp(a, b, n) == 0))
int hist_erasedups (void);
static void static void
usage() usage()
{ {

View File

@ -43,6 +43,8 @@
#define PURGE_REGEXP 0x01 #define PURGE_REGEXP 0x01
int hist_purgecmd (char *, int);
static void static void
usage() usage()
{ {

View File

@ -27,8 +27,11 @@
# include <readline/history.h> # include <readline/history.h>
#endif #endif
#include <unistd.h>
#include <stdlib.h>
#include <string.h> #include <string.h>
int
main (argc, argv) main (argc, argv)
int argc; int argc;
char **argv; char **argv;

View File

@ -137,7 +137,7 @@ fcopy(fp)
if (vflag && isascii ((unsigned char)c) && isprint((unsigned char)c) == 0) if (vflag && isascii ((unsigned char)c) && isprint((unsigned char)c) == 0)
{ {
x = rl_untranslate_keyseq (c); x = rl_untranslate_keyseq (c);
if (fputs (x, stdout) != 0) if (fputs (x, stdout) == EOF)
return 1; return 1;
} }
else if (putchar (c) == EOF) else if (putchar (c) == EOF)

View File

@ -28,6 +28,13 @@
# include <config.h> # include <config.h>
#endif #endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#else
extern int getopt();
extern int sleep();
#endif
#include <stdio.h> #include <stdio.h>
#include <sys/types.h> #include <sys/types.h>

View File

@ -0,0 +1,61 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#if defined (READLINE_LIBRARY)
# include "readline.h"
# include "history.h"
#else
# include <readline/readline.h>
# include <readline/history.h>
#endif
int
main (int c, char **v)
{
Keymap nmap, emacsmap, newemacs;
int r, errs;
errs = 0;
nmap = rl_make_keymap ();
r = rl_set_keymap_name ("emacs", nmap);
if (r >= 0)
{
fprintf (stderr, "rlkeymaps: error: able to rename `emacs' keymap\n");
errs++;
}
emacsmap = rl_get_keymap_by_name ("emacs");
r = rl_set_keymap_name ("newemacs", emacsmap);
if (r >= 0)
{
fprintf (stderr, "rlkeymaps: error: able to set new name for emacs keymap\n");
errs++;
}
r = rl_set_keymap_name ("newemacs", nmap);
if (r < 0)
{
fprintf (stderr, "rlkeymaps: error: newemacs: could not set keymap name\n");
errs++;
}
newemacs = rl_copy_keymap (emacsmap);
r = rl_set_keymap_name ("newemacs", newemacs);
if (r < 0)
{
fprintf (stderr, "rlkeymaps: error: newemacs: could not set `newemacs' keymap to new map\n");
errs++;
}
r = rl_set_keymap_name ("emacscopy", newemacs);
if (r < 0)
{
fprintf (stderr, "rlkeymaps: error: emacscopy: could not rename created keymap\n");
errs++;
}
exit (errs);
}

View File

@ -46,6 +46,7 @@ extern void exit();
extern HIST_ENTRY **history_list (); extern HIST_ENTRY **history_list ();
int
main () main ()
{ {
char *temp, *prompt; char *temp, *prompt;

View File

@ -1,6 +1,6 @@
/* funmap.c -- attach names to functions. */ /* funmap.c -- attach names to functions. */
/* Copyright (C) 1987-2016 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -110,6 +110,7 @@ static const FUNMAP default_funmap[] = {
{ "menu-complete", rl_menu_complete }, { "menu-complete", rl_menu_complete },
{ "menu-complete-backward", rl_backward_menu_complete }, { "menu-complete-backward", rl_backward_menu_complete },
{ "next-history", rl_get_next_history }, { "next-history", rl_get_next_history },
{ "next-screen-line", rl_next_screen_line },
{ "non-incremental-forward-search-history", rl_noninc_forward_search }, { "non-incremental-forward-search-history", rl_noninc_forward_search },
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search }, { "non-incremental-reverse-search-history", rl_noninc_reverse_search },
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again }, { "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
@ -121,6 +122,7 @@ static const FUNMAP default_funmap[] = {
#endif #endif
{ "possible-completions", rl_possible_completions }, { "possible-completions", rl_possible_completions },
{ "previous-history", rl_get_previous_history }, { "previous-history", rl_get_previous_history },
{ "previous-screen-line", rl_previous_screen_line },
{ "print-last-kbd-macro", rl_print_last_kbd_macro }, { "print-last-kbd-macro", rl_print_last_kbd_macro },
{ "quoted-insert", rl_quoted_insert }, { "quoted-insert", rl_quoted_insert },
{ "re-read-init-file", rl_re_read_init_file }, { "re-read-init-file", rl_re_read_init_file },
@ -204,9 +206,7 @@ static const FUNMAP default_funmap[] = {
}; };
int int
rl_add_funmap_entry (name, function) rl_add_funmap_entry (const char *name, rl_command_func_t *function)
const char *name;
rl_command_func_t *function;
{ {
if (funmap_entry + 2 >= funmap_size) if (funmap_entry + 2 >= funmap_size)
{ {
@ -226,7 +226,7 @@ static int funmap_initialized;
/* Make the funmap contain all of the default entries. */ /* Make the funmap contain all of the default entries. */
void void
rl_initialize_funmap () rl_initialize_funmap (void)
{ {
register int i; register int i;
@ -244,7 +244,7 @@ rl_initialize_funmap ()
is sorted. The array itself is allocated, but not the strings inside. is sorted. The array itself is allocated, but not the strings inside.
You should free () the array when you done, but not the pointers. */ You should free () the array when you done, but not the pointers. */
const char ** const char **
rl_funmap_names () rl_funmap_names (void)
{ {
const char **result; const char **result;
int result_size, result_index; int result_size, result_index;

View File

@ -1,6 +1,6 @@
/* histexpand.c -- history expansion. */ /* histexpand.c -- history expansion. */
/* Copyright (C) 1989-2015 Free Software Foundation, Inc. /* Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines. routines for managing the text of previously typed lines.
@ -55,6 +55,8 @@
#define slashify_in_quotes "\\`\"$" #define slashify_in_quotes "\\`\"$"
#define fielddelim(c) (whitespace(c) || (c) == '\n')
typedef int _hist_search_func_t PARAMS((const char *, int)); typedef int _hist_search_func_t PARAMS((const char *, int));
static char error_pointer; static char error_pointer;
@ -107,6 +109,8 @@ char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
particular history expansion should be performed. */ particular history expansion should be performed. */
rl_linebuf_func_t *history_inhibit_expansion_function; rl_linebuf_func_t *history_inhibit_expansion_function;
int history_quoting_state = 0;
/* **************************************************************** */ /* **************************************************************** */
/* */ /* */
/* History Expansion */ /* History Expansion */
@ -132,10 +136,7 @@ static char *search_match;
So you might call this function like: So you might call this function like:
line = get_history_event ("!echo:p", &index, 0); */ line = get_history_event ("!echo:p", &index, 0); */
char * char *
get_history_event (string, caller_index, delimiting_quote) get_history_event (const char *string, int *caller_index, int delimiting_quote)
const char *string;
int *caller_index;
int delimiting_quote;
{ {
register int i; register int i;
register char c; register char c;
@ -316,9 +317,7 @@ get_history_event (string, caller_index, delimiting_quote)
to the closing single quote. FLAGS currently used to allow backslash to the closing single quote. FLAGS currently used to allow backslash
to escape a single quote (e.g., for bash $'...'). */ to escape a single quote (e.g., for bash $'...'). */
static void static void
hist_string_extract_single_quoted (string, sindex, flags) hist_string_extract_single_quoted (char *string, int *sindex, int flags)
char *string;
int *sindex, flags;
{ {
register int i; register int i;
@ -332,8 +331,7 @@ hist_string_extract_single_quoted (string, sindex, flags)
} }
static char * static char *
quote_breaks (s) quote_breaks (char *s)
char *s;
{ {
register char *p, *r; register char *p, *r;
char *ret; char *ret;
@ -374,9 +372,7 @@ quote_breaks (s)
} }
static char * static char *
hist_error(s, start, current, errtype) hist_error(char *s, int start, int current, int errtype)
char *s;
int start, current, errtype;
{ {
char *temp; char *temp;
const char *emsg; const char *emsg;
@ -433,9 +429,7 @@ hist_error(s, start, current, errtype)
subst_rhs is allowed to be set to the empty string. */ subst_rhs is allowed to be set to the empty string. */
static char * static char *
get_subst_pattern (str, iptr, delimiter, is_rhs, lenptr) get_subst_pattern (char *str, int *iptr, int delimiter, int is_rhs, int *lenptr)
char *str;
int *iptr, delimiter, is_rhs, *lenptr;
{ {
register int si, i, j, k; register int si, i, j, k;
char *s; char *s;
@ -490,7 +484,7 @@ get_subst_pattern (str, iptr, delimiter, is_rhs, lenptr)
} }
static void static void
postproc_subst_rhs () postproc_subst_rhs (void)
{ {
char *new; char *new;
int i, j, new_size; int i, j, new_size;
@ -526,12 +520,9 @@ postproc_subst_rhs ()
if the `p' modifier was supplied and the caller should just print if the `p' modifier was supplied and the caller should just print
the returned string. Returns the new index into string in the returned string. Returns the new index into string in
*END_INDEX_PTR, and the expanded specifier in *RET_STRING. */ *END_INDEX_PTR, and the expanded specifier in *RET_STRING. */
/* need current line for !# */
static int static int
history_expand_internal (string, start, qc, end_index_ptr, ret_string, current_line) history_expand_internal (char *string, int start, int qc, int *end_index_ptr, char **ret_string, char *current_line)
char *string;
int start, qc, *end_index_ptr;
char **ret_string;
char *current_line; /* for !# */
{ {
int i, n, starting_index; int i, n, starting_index;
int substitute_globally, subst_bywords, want_quotes, print_only; int substitute_globally, subst_bywords, want_quotes, print_only;
@ -780,7 +771,7 @@ history_expand_internal (string, start, qc, end_index_ptr, ret_string, current_l
the last time. */ the last time. */
if (subst_bywords && si > we) if (subst_bywords && si > we)
{ {
for (; temp[si] && whitespace (temp[si]); si++) for (; temp[si] && fielddelim (temp[si]); si++)
; ;
ws = si; ws = si;
we = history_tokenize_word (temp, si); we = history_tokenize_word (temp, si);
@ -908,9 +899,7 @@ history_expand_internal (string, start, qc, end_index_ptr, ret_string, current_l
while (0) while (0)
int int
history_expand (hstring, output) history_expand (char *hstring, char **output)
char *hstring;
char **output;
{ {
register int j; register int j;
int i, r, l, passc, cc, modified, eindex, only_printing, dquote, squote, flag; int i, r, l, passc, cc, modified, eindex, only_printing, dquote, squote, flag;
@ -976,7 +965,22 @@ history_expand (hstring, output)
/* `!' followed by one of the characters in history_no_expand_chars /* `!' followed by one of the characters in history_no_expand_chars
is NOT an expansion. */ is NOT an expansion. */
for (i = dquote = squote = 0; string[i]; i++) dquote = history_quoting_state == '"';
squote = history_quoting_state == '\'';
/* If the calling application tells us we are already reading a
single-quoted string, consume the rest of the string right now
and then go on. */
i = 0;
if (squote && history_quotes_inhibit_expansion)
{
hist_string_extract_single_quoted (string, &i, 0);
squote = 0;
if (string[i])
i++;
}
for ( ; string[i]; i++)
{ {
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
@ -1064,7 +1068,29 @@ history_expand (hstring, output)
} }
/* Extract and perform the substitution. */ /* Extract and perform the substitution. */
for (passc = dquote = squote = i = j = 0; i < l; i++) dquote = history_quoting_state == '"';
squote = history_quoting_state == '\'';
/* If the calling application tells us we are already reading a
single-quoted string, consume the rest of the string right now
and then go on. */
i = j = 0;
if (squote && history_quotes_inhibit_expansion)
{
int c;
hist_string_extract_single_quoted (string, &i, 0);
squote = 0;
for (c = 0; c < i; c++)
ADD_CHAR (string[c]);
if (string[i])
{
ADD_CHAR (string[i]);
i++;
}
}
for (passc = 0; i < l; i++)
{ {
int qc, tchar = string[i]; int qc, tchar = string[i];
@ -1249,9 +1275,7 @@ history_expand (hstring, output)
CALLER_INDEX is the offset in SPEC to start looking; it is updated CALLER_INDEX is the offset in SPEC to start looking; it is updated
to point to just after the last character parsed. */ to point to just after the last character parsed. */
static char * static char *
get_history_word_specifier (spec, from, caller_index) get_history_word_specifier (char *spec, char *from, int *caller_index)
char *spec, *from;
int *caller_index;
{ {
register int i = *caller_index; register int i = *caller_index;
int first, last; int first, last;
@ -1357,9 +1381,7 @@ get_history_word_specifier (spec, from, caller_index)
tokens, so that FIRST = -1 means the next to last token on the line). tokens, so that FIRST = -1 means the next to last token on the line).
If LAST is `$' the last arg from STRING is used. */ If LAST is `$' the last arg from STRING is used. */
char * char *
history_arg_extract (first, last, string) history_arg_extract (int first, int last, const char *string)
int first, last;
const char *string;
{ {
register int i, len; register int i, len;
char *result; char *result;
@ -1418,9 +1440,7 @@ history_arg_extract (first, last, string)
} }
static int static int
history_tokenize_word (string, ind) history_tokenize_word (const char *string, int ind)
const char *string;
int ind;
{ {
register int i, j; register int i, j;
int delimiter, nestdelim, delimopen; int delimiter, nestdelim, delimopen;
@ -1428,7 +1448,7 @@ history_tokenize_word (string, ind)
i = ind; i = ind;
delimiter = nestdelim = 0; delimiter = nestdelim = 0;
if (member (string[i], "()\n")) if (member (string[i], "()\n")) /* XXX - included \n, but why? been here forever */
{ {
i++; i++;
return i; return i;
@ -1450,11 +1470,11 @@ history_tokenize_word (string, ind)
} }
} }
if (member (string[i], "<>;&|$")) if (member (string[i], "<>;&|"))
{ {
int peek = string[i + 1]; int peek = string[i + 1];
if (peek == string[i] && peek != '$') if (peek == string[i])
{ {
if (peek == '<' && string[i + 2] == '-') if (peek == '<' && string[i + 2] == '-')
i++; i++;
@ -1477,9 +1497,8 @@ history_tokenize_word (string, ind)
i += 2; i += 2;
return i; return i;
} }
/* XXX - separated out for later -- bash-4.2 */ /* XXX - process substitution -- separated out for later -- bash-4.2 */
else if ((peek == '(' && (string[i] == '>' || string[i] == '<')) || /* ) */ else if (peek == '(' && (string[i] == '>' || string[i] == '<')) /*)*/
(peek == '(' && string[i] == '$')) /*)*/
{ {
i += 2; i += 2;
delimopen = '('; delimopen = '(';
@ -1487,34 +1506,9 @@ history_tokenize_word (string, ind)
nestdelim = 1; nestdelim = 1;
goto get_word; goto get_word;
} }
#if 0
else if (peek == '\'' && string[i] == '$')
{
i += 2; /* XXX */
return i;
}
#endif
if (string[i] != '$') i++;
{ return i;
i++;
return i;
}
}
/* same code also used for $(...)/<(...)/>(...) above */
if (member (string[i], "!@?+*"))
{
int peek = string[i + 1];
if (peek == '(') /*)*/
{
/* Shell extended globbing patterns */
i += 2;
delimopen = '(';
delimiter = ')'; /* XXX - not perfect */
nestdelim = 1;
}
} }
get_word: get_word:
@ -1559,6 +1553,16 @@ get_word:
continue; continue;
} }
/* Command and process substitution; shell extended globbing patterns */
if (nestdelim == 0 && delimiter == 0 && member (string[i], "<>$!@?+*") && string[i+1] == '(') /*)*/
{
i += 2;
delimopen = '(';
delimiter = ')';
nestdelim = 1;
continue;
}
if (delimiter == 0 && (member (string[i], history_word_delimiters))) if (delimiter == 0 && (member (string[i], history_word_delimiters)))
break; break;
@ -1570,9 +1574,7 @@ get_word:
} }
static char * static char *
history_substring (string, start, end) history_substring (const char *string, int start, int end)
const char *string;
int start, end;
{ {
register int len; register int len;
register char *result; register char *result;
@ -1589,9 +1591,7 @@ history_substring (string, start, end)
WIND. The position in the returned array of strings is returned in WIND. The position in the returned array of strings is returned in
*INDP. */ *INDP. */
static char ** static char **
history_tokenize_internal (string, wind, indp) history_tokenize_internal (const char *string, int wind, int *indp)
const char *string;
int wind, *indp;
{ {
char **result; char **result;
register int i, start, result_index, size; register int i, start, result_index, size;
@ -1606,7 +1606,7 @@ history_tokenize_internal (string, wind, indp)
for (i = result_index = size = 0, result = (char **)NULL; string[i]; ) for (i = result_index = size = 0, result = (char **)NULL; string[i]; )
{ {
/* Skip leading whitespace. */ /* Skip leading whitespace. */
for (; string[i] && whitespace (string[i]); i++) for (; string[i] && fielddelim (string[i]); i++)
; ;
if (string[i] == 0 || string[i] == history_comment_char) if (string[i] == 0 || string[i] == history_comment_char)
return (result); return (result);
@ -1644,17 +1644,14 @@ history_tokenize_internal (string, wind, indp)
/* Return an array of tokens, much as the shell might. The tokens are /* Return an array of tokens, much as the shell might. The tokens are
parsed out of STRING. */ parsed out of STRING. */
char ** char **
history_tokenize (string) history_tokenize (const char *string)
const char *string;
{ {
return (history_tokenize_internal (string, -1, (int *)NULL)); return (history_tokenize_internal (string, -1, (int *)NULL));
} }
/* Free members of WORDS from START to an empty string */ /* Free members of WORDS from START to an empty string */
static void static void
freewords (words, start) freewords (char **words, int start)
char **words;
int start;
{ {
register int i; register int i;
@ -1666,9 +1663,7 @@ freewords (words, start)
in the history line LINE. Used to save the word matched by the in the history line LINE. Used to save the word matched by the
last history !?string? search. */ last history !?string? search. */
static char * static char *
history_find_word (line, ind) history_find_word (char *line, int ind)
char *line;
int ind;
{ {
char **words, *s; char **words, *s;
int i, wind; int i, wind;

View File

@ -1,6 +1,6 @@
/* histfile.c - functions to manipulate the history file. */ /* histfile.c - functions to manipulate the history file. */
/* Copyright (C) 1989-2016 Free Software Foundation, Inc. /* Copyright (C) 1989-2018 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines. routines for managing the text of previously typed lines.
@ -143,8 +143,7 @@ static int histfile_restore PARAMS((const char *, const char *));
filename. This only matters when you don't specify the filename. This only matters when you don't specify the
filename to read_history (), or write_history (). */ filename to read_history (), or write_history (). */
static char * static char *
history_filename (filename) history_filename (const char *filename)
const char *filename;
{ {
char *return_val; char *return_val;
const char *home; const char *home;
@ -179,8 +178,7 @@ history_filename (filename)
} }
static char * static char *
history_backupfile (filename) history_backupfile (const char *filename)
const char *filename;
{ {
const char *fn; const char *fn;
char *ret, linkbuf[PATH_MAX+1]; char *ret, linkbuf[PATH_MAX+1];
@ -208,8 +206,7 @@ history_backupfile (filename)
} }
static char * static char *
history_tempfile (filename) history_tempfile (const char *filename)
const char *filename;
{ {
const char *fn; const char *fn;
char *ret, linkbuf[PATH_MAX+1]; char *ret, linkbuf[PATH_MAX+1];
@ -251,8 +248,7 @@ history_tempfile (filename)
If FILENAME is NULL, then read from ~/.history. Returns 0 if If FILENAME is NULL, then read from ~/.history. Returns 0 if
successful, or errno if not. */ successful, or errno if not. */
int int
read_history (filename) read_history (const char *filename)
const char *filename;
{ {
return (read_history_range (filename, 0, -1)); return (read_history_range (filename, 0, -1));
} }
@ -263,9 +259,7 @@ read_history (filename)
until the end of the file. If FILENAME is NULL, then read from until the end of the file. If FILENAME is NULL, then read from
~/.history. Returns 0 if successful, or errno if not. */ ~/.history. Returns 0 if successful, or errno if not. */
int int
read_history_range (filename, from, to) read_history_range (const char *filename, int from, int to)
const char *filename;
int from, to;
{ {
register char *line_start, *line_end, *p; register char *line_start, *line_end, *p;
char *input, *buffer, *bufend, *last_ts; char *input, *buffer, *bufend, *last_ts;
@ -289,6 +283,16 @@ read_history_range (filename, from, to)
if ((file < 0) || (fstat (file, &finfo) == -1)) if ((file < 0) || (fstat (file, &finfo) == -1))
goto error_and_exit; goto error_and_exit;
if (S_ISREG (finfo.st_mode) == 0)
{
#ifdef EFTYPE
errno = EFTYPE;
#else
errno = EINVAL;
#endif
goto error_and_exit;
}
file_size = (size_t)finfo.st_size; file_size = (size_t)finfo.st_size;
/* check for overflow on very large files */ /* check for overflow on very large files */
@ -298,6 +302,12 @@ read_history_range (filename, from, to)
goto error_and_exit; goto error_and_exit;
} }
if (file_size == 0)
{
free (input);
return 0; /* don't waste time if we don't have to */
}
#ifdef HISTORY_USE_MMAP #ifdef HISTORY_USE_MMAP
/* We map read/write and private so we can change newlines to NULs without /* We map read/write and private so we can change newlines to NULs without
affecting the underlying object. */ affecting the underlying object. */
@ -344,6 +354,7 @@ read_history_range (filename, from, to)
/* Start at beginning of file, work to end. */ /* Start at beginning of file, work to end. */
bufend = buffer + chars_read; bufend = buffer + chars_read;
*bufend = '\0'; /* null-terminate buffer for timestamp checks */
current_line = 0; current_line = 0;
/* Heuristic: the history comment character rarely changes, so assume we /* Heuristic: the history comment character rarely changes, so assume we
@ -385,7 +396,7 @@ read_history_range (filename, from, to)
{ {
if (HIST_TIMESTAMP_START(line_start) == 0) if (HIST_TIMESTAMP_START(line_start) == 0)
{ {
if (last_ts == NULL && history_multiline_entries) if (last_ts == NULL && history_length > 0 && history_multiline_entries)
_hs_append_history_line (history_length - 1, line_start); _hs_append_history_line (history_length - 1, line_start);
else else
add_history (line_start); add_history (line_start);
@ -427,9 +438,7 @@ read_history_range (filename, from, to)
/* Save FILENAME to BACK, handling case where FILENAME is a symlink /* Save FILENAME to BACK, handling case where FILENAME is a symlink
(e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */ (e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */
static int static int
histfile_backup (filename, back) histfile_backup (const char *filename, const char *back)
const char *filename;
const char *back;
{ {
#if defined (HAVE_READLINK) #if defined (HAVE_READLINK)
char linkbuf[PATH_MAX+1]; char linkbuf[PATH_MAX+1];
@ -448,9 +457,7 @@ histfile_backup (filename, back)
/* Restore ORIG from BACKUP handling case where ORIG is a symlink /* Restore ORIG from BACKUP handling case where ORIG is a symlink
(e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */ (e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */
static int static int
histfile_restore (backup, orig) histfile_restore (const char *backup, const char *orig)
const char *backup;
const char *orig;
{ {
#if defined (HAVE_READLINK) #if defined (HAVE_READLINK)
char linkbuf[PATH_MAX+1]; char linkbuf[PATH_MAX+1];
@ -470,9 +477,7 @@ histfile_restore (backup, orig)
If FNAME is NULL, then use ~/.history. Writes a new file and renames If FNAME is NULL, then use ~/.history. Writes a new file and renames
it to the original name. Returns 0 on success, errno on failure. */ it to the original name. Returns 0 on success, errno on failure. */
int int
history_truncate_file (fname, lines) history_truncate_file (const char *fname, int lines)
const char *fname;
int lines;
{ {
char *buffer, *filename, *tempname, *bp, *bp1; /* bp1 == bp+1 */ char *buffer, *filename, *tempname, *bp, *bp1; /* bp1 == bp+1 */
int file, chars_read, rv, orig_lines, exists, r; int file, chars_read, rv, orig_lines, exists, r;
@ -606,12 +611,14 @@ history_truncate_file (fname, lines)
history_lines_written_to_file = 0; history_lines_written_to_file = 0;
} }
#if defined (HAVE_CHOWN)
/* Make sure the new filename is owned by the same user as the old. If one /* Make sure the new filename is owned by the same user as the old. If one
user is running this, it's a no-op. If the shell is running after sudo user is running this, it's a no-op. If the shell is running after sudo
with a shared history file, we don't want to leave the history file with a shared history file, we don't want to leave the history file
owned by root. */ owned by root. */
if (rv == 0 && exists) if (rv == 0 && exists)
r = chown (filename, finfo.st_uid, finfo.st_gid); r = chown (filename, finfo.st_uid, finfo.st_gid);
#endif
xfree (filename); xfree (filename);
FREE (tempname); FREE (tempname);
@ -623,9 +630,7 @@ history_truncate_file (fname, lines)
from the history list to FILENAME. OVERWRITE is non-zero if you from the history list to FILENAME. OVERWRITE is non-zero if you
wish to replace FILENAME with the entries. */ wish to replace FILENAME with the entries. */
static int static int
history_do_write (filename, nelements, overwrite) history_do_write (const char *filename, int nelements, int overwrite)
const char *filename;
int nelements, overwrite;
{ {
register int i; register int i;
char *output, *tempname, *histname; char *output, *tempname, *histname;
@ -753,12 +758,14 @@ mmap_error:
history_lines_written_to_file = 0; history_lines_written_to_file = 0;
} }
#if defined (HAVE_CHOWN)
/* Make sure the new filename is owned by the same user as the old. If one /* Make sure the new filename is owned by the same user as the old. If one
user is running this, it's a no-op. If the shell is running after sudo user is running this, it's a no-op. If the shell is running after sudo
with a shared history file, we don't want to leave the history file with a shared history file, we don't want to leave the history file
owned by root. */ owned by root. */
if (rv == 0 && exists) if (rv == 0 && exists)
mode = chown (histname, finfo.st_uid, finfo.st_gid); mode = chown (histname, finfo.st_uid, finfo.st_gid);
#endif
FREE (histname); FREE (histname);
FREE (tempname); FREE (tempname);
@ -769,9 +776,7 @@ mmap_error:
/* Append NELEMENT entries to FILENAME. The entries appended are from /* Append NELEMENT entries to FILENAME. The entries appended are from
the end of the list minus NELEMENTs up to the end of the list. */ the end of the list minus NELEMENTs up to the end of the list. */
int int
append_history (nelements, filename) append_history (int nelements, const char *filename)
int nelements;
const char *filename;
{ {
return (history_do_write (filename, nelements, HISTORY_APPEND)); return (history_do_write (filename, nelements, HISTORY_APPEND));
} }
@ -780,8 +785,7 @@ append_history (nelements, filename)
then write the history list to ~/.history. Values returned then write the history list to ~/.history. Values returned
are as in read_history ().*/ are as in read_history ().*/
int int
write_history (filename) write_history (const char *filename)
const char *filename;
{ {
return (history_do_write (filename, history_length, HISTORY_OVERWRITE)); return (history_do_write (filename, history_length, HISTORY_OVERWRITE));
} }

View File

@ -51,9 +51,9 @@
#endif #endif
#ifndef member #ifndef member
# ifndef strchr # if !defined (strchr) && !defined (__STDC__)
extern char *strchr (); extern char *strchr ();
# endif # endif /* !strchr && !__STDC__ */
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0) #define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
#endif #endif
@ -69,11 +69,17 @@ extern char *strchr ();
#define NO_PREV_SUBST 4 #define NO_PREV_SUBST 4
/* Possible definitions for history starting point specification. */ /* Possible definitions for history starting point specification. */
#define ANCHORED_SEARCH 1 #define NON_ANCHORED_SEARCH 0
#define NON_ANCHORED_SEARCH 0 #define ANCHORED_SEARCH 0x01
#define PATTERN_SEARCH 0x02
/* Possible definitions for what style of writing the history file we want. */ /* Possible definitions for what style of writing the history file we want. */
#define HISTORY_APPEND 0 #define HISTORY_APPEND 0
#define HISTORY_OVERWRITE 1 #define HISTORY_OVERWRITE 1
/* internal extern function declarations used by other parts of the library */
/* histsearch.c */
extern int _hs_history_patsearch PARAMS((const char *, int, int));
#endif /* !_HISTLIB_H_ */ #endif /* !_HISTLIB_H_ */

View File

@ -1,6 +1,6 @@
/* history.c -- standalone history library */ /* history.c -- standalone history library */
/* Copyright (C) 1989-2015 Free Software Foundation, Inc. /* Copyright (C) 1989-2017 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines. routines for managing the text of previously typed lines.
@ -97,7 +97,7 @@ int history_base = 1;
/* Return the current HISTORY_STATE of the history. */ /* Return the current HISTORY_STATE of the history. */
HISTORY_STATE * HISTORY_STATE *
history_get_history_state () history_get_history_state (void)
{ {
HISTORY_STATE *state; HISTORY_STATE *state;
@ -115,8 +115,7 @@ history_get_history_state ()
/* Set the state of the current history array to STATE. */ /* Set the state of the current history array to STATE. */
void void
history_set_history_state (state) history_set_history_state (HISTORY_STATE *state)
HISTORY_STATE *state;
{ {
the_history = state->entries; the_history = state->entries;
history_offset = state->offset; history_offset = state->offset;
@ -129,7 +128,7 @@ history_set_history_state (state)
/* Begin a session in which the history functions might be used. This /* Begin a session in which the history functions might be used. This
initializes interactive variables. */ initializes interactive variables. */
void void
using_history () using_history (void)
{ {
history_offset = history_length; history_offset = history_length;
} }
@ -138,7 +137,7 @@ using_history ()
This just adds up the lengths of the_history->lines and the associated This just adds up the lengths of the_history->lines and the associated
timestamps. */ timestamps. */
int int
history_total_bytes () history_total_bytes (void)
{ {
register int i, result; register int i, result;
@ -151,7 +150,7 @@ history_total_bytes ()
/* Returns the magic number which says what history element we are /* Returns the magic number which says what history element we are
looking at now. In this implementation, it returns history_offset. */ looking at now. In this implementation, it returns history_offset. */
int int
where_history () where_history (void)
{ {
return (history_offset); return (history_offset);
} }
@ -159,8 +158,7 @@ where_history ()
/* Make the current history item be the one at POS, an absolute index. /* Make the current history item be the one at POS, an absolute index.
Returns zero if POS is out of range, else non-zero. */ Returns zero if POS is out of range, else non-zero. */
int int
history_set_pos (pos) history_set_pos (int pos)
int pos;
{ {
if (pos > history_length || pos < 0 || !the_history) if (pos > history_length || pos < 0 || !the_history)
return (0); return (0);
@ -172,7 +170,7 @@ history_set_pos (pos)
is the actual array of data, and could be bashed or made corrupt easily. is the actual array of data, and could be bashed or made corrupt easily.
The array is terminated with a NULL pointer. */ The array is terminated with a NULL pointer. */
HIST_ENTRY ** HIST_ENTRY **
history_list () history_list (void)
{ {
return (the_history); return (the_history);
} }
@ -180,7 +178,7 @@ history_list ()
/* Return the history entry at the current position, as determined by /* Return the history entry at the current position, as determined by
history_offset. If there is no entry there, return a NULL pointer. */ history_offset. If there is no entry there, return a NULL pointer. */
HIST_ENTRY * HIST_ENTRY *
current_history () current_history (void)
{ {
return ((history_offset == history_length) || the_history == 0) return ((history_offset == history_length) || the_history == 0)
? (HIST_ENTRY *)NULL ? (HIST_ENTRY *)NULL
@ -191,7 +189,7 @@ current_history ()
a pointer to that entry. If there is no previous entry then return a pointer to that entry. If there is no previous entry then return
a NULL pointer. */ a NULL pointer. */
HIST_ENTRY * HIST_ENTRY *
previous_history () previous_history (void)
{ {
return history_offset ? the_history[--history_offset] : (HIST_ENTRY *)NULL; return history_offset ? the_history[--history_offset] : (HIST_ENTRY *)NULL;
} }
@ -200,7 +198,7 @@ previous_history ()
a pointer to that entry. If there is no next entry then return a a pointer to that entry. If there is no next entry then return a
NULL pointer. */ NULL pointer. */
HIST_ENTRY * HIST_ENTRY *
next_history () next_history (void)
{ {
return (history_offset == history_length) ? (HIST_ENTRY *)NULL : the_history[++history_offset]; return (history_offset == history_length) ? (HIST_ENTRY *)NULL : the_history[++history_offset];
} }
@ -208,8 +206,7 @@ next_history ()
/* Return the history entry which is logically at OFFSET in the history array. /* Return the history entry which is logically at OFFSET in the history array.
OFFSET is relative to history_base. */ OFFSET is relative to history_base. */
HIST_ENTRY * HIST_ENTRY *
history_get (offset) history_get (int offset)
int offset;
{ {
int local_index; int local_index;
@ -220,9 +217,7 @@ history_get (offset)
} }
HIST_ENTRY * HIST_ENTRY *
alloc_history_entry (string, ts) alloc_history_entry (char *string, char *ts)
char *string;
char *ts;
{ {
HIST_ENTRY *temp; HIST_ENTRY *temp;
@ -236,8 +231,7 @@ alloc_history_entry (string, ts)
} }
time_t time_t
history_get_time (hist) history_get_time (HIST_ENTRY *hist)
HIST_ENTRY *hist;
{ {
char *ts; char *ts;
time_t t; time_t t;
@ -255,7 +249,7 @@ history_get_time (hist)
} }
static char * static char *
hist_inittime () hist_inittime (void)
{ {
time_t t; time_t t;
char ts[64], *ret; char ts[64], *ret;
@ -275,8 +269,7 @@ hist_inittime ()
/* Place STRING at the end of the history list. The data field /* Place STRING at the end of the history list. The data field
is set to NULL. */ is set to NULL. */
void void
add_history (string) add_history (const char *string)
const char *string;
{ {
HIST_ENTRY *temp; HIST_ENTRY *temp;
int new_length; int new_length;
@ -335,8 +328,7 @@ add_history (string)
/* Change the time stamp of the most recent history entry to STRING. */ /* Change the time stamp of the most recent history entry to STRING. */
void void
add_history_time (string) add_history_time (const char *string)
const char *string;
{ {
HIST_ENTRY *hs; HIST_ENTRY *hs;
@ -350,8 +342,7 @@ add_history_time (string)
/* Free HIST and return the data so the calling application can free it /* Free HIST and return the data so the calling application can free it
if necessary and desired. */ if necessary and desired. */
histdata_t histdata_t
free_history_entry (hist) free_history_entry (HIST_ENTRY *hist)
HIST_ENTRY *hist;
{ {
histdata_t x; histdata_t x;
@ -365,8 +356,7 @@ free_history_entry (hist)
} }
HIST_ENTRY * HIST_ENTRY *
copy_history_entry (hist) copy_history_entry (HIST_ENTRY *hist)
HIST_ENTRY *hist;
{ {
HIST_ENTRY *ret; HIST_ENTRY *ret;
char *ts; char *ts;
@ -388,10 +378,7 @@ copy_history_entry (hist)
the old entry so you can dispose of the data. In the case of an the old entry so you can dispose of the data. In the case of an
invalid WHICH, a NULL pointer is returned. */ invalid WHICH, a NULL pointer is returned. */
HIST_ENTRY * HIST_ENTRY *
replace_history_entry (which, line, data) replace_history_entry (int which, const char *line, histdata_t data)
int which;
const char *line;
histdata_t data;
{ {
HIST_ENTRY *temp, *old_value; HIST_ENTRY *temp, *old_value;
@ -413,17 +400,26 @@ replace_history_entry (which, line, data)
end of the current line first. This can be used to construct multi-line end of the current line first. This can be used to construct multi-line
history entries while reading lines from the history file. */ history entries while reading lines from the history file. */
void void
_hs_append_history_line (which, line) _hs_append_history_line (int which, const char *line)
int which;
const char *line;
{ {
HIST_ENTRY *hent; HIST_ENTRY *hent;
size_t newlen, curlen; size_t newlen, curlen, minlen;
char *newline; char *newline;
hent = the_history[which]; hent = the_history[which];
curlen = strlen (hent->line); curlen = strlen (hent->line);
newlen = curlen + strlen (line) + 2; minlen = curlen + strlen (line) + 2; /* min space needed */
if (curlen > 256) /* XXX - for now */
{
newlen = 512; /* now realloc in powers of 2 */
/* we recalcluate every time; the operations are cheap */
while (newlen < minlen)
newlen <<= 1;
}
else
newlen = minlen;
/* Assume that realloc returns the same pointer and doesn't try a new
alloc/copy if the new size is the same as the one last passed. */
newline = realloc (hent->line, newlen); newline = realloc (hent->line, newlen);
if (newline) if (newline)
{ {
@ -440,9 +436,7 @@ _hs_append_history_line (which, line)
WHICH >= 0 means to replace that particular history entry's data, as WHICH >= 0 means to replace that particular history entry's data, as
long as it matches OLD. */ long as it matches OLD. */
void void
_hs_replace_history_data (which, old, new) _hs_replace_history_data (int which, histdata_t *old, histdata_t *new)
int which;
histdata_t *old, *new;
{ {
HIST_ENTRY *entry; HIST_ENTRY *entry;
register int i, last; register int i, last;
@ -482,29 +476,76 @@ _hs_replace_history_data (which, old, new)
element is returned to you so you can free the line, data, element is returned to you so you can free the line, data,
and containing structure. */ and containing structure. */
HIST_ENTRY * HIST_ENTRY *
remove_history (which) remove_history (int which)
int which;
{ {
HIST_ENTRY *return_value; HIST_ENTRY *return_value;
register int i; register int i;
#if 1
int nentries;
HIST_ENTRY **start, **end;
#endif
if (which < 0 || which >= history_length || history_length == 0 || the_history == 0) if (which < 0 || which >= history_length || history_length == 0 || the_history == 0)
return ((HIST_ENTRY *)NULL); return ((HIST_ENTRY *)NULL);
return_value = the_history[which]; return_value = the_history[which];
#if 1
/* Copy the rest of the entries, moving down one slot. Copy includes
trailing NULL. */
nentries = history_length - which;
start = the_history + which;
end = start + 1;
memmove (start, end, nentries * sizeof (HIST_ENTRY *));
#else
for (i = which; i < history_length; i++) for (i = which; i < history_length; i++)
the_history[i] = the_history[i + 1]; the_history[i] = the_history[i + 1];
#endif
history_length--; history_length--;
return (return_value); return (return_value);
} }
HIST_ENTRY **
remove_history_range (int first, int last)
{
HIST_ENTRY **return_value;
register int i;
int nentries;
HIST_ENTRY **start, **end;
if (the_history == 0 || history_length == 0)
return ((HIST_ENTRY **)NULL);
if (first < 0 || first >= history_length || last < 0 || last >= history_length)
return ((HIST_ENTRY **)NULL);
if (first > last)
return (HIST_ENTRY **)NULL;
nentries = last - first + 1;
return_value = (HIST_ENTRY **)malloc ((nentries + 1) * sizeof (HIST_ENTRY *));
if (return_value == 0)
return return_value;
/* Return all the deleted entries in a list */
for (i = first ; i <= last; i++)
return_value[i - first] = the_history[i];
return_value[i - first] = (HIST_ENTRY *)NULL;
/* Copy the rest of the entries, moving down NENTRIES slots. Copy includes
trailing NULL. */
start = the_history + first;
end = the_history + last + 1;
memmove (start, end, (history_length - last) * sizeof (HIST_ENTRY *));
history_length -= nentries;
return (return_value);
}
/* Stifle the history list, remembering only MAX number of lines. */ /* Stifle the history list, remembering only MAX number of lines. */
void void
stifle_history (max) stifle_history (int max)
int max;
{ {
register int i, j; register int i, j;
@ -532,7 +573,7 @@ stifle_history (max)
number of history entries. The value is positive if the history number of history entries. The value is positive if the history
was stifled, negative if it wasn't. */ was stifled, negative if it wasn't. */
int int
unstifle_history () unstifle_history (void)
{ {
if (history_stifled) if (history_stifled)
{ {
@ -544,13 +585,13 @@ unstifle_history ()
} }
int int
history_is_stifled () history_is_stifled (void)
{ {
return (history_stifled); return (history_stifled);
} }
void void
clear_history () clear_history (void)
{ {
register int i; register int i;
@ -562,4 +603,5 @@ clear_history ()
} }
history_offset = history_length = 0; history_offset = history_length = 0;
history_base = 1; /* reset history base to default */
} }

View File

@ -86,11 +86,13 @@ extern void add_history PARAMS((const char *));
STRING. */ STRING. */
extern void add_history_time PARAMS((const char *)); extern void add_history_time PARAMS((const char *));
/* A reasonably useless function, only here for completeness. WHICH /* Remove an entry from the history list. WHICH is the magic number that
is the magic number that tells us which element to delete. The tells us which element to delete. The elements are numbered from 0. */
elements are numbered from 0. */
extern HIST_ENTRY *remove_history PARAMS((int)); extern HIST_ENTRY *remove_history PARAMS((int));
/* Remove a set of entries from the history list: FIRST to LAST, inclusive */
extern HIST_ENTRY **remove_history_range PARAMS((int, int));
/* Allocate a history entry consisting of STRING and TIMESTAMP and return /* Allocate a history entry consisting of STRING and TIMESTAMP and return
a pointer to it. */ a pointer to it. */
extern HIST_ENTRY *alloc_history_entry PARAMS((char *, char *)); extern HIST_ENTRY *alloc_history_entry PARAMS((char *, char *));
@ -259,7 +261,9 @@ extern char *history_word_delimiters;
extern char history_comment_char; extern char history_comment_char;
extern char *history_no_expand_chars; extern char *history_no_expand_chars;
extern char *history_search_delimiter_chars; extern char *history_search_delimiter_chars;
extern int history_quotes_inhibit_expansion; extern int history_quotes_inhibit_expansion;
extern int history_quoting_state;
extern int history_write_timestamps; extern int history_write_timestamps;

View File

@ -1,6 +1,6 @@
/* histsearch.c -- searching the history list. */ /* histsearch.c -- searching the history list. */
/* Copyright (C) 1989, 1992-2009 Free Software Foundation, Inc. /* Copyright (C) 1989, 1992-2009,2017 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines. routines for managing the text of previously typed lines.
@ -39,8 +39,13 @@
# include <unistd.h> # include <unistd.h>
#endif #endif
#if defined (HAVE_FNMATCH)
# include <fnmatch.h>
#endif
#include "history.h" #include "history.h"
#include "histlib.h" #include "histlib.h"
#include "xmalloc.h"
/* The list of alternate characters that can delimit a history search /* The list of alternate characters that can delimit a history search
string. */ string. */
@ -59,18 +64,22 @@ static int history_search_internal PARAMS((const char *, int, int));
returned. */ returned. */
static int static int
history_search_internal (string, direction, anchored) history_search_internal (const char *string, int direction, int flags)
const char *string;
int direction, anchored;
{ {
register int i, reverse; register int i, reverse;
register char *line; register char *line;
register int line_index; register int line_index;
int string_len; int string_len, anchored, patsearch;
HIST_ENTRY **the_history; /* local */ HIST_ENTRY **the_history; /* local */
i = history_offset; i = history_offset;
reverse = (direction < 0); reverse = (direction < 0);
anchored = (flags & ANCHORED_SEARCH);
#if defined (HAVE_FNMATCH)
patsearch = (flags & PATTERN_SEARCH);
#else
patsearch = 0;
#endif
/* Take care of trivial cases first. */ /* Take care of trivial cases first. */
if (string == 0 || *string == '\0') if (string == 0 || *string == '\0')
@ -98,7 +107,7 @@ history_search_internal (string, direction, anchored)
line_index = strlen (line); line_index = strlen (line);
/* If STRING is longer than line, no match. */ /* If STRING is longer than line, no match. */
if (string_len > line_index) if (patsearch == 0 && (string_len > line_index))
{ {
NEXT_LINE (); NEXT_LINE ();
continue; continue;
@ -107,6 +116,17 @@ history_search_internal (string, direction, anchored)
/* Handle anchored searches first. */ /* Handle anchored searches first. */
if (anchored == ANCHORED_SEARCH) if (anchored == ANCHORED_SEARCH)
{ {
#if defined (HAVE_FNMATCH)
if (patsearch)
{
if (fnmatch (string, line, 0) == 0)
{
history_offset = i;
return (0);
}
}
else
#endif
if (STREQN (string, line, string_len)) if (STREQN (string, line, string_len))
{ {
history_offset = i; history_offset = i;
@ -120,10 +140,21 @@ history_search_internal (string, direction, anchored)
/* Do substring search. */ /* Do substring search. */
if (reverse) if (reverse)
{ {
line_index -= string_len; line_index -= (patsearch == 0) ? string_len : 1;
while (line_index >= 0) while (line_index >= 0)
{ {
#if defined (HAVE_FNMATCH)
if (patsearch)
{
if (fnmatch (string, line + line_index, 0) == 0)
{
history_offset = i;
return (line_index);
}
}
else
#endif
if (STREQN (string, line + line_index, string_len)) if (STREQN (string, line + line_index, string_len))
{ {
history_offset = i; history_offset = i;
@ -141,6 +172,17 @@ history_search_internal (string, direction, anchored)
while (line_index < limit) while (line_index < limit)
{ {
#if defined (HAVE_FNMATCH)
if (patsearch)
{
if (fnmatch (string, line + line_index, 0) == 0)
{
history_offset = i;
return (line_index);
}
}
else
#endif
if (STREQN (string, line + line_index, string_len)) if (STREQN (string, line + line_index, string_len))
{ {
history_offset = i; history_offset = i;
@ -153,20 +195,73 @@ history_search_internal (string, direction, anchored)
} }
} }
int
_hs_history_patsearch (const char *string, int direction, int flags)
{
char *pat;
size_t len, start;
int ret, unescaped_backslash;
#if defined (HAVE_FNMATCH)
/* Assume that the string passed does not have a leading `^' and any
anchored search request is captured in FLAGS */
len = strlen (string);
ret = len - 1;
/* fnmatch is required to reject a pattern that ends with an unescaped
backslash */
if (unescaped_backslash = (string[ret] == '\\'))
{
while (ret > 0 && string[--ret] == '\\')
unescaped_backslash = 1 - unescaped_backslash;
}
if (unescaped_backslash)
return -1;
pat = (char *)xmalloc (len + 3);
/* If the search string is not anchored, we'll be calling fnmatch (assuming
we have it). Prefix a `*' to the front of the search string so we search
anywhere in the line. */
if ((flags & ANCHORED_SEARCH) == 0 && string[0] != '*')
{
pat[0] = '*';
start = 1;
len++;
}
else
{
start = 0;
}
/* Attempt to reduce the number of searches by tacking a `*' onto the end
of a pattern that doesn't have one. Assume a pattern that ends in a
backslash contains an even number of trailing backslashes; we check
above */
strcpy (pat + start, string);
if (pat[len - 1] != '*')
{
pat[len] = '*'; /* XXX */
pat[len+1] = '\0';
}
#else
pat = string;
#endif
ret = history_search_internal (pat, direction, flags|PATTERN_SEARCH);
if (pat != string)
free (pat);
return ret;
}
/* Do a non-anchored search for STRING through the history in DIRECTION. */ /* Do a non-anchored search for STRING through the history in DIRECTION. */
int int
history_search (string, direction) history_search (const char *string, int direction)
const char *string;
int direction;
{ {
return (history_search_internal (string, direction, NON_ANCHORED_SEARCH)); return (history_search_internal (string, direction, NON_ANCHORED_SEARCH));
} }
/* Do an anchored search for string through the history in DIRECTION. */ /* Do an anchored search for string through the history in DIRECTION. */
int int
history_search_prefix (string, direction) history_search_prefix (const char *string, int direction)
const char *string;
int direction;
{ {
return (history_search_internal (string, direction, ANCHORED_SEARCH)); return (history_search_internal (string, direction, ANCHORED_SEARCH));
} }
@ -175,9 +270,7 @@ history_search_prefix (string, direction)
backwards. POS is an absolute index into the history list at backwards. POS is an absolute index into the history list at
which point to begin searching. */ which point to begin searching. */
int int
history_search_pos (string, dir, pos) history_search_pos (const char *string, int dir, int pos)
const char *string;
int dir, pos;
{ {
int ret, old; int ret, old;

View File

@ -1,6 +1,6 @@
/* input.c -- character input functions for readline. */ /* input.c -- character input functions for readline. */
/* Copyright (C) 1994-2015 Free Software Foundation, Inc. /* Copyright (C) 1994-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -76,6 +76,10 @@ extern int errno;
# define O_NDELAY O_NONBLOCK /* Posix style */ # define O_NDELAY O_NONBLOCK /* Posix style */
#endif #endif
#if defined (HAVE_PSELECT)
extern sigset_t _rl_orig_sigset;
#endif
/* Non-null means it is a pointer to a function to run while waiting for /* Non-null means it is a pointer to a function to run while waiting for
character input. */ character input. */
rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL; rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL;
@ -108,10 +112,10 @@ int w32_isatty (int fd)
{ {
if (_isatty(fd)) if (_isatty(fd))
{ {
HANDLE h = (HANDLE) _get_osfhandle (fd); HANDLE h;
DWORD ignored; DWORD ignored;
if (h == INVALID_HANDLE_VALUE) if ((h = (HANDLE) _get_osfhandle (fd)) == INVALID_HANDLE_VALUE)
{ {
errno = EBADF; errno = EBADF;
return 0; return 0;
@ -139,13 +143,13 @@ static int ibuffer_len = sizeof (ibuffer) - 1;
#define any_typein (push_index != pop_index) #define any_typein (push_index != pop_index)
int int
_rl_any_typein () _rl_any_typein (void)
{ {
return any_typein; return any_typein;
} }
int int
_rl_pushed_input_available () _rl_pushed_input_available (void)
{ {
return (push_index != pop_index); return (push_index != pop_index);
} }
@ -153,7 +157,7 @@ _rl_pushed_input_available ()
/* Return the amount of space available in the buffer for stuffing /* Return the amount of space available in the buffer for stuffing
characters. */ characters. */
static int static int
ibuffer_space () ibuffer_space (void)
{ {
if (pop_index > push_index) if (pop_index > push_index)
return (pop_index - push_index - 1); return (pop_index - push_index - 1);
@ -165,8 +169,7 @@ ibuffer_space ()
Return the key in KEY. Return the key in KEY.
Result is non-zero if there was a key, or 0 if there wasn't. */ Result is non-zero if there was a key, or 0 if there wasn't. */
static int static int
rl_get_char (key) rl_get_char (int *key)
int *key;
{ {
if (push_index == pop_index) if (push_index == pop_index)
return (0); return (0);
@ -186,8 +189,7 @@ rl_get_char (key)
Returns non-zero if successful, zero if there is Returns non-zero if successful, zero if there is
no space left in the buffer. */ no space left in the buffer. */
int int
_rl_unget_char (key) _rl_unget_char (int key)
int key;
{ {
if (ibuffer_space ()) if (ibuffer_space ())
{ {
@ -204,7 +206,7 @@ _rl_unget_char (key)
IBUFFER. Otherwise, just return. Returns number of characters read IBUFFER. Otherwise, just return. Returns number of characters read
(0 if none available) and -1 on error (EIO). */ (0 if none available) and -1 on error (EIO). */
static int static int
rl_gather_tyi () rl_gather_tyi (void)
{ {
int tty; int tty;
register int tem, result; register int tem, result;
@ -307,8 +309,7 @@ rl_gather_tyi ()
} }
int int
rl_set_keyboard_input_timeout (u) rl_set_keyboard_input_timeout (int u)
int u;
{ {
int o; int o;
@ -325,7 +326,7 @@ rl_set_keyboard_input_timeout (u)
the user, it should use _rl_input_queued(timeout_value_in_microseconds) the user, it should use _rl_input_queued(timeout_value_in_microseconds)
instead. */ instead. */
int int
_rl_input_available () _rl_input_available (void)
{ {
#if defined(HAVE_SELECT) #if defined(HAVE_SELECT)
fd_set readfds, exceptfds; fd_set readfds, exceptfds;
@ -367,8 +368,7 @@ _rl_input_available ()
} }
int int
_rl_input_queued (t) _rl_input_queued (int t)
int t;
{ {
int old_timeout, r; int old_timeout, r;
@ -379,8 +379,7 @@ _rl_input_queued (t)
} }
void void
_rl_insert_typein (c) _rl_insert_typein (int c)
int c;
{ {
int key, t, i; int key, t, i;
char *string; char *string;
@ -405,8 +404,7 @@ _rl_insert_typein (c)
/* Add KEY to the buffer of characters to be read. Returns 1 if the /* Add KEY to the buffer of characters to be read. Returns 1 if the
character was stuffed correctly; 0 otherwise. */ character was stuffed correctly; 0 otherwise. */
int int
rl_stuff_char (key) rl_stuff_char (int key)
int key;
{ {
if (ibuffer_space () == 0) if (ibuffer_space () == 0)
return 0; return 0;
@ -430,8 +428,7 @@ rl_stuff_char (key)
/* Make C be the next command to be executed. */ /* Make C be the next command to be executed. */
int int
rl_execute_next (c) rl_execute_next (int c)
int c;
{ {
rl_pending_input = c; rl_pending_input = c;
RL_SETSTATE (RL_STATE_INPUTPENDING); RL_SETSTATE (RL_STATE_INPUTPENDING);
@ -440,7 +437,7 @@ rl_execute_next (c)
/* Clear any pending input pushed with rl_execute_next() */ /* Clear any pending input pushed with rl_execute_next() */
int int
rl_clear_pending_input () rl_clear_pending_input (void)
{ {
rl_pending_input = 0; rl_pending_input = 0;
RL_UNSETSTATE (RL_STATE_INPUTPENDING); RL_UNSETSTATE (RL_STATE_INPUTPENDING);
@ -455,20 +452,20 @@ rl_clear_pending_input ()
/* Read a key, including pending input. */ /* Read a key, including pending input. */
int int
rl_read_key () rl_read_key (void)
{ {
int c, r; int c, r;
if (rl_pending_input) if (rl_pending_input)
{ {
c = rl_pending_input; c = rl_pending_input; /* XXX - cast to unsigned char if > 0? */
rl_clear_pending_input (); rl_clear_pending_input ();
} }
else else
{ {
/* If input is coming from a macro, then use that. */ /* If input is coming from a macro, then use that. */
if (c = _rl_next_macro_key ()) if (c = _rl_next_macro_key ())
return (c); return ((unsigned char)c);
/* If the user has an event function, then call it periodically. */ /* If the user has an event function, then call it periodically. */
if (rl_event_hook) if (rl_event_hook)
@ -505,8 +502,7 @@ rl_read_key ()
} }
int int
rl_getc (stream) rl_getc (FILE *stream)
FILE *stream;
{ {
int result; int result;
unsigned char c; unsigned char c;
@ -527,11 +523,15 @@ rl_getc (stream)
#endif #endif
result = 0; result = 0;
#if defined (HAVE_PSELECT) #if defined (HAVE_PSELECT)
sigemptyset (&empty_set);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &empty_set);
FD_ZERO (&readfds); FD_ZERO (&readfds);
FD_SET (fileno (stream), &readfds); FD_SET (fileno (stream), &readfds);
# if defined (HANDLE_SIGNALS)
result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &_rl_orig_sigset);
# else
sigemptyset (&empty_set);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &empty_set);
result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &empty_set); result = pselect (fileno (stream) + 1, &readfds, NULL, NULL, NULL, &empty_set);
# endif /* HANDLE_SIGNALS */
#endif #endif
if (result >= 0) if (result >= 0)
result = read (fileno (stream), &c, sizeof (unsigned char)); result = read (fileno (stream), &c, sizeof (unsigned char));
@ -618,9 +618,7 @@ handle_error:
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
/* read multibyte char */ /* read multibyte char */
int int
_rl_read_mbchar (mbchar, size) _rl_read_mbchar (char *mbchar, int size)
char *mbchar;
int size;
{ {
int mb_len, c; int mb_len, c;
size_t mbchar_bytes_length; size_t mbchar_bytes_length;
@ -669,12 +667,9 @@ _rl_read_mbchar (mbchar, size)
may be FIRST. Used by the search functions, among others. Very similar may be FIRST. Used by the search functions, among others. Very similar
to _rl_read_mbchar. */ to _rl_read_mbchar. */
int int
_rl_read_mbstring (first, mb, mlen) _rl_read_mbstring (int first, char *mb, int mlen)
int first;
char *mb;
int mlen;
{ {
int i, c; int i, c, n;
mbstate_t ps; mbstate_t ps;
c = first; c = first;
@ -683,7 +678,8 @@ _rl_read_mbstring (first, mb, mlen)
{ {
mb[i] = (char)c; mb[i] = (char)c;
memset (&ps, 0, sizeof (mbstate_t)); memset (&ps, 0, sizeof (mbstate_t));
if (_rl_get_char_len (mb, &ps) == -2) n = _rl_get_char_len (mb, &ps);
if (n == -2)
{ {
/* Read more for multibyte character */ /* Read more for multibyte character */
RL_SETSTATE (RL_STATE_MOREINPUT); RL_SETSTATE (RL_STATE_MOREINPUT);

View File

@ -6,7 +6,7 @@
/* */ /* */
/* **************************************************************** */ /* **************************************************************** */
/* Copyright (C) 1987-2015 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -78,8 +78,7 @@ static int last_isearch_string_len;
static char * const default_isearch_terminators = "\033\012"; static char * const default_isearch_terminators = "\033\012";
_rl_search_cxt * _rl_search_cxt *
_rl_scxt_alloc (type, flags) _rl_scxt_alloc (int type, int flags)
int type, flags;
{ {
_rl_search_cxt *cxt; _rl_search_cxt *cxt;
@ -120,9 +119,7 @@ _rl_scxt_alloc (type, flags)
} }
void void
_rl_scxt_dispose (cxt, flags) _rl_scxt_dispose (_rl_search_cxt *cxt, int flags)
_rl_search_cxt *cxt;
int flags;
{ {
FREE (cxt->search_string); FREE (cxt->search_string);
FREE (cxt->allocated_line); FREE (cxt->allocated_line);
@ -134,8 +131,7 @@ _rl_scxt_dispose (cxt, flags)
/* Search backwards through the history looking for a string which is typed /* Search backwards through the history looking for a string which is typed
interactively. Start with the current line. */ interactively. Start with the current line. */
int int
rl_reverse_search_history (sign, key) rl_reverse_search_history (int sign, int key)
int sign, key;
{ {
return (rl_search_history (-sign, key)); return (rl_search_history (-sign, key));
} }
@ -143,8 +139,7 @@ rl_reverse_search_history (sign, key)
/* Search forwards through the history looking for a string which is typed /* Search forwards through the history looking for a string which is typed
interactively. Start with the current line. */ interactively. Start with the current line. */
int int
rl_forward_search_history (sign, key) rl_forward_search_history (int sign, int key)
int sign, key;
{ {
return (rl_search_history (sign, key)); return (rl_search_history (sign, key));
} }
@ -155,9 +150,7 @@ rl_forward_search_history (sign, key)
WHERE is the history list number of the current line. If it is WHERE is the history list number of the current line. If it is
-1, then this line is the starting one. */ -1, then this line is the starting one. */
static void static void
rl_display_search (search_string, flags, where) rl_display_search (char *search_string, int flags, int where)
char *search_string;
int flags, where;
{ {
char *message; char *message;
int msglen, searchlen; int msglen, searchlen;
@ -206,8 +199,7 @@ rl_display_search (search_string, flags, where)
} }
static _rl_search_cxt * static _rl_search_cxt *
_rl_isearch_init (direction) _rl_isearch_init (int direction)
int direction;
{ {
_rl_search_cxt *cxt; _rl_search_cxt *cxt;
register int i; register int i;
@ -267,11 +259,10 @@ _rl_isearch_init (direction)
} }
static void static void
_rl_isearch_fini (cxt) _rl_isearch_fini (_rl_search_cxt *cxt)
_rl_search_cxt *cxt;
{ {
/* First put back the original state. */ /* First put back the original state. */
strcpy (rl_line_buffer, cxt->lines[cxt->save_line]); rl_replace_line (cxt->lines[cxt->save_line], 0);
rl_restore_prompt (); rl_restore_prompt ();
@ -301,13 +292,13 @@ _rl_isearch_fini (cxt)
rl_point = cxt->sline_index; rl_point = cxt->sline_index;
/* Don't worry about where to put the mark here; rl_get_previous_history /* Don't worry about where to put the mark here; rl_get_previous_history
and rl_get_next_history take care of it. */ and rl_get_next_history take care of it. */
_rl_fix_point (0);
rl_clear_message (); rl_clear_message ();
} }
int int
_rl_search_getchar (cxt) _rl_search_getchar (_rl_search_cxt *cxt)
_rl_search_cxt *cxt;
{ {
int c; int c;
@ -334,11 +325,12 @@ _rl_search_getchar (cxt)
-1 if the caller should just free the context and return, 0 if we should -1 if the caller should just free the context and return, 0 if we should
break out of the loop, and 1 if we should continue to read characters. */ break out of the loop, and 1 if we should continue to read characters. */
int int
_rl_isearch_dispatch (cxt, c) _rl_isearch_dispatch (_rl_search_cxt *cxt, int c)
_rl_search_cxt *cxt;
int c;
{ {
int n, wstart, wlen, limit, cval; int n, wstart, wlen, limit, cval, incr;
char *paste;
size_t pastelen;
int j;
rl_command_func_t *f; rl_command_func_t *f;
f = (rl_command_func_t *)NULL; f = (rl_command_func_t *)NULL;
@ -409,6 +401,8 @@ add_character:
cxt->lastc = -5; cxt->lastc = -5;
else if (c == CTRL ('Y') || f == rl_yank) /* XXX */ else if (c == CTRL ('Y') || f == rl_yank) /* XXX */
cxt->lastc = -6; cxt->lastc = -6;
else if (f == rl_bracketed_paste_begin)
cxt->lastc = -7;
} }
/* If we changed the keymap earlier while translating a key sequence into /* If we changed the keymap earlier while translating a key sequence into
@ -527,7 +521,7 @@ add_character:
} }
return (1); return (1);
} }
else if (cxt->sflags & SF_REVERSE) else if ((cxt->sflags & SF_REVERSE) && cxt->sline_index >= 0)
cxt->sline_index--; cxt->sline_index--;
else if (cxt->sline_index != cxt->sline_len) else if (cxt->sline_index != cxt->sline_len)
cxt->sline_index++; cxt->sline_index++;
@ -631,22 +625,44 @@ add_character:
cxt->search_string[cxt->search_string_index] = '\0'; cxt->search_string[cxt->search_string_index] = '\0';
break; break;
case -7: /* bracketed paste */
paste = _rl_bracketed_text (&pastelen);
if (paste == 0 || *paste == 0)
{
free (paste);
break;
}
if (cxt->search_string_index + pastelen + 1 >= cxt->search_string_size)
{
cxt->search_string_size += pastelen + 2;
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
}
strcpy (cxt->search_string + cxt->search_string_index, paste);
cxt->search_string_index += pastelen;
free (paste);
break;
/* Add character to search string and continue search. */ /* Add character to search string and continue search. */
default: default:
if (cxt->search_string_index + 2 >= cxt->search_string_size) #if defined (HANDLE_MULTIBYTE)
wlen = (cxt->mb[0] == 0 || cxt->mb[1] == 0) ? 1 : RL_STRLEN (cxt->mb);
#else
wlen = 1;
#endif
if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size)
{ {
cxt->search_string_size += 128; cxt->search_string_size += 128; /* 128 much greater than MB_CUR_MAX */
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size); cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
} }
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0) if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{ {
int j, l; int j;
if (cxt->mb[0] == 0 || cxt->mb[1] == 0) if (cxt->mb[0] == 0 || cxt->mb[1] == 0)
cxt->search_string[cxt->search_string_index++] = cxt->mb[0]; cxt->search_string[cxt->search_string_index++] = cxt->mb[0];
else else
for (j = 0, l = RL_STRLEN (cxt->mb); j < l; ) for (j = 0; j < wlen; )
cxt->search_string[cxt->search_string_index++] = cxt->mb[j++]; cxt->search_string[cxt->search_string_index++] = cxt->mb[j++];
} }
else else
@ -676,6 +692,12 @@ add_character:
} }
else else
cxt->sline_index += cxt->direction; cxt->sline_index += cxt->direction;
if (cxt->sline_index < 0)
{
cxt->sline_index = 0;
break;
}
} }
if (cxt->sflags & SF_FOUND) if (cxt->sflags & SF_FOUND)
break; break;
@ -703,7 +725,12 @@ add_character:
(cxt->search_string_index > cxt->sline_len)); (cxt->search_string_index > cxt->sline_len));
if (cxt->sflags & SF_FAILED) if (cxt->sflags & SF_FAILED)
break; {
/* XXX - reset sline_index if < 0 */
if (cxt->sline_index < 0)
cxt->sline_index = 0;
break;
}
/* Now set up the line for searching... */ /* Now set up the line for searching... */
cxt->sline_index = (cxt->sflags & SF_REVERSE) ? cxt->sline_len - cxt->search_string_index : 0; cxt->sline_index = (cxt->sflags & SF_REVERSE) ? cxt->sline_len - cxt->search_string_index : 0;
@ -734,9 +761,7 @@ add_character:
} }
int int
_rl_isearch_cleanup (cxt, r) _rl_isearch_cleanup (_rl_search_cxt *cxt, int r)
_rl_search_cxt *cxt;
int r;
{ {
if (r >= 0) if (r >= 0)
_rl_isearch_fini (cxt); _rl_isearch_fini (cxt);
@ -753,8 +778,7 @@ _rl_isearch_cleanup (cxt, r)
DIRECTION is which direction to search; >= 0 means forward, < 0 means DIRECTION is which direction to search; >= 0 means forward, < 0 means
backwards. */ backwards. */
static int static int
rl_search_history (direction, invoking_key) rl_search_history (int direction, int invoking_key)
int direction, invoking_key;
{ {
_rl_search_cxt *cxt; /* local for now, but saved globally */ _rl_search_cxt *cxt; /* local for now, but saved globally */
int c, r; int c, r;
@ -792,8 +816,7 @@ rl_search_history (direction, invoking_key)
If _rl_isearch_dispatch finishes searching, this function is responsible If _rl_isearch_dispatch finishes searching, this function is responsible
for turning off RL_STATE_ISEARCH, which it does using _rl_isearch_cleanup. */ for turning off RL_STATE_ISEARCH, which it does using _rl_isearch_cleanup. */
int int
_rl_isearch_callback (cxt) _rl_isearch_callback (_rl_search_cxt *cxt)
_rl_search_cxt *cxt;
{ {
int c, r; int c, r;

View File

@ -1,6 +1,6 @@
/* keymaps.c -- Functions and keymaps for the GNU Readline library. */ /* keymaps.c -- Functions and keymaps for the GNU Readline library. */
/* Copyright (C) 1988,1989-2009 Free Software Foundation, Inc. /* Copyright (C) 1988,1989-2009,2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -54,7 +54,7 @@
/* Return a new, empty keymap. /* Return a new, empty keymap.
Free it with free() when you are done. */ Free it with free() when you are done. */
Keymap Keymap
rl_make_bare_keymap () rl_make_bare_keymap (void)
{ {
register int i; register int i;
Keymap keymap; Keymap keymap;
@ -77,11 +77,25 @@ rl_make_bare_keymap ()
return (keymap); return (keymap);
} }
/* A convenience function that returns 1 if there are no keys bound to
functions in KEYMAP */
int
rl_empty_keymap (Keymap keymap)
{
int i;
for (i = 0; i < ANYOTHERKEY; i++)
{
if (keymap[i].type != ISFUNC || keymap[i].function)
return 0;
}
return 1;
}
/* Return a new keymap which is a copy of MAP. Just copies pointers, does /* Return a new keymap which is a copy of MAP. Just copies pointers, does
not copy text of macros or descend into child keymaps. */ not copy text of macros or descend into child keymaps. */
Keymap Keymap
rl_copy_keymap (map) rl_copy_keymap (Keymap map)
Keymap map;
{ {
register int i; register int i;
Keymap temp; Keymap temp;
@ -99,7 +113,7 @@ rl_copy_keymap (map)
the uppercase Meta characters bound to run their lowercase equivalents, the uppercase Meta characters bound to run their lowercase equivalents,
and the Meta digits bound to produce numeric arguments. */ and the Meta digits bound to produce numeric arguments. */
Keymap Keymap
rl_make_keymap () rl_make_keymap (void)
{ {
register int i; register int i;
Keymap newmap; Keymap newmap;
@ -125,8 +139,7 @@ rl_make_keymap ()
/* Free the storage associated with MAP. */ /* Free the storage associated with MAP. */
void void
rl_discard_keymap (map) rl_discard_keymap (Keymap map)
Keymap map;
{ {
int i; int i;
@ -154,8 +167,7 @@ rl_discard_keymap (map)
/* Convenience function that discards, then frees, MAP. */ /* Convenience function that discards, then frees, MAP. */
void void
rl_free_keymap (map) rl_free_keymap (Keymap map)
Keymap map;
{ {
rl_discard_keymap (map); rl_discard_keymap (map);
xfree ((char *)map); xfree ((char *)map);

View File

@ -90,6 +90,9 @@ extern Keymap rl_get_keymap PARAMS((void));
/* Set the current keymap to MAP. */ /* Set the current keymap to MAP. */
extern void rl_set_keymap PARAMS((Keymap)); extern void rl_set_keymap PARAMS((Keymap));
/* Set the name of MAP to NAME */
extern int rl_set_keymap_name PARAMS((const char *, Keymap));
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,6 +1,6 @@
/* kill.c -- kill ring management. */ /* kill.c -- kill ring management. */
/* Copyright (C) 1994-2015 Free Software Foundation, Inc. /* Copyright (C) 1994-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -78,8 +78,7 @@ static int rl_yank_nth_arg_internal PARAMS((int, int, int));
/* How to say that you only want to save a certain amount /* How to say that you only want to save a certain amount
of kill material. */ of kill material. */
int int
rl_set_retained_kills (num) rl_set_retained_kills (int num)
int num;
{ {
return 0; return 0;
} }
@ -89,9 +88,7 @@ rl_set_retained_kills (num)
non-zero, and the last command was a kill, the text is appended to the non-zero, and the last command was a kill, the text is appended to the
current kill ring slot, otherwise prepended. */ current kill ring slot, otherwise prepended. */
static int static int
_rl_copy_to_kill_ring (text, append) _rl_copy_to_kill_ring (char *text, int append)
char *text;
int append;
{ {
char *old, *new; char *old, *new;
int slot; int slot;
@ -122,7 +119,7 @@ _rl_copy_to_kill_ring (text, append)
else else
{ {
slot = rl_kill_ring_length += 1; slot = rl_kill_ring_length += 1;
rl_kill_ring = (char **)xrealloc (rl_kill_ring, slot * sizeof (char *)); rl_kill_ring = (char **)xrealloc (rl_kill_ring, (slot + 1) * sizeof (char *));
} }
rl_kill_ring[--slot] = (char *)NULL; rl_kill_ring[--slot] = (char *)NULL;
} }
@ -131,7 +128,7 @@ _rl_copy_to_kill_ring (text, append)
slot = rl_kill_ring_length - 1; slot = rl_kill_ring_length - 1;
/* If the last command was a kill, prepend or append. */ /* If the last command was a kill, prepend or append. */
if (_rl_last_command_was_kill && rl_editing_mode != vi_mode) if (_rl_last_command_was_kill && rl_kill_ring[slot] && rl_editing_mode != vi_mode)
{ {
old = rl_kill_ring[slot]; old = rl_kill_ring[slot];
new = (char *)xmalloc (1 + strlen (old) + strlen (text)); new = (char *)xmalloc (1 + strlen (old) + strlen (text));
@ -163,8 +160,7 @@ _rl_copy_to_kill_ring (text, append)
last command was not a kill command, then a new slot is made for last command was not a kill command, then a new slot is made for
this kill. */ this kill. */
int int
rl_kill_text (from, to) rl_kill_text (int from, int to)
int from, to;
{ {
char *text; char *text;
@ -198,8 +194,7 @@ rl_kill_text (from, to)
/* Delete the word at point, saving the text in the kill ring. */ /* Delete the word at point, saving the text in the kill ring. */
int int
rl_kill_word (count, key) rl_kill_word (int count, int key)
int count, key;
{ {
int orig_point; int orig_point;
@ -222,17 +217,16 @@ rl_kill_word (count, key)
/* Rubout the word before point, placing it on the kill ring. */ /* Rubout the word before point, placing it on the kill ring. */
int int
rl_backward_kill_word (count, ignore) rl_backward_kill_word (int count, int key)
int count, ignore;
{ {
int orig_point; int orig_point;
if (count < 0) if (count < 0)
return (rl_kill_word (-count, ignore)); return (rl_kill_word (-count, key));
else else
{ {
orig_point = rl_point; orig_point = rl_point;
rl_backward_word (count, ignore); rl_backward_word (count, key);
if (rl_point != orig_point) if (rl_point != orig_point)
rl_kill_text (orig_point, rl_point); rl_kill_text (orig_point, rl_point);
@ -246,17 +240,16 @@ rl_backward_kill_word (count, ignore)
/* Kill from here to the end of the line. If DIRECTION is negative, kill /* Kill from here to the end of the line. If DIRECTION is negative, kill
back to the line start instead. */ back to the line start instead. */
int int
rl_kill_line (direction, ignore) rl_kill_line (int direction, int key)
int direction, ignore;
{ {
int orig_point; int orig_point;
if (direction < 0) if (direction < 0)
return (rl_backward_kill_line (1, ignore)); return (rl_backward_kill_line (1, key));
else else
{ {
orig_point = rl_point; orig_point = rl_point;
rl_end_of_line (1, ignore); rl_end_of_line (1, key);
if (orig_point != rl_point) if (orig_point != rl_point)
rl_kill_text (orig_point, rl_point); rl_kill_text (orig_point, rl_point);
rl_point = orig_point; rl_point = orig_point;
@ -269,13 +262,12 @@ rl_kill_line (direction, ignore)
/* Kill backwards to the start of the line. If DIRECTION is negative, kill /* Kill backwards to the start of the line. If DIRECTION is negative, kill
forwards to the line end instead. */ forwards to the line end instead. */
int int
rl_backward_kill_line (direction, ignore) rl_backward_kill_line (int direction, int key)
int direction, ignore;
{ {
int orig_point; int orig_point;
if (direction < 0) if (direction < 0)
return (rl_kill_line (1, ignore)); return (rl_kill_line (1, key));
else else
{ {
if (rl_point == 0) if (rl_point == 0)
@ -283,7 +275,7 @@ rl_backward_kill_line (direction, ignore)
else else
{ {
orig_point = rl_point; orig_point = rl_point;
rl_beg_of_line (1, ignore); rl_beg_of_line (1, key);
if (rl_point != orig_point) if (rl_point != orig_point)
rl_kill_text (orig_point, rl_point); rl_kill_text (orig_point, rl_point);
if (rl_editing_mode == emacs_mode) if (rl_editing_mode == emacs_mode)
@ -295,8 +287,7 @@ rl_backward_kill_line (direction, ignore)
/* Kill the whole line, no matter where point is. */ /* Kill the whole line, no matter where point is. */
int int
rl_kill_full_line (count, ignore) rl_kill_full_line (int count, int key)
int count, ignore;
{ {
rl_begin_undo_group (); rl_begin_undo_group ();
rl_point = 0; rl_point = 0;
@ -313,8 +304,7 @@ rl_kill_full_line (count, ignore)
/* This does what C-w does in Unix. We can't prevent people from /* This does what C-w does in Unix. We can't prevent people from
using behaviour that they expect. */ using behaviour that they expect. */
int int
rl_unix_word_rubout (count, key) rl_unix_word_rubout (int count, int key)
int count, key;
{ {
int orig_point; int orig_point;
@ -332,7 +322,7 @@ rl_unix_word_rubout (count, key)
rl_point--; rl_point--;
while (rl_point && (whitespace (rl_line_buffer[rl_point - 1]) == 0)) while (rl_point && (whitespace (rl_line_buffer[rl_point - 1]) == 0))
rl_point--; rl_point--; /* XXX - multibyte? */
} }
rl_kill_text (orig_point, rl_point); rl_kill_text (orig_point, rl_point);
@ -346,8 +336,7 @@ rl_unix_word_rubout (count, key)
/* This deletes one filename component in a Unix pathname. That is, it /* This deletes one filename component in a Unix pathname. That is, it
deletes backward to directory separator (`/') or whitespace. */ deletes backward to directory separator (`/') or whitespace. */
int int
rl_unix_filename_rubout (count, key) rl_unix_filename_rubout (int count, int key)
int count, key;
{ {
int orig_point, c; int orig_point, c;
@ -370,7 +359,7 @@ rl_unix_filename_rubout (count, key)
while (rl_point && (whitespace (c) == 0) && c != '/') while (rl_point && (whitespace (c) == 0) && c != '/')
{ {
rl_point--; rl_point--; /* XXX - multibyte? */
c = rl_line_buffer[rl_point - 1]; c = rl_line_buffer[rl_point - 1];
} }
} }
@ -390,8 +379,7 @@ rl_unix_filename_rubout (count, key)
into the line at all, and if you aren't, then you know what you are into the line at all, and if you aren't, then you know what you are
doing. */ doing. */
int int
rl_unix_line_discard (count, key) rl_unix_line_discard (int count, int key)
int count, key;
{ {
if (rl_point == 0) if (rl_point == 0)
rl_ding (); rl_ding ();
@ -408,8 +396,7 @@ rl_unix_line_discard (count, key)
/* Copy the text in the `region' to the kill ring. If DELETE is non-zero, /* Copy the text in the `region' to the kill ring. If DELETE is non-zero,
delete the text from the line as well. */ delete the text from the line as well. */
static int static int
region_kill_internal (delete) region_kill_internal (int delete)
int delete;
{ {
char *text; char *text;
@ -427,16 +414,14 @@ region_kill_internal (delete)
/* Copy the text in the region to the kill ring. */ /* Copy the text in the region to the kill ring. */
int int
rl_copy_region_to_kill (count, ignore) rl_copy_region_to_kill (int count, int key)
int count, ignore;
{ {
return (region_kill_internal (0)); return (region_kill_internal (0));
} }
/* Kill the text between the point and mark. */ /* Kill the text between the point and mark. */
int int
rl_kill_region (count, ignore) rl_kill_region (int count, int key)
int count, ignore;
{ {
int r, npoint; int r, npoint;
@ -450,8 +435,7 @@ rl_kill_region (count, ignore)
/* Copy COUNT words to the kill ring. DIR says which direction we look /* Copy COUNT words to the kill ring. DIR says which direction we look
to find the words. */ to find the words. */
static int static int
_rl_copy_word_as_kill (count, dir) _rl_copy_word_as_kill (int count, int dir)
int count, dir;
{ {
int om, op, r; int om, op, r;
@ -479,8 +463,7 @@ _rl_copy_word_as_kill (count, dir)
} }
int int
rl_copy_forward_word (count, key) rl_copy_forward_word (int count, int key)
int count, key;
{ {
if (count < 0) if (count < 0)
return (rl_copy_backward_word (-count, key)); return (rl_copy_backward_word (-count, key));
@ -489,8 +472,7 @@ rl_copy_forward_word (count, key)
} }
int int
rl_copy_backward_word (count, key) rl_copy_backward_word (int count, int key)
int count, key;
{ {
if (count < 0) if (count < 0)
return (rl_copy_forward_word (-count, key)); return (rl_copy_forward_word (-count, key));
@ -500,8 +482,7 @@ rl_copy_backward_word (count, key)
/* Yank back the last killed text. This ignores arguments. */ /* Yank back the last killed text. This ignores arguments. */
int int
rl_yank (count, ignore) rl_yank (int count, int key)
int count, ignore;
{ {
if (rl_kill_ring == 0) if (rl_kill_ring == 0)
{ {
@ -519,8 +500,7 @@ rl_yank (count, ignore)
delete that text from the line, rotate the index down, and delete that text from the line, rotate the index down, and
yank back some other text. */ yank back some other text. */
int int
rl_yank_pop (count, key) rl_yank_pop (int count, int key)
int count, key;
{ {
int l, n; int l, n;
@ -552,8 +532,7 @@ rl_yank_pop (count, key)
#if defined (VI_MODE) #if defined (VI_MODE)
int int
rl_vi_yank_pop (count, key) rl_vi_yank_pop (int count, int key)
int count, key;
{ {
int l, n; int l, n;
@ -587,8 +566,7 @@ rl_vi_yank_pop (count, key)
/* Yank the COUNTh argument from the previous history line, skipping /* Yank the COUNTh argument from the previous history line, skipping
HISTORY_SKIP lines before looking for the `previous line'. */ HISTORY_SKIP lines before looking for the `previous line'. */
static int static int
rl_yank_nth_arg_internal (count, ignore, history_skip) rl_yank_nth_arg_internal (int count, int key, int history_skip)
int count, ignore, history_skip;
{ {
register HIST_ENTRY *entry; register HIST_ENTRY *entry;
char *arg; char *arg;
@ -629,7 +607,7 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
inserts it right *after* rl_point. */ inserts it right *after* rl_point. */
if (rl_editing_mode == vi_mode) if (rl_editing_mode == vi_mode)
{ {
rl_vi_append_mode (1, ignore); rl_vi_append_mode (1, key);
rl_insert_text (" "); rl_insert_text (" ");
} }
#endif /* VI_MODE */ #endif /* VI_MODE */
@ -643,18 +621,16 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
/* Yank the COUNTth argument from the previous history line. */ /* Yank the COUNTth argument from the previous history line. */
int int
rl_yank_nth_arg (count, ignore) rl_yank_nth_arg (int count, int key)
int count, ignore;
{ {
return (rl_yank_nth_arg_internal (count, ignore, 0)); return (rl_yank_nth_arg_internal (count, key, 0));
} }
/* Yank the last argument from the previous history line. This `knows' /* Yank the last argument from the previous history line. This `knows'
how rl_yank_nth_arg treats a count of `$'. With an argument, this how rl_yank_nth_arg treats a count of `$'. With an argument, this
behaves the same as rl_yank_nth_arg. */ behaves the same as rl_yank_nth_arg. */
int int
rl_yank_last_arg (count, key) rl_yank_last_arg (int count, int key)
int count, key;
{ {
static int history_skip = 0; static int history_skip = 0;
static int explicit_arg_p = 0; static int explicit_arg_p = 0;
@ -694,17 +670,16 @@ rl_yank_last_arg (count, key)
`bracketed paste' sequence, read the rest of the pasted input until the `bracketed paste' sequence, read the rest of the pasted input until the
closing sequence and insert the pasted text as a single unit without closing sequence and insert the pasted text as a single unit without
interpretation. */ interpretation. */
int char *
rl_bracketed_paste_begin (count, key) _rl_bracketed_text (size_t *lenp)
int count, key;
{ {
int retval, c; int c;
size_t len, cap; size_t len, cap;
char *buf; char *buf;
retval = 1;
len = 0; len = 0;
buf = xmalloc (cap = 64); buf = xmalloc (cap = 64);
buf[0] = '\0';
RL_SETSTATE (RL_STATE_MOREINPUT); RL_SETSTATE (RL_STATE_MOREINPUT);
while ((c = rl_read_key ()) >= 0) while ((c = rl_read_key ()) >= 0)
@ -733,20 +708,33 @@ rl_bracketed_paste_begin (count, key)
if (len == cap) if (len == cap)
buf = xrealloc (buf, cap + 1); buf = xrealloc (buf, cap + 1);
buf[len] = '\0'; buf[len] = '\0';
retval = rl_insert_text (buf);
} }
if (lenp)
*lenp = len;
return (buf);
}
int
rl_bracketed_paste_begin (int count, int key)
{
int retval, c;
size_t len, cap;
char *buf;
buf = _rl_bracketed_text (&len);
retval = rl_insert_text (buf) == len ? 0 : 1;
xfree (buf); xfree (buf);
return (retval); return (retval);
} }
/* A special paste command for Windows users.. */ /* A special paste command for Windows users. */
#if defined (_WIN32) #if defined (_WIN32)
#include <windows.h> #include <windows.h>
int int
rl_paste_from_clipboard (count, key) rl_paste_from_clipboard (int count, int key)
int count, key;
{ {
char *data, *ptr; char *data, *ptr;
int len; int len;

View File

@ -1,6 +1,6 @@
/* macro.c -- keyboard macros for readline. */ /* macro.c -- keyboard macros for readline. */
/* Copyright (C) 1994-2009 Free Software Foundation, Inc. /* Copyright (C) 1994-2009,2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -49,6 +49,8 @@
#include "rlprivate.h" #include "rlprivate.h"
#include "xmalloc.h" #include "xmalloc.h"
#define MAX_MACRO_LEVEL 16
/* **************************************************************** */ /* **************************************************************** */
/* */ /* */
/* Hacking Keyboard Macros */ /* Hacking Keyboard Macros */
@ -83,13 +85,24 @@ struct saved_macro {
/* The list of saved macros. */ /* The list of saved macros. */
static struct saved_macro *macro_list = (struct saved_macro *)NULL; static struct saved_macro *macro_list = (struct saved_macro *)NULL;
static int macro_level = 0;
/* Set up to read subsequent input from STRING. /* Set up to read subsequent input from STRING.
STRING is free ()'ed when we are done with it. */ STRING is free ()'ed when we are done with it. */
void void
_rl_with_macro_input (string) _rl_with_macro_input (char *string)
char *string;
{ {
_rl_push_executing_macro (); if (macro_level > MAX_MACRO_LEVEL)
{
_rl_errmsg ("maximum macro execution nesting level exceeded");
_rl_abort_internal ();
return;
}
#if 0
if (rl_executing_macro) /* XXX - later */
#endif
_rl_push_executing_macro ();
rl_executing_macro = string; rl_executing_macro = string;
executing_macro_index = 0; executing_macro_index = 0;
RL_SETSTATE(RL_STATE_MACROINPUT); RL_SETSTATE(RL_STATE_MACROINPUT);
@ -98,7 +111,7 @@ _rl_with_macro_input (string)
/* Return the next character available from a macro, or 0 if /* Return the next character available from a macro, or 0 if
there are no macro characters. */ there are no macro characters. */
int int
_rl_next_macro_key () _rl_next_macro_key (void)
{ {
int c; int c;
@ -117,12 +130,26 @@ _rl_next_macro_key ()
_rl_pop_executing_macro (); _rl_pop_executing_macro ();
return c; return c;
#else #else
/* XXX - consider doing the same as the callback code, just not testing
whether we're running in callback mode */
return (rl_executing_macro[executing_macro_index++]); return (rl_executing_macro[executing_macro_index++]);
#endif #endif
} }
int int
_rl_prev_macro_key () _rl_peek_macro_key (void)
{
if (rl_executing_macro == 0)
return (0);
if (rl_executing_macro[executing_macro_index] == 0 && (macro_list == 0 || macro_list->string == 0))
return (0);
if (rl_executing_macro[executing_macro_index] == 0 && macro_list && macro_list->string)
return (macro_list->string[0]);
return (rl_executing_macro[executing_macro_index]);
}
int
_rl_prev_macro_key (void)
{ {
if (rl_executing_macro == 0) if (rl_executing_macro == 0)
return (0); return (0);
@ -136,7 +163,7 @@ _rl_prev_macro_key ()
/* Save the currently executing macro on a stack of saved macros. */ /* Save the currently executing macro on a stack of saved macros. */
void void
_rl_push_executing_macro () _rl_push_executing_macro (void)
{ {
struct saved_macro *saver; struct saved_macro *saver;
@ -146,12 +173,14 @@ _rl_push_executing_macro ()
saver->string = rl_executing_macro; saver->string = rl_executing_macro;
macro_list = saver; macro_list = saver;
macro_level++;
} }
/* Discard the current macro, replacing it with the one /* Discard the current macro, replacing it with the one
on the top of the stack of saved macros. */ on the top of the stack of saved macros. */
void void
_rl_pop_executing_macro () _rl_pop_executing_macro (void)
{ {
struct saved_macro *macro; struct saved_macro *macro;
@ -168,14 +197,15 @@ _rl_pop_executing_macro ()
xfree (macro); xfree (macro);
} }
macro_level--;
if (rl_executing_macro == 0) if (rl_executing_macro == 0)
RL_UNSETSTATE(RL_STATE_MACROINPUT); RL_UNSETSTATE(RL_STATE_MACROINPUT);
} }
/* Add a character to the macro being built. */ /* Add a character to the macro being built. */
void void
_rl_add_macro_char (c) _rl_add_macro_char (int c)
int c;
{ {
if (current_macro_index + 1 >= current_macro_size) if (current_macro_index + 1 >= current_macro_size)
{ {
@ -190,7 +220,7 @@ _rl_add_macro_char (c)
} }
void void
_rl_kill_kbd_macro () _rl_kill_kbd_macro (void)
{ {
if (current_macro) if (current_macro)
{ {
@ -213,8 +243,7 @@ _rl_kill_kbd_macro ()
definition to the end of the existing macro, and start by definition to the end of the existing macro, and start by
re-executing the existing macro. */ re-executing the existing macro. */
int int
rl_start_kbd_macro (ignore1, ignore2) rl_start_kbd_macro (int ignore1, int ignore2)
int ignore1, ignore2;
{ {
if (RL_ISSTATE (RL_STATE_MACRODEF)) if (RL_ISSTATE (RL_STATE_MACRODEF))
{ {
@ -238,8 +267,7 @@ rl_start_kbd_macro (ignore1, ignore2)
A numeric argument says to execute the macro right now, A numeric argument says to execute the macro right now,
that many times, counting the definition as the first time. */ that many times, counting the definition as the first time. */
int int
rl_end_kbd_macro (count, ignore) rl_end_kbd_macro (int count, int ignore)
int count, ignore;
{ {
if (RL_ISSTATE (RL_STATE_MACRODEF) == 0) if (RL_ISSTATE (RL_STATE_MACRODEF) == 0)
{ {
@ -258,8 +286,7 @@ rl_end_kbd_macro (count, ignore)
/* Execute the most recently defined keyboard macro. /* Execute the most recently defined keyboard macro.
COUNT says how many times to execute it. */ COUNT says how many times to execute it. */
int int
rl_call_last_kbd_macro (count, ignore) rl_call_last_kbd_macro (int count, int ignore)
int count, ignore;
{ {
if (current_macro == 0) if (current_macro == 0)
_rl_abort_internal (); _rl_abort_internal ();
@ -277,8 +304,7 @@ rl_call_last_kbd_macro (count, ignore)
} }
int int
rl_print_last_kbd_macro (count, ignore) rl_print_last_kbd_macro (int count, int ignore)
int count, ignore;
{ {
char *m; char *m;
@ -300,8 +326,7 @@ rl_print_last_kbd_macro (count, ignore)
} }
void void
rl_push_macro_input (macro) rl_push_macro_input (char *macro)
char *macro;
{ {
_rl_with_macro_input (macro); _rl_with_macro_input (macro);
} }

View File

@ -1,6 +1,6 @@
/* mbutil.c -- readline multibyte character utility functions */ /* mbutil.c -- readline multibyte character utility functions */
/* Copyright (C) 2001-2015 Free Software Foundation, Inc. /* Copyright (C) 2001-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -75,10 +75,59 @@ int _rl_utf8locale = 0;
#if defined(HANDLE_MULTIBYTE) #if defined(HANDLE_MULTIBYTE)
/* **************************************************************** */
/* */
/* UTF-8 specific Character Utility Functions */
/* */
/* **************************************************************** */
/* Return the length in bytes of the possibly-multibyte character beginning
at S. Encoding is UTF-8. */
static int static int
_rl_find_next_mbchar_internal (string, seed, count, find_non_zero) _rl_utf8_mblen (const char *s, size_t n)
char *string; {
int seed, count, find_non_zero; unsigned char c, c1;
if (s == 0)
return (0); /* no shift states */
if (n <= 0)
return (-1);
c = (unsigned char)*s;
if (c < 0x80)
return (c != 0);
if (c >= 0xc2)
{
c1 = (unsigned char)s[1];
if (c < 0xe0)
{
if (n >= 2 && (s[1] ^ 0x80) < 0x40)
return 2;
}
else if (c < 0xf0)
{
if (n >= 3
&& (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (c >= 0xe1 || c1 >= 0xa0)
&& (c != 0xed || c1 < 0xa0))
return 3;
}
else if (c < 0xf8)
{
if (n >= 4
&& (s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40
&& (s[3] ^ 0x80) < 0x40
&& (c >= 0xf1 || c1 >= 0x90)
&& (c < 0xf4 || (c == 0xf4 && c1 < 0x90)))
return 4;
}
}
/* invalid or incomplete multibyte character */
return -1;
}
static int
_rl_find_next_mbchar_internal (char *string, int seed, int count, int find_non_zero)
{ {
size_t tmp, len; size_t tmp, len;
mbstate_t ps; mbstate_t ps;
@ -94,6 +143,11 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
return seed; return seed;
point = seed + _rl_adjust_point (string, seed, &ps); point = seed + _rl_adjust_point (string, seed, &ps);
/* if _rl_adjust_point returns -1, the character or string is invalid.
treat as a byte. */
if (point == seed - 1) /* invalid */
return seed + 1;
/* if this is true, means that seed was not pointing to a byte indicating /* if this is true, means that seed was not pointing to a byte indicating
the beginning of a multibyte character. Correct the point and consume the beginning of a multibyte character. Correct the point and consume
one char. */ one char. */
@ -105,7 +159,14 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
len = strlen (string + point); len = strlen (string + point);
if (len == 0) if (len == 0)
break; break;
tmp = mbrtowc (&wc, string+point, len, &ps); if (_rl_utf8locale && UTF8_SINGLEBYTE(string[point]))
{
tmp = 1;
wc = (wchar_t) string[point];
memset(&ps, 0, sizeof(mbstate_t));
}
else
tmp = mbrtowc (&wc, string+point, len, &ps);
if (MB_INVALIDCH ((size_t)tmp)) if (MB_INVALIDCH ((size_t)tmp))
{ {
/* invalid bytes. assume a byte represents a character */ /* invalid bytes. assume a byte represents a character */
@ -146,9 +207,7 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
} }
/*static*/ int /*static*/ int
_rl_find_prev_mbchar_internal (string, seed, find_non_zero) _rl_find_prev_mbchar_internal (char *string, int seed, int find_non_zero)
char *string;
int seed, find_non_zero;
{ {
mbstate_t ps; mbstate_t ps;
int prev, non_zero_prev, point, length; int prev, non_zero_prev, point, length;
@ -166,10 +225,17 @@ _rl_find_prev_mbchar_internal (string, seed, find_non_zero)
prev = non_zero_prev = point = 0; prev = non_zero_prev = point = 0;
while (point < seed) while (point < seed)
{ {
tmp = mbrtowc (&wc, string + point, length - point, &ps); if (_rl_utf8locale && UTF8_SINGLEBYTE(string[point]))
{
tmp = 1;
wc = (wchar_t) string[point];
memset(&ps, 0, sizeof(mbstate_t));
}
else
tmp = mbrtowc (&wc, string + point, length - point, &ps);
if (MB_INVALIDCH ((size_t)tmp)) if (MB_INVALIDCH ((size_t)tmp))
{ {
/* in this case, bytes are invalid or shorted to compose /* in this case, bytes are invalid or too short to compose
multibyte char, so assume that the first byte represents multibyte char, so assume that the first byte represents
a single character anyway. */ a single character anyway. */
tmp = 1; tmp = 1;
@ -206,16 +272,23 @@ _rl_find_prev_mbchar_internal (string, seed, find_non_zero)
if an invalid multibyte sequence was encountered. It returns (size_t)(-2) if an invalid multibyte sequence was encountered. It returns (size_t)(-2)
if it couldn't parse a complete multibyte character. */ if it couldn't parse a complete multibyte character. */
int int
_rl_get_char_len (src, ps) _rl_get_char_len (char *src, mbstate_t *ps)
char *src;
mbstate_t *ps;
{ {
size_t tmp; size_t tmp, l;
int mb_cur_max;
tmp = mbrlen((const char *)src, (size_t)strlen (src), ps); /* Look at no more than MB_CUR_MAX characters */
l = (size_t)strlen (src);
if (_rl_utf8locale && l > 0 && UTF8_SINGLEBYTE(*src))
tmp = (*src != 0) ? 1 : 0;
else
{
mb_cur_max = MB_CUR_MAX;
tmp = mbrlen((const char *)src, (l < mb_cur_max) ? l : mb_cur_max, ps);
}
if (tmp == (size_t)(-2)) if (tmp == (size_t)(-2))
{ {
/* shorted to compose multibyte char */ /* too short to compose multibyte char */
if (ps) if (ps)
memset (ps, 0, sizeof(mbstate_t)); memset (ps, 0, sizeof(mbstate_t));
return -2; return -2;
@ -237,13 +310,7 @@ _rl_get_char_len (src, ps)
/* compare the specified two characters. If the characters matched, /* compare the specified two characters. If the characters matched,
return 1. Otherwise return 0. */ return 1. Otherwise return 0. */
int int
_rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2) _rl_compare_chars (char *buf1, int pos1, mbstate_t *ps1, char *buf2, int pos2, mbstate_t *ps2)
char *buf1;
int pos1;
mbstate_t *ps1;
char *buf2;
int pos2;
mbstate_t *ps2;
{ {
int i, w1, w2; int i, w1, w2;
@ -263,18 +330,16 @@ _rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2)
/* adjust pointed byte and find mbstate of the point of string. /* adjust pointed byte and find mbstate of the point of string.
adjusted point will be point <= adjusted_point, and returns adjusted point will be point <= adjusted_point, and returns
differences of the byte(adjusted_point - point). differences of the byte(adjusted_point - point).
if point is invalied (point < 0 || more than string length), if point is invalid (point < 0 || more than string length),
it returns -1 */ it returns -1 */
int int
_rl_adjust_point (string, point, ps) _rl_adjust_point (char *string, int point, mbstate_t *ps)
char *string;
int point;
mbstate_t *ps;
{ {
size_t tmp = 0; size_t tmp;
int length; int length, pos;
int pos = 0;
tmp = 0;
pos = 0;
length = strlen(string); length = strlen(string);
if (point < 0) if (point < 0)
return -1; return -1;
@ -283,10 +348,13 @@ _rl_adjust_point (string, point, ps)
while (pos < point) while (pos < point)
{ {
tmp = mbrlen (string + pos, length - pos, ps); if (_rl_utf8locale && UTF8_SINGLEBYTE(string[pos]))
tmp = 1;
else
tmp = mbrlen (string + pos, length - pos, ps);
if (MB_INVALIDCH ((size_t)tmp)) if (MB_INVALIDCH ((size_t)tmp))
{ {
/* in this case, bytes are invalid or shorted to compose /* in this case, bytes are invalid or too short to compose
multibyte char, so assume that the first byte represents multibyte char, so assume that the first byte represents
a single character anyway. */ a single character anyway. */
pos++; pos++;
@ -305,11 +373,7 @@ _rl_adjust_point (string, point, ps)
} }
int int
_rl_is_mbchar_matched (string, seed, end, mbchar, length) _rl_is_mbchar_matched (char *string, int seed, int end, char *mbchar, int length)
char *string;
int seed, end;
char *mbchar;
int length;
{ {
int i; int i;
@ -323,9 +387,7 @@ _rl_is_mbchar_matched (string, seed, end, mbchar, length)
} }
wchar_t wchar_t
_rl_char_value (buf, ind) _rl_char_value (char *buf, int ind)
char *buf;
int ind;
{ {
size_t tmp; size_t tmp;
wchar_t wc; wchar_t wc;
@ -334,9 +396,13 @@ _rl_char_value (buf, ind)
if (MB_LEN_MAX == 1 || rl_byte_oriented) if (MB_LEN_MAX == 1 || rl_byte_oriented)
return ((wchar_t) buf[ind]); return ((wchar_t) buf[ind]);
if (_rl_utf8locale && UTF8_SINGLEBYTE(buf[ind]))
return ((wchar_t) buf[ind]);
l = strlen (buf); l = strlen (buf);
if (ind >= l - 1) if (ind >= l - 1)
return ((wchar_t) buf[ind]); return ((wchar_t) buf[ind]);
if (l < ind) /* Sanity check */
l = strlen (buf+ind);
memset (&ps, 0, sizeof (mbstate_t)); memset (&ps, 0, sizeof (mbstate_t));
tmp = mbrtowc (&wc, buf + ind, l - ind, &ps); tmp = mbrtowc (&wc, buf + ind, l - ind, &ps);
if (MB_INVALIDCH (tmp) || MB_NULLWCH (tmp)) if (MB_INVALIDCH (tmp) || MB_NULLWCH (tmp))
@ -350,9 +416,7 @@ _rl_char_value (buf, ind)
characters. */ characters. */
#undef _rl_find_next_mbchar #undef _rl_find_next_mbchar
int int
_rl_find_next_mbchar (string, seed, count, flags) _rl_find_next_mbchar (char *string, int seed, int count, int flags)
char *string;
int seed, count, flags;
{ {
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
return _rl_find_next_mbchar_internal (string, seed, count, flags); return _rl_find_next_mbchar_internal (string, seed, count, flags);
@ -366,9 +430,7 @@ _rl_find_next_mbchar (string, seed, count, flags)
we look for non-zero-width multibyte characters. */ we look for non-zero-width multibyte characters. */
#undef _rl_find_prev_mbchar #undef _rl_find_prev_mbchar
int int
_rl_find_prev_mbchar (string, seed, flags) _rl_find_prev_mbchar (char *string, int seed, int flags)
char *string;
int seed, flags;
{ {
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
return _rl_find_prev_mbchar_internal (string, seed, flags); return _rl_find_prev_mbchar_internal (string, seed, flags);

View File

@ -1,6 +1,6 @@
/* misc.c -- miscellaneous bindable readline functions. */ /* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2015 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -76,7 +76,7 @@ int _rl_history_saved_point = -1;
/* **************************************************************** */ /* **************************************************************** */
int int
_rl_arg_overflow () _rl_arg_overflow (void)
{ {
if (rl_numeric_arg > 1000000) if (rl_numeric_arg > 1000000)
{ {
@ -92,7 +92,7 @@ _rl_arg_overflow ()
} }
void void
_rl_arg_init () _rl_arg_init (void)
{ {
rl_save_prompt (); rl_save_prompt ();
_rl_argcxt = 0; _rl_argcxt = 0;
@ -100,7 +100,7 @@ _rl_arg_init ()
} }
int int
_rl_arg_getchar () _rl_arg_getchar (void)
{ {
int c; int c;
@ -116,9 +116,7 @@ _rl_arg_getchar ()
argument should be aborted, 0 if we should not read any more chars, and argument should be aborted, 0 if we should not read any more chars, and
1 if we should continue to read chars. */ 1 if we should continue to read chars. */
int int
_rl_arg_dispatch (cxt, c) _rl_arg_dispatch (_rl_arg_cxt cxt, int c)
_rl_arg_cxt cxt;
int c;
{ {
int key, r; int key, r;
@ -193,7 +191,7 @@ _rl_arg_dispatch (cxt, c)
/* Handle C-u style numeric args, as well as M--, and M-digits. */ /* Handle C-u style numeric args, as well as M--, and M-digits. */
static int static int
rl_digit_loop () rl_digit_loop (void)
{ {
int c, r; int c, r;
@ -220,7 +218,7 @@ rl_digit_loop ()
/* Create a default argument. */ /* Create a default argument. */
void void
_rl_reset_argument () _rl_reset_argument (void)
{ {
rl_numeric_arg = rl_arg_sign = 1; rl_numeric_arg = rl_arg_sign = 1;
rl_explicit_arg = 0; rl_explicit_arg = 0;
@ -229,8 +227,7 @@ _rl_reset_argument ()
/* Start a numeric argument with initial value KEY */ /* Start a numeric argument with initial value KEY */
int int
rl_digit_argument (ignore, key) rl_digit_argument (int ignore, int key)
int ignore, key;
{ {
_rl_arg_init (); _rl_arg_init ();
if (RL_ISSTATE (RL_STATE_CALLBACK)) if (RL_ISSTATE (RL_STATE_CALLBACK))
@ -250,8 +247,7 @@ rl_digit_argument (ignore, key)
Read a key. If the key has nothing to do with arguments, then Read a key. If the key has nothing to do with arguments, then
dispatch on it. If the key is the abort character then abort. */ dispatch on it. If the key is the abort character then abort. */
int int
rl_universal_argument (count, key) rl_universal_argument (int count, int key)
int count, key;
{ {
_rl_arg_init (); _rl_arg_init ();
rl_numeric_arg *= 4; rl_numeric_arg *= 4;
@ -260,8 +256,7 @@ rl_universal_argument (count, key)
} }
int int
_rl_arg_callback (cxt) _rl_arg_callback (_rl_arg_cxt cxt)
_rl_arg_cxt cxt;
{ {
int c, r; int c, r;
@ -280,12 +275,14 @@ _rl_arg_callback (cxt)
} }
r = _rl_arg_dispatch (cxt, c); r = _rl_arg_dispatch (cxt, c);
if (r > 0)
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
return (r != 1); return (r != 1);
} }
/* What to do when you abort reading an argument. */ /* What to do when you abort reading an argument. */
int int
rl_discard_argument () rl_discard_argument (void)
{ {
rl_ding (); rl_ding ();
rl_clear_message (); rl_clear_message ();
@ -310,7 +307,7 @@ HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
/* Set the history pointer back to the last entry in the history. */ /* Set the history pointer back to the last entry in the history. */
void void
_rl_start_using_history () _rl_start_using_history (void)
{ {
using_history (); using_history ();
if (_rl_saved_line_for_history) if (_rl_saved_line_for_history)
@ -321,8 +318,7 @@ _rl_start_using_history ()
/* Free the contents (and containing structure) of a HIST_ENTRY. */ /* Free the contents (and containing structure) of a HIST_ENTRY. */
void void
_rl_free_history_entry (entry) _rl_free_history_entry (HIST_ENTRY *entry)
HIST_ENTRY *entry;
{ {
if (entry == 0) if (entry == 0)
return; return;
@ -335,7 +331,7 @@ _rl_free_history_entry (entry)
/* Perhaps put back the current line if it has changed. */ /* Perhaps put back the current line if it has changed. */
int int
rl_maybe_replace_line () rl_maybe_replace_line (void)
{ {
HIST_ENTRY *temp; HIST_ENTRY *temp;
@ -353,7 +349,7 @@ rl_maybe_replace_line ()
/* Restore the _rl_saved_line_for_history if there is one. */ /* Restore the _rl_saved_line_for_history if there is one. */
int int
rl_maybe_unsave_line () rl_maybe_unsave_line (void)
{ {
if (_rl_saved_line_for_history) if (_rl_saved_line_for_history)
{ {
@ -372,7 +368,7 @@ rl_maybe_unsave_line ()
/* Save the current line in _rl_saved_line_for_history. */ /* Save the current line in _rl_saved_line_for_history. */
int int
rl_maybe_save_line () rl_maybe_save_line (void)
{ {
if (_rl_saved_line_for_history == 0) if (_rl_saved_line_for_history == 0)
{ {
@ -386,7 +382,7 @@ rl_maybe_save_line ()
} }
int int
_rl_free_saved_history_line () _rl_free_saved_history_line (void)
{ {
if (_rl_saved_line_for_history) if (_rl_saved_line_for_history)
{ {
@ -397,7 +393,7 @@ _rl_free_saved_history_line ()
} }
static void static void
_rl_history_set_point () _rl_history_set_point (void)
{ {
rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1) rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1)
? _rl_history_saved_point ? _rl_history_saved_point
@ -415,9 +411,7 @@ _rl_history_set_point ()
} }
void void
rl_replace_from_history (entry, flags) rl_replace_from_history (HIST_ENTRY *entry, int flags)
HIST_ENTRY *entry;
int flags; /* currently unused */
{ {
/* Can't call with `1' because rl_undo_list might point to an undo list /* Can't call with `1' because rl_undo_list might point to an undo list
from a history entry, just like we're setting up here. */ from a history entry, just like we're setting up here. */
@ -441,7 +435,7 @@ rl_replace_from_history (entry, flags)
intended to be called while actively editing, and the current line is intended to be called while actively editing, and the current line is
not assumed to have been added to the history list. */ not assumed to have been added to the history list. */
void void
_rl_revert_all_lines () _rl_revert_all_lines (void)
{ {
int hpos; int hpos;
HIST_ENTRY *entry; HIST_ENTRY *entry;
@ -490,7 +484,7 @@ _rl_revert_all_lines ()
to an UNDO_LIST * saved as some history entry's data member. This to an UNDO_LIST * saved as some history entry's data member. This
should not be called while editing is active. */ should not be called while editing is active. */
void void
rl_clear_history () rl_clear_history (void)
{ {
HIST_ENTRY **hlist, *hent; HIST_ENTRY **hlist, *hent;
register int i; register int i;
@ -524,16 +518,14 @@ rl_clear_history ()
/* Meta-< goes to the start of the history. */ /* Meta-< goes to the start of the history. */
int int
rl_beginning_of_history (count, key) rl_beginning_of_history (int count, int key)
int count, key;
{ {
return (rl_get_previous_history (1 + where_history (), key)); return (rl_get_previous_history (1 + where_history (), key));
} }
/* Meta-> goes to the end of the history. (The current line). */ /* Meta-> goes to the end of the history. (The current line). */
int int
rl_end_of_history (count, key) rl_end_of_history (int count, int key)
int count, key;
{ {
rl_maybe_replace_line (); rl_maybe_replace_line ();
using_history (); using_history ();
@ -543,8 +535,7 @@ rl_end_of_history (count, key)
/* Move down to the next history line. */ /* Move down to the next history line. */
int int
rl_get_next_history (count, key) rl_get_next_history (int count, int key)
int count, key;
{ {
HIST_ENTRY *temp; HIST_ENTRY *temp;
@ -582,15 +573,14 @@ rl_get_next_history (count, key)
/* Get the previous item out of our interactive history, making it the current /* Get the previous item out of our interactive history, making it the current
line. If there is no previous history, just ding. */ line. If there is no previous history, just ding. */
int int
rl_get_previous_history (count, key) rl_get_previous_history (int count, int key)
int count, key;
{ {
HIST_ENTRY *old_temp, *temp; HIST_ENTRY *old_temp, *temp;
if (count < 0) if (count < 0)
return (rl_get_next_history (-count, key)); return (rl_get_next_history (-count, key));
if (count == 0) if (count == 0 || history_list () == 0)
return 0; return 0;
/* either not saved by rl_newline or at end of line, so set appropriately. */ /* either not saved by rl_newline or at end of line, so set appropriately. */
@ -620,7 +610,10 @@ rl_get_previous_history (count, key)
temp = old_temp; temp = old_temp;
if (temp == 0) if (temp == 0)
rl_ding (); {
rl_maybe_unsave_line ();
rl_ding ();
}
else else
{ {
rl_replace_from_history (temp, 0); rl_replace_from_history (temp, 0);
@ -637,8 +630,7 @@ rl_get_previous_history (count, key)
/* **************************************************************** */ /* **************************************************************** */
/* How to toggle back and forth between editing modes. */ /* How to toggle back and forth between editing modes. */
int int
rl_vi_editing_mode (count, key) rl_vi_editing_mode (int count, int key)
int count, key;
{ {
#if defined (VI_MODE) #if defined (VI_MODE)
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */ _rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
@ -650,8 +642,7 @@ rl_vi_editing_mode (count, key)
} }
int int
rl_emacs_editing_mode (count, key) rl_emacs_editing_mode (int count, int key)
int count, key;
{ {
rl_editing_mode = emacs_mode; rl_editing_mode = emacs_mode;
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */ _rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
@ -665,8 +656,7 @@ rl_emacs_editing_mode (count, key)
/* Function for the rest of the library to use to set insert/overwrite mode. */ /* Function for the rest of the library to use to set insert/overwrite mode. */
void void
_rl_set_insert_mode (im, force) _rl_set_insert_mode (int im, int force)
int im, force;
{ {
#ifdef CURSOR_MODE #ifdef CURSOR_MODE
_rl_set_cursor (im, force); _rl_set_cursor (im, force);
@ -678,8 +668,7 @@ _rl_set_insert_mode (im, force)
/* Toggle overwrite mode. A positive explicit argument selects overwrite /* Toggle overwrite mode. A positive explicit argument selects overwrite
mode. A negative or zero explicit argument selects insert mode. */ mode. A negative or zero explicit argument selects insert mode. */
int int
rl_overwrite_mode (count, key) rl_overwrite_mode (int count, int key)
int count, key;
{ {
if (rl_explicit_arg == 0) if (rl_explicit_arg == 0)
_rl_set_insert_mode (rl_insert_mode ^ 1, 0); _rl_set_insert_mode (rl_insert_mode ^ 1, 0);

View File

@ -1,6 +1,6 @@
/* nls.c -- skeletal internationalization code. */ /* nls.c -- skeletal internationalization code. */
/* Copyright (C) 1996-2009 Free Software Foundation, Inc. /* Copyright (C) 1996-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -74,6 +74,7 @@ static char *legal_lang_values[] =
"iso88599", "iso88599",
"iso885910", "iso885910",
"koi8r", "koi8r",
"utf8",
0 0
}; };
@ -85,8 +86,7 @@ static char *find_codeset PARAMS((char *, size_t *));
static char *_rl_get_locale_var PARAMS((const char *)); static char *_rl_get_locale_var PARAMS((const char *));
static char * static char *
_rl_get_locale_var (v) _rl_get_locale_var (const char *v)
const char *v;
{ {
char *lspec; char *lspec;
@ -100,8 +100,7 @@ _rl_get_locale_var (v)
} }
static int static int
utf8locale (lspec) utf8locale (char *lspec)
char *lspec;
{ {
char *cp; char *cp;
size_t len; size_t len;
@ -118,16 +117,12 @@ utf8locale (lspec)
#endif #endif
} }
/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value /* Query the right environment variables and call setlocale() to initialize
to decide the defaults for 8-bit character input and output. Returns the C library locale settings. */
1 if we set eight-bit mode. */ char *
int _rl_init_locale (void)
_rl_init_eightbit ()
{ {
/* If we have setlocale(3), just check the current LC_CTYPE category char *ret, *lspec;
value, and go into eight-bit mode if it's not C or POSIX. */
#if defined (HAVE_SETLOCALE)
char *lspec, *t;
/* Set the LC_CTYPE locale category from environment variables. */ /* Set the LC_CTYPE locale category from environment variables. */
lspec = _rl_get_locale_var ("LC_CTYPE"); lspec = _rl_get_locale_var ("LC_CTYPE");
@ -140,10 +135,25 @@ _rl_init_eightbit ()
lspec = setlocale (LC_CTYPE, (char *)NULL); lspec = setlocale (LC_CTYPE, (char *)NULL);
if (lspec == 0) if (lspec == 0)
lspec = ""; lspec = "";
t = setlocale (LC_CTYPE, lspec); ret = setlocale (LC_CTYPE, lspec); /* ok, since it does not change locale */
if (t && *t) _rl_utf8locale = (ret && *ret) ? utf8locale (ret) : 0;
_rl_utf8locale = utf8locale (t);
return ret;
}
/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value
to decide the defaults for 8-bit character input and output. Returns
1 if we set eight-bit mode. */
int
_rl_init_eightbit (void)
{
/* If we have setlocale(3), just check the current LC_CTYPE category
value, and go into eight-bit mode if it's not C or POSIX. */
#if defined (HAVE_SETLOCALE)
char *lspec, *t;
t = _rl_init_locale (); /* returns static pointer */
if (t && *t && (t[0] != 'C' || t[1]) && (STREQ (t, "POSIX") == 0)) if (t && *t && (t[0] != 'C' || t[1]) && (STREQ (t, "POSIX") == 0))
{ {
@ -174,16 +184,17 @@ _rl_init_eightbit ()
_rl_output_meta_chars = 1; _rl_output_meta_chars = 1;
break; break;
} }
_rl_utf8locale = *t ? STREQ (t, "utf8") : 0;
xfree (t); xfree (t);
return (legal_lang_values[i] ? 1 : 0); return (legal_lang_values[i] ? 1 : 0);
#endif /* !HAVE_SETLOCALE */ #endif /* !HAVE_SETLOCALE */
} }
#if !defined (HAVE_SETLOCALE) #if !defined (HAVE_SETLOCALE)
static char * static char *
normalize_codeset (codeset) normalize_codeset (char *codeset)
char *codeset;
{ {
size_t namelen, i; size_t namelen, i;
int len, all_digits; int len, all_digits;
@ -230,9 +241,7 @@ normalize_codeset (codeset)
/* Isolate codeset portion of locale specification. */ /* Isolate codeset portion of locale specification. */
static char * static char *
find_codeset (name, lenp) find_codeset (char *name, size_t *lenp)
char *name;
size_t *lenp;
{ {
char *cp, *language, *result; char *cp, *language, *result;

View File

@ -1,6 +1,6 @@
/* parens.c -- implementation of matching parentheses feature. */ /* parens.c -- implementation of matching parentheses feature. */
/* Copyright (C) 1987, 1989, 1992-2015 Free Software Foundation, Inc. /* Copyright (C) 1987, 1989, 1992-2015, 2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -64,8 +64,7 @@ static int _paren_blink_usec = 500000;
/* Change emacs_standard_keymap to have bindings for paren matching when /* 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. */ ON_OR_OFF is 1, change them back to self_insert when ON_OR_OFF == 0. */
void void
_rl_enable_paren_matching (on_or_off) _rl_enable_paren_matching (int on_or_off)
int on_or_off;
{ {
if (on_or_off) if (on_or_off)
{ {
@ -98,8 +97,7 @@ _rl_enable_paren_matching (on_or_off)
} }
int int
rl_set_paren_blink_timeout (u) rl_set_paren_blink_timeout (int u)
int u;
{ {
int o; int o;
@ -110,8 +108,7 @@ rl_set_paren_blink_timeout (u)
} }
int int
rl_insert_close (count, invoking_key) rl_insert_close (int count, int invoking_key)
int count, invoking_key;
{ {
if (rl_explicit_arg || !rl_blink_matching_paren) if (rl_explicit_arg || !rl_blink_matching_paren)
_rl_insert_char (count, invoking_key); _rl_insert_char (count, invoking_key);
@ -148,9 +145,7 @@ rl_insert_close (count, invoking_key)
} }
static int static int
find_matching_open (string, from, closer) find_matching_open (char *string, int from, int closer)
char *string;
int from, closer;
{ {
register int i; register int i;
int opener, level, delimiter; int opener, level, delimiter;

View File

@ -2,8 +2,8 @@
Modified by Chet Ramey for Readline. Modified by Chet Ramey for Readline.
Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012 Free Software Foundation, Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2017
Inc. Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -297,7 +297,7 @@ get_funky_string (char **dest, const char **src, bool equals_end, size_t *output
} }
#endif /* COLOR_SUPPORT */ #endif /* COLOR_SUPPORT */
void _rl_parse_colors() void _rl_parse_colors(void)
{ {
#if defined (COLOR_SUPPORT) #if defined (COLOR_SUPPORT)
const char *p; /* Pointer to character being parsed */ const char *p; /* Pointer to character being parsed */

View File

@ -1,3 +1,3 @@
# Do not edit -- exists only for use by patch # Do not edit -- exists only for use by patch
5 0

View File

@ -1,7 +1,7 @@
/* readline.c -- a general facility for reading lines of input /* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */ with emacs style editing and completion. */
/* Copyright (C) 1987-2016 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -214,6 +214,9 @@ int _rl_eof_char = CTRL ('D');
/* Non-zero makes this the next keystroke to read. */ /* Non-zero makes this the next keystroke to read. */
int rl_pending_input = 0; int rl_pending_input = 0;
/* If non-zero when readline_internal returns, it means we found EOF */
int _rl_eof_found = 0;
/* Pointer to a useful terminal name. */ /* Pointer to a useful terminal name. */
const char *rl_terminal_name = (const char *)NULL; const char *rl_terminal_name = (const char *)NULL;
@ -222,7 +225,7 @@ int _rl_horizontal_scroll_mode = 0;
/* Non-zero means to display an asterisk at the starts of history lines /* Non-zero means to display an asterisk at the starts of history lines
which have been modified. */ which have been modified. */
int _rl_mark_modified_lines = 0; int _rl_mark_modified_lines = 0;
/* The style of `bell' notification preferred. This can be set to NO_BELL, /* The style of `bell' notification preferred. This can be set to NO_BELL,
AUDIBLE_BELL, or VISIBLE_BELL. */ AUDIBLE_BELL, or VISIBLE_BELL. */
@ -242,7 +245,7 @@ int rl_erase_empty_line = 0;
/* Non-zero means to read only this many characters rather than up to a /* Non-zero means to read only this many characters rather than up to a
character bound to accept-line. */ character bound to accept-line. */
int rl_num_chars_to_read; int rl_num_chars_to_read = 0;
/* Line buffer and maintenance. */ /* Line buffer and maintenance. */
char *rl_line_buffer = (char *)NULL; char *rl_line_buffer = (char *)NULL;
@ -325,8 +328,7 @@ int _rl_meta_flag = 0; /* Forward declaration */
/* Set up the prompt and expand it. Called from readline() and /* Set up the prompt and expand it. Called from readline() and
rl_callback_handler_install (). */ rl_callback_handler_install (). */
int int
rl_set_prompt (prompt) rl_set_prompt (const char *prompt)
const char *prompt;
{ {
FREE (rl_prompt); FREE (rl_prompt);
rl_prompt = prompt ? savestring (prompt) : (char *)NULL; rl_prompt = prompt ? savestring (prompt) : (char *)NULL;
@ -339,8 +341,7 @@ rl_set_prompt (prompt)
/* Read a line of input. Prompt with PROMPT. An empty PROMPT means /* Read a line of input. Prompt with PROMPT. An empty PROMPT means
none. A return value of NULL means that EOF was encountered. */ none. A return value of NULL means that EOF was encountered. */
char * char *
readline (prompt) readline (const char *prompt)
const char *prompt;
{ {
char *value; char *value;
#if 0 #if 0
@ -401,7 +402,7 @@ readline (prompt)
#endif #endif
STATIC_CALLBACK void STATIC_CALLBACK void
readline_internal_setup () readline_internal_setup (void)
{ {
char *nprompt; char *nprompt;
@ -419,7 +420,10 @@ readline_internal_setup ()
#if defined (VI_MODE) #if defined (VI_MODE)
if (rl_editing_mode == vi_mode) if (rl_editing_mode == vi_mode)
rl_vi_insertion_mode (1, 'i'); /* don't want to reset last */ rl_vi_insertion_mode (1, 'i'); /* don't want to reset last */
else
#endif /* VI_MODE */ #endif /* VI_MODE */
if (_rl_show_mode_in_prompt)
_rl_reset_prompt ();
/* If we're not echoing, we still want to at least print a prompt, because /* If we're not echoing, we still want to at least print a prompt, because
rl_redisplay will not do it for us. If the calling application has a rl_redisplay will not do it for us. If the calling application has a
@ -450,8 +454,7 @@ readline_internal_setup ()
} }
STATIC_CALLBACK char * STATIC_CALLBACK char *
readline_internal_teardown (eof) readline_internal_teardown (int eof)
int eof;
{ {
char *temp; char *temp;
HIST_ENTRY *entry; HIST_ENTRY *entry;
@ -493,7 +496,7 @@ readline_internal_teardown (eof)
} }
void void
_rl_internal_char_cleanup () _rl_internal_char_cleanup (void)
{ {
#if defined (VI_MODE) #if defined (VI_MODE)
/* In vi mode, when you exit insert mode, the cursor moves back /* In vi mode, when you exit insert mode, the cursor moves back
@ -524,13 +527,13 @@ _rl_internal_char_cleanup ()
STATIC_CALLBACK int STATIC_CALLBACK int
#if defined (READLINE_CALLBACKS) #if defined (READLINE_CALLBACKS)
readline_internal_char () readline_internal_char (void)
#else #else
readline_internal_charloop () readline_internal_charloop (void)
#endif #endif
{ {
static int lastc, eof_found; static int lastc, eof_found;
int c, code, lk; int c, code, lk, r;
lastc = EOF; lastc = EOF;
@ -626,7 +629,7 @@ readline_internal_charloop ()
} }
lastc = c; lastc = c;
_rl_dispatch ((unsigned char)c, _rl_keymap); r = _rl_dispatch ((unsigned char)c, _rl_keymap);
RL_CHECK_SIGNALS (); RL_CHECK_SIGNALS ();
/* If there was no change in _rl_last_command_was_kill, then no kill /* If there was no change in _rl_last_command_was_kill, then no kill
@ -648,7 +651,7 @@ readline_internal_charloop ()
#if defined (READLINE_CALLBACKS) #if defined (READLINE_CALLBACKS)
static int static int
readline_internal_charloop () readline_internal_charloop (void)
{ {
int eof = 1; int eof = 1;
@ -662,17 +665,15 @@ readline_internal_charloop ()
the global rl_outstream. the global rl_outstream.
If rl_prompt is non-null, then that is our prompt. */ If rl_prompt is non-null, then that is our prompt. */
static char * static char *
readline_internal () readline_internal (void)
{ {
int eof;
readline_internal_setup (); readline_internal_setup ();
eof = readline_internal_charloop (); _rl_eof_found = readline_internal_charloop ();
return (readline_internal_teardown (eof)); return (readline_internal_teardown (_rl_eof_found));
} }
void void
_rl_init_line_state () _rl_init_line_state (void)
{ {
rl_point = rl_end = rl_mark = 0; rl_point = rl_end = rl_mark = 0;
the_line = rl_line_buffer; the_line = rl_line_buffer;
@ -680,14 +681,14 @@ _rl_init_line_state ()
} }
void void
_rl_set_the_line () _rl_set_the_line (void)
{ {
the_line = rl_line_buffer; the_line = rl_line_buffer;
} }
#if defined (READLINE_CALLBACKS) #if defined (READLINE_CALLBACKS)
_rl_keyseq_cxt * _rl_keyseq_cxt *
_rl_keyseq_cxt_alloc () _rl_keyseq_cxt_alloc (void)
{ {
_rl_keyseq_cxt *cxt; _rl_keyseq_cxt *cxt;
@ -703,14 +704,13 @@ _rl_keyseq_cxt_alloc ()
} }
void void
_rl_keyseq_cxt_dispose (cxt) _rl_keyseq_cxt_dispose (_rl_keyseq_cxt *cxt)
_rl_keyseq_cxt *cxt;
{ {
xfree (cxt); xfree (cxt);
} }
void void
_rl_keyseq_chain_dispose () _rl_keyseq_chain_dispose (void)
{ {
_rl_keyseq_cxt *cxt; _rl_keyseq_cxt *cxt;
@ -724,8 +724,7 @@ _rl_keyseq_chain_dispose ()
#endif #endif
static int static int
_rl_subseq_getchar (key) _rl_subseq_getchar (int key)
int key;
{ {
int k; int k;
@ -742,8 +741,7 @@ _rl_subseq_getchar (key)
#if defined (READLINE_CALLBACKS) #if defined (READLINE_CALLBACKS)
int int
_rl_dispatch_callback (cxt) _rl_dispatch_callback (_rl_keyseq_cxt *cxt)
_rl_keyseq_cxt *cxt;
{ {
int nkey, r; int nkey, r;
@ -794,19 +792,14 @@ _rl_dispatch_callback (cxt)
If the associated command is really a keymap, then read If the associated command is really a keymap, then read
another key, and dispatch into that map. */ another key, and dispatch into that map. */
int int
_rl_dispatch (key, map) _rl_dispatch (register int key, Keymap map)
register int key;
Keymap map;
{ {
_rl_dispatching_keymap = map; _rl_dispatching_keymap = map;
return _rl_dispatch_subseq (key, map, 0); return _rl_dispatch_subseq (key, map, 0);
} }
int int
_rl_dispatch_subseq (key, map, got_subseq) _rl_dispatch_subseq (register int key, Keymap map, int got_subseq)
register int key;
Keymap map;
int got_subseq;
{ {
int r, newkey; int r, newkey;
char *macro; char *macro;
@ -920,6 +913,15 @@ _rl_dispatch_subseq (key, map, got_subseq)
_rl_pushed_input_available () == 0 && _rl_pushed_input_available () == 0 &&
_rl_input_queued ((_rl_keyseq_timeout > 0) ? _rl_keyseq_timeout*1000 : 0) == 0) _rl_input_queued ((_rl_keyseq_timeout > 0) ? _rl_keyseq_timeout*1000 : 0) == 0)
return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key))); return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key)));
/* This is a very specific test. It can possibly be generalized in
the future, but for now it handles a specific case of ESC being
the last character in a keyboard macro. */
if (rl_editing_mode == vi_mode && key == ESC && map == vi_insertion_keymap &&
(RL_ISSTATE (RL_STATE_INPUTPENDING) == 0) &&
(RL_ISSTATE (RL_STATE_MACROINPUT) && _rl_peek_macro_key () == 0) &&
_rl_pushed_input_available () == 0 &&
_rl_input_queued ((_rl_keyseq_timeout > 0) ? _rl_keyseq_timeout*1000 : 0) == 0)
return (_rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key)));
#endif #endif
RESIZE_KEYSEQ_BUFFER (); RESIZE_KEYSEQ_BUFFER ();
@ -1014,10 +1016,7 @@ _rl_dispatch_subseq (key, map, got_subseq)
} }
static int static int
_rl_subseq_result (r, map, key, got_subseq) _rl_subseq_result (int r, Keymap map, int key, int got_subseq)
int r;
Keymap map;
int key, got_subseq;
{ {
Keymap m; Keymap m;
int type, nt; int type, nt;
@ -1091,11 +1090,11 @@ _rl_subseq_result (r, map, key, got_subseq)
/* Initialize readline (and terminal if not already). */ /* Initialize readline (and terminal if not already). */
int int
rl_initialize () rl_initialize (void)
{ {
/* If we have never been called before, initialize the /* If we have never been called before, initialize the
terminal and data structures. */ terminal and data structures. */
if (!rl_initialized) if (rl_initialized == 0)
{ {
RL_SETSTATE(RL_STATE_INITIALIZING); RL_SETSTATE(RL_STATE_INITIALIZING);
readline_initialize_everything (); readline_initialize_everything ();
@ -1103,6 +1102,8 @@ rl_initialize ()
rl_initialized++; rl_initialized++;
RL_SETSTATE(RL_STATE_INITIALIZED); RL_SETSTATE(RL_STATE_INITIALIZED);
} }
else
(void)_rl_init_locale (); /* check current locale */
/* Initialize the current line information. */ /* Initialize the current line information. */
_rl_init_line_state (); _rl_init_line_state ();
@ -1137,7 +1138,7 @@ rl_initialize ()
#if 0 #if 0
#if defined (__EMX__) #if defined (__EMX__)
static void static void
_emx_build_environ () _emx_build_environ (void)
{ {
TIB *tibp; TIB *tibp;
PIB *pibp; PIB *pibp;
@ -1162,7 +1163,7 @@ _emx_build_environ ()
/* Initialize the entire state of the world. */ /* Initialize the entire state of the world. */
static void static void
readline_initialize_everything () readline_initialize_everything (void)
{ {
#if 0 #if 0
#if defined (__EMX__) #if defined (__EMX__)
@ -1247,7 +1248,7 @@ readline_initialize_everything ()
input editing characters, then bind them to their readline input editing characters, then bind them to their readline
equivalents, iff the characters are not bound to keymaps. */ equivalents, iff the characters are not bound to keymaps. */
static void static void
readline_default_bindings () readline_default_bindings (void)
{ {
if (_rl_bind_stty_chars) if (_rl_bind_stty_chars)
rl_tty_set_default_bindings (_rl_keymap); rl_tty_set_default_bindings (_rl_keymap);
@ -1256,7 +1257,7 @@ readline_default_bindings ()
/* Reset the default bindings for the terminal special characters we're /* Reset the default bindings for the terminal special characters we're
interested in back to rl_insert and read the new ones. */ interested in back to rl_insert and read the new ones. */
static void static void
reset_default_bindings () reset_default_bindings (void)
{ {
if (_rl_bind_stty_chars) if (_rl_bind_stty_chars)
{ {
@ -1267,8 +1268,7 @@ reset_default_bindings ()
/* Bind some common arrow key sequences in MAP. */ /* Bind some common arrow key sequences in MAP. */
static void static void
bind_arrow_keys_internal (map) bind_arrow_keys_internal (Keymap map)
Keymap map;
{ {
Keymap xkeymap; Keymap xkeymap;
@ -1296,6 +1296,15 @@ bind_arrow_keys_internal (map)
rl_bind_keyseq_if_unbound ("\033OH", rl_beg_of_line); rl_bind_keyseq_if_unbound ("\033OH", rl_beg_of_line);
rl_bind_keyseq_if_unbound ("\033OF", rl_end_of_line); rl_bind_keyseq_if_unbound ("\033OF", rl_end_of_line);
/* Key bindings for control-arrow keys */
rl_bind_keyseq_if_unbound ("\033[1;5C", rl_forward_word);
rl_bind_keyseq_if_unbound ("\033[1;5D", rl_backward_word);
rl_bind_keyseq_if_unbound ("\033[3;5~", rl_kill_word);
/* Key bindings for alt-arrow keys */
rl_bind_keyseq_if_unbound ("\033[1;3C", rl_forward_word);
rl_bind_keyseq_if_unbound ("\033[1;3D", rl_backward_word);
#if defined (__MINGW32__) #if defined (__MINGW32__)
rl_bind_keyseq_if_unbound ("\340H", rl_get_previous_history); rl_bind_keyseq_if_unbound ("\340H", rl_get_previous_history);
rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history); rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history);
@ -1324,7 +1333,7 @@ bind_arrow_keys_internal (map)
the inputrc file a chance to bind them and create `real' keymaps the inputrc file a chance to bind them and create `real' keymaps
for the arrow key prefix. */ for the arrow key prefix. */
static void static void
bind_arrow_keys () bind_arrow_keys (void)
{ {
bind_arrow_keys_internal (emacs_standard_keymap); bind_arrow_keys_internal (emacs_standard_keymap);
@ -1339,7 +1348,7 @@ bind_arrow_keys ()
} }
static void static void
bind_bracketed_paste_prefix () bind_bracketed_paste_prefix (void)
{ {
Keymap xkeymap; Keymap xkeymap;
@ -1361,8 +1370,7 @@ bind_bracketed_paste_prefix ()
/* **************************************************************** */ /* **************************************************************** */
int int
rl_save_state (sp) rl_save_state (struct readline_state *sp)
struct readline_state *sp;
{ {
if (sp == 0) if (sp == 0)
return -1; return -1;
@ -1402,8 +1410,7 @@ rl_save_state (sp)
} }
int int
rl_restore_state (sp) rl_restore_state (struct readline_state *sp)
struct readline_state *sp;
{ {
if (sp == 0) if (sp == 0)
return -1; return -1;

View File

@ -39,8 +39,8 @@ extern "C" {
#endif #endif
/* Hex-encoded Readline version number. */ /* Hex-encoded Readline version number. */
#define RL_READLINE_VERSION 0x0700 /* Readline 7.0 */ #define RL_READLINE_VERSION 0x0800 /* Readline 8.0 */
#define RL_VERSION_MAJOR 7 #define RL_VERSION_MAJOR 8
#define RL_VERSION_MINOR 0 #define RL_VERSION_MINOR 0
/* Readline data structures. */ /* Readline data structures. */
@ -98,6 +98,9 @@ extern int rl_clear_screen PARAMS((int, int));
extern int rl_skip_csi_sequence PARAMS((int, int)); extern int rl_skip_csi_sequence PARAMS((int, int));
extern int rl_arrow_keys PARAMS((int, int)); extern int rl_arrow_keys PARAMS((int, int));
extern int rl_previous_screen_line PARAMS((int, int));
extern int rl_next_screen_line PARAMS((int, int));
/* Bindable commands for inserting and deleting text. */ /* Bindable commands for inserting and deleting text. */
extern int rl_insert PARAMS((int, int)); extern int rl_insert PARAMS((int, int));
extern int rl_quoted_insert PARAMS((int, int)); extern int rl_quoted_insert PARAMS((int, int));
@ -329,6 +332,7 @@ extern char *rl_untranslate_keyseq PARAMS((int));
extern rl_command_func_t *rl_named_function PARAMS((const char *)); extern rl_command_func_t *rl_named_function PARAMS((const char *));
extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *)); extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
extern rl_command_func_t *rl_function_of_keyseq_len PARAMS((const char *, size_t, Keymap, int *));
extern void rl_list_funmap_names PARAMS((void)); extern void rl_list_funmap_names PARAMS((void));
extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap)); extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
@ -343,6 +347,7 @@ extern int rl_parse_and_bind PARAMS((char *));
/* Functions for manipulating keymaps. */ /* Functions for manipulating keymaps. */
extern Keymap rl_make_bare_keymap PARAMS((void)); extern Keymap rl_make_bare_keymap PARAMS((void));
extern int rl_empty_keymap PARAMS((Keymap));
extern Keymap rl_copy_keymap PARAMS((Keymap)); extern Keymap rl_copy_keymap PARAMS((Keymap));
extern Keymap rl_make_keymap PARAMS((void)); extern Keymap rl_make_keymap PARAMS((void));
extern void rl_discard_keymap PARAMS((Keymap)); extern void rl_discard_keymap PARAMS((Keymap));
@ -352,6 +357,9 @@ extern Keymap rl_get_keymap_by_name PARAMS((const char *));
extern char *rl_get_keymap_name PARAMS((Keymap)); extern char *rl_get_keymap_name PARAMS((Keymap));
extern void rl_set_keymap PARAMS((Keymap)); extern void rl_set_keymap PARAMS((Keymap));
extern Keymap rl_get_keymap PARAMS((void)); extern Keymap rl_get_keymap PARAMS((void));
extern int rl_set_keymap_name PARAMS((const char *, Keymap));
/* Undocumented; used internally only. */ /* Undocumented; used internally only. */
extern void rl_set_keymap_from_edit_mode PARAMS((void)); extern void rl_set_keymap_from_edit_mode PARAMS((void));
extern char *rl_get_keymap_name_from_edit_mode PARAMS((void)); extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
@ -413,6 +421,7 @@ extern void rl_deprep_terminal PARAMS((void));
extern void rl_tty_set_default_bindings PARAMS((Keymap)); extern void rl_tty_set_default_bindings PARAMS((Keymap));
extern void rl_tty_unset_default_bindings PARAMS((Keymap)); extern void rl_tty_unset_default_bindings PARAMS((Keymap));
extern int rl_tty_set_echoing PARAMS((int));
extern int rl_reset_terminal PARAMS((const char *)); extern int rl_reset_terminal PARAMS((const char *));
extern void rl_resize_terminal PARAMS((void)); extern void rl_resize_terminal PARAMS((void));
extern void rl_set_screen_size PARAMS((int, int)); extern void rl_set_screen_size PARAMS((int, int));
@ -443,6 +452,7 @@ extern void rl_reset_after_signal PARAMS((void));
extern void rl_free_line_state PARAMS((void)); extern void rl_free_line_state PARAMS((void));
extern int rl_pending_signal PARAMS((void)); extern int rl_pending_signal PARAMS((void));
extern void rl_check_signals PARAMS((void));
extern void rl_echo_signal_char PARAMS((int)); extern void rl_echo_signal_char PARAMS((int));

View File

@ -7,6 +7,6 @@ Name: Readline
Description: Gnu Readline library for command line editing Description: Gnu Readline library for command line editing
URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html URL: http://tiswww.cwru.edu/php/chet/readline/rltop.html
Version: @LIBVERSION@ Version: @LIBVERSION@
Requires.private: tinfo Requires.private: @TERMCAP_PKG_CONFIG_LIB@
Libs: -L${libdir} -lreadline Libs: -L${libdir} -lreadline
Cflags: -I${includedir}/readline Cflags: -I${includedir}/readline

View File

@ -42,7 +42,7 @@
/* The next-to-last-ditch effort file name for a user-specific init file. */ /* The next-to-last-ditch effort file name for a user-specific init file. */
#define DEFAULT_INPUTRC "~/.inputrc" #define DEFAULT_INPUTRC "~/.inputrc"
/* The ultimate last-ditch filenname for an init file -- system-wide. */ /* The ultimate last-ditch filename for an init file -- system-wide. */
#define SYS_INPUTRC "/etc/inputrc" #define SYS_INPUTRC "/etc/inputrc"
/* If defined, expand tabs to spaces. */ /* If defined, expand tabs to spaces. */

View File

@ -172,6 +172,10 @@ _rl_wcwidth (wc)
# define IS_COMBINING_CHAR(x) (WCWIDTH(x) == 0) # define IS_COMBINING_CHAR(x) (WCWIDTH(x) == 0)
#endif #endif
#define UTF8_SINGLEBYTE(c) (((c) & 0x80) == 0)
#define UTF8_MBFIRSTCHAR(c) (((c) & 0xc0) == 0xc0)
#define UTF8_MBCHAR(c) (((c) & 0xc0) == 0x80)
#else /* !HANDLE_MULTIBYTE */ #else /* !HANDLE_MULTIBYTE */
#undef MB_LEN_MAX #undef MB_LEN_MAX
@ -196,6 +200,12 @@ _rl_wcwidth (wc)
#define MB_INVALIDCH(x) (0) #define MB_INVALIDCH(x) (0)
#define MB_NULLWCH(x) (0) #define MB_NULLWCH(x) (0)
#define UTF8_SINGLEBYTE(c) (1)
#if !defined (HAVE_WCHAR_T) && !defined (wchar_t)
# define wchar_t int
#endif
#endif /* !HANDLE_MULTIBYTE */ #endif /* !HANDLE_MULTIBYTE */
extern int rl_byte_oriented; extern int rl_byte_oriented;

View File

@ -26,6 +26,7 @@
#include "rlconf.h" /* for VISIBLE_STATS */ #include "rlconf.h" /* for VISIBLE_STATS */
#include "rlstdc.h" #include "rlstdc.h"
#include "posixjmp.h" /* defines procenv_t */ #include "posixjmp.h" /* defines procenv_t */
#include "rlmbutil.h" /* for HANDLE_MULTIBYTE */
/************************************************************************* /*************************************************************************
* * * *
@ -64,6 +65,7 @@
#define SF_FOUND 0x02 #define SF_FOUND 0x02
#define SF_FAILED 0x04 #define SF_FAILED 0x04
#define SF_CHGKMAP 0x08 #define SF_CHGKMAP 0x08
#define SF_PATTERN 0x10 /* unused so far */
typedef struct __rl_search_context typedef struct __rl_search_context
{ {
@ -305,10 +307,13 @@ extern int _rl_search_getchar PARAMS((_rl_search_cxt *));
#define BRACK_PASTE_SLEN 6 #define BRACK_PASTE_SLEN 6
#define BRACK_PASTE_INIT "\033[?2004h" #define BRACK_PASTE_INIT "\033[?2004h"
#define BRACK_PASTE_FINI "\033[?2004l" #define BRACK_PASTE_FINI "\033[?2004l\r"
extern char *_rl_bracketed_text PARAMS((size_t *));
/* macro.c */ /* macro.c */
extern void _rl_with_macro_input PARAMS((char *)); extern void _rl_with_macro_input PARAMS((char *));
extern int _rl_peek_macro_key PARAMS((void));
extern int _rl_next_macro_key PARAMS((void)); extern int _rl_next_macro_key PARAMS((void));
extern int _rl_prev_macro_key PARAMS((void)); extern int _rl_prev_macro_key PARAMS((void));
extern void _rl_push_executing_macro PARAMS((void)); extern void _rl_push_executing_macro PARAMS((void));
@ -330,6 +335,7 @@ extern void _rl_set_insert_mode PARAMS((int, int));
extern void _rl_revert_all_lines PARAMS((void)); extern void _rl_revert_all_lines PARAMS((void));
/* nls.c */ /* nls.c */
extern char *_rl_init_locale PARAMS((void));
extern int _rl_init_eightbit PARAMS((void)); extern int _rl_init_eightbit PARAMS((void));
/* parens.c */ /* parens.c */
@ -378,6 +384,7 @@ extern void _rl_set_cursor PARAMS((int, int));
extern void _rl_fix_point PARAMS((int)); extern void _rl_fix_point PARAMS((int));
extern int _rl_replace_text PARAMS((const char *, int, int)); extern int _rl_replace_text PARAMS((const char *, int, int));
extern int _rl_forward_char_internal PARAMS((int)); extern int _rl_forward_char_internal PARAMS((int));
extern int _rl_backward_char_internal PARAMS((int));
extern int _rl_insert_char PARAMS((int, int)); extern int _rl_insert_char PARAMS((int, int));
extern int _rl_overwrite_char PARAMS((int, int)); extern int _rl_overwrite_char PARAMS((int, int));
extern int _rl_overwrite_rubout PARAMS((int, int)); extern int _rl_overwrite_rubout PARAMS((int, int));
@ -507,6 +514,7 @@ extern FILE *_rl_in_stream;
extern FILE *_rl_out_stream; extern FILE *_rl_out_stream;
extern int _rl_last_command_was_kill; extern int _rl_last_command_was_kill;
extern int _rl_eof_char; extern int _rl_eof_char;
extern int _rl_eof_found;
extern procenv_t _rl_top_level; extern procenv_t _rl_top_level;
extern _rl_keyseq_cxt *_rl_kscxt; extern _rl_keyseq_cxt *_rl_kscxt;
extern int _rl_keyseq_timeout; extern int _rl_keyseq_timeout;
@ -534,6 +542,7 @@ extern int _rl_enable_keypad;
extern int _rl_enable_meta; extern int _rl_enable_meta;
extern char *_rl_term_clreol; extern char *_rl_term_clreol;
extern char *_rl_term_clrpag; extern char *_rl_term_clrpag;
extern char *_rl_term_clrscroll;
extern char *_rl_term_im; extern char *_rl_term_im;
extern char *_rl_term_ic; extern char *_rl_term_ic;
extern char *_rl_term_ei; extern char *_rl_term_ei;

View File

@ -1,7 +1,7 @@
/* rltty.c -- functions to prepare and restore the terminal for readline's /* rltty.c -- functions to prepare and restore the terminal for readline's
use. */ use. */
/* Copyright (C) 1992-2016 Free Software Foundation, Inc. /* Copyright (C) 1992-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -130,8 +130,7 @@ static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t *)); static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t *));
static void static void
save_tty_chars (tiop) save_tty_chars (TIOTYPE *tiop)
TIOTYPE *tiop;
{ {
_rl_last_tty_chars = _rl_tty_chars; _rl_last_tty_chars = _rl_tty_chars;
@ -168,9 +167,7 @@ save_tty_chars (tiop)
} }
static int static int
get_tty_settings (tty, tiop) get_tty_settings (int tty, TIOTYPE *tiop)
int tty;
TIOTYPE *tiop;
{ {
set_winsize (tty); set_winsize (tty);
@ -200,9 +197,7 @@ get_tty_settings (tty, tiop)
} }
static int static int
set_tty_settings (tty, tiop) set_tty_settings (int tty, TIOTYPE *tiop)
int tty;
TIOTYPE *tiop;
{ {
if (tiop->flags & SGTTY_SET) if (tiop->flags & SGTTY_SET)
{ {
@ -239,9 +234,7 @@ set_tty_settings (tty, tiop)
} }
static void static void
prepare_terminal_settings (meta_flag, oldtio, tiop) prepare_terminal_settings (int meta_flag, TIOTYPE oldtio, TIOTYPE *tiop)
int meta_flag;
TIOTYPE oldtio, *tiop;
{ {
_rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO); _rl_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
_rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL); _rl_echoctl = (oldtio.sgttyb.sg_flags & ECHOCTL);
@ -357,8 +350,7 @@ static void _rl_bind_tty_special_chars PARAMS((Keymap, TIOTYPE));
#endif #endif
static void static void
save_tty_chars (tiop) save_tty_chars (TIOTYPE *tiop)
TIOTYPE *tiop;
{ {
_rl_last_tty_chars = _rl_tty_chars; _rl_last_tty_chars = _rl_tty_chars;
@ -403,8 +395,7 @@ save_tty_chars (tiop)
#if defined (_AIX) || defined (_AIX41) #if defined (_AIX) || defined (_AIX41)
/* Currently this is only used on AIX */ /* Currently this is only used on AIX */
static void static void
rltty_warning (msg) rltty_warning (char *msg)
char *msg;
{ {
_rl_errmsg ("warning: %s", msg); _rl_errmsg ("warning: %s", msg);
} }
@ -412,8 +403,7 @@ rltty_warning (msg)
#if defined (_AIX) #if defined (_AIX)
void void
setopost(tp) setopost (TIOTYPE *tp)
TIOTYPE *tp;
{ {
if ((tp->c_oflag & OPOST) == 0) if ((tp->c_oflag & OPOST) == 0)
{ {
@ -424,9 +414,7 @@ TIOTYPE *tp;
#endif #endif
static int static int
_get_tty_settings (tty, tiop) _get_tty_settings (int tty, TIOTYPE *tiop)
int tty;
TIOTYPE *tiop;
{ {
int ioctl_ret; int ioctl_ret;
@ -457,9 +445,7 @@ _get_tty_settings (tty, tiop)
} }
static int static int
get_tty_settings (tty, tiop) get_tty_settings (int tty, TIOTYPE *tiop)
int tty;
TIOTYPE *tiop;
{ {
set_winsize (tty); set_winsize (tty);
@ -475,9 +461,7 @@ get_tty_settings (tty, tiop)
} }
static int static int
_set_tty_settings (tty, tiop) _set_tty_settings (int tty, TIOTYPE *tiop)
int tty;
TIOTYPE *tiop;
{ {
while (SETATTR (tty, tiop) < 0) while (SETATTR (tty, tiop) < 0)
{ {
@ -489,9 +473,7 @@ _set_tty_settings (tty, tiop)
} }
static int static int
set_tty_settings (tty, tiop) set_tty_settings (int tty, TIOTYPE *tiop)
int tty;
TIOTYPE *tiop;
{ {
if (_set_tty_settings (tty, tiop) < 0) if (_set_tty_settings (tty, tiop) < 0)
return -1; return -1;
@ -518,10 +500,11 @@ set_tty_settings (tty, tiop)
} }
static void static void
prepare_terminal_settings (meta_flag, oldtio, tiop) prepare_terminal_settings (int meta_flag, TIOTYPE oldtio, TIOTYPE *tiop)
int meta_flag;
TIOTYPE oldtio, *tiop;
{ {
int sc;
Keymap kmap;
_rl_echoing_p = (oldtio.c_lflag & ECHO); _rl_echoing_p = (oldtio.c_lflag & ECHO);
#if defined (ECHOCTL) #if defined (ECHOCTL)
_rl_echoctl = (oldtio.c_lflag & ECHOCTL); _rl_echoctl = (oldtio.c_lflag & ECHOCTL);
@ -578,6 +561,20 @@ prepare_terminal_settings (meta_flag, oldtio, tiop)
tiop->c_cc[VDSUSP] = _POSIX_VDISABLE; tiop->c_cc[VDSUSP] = _POSIX_VDISABLE;
#endif #endif
/* Conditionally disable some other tty special characters if there is a
key binding for them in the current keymap. Readline ordinarily doesn't
bind these characters, but an application or user might. */
#if defined (VI_MODE)
kmap = (rl_editing_mode == vi_mode) ? vi_insertion_keymap : _rl_keymap;
#else
kmap = _rl_keymap;
#endif
#if defined (VDISCARD)
sc = tiop->c_cc[VDISCARD];
if (sc != _POSIX_VDISABLE && kmap[(unsigned char)sc].type == ISFUNC)
tiop->c_cc[VDISCARD] = _POSIX_VDISABLE;
#endif /* VDISCARD */
#endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */ #endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */
} }
#endif /* !NEW_TTY_DRIVER */ #endif /* !NEW_TTY_DRIVER */
@ -585,21 +582,19 @@ prepare_terminal_settings (meta_flag, oldtio, tiop)
/* Put the terminal in CBREAK mode so that we can detect key presses. */ /* Put the terminal in CBREAK mode so that we can detect key presses. */
#if defined (NO_TTY_DRIVER) #if defined (NO_TTY_DRIVER)
void void
rl_prep_terminal (meta_flag) rl_prep_terminal (int meta_flag)
int meta_flag;
{ {
_rl_echoing_p = 1; _rl_echoing_p = 1;
} }
void void
rl_deprep_terminal () rl_deprep_terminal (void)
{ {
} }
#else /* ! NO_TTY_DRIVER */ #else /* ! NO_TTY_DRIVER */
void void
rl_prep_terminal (meta_flag) rl_prep_terminal (int meta_flag)
int meta_flag;
{ {
int tty, nprep; int tty, nprep;
TIOTYPE tio; TIOTYPE tio;
@ -682,7 +677,7 @@ rl_prep_terminal (meta_flag)
/* Restore the terminal's normal settings and modes. */ /* Restore the terminal's normal settings and modes. */
void void
rl_deprep_terminal () rl_deprep_terminal (void)
{ {
int tty; int tty;
@ -695,7 +690,11 @@ rl_deprep_terminal ()
tty = rl_instream ? fileno (rl_instream) : fileno (stdin); tty = rl_instream ? fileno (rl_instream) : fileno (stdin);
if (terminal_prepped & TPX_BRACKPASTE) if (terminal_prepped & TPX_BRACKPASTE)
fprintf (rl_outstream, BRACK_PASTE_FINI); {
fprintf (rl_outstream, BRACK_PASTE_FINI);
if (_rl_eof_found)
fprintf (rl_outstream, "\n");
}
if (_rl_enable_keypad) if (_rl_enable_keypad)
_rl_control_keypad (0); _rl_control_keypad (0);
@ -718,8 +717,7 @@ rl_deprep_terminal ()
/* Set readline's idea of whether or not it is echoing output to the terminal, /* Set readline's idea of whether or not it is echoing output to the terminal,
returning the old value. */ returning the old value. */
int int
rl_tty_set_echoing (u) rl_tty_set_echoing (int u)
int u;
{ {
int o; int o;
@ -735,8 +733,7 @@ rl_tty_set_echoing (u)
/* **************************************************************** */ /* **************************************************************** */
int int
rl_restart_output (count, key) rl_restart_output (int count, int key)
int count, key;
{ {
#if defined (__MINGW32__) #if defined (__MINGW32__)
return 0; return 0;
@ -773,8 +770,7 @@ rl_restart_output (count, key)
} }
int int
rl_stop_output (count, key) rl_stop_output (int count, int key)
int count, key;
{ {
#if defined (__MINGW32__) #if defined (__MINGW32__)
return 0; return 0;
@ -822,11 +818,7 @@ rl_stop_output (count, key)
#elif defined (NEW_TTY_DRIVER) #elif defined (NEW_TTY_DRIVER)
static void static void
set_special_char (kmap, tiop, sc, func) set_special_char (Keymap kmap, TIOTYPE *tiop, int sc, rl_command_func_t *func)
Keymap kmap;
TIOTYPE *tiop;
int sc;
rl_command_func_t *func;
{ {
if (sc != -1 && kmap[(unsigned char)sc].type == ISFUNC) if (sc != -1 && kmap[(unsigned char)sc].type == ISFUNC)
kmap[(unsigned char)sc].function = func; kmap[(unsigned char)sc].function = func;
@ -837,9 +829,7 @@ set_special_char (kmap, tiop, sc, func)
kmap[(unsigned char)c].function = rl_insert; kmap[(unsigned char)c].function = rl_insert;
static void static void
_rl_bind_tty_special_chars (kmap, ttybuff) _rl_bind_tty_special_chars (Keymap kmap, TIOTYPE ttybuff)
Keymap kmap;
TIOTYPE ttybuff;
{ {
if (ttybuff.flags & SGTTY_SET) if (ttybuff.flags & SGTTY_SET)
{ {
@ -858,11 +848,7 @@ _rl_bind_tty_special_chars (kmap, ttybuff)
#else /* !NEW_TTY_DRIVER */ #else /* !NEW_TTY_DRIVER */
static void static void
set_special_char (kmap, tiop, sc, func) set_special_char (Keymap kmap, TIOTYPE *tiop, int sc, rl_command_func_t *func)
Keymap kmap;
TIOTYPE *tiop;
int sc;
rl_command_func_t *func;
{ {
unsigned char uc; unsigned char uc;
@ -877,9 +863,7 @@ set_special_char (kmap, tiop, sc, func)
kmap[uc].function = rl_insert; kmap[uc].function = rl_insert;
static void static void
_rl_bind_tty_special_chars (kmap, ttybuff) _rl_bind_tty_special_chars (Keymap kmap, TIOTYPE ttybuff)
Keymap kmap;
TIOTYPE ttybuff;
{ {
SET_SPECIAL (VERASE, rl_rubout); SET_SPECIAL (VERASE, rl_rubout);
SET_SPECIAL (VKILL, rl_unix_line_discard); SET_SPECIAL (VKILL, rl_unix_line_discard);
@ -903,8 +887,7 @@ _rl_bind_tty_special_chars (kmap, ttybuff)
/* Set the system's default editing characters to their readline equivalents /* 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. */ in KMAP. Should be static, now that we have rl_tty_set_default_bindings. */
void void
rltty_set_default_bindings (kmap) rltty_set_default_bindings (Keymap kmap)
Keymap kmap;
{ {
#if !defined (NO_TTY_DRIVER) #if !defined (NO_TTY_DRIVER)
TIOTYPE ttybuff; TIOTYPE ttybuff;
@ -920,8 +903,7 @@ rltty_set_default_bindings (kmap)
/* New public way to set the system default editing chars to their readline /* New public way to set the system default editing chars to their readline
equivalents. */ equivalents. */
void void
rl_tty_set_default_bindings (kmap) rl_tty_set_default_bindings (Keymap kmap)
Keymap kmap;
{ {
rltty_set_default_bindings (kmap); rltty_set_default_bindings (kmap);
} }
@ -931,8 +913,7 @@ rl_tty_set_default_bindings (kmap)
chars with save_tty_chars(). This only works on POSIX termios or termio chars with save_tty_chars(). This only works on POSIX termios or termio
systems. */ systems. */
void void
rl_tty_unset_default_bindings (kmap) rl_tty_unset_default_bindings (Keymap kmap)
Keymap kmap;
{ {
/* Don't bother before we've saved the tty special chars at least once. */ /* Don't bother before we've saved the tty special chars at least once. */
if (RL_ISSTATE(RL_STATE_TTYCSAVED) == 0) if (RL_ISSTATE(RL_STATE_TTYCSAVED) == 0)
@ -954,13 +935,13 @@ rl_tty_unset_default_bindings (kmap)
#if defined (NEW_TTY_DRIVER) || defined (NO_TTY_DRIVER) #if defined (NEW_TTY_DRIVER) || defined (NO_TTY_DRIVER)
int int
_rl_disable_tty_signals () _rl_disable_tty_signals (void)
{ {
return 0; return 0;
} }
int int
_rl_restore_tty_signals () _rl_restore_tty_signals (void)
{ {
return 0; return 0;
} }
@ -970,7 +951,7 @@ static TIOTYPE sigstty, nosigstty;
static int tty_sigs_disabled = 0; static int tty_sigs_disabled = 0;
int int
_rl_disable_tty_signals () _rl_disable_tty_signals (void)
{ {
if (tty_sigs_disabled) if (tty_sigs_disabled)
return 0; return 0;
@ -991,7 +972,7 @@ _rl_disable_tty_signals ()
} }
int int
_rl_restore_tty_signals () _rl_restore_tty_signals (void)
{ {
int r; int r;

View File

@ -1,6 +1,6 @@
/* savestring.c - function version of savestring for backwards compatibility */ /* savestring.c - function version of savestring for backwards compatibility */
/* Copyright (C) 1998,2003 Free Software Foundation, Inc. /* Copyright (C) 1998,2003,2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -30,8 +30,7 @@
/* Backwards compatibility, now that savestring has been removed from /* Backwards compatibility, now that savestring has been removed from
all `public' readline header files. */ all `public' readline header files. */
char * char *
savestring (s) savestring (const char *s)
const char *s;
{ {
char *ret; char *ret;

View File

@ -1,6 +1,6 @@
/* search.c - code for non-incremental searching in emacs and vi modes. */ /* search.c - code for non-incremental searching in emacs and vi modes. */
/* Copyright (C) 1992-2015 Free Software Foundation, Inc. /* Copyright (C) 1992-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -73,8 +73,8 @@ static char *history_search_string;
static int history_string_size; static int history_string_size;
static void make_history_line_current PARAMS((HIST_ENTRY *)); static void make_history_line_current PARAMS((HIST_ENTRY *));
static int noninc_search_from_pos PARAMS((char *, int, int)); static int noninc_search_from_pos PARAMS((char *, int, int, int, int *));
static int noninc_dosearch PARAMS((char *, int)); static int noninc_dosearch PARAMS((char *, int, int));
static int noninc_search PARAMS((int, int)); static int noninc_search PARAMS((int, int));
static int rl_history_search_internal PARAMS((int, int)); static int rl_history_search_internal PARAMS((int, int));
static void rl_history_search_reinit PARAMS((int)); static void rl_history_search_reinit PARAMS((int));
@ -87,8 +87,7 @@ static int _rl_nsearch_dispatch PARAMS((_rl_search_cxt *, int));
current line. This doesn't do anything with rl_point; the caller current line. This doesn't do anything with rl_point; the caller
must set it. */ must set it. */
static void static void
make_history_line_current (entry) make_history_line_current (HIST_ENTRY *entry)
HIST_ENTRY *entry;
{ {
_rl_replace_text (entry->line, 0, rl_end); _rl_replace_text (entry->line, 0, rl_end);
_rl_fix_point (1); _rl_fix_point (1);
@ -112,11 +111,10 @@ make_history_line_current (entry)
for STRING. DIR < 0 means to search backwards through the history list, for STRING. DIR < 0 means to search backwards through the history list,
DIR >= 0 means to search forward. */ DIR >= 0 means to search forward. */
static int static int
noninc_search_from_pos (string, pos, dir) noninc_search_from_pos (char *string, int pos, int dir, int flags, int *ncp)
char *string;
int pos, dir;
{ {
int ret, old; int ret, old, sflags;
char *s;
if (pos < 0) if (pos < 0)
return -1; return -1;
@ -126,12 +124,28 @@ noninc_search_from_pos (string, pos, dir)
return -1; return -1;
RL_SETSTATE(RL_STATE_SEARCH); RL_SETSTATE(RL_STATE_SEARCH);
if (*string == '^') /* These functions return the match offset in the line; history_offset gives
the matching line in the history list */
if (flags & SF_PATTERN)
{
s = string;
sflags = 0; /* Non-anchored search */
if (*s == '^')
{
sflags |= ANCHORED_SEARCH;
s++;
}
ret = _hs_history_patsearch (s, dir, sflags);
}
else if (*string == '^')
ret = history_search_prefix (string + 1, dir); ret = history_search_prefix (string + 1, dir);
else else
ret = history_search (string, dir); ret = history_search (string, dir);
RL_UNSETSTATE(RL_STATE_SEARCH); RL_UNSETSTATE(RL_STATE_SEARCH);
if (ncp)
*ncp = ret; /* caller will catch -1 to indicate no-op */
if (ret != -1) if (ret != -1)
ret = where_history (); ret = where_history ();
@ -143,9 +157,7 @@ noninc_search_from_pos (string, pos, dir)
search is backwards through previous entries, else through subsequent search is backwards through previous entries, else through subsequent
entries. Returns 1 if the search was successful, 0 otherwise. */ entries. Returns 1 if the search was successful, 0 otherwise. */
static int static int
noninc_dosearch (string, dir) noninc_dosearch (char *string, int dir, int flags)
char *string;
int dir;
{ {
int oldpos, pos; int oldpos, pos;
HIST_ENTRY *entry; HIST_ENTRY *entry;
@ -156,7 +168,7 @@ noninc_dosearch (string, dir)
return 0; return 0;
} }
pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir); pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir, flags, (int *)0);
if (pos == -1) if (pos == -1)
{ {
/* Search failed, current history position unchanged. */ /* Search failed, current history position unchanged. */
@ -188,8 +200,7 @@ noninc_dosearch (string, dir)
} }
static _rl_search_cxt * static _rl_search_cxt *
_rl_nsearch_init (dir, pchar) _rl_nsearch_init (int dir, int pchar)
int dir, pchar;
{ {
_rl_search_cxt *cxt; _rl_search_cxt *cxt;
char *p; char *p;
@ -197,6 +208,10 @@ _rl_nsearch_init (dir, pchar)
cxt = _rl_scxt_alloc (RL_SEARCH_NSEARCH, 0); cxt = _rl_scxt_alloc (RL_SEARCH_NSEARCH, 0);
if (dir < 0) if (dir < 0)
cxt->sflags |= SF_REVERSE; /* not strictly needed */ cxt->sflags |= SF_REVERSE; /* not strictly needed */
#if defined (VI_MODE)
if (VI_COMMAND_MODE() && (pchar == '?' || pchar == '/'))
cxt->sflags |= SF_PATTERN;
#endif
cxt->direction = dir; cxt->direction = dir;
cxt->history_pos = cxt->save_line; cxt->history_pos = cxt->save_line;
@ -224,9 +239,7 @@ _rl_nsearch_init (dir, pchar)
} }
int int
_rl_nsearch_cleanup (cxt, r) _rl_nsearch_cleanup (_rl_search_cxt *cxt, int r)
_rl_search_cxt *cxt;
int r;
{ {
_rl_scxt_dispose (cxt, 0); _rl_scxt_dispose (cxt, 0);
_rl_nscxt = 0; _rl_nscxt = 0;
@ -237,8 +250,7 @@ _rl_nsearch_cleanup (cxt, r)
} }
static void static void
_rl_nsearch_abort (cxt) _rl_nsearch_abort (_rl_search_cxt *cxt)
_rl_search_cxt *cxt;
{ {
rl_maybe_unsave_line (); rl_maybe_unsave_line ();
rl_clear_message (); rl_clear_message ();
@ -253,10 +265,11 @@ _rl_nsearch_abort (cxt)
if the caller should abort the search, 0 if we should break out of the if the caller should abort the search, 0 if we should break out of the
loop, and 1 if we should continue to read characters. */ loop, and 1 if we should continue to read characters. */
static int static int
_rl_nsearch_dispatch (cxt, c) _rl_nsearch_dispatch (_rl_search_cxt *cxt, int c)
_rl_search_cxt *cxt;
int c;
{ {
if (c < 0)
c = CTRL ('C');
switch (c) switch (c)
{ {
case CTRL('W'): case CTRL('W'):
@ -306,8 +319,7 @@ _rl_nsearch_dispatch (cxt, c)
using _rl_nsearch_cleanup (). Returns 1 if the search was successful, using _rl_nsearch_cleanup (). Returns 1 if the search was successful,
0 otherwise. */ 0 otherwise. */
static int static int
_rl_nsearch_dosearch (cxt) _rl_nsearch_dosearch (_rl_search_cxt *cxt)
_rl_search_cxt *cxt;
{ {
rl_mark = cxt->save_mark; rl_mark = cxt->save_mark;
@ -340,7 +352,7 @@ _rl_nsearch_dosearch (cxt)
} }
rl_restore_prompt (); rl_restore_prompt ();
return (noninc_dosearch (noninc_search_string, cxt->direction)); return (noninc_dosearch (noninc_search_string, cxt->direction, cxt->sflags&SF_PATTERN));
} }
/* Search non-interactively through the history list. DIR < 0 means to /* Search non-interactively through the history list. DIR < 0 means to
@ -349,9 +361,7 @@ _rl_nsearch_dosearch (cxt)
history list. PCHAR is the character to use for prompting when reading history list. PCHAR is the character to use for prompting when reading
the search string; if not specified (0), it defaults to `:'. */ the search string; if not specified (0), it defaults to `:'. */
static int static int
noninc_search (dir, pchar) noninc_search (int dir, int pchar)
int dir;
int pchar;
{ {
_rl_search_cxt *cxt; _rl_search_cxt *cxt;
int c, r; int c, r;
@ -367,6 +377,12 @@ noninc_search (dir, pchar)
{ {
c = _rl_search_getchar (cxt); c = _rl_search_getchar (cxt);
if (c < 0)
{
_rl_nsearch_abort (cxt);
return 1;
}
if (c == 0) if (c == 0)
break; break;
@ -384,8 +400,7 @@ noninc_search (dir, pchar)
/* Search forward through the history list for a string. If the vi-mode /* Search forward through the history list for a string. If the vi-mode
code calls this, KEY will be `?'. */ code calls this, KEY will be `?'. */
int int
rl_noninc_forward_search (count, key) rl_noninc_forward_search (int count, int key)
int count, key;
{ {
return noninc_search (1, (key == '?') ? '?' : 0); return noninc_search (1, (key == '?') ? '?' : 0);
} }
@ -393,17 +408,16 @@ rl_noninc_forward_search (count, key)
/* Reverse search the history list for a string. If the vi-mode code /* Reverse search the history list for a string. If the vi-mode code
calls this, KEY will be `/'. */ calls this, KEY will be `/'. */
int int
rl_noninc_reverse_search (count, key) rl_noninc_reverse_search (int count, int key)
int count, key;
{ {
return noninc_search (-1, (key == '/') ? '/' : 0); return noninc_search (-1, (key == '/') ? '/' : 0);
} }
/* Search forward through the history list for the last string searched /* Search forward through the history list for the last string searched
for. If there is no saved search string, abort. */ for. If there is no saved search string, abort. If the vi-mode code
calls this, KEY will be `N'. */
int int
rl_noninc_forward_search_again (count, key) rl_noninc_forward_search_again (int count, int key)
int count, key;
{ {
int r; int r;
@ -412,15 +426,20 @@ rl_noninc_forward_search_again (count, key)
rl_ding (); rl_ding ();
return (1); return (1);
} }
r = noninc_dosearch (noninc_search_string, 1); #if defined (VI_MODE)
if (VI_COMMAND_MODE() && key == 'N')
r = noninc_dosearch (noninc_search_string, 1, SF_PATTERN);
else
#endif
r = noninc_dosearch (noninc_search_string, 1, 0);
return (r != 1); return (r != 1);
} }
/* Reverse search in the history list for the last string searched /* Reverse search in the history list for the last string searched
for. If there is no saved search string, abort. */ for. If there is no saved search string, abort. If the vi-mode code
calls this, KEY will be `n'. */
int int
rl_noninc_reverse_search_again (count, key) rl_noninc_reverse_search_again (int count, int key)
int count, key;
{ {
int r; int r;
@ -429,18 +448,28 @@ rl_noninc_reverse_search_again (count, key)
rl_ding (); rl_ding ();
return (1); return (1);
} }
r = noninc_dosearch (noninc_search_string, -1); #if defined (VI_MODE)
if (VI_COMMAND_MODE() && key == 'n')
r = noninc_dosearch (noninc_search_string, -1, SF_PATTERN);
else
#endif
r = noninc_dosearch (noninc_search_string, -1, 0);
return (r != 1); return (r != 1);
} }
#if defined (READLINE_CALLBACKS) #if defined (READLINE_CALLBACKS)
int int
_rl_nsearch_callback (cxt) _rl_nsearch_callback (_rl_search_cxt *cxt)
_rl_search_cxt *cxt;
{ {
int c, r; int c, r;
c = _rl_search_getchar (cxt); c = _rl_search_getchar (cxt);
if (c <= 0)
{
if (c < 0)
_rl_nsearch_abort (cxt);
return 1;
}
r = _rl_nsearch_dispatch (cxt, c); r = _rl_nsearch_dispatch (cxt, c);
if (r != 0) if (r != 0)
return 1; return 1;
@ -451,11 +480,10 @@ _rl_nsearch_callback (cxt)
#endif #endif
static int static int
rl_history_search_internal (count, dir) rl_history_search_internal (int count, int dir)
int count, dir;
{ {
HIST_ENTRY *temp; HIST_ENTRY *temp;
int ret, oldpos; int ret, oldpos, newcol;
char *t; char *t;
rl_maybe_save_line (); rl_maybe_save_line ();
@ -469,7 +497,7 @@ rl_history_search_internal (count, dir)
while (count) while (count)
{ {
RL_CHECK_SIGNALS (); RL_CHECK_SIGNALS ();
ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir); ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir, 0, &newcol);
if (ret == -1) if (ret == -1)
break; break;
@ -512,12 +540,17 @@ rl_history_search_internal (count, dir)
/* Copy the line we found into the current line buffer. */ /* Copy the line we found into the current line buffer. */
make_history_line_current (temp); make_history_line_current (temp);
/* decide where to put rl_point -- need to change this for pattern search */
if (rl_history_search_flags & ANCHORED_SEARCH) if (rl_history_search_flags & ANCHORED_SEARCH)
rl_point = rl_history_search_len; /* easy case */ rl_point = rl_history_search_len; /* easy case */
else else
{ {
t = strstr (rl_line_buffer, history_search_string); #if 0
t = strstr (rl_line_buffer, history_search_string); /* XXX */
rl_point = t ? (int)(t - rl_line_buffer) + rl_history_search_len : rl_end; rl_point = t ? (int)(t - rl_line_buffer) + rl_history_search_len : rl_end;
#else
rl_point = (newcol >= 0) ? newcol : rl_end;
#endif
} }
rl_mark = rl_end; rl_mark = rl_end;
@ -525,8 +558,7 @@ rl_history_search_internal (count, dir)
} }
static void static void
rl_history_search_reinit (flags) rl_history_search_reinit (int flags)
int flags;
{ {
int sind; int sind;
@ -556,8 +588,7 @@ rl_history_search_reinit (flags)
from the start of the line to rl_point. This is a non-incremental from the start of the line to rl_point. This is a non-incremental
search. The search is anchored to the beginning of the history line. */ search. The search is anchored to the beginning of the history line. */
int int
rl_history_search_forward (count, ignore) rl_history_search_forward (int count, int ignore)
int count, ignore;
{ {
if (count == 0) if (count == 0)
return (0); return (0);
@ -575,8 +606,7 @@ rl_history_search_forward (count, ignore)
from the start of the line to rl_point. This is a non-incremental from the start of the line to rl_point. This is a non-incremental
search. */ search. */
int int
rl_history_search_backward (count, ignore) rl_history_search_backward (int count, int ignore)
int count, ignore;
{ {
if (count == 0) if (count == 0)
return (0); return (0);
@ -595,8 +625,7 @@ rl_history_search_backward (count, ignore)
search. The search succeeds if the search string is present anywhere search. The search succeeds if the search string is present anywhere
in the history line. */ in the history line. */
int int
rl_history_substr_search_forward (count, ignore) rl_history_substr_search_forward (int count, int ignore)
int count, ignore;
{ {
if (count == 0) if (count == 0)
return (0); return (0);
@ -614,8 +643,7 @@ rl_history_substr_search_forward (count, ignore)
from the start of the line to rl_point. This is a non-incremental from the start of the line to rl_point. This is a non-incremental
search. */ search. */
int int
rl_history_substr_search_backward (count, ignore) rl_history_substr_search_backward (int count, int ignore)
int count, ignore;
{ {
if (count == 0) if (count == 0)
return (0); return (0);

View File

@ -1,7 +1,7 @@
/* shell.c -- readline utility functions that are normally provided by /* shell.c -- readline utility functions that are normally provided by
bash when readline is linked as part of the shell. */ bash when readline is linked as part of the shell. */
/* Copyright (C) 1997-2009 Free Software Foundation, Inc. /* Copyright (C) 1997-2009,2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -92,8 +92,7 @@ extern struct passwd *getpwuid PARAMS((uid_t));
/* Does shell-like quoting using single quotes. */ /* Does shell-like quoting using single quotes. */
char * char *
sh_single_quote (string) sh_single_quote (char *string)
char *string;
{ {
register int c; register int c;
char *result, *r, *s; char *result, *r, *s;
@ -127,8 +126,7 @@ static char putenv_buf1[INT_STRLEN_BOUND (int) + 6 + 1]; /* sizeof("LINES=") ==
static char putenv_buf2[INT_STRLEN_BOUND (int) + 8 + 1]; /* sizeof("COLUMNS=") == 8 */ static char putenv_buf2[INT_STRLEN_BOUND (int) + 8 + 1]; /* sizeof("COLUMNS=") == 8 */
void void
sh_set_lines_and_columns (lines, cols) sh_set_lines_and_columns (int lines, int cols)
int lines, cols;
{ {
#if defined (HAVE_SETENV) #if defined (HAVE_SETENV)
sprintf (setenv_buf, "%d", lines); sprintf (setenv_buf, "%d", lines);
@ -148,14 +146,13 @@ sh_set_lines_and_columns (lines, cols)
} }
char * char *
sh_get_env_value (varname) sh_get_env_value (const char *varname)
const char *varname;
{ {
return ((char *)getenv (varname)); return ((char *)getenv (varname));
} }
char * char *
sh_get_home_dir () sh_get_home_dir (void)
{ {
static char *home_dir = (char *)NULL; static char *home_dir = (char *)NULL;
struct passwd *entry; struct passwd *entry;
@ -188,8 +185,7 @@ sh_get_home_dir ()
#endif #endif
int int
sh_unset_nodelay_mode (fd) sh_unset_nodelay_mode (int fd)
int fd;
{ {
#if defined (HAVE_FCNTL) #if defined (HAVE_FCNTL)
int flags, bflags; int flags, bflags;

View File

@ -1,6 +1,6 @@
/* signals.c -- signal handling support for readline. */ /* signals.c -- signal handling support for readline. */
/* Copyright (C) 1987-2016 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -113,6 +113,10 @@ int _rl_susp_char = 0;
static int signals_set_flag; static int signals_set_flag;
static int sigwinch_set_flag; static int sigwinch_set_flag;
#if defined (HAVE_POSIX_SIGNALS)
sigset_t _rl_orig_sigset;
#endif /* !HAVE_POSIX_SIGNALS */
/* **************************************************************** */ /* **************************************************************** */
/* */ /* */
/* Signal Handling */ /* Signal Handling */
@ -134,8 +138,7 @@ void *_rl_sigcleanarg;
/* Called from RL_CHECK_SIGNALS() macro */ /* Called from RL_CHECK_SIGNALS() macro */
RETSIGTYPE RETSIGTYPE
_rl_signal_handler (sig) _rl_signal_handler (int sig)
int sig;
{ {
_rl_caught_signal = 0; /* XXX */ _rl_caught_signal = 0; /* XXX */
@ -158,8 +161,7 @@ _rl_signal_handler (sig)
} }
static RETSIGTYPE static RETSIGTYPE
rl_signal_handler (sig) rl_signal_handler (int sig)
int sig;
{ {
if (_rl_interrupt_immediately) if (_rl_interrupt_immediately)
{ {
@ -173,8 +175,7 @@ rl_signal_handler (sig)
} }
static RETSIGTYPE static RETSIGTYPE
_rl_handle_signal (sig) _rl_handle_signal (int sig)
int sig;
{ {
#if defined (HAVE_POSIX_SIGNALS) #if defined (HAVE_POSIX_SIGNALS)
sigset_t set; sigset_t set;
@ -248,9 +249,11 @@ _rl_handle_signal (sig)
rl_cleanup_after_signal (); rl_cleanup_after_signal ();
#if defined (HAVE_POSIX_SIGNALS) #if defined (HAVE_POSIX_SIGNALS)
# if defined (SIGTSTP)
/* Unblock SIGTTOU blocked above */ /* Unblock SIGTTOU blocked above */
if (sig == SIGTTIN || sig == SIGTSTP) if (sig == SIGTTIN || sig == SIGTSTP)
sigprocmask (SIG_UNBLOCK, &set, (sigset_t *)NULL); sigprocmask (SIG_UNBLOCK, &set, (sigset_t *)NULL);
# endif
sigemptyset (&set); sigemptyset (&set);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set); sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
@ -289,8 +292,7 @@ _rl_handle_signal (sig)
#if defined (SIGWINCH) #if defined (SIGWINCH)
static RETSIGTYPE static RETSIGTYPE
rl_sigwinch_handler (sig) rl_sigwinch_handler (int sig)
int sig;
{ {
SigHandler *oh; SigHandler *oh;
@ -321,9 +323,7 @@ rl_sigwinch_handler (sig)
#if !defined (HAVE_POSIX_SIGNALS) #if !defined (HAVE_POSIX_SIGNALS)
static int static int
rl_sigaction (sig, nh, oh) rl_sigaction (int sig, sighandler_cxt *nh, sighandler_cxt *oh)
int sig;
sighandler_cxt *nh, *oh;
{ {
oh->sa_handler = signal (sig, nh->sa_handler); oh->sa_handler = signal (sig, nh->sa_handler);
return 0; return 0;
@ -334,10 +334,7 @@ rl_sigaction (sig, nh, oh)
information in OHANDLER. Return the old signal handler, like information in OHANDLER. Return the old signal handler, like
signal(). */ signal(). */
static SigHandler * static SigHandler *
rl_set_sighandler (sig, handler, ohandler) rl_set_sighandler (int sig, SigHandler *handler, sighandler_cxt *ohandler)
int sig;
SigHandler *handler;
sighandler_cxt *ohandler;
{ {
sighandler_cxt old_handler; sighandler_cxt old_handler;
#if defined (HAVE_POSIX_SIGNALS) #if defined (HAVE_POSIX_SIGNALS)
@ -368,10 +365,7 @@ rl_set_sighandler (sig, handler, ohandler)
/* Set disposition of SIG to HANDLER, returning old state in OHANDLER. Don't /* Set disposition of SIG to HANDLER, returning old state in OHANDLER. Don't
change disposition if OHANDLER indicates the signal was ignored. */ change disposition if OHANDLER indicates the signal was ignored. */
static void static void
rl_maybe_set_sighandler (sig, handler, ohandler) rl_maybe_set_sighandler (int sig, SigHandler *handler, sighandler_cxt *ohandler)
int sig;
SigHandler *handler;
sighandler_cxt *ohandler;
{ {
sighandler_cxt dummy; sighandler_cxt dummy;
SigHandler *oh; SigHandler *oh;
@ -388,9 +382,7 @@ rl_maybe_set_sighandler (sig, handler, ohandler)
disposition was changed using rl_maybe_set_sighandler or for which the disposition was changed using rl_maybe_set_sighandler or for which the
SIG_IGN check was performed inline (e.g., SIGALRM below). */ SIG_IGN check was performed inline (e.g., SIGALRM below). */
static void static void
rl_maybe_restore_sighandler (sig, handler) rl_maybe_restore_sighandler (int sig, sighandler_cxt *handler)
int sig;
sighandler_cxt *handler;
{ {
sighandler_cxt dummy; sighandler_cxt dummy;
@ -401,7 +393,7 @@ rl_maybe_restore_sighandler (sig, handler)
} }
int int
rl_set_signals () rl_set_signals (void)
{ {
sighandler_cxt dummy; sighandler_cxt dummy;
SigHandler *oh; SigHandler *oh;
@ -442,8 +434,8 @@ rl_set_signals ()
if (rl_catch_signals && signals_set_flag == 0) if (rl_catch_signals && signals_set_flag == 0)
{ {
#if defined (HAVE_POSIX_SIGNALS) #if defined (HAVE_POSIX_SIGNALS)
sigemptyset (&oset); sigemptyset (&_rl_orig_sigset);
sigprocmask (SIG_BLOCK, &bset, &oset); sigprocmask (SIG_BLOCK, &bset, &_rl_orig_sigset);
#endif #endif
rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int); rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int);
@ -484,7 +476,14 @@ rl_set_signals ()
signals_set_flag = 1; signals_set_flag = 1;
#if defined (HAVE_POSIX_SIGNALS) #if defined (HAVE_POSIX_SIGNALS)
sigprocmask (SIG_SETMASK, &oset, (sigset_t *)NULL); sigprocmask (SIG_SETMASK, &_rl_orig_sigset, (sigset_t *)NULL);
#endif
}
else if (rl_catch_signals == 0)
{
#if defined (HAVE_POSIX_SIGNALS)
sigemptyset (&_rl_orig_sigset);
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &_rl_orig_sigset);
#endif #endif
} }
@ -500,14 +499,12 @@ rl_set_signals ()
} }
int int
rl_clear_signals () rl_clear_signals (void)
{ {
sighandler_cxt dummy; sighandler_cxt dummy;
if (rl_catch_signals && signals_set_flag == 1) if (rl_catch_signals && signals_set_flag == 1)
{ {
sigemptyset (&dummy.sa_mask);
/* Since rl_maybe_set_sighandler doesn't override a SIG_IGN handler, /* Since rl_maybe_set_sighandler doesn't override a SIG_IGN handler,
we should in theory not have to restore a handler where we should in theory not have to restore a handler where
old_xxx.sa_handler == SIG_IGN. That's what rl_maybe_restore_sighandler old_xxx.sa_handler == SIG_IGN. That's what rl_maybe_restore_sighandler
@ -555,7 +552,7 @@ rl_clear_signals ()
/* Clean up the terminal and readline state after catching a signal, before /* Clean up the terminal and readline state after catching a signal, before
resending it to the calling application. */ resending it to the calling application. */
void void
rl_cleanup_after_signal () rl_cleanup_after_signal (void)
{ {
_rl_clean_up_for_exit (); _rl_clean_up_for_exit ();
if (rl_deprep_term_function) if (rl_deprep_term_function)
@ -566,7 +563,7 @@ rl_cleanup_after_signal ()
/* Reset the terminal and readline state after a signal handler returns. */ /* Reset the terminal and readline state after a signal handler returns. */
void void
rl_reset_after_signal () rl_reset_after_signal (void)
{ {
if (rl_prep_term_function) if (rl_prep_term_function)
(*rl_prep_term_function) (_rl_meta_flag); (*rl_prep_term_function) (_rl_meta_flag);
@ -578,7 +575,7 @@ rl_reset_after_signal ()
numeric arguments in process) after catching a signal, before calling numeric arguments in process) after catching a signal, before calling
rl_cleanup_after_signal(). */ rl_cleanup_after_signal(). */
void void
rl_free_line_state () rl_free_line_state (void)
{ {
register HIST_ENTRY *entry; register HIST_ENTRY *entry;
@ -594,10 +591,16 @@ rl_free_line_state ()
} }
int int
rl_pending_signal () rl_pending_signal (void)
{ {
return (_rl_caught_signal); return (_rl_caught_signal);
} }
void
rl_check_signals (void)
{
RL_CHECK_SIGNALS ();
}
#endif /* HANDLE_SIGNALS */ #endif /* HANDLE_SIGNALS */
/* **************************************************************** */ /* **************************************************************** */
@ -622,7 +625,7 @@ static int sigwinch_blocked;
/* Cause SIGINT to not be delivered until the corresponding call to /* Cause SIGINT to not be delivered until the corresponding call to
release_sigint(). */ release_sigint(). */
void void
_rl_block_sigint () _rl_block_sigint (void)
{ {
if (sigint_blocked) if (sigint_blocked)
return; return;
@ -632,7 +635,7 @@ _rl_block_sigint ()
/* Allow SIGINT to be delivered. */ /* Allow SIGINT to be delivered. */
void void
_rl_release_sigint () _rl_release_sigint (void)
{ {
if (sigint_blocked == 0) if (sigint_blocked == 0)
return; return;
@ -644,7 +647,7 @@ _rl_release_sigint ()
/* Cause SIGWINCH to not be delivered until the corresponding call to /* Cause SIGWINCH to not be delivered until the corresponding call to
release_sigwinch(). */ release_sigwinch(). */
void void
_rl_block_sigwinch () _rl_block_sigwinch (void)
{ {
if (sigwinch_blocked) if (sigwinch_blocked)
return; return;
@ -673,7 +676,7 @@ _rl_block_sigwinch ()
/* Allow SIGWINCH to be delivered. */ /* Allow SIGWINCH to be delivered. */
void void
_rl_release_sigwinch () _rl_release_sigwinch (void)
{ {
if (sigwinch_blocked == 0) if (sigwinch_blocked == 0)
return; return;
@ -703,8 +706,7 @@ _rl_release_sigwinch ()
/* */ /* */
/* **************************************************************** */ /* **************************************************************** */
void void
rl_echo_signal_char (sig) rl_echo_signal_char (int sig)
int sig;
{ {
char cstr[3]; char cstr[3];
int cslen, c; int cslen, c;

View File

@ -247,7 +247,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
exit ;; exit ;;
*:Bitrig:*:*) *:Bitrig:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
exit ;; exit ;;
*:OpenBSD:*:*) *:OpenBSD:*:*)
UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
@ -395,7 +395,7 @@ case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
echo i386-pc-auroraux"$UNAME_RELEASE" echo i386-pc-auroraux"$UNAME_RELEASE"
exit ;; exit ;;
i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
echo i386-pc-auroraux${UNAME_RELEASE} echo i386-pc-auroraux"$UNAME_RELEASE"
exit ;; exit ;;
i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
set_cc_for_build set_cc_for_build
@ -877,7 +877,7 @@ EOF
echo "$UNAME_MACHINE"-pc-mingw64 echo "$UNAME_MACHINE"-pc-mingw64
exit ;; exit ;;
*:MINGW64*:*) *:MINGW64*:*)
echo ${UNAME_MACHINE}-pc-mingw64 echo "$UNAME_MACHINE"-pc-mingw64
exit ;; exit ;;
*:MINGW*:*) *:MINGW*:*)
echo "$UNAME_MACHINE"-pc-mingw32 echo "$UNAME_MACHINE"-pc-mingw32
@ -945,11 +945,11 @@ EOF
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;; exit ;;
aarch64:Linux:*:*) aarch64:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC} echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;; exit ;;
aarch64_be:Linux:*:*) aarch64_be:Linux:*:*)
UNAME_MACHINE=aarch64_be UNAME_MACHINE=aarch64_be
echo ${UNAME_MACHINE}-unknown-linux-${LIBC} echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;; exit ;;
alpha:Linux:*:*) alpha:Linux:*:*)
case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@ -962,11 +962,11 @@ EOF
EV68*) UNAME_MACHINE=alphaev68 ;; EV68*) UNAME_MACHINE=alphaev68 ;;
esac esac
objdump --private-headers /bin/sh | grep -q ld.so.1 objdump --private-headers /bin/sh | grep -q ld.so.1
if test "$?" = 0 ; then LIBC="gnulibc1" ; fi if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
echo ${UNAME_MACHINE}-unknown-linux-${LIBC} echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;; exit ;;
arc:Linux:*:* | arceb:Linux:*:*) arc:Linux:*:* | arceb:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-${LIBC} echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
exit ;; exit ;;
arm*:Linux:*:*) arm*:Linux:*:*)
set_cc_for_build set_cc_for_build
@ -1494,10 +1494,13 @@ EOF
echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE"
exit ;; exit ;;
i*86:AROS:*:*) i*86:AROS:*:*)
echo ${UNAME_MACHINE}-pc-aros echo "$UNAME_MACHINE"-pc-aros
exit ;; exit ;;
x86_64:VMkernel:*:*) x86_64:VMkernel:*:*)
echo ${UNAME_MACHINE}-unknown-esx echo "$UNAME_MACHINE"-unknown-esx
exit ;;
amd64:Isilon\ OneFS:*:*)
echo x86_64-unknown-onefs
exit ;; exit ;;
esac esac
@ -1624,12 +1627,13 @@ main ()
#endif #endif
#endif #endif
#if defined (alliant) && defined (i860) case "$UNAME_MACHINE:$UNAME_SYSTEM" in
printf ("i860-alliant-bsd\n"); exit (0); mips:Linux | mips64:Linux)
#endif # If we got here on MIPS GNU/Linux, output extra information.
cat >&2 <<EOF
exit (1); NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
} the system type. Please install a C compiler and try again.
EOF EOF
$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` && $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`$dummy` &&

View File

@ -2,27 +2,13 @@
# Output a system dependent set of variables, describing how to set the # Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable. # run time search path of shared libraries in an executable.
# #
# Copyright 1996-2003 Free Software Foundation, Inc. # Copyright 1996-2018 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001 # Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
# #
# This program is free software: you can redistribute it and/or modify # This file is free software; the Free Software Foundation gives
# it under the terms of the GNU General Public License as published by # unlimited permission to copy and/or distribute it, with or without
# the Free Software Foundation, either version 3 of the License, or # modifications, as long as this notice is preserved.
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# #
# The first argument passed to this file is the canonical host specification, # The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
@ -39,7 +25,7 @@
# known workaround is to choose shorter directory names for the build # known workaround is to choose shorter directory names for the build
# directory and/or the installation directory. # directory and/or the installation directory.
# All known linkers require a `.a' archive for static linking (except M$VC, # All known linkers require a '.a' archive for static linking (except MSVC,
# which needs '.lib'). # which needs '.lib').
libext=a libext=a
shrext=.so shrext=.so
@ -49,7 +35,19 @@ host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC. # Code taken from libtool.m4's _LT_CC_BASENAME.
for cc_temp in $CC""; do
case $cc_temp in
compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
\-*) ;;
*) break;;
esac
done
cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
# Code taken from libtool.m4's _LT_COMPILER_PIC.
wl= wl=
if test "$GCC" = yes; then if test "$GCC" = yes; then
@ -59,7 +57,7 @@ else
aix*) aix*)
wl='-Wl,' wl='-Wl,'
;; ;;
mingw* | pw32* | os2*) mingw* | cygwin* | pw32* | os2* | cegcc*)
;; ;;
hpux9* | hpux10* | hpux11*) hpux9* | hpux10* | hpux11*)
wl='-Wl,' wl='-Wl,'
@ -67,40 +65,83 @@ else
irix5* | irix6* | nonstopux*) irix5* | irix6* | nonstopux*)
wl='-Wl,' wl='-Wl,'
;; ;;
newsos6) linux* | k*bsd*-gnu | kopensolaris*-gnu)
;; case $cc_basename in
linux*) ecc*)
case $CC in
icc|ecc)
wl='-Wl,' wl='-Wl,'
;; ;;
ccc) icc* | ifort*)
wl='-Wl,' wl='-Wl,'
;; ;;
lf95*)
wl='-Wl,'
;;
nagfor*)
wl='-Wl,-Wl,,'
;;
pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
wl='-Wl,'
;;
ccc*)
wl='-Wl,'
;;
xl* | bgxl* | bgf* | mpixl*)
wl='-Wl,'
;;
como)
wl='-lopt='
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ F* | *Sun*Fortran*)
wl=
;;
*Sun\ C*)
wl='-Wl,'
;;
esac
;;
esac esac
;; ;;
newsos6)
;;
*nto* | *qnx*)
;;
osf3* | osf4* | osf5*) osf3* | osf4* | osf5*)
wl='-Wl,' wl='-Wl,'
;; ;;
sco3.2v5*) rdos*)
;; ;;
solaris*) solaris*)
wl='-Wl,' case $cc_basename in
f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
wl='-Qoption ld '
;;
*)
wl='-Wl,'
;;
esac
;; ;;
sunos4*) sunos4*)
wl='-Qoption ld ' wl='-Qoption ld '
;; ;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) sysv4 | sysv4.2uw2* | sysv4.3*)
wl='-Wl,' wl='-Wl,'
;; ;;
sysv4*MP*) sysv4*MP*)
;; ;;
sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
wl='-Wl,'
;;
unicos*)
wl='-Wl,'
;;
uts4*) uts4*)
;; ;;
esac esac
fi fi
# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS. # Code taken from libtool.m4's _LT_LINKER_SHLIBS.
hardcode_libdir_flag_spec= hardcode_libdir_flag_spec=
hardcode_libdir_separator= hardcode_libdir_separator=
@ -108,7 +149,7 @@ hardcode_direct=no
hardcode_minus_L=no hardcode_minus_L=no
case "$host_os" in case "$host_os" in
cygwin* | mingw* | pw32*) cygwin* | mingw* | pw32* | cegcc*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time # FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using # When not using gcc, we currently assume that we are using
# Microsoft Visual C++. # Microsoft Visual C++.
@ -116,6 +157,10 @@ case "$host_os" in
with_gnu_ld=no with_gnu_ld=no
fi fi
;; ;;
interix*)
# we just hope/assume this is gcc and not c89 (= MSVC++)
with_gnu_ld=yes
;;
openbsd*) openbsd*)
with_gnu_ld=no with_gnu_ld=no
;; ;;
@ -123,32 +168,37 @@ esac
ld_shlibs=yes ld_shlibs=yes
if test "$with_gnu_ld" = yes; then if test "$with_gnu_ld" = yes; then
# Set some defaults for GNU ld with shared library support. These
# are reset later if shared libraries are not supported. Putting them
# here allows them to be overridden if necessary.
# Unlike libtool, we use -rpath here, not --rpath, since the documented
# option of GNU ld is called -rpath, not --rpath.
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
case "$host_os" in case "$host_os" in
aix3* | aix4* | aix5*) aix[3-9]*)
# On AIX/PPC, the GNU linker is very broken # On AIX/PPC, the GNU linker is very broken
if test "$host_cpu" != ia64; then if test "$host_cpu" != ia64; then
ld_shlibs=no ld_shlibs=no
fi fi
;; ;;
amigaos*) amigaos*)
hardcode_libdir_flag_spec='-L$libdir' case "$host_cpu" in
hardcode_minus_L=yes powerpc)
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports ;;
# that the semantics of dynamic libraries on AmigaOS, at least up m68k)
# to version 4, is to share data among multiple programs linked hardcode_libdir_flag_spec='-L$libdir'
# with the same dynamic library. Since this doesn't match the hardcode_minus_L=yes
# behavior of shared libraries on other platforms, we can use ;;
# them. esac
ld_shlibs=no
;; ;;
beos*) beos*)
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
: :
else else
ld_shlibs=no ld_shlibs=no
fi fi
;; ;;
cygwin* | mingw* | pw32*) cygwin* | mingw* | pw32* | cegcc*)
# hardcode_libdir_flag_spec is actually meaningless, as there is # hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs. # no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_flag_spec='-L$libdir'
@ -158,32 +208,57 @@ if test "$with_gnu_ld" = yes; then
ld_shlibs=no ld_shlibs=no
fi fi
;; ;;
netbsd*) haiku*)
;; ;;
solaris* | sysv5*) interix[3-9]*)
if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then hardcode_direct=no
ld_shlibs=no hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then ;;
gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
: :
else else
ld_shlibs=no ld_shlibs=no
fi fi
;; ;;
netbsd*)
;;
solaris*)
if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
ld_shlibs=no
elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
case `$LD -v 2>&1` in
*\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
ld_shlibs=no
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
else
ld_shlibs=no
fi
;;
esac
;;
sunos4*) sunos4*)
hardcode_direct=yes hardcode_direct=yes
;; ;;
*) *)
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
: :
else else
ld_shlibs=no ld_shlibs=no
fi fi
;; ;;
esac esac
if test "$ld_shlibs" = yes; then if test "$ld_shlibs" = no; then
# Unlike libtool, we use -rpath here, not --rpath, since the documented hardcode_libdir_flag_spec=
# option of GNU ld is called -rpath, not --rpath.
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
fi fi
else else
case "$host_os" in case "$host_os" in
@ -197,7 +272,7 @@ else
hardcode_direct=unsupported hardcode_direct=unsupported
fi fi
;; ;;
aix4* | aix5*) aix[4-9]*)
if test "$host_cpu" = ia64; then if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't # On IA64, the linker does run time linking by default, so we don't
# have to do anything special. # have to do anything special.
@ -207,13 +282,14 @@ else
# Test if we are trying to use run time linking or normal # Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we # AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking. # need to do runtime linking.
case $host_os in aix4.[23]|aix4.[23].*|aix5*) case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
for ld_flag in $LDFLAGS; do for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes aix_use_runtimelinking=yes
break break
fi fi
done done
;;
esac esac
fi fi
hardcode_direct=yes hardcode_direct=yes
@ -225,7 +301,7 @@ else
strings "$collect2name" | grep resolve_lib_name >/dev/null strings "$collect2name" | grep resolve_lib_name >/dev/null
then then
# We have reworked collect2 # We have reworked collect2
hardcode_direct=yes :
else else
# We have old collect2 # We have old collect2
hardcode_direct=unsupported hardcode_direct=unsupported
@ -233,6 +309,7 @@ else
hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_flag_spec='-L$libdir'
hardcode_libdir_separator= hardcode_libdir_separator=
fi fi
;;
esac esac
fi fi
# Begin _LT_AC_SYS_LIBPATH_AIX. # Begin _LT_AC_SYS_LIBPATH_AIX.
@ -260,14 +337,18 @@ else
fi fi
;; ;;
amigaos*) amigaos*)
hardcode_libdir_flag_spec='-L$libdir' case "$host_cpu" in
hardcode_minus_L=yes powerpc)
# see comment about different semantics on the GNU ld section ;;
ld_shlibs=no m68k)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
esac
;; ;;
bsdi4*) bsdi[45]*)
;; ;;
cygwin* | mingw* | pw32*) cygwin* | mingw* | pw32* | cegcc*)
# When not using gcc, we currently assume that we are using # When not using gcc, we currently assume that we are using
# Microsoft Visual C++. # Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is # hardcode_libdir_flag_spec is actually meaningless, as there is
@ -276,25 +357,21 @@ else
libext=lib libext=lib
;; ;;
darwin* | rhapsody*) darwin* | rhapsody*)
if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then hardcode_direct=no
hardcode_direct=no if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
:
else
ld_shlibs=no
fi fi
;; ;;
dgux*) dgux*)
hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_flag_spec='-L$libdir'
;; ;;
freebsd1*) freebsd2.[01]*)
ld_shlibs=no
;;
freebsd2.2*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
freebsd2*)
hardcode_direct=yes hardcode_direct=yes
hardcode_minus_L=yes hardcode_minus_L=yes
;; ;;
freebsd*) freebsd* | dragonfly*)
hardcode_libdir_flag_spec='-R$libdir' hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes hardcode_direct=yes
;; ;;
@ -306,24 +383,25 @@ else
# but as the default location of the library. # but as the default location of the library.
hardcode_minus_L=yes hardcode_minus_L=yes
;; ;;
hpux10* | hpux11*) hpux10*)
if test "$with_gnu_ld" = no; then if test "$with_gnu_ld" = no; then
case "$host_cpu" in hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hppa*64*) hardcode_libdir_separator=:
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir' hardcode_direct=yes
hardcode_libdir_separator=: # hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
fi
;;
hpux11*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
case $host_cpu in
hppa*64*|ia64*)
hardcode_direct=no hardcode_direct=no
;; ;;
ia64*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=no
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
*) *)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH, # hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library. # but as the default location of the library.
@ -345,19 +423,25 @@ else
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir' hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=: hardcode_libdir_separator=:
;; ;;
*nto* | *qnx*)
;;
openbsd*) openbsd*)
hardcode_direct=yes if test -f /usr/libexec/ld.so; then
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then hardcode_direct=yes
hardcode_libdir_flag_spec='${wl}-rpath,$libdir' if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
else
case "$host_os" in
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi
else else
case "$host_os" in ld_shlibs=no
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi fi
;; ;;
os2*) os2*)
@ -377,8 +461,6 @@ else
fi fi
hardcode_libdir_separator=: hardcode_libdir_separator=:
;; ;;
sco3.2v5*)
;;
solaris*) solaris*)
hardcode_libdir_flag_spec='-R$libdir' hardcode_libdir_flag_spec='-R$libdir'
;; ;;
@ -407,14 +489,11 @@ else
ld_shlibs=yes ld_shlibs=yes
fi fi
;; ;;
sysv4.2uw2*) sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
hardcode_direct=yes
hardcode_minus_L=no
;; ;;
sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*) sysv5* | sco3.2v5* | sco5v6*)
;; hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
sysv5*) hardcode_libdir_separator=':'
hardcode_libdir_flag_spec=
;; ;;
uts4*) uts4*)
hardcode_libdir_flag_spec='-L$libdir' hardcode_libdir_flag_spec='-L$libdir'
@ -426,35 +505,59 @@ else
fi fi
# Check dynamic linker characteristics # Check dynamic linker characteristics
# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER. # Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER.
# Unlike libtool.m4, here we don't care about _all_ names of the library, but
# only about the one the linker finds when passed -lNAME. This is the last
# element of library_names_spec in libtool.m4, or possibly two of them if the
# linker has special search rules.
library_names_spec= # the last element of library_names_spec in libtool.m4
libname_spec='lib$name' libname_spec='lib$name'
case "$host_os" in case "$host_os" in
aix3*) aix3*)
library_names_spec='$libname.a'
;; ;;
aix4* | aix5*) aix[4-9]*)
library_names_spec='$libname$shrext'
;; ;;
amigaos*) amigaos*)
case "$host_cpu" in
powerpc*)
library_names_spec='$libname$shrext' ;;
m68k)
library_names_spec='$libname.a' ;;
esac
;; ;;
beos*) beos*)
library_names_spec='$libname$shrext'
;; ;;
bsdi4*) bsdi[45]*)
library_names_spec='$libname$shrext'
;; ;;
cygwin* | mingw* | pw32*) cygwin* | mingw* | pw32* | cegcc*)
shrext=.dll shrext=.dll
library_names_spec='$libname.dll.a $libname.lib'
;; ;;
darwin* | rhapsody*) darwin* | rhapsody*)
shrext=.dylib shrext=.dylib
library_names_spec='$libname$shrext'
;; ;;
dgux*) dgux*)
library_names_spec='$libname$shrext'
;; ;;
freebsd1*) freebsd[23].*)
library_names_spec='$libname$shrext$versuffix'
;; ;;
freebsd*) freebsd* | dragonfly*)
library_names_spec='$libname$shrext'
;; ;;
gnu*) gnu*)
library_names_spec='$libname$shrext'
;;
haiku*)
library_names_spec='$libname$shrext'
;; ;;
hpux9* | hpux10* | hpux11*) hpux9* | hpux10* | hpux11*)
case "$host_cpu" in case $host_cpu in
ia64*) ia64*)
shrext=.so shrext=.so
;; ;;
@ -465,8 +568,13 @@ case "$host_os" in
shrext=.sl shrext=.sl
;; ;;
esac esac
library_names_spec='$libname$shrext'
;;
interix[3-9]*)
library_names_spec='$libname$shrext'
;; ;;
irix5* | irix6* | nonstopux*) irix5* | irix6* | nonstopux*)
library_names_spec='$libname$shrext'
case "$host_os" in case "$host_os" in
irix5* | nonstopux*) irix5* | nonstopux*)
libsuff= shlibsuff= libsuff= shlibsuff=
@ -483,42 +591,65 @@ case "$host_os" in
;; ;;
linux*oldld* | linux*aout* | linux*coff*) linux*oldld* | linux*aout* | linux*coff*)
;; ;;
linux*) linux* | k*bsd*-gnu | kopensolaris*-gnu)
library_names_spec='$libname$shrext'
;;
knetbsd*-gnu)
library_names_spec='$libname$shrext'
;; ;;
netbsd*) netbsd*)
library_names_spec='$libname$shrext'
;; ;;
newsos6) newsos6)
library_names_spec='$libname$shrext'
;; ;;
nto-qnx) *nto* | *qnx*)
library_names_spec='$libname$shrext'
;; ;;
openbsd*) openbsd*)
library_names_spec='$libname$shrext$versuffix'
;; ;;
os2*) os2*)
libname_spec='$name' libname_spec='$name'
shrext=.dll shrext=.dll
library_names_spec='$libname.a'
;; ;;
osf3* | osf4* | osf5*) osf3* | osf4* | osf5*)
library_names_spec='$libname$shrext'
;; ;;
sco3.2v5*) rdos*)
;; ;;
solaris*) solaris*)
library_names_spec='$libname$shrext'
;; ;;
sunos4*) sunos4*)
library_names_spec='$libname$shrext$versuffix'
;; ;;
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) sysv4 | sysv4.3*)
library_names_spec='$libname$shrext'
;; ;;
sysv4*MP*) sysv4*MP*)
library_names_spec='$libname$shrext'
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
library_names_spec='$libname$shrext'
;;
tpf*)
library_names_spec='$libname$shrext'
;; ;;
uts4*) uts4*)
library_names_spec='$libname$shrext'
;; ;;
esac esac
sed_quote_subst='s/\(["`$\\]\)/\\\1/g' sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"` escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
shlibext=`echo "$shrext" | sed -e 's,^\.,,'` shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"` escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
# How to pass a linker flag through the compiler. # How to pass a linker flag through the compiler.
wl="$escaped_wl" wl="$escaped_wl"
@ -529,6 +660,12 @@ libext="$libext"
# Shared library suffix (normally "so"). # Shared library suffix (normally "so").
shlibext="$shlibext" shlibext="$shlibext"
# Format of library name prefix.
libname_spec="$escaped_libname_spec"
# Library names that the linker finds when passed -lNAME.
library_names_spec="$escaped_library_names_spec"
# Flag to hardcode \$libdir into a binary during linking. # Flag to hardcode \$libdir into a binary during linking.
# This must work even if \$libdir does not exist. # This must work even if \$libdir does not exist.
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec" hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"

View File

@ -73,7 +73,7 @@ fi
case "$host_os" in case "$host_os" in
hpux*|darwin*|macosx*|linux*|solaris2*) hpux*|darwin*|macosx*|linux*|solaris2*)
if [ -z "$uninstall" ]; then if [ -z "$uninstall" ]; then
chmod 555 ${INSTALLDIR}/${LIBNAME} chmod 755 ${INSTALLDIR}/${LIBNAME}
fi ;; fi ;;
cygwin*|mingw*) cygwin*|mingw*)
IMPLIBNAME=`echo ${LIBNAME} \ IMPLIBNAME=`echo ${LIBNAME} \

View File

@ -189,7 +189,7 @@ darwin*)
darwin[1-7].*) darwin[1-7].*)
SHOBJ_STATUS=unsupported SHOBJ_STATUS=unsupported
SHOBJ_LDFLAGS='-dynamic' SHOBJ_LDFLAGS='-dynamic'
SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF) -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF) -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -v'
;; ;;
# Darwin 8 == Mac OS X 10.4; Mac OS X 10.N == Darwin N+4 # Darwin 8 == Mac OS X 10.4; Mac OS X 10.N == Darwin N+4
*) *)
@ -205,7 +205,7 @@ darwin*)
;; ;;
esac esac
SHOBJ_LDFLAGS="-dynamiclib -dynamic -undefined dynamic_lookup ${SHOBJ_ARCHFLAGS}" SHOBJ_LDFLAGS="-dynamiclib -dynamic -undefined dynamic_lookup ${SHOBJ_ARCHFLAGS}"
SHLIB_XLDFLAGS="-dynamiclib ${SHOBJ_ARCHFLAGS}"' -install_name $(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF) -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v' SHLIB_XLDFLAGS="-dynamiclib ${SHOBJ_ARCHFLAGS}"' -install_name $(libdir)/`echo $@ | sed "s:\\..*::"`.$(SHLIB_MAJOR).$(SHLIB_LIBSUFF) -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -v'
;; ;;
esac esac

View File

@ -1,6 +1,6 @@
/* terminal.c -- controlling the terminal with termcap. */ /* terminal.c -- controlling the terminal with termcap. */
/* Copyright (C) 1996-2015 Free Software Foundation, Inc. /* Copyright (C) 1996-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -112,6 +112,7 @@ char PC, *BC, *UP;
/* Some strings to control terminal actions. These are output by tputs (). */ /* Some strings to control terminal actions. These are output by tputs (). */
char *_rl_term_clreol; char *_rl_term_clreol;
char *_rl_term_clrpag; char *_rl_term_clrpag;
char *_rl_term_clrscroll;
char *_rl_term_cr; char *_rl_term_cr;
char *_rl_term_backspace; char *_rl_term_backspace;
char *_rl_term_goto; char *_rl_term_goto;
@ -131,6 +132,7 @@ char *_rl_term_IC;
char *_rl_term_dc; char *_rl_term_dc;
char *_rl_term_DC; char *_rl_term_DC;
/* How to move forward a char, non-destructively */
char *_rl_term_forward_char; char *_rl_term_forward_char;
/* How to go up a line. */ /* How to go up a line. */
@ -188,8 +190,7 @@ int _rl_enable_meta = 1;
#if defined (__EMX__) #if defined (__EMX__)
static void static void
_emx_get_screensize (swp, shp) _emx_get_screensize (int *swp, int *shp)
int *swp, *shp;
{ {
int sz[2]; int sz[2];
@ -204,8 +205,7 @@ _emx_get_screensize (swp, shp)
#if defined (__MINGW32__) #if defined (__MINGW32__)
static void static void
_win_get_screensize (swp, shp) _win_get_screensize (int *swp, int *shp)
int *swp, *shp;
{ {
HANDLE hConOut; HANDLE hConOut;
CONSOLE_SCREEN_BUFFER_INFO scr; CONSOLE_SCREEN_BUFFER_INFO scr;
@ -227,8 +227,7 @@ _win_get_screensize (swp, shp)
values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being
non-null serve to check whether or not we have initialized termcap. */ non-null serve to check whether or not we have initialized termcap. */
void void
_rl_get_screen_size (tty, ignore_env) _rl_get_screen_size (int tty, int ignore_env)
int tty, ignore_env;
{ {
char *ss; char *ss;
#if defined (TIOCGWINSZ) #if defined (TIOCGWINSZ)
@ -318,8 +317,7 @@ _rl_get_screen_size (tty, ignore_env)
} }
void void
_rl_set_screen_size (rows, cols) _rl_set_screen_size (int rows, int cols)
int rows, cols;
{ {
if (_rl_term_autowrap == -1) if (_rl_term_autowrap == -1)
_rl_init_terminal_io (rl_terminal_name); _rl_init_terminal_io (rl_terminal_name);
@ -338,15 +336,13 @@ _rl_set_screen_size (rows, cols)
} }
void void
rl_set_screen_size (rows, cols) rl_set_screen_size (int rows, int cols)
int rows, cols;
{ {
_rl_set_screen_size (rows, cols); _rl_set_screen_size (rows, cols);
} }
void void
rl_get_screen_size (rows, cols) rl_get_screen_size (int *rows, int *cols)
int *rows, *cols;
{ {
if (rows) if (rows)
*rows = _rl_screenheight; *rows = _rl_screenheight;
@ -355,19 +351,19 @@ rl_get_screen_size (rows, cols)
} }
void void
rl_reset_screen_size () rl_reset_screen_size (void)
{ {
_rl_get_screen_size (fileno (rl_instream), 0); _rl_get_screen_size (fileno (rl_instream), 0);
} }
void void
_rl_sigwinch_resize_terminal () _rl_sigwinch_resize_terminal (void)
{ {
_rl_get_screen_size (fileno (rl_instream), 1); _rl_get_screen_size (fileno (rl_instream), 1);
} }
void void
rl_resize_terminal () rl_resize_terminal (void)
{ {
_rl_get_screen_size (fileno (rl_instream), 1); _rl_get_screen_size (fileno (rl_instream), 1);
if (_rl_echoing_p) if (_rl_echoing_p)
@ -390,6 +386,7 @@ static const struct _tc_string tc_strings[] =
{ {
{ "@7", &_rl_term_at7 }, { "@7", &_rl_term_at7 },
{ "DC", &_rl_term_DC }, { "DC", &_rl_term_DC },
{ "E3", &_rl_term_clrscroll },
{ "IC", &_rl_term_IC }, { "IC", &_rl_term_IC },
{ "ce", &_rl_term_clreol }, { "ce", &_rl_term_clreol },
{ "cl", &_rl_term_clrpag }, { "cl", &_rl_term_clrpag },
@ -424,8 +421,7 @@ static const struct _tc_string tc_strings[] =
/* Read the desired terminal capability strings into BP. The capabilities /* Read the desired terminal capability strings into BP. The capabilities
are described in the TC_STRINGS table. */ are described in the TC_STRINGS table. */
static void static void
get_term_capabilities (bp) get_term_capabilities (char **bp)
char **bp;
{ {
#if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */ #if !defined (__DJGPP__) /* XXX - doesn't DJGPP have a termcap library? */
register int i; register int i;
@ -437,15 +433,14 @@ get_term_capabilities (bp)
} }
int int
_rl_init_terminal_io (terminal_name) _rl_init_terminal_io (const char *terminal_name)
const char *terminal_name;
{ {
const char *term; const char *term;
char *buffer; char *buffer;
int tty, tgetent_ret; int tty, tgetent_ret;
term = terminal_name ? terminal_name : sh_get_env_value ("TERM"); term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
_rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL; _rl_term_clrpag = _rl_term_cr = _rl_term_clreol = _rl_term_clrscroll = (char *)NULL;
tty = rl_instream ? fileno (rl_instream) : 0; tty = rl_instream ? fileno (rl_instream) : 0;
if (term == 0) if (term == 0)
@ -458,7 +453,7 @@ _rl_init_terminal_io (terminal_name)
_rl_term_mm = _rl_term_mo = (char *)NULL; _rl_term_mm = _rl_term_mo = (char *)NULL;
_rl_terminal_can_insert = term_has_meta = _rl_term_autowrap = 0; _rl_terminal_can_insert = term_has_meta = _rl_term_autowrap = 0;
_rl_term_cr = "\r"; _rl_term_cr = "\r";
_rl_term_clreol = _rl_term_clrpag = _rl_term_backspace = (char *)NULL; _rl_term_backspace = (char *)NULL;
_rl_term_goto = _rl_term_pc = _rl_term_ip = (char *)NULL; _rl_term_goto = _rl_term_pc = _rl_term_ip = (char *)NULL;
_rl_term_ks = _rl_term_ke =_rl_term_vs = _rl_term_ve = (char *)NULL; _rl_term_ks = _rl_term_ke =_rl_term_vs = _rl_term_ve = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL; _rl_term_kh = _rl_term_kH = _rl_term_at7 = _rl_term_kI = (char *)NULL;
@ -584,8 +579,7 @@ _rl_init_terminal_io (terminal_name)
/* Bind the arrow key sequences from the termcap description in MAP. */ /* Bind the arrow key sequences from the termcap description in MAP. */
static void static void
bind_termcap_arrow_keys (map) bind_termcap_arrow_keys (Keymap map)
Keymap map;
{ {
Keymap xkeymap; Keymap xkeymap;
@ -601,13 +595,13 @@ bind_termcap_arrow_keys (map)
rl_bind_keyseq_if_unbound (_rl_term_at7, rl_end_of_line); /* End */ rl_bind_keyseq_if_unbound (_rl_term_at7, rl_end_of_line); /* End */
rl_bind_keyseq_if_unbound (_rl_term_kD, rl_delete); rl_bind_keyseq_if_unbound (_rl_term_kD, rl_delete);
rl_bind_keyseq_if_unbound (_rl_term_kI, rl_overwrite_mode); /* Insert */
_rl_keymap = xkeymap; _rl_keymap = xkeymap;
} }
char * char *
rl_get_termcap (cap) rl_get_termcap (const char *cap)
const char *cap;
{ {
register int i; register int i;
@ -624,8 +618,7 @@ rl_get_termcap (cap)
/* Re-initialize the terminal considering that the TERM/TERMCAP variable /* Re-initialize the terminal considering that the TERM/TERMCAP variable
has changed. */ has changed. */
int int
rl_reset_terminal (terminal_name) rl_reset_terminal (const char *terminal_name)
const char *terminal_name;
{ {
_rl_screenwidth = _rl_screenheight = 0; _rl_screenwidth = _rl_screenheight = 0;
_rl_init_terminal_io (terminal_name); _rl_init_terminal_io (terminal_name);
@ -635,15 +628,13 @@ rl_reset_terminal (terminal_name)
/* A function for the use of tputs () */ /* A function for the use of tputs () */
#ifdef _MINIX #ifdef _MINIX
void void
_rl_output_character_function (c) _rl_output_character_function (int c)
int c;
{ {
putc (c, _rl_out_stream); putc (c, _rl_out_stream);
} }
#else /* !_MINIX */ #else /* !_MINIX */
int int
_rl_output_character_function (c) _rl_output_character_function (int c)
int c;
{ {
return putc (c, _rl_out_stream); return putc (c, _rl_out_stream);
} }
@ -651,17 +642,14 @@ _rl_output_character_function (c)
/* Write COUNT characters from STRING to the output stream. */ /* Write COUNT characters from STRING to the output stream. */
void void
_rl_output_some_chars (string, count) _rl_output_some_chars (const char *string, int count)
const char *string;
int count;
{ {
fwrite (string, 1, count, _rl_out_stream); fwrite (string, 1, count, _rl_out_stream);
} }
/* Move the cursor back. */ /* Move the cursor back. */
int int
_rl_backspace (count) _rl_backspace (int count)
int count;
{ {
register int i; register int i;
@ -678,7 +666,7 @@ _rl_backspace (count)
/* Move to the start of the next line. */ /* Move to the start of the next line. */
int int
rl_crlf () rl_crlf (void)
{ {
#if defined (NEW_TTY_DRIVER) || defined (__MINT__) #if defined (NEW_TTY_DRIVER) || defined (__MINT__)
if (_rl_term_cr) if (_rl_term_cr)
@ -690,7 +678,7 @@ rl_crlf ()
/* Ring the terminal bell. */ /* Ring the terminal bell. */
int int
rl_ding () rl_ding (void)
{ {
if (_rl_echoing_p) if (_rl_echoing_p)
{ {
@ -729,7 +717,7 @@ rl_ding ()
static int enabled_meta = 0; /* flag indicating we enabled meta mode */ static int enabled_meta = 0; /* flag indicating we enabled meta mode */
void void
_rl_enable_meta_key () _rl_enable_meta_key (void)
{ {
#if !defined (__DJGPP__) #if !defined (__DJGPP__)
if (term_has_meta && _rl_term_mm) if (term_has_meta && _rl_term_mm)
@ -741,7 +729,7 @@ _rl_enable_meta_key ()
} }
void void
_rl_disable_meta_key () _rl_disable_meta_key (void)
{ {
#if !defined (__DJGPP__) #if !defined (__DJGPP__)
if (term_has_meta && _rl_term_mo && enabled_meta) if (term_has_meta && _rl_term_mo && enabled_meta)
@ -753,8 +741,7 @@ _rl_disable_meta_key ()
} }
void void
_rl_control_keypad (on) _rl_control_keypad (int on)
int on;
{ {
#if !defined (__DJGPP__) #if !defined (__DJGPP__)
if (on && _rl_term_ks) if (on && _rl_term_ks)
@ -775,8 +762,7 @@ _rl_control_keypad (on)
cursor. Overwrite mode gets a very visible cursor. Only does cursor. Overwrite mode gets a very visible cursor. Only does
anything if we have both capabilities. */ anything if we have both capabilities. */
void void
_rl_set_cursor (im, force) _rl_set_cursor (int im, int force)
int im, force;
{ {
#ifndef __MSDOS__ #ifndef __MSDOS__
if (_rl_term_ve && _rl_term_vs) if (_rl_term_ve && _rl_term_vs)

View File

@ -1,6 +1,6 @@
/* text.c -- text handling commands for readline. */ /* text.c -- text handling commands for readline. */
/* Copyright (C) 1987-2016 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -83,8 +83,7 @@ int _rl_optimize_typeahead = 1; /* rl_insert tries to read typeahead */
way that you should do insertion. _rl_insert_char () calls this way that you should do insertion. _rl_insert_char () calls this
function. Returns the number of characters inserted. */ function. Returns the number of characters inserted. */
int int
rl_insert_text (string) rl_insert_text (const char *string)
const char *string;
{ {
register int i, l; register int i, l;
@ -121,8 +120,7 @@ rl_insert_text (string)
/* Delete the string between FROM and TO. FROM is inclusive, TO is not. /* Delete the string between FROM and TO. FROM is inclusive, TO is not.
Returns the number of characters deleted. */ Returns the number of characters deleted. */
int int
rl_delete_text (from, to) rl_delete_text (int from, int to)
int from, to;
{ {
register char *text; register char *text;
register int diff, i; register int diff, i;
@ -172,8 +170,7 @@ rl_delete_text (from, to)
} while (0) } while (0)
void void
_rl_fix_point (fix_mark_too) _rl_fix_point (int fix_mark_too)
int fix_mark_too;
{ {
_RL_FIX_POINT (rl_point); _RL_FIX_POINT (rl_point);
if (fix_mark_too) if (fix_mark_too)
@ -185,9 +182,7 @@ _rl_fix_point (fix_mark_too)
TEXT. The operation is undoable. To replace the entire line in an TEXT. The operation is undoable. To replace the entire line in an
undoable mode, use _rl_replace_text(text, 0, rl_end); */ undoable mode, use _rl_replace_text(text, 0, rl_end); */
int int
_rl_replace_text (text, start, end) _rl_replace_text (const char *text, int start, int end)
const char *text;
int start, end;
{ {
int n; int n;
@ -206,9 +201,7 @@ _rl_replace_text (text, start, end)
/* Replace the current line buffer contents with TEXT. If CLEAR_UNDO is /* Replace the current line buffer contents with TEXT. If CLEAR_UNDO is
non-zero, we free the current undo list. */ non-zero, we free the current undo list. */
void void
rl_replace_line (text, clear_undo) rl_replace_line (const char *text, int clear_undo)
const char *text;
int clear_undo;
{ {
int len; int len;
@ -259,8 +252,7 @@ rl_replace_line (text, clear_undo)
/* Move forward COUNT bytes. */ /* Move forward COUNT bytes. */
int int
rl_forward_byte (count, key) rl_forward_byte (int count, int key)
int count, key;
{ {
if (count < 0) if (count < 0)
return (rl_backward_byte (-count, key)); return (rl_backward_byte (-count, key));
@ -292,8 +284,7 @@ rl_forward_byte (count, key)
} }
int int
_rl_forward_char_internal (count) _rl_forward_char_internal (int count)
int count;
{ {
int point; int point;
@ -306,21 +297,47 @@ _rl_forward_char_internal (count)
#endif #endif
if (rl_end < 0) if (rl_end < 0)
rl_end = 0; rl_end = 0;
#else #else
point = rl_point + count; point = rl_point + count;
if (point > rl_end)
point = rl_end;
#endif #endif
if (point > rl_end)
point = rl_end;
return (point);
}
int
_rl_backward_char_internal (int count)
{
int point;
point = rl_point;
#if defined (HANDLE_MULTIBYTE)
if (count > 0)
{
while (count > 0 && point > 0)
{
point = _rl_find_prev_mbchar (rl_line_buffer, point, MB_FIND_NONZERO);
count--;
}
if (count > 0)
return 0; /* XXX - rl_ding() here? */
}
#else
if (count > 0)
point -= count;
#endif
if (point < 0)
point = 0;
return (point); return (point);
} }
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
/* Move forward COUNT characters. */ /* Move forward COUNT characters. */
int int
rl_forward_char (count, key) rl_forward_char (int count, int key)
int count, key;
{ {
int point; int point;
@ -350,8 +367,7 @@ rl_forward_char (count, key)
} }
#else /* !HANDLE_MULTIBYTE */ #else /* !HANDLE_MULTIBYTE */
int int
rl_forward_char (count, key) rl_forward_char (int count, int key)
int count, key;
{ {
return (rl_forward_byte (count, key)); return (rl_forward_byte (count, key));
} }
@ -359,16 +375,14 @@ rl_forward_char (count, key)
/* Backwards compatibility. */ /* Backwards compatibility. */
int int
rl_forward (count, key) rl_forward (int count, int key)
int count, key;
{ {
return (rl_forward_char (count, key)); return (rl_forward_char (count, key));
} }
/* Move backward COUNT bytes. */ /* Move backward COUNT bytes. */
int int
rl_backward_byte (count, key) rl_backward_byte (int count, int key)
int count, key;
{ {
if (count < 0) if (count < 0)
return (rl_forward_byte (-count, key)); return (rl_forward_byte (-count, key));
@ -393,8 +407,7 @@ rl_backward_byte (count, key)
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
/* Move backward COUNT characters. */ /* Move backward COUNT characters. */
int int
rl_backward_char (count, key) rl_backward_char (int count, int key)
int count, key;
{ {
int point; int point;
@ -426,8 +439,7 @@ rl_backward_char (count, key)
} }
#else #else
int int
rl_backward_char (count, key) rl_backward_char (int count, int key)
int count, key;
{ {
return (rl_backward_byte (count, key)); return (rl_backward_byte (count, key));
} }
@ -435,16 +447,14 @@ rl_backward_char (count, key)
/* Backwards compatibility. */ /* Backwards compatibility. */
int int
rl_backward (count, key) rl_backward (int count, int key)
int count, key;
{ {
return (rl_backward_char (count, key)); return (rl_backward_char (count, key));
} }
/* Move to the beginning of the line. */ /* Move to the beginning of the line. */
int int
rl_beg_of_line (count, key) rl_beg_of_line (int count, int key)
int count, key;
{ {
rl_point = 0; rl_point = 0;
return 0; return 0;
@ -452,8 +462,7 @@ rl_beg_of_line (count, key)
/* Move to the end of the line. */ /* Move to the end of the line. */
int int
rl_end_of_line (count, key) rl_end_of_line (int count, int key)
int count, key;
{ {
rl_point = rl_end; rl_point = rl_end;
return 0; return 0;
@ -461,8 +470,7 @@ rl_end_of_line (count, key)
/* Move forward a word. We do what Emacs does. Handles multibyte chars. */ /* Move forward a word. We do what Emacs does. Handles multibyte chars. */
int int
rl_forward_word (count, key) rl_forward_word (int count, int key)
int count, key;
{ {
int c; int c;
@ -510,8 +518,7 @@ rl_forward_word (count, key)
/* Move backward a word. We do what Emacs does. Handles multibyte chars. */ /* Move backward a word. We do what Emacs does. Handles multibyte chars. */
int int
rl_backward_word (count, key) rl_backward_word (int count, int key)
int count, key;
{ {
int c, p; int c, p;
@ -560,8 +567,7 @@ rl_backward_word (count, key)
/* Clear the current line. Numeric argument to C-l does this. */ /* Clear the current line. Numeric argument to C-l does this. */
int int
rl_refresh_line (ignore1, ignore2) rl_refresh_line (int ignore1, int ignore2)
int ignore1, ignore2;
{ {
int curr_line; int curr_line;
@ -582,8 +588,7 @@ rl_refresh_line (ignore1, ignore2)
the prompt and the current input line. Given a numeric arg, redraw only the prompt and the current input line. Given a numeric arg, redraw only
the current line. */ the current line. */
int int
rl_clear_screen (count, key) rl_clear_screen (int count, int key)
int count, key;
{ {
if (rl_explicit_arg) if (rl_explicit_arg)
{ {
@ -599,8 +604,25 @@ rl_clear_screen (count, key)
} }
int int
rl_skip_csi_sequence (count, key) rl_previous_screen_line (int count, int key)
int count, key; {
int c;
c = _rl_term_autowrap ? _rl_screenwidth : (_rl_screenwidth + 1);
return (rl_backward_char (c, key));
}
int
rl_next_screen_line (int count, int key)
{
int c;
c = _rl_term_autowrap ? _rl_screenwidth : (_rl_screenwidth + 1);
return (rl_forward_char (c, key));
}
int
rl_skip_csi_sequence (int count, int key)
{ {
int ch; int ch;
@ -614,8 +636,7 @@ rl_skip_csi_sequence (count, key)
} }
int int
rl_arrow_keys (count, c) rl_arrow_keys (int count, int key)
int count, c;
{ {
int ch; int ch;
@ -672,8 +693,7 @@ static mbstate_t ps = {0};
If C introduces a multibyte sequence, we read the whole sequence and If C introduces a multibyte sequence, we read the whole sequence and
then insert the multibyte char into the line buffer. */ then insert the multibyte char into the line buffer. */
int int
_rl_insert_char (count, c) _rl_insert_char (int count, int c)
int count, c;
{ {
register int i; register int i;
char *string; char *string;
@ -695,6 +715,12 @@ _rl_insert_char (count, c)
incoming[1] = '\0'; incoming[1] = '\0';
incoming_length = 1; incoming_length = 1;
} }
else if (_rl_utf8locale && (c & 0x80) == 0)
{
incoming[0] = c;
incoming[1] = '\0';
incoming_length = 1;
}
else else
{ {
wchar_t wc; wchar_t wc;
@ -739,6 +765,12 @@ _rl_insert_char (count, c)
effect of mbstate is undefined. */ effect of mbstate is undefined. */
memset (&ps, 0, sizeof (mbstate_t)); memset (&ps, 0, sizeof (mbstate_t));
} }
else if (ret == 1)
{
incoming[0] = pending_bytes[0];
incoming[incoming_length = 1] = '\0';
pending_bytes_length = 0;
}
else else
{ {
/* We successfully read a single multibyte character. */ /* We successfully read a single multibyte character. */
@ -761,8 +793,13 @@ _rl_insert_char (count, c)
i = 0; i = 0;
while (i < string_size) while (i < string_size)
{ {
strncpy (string + i, incoming, incoming_length); if (incoming_length == 1)
i += incoming_length; string[i++] = *incoming;
else
{
strncpy (string + i, incoming, incoming_length);
i += incoming_length;
}
} }
incoming_length = 0; incoming_length = 0;
stored_count = 0; stored_count = 0;
@ -790,8 +827,13 @@ _rl_insert_char (count, c)
i = 0; i = 0;
while (i < string_size) while (i < string_size)
{ {
strncpy (string + i, incoming, incoming_length); if (incoming_length == 1)
i += incoming_length; string[i++] = *incoming;
else
{
strncpy (string + i, incoming, incoming_length);
i += incoming_length;
}
} }
while (count) while (count)
@ -857,8 +899,7 @@ _rl_insert_char (count, c)
If C introduces a multibyte character sequence, read the entire sequence If C introduces a multibyte character sequence, read the entire sequence
before starting the overwrite loop. */ before starting the overwrite loop. */
int int
_rl_overwrite_char (count, c) _rl_overwrite_char (int count, int c)
int count, c;
{ {
int i; int i;
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
@ -891,8 +932,7 @@ _rl_overwrite_char (count, c)
} }
int int
rl_insert (count, c) rl_insert (int count, int c)
int count, c;
{ {
int r, n, x; int r, n, x;
@ -902,6 +942,7 @@ rl_insert (count, c)
x = 0; x = 0;
n = (unsigned short)-2; n = (unsigned short)-2;
while (_rl_optimize_typeahead && while (_rl_optimize_typeahead &&
rl_num_chars_to_read == 0 &&
(RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) && (RL_ISSTATE (RL_STATE_INPUTPENDING|RL_STATE_MACROINPUT) == 0) &&
_rl_pushed_input_available () == 0 && _rl_pushed_input_available () == 0 &&
_rl_input_queued (0) && _rl_input_queued (0) &&
@ -941,8 +982,7 @@ rl_insert (count, c)
/* Insert the next typed character verbatim. */ /* Insert the next typed character verbatim. */
static int static int
_rl_insert_next (count) _rl_insert_next (int count)
int count;
{ {
int c; int c;
@ -966,24 +1006,37 @@ _rl_insert_next (count)
#if defined (READLINE_CALLBACKS) #if defined (READLINE_CALLBACKS)
static int static int
_rl_insert_next_callback (data) _rl_insert_next_callback (_rl_callback_generic_arg *data)
_rl_callback_generic_arg *data;
{ {
int count; int count, r;
count = data->count; count = data->count;
r = 0;
if (count < 0)
{
data->count++;
r = _rl_insert_next (1);
_rl_want_redisplay = 1;
/* If we should keep going, leave the callback function installed */
if (data->count < 0 && r == 0)
return r;
count = 0; /* data->count == 0 || r != 0; force break below */
}
/* Deregister function, let rl_callback_read_char deallocate data */ /* Deregister function, let rl_callback_read_char deallocate data */
_rl_callback_func = 0; _rl_callback_func = 0;
_rl_want_redisplay = 1; _rl_want_redisplay = 1;
if (count == 0)
return r;
return _rl_insert_next (count); return _rl_insert_next (count);
} }
#endif #endif
int int
rl_quoted_insert (count, key) rl_quoted_insert (int count, int key)
int count, key;
{ {
/* Let's see...should the callback interface futz with signal handling? */ /* Let's see...should the callback interface futz with signal handling? */
#if defined (HANDLE_SIGNALS) #if defined (HANDLE_SIGNALS)
@ -999,14 +1052,24 @@ rl_quoted_insert (count, key)
return (0); return (0);
} }
#endif #endif
/* A negative count means to quote the next -COUNT characters. */
if (count < 0)
{
int r;
do
r = _rl_insert_next (1);
while (r == 0 && ++count < 0);
return r;
}
return _rl_insert_next (count); return _rl_insert_next (count);
} }
/* Insert a tab character. */ /* Insert a tab character. */
int int
rl_tab_insert (count, key) rl_tab_insert (int count, int key)
int count, key;
{ {
return (_rl_insert_char (count, '\t')); return (_rl_insert_char (count, '\t'));
} }
@ -1015,8 +1078,7 @@ rl_tab_insert (count, key)
KEY is the key that invoked this command. I guess it could have KEY is the key that invoked this command. I guess it could have
meaning in the future. */ meaning in the future. */
int int
rl_newline (count, key) rl_newline (int count, int key)
int count, key;
{ {
rl_done = 1; rl_done = 1;
@ -1049,8 +1111,7 @@ rl_newline (count, key)
is just a stub, you bind keys to it and the code in _rl_dispatch () is just a stub, you bind keys to it and the code in _rl_dispatch ()
is special cased. */ is special cased. */
int int
rl_do_lowercase_version (ignore1, ignore2) rl_do_lowercase_version (int ignore1, int ignore2)
int ignore1, ignore2;
{ {
return 0; return 0;
} }
@ -1059,8 +1120,7 @@ rl_do_lowercase_version (ignore1, ignore2)
rubout in overwrite mode has one oddity: it replaces a control rubout in overwrite mode has one oddity: it replaces a control
character that's displayed as two characters (^X) with two spaces. */ character that's displayed as two characters (^X) with two spaces. */
int int
_rl_overwrite_rubout (count, key) _rl_overwrite_rubout (int count, int key)
int count, key;
{ {
int opoint; int opoint;
int i, l; int i, l;
@ -1102,8 +1162,7 @@ _rl_overwrite_rubout (count, key)
/* Rubout the character behind point. */ /* Rubout the character behind point. */
int int
rl_rubout (count, key) rl_rubout (int count, int key)
int count, key;
{ {
if (count < 0) if (count < 0)
return (rl_delete (-count, key)); return (rl_delete (-count, key));
@ -1121,8 +1180,7 @@ rl_rubout (count, key)
} }
int int
_rl_rubout_char (count, key) _rl_rubout_char (int count, int key)
int count, key;
{ {
int orig_point; int orig_point;
unsigned char c; unsigned char c;
@ -1167,8 +1225,7 @@ _rl_rubout_char (count, key)
/* Delete the character under the cursor. Given a numeric argument, /* Delete the character under the cursor. Given a numeric argument,
kill that many characters instead. */ kill that many characters instead. */
int int
rl_delete (count, key) rl_delete (int count, int key)
int count, key;
{ {
int xpoint; int xpoint;
@ -1205,8 +1262,7 @@ rl_delete (count, key)
behind the cursor is deleted. COUNT is obeyed and may be used behind the cursor is deleted. COUNT is obeyed and may be used
to delete forward or backward that many characters. */ to delete forward or backward that many characters. */
int int
rl_rubout_or_delete (count, key) rl_rubout_or_delete (int count, int key)
int count, key;
{ {
if (rl_end != 0 && rl_point == rl_end) if (rl_end != 0 && rl_point == rl_end)
return (_rl_rubout_char (count, key)); return (_rl_rubout_char (count, key));
@ -1216,8 +1272,7 @@ rl_rubout_or_delete (count, key)
/* Delete all spaces and tabs around point. */ /* Delete all spaces and tabs around point. */
int int
rl_delete_horizontal_space (count, ignore) rl_delete_horizontal_space (int count, int ignore)
int count, ignore;
{ {
int start; int start;
@ -1245,8 +1300,7 @@ rl_delete_horizontal_space (count, ignore)
is caught before this is invoked, so this really does the same thing as is caught before this is invoked, so this really does the same thing as
delete-char-or-list-or-eof, as long as it's bound to the eof character. */ delete-char-or-list-or-eof, as long as it's bound to the eof character. */
int int
rl_delete_or_show_completions (count, key) rl_delete_or_show_completions (int count, int key)
int count, key;
{ {
if (rl_end != 0 && rl_point == rl_end) if (rl_end != 0 && rl_point == rl_end)
return (rl_possible_completions (count, key)); return (rl_possible_completions (count, key));
@ -1261,8 +1315,7 @@ rl_delete_or_show_completions (count, key)
/* Turn the current line into a comment in shell history. /* Turn the current line into a comment in shell history.
A K*rn shell style function. */ A K*rn shell style function. */
int int
rl_insert_comment (count, key) rl_insert_comment (int count, int key)
int count, key;
{ {
char *rl_comment_text; char *rl_comment_text;
int rl_comment_len; int rl_comment_len;
@ -1300,24 +1353,21 @@ rl_insert_comment (count, key)
/* Uppercase the word at point. */ /* Uppercase the word at point. */
int int
rl_upcase_word (count, key) rl_upcase_word (int count, int key)
int count, key;
{ {
return (rl_change_case (count, UpCase)); return (rl_change_case (count, UpCase));
} }
/* Lowercase the word at point. */ /* Lowercase the word at point. */
int int
rl_downcase_word (count, key) rl_downcase_word (int count, int key)
int count, key;
{ {
return (rl_change_case (count, DownCase)); return (rl_change_case (count, DownCase));
} }
/* Upcase the first letter, downcase the rest. */ /* Upcase the first letter, downcase the rest. */
int int
rl_capitalize_word (count, key) rl_capitalize_word (int count, int key)
int count, key;
{ {
return (rl_change_case (count, CapCase)); return (rl_change_case (count, CapCase));
} }
@ -1328,11 +1378,11 @@ rl_capitalize_word (count, key)
If a negative argument is given, leave point where it started, If a negative argument is given, leave point where it started,
otherwise, leave it where it moves to. */ otherwise, leave it where it moves to. */
static int static int
rl_change_case (count, op) rl_change_case (int count, int op)
int count, op;
{ {
int start, next, end; int start, next, end;
int inword, c, nc, nop; int inword, nc, nop;
wchar_t c;
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
wchar_t wc, nwc; wchar_t wc, nwc;
char mb[MB_LEN_MAX+1]; char mb[MB_LEN_MAX+1];
@ -1382,7 +1432,10 @@ rl_change_case (count, op)
} }
else else
nop = op; nop = op;
if (MB_CUR_MAX == 1 || rl_byte_oriented || isascii ((unsigned char)c)) /* Can't check isascii here; some languages (e.g, Turkish) have
multibyte upper and lower case equivalents of single-byte ascii
characters */
if (MB_CUR_MAX == 1 || rl_byte_oriented)
{ {
nc = (nop == UpCase) ? _rl_to_upper (c) : _rl_to_lower (c); nc = (nop == UpCase) ? _rl_to_upper (c) : _rl_to_lower (c);
rl_line_buffer[start] = nc; rl_line_buffer[start] = nc;
@ -1398,11 +1451,35 @@ rl_change_case (count, op)
nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc); nwc = (nop == UpCase) ? _rl_to_wupper (wc) : _rl_to_wlower (wc);
if (nwc != wc) /* just skip unchanged characters */ if (nwc != wc) /* just skip unchanged characters */
{ {
char *s, *e;
mlen = wcrtomb (mb, nwc, &mps); mlen = wcrtomb (mb, nwc, &mps);
if (mlen > 0) if (mlen > 0)
mb[mlen] = '\0'; mb[mlen] = '\0';
/* Assume the same width */ /* what to do if m != mlen? adjust below */
strncpy (rl_line_buffer + start, mb, mlen); /* m == length of old char, mlen == length of new char */
s = rl_line_buffer + start;
e = rl_line_buffer + rl_end;
if (m == mlen)
memcpy (s, mb, mlen);
else if (m > mlen)
{
memcpy (s, mb, mlen);
memmove (s + mlen, s + m, (e - s) - m);
next -= m - mlen; /* next char changes */
end -= m - mlen; /* end of word changes */
rl_end -= m - mlen; /* end of line changes */
rl_line_buffer[rl_end] = 0;
}
else if (m < mlen)
{
rl_extend_line_buffer (mlen - m + 1);
memmove (s + mlen, s + m, (e - s) - m);
memcpy (s, mb, mlen);
next += mlen - m; /* next char changes */
end += mlen - m; /* end of word changes */
rl_end += mlen - m; /* end of line changes */
rl_line_buffer[rl_end] = 0;
}
} }
} }
#endif #endif
@ -1423,8 +1500,7 @@ rl_change_case (count, op)
/* Transpose the words at point. If point is at the end of the line, /* Transpose the words at point. If point is at the end of the line,
transpose the two words before point. */ transpose the two words before point. */
int int
rl_transpose_words (count, key) rl_transpose_words (int count, int key)
int count, key;
{ {
char *word1, *word2; char *word1, *word2;
int w1_beg, w1_end, w2_beg, w2_end; int w1_beg, w1_end, w2_beg, w2_end;
@ -1484,8 +1560,7 @@ rl_transpose_words (count, key)
/* Transpose the characters at point. If point is at the end of the line, /* Transpose the characters at point. If point is at the end of the line,
then transpose the characters before point. */ then transpose the characters before point. */
int int
rl_transpose_chars (count, key) rl_transpose_chars (int count, int key)
int count, key;
{ {
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
char *dummy; char *dummy;
@ -1549,13 +1624,9 @@ rl_transpose_chars (count, key)
int int
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
_rl_char_search_internal (count, dir, smbchar, len) _rl_char_search_internal (int count, int dir, char *smbchar, int len)
int count, dir;
char *smbchar;
int len;
#else #else
_rl_char_search_internal (count, dir, schar) _rl_char_search_internal (int count, int dir, int schar)
int count, dir, schar;
#endif #endif
{ {
int pos, inc; int pos, inc;
@ -1619,8 +1690,7 @@ _rl_char_search_internal (count, dir, schar)
that there are two separate versions of this function. */ that there are two separate versions of this function. */
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
static int static int
_rl_char_search (count, fdir, bdir) _rl_char_search (int count, int fdir, int bdir)
int count, fdir, bdir;
{ {
char mbchar[MB_LEN_MAX]; char mbchar[MB_LEN_MAX];
int mb_len; int mb_len;
@ -1637,8 +1707,7 @@ _rl_char_search (count, fdir, bdir)
} }
#else /* !HANDLE_MULTIBYTE */ #else /* !HANDLE_MULTIBYTE */
static int static int
_rl_char_search (count, fdir, bdir) _rl_char_search (int count, int fdir, int bdir)
int count, fdir, bdir;
{ {
int c; int c;
@ -1669,8 +1738,7 @@ _rl_char_search_callback (data)
#endif #endif
int int
rl_char_search (count, key) rl_char_search (int count, int key)
int count, key;
{ {
#if defined (READLINE_CALLBACKS) #if defined (READLINE_CALLBACKS)
if (RL_ISSTATE (RL_STATE_CALLBACK)) if (RL_ISSTATE (RL_STATE_CALLBACK))
@ -1687,8 +1755,7 @@ rl_char_search (count, key)
} }
int int
rl_backward_char_search (count, key) rl_backward_char_search (int count, int key)
int count, key;
{ {
#if defined (READLINE_CALLBACKS) #if defined (READLINE_CALLBACKS)
if (RL_ISSTATE (RL_STATE_CALLBACK)) if (RL_ISSTATE (RL_STATE_CALLBACK))
@ -1712,10 +1779,9 @@ rl_backward_char_search (count, key)
/* Set the mark at POSITION. */ /* Set the mark at POSITION. */
int int
_rl_set_mark_at_pos (position) _rl_set_mark_at_pos (int position)
int position;
{ {
if (position > rl_end) if (position < 0 || position > rl_end)
return 1; return 1;
rl_mark = position; rl_mark = position;
@ -1724,23 +1790,22 @@ _rl_set_mark_at_pos (position)
/* A bindable command to set the mark. */ /* A bindable command to set the mark. */
int int
rl_set_mark (count, key) rl_set_mark (int count, int key)
int count, key;
{ {
return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point)); return (_rl_set_mark_at_pos (rl_explicit_arg ? count : rl_point));
} }
/* Exchange the position of mark and point. */ /* Exchange the position of mark and point. */
int int
rl_exchange_point_and_mark (count, key) rl_exchange_point_and_mark (int count, int key)
int count, key;
{ {
if (rl_mark > rl_end) if (rl_mark > rl_end)
rl_mark = -1; rl_mark = -1;
if (rl_mark == -1) if (rl_mark < 0)
{ {
rl_ding (); rl_ding ();
rl_mark = 0; /* like _RL_FIX_POINT */
return 1; return 1;
} }
else else

View File

@ -1,6 +1,6 @@
/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */ /* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */
/* Copyright (C) 1988-2009 Free Software Foundation, Inc. /* Copyright (C) 1988-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -125,9 +125,7 @@ static char *glue_prefix_and_suffix PARAMS((char *, const char *, int));
the tilde which starts the expansion. Place the length of the text the tilde which starts the expansion. Place the length of the text
which identified this tilde starter in LEN, excluding the tilde itself. */ which identified this tilde starter in LEN, excluding the tilde itself. */
static int static int
tilde_find_prefix (string, len) tilde_find_prefix (const char *string, int *len)
const char *string;
int *len;
{ {
register int i, j, string_len; register int i, j, string_len;
register char **prefixes; register char **prefixes;
@ -160,8 +158,7 @@ tilde_find_prefix (string, len)
/* Find the end of a tilde expansion in STRING, and return the index of /* Find the end of a tilde expansion in STRING, and return the index of
the character which ends the tilde definition. */ the character which ends the tilde definition. */
static int static int
tilde_find_suffix (string) tilde_find_suffix (const char *string)
const char *string;
{ {
register int i, j, string_len; register int i, j, string_len;
register char **suffixes; register char **suffixes;
@ -189,8 +186,7 @@ tilde_find_suffix (string)
/* Return a new string which is the result of tilde expanding STRING. */ /* Return a new string which is the result of tilde expanding STRING. */
char * char *
tilde_expand (string) tilde_expand (const char *string)
const char *string;
{ {
char *result; char *result;
int result_size, result_index; int result_size, result_index;
@ -267,9 +263,7 @@ tilde_expand (string)
non-null, the index of the end of the prefix into FNAME is returned in non-null, the index of the end of the prefix into FNAME is returned in
the location it points to. */ the location it points to. */
static char * static char *
isolate_tilde_prefix (fname, lenp) isolate_tilde_prefix (const char *fname, int *lenp)
const char *fname;
int *lenp;
{ {
char *ret; char *ret;
int i; int i;
@ -293,9 +287,7 @@ isolate_tilde_prefix (fname, lenp)
function. Right now, it just calls tilde_find_suffix and allocates new function. Right now, it just calls tilde_find_suffix and allocates new
memory, but it can be expanded to do different things later. */ memory, but it can be expanded to do different things later. */
char * char *
tilde_find_word (fname, flags, lenp) tilde_find_word (const char *fname, int flags, int *lenp)
const char *fname;
int flags, *lenp;
{ {
int x; int x;
char *r; char *r;
@ -323,10 +315,7 @@ tilde_find_word (fname, flags, lenp)
/* Return a string that is PREFIX concatenated with SUFFIX starting at /* Return a string that is PREFIX concatenated with SUFFIX starting at
SUFFIND. */ SUFFIND. */
static char * static char *
glue_prefix_and_suffix (prefix, suffix, suffind) glue_prefix_and_suffix (char *prefix, const char *suffix, int suffind)
char *prefix;
const char *suffix;
int suffind;
{ {
char *ret; char *ret;
int plen, slen; int plen, slen;
@ -344,8 +333,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
tilde. If there is no expansion, call tilde_expansion_failure_hook. tilde. If there is no expansion, call tilde_expansion_failure_hook.
This always returns a newly-allocated string, never static storage. */ This always returns a newly-allocated string, never static storage. */
char * char *
tilde_expand_word (filename) tilde_expand_word (const char *filename)
const char *filename;
{ {
char *dirname, *expansion, *username; char *dirname, *expansion, *username;
int user_len; int user_len;
@ -434,9 +422,7 @@ tilde_expand_word (filename)
#undef NULL #undef NULL
#include <stdio.h> #include <stdio.h>
main (argc, argv) main (int argc, char **argv)
int argc;
char **argv;
{ {
char *result, line[512]; char *result, line[512];
int done = 0; int done = 0;
@ -464,11 +450,10 @@ main (argc, argv)
exit (0); exit (0);
} }
static void memory_error_and_abort (); static void memory_error_and_abort (void);
static void * static void *
xmalloc (bytes) xmalloc (size_t bytes)
size_t bytes;
{ {
void *temp = (char *)malloc (bytes); void *temp = (char *)malloc (bytes);
@ -478,9 +463,7 @@ xmalloc (bytes)
} }
static void * static void *
xrealloc (pointer, bytes) xrealloc (void *pointer, int bytes)
void *pointer;
int bytes;
{ {
void *temp; void *temp;
@ -496,7 +479,7 @@ xrealloc (pointer, bytes)
} }
static void static void
memory_error_and_abort () memory_error_and_abort (void)
{ {
fprintf (stderr, "readline: out of virtual memory\n"); fprintf (stderr, "readline: out of virtual memory\n");
abort (); abort ();

View File

@ -1,6 +1,6 @@
/* undo.c - manage list of changes to lines, offering opportunity to undo them */ /* undo.c - manage list of changes to lines, offering opportunity to undo them */
/* Copyright (C) 1987-2015 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -51,6 +51,8 @@
extern void _hs_replace_history_data PARAMS((int, histdata_t *, histdata_t *)); extern void _hs_replace_history_data PARAMS((int, histdata_t *, histdata_t *));
extern HIST_ENTRY *_rl_saved_line_for_history;
/* Non-zero tells rl_delete_text and rl_insert_text to not add to /* Non-zero tells rl_delete_text and rl_insert_text to not add to
the undo list. */ the undo list. */
int _rl_doing_an_undo = 0; int _rl_doing_an_undo = 0;
@ -68,10 +70,7 @@ UNDO_LIST *rl_undo_list = (UNDO_LIST *)NULL;
/* **************************************************************** */ /* **************************************************************** */
static UNDO_LIST * static UNDO_LIST *
alloc_undo_entry (what, start, end, text) alloc_undo_entry (enum undo_code what, int start, int end, char *text)
enum undo_code what;
int start, end;
char *text;
{ {
UNDO_LIST *temp; UNDO_LIST *temp;
@ -88,10 +87,7 @@ alloc_undo_entry (what, start, end, text)
/* Remember how to undo something. Concatenate some undos if that /* Remember how to undo something. Concatenate some undos if that
seems right. */ seems right. */
void void
rl_add_undo (what, start, end, text) rl_add_undo (enum undo_code what, int start, int end, char *text)
enum undo_code what;
int start, end;
char *text;
{ {
UNDO_LIST *temp; UNDO_LIST *temp;
@ -102,8 +98,7 @@ rl_add_undo (what, start, end, text)
/* Free an UNDO_LIST */ /* Free an UNDO_LIST */
void void
_rl_free_undo_list (ul) _rl_free_undo_list (UNDO_LIST *ul)
UNDO_LIST *ul;
{ {
UNDO_LIST *release; UNDO_LIST *release;
@ -121,7 +116,7 @@ _rl_free_undo_list (ul)
/* Free the existing undo list. */ /* Free the existing undo list. */
void void
rl_free_undo_list () rl_free_undo_list (void)
{ {
UNDO_LIST *release, *orig_list; UNDO_LIST *release, *orig_list;
@ -132,8 +127,7 @@ rl_free_undo_list ()
} }
UNDO_LIST * UNDO_LIST *
_rl_copy_undo_entry (entry) _rl_copy_undo_entry (UNDO_LIST *entry)
UNDO_LIST *entry;
{ {
UNDO_LIST *new; UNDO_LIST *new;
@ -143,8 +137,7 @@ _rl_copy_undo_entry (entry)
} }
UNDO_LIST * UNDO_LIST *
_rl_copy_undo_list (head) _rl_copy_undo_list (UNDO_LIST *head)
UNDO_LIST *head;
{ {
UNDO_LIST *list, *new, *roving, *c; UNDO_LIST *list, *new, *roving, *c;
@ -173,9 +166,9 @@ _rl_copy_undo_list (head)
/* Undo the next thing in the list. Return 0 if there /* Undo the next thing in the list. Return 0 if there
is nothing to undo, or non-zero if there was. */ is nothing to undo, or non-zero if there was. */
int int
rl_do_undo () rl_do_undo (void)
{ {
UNDO_LIST *release; UNDO_LIST *release, *search;
int waiting_for_begin, start, end; int waiting_for_begin, start, end;
HIST_ENTRY *cur, *temp; HIST_ENTRY *cur, *temp;
@ -232,6 +225,7 @@ rl_do_undo ()
release = rl_undo_list; release = rl_undo_list;
rl_undo_list = rl_undo_list->next; rl_undo_list = rl_undo_list->next;
release->next = 0; /* XXX */
/* If we are editing a history entry, make sure the change is replicated /* If we are editing a history entry, make sure the change is replicated
in the history entry's line */ in the history entry's line */
@ -244,8 +238,30 @@ rl_do_undo ()
xfree (temp); xfree (temp);
} }
/* Make sure there aren't any history entries with that undo list */
_hs_replace_history_data (-1, (histdata_t *)release, (histdata_t *)rl_undo_list); _hs_replace_history_data (-1, (histdata_t *)release, (histdata_t *)rl_undo_list);
/* And make sure this list isn't anywhere in the saved line for history */
if (_rl_saved_line_for_history && _rl_saved_line_for_history->data)
{
/* Brute force; no finesse here */
search = (UNDO_LIST *)_rl_saved_line_for_history->data;
if (search == release)
_rl_saved_line_for_history->data = rl_undo_list;
else
{
while (search->next)
{
if (search->next == release)
{
search->next = rl_undo_list;
break;
}
search = search->next;
}
}
}
xfree (release); xfree (release);
} }
while (waiting_for_begin); while (waiting_for_begin);
@ -255,8 +271,7 @@ rl_do_undo ()
#undef TRANS #undef TRANS
int int
_rl_fix_last_undo_of_type (type, start, end) _rl_fix_last_undo_of_type (int type, int start, int end)
int type, start, end;
{ {
UNDO_LIST *rl; UNDO_LIST *rl;
@ -274,7 +289,7 @@ _rl_fix_last_undo_of_type (type, start, end)
/* Begin a group. Subsequent undos are undone as an atomic operation. */ /* Begin a group. Subsequent undos are undone as an atomic operation. */
int int
rl_begin_undo_group () rl_begin_undo_group (void)
{ {
rl_add_undo (UNDO_BEGIN, 0, 0, 0); rl_add_undo (UNDO_BEGIN, 0, 0, 0);
_rl_undo_group_level++; _rl_undo_group_level++;
@ -283,7 +298,7 @@ rl_begin_undo_group ()
/* End an undo group started with rl_begin_undo_group (). */ /* End an undo group started with rl_begin_undo_group (). */
int int
rl_end_undo_group () rl_end_undo_group (void)
{ {
rl_add_undo (UNDO_END, 0, 0, 0); rl_add_undo (UNDO_END, 0, 0, 0);
_rl_undo_group_level--; _rl_undo_group_level--;
@ -292,8 +307,7 @@ rl_end_undo_group ()
/* Save an undo entry for the text from START to END. */ /* Save an undo entry for the text from START to END. */
int int
rl_modifying (start, end) rl_modifying (int start, int end)
int start, end;
{ {
if (start > end) if (start > end)
{ {
@ -313,8 +327,7 @@ rl_modifying (start, end)
/* Revert the current line to its previous state. */ /* Revert the current line to its previous state. */
int int
rl_revert_line (count, key) rl_revert_line (int count, int key)
int count, key;
{ {
if (rl_undo_list == 0) if (rl_undo_list == 0)
rl_ding (); rl_ding ();
@ -333,8 +346,7 @@ rl_revert_line (count, key)
/* Do some undoing of things that were done. */ /* Do some undoing of things that were done. */
int int
rl_undo_command (count, key) rl_undo_command (int count, int key)
int count, key;
{ {
if (count < 0) if (count < 0)
return 0; /* Nothing to do. */ return 0; /* Nothing to do. */

View File

@ -1,6 +1,6 @@
/* util.c -- readline utility functions */ /* util.c -- readline utility functions */
/* Copyright (C) 1987-2015 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -70,8 +70,7 @@ int _rl_allow_pathname_alphabetic_chars = 0;
static const char * const pathname_alphabetic_chars = "/-_=~.#$"; static const char * const pathname_alphabetic_chars = "/-_=~.#$";
int int
rl_alphabetic (c) rl_alphabetic (int c)
int c;
{ {
if (ALPHABETIC (c)) if (ALPHABETIC (c))
return (1); return (1);
@ -97,7 +96,7 @@ _rl_walphabetic (wchar_t wc)
/* How to abort things. */ /* How to abort things. */
int int
_rl_abort_internal () _rl_abort_internal (void)
{ {
rl_ding (); rl_ding ();
rl_clear_message (); rl_clear_message ();
@ -117,22 +116,19 @@ _rl_abort_internal ()
} }
int int
rl_abort (count, key) rl_abort (int count, int key)
int count, key;
{ {
return (_rl_abort_internal ()); return (_rl_abort_internal ());
} }
int int
_rl_null_function (count, key) _rl_null_function (int count, int key)
int count, key;
{ {
return 0; return 0;
} }
int int
rl_tty_status (count, key) rl_tty_status (int count, int key)
int count, key;
{ {
#if defined (TIOCSTAT) #if defined (TIOCSTAT)
ioctl (1, TIOCSTAT, (char *)0); ioctl (1, TIOCSTAT, (char *)0);
@ -146,8 +142,7 @@ rl_tty_status (count, key)
/* Return a copy of the string between FROM and TO. /* Return a copy of the string between FROM and TO.
FROM is inclusive, TO is not. */ FROM is inclusive, TO is not. */
char * char *
rl_copy_text (from, to) rl_copy_text (int from, int to)
int from, to;
{ {
register int length; register int length;
char *copy; char *copy;
@ -166,8 +161,7 @@ rl_copy_text (from, to)
/* Increase the size of RL_LINE_BUFFER until it has enough space to hold /* Increase the size of RL_LINE_BUFFER until it has enough space to hold
LEN characters. */ LEN characters. */
void void
rl_extend_line_buffer (len) rl_extend_line_buffer (int len)
int len;
{ {
while (len >= rl_line_buffer_len) while (len >= rl_line_buffer_len)
{ {
@ -181,8 +175,7 @@ rl_extend_line_buffer (len)
/* A function for simple tilde expansion. */ /* A function for simple tilde expansion. */
int int
rl_tilde_expand (ignore, key) rl_tilde_expand (int ignore, int key)
int ignore, key;
{ {
register int start, end; register int start, end;
char *homedir, *temp; char *homedir, *temp;
@ -200,7 +193,7 @@ rl_tilde_expand (ignore, key)
} }
else if (start >= 0 && rl_line_buffer[start] != '~') else if (start >= 0 && rl_line_buffer[start] != '~')
{ {
for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--) for (; start >= 0 && !whitespace (rl_line_buffer[start]); start--)
; ;
start++; start++;
} }
@ -324,8 +317,7 @@ _rl_errmsg (format, arg1, arg2)
/* Determine if s2 occurs in s1. If so, return a pointer to the /* Determine if s2 occurs in s1. If so, return a pointer to the
match in s1. The compare is case insensitive. */ match in s1. The compare is case insensitive. */
char * char *
_rl_strindex (s1, s2) _rl_strindex (const char *s1, const char *s2)
register const char *s1, *s2;
{ {
register int i, l, len; register int i, l, len;
@ -339,8 +331,7 @@ _rl_strindex (s1, s2)
/* Find the first occurrence in STRING1 of any character from STRING2. /* Find the first occurrence in STRING1 of any character from STRING2.
Return a pointer to the character in STRING1. */ Return a pointer to the character in STRING1. */
char * char *
_rl_strpbrk (string1, string2) _rl_strpbrk (const char *string1, const char *string2)
const char *string1, *string2;
{ {
register const char *scan; register const char *scan;
#if defined (HANDLE_MULTIBYTE) #if defined (HANDLE_MULTIBYTE)
@ -374,10 +365,7 @@ _rl_strpbrk (string1, string2)
/* Compare at most COUNT characters from string1 to string2. Case /* Compare at most COUNT characters from string1 to string2. Case
doesn't matter (strncasecmp). */ doesn't matter (strncasecmp). */
int int
_rl_strnicmp (string1, string2, count) _rl_strnicmp (const char *string1, const char *string2, int count)
const char *string1;
const char *string2;
int count;
{ {
register const char *s1; register const char *s1;
register const char *s2; register const char *s2;
@ -404,9 +392,7 @@ _rl_strnicmp (string1, string2, count)
/* strcmp (), but caseless (strcasecmp). */ /* strcmp (), but caseless (strcasecmp). */
int int
_rl_stricmp (string1, string2) _rl_stricmp (const char *string1, const char *string2)
const char *string1;
const char *string2;
{ {
register const char *s1; register const char *s1;
register const char *s2; register const char *s2;
@ -431,8 +417,7 @@ _rl_stricmp (string1, string2)
/* Stupid comparison routine for qsort () ing strings. */ /* Stupid comparison routine for qsort () ing strings. */
int int
_rl_qsort_string_compare (s1, s2) _rl_qsort_string_compare (char **s1, char **s2)
char **s1, **s2;
{ {
#if defined (HAVE_STRCOLL) #if defined (HAVE_STRCOLL)
return (strcoll (*s1, *s2)); return (strcoll (*s1, *s2));
@ -448,7 +433,7 @@ _rl_qsort_string_compare (s1, s2)
} }
/* Function equivalents for the macros defined in chardefs.h. */ /* Function equivalents for the macros defined in chardefs.h. */
#define FUNCTION_FOR_MACRO(f) int (f) (c) int c; { return f (c); } #define FUNCTION_FOR_MACRO(f) int (f) (int c) { return f (c); }
FUNCTION_FOR_MACRO (_rl_digit_p) FUNCTION_FOR_MACRO (_rl_digit_p)
FUNCTION_FOR_MACRO (_rl_digit_value) FUNCTION_FOR_MACRO (_rl_digit_value)
@ -461,8 +446,7 @@ FUNCTION_FOR_MACRO (_rl_uppercase_p)
/* A convenience function, to force memory deallocation to be performed /* A convenience function, to force memory deallocation to be performed
by readline. DLLs on Windows apparently require this. */ by readline. DLLs on Windows apparently require this. */
void void
rl_free (mem) rl_free (void *mem)
void *mem;
{ {
if (mem) if (mem)
free (mem); free (mem);
@ -472,8 +456,7 @@ rl_free (mem)
all `public' readline header files. */ all `public' readline header files. */
#undef _rl_savestring #undef _rl_savestring
char * char *
_rl_savestring (s) _rl_savestring (const char *s)
const char *s;
{ {
return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s))); return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s)));
} }
@ -512,7 +495,7 @@ _rl_trace (va_alist)
} }
int int
_rl_tropen () _rl_tropen (void)
{ {
char fnbuf[128], *x; char fnbuf[128], *x;
@ -521,7 +504,7 @@ _rl_tropen ()
#if defined (_WIN32) && !defined (__CYGWIN__) #if defined (_WIN32) && !defined (__CYGWIN__)
/* Windows doesn't have /var/tmp, so open the trace file in the /* Windows doesn't have /var/tmp, so open the trace file in the
user's temporary directory instead. */ user's temporary directory instead. */
sprintf (fnbuf, "%s/rltrace.%ld", snprintf (fnbuf, sizeof (fnbuf), "%s/rltrace.%ld",
(sh_get_env_value ("TEMP") (sh_get_env_value ("TEMP")
? sh_get_env_value ("TEMP") ? sh_get_env_value ("TEMP")
: "."), : "."),
@ -535,7 +518,7 @@ _rl_tropen ()
} }
int int
_rl_trclose () _rl_trclose (void)
{ {
int r; int r;
@ -545,8 +528,7 @@ _rl_trclose ()
} }
void void
_rl_settracefp (fp) _rl_settracefp (FILE *fp)
FILE *fp;
{ {
_rl_tracefp = fp; _rl_tracefp = fp;
} }
@ -562,8 +544,7 @@ _rl_settracefp (fp)
/* Report STRING to the audit system. */ /* Report STRING to the audit system. */
void void
_rl_audit_tty (string) _rl_audit_tty (char *string)
char *string;
{ {
struct audit_message req; struct audit_message req;
struct sockaddr_nl addr; struct sockaddr_nl addr;

View File

@ -1,6 +1,6 @@
/* vi_keymap.c -- the keymap for vi_mode in readline (). */ /* vi_keymap.c -- the keymap for vi_mode in readline (). */
/* Copyright (C) 1987-2016 Free Software Foundation, Inc. /* Copyright (C) 1987-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
/* xfree.c -- safe version of free that ignores attempts to free NUL */ /* xfree.c -- safe version of free that ignores attempts to free NUL */
/* Copyright (C) 1991-2010 Free Software Foundation, Inc. /* Copyright (C) 1991-2010,2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -42,8 +42,7 @@
/* Use this as the function to call when adding unwind protects so we /* Use this as the function to call when adding unwind protects so we
don't need to know what free() returns. */ don't need to know what free() returns. */
void void
xfree (string) xfree (PTR_T string)
PTR_T string;
{ {
if (string) if (string)
free (string); free (string);

View File

@ -1,6 +1,6 @@
/* xmalloc.c -- safe versions of malloc and realloc */ /* xmalloc.c -- safe versions of malloc and realloc */
/* Copyright (C) 1991-2009 Free Software Foundation, Inc. /* Copyright (C) 1991-2017 Free Software Foundation, Inc.
This file is part of the GNU Readline Library (Readline), a library This file is part of the GNU Readline Library (Readline), a library
for reading lines of text with interactive input and history editing. for reading lines of text with interactive input and history editing.
@ -42,8 +42,7 @@
/* **************************************************************** */ /* **************************************************************** */
static void static void
memory_error_and_abort (fname) memory_error_and_abort (char *fname)
char *fname;
{ {
fprintf (stderr, "%s: out of virtual memory\n", fname); fprintf (stderr, "%s: out of virtual memory\n", fname);
exit (2); exit (2);
@ -53,8 +52,7 @@ memory_error_and_abort (fname)
to hold BYTES number of bytes. If the memory cannot be allocated, to hold BYTES number of bytes. If the memory cannot be allocated,
print an error message and abort. */ print an error message and abort. */
PTR_T PTR_T
xmalloc (bytes) xmalloc (size_t bytes)
size_t bytes;
{ {
PTR_T temp; PTR_T temp;
@ -65,9 +63,7 @@ xmalloc (bytes)
} }
PTR_T PTR_T
xrealloc (pointer, bytes) xrealloc (PTR_T pointer, size_t bytes)
PTR_T pointer;
size_t bytes;
{ {
PTR_T temp; PTR_T temp;