Import of readline 4.3.

Non-readline modified files:

src/gdb/ChangeLog src/gdb/defs.h src/gdb/cli/cli-cmds.c
src/gdb/cli/cli-setshow.c src/gdb/tui/ChangeLog
src/gdb/tui/tuiWin.c

In readline directory:

        * compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
        text.c, doc/history.0, doc/history.3, support/wcwidth.c,
        examples/readlinebuf.h, examples/rlcat.c: New files.

        * CHANGELOG, CHANGES, INSTALL,  MANIFEST, Makefile.in, README,
        aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
        complete.c, config.h.in, configure, configure.in, display.c,
        emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
        history.c, history.h, histsearch.c, input.c, isearch.c,
        keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
        posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
        rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
        search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
        undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
        doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
        doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
        doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
        doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
        shlib/Makefile.in, support/install.sh, support/mkdirs,
        support/mkdist, support/shlib-install, support/shobj-conf,
        examples/Inputrc, examples/Makefile.in, examples/fileman.c,
        examples/histexamp.c, examples/manexamp.c, examples/rl.c,
        examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
        Modified files.
This commit is contained in:
Elena Zannoni 2002-12-08 22:31:39 +00:00
parent ffbceea9fb
commit 9255ee3150
99 changed files with 23487 additions and 8960 deletions

View File

@ -1,3 +1,11 @@
2002-12-08 Elena Zannoni <ezannoni@redhat.com>
Import of readline 4.3:
* cli/cli-cmds.c: Include readline/tilde.h.
* cli/cli-setshow.c: Ditto.
* defs.h: Don't declare tilde_expand anymore, since readline
exports it.
2002-12-08 Elena Zannoni <ezannoni@redhat.com>
* Makefile.in (thread-db.o): Add explicit rule to ignore the use of

View File

@ -19,6 +19,7 @@
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <readline/tilde.h>
#include "defs.h"
#include "completer.h"
#include "target.h" /* For baud_rate, remote_debug and remote_timeout */

View File

@ -17,6 +17,7 @@
Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <readline/tilde.h>
#include "defs.h"
#include "value.h"
#include <ctype.h>

View File

@ -614,10 +614,6 @@ enum lval_type
struct frame_info;
/* From readline (but not in any readline .h files). */
extern char *tilde_expand (char *);
/* Control types for commands */
enum misc_command_type

View File

@ -1,3 +1,11 @@
2002-12-08 Elena Zannoni <ezannoni@redhat.com>
Import of readline 4.3.
Fix PR gdb/675
* tuiWin.c: Include readline/readline.h.
(tui_update_gdb_sizes): Use accessor function rl_get_screen_size.
(tuiResizeAll): Ditto.
2002-12-06 Elena Zannoni <ezannoni@redhat.com>
* tuiStack.c (tuiShowFrameInfo): Fix typo.

View File

@ -46,6 +46,7 @@
#include <string.h>
#include <ctype.h>
#include <readline/readline.h>
#include "defs.h"
#include "command.h"
#include "symtab.h"
@ -417,8 +418,9 @@ void
tui_update_gdb_sizes ()
{
char cmd[50];
extern int screenheight, screenwidth; /* in readline */
int screenheight, screenwidth;
rl_get_screen_size (&screenheight, &screenwidth);
/* Set to TUI command window dimension or use readline values. */
sprintf (cmd, "set width %d",
tui_active ? cmdWin->generic.width : screenwidth);
@ -634,8 +636,9 @@ void
tuiResizeAll (void)
{
int heightDiff, widthDiff;
extern int screenheight, screenwidth; /* in readline */
int screenheight, screenwidth;
rl_get_screen_size (&screenheight, &screenwidth);
widthDiff = screenwidth - termWidth ();
heightDiff = screenheight - termHeight ();
if (heightDiff || widthDiff)

View File

@ -337,3 +337,363 @@ doc/Makefile.in
configure.in
- changed LIBVERSION to 4.1-beta5
3/17/2000
---------
[readline-4.1 released]
3/23
----
Makefile.in
- remove the `-t' argument to ranlib in the install recipe; some
ranlibs don't have it and attempt to create a file named `-t'
3/27
----
support/shlib-install
- install shared libraries unwritable by anyone on HP-UX
- changed symlinks to relative pathnames on all platforms
shlib/Makefile.in
- added missing `includedir' assignment, substituted by configure
Makefile.in
- added missing @SET_MAKE@ so configure can set $MAKE appropriately
configure.in
- add call to AC_PROG_MAKE_SET
8/30
----
shlib/Makefile.in
- change the soname bound into the shared libraries, so it includes
only the major version number. If it includes the minor version,
programs depending on it must be rebuilt (which may or may not be
a bad thing)
9/6
---
examples/rlfe.c
- add -l option to log input and output (-a option appends to logfile)
- add -n option to set readline application name
- add -v, -h options for version and help information
- change a few things because getopt() is now used to parse arguments
9/12
----
support/shlib-install
- fix up the libname on HPUX 11
10/18
-----
configure.in
- changed library version to 4.2-alpha
10/30
-----
configure.in
- add -fsigned-char to LOCAL_CFLAGS for Linux running on the IBM
S/390
Makefile.in
- added new file, rltypedefs.h, installed by default with `make install'
11/2
----
compat.c
- new file, with backwards-compatibility function definitions
Makefile.in,shlib/Makefile.in
- make sure that compat.o/compat.so are built and linked apppropriately
support/shobj-conf
- picked up bash version, which means that shared libs built on
linux and BSD/OS 4.x will have an soname that does not include
the minor version number
11/13
-----
examples/rlfe.c
- rlfe can perform filename completion for relative pathnames in the
inferior process's context if the OS supports /proc/PID/cwd (linux
does it OK, Solaris is slightly warped, none of the BSDs have it)
11/17/2000
----------
[readline-4.2-alpha released]
11/27
-----
Makefile.in,shlib/Makefile.in
- added dependencies for rltypedefs.h
shlib/Makefile.in
- changed dependencies on histlib.h to $(topdir)/histlib.h
1/22
----
configure.in
- changed release version to 4.2-beta
2/2
---
examples/Makefile.in
- build histexamp as part of the examples
2/5
---
doc/Makefile.in
- don't remove the dvi, postscript, html, info, and text `objects'
on a `make distclean', only on a `make maintainer-clean'
3/6
---
doc/history.{0,3}, doc/history_3.ps
- new manual page for history library
doc/Makefile.in
- rules to install and uninstall history.3 in ${man3dir}
- rules to build history.0 and history_3.ps
4/2
---
configure.in
- changed LIBVERSION to `4.2'
4/5
---
[readline-4.2 frozen]
4/9
---
[readline-4.2 released]
5/2
---
Makefile.in,{doc,examples,shlib}/Makefile.in
- added support for DESTDIR installation root prefix, to support
building packages
doc/Makefile.in
- add an info `dir' file entry for rluserman.info on `make install'
- change man1ext to `.1' and man3ext to `.3'
- install man pages with a $(man3ext) extension in the target directory
- add support for installing html documentation if `htmldir' has a
value
Makefile.in
- on `make install', install from the `shlib' directory, too
- on `make uninstall', uninstall in the `doc' and `shlib'
subdirectories, too
support/shlib-install
- add `freebsdelf*', `freebsdaout*', Hurd, `sysv4*', `sysv5*', `dgux*'
targets for symlink creation
5/7
---
configure.in, config.h.in
- check for <limits.h>, define HAVE_LIMITS_H if found
5/8
---
aclocal.m4
- pick up change to BASH_CHECK_LIB_TERMCAP that adds check for
libtinfo (termcap-specific portion of ncurses-5.2)
5/9
---
configure.in
- call AC_C_CONST to find out whether or not the compiler supports
`const'
config.h.in
- placeholder for `const' define, if any
5/10
----
configure.in
- fix AC_CHECK_PROG(ar, ...) test to specify right value for the
case where ar is not found; should produce a better error message
5/14
----
configure.in,config.h.in
- check for vsnprintf, define HAVE_VSNPRINTF if found
5/21
----
configure.in, config.h.in
- add checks for size_t, ssize_t
5/30
----
configure.in
- update autoconf to version 2.50, use in AC_PREREQ
- changed AC_INIT to new flavor
- added AC_CONFIG_SRCDIR
- AC_CONFIG_HEADER -> AC_CONFIG_HEADERS
- call AC_C_PROTOTYPES
- AC_RETSIGTYPE -> AC_TYPE_SIGNAL
8/22
----
configure.in
- updated the version number to 4.2a
Makefile.in,shlib/Makefile.in
- make sure tilde.o is built -DREADLINE_LIBRARY when being built as
part of the standalone library, so it picks up the right include
files
8/23
----
support/shlib-install
- support for Darwin/MacOS X shared library installation
9/24
----
examples/readlinebuf.h
- a new file, a C++ streambuf interface that uses readline for I/O.
Donated by Dimitris Vyzovitis <vyzo@media.mit.edu>
10/9
----
configure.in
- replaced call to BASH_HAVE_TIOCGWINSZ with AC_HEADER_TIOCGWINSZ
[readline-4.2a-beta1 frozen]
10/15
-----
configure.in, config.h.in
- check for <memory.h>, define HAVE_MEMORY_H if found
- check for <strings.h>, define HAVE_STRINGS_H if found
10/18
-----
configure.in, config.h.in
- check for isascii, define HAVE_ISASCII if found
configure.in
- changed the macro names from bash as appropriate:
BASH_SIGNAL_CHECK -> BASH_SYS_SIGNAL_VINTAGE
BASH_REINSTALL_SIGHANDLERS -> BASH_SYS_REINSTALL_SIGHANDLERS
BASH_MISC_SPEED_T -> BASH_CHECK_SPEED_T
10/22
-----
configure.in
- check for isxdigit with AC_CHECK_FUNCS
config.h.in
- new define for HAVE_ISXDIGIT
10/29
-----
configure.in, config.h.in
- check for strpbrk with AC_CHECK_FUNCS, define HAVE_STRPBRK if found
11/1
----
Makefile.in
- make sure DESTDIR is passed to install and uninstall makes in
subdirectories
- when saving old copies of installed libraries, make sure we use
DESTDIR for the old installation tree
[readline-4.2a-rc1 frozen]
11/2
----
Makefile.in, shlib/Makefile.in
- don't put -I$(includedir) into CFLAGS
11/15
-----
[readline-4.2a released]
11/20
-----
examples/rlcat.c
- new file
examples/Makefile.in
- changes for rlcat
11/28
-----
configure.in
- default TERMCAP_LIB to -lcurses if $prefer_curses == yes (as when
--with-curses is supplied)
examples/Makefile.in
- substitute @LDFLAGS@ in LDFLAGS assignment
11/29
-----
config.h.in
- add necessary defines for multibyte include files and functions
- add code to define HANDLE_MULTIBYTE if prerequisites are met
configure.in
- call BASH_CHECK_MULTIBYTE
12/14
-----
config.h.in
- add #undef PROTOTYPES, filled in by AC_C_PROTOTYPES
12/17
-----
config.h.in
- moved HANDLE_MULTIBYTE code to rlmbutil.h
rlmbutil.h, mbutil.c
- new files
Makefile.in, shlib/Makefile.in
- added rules for mbutil.c
12/20
-----
configure.in
- added --enable-shared, --enable-static options to configure to
say which libraries are built by default (both default to yes)
- if SHLIB_STATUS == 'unsupported', turn off default shared library
building
- substitute new STATIC_TARGET, SHARED_TARGET, STATIC_INSTALL_TARGET,
and SHARED_INSTALL_TARGET
Makefile.in
- `all' target now depends on (substituted) @STATIC_TARGET@ and
@SHARED_TARGET@
- `install' target now depends on (substituted) @STATIC_INSTALL_TARGET@
and @SHARED_INSTALL_TARGET@
INSTALL, README
- updated with new info about --enable-shared and --enable-static
1/10/2002
---------
configure.in
- bumped the library version number to 4.3
1/24
----
Makefile.in,shlib/Makefile.in
- changes for new file, text.c, with character and text handling
functions from readline.c
2/20
----
{configure.config.h}.in
- call AC_C_CHAR_UNSIGNED, define __CHAR_UNSIGNED__ if chars are
unsigned by default
5/20
----
doc/Makefile.in
- new maybe-clean target that removes the generated documentation if
the build directory differs from the source directory
- distclean target now depends on maybe-clean

View File

@ -1,3 +1,314 @@
This document details the changes between this version, readline-4.3,
and the previous version, readline-4.2a.
1. Changes to Readline
a. Fixed output of comment-begin character when listing variable values.
b. Added some default key bindings for common escape sequences produced by
HOME and END keys.
c. Fixed the mark handling code to be more emacs-compatible.
d. A bug was fixed in the code that prints possible completions to keep it
from printing empty strings in certain circumstances.
e. Change the key sequence printing code to print ESC as M\- if ESC is a
meta-prefix character -- it's easier for users to understand than \e.
f. Fixed unstifle_history() to return values that match the documentation.
g. Fixed the event loop (rl_event_hook) to handle the case where the input
file descriptor is invalidated.
h. Fixed the prompt display code to work better when the application has a
custom redisplay function.
i. Changes to make reading and writing the history file a little faster, and
to cope with huge history files without calling abort(3) from xmalloc.
j. The vi-mode `S' and `s' commands are now undone correctly.
k. Fixed a problem which caused the display to be messed up when the last
line of a multi-line prompt (possibly containing invisible characters)
was longer than the screen width.
2. New Features in Readline
a. Support for key `subsequences': allows, e.g., ESC and ESC-a to both
be bound to readline functions. Now the arrow keys may be used in vi
insert mode.
b. When listing completions, and the number of lines displayed is more than
the screen length, readline uses an internal pager to display the results.
This is controlled by the `page-completions' variable (default on).
c. New code to handle editing and displaying multibyte characters.
d. The behavior introduced in bash-2.05a of deciding whether or not to
append a slash to a completed name that is a symlink to a directory has
been made optional, controlled by the `mark-symlinked-directories'
variable (default is the 2.05a behavior).
e. The `insert-comment' command now acts as a toggle if given a numeric
argument: if the first characters on the line don't specify a
comment, insert one; if they do, delete the comment text
f. New application-settable completion variable:
rl_completion_mark_symlink_dirs, allows an application's completion
function to temporarily override the user's preference for appending
slashes to names which are symlinks to directories.
g. New function available to application completion functions:
rl_completion_mode, to tell how the completion function was invoked
and decide which argument to supply to rl_complete_internal (to list
completions, etc.).
h. Readline now has an overwrite mode, toggled by the `overwrite-mode'
bindable command, which could be bound to `Insert'.
i. New application-settable completion variable:
rl_completion_suppress_append, inhibits appending of
rl_completion_append_character to completed words.
j. New key bindings when reading an incremental search string: ^W yanks
the currently-matched word out of the current line into the search
string; ^Y yanks the rest of the current line into the search string,
DEL or ^H deletes characters from the search string.
-------------------------------------------------------------------------------
This document details the changes between this version, readline-4.2a,
and the previous version, readline-4.2.
1. Changes to Readline
a. More `const' and type casting fixes.
b. Changed rl_message() to use vsnprintf(3) (if available) to fix buffer
overflow problems.
c. The completion code no longer appends a `/' or ` ' to a match when
completing a symbolic link that resolves to a directory name, unless
the match does not add anything to the word being completed. This
means that a tab will complete the word up to the full name, but not
add anything, and a subsequent tab will add a slash.
d. Fixed a trivial typo that made the vi-mode `dT' command not work.
e. Fixed the tty code so that ^S and ^Q can be inserted with rl_quoted_insert.
f. Fixed the tty code so that ^V works more than once.
g. Changed the use of __P((...)) for function prototypes to PARAMS((...))
because the use of __P in typedefs conflicted g++ and glibc.
h. The completion code now attempts to do a better job of preserving the
case of the word the user typed if ignoring case in completions.
i. Readline defaults to not echoing the input and lets the terminal
initialization code enable echoing if there is a controlling terminal.
j. The key binding code now processes only two hex digits after a `\x'
escape sequence, and the documentation was changed to note that the
octal and hex escape sequences result in an eight-bit value rather
than strict ASCII.
k. Fixed a few places where negative array subscripts could have occurred.
l. Fixed the vi-mode code to use a better method to determine the bounds of
the array used to hold the marks, and to avoid out-of-bounds references.
m. Fixed the defines in chardefs.h to work better when chars are signed.
n. Fixed configure.in to use the new names for bash autoconf macros.
o. Readline no longer attempts to define its own versions of some ctype
macros if they are implemented as functions in libc but not as macros in
<ctype.h>.
p. Fixed a problem where rl_backward could possibly set point to before
the beginning of the line.
q. Fixed Makefile to not put -I/usr/include into CFLAGS, since it can cause
include file problems.
2. New Features in Readline
a. Added extern declaration for rl_get_termcap to readline.h, making it a
public function (it was always there, just not in readline.h).
b. New #defines in readline.h: RL_READLINE_VERSION, currently 0x0402,
RL_VERSION_MAJOR, currently 4, and RL_VERSION_MINOR, currently 2.
c. New readline variable: rl_readline_version, mirrors RL_READLINE_VERSION.
d. New bindable boolean readline variable: match-hidden-files. Controls
completion of files beginning with a `.' (on Unix). Enabled by default.
e. The history expansion code now allows any character to terminate a
`:first-' modifier, like csh.
f. The incremental search code remembers the last search string and uses
it if ^R^R is typed without a search string.
h. New bindable variable `history-preserve-point'. If set, the history
code attempts to place the user at the same location on each history
line retrived with previous-history or next-history.
-------------------------------------------------------------------------------
This document details the changes between this version, readline-4.2,
and the previous version, readline-4.1.
1. Changes to Readline
a. When setting the terminal attributes on systems using `struct termio',
readline waits for output to drain before changing the attributes.
b. A fix was made to the history word tokenization code to avoid attempts to
dereference a null pointer.
c. Readline now defaults rl_terminal_name to $TERM if the calling application
has left it unset, and tries to initialize with the resultant value.
d. Instead of calling (*rl_getc_function)() directly to get input in certain
places, readline now calls rl_read_key() consistently.
e. Fixed a bug in the completion code that allowed a backslash to quote a
single quote inside a single-quoted string.
f. rl_prompt is no longer assigned directly from the argument to readline(),
but uses memory allocated by readline. This allows constant strings to
be passed to readline without problems arising when the prompt processing
code wants to modify the string.
g. Fixed a bug that caused non-interactive history searches to return the
wrong line when performing multiple searches backward for the same string.
h. Many variables, function arguments, and function return values are now
declared `const' where appropriate, to improve behavior when linking with
C++ code.
i. The control character detection code now works better on systems where
`char' is unsigned by default.
j. The vi-mode numeric argument is now capped at 999999, just like emacs mode.
k. The Function, CPFunction, CPPFunction, and VFunction typedefs have been
replaced with a set of specific prototyped typedefs, though they are
still in the readline header files for backwards compatibility.
m. Nearly all of the (undocumented) internal global variables in the library
now have an _rl_ prefix -- there were a number that did not, like
screenheight, screenwidth, alphabetic, etc.
n. The ding() convenience function has been renamed to rl_ding(), though the
old function is still defined for backwards compatibility.
o. The completion convenience functions filename_completion_function,
username_completion_function, and completion_matches now have an rl_
prefix, though the old names are still defined for backwards compatibility.
p. The functions shared by readline and bash (linkage is satisfied from bash
when compiling with bash, and internally otherwise) now have an sh_ prefix.
q. Changed the shared library creation procedure on Linux and BSD/OS 4.x so
that the `soname' contains only the major version number rather than the
major and minor numbers.
r. Fixed a redisplay bug that occurred when the prompt spanned more than one
physical line and contained invisible characters.
s. Added a missing `includedir' variable to the Makefile.
t. When installing the shared libraries, make sure symbolic links are relative.
u. Added configure test so that it can set `${MAKE}' appropriately.
v. Fixed a bug in rl_forward that could cause the point to be set to before
the beginning of the line in vi mode.
w. Fixed a bug in the callback read-char interface to make it work when a
readline function pushes some input onto the input stream with
rl_execute_next (like the incremental search functions).
x. Fixed a file descriptor leak in the history file manipulation code that
was tripped when attempting to truncate a non-regular file (like
/dev/null).
y. Changes to make all of the exported readline functions declared in
readline.h have an rl_ prefix (rltty_set_default_bindings is now
rl_tty_set_default_bindings, crlf is now rl_crlf, etc.)
z. The formatted documentation included in the base readline distribution
is no longer removed on a `make distclean'.
aa. Some changes were made to avoid gcc warnings with -Wall.
bb. rl_get_keymap_by_name now finds keymaps case-insensitively, so
`set keymap EMACS' works.
cc. The history file writing and truncation functions now return a useful
status on error.
dd. Fixed a bug that could cause applications to dereference a NULL pointer
if a NULL second argument was passed to history_expand().
ee. If a hook function assigned to rl_event_hook sets rl_done to a non-zero
value, rl_read_key() now immediately returns '\n' (which is assumed to
be bound to accept-line).
2. New Features in Readline
a. The blink timeout for paren matching is now settable by applications,
via the rl_set_paren_blink_timeout() function.
b. _rl_executing_macro has been renamed to rl_executing_macro, which means
it's now part of the public interface.
c. Readline has a new variable, rl_readline_state, which is a bitmap that
encapsulates the current state of the library; intended for use by
callbacks and hook functions.
d. rlfe has a new -l option to log input and output (-a appends to logfile),
a new -n option to set the readline application name, and -v and -h
options for version and help information.
e. rlfe can now perform filename completion for the inferior process if the
OS has a /proc/<PID>/cwd that can be read with readlink(2) to get the
inferior's current working directory.
f. A new file, rltypedefs.h, contains the new typedefs for function pointers
and is installed by `make install'.
g. New application-callable function rl_set_prompt(const char *prompt):
expands its prompt string argument and sets rl_prompt to the result.
h. New application-callable function rl_set_screen_size(int rows, int cols):
public method for applications to set readline's idea of the screen
dimensions.
i. The history example program (examples/histexamp.c) is now built as one
of the examples.
j. The documentation has been updated to cover nearly all of the public
functions and variables declared in readline.h.
k. New function, rl_get_screen_size (int *rows, int *columns), returns
readline's idea of the screen dimensions.
l. The timeout in rl_gather_tyi (readline keyboard input polling function)
is now settable via a function (rl_set_keyboard_input_timeout()).
m. Renamed the max_input_history variable to history_max_entries; the old
variable is maintained for backwards compatibility.
n. The list of characters that separate words for the history tokenizer is
now settable with a variable: history_word_delimiters. The default
value is as before.
o. There is a new history.3 manual page documenting the history library.
-------------------------------------------------------------------------------
This document details the changes between this version, readline-4.1,
and the previous version, readline-4.0.

View File

@ -1,3 +1,32 @@
2002-12-06 Elena Zannoni <ezannoni@redhat.com>
Import of readline 4.3:
* compat.c, mbutil.c, misc.c, rlmbutil.h, rltypedefs.h,
text.c, doc/history.0, doc/history.3, support/wcwidth.c,
examples/readlinebuf.h, examples/rlcat.c: New files.
* CHANGELOG, CHANGES, INSTALL, MANIFEST, Makefile.in, README,
aclocal.m4, ansi_stdlib.h, bind.c, callback.c, chardefs.h,
complete.c, config.h.in, configure, configure.in, display.c,
emacs_keymap.c, funmap.c, histexpand.c, histfile.c, histlib.h,
history.c, history.h, histsearch.c, input.c, isearch.c,
keymaps.c, keymaps.h, kill.c, macro.c, nls.c, parens.c,
posixdir.h, readline.c, readline.h, rlconf.h, rldefs.h,
rlprivate.h, rlshell.h, rlstdc.h, rltty.c, savestring.c,
search.c, shell.c, signals.c, terminal.c, tilde.c, tilde.h,
undo.c, util.c, vi_keymap.c, vi_mode.c, xmalloc.c, xmalloc.h,
doc/Makefile.in, doc/hist.texinfo, doc/hstech.texinfo,
doc/hsuser.texinfo, doc/manvers.texinfo, doc/readline.3,
doc/rlman.texinfo, doc/rltech.texinfo, doc/rluser.texinfo
doc/rluserman.texinfo, doc/texi2dvi, doc/texi2html,
shlib/Makefile.in, support/install.sh, support/mkdirs,
support/mkdist, support/shlib-install, support/shobj-conf,
examples/Inputrc, examples/Makefile.in, examples/fileman.c,
examples/histexamp.c, examples/manexamp.c, examples/rl.c,
examples/rlfe.c, examples/rltest.c, examples/rlversion.c:
Modified files.
2002-08-23 Andrew Cagney <ac131313@redhat.com>
* support/config.guess: Import version 2002-08-23.

View File

@ -1,73 +1,81 @@
Basic Installation
==================
These are generic installation instructions.
These are installation instructions for Readline-4.3.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
The simplest way to compile readline is:
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
1. `cd' to the directory containing the readline source code and type
`./configure' to configure readline for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
Running `configure' takes some time. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
2. Type `make' to compile readline and build the static readline
and history libraries. If supported, the shared readline and history
libraries will be built also. See below for instructions on compiling
the other parts of the distribution. Typing `make everything' will
cause the static and shared libraries (if supported) and the example
programs to be built.
3. Optionally, type `make check' to run any self-tests that come with
the package.
3. Type `make install' to install the static readline and history
libraries, the readline include files, the documentation, and, if
supported, the shared readline and history libraries.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
4. You can remove the created libraries and object files from the
build directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile readline for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
for the readline developers, and should be used with care.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It
uses those values to create a `Makefile' in the build directory,
and Makefiles in the `doc', `shlib', and `examples'
subdirectories. It also creates a `config.h' file containing
system-dependent definitions. Finally, it creates a shell script
`config.status' that you can run in the future to recreate the
current configuration, a file `config.cache' that saves the
results of its tests to speed up reconfiguring, and a file
`config.log' containing compiler output (useful mainly for
debugging `configure').
If you need to do unusual things to compile readline, please try
to figure out how `configure' could check whether to do them, and
mail diffs or instructions to <bug-readline@gnu.org> so they can
be considered for the next release. If at some point
`config.cache' contains results you don't want to keep, you may
remove or edit it.
The file `configure.in' is used to create `configure' by a
program called `autoconf'. You only need `configure.in' if you
want to change it or regenerate `configure' using a newer version
of `autoconf'. The readline `configure.in' requires autoconf
version 2.50 or newer.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
You can compile readline for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
@ -75,80 +83,59 @@ directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile readline for one architecture at a
time in the source code directory. After you have installed
readline for one architecture, use `make distclean' before
reconfiguring for another architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
By default, `make install' will install the readline libraries in
`/usr/local/lib', the include files in
`/usr/local/include/readline', the man pages in `/usr/local/man',
and the info files in `/usr/local/info'. You can specify an
installation prefix other than `/usr/local' by giving `configure'
the option `--prefix=PATH' or by supplying a value for the
DESTDIR variable when running `make install'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files.
If you give `configure' the option `--exec-prefix=PATH', the
readline Makefiles will use PATH as the prefix for installing the
libraries. Documentation and other data files will still use the
regular prefix.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
There may be some features `configure' can not figure out
automatically, but need to determine by the type of host readline
will run on. Usually `configure' can figure that out, but if it
prints a message saying it can not guess the host type, give it
the `--host=TYPE' option. TYPE can either be a short name for
the system type, such as `sun4', or a canonical name with three
fields: CPU-COMPANY-SYSTEM (e.g., i386-unknown-freebsd4.2).
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
See the file `config.sub' for the possible values of each field.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
A warning: the readline `configure' looks for a site script, but not
all `configure' scripts do.
Operation Controls
==================
`configure' recognizes the following options to control how it
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
@ -174,3 +161,113 @@ operates.
`configure' also accepts some other, not widely useful, options.
Optional Features
=================
The readline `configure' recognizes a single `--with-PACKAGE' option:
`--with-curses'
This tells readline that it can find the termcap library functions
(tgetent, et al.) in the curses library, rather than a separate
termcap library. Readline uses the termcap functions, but does not
link with the termcap or curses library itself, allowing applications
which link with readline the to choose an appropriate library.
This option tells readline to link the example programs with the
curses library rather than libtermcap.
`configure' also recognizes two `--enable-FEATURE' options:
`--enable-shared'
Build the shared libraries by default on supported platforms. The
default is `yes'.
`--enable-static'
Build the static libraries by default. The default is `yes'.
Shared Libraries
================
There is support for building shared versions of the readline and
history libraries. The configure script creates a Makefile in
the `shlib' subdirectory, and typing `make shared' will cause
shared versions of the readline and history libraries to be built
on supported platforms.
If `configure' is given the `--enable-shared' option, it will attempt
to build the shared libraries by default on supported platforms.
Configure calls the script support/shobj-conf to test whether or
not shared library creation is supported and to generate the values
of variables that are substituted into shlib/Makefile. If you
try to build shared libraries on an unsupported platform, `make'
will display a message asking you to update support/shobj-conf for
your platform.
If you need to update support/shobj-conf, you will need to create
a `stanza' for your operating system and compiler. The script uses
the value of host_os and ${CC} as determined by configure. For
instance, FreeBSD 4.2 with any version of gcc is identified as
`freebsd4.2-gcc*'.
In the stanza for your operating system-compiler pair, you will need to
define several variables. They are:
SHOBJ_CC The C compiler used to compile source files into shareable
object files. This is normally set to the value of ${CC}
by configure, and should not need to be changed.
SHOBJ_CFLAGS Flags to pass to the C compiler ($SHOBJ_CC) to create
position-independent code. If you are using gcc, this
should probably be set to `-fpic'.
SHOBJ_LD The link editor to be used to create the shared library from
the object files created by $SHOBJ_CC. If you are using
gcc, a value of `gcc' will probably work.
SHOBJ_LDFLAGS Flags to pass to SHOBJ_LD to enable shared object creation.
If you are using gcc, `-shared' may be all that is necessary.
These should be the flags needed for generic shared object
creation.
SHLIB_XLDFLAGS Additional flags to pass to SHOBJ_LD for shared library
creation. Many systems use the -R option to the link
editor to embed a path within the library for run-time
library searches. A reasonable value for such systems would
be `-R$(libdir)'.
SHLIB_LIBS Any additional libraries that shared libraries should be
linked against when they are created.
SHLIB_LIBSUFF The suffix to add to `libreadline' and `libhistory' when
generating the filename of the shared library. Many systems
use `so'; HP-UX uses `sl'.
SHLIB_LIBVERSION The string to append to the filename to indicate the version
of the shared library. It should begin with $(SHLIB_LIBSUFF),
and possibly include version information that allows the
run-time loader to load the version of the shared library
appropriate for a particular program. Systems using shared
libraries similar to SunOS 4.x use major and minor library
version numbers; for those systems a value of
`$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' is appropriate.
Systems based on System V Release 4 don't use minor version
numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
Other Unix versions use different schemes.
SHLIB_STATUS Set this to `supported' when you have defined the other
necessary variables. Make uses this to determine whether
or not shared library creation should be attempted. If
shared libraries are not supported, this will be set to
`unsupported'.
You should look at the existing stanzas in support/shobj-conf for ideas.
Once you have updated support/shobj-conf, re-run configure and type
`make shared' or `make'. The shared libraries will be created in the
shlib subdirectory.
If shared libraries are created, `make install' will install them.
You may install only the shared libraries by running `make
install-shared' from the top-level build directory. Running `make
install' in the shlib subdirectory will also work. If you don't want
to install any created shared libraries, run `make install-static'.

View File

@ -28,15 +28,19 @@ posixstat.h f
readline.h f
rlconf.h f
rldefs.h f
rlmbutil.h f
rlprivate.h f
rlshell.h f
rlstdc.h f
rltty.h f
rltypedefs.h f
rlwinsize.h f
tcap.h f
tilde.h f
xmalloc.h f
bind.c f
callback.c f
compat.c f
complete.c f
display.c f
emacs_keymap.c f
@ -46,6 +50,8 @@ isearch.c f
keymaps.c f
kill.c f
macro.c f
mbutil.c f
misc.c f
nls.c f
parens.c f
readline.c f
@ -55,12 +61,12 @@ search.c f
shell.c f
signals.c f
terminal.c f
text.c f
tilde.c f
undo.c f
util.c f
vi_keymap.c f
vi_mode.c f
callback.c f
xmalloc.c f
history.c f
histexpand.c f
@ -74,6 +80,7 @@ support/mkdirs f
support/mkdist f
support/shobj-conf f
support/shlib-install f
support/wcwidth.c f
doc/Makefile.in f
doc/texinfo.tex f
doc/manvers.texinfo f
@ -85,12 +92,15 @@ doc/hist.texinfo f
doc/hstech.texinfo f
doc/hsuser.texinfo f
doc/readline.3 f
doc/history.3 f
doc/texi2dvi f
doc/texi2html f
examples/Makefile.in f
examples/excallback.c f
examples/fileman.c f
examples/manexamp.c f
examples/readlinebuf.h f
examples/rlcat.c f
examples/rlfe.c f
examples/rltest.c f
examples/rl.c f
@ -111,3 +121,6 @@ doc/readline.html f
doc/history.html f
doc/rluserman.html f
doc/readline.0 f
doc/history.0 f
doc/readline_3.ps f
doc/history_3.ps f

View File

@ -35,6 +35,7 @@ RM = rm -f
CP = cp
MV = mv
@SET_MAKE@
SHELL = @MAKE_SHELL@
prefix = @prefix@
@ -49,6 +50,9 @@ infodir = @infodir@
man3dir = $(mandir)/man3
# Support an alternate destination root directory for package building
DESTDIR =
# Programs to make tags files.
ETAGS = etags -tw
CTAGS = ctags -tw
@ -63,9 +67,16 @@ LOCAL_DEFS = @LOCAL_DEFS@
TERMCAP_LIB = @TERMCAP_LIB@
# For libraries which include headers from other libraries.
INCLUDES = -I. -I$(srcdir) -I$(includedir)
INCLUDES = -I. -I$(srcdir)
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES) $(LOCAL_CFLAGS) $(CFLAGS)
XCCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES)
CCFLAGS = $(XCCFLAGS) $(LOCAL_CFLAGS) $(CFLAGS)
# could add -Werror here
GCC_LINT_FLAGS = -ansi -Wall -Wshadow -Wpointer-arith -Wcast-qual \
-Wwrite-strings -Wstrict-prototypes \
-Wmissing-prototypes -Wno-implicit -pedantic
GCC_LINT_CFLAGS = $(XCCFLAGS) $(GCC_LINT_FLAGS) @CFLAGS@ @LOCAL_CFLAGS@
.c.o:
${RM} $@
@ -85,19 +96,22 @@ CSOURCES = $(srcdir)/readline.c $(srcdir)/funmap.c $(srcdir)/keymaps.c \
$(srcdir)/callback.c $(srcdir)/terminal.c $(srcdir)/xmalloc.c \
$(srcdir)/history.c $(srcdir)/histsearch.c $(srcdir)/histexpand.c \
$(srcdir)/histfile.c $(srcdir)/nls.c $(srcdir)/search.c \
$(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c
$(srcdir)/shell.c $(srcdir)/savestring.c $(srcdir)/tilde.c \
$(srcdir)/text.c $(srcdir)/misc.c $(srcdir)/compat.c \
$(srcdir)/mbutil.c
# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
posixstat.h posixdir.h posixjmp.h tilde.h rlconf.h rltty.h \
ansi_stdlib.h tcap.h rlstdc.h xmalloc.h rlprivate.h rlshell.h
ansi_stdlib.h tcap.h rlstdc.h xmalloc.h rlprivate.h rlshell.h \
rltypedefs.h rlmbutil.h
HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o
HISTOBJ = history.o histexpand.o histfile.o histsearch.o shell.o mbutil.o
TILDEOBJ = tilde.o
OBJECTS = readline.o vi_mode.o funmap.o keymaps.o parens.o search.o \
rltty.o complete.o bind.o isearch.o display.o signals.o \
util.o kill.o undo.o macro.o input.o callback.o terminal.o \
nls.o xmalloc.o $(HISTOBJ) $(TILDEOBJ)
text.o nls.o misc.o compat.o xmalloc.o $(HISTOBJ) $(TILDEOBJ)
# The texinfo files which document this library.
DOCSOURCE = doc/rlman.texinfo doc/rltech.texinfo doc/rluser.texinfo
@ -111,13 +125,15 @@ CREATED_CONFIGURE = config.status config.h config.cache config.log \
CREATED_TAGS = TAGS tags
INSTALLED_HEADERS = readline.h chardefs.h keymaps.h history.h tilde.h \
rlstdc.h rlconf.h
rlstdc.h rlconf.h rltypedefs.h
##########################################################################
TARGETS = @STATIC_TARGET@ @SHARED_TARGET@
INSTALL_TARGETS = @STATIC_INSTALL_TARGET@ @SHARED_INSTALL_TARGET@
all: static
all: $(TARGETS)
everything: static shared examples
everything: all examples
static: $(STATIC_LIBS)
@ -131,9 +147,18 @@ libhistory.a: $(HISTOBJ) xmalloc.o
$(AR) $(ARFLAGS) $@ $(HISTOBJ) xmalloc.o
-test -n "$(RANLIB)" && $(RANLIB) $@
# Since tilde.c is shared between readline and bash, make sure we compile
# it with the right flags when it's built as part of readline
tilde.o: tilde.c
rm -f $@
$(CC) $(CCFLAGS) -DREADLINE_LIBRARY -c $(srcdir)/tilde.c
readline: $(OBJECTS) readline.h rldefs.h chardefs.h ./libreadline.a
$(CC) $(CCFLAGS) -o $@ ./examples/rl.c ./libreadline.a ${TERMCAP_LIB}
lint: force
$(MAKE) $(MFLAGS) CCFLAGS='$(GCC_LINT_CFLAGS)' static
Makefile makefile: config.status $(srcdir)/Makefile.in
CONFIG_FILES=Makefile CONFIG_HEADERS= $(SHELL) ./config.status
@ -170,11 +195,11 @@ force:
install-headers: installdirs ${INSTALLED_HEADERS}
for f in ${INSTALLED_HEADERS}; do \
$(INSTALL_DATA) $(srcdir)/$$f $(includedir)/readline ; \
$(INSTALL_DATA) $(srcdir)/$$f $(DESTDIR)$(includedir)/readline ; \
done
uninstall-headers:
-test -n "$(includedir)" && cd $(includedir)/readline && \
-test -n "$(includedir)" && cd $(DESTDIR)$(includedir)/readline && \
${RM} ${INSTALLED_HEADERS}
maybe-uninstall-headers: uninstall-headers
@ -189,31 +214,39 @@ maybe-uninstall-headers: uninstall-headers
install:
#install: installdirs $(STATIC_LIBS) install-headers
# -$(MV) $(libdir)/libreadline.a $(libdir)/libreadline.old
# $(INSTALL_DATA) libreadline.a $(libdir)/libreadline.a
# -test -n "$(RANLIB)" && $(RANLIB) -t $(libdir)/libreadline.a
# -$(MV) $(libdir)/libhistory.a $(libdir)/libhistory.old
# $(INSTALL_DATA) libhistory.a $(libdir)/libhistory.a
# -test -n "$(RANLIB)" && $(RANLIB) -t $(libdir)/libhistory.a
# -( if test -d doc ; then \
# cd doc && \
# ${MAKE} ${MFLAGS} infodir=$(infodir) $@; \
# fi )
#install: $(INSTALL_TARGETS)
install-static: installdirs $(STATIC_LIBS) install-headers
-$(MV) $(DESTDIR)$(libdir)/libreadline.a $(DESTDIR)$(libdir)/libreadline.old
$(INSTALL_DATA) libreadline.a $(DESTDIR)$(libdir)/libreadline.a
-test -n "$(RANLIB)" && $(RANLIB) $(DESTDIR)$(libdir)/libreadline.a
-$(MV) $(DESTDIR)$(libdir)/libhistory.a $(DESTDIR)$(libdir)/libhistory.old
$(INSTALL_DATA) libhistory.a $(DESTDIR)$(libdir)/libhistory.a
-test -n "$(RANLIB)" && $(RANLIB) $(DESTDIR)$(libdir)/libhistory.a
-( if test -d doc ; then \
cd doc && \
${MAKE} ${MFLAGS} infodir=$(infodir) DESTDIR=${DESTDIR} install; \
fi )
installdirs: $(srcdir)/support/mkdirs
-$(SHELL) $(srcdir)/support/mkdirs $(includedir) \
$(includedir)/readline $(libdir) $(infodir) $(man3dir)
-$(SHELL) $(srcdir)/support/mkdirs $(DESTDIR)$(includedir) \
$(DESTDIR)$(includedir)/readline $(DESTDIR)$(libdir) \
$(DESTDIR)$(infodir) $(DESTDIR)$(man3dir)
uninstall: uninstall-headers
-test -n "$(libdir)" && cd $(libdir) && \
-test -n "$(DESTDIR)$(libdir)" && cd $(DESTDIR)$(libdir) && \
${RM} libreadline.a libreadline.old libhistory.a libhistory.old $(SHARED_LIBS)
-( if test -d doc ; then \
cd doc && \
${MAKE} ${MFLAGS} infodir=$(infodir) DESTDIR=${DESTDIR} $@; \
fi )
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
install-shared: installdirs install-headers shared
-( cd shlib ; ${MAKE} ${MFLAGS} install )
-( cd shlib ; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install )
uninstall-shared: maybe-uninstall-headers
-( cd shlib; ${MAKE} ${MFLAGS} uninstall )
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
TAGS: force
$(ETAGS) $(CSOURCES) $(HSOURCES)
@ -262,90 +295,99 @@ dist: force
# Dependencies
bind.o: ansi_stdlib.h posixstat.h
bind.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
bind.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
bind.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
bind.o: history.h
callback.o: rlconf.h
callback.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
callback.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
callback.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
compat.o: rlstdc.h
complete.o: ansi_stdlib.h posixdir.h posixstat.h
complete.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
complete.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
complete.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
display.o: ansi_stdlib.h posixstat.h
display.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
display.o: tcap.h
display.o: readline.h keymaps.h chardefs.h tilde.h
display.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
display.o: history.h rlstdc.h
funmap.o: readline.h keymaps.h chardefs.h tilde.h
funmap.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
funmap.o: rlconf.h ansi_stdlib.h rlstdc.h
funmap.o: ${BUILD_DIR}/config.h
histexpand.o: ansi_stdlib.h
histexpand.o: history.h histlib.h rlstdc.h
histexpand.o: history.h histlib.h rlstdc.h rltypedefs.h
histexpand.o: ${BUILD_DIR}/config.h
histfile.o: ansi_stdlib.h
histfile.o: history.h histlib.h rlstdc.h
histfile.o: history.h histlib.h rlstdc.h rltypedefs.h
histfile.o: ${BUILD_DIR}/config.h
history.o: ansi_stdlib.h
history.o: history.h histlib.h rlstdc.h
history.o: history.h histlib.h rlstdc.h rltypedefs.h
history.o: ${BUILD_DIR}/config.h
histsearch.o: ansi_stdlib.h
histsearch.o: history.h histlib.h rlstdc.h
histsearch.o: history.h histlib.h rlstdc.h rltypedefs.h
histsearch.o: ${BUILD_DIR}/config.h
input.o: ansi_stdlib.h
input.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
input.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
input.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
isearch.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
isearch.o: readline.h keymaps.h chardefs.h tilde.h
isearch.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
isearch.o: ansi_stdlib.h history.h rlstdc.h
keymaps.o: emacs_keymap.c vi_keymap.c
keymaps.o: keymaps.h chardefs.h rlconf.h ansi_stdlib.h
keymaps.o: readline.h keymaps.h chardefs.h tilde.h
keymaps.o: keymaps.h rltypedefs.h chardefs.h rlconf.h ansi_stdlib.h
keymaps.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
keymaps.o: ${BUILD_DIR}/config.h rlstdc.h
kill.o: ansi_stdlib.h
kill.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
kill.o: readline.h keymaps.h chardefs.h tilde.h
kill.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
kill.o: history.h rlstdc.h
macro.o: ansi_stdlib.h
macro.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
macro.o: readline.h keymaps.h chardefs.h tilde.h
macro.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
macro.o: history.h rlstdc.h
mbutil.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
mbutil.o: readline.h keymaps.h rltypedefs.h chardefs.h rlstdc.h
misc.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
misc.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
misc.o: history.h rlstdc.h ansi_stdlib.h
nls.o: ansi_stdlib.h
nls.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
nls.o: readline.h keymaps.h chardefs.h tilde.h
nls.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
nls.o: history.h rlstdc.h
parens.o: rlconf.h
parens.o: ${BUILD_DIR}/config.h
parens.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
readline.o: readline.h keymaps.h chardefs.h tilde.h
parens.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
readline.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
readline.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
readline.o: history.h rlstdc.h
readline.o: posixstat.h ansi_stdlib.h posixjmp.h
rltty.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
rltty.o: rltty.h
rltty.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
rltty.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
search.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
search.o: readline.h keymaps.h chardefs.h tilde.h
search.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
search.o: ansi_stdlib.h history.h rlstdc.h
shell.o: ${BUILD_DIR}/config.h
shell.o: ansi_stdlib.h
signals.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
signals.o: readline.h keymaps.h chardefs.h tilde.h
signals.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
signals.o: history.h rlstdc.h
terminal.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
terminal.o: tcap.h
terminal.o: readline.h keymaps.h chardefs.h tilde.h
terminal.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
terminal.o: history.h rlstdc.h
text.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
text.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
text.o: history.h rlstdc.h ansi_stdlib.h
tilde.o: ansi_stdlib.h
tilde.o: ${BUILD_DIR}/config.h
tilde.o: tilde.h
undo.o: ansi_stdlib.h
undo.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
undo.o: readline.h keymaps.h chardefs.h tilde.h
undo.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
undo.o: history.h rlstdc.h
util.o: posixjmp.h ansi_stdlib.h
util.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
util.o: readline.h keymaps.h chardefs.h tilde.h rlstdc.h
util.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h rlstdc.h
vi_mode.o: rldefs.h ${BUILD_DIR}/config.h rlconf.h
vi_mode.o: readline.h keymaps.h chardefs.h tilde.h
vi_mode.o: readline.h keymaps.h rltypedefs.h chardefs.h tilde.h
vi_mode.o: history.h ansi_stdlib.h rlstdc.h
xmalloc.o: ${BUILD_DIR}/config.h
xmalloc.o: ansi_stdlib.h
@ -366,6 +408,8 @@ input.o: rlprivate.h
isearch.o: rlprivate.h
kill.o: rlprivate.h
macro.o: rlprivate.h
mbutil.o: rlprivate.h
misc.o: rlprivate.h
nls.o: rlprivate.h
parens.o: rlprivate.h
readline.o: rlprivate.h
@ -373,6 +417,7 @@ rltty.o: rlprivate.h
search.o: rlprivate.h
signals.o: rlprivate.h
terminal.o: rlprivate.h
text.o: rlprivate.h
undo.o: rlprivate.h
util.o: rlprivate.h
vi_mode.o: rlprivate.h
@ -389,69 +434,96 @@ isearch.o: xmalloc.h
keymaps.o: xmalloc.h
kill.o: xmalloc.h
macro.o: xmalloc.h
mbutil.o: xmalloc.h
misc.o: xmalloc.h
readline.o: xmalloc.h
savestring.o: xmalloc.h
search.o: xmalloc.h
shell.o: xmalloc.h
terminal.o: xmalloc.h
text.o: xmalloc.h
tilde.o: xmalloc.h
tilde.o: xmalloc.h
undo.o: xmalloc.h
util.o: xmalloc.h
vi_mode.o: xmalloc.h
xmalloc.o: xmalloc.h
complete.o: rlmbutil.h
display.o: rlmbutil.h
histexpand.o: rlmbutil.h
input.o: rlmbutil.h
isearch.o: rlmbutil.h
mbutil.o: rlmbutil.h
misc.o: rlmbutil.h
readline.o: rlmbutil.h
search.o: rlmbutil.h
text.o: rlmbutil.h
vi_mode.o: rlmbutil.h
readline.o: $(srcdir)/readline.c
vi_mode.o: $(srcdir)/vi_mode.c
funmap.o: $(srcdir)/funmap.c
keymaps.o: $(srcdir)/keymaps.c
parens.o: $(srcdir)/parens.c
search.o: $(srcdir)/search.c
rltty.o: $(srcdir)/rltty.c
complete.o: $(srcdir)/complete.c
bind.o: $(srcdir)/bind.c
isearch.o: $(srcdir)/isearch.c
display.o: $(srcdir)/display.c
signals.o: $(srcdir)/signals.c
util.o: $(srcdir)/util.c
kill.o: $(srcdir)/kill.c
undo.o: $(srcdir)/undo.c
macro.o: $(srcdir)/macro.c
input.o: $(srcdir)/input.c
callback.o: $(srcdir)/callback.c
terminal.o: $(srcdir)/terminal.c
compat.o: $(srcdir)/compat.c
complete.o: $(srcdir)/complete.c
display.o: $(srcdir)/display.c
funmap.o: $(srcdir)/funmap.c
input.o: $(srcdir)/input.c
isearch.o: $(srcdir)/isearch.c
keymaps.o: $(srcdir)/keymaps.c $(srcdir)/emacs_keymap.c $(srcdir)/vi_keymap.c
kill.o: $(srcdir)/kill.c
macro.o: $(srcdir)/macro.c
mbutil.o: $(srcdir)/mbutil.c
misc.o: $(srcdir)/misc.c
nls.o: $(srcdir)/nls.c
parens.o: $(srcdir)/parens.c
readline.o: $(srcdir)/readline.c
rltty.o: $(srcdir)/rltty.c
savestring.o: $(srcdir)/savestring.c
search.o: $(srcdir)/search.c
shell.o: $(srcdir)/shell.c
signals.o: $(srcdir)/signals.c
terminal.o: $(srcdir)/terminal.c
text.o: $(srcdir)/text.c
tilde.o: $(srcdir)/tilde.c
undo.o: $(srcdir)/undo.c
util.o: $(srcdir)/util.c
vi_mode.o: $(srcdir)/vi_mode.c
xmalloc.o: $(srcdir)/xmalloc.c
history.o: $(srcdir)/history.c
histexpand.o: $(srcdir)/histexpand.c
histfile.o: $(srcdir)/histfile.c
history.o: $(srcdir)/history.c
histsearch.o: $(srcdir)/histsearch.c
savestring.o: $(srcdir)/savestring.c
shell.o: $(srcdir)/shell.c
tilde.o: $(srcdir)/tilde.c
readline.o: readline.c
vi_mode.o: vi_mode.c
funmap.o: funmap.c
keymaps.o: keymaps.c
parens.o: parens.c
search.o: search.c
rltty.o: rltty.c
complete.o: complete.c
bind.o: bind.c
isearch.o: isearch.c
display.o: display.c
signals.o: signals.c
util.o: util.c
kill.o: kill.c
undo.o: undo.c
macro.o: macro.c
input.o: input.c
callback.o: callback.c
terminal.o: terminal.c
compat.o: compat.c
complete.o: complete.c
display.o: display.c
funmap.o: funmap.c
input.o: input.c
isearch.o: isearch.c
keymaps.o: keymaps.c emacs_keymap.c vi_keymap.c
kill.o: kill.c
macro.o: macro.c
mbutil.o: mbutil.c
misc.o: misc.c
nls.o: nls.c
parens.o: parens.c
readline.o: readline.c
rltty.o: rltty.c
savestring.o: savestring.c
search.o: search.c
shell.o: shell.c
signals.o: signals.c
terminal.o: terminal.c
text.o: text.c
tilde.o: tilde.c
undo.o: undo.c
util.o: util.c
vi_mode.o: vi_mode.c
xmalloc.o: xmalloc.c
history.o: history.c
histexpand.o: histexpand.c
histfile.o: histfile.c
history.o: history.c
histsearch.o: histsearch.c
savestring.o: savestring.c
shell.o: shell.c
tilde.o: tilde.c

View File

@ -1,7 +1,7 @@
Introduction
============
This is the Gnu Readline library, version 4.1.
This is the Gnu Readline library, version 4.3.
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
@ -16,8 +16,8 @@ may be used without Readline in applications which desire its
capabilities.
The Readline library is free software, distributed under the terms of
the GNU Public License, version 2. For more information, see the file
COPYING.
the [GNU] General Public License, version 2. For more information, see
the file COPYING.
To build the library, try typing `./configure', then `make'. The
configuration process is automated, so no further intervention should
@ -37,6 +37,9 @@ to customize and control the build process.
The file rlconf.h contains C preprocessor defines that enable and disable
certain Readline features.
The special make target `everything' will build the static and shared
libraries (if the target platform supports them) and the examples.
Examples
========
@ -54,6 +57,9 @@ a Makefile in the `shlib' subdirectory, and typing `make shared'
will cause shared versions of the Readline and History libraries
to be built on supported platforms.
If `configure' is given the `--enable-shared' option, it will attempt
to build the shared libraries by default on supported platforms.
Configure calls the script support/shobj-conf to test whether or
not shared library creation is supported and to generate the values
of variables that are substituted into shlib/Makefile. If you
@ -64,8 +70,8 @@ your platform.
If you need to update support/shobj-conf, you will need to create
a `stanza' for your operating system and compiler. The script uses
the value of host_os and ${CC} as determined by configure. For
instance, FreeBSD 2.2.5 with any version of gcc is identified as
`freebsd2.2.5-gcc*'.
instance, FreeBSD 4.2 with any version of gcc is identified as
`freebsd4.2-gcc*'.
In the stanza for your operating system-compiler pair, you will need to
define several variables. They are:
@ -122,18 +128,21 @@ Once you have updated support/shobj-conf, re-run configure and type
`make shared'. The shared libraries will be created in the shlib
subdirectory.
Since shared libraries are not created on all platforms, `make install'
will not automatically install the shared libraries. To install them,
change the current directory to shlib and type `make install'. Running
`make install-shared' from the top-level build directory will also work.
If shared libraries are created, `make install' will install them.
You may install only the shared libraries by running `make
install-shared' from the top-level build directory. Running `make
install' in the shlib subdirectory will also work. If you don't want
to install any created shared libraries, run `make install-static'.
Documentation
=============
The documentation for the Readline and History libraries appears in the
`doc' subdirectory. There are two texinfo files and a Unix-style manual
page describing the programming facilities available in the Readline
library. The texinfo files include both user and programmer's manuals.
The documentation for the Readline and History libraries appears in
the `doc' subdirectory. There are three texinfo files and a
Unix-style manual page describing the facilities available in the
Readline library. The texinfo files include both user and
programmer's manuals. HTML versions of the manuals appear in the
`doc' subdirectory as well.
Reporting Bugs
==============
@ -144,7 +153,7 @@ Bug reports for Readline should be sent to:
When reporting a bug, please include the following information:
* the version number and release status of Readline (e.g., 4.0-release)
* the version number and release status of Readline (e.g., 4.2-release)
* the machine and OS that it is running on
* a list of the compilation flags or the contents of `config.h', if
appropriate

1557
readline/aclocal.m4 vendored

File diff suppressed because it is too large Load Diff

View File

@ -25,11 +25,24 @@
/* String conversion functions. */
extern int atoi ();
extern long int atol ();
extern double atof ();
extern double strtod ();
/* Memory allocation functions. */
extern char *malloc ();
extern char *realloc ();
/* Generic pointer type. */
#ifndef PTR_T
#if defined (__STDC__)
# define PTR_T void *
#else
# define PTR_T char *
#endif
#endif /* PTR_T */
extern PTR_T malloc ();
extern PTR_T realloc ();
extern void free ();
/* Other miscellaneous functions. */

View File

@ -68,9 +68,11 @@ extern char *strchr (), *strrchr ();
/* Variables exported by this file. */
Keymap rl_binding_keymap;
static int _rl_read_init_file __P((char *, int));
static int glean_key_from_name __P((char *));
static int substring_member_of_array __P((char *, char **));
static char *_rl_read_file PARAMS((char *, size_t *));
static void _rl_init_file_error PARAMS((const char *));
static int _rl_read_init_file PARAMS((const char *, int));
static int glean_key_from_name PARAMS((char *));
static int substring_member_of_array PARAMS((char *, const char **));
static int currently_reading_init_file;
@ -83,13 +85,13 @@ static int _rl_prefer_visible_bell = 1;
/* */
/* **************************************************************** */
/* rl_add_defun (char *name, Function *function, int key)
/* rl_add_defun (char *name, rl_command_func_t *function, int key)
Add NAME to the list of named functions. Make FUNCTION be the function
that gets called. If KEY is not -1, then bind it. */
int
rl_add_defun (name, function, key)
char *name;
Function *function;
const char *name;
rl_command_func_t *function;
int key;
{
if (key != -1)
@ -102,7 +104,7 @@ rl_add_defun (name, function, key)
int
rl_bind_key (key, function)
int key;
Function *function;
rl_command_func_t *function;
{
if (key < 0)
return (key);
@ -133,7 +135,7 @@ rl_bind_key (key, function)
int
rl_bind_key_in_map (key, function, map)
int key;
Function *function;
rl_command_func_t *function;
Keymap map;
{
int result;
@ -152,7 +154,7 @@ int
rl_unbind_key (key)
int key;
{
return (rl_bind_key (key, (Function *)NULL));
return (rl_bind_key (key, (rl_command_func_t *)NULL));
}
/* Make KEY do nothing in MAP.
@ -162,13 +164,13 @@ rl_unbind_key_in_map (key, map)
int key;
Keymap map;
{
return (rl_bind_key_in_map (key, (Function *)NULL, map));
return (rl_bind_key_in_map (key, (rl_command_func_t *)NULL, map));
}
/* Unbind all keys bound to FUNCTION in MAP. */
int
rl_unbind_function_in_map (func, map)
Function *func;
rl_command_func_t *func;
Keymap map;
{
register int i, rval;
@ -177,7 +179,7 @@ rl_unbind_function_in_map (func, map)
{
if (map[i].type == ISFUNC && map[i].function == func)
{
map[i].function = (Function *)NULL;
map[i].function = (rl_command_func_t *)NULL;
rval = 1;
}
}
@ -186,10 +188,10 @@ rl_unbind_function_in_map (func, map)
int
rl_unbind_command_in_map (command, map)
char *command;
const char *command;
Keymap map;
{
Function *func;
rl_command_func_t *func;
func = rl_named_function (command);
if (func == 0)
@ -202,8 +204,8 @@ rl_unbind_command_in_map (command, map)
place to do bindings is in MAP. */
int
rl_set_key (keyseq, function, map)
char *keyseq;
Function *function;
const char *keyseq;
rl_command_func_t *function;
Keymap map;
{
return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map));
@ -214,7 +216,7 @@ rl_set_key (keyseq, function, map)
necessary. The initial place to do bindings is in MAP. */
int
rl_macro_bind (keyseq, macro, map)
char *keyseq, *macro;
const char *keyseq, *macro;
Keymap map;
{
char *macro_keys;
@ -239,12 +241,16 @@ rl_macro_bind (keyseq, macro, map)
int
rl_generic_bind (type, keyseq, data, map)
int type;
char *keyseq, *data;
const char *keyseq;
char *data;
Keymap map;
{
char *keys;
int keys_len;
register int i;
KEYMAP_ENTRY k;
k.function = 0;
/* If no keys to bind to, exit right away. */
if (!keyseq || !*keyseq)
@ -254,7 +260,7 @@ rl_generic_bind (type, keyseq, data, map)
return -1;
}
keys = xmalloc (1 + (2 * strlen (keyseq)));
keys = (char *)xmalloc (1 + (2 * strlen (keyseq)));
/* Translate the ASCII representation of KEYSEQ into an array of
characters. Stuff the characters into KEYS, and the length of
@ -268,7 +274,12 @@ rl_generic_bind (type, keyseq, data, map)
/* Bind keys, making new keymaps as necessary. */
for (i = 0; i < keys_len; i++)
{
int ic = (int) ((unsigned char)keys[i]);
unsigned char uc = keys[i];
int ic;
ic = uc;
if (ic < 0 || ic >= KEYMAP_SIZE)
return -1;
if (_rl_convert_meta_chars_to_ascii && META_CHAR (ic))
{
@ -281,18 +292,40 @@ rl_generic_bind (type, keyseq, data, map)
{
if (map[ic].type != ISKMAP)
{
if (map[ic].type == ISMACR)
free ((char *)map[ic].function);
/* We allow subsequences of keys. If a keymap is being
created that will `shadow' an existing function or macro
key binding, we save that keybinding into the ANYOTHERKEY
index in the new map. The dispatch code will look there
to find the function to execute if the subsequence is not
matched. ANYOTHERKEY was chosen to be greater than
UCHAR_MAX. */
k = map[ic];
map[ic].type = ISKMAP;
map[ic].function = KEYMAP_TO_FUNCTION (rl_make_bare_keymap());
}
map = FUNCTION_TO_KEYMAP (map, ic);
/* The dispatch code will return this function if no matching
key sequence is found in the keymap. This (with a little
help from the dispatch code in readline.c) allows `a' to be
mapped to something, `abc' to be mapped to something else,
and the function bound to `a' to be executed when the user
types `abx', leaving `bx' in the input queue. */
if (k.function /* && k.type == ISFUNC */)
{
map[ANYOTHERKEY] = k;
k.function = 0;
}
}
else
{
if (map[ic].type == ISMACR)
free ((char *)map[ic].function);
else if (map[ic].type == ISKMAP)
{
map = FUNCTION_TO_KEYMAP (map, ic);
ic = ANYOTHERKEY;
}
map[ic].function = KEYMAP_TO_FUNCTION (data);
map[ic].type = type;
@ -309,7 +342,8 @@ rl_generic_bind (type, keyseq, data, map)
non-zero if there was an error parsing SEQ. */
int
rl_translate_keyseq (seq, array, len)
char *seq, *array;
const char *seq;
char *array;
int *len;
{
register int i, c, l, temp;
@ -329,7 +363,7 @@ rl_translate_keyseq (seq, array, len)
/* Handle special case of backwards define. */
if (strncmp (&seq[i], "C-\\M-", 5) == 0)
{
array[l++] = ESC;
array[l++] = ESC; /* ESC is meta-prefix */
i += 5;
array[l++] = CTRL (_rl_to_upper (seq[i]));
if (seq[i] == '\0')
@ -338,7 +372,7 @@ rl_translate_keyseq (seq, array, len)
else if (c == 'M')
{
i++;
array[l++] = ESC; /* XXX */
array[l++] = ESC; /* ESC is meta-prefix */
}
else if (c == 'C')
{
@ -391,16 +425,16 @@ rl_translate_keyseq (seq, array, len)
for (temp = 2, c -= '0'; ISOCTAL (seq[i]) && temp--; i++)
c = (c * 8) + OCTVALUE (seq[i]);
i--; /* auto-increment in for loop */
array[l++] = c % (largest_char + 1);
array[l++] = c & largest_char;
break;
case 'x':
i++;
for (temp = 3, c = 0; isxdigit (seq[i]) && temp--; i++)
for (temp = 2, c = 0; ISXDIGIT ((unsigned char)seq[i]) && temp--; i++)
c = (c * 16) + HEXVALUE (seq[i]);
if (temp == 3)
if (temp == 2)
c = 'x';
i--; /* auto-increment in for loop */
array[l++] = c % (largest_char + 1);
array[l++] = c & largest_char;
break;
default: /* backslashes before non-special chars just add the char */
array[l++] = c;
@ -470,7 +504,7 @@ _rl_untranslate_macro_value (seq)
char *ret, *r, *s;
int c;
r = ret = xmalloc (7 * strlen (seq) + 1);
r = ret = (char *)xmalloc (7 * strlen (seq) + 1);
for (s = seq; *s; s++)
{
c = *s;
@ -513,9 +547,9 @@ _rl_untranslate_macro_value (seq)
/* Return a pointer to the function that STRING represents.
If STRING doesn't have a matching function, then a NULL pointer
is returned. */
Function *
rl_command_func_t *
rl_named_function (string)
char *string;
const char *string;
{
register int i;
@ -524,7 +558,7 @@ rl_named_function (string)
for (i = 0; funmap[i]; i++)
if (_rl_stricmp (funmap[i]->name, string) == 0)
return (funmap[i]->function);
return ((Function *)NULL);
return ((rl_command_func_t *)NULL);
}
/* Return the function (or macro) definition which would be invoked via
@ -532,9 +566,9 @@ rl_named_function (string)
used. TYPE, if non-NULL, is a pointer to an int which will receive the
type of the object pointed to. One of ISFUNC (function), ISKMAP (keymap),
or ISMACR (macro). */
Function *
rl_command_func_t *
rl_function_of_keyseq (keyseq, map, type)
char *keyseq;
const char *keyseq;
Keymap map;
int *type;
{
@ -545,7 +579,7 @@ rl_function_of_keyseq (keyseq, map, type)
for (i = 0; keyseq && keyseq[i]; i++)
{
int ic = keyseq[i];
unsigned char ic = keyseq[i];
if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
{
@ -585,14 +619,14 @@ rl_function_of_keyseq (keyseq, map, type)
return (map[ic].function);
}
}
return ((Function *) NULL);
return ((rl_command_func_t *) NULL);
}
/* The last key bindings file read. */
static char *last_readline_init_file = (char *)NULL;
/* The file we're currently reading key bindings from. */
static char *current_readline_init_file;
static const char *current_readline_init_file;
static int current_readline_init_include_level;
static int current_readline_init_lineno;
@ -630,25 +664,15 @@ _rl_read_file (filename, sizep)
i = read (file, buffer, file_size);
close (file);
#if 0
if (i < file_size)
#else
if (i < 0)
#endif
{
free (buffer);
return ((char *)NULL);
}
#if 0
buffer[file_size] = '\0';
if (sizep)
*sizep = file_size;
#else
buffer[i] = '\0';
if (sizep)
*sizep = i;
#endif
return (buffer);
}
@ -659,7 +683,7 @@ rl_re_read_init_file (count, ignore)
int count, ignore;
{
int r;
r = rl_read_init_file ((char *)NULL);
r = rl_read_init_file ((const char *)NULL);
rl_set_keymap_from_edit_mode ();
return r;
}
@ -673,14 +697,14 @@ rl_re_read_init_file (count, ignore)
otherwise errno is returned. */
int
rl_read_init_file (filename)
char *filename;
const char *filename;
{
/* Default the filename. */
if (filename == 0)
{
filename = last_readline_init_file;
if (filename == 0)
filename = get_env_value ("INPUTRC");
filename = sh_get_env_value ("INPUTRC");
if (filename == 0)
filename = DEFAULT_INPUTRC;
}
@ -698,7 +722,7 @@ rl_read_init_file (filename)
static int
_rl_read_init_file (filename, include_level)
char *filename;
const char *filename;
int include_level;
{
register int i;
@ -733,7 +757,7 @@ _rl_read_init_file (filename, include_level)
/* Find the end of this line. */
for (i = 0; line + i != end && line[i] != '\n'; i++);
#if defined (__CYGWIN32__)
#if defined (__CYGWIN__)
/* ``Be liberal in what you accept.'' */
if (line[i] == '\n' && line[i-1] == '\r')
line[i - 1] = '\0';
@ -765,7 +789,7 @@ _rl_read_init_file (filename, include_level)
static void
_rl_init_file_error (msg)
char *msg;
const char *msg;
{
if (currently_reading_init_file)
fprintf (stderr, "readline: %s: line %d: %s\n", current_readline_init_file,
@ -780,10 +804,21 @@ _rl_init_file_error (msg)
/* */
/* **************************************************************** */
typedef int _rl_parser_func_t PARAMS((char *));
/* Things that mean `Control'. */
const char *_rl_possible_control_prefixes[] = {
"Control-", "C-", "CTRL-", (const char *)NULL
};
const char *_rl_possible_meta_prefixes[] = {
"Meta", "M-", (const char *)NULL
};
/* Conditionals. */
/* Calling programs set this to have their argv[0]. */
char *rl_readline_name = "other";
const char *rl_readline_name = "other";
/* Stack of previous values of parsing_conditionalized_out. */
static unsigned char *if_stack = (unsigned char *)NULL;
@ -905,7 +940,8 @@ static int
parser_include (args)
char *args;
{
char *old_init_file, *e;
const char *old_init_file;
char *e;
int old_line_number, old_include_level, r;
if (_rl_parsing_conditionalized_out)
@ -918,7 +954,7 @@ parser_include (args)
e = strchr (args, '\n');
if (e)
*e = '\0';
r = _rl_read_init_file (args, old_include_level + 1);
r = _rl_read_init_file ((const char *)args, old_include_level + 1);
current_readline_init_file = old_init_file;
current_readline_init_lineno = old_line_number;
@ -929,14 +965,14 @@ parser_include (args)
/* Associate textual names with actual functions. */
static struct {
char *name;
Function *function;
const char *name;
_rl_parser_func_t *function;
} parser_directives [] = {
{ "if", parser_if },
{ "endif", parser_endif },
{ "else", parser_else },
{ "include", parser_include },
{ (char *)0x0, (Function *)0x0 }
{ (char *)0x0, (_rl_parser_func_t *)0x0 }
};
/* Handle a parser directive. STATEMENT is the line of the directive
@ -1061,7 +1097,7 @@ rl_parse_and_bind (string)
/* Make VAR point to start of variable name. */
while (*var && whitespace (*var)) var++;
/* Make value point to start of value string. */
/* Make VALUE point to start of value string. */
value = var;
while (*value && !whitespace (*value)) value++;
if (*value)
@ -1131,7 +1167,7 @@ rl_parse_and_bind (string)
char *seq;
register int j, k, passc;
seq = xmalloc (1 + strlen (string));
seq = (char *)xmalloc (1 + strlen (string));
for (j = 1, k = passc = 0; string[j]; j++)
{
/* Allow backslash to quote characters, but leave them in place.
@ -1180,16 +1216,16 @@ rl_parse_and_bind (string)
key = glean_key_from_name (kname);
/* Add in control and meta bits. */
if (substring_member_of_array (string, possible_control_prefixes))
if (substring_member_of_array (string, _rl_possible_control_prefixes))
key = CTRL (_rl_to_upper (key));
if (substring_member_of_array (string, possible_meta_prefixes))
if (substring_member_of_array (string, _rl_possible_meta_prefixes))
key = META (key);
/* Temporary. Handle old-style keyname with macro-binding. */
if (*funname == '\'' || *funname == '"')
{
unsigned char useq[2];
char useq[2];
int fl = strlen (funname);
useq[0] = key; useq[1] = '\0';
@ -1221,22 +1257,27 @@ rl_parse_and_bind (string)
#define V_SPECIAL 0x1
static struct {
char *name;
const char *name;
int *value;
int flags;
} boolean_varlist [] = {
{ "blink-matching-paren", &rl_blink_matching_paren, V_SPECIAL },
{ "byte-oriented", &rl_byte_oriented, 0 },
{ "completion-ignore-case", &_rl_completion_case_fold, 0 },
{ "convert-meta", &_rl_convert_meta_chars_to_ascii, 0 },
{ "disable-completion", &rl_inhibit_completion, 0 },
{ "enable-keypad", &_rl_enable_keypad, 0 },
{ "expand-tilde", &rl_complete_with_tilde_expansion, 0 },
{ "history-preserve-point", &_rl_history_preserve_point, 0 },
{ "horizontal-scroll-mode", &_rl_horizontal_scroll_mode, 0 },
{ "input-meta", &_rl_meta_flag, 0 },
{ "mark-directories", &_rl_complete_mark_directories, 0 },
{ "mark-modified-lines", &_rl_mark_modified_lines, 0 },
{ "mark-symlinked-directories", &_rl_complete_mark_symlink_dirs, 0 },
{ "match-hidden-files", &_rl_match_hidden_files, 0 },
{ "meta-flag", &_rl_meta_flag, 0 },
{ "output-meta", &_rl_output_meta_chars, 0 },
{ "page-completions", &_rl_page_completions, 0 },
{ "prefer-visible-bell", &_rl_prefer_visible_bell, V_SPECIAL },
{ "print-completions-horizontally", &_rl_print_completions_horizontally, 0 },
{ "show-all-if-ambiguous", &_rl_complete_show_all, 0 },
@ -1248,7 +1289,7 @@ static struct {
static int
find_boolean_var (name)
char *name;
const char *name;
{
register int i;
@ -1265,7 +1306,7 @@ static void
hack_special_boolean_var (i)
int i;
{
char *name;
const char *name;
name = boolean_varlist[i].name;
@ -1280,6 +1321,8 @@ hack_special_boolean_var (i)
}
}
typedef int _rl_sv_func_t PARAMS((const char *));
/* These *must* correspond to the array indices for the appropriate
string variable. (Though they're not used right now.) */
#define V_BELLSTYLE 0
@ -1292,17 +1335,17 @@ hack_special_boolean_var (i)
#define V_INT 2
/* Forward declarations */
static int sv_bell_style __P((char *));
static int sv_combegin __P((char *));
static int sv_compquery __P((char *));
static int sv_editmode __P((char *));
static int sv_isrchterm __P((char *));
static int sv_keymap __P((char *));
static int sv_bell_style PARAMS((const char *));
static int sv_combegin PARAMS((const char *));
static int sv_compquery PARAMS((const char *));
static int sv_editmode PARAMS((const char *));
static int sv_isrchterm PARAMS((const char *));
static int sv_keymap PARAMS((const char *));
static struct {
char *name;
const char *name;
int flags;
Function *set_func;
_rl_sv_func_t *set_func;
} string_varlist[] = {
{ "bell-style", V_STRING, sv_bell_style },
{ "comment-begin", V_STRING, sv_combegin },
@ -1315,7 +1358,7 @@ static struct {
static int
find_string_var (name)
char *name;
const char *name;
{
register int i;
@ -1339,7 +1382,7 @@ bool_to_int (value)
int
rl_variable_bind (name, value)
char *name, *value;
const char *name, *value;
{
register int i;
int v;
@ -1367,7 +1410,7 @@ rl_variable_bind (name, value)
static int
sv_editmode (value)
char *value;
const char *value;
{
if (_rl_strnicmp (value, "vi", 2) == 0)
{
@ -1388,7 +1431,7 @@ sv_editmode (value)
static int
sv_combegin (value)
char *value;
const char *value;
{
if (value && *value)
{
@ -1401,7 +1444,7 @@ sv_combegin (value)
static int
sv_compquery (value)
char *value;
const char *value;
{
int nval = 100;
@ -1417,7 +1460,7 @@ sv_compquery (value)
static int
sv_keymap (value)
char *value;
const char *value;
{
Keymap kmap;
@ -1430,28 +1473,26 @@ sv_keymap (value)
return 1;
}
#define _SET_BELL(v) do { _rl_bell_preference = v; return 0; } while (0)
static int
sv_bell_style (value)
char *value;
const char *value;
{
if (value == 0 || *value == '\0')
_SET_BELL (AUDIBLE_BELL);
_rl_bell_preference = AUDIBLE_BELL;
else if (_rl_stricmp (value, "none") == 0 || _rl_stricmp (value, "off") == 0)
_SET_BELL (NO_BELL);
_rl_bell_preference = NO_BELL;
else if (_rl_stricmp (value, "audible") == 0 || _rl_stricmp (value, "on") == 0)
_SET_BELL (AUDIBLE_BELL);
_rl_bell_preference = AUDIBLE_BELL;
else if (_rl_stricmp (value, "visible") == 0)
_SET_BELL (VISIBLE_BELL);
_rl_bell_preference = VISIBLE_BELL;
else
return 1;
return 0;
}
#undef _SET_BELL
static int
sv_isrchterm (value)
char *value;
const char *value;
{
int beg, end, delim;
char *v;
@ -1477,7 +1518,7 @@ sv_isrchterm (value)
v[end] = '\0';
/* The value starts at v + beg. Translate it into a character string. */
_rl_isearch_terminators = (unsigned char *)xmalloc (2 * strlen (v) + 1);
_rl_isearch_terminators = (char *)xmalloc (2 * strlen (v) + 1);
rl_translate_keyseq (v + beg, _rl_isearch_terminators, &end);
_rl_isearch_terminators[end] = '\0';
@ -1489,7 +1530,7 @@ sv_isrchterm (value)
For example, `Space' returns ' '. */
typedef struct {
char *name;
const char *name;
int value;
} assoc_list;
@ -1523,7 +1564,7 @@ glean_key_from_name (name)
/* Auxiliary functions to manage keymaps. */
static struct {
char *name;
const char *name;
Keymap map;
} keymap_names[] = {
{ "emacs", emacs_standard_keymap },
@ -1541,12 +1582,12 @@ static struct {
Keymap
rl_get_keymap_by_name (name)
char *name;
const char *name;
{
register int i;
for (i = 0; keymap_names[i].name; i++)
if (strcmp (name, keymap_names[i].name) == 0)
if (_rl_stricmp (name, keymap_names[i].name) == 0)
return (keymap_names[i].map);
return ((Keymap) NULL);
}
@ -1558,7 +1599,7 @@ rl_get_keymap_name (map)
register int i;
for (i = 0; keymap_names[i].name; i++)
if (map == keymap_names[i].map)
return (keymap_names[i].name);
return ((char *)keymap_names[i].name);
return ((char *)NULL);
}
@ -1616,7 +1657,7 @@ void
rl_list_funmap_names ()
{
register int i;
char **funmap_names;
const char **funmap_names;
funmap_names = rl_funmap_names ();
@ -1643,17 +1684,18 @@ _rl_get_keyname (key)
pairs for possible inclusion in an inputrc file, we don't want to
do any special meta processing on KEY. */
#if 0
#if 1
/* XXX - Experimental */
/* We might want to do this, but the old version of the code did not. */
/* If this is an escape character, we don't want to do any more processing.
Just add the special ESC key sequence and return. */
if (c == ESC)
{
keyseq[0] = '\\';
keyseq[1] = 'e';
keyseq[2] = '\0';
return keyseq;
keyname[0] = '\\';
keyname[1] = 'e';
keyname[2] = '\0';
return keyname;
}
#endif
@ -1706,7 +1748,7 @@ _rl_get_keyname (key)
sequences that are used to invoke FUNCTION in MAP. */
char **
rl_invoking_keyseqs_in_map (function, map)
Function *function;
rl_command_func_t *function;
Keymap map;
{
register int key;
@ -1735,7 +1777,7 @@ rl_invoking_keyseqs_in_map (function, map)
if (result_index + 2 > result_size)
{
result_size += 10;
result = (char **) xrealloc (result, result_size * sizeof (char *));
result = (char **)xrealloc (result, result_size * sizeof (char *));
}
result[result_index++] = keyname;
@ -1764,7 +1806,12 @@ rl_invoking_keyseqs_in_map (function, map)
char *keyname = (char *)xmalloc (6 + strlen (seqs[i]));
if (key == ESC)
#if 0
sprintf (keyname, "\\e");
#else
/* XXX - experimental */
sprintf (keyname, "\\M-");
#endif
else if (CTRL_CHAR (key))
sprintf (keyname, "\\C-%c", _rl_to_lower (UNCTRL (key)));
else if (key == RUBOUT)
@ -1787,7 +1834,7 @@ rl_invoking_keyseqs_in_map (function, map)
if (result_index + 2 > result_size)
{
result_size += 10;
result = (char **) xrealloc (result, result_size * sizeof (char *));
result = (char **)xrealloc (result, result_size * sizeof (char *));
}
result[result_index++] = keyname;
@ -1806,7 +1853,7 @@ rl_invoking_keyseqs_in_map (function, map)
sequences that can be used to invoke FUNCTION using the current keymap. */
char **
rl_invoking_keyseqs (function)
Function *function;
rl_command_func_t *function;
{
return (rl_invoking_keyseqs_in_map (function, _rl_keymap));
}
@ -1819,8 +1866,8 @@ rl_function_dumper (print_readably)
int print_readably;
{
register int i;
char **names;
char *name;
const char **names;
const char *name;
names = rl_funmap_names ();
@ -1828,7 +1875,7 @@ rl_function_dumper (print_readably)
for (i = 0; name = names[i]; i++)
{
Function *function;
rl_command_func_t *function;
char **invokers;
function = rl_named_function (name);
@ -1911,11 +1958,8 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
{
case ISMACR:
keyname = _rl_get_keyname (key);
#if 0
out = (char *)map[key].function;
#else
out = _rl_untranslate_macro_value ((char *)map[key].function);
#endif
if (print_readably)
fprintf (rl_outstream, "\"%s%s\": \"%s\"\n", prefix ? prefix : "",
keyname,
@ -1925,9 +1969,7 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
keyname,
out ? out : "");
free (keyname);
#if 1
free (out);
#endif
break;
case ISFUNC:
break;
@ -1935,7 +1977,7 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
prefix_len = prefix ? strlen (prefix) : 0;
if (key == ESC)
{
keyname = xmalloc (3 + prefix_len);
keyname = (char *)xmalloc (3 + prefix_len);
if (prefix)
strcpy (keyname, prefix);
keyname[prefix_len] = '\\';
@ -1947,7 +1989,7 @@ _rl_macro_dumper_internal (print_readably, map, prefix)
keyname = _rl_get_keyname (key);
if (prefix)
{
out = xmalloc (strlen (keyname) + prefix_len + 1);
out = (char *)xmalloc (strlen (keyname) + prefix_len + 1);
strcpy (out, prefix);
strcpy (out + prefix_len, keyname);
free (keyname);
@ -1985,7 +2027,7 @@ rl_variable_dumper (print_readably)
int print_readably;
{
int i;
char *kname;
const char *kname;
for (i = 0; boolean_varlist[i].name; i++)
{
@ -2017,7 +2059,7 @@ rl_variable_dumper (print_readably)
if (print_readably)
fprintf (rl_outstream, "set comment-begin %s\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
else
fprintf (rl_outstream, "comment-begin is set to `%s'\n", _rl_comment_begin ? _rl_comment_begin : "");
fprintf (rl_outstream, "comment-begin is set to `%s'\n", _rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
/* completion-query-items */
if (print_readably)
@ -2031,15 +2073,6 @@ rl_variable_dumper (print_readably)
else
fprintf (rl_outstream, "editing-mode is set to `%s'\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi");
/* keymap */
kname = rl_get_keymap_name (_rl_keymap);
if (kname == 0)
kname = rl_get_keymap_name_from_edit_mode ();
if (print_readably)
fprintf (rl_outstream, "set keymap %s\n", kname ? kname : "none");
else
fprintf (rl_outstream, "keymap is set to `%s'\n", kname ? kname : "none");
/* isearch-terminators */
if (_rl_isearch_terminators)
{
@ -2054,6 +2087,15 @@ rl_variable_dumper (print_readably)
free (disp);
}
/* keymap */
kname = rl_get_keymap_name (_rl_keymap);
if (kname == 0)
kname = rl_get_keymap_name_from_edit_mode ();
if (print_readably)
fprintf (rl_outstream, "set keymap %s\n", kname ? kname : "none");
else
fprintf (rl_outstream, "keymap is set to `%s'\n", kname ? kname : "none");
}
/* Print all of the current variables and their values to
@ -2070,18 +2112,24 @@ rl_dump_variables (count, key)
return (0);
}
/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. */
/* Bind key sequence KEYSEQ to DEFAULT_FUNC if KEYSEQ is unbound. Right
now, this is always used to attempt to bind the arrow keys, hence the
check for rl_vi_movement_mode. */
void
_rl_bind_if_unbound (keyseq, default_func)
char *keyseq;
Function *default_func;
const char *keyseq;
rl_command_func_t *default_func;
{
Function *func;
rl_command_func_t *func;
if (keyseq)
{
func = rl_function_of_keyseq (keyseq, _rl_keymap, (int *)NULL);
#if defined (VI_MODE)
if (!func || func == rl_do_lowercase_version || func == rl_vi_movement_mode)
#else
if (!func || func == rl_do_lowercase_version)
#endif
rl_set_key (keyseq, default_func, _rl_keymap);
}
}
@ -2089,7 +2137,8 @@ _rl_bind_if_unbound (keyseq, default_func)
/* Return non-zero if any members of ARRAY are a substring in STRING. */
static int
substring_member_of_array (string, array)
char *string, **array;
char *string;
const char **array;
{
while (*array)
{

View File

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

View File

@ -27,10 +27,14 @@
#if defined (HAVE_CONFIG_H)
# if defined (HAVE_STRING_H)
# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
# include <memory.h>
# endif
# include <string.h>
# else
# include <strings.h>
# endif /* HAVE_STRING_H */
# if defined (HAVE_STRINGS_H)
# include <strings.h>
# endif /* HAVE_STRINGS_H */
#else
# include <string.h>
#endif /* !HAVE_CONFIG_H */
@ -40,7 +44,10 @@
#endif
#ifdef CTRL
#undef CTRL
# undef CTRL
#endif
#ifdef UNCTRL
# undef UNCTRL
#endif
/* Some character stuff. */
@ -51,7 +58,7 @@
#define meta_character_bit 0x080 /* x0000000, must be on. */
#define largest_char 255 /* Largest character value. */
#define CTRL_CHAR(c) ((c) < control_character_threshold && (c) >= 0)
#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
#define CTRL(c) ((c) & control_character_mask)
@ -60,33 +67,59 @@
#define UNMETA(c) ((c) & (~meta_character_bit))
#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
/* Old versions
#define _rl_lowercase_p(c) (((c) > ('a' - 1) && (c) < ('z' + 1)))
#define _rl_uppercase_p(c) (((c) > ('A' - 1) && (c) < ('Z' + 1)))
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
*/
#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
# define IN_CTYPE_DOMAIN(c) 1
#else
# define IN_CTYPE_DOMAIN(c) isascii(c)
#endif
#define _rl_lowercase_p(c) (islower(c))
#define _rl_uppercase_p(c) (isupper(c))
#define _rl_digit_p(x) (isdigit (x))
#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
#endif
#define _rl_pure_alphabetic(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c))
#define ALPHABETIC(c) (_rl_lowercase_p(c) || _rl_uppercase_p(c) || _rl_digit_p(c))
#define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
/* Old versions
# define _rl_to_upper(c) (_rl_lowercase_p(c) ? ((c) - 32) : (c))
# define _rl_to_lower(c) (_rl_uppercase_p(c) ? ((c) + 32) : (c))
*/
/* Some systems define these; we want our definitions. */
#undef ISPRINT
#define ISALNUM(c) (IN_CTYPE_DOMAIN (c) && isalnum (c))
#define ISALPHA(c) (IN_CTYPE_DOMAIN (c) && isalpha (c))
#define ISDIGIT(c) (IN_CTYPE_DOMAIN (c) && isdigit (c))
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c))
#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c))
#ifndef _rl_to_upper
# define _rl_to_upper(c) (islower(c) ? toupper(c) : (c))
# define _rl_to_lower(c) (isupper(c) ? tolower(c) : (c))
# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
#endif
#ifndef _rl_digit_value
#define _rl_digit_value(x) ((x) - '0')
# define _rl_digit_value(x) ((x) - '0')
#endif
#ifndef _rl_isident
# define _rl_isident(c) (ISALNUM(c) || (c) == '_')
#endif
#ifndef ISOCTAL
# define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
#endif
#define OCTVALUE(c) ((c) - '0')
#define HEXVALUE(c) \
(((c) >= 'a' && (c) <= 'f') \
? (c)-'a'+10 \
: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
#ifndef NEWLINE
#define NEWLINE '\n'
#endif
@ -123,18 +156,4 @@
#endif
#define ESC CTRL('[')
#ifndef ISOCTAL
#define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
#endif
#define OCTVALUE(c) ((c) - '0')
#ifndef isxdigit
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
#endif
#define HEXVALUE(c) \
(((c) >= 'a' && (c) <= 'f') \
? (c)-'a'+10 \
: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
#endif /* _CHARDEFS_H_ */

113
readline/compat.c Normal file
View File

@ -0,0 +1,113 @@
/* compat.c -- backwards compatibility functions. */
/* Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <stdio.h>
#include "rlstdc.h"
#include "rltypedefs.h"
extern void rl_free_undo_list PARAMS((void));
extern int rl_maybe_save_line PARAMS((void));
extern int rl_maybe_unsave_line PARAMS((void));
extern int rl_maybe_replace_line PARAMS((void));
extern int rl_crlf PARAMS((void));
extern int rl_ding PARAMS((void));
extern int rl_alphabetic PARAMS((int));
extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
extern char *rl_username_completion_function PARAMS((const char *, int));
extern char *rl_filename_completion_function PARAMS((const char *, int));
/* Provide backwards-compatible entry points for old function names. */
void
free_undo_list ()
{
rl_free_undo_list ();
}
int
maybe_replace_line ()
{
return rl_maybe_replace_line ();
}
int
maybe_save_line ()
{
return rl_maybe_save_line ();
}
int
maybe_unsave_line ()
{
return rl_maybe_unsave_line ();
}
int
ding ()
{
return rl_ding ();
}
int
crlf ()
{
return rl_crlf ();
}
int
alphabetic (c)
int c;
{
return rl_alphabetic (c);
}
char **
completion_matches (s, f)
const char *s;
rl_compentry_func_t *f;
{
return rl_completion_matches (s, f);
}
char *
username_completion_function (s, i)
const char *s;
int i;
{
return rl_username_completion_function (s, i);
}
char *
filename_completion_function (s, i)
const char *s;
int i;
{
return rl_filename_completion_function (s, i);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,63 +1,40 @@
/* config.h.in. Generated automatically from configure.in by autoheader. */
/* Define if you have the strcoll function and it is properly defined. */
#undef HAVE_STRCOLL
/* config.h.in. Maintained by hand. */
/* Define if on MINIX. */
#undef _MINIX
/* Define if the system does not provide POSIX.1 features except
with this defined. */
#undef _POSIX_1_SOURCE
/* Define if you need to in order for stat and other things to work. */
#undef _POSIX_SOURCE
/* Define as the return type of signal handlers (int or void). */
#undef RETSIGTYPE
/* Characteristics of the compiler. */
#undef const
#undef size_t
#undef ssize_t
#undef PROTOTYPES
#undef __CHAR_UNSIGNED__
/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
#undef STAT_MACROS_BROKEN
/* Definitions pulled in from aclocal.m4. */
#undef VOID_SIGHANDLER
#undef GWINSZ_IN_SYS_IOCTL
/* Define if you have the isascii function. */
#undef HAVE_ISASCII
#undef TIOCSTAT_IN_SYS_IOCTL
#undef HAVE_GETPW_DECLS
#undef FIONREAD_IN_SYS_IOCTL
#undef HAVE_BSD_SIGNALS
/* Define if you have the isxdigit function. */
#undef HAVE_ISXDIGIT
/* Define if you have the lstat function. */
#undef HAVE_LSTAT
#undef HAVE_POSIX_SIGNALS
/* Define if you have the mbsrtowcs function. */
#undef HAVE_MBSRTOWCS
#undef HAVE_POSIX_SIGSETJMP
#undef HAVE_USG_SIGHOLD
#undef MUST_REINSTALL_SIGHANDLERS
#undef SPEED_T_IN_SYS_TYPES
#undef STRCOLL_BROKEN
#undef STRUCT_DIRENT_HAS_D_FILENO
#undef STRUCT_DIRENT_HAS_D_INO
#undef STRUCT_WINSIZE_IN_SYS_IOCTL
#undef STRUCT_WINSIZE_IN_TERMIOS
/* Define if you have the lstat function. */
#undef HAVE_LSTAT
/* Define if you have the memmove function. */
/* Define if you have the memmove function. */
#undef HAVE_MEMMOVE
/* Define if you have the putenv function. */
@ -69,21 +46,44 @@
/* Define if you have the setenv function. */
#undef HAVE_SETENV
/* Define if you have the setlocale function. */
/* Define if you have the setlocale function. */
#undef HAVE_SETLOCALE
/* Define if you have the strcasecmp function. */
#undef HAVE_STRCASECMP
/* Define if you have the strcoll function. */
#undef HAVE_STRCOLL
#undef STRCOLL_BROKEN
/* Define if you have the strpbrk function. */
#undef HAVE_STRPBRK
/* Define if you have the tcgetattr function. */
#undef HAVE_TCGETATTR
/* Define if you have the vsnprintf function. */
#undef HAVE_VSNPRINTF
/* Define if you have the wcwidth function. */
#undef HAVE_WCWIDTH
/* Define if you have the <dirent.h> header file. */
#undef HAVE_DIRENT_H
/* Define if you have the <langinfo.h> header file. */
#undef HAVE_LANGINFO_H
/* Define if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
/* Define if you have the <locale.h> header file. */
#undef HAVE_LOCALE_H
/* Define if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define if you have the <ndir.h> header file. */
#undef HAVE_NDIR_H
@ -96,6 +96,9 @@
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define if you have the <sys/dir.h> header file. */
#undef HAVE_SYS_DIR_H
@ -131,7 +134,49 @@
/* Define if you have the <varargs.h> header file. */
#undef HAVE_VARARGS_H
/* config.h.bot */
/* Define if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
/* Define if you have the <varargs.h> header file. */
#undef HAVE_WCTYPE_H
#undef HAVE_MBSTATE_T
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
#undef HAVE_LANGINFO_CODESET
/* Definitions pulled in from aclocal.m4. */
#undef VOID_SIGHANDLER
#undef GWINSZ_IN_SYS_IOCTL
#undef STRUCT_WINSIZE_IN_SYS_IOCTL
#undef STRUCT_WINSIZE_IN_TERMIOS
#undef TIOCSTAT_IN_SYS_IOCTL
#undef FIONREAD_IN_SYS_IOCTL
#undef SPEED_T_IN_SYS_TYPES
#undef HAVE_GETPW_DECLS
#undef STRUCT_DIRENT_HAS_D_INO
#undef STRUCT_DIRENT_HAS_D_FILENO
#undef HAVE_BSD_SIGNALS
#undef HAVE_POSIX_SIGNALS
#undef HAVE_USG_SIGHOLD
#undef MUST_REINSTALL_SIGHANDLERS
#undef HAVE_POSIX_SIGSETJMP
/* modify settings or make new ones based on what autoconf tells us. */
/* Ultrix botches type-ahead when switching from canonical to

6216
readline/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -4,33 +4,47 @@ dnl
dnl report bugs to chet@po.cwru.edu
dnl
dnl Process this file with autoconf to produce a configure script.
AC_REVISION([for Readline 4.1, version 2.22, from autoconf version] AC_ACVERSION)
LIBVERSION=4.1
AC_REVISION([for Readline 4.3, version 2.45, from autoconf version] AC_ACVERSION)
AC_INIT(readline.h)
AC_CONFIG_HEADER(config.h)
AC_INIT(readline, 4.3, bug-readline@gnu.org)
dnl make sure we are using a recent autoconf version
AC_PREREQ(2.10)
AC_PREREQ(2.50)
AC_CONFIG_SRCDIR(readline.h)
dnl AC_CONFIG_AUX_DIR(./support)
AC_CONFIG_HEADERS(config.h)
dnl update the value of RL_READLINE_VERSION in readline.h when this changes
LIBVERSION=4.3
AC_CANONICAL_HOST
dnl configure defaults
opt_curses=no
opt_shared=no
dnl arguments to configure
AC_ARG_WITH(curses, --with-curses use the curses library instead of the termcap library,opt_curses=$withval)
AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
if test "$opt_curses" = "yes"; then
prefer_curses=yes
fi
dnl option parsing for optional features
opt_static_libs=yes
opt_shared_libs=yes
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)
echo ""
echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_vendor}-${host_os}"
echo ""
# We want these before the checks, so the checks can modify their values.
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
AC_PROG_MAKE_SET
AC_PROG_CC
dnl AC_AIX
AC_MINIX
@ -78,7 +92,7 @@ test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
AC_CHECK_PROG(AR, ar, ar)
AC_CHECK_PROG(AR, ar, , ar)
dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
dnl This allows people to set it when running configure or make
test -n "$ARFLAGS" || ARFLAGS="cr"
@ -87,33 +101,42 @@ AC_PROG_RANLIB
MAKE_SHELL=/bin/sh
AC_SUBST(MAKE_SHELL)
AC_RETSIGTYPE
AC_C_CONST
AC_C_PROTOTYPES
AC_C_CHAR_UNSIGNED
AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_CHECK_TYPE(ssize_t, int)
AC_HEADER_STAT
AC_HEADER_DIRENT
AC_CHECK_FUNCS(lstat memmove putenv select setenv setlocale \
strcasecmp tcgetattr)
strcasecmp strpbrk tcgetattr vsnprintf isascii isxdigit)
AC_FUNC_STRCOLL
AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h \
sys/ptem.h sys/pte.h sys/stream.h sys/select.h \
termcap.h termios.h termio.h sys/file.h locale.h)
AC_CHECK_HEADERS(unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \
limits.h sys/ptem.h sys/pte.h sys/stream.h sys/select.h \
termcap.h termios.h termio.h sys/file.h locale.h memory.h )
BASH_SIGNAL_CHECK
BASH_REINSTALL_SIGHANDLERS
BASH_SYS_SIGNAL_VINTAGE
BASH_SYS_REINSTALL_SIGHANDLERS
BASH_FUNC_POSIX_SETJMP
BASH_FUNC_LSTAT
BASH_CHECK_GETPW_FUNCS
BASH_FUNC_STRCOLL
BASH_CHECK_GETPW_FUNCS
AC_HEADER_TIOCGWINSZ
BASH_TYPE_SIGHANDLER
BASH_HAVE_TIOCGWINSZ
BASH_HAVE_TIOCSTAT
BASH_HAVE_FIONREAD
BASH_MISC_SPEED_T
BASH_CHECK_SPEED_T
BASH_STRUCT_WINSIZE
BASH_STRUCT_DIRENT_D_INO
BASH_STRUCT_DIRENT_D_FILENO
@ -124,12 +147,18 @@ aix*) prefer_curses=yes ;;
esac
BASH_CHECK_LIB_TERMCAP
if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
TERMCAP_LIB=-ltermcap #default
if test "$prefer_curses" = yes; then
TERMCAP_LIB=-lcurses
else
TERMCAP_LIB=-ltermcap #default
fi
fi
BASH_CHECK_MULTIBYTE
case "$host_cpu" in
*cray*) LOCAL_CFLAGS=-DCRAY ;;
*s390*) LOCAL_CFLAGS=-fsigned-char ;;
*s390*) LOCAL_CFLAGS=-fsigned-char ;;
esac
case "$host_os" in
@ -158,6 +187,12 @@ if test -f ${srcdir}/support/shobj-conf; then
AC_SUBST(SHLIB_LIBS)
AC_MSG_RESULT($SHLIB_STATUS)
# SHLIB_STATUS is either `supported' or `unsupported'. If it's
# `unsupported', turn off any default shared library building
if test "$SHLIB_STATUS" = 'unsupported'; then
opt_shared_libs=no
fi
# shared library versioning
# quoted for m4 so I can use character classes
SHLIB_MAJOR=[`expr "$LIBVERSION" : '\([0-9]\)\..*'`]
@ -166,6 +201,20 @@ if test -f ${srcdir}/support/shobj-conf; then
AC_SUBST(SHLIB_MINOR)
fi
if test "$opt_static_libs" = "yes"; then
STATIC_TARGET=static
STATIC_INSTALL_TARGET=install-static
fi
if test "$opt_shared_libs" = "yes"; then
SHARED_TARGET=shared
SHARED_INSTALL_TARGET=install-shared
fi
AC_SUBST(STATIC_TARGET)
AC_SUBST(SHARED_TARGET)
AC_SUBST(STATIC_INSTALL_TARGET)
AC_SUBST(SHARED_INSTALL_TARGET)
case "$host_os" in
msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file
*) BUILD_DIR=`pwd` ;;

File diff suppressed because it is too large Load Diff

View File

@ -27,10 +27,16 @@ infodir = @infodir@
mandir = @mandir@
manpfx = man
man1ext = 1
man1dir = $(mandir)/$(manpfx)$(man1ext)
man3ext = 3
man3dir = $(mandir)/$(manpfx)$(man3ext)
man1ext = .1
man1dir = $(mandir)/$(manpfx)1
man3ext = .3
man3dir = $(mandir)/$(manpfx)3
# set this to a value to have the HTML documentation installed
htmldir =
# Support an alternate destination root directory for package building
DESTDIR =
SHELL = @MAKE_SHELL@
RM = rm -f
@ -63,13 +69,13 @@ GROFF = groff
DVIOBJ = readline.dvi history.dvi rluserman.dvi
INFOOBJ = readline.info history.info rluserman.info
PSOBJ = readline.ps history.ps rluserman.ps
PSOBJ = readline.ps history.ps rluserman.ps readline_3.ps history_3.ps
HTMLOBJ = readline.html history.html rluserman.html
TEXTOBJ = readline.0
TEXTOBJ = readline.0 history.0
INTERMEDIATE_OBJ = rlman.dvi hist.dvi rluserman.dvi
CREATED_DOCS = $(DVIOBJ) $(INFOOBJ) $(PSOBJ) $(HTMLOBJ) $(TEXTOBJ)
DIST_DOCS = $(DVIOBJ) $(PSOBJ) $(HTMLOBJ) $(INFOOBJ) $(TEXTOBJ)
.SUFFIXES: .0 .3 .ps .txt .dvi
@ -112,10 +118,12 @@ history.ps: history.dvi
$(RM) $@
$(DVIPS) history.dvi
#
# This leaves readline.html and rlman.html -- rlman.html is for www.gnu.org
#
readline.html: ${RLSRC}
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rlman.texinfo
sed -e 's:rlman.html:readline.html:g' rlman.html > readline.html
$(RM) rlman.html
rluserman.html: ${RLSRC}
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rluserman.texinfo
@ -133,49 +141,94 @@ text: $(TEXTOBJ)
readline.0: readline.3
readline_3.ps: readline.3
${RM} $@
${GROFF} -man < $(srcdir)/readline.3 > $@
history.0: history.3
history_3.ps: history.3
${RM} $@
${GROFF} -man < $(srcdir)/history.3 > $@
clean:
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
*.fns *.kys *.tps *.vrs *.bt *.bts *.o core
distclean: clean
$(RM) $(CREATED_DOCS)
$(RM) $(INTERMEDIATE_OBJ)
$(RM) Makefile
*.fns *.kys *.tps *.vrs *.bt *.bts *.o core *.core
mostlyclean: clean
distclean: clean maybe-clean
$(RM) $(INTERMEDIATE_OBJ)
$(RM) Makefile
maybe-clean:
-if test "X$(topdir)" != "X$(BUILD_DIR)"; then \
$(RM) $(DIST_DOCS); \
fi
maintainer-clean: clean
$(RM) $(CREATED_DOCS)
$(RM) $(DIST_DOCS)
$(RM) $(INTERMEDIATE_OBJ)
$(RM) Makefile
installdirs: $(topdir)/support/mkdirs
-$(SHELL) $(topdir)/support/mkdirs $(infodir) $(man3dir)
-$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(infodir) $(DESTDIR)$(man3dir)
-if test -n "${htmldir}" ; then \
$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(htmldir) ; \
fi
install: installdirs
if test -f readline.info; then \
${INSTALL_DATA} readline.info $(infodir)/readline.info; \
${INSTALL_DATA} readline.info $(DESTDIR)$(infodir)/readline.info; \
else \
${INSTALL_DATA} $(srcdir)/readline.info $(infodir)/readline.info; \
${INSTALL_DATA} $(srcdir)/readline.info $(DESTDIR)$(infodir)/readline.info; \
fi
if test -f rluserman.info; then \
${INSTALL_DATA} rluserman.info $(infodir)/rluserman.info; \
${INSTALL_DATA} rluserman.info $(DESTDIR)$(infodir)/rluserman.info; \
else \
${INSTALL_DATA} $(srcdir)/rluserman.info $(infodir)/rluserman.info; \
${INSTALL_DATA} $(srcdir)/rluserman.info $(DESTDIR)$(infodir)/rluserman.info; \
fi
if test -f history.info; then \
${INSTALL_DATA} history.info $(infodir)/history.info; \
${INSTALL_DATA} history.info $(DESTDIR)$(infodir)/history.info; \
else \
${INSTALL_DATA} $(srcdir)/history.info $(infodir)/history.info; \
${INSTALL_DATA} $(srcdir)/history.info $(DESTDIR)$(infodir)/history.info; \
fi
-if $(SHELL) -c 'install-info --version' >/dev/null 2>&1; then \
install-info --dir-file=$(infodir)/dir $(infodir)/readline.info ; \
install-info --dir-file=$(infodir)/dir $(infodir)/history.info ; \
install-info --dir-file=$(DESTDIR)$(infodir)/dir \
$(DESTDIR)$(infodir)/readline.info ; \
install-info --dir-file=$(DESTDIR)$(infodir)/dir \
$(DESTDIR)$(infodir)/history.info ; \
install-info --dir-file=$(DESTDIR)$(infodir)/dir \
$(DESTDIR)$(infodir)/rluserman.info ; \
else true; fi
-${INSTALL_DATA} $(srcdir)/readline.3 $(man3dir)/readline.3
-${INSTALL_DATA} $(srcdir)/readline.3 $(DESTDIR)$(man3dir)/readline$(man3ext)
-${INSTALL_DATA} $(srcdir)/history.3 $(DESTDIR)$(man3dir)/history$(man3ext)
-if test -n "${htmldir}" ; then \
if test -f readline.html; then \
${INSTALL_DATA} readline.html $(DESTDIR)$(htmldir)/readline.html; \
else \
${INSTALL_DATA} $(srcdir)/readline.html $(DESTDIR)$(htmldir)/readline.html; \
fi ; \
if test -f history.html; then \
${INSTALL_DATA} history.html $(DESTDIR)$(htmldir)/history.html; \
else \
${INSTALL_DATA} $(srcdir)/history.html $(DESTDIR)$(htmldir)/history.html; \
fi ; \
if test -f rluserman.html; then \
${INSTALL_DATA} rluserman.html $(DESTDIR)$(htmldir)/rluserman.html; \
else \
${INSTALL_DATA} $(srcdir)/rluserman.html $(DESTDIR)$(htmldir)/rluserman.html; \
fi ; \
fi
uninstall:
$(RM) $(infodir)/readline.info
$(RM) $(infodir)/rluserman.info
$(RM) $(infodir)/history.info
$(RM) $(man3dir)/readline.3
$(RM) $(DESTDIR)$(infodir)/readline.info
$(RM) $(DESTDIR)$(infodir)/rluserman.info
$(RM) $(DESTDIR)$(infodir)/history.info
$(RM) $(DESTDIR)$(man3dir)/readline$(man3ext)
$(RM) $(DESTDIR)$(man3dir)/history$(man3ext)
-if test -n "${htmldir}" ; then \
$(RM) $(DESTDIR)$(htmldir)/readline.html ; \
$(RM) $(DESTDIR)$(htmldir)/rluserman.html ; \
$(RM) $(DESTDIR)$(htmldir)/history.html ; \
fi

View File

@ -18,7 +18,7 @@ This document describes the GNU History library, a programming tool that
provides a consistent user interface for recalling lines of previously
typed input.
Copyright (C) 1988-1999 Free Software Foundation, Inc.
Copyright (C) 1988-2002 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@ -73,7 +73,7 @@ except that this permission notice may be stated in a translation approved
by the Free Software Foundation.
@vskip 0pt plus 1filll
Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
Copyright @copyright{} 1988-2002 Free Software Foundation, Inc.
@end titlepage
@ifinfo

660
readline/doc/history.0 Normal file
View File

@ -0,0 +1,660 @@
HISTORY(3) HISTORY(3)
NNAAMMEE
history - GNU History Library
CCOOPPYYRRIIGGHHTT
The GNU History Library is Copyright (C) 1989-2002 by the
Free Software Foundation, Inc.
DDEESSCCRRIIPPTTIIOONN
Many programs read input from the user a line at a time.
The GNU History library is able to keep track of those
lines, associate arbitrary data with each line, and uti-
lize information from previous lines in composing new
ones.
HHIISSTTOORRYY EEXXPPAANNSSIIOONN
The history library supports a history expansion feature
that is identical to the history expansion in bbaasshh.. This
section describes what syntax features are available.
History expansions introduce words from the history list
into the input stream, making it easy to repeat commands,
insert the arguments to a previous command into the cur-
rent input line, or fix errors in previous commands
quickly.
History expansion is usually performed immediately after a
complete line is read. It takes place in two parts. The
first is to determine which line from the history list to
use during substitution. The second is to select portions
of that line for inclusion into the current one. The line
selected from the history is the _e_v_e_n_t, and the portions
of that line that are acted upon are _w_o_r_d_s. Various _m_o_d_i_-
_f_i_e_r_s are available to manipulate the selected words. The
line is broken into words in the same fashion as bbaasshh does
when reading input, so that several words that would oth-
erwise be separated are considered one word when sur-
rounded by quotes (see the description of hhiissttoorryy__ttookk--
eenniizzee(()) below). History expansions are introduced by the
appearance of the history expansion character, which is !!
by default. Only backslash (\\) and single quotes can
quote the history expansion character.
EEvveenntt DDeessiiggnnaattoorrss
An event designator is a reference to a command line entry
in the history list.
!! Start a history substitution, except when followed
by a bbllaannkk, newline, = or (.
!!_n Refer to command line _n.
!!--_n Refer to the current command line minus _n.
!!!! Refer to the previous command. This is a synonym
for `!-1'.
GNU History 4.3 2002 January 31 1
HISTORY(3) HISTORY(3)
!!_s_t_r_i_n_g
Refer to the most recent command starting with
_s_t_r_i_n_g.
!!??_s_t_r_i_n_g[[??]]
Refer to the most recent command containing _s_t_r_i_n_g.
The trailing ?? may be omitted if _s_t_r_i_n_g is followed
immediately by a newline.
^^_s_t_r_i_n_g_1^^_s_t_r_i_n_g_2^^
Quick substitution. Repeat the last command,
replacing _s_t_r_i_n_g_1 with _s_t_r_i_n_g_2. Equivalent to
``!!:s/_s_t_r_i_n_g_1/_s_t_r_i_n_g_2/'' (see MMooddiiffiieerrss below).
!!## The entire command line typed so far.
WWoorrdd DDeessiiggnnaattoorrss
Word designators are used to select desired words from the
event. A :: separates the event specification from the
word designator. It may be omitted if the word designator
begins with a ^^, $$, **, --, or %%. Words are numbered from
the beginning of the line, with the first word being
denoted by 0 (zero). Words are inserted into the current
line separated by single spaces.
00 ((zzeerroo))
The zeroth word. For the shell, this is the com-
mand word.
_n The _nth word.
^^ The first argument. That is, word 1.
$$ The last argument.
%% The word matched by the most recent `?_s_t_r_i_n_g?'
search.
_x--_y A range of words; `-_y' abbreviates `0-_y'.
** All of the words but the zeroth. This is a synonym
for `_1_-_$'. It is not an error to use ** if there is
just one word in the event; the empty string is
returned in that case.
xx** Abbreviates _x_-_$.
xx-- Abbreviates _x_-_$ like xx**, but omits the last word.
If a word designator is supplied without an event specifi-
cation, the previous command is used as the event.
MMooddiiffiieerrss
After the optional word designator, there may appear a
sequence of one or more of the following modifiers, each
preceded by a `:'.
hh Remove a trailing file name component, leaving only
the head.
tt Remove all leading file name components, leaving
the tail.
rr Remove a trailing suffix of the form _._x_x_x, leaving
the basename.
ee Remove all but the trailing suffix.
pp Print the new command but do not execute it.
GNU History 4.3 2002 January 31 2
HISTORY(3) HISTORY(3)
qq Quote the substituted words, escaping further sub-
stitutions.
xx Quote the substituted words as with qq, but break
into words at bbllaannkkss and newlines.
ss//_o_l_d//_n_e_w//
Substitute _n_e_w for the first occurrence of _o_l_d in
the event line. Any delimiter can be used in place
of /. The final delimiter is optional if it is the
last character of the event line. The delimiter
may be quoted in _o_l_d and _n_e_w with a single back-
slash. If & appears in _n_e_w, it is replaced by _o_l_d.
A single backslash will quote the &. If _o_l_d is
null, it is set to the last _o_l_d substituted, or, if
no previous history substitutions took place, the
last _s_t_r_i_n_g in a !!??_s_t_r_i_n_g[[??]] search.
&& Repeat the previous substitution.
gg Cause changes to be applied over the entire event
line. This is used in conjunction with `::ss' (e.g.,
`::ggss//_o_l_d//_n_e_w//') or `::&&'. If used with `::ss', any
delimiter can be used in place of /, and the final
delimiter is optional if it is the last character
of the event line.
PPRROOGGRRAAMMMMIINNGG WWIITTHH HHIISSTTOORRYY FFUUNNCCTTIIOONNSS
This section describes how to use the History library in
other programs.
IInnttrroodduuccttiioonn ttoo HHiissttoorryy
The programmer using the History library has available
functions for remembering lines on a history list, associ-
ating arbitrary data with a line, removing lines from the
list, searching through the list for a line containing an
arbitrary text string, and referencing any line in the
list directly. In addition, a history _e_x_p_a_n_s_i_o_n function
is available which provides for a consistent user inter-
face across different programs.
The user using programs written with the History library
has the benefit of a consistent user interface with a set
of well-known commands for manipulating the text of previ-
ous lines and using that text in new commands. The basic
history manipulation commands are identical to the history
substitution provided by bbaasshh.
If the programmer desires, he can use the Readline
library, which includes some history manipulation by
default, and has the added advantage of command line edit-
ing.
Before declaring any functions using any functionality the
History library provides in other code, an application
writer should include the file _<_r_e_a_d_l_i_n_e_/_h_i_s_t_o_r_y_._h_> in any
file that uses the History library's features. It sup-
plies extern declarations for all of the library's public
GNU History 4.3 2002 January 31 3
HISTORY(3) HISTORY(3)
functions and variables, and declares all of the public
data structures.
HHiissttoorryy SSttoorraaggee
The history list is an array of history entries. A his-
tory entry is declared as follows:
_t_y_p_e_d_e_f _v_o_i_d _* hhiissttddaattaa__tt;;
typedef struct _hist_entry {
char *line;
histdata_t data;
} HIST_ENTRY;
The history list itself might therefore be declared as
_H_I_S_T___E_N_T_R_Y _*_* tthhee__hhiissttoorryy__lliisstt;;
The state of the History library is encapsulated into a
single structure:
/*
* A structure used to pass around the current state of the history.
*/
typedef struct _hist_state {
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
int offset; /* The location pointer within this array. */
int length; /* Number of elements within this array. */
int size; /* Number of slots allocated to this array. */
int flags;
} HISTORY_STATE;
If the flags member includes HHSS__SSTTIIFFLLEEDD, the history has
been stifled.
HHiissttoorryy FFuunnccttiioonnss
This section describes the calling sequence for the vari-
ous functions exported by the GNU History library.
IInniittiiaalliizziinngg HHiissttoorryy aanndd SSttaattee MMaannaaggeemmeenntt
This section describes functions used to initialize and
manage the state of the History library when you want to
use the history functions in your program.
_v_o_i_d uussiinngg__hhiissttoorryy (_v_o_i_d)
Begin a session in which the history functions might be
used. This initializes the interactive variables.
_H_I_S_T_O_R_Y___S_T_A_T_E _* hhiissttoorryy__ggeett__hhiissttoorryy__ssttaattee (_v_o_i_d)
Return a structure describing the current state of the
input history.
_v_o_i_d hhiissttoorryy__sseett__hhiissttoorryy__ssttaattee (_H_I_S_T_O_R_Y___S_T_A_T_E _*_s_t_a_t_e)
GNU History 4.3 2002 January 31 4
HISTORY(3) HISTORY(3)
Set the state of the history list according to _s_t_a_t_e.
HHiissttoorryy LLiisstt MMaannaaggeemmeenntt
These functions manage individual entries on the history
list, or set parameters managing the list itself.
_v_o_i_d aadddd__hhiissttoorryy (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g)
Place _s_t_r_i_n_g at the end of the history list. The associ-
ated data field (if any) is set to NNUULLLL.
_H_I_S_T___E_N_T_R_Y _* rreemmoovvee__hhiissttoorryy (_i_n_t _w_h_i_c_h)
Remove history entry at offset _w_h_i_c_h from the history.
The removed element is returned so you can free the line,
data, and containing structure.
_H_I_S_T___E_N_T_R_Y _* rreeppllaaccee__hhiissttoorryy__eennttrryy (_i_n_t _w_h_i_c_h_, _c_o_n_s_t _c_h_a_r
_*_l_i_n_e_, _h_i_s_t_d_a_t_a___t _d_a_t_a)
Make the history entry at offset _w_h_i_c_h have _l_i_n_e and _d_a_t_a.
This returns the old entry so you can dispose of the data.
In the case of an invalid _w_h_i_c_h, a NNUULLLL pointer is
returned.
_v_o_i_d cclleeaarr__hhiissttoorryy (_v_o_i_d)
Clear the history list by deleting all the entries.
_v_o_i_d ssttiiffllee__hhiissttoorryy (_i_n_t _m_a_x)
Stifle the history list, remembering only the last _m_a_x
entries.
_i_n_t uunnssttiiffllee__hhiissttoorryy (_v_o_i_d)
Stop stifling the history. This returns the previously-
set maximum number of history entries (as set by ssttii--
ffllee__hhiissttoorryy(())). history was stifled. The value is posi-
tive if the history was stifled, negative if it wasn't.
_i_n_t hhiissttoorryy__iiss__ssttiifflleedd (_v_o_i_d)
Returns non-zero if the history is stifled, zero if it is
not.
IInnffoorrmmaattiioonn AAbboouutt tthhee HHiissttoorryy LLiisstt
These functions return information about the entire his-
tory list or individual list entries.
_H_I_S_T___E_N_T_R_Y _*_* hhiissttoorryy__lliisstt (_v_o_i_d)
Return a NNUULLLL terminated array of _H_I_S_T___E_N_T_R_Y _* which is
the current input history. Element 0 of this list is the
beginning of time. If there is no history, return NNUULLLL.
_i_n_t wwhheerree__hhiissttoorryy (_v_o_i_d)
Returns the offset of the current history element.
_H_I_S_T___E_N_T_R_Y _* ccuurrrreenntt__hhiissttoorryy (_v_o_i_d)
GNU History 4.3 2002 January 31 5
HISTORY(3) HISTORY(3)
Return the history entry at the current position, as
determined by wwhheerree__hhiissttoorryy(()). If there is no entry
there, return a NNUULLLL pointer.
_H_I_S_T___E_N_T_R_Y _* hhiissttoorryy__ggeett (_i_n_t _o_f_f_s_e_t)
Return the history entry at position _o_f_f_s_e_t, starting from
hhiissttoorryy__bbaassee. If there is no entry there, or if _o_f_f_s_e_t is
greater than the history length, return a NNUULLLL pointer.
_i_n_t hhiissttoorryy__ttoottaall__bbyytteess (_v_o_i_d)
Return the number of bytes that the primary history
entries are using. This function returns the sum of the
lengths of all the lines in the history.
MMoovviinngg AArroouunndd tthhee HHiissttoorryy LLiisstt
These functions allow the current index into the history
list to be set or changed.
_i_n_t hhiissttoorryy__sseett__ppooss (_i_n_t _p_o_s)
Set the current history offset to _p_o_s, an absolute index
into the list. Returns 1 on success, 0 if _p_o_s is less
than zero or greater than the number of history entries.
_H_I_S_T___E_N_T_R_Y _* pprreevviioouuss__hhiissttoorryy (_v_o_i_d)
Back up the current history offset to the previous history
entry, and return a pointer to that entry. If there is no
previous entry, return a NNUULLLL pointer.
_H_I_S_T___E_N_T_R_Y _* nneexxtt__hhiissttoorryy (_v_o_i_d)
Move the current history offset forward to the next his-
tory entry, and return the a pointer to that entry. If
there is no next entry, return a NNUULLLL pointer.
SSeeaarrcchhiinngg tthhee HHiissttoorryy LLiisstt
These functions allow searching of the history list for
entries containing a specific string. Searching may be
performed both forward and backward from the current his-
tory position. The search may be _a_n_c_h_o_r_e_d, meaning that
the string must match at the beginning of the history
entry.
_i_n_t hhiissttoorryy__sseeaarrcchh (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g_, _i_n_t _d_i_r_e_c_t_i_o_n)
Search the history for _s_t_r_i_n_g, starting at the current
history offset. If _d_i_r_e_c_t_i_o_n is less than 0, then the
search is through previous entries, otherwise through sub-
sequent entries. If _s_t_r_i_n_g is found, then the current
history index is set to that history entry, and the value
returned is the offset in the line of the entry where
_s_t_r_i_n_g was found. Otherwise, nothing is changed, and a -1
is returned.
_i_n_t hhiissttoorryy__sseeaarrcchh__pprreeffiixx (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g_, _i_n_t
GNU History 4.3 2002 January 31 6
HISTORY(3) HISTORY(3)
_d_i_r_e_c_t_i_o_n)
Search the history for _s_t_r_i_n_g, starting at the current
history offset. The search is anchored: matching lines
must begin with _s_t_r_i_n_g. If _d_i_r_e_c_t_i_o_n is less than 0, then
the search is through previous entries, otherwise through
subsequent entries. If _s_t_r_i_n_g is found, then the current
history index is set to that entry, and the return value
is 0. Otherwise, nothing is changed, and a -1 is
returned.
_i_n_t hhiissttoorryy__sseeaarrcchh__ppooss (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g_, _i_n_t _d_i_r_e_c_t_i_o_n_,
_i_n_t _p_o_s)
Search for _s_t_r_i_n_g in the history list, starting at _p_o_s, an
absolute index into the list. If _d_i_r_e_c_t_i_o_n is negative,
the search proceeds backward from _p_o_s, otherwise forward.
Returns the absolute index of the history element where
_s_t_r_i_n_g was found, or -1 otherwise.
MMaannaaggiinngg tthhee HHiissttoorryy FFiillee
The History library can read the history from and write it
to a file. This section documents the functions for man-
aging a history file.
_i_n_t rreeaadd__hhiissttoorryy (_c_o_n_s_t _c_h_a_r _*_f_i_l_e_n_a_m_e)
Add the contents of _f_i_l_e_n_a_m_e to the history list, a line
at a time. If _f_i_l_e_n_a_m_e is NNUULLLL, then read from _~_/_._h_i_s_-
_t_o_r_y. Returns 0 if successful, or eerrrrnnoo if not.
_i_n_t rreeaadd__hhiissttoorryy__rraannggee (_c_o_n_s_t _c_h_a_r _*_f_i_l_e_n_a_m_e_, _i_n_t _f_r_o_m_,
_i_n_t _t_o)
Read a range of lines from _f_i_l_e_n_a_m_e, adding them to the
history list. Start reading at line _f_r_o_m and end at _t_o.
If _f_r_o_m is zero, start at the beginning. If _t_o is less
than _f_r_o_m, then read until the end of the file. If _f_i_l_e_-
_n_a_m_e is NNUULLLL, then read from _~_/_._h_i_s_t_o_r_y. Returns 0 if
successful, or eerrrrnnoo if not.
_i_n_t wwrriittee__hhiissttoorryy (_c_o_n_s_t _c_h_a_r _*_f_i_l_e_n_a_m_e)
Write the current history to _f_i_l_e_n_a_m_e, overwriting _f_i_l_e_-
_n_a_m_e if necessary. If _f_i_l_e_n_a_m_e is NNUULLLL, then write the
history list to _~_/_._h_i_s_t_o_r_y. Returns 0 on success, or
eerrrrnnoo on a read or write error.
_i_n_t aappppeenndd__hhiissttoorryy (_i_n_t _n_e_l_e_m_e_n_t_s_, _c_o_n_s_t _c_h_a_r _*_f_i_l_e_n_a_m_e)
Append the last _n_e_l_e_m_e_n_t_s of the history list to _f_i_l_e_n_a_m_e.
If _f_i_l_e_n_a_m_e is NNUULLLL, then append to _~_/_._h_i_s_t_o_r_y. Returns 0
on success, or eerrrrnnoo on a read or write error.
_i_n_t hhiissttoorryy__ttrruunnccaattee__ffiillee (_c_o_n_s_t _c_h_a_r _*_f_i_l_e_n_a_m_e_, _i_n_t
_n_l_i_n_e_s)
Truncate the history file _f_i_l_e_n_a_m_e, leaving only the last
_n_l_i_n_e_s lines. If _f_i_l_e_n_a_m_e is NNUULLLL, then _~_/_._h_i_s_t_o_r_y is
GNU History 4.3 2002 January 31 7
HISTORY(3) HISTORY(3)
truncated. Returns 0 on success, or eerrrrnnoo on failure.
HHiissttoorryy EExxppaannssiioonn
These functions implement history expansion.
_i_n_t hhiissttoorryy__eexxppaanndd (_c_h_a_r _*_s_t_r_i_n_g_, _c_h_a_r _*_*_o_u_t_p_u_t)
Expand _s_t_r_i_n_g, placing the result into _o_u_t_p_u_t, a pointer
to a string. Returns:
0 If no expansions took place (or, if the only
change in the text was the removal of escape
characters preceding the history expansion
character);
1 if expansions did take place;
-1 if there was an error in expansion;
2 if the returned line should be displayed,
but not executed, as with the ::pp modifier.
If an error ocurred in expansion, then _o_u_t_p_u_t contains a
descriptive error message.
_c_h_a_r _* ggeett__hhiissttoorryy__eevveenntt (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g_, _i_n_t _*_c_i_n_d_e_x_,
_i_n_t _q_c_h_a_r)
Returns the text of the history event beginning at _s_t_r_i_n_g
+ _*_c_i_n_d_e_x. _*_c_i_n_d_e_x is modified to point to after the
event specifier. At function entry, _c_i_n_d_e_x points to the
index into _s_t_r_i_n_g where the history event specification
begins. _q_c_h_a_r is a character that is allowed to end the
event specification in addition to the ``normal'' termi-
nating characters.
_c_h_a_r _*_* hhiissttoorryy__ttookkeenniizzee (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g)
Return an array of tokens parsed out of _s_t_r_i_n_g, much as
the shell might. The tokens are split on the characters
in the hhiissttoorryy__wwoorrdd__ddeelliimmiitteerrss variable, and shell quoting
conventions are obeyed.
_c_h_a_r _* hhiissttoorryy__aarrgg__eexxttrraacctt (_i_n_t _f_i_r_s_t_, _i_n_t _l_a_s_t_, _c_o_n_s_t
_c_h_a_r _*_s_t_r_i_n_g)
Extract a string segment consisting of the _f_i_r_s_t through
_l_a_s_t arguments present in _s_t_r_i_n_g. Arguments are split
using hhiissttoorryy__ttookkeenniizzee(()).
HHiissttoorryy VVaarriiaabblleess
This section describes the externally-visible variables
exported by the GNU History Library.
_i_n_t hhiissttoorryy__bbaassee
The logical offset of the first entry in the history list.
_i_n_t hhiissttoorryy__lleennggtthh
The number of entries currently stored in the history
list.
GNU History 4.3 2002 January 31 8
HISTORY(3) HISTORY(3)
_i_n_t hhiissttoorryy__mmaaxx__eennttrriieess
The maximum number of history entries. This must be
changed using ssttiiffllee__hhiissttoorryy(()).
_c_h_a_r hhiissttoorryy__eexxppaannssiioonn__cchhaarr
The character that introduces a history event. The
default is !!. Setting this to 0 inhibits history expan-
sion.
_c_h_a_r hhiissttoorryy__ssuubbsstt__cchhaarr
The character that invokes word substitution if found at
the start of a line. The default is ^^.
_c_h_a_r hhiissttoorryy__ccoommmmeenntt__cchhaarr
During tokenization, if this character is seen as the
first character of a word, then it and all subsequent
characters up to a newline are ignored, suppressing his-
tory expansion for the remainder of the line. This is
disabled by default.
_c_h_a_r _* hhiissttoorryy__wwoorrdd__ddeelliimmiitteerrss
The characters that separate tokens for hhiissttoorryy__ttookk--
eenniizzee(()). The default value is "" \\tt\\nn(())<<>>;;&&||"".
_c_h_a_r _* hhiissttoorryy__nnoo__eexxppaanndd__cchhaarrss
The list of characters which inhibit history expansion if
found immediately following hhiissttoorryy__eexxppaannssiioonn__cchhaarr. The
default is space, tab, newline, \\rr, and ==.
_c_h_a_r _* hhiissttoorryy__sseeaarrcchh__ddeelliimmiitteerr__cchhaarrss
The list of additional characters which can delimit a his-
tory search string, in addition to space, tab, _: and _? in
the case of a substring search. The default is empty.
_i_n_t hhiissttoorryy__qquuootteess__iinnhhiibbiitt__eexxppaannssiioonn
If non-zero, single-quoted words are not scanned for the
history expansion character. The default value is 0.
_r_l___l_i_n_e_b_u_f___f_u_n_c___t _* hhiissttoorryy__iinnhhiibbiitt__eexxppaannssiioonn__ffuunnccttiioonn
This should be set to the address of a function that takes
two arguments: a cchhaarr ** (_s_t_r_i_n_g) and an iinntt index into
that string (_i). It should return a non-zero value if the
history expansion starting at _s_t_r_i_n_g_[_i_] should not be per-
formed; zero if the expansion should be done. It is
intended for use by applications like bbaasshh that use the
history expansion character for additional purposes. By
default, this variable is set to NNUULLLL.
FFIILLEESS
_~_/_._h_i_s_t_o_r_y
Default filename for reading and writing saved his-
tory
GNU History 4.3 2002 January 31 9
HISTORY(3) HISTORY(3)
SSEEEE AALLSSOO
_T_h_e _G_n_u _R_e_a_d_l_i_n_e _L_i_b_r_a_r_y, Brian Fox and Chet Ramey
_T_h_e _G_n_u _H_i_s_t_o_r_y _L_i_b_r_a_r_y, Brian Fox and Chet Ramey
_b_a_s_h(1)
_r_e_a_d_l_i_n_e(3)
AAUUTTHHOORRSS
Brian Fox, Free Software Foundation
bfox@gnu.org
Chet Ramey, Case Western Reserve University
chet@ins.CWRU.Edu
BBUUGG RREEPPOORRTTSS
If you find a bug in the hhiissttoorryy library, you should
report it. But first, you should make sure that it really
is a bug, and that it appears in the latest version of the
hhiissttoorryy library that you have.
Once you have determined that a bug actually exists, mail
a bug report to _b_u_g_-_r_e_a_d_l_i_n_e@_g_n_u_._o_r_g. If you have a fix,
you are welcome to mail that as well! Suggestions and
`philosophical' bug reports may be mailed to _b_u_g_-_r_e_a_d_-
_l_i_n_e@_g_n_u_._o_r_g or posted to the Usenet newsgroup
ggnnuu..bbaasshh..bbuugg.
Comments and bug reports concerning this manual page
should be directed to _c_h_e_t_@_i_n_s_._C_W_R_U_._E_d_u.
GNU History 4.3 2002 January 31 10

640
readline/doc/history.3 Normal file
View File

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

View File

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

View File

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

View File

@ -1,6 +1,10 @@
@set EDITION 4.1
@set VERSION 4.1
@set UPDATED 2000 January 19
@set UPDATE-MONTH January 2000
@ignore
Copyright (C) 1988-2002 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Wed Jan 19 12:16:30 EST 2000
@set EDITION 4.3
@set VERSION 4.3
@set UPDATED 2002 March 4
@set UPDATE-MONTH March 2002
@set LASTCHANGE Mon Mar 4 12:00:16 EST 2002

View File

@ -6,9 +6,9 @@
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
.\" Last Change: Tue Jun 1 13:28:03 EDT 1999
.\" Last Change: Tue Jan 22 09:18:25 EST 2002
.\"
.TH READLINE 3 "1999 Jun 1" GNU
.TH READLINE 3 "2002 January 22" "GNU Readline 4.3"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@ -23,20 +23,19 @@ readline \- get a line from a user with editing
.nf
.ft B
#include <stdio.h>
#include <readline.h>
#include <history.h>
#include <readline/readline.h>
#include <readline/history.h>
.ft
.fi
.LP
.nf
.ft B
char *readline (prompt)
char *prompt;
.ft
\fIchar *\fP
.br
\fBreadline\fP (\fIconst char *prompt\fP);
.fi
.SH COPYRIGHT
.if n Readline is Copyright (C) 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
.if t Readline is Copyright \(co 1989, 1991, 1993, 1995, 1996 by the Free Software Foundation, Inc.
.if n Readline is Copyright (C) 1989\-2002 by the Free Software Foundation, Inc.
.if t Readline is Copyright \(co 1989\-2002 by the Free Software Foundation, Inc.
.SH DESCRIPTION
.LP
.B readline
@ -45,9 +44,10 @@ and return it, using
.B prompt
as a prompt. If
.B prompt
is null, no prompt is issued. The line returned is allocated with
.IR malloc (3),
so the caller must free it when finished. The line returned
is \fBNULL\fP or the empty string, no prompt is issued.
The line returned is allocated with
.IR malloc (3);
the caller must free it when finished. The line returned
has the final newline removed, so only the text of the line
remains.
.LP
@ -57,6 +57,11 @@ line.
By default, the line editing commands
are similar to those of emacs.
A vi\-style line editing interface is also available.
.LP
This manual page describes only the most basic use of \fBreadline\fP.
Much more functionality is available; see
\fIThe GNU Readline Library\fP and \fIThe GNU History Library\fP
for additional information.
.SH RETURN VALUE
.LP
.B readline
@ -130,6 +135,7 @@ or
.RS
C\-Meta\-u: universal\-argument
.RE
.sp
into the
.I inputrc
would make M\-C\-u execute the readline command
@ -137,15 +143,16 @@ would make M\-C\-u execute the readline command
.PP
The following symbolic character names are recognized while
processing key bindings:
.IR RUBOUT ,
.IR DEL ,
.IR ESC ,
.IR ESCAPE ,
.IR LFD ,
.IR NEWLINE ,
.IR RET ,
.IR RETURN ,
.IR SPC ,
.IR RUBOUT ,
.IR SPACE ,
.IR SPC ,
and
.IR TAB .
.PP
@ -161,6 +168,7 @@ command or the text of a macro and a key sequence to which
it should be bound. The name may be specified in one of two ways:
as a symbolic key name, possibly with \fIMeta\-\fP or \fIControl\-\fP
prefixes, or as a key sequence.
.PP
When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP,
.I keyname
is the name of a key spelled out in English. For example:
@ -170,7 +178,7 @@ Control\-u: universal\-argument
.br
Meta\-Rubout: backward\-kill\-word
.br
Control\-o: ">&output"
Control\-o: "> output"
.RE
.LP
In the above example,
@ -184,7 +192,8 @@ and
.I C\-o
is bound to run the macro
expressed on the right hand side (that is, to insert the text
.I >&output
.if t \f(CW> output\fP
.if n ``> output''
into the line).
.PP
In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
@ -194,7 +203,8 @@ differs from
above in that strings denoting
an entire key sequence may be specified by placing the sequence
within double quotes. Some GNU Emacs style key escapes can be
used, as in the following example.
used, as in the following example, but the symbolic character names
are not recognized.
.sp
.RS
"\eC\-u": universal\-argument
@ -214,8 +224,11 @@ is bound to the function
and
.I "ESC [ 1 1 ~"
is bound to insert the text
.BR "Function Key 1" .
The full set of GNU Emacs style escape sequences is
.if t \f(CWFunction Key 1\fP.
.if n ``Function Key 1''.
.PP
The full set of GNU Emacs style escape sequences available when specifying
key sequences is
.RS
.PD 0
.TP
@ -232,10 +245,10 @@ an escape character
backslash
.TP
.B \e"
literal "
literal ", a double quote
.TP
.B \e'
literal '
literal ', a single quote
.RE
.PD
.PP
@ -269,12 +282,12 @@ horizontal tab
vertical tab
.TP
.B \e\fInnn\fP
the character whose ASCII code is the octal value \fInnn\fP
the eight-bit character whose value is the octal value \fInnn\fP
(one to three digits)
.TP
.B \ex\fInnn\fP
the character whose ASCII code is the hexadecimal value \fInnn\fP
(one to three digits)
.B \ex\fIHH\fP
the eight-bit character whose value is the hexadecimal value \fIHH\fP
(one or two hex digits)
.RE
.PD
.PP
@ -313,7 +326,8 @@ file with a statement of the form
Except where noted, readline variables can take the values
.B On
or
.BR Off .
.B Off
(without regard to case).
The variables and their default values are:
.PP
.PD 0
@ -351,7 +365,7 @@ on the terminal.
.B convert\-meta (On)
If set to \fBOn\fP, readline will convert characters with the
eighth bit set to an ASCII key sequence
by stripping the eighth bit and prepending an
by stripping the eighth bit and prefixing it with an
escape character (in effect, using escape as the \fImeta prefix\fP).
.TP
.B disable\-completion (Off)
@ -361,7 +375,7 @@ mapped to \fBself-insert\fP.
.TP
.B editing\-mode (emacs)
Controls whether readline begins with a set of key bindings similar
to \fIemacs\fP or \fIvi\fP.
to emacs or vi.
.B editing\-mode
can be set to either
.B emacs
@ -377,6 +391,11 @@ arrow keys.
If set to \fBon\fP, tilde expansion is performed when readline
attempts word completion.
.TP
.B history-preserve-point
If set to \fBon\fP, the history code attempts to place point at the
same location on each history line retrived with \fBprevious-history\fP
or \fBnext-history\fP.
.TP
.B horizontal\-scroll\-mode (Off)
When set to \fBOn\fP, makes readline use a single line for display,
scrolling the input horizontally on a single screen line when it
@ -384,12 +403,12 @@ becomes longer than the screen width rather than wrapping to a new line.
.TP
.B input\-meta (Off)
If set to \fBOn\fP, readline will enable eight-bit input (that is,
it will not strip the high bit from the characters it reads),
it will not clear the eighth bit in the characters it reads),
regardless of what the terminal claims it can support. The name
.B meta\-flag
is a synonym for this variable.
.TP
.B isearch\-terminators (``C\-[C\-J'')
.B isearch\-terminators (``C\-[ C\-J'')
The string of characters that should terminate an incremental
search without subsequently executing the character as a command.
If this variable has not been given a value, the characters
@ -402,24 +421,39 @@ vi-command\fP, and
.IR vi-insert .
\fIvi\fP is equivalent to \fIvi-command\fP; \fIemacs\fP is
equivalent to \fIemacs-standard\fP. The default value is
.IR emacs ;
the value of
.IR emacs .
The value of
.B editing\-mode
also affects the default keymap.
.TP
.B mark\-directories (On)
If set to \fBOn\fP, complete<d directory names have a slash
If set to \fBOn\fP, completed directory names have a slash
appended.
.TP
.B mark\-modified\-lines (Off)
If set to \fBOn\fP, history lines that have been modified are displayed
with a preceding asterisk (\fB*\fP).
.TP
.B mark\-symlinked\-directories (Off)
If set to \fBOn\fP, completed names which are symbolic links to directories
have a slash appended (subject to the value of
\fBmark\-directories\fP).
.TP
.B match\-hidden\-files (On)
This variable, when set to \fBOn\fP, causes readline to match files whose
names begin with a `.' (hidden files) when performing filename
completion, unless the leading `.' is
supplied by the user in the filename to be completed.
.TP
.B output\-meta (Off)
If set to \fBOn\fP, readline will display characters with the
eighth bit set directly rather than as a meta-prefixed escape
sequence.
.TP
.B page\-completions (On)
If set to \fBOn\fP, readline uses an internal \fImore\fP-like pager
to display a screenful of possible completions at a time.
.TP
.B print\-completions\-horizontally (Off)
If set to \fBOn\fP, readline will display completions with matches
sorted horizontally in alphabetical order, rather than down the screen.
@ -433,7 +467,7 @@ matches to be listed immediately instead of ringing the bell.
.TP
.B visible\-stats (Off)
If set to \fBOn\fP, a character denoting a file's type as reported
by \fBstat\fP(2) is appended to the filename when listing possible
by \fIstat\fP(2) is appended to the filename when listing possible
completions.
.PD
.SS Conditional Constructs
@ -481,7 +515,7 @@ key sequence that quotes the current or previous word in Bash:
.sp 1
.RS
.nf
\fB$if\fP bash
\fB$if\fP Bash
# Quote the current or previous word
"\eC-xq": "\eeb\e"\eef\e""
\fB$endif\fP
@ -519,22 +553,27 @@ As each character of the search string is typed, readline displays
the next entry from the history matching the string typed so far.
An incremental search requires only as many characters as needed to
find the desired history entry.
The characters present in the value of the \fIisearch-terminators\fP
To search backward in the history for a particular string, type
\fBC\-r\fP. Typing \fBC\-s\fP searches forward through the history.
The characters present in the value of the \fBisearch-terminators\fP
variable are used to terminate an incremental search.
If that variable has not been assigned a value the Escape and
Control-J characters will terminate an incremental search.
Control-G will abort an incremental search and restore the original
If that variable has not been assigned a value the \fIEscape\fP and
\fBC\-J\fP characters will terminate an incremental search.
\fBC\-G\fP will abort an incremental search and restore the original
line.
When the search is terminated, the history entry containing the
search string becomes the current line.
To find other matching entries in the history list, type Control-S or
Control-R as appropriate.
.PP
To find other matching entries in the history list, type \fBC\-s\fP or
\fBC\-r\fP as appropriate.
This will search backward or forward in the history for the next
line matching the search string typed so far.
Any other key sequence bound to a readline command will terminate
the search and execute that command.
For instance, a \fInewline\fP will terminate the search and accept
For instance, a newline will terminate the search and accept
the line, thereby executing the command from the history list.
A movement command will terminate the search, make the last line found
the current line, and begin editing.
.PP
Non-incremental searches read the entire search string before starting
to search for matching history lines. The search string may be
@ -544,6 +583,11 @@ typed by the user or be part of the contents of the current line.
The following is a list of the names of the commands and the default
key sequences to which they are bound.
Command names without an accompanying key sequence are unbound by default.
.PP
In the following descriptions, \fIpoint\fP refers to the current cursor
position, and \fImark\fP refers to a cursor position saved by the
\fBset\-mark\fP command.
The text between the point and mark is referred to as the \fIregion\fP.
.SS Commands for Moving
.PP
.PD 0
@ -581,9 +625,11 @@ Refresh the current line.
.PD 0
.TP
.B accept\-line (Newline, Return)
Accept the line regardless of where the cursor is. If this line is
non-empty, add it to the history list. If the line is a modified
history line, then restore the history line to its original state.
Accept the line regardless of where the cursor is.
If this line is
non-empty, it may be added to the history list for future recall with
\fBadd_history()\fP.
If the line is a modified history line, the history line is restored to its original state.
.TP
.B previous\-history (C\-p)
Fetch the previous command from the history list, moving back in
@ -629,8 +675,8 @@ This is a non-incremental search.
.TP
.B yank\-nth\-arg (M\-C\-y)
Insert the first argument to the previous command (usually
the second word on the previous line) at point (the current
cursor position). With an argument
the second word on the previous line) at point.
With an argument
.IR n ,
insert the \fIn\fPth word from the previous command (the words
in the previous command begin with word 0). A negative argument
@ -649,9 +695,9 @@ list, inserting the last argument of each line in turn.
.PD 0
.TP
.B delete\-char (C\-d)
Delete the character under the cursor. If point is at the
Delete the character at point. If point is at the
beginning of the line, there are no characters in the line, and
the last character typed was not bound to \fBBdelete\-char\fP, then return
the last character typed was not bound to \fBdelete\-char\fP, then return
.SM
.BR EOF .
.TP
@ -662,7 +708,7 @@ save the deleted text on the kill ring.
.B forward\-backward\-delete\-char
Delete the character under the cursor, unless the cursor is at the
end of the line, in which case the character behind the cursor is
deleted. By default, this is not bound to a key.
deleted.
.TP
.B quoted\-insert (C\-q, C\-v)
Add the next character that you type to the line verbatim. This is
@ -675,13 +721,17 @@ Insert a tab character.
Insert the character typed.
.TP
.B transpose\-chars (C\-t)
Drag the character before point forward over the character at point.
Point moves forward as well. If point is at the end of the line, then
transpose the two characters before point. Negative arguments don't work.
Drag the character before point forward over the character at point,
moving point forward as well.
If point is at the end of the line, then this transposes
the two characters before point.
Negative arguments have no effect.
.TP
.B transpose\-words (M\-t)
Drag the word behind the cursor past the word in front of the cursor
moving the cursor over that word as well.
Drag the word before point past the word after point,
moving point over that word as well.
If point is at the end of the line, this transposes
the last two words on the line.
.TP
.B upcase\-word (M\-u)
Uppercase the current (or following) word. With a negative argument,
@ -694,13 +744,24 @@ lowercase the previous word, but do not move point.
.B capitalize\-word (M\-c)
Capitalize the current (or following) word. With a negative argument,
capitalize the previous word, but do not move point.
.TP
.B overwrite\-mode
Toggle overwrite mode. With an explicit positive numeric argument,
switches to overwrite mode. With an explicit non-positive numeric
argument, switches to insert mode. This command affects only
\fBemacs\fP mode; \fBvi\fP mode does overwrite differently.
Each call to \fIreadline()\fP starts in insert mode.
In overwrite mode, characters bound to \fBself\-insert\fP replace
the text at point rather than pushing the text to the right.
Characters bound to \fBbackward\-delete\-char\fP replace the character
before point with a space. By default, this command is unbound.
.PD
.SS Killing and Yanking
.PP
.PD 0
.TP
.B kill\-line (C\-k)
Kill the text from the current cursor position to the end of the line.
Kill the text from point to the end of the line.
.TP
.B backward\-kill\-line (C\-x Rubout)
Kill backward to the beginning of the line.
@ -711,22 +772,20 @@ The killed text is saved on the kill-ring.
.\" There is no real difference between this and backward-kill-line
.TP
.B kill\-whole\-line
Kill all characters on the current line, no matter where the
cursor is.
Kill all characters on the current line, no matter where point is.
.TP
.B kill\-word (M\-d)
Kill from the cursor to the end of the current word, or if between
Kill from point the end of the current word, or if between
words, to the end of the next word. Word boundaries are the same as
those used by \fBforward\-word\fP.
.TP
.B backward\-kill\-word (M\-Rubout)
Kill the word behind the cursor. Word boundaries are the same as
those used by \fBbackward\-word\fP.
Kill the word behind point.
Word boundaries are the same as those used by \fBbackward\-word\fP.
.TP
.B unix\-word\-rubout (C\-w)
Kill the word behind the cursor, using white space as a word boundary.
The word boundaries are different from
.BR backward\-kill\-word .
Kill the word behind point, using white space as a word boundary.
The killed text is saved on the kill-ring.
.TP
.B delete\-horizontal\-space (M\-\e)
Delete all spaces and tabs around point.
@ -747,7 +806,7 @@ Copy the word following point to the kill buffer.
The word boundaries are the same as \fBforward\-word\fP.
.TP
.B yank (C\-y)
Yank the top of the kill ring into the buffer at the cursor.
Yank the top of the kill ring into the buffer at point.
.TP
.B yank\-pop (M\-y)
Rotate the kill ring, and yank the new top. Only works following
@ -808,8 +867,9 @@ Similar to \fBcomplete\fP, but replaces the word to be completed
with a single match from the list of possible completions.
Repeated execution of \fBmenu\-complete\fP steps through the list
of possible completions, inserting each match in turn.
At the end of the list of completions, the bell is rung and the
original text is restored.
At the end of the list of completions, the bell is rung
(subject to the setting of \Bbell\-style\fP)
and the original text is restored.
An argument of \fIn\fP moves \fIn\fP positions forward in the list
of matches; a negative argument may be used to move backward
through the list.
@ -821,7 +881,6 @@ Deletes the character under the cursor if not at the beginning or
end of the line (like \fBdelete-char\fP).
If at the end of the line, behaves identically to
\fBpossible-completions\fP.
This command is unbound by default.
.PD
.SS Keyboard Macros
.PP
@ -874,8 +933,8 @@ command enough times to return the line to its initial state.
.B tilde\-expand (M\-&)
Perform tilde expansion on the current word.
.TP
.B set\-mark (C\-@, M-<space>)
Set the mark to the current point. If a
.B set\-mark (C\-@, M\-<space>)
Set the mark to the point. If a
numeric argument is supplied, the mark is set to that position.
.TP
.B exchange\-point\-and\-mark (C\-x C\-x)
@ -891,11 +950,20 @@ A character is read and point is moved to the previous occurrence of that
character. A negative count searches for subsequent occurrences.
.TP
.B insert\-comment (M\-#)
The value of the readline
Without a numeric argument, the value of the readline
.B comment\-begin
variable is inserted at the beginning of the current line, and the line
is accepted as if a newline had been typed. This makes the current line
a shell comment.
variable is inserted at the beginning of the current line.
If a numeric argument is supplied, this command acts as a toggle: if
the characters at the beginning of the line do not match the value
of \fBcomment\-begin\fP, the value is inserted, otherwise
the characters in \fBcomment-begin\fP are deleted from the beginning of
the line.
In either case, the line is accepted as if a newline had been typed.
The default value of
.B comment\-begin
makes the current line a shell comment.
If a numeric argument causes the comment character to be removed, the line
will be executed by the shell.
.TP
.B dump\-functions
Print all of the functions and their key bindings to the
@ -918,7 +986,7 @@ of an \fIinputrc\fP file.
.B emacs\-editing\-mode (C\-e)
When in
.B vi
editing mode, this causes a switch to
command mode, this causes a switch to
.B emacs
editing mode.
.TP
@ -932,25 +1000,23 @@ editing mode.
.SH DEFAULT KEY BINDINGS
.LP
The following is a list of the default emacs and vi bindings.
Characters with the 8th bit set are written as M\-<character>, and
Characters with the eighth bit set are written as M\-<character>, and
are referred to as
.I metafied
characters.
The printable ASCII characters not mentioned in the list of emacs
standard bindings are bound to the
.I self\-insert
.B self\-insert
function, which just inserts the given character into the input line.
In vi insertion mode, all characters not specifically mentioned are
bound to
.IR self\-insert .
.BR self\-insert .
Characters assigned to signal generation by
.IR stty (1)
or the terminal driver, such as C-Z or C-C,
retain that function.
Upper and lower case
.I metafied
characters are bound to the same function in the emacs mode
meta keymap.
Upper and lower case metafied characters are bound to the same function in
the emacs mode meta keymap.
The remaining characters are unbound, which causes readline
to ring the bell (subject to the setting of the
.B bell\-style
@ -1036,7 +1102,7 @@ Emacs Meta bindings
"M-Y" yank-pop
"M-\e" delete-horizontal-space
"M-~" tilde-expand
"M-C-?" backward-delete-word
"M-C-?" backward-kill-word
"M-_" yank-last-arg
.PP
Emacs Control-X bindings
@ -1096,6 +1162,7 @@ VI Command Mode functions
"C-V" quoted-insert
"C-W" unix-word-rubout
"C-Y" yank
"C-_" vi-undo
"\^ " forward-char
"#" insert-comment
"$" end-of-line
@ -1150,7 +1217,7 @@ VI Command Mode functions
"r" vi-change-char
"s" vi-subst
"t" vi-char-search
"u" undo
"u" vi-undo
"w" vi-next-word
"x" vi-delete
"y" vi-yank-to

View File

@ -18,7 +18,7 @@ This document describes the GNU Readline Library, a utility which aids
in the consistency of user interface across discrete programs that need
to provide a command line interface.
Copyright (C) 1988-1999 Free Software Foundation, Inc.
Copyright (C) 1988-2002 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@ -73,7 +73,7 @@ except that this permission notice may be stated in a translation approved
by the Free Software Foundation.
@vskip 0pt plus 1filll
Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
Copyright @copyright{} 1988-2002 Free Software Foundation, Inc.
@end titlepage
@ifinfo

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -10,14 +10,14 @@
@ifinfo
@dircategory Libraries
@direntry
* Readline: (readline). The GNU readline library API
* RLuserman: (rluserman). The GNU readline library User's Manual.
@end direntry
This document describes the end user interface of the GNU Readline Library,
a utility which aids in the consistency of user interface across discrete
programs that need to provide a command line interface.
Copyright (C) 1988-1999 Free Software Foundation, Inc.
Copyright (C) 1988-2002 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
@ -72,7 +72,7 @@ except that this permission notice may be stated in a translation approved
by the Free Software Foundation.
@vskip 0pt plus 1filll
Copyright @copyright{} 1988-1999 Free Software Foundation, Inc.
Copyright @copyright{} 1988-2002 Free Software Foundation, Inc.
@end titlepage
@ifinfo

View File

@ -1,8 +1,8 @@
#! /bin/sh
# texi2dvi --- smartly produce DVI files from texinfo sources
# texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.
# $Id$
#
# Copyright (C) 1992, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
# Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
#
# 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
@ -19,344 +19,550 @@
# program's maintainer or write to: The Free Software Foundation,
# Inc.; 59 Temple Place, Suite 330; Boston, MA 02111-1307, USA.
#
# Commentary:
#
# Author: Noah Friedman <friedman@gnu.org>
# Original author: Noah Friedman <friedman@gnu.org>.
#
# Please send bug reports, etc. to bug-texinfo@gnu.org.
# If possible, please send a copy of the output of the script called with
# the `--debug' option when making a bug report.
#
# In the interest of general portability, some common bourne shell
# constructs were avoided because they weren't guaranteed to be available
# in some earlier implementations. I've tried to make this program as
# portable as possible. Welcome to unix, where the lowest common
# denominator is rapidly diminishing.
#
# Among the more interesting lossages I noticed among Bourne shells:
# * No shell functions.
# * No `unset' builtin.
# * `shift' cannot take a numeric argument, and signals an error if
# there are no arguments to shift.
#
# Code:
# Name by which this script was invoked.
progname=`echo "$0" | sed -e 's/[^\/]*\///g'`
# This string is expanded by rcs automatically when this file is checked out.
rcs_revision='$Revision$'
version=`set - $rcs_revision; echo $2`
rcs_version=`set - $rcs_revision; echo $2`
program=`echo $0 | sed -e 's!.*/!!'`
version="texi2dvi (GNU Texinfo 4.0) $rcs_version
# To prevent hairy quoting and escaping later.
bq='`'
eq="'"
usage="Usage: $0 [OPTION]... FILE...
Run a Texinfo document through TeX.
Options:
-b, --batch No interaction (\nonstopmode in TeX).
-c, --clean Remove all auxiliary files.
-D, --debug Turn on shell debugging ($bq${bq}set -x$eq$eq).
-t, --texinfo CMD Insert CMD after @setfilename before running TeX.
--verbose Report on what is done.
-h, --help Display this help and exit.
-v, --version Display version information and exit.
The values of the TEX, TEXINDEX, and MAKEINFO environment variables are
used to run those commands, if they are set.
Email bug reports to bug-texinfo@gnu.org."
# Initialize variables.
# Don't use `unset' since old bourne shells don't have this command.
# Instead, assign them an empty value.
# Some of these, like TEX and TEXINDEX, may be inherited from the environment.
backup_extension=.bak # these files get deleted if all goes well.
batch=
clean=
debug=
orig_pwd="`pwd`"
textra=
verbose=false
makeinfo="${MAKEINFO-makeinfo}"
texindex="${TEXINDEX-texindex}"
tex="${TEX-tex}"
# Save this so we can construct a new TEXINPUTS path for each file.
TEXINPUTS_orig="$TEXINPUTS"
export TEXINPUTS
# Parse command line arguments.
# Make sure that all wildcarded options are long enough to be unambiguous.
# It's a good idea to document the full long option name in each case.
# Long options which take arguments will need a `*' appended to the
# canonical name to match the value appended after the `=' character.
while :; do
test $# -eq 0 && break
case "$1" in
-b | --batch | --b* ) batch=t; shift ;;
-c | --clean | --c* ) clean=t; shift ;;
-D | --debug | --d* ) debug=t; shift ;;
-h | --help | --h* ) echo "$usage"; exit 0 ;;
# OK, we should do real option parsing here, but be lazy for now.
-t | --texinfo | --t*) shift; textra="$textra $1"; shift ;;
-v | --vers* )
echo "$progname (GNU Texinfo 3.12) $version"
echo "Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1999 Free Software Foundation, Inc.
There is NO warranty. You may redistribute this software
under the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING."
exit 0 ;;
--verb* ) verbose=echo; shift ;;
-- ) # Stop option processing
shift
break ;;
-* )
case "$1" in
--*=* ) arg=`echo "$1" | sed -e 's/=.*//'` ;;
* ) arg="$1" ;;
esac
exec 1>&2
echo "$progname: Unknown or ambiguous option $bq$arg$eq."
echo "$progname: Try $bq--help$eq for more information."
exit 1 ;;
* ) break ;;
esac
done
# See if there are any command line args left (which will be interpreted as
# filename arguments).
if test $# -eq 0; then
exec 1>&2
echo "$progname: At least one file name is required as an argument."
echo "$progname: Try $bq--help$eq for more information."
usage="Usage: $program [OPTION]... FILE...
Run each Texinfo or LaTeX FILE through TeX in turn until all
cross-references are resolved, building all indices. The directory
containing each FILE is searched for included files. The suffix of FILE
is used to determine its language (LaTeX or Texinfo).
Makeinfo is used to perform Texinfo macro expansion before running TeX
when needed.
Options:
-@ Use @input instead of \input; for preloaded Texinfo.
-b, --batch No interaction.
-c, --clean Remove all auxiliary files.
-D, --debug Turn on shell debugging (set -x).
-e, --expand Force macro expansion using makeinfo.
-I DIR Search DIR for Texinfo files.
-h, --help Display this help and exit successfully.
-l, --language=LANG Specify the LANG of FILE: LaTeX or Texinfo.
-p, --pdf Use pdftex or pdflatex for processing.
-q, --quiet No output unless errors (implies --batch).
-s, --silent Same as --quiet.
-t, --texinfo=CMD Insert CMD after @setfilename in copy of input file.
Multiple values accumulate.
-v, --version Display version information and exit successfully.
-V, --verbose Report on what is done.
The values of the BIBTEX, LATEX (or PDFLATEX), MAKEINDEX, MAKEINFO,
TEX (or PDFTEX), and TEXINDEX environment variables are used to run
those commands, if they are set.
Email bug reports to <bug-texinfo@gnu.org>,
general questions and discussion to <help-texinfo@gnu.org>."
# Initialize variables for option overriding and otherwise.
# Don't use `unset' since old bourne shells don't have this command.
# Instead, assign them an empty value.
escape='\'
batch=false # eval for batch mode
clean=
debug=
expand= # t for expansion via makeinfo
oformat=dvi
set_language=
miincludes= # makeinfo include path
textra=
tmpdir=${TMPDIR:-/tmp}/t2d$$ # avoid collisions on 8.3 filesystems.
txincludes= # TEXINPUTS extensions
txiprereq=19990129 # minimum texinfo.tex version to have macro expansion
quiet= # by default let the tools' message be displayed
verbose=false # echo for verbose mode
orig_pwd=`pwd`
# Systems which define $COMSPEC or $ComSpec use semicolons to separate
# directories in TEXINPUTS.
if test -n "$COMSPEC$ComSpec"; then
path_sep=";"
else
path_sep=":"
fi
# Save this so we can construct a new TEXINPUTS path for each file.
TEXINPUTS_orig="$TEXINPUTS"
# Unfortunately makeindex does not read TEXINPUTS.
INDEXSTYLE_orig="$INDEXSTYLE"
export TEXINPUTS INDEXSTYLE
# Push a token among the arguments that will be used to notice when we
# ended options/arguments parsing.
# Use "set dummy ...; shift" rather than 'set - ..." because on
# Solaris set - turns off set -x (but keeps set -e).
# Use ${1+"$@"} rather than "$@" because Digital Unix and Ultrix 4.3
# still expand "$@" to a single argument (the empty string) rather
# than nothing at all.
arg_sep="$$--$$"
set dummy ${1+"$@"} "$arg_sep"; shift
#
# Parse command line arguments.
while test x"$1" != x"$arg_sep"; do
# Handle --option=value by splitting apart and putting back on argv.
case "$1" in
--*=*)
opt=`echo "$1" | sed -e 's/=.*//'`
val=`echo "$1" | sed -e 's/[^=]*=//'`
shift
set dummy "$opt" "$val" ${1+"$@"}; shift
;;
esac
# This recognizes --quark as --quiet. So what.
case "$1" in
-@ ) escape=@;;
# Silently and without documentation accept -b and --b[atch] as synonyms.
-b | --b*) batch=eval;;
-q | -s | --q* | --s*) quiet=t; batch=eval;;
-c | --c*) clean=t;;
-D | --d*) debug=t;;
-e | --e*) expand=t;;
-h | --h*) echo "$usage"; exit 0;;
-I | --I*)
shift
miincludes="$miincludes -I $1"
txincludes="$txincludes$path_sep$1"
;;
-l | --l*) shift; set_language=$1;;
-p | --p*) oformat=pdf;;
-t | --t*) shift; textra="$textra\\
$1";;
-v | --vers*) echo "$version"; exit 0;;
-V | --verb*) verbose=echo;;
--) # What remains are not options.
shift
while test x"$1" != x"$arg_sep"; do
set dummy ${1+"$@"} "$1"; shift
shift
done
break;;
-*)
echo "$0: Unknown or ambiguous option \`$1'." >&2
echo "$0: Try \`--help' for more information." >&2
exit 1;;
*) set dummy ${1+"$@"} "$1"; shift;;
esac
shift
done
# Pop the token
shift
# Interpret remaining command line args as filenames.
if test $# = 0; then
echo "$0: Missing file arguments." >&2
echo "$0: Try \`--help' for more information." >&2
exit 2
fi
# Prepare the temporary directory. Remove it at exit, unless debugging.
if test -z "$debug"; then
trap "cd / && rm -rf $tmpdir" 0 1 2 15
fi
# Create the temporary directory with strict rights
(umask 077 && mkdir $tmpdir) || exit 1
# Prepare the tools we might need. This may be extra work in some
# cases, but improves the readibility of the script.
utildir=$tmpdir/utils
mkdir $utildir || exit 1
# A sed script that preprocesses Texinfo sources in order to keep the
# iftex sections only. We want to remove non TeX sections, and
# comment (with `@c texi2dvi') TeX sections so that makeinfo does not
# try to parse them. Nevertheless, while commenting TeX sections,
# don't comment @macro/@end macro so that makeinfo does propagate
# them. Unfortunately makeinfo --iftex --no-ifhtml --no-ifinfo
# doesn't work well enough (yet) to use that, so work around with sed.
comment_iftex_sed=$utildir/comment.sed
cat <<EOF >$comment_iftex_sed
/^@tex/,/^@end tex/{
s/^/@c texi2dvi/
}
/^@iftex/,/^@end iftex/{
s/^/@c texi2dvi/
/^@c texi2dvi@macro/,/^@c texi2dvi@end macro/{
s/^@c texi2dvi//
}
}
/^@html/,/^@end html/d
/^@ifhtml/,/^@end ifhtml/d
/^@ifnottex/,/^@end ifnottex/d
/^@ifinfo/,/^@end ifinfo/{
/^@node/p
/^@menu/,/^@end menu/p
d
}
EOF
# Uncommenting is simple: Remove any leading `@c texi2dvi'.
uncomment_iftex_sed=$utildir/uncomment.sed
cat <<EOF >$uncomment_iftex_sed
s/^@c texi2dvi//
EOF
# A shell script that computes the list of xref files.
# Takes the filename (without extension) of which we look for xref
# files as argument. The index files must be reported last.
get_xref_files=$utildir/get_xref.sh
cat <<\EOF >$get_xref_files
#! /bin/sh
# Get list of xref files (indexes, tables and lists).
# Find all files having root filename with a two-letter extension,
# saves the ones that are really Texinfo-related files. .?o? catches
# LaTeX tables and lists.
for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
# If file is empty, skip it.
test -s "$this_file" || continue
# If the file is not suitable to be an index or xref file, don't
# process it. The file can't be if its first character is not a
# backslash or single quote.
first_character=`sed -n '1s/^\(.\).*$/\1/p;q' $this_file`
if test "x$first_character" = "x\\" \
|| test "x$first_character" = "x'"; then
xref_files="$xref_files ./$this_file"
fi
done
echo "$xref_files"
EOF
chmod 500 $get_xref_files
# File descriptor usage:
# 0 standard input
# 1 standard output (--verbose messages)
# 2 standard error
# 3 some systems may open it to /dev/tty
# 4 used on the Kubota Titan
# 5 tools output (turned off by --quiet)
# Tools' output. If quiet, discard, else redirect to the message flow.
if test "$quiet" = t; then
exec 5>/dev/null
else
exec 5>&1
fi
# Enable tracing
test "$debug" = t && set -x
# Texify files
#
# TeXify files.
for command_line_filename in ${1+"$@"}; do
$verbose "Processing $command_line_filename ..."
# See if file exists. If it doesn't we're in trouble since, even
# If the COMMAND_LINE_FILENAME is not absolute (e.g., --debug.tex),
# prepend `./' in order to avoid that the tools take it as an option.
echo "$command_line_filename" | egrep '^(/|[A-z]:/)' >/dev/null \
|| command_line_filename="./$command_line_filename"
# See if the file exists. If it doesn't we're in trouble since, even
# though the user may be able to reenter a valid filename at the tex
# prompt (assuming they're attending the terminal), this script won't
# be able to find the right index files and so forth.
if test ! -r "${command_line_filename}"; then
echo "$0: Could not read ${command_line_filename}." >&2
# be able to find the right xref files and so forth.
if test ! -r "$command_line_filename"; then
echo "$0: Could not read $command_line_filename, skipping." >&2
continue
fi
# Roughly equivalent to `dirname ...`, but more portable
directory="`echo ${command_line_filename} | sed 's/\/[^\/]*$//'`"
filename_texi="`basename ${command_line_filename}`"
# Strip off the last extension part (probably .texinfo or .texi)
filename_noext="`echo ${filename_texi} | sed 's/\.[^.]*$//'`"
# Get the name of the current directory. We want the full path
# because in clean mode we are in tmp, in which case a relative
# path has no meaning.
filename_dir=`echo $command_line_filename | sed 's!/[^/]*$!!;s!^$!.!'`
filename_dir=`cd "$filename_dir" >/dev/null && pwd`
# Use same basename since we want to generate aux files with the same
# basename as the manual. Use extension .texi for the temp file so
# that TeX will ignore it. Thus, we must use a subdirectory.
#
# Output the macro-expanded file to here. The vastly abbreviated
# temporary directory name is so we don't have collisions on 8.3 or
# 14-character filesystems.
tmp_dir=${TMPDIR-/tmp}/txi2d.$$
filename_tmp=$tmp_dir/$filename_noext.texi
# Output the file with the user's extra commands to here.
tmp_dir2=${tmp_dir}.2
filename_tmp2=$tmp_dir2/$filename_noext.texi
mkdir $tmp_dir $tmp_dir2
# Always remove the temporary directories.
trap "rm -rf $tmp_dir $tmp_dir2" 1 2 15
# Strip directory part but leave extension.
filename_ext=`basename "$command_line_filename"`
# Strip extension.
filename_noext=`echo "$filename_ext" | sed 's/\.[^.]*$//'`
ext=`echo "$filename_ext" | sed 's/^.*\.//'`
# If directory and file are the same, then it's probably because there's
# no pathname component. Set dirname to `.', the current directory.
if test "z${directory}" = "z${command_line_filename}"; then
directory=.
# _src. Use same basename since we want to generate aux files with
# the same basename as the manual. If --expand, then output the
# macro-expanded file to here, else copy the original file.
tmpdir_src=$tmpdir/src
filename_src=$tmpdir_src/$filename_noext.$ext
# _xtr. The file with the user's extra commands.
tmpdir_xtr=$tmpdir/xtr
filename_xtr=$tmpdir_xtr/$filename_noext.$ext
# _bak. Copies of the previous xref files (another round is run if
# they differ from the new one).
tmpdir_bak=$tmpdir/bak
# Make all those directories and give up if we can't succeed.
mkdir $tmpdir_src $tmpdir_xtr $tmpdir_bak || exit 1
# Source file might include additional sources. Put `.' and
# directory where source file(s) reside in TEXINPUTS before anything
# else. `.' goes first to ensure that any old .aux, .cps,
# etc. files in ${directory} don't get used in preference to fresher
# files in `.'. Include orig_pwd in case we are in clean mode, where
# we've cd'd to a temp directory.
common=".$path_sep$orig_pwd$path_sep$filename_dir$path_sep$txincludes$path_sep"
TEXINPUTS="$common$TEXINPUTS_orig"
INDEXSTYLE="$common$INDEXSTYLE_orig"
# If the user explicitly specified the language, use that.
# Otherwise, if the first line is \input texinfo, assume it's texinfo.
# Otherwise, guess from the file extension.
if test -n "$set_language"; then
language=$set_language
elif sed 1q "$command_line_filename" | fgrep 'input texinfo' >/dev/null; then
language=texinfo
else
language=
fi
# Source file might @include additional texinfo sources. Put `.' and
# directory where source file(s) reside in TEXINPUTS before anything
# else. `.' goes first to ensure that any old .aux, .cps, etc. files in
# ${directory} don't get used in preference to fresher files in `.'.
TEXINPUTS=".:${directory}:${TEXINPUTS_orig}"
# Get the type of the file (latex or texinfo) from the given language
# we just guessed, or from the file extension if not set yet.
case ${language:-$filename_ext} in
[lL]a[tT]e[xX] | *.ltx | *.tex)
# Assume a LaTeX file. LaTeX needs bibtex and uses latex for
# compilation. No makeinfo.
bibtex=${BIBTEX:-bibtex}
makeinfo= # no point in running makeinfo on latex source.
texindex=${MAKEINDEX:-makeindex}
if test $oformat = dvi; then
tex=${LATEX:-latex}
else
tex=${PDFLATEX:-pdflatex}
fi
;;
# Expand macro commands in the original source file using Makeinfo;
# the macro syntax bfox implemented is impossible to implement in TeX.
*)
# Assume a Texinfo file. Texinfo files need makeinfo, texindex and tex.
bibtex=
texindex=${TEXINDEX:-texindex}
if test $oformat = dvi; then
tex=${TEX:-tex}
else
tex=${PDFTEX:-pdftex}
fi
# Unless required by the user, makeinfo expansion is wanted only
# if texinfo.tex is too old.
if test "$expand" = t; then
makeinfo=${MAKEINFO:-makeinfo}
else
# Check if texinfo.tex performs macro expansion by looking for
# its version. The version is a date of the form YEAR-MO-DA.
# We don't need to use [0-9] to match the digits since anyway
# the comparison with $txiprereq, a number, will fail with non
# digits.
txiversion_tex=txiversion.tex
echo '\input texinfo.tex @bye' >$tmpdir/$txiversion_tex
# Run in the tmpdir to avoid leaving files.
eval `cd $tmpdir >/dev/null \
&& $tex $txiversion_tex 2>/dev/null \
| sed -n 's/^.*\[\(.*\)version \(....\)-\(..\)-\(..\).*$/txiformat=\1 txiversion="\2\3\4"/p'`
$verbose "texinfo.tex preloaded as \`$txiformat', version is \`$txiversion' ..."
if test "$txiprereq" -le "$txiversion" >/dev/null 2>&1; then
makeinfo=
else
makeinfo=${MAKEINFO:-makeinfo}
fi
# As long as we had to run TeX, offer the user this convenience
if test "$txiformat" = Texinfo; then
escape=@
fi
fi
;;
esac
# Expand macro commands in the original source file using Makeinfo.
# Always use `end' footnote style, since the `separate' style
# generates different output (arguably this is a bug in -E).
# Discard main info output, the user asked to run TeX, not makeinfo.
# Redirect output to /dev/null to throw away `Making info file...' msg.
$verbose "Macro-expanding $command_line_filename to $filename_tmp ..."
$makeinfo --footnote-style=end -E $filename_tmp -o /dev/null \
$command_line_filename >/dev/null
# But if there were no macros, or makeinfo failed for some reason,
# just use the original file. (It shouldn't make any difference, but
# let's be safe.)
if test $? -ne 0 || cmp -s $filename_tmp $command_line_filename; then
$verbose "Reverting to $command_line_filename ..."
cp -p $command_line_filename $filename_tmp
if test -n "$makeinfo"; then
$verbose "Macro-expanding $command_line_filename to $filename_src ..."
sed -f $comment_iftex_sed "$command_line_filename" \
| $makeinfo --footnote-style=end -I "$filename_dir" $miincludes \
-o /dev/null --macro-expand=- \
| sed -f $uncomment_iftex_sed >"$filename_src"
filename_input=$filename_src
fi
# If makeinfo failed (or was not even run), use the original file as input.
if test $? -ne 0 \
|| test ! -r "$filename_src"; then
$verbose "Reverting to $command_line_filename ..."
filename_input=$filename_dir/$filename_ext
fi
filename_input=$filename_tmp
dirname_input=$tmp_dir
# Used most commonly for @finalout, @smallbook, etc.
if test -n "$textra"; then
$verbose "Inserting extra commands: $textra."
$verbose "Inserting extra commands: $textra"
sed '/^@setfilename/a\
'"$textra" $filename_input >$filename_tmp2
filename_input=$filename_tmp2
dirname_input=$tmp_dir2
'"$textra" "$filename_input" >$filename_xtr
filename_input=$filename_xtr
fi
# If clean mode was specified, then move to the temporary directory.
if test "$clean" = t; then
$verbose "cd $dirname_input"
cd $dirname_input || exit 1
filename_input=`basename $filename_input`
$verbose "cd $tmpdir_src"
cd "$tmpdir_src" || exit 1
fi
while true; do # will break out of loop below
# "Unset" variables that might have values from previous iterations and
# which won't be completely reset later.
definite_index_files=
while :; do # will break out of loop below
orig_xref_files=`$get_xref_files "$filename_noext"`
# Find all files having root filename with a two-letter extension,
# determine whether they're really index files, and save them. Foo.aux
# is actually the cross-references file, but we need to keep track of
# that too.
possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`"
for this_file in ${possible_index_files}; do
# If file is empty, forget it.
test -s "${this_file}" || continue
# Save copies of originals for later comparison.
if test -n "$orig_xref_files"; then
$verbose "Backing up xref files: `echo $orig_xref_files | sed 's|\./||g'`"
cp $orig_xref_files $tmpdir_bak
fi
# Examine first character of file. If it's not suitable to be an
# index or xref file, don't process it.
first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`"
if test "x${first_character}" = "x\\" \
|| test "x${first_character}" = "x'"; then
definite_index_files="${definite_index_files} ${this_file}"
# Run bibtex on current file.
# - If its input (AUX) exists.
# - If AUX contains both `\bibdata' and `\bibstyle'.
# - If some citations are missing (LOG contains `Citation').
# or the LOG complains of a missing .bbl
#
# We run bibtex first, because I can see reasons for the indexes
# to change after bibtex is run, but I see no reason for the
# converse.
#
# Don't try to be too smart. Running bibtex only if the bbl file
# exists and is older than the LaTeX file is wrong, since the
# document might include files that have changed. Because there
# can be several AUX (if there are \include's), but a single LOG,
# looking for missing citations in LOG is easier, though we take
# the risk to match false messages.
if test -n "$bibtex" \
&& test -r "$filename_noext.aux" \
&& test -r "$filename_noext.log" \
&& (grep '^\\bibdata[{]' "$filename_noext.aux" \
&& grep '^\\bibstyle[{]' "$filename_noext.aux" \
&& (grep 'Warning:.*Citation.*undefined' "$filename_noext.log" \
|| grep 'No file .*\.bbl\.' "$filename_noext.log")) \
>/dev/null 2>&1; \
then
$verbose "Running $bibtex $filename_noext ..."
if $bibtex "$filename_noext" >&5; then :; else
echo "$0: $bibtex exited with bad status, quitting." >&2
exit 1
fi
done
orig_index_files="${definite_index_files}"
orig_index_files_sans_aux="`echo ${definite_index_files} \
| sed 's/'${filename_noext}'\.aux//;
s/^[ ]*//;s/[ ]*$//;'`"
fi
# Now save copies of original index files so we have some means of
# comparison later.
$verbose "Backing up current index files: $orig_index_files ..."
for index_file_to_save in ${orig_index_files}; do
cp "${index_file_to_save}" "${index_file_to_save}${backup_extension}"
done
# Run texindex on current index files. If they already exist, and
# after running TeX a first time the index files don't change, then
# there's no reason to run TeX again. But we won't know that if the
# index files are out of date or nonexistent.
if test -n "${orig_index_files_sans_aux}"; then
$verbose "Running $texindex $orig_index_files_sans_aux ..."
${texindex} ${orig_index_files_sans_aux}
# What we'll run texindex on -- exclude non-index files.
# Since we know index files are last, it is correct to remove everything
# before .aux and .?o?.
index_files=`echo "$orig_xref_files" \
| sed "s!.*\.aux!!g;
s!./$filename_noext\..o.!!g;
s/^[ ]*//;s/[ ]*$//"`
# Run texindex (or makeindex) on current index files. If they
# already exist, and after running TeX a first time the index
# files don't change, then there's no reason to run TeX again.
# But we won't know that if the index files are out of date or
# nonexistent.
if test -n "$texindex" && test -n "$index_files"; then
$verbose "Running $texindex $index_files ..."
if $texindex $index_files 2>&5 1>&2; then :; else
echo "$0: $texindex exited with bad status, quitting." >&2
exit 1
fi
fi
# Finally, run TeX.
if test "$batch" = t; then
tex_mode='\nonstopmode'
else
tex_mode=
# Prevent $ESCAPE from being interpreted by the shell if it happens
# to be `/'.
$batch tex_args="\\${escape}nonstopmode\ \\${escape}input"
$verbose "Running $cmd ..."
cmd="$tex $tex_args $filename_input"
if $cmd >&5; then :; else
echo "$0: $tex exited with bad status, quitting." >&2
echo "$0: see $filename_noext.log for errors." >&2
test "$clean" = t \
&& cp "$filename_noext.log" "$orig_pwd"
exit 1
fi
$verbose "Running $tex $filename_input ..."
cmd="$tex $tex_mode \\input $filename_input"
$cmd
# Check if index files changed.
#
definite_index_files=
# Get list of new index files.
possible_index_files="`eval echo ${filename_noext}.?? ${filename_noext}.aux`"
for this_file in ${possible_index_files}; do
# If file is empty, forget it.
test -s "${this_file}" || continue
# Examine first character of file. If it's not a backslash or
# single quote, then it's definitely not an index or xref file.
# (Will have to check for @ when we switch to Texinfo syntax in
# all these files...)
first_character="`sed -n '1s/^\(.\).*$/\1/p;q' ${this_file}`"
if test "x${first_character}" = "x\\" \
|| test "x${first_character}" = "x'"; then
definite_index_files="${definite_index_files} ${this_file}"
fi
done
new_index_files="${definite_index_files}"
new_index_files_sans_aux="`echo ${definite_index_files} \
| sed 's/'${filename_noext}'\.aux//;
s/^[ ]*//;s/[ ]*$//;'`"
# Decide if looping again is needed.
finished=t
# If old and new list don't at least have the same file list, then one
# file or another has definitely changed.
$verbose "Original index files =$orig_index_files"
$verbose "New index files =$new_index_files"
if test "z${orig_index_files}" != "z${new_index_files}"; then
index_files_changed_p=t
else
# File list is the same. We must compare each file until we find a
# difference.
index_files_changed_p=
for this_file in ${new_index_files}; do
$verbose "Comparing index file $this_file ..."
# cmp -s will return nonzero exit status if files differ.
cmp -s "${this_file}" "${this_file}${backup_extension}"
if test $? -ne 0; then
# We only need to keep comparing until we find *one* that
# differs, because we'll have to run texindex & tex no
# matter what.
index_files_changed_p=t
$verbose "Index file $this_file differed:"
test $verbose = echo \
&& diff -c "${this_file}${backup_extension}" "${this_file}"
# LaTeX (and the package changebar) report in the LOG file if it
# should be rerun. This is needed for files included from
# subdirs, since texi2dvi does not try to compare xref files in
# subdirs. Performing xref files test is still good since LaTeX
# does not report changes in xref files.
if fgrep "Rerun to get" "$filename_noext.log" >/dev/null 2>&1; then
finished=
fi
# Check if xref files changed.
new_xref_files=`$get_xref_files "$filename_noext"`
$verbose "Original xref files = `echo $orig_xref_files | sed 's|\./||g'`"
$verbose "New xref files = `echo $new_xref_files | sed 's|\./||g'`"
# If old and new lists don't at least have the same file list,
# then one file or another has definitely changed.
test "x$orig_xref_files" != "x$new_xref_files" && finished=
# File list is the same. We must compare each file until we find
# a difference.
if test -n "$finished"; then
for this_file in $new_xref_files; do
$verbose "Comparing xref file `echo $this_file | sed 's|\./||g'` ..."
# cmp -s returns nonzero exit status if files differ.
if cmp -s "$this_file" "$tmpdir_bak/$this_file"; then :; else
# We only need to keep comparing until we find one that
# differs, because we'll have to run texindex & tex again no
# matter how many more there might be.
finished=
$verbose "xref file `echo $this_file | sed 's|\./||g'` differed ..."
test "$debug" = t && diff -c "$tmpdir_bak/$this_file" "$this_file"
break
fi
done
fi
# If index files have changed since TeX has been run, or if the aux
# file wasn't present originally, run texindex and TeX again.
if test "${index_files_changed_p}"; then :; else
# Nothing changed. We're done with TeX.
break
fi
# If finished, exit the loop, else rerun the loop.
test -n "$finished" && break
done
# If we were in clean mode, compilation was in a tmp directory.
# Copy the DVI file into the directory where the compilation
# Copy the DVI (or PDF) file into the directory where the compilation
# has been done. (The temp dir is about to get removed anyway.)
# We also return to the original directory so that
# - the next file is processed in correct conditions
# - the temporary file can be removed
if test -n "$clean"; then
$verbose "Copying DVI file from `pwd` to $orig_pwd"
cp -p $filename_noext.dvi $orig_pwd
$verbose "Copying $oformat file from `pwd` to $orig_pwd"
cp -p "./$filename_noext.$oformat" "$orig_pwd"
cd / # in case $orig_pwd is on a different drive (for DOS)
cd $orig_pwd || exit 1
fi
# Generate list of files to delete, then call rm once with the entire
# list. This is significantly faster than multiple executions of rm.
file_list=
for file in ${orig_index_files}; do
file_list="${file_list} ${file}${backup_extension}"
done
if test -n "${file_list}"; then
$verbose "Removing $file_list $tmp_dir $tmp_dir2 ..."
rm -f ${file_list}
rm -rf $tmp_dir $tmp_dir2
# Remove temporary files.
if test "x$debug" = "x"; then
$verbose "Removing $tmpdir_src $tmpdir_xtr $tmpdir_bak ..."
cd /
rm -rf $tmpdir_src $tmpdir_xtr $tmpdir_bak
fi
done
$verbose "$0 done."
true # exit successfully.
exit 0 # exit successfully, not however we ended the loop.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,22 @@
# on which program is running, or what terminal is active.
#
# Copyright (C) 1989-2002 Free Software Foundation, Inc.
#
# 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
# the Free Software Foundation; either version 2, or (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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
# In all programs, all terminals, make sure this is bound.
"\C-x\C-r": re-read-init-file

View File

@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
RL_LIBRARY_VERSION = @LIBVERSION@
SHELL = @MAKE_SHELL@
RM = rm -f
@ -25,16 +26,19 @@ VPATH = .:@srcdir@
top_srcdir = @top_srcdir@
BUILD_DIR = .
# Support an alternate destination root directory for package building
DESTDIR =
DEFS = @DEFS@
CC = @CC@
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DREADLINE_LIBRARY
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DREADLINE_LIBRARY -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
CPPFLAGS = @CPPFLAGS@
INCLUDES = -I$(srcdir) -I$(top_srcdir) -I..
CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS)
LDFLAGS = -g -L..
LDFLAGS = -g -L.. @LDFLAGS@
READLINE_LIB = ../libreadline.a
HISTORY_LIB = ../libhistory.a
@ -45,26 +49,34 @@ TERMCAP_LIB = @TERMCAP_LIB@
${RM} $@
$(CC) $(CCFLAGS) -c $<
EXECUTABLES = fileman rltest rl rlversion
OBJECTS = fileman.o rltest.o rl.o rlversion.o
EXECUTABLES = fileman rltest rl rlcat rlversion histexamp
OBJECTS = fileman.o rltest.o rl.o rlversion.o histexamp.o
all: $(EXECUTABLES)
everything: all rlfe
rl: rl.o
rl: rl.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rl.o -lreadline $(TERMCAP_LIB)
fileman: fileman.o
rlcat: rlcat.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rlcat.o -lreadline $(TERMCAP_LIB)
fileman: fileman.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ fileman.o -lreadline $(TERMCAP_LIB)
rltest: rltest.o
rltest: rltest.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rltest.o -lreadline $(TERMCAP_LIB)
rlversion: rlversion.o $(READLINE_LIB)
$(CC) $(LDFLAGS) -o $@ rlversion.o -lreadline $(TERMCAP_LIB)
histexamp: histexamp.o $(HISTORY_LIB)
$(CC) $(LDFLAGS) -o $@ histexamp.o -lhistory $(TERMCAP_LIB)
clean mostlyclean:
$(RM) $(OBJECTS)
$(RM) $(EXECUTABLES) *.exe
$(RM) rlfe.o rlfe
distclean maintainer-clean: clean
$(RM) Makefile
@ -73,6 +85,13 @@ fileman.o: fileman.c
rltest.o: rltest.c
rl.o: rl.c
rlversion.o: rlversion.c
histexamp.o: histexamp.c
fileman.o: $(top_srcdir)/readline.h
rltest.o: $(top_srcdir)/readline.h
rl.o: $(top_srcdir)/readline.h
rlversion.o: $(top_srcdir)/readline.h
histexamp.o: $(top_srcdir)/history.h
# Stuff for Per Bothner's `rlfe' program

View File

@ -1,3 +1,23 @@
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
/* fileman.c -- A tiny application which demonstrates how to use the
GNU Readline library. This application interactively allows users
to manipulate files and their modes. */
@ -41,15 +61,22 @@
extern char *xmalloc ();
/* The names of functions that actually do the manipulation. */
int com_list (), com_view (), com_rename (), com_stat (), com_pwd ();
int com_delete (), com_help (), com_cd (), com_quit ();
int com_list PARAMS((char *));
int com_view PARAMS((char *));
int com_rename PARAMS((char *));
int com_stat PARAMS((char *));
int com_pwd PARAMS((char *));
int com_delete PARAMS((char *));
int com_help PARAMS((char *));
int com_cd PARAMS((char *));
int com_quit PARAMS((char *));
/* A structure which contains information on the commands this program
can understand. */
typedef struct {
char *name; /* User printable name of the function. */
Function *func; /* Function to call to do the job. */
rl_icpfunc_t *func; /* Function to call to do the job. */
char *doc; /* Documentation for this function. */
} COMMAND;
@ -65,7 +92,7 @@ COMMAND commands[] = {
{ "rename", com_rename, "Rename FILE to NEWNAME" },
{ "stat", com_stat, "Print out statistics on FILE" },
{ "view", com_view, "View the contents of FILE" },
{ (char *)NULL, (Function *)NULL, (char *)NULL }
{ (char *)NULL, (rl_icpfunc_t *)NULL, (char *)NULL }
};
/* Forward declarations. */
@ -205,8 +232,8 @@ stripwhite (string)
/* */
/* **************************************************************** */
char *command_generator ();
char **fileman_completion ();
char *command_generator PARAMS((const char *, int));
char **fileman_completion PARAMS((const char *, int, int));
/* Tell the GNU Readline library how to complete. We want to try to complete
on command names if this is the first word in the line, or on filenames
@ -217,7 +244,7 @@ initialize_readline ()
rl_readline_name = "FileMan";
/* Tell the completer that we want a crack first. */
rl_attempted_completion_function = (CPPFunction *)fileman_completion;
rl_attempted_completion_function = fileman_completion;
}
/* Attempt to complete on the contents of TEXT. START and END bound the
@ -227,7 +254,7 @@ initialize_readline ()
or NULL if there aren't any. */
char **
fileman_completion (text, start, end)
char *text;
const char *text;
int start, end;
{
char **matches;
@ -238,7 +265,7 @@ fileman_completion (text, start, end)
to complete. Otherwise it is the name of a file in the current
directory. */
if (start == 0)
matches = completion_matches (text, command_generator);
matches = rl_completion_matches (text, command_generator);
return (matches);
}
@ -248,7 +275,7 @@ fileman_completion (text, start, end)
start at the top of the list. */
char *
command_generator (text, state)
char *text;
const char *text;
int state;
{
static int list_index, len;

View File

@ -1,4 +1,34 @@
main ()
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <stdio.h>
#ifdef READLINE_LIBRARY
# include "history.h"
#else
# include <readline/history.h>
#endif
main (argc, argv)
int argc;
char **argv;
{
char line[1024], *t;
int len, done = 0;

View File

@ -1,12 +1,31 @@
/* manexamp.c -- The examples which appear in the documentation are here. */
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#include <stdio.h>
#include <readline/readline.h>
/* **************************************************************** */
/* */
* How to Emulate gets () */
/* How to Emulate gets () */
/* */
/* **************************************************************** */
@ -82,13 +101,12 @@ invert_case_line (count, key)
for (; start != end; start += direction)
{
if (uppercase_p (rl_line_buffer[start]))
rl_line_buffer[start] = to_lower (rl_line_buffer[start]);
else if (lowercase_p (rl_line_buffer[start]))
rl_line_buffer[start] = to_upper (rl_line_buffer[start]);
if (_rl_uppercase_p (rl_line_buffer[start]))
rl_line_buffer[start] = _rl_to_lower (rl_line_buffer[start]);
else if (_rl_lowercase_p (rl_line_buffer[start]))
rl_line_buffer[start] = _rl_to_upper (rl_line_buffer[start]);
}
/* Move point to on top of the last character changed. */
rl_point = end - direction;
}

View File

@ -0,0 +1,139 @@
/*******************************************************************************
* $Revision$
* $Date$
* $Author$
*
* Contents: A streambuf which uses the GNU readline library for line I/O
* (c) 2001 by Dimitris Vyzovitis [vyzo@media.mit.edu]
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (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, write to the Free
* Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
******************************************************************************/
#ifndef _READLINEBUF_H_
#define _READLINEBUF_H_
#include <iostream>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <cstdio>
#include <readline/readline.h>
#include <readline/history.h>
#if (defined __GNUC__) && (__GNUC__ < 3)
#include <streambuf.h>
#else
#include <streambuf>
using std::streamsize;
using std::streambuf;
#endif
class readlinebuf : public streambuf {
public:
#if (defined __GNUC__) && (__GNUC__ < 3)
typedef char char_type;
typedef int int_type;
typedef streampos pos_type;
typedef streamoff off_type;
#endif
static const int_type eof = EOF; // this is -1
static const int_type not_eof = 0;
private:
const char* prompt_;
bool history_;
char* line_;
int low_;
int high_;
protected:
virtual int_type showmanyc() const { return high_ - low_; }
virtual streamsize xsgetn( char_type* buf, streamsize n ) {
int rd = n > (high_ - low_)? (high_ - low_) : n;
memcpy( buf, line_, rd );
low_ += rd;
if ( rd < n ) {
low_ = high_ = 0;
free( line_ ); // free( NULL ) is a noop
line_ = readline( prompt_ );
if ( line_ ) {
high_ = strlen( line_ );
if ( history_ && high_ ) add_history( line_ );
rd += xsgetn( buf + rd, n - rd );
}
}
return rd;
}
virtual int_type underflow() {
if ( high_ == low_ ) {
low_ = high_ = 0;
free( line_ ); // free( NULL ) is a noop
line_ = readline( prompt_ );
if ( line_ ) {
high_ = strlen( line_ );
if ( history_ && high_ ) add_history( line_ );
}
}
if ( low_ < high_ ) return line_[low_];
else return eof;
}
virtual int_type uflow() {
int_type c = underflow();
if ( c != eof ) ++low_;
return c;
}
virtual int_type pbackfail( int_type c = eof ) {
if ( low_ > 0 ) --low_;
else if ( c != eof ) {
if ( high_ > 0 ) {
char* nl = (char*)realloc( line_, high_ + 1 );
if ( nl ) {
line_ = (char*)memcpy( nl + 1, line_, high_ );
high_ += 1;
line_[0] = char( c );
} else return eof;
} else {
assert( !line_ );
line_ = (char*)malloc( sizeof( char ) );
*line_ = char( c );
high_ = 1;
}
} else return eof;
return not_eof;
}
public:
readlinebuf( const char* prompt = NULL, bool history = true )
: prompt_( prompt ), history_( history ),
line_( NULL ), low_( 0 ), high_( 0 ) {
setbuf( 0, 0 );
}
};
#endif

View File

@ -5,6 +5,26 @@
* usage: rl [-p prompt] [-u unit] [-d default] [-n nchars]
*/
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
@ -38,7 +58,7 @@ set_deftext ()
{
rl_insert_text (deftext);
deftext = (char *)NULL;
rl_startup_hook = (Function *)NULL;
rl_startup_hook = (rl_hook_func_t *)NULL;
}
return 0;
}
@ -126,6 +146,6 @@ main (argc, argv)
if (temp == 0)
exit (1);
puts (temp);
printf ("%s\n", temp);
exit (0);
}

174
readline/examples/rlcat.c Normal file
View File

@ -0,0 +1,174 @@
/*
* rlcat - cat(1) using readline
*
* usage: rlcat
*/
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h>
#include "posixstat.h"
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#if defined (READLINE_LIBRARY)
# include "readline.h"
# include "history.h"
#else
# include <readline/readline.h>
# include <readline/history.h>
#endif
extern int optind;
extern char *optarg;
static int stdcat();
static char *progname;
static int vflag;
static void
usage()
{
fprintf (stderr, "%s: usage: %s [-vEVN] [filename]\n", progname, progname);
}
int
main (argc, argv)
int argc;
char **argv;
{
char *temp;
int opt, Vflag, Nflag;
progname = strrchr(argv[0], '/');
if (progname == 0)
progname = argv[0];
else
progname++;
vflag = Vflag = Nflag = 0;
while ((opt = getopt(argc, argv, "vEVN")) != EOF)
{
switch (opt)
{
case 'v':
vflag = 1;
break;
case 'V':
Vflag = 1;
break;
case 'E':
Vflag = 0;
break;
case 'N':
Nflag = 1;
break;
default:
usage ();
exit (2);
}
}
argc -= optind;
argv += optind;
if (isatty(0) == 0 || argc || Nflag)
return stdcat(argc, argv);
rl_variable_bind ("editing-mode", Vflag ? "vi" : "emacs");
while (temp = readline (""))
{
if (*temp)
add_history (temp);
printf ("%s\n", temp);
}
return (ferror (stdout));
}
static int
fcopy(fp)
FILE *fp;
{
int c;
char *x;
while ((c = getc(fp)) != EOF)
{
if (vflag && isascii ((unsigned char)c) && isprint((unsigned char)c) == 0)
{
x = rl_untranslate_keyseq (c);
if (fputs (x, stdout) != 0)
return 1;
}
else if (putchar (c) == EOF)
return 1;
}
return (ferror (stdout));
}
int
stdcat (argc, argv)
int argc;
char **argv;
{
int i, fd, r;
char *s;
FILE *fp;
if (argc == 0)
return (fcopy(stdin));
for (i = 0, r = 1; i < argc; i++)
{
if (*argv[i] == '-' && argv[i][1] == 0)
fp = stdin;
else
{
fp = fopen (argv[i], "r");
if (fp == 0)
{
fprintf (stderr, "%s: %s: cannot open: %s\n", progname, argv[i], strerror(errno));
continue;
}
}
r = fcopy (fp);
if (fp != stdin)
fclose(fp);
}
return r;
}

View File

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

View File

@ -4,6 +4,26 @@
/* */
/* **************************************************************** */
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
#include <config.h>
#endif

View File

@ -2,6 +2,26 @@
* rlversion -- print out readline's version number
*/
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif

View File

@ -46,7 +46,7 @@ typedef int QSFUNC (const void *, const void *);
typedef int QSFUNC ();
#endif
extern int _rl_qsort_string_compare ();
extern int _rl_qsort_string_compare PARAMS((char **, char **));
FUNMAP **funmap;
static int funmap_size;
@ -60,7 +60,8 @@ static FUNMAP default_funmap[] = {
{ "abort", rl_abort },
{ "accept-line", rl_newline },
{ "arrow-key-prefix", rl_arrow_keys },
{ "backward-char", rl_backward },
{ "backward-byte", rl_backward_byte },
{ "backward-char", rl_backward_char },
{ "backward-delete-char", rl_rubout },
{ "backward-kill-line", rl_backward_kill_line },
{ "backward-kill-word", rl_backward_kill_word },
@ -91,7 +92,8 @@ static FUNMAP default_funmap[] = {
{ "end-of-line", rl_end_of_line },
{ "exchange-point-and-mark", rl_exchange_point_and_mark },
{ "forward-backward-delete-char", rl_rubout_or_delete },
{ "forward-char", rl_forward },
{ "forward-byte", rl_forward_byte },
{ "forward-char", rl_forward_char },
{ "forward-search-history", rl_forward_search_history },
{ "forward-word", rl_forward_word },
{ "history-search-backward", rl_history_search_backward },
@ -108,7 +110,8 @@ static FUNMAP default_funmap[] = {
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
#ifdef __CYGWIN32__
{ "overwrite-mode", rl_overwrite_mode },
#ifdef __CYGWIN__
{ "paste-from-clipboard", rl_paste_from_clipboard },
#endif
{ "possible-completions", rl_possible_completions },
@ -142,7 +145,6 @@ static FUNMAP default_funmap[] = {
{ "vi-arg-digit", rl_vi_arg_digit },
{ "vi-back-to-indent", rl_vi_back_to_indent },
{ "vi-bWord", rl_vi_bWord },
{ "vi-bracktype", rl_vi_bracktype },
{ "vi-bword", rl_vi_bword },
{ "vi-change-case", rl_vi_change_case },
{ "vi-change-char", rl_vi_change_char },
@ -182,13 +184,13 @@ static FUNMAP default_funmap[] = {
{ "vi-yank-to", rl_vi_yank_to },
#endif /* VI_MODE */
{(char *)NULL, (Function *)NULL }
{(char *)NULL, (rl_command_func_t *)NULL }
};
int
rl_add_funmap_entry (name, function)
char *name;
Function *function;
const char *name;
rl_command_func_t *function;
{
if (funmap_entry + 2 >= funmap_size)
{
@ -225,21 +227,21 @@ rl_initialize_funmap ()
/* Produce a NULL terminated array of known function names. The array
is sorted. The array itself is allocated, but not the strings inside.
You should free () the array when you done, but not the pointrs. */
char **
const char **
rl_funmap_names ()
{
char **result;
const char **result;
int result_size, result_index;
/* Make sure that the function map has been initialized. */
rl_initialize_funmap ();
for (result_index = result_size = 0, result = (char **)NULL; funmap[result_index]; result_index++)
for (result_index = result_size = 0, result = (const char **)NULL; funmap[result_index]; result_index++)
{
if (result_index + 2 > result_size)
{
result_size += 20;
result = (char **)xrealloc (result, result_size * sizeof (char *));
result = (const char **)xrealloc (result, result_size * sizeof (char *));
}
result[result_index] = funmap[result_index]->name;
@ -249,12 +251,3 @@ rl_funmap_names ()
qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
return (result);
}
/* Things that mean `Control'. */
char *possible_control_prefixes[] = {
"Control-", "C-", "CTRL-", (char *)NULL
};
char *possible_meta_prefixes[] = {
"Meta", "M-", (char *)NULL
};

View File

@ -41,11 +41,7 @@
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "rlmbutil.h"
#include "history.h"
#include "histlib.h"
@ -56,6 +52,10 @@
#define HISTORY_WORD_DELIMITERS " \t\n;&()|<>"
#define HISTORY_QUOTE_CHARACTERS "\"'`"
typedef int _hist_search_func_t PARAMS((const char *, int));
extern int rl_byte_oriented; /* declared in mbutil.c */
static char error_pointer;
static char *subst_lhs;
@ -63,10 +63,10 @@ static char *subst_rhs;
static int subst_lhs_len;
static int subst_rhs_len;
static char *get_history_word_specifier __P((char *, char *, int *));
static char *history_find_word __P((char *, int));
static char *get_history_word_specifier PARAMS((char *, char *, int *));
static char *history_find_word PARAMS((char *, int));
static char *quote_breaks __P((char *));
static char *quote_breaks PARAMS((char *));
/* Variables exported by this file. */
/* The character that represents the start of a history expansion
@ -91,9 +91,12 @@ char *history_no_expand_chars = " \t\n\r=";
The default is 0. */
int history_quotes_inhibit_expansion = 0;
/* Used to split words by history_tokenize_internal. */
char *history_word_delimiters = HISTORY_WORD_DELIMITERS;
/* If set, this points to a function that is called to verify that a
particular history expansion should be performed. */
Function *history_inhibit_expansion_function;
rl_linebuf_func_t *history_inhibit_expansion_function;
/* **************************************************************** */
/* */
@ -122,7 +125,7 @@ static char *search_match;
line = get_history_event ("!echo:p", &index, 0); */
char *
get_history_event (string, caller_index, delimiting_quote)
char *string;
const char *string;
int *caller_index;
int delimiting_quote;
{
@ -130,7 +133,7 @@ get_history_event (string, caller_index, delimiting_quote)
register char c;
HIST_ENTRY *entry;
int which, sign, local_index, substring_okay;
Function *search_func;
_hist_search_func_t *search_func;
char *temp;
/* The event can be specified in a number of ways.
@ -199,15 +202,33 @@ get_history_event (string, caller_index, delimiting_quote)
/* Only a closing `?' or a newline delimit a substring search string. */
for (local_index = i; c = string[i]; i++)
if ((!substring_okay && (whitespace (c) || c == ':' ||
(history_search_delimiter_chars && member (c, history_search_delimiter_chars)) ||
string[i] == delimiting_quote)) ||
string[i] == '\n' ||
(substring_okay && string[i] == '?'))
break;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int v;
mbstate_t ps;
memset (&ps, 0, sizeof (mbstate_t));
/* These produce warnings because we're passing a const string to a
function that takes a non-const string. */
_rl_adjust_point (string, i, &ps);
if ((v = _rl_get_char_len (string + i, &ps)) > 1)
{
i += v - 1;
continue;
}
}
else
#endif /* HANDLE_MULTIBYTE */
if ((!substring_okay && (whitespace (c) || c == ':' ||
(history_search_delimiter_chars && member (c, history_search_delimiter_chars)) ||
string[i] == delimiting_quote)) ||
string[i] == '\n' ||
(substring_okay && string[i] == '?'))
break;
which = i - local_index;
temp = xmalloc (1 + which);
temp = (char *)xmalloc (1 + which);
if (which)
strncpy (temp, string + local_index, which);
temp[which] = '\0';
@ -309,7 +330,7 @@ quote_breaks (s)
len += 2;
}
r = ret = xmalloc (len);
r = ret = (char *)xmalloc (len);
*r++ = '\'';
for (p = s; p && *p; )
{
@ -340,7 +361,8 @@ hist_error(s, start, current, errtype)
char *s;
int start, current, errtype;
{
char *temp, *emsg;
char *temp;
const char *emsg;
int ll, elen;
ll = current - start;
@ -373,7 +395,7 @@ hist_error(s, start, current, errtype)
break;
}
temp = xmalloc (ll + elen + 3);
temp = (char *)xmalloc (ll + elen + 3);
strncpy (temp, s + start, ll);
temp[ll] = ':';
temp[ll + 1] = ' ';
@ -399,17 +421,37 @@ get_subst_pattern (str, iptr, delimiter, is_rhs, lenptr)
int *iptr, delimiter, is_rhs, *lenptr;
{
register int si, i, j, k;
char *s = (char *) NULL;
char *s;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
#endif
s = (char *)NULL;
i = *iptr;
#if defined (HANDLE_MULTIBYTE)
memset (&ps, 0, sizeof (mbstate_t));
_rl_adjust_point (str, i, &ps);
#endif
for (si = i; str[si] && str[si] != delimiter; si++)
if (str[si] == '\\' && str[si + 1] == delimiter)
si++;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int v;
if ((v = _rl_get_char_len (str + si, &ps)) > 1)
si += v - 1;
else if (str[si] == '\\' && str[si + 1] == delimiter)
si++;
}
else
#endif /* HANDLE_MULTIBYTE */
if (str[si] == '\\' && str[si + 1] == delimiter)
si++;
if (si > i || is_rhs)
{
s = xmalloc (si - i + 1);
s = (char *)xmalloc (si - i + 1);
for (j = 0, k = i; k < si; j++, k++)
{
/* Remove a backslash quoting the search string delimiter. */
@ -436,13 +478,13 @@ postproc_subst_rhs ()
char *new;
int i, j, new_size;
new = xmalloc (new_size = subst_rhs_len + subst_lhs_len);
new = (char *)xmalloc (new_size = subst_rhs_len + subst_lhs_len);
for (i = j = 0; i < subst_rhs_len; i++)
{
if (subst_rhs[i] == '&')
{
if (j + subst_lhs_len >= new_size)
new = xrealloc (new, (new_size = new_size * 2 + subst_lhs_len));
new = (char *)xrealloc (new, (new_size = new_size * 2 + subst_lhs_len));
strcpy (new + j, subst_lhs);
j += subst_lhs_len;
}
@ -452,7 +494,7 @@ postproc_subst_rhs ()
if (subst_rhs[i] == '\\' && subst_rhs[i + 1] == '&')
i++;
if (j >= new_size)
new = xrealloc (new, new_size *= 2);
new = (char *)xrealloc (new, new_size *= 2);
new[j++] = subst_rhs[i];
}
}
@ -478,8 +520,13 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
int substitute_globally, want_quotes, print_only;
char *event, *temp, *result, *tstr, *t, c, *word_spec;
int result_len;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
result = xmalloc (result_len = 128);
memset (&ps, 0, sizeof (mbstate_t));
#endif
result = (char *)xmalloc (result_len = 128);
i = start;
@ -508,8 +555,21 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
quote, then this expansion takes place inside of the
quoted string. If we have to search for some text ("!foo"),
allow the delimiter to end the search string. */
if (i && (string[i - 1] == '\'' || string[i - 1] == '"'))
quoted_search_delimiter = string[i - 1];
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int c, l;
l = _rl_find_prev_mbchar (string, i, MB_FIND_ANY);
c = string[l];
/* XXX - original patch had i - 1 ??? If i == 0 it would fail. */
if (i && (c == '\'' || c == '"'))
quoted_search_delimiter = c;
}
else
#endif /* HANDLE_MULTIBYTE */
if (i && (string[i - 1] == '\'' || string[i - 1] == '"'))
quoted_search_delimiter = string[i - 1];
event = get_history_event (string, &i, quoted_search_delimiter);
}
@ -622,13 +682,26 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
case '&':
case 's':
{
char *new_event, *t;
char *new_event;
int delimiter, failed, si, l_temp;
if (c == 's')
{
if (i + 2 < (int)strlen (string))
delimiter = string[i + 2];
{
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
_rl_adjust_point (string, i + 2, &ps);
if (_rl_get_char_len (string + i + 2, &ps) > 1)
delimiter = 0;
else
delimiter = string[i + 2];
}
else
#endif /* HANDLE_MULTIBYTE */
delimiter = string[i + 2];
}
else
break; /* no search delimiter */
@ -692,7 +765,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
if (STREQN (temp+si, subst_lhs, subst_lhs_len))
{
int len = subst_rhs_len - subst_lhs_len + l_temp;
new_event = xmalloc (1 + len);
new_event = (char *)xmalloc (1 + len);
strncpy (new_event, temp, si);
strncpy (new_event + si, subst_rhs, subst_rhs_len);
strncpy (new_event + si + subst_rhs_len,
@ -741,7 +814,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
char *x;
if (want_quotes == 'q')
x = single_quote (temp);
x = sh_single_quote (temp);
else if (want_quotes == 'x')
x = quote_breaks (temp);
else
@ -753,7 +826,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
n = strlen (temp);
if (n >= result_len)
result = xrealloc (result, n + 2);
result = (char *)xrealloc (result, n + 2);
strcpy (result, temp);
free (temp);
@ -784,7 +857,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
{ \
while (j >= result_len) \
result_len += 128; \
result = xrealloc (result, result_len); \
result = (char *)xrealloc (result, result_len); \
} \
strcpy (result + j - sl, s); \
} \
@ -794,7 +867,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
do \
{ \
if (j >= result_len - 1) \
result = xrealloc (result, result_len += 64); \
result = (char *)xrealloc (result, result_len += 64); \
result[j++] = c; \
result[j] = '\0'; \
} \
@ -813,9 +886,17 @@ history_expand (hstring, output)
int result_len;
char *result;
#if defined (HANDLE_MULTIBYTE)
char mb[MB_LEN_MAX];
mbstate_t ps;
#endif
/* Used when adding the string. */
char *temp;
if (output == 0)
return 0;
/* Setting the history expansion character to 0 inhibits all
history expansion. */
if (history_expansion_char == 0)
@ -825,7 +906,7 @@ history_expand (hstring, output)
}
/* Prepare the buffer for printing error messages. */
result = xmalloc (result_len = 256);
result = (char *)xmalloc (result_len = 256);
result[0] = '\0';
only_printing = modified = 0;
@ -842,7 +923,7 @@ history_expand (hstring, output)
that is the substitution that we do. */
if (hstring[0] == history_subst_char)
{
string = xmalloc (l + 5);
string = (char *)xmalloc (l + 5);
string[0] = string[1] = history_expansion_char;
string[2] = ':';
@ -852,6 +933,10 @@ history_expand (hstring, output)
}
else
{
#if defined (HANDLE_MULTIBYTE)
memset (&ps, 0, sizeof (mbstate_t));
#endif
string = hstring;
/* If not quick substitution, still maybe have to do expansion. */
@ -859,13 +944,26 @@ history_expand (hstring, output)
is NOT an expansion. */
for (i = 0; string[i]; i++)
{
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int v;
v = _rl_get_char_len (string + i, &ps);
if (v > 1)
{
i += v - 1;
continue;
}
}
#endif /* HANDLE_MULTIBYTE */
cc = string[i + 1];
/* The history_comment_char, if set, appearing that the beginning
/* The history_comment_char, if set, appearing at the beginning
of a word signifies that the rest of the line should not have
history expansion performed on it.
Skip the rest of the line and break out of the loop. */
if (history_comment_char && string[i] == history_comment_char &&
(i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS)))
(i == 0 || member (string[i - 1], history_word_delimiters)))
{
while (string[i])
i++;
@ -923,6 +1021,30 @@ history_expand (hstring, output)
continue;
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int k, c;
c = tchar;
memset (mb, 0, sizeof (mb));
for (k = 0; k < MB_LEN_MAX; k++)
{
mb[k] = (char)c;
memset (&ps, 0, sizeof (mbstate_t));
if (_rl_get_char_len (mb, &ps) == -2)
c = string[++i];
else
break;
}
if (strlen (mb) > 1)
{
ADD_STRING (mb);
break;
}
}
#endif /* HANDLE_MULTIBYTE */
if (tchar == history_expansion_char)
tchar = -3;
else if (tchar == history_comment_char)
@ -951,7 +1073,7 @@ history_expand (hstring, output)
hist_string_extract_single_quoted (string, &i);
slen = i - quote + 2;
temp = xmalloc (slen);
temp = (char *)xmalloc (slen);
strncpy (temp, string + quote, slen);
temp[slen - 1] = '\0';
ADD_STRING (temp);
@ -963,9 +1085,9 @@ history_expand (hstring, output)
}
case -2: /* history_comment_char */
if (i == 0 || member (string[i - 1], HISTORY_WORD_DELIMITERS))
if (i == 0 || member (string[i - 1], history_word_delimiters))
{
temp = xmalloc (l - i + 1);
temp = (char *)xmalloc (l - i + 1);
strcpy (temp, string + i);
ADD_STRING (temp);
free (temp);
@ -997,7 +1119,7 @@ history_expand (hstring, output)
{
if (result)
{
temp = xmalloc (1 + strlen (result));
temp = (char *)xmalloc (1 + strlen (result));
strcpy (temp, result);
ADD_STRING (temp);
free (temp);
@ -1131,7 +1253,14 @@ get_history_word_specifier (spec, from, caller_index)
i++;
last = '$';
}
else if (!spec[i] || spec[i] == ':') /* could be modifier separator */
#if 0
else if (!spec[i] || spec[i] == ':')
/* check against `:' because there could be a modifier separator */
#else
else
/* csh seems to allow anything to terminate the word spec here,
leaving it as an abbreviation. */
#endif
last = -1; /* x- abbreviates x-$ omitting word `$' */
}
@ -1151,7 +1280,7 @@ get_history_word_specifier (spec, from, caller_index)
char *
history_arg_extract (first, last, string)
int first, last;
char *string;
const char *string;
{
register int i, len;
char *result;
@ -1187,7 +1316,7 @@ history_arg_extract (first, last, string)
{
for (size = 0, i = first; i < last; i++)
size += strlen (list[i]) + 1;
result = xmalloc (size + 1);
result = (char *)xmalloc (size + 1);
result[0] = '\0';
for (i = first, offset = 0; i < last; i++)
@ -1217,13 +1346,18 @@ history_arg_extract (first, last, string)
*INDP. */
static char **
history_tokenize_internal (string, wind, indp)
char *string;
const char *string;
int wind, *indp;
{
char **result;
register int i, start, result_index, size;
int len, delimiter;
/* If we're searching for a string that's not part of a word (e.g., " "),
make sure we set *INDP to a reasonable value. */
if (indp && wind != -1)
*indp = -1;
/* Get a token, and stuff it into RESULT. The tokens are split
exactly where the shell would split them. */
for (i = result_index = size = 0, result = (char **)NULL; string[i]; )
@ -1298,7 +1432,7 @@ history_tokenize_internal (string, wind, indp)
continue;
}
if (!delimiter && (member (string[i], HISTORY_WORD_DELIMITERS)))
if (!delimiter && (member (string[i], history_word_delimiters)))
break;
if (!delimiter && member (string[i], HISTORY_QUOTE_CHARACTERS))
@ -1315,7 +1449,7 @@ history_tokenize_internal (string, wind, indp)
len = i - start;
if (result_index + 2 >= size)
result = (char **)xrealloc (result, ((size += 10) * sizeof (char *)));
result[result_index] = xmalloc (1 + len);
result[result_index] = (char *)xmalloc (1 + len);
strncpy (result[result_index], string + start, len);
result[result_index][len] = '\0';
result[++result_index] = (char *)NULL;
@ -1328,7 +1462,7 @@ history_tokenize_internal (string, wind, indp)
parsed out of STRING. */
char **
history_tokenize (string)
char *string;
const char *string;
{
return (history_tokenize_internal (string, -1, (int *)NULL));
}
@ -1345,7 +1479,7 @@ history_find_word (line, ind)
int i, wind;
words = history_tokenize_internal (line, ind, &wind);
if (wind == -1)
if (wind == -1 || words == 0)
return ((char *)NULL);
s = words[wind];
for (i = 0; i < wind; i++)

View File

@ -48,12 +48,26 @@
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#if defined (__EMX__) || defined (__CYGWIN__)
# undef HAVE_MMAP
#endif
#ifdef HAVE_MMAP
# include <sys/mman.h>
# ifdef MAP_FILE
# define MAP_RFLAGS (MAP_FILE|MAP_PRIVATE)
# define MAP_WFLAGS (MAP_FILE|MAP_SHARED)
# else
# define MAP_RFLAGS MAP_PRIVATE
# define MAP_WFLAGS MAP_SHARED
# endif
# ifndef MAP_FAILED
# define MAP_FAILED ((void *)-1)
# endif
#endif /* HAVE_MMAP */
/* If we're compiling for __EMX__ (OS/2) or __CYGWIN__ (cygwin32 environment
on win 95/98/nt), we want to open files with O_BINARY mode so that there
@ -84,9 +98,10 @@ extern int errno;
filename to read_history (), or write_history (). */
static char *
history_filename (filename)
char *filename;
const char *filename;
{
char *return_val, *home;
char *return_val;
const char *home;
int home_len;
return_val = filename ? savestring (filename) : (char *)NULL;
@ -94,7 +109,7 @@ history_filename (filename)
if (return_val)
return (return_val);
home = get_env_value ("HOME");
home = sh_get_env_value ("HOME");
if (home == 0)
{
@ -104,7 +119,7 @@ history_filename (filename)
else
home_len = strlen (home);
return_val = xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
return_val = (char *)xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
strcpy (return_val, home);
return_val[home_len] = '/';
#if defined (__MSDOS__)
@ -121,7 +136,7 @@ history_filename (filename)
successful, or errno if not. */
int
read_history (filename)
char *filename;
const char *filename;
{
return (read_history_range (filename, 0, -1));
}
@ -133,11 +148,11 @@ read_history (filename)
~/.history. Returns 0 if successful, or errno if not. */
int
read_history_range (filename, from, to)
char *filename;
const char *filename;
int from, to;
{
register int line_start, line_end;
char *input, *buffer;
register char *line_start, *line_end;
char *input, *buffer, *bufend;
int file, current_line, chars_read;
struct stat finfo;
size_t file_size;
@ -156,23 +171,39 @@ read_history_range (filename, from, to)
{
#if defined (EFBIG)
errno = EFBIG;
#elif defined (EOVERFLOW)
errno = EOVERFLOW;
#endif
goto error_and_exit;
}
buffer = xmalloc (file_size + 1);
#ifdef HAVE_MMAP
/* We map read/write and private so we can change newlines to NULs without
affecting the underlying object. */
buffer = (char *)mmap (0, file_size, PROT_READ|PROT_WRITE, MAP_RFLAGS, file, 0);
if ((void *)buffer == MAP_FAILED)
goto error_and_exit;
chars_read = file_size;
#else
buffer = (char *)malloc (file_size + 1);
if (buffer == 0)
goto error_and_exit;
chars_read = read (file, buffer, file_size);
#endif
if (chars_read < 0)
{
error_and_exit:
chars_read = errno;
if (file >= 0)
close (file);
FREE (input);
#ifndef HAVE_MMAP
FREE (buffer);
#endif
return (errno);
return (chars_read);
}
close (file);
@ -182,29 +213,25 @@ read_history_range (filename, from, to)
to = chars_read;
/* Start at beginning of file, work to end. */
line_start = line_end = current_line = 0;
bufend = buffer + chars_read;
current_line = 0;
/* Skip lines until we are at FROM. */
while (line_start < chars_read && current_line < from)
{
for (line_end = line_start; line_end < chars_read; line_end++)
if (buffer[line_end] == '\n')
{
current_line++;
line_start = line_end + 1;
if (current_line == from)
break;
}
}
for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
if (*line_end == '\n')
{
current_line++;
line_start = line_end + 1;
}
/* If there are lines left to gobble, then gobble them now. */
for (line_end = line_start; line_end < chars_read; line_end++)
if (buffer[line_end] == '\n')
for (line_end = line_start; line_end < bufend; line_end++)
if (*line_end == '\n')
{
buffer[line_end] = '\0';
*line_end = '\0';
if (buffer[line_start])
add_history (buffer + line_start);
if (*line_start)
add_history (line_start);
current_line++;
@ -215,34 +242,52 @@ read_history_range (filename, from, to)
}
FREE (input);
#ifndef HAVE_MMAP
FREE (buffer);
#else
munmap (buffer, file_size);
#endif
return (0);
}
/* Truncate the history file FNAME, leaving only LINES trailing lines.
If FNAME is NULL, then use ~/.history. */
If FNAME is NULL, then use ~/.history. Returns 0 on success, errno
on failure. */
int
history_truncate_file (fname, lines)
char *fname;
const char *fname;
int lines;
{
register int i;
int file, chars_read;
char *buffer, *filename;
char *buffer, *filename, *bp;
int file, chars_read, rv;
struct stat finfo;
size_t file_size;
buffer = (char *)NULL;
filename = history_filename (fname);
file = open (filename, O_RDONLY|O_BINARY, 0666);
if (file == -1 || fstat (file, &finfo) == -1)
goto truncate_exit;
rv = 0;
/* Don't try to truncate non-regular files. */
if (S_ISREG(finfo.st_mode) == 0)
goto truncate_exit;
if (file == -1 || fstat (file, &finfo) == -1)
{
rv = errno;
if (file != -1)
close (file);
goto truncate_exit;
}
if (S_ISREG (finfo.st_mode) == 0)
{
close (file);
#ifdef EFTYPE
rv = EFTYPE;
#else
rv = EINVAL;
#endif
goto truncate_exit;
}
file_size = (size_t)finfo.st_size;
@ -251,23 +296,36 @@ history_truncate_file (fname, lines)
{
close (file);
#if defined (EFBIG)
errno = EFBIG;
rv = errno = EFBIG;
#elif defined (EOVERFLOW)
rv = errno = EOVERFLOW;
#else
rv = errno = EINVAL;
#endif
goto truncate_exit;
}
buffer = xmalloc (file_size + 1);
buffer = (char *)malloc (file_size + 1);
if (buffer == 0)
{
close (file);
goto truncate_exit;
}
chars_read = read (file, buffer, file_size);
close (file);
if (chars_read <= 0)
goto truncate_exit;
{
rv = (chars_read < 0) ? errno : 0;
goto truncate_exit;
}
/* Count backwards from the end of buffer until we have passed
LINES lines. */
for (i = chars_read - 1; lines && i; i--)
for (bp = buffer + chars_read - 1; lines && bp > buffer; bp--)
{
if (buffer[i] == '\n')
if (*bp == '\n')
lines--;
}
@ -276,22 +334,22 @@ history_truncate_file (fname, lines)
anything. It's the first line if we don't find a newline between
the current value of i and 0. Otherwise, write from the start of
this line until the end of the buffer. */
for ( ; i; i--)
if (buffer[i] == '\n')
for ( ; bp > buffer; bp--)
if (*bp == '\n')
{
i++;
bp++;
break;
}
/* Write only if there are more lines in the file than we want to
truncate to. */
if (i && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
if (bp > buffer && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
{
write (file, buffer + i, chars_read - i);
write (file, bp, chars_read - (bp - buffer));
#if defined (__BEOS__)
/* BeOS ignores O_TRUNC. */
ftruncate (file, chars_read - i);
ftruncate (file, chars_read - (bp - buffer));
#endif
close (file);
@ -302,7 +360,7 @@ history_truncate_file (fname, lines)
FREE (buffer);
free (filename);
return 0;
return rv;
}
/* Workhorse function for writing history. Writes NELEMENT entries
@ -310,15 +368,21 @@ history_truncate_file (fname, lines)
wish to replace FILENAME with the entries. */
static int
history_do_write (filename, nelements, overwrite)
char *filename;
const char *filename;
int nelements, overwrite;
{
register int i;
char *output;
int file, mode;
int file, mode, rv;
size_t cursize;
#ifdef HAVE_MMAP
mode = overwrite ? O_RDWR|O_CREAT|O_TRUNC|O_BINARY : O_RDWR|O_APPEND|O_BINARY;
#else
mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
#endif
output = history_filename (filename);
rv = 0;
if ((file = open (output, mode, 0600)) == -1)
{
@ -326,6 +390,10 @@ history_do_write (filename, nelements, overwrite)
return (errno);
}
#ifdef HAVE_MMAP
cursize = overwrite ? 0 : lseek (file, 0, SEEK_END);
#endif
if (nelements > history_length)
nelements = history_length;
@ -343,7 +411,28 @@ history_do_write (filename, nelements, overwrite)
buffer_size += 1 + strlen (the_history[i]->line);
/* Allocate the buffer, and fill it. */
buffer = xmalloc (buffer_size);
#ifdef HAVE_MMAP
if (ftruncate (file, buffer_size+cursize) == -1)
goto mmap_error;
buffer = (char *)mmap (0, buffer_size, PROT_READ|PROT_WRITE, MAP_WFLAGS, file, cursize);
if ((void *)buffer == MAP_FAILED)
{
mmap_error:
rv = errno;
FREE (output);
close (file);
return rv;
}
#else
buffer = (char *)malloc (buffer_size);
if (buffer == 0)
{
rv = errno;
FREE (output);
close (file);
return rv;
}
#endif
for (j = 0, i = history_length - nelements; i < history_length; i++)
{
@ -352,15 +441,21 @@ history_do_write (filename, nelements, overwrite)
buffer[j++] = '\n';
}
write (file, buffer, buffer_size);
#ifdef HAVE_MMAP
if (msync (buffer, buffer_size, 0) != 0 || munmap (buffer, buffer_size) != 0)
rv = errno;
#else
if (write (file, buffer, buffer_size) < 0)
rv = errno;
free (buffer);
#endif
}
close (file);
FREE (output);
return (0);
return (rv);
}
/* Append NELEMENT entries to FILENAME. The entries appended are from
@ -368,7 +463,7 @@ history_do_write (filename, nelements, overwrite)
int
append_history (nelements, filename)
int nelements;
char *filename;
const char *filename;
{
return (history_do_write (filename, nelements, HISTORY_APPEND));
}
@ -378,7 +473,7 @@ append_history (nelements, filename)
are as in read_history ().*/
int
write_history (filename)
char *filename;
const char *filename;
{
return (history_do_write (filename, history_length, HISTORY_OVERWRITE));
}

View File

@ -22,14 +22,11 @@
#if !defined (_HISTLIB_H_)
#define _HISTLIB_H_
/* Function pointers can be declared as (Function *)foo. */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif /* _FUNCTION_DEF */
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#if !defined (STREQ)
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
@ -38,9 +35,6 @@ typedef char **CPPFunction ();
#endif
#ifndef savestring
# ifndef strcpy
extern char *strcpy ();
# endif
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#endif

View File

@ -44,12 +44,6 @@
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "history.h"
#include "histlib.h"
@ -71,9 +65,13 @@ static HIST_ENTRY **the_history = (HIST_ENTRY **)NULL;
history that we save. */
static int history_stifled;
/* The current number of slots allocated to the input_history. */
static int history_size;
/* If HISTORY_STIFLED is non-zero, then this is the maximum number of
entries to remember. */
int max_input_history;
int history_max_entries;
int max_input_history; /* backwards compatibility */
/* The current location of the interactive history pointer. Just makes
life easier for outside callers. */
@ -82,9 +80,6 @@ int history_offset;
/* The number of strings currently stored in the history list. */
int history_length;
/* The current number of slots allocated to the input_history. */
static int history_size;
/* The logical `base' of the history array. It defaults to 1. */
int history_base = 1;
@ -134,9 +129,7 @@ history_total_bytes ()
{
register int i, result;
result = 0;
for (i = 0; the_history && the_history[i]; i++)
for (i = result = 0; the_history && the_history[i]; i++)
result += strlen (the_history[i]->line);
return (result);
@ -217,16 +210,16 @@ history_get (offset)
is set to NULL. */
void
add_history (string)
char *string;
const char *string;
{
HIST_ENTRY *temp;
if (history_stifled && (history_length == max_input_history))
if (history_stifled && (history_length == history_max_entries))
{
register int i;
/* If the history is stifled, and history_length is zero,
and it equals max_input_history, we don't save items. */
and it equals history_max_entries, we don't save items. */
if (history_length == 0)
return;
@ -277,15 +270,15 @@ add_history (string)
HIST_ENTRY *
replace_history_entry (which, line, data)
int which;
char *line;
const char *line;
histdata_t data;
{
HIST_ENTRY *temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
HIST_ENTRY *old_value;
HIST_ENTRY *temp, *old_value;
if (which >= history_length)
return ((HIST_ENTRY *)NULL);
temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
old_value = the_history[which];
temp->line = savestring (line);
@ -303,12 +296,12 @@ remove_history (which)
int which;
{
HIST_ENTRY *return_value;
register int i;
if (which >= history_length || !history_length)
return_value = (HIST_ENTRY *)NULL;
else
{
register int i;
return_value = the_history[which];
for (i = which; i < history_length; i++)
@ -325,13 +318,13 @@ void
stifle_history (max)
int max;
{
register int i, j;
if (max < 0)
max = 0;
if (history_length > max)
{
register int i, j;
/* This loses because we cannot free the data. */
for (i = 0, j = history_length - max; i < j; i++)
{
@ -347,22 +340,22 @@ stifle_history (max)
}
history_stifled = 1;
max_input_history = max;
max_input_history = history_max_entries = max;
}
/* Stop stifling the history. This returns the previous amount the
history was stifled by. The value is positive if the history was
stifled, negative if it wasn't. */
/* Stop stifling the history. This returns the previous maximum
number of history entries. The value is positive if the history
was stifled, negative if it wasn't. */
int
unstifle_history ()
{
if (history_stifled)
{
history_stifled = 0;
return (-max_input_history);
return (history_max_entries);
}
return (max_input_history);
else
return (-history_max_entries);
}
int

View File

@ -28,16 +28,10 @@ extern "C" {
#if defined READLINE_LIBRARY
# include "rlstdc.h"
# include "rltypedefs.h"
#else
# include <readline/rlstdc.h>
#endif
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
# include <readline/rltypedefs.h>
#endif
#ifdef __STDC__
@ -68,81 +62,81 @@ typedef struct _hist_state {
/* Begin a session in which the history functions might be used. This
just initializes the interactive variables. */
extern void using_history __P((void));
extern void using_history PARAMS((void));
/* Return the current HISTORY_STATE of the history. */
extern HISTORY_STATE *history_get_history_state __P((void));
extern HISTORY_STATE *history_get_history_state PARAMS((void));
/* Set the state of the current history array to STATE. */
extern void history_set_history_state __P((HISTORY_STATE *));
extern void history_set_history_state PARAMS((HISTORY_STATE *));
/* Manage the history list. */
/* Place STRING at the end of the history list.
The associated data field (if any) is set to NULL. */
extern void add_history __P((char *));
extern void add_history PARAMS((const char *));
/* A reasonably useless function, only here for completeness. WHICH
is the magic number that tells us which element to delete. The
elements are numbered from 0. */
extern HIST_ENTRY *remove_history __P((int));
extern HIST_ENTRY *remove_history PARAMS((int));
/* Make the history entry at WHICH have LINE and DATA. This returns
the old entry so you can dispose of the data. In the case of an
invalid WHICH, a NULL pointer is returned. */
extern HIST_ENTRY *replace_history_entry __P((int, char *, histdata_t));
extern HIST_ENTRY *replace_history_entry PARAMS((int, const char *, histdata_t));
/* Clear the history list and start over. */
extern void clear_history __P((void));
extern void clear_history PARAMS((void));
/* Stifle the history list, remembering only MAX number of entries. */
extern void stifle_history __P((int));
extern void stifle_history PARAMS((int));
/* Stop stifling the history. This returns the previous amount the
history was stifled by. The value is positive if the history was
stifled, negative if it wasn't. */
extern int unstifle_history __P((void));
extern int unstifle_history PARAMS((void));
/* Return 1 if the history is stifled, 0 if it is not. */
extern int history_is_stifled __P((void));
extern int history_is_stifled PARAMS((void));
/* Information about the history list. */
/* Return a NULL terminated array of HIST_ENTRY which is the current input
history. Element 0 of this list is the beginning of time. If there
is no history, return NULL. */
extern HIST_ENTRY **history_list __P((void));
extern HIST_ENTRY **history_list PARAMS((void));
/* Returns the number which says what history element we are now
looking at. */
extern int where_history __P((void));
extern int where_history PARAMS((void));
/* Return the history entry at the current position, as determined by
history_offset. If there is no entry there, return a NULL pointer. */
extern HIST_ENTRY *current_history __P((void));
extern HIST_ENTRY *current_history PARAMS((void));
/* Return the history entry which is logically at OFFSET in the history
array. OFFSET is relative to history_base. */
extern HIST_ENTRY *history_get __P((int));
extern HIST_ENTRY *history_get PARAMS((int));
/* Return the number of bytes that the primary history entries are using.
This just adds up the lengths of the_history->lines. */
extern int history_total_bytes __P((void));
extern int history_total_bytes PARAMS((void));
/* Moving around the history list. */
/* Set the position in the history list to POS. */
extern int history_set_pos __P((int));
extern int history_set_pos PARAMS((int));
/* Back up history_offset to the previous history entry, and return
a pointer to that entry. If there is no previous entry, return
a NULL pointer. */
extern HIST_ENTRY *previous_history __P((void));
extern HIST_ENTRY *previous_history PARAMS((void));
/* Move history_offset forward to the next item in the input_history,
and return the a pointer to that entry. If there is no next entry,
return a NULL pointer. */
extern HIST_ENTRY *next_history __P((void));
extern HIST_ENTRY *next_history PARAMS((void));
/* Searching the history list. */
@ -152,45 +146,45 @@ extern HIST_ENTRY *next_history __P((void));
current_history () is the history entry, and the value of this function
is the offset in the line of that history entry that the string was
found in. Otherwise, nothing is changed, and a -1 is returned. */
extern int history_search __P((char *, int));
extern int history_search PARAMS((const char *, int));
/* Search the history for STRING, starting at history_offset.
The search is anchored: matching lines must begin with string.
DIRECTION is as in history_search(). */
extern int history_search_prefix __P((char *, int));
extern int history_search_prefix PARAMS((const char *, int));
/* Search for STRING in the history list, starting at POS, an
absolute index into the list. DIR, if negative, says to search
backwards from POS, else forwards.
Returns the absolute index of the history element where STRING
was found, or -1 otherwise. */
extern int history_search_pos __P((char *, int, int));
extern int history_search_pos PARAMS((const char *, int, int));
/* Managing the history file. */
/* Add the contents of FILENAME to the history list, a line at a time.
If FILENAME is NULL, then read from ~/.history. Returns 0 if
successful, or errno if not. */
extern int read_history __P((char *));
extern int read_history PARAMS((const char *));
/* Read a range of lines from FILENAME, adding them to the history list.
Start reading at the FROM'th line and end at the TO'th. If FROM
is zero, start at the beginning. If TO is less than FROM, read
until the end of the file. If FILENAME is NULL, then read from
~/.history. Returns 0 if successful, or errno if not. */
extern int read_history_range __P((char *, int, int));
extern int read_history_range PARAMS((const char *, int, int));
/* Write the current history to FILENAME. If FILENAME is NULL,
then write the history list to ~/.history. Values returned
are as in read_history (). */
extern int write_history __P((char *));
extern int write_history PARAMS((const char *));
/* Append NELEMENT entries to FILENAME. The entries appended are from
the end of the list minus NELEMENTs up to the end of the list. */
extern int append_history __P((int, char *));
extern int append_history PARAMS((int, const char *));
/* Truncate the history file, leaving only the last NLINES lines. */
extern int history_truncate_file __P((char *, int));
extern int history_truncate_file PARAMS((const char *, int));
/* History expansion. */
@ -206,12 +200,12 @@ extern int history_truncate_file __P((char *, int));
If an error ocurred in expansion, then OUTPUT contains a descriptive
error message. */
extern int history_expand __P((char *, char **));
extern int history_expand PARAMS((char *, char **));
/* Extract a string segment consisting of the FIRST through LAST
arguments present in STRING. Arguments are broken up as in
the shell. */
extern char *history_arg_extract __P((int, int, char *));
extern char *history_arg_extract PARAMS((int, int, const char *));
/* Return the text of the history event beginning at the current
offset into STRING. Pass STRING with *INDEX equal to the
@ -219,27 +213,31 @@ extern char *history_arg_extract __P((int, int, char *));
DELIMITING_QUOTE is a character that is allowed to end the string
specification for what to search for in addition to the normal
characters `:', ` ', `\t', `\n', and sometimes `?'. */
extern char *get_history_event __P((char *, int *, int));
extern char *get_history_event PARAMS((const char *, int *, int));
/* Return an array of tokens, much as the shell might. The tokens are
parsed out of STRING. */
extern char **history_tokenize __P((char *));
extern char **history_tokenize PARAMS((const char *));
/* Exported history variables. */
extern int history_base;
extern int history_length;
extern int max_input_history;
extern int history_max_entries;
extern char history_expansion_char;
extern char history_subst_char;
extern char *history_word_delimiters;
extern char history_comment_char;
extern char *history_no_expand_chars;
extern char *history_search_delimiter_chars;
extern int history_quotes_inhibit_expansion;
/* Backwards compatibility */
extern int max_input_history;
/* If set, this function is called to decide whether or not a particular
history expansion should be treated as a special case for the calling
application and not expanded. */
extern Function *history_inhibit_expansion_function;
extern rl_linebuf_func_t *history_inhibit_expansion_function;
#ifdef __cplusplus
}

View File

@ -32,17 +32,13 @@
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#if defined (HAVE_STRING_H)
# include <string.h>
#else
# include <strings.h>
#endif /* !HAVE_STRING_H */
#include "history.h"
#include "histlib.h"
@ -51,6 +47,8 @@
string. */
char *history_search_delimiter_chars = (char *)NULL;
static int history_search_internal PARAMS((const char *, int, int));
/* Search the history for STRING, starting at history_offset.
If DIRECTION < 0, then the search is through previous entries, else
through subsequent. If ANCHORED is non-zero, the string must
@ -63,7 +61,7 @@ char *history_search_delimiter_chars = (char *)NULL;
static int
history_search_internal (string, direction, anchored)
char *string;
const char *string;
int direction, anchored;
{
register int i, reverse;
@ -159,7 +157,7 @@ history_search_internal (string, direction, anchored)
/* Do a non-anchored search for STRING through the history in DIRECTION. */
int
history_search (string, direction)
char *string;
const char *string;
int direction;
{
return (history_search_internal (string, direction, NON_ANCHORED_SEARCH));
@ -168,7 +166,7 @@ history_search (string, direction)
/* Do an anchored search for string through the history in DIRECTION. */
int
history_search_prefix (string, direction)
char *string;
const char *string;
int direction;
{
return (history_search_internal (string, direction, ANCHORED_SEARCH));
@ -179,7 +177,7 @@ history_search_prefix (string, direction)
which point to begin searching. */
int
history_search_pos (string, dir, pos)
char *string;
const char *string;
int dir, pos;
{
int ret, old;

View File

@ -63,6 +63,7 @@ extern int errno;
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
/* Some standard library routines. */
#include "readline.h"
@ -78,9 +79,15 @@ extern int errno;
/* Non-null means it is a pointer to a function to run while waiting for
character input. */
Function *rl_event_hook = (Function *)NULL;
rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL;
Function *rl_getc_function = rl_getc;
rl_getc_func_t *rl_getc_function = rl_getc;
static int _keyboard_input_timeout = 100000; /* 0.1 seconds; it's in usec */
static int ibuffer_space PARAMS((void));
static int rl_get_char PARAMS((int *));
static int rl_gather_tyi PARAMS((void));
/* **************************************************************** */
/* */
@ -132,8 +139,8 @@ rl_get_char (key)
/* Stuff KEY into the *front* of the input buffer.
Returns non-zero if successful, zero if there is
no space left in the buffer. */
static int
rl_unget_char (key)
int
_rl_unget_char (key)
int key;
{
if (ibuffer_space ())
@ -147,9 +154,10 @@ rl_unget_char (key)
return (0);
}
/* If a character is available to be read, then read it
and stuff it into IBUFFER. Otherwise, just return. */
static void
/* If a character is available to be read, then read it and stuff it into
IBUFFER. Otherwise, just return. Returns number of characters read
(0 if none available) and -1 on error (EIO). */
static int
rl_gather_tyi ()
{
int tty;
@ -169,14 +177,18 @@ rl_gather_tyi ()
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
timeout.tv_sec = 0;
timeout.tv_usec = 100000; /* 0.1 seconds */
if (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) <= 0)
return; /* Nothing to read. */
timeout.tv_usec = _keyboard_input_timeout;
result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
if (result <= 0)
return 0; /* Nothing to read. */
#endif
result = -1;
#if defined (FIONREAD)
errno = 0;
result = ioctl (tty, FIONREAD, &chars_avail);
if (result == -1 && errno == EIO)
return -1;
#endif
#if defined (O_NDELAY)
@ -189,14 +201,14 @@ rl_gather_tyi ()
fcntl (tty, F_SETFL, tem);
if (chars_avail == -1 && errno == EAGAIN)
return;
return 0;
}
#endif /* O_NDELAY */
/* If there's nothing available, don't waste time trying to read
something. */
if (chars_avail <= 0)
return;
return 0;
tem = ibuffer_space ();
@ -220,10 +232,28 @@ rl_gather_tyi ()
if (chars_avail)
rl_stuff_char (input);
}
return 1;
}
int
rl_set_keyboard_input_timeout (u)
int u;
{
int o;
o = _keyboard_input_timeout;
if (u > 0)
_keyboard_input_timeout = u;
return (o);
}
/* Is there input available to be read on the readline input file
descriptor? Only works if the system has select(2) or FIONREAD. */
descriptor? Only works if the system has select(2) or FIONREAD.
Uses the value of _keyboard_input_timeout as the timeout; if another
readline function wants to specify a timeout and not leave it up to
the user, it should use _rl_input_queued(timeout_value_in_microseconds)
instead. */
int
_rl_input_available ()
{
@ -231,7 +261,7 @@ _rl_input_available ()
fd_set readfds, exceptfds;
struct timeval timeout;
#endif
#if defined(FIONREAD)
#if !defined (HAVE_SELECT) && defined(FIONREAD)
int chars_avail;
#endif
int tty;
@ -244,18 +274,32 @@ _rl_input_available ()
FD_SET (tty, &readfds);
FD_SET (tty, &exceptfds);
timeout.tv_sec = 0;
timeout.tv_usec = 100000; /* 0.1 seconds */
timeout.tv_usec = _keyboard_input_timeout;
return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
#endif
#else
#if defined (FIONREAD)
if (ioctl (tty, FIONREAD, &chars_avail) == 0)
return (chars_avail);
#endif
#endif
return 0;
}
int
_rl_input_queued (t)
int t;
{
int old_timeout, r;
old_timeout = rl_set_keyboard_input_timeout (t);
r = _rl_input_available ();
rl_set_keyboard_input_timeout (old_timeout);
return r;
}
void
_rl_insert_typein (c)
int c;
@ -264,7 +308,7 @@ _rl_insert_typein (c)
char *string;
i = key = 0;
string = xmalloc (ibuffer_len + 1);
string = (char *)xmalloc (ibuffer_len + 1);
string[i++] = (char) c;
while ((t = rl_get_char (&key)) &&
@ -273,7 +317,7 @@ _rl_insert_typein (c)
string[i++] = key;
if (t)
rl_unget_char (key);
_rl_unget_char (key);
string[i] = '\0';
rl_insert_text (string);
@ -293,6 +337,7 @@ rl_stuff_char (key)
{
key = NEWLINE;
rl_pending_input = EOF;
RL_SETSTATE (RL_STATE_INPUTPENDING);
}
ibuffer[push_index++] = key;
if (push_index >= ibuffer_len)
@ -307,6 +352,16 @@ rl_execute_next (c)
int c;
{
rl_pending_input = c;
RL_SETSTATE (RL_STATE_INPUTPENDING);
return 0;
}
/* Clear any pending input pushed with rl_execute_next() */
int
rl_clear_pending_input ()
{
rl_pending_input = 0;
RL_UNSETSTATE (RL_STATE_INPUTPENDING);
return 0;
}
@ -327,7 +382,7 @@ rl_read_key ()
if (rl_pending_input)
{
c = rl_pending_input;
rl_pending_input = 0;
rl_clear_pending_input ();
}
else
{
@ -341,7 +396,13 @@ rl_read_key ()
while (rl_event_hook && rl_get_char (&c) == 0)
{
(*rl_event_hook) ();
rl_gather_tyi ();
if (rl_done) /* XXX - experimental */
return ('\n');
if (rl_gather_tyi () < 0) /* XXX - EIO */
{
rl_done = 1;
return ('\n');
}
}
}
else
@ -392,7 +453,7 @@ rl_getc (stream)
if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
{
if (unset_nodelay_mode (fileno (stream)) < 0)
if (sh_unset_nodelay_mode (fileno (stream)) < 0)
return (EOF);
continue;
}
@ -407,3 +468,73 @@ rl_getc (stream)
return (EOF);
}
}
#if defined (HANDLE_MULTIBYTE)
/* read multibyte char */
int
_rl_read_mbchar (mbchar, size)
char *mbchar;
int size;
{
int mb_len = 0;
size_t mbchar_bytes_length;
wchar_t wc;
mbstate_t ps, ps_back;
memset(&ps, 0, sizeof (mbstate_t));
memset(&ps_back, 0, sizeof (mbstate_t));
while (mb_len < size)
{
RL_SETSTATE(RL_STATE_MOREINPUT);
mbchar[mb_len++] = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
if (mbchar_bytes_length == (size_t)(-1))
break; /* invalid byte sequence for the current locale */
else if (mbchar_bytes_length == (size_t)(-2))
{
/* shorted bytes */
ps = ps_back;
continue;
}
else if (mbchar_bytes_length > (size_t)(0))
break;
}
return mb_len;
}
/* Read a multibyte-character string whose first character is FIRST into
the buffer MB of length MBLEN. Returns the last character read, which
may be FIRST. Used by the search functions, among others. Very similar
to _rl_read_mbchar. */
int
_rl_read_mbstring (first, mb, mblen)
int first;
char *mb;
int mblen;
{
int i, c;
mbstate_t ps;
c = first;
memset (mb, 0, mblen);
for (i = 0; i < mblen; i++)
{
mb[i] = (char)c;
memset (&ps, 0, sizeof (mbstate_t));
if (_rl_get_char_len (mb, &ps) == -2)
{
/* Read more for multibyte character */
RL_SETSTATE (RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE (RL_STATE_MOREINPUT);
}
else
break;
}
return c;
}
#endif /* HANDLE_MULTIBYTE */

View File

@ -4,7 +4,7 @@
/* */
/* **************************************************************** */
/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file contains the Readline Library (the Library), a set of
routines for providing Emacs style line input to programs that ask
@ -45,6 +45,8 @@
#endif
#include "rldefs.h"
#include "rlmbutil.h"
#include "readline.h"
#include "history.h"
@ -52,18 +54,24 @@
#include "xmalloc.h"
/* Variables exported to other files in the readline library. */
unsigned char *_rl_isearch_terminators = (unsigned char *)NULL;
char *_rl_isearch_terminators = (char *)NULL;
/* Variables imported from other files in the readline library. */
extern HIST_ENTRY *saved_line_for_history;
extern HIST_ENTRY *_rl_saved_line_for_history;
/* Forward declarations */
static int rl_search_history __P((int, int));
static int rl_search_history PARAMS((int, int));
/* Last line found by the current incremental search, so we don't `find'
identical lines many times in a row. */
static char *prev_line_found;
/* Last search string and its length. */
static char *last_isearch_string;
static int last_isearch_string_len;
static char *default_isearch_terminators = "\033\012";
/* Search backwards through the history looking for a string which is typed
interactively. Start with the current line. */
int
@ -97,7 +105,7 @@ rl_display_search (search_string, reverse_p, where)
searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
message = xmalloc (searchlen + 33);
message = (char *)xmalloc (searchlen + 33);
msglen = 0;
#if defined (NOTDEF)
@ -127,7 +135,7 @@ rl_display_search (search_string, reverse_p, where)
strcpy (message + msglen, "': ");
rl_message ("%s", message, 0);
rl_message ("%s", message);
free (message);
(*rl_redisplay_function) ();
}
@ -159,8 +167,12 @@ rl_search_history (direction, invoking_key)
HIST_ENTRY **hlist;
register int i;
int orig_point, orig_line, last_found_line;
int orig_point, orig_mark, orig_line, last_found_line;
int c, found, failed, sline_len;
int n, wstart, wlen;
#if defined (HANDLE_MULTIBYTE)
char mb[MB_LEN_MAX];
#endif
/* The line currently being searched. */
char *sline;
@ -174,19 +186,21 @@ rl_search_history (direction, invoking_key)
/* The list of characters which terminate the search, but are not
subsequently executed. If the variable isearch-terminators has
been set, we use that value, otherwise we use ESC and C-J. */
unsigned char *isearch_terminators;
char *isearch_terminators;
RL_SETSTATE(RL_STATE_ISEARCH);
orig_point = rl_point;
orig_mark = rl_mark;
last_found_line = orig_line = where_history ();
reverse = direction < 0;
hlist = history_list ();
allocated_line = (char *)NULL;
isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
: (unsigned char *)"\033\012";
: default_isearch_terminators;
/* Create an arrary of pointers to the lines that we want to search. */
maybe_replace_line ();
rl_maybe_replace_line ();
i = 0;
if (hlist)
for (i = 0; hlist[i]; i++);
@ -197,12 +211,12 @@ rl_search_history (direction, invoking_key)
for (i = 0; i < hlen; i++)
lines[i] = hlist[i]->line;
if (saved_line_for_history)
lines[i] = saved_line_for_history->line;
if (_rl_saved_line_for_history)
lines[i] = _rl_saved_line_for_history->line;
else
{
/* Keep track of this so we can free it. */
allocated_line = xmalloc (1 + strlen (rl_line_buffer));
allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer));
strcpy (allocated_line, &rl_line_buffer[0]);
lines[i] = allocated_line;
}
@ -215,7 +229,7 @@ rl_search_history (direction, invoking_key)
rl_save_prompt ();
/* Initialize search parameters. */
search_string = xmalloc (search_string_size = 128);
search_string = (char *)xmalloc (search_string_size = 128);
*search_string = '\0';
search_string_index = 0;
prev_line_found = (char *)0; /* XXX */
@ -232,12 +246,20 @@ rl_search_history (direction, invoking_key)
found = failed = 0;
for (;;)
{
Function *f = (Function *)NULL;
rl_command_func_t *f = (rl_command_func_t *)NULL;
/* Read a key and decide how to proceed. */
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (_rl_keymap[c].type == ISFUNC)
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = _rl_read_mbstring (c, mb, MB_LEN_MAX);
#endif
/* Translate the keys we do something with to opcodes. */
if (c >= 0 && _rl_keymap[c].type == ISFUNC)
{
f = _rl_keymap[c].function;
@ -245,34 +267,56 @@ rl_search_history (direction, invoking_key)
c = reverse ? -1 : -2;
else if (f == rl_forward_search_history)
c = !reverse ? -1 : -2;
else if (f == rl_rubout)
c = -3;
else if (c == CTRL ('G'))
c = -4;
else if (c == CTRL ('W')) /* XXX */
c = -5;
else if (c == CTRL ('Y')) /* XXX */
c = -6;
}
#if 0
/* Let NEWLINE (^J) terminate the search for people who don't like
using ESC. ^M can still be used to terminate the search and
immediately execute the command. */
if (c == ESC || c == NEWLINE)
#else
/* The characters in isearch_terminators (set from the user-settable
variable isearch-terminators) are used to terminate the search but
not subsequently execute the character as a command. The default
value is "\033\012" (ESC and C-J). */
if (strchr (isearch_terminators, c))
#endif
{
/* ESC still terminates the search, but if there is pending
input or if input arrives within 0.1 seconds (on systems
with select(2)) it is used as a prefix character
with rl_execute_next. WATCH OUT FOR THIS! This is intended
to allow the arrow keys to be used like ^F and ^B are used
to terminate the search and execute the movement command. */
if (c == ESC && _rl_input_available ()) /* XXX */
to terminate the search and execute the movement command.
XXX - since _rl_input_available depends on the application-
settable keyboard timeout value, this could alternatively
use _rl_input_queued(100000) */
if (c == ESC && _rl_input_available ())
rl_execute_next (ESC);
break;
}
if (c >= 0 && (CTRL_CHAR (c) || META_CHAR (c) || c == RUBOUT) && c != CTRL ('G'))
#define ENDSRCH_CHAR(c) \
((CTRL_CHAR (c) || META_CHAR (c) || (c) == RUBOUT) && ((c) != CTRL ('G')))
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
if (c >= 0 && strlen (mb) == 1 && ENDSRCH_CHAR (c))
{
/* This sets rl_pending_input to c; it will be picked up the next
time rl_read_key is called. */
rl_execute_next (c);
break;
}
}
else
#endif
if (c >= 0 && ENDSRCH_CHAR (c))
{
/* This sets rl_pending_input to c; it will be picked up the next
time rl_read_key is called. */
rl_execute_next (c);
break;
}
@ -281,13 +325,24 @@ rl_search_history (direction, invoking_key)
{
case -1:
if (search_string_index == 0)
continue;
{
if (last_isearch_string)
{
search_string_size = 64 + last_isearch_string_len;
search_string = (char *)xrealloc (search_string, search_string_size);
strcpy (search_string, last_isearch_string);
search_string_index = last_isearch_string_len;
rl_display_search (search_string, reverse, -1);
break;
}
continue;
}
else if (reverse)
--line_index;
else if (line_index != sline_len)
++line_index;
else
ding ();
rl_ding ();
break;
/* switch directions */
@ -296,40 +351,96 @@ rl_search_history (direction, invoking_key)
reverse = direction < 0;
break;
case CTRL ('G'):
strcpy (rl_line_buffer, lines[orig_line]);
/* delete character from search string. */
case -3: /* C-H, DEL */
/* This is tricky. To do this right, we need to keep a
stack of search positions for the current search, with
sentinels marking the beginning and end. But this will
do until we have a real isearch-undo. */
if (search_string_index == 0)
rl_ding ();
else
search_string[--search_string_index] = '\0';
break;
case -4: /* C-G */
rl_replace_line (lines[orig_line], 0);
rl_point = orig_point;
rl_end = strlen (rl_line_buffer);
rl_mark = orig_mark;
rl_restore_prompt();
rl_clear_message ();
if (allocated_line)
free (allocated_line);
free (lines);
RL_UNSETSTATE(RL_STATE_ISEARCH);
return 0;
#if 0
/* delete character from search string. */
case -3:
if (search_string_index == 0)
ding ();
else
case -5: /* C-W */
/* skip over portion of line we already matched */
wstart = rl_point + search_string_index;
if (wstart >= rl_end)
{
search_string[--search_string_index] = '\0';
/* This is tricky. To do this right, we need to keep a
stack of search positions for the current search, with
sentinels marking the beginning and end. */
rl_ding ();
break;
}
/* if not in a word, move to one. */
if (rl_alphabetic(rl_line_buffer[wstart]) == 0)
{
rl_ding ();
break;
}
n = wstart;
while (n < rl_end && rl_alphabetic(rl_line_buffer[n]))
n++;
wlen = n - wstart + 1;
if (search_string_index + wlen + 1 >= search_string_size)
{
search_string_size += wlen + 1;
search_string = (char *)xrealloc (search_string, search_string_size);
}
for (; wstart < n; wstart++)
search_string[search_string_index++] = rl_line_buffer[wstart];
search_string[search_string_index] = '\0';
break;
case -6: /* C-Y */
/* skip over portion of line we already matched */
wstart = rl_point + search_string_index;
if (wstart >= rl_end)
{
rl_ding ();
break;
}
n = rl_end - wstart + 1;
if (search_string_index + n + 1 >= search_string_size)
{
search_string_size += n + 1;
search_string = (char *)xrealloc (search_string, search_string_size);
}
for (n = wstart; n < rl_end; n++)
search_string[search_string_index++] = rl_line_buffer[n];
search_string[search_string_index] = '\0';
break;
#endif
default:
/* Add character to search string and continue search. */
if (search_string_index + 2 >= search_string_size)
{
search_string_size += 128;
search_string = xrealloc (search_string, search_string_size);
search_string = (char *)xrealloc (search_string, search_string_size);
}
search_string[search_string_index++] = c;
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int j, l;
for (j = 0, l = strlen (mb); j < l; )
search_string[search_string_index++] = mb[j++];
}
else
#endif
search_string[search_string_index++] = c;
search_string[search_string_index] = '\0';
break;
}
@ -384,7 +495,7 @@ rl_search_history (direction, invoking_key)
if (failed)
{
/* We cannot find the search string. Ding the bell. */
ding ();
rl_ding ();
i = last_found_line;
continue; /* XXX - was break */
}
@ -394,17 +505,9 @@ rl_search_history (direction, invoking_key)
the location. */
if (found)
{
int line_len;
prev_line_found = lines[i];
line_len = strlen (lines[i]);
if (line_len >= rl_line_buffer_len)
rl_extend_line_buffer (line_len);
strcpy (rl_line_buffer, lines[i]);
rl_replace_line (lines[i], 0);
rl_point = line_index;
rl_end = line_len;
last_found_line = i;
rl_display_search (search_string, reverse, (i == orig_line) ? -1 : i);
}
@ -420,23 +523,38 @@ rl_search_history (direction, invoking_key)
rl_restore_prompt ();
/* Free the search string. */
free (search_string);
/* Save the search string for possible later use. */
FREE (last_isearch_string);
last_isearch_string = search_string;
last_isearch_string_len = search_string_index;
if (last_found_line < orig_line)
rl_get_previous_history (orig_line - last_found_line, 0);
else
rl_get_next_history (last_found_line - orig_line, 0);
/* If the string was not found, put point at the end of the line. */
/* If the string was not found, put point at the end of the last matching
line. If last_found_line == orig_line, we didn't find any matching
history lines at all, so put point back in its original position. */
if (line_index < 0)
line_index = strlen (rl_line_buffer);
{
if (last_found_line == orig_line)
line_index = orig_point;
else
line_index = strlen (rl_line_buffer);
rl_mark = orig_mark;
}
rl_point = line_index;
/* Don't worry about where to put the mark here; rl_get_previous_history
and rl_get_next_history take care of it. */
rl_clear_message ();
if (allocated_line)
free (allocated_line);
FREE (allocated_line);
free (lines);
RL_UNSETSTATE(RL_STATE_ISEARCH);
return 0;
}

View File

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

View File

@ -30,17 +30,11 @@ extern "C" {
#if defined (READLINE_LIBRARY)
# include "rlstdc.h"
# include "chardefs.h"
# include "rltypedefs.h"
#else
# include <readline/rlstdc.h>
# include <readline/chardefs.h>
#endif
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
# include <readline/rltypedefs.h>
#endif
/* A keymap contains one entry for each key in the ASCII set.
@ -50,16 +44,17 @@ typedef char **CPPFunction ();
TYPE says which kind of thing FUNCTION is. */
typedef struct _keymap_entry {
char type;
Function *function;
rl_command_func_t *function;
} KEYMAP_ENTRY;
/* This must be large enough to hold bindings for all of the characters
in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
and so on). */
#define KEYMAP_SIZE 256
and so on) plus one for subsequence matching. */
#define KEYMAP_SIZE 257
#define ANYOTHERKEY KEYMAP_SIZE-1
/* I wanted to make the above structure contain a union of:
union { Function *function; struct _keymap_entry *keymap; } value;
union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
but this made it impossible for me to create a static array.
Maybe I need C lessons. */
@ -76,30 +71,30 @@ extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
/* Return a new, empty keymap.
Free it with free() when you are done. */
extern Keymap rl_make_bare_keymap __P((void));
extern Keymap rl_make_bare_keymap PARAMS((void));
/* Return a new keymap which is a copy of MAP. */
extern Keymap rl_copy_keymap __P((Keymap));
extern Keymap rl_copy_keymap PARAMS((Keymap));
/* Return a new keymap with the printing characters bound to rl_insert,
the lowercase Meta characters bound to run their equivalents, and
the Meta digits bound to produce numeric arguments. */
extern Keymap rl_make_keymap __P((void));
extern Keymap rl_make_keymap PARAMS((void));
/* Free the storage associated with a keymap. */
extern void rl_discard_keymap __P((Keymap));
extern void rl_discard_keymap PARAMS((Keymap));
/* These functions actually appear in bind.c */
/* Return the keymap corresponding to a given name. Names look like
`emacs' or `emacs-meta' or `vi-insert'. */
extern Keymap rl_get_keymap_by_name __P((char *));
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
/* Return the current keymap. */
extern Keymap rl_get_keymap __P((void));
extern Keymap rl_get_keymap PARAMS((void));
/* Set the current keymap to MAP. */
extern void rl_set_keymap __P((Keymap));
extern void rl_set_keymap PARAMS((Keymap));
#ifdef __cplusplus
}

View File

@ -70,6 +70,11 @@ static int rl_kill_index;
/* How many slots we have in the kill ring. */
static int rl_kill_ring_length;
static int _rl_copy_to_kill_ring PARAMS((char *, int));
static int region_kill_internal PARAMS((int));
static int _rl_copy_word_as_kill PARAMS((int, int));
static int rl_yank_nth_arg_internal PARAMS((int, int, int));
/* How to say that you only want to save a certain amount
of kill material. */
int
@ -129,7 +134,7 @@ _rl_copy_to_kill_ring (text, append)
if (_rl_last_command_was_kill && rl_editing_mode != vi_mode)
{
old = rl_kill_ring[slot];
new = xmalloc (1 + strlen (old) + strlen (text));
new = (char *)xmalloc (1 + strlen (old) + strlen (text));
if (append)
{
@ -196,18 +201,21 @@ int
rl_kill_word (count, key)
int count, key;
{
int orig_point = rl_point;
int orig_point;
if (count < 0)
return (rl_backward_kill_word (-count, key));
else
{
orig_point = rl_point;
rl_forward_word (count, key);
if (rl_point != orig_point)
rl_kill_text (orig_point, rl_point);
rl_point = orig_point;
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
return 0;
}
@ -217,16 +225,20 @@ int
rl_backward_kill_word (count, ignore)
int count, ignore;
{
int orig_point = rl_point;
int orig_point;
if (count < 0)
return (rl_kill_word (-count, ignore));
else
{
orig_point = rl_point;
rl_backward_word (count, ignore);
if (rl_point != orig_point)
rl_kill_text (orig_point, rl_point);
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
return 0;
}
@ -237,16 +249,19 @@ int
rl_kill_line (direction, ignore)
int direction, ignore;
{
int orig_point = rl_point;
int orig_point;
if (direction < 0)
return (rl_backward_kill_line (1, ignore));
else
{
orig_point = rl_point;
rl_end_of_line (1, ignore);
if (orig_point != rl_point)
rl_kill_text (orig_point, rl_point);
rl_point = orig_point;
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
return 0;
}
@ -257,18 +272,22 @@ int
rl_backward_kill_line (direction, ignore)
int direction, ignore;
{
int orig_point = rl_point;
int orig_point;
if (direction < 0)
return (rl_kill_line (1, ignore));
else
{
if (!rl_point)
ding ();
rl_ding ();
else
{
orig_point = rl_point;
rl_beg_of_line (1, ignore);
rl_kill_text (orig_point, rl_point);
if (rl_point != orig_point)
rl_kill_text (orig_point, rl_point);
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
}
return 0;
@ -282,6 +301,7 @@ rl_kill_full_line (count, ignore)
rl_begin_undo_group ();
rl_point = 0;
rl_kill_text (rl_point, rl_end);
rl_mark = 0;
rl_end_undo_group ();
return 0;
}
@ -299,7 +319,7 @@ rl_unix_word_rubout (count, key)
int orig_point;
if (rl_point == 0)
ding ();
rl_ding ();
else
{
orig_point = rl_point;
@ -316,6 +336,8 @@ rl_unix_word_rubout (count, key)
}
rl_kill_text (orig_point, rl_point);
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
return 0;
}
@ -331,11 +353,13 @@ rl_unix_line_discard (count, key)
int count, key;
{
if (rl_point == 0)
ding ();
rl_ding ();
else
{
rl_kill_text (rl_point, 0);
rl_point = 0;
if (rl_editing_mode == emacs_mode)
rl_mark = rl_point;
}
return 0;
}
@ -348,17 +372,14 @@ region_kill_internal (delete)
{
char *text;
if (rl_mark == rl_point)
if (rl_mark != rl_point)
{
_rl_last_command_was_kill++;
return 0;
text = rl_copy_text (rl_point, rl_mark);
if (delete)
rl_delete_text (rl_point, rl_mark);
_rl_copy_to_kill_ring (text, rl_point < rl_mark);
}
text = rl_copy_text (rl_point, rl_mark);
if (delete)
rl_delete_text (rl_point, rl_mark);
_rl_copy_to_kill_ring (text, rl_point < rl_mark);
_rl_last_command_was_kill++;
return 0;
}
@ -512,19 +533,21 @@ rl_yank_nth_arg_internal (count, ignore, history_skip)
if (entry == 0)
{
ding ();
rl_ding ();
return -1;
}
arg = history_arg_extract (count, count, entry->line);
if (!arg || !*arg)
{
ding ();
rl_ding ();
return -1;
}
rl_begin_undo_group ();
_rl_set_mark_at_pos (rl_point);
#if defined (VI_MODE)
/* Vi mode always inserts a space before yanking the argument, and it
inserts it right *after* rl_point. */
@ -592,7 +615,7 @@ rl_yank_last_arg (count, key)
}
/* A special paste command for users of Cygnus's cygwin32. */
#if defined (__CYGWIN32__)
#if defined (__CYGWIN__)
#include <windows.h>
int
@ -612,12 +635,13 @@ rl_paste_from_clipboard (count, key)
if (ptr)
{
len = ptr - data;
ptr = xmalloc (len + 1);
ptr = (char *)xmalloc (len + 1);
ptr[len] = '\0';
strncpy (ptr, data, len);
}
else
ptr = data;
_rl_set_mark_at_pos (rl_point);
rl_insert_text (ptr);
if (ptr != data)
free (ptr);
@ -625,4 +649,4 @@ rl_paste_from_clipboard (count, key)
}
return (0);
}
#endif /* __CYGWIN32__ */
#endif /* __CYGWIN__ */

View File

@ -49,20 +49,15 @@
#include "rlprivate.h"
#include "xmalloc.h"
#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
/* **************************************************************** */
/* */
/* Hacking Keyboard Macros */
/* */
/* **************************************************************** */
/* Non-zero means to save keys that we dispatch on in a kbd macro. */
int _rl_defining_kbd_macro = 0;
/* The currently executing macro string. If this is non-zero,
then it is a malloc ()'ed string where input is coming from. */
char *_rl_executing_macro = (char *)NULL;
char *rl_executing_macro = (char *)NULL;
/* The offset in the above string to the next character to be read. */
static int executing_macro_index;
@ -95,8 +90,9 @@ _rl_with_macro_input (string)
char *string;
{
_rl_push_executing_macro ();
_rl_executing_macro = string;
rl_executing_macro = string;
executing_macro_index = 0;
RL_SETSTATE(RL_STATE_MACROINPUT);
}
/* Return the next character available from a macro, or 0 if
@ -104,16 +100,16 @@ _rl_with_macro_input (string)
int
_rl_next_macro_key ()
{
if (_rl_executing_macro == 0)
if (rl_executing_macro == 0)
return (0);
if (_rl_executing_macro[executing_macro_index] == 0)
if (rl_executing_macro[executing_macro_index] == 0)
{
_rl_pop_executing_macro ();
return (_rl_next_macro_key ());
}
return (_rl_executing_macro[executing_macro_index++]);
return (rl_executing_macro[executing_macro_index++]);
}
/* Save the currently executing macro on a stack of saved macros. */
@ -125,7 +121,7 @@ _rl_push_executing_macro ()
saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro));
saver->next = macro_list;
saver->sindex = executing_macro_index;
saver->string = _rl_executing_macro;
saver->string = rl_executing_macro;
macro_list = saver;
}
@ -137,20 +133,21 @@ _rl_pop_executing_macro ()
{
struct saved_macro *macro;
if (_rl_executing_macro)
free (_rl_executing_macro);
_rl_executing_macro = (char *)NULL;
FREE (rl_executing_macro);
rl_executing_macro = (char *)NULL;
executing_macro_index = 0;
if (macro_list)
{
macro = macro_list;
_rl_executing_macro = macro_list->string;
rl_executing_macro = macro_list->string;
executing_macro_index = macro_list->sindex;
macro_list = macro_list->next;
free (macro);
}
if (rl_executing_macro == 0)
RL_UNSETSTATE(RL_STATE_MACROINPUT);
}
/* Add a character to the macro being built. */
@ -161,9 +158,9 @@ _rl_add_macro_char (c)
if (current_macro_index + 1 >= current_macro_size)
{
if (current_macro == 0)
current_macro = xmalloc (current_macro_size = 25);
current_macro = (char *)xmalloc (current_macro_size = 25);
else
current_macro = xrealloc (current_macro, current_macro_size += 25);
current_macro = (char *)xrealloc (current_macro, current_macro_size += 25);
}
current_macro[current_macro_index++] = c;
@ -180,14 +177,11 @@ _rl_kill_kbd_macro ()
}
current_macro_size = current_macro_index = 0;
if (_rl_executing_macro)
{
free (_rl_executing_macro);
_rl_executing_macro = (char *) NULL;
}
FREE (rl_executing_macro);
rl_executing_macro = (char *) NULL;
executing_macro_index = 0;
_rl_defining_kbd_macro = 0;
RL_UNSETSTATE(RL_STATE_MACRODEF);
}
/* Begin defining a keyboard macro.
@ -200,7 +194,7 @@ int
rl_start_kbd_macro (ignore1, ignore2)
int ignore1, ignore2;
{
if (_rl_defining_kbd_macro)
if (RL_ISSTATE (RL_STATE_MACRODEF))
{
_rl_abort_internal ();
return -1;
@ -214,7 +208,7 @@ rl_start_kbd_macro (ignore1, ignore2)
else
current_macro_index = 0;
_rl_defining_kbd_macro = 1;
RL_SETSTATE(RL_STATE_MACRODEF);
return 0;
}
@ -225,7 +219,7 @@ int
rl_end_kbd_macro (count, ignore)
int count, ignore;
{
if (_rl_defining_kbd_macro == 0)
if (RL_ISSTATE (RL_STATE_MACRODEF) == 0)
{
_rl_abort_internal ();
return -1;
@ -234,7 +228,7 @@ rl_end_kbd_macro (count, ignore)
current_macro_index -= rl_key_sequence_length - 1;
current_macro[current_macro_index] = '\0';
_rl_defining_kbd_macro = 0;
RL_UNSETSTATE(RL_STATE_MACRODEF);
return (rl_call_last_kbd_macro (--count, 0));
}
@ -248,9 +242,9 @@ rl_call_last_kbd_macro (count, ignore)
if (current_macro == 0)
_rl_abort_internal ();
if (_rl_defining_kbd_macro)
if (RL_ISSTATE (RL_STATE_MACRODEF))
{
ding (); /* no recursive macros */
rl_ding (); /* no recursive macros */
current_macro[--current_macro_index] = '\0'; /* erase this char */
return 0;
}

337
readline/mbutil.c Normal file
View File

@ -0,0 +1,337 @@
/* mbutil.c -- readline multibyte character utility functions */
/* Copyright (C) 2001 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#include <sys/types.h>
#include <fcntl.h>
#include "posixjmp.h"
#if defined (HAVE_UNISTD_H)
# include <unistd.h> /* for _POSIX_VERSION */
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#include <stdio.h>
#include <ctype.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
#if defined (TIOCSTAT_IN_SYS_IOCTL)
# include <sys/ioctl.h>
#endif /* TIOCSTAT_IN_SYS_IOCTL */
/* Some standard library routines. */
#include "readline.h"
#include "rlprivate.h"
#include "xmalloc.h"
/* Declared here so it can be shared between the readline and history
libraries. */
#if defined (HANDLE_MULTIBYTE)
int rl_byte_oriented = 0;
#else
int rl_byte_oriented = 1;
#endif
/* **************************************************************** */
/* */
/* Multibyte Character Utility Functions */
/* */
/* **************************************************************** */
#if defined(HANDLE_MULTIBYTE)
static int
_rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
char *string;
int seed, count, find_non_zero;
{
size_t tmp = 0;
mbstate_t ps;
int point = 0;
wchar_t wc;
memset(&ps, 0, sizeof (mbstate_t));
if (seed < 0)
seed = 0;
if (count <= 0)
return seed;
point = seed + _rl_adjust_point(string, seed, &ps);
/* if this is true, means that seed was not pointed character
started byte. So correct the point and consume count */
if (seed < point)
count --;
while (count > 0)
{
tmp = mbrtowc (&wc, string+point, strlen(string + point), &ps);
if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
{
/* invalid bytes. asume a byte represents a character */
point++;
count--;
/* reset states. */
memset(&ps, 0, sizeof(mbstate_t));
}
else if (tmp == (size_t)0)
/* found '\0' char */
break;
else
{
/* valid bytes */
point += tmp;
if (find_non_zero)
{
if (wcwidth (wc) == 0)
continue;
else
count--;
}
else
count--;
}
}
if (find_non_zero)
{
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
while (wcwidth (wc) == 0)
{
point += tmp;
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
if (tmp == (size_t)(0) || tmp == (size_t)(-1) || tmp == (size_t)(-2))
break;
}
}
return point;
}
static int
_rl_find_prev_mbchar_internal (string, seed, find_non_zero)
char *string;
int seed, find_non_zero;
{
mbstate_t ps;
int prev, non_zero_prev, point, length;
size_t tmp;
wchar_t wc;
memset(&ps, 0, sizeof(mbstate_t));
length = strlen(string);
if (seed < 0)
return 0;
else if (length < seed)
return length;
prev = non_zero_prev = point = 0;
while (point < seed)
{
tmp = mbrtowc (&wc, string + point, length - point, &ps);
if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
{
/* in this case, bytes are invalid or shorted to compose
multibyte char, so assume that the first byte represents
a single character anyway. */
tmp = 1;
/* clear the state of the byte sequence, because
in this case effect of mbstate is undefined */
memset(&ps, 0, sizeof (mbstate_t));
}
else if (tmp == 0)
break; /* Found '\0' char. Can this happen? */
else
{
if (find_non_zero)
{
if (wcwidth (wc) != 0)
prev = point;
}
else
prev = point;
}
point += tmp;
}
return prev;
}
/* return the number of bytes parsed from the multibyte sequence starting
at src, if a non-L'\0' wide character was recognized. It returns 0,
if a L'\0' wide character was recognized. It returns (size_t)(-1),
if an invalid multibyte sequence was encountered. It returns (size_t)(-2)
if it couldn't parse a complete multibyte character. */
int
_rl_get_char_len (src, ps)
char *src;
mbstate_t *ps;
{
size_t tmp;
tmp = mbrlen((const char *)src, (size_t)strlen (src), ps);
if (tmp == (size_t)(-2))
{
/* shorted to compose multibyte char */
memset (ps, 0, sizeof(mbstate_t));
return -2;
}
else if (tmp == (size_t)(-1))
{
/* invalid to compose multibyte char */
/* initialize the conversion state */
memset (ps, 0, sizeof(mbstate_t));
return -1;
}
else if (tmp == (size_t)0)
return 0;
else
return (int)tmp;
}
/* compare the specified two characters. If the characters matched,
return 1. Otherwise return 0. */
int
_rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2)
char *buf1, *buf2;
mbstate_t *ps1, *ps2;
int pos1, pos2;
{
int i, w1, w2;
if ((w1 = _rl_get_char_len (&buf1[pos1], ps1)) <= 0 ||
(w2 = _rl_get_char_len (&buf2[pos2], ps2)) <= 0 ||
(w1 != w2) ||
(buf1[pos1] != buf2[pos2]))
return 0;
for (i = 1; i < w1; i++)
if (buf1[pos1+i] != buf2[pos2+i])
return 0;
return 1;
}
/* adjust pointed byte and find mbstate of the point of string.
adjusted point will be point <= adjusted_point, and returns
differences of the byte(adjusted_point - point).
if point is invalied (point < 0 || more than string length),
it returns -1 */
int
_rl_adjust_point(string, point, ps)
char *string;
int point;
mbstate_t *ps;
{
size_t tmp = 0;
int length;
int pos = 0;
length = strlen(string);
if (point < 0)
return -1;
if (length < point)
return -1;
while (pos < point)
{
tmp = mbrlen (string + pos, length - pos, ps);
if((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
{
/* in this case, bytes are invalid or shorted to compose
multibyte char, so assume that the first byte represents
a single character anyway. */
pos++;
/* clear the state of the byte sequence, because
in this case effect of mbstate is undefined */
memset (ps, 0, sizeof (mbstate_t));
}
else
pos += tmp;
}
return (pos - point);
}
int
_rl_is_mbchar_matched (string, seed, end, mbchar, length)
char *string;
int seed, end;
char *mbchar;
int length;
{
int i;
if ((end - seed) < length)
return 0;
for (i = 0; i < length; i++)
if (string[seed + i] != mbchar[i])
return 0;
return 1;
}
#endif /* HANDLE_MULTIBYTE */
/* Find next `count' characters started byte point of the specified seed.
If flags is MB_FIND_NONZERO, we look for non-zero-width multibyte
characters. */
#undef _rl_find_next_mbchar
int
_rl_find_next_mbchar (string, seed, count, flags)
char *string;
int seed, count, flags;
{
#if defined (HANDLE_MULTIBYTE)
return _rl_find_next_mbchar_internal (string, seed, count, flags);
#else
return (seed + count);
#endif
}
/* Find previous character started byte point of the specified seed.
Returned point will be point <= seed. If flags is MB_FIND_NONZERO,
we look for non-zero-width multibyte characters. */
#undef _rl_find_prev_mbchar
int
_rl_find_prev_mbchar (string, seed, flags)
char *string;
int seed, flags;
{
#if defined (HANDLE_MULTIBYTE)
return _rl_find_prev_mbchar_internal (string, seed, flags);
#else
return ((seed == 0) ? seed : seed - 1);
#endif
}

496
readline/misc.c Normal file
View File

@ -0,0 +1,496 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#define READLINE_LIBRARY
#if defined (HAVE_CONFIG_H)
# include <config.h>
#endif
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
#if defined (HAVE_STDLIB_H)
# include <stdlib.h>
#else
# include "ansi_stdlib.h"
#endif /* HAVE_STDLIB_H */
#if defined (HAVE_LOCALE_H)
# include <locale.h>
#endif
#include <stdio.h>
/* System-specific feature definitions and include files. */
#include "rldefs.h"
#include "rlmbutil.h"
/* Some standard library routines. */
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
#include "rlshell.h"
#include "xmalloc.h"
static int rl_digit_loop PARAMS((void));
static void _rl_history_set_point PARAMS((void));
/* Forward declarations used in this file */
void _rl_free_history_entry PARAMS((HIST_ENTRY *));
/* If non-zero, rl_get_previous_history and rl_get_next_history attempt
to preserve the value of rl_point from line to line. */
int _rl_history_preserve_point = 0;
/* Saved target point for when _rl_history_preserve_point is set. Special
value of -1 means that point is at the end of the line. */
int _rl_history_saved_point = -1;
/* **************************************************************** */
/* */
/* Numeric Arguments */
/* */
/* **************************************************************** */
/* Handle C-u style numeric args, as well as M--, and M-digits. */
static int
rl_digit_loop ()
{
int key, c, sawminus, sawdigits;
rl_save_prompt ();
RL_SETSTATE(RL_STATE_NUMERICARG);
sawminus = sawdigits = 0;
while (1)
{
if (rl_numeric_arg > 1000000)
{
sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
rl_ding ();
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return 1;
}
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
RL_SETSTATE(RL_STATE_MOREINPUT);
key = c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (c < 0)
{
_rl_abort_internal ();
return -1;
}
/* If we see a key bound to `universal-argument' after seeing digits,
it ends the argument but is otherwise ignored. */
if (_rl_keymap[c].type == ISFUNC &&
_rl_keymap[c].function == rl_universal_argument)
{
if (sawdigits == 0)
{
rl_numeric_arg *= 4;
continue;
}
else
{
RL_SETSTATE(RL_STATE_MOREINPUT);
key = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (_rl_dispatch (key, _rl_keymap));
}
}
c = UNMETA (c);
if (_rl_digit_p (c))
{
rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + c - '0' : c - '0';
sawdigits = rl_explicit_arg = 1;
}
else if (c == '-' && rl_explicit_arg == 0)
{
rl_numeric_arg = sawminus = 1;
rl_arg_sign = -1;
}
else
{
/* Make M-- command equivalent to M--1 command. */
if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0)
rl_explicit_arg = 1;
rl_restore_prompt ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (_rl_dispatch (key, _rl_keymap));
}
}
/*NOTREACHED*/
}
/* Add the current digit to the argument in progress. */
int
rl_digit_argument (ignore, key)
int ignore, key;
{
rl_execute_next (key);
return (rl_digit_loop ());
}
/* What to do when you abort reading an argument. */
int
rl_discard_argument ()
{
rl_ding ();
rl_clear_message ();
_rl_init_argument ();
return 0;
}
/* Create a default argument. */
int
_rl_init_argument ()
{
rl_numeric_arg = rl_arg_sign = 1;
rl_explicit_arg = 0;
return 0;
}
/* C-u, universal argument. Multiply the current argument by 4.
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. */
int
rl_universal_argument (count, key)
int count, key;
{
rl_numeric_arg *= 4;
return (rl_digit_loop ());
}
/* **************************************************************** */
/* */
/* History Utilities */
/* */
/* **************************************************************** */
/* We already have a history library, and that is what we use to control
the history features of readline. This is our local interface to
the history mechanism. */
/* While we are editing the history, this is the saved
version of the original line. */
HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
/* Set the history pointer back to the last entry in the history. */
void
_rl_start_using_history ()
{
using_history ();
if (_rl_saved_line_for_history)
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Free the contents (and containing structure) of a HIST_ENTRY. */
void
_rl_free_history_entry (entry)
HIST_ENTRY *entry;
{
if (entry == 0)
return;
if (entry->line)
free (entry->line);
free (entry);
}
/* Perhaps put back the current line if it has changed. */
int
rl_maybe_replace_line ()
{
HIST_ENTRY *temp;
temp = current_history ();
/* If the current line has changed, save the changes. */
if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
{
temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
free (temp->line);
free (temp);
}
return 0;
}
/* Restore the _rl_saved_line_for_history if there is one. */
int
rl_maybe_unsave_line ()
{
if (_rl_saved_line_for_history)
{
rl_replace_line (_rl_saved_line_for_history->line, 0);
rl_undo_list = (UNDO_LIST *)_rl_saved_line_for_history->data;
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
rl_point = rl_end; /* rl_replace_line sets rl_end */
}
else
rl_ding ();
return 0;
}
/* Save the current line in _rl_saved_line_for_history. */
int
rl_maybe_save_line ()
{
if (_rl_saved_line_for_history == 0)
{
_rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
_rl_saved_line_for_history->line = savestring (rl_line_buffer);
_rl_saved_line_for_history->data = (char *)rl_undo_list;
}
return 0;
}
int
_rl_free_saved_history_line ()
{
if (_rl_saved_line_for_history)
{
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
return 0;
}
static void
_rl_history_set_point ()
{
rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1)
? _rl_history_saved_point
: rl_end;
if (rl_point > rl_end)
rl_point = rl_end;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_point = 0;
#endif /* VI_MODE */
if (rl_editing_mode == emacs_mode)
rl_mark = (rl_point == rl_end ? 0 : rl_end);
}
void
rl_replace_from_history (entry, flags)
HIST_ENTRY *entry;
int flags; /* currently unused */
{
rl_replace_line (entry->line, 0);
rl_undo_list = (UNDO_LIST *)entry->data;
rl_point = rl_end;
rl_mark = 0;
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
{
rl_point = 0;
rl_mark = rl_end;
}
#endif
}
/* **************************************************************** */
/* */
/* History Commands */
/* */
/* **************************************************************** */
/* Meta-< goes to the start of the history. */
int
rl_beginning_of_history (count, key)
int count, key;
{
return (rl_get_previous_history (1 + where_history (), key));
}
/* Meta-> goes to the end of the history. (The current line). */
int
rl_end_of_history (count, key)
int count, key;
{
rl_maybe_replace_line ();
using_history ();
rl_maybe_unsave_line ();
return 0;
}
/* Move down to the next history line. */
int
rl_get_next_history (count, key)
int count, key;
{
HIST_ENTRY *temp;
if (count < 0)
return (rl_get_previous_history (-count, key));
if (count == 0)
return 0;
rl_maybe_replace_line ();
/* either not saved by rl_newline or at end of line, so set appropriately. */
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
temp = (HIST_ENTRY *)NULL;
while (count)
{
temp = next_history ();
if (!temp)
break;
--count;
}
if (temp == 0)
rl_maybe_unsave_line ();
else
{
rl_replace_from_history (temp, 0);
_rl_history_set_point ();
}
return 0;
}
/* Get the previous item out of our interactive history, making it the current
line. If there is no previous history, just ding. */
int
rl_get_previous_history (count, key)
int count, key;
{
HIST_ENTRY *old_temp, *temp;
if (count < 0)
return (rl_get_next_history (-count, key));
if (count == 0)
return 0;
/* either not saved by rl_newline or at end of line, so set appropriately. */
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
/* If we don't have a line saved, then save this one. */
rl_maybe_save_line ();
/* If the current line has changed, save the changes. */
rl_maybe_replace_line ();
temp = old_temp = (HIST_ENTRY *)NULL;
while (count)
{
temp = previous_history ();
if (temp == 0)
break;
old_temp = temp;
--count;
}
/* If there was a large argument, and we moved back to the start of the
history, that is not an error. So use the last value found. */
if (!temp && old_temp)
temp = old_temp;
if (temp == 0)
rl_ding ();
else
{
rl_replace_from_history (temp, 0);
_rl_history_set_point ();
}
return 0;
}
/* **************************************************************** */
/* */
/* Editing Modes */
/* */
/* **************************************************************** */
/* How to toggle back and forth between editing modes. */
int
rl_vi_editing_mode (count, key)
int count, key;
{
#if defined (VI_MODE)
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
rl_editing_mode = vi_mode;
rl_vi_insertion_mode (1, key);
#endif /* VI_MODE */
return 0;
}
int
rl_emacs_editing_mode (count, key)
int count, key;
{
rl_editing_mode = emacs_mode;
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
_rl_keymap = emacs_standard_keymap;
return 0;
}
/* Function for the rest of the library to use to set insert/overwrite mode. */
void
_rl_set_insert_mode (im, force)
int im, force;
{
#ifdef CURSOR_MODE
_rl_set_cursor (im, force);
#endif
rl_insert_mode = im;
}
/* Toggle overwrite mode. A positive explicit argument selects overwrite
mode. A negative or zero explicit argument selects insert mode. */
int
rl_overwrite_mode (count, key)
int count, key;
{
if (rl_explicit_arg == 0)
_rl_set_insert_mode (rl_insert_mode ^ 1, 0);
else if (count > 0)
_rl_set_insert_mode (RL_IM_OVERWRITE, 0);
else
_rl_set_insert_mode (RL_IM_INSERT, 0);
return 0;
}

View File

@ -71,8 +71,8 @@ static char *legal_lang_values[] =
0
};
static char *normalize_codeset __P((char *));
static char *find_codeset __P((char *, size_t *));
static char *normalize_codeset PARAMS((char *));
static char *find_codeset PARAMS((char *, size_t *));
#endif /* !HAVE_SETLOCALE */
/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value
@ -105,9 +105,9 @@ _rl_init_eightbit ()
/* We don't have setlocale. Finesse it. Check the environment for the
appropriate variables and set eight-bit mode if they have the right
values. */
lspec = get_env_value ("LC_ALL");
if (lspec == 0) lspec = get_env_value ("LC_CTYPE");
if (lspec == 0) lspec = get_env_value ("LANG");
lspec = sh_get_env_value ("LC_ALL");
if (lspec == 0) lspec = sh_get_env_value ("LC_CTYPE");
if (lspec == 0) lspec = sh_get_env_value ("LANG");
if (lspec == 0 || (t = normalize_codeset (lspec)) == 0)
return (0);
for (i = 0; t && legal_lang_values[i]; i++)
@ -141,10 +141,10 @@ normalize_codeset (codeset)
all_digits = 1;
for (len = 0, i = 0; i < namelen; i++)
{
if (isalnum (codeset[i]))
if (ISALNUM ((unsigned char)codeset[i]))
{
len++;
all_digits &= isdigit (codeset[i]);
all_digits &= _rl_digit_p (codeset[i]);
}
}
@ -162,9 +162,9 @@ normalize_codeset (codeset)
}
for (i = 0; i < namelen; i++)
if (isalpha (codeset[i]))
*wp++ = (isupper (codeset[i])) ? tolower (codeset[i]) : codeset[i];
else if (isdigit (codeset[i]))
if (ISALPHA ((unsigned char)codeset[i]))
*wp++ = _rl_to_lower (codeset[i]);
else if (_rl_digit_p (codeset[i]))
*wp++ = codeset[i];
*wp = '\0';

View File

@ -30,6 +30,10 @@
#include <stdio.h>
#include <sys/types.h>
#if defined (HAVE_UNISTD_H)
# include <unistd.h>
#endif
#if defined (FD_SET) && !defined (HAVE_SELECT)
# define HAVE_SELECT
#endif
@ -54,7 +58,7 @@ extern char *strchr (), *strrchr ();
#include "readline.h"
#include "rlprivate.h"
static int find_matching_open __P((char *, int, int));
static int find_matching_open PARAMS((char *, int, int));
/* Non-zero means try to blink the matching open parenthesis when the
close parenthesis is inserted. */
@ -64,6 +68,8 @@ int rl_blink_matching_paren = 1;
int rl_blink_matching_paren = 0;
#endif /* !HAVE_SELECT */
static int _paren_blink_usec = 500000;
/* Change emacs_standard_keymap to have bindings for paren matching when
ON_OR_OFF is 1, change them back to self_insert when ON_OR_OFF == 0. */
void
@ -84,12 +90,24 @@ _rl_enable_paren_matching (on_or_off)
}
}
int
rl_set_paren_blink_timeout (u)
int u;
{
int o;
o = _paren_blink_usec;
if (u > 0)
_paren_blink_usec = u;
return (o);
}
int
rl_insert_close (count, invoking_key)
int count, invoking_key;
{
if (rl_explicit_arg || !rl_blink_matching_paren)
rl_insert (count, invoking_key);
_rl_insert_char (count, invoking_key);
else
{
#if defined (HAVE_SELECT)
@ -97,7 +115,7 @@ rl_insert_close (count, invoking_key)
struct timeval timer;
fd_set readfds;
rl_insert (1, invoking_key);
_rl_insert_char (1, invoking_key);
(*rl_redisplay_function) ();
match_point =
find_matching_open (rl_line_buffer, rl_point - 2, invoking_key);
@ -109,7 +127,7 @@ rl_insert_close (count, invoking_key)
FD_ZERO (&readfds);
FD_SET (fileno (rl_instream), &readfds);
timer.tv_sec = 0;
timer.tv_usec = 500000;
timer.tv_usec = _paren_blink_usec;
orig_point = rl_point;
rl_point = match_point;
@ -117,7 +135,7 @@ rl_insert_close (count, invoking_key)
ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer);
rl_point = orig_point;
#else /* !HAVE_SELECT */
rl_insert (count, invoking_key);
_rl_insert_char (count, invoking_key);
#endif /* !HAVE_SELECT */
}
return 0;

View File

@ -46,4 +46,12 @@
# define d_fileno d_ino
#endif
#if defined (_POSIX_SOURCE) && (!defined (STRUCT_DIRENT_HAS_D_INO) || defined (BROKEN_DIRENT_D_INO))
/* Posix does not require that the d_ino field be present, and some
systems do not provide it. */
# define REAL_DIR_ENTRY(dp) 1
#else
# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
#endif /* _POSIX_SOURCE */
#endif /* !_POSIXDIR_H_ */

File diff suppressed because it is too large Load Diff

View File

@ -29,14 +29,21 @@ extern "C" {
#if defined (READLINE_LIBRARY)
# include "rlstdc.h"
# include "rltypedefs.h"
# include "keymaps.h"
# include "tilde.h"
#else
# include <readline/rlstdc.h>
# include <readline/rltypedefs.h>
# include <readline/keymaps.h>
# include <readline/tilde.h>
#endif
/* Hex-encoded Readline version number. */
#define RL_READLINE_VERSION 0x0403 /* Readline 4.3 */
#define RL_VERSION_MAJOR 4
#define RL_VERSION_MINOR 3
/* Readline data structures. */
/* Maintaining the state of undo. We remember individual deletes and inserts
@ -60,8 +67,8 @@ extern UNDO_LIST *rl_undo_list;
/* The data structure for mapping textual names to code addresses. */
typedef struct _funmap {
char *name;
Function *function;
const char *name;
rl_command_func_t *function;
} FUNMAP;
extern FUNMAP **funmap;
@ -73,184 +80,191 @@ extern FUNMAP **funmap;
/* **************************************************************** */
/* Bindable commands for numeric arguments. */
extern int rl_digit_argument __P((int, int));
extern int rl_universal_argument __P((int, int));
extern int rl_digit_argument PARAMS((int, int));
extern int rl_universal_argument PARAMS((int, int));
/* Bindable commands for moving the cursor. */
extern int rl_forward __P((int, int));
extern int rl_backward __P((int, int));
extern int rl_beg_of_line __P((int, int));
extern int rl_end_of_line __P((int, int));
extern int rl_forward_word __P((int, int));
extern int rl_backward_word __P((int, int));
extern int rl_refresh_line __P((int, int));
extern int rl_clear_screen __P((int, int));
extern int rl_arrow_keys __P((int, int));
extern int rl_forward_byte PARAMS((int, int));
extern int rl_forward_char PARAMS((int, int));
extern int rl_forward PARAMS((int, int));
extern int rl_backward_byte PARAMS((int, int));
extern int rl_backward_char PARAMS((int, int));
extern int rl_backward PARAMS((int, int));
extern int rl_beg_of_line PARAMS((int, int));
extern int rl_end_of_line PARAMS((int, int));
extern int rl_forward_word PARAMS((int, int));
extern int rl_backward_word PARAMS((int, int));
extern int rl_refresh_line PARAMS((int, int));
extern int rl_clear_screen PARAMS((int, int));
extern int rl_arrow_keys PARAMS((int, int));
/* Bindable commands for inserting and deleting text. */
extern int rl_insert __P((int, int));
extern int rl_quoted_insert __P((int, int));
extern int rl_tab_insert __P((int, int));
extern int rl_newline __P((int, int));
extern int rl_do_lowercase_version __P((int, int));
extern int rl_rubout __P((int, int));
extern int rl_delete __P((int, int));
extern int rl_rubout_or_delete __P((int, int));
extern int rl_delete_horizontal_space __P((int, int));
extern int rl_delete_or_show_completions __P((int, int));
extern int rl_insert_comment __P((int, int));
extern int rl_insert PARAMS((int, int));
extern int rl_quoted_insert PARAMS((int, int));
extern int rl_tab_insert PARAMS((int, int));
extern int rl_newline PARAMS((int, int));
extern int rl_do_lowercase_version PARAMS((int, int));
extern int rl_rubout PARAMS((int, int));
extern int rl_delete PARAMS((int, int));
extern int rl_rubout_or_delete PARAMS((int, int));
extern int rl_delete_horizontal_space PARAMS((int, int));
extern int rl_delete_or_show_completions PARAMS((int, int));
extern int rl_insert_comment PARAMS((int, int));
/* Bindable commands for changing case. */
extern int rl_upcase_word __P((int, int));
extern int rl_downcase_word __P((int, int));
extern int rl_capitalize_word __P((int, int));
extern int rl_upcase_word PARAMS((int, int));
extern int rl_downcase_word PARAMS((int, int));
extern int rl_capitalize_word PARAMS((int, int));
/* Bindable commands for transposing characters and words. */
extern int rl_transpose_words __P((int, int));
extern int rl_transpose_chars __P((int, int));
extern int rl_transpose_words PARAMS((int, int));
extern int rl_transpose_chars PARAMS((int, int));
/* Bindable commands for searching within a line. */
extern int rl_char_search __P((int, int));
extern int rl_backward_char_search __P((int, int));
extern int rl_char_search PARAMS((int, int));
extern int rl_backward_char_search PARAMS((int, int));
/* Bindable commands for readline's interface to the command history. */
extern int rl_beginning_of_history __P((int, int));
extern int rl_end_of_history __P((int, int));
extern int rl_get_next_history __P((int, int));
extern int rl_get_previous_history __P((int, int));
extern int rl_beginning_of_history PARAMS((int, int));
extern int rl_end_of_history PARAMS((int, int));
extern int rl_get_next_history PARAMS((int, int));
extern int rl_get_previous_history PARAMS((int, int));
/* Bindable commands for managing the mark and region. */
extern int rl_set_mark __P((int, int));
extern int rl_exchange_point_and_mark __P((int, int));
extern int rl_set_mark PARAMS((int, int));
extern int rl_exchange_point_and_mark PARAMS((int, int));
/* Bindable commands to set the editing mode (emacs or vi). */
extern int rl_vi_editing_mode __P((int, int));
extern int rl_emacs_editing_mode __P((int, int));
extern int rl_vi_editing_mode PARAMS((int, int));
extern int rl_emacs_editing_mode PARAMS((int, int));
/* Bindable commands to change the insert mode (insert or overwrite) */
extern int rl_overwrite_mode PARAMS((int, int));
/* Bindable commands for managing key bindings. */
extern int rl_re_read_init_file __P((int, int));
extern int rl_dump_functions __P((int, int));
extern int rl_dump_macros __P((int, int));
extern int rl_dump_variables __P((int, int));
extern int rl_re_read_init_file PARAMS((int, int));
extern int rl_dump_functions PARAMS((int, int));
extern int rl_dump_macros PARAMS((int, int));
extern int rl_dump_variables PARAMS((int, int));
/* Bindable commands for word completion. */
extern int rl_complete __P((int, int));
extern int rl_possible_completions __P((int, int));
extern int rl_insert_completions __P((int, int));
extern int rl_menu_complete __P((int, int));
extern int rl_complete PARAMS((int, int));
extern int rl_possible_completions PARAMS((int, int));
extern int rl_insert_completions PARAMS((int, int));
extern int rl_menu_complete PARAMS((int, int));
/* Bindable commands for killing and yanking text, and managing the kill ring. */
extern int rl_kill_word __P((int, int));
extern int rl_backward_kill_word __P((int, int));
extern int rl_kill_line __P((int, int));
extern int rl_backward_kill_line __P((int, int));
extern int rl_kill_full_line __P((int, int));
extern int rl_unix_word_rubout __P((int, int));
extern int rl_unix_line_discard __P((int, int));
extern int rl_copy_region_to_kill __P((int, int));
extern int rl_kill_region __P((int, int));
extern int rl_copy_forward_word __P((int, int));
extern int rl_copy_backward_word __P((int, int));
extern int rl_yank __P((int, int));
extern int rl_yank_pop __P((int, int));
extern int rl_yank_nth_arg __P((int, int));
extern int rl_yank_last_arg __P((int, int));
/* Not available unless __CYGWIN32__ is defined. */
#ifdef __CYGWIN32__
extern int rl_paste_from_clipboard __P((int, int));
extern int rl_kill_word PARAMS((int, int));
extern int rl_backward_kill_word PARAMS((int, int));
extern int rl_kill_line PARAMS((int, int));
extern int rl_backward_kill_line PARAMS((int, int));
extern int rl_kill_full_line PARAMS((int, int));
extern int rl_unix_word_rubout PARAMS((int, int));
extern int rl_unix_line_discard PARAMS((int, int));
extern int rl_copy_region_to_kill PARAMS((int, int));
extern int rl_kill_region PARAMS((int, int));
extern int rl_copy_forward_word PARAMS((int, int));
extern int rl_copy_backward_word PARAMS((int, int));
extern int rl_yank PARAMS((int, int));
extern int rl_yank_pop PARAMS((int, int));
extern int rl_yank_nth_arg PARAMS((int, int));
extern int rl_yank_last_arg PARAMS((int, int));
/* Not available unless __CYGWIN__ is defined. */
#ifdef __CYGWIN__
extern int rl_paste_from_clipboard PARAMS((int, int));
#endif
/* Bindable commands for incremental searching. */
extern int rl_reverse_search_history __P((int, int));
extern int rl_forward_search_history __P((int, int));
extern int rl_reverse_search_history PARAMS((int, int));
extern int rl_forward_search_history PARAMS((int, int));
/* Bindable keyboard macro commands. */
extern int rl_start_kbd_macro __P((int, int));
extern int rl_end_kbd_macro __P((int, int));
extern int rl_call_last_kbd_macro __P((int, int));
extern int rl_start_kbd_macro PARAMS((int, int));
extern int rl_end_kbd_macro PARAMS((int, int));
extern int rl_call_last_kbd_macro PARAMS((int, int));
/* Bindable undo commands. */
extern int rl_revert_line __P((int, int));
extern int rl_undo_command __P((int, int));
extern int rl_revert_line PARAMS((int, int));
extern int rl_undo_command PARAMS((int, int));
/* Bindable tilde expansion commands. */
extern int rl_tilde_expand __P((int, int));
extern int rl_tilde_expand PARAMS((int, int));
/* Bindable terminal control commands. */
extern int rl_restart_output __P((int, int));
extern int rl_stop_output __P((int, int));
extern int rl_restart_output PARAMS((int, int));
extern int rl_stop_output PARAMS((int, int));
/* Miscellaneous bindable commands. */
extern int rl_abort __P((int, int));
extern int rl_tty_status __P((int, int));
extern int rl_abort PARAMS((int, int));
extern int rl_tty_status PARAMS((int, int));
/* Bindable commands for incremental and non-incremental history searching. */
extern int rl_history_search_forward __P((int, int));
extern int rl_history_search_backward __P((int, int));
extern int rl_noninc_forward_search __P((int, int));
extern int rl_noninc_reverse_search __P((int, int));
extern int rl_noninc_forward_search_again __P((int, int));
extern int rl_noninc_reverse_search_again __P((int, int));
extern int rl_history_search_forward PARAMS((int, int));
extern int rl_history_search_backward PARAMS((int, int));
extern int rl_noninc_forward_search PARAMS((int, int));
extern int rl_noninc_reverse_search PARAMS((int, int));
extern int rl_noninc_forward_search_again PARAMS((int, int));
extern int rl_noninc_reverse_search_again PARAMS((int, int));
/* Bindable command used when inserting a matching close character. */
extern int rl_insert_close __P((int, int));
extern int rl_insert_close PARAMS((int, int));
/* Not available unless READLINE_CALLBACKS is defined. */
extern void rl_callback_handler_install __P((char *, VFunction *));
extern void rl_callback_read_char __P((void));
extern void rl_callback_handler_remove __P((void));
extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
extern void rl_callback_read_char PARAMS((void));
extern void rl_callback_handler_remove PARAMS((void));
/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
/* VI-mode bindable commands. */
extern int rl_vi_redo __P((int, int));
extern int rl_vi_undo __P((int, int));
extern int rl_vi_yank_arg __P((int, int));
extern int rl_vi_fetch_history __P((int, int));
extern int rl_vi_search_again __P((int, int));
extern int rl_vi_search __P((int, int));
extern int rl_vi_complete __P((int, int));
extern int rl_vi_tilde_expand __P((int, int));
extern int rl_vi_prev_word __P((int, int));
extern int rl_vi_next_word __P((int, int));
extern int rl_vi_end_word __P((int, int));
extern int rl_vi_insert_beg __P((int, int));
extern int rl_vi_append_mode __P((int, int));
extern int rl_vi_append_eol __P((int, int));
extern int rl_vi_eof_maybe __P((int, int));
extern int rl_vi_insertion_mode __P((int, int));
extern int rl_vi_movement_mode __P((int, int));
extern int rl_vi_arg_digit __P((int, int));
extern int rl_vi_change_case __P((int, int));
extern int rl_vi_put __P((int, int));
extern int rl_vi_column __P((int, int));
extern int rl_vi_delete_to __P((int, int));
extern int rl_vi_change_to __P((int, int));
extern int rl_vi_yank_to __P((int, int));
extern int rl_vi_delete __P((int, int));
extern int rl_vi_back_to_indent __P((int, int));
extern int rl_vi_first_print __P((int, int));
extern int rl_vi_char_search __P((int, int));
extern int rl_vi_match __P((int, int));
extern int rl_vi_change_char __P((int, int));
extern int rl_vi_subst __P((int, int));
extern int rl_vi_overstrike __P((int, int));
extern int rl_vi_overstrike_delete __P((int, int));
extern int rl_vi_replace __P((int, int));
extern int rl_vi_set_mark __P((int, int));
extern int rl_vi_goto_mark __P((int, int));
extern int rl_vi_redo PARAMS((int, int));
extern int rl_vi_undo PARAMS((int, int));
extern int rl_vi_yank_arg PARAMS((int, int));
extern int rl_vi_fetch_history PARAMS((int, int));
extern int rl_vi_search_again PARAMS((int, int));
extern int rl_vi_search PARAMS((int, int));
extern int rl_vi_complete PARAMS((int, int));
extern int rl_vi_tilde_expand PARAMS((int, int));
extern int rl_vi_prev_word PARAMS((int, int));
extern int rl_vi_next_word PARAMS((int, int));
extern int rl_vi_end_word PARAMS((int, int));
extern int rl_vi_insert_beg PARAMS((int, int));
extern int rl_vi_append_mode PARAMS((int, int));
extern int rl_vi_append_eol PARAMS((int, int));
extern int rl_vi_eof_maybe PARAMS((int, int));
extern int rl_vi_insertion_mode PARAMS((int, int));
extern int rl_vi_movement_mode PARAMS((int, int));
extern int rl_vi_arg_digit PARAMS((int, int));
extern int rl_vi_change_case PARAMS((int, int));
extern int rl_vi_put PARAMS((int, int));
extern int rl_vi_column PARAMS((int, int));
extern int rl_vi_delete_to PARAMS((int, int));
extern int rl_vi_change_to PARAMS((int, int));
extern int rl_vi_yank_to PARAMS((int, int));
extern int rl_vi_delete PARAMS((int, int));
extern int rl_vi_back_to_indent PARAMS((int, int));
extern int rl_vi_first_print PARAMS((int, int));
extern int rl_vi_char_search PARAMS((int, int));
extern int rl_vi_match PARAMS((int, int));
extern int rl_vi_change_char PARAMS((int, int));
extern int rl_vi_subst PARAMS((int, int));
extern int rl_vi_overstrike PARAMS((int, int));
extern int rl_vi_overstrike_delete PARAMS((int, int));
extern int rl_vi_replace PARAMS((int, int));
extern int rl_vi_set_mark PARAMS((int, int));
extern int rl_vi_goto_mark PARAMS((int, int));
/* VI-mode utility functions. */
extern int rl_vi_check __P((void));
extern int rl_vi_domove __P((int, int *));
extern int rl_vi_bracktype __P((int));
extern int rl_vi_check PARAMS((void));
extern int rl_vi_domove PARAMS((int, int *));
extern int rl_vi_bracktype PARAMS((int));
/* VI-mode pseudo-bindable commands, used as utility functions. */
extern int rl_vi_fWord __P((int, int));
extern int rl_vi_bWord __P((int, int));
extern int rl_vi_eWord __P((int, int));
extern int rl_vi_fword __P((int, int));
extern int rl_vi_bword __P((int, int));
extern int rl_vi_eword __P((int, int));
extern int rl_vi_fWord PARAMS((int, int));
extern int rl_vi_bWord PARAMS((int, int));
extern int rl_vi_eWord PARAMS((int, int));
extern int rl_vi_fword PARAMS((int, int));
extern int rl_vi_bword PARAMS((int, int));
extern int rl_vi_eword PARAMS((int, int));
/* **************************************************************** */
/* */
@ -260,142 +274,176 @@ extern int rl_vi_eword __P((int, int));
/* Readline functions. */
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
extern char *readline __P((char *));
extern char *readline PARAMS((const char *));
extern int rl_initialize __P((void));
extern int rl_set_prompt PARAMS((const char *));
extern int rl_expand_prompt PARAMS((char *));
extern int rl_discard_argument __P((void));
extern int rl_initialize PARAMS((void));
/* Undocumented; unused by readline */
extern int rl_discard_argument PARAMS((void));
/* Utility functions to bind keys to readline commands. */
extern int rl_add_defun __P((char *, Function *, int));
extern int rl_bind_key __P((int, Function *));
extern int rl_bind_key_in_map __P((int, Function *, Keymap));
extern int rl_unbind_key __P((int));
extern int rl_unbind_key_in_map __P((int, Keymap));
extern int rl_unbind_function_in_map __P((Function *, Keymap));
extern int rl_unbind_command_in_map __P((char *, Keymap));
extern int rl_set_key __P((char *, Function *, Keymap));
extern int rl_generic_bind __P((int, char *, char *, Keymap));
extern int rl_variable_bind __P((char *, char *));
extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
extern int rl_bind_key PARAMS((int, rl_command_func_t *));
extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
extern int rl_unbind_key PARAMS((int));
extern int rl_unbind_key_in_map PARAMS((int, Keymap));
extern int rl_unbind_function_in_map PARAMS((rl_command_func_t *, Keymap));
extern int rl_unbind_command_in_map PARAMS((const char *, Keymap));
extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
extern int rl_variable_bind PARAMS((const char *, const char *));
/* Backwards compatibility, use rl_generic_bind instead. */
extern int rl_macro_bind __P((char *, char *, Keymap));
extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
/* Undocumented in the texinfo manual; not really useful to programs. */
extern int rl_translate_keyseq __P((char *, char *, int *));
extern char *rl_untranslate_keyseq __P((int));
extern int rl_translate_keyseq PARAMS((const char *, char *, int *));
extern char *rl_untranslate_keyseq PARAMS((int));
extern Function *rl_named_function __P((char *));
extern Function *rl_function_of_keyseq __P((char *, Keymap, int *));
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 void rl_list_funmap_names __P((void));
extern char **rl_invoking_keyseqs_in_map __P((Function *, Keymap));
extern char **rl_invoking_keyseqs __P((Function *));
extern void rl_list_funmap_names PARAMS((void));
extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
extern void rl_function_dumper __P((int));
extern void rl_macro_dumper __P((int));
extern void rl_variable_dumper __P((int));
extern void rl_function_dumper PARAMS((int));
extern void rl_macro_dumper PARAMS((int));
extern void rl_variable_dumper PARAMS((int));
extern int rl_read_init_file __P((char *));
extern int rl_parse_and_bind __P((char *));
extern int rl_read_init_file PARAMS((const char *));
extern int rl_parse_and_bind PARAMS((char *));
/* Functions for manipulating keymaps. */
extern Keymap rl_make_bare_keymap __P((void));
extern Keymap rl_copy_keymap __P((Keymap));
extern Keymap rl_make_keymap __P((void));
extern void rl_discard_keymap __P((Keymap));
extern Keymap rl_make_bare_keymap PARAMS((void));
extern Keymap rl_copy_keymap PARAMS((Keymap));
extern Keymap rl_make_keymap PARAMS((void));
extern void rl_discard_keymap PARAMS((Keymap));
extern Keymap rl_get_keymap_by_name __P((char *));
extern char *rl_get_keymap_name __P((Keymap));
extern void rl_set_keymap __P((Keymap));
extern Keymap rl_get_keymap __P((void));
extern void rl_set_keymap_from_edit_mode __P((void));
extern char *rl_get_keymap_name_from_edit_mode __P((void));
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
extern char *rl_get_keymap_name PARAMS((Keymap));
extern void rl_set_keymap PARAMS((Keymap));
extern Keymap rl_get_keymap PARAMS((void));
/* Undocumented; used internally only. */
extern void rl_set_keymap_from_edit_mode PARAMS((void));
extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
/* Functions for manipulating the funmap, which maps command names to functions. */
extern int rl_add_funmap_entry __P((char *, Function *));
extern void rl_initialize_funmap __P((void));
extern char **rl_funmap_names __P((void));
extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
extern const char **rl_funmap_names PARAMS((void));
/* Undocumented, only used internally -- there is only one funmap, and this
function may be called only once. */
extern void rl_initialize_funmap PARAMS((void));
/* Utility functions for managing keyboard macros. */
extern void rl_push_macro_input __P((char *));
extern void rl_push_macro_input PARAMS((char *));
/* Functions for undoing, from undo.c */
extern void rl_add_undo __P((enum undo_code, int, int, char *));
extern void free_undo_list __P((void));
extern int rl_do_undo __P((void));
extern int rl_begin_undo_group __P((void));
extern int rl_end_undo_group __P((void));
extern int rl_modifying __P((int, int));
extern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
extern void rl_free_undo_list PARAMS((void));
extern int rl_do_undo PARAMS((void));
extern int rl_begin_undo_group PARAMS((void));
extern int rl_end_undo_group PARAMS((void));
extern int rl_modifying PARAMS((int, int));
/* Functions for redisplay. */
extern void rl_redisplay __P((void));
extern int rl_on_new_line __P((void));
extern int rl_on_new_line_with_prompt __P((void));
extern int rl_forced_update_display __P((void));
extern int rl_clear_message __P((void));
extern int rl_reset_line_state __P((void));
extern void rl_redisplay PARAMS((void));
extern int rl_on_new_line PARAMS((void));
extern int rl_on_new_line_with_prompt PARAMS((void));
extern int rl_forced_update_display PARAMS((void));
extern int rl_clear_message PARAMS((void));
extern int rl_reset_line_state PARAMS((void));
extern int rl_crlf PARAMS((void));
#if (defined (__STDC__) || defined (__cplusplus)) && defined (USE_VARARGS) && defined (PREFER_STDARG)
extern int rl_message (const char *, ...);
extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
#else
extern int rl_message ();
#endif
extern int rl_show_char PARAMS((int));
/* Undocumented in texinfo manual. */
extern int rl_show_char __P((int));
extern int rl_character_len __P((int, int));
extern int crlf __P((void));
extern int rl_character_len PARAMS((int, int));
/* Save and restore internal prompt redisplay information. */
extern void rl_save_prompt __P((void));
extern void rl_restore_prompt __P((void));
extern void rl_save_prompt PARAMS((void));
extern void rl_restore_prompt PARAMS((void));
/* Modifying text. */
extern int rl_insert_text __P((char *));
extern int rl_delete_text __P((int, int));
extern int rl_kill_text __P((int, int));
extern char *rl_copy_text __P((int, int));
extern void rl_replace_line PARAMS((const char *, int));
extern int rl_insert_text PARAMS((const char *));
extern int rl_delete_text PARAMS((int, int));
extern int rl_kill_text PARAMS((int, int));
extern char *rl_copy_text PARAMS((int, int));
/* Terminal and tty mode management. */
extern void rl_prep_terminal __P((int));
extern void rl_deprep_terminal __P((void));
extern void rltty_set_default_bindings __P((Keymap));
extern void rl_prep_terminal PARAMS((int));
extern void rl_deprep_terminal PARAMS((void));
extern void rl_tty_set_default_bindings PARAMS((Keymap));
extern int rl_reset_terminal __P((char *));
extern void rl_resize_terminal __P((void));
extern int rl_reset_terminal PARAMS((const char *));
extern void rl_resize_terminal PARAMS((void));
extern void rl_set_screen_size PARAMS((int, int));
extern void rl_get_screen_size PARAMS((int *, int *));
/* `Public' utility functions . */
extern void rl_extend_line_buffer __P((int));
extern int ding __P((void));
extern char *rl_get_termcap PARAMS((const char *));
/* Functions for character input. */
extern int rl_stuff_char __P((int));
extern int rl_execute_next __P((int));
extern int rl_read_key __P((void));
extern int rl_getc __P((FILE *));
extern int rl_stuff_char PARAMS((int));
extern int rl_execute_next PARAMS((int));
extern int rl_clear_pending_input PARAMS((void));
extern int rl_read_key PARAMS((void));
extern int rl_getc PARAMS((FILE *));
extern int rl_set_keyboard_input_timeout PARAMS((int));
/* `Public' utility functions . */
extern void rl_extend_line_buffer PARAMS((int));
extern int rl_ding PARAMS((void));
extern int rl_alphabetic PARAMS((int));
/* Readline signal handling, from signals.c */
extern int rl_set_signals __P((void));
extern int rl_clear_signals __P((void));
extern void rl_cleanup_after_signal __P((void));
extern void rl_reset_after_signal __P((void));
extern void rl_free_line_state __P((void));
extern int rl_set_signals PARAMS((void));
extern int rl_clear_signals PARAMS((void));
extern void rl_cleanup_after_signal PARAMS((void));
extern void rl_reset_after_signal PARAMS((void));
extern void rl_free_line_state PARAMS((void));
/* Undocumented. */
extern int rl_expand_prompt __P((char *));
extern int rl_set_paren_blink_timeout PARAMS((int));
extern int maybe_save_line __P((void));
extern int maybe_unsave_line __P((void));
extern int maybe_replace_line __P((void));
/* Undocumented. */
extern int rl_maybe_save_line PARAMS((void));
extern int rl_maybe_unsave_line PARAMS((void));
extern int rl_maybe_replace_line PARAMS((void));
/* Completion functions. */
extern int rl_complete_internal __P((int));
extern void rl_display_match_list __P((char **, int, int));
extern int rl_complete_internal PARAMS((int));
extern void rl_display_match_list PARAMS((char **, int, int));
extern char **completion_matches __P((char *, CPFunction *));
extern char *username_completion_function __P((char *, int));
extern char *filename_completion_function __P((char *, int));
extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
extern char *rl_username_completion_function PARAMS((const char *, int));
extern char *rl_filename_completion_function PARAMS((const char *, int));
extern int rl_completion_mode PARAMS((rl_command_func_t *));
#if 0
/* Backwards compatibility (compat.c). These will go away sometime. */
extern void free_undo_list PARAMS((void));
extern int maybe_save_line PARAMS((void));
extern int maybe_unsave_line PARAMS((void));
extern int maybe_replace_line PARAMS((void));
extern int ding PARAMS((void));
extern int alphabetic PARAMS((int));
extern int crlf PARAMS((void));
extern char **completion_matches PARAMS((char *, rl_compentry_func_t *));
extern char *username_completion_function PARAMS((const char *, int));
extern char *filename_completion_function PARAMS((const char *, int));
#endif
/* **************************************************************** */
/* */
@ -404,14 +452,26 @@ extern char *filename_completion_function __P((char *, int));
/* **************************************************************** */
/* The version of this incarnation of the readline library. */
extern char *rl_library_version;
extern const char *rl_library_version; /* e.g., "4.2" */
extern int rl_readline_version; /* e.g., 0x0402 */
/* True if this is real GNU readline. */
extern int rl_gnu_readline_p;
/* Flags word encapsulating the current readline state. */
extern int rl_readline_state;
/* Says which editing mode readline is currently using. 1 means emacs mode;
0 means vi mode. */
extern int rl_editing_mode;
/* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means
overwrite mode. Reset to insert mode on each input line. */
extern int rl_insert_mode;
/* The name of the calling program. You should initialize this to
whatever was in argv[0]. It is used when parsing conditionals. */
extern char *rl_readline_name;
extern const char *rl_readline_name;
/* The prompt readline uses. This is set from the argument to
readline (), and should not be assigned to directly. */
@ -421,7 +481,8 @@ extern char *rl_prompt;
extern char *rl_line_buffer;
/* The location of point, and end. */
extern int rl_point, rl_end;
extern int rl_point;
extern int rl_end;
/* The mark, or saved cursor position. */
extern int rl_mark;
@ -438,29 +499,44 @@ extern int rl_pending_input;
or directly from an application. */
extern int rl_dispatching;
/* Non-zero if the user typed a numeric argument before executing the
current function. */
extern int rl_explicit_arg;
/* The current value of the numeric argument specified by the user. */
extern int rl_numeric_arg;
/* The address of the last command function Readline executed. */
extern rl_command_func_t *rl_last_func;
/* The name of the terminal to use. */
extern char *rl_terminal_name;
extern const char *rl_terminal_name;
/* The input and output streams. */
extern FILE *rl_instream, *rl_outstream;
extern FILE *rl_instream;
extern FILE *rl_outstream;
/* If non-zero, then this is the address of a function to call just
before readline_internal () prints the first prompt. */
extern Function *rl_startup_hook;
extern rl_hook_func_t *rl_startup_hook;
/* If non-zero, this is the address of a function to call just before
readline_internal_setup () returns and readline_internal starts
reading input characters. */
extern Function *rl_pre_input_hook;
extern rl_hook_func_t *rl_pre_input_hook;
/* The address of a function to call periodically while Readline is
awaiting character input, or NULL, for no event handling. */
extern Function *rl_event_hook;
extern rl_hook_func_t *rl_event_hook;
extern Function *rl_getc_function;
extern VFunction *rl_redisplay_function;
extern VFunction *rl_prep_term_function;
extern VFunction *rl_deprep_term_function;
/* The address of the function to call to fetch a character from the current
Readline input stream */
extern rl_getc_func_t *rl_getc_function;
extern rl_voidfunc_t *rl_redisplay_function;
extern rl_vintfunc_t *rl_prep_term_function;
extern rl_voidfunc_t *rl_deprep_term_function;
/* Dispatch variables. */
extern Keymap rl_executing_keymap;
@ -481,6 +557,9 @@ extern int rl_already_prompted;
up to a character bound to accept-line. */
extern int rl_num_chars_to_read;
/* The text of a currently-executing keyboard macro. */
extern char *rl_executing_macro;
/* Variables to control readline signal handling. */
/* If non-zero, readline will install its own signal handlers for
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
@ -495,9 +574,9 @@ extern int rl_catch_sigwinch;
/* Completion variables. */
/* Pointer to the generator function for completion_matches ().
NULL means to use filename_entry_function (), the default filename
completer. */
extern Function *rl_completion_entry_function;
NULL means to use rl_filename_completion_function (), the default
filename completer. */
extern rl_compentry_func_t *rl_completion_entry_function;
/* If rl_ignore_some_completions_function is non-NULL it is the address
of a function to call after all of the possible matches have been
@ -505,7 +584,7 @@ extern Function *rl_completion_entry_function;
The function is called with one argument; a NULL terminated array
of (char *). If your function removes any of the elements, they
must be free()'ed. */
extern Function *rl_ignore_some_completions_function;
extern rl_compignore_func_t *rl_ignore_some_completions_function;
/* Pointer to alternative function to create matches.
Function is called with TEXT, START, and END.
@ -514,39 +593,50 @@ extern Function *rl_ignore_some_completions_function;
If this function exists and returns NULL then call the value of
rl_completion_entry_function to try to match, otherwise use the
array of strings returned. */
extern CPPFunction *rl_attempted_completion_function;
extern rl_completion_func_t *rl_attempted_completion_function;
/* The basic list of characters that signal a break between words for the
completer routine. The initial contents of this variable is what
breaks words in the shell, i.e. "n\"\\'`@$>". */
extern char *rl_basic_word_break_characters;
extern const char *rl_basic_word_break_characters;
/* The list of characters that signal a break between words for
rl_complete_internal. The default list is the contents of
rl_basic_word_break_characters. */
extern char *rl_completer_word_break_characters;
extern const char *rl_completer_word_break_characters;
/* List of characters which can be used to quote a substring of the line.
Completion occurs on the entire substring, and within the substring
rl_completer_word_break_characters are treated as any other character,
unless they also appear within this list. */
extern char *rl_completer_quote_characters;
extern const char *rl_completer_quote_characters;
/* List of quote characters which cause a word break. */
extern char *rl_basic_quote_characters;
extern const char *rl_basic_quote_characters;
/* List of characters that need to be quoted in filenames by the completer. */
extern char *rl_filename_quote_characters;
extern const char *rl_filename_quote_characters;
/* List of characters that are word break characters, but should be left
in TEXT when it is passed to the completion function. The shell uses
this to help determine what kind of completing to do. */
extern char *rl_special_prefixes;
extern const char *rl_special_prefixes;
/* If non-zero, then this is the address of a function to call when
completing on a directory name. The function is called with
the address of a string (the current directory name) as an arg. */
extern Function *rl_directory_completion_hook;
the address of a string (the current directory name) as an arg. It
changes what is displayed when the possible completions are printed
or inserted. */
extern rl_icppfunc_t *rl_directory_completion_hook;
/* If non-zero, this is the address of a function to call when completing
a directory name. This function takes the address of the directory name
to be modified as an argument. Unlike rl_directory_completion_hook, it
only modifies the directory name used in opendir(2), not what is displayed
when the possible completions are printed or inserted. It is called
before rl_directory_completion_hook. I'm not happy with how this works
yet, so it's undocumented. */
extern rl_icppfunc_t *rl_directory_rewrite_hook;
/* Backwards compatibility with previous versions of readline. */
#define rl_symbolic_link_hook rl_directory_completion_hook
@ -558,7 +648,7 @@ extern Function *rl_directory_completion_hook;
where MATCHES is the array of strings that matched, NUM_MATCHES is the
number of strings in that array, and MAX_LENGTH is the length of the
longest string in that array. */
extern VFunction *rl_completion_display_matches_hook;
extern rl_compdisp_func_t *rl_completion_display_matches_hook;
/* Non-zero means that the results of the matches are to be treated
as filenames. This is ALWAYS zero on entry, and can only be changed
@ -576,17 +666,17 @@ extern int rl_filename_quoting_desired;
Called with the text to quote, the type of match found (single or multiple)
and a pointer to the quoting character to be used, which the function can
reset if desired. */
extern CPFunction *rl_filename_quoting_function;
extern rl_quote_func_t *rl_filename_quoting_function;
/* Function to call to remove quoting characters from a filename. Called
before completion is attempted, so the embedded quotes do not interfere
with matching names in the file system. */
extern CPFunction *rl_filename_dequoting_function;
extern rl_dequote_func_t *rl_filename_dequoting_function;
/* Function to call to decide whether or not a word break character is
quoted. If a character is quoted, it does not break words for the
completer. */
extern Function *rl_char_is_quoted_p;
extern rl_linebuf_func_t *rl_char_is_quoted_p;
/* Non-zero means to suppress normal filename completion after the
user-specified completion function has been called. */
@ -601,18 +691,33 @@ extern int rl_completion_type;
default is a space. Nothing is added if this is '\0'. */
extern int rl_completion_append_character;
/* If set to non-zero by an application completion function,
rl_completion_append_character will not be appended. */
extern int rl_completion_suppress_append;
/* Up to this many items will be displayed in response to a
possible-completions call. After that, we ask the user if she
is sure she wants to see them all. The default value is 100. */
extern int rl_completion_query_items;
/* If non-zero, a slash will be appended to completed filenames that are
symbolic links to directory names, subject to the value of the
mark-directories variable (which is user-settable). This exists so
that application completion functions can override the user's preference
(set via the mark-symlinked-directories variable) if appropriate.
It's set to the value of _rl_complete_mark_symlink_dirs in
rl_complete_internal before any application-specific completion
function is called, so without that function doing anything, the user's
preferences are honored. */
extern int rl_completion_mark_symlink_dirs;
/* If non-zero, then disallow duplicates in the matches. */
extern int rl_ignore_completion_duplicates;
/* If this is non-zero, completion is (temporarily) inhibited, and the
completion character will be inserted as any other. */
extern int rl_inhibit_completion;
/* Definitions available for use by readline clients. */
#define RL_PROMPT_START_IGNORE '\001'
#define RL_PROMPT_END_IGNORE '\002'
@ -623,11 +728,69 @@ extern int rl_inhibit_completion;
#define SINGLE_MATCH 1
#define MULT_MATCH 2
#if 0
#if !defined (savestring)
extern char *savestring __P((char *)); /* XXX backwards compatibility */
#endif
#endif
/* Possible state values for rl_readline_state */
#define RL_STATE_NONE 0x00000 /* no state; before first call */
#define RL_STATE_INITIALIZING 0x00001 /* initializing */
#define RL_STATE_INITIALIZED 0x00002 /* initialization done */
#define RL_STATE_TERMPREPPED 0x00004 /* terminal is prepped */
#define RL_STATE_READCMD 0x00008 /* reading a command key */
#define RL_STATE_METANEXT 0x00010 /* reading input after ESC */
#define RL_STATE_DISPATCHING 0x00020 /* dispatching to a command */
#define RL_STATE_MOREINPUT 0x00040 /* reading more input in a command function */
#define RL_STATE_ISEARCH 0x00080 /* doing incremental search */
#define RL_STATE_NSEARCH 0x00100 /* doing non-inc search */
#define RL_STATE_SEARCH 0x00200 /* doing a history search */
#define RL_STATE_NUMERICARG 0x00400 /* reading numeric argument */
#define RL_STATE_MACROINPUT 0x00800 /* getting input from a macro */
#define RL_STATE_MACRODEF 0x01000 /* defining keyboard macro */
#define RL_STATE_OVERWRITE 0x02000 /* overwrite mode */
#define RL_STATE_COMPLETING 0x04000 /* doing completion */
#define RL_STATE_SIGHANDLER 0x08000 /* in readline sighandler */
#define RL_STATE_UNDOING 0x10000 /* doing an undo */
#define RL_STATE_INPUTPENDING 0x20000 /* rl_execute_next called */
#define RL_STATE_DONE 0x80000 /* done; accepted line */
#define RL_SETSTATE(x) (rl_readline_state |= (x))
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
#define RL_ISSTATE(x) (rl_readline_state & (x))
struct readline_state {
/* line state */
int point;
int end;
int mark;
char *buffer;
int buflen;
UNDO_LIST *ul;
char *prompt;
/* global state */
int rlstate;
int done;
Keymap kmap;
/* input state */
rl_command_func_t *lastfunc;
int insmode;
int edmode;
int kseqlen;
FILE *inf;
FILE *outf;
int pendingin;
char *macro;
/* signal state */
int catchsigs;
int catchsigwinch;
/* reserved for future expansion, so the struct size doesn't change */
char reserved[64];
};
extern int rl_save_state PARAMS((struct readline_state *));
extern int rl_restore_state PARAMS((struct readline_state *));
#ifdef __cplusplus
}

View File

@ -54,4 +54,7 @@
X `callback' style. */
#define READLINE_CALLBACKS
/* Define this if you want the cursor to indicate insert or overwrite mode. */
/* #define CURSOR_MODE */
#endif /* _RLCONF_H_ */

View File

@ -30,6 +30,8 @@
# include "config.h"
#endif
#include "rlstdc.h"
#if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
# define TERMIOS_TTY_DRIVER
#else
@ -71,7 +73,14 @@ extern char *strchr (), *strrchr ();
#define _rl_stricmp strcasecmp
#define _rl_strnicmp strncasecmp
#else
extern int _rl_stricmp (), _rl_strnicmp ();
extern int _rl_stricmp PARAMS((char *, char *));
extern int _rl_strnicmp PARAMS((char *, char *, int));
#endif
#if defined (HAVE_STRPBRK)
# define _rl_strpbrk(a,b) strpbrk((a),(b))
#else
extern char *_rl_strpbrk PARAMS((const char *, const char *));
#endif
#if !defined (emacs_mode)
@ -80,6 +89,13 @@ extern int _rl_stricmp (), _rl_strnicmp ();
# define emacs_mode 1
#endif
#if !defined (RL_IM_INSERT)
# define RL_IM_INSERT 1
# define RL_IM_OVERWRITE 0
#
# define RL_IM_DEFAULT RL_IM_INSERT
#endif
/* If you cast map[key].function to type (Keymap) on a Cray,
the compiler takes the value of map[key].function and
divides it by 4 to convert between pointer types (pointers
@ -87,15 +103,14 @@ extern int _rl_stricmp (), _rl_strnicmp ();
This is not what is wanted. */
#if defined (CRAY)
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)((int)map[key].function)
# define KEYMAP_TO_FUNCTION(data) (Function *)((int)(data))
# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)((int)(data))
#else
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)(map[key].function)
# define KEYMAP_TO_FUNCTION(data) (Function *)(data)
# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)(data)
#endif
#ifndef savestring
extern char *xmalloc ();
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
#endif
/* Possible values for _rl_bell_preference. */
@ -113,9 +128,10 @@ extern char *xmalloc ();
/* Possible values for the found_quote flags word used by the completion
functions. It says what kind of (shell-like) quoting we found anywhere
in the line. */
#define RL_QF_SINGLE_QUOTE 0x1
#define RL_QF_DOUBLE_QUOTE 0x2
#define RL_QF_BACKSLASH 0x4
#define RL_QF_SINGLE_QUOTE 0x01
#define RL_QF_DOUBLE_QUOTE 0x02
#define RL_QF_BACKSLASH 0x04
#define RL_QF_OTHER_QUOTE 0x08
/* Default readline line buffer length. */
#define DEFAULT_BUFFER_SIZE 256
@ -130,6 +146,10 @@ extern char *xmalloc ();
# define FREE(x) if (x) free (x)
#endif
#if !defined (SWAP)
# define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
#endif
/* CONFIGURATION SECTION */
#include "rlconf.h"

108
readline/rlmbutil.h Normal file
View File

@ -0,0 +1,108 @@
/* rlmbutil.h -- utility functions for multibyte characters. */
/* Copyright (C) 2001 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#if !defined (_RL_MBUTIL_H_)
#define _RL_MBUTIL_H_
#include "rlstdc.h"
/************************************************/
/* check multibyte capability for I18N code */
/************************************************/
/* For platforms which support the ISO C amendement 1 functionality we
support user defined character classes. */
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H)
# include <wchar.h>
# include <wctype.h>
# if defined (HAVE_MBSRTOWCS) /* system is supposed to support XPG5 */
# define HANDLE_MULTIBYTE 1
# endif
#endif
/* Some systems, like BeOS, have multibyte encodings but lack mbstate_t. */
#if HANDLE_MULTIBYTE && !defined (HAVE_MBSTATE_T)
# define wcsrtombs(dest, src, len, ps) (wcsrtombs) (dest, src, len, 0)
# define mbsrtowcs(dest, src, len, ps) (mbsrtowcs) (dest, src, len, 0)
# define wcrtomb(s, wc, ps) (wcrtomb) (s, wc, 0)
# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
# define mbrlen(s, n, ps) (mbrlen) (s, n, 0)
# define mbstate_t int
#endif
/* Make sure MB_LEN_MAX is at least 16 on systems that claim to be able to
handle multibyte chars (some systems define MB_LEN_MAX as 1) */
#ifdef HANDLE_MULTIBYTE
# include <limits.h>
# if defined(MB_LEN_MAX) && (MB_LEN_MAX < 16)
# undef MB_LEN_MAX
# endif
# if !defined (MB_LEN_MAX)
# define MB_LEN_MAX 16
# endif
#endif
/************************************************/
/* end of multibyte capability checks for I18N */
/************************************************/
/*
* Flags for _rl_find_prev_mbchar and _rl_find_next_mbchar:
*
* MB_FIND_ANY find any multibyte character
* MB_FIND_NONZERO find a non-zero-width multibyte character
*/
#define MB_FIND_ANY 0x00
#define MB_FIND_NONZERO 0x01
extern int _rl_find_prev_mbchar PARAMS((char *, int, int));
extern int _rl_find_next_mbchar PARAMS((char *, int, int, int));
#ifdef HANDLE_MULTIBYTE
extern int _rl_compare_chars PARAMS((char *, int, mbstate_t *, char *, int, mbstate_t *));
extern int _rl_get_char_len PARAMS((char *, mbstate_t *));
extern int _rl_adjust_point PARAMS((char *, int, mbstate_t *));
extern int _rl_read_mbchar PARAMS((char *, int));
extern int _rl_read_mbstring PARAMS((int, char *, int));
extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
#else /* !HANDLE_MULTIBYTE */
#undef MB_LEN_MAX
#undef MB_CUR_MAX
#define MB_LEN_MAX 1
#define MB_CUR_MAX 1
#define _rl_find_prev_mbchar(b, i, f) (((i) == 0) ? (i) : ((i) - 1))
#define _rl_find_next_mbchar(b, i1, i2, f) ((i1) + (i2))
#endif /* !HANDLE_MULTIBYTE */
extern int rl_byte_oriented;
#endif /* _RL_MBUTIL_H_ */

View File

@ -26,7 +26,7 @@
#include "rlconf.h" /* for VISIBLE_STATS */
#include "rlstdc.h"
#include "posixjmp.h" /* defines procenv_t */
#include "posixjmp.h" /* defines procenv_t */
/*************************************************************************
* *
@ -34,9 +34,6 @@
* *
*************************************************************************/
/* terminal.c */
extern char *rl_get_termcap __P((char *));
/*************************************************************************
* *
* Global variables undocumented in texinfo manual and not in readline.h *
@ -51,14 +48,11 @@ extern int rl_visible_stats;
/* readline.c */
extern int rl_line_buffer_len;
extern int rl_numeric_arg;
extern int rl_arg_sign;
extern int rl_explicit_arg;
extern int rl_editing_mode;
extern int rl_visible_prompt_length;
extern Function *rl_last_func;
extern int readline_echoing_p;
extern int rl_key_sequence_length;
extern int rl_byte_oriented;
/* display.c */
extern int rl_display_fixed;
@ -72,26 +66,17 @@ extern int rl_blink_matching_paren;
* *
*************************************************************************/
/* bind.c */
extern char *rl_untranslate_keyseq __P((int));
/* kill.c */
extern int rl_set_retained_kills __P((int));
/* readline.c */
extern int rl_discard_argument __P((void));
/* rltty.c */
extern int rl_stop_output __P((int, int));
extern int rl_set_retained_kills PARAMS((int));
/* terminal.c */
extern void _rl_set_screen_size __P((int, int));
extern void _rl_set_screen_size PARAMS((int, int));
/* undo.c */
extern int _rl_fix_last_undo_of_type __P((int, int, int));
extern int _rl_fix_last_undo_of_type PARAMS((int, int, int));
/* util.c */
extern char *_rl_savestring __P((char *));
extern char *_rl_savestring PARAMS((const char *));
/*************************************************************************
* *
@ -111,106 +96,135 @@ extern char *_rl_savestring __P((char *));
#if defined(READLINE_CALLBACKS)
/* readline.c */
extern void readline_internal_setup __P((void));
extern char *readline_internal_teardown __P((int));
extern int readline_internal_char __P((void));
extern void readline_internal_setup PARAMS((void));
extern char *readline_internal_teardown PARAMS((int));
extern int readline_internal_char PARAMS((void));
#endif /* READLINE_CALLBACKS */
/* bind.c */
extern void _rl_bind_if_unbound __P((char *, Function *));
extern void _rl_bind_if_unbound PARAMS((const char *, rl_command_func_t *));
/* complete.c */
extern char _rl_find_completion_word PARAMS((int *, int *));
extern void _rl_free_match_list PARAMS((char **));
/* display.c */
extern char *_rl_strip_prompt __P((char *));
extern void _rl_move_cursor_relative __P((int, char *));
extern void _rl_move_vert __P((int));
extern void _rl_save_prompt __P((void));
extern void _rl_restore_prompt __P((void));
extern char *_rl_make_prompt_for_search __P((int));
extern void _rl_erase_at_end_of_line __P((int));
extern void _rl_clear_to_eol __P((int));
extern void _rl_clear_screen __P((void));
extern void _rl_update_final __P((void));
extern void _rl_redisplay_after_sigwinch __P((void));
extern void _rl_clean_up_for_exit __P((void));
extern void _rl_erase_entire_line __P((void));
extern int _rl_currentb_display_line __P((void));
extern char *_rl_strip_prompt PARAMS((char *));
extern void _rl_move_cursor_relative PARAMS((int, const char *));
extern void _rl_move_vert PARAMS((int));
extern void _rl_save_prompt PARAMS((void));
extern void _rl_restore_prompt PARAMS((void));
extern char *_rl_make_prompt_for_search PARAMS((int));
extern void _rl_erase_at_end_of_line PARAMS((int));
extern void _rl_clear_to_eol PARAMS((int));
extern void _rl_clear_screen PARAMS((void));
extern void _rl_update_final PARAMS((void));
extern void _rl_redisplay_after_sigwinch PARAMS((void));
extern void _rl_clean_up_for_exit PARAMS((void));
extern void _rl_erase_entire_line PARAMS((void));
extern int _rl_current_display_line PARAMS((void));
/* input.c */
extern int _rl_any_typein __P((void));
extern int _rl_input_available __P((void));
extern void _rl_insert_typein __P((int));
extern int _rl_any_typein PARAMS((void));
extern int _rl_input_available PARAMS((void));
extern int _rl_input_queued PARAMS((int));
extern void _rl_insert_typein PARAMS((int));
extern int _rl_unget_char PARAMS((int));
/* macro.c */
extern void _rl_with_macro_input __P((char *));
extern int _rl_next_macro_key __P((void));
extern void _rl_push_executing_macro __P((void));
extern void _rl_pop_executing_macro __P((void));
extern void _rl_add_macro_char __P((int));
extern void _rl_kill_kbd_macro __P((void));
extern void _rl_with_macro_input PARAMS((char *));
extern int _rl_next_macro_key PARAMS((void));
extern void _rl_push_executing_macro PARAMS((void));
extern void _rl_pop_executing_macro PARAMS((void));
extern void _rl_add_macro_char PARAMS((int));
extern void _rl_kill_kbd_macro PARAMS((void));
/* misc.c */
extern int _rl_init_argument PARAMS((void));
extern void _rl_start_using_history PARAMS((void));
extern int _rl_free_saved_history_line PARAMS((void));
extern void _rl_set_insert_mode PARAMS((int, int));
/* nls.c */
extern int _rl_init_eightbit __P((void));
extern int _rl_init_eightbit PARAMS((void));
/* parens.c */
extern void _rl_enable_paren_matching __P((int));
extern void _rl_enable_paren_matching PARAMS((int));
/* readline.c */
extern void _rl_init_line_state __P((void));
extern void _rl_set_the_line __P((void));
extern int _rl_dispatch __P((int, Keymap));
extern int _rl_init_argument __P((void));
extern void _rl_fix_point __P((int));
extern void _rl_replace_text __P((char *, int, int));
extern int _rl_char_search_internal __P((int, int, int));
extern int _rl_set_mark_at_pos __P((int));
extern void _rl_init_line_state PARAMS((void));
extern void _rl_set_the_line PARAMS((void));
extern int _rl_dispatch PARAMS((int, Keymap));
extern int _rl_dispatch_subseq PARAMS((int, Keymap, int));
/* rltty.c */
extern int _rl_disable_tty_signals __P((void));
extern int _rl_restore_tty_signals __P((void));
extern int _rl_disable_tty_signals PARAMS((void));
extern int _rl_restore_tty_signals PARAMS((void));
/* terminal.c */
extern void _rl_get_screen_size __P((int, int));
extern int _rl_init_terminal_io __P((char *));
extern void _rl_get_screen_size PARAMS((int, int));
extern int _rl_init_terminal_io PARAMS((const char *));
#ifdef _MINIX
extern void _rl_output_character_function __P((int));
extern void _rl_output_character_function PARAMS((int));
#else
extern int _rl_output_character_function __P((int));
extern int _rl_output_character_function PARAMS((int));
#endif
extern void _rl_output_some_chars __P((char *, int));
extern int _rl_backspace __P((int));
extern void _rl_enable_meta_key __P((void));
extern void _rl_control_keypad __P((int));
extern void _rl_output_some_chars PARAMS((const char *, int));
extern int _rl_backspace PARAMS((int));
extern void _rl_enable_meta_key PARAMS((void));
extern void _rl_control_keypad PARAMS((int));
extern void _rl_set_cursor PARAMS((int, int));
/* text.c */
extern void _rl_fix_point PARAMS((int));
extern int _rl_replace_text PARAMS((const char *, int, int));
extern int _rl_insert_char PARAMS((int, int));
extern int _rl_overwrite_char PARAMS((int, int));
extern int _rl_overwrite_rubout PARAMS((int, int));
extern int _rl_rubout_char PARAMS((int, int));
#if defined (HANDLE_MULTIBYTE)
extern int _rl_char_search_internal PARAMS((int, int, char *, int));
#else
extern int _rl_char_search_internal PARAMS((int, int, int));
#endif
extern int _rl_set_mark_at_pos PARAMS((int));
/* util.c */
extern int alphabetic __P((int));
extern int _rl_abort_internal __P((void));
extern char *_rl_strindex __P((char *, char *));
extern int _rl_qsort_string_compare __P((char **, char **));
extern int (_rl_uppercase_p) __P((int));
extern int (_rl_lowercase_p) __P((int));
extern int (_rl_pure_alphabetic) __P((int));
extern int (_rl_digit_p) __P((int));
extern int (_rl_to_lower) __P((int));
extern int (_rl_to_upper) __P((int));
extern int (_rl_digit_value) __P((int));
extern int _rl_abort_internal PARAMS((void));
extern char *_rl_strindex PARAMS((const char *, const char *));
extern int _rl_qsort_string_compare PARAMS((char **, char **));
extern int (_rl_uppercase_p) PARAMS((int));
extern int (_rl_lowercase_p) PARAMS((int));
extern int (_rl_pure_alphabetic) PARAMS((int));
extern int (_rl_digit_p) PARAMS((int));
extern int (_rl_to_lower) PARAMS((int));
extern int (_rl_to_upper) PARAMS((int));
extern int (_rl_digit_value) PARAMS((int));
/* vi_mode.c */
extern void _rl_vi_initialize_line __P((void));
extern void _rl_vi_reset_last __P((void));
extern void _rl_vi_set_last __P((int, int, int));
extern int _rl_vi_textmod_command __P((int));
extern void _rl_vi_done_inserting __P((void));
extern void _rl_vi_initialize_line PARAMS((void));
extern void _rl_vi_reset_last PARAMS((void));
extern void _rl_vi_set_last PARAMS((int, int, int));
extern int _rl_vi_textmod_command PARAMS((int));
extern void _rl_vi_done_inserting PARAMS((void));
/*************************************************************************
* Undocumented private variables *
*************************************************************************/
/* bind.c */
extern const char *_rl_possible_control_prefixes[];
extern const char *_rl_possible_meta_prefixes[];
/* complete.c */
extern int _rl_complete_show_all;
extern int _rl_complete_mark_directories;
extern int _rl_complete_mark_symlink_dirs;
extern int _rl_print_completions_horizontally;
extern int _rl_completion_case_fold;
extern int _rl_match_hidden_files;
extern int _rl_page_completions;
/* display.c */
extern int _rl_vis_botlin;
@ -218,17 +232,16 @@ extern int _rl_last_c_pos;
extern int _rl_suppress_redisplay;
extern char *rl_display_prompt;
/* funmap.c */
extern char *possible_control_prefixes[];
extern char *possible_meta_prefixes[];
/* isearch.c */
extern unsigned char *_rl_isearch_terminators;
extern char *_rl_isearch_terminators;
/* macro.c */
extern int _rl_defining_kbd_macro;
extern char *_rl_executing_macro;
/* misc.c */
extern int _rl_history_preserve_point;
extern int _rl_history_saved_point;
/* readline.c */
extern int _rl_horizontal_scroll_mode;
extern int _rl_mark_modified_lines;
@ -248,20 +261,20 @@ extern procenv_t readline_top_level;
/* terminal.c */
extern int _rl_enable_keypad;
extern int _rl_enable_meta;
extern char *term_clreol;
extern char *term_clrpag;
extern char *term_im;
extern char *term_ic;
extern char *term_ei;
extern char *term_DC;
extern char *term_up;
extern char *term_dc;
extern char *term_cr;
extern char *term_IC;
extern int screenheight;
extern int screenwidth;
extern int screenchars;
extern int terminal_can_insert;
extern char *_rl_term_clreol;
extern char *_rl_term_clrpag;
extern char *_rl_term_im;
extern char *_rl_term_ic;
extern char *_rl_term_ei;
extern char *_rl_term_DC;
extern char *_rl_term_up;
extern char *_rl_term_dc;
extern char *_rl_term_cr;
extern char *_rl_term_IC;
extern int _rl_screenheight;
extern int _rl_screenwidth;
extern int _rl_screenchars;
extern int _rl_terminal_can_insert;
extern int _rl_term_autowrap;
/* undo.c */

View File

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

View File

@ -26,13 +26,19 @@
/* A function can be defined using prototypes and compile on both ANSI C
and traditional C compilers with something like this:
extern char *func __P((char *, char *, int)); */
extern char *func PARAMS((char *, char *, int)); */
#if !defined (__P)
#if !defined (PARAMS)
# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
# define __P(protos) protos
# define PARAMS(protos) protos
# else
# define __P(protos) ()
# define PARAMS(protos) ()
# endif
#endif
#ifndef __attribute__
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
# define __attribute__(x)
# endif
#endif

View File

@ -49,8 +49,13 @@
extern int errno;
#endif /* !errno */
VFunction *rl_prep_term_function = rl_prep_terminal;
VFunction *rl_deprep_term_function = rl_deprep_terminal;
rl_vintfunc_t *rl_prep_term_function = rl_prep_terminal;
rl_voidfunc_t *rl_deprep_term_function = rl_deprep_terminal;
static void block_sigint PARAMS((void));
static void release_sigint PARAMS((void));
static void set_winsize PARAMS((int));
/* **************************************************************** */
/* */
@ -173,6 +178,14 @@ struct bsdtty {
static TIOTYPE otio;
static void save_tty_chars PARAMS((TIOTYPE *));
static int _get_tty_settings PARAMS((int, TIOTYPE *));
static int get_tty_settings PARAMS((int, TIOTYPE *));
static int _set_tty_settings PARAMS((int, TIOTYPE *));
static int set_tty_settings PARAMS((int, TIOTYPE *));
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
static void
save_tty_chars (tiop)
TIOTYPE *tiop;
@ -220,22 +233,23 @@ get_tty_settings (tty, tiop)
tiop->flags = tiop->lflag = 0;
ioctl (tty, TIOCGETP, &(tiop->sgttyb));
if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
return -1;
tiop->flags |= SGTTY_SET;
#if defined (TIOCLGET)
ioctl (tty, TIOCLGET, &(tiop->lflag));
tiop->flags |= LFLAG_SET;
if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0)
tiop->flags |= LFLAG_SET;
#endif
#if defined (TIOCGETC)
ioctl (tty, TIOCGETC, &(tiop->tchars));
tiop->flags |= TCHARS_SET;
if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0)
tiop->flags |= TCHARS_SET;
#endif
#if defined (TIOCGLTC)
ioctl (tty, TIOCGLTC, &(tiop->ltchars));
tiop->flags |= LTCHARS_SET;
if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0)
tiop->flags |= LTCHARS_SET;
#endif
return 0;
@ -281,23 +295,23 @@ set_tty_settings (tty, tiop)
}
static void
prepare_terminal_settings (meta_flag, otio, tiop)
prepare_terminal_settings (meta_flag, oldtio, tiop)
int meta_flag;
TIOTYPE otio, *tiop;
TIOTYPE oldtio, *tiop;
{
readline_echoing_p = (otio.sgttyb.sg_flags & ECHO);
readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
/* Copy the original settings to the structure we're going to use for
our settings. */
tiop->sgttyb = otio.sgttyb;
tiop->lflag = otio.lflag;
tiop->sgttyb = oldtio.sgttyb;
tiop->lflag = oldtio.lflag;
#if defined (TIOCGETC)
tiop->tchars = otio.tchars;
tiop->tchars = oldtio.tchars;
#endif
#if defined (TIOCGLTC)
tiop->ltchars = otio.ltchars;
tiop->ltchars = oldtio.ltchars;
#endif
tiop->flags = otio.flags;
tiop->flags = oldtio.flags;
/* First, the basic settings to put us into character-at-a-time, no-echo
input mode. */
@ -310,8 +324,8 @@ prepare_terminal_settings (meta_flag, otio, tiop)
#if !defined (ANYP)
# define ANYP (EVENP | ODDP)
#endif
if (((otio.sgttyb.sg_flags & ANYP) == ANYP) ||
((otio.sgttyb.sg_flags & ANYP) == 0))
if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
((oldtio.sgttyb.sg_flags & ANYP) == 0))
{
tiop->sgttyb.sg_flags |= ANYP;
@ -330,13 +344,13 @@ prepare_terminal_settings (meta_flag, otio, tiop)
tiop->tchars.t_startc = -1; /* C-q */
/* If there is an XON character, bind it to restart the output. */
if (otio.tchars.t_startc != -1)
rl_bind_key (otio.tchars.t_startc, rl_restart_output);
if (oldtio.tchars.t_startc != -1)
rl_bind_key (oldtio.tchars.t_startc, rl_restart_output);
# endif /* USE_XON_XOFF */
/* If there is an EOF char, bind _rl_eof_char to it. */
if (otio.tchars.t_eofc != -1)
_rl_eof_char = otio.tchars.t_eofc;
if (oldtio.tchars.t_eofc != -1)
_rl_eof_char = oldtio.tchars.t_eofc;
# if defined (NO_KILL_INTR)
/* Get rid of terminal-generated SIGQUIT and SIGINT. */
@ -375,11 +389,19 @@ prepare_terminal_settings (meta_flag, otio, tiop)
# define TIOTYPE struct termio
# define DRAIN_OUTPUT(fd)
# define GETATTR(tty, tiop) (ioctl (tty, TCGETA, tiop))
# define SETATTR(tty, tiop) (ioctl (tty, TCSETA, tiop))
# define SETATTR(tty, tiop) (ioctl (tty, TCSETAW, tiop))
#endif /* !TERMIOS_TTY_DRIVER */
static TIOTYPE otio;
static void save_tty_chars PARAMS((TIOTYPE *));
static int _get_tty_settings PARAMS((int, TIOTYPE *));
static int get_tty_settings PARAMS((int, TIOTYPE *));
static int _set_tty_settings PARAMS((int, TIOTYPE *));
static int set_tty_settings PARAMS((int, TIOTYPE *));
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
#if defined (FLUSHO)
# define OUTPUT_BEING_FLUSHED(tp) (tp->c_lflag & FLUSHO)
#else
@ -549,16 +571,16 @@ set_tty_settings (tty, tiop)
}
static void
prepare_terminal_settings (meta_flag, otio, tiop)
prepare_terminal_settings (meta_flag, oldtio, tiop)
int meta_flag;
TIOTYPE otio, *tiop;
TIOTYPE oldtio, *tiop;
{
readline_echoing_p = (otio.c_lflag & ECHO);
readline_echoing_p = (oldtio.c_lflag & ECHO);
tiop->c_lflag &= ~(ICANON | ECHO);
if ((unsigned char) otio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
_rl_eof_char = otio.c_cc[VEOF];
if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
_rl_eof_char = oldtio.c_cc[VEOF];
#if defined (USE_XON_XOFF)
#if defined (IXANY)
@ -589,7 +611,7 @@ prepare_terminal_settings (meta_flag, otio, tiop)
if (OUTPUT_BEING_FLUSHED (tiop))
{
tiop->c_lflag &= ~FLUSHO;
otio.c_lflag &= ~FLUSHO;
oldtio.c_lflag &= ~FLUSHO;
}
#endif
@ -649,6 +671,7 @@ rl_prep_terminal (meta_flag)
fflush (rl_outstream);
terminal_prepped = 1;
RL_SETSTATE(RL_STATE_TERMPREPPED);
release_sigint ();
}
@ -679,6 +702,7 @@ rl_deprep_terminal ()
}
terminal_prepped = 0;
RL_UNSETSTATE(RL_STATE_TERMPREPPED);
release_sigint ();
}
@ -755,6 +779,9 @@ rl_stop_output (count, key)
/* Default Key Bindings */
/* */
/* **************************************************************** */
/* Set the system's default editing characters to their readline equivalents
in KMAP. Should be static, now that we have rl_tty_set_default_bindings. */
void
rltty_set_default_bindings (kmap)
Keymap kmap;
@ -769,8 +796,8 @@ rltty_set_default_bindings (kmap)
{ \
int ic; \
ic = sc; \
if (ic != -1 && kmap[ic].type == ISFUNC) \
kmap[ic].function = func; \
if (ic != -1 && kmap[(unsigned char)ic].type == ISFUNC) \
kmap[(unsigned char)ic].function = func; \
} \
while (0)
@ -819,6 +846,15 @@ rltty_set_default_bindings (kmap)
#endif /* !NEW_TTY_DRIVER */
}
/* New public way to set the system default editing chars to their readline
equivalents. */
void
rl_tty_set_default_bindings (kmap)
Keymap kmap;
{
rltty_set_default_bindings (kmap);
}
#if defined (HANDLE_SIGNALS)
#if defined (NEW_TTY_DRIVER)
@ -850,6 +886,7 @@ _rl_disable_tty_signals ()
nosigstty = sigstty;
nosigstty.c_lflag &= ~ISIG;
nosigstty.c_iflag &= ~IXON;
if (_set_tty_settings (fileno (rl_instream), &nosigstty) < 0)
return (_set_tty_settings (fileno (rl_instream), &sigstty));
@ -861,10 +898,17 @@ _rl_disable_tty_signals ()
int
_rl_restore_tty_signals ()
{
int r;
if (tty_sigs_disabled == 0)
return 0;
return (_set_tty_settings (fileno (rl_instream), &sigstty));
r = _set_tty_settings (fileno (rl_instream), &sigstty);
if (r == 0)
tty_sigs_disabled = 0;
return r;
}
#endif /* !NEW_TTY_DRIVER */

88
readline/rltypedefs.h Normal file
View File

@ -0,0 +1,88 @@
/* rltypedefs.h -- Type declarations for readline functions. */
/* Copyright (C) 2000 Free Software Foundation, Inc.
This file is part of the GNU Readline Library, a library for
reading lines of text with interactive input and history editing.
The GNU Readline Library is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2, or
(at your option) any later version.
The GNU Readline Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
The GNU General Public License is often shipped with GNU software, and
is generally kept in a file called COPYING or LICENSE. If you do not
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
#ifndef _RL_TYPEDEFS_H_
#define _RL_TYPEDEFS_H_
#ifdef __cplusplus
extern "C" {
#endif
/* Old-style */
#if !defined (_FUNCTION_DEF)
# define _FUNCTION_DEF
typedef int Function ();
typedef void VFunction ();
typedef char *CPFunction ();
typedef char **CPPFunction ();
#endif /* _FUNCTION_DEF */
/* New style. */
#if !defined (_RL_FUNCTION_TYPEDEF)
# define _RL_FUNCTION_TYPEDEF
/* Bindable functions */
typedef int rl_command_func_t PARAMS((int, int));
/* Typedefs for the completion system */
typedef char *rl_compentry_func_t PARAMS((const char *, int));
typedef char **rl_completion_func_t PARAMS((const char *, int, int));
typedef char *rl_quote_func_t PARAMS((char *, int, char *));
typedef char *rl_dequote_func_t PARAMS((char *, int));
typedef int rl_compignore_func_t PARAMS((char **));
typedef void rl_compdisp_func_t PARAMS((char **, int, int));
/* Type for input and pre-read hook functions like rl_event_hook */
typedef int rl_hook_func_t PARAMS((void));
/* Input function type */
typedef int rl_getc_func_t PARAMS((FILE *));
/* Generic function that takes a character buffer (which could be the readline
line buffer) and an index into it (which could be rl_point) and returns
an int. */
typedef int rl_linebuf_func_t PARAMS((char *, int));
/* `Generic' function pointer typedefs */
typedef int rl_intfunc_t PARAMS((int));
#define rl_ivoidfunc_t rl_hook_func_t
typedef int rl_icpfunc_t PARAMS((char *));
typedef int rl_icppfunc_t PARAMS((char **));
typedef void rl_voidfunc_t PARAMS((void));
typedef void rl_vintfunc_t PARAMS((int));
typedef void rl_vcpfunc_t PARAMS((char *));
typedef void rl_vcppfunc_t PARAMS((char **));
#endif /* _RL_FUNCTION_TYPEDEF */
#ifdef __cplusplus
}
#endif
#endif /* _RL_TYPEDEFS_H_ */

View File

@ -20,14 +20,17 @@
have a copy of the license, write to the Free Software Foundation,
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
extern char *strcpy ();
extern char *xmalloc ();
#include <config.h>
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "xmalloc.h"
/* Backwards compatibility, now that savestring has been removed from
all `public' readline header files. */
char *
savestring (s)
char *s;
const char *s;
{
return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s)));
return ((char *)strcpy ((char *)xmalloc (1 + strlen (s)), (s)));
}

View File

@ -40,6 +40,8 @@
#endif
#include "rldefs.h"
#include "rlmbutil.h"
#include "readline.h"
#include "history.h"
@ -51,10 +53,10 @@
#endif
#define abs(x) (((x) >= 0) ? (x) : -(x))
extern HIST_ENTRY *saved_line_for_history;
extern HIST_ENTRY *_rl_saved_line_for_history;
/* Functions imported from the rest of the library. */
extern int _rl_free_history_entry __P((HIST_ENTRY *));
extern int _rl_free_history_entry PARAMS((HIST_ENTRY *));
static char *noninc_search_string = (char *) NULL;
static int noninc_history_pos;
@ -66,6 +68,13 @@ static int rl_history_search_pos;
static char *history_search_string;
static int history_string_size;
static void make_history_line_current PARAMS((HIST_ENTRY *));
static int noninc_search_from_pos PARAMS((char *, int, int));
static void noninc_dosearch PARAMS((char *, int));
static void noninc_search PARAMS((int, int));
static int rl_history_search_internal PARAMS((int, int));
static void rl_history_search_reinit PARAMS((void));
/* Make the data from the history entry ENTRY be the contents of the
current line. This doesn't do anything with rl_point; the caller
must set it. */
@ -73,19 +82,12 @@ static void
make_history_line_current (entry)
HIST_ENTRY *entry;
{
int line_len;
line_len = strlen (entry->line);
if (line_len >= rl_line_buffer_len)
rl_extend_line_buffer (line_len);
strcpy (rl_line_buffer, entry->line);
rl_replace_line (entry->line, 0);
rl_undo_list = (UNDO_LIST *)entry->data;
rl_end = line_len;
if (saved_line_for_history)
_rl_free_history_entry (saved_line_for_history);
saved_line_for_history = (HIST_ENTRY *)NULL;
if (_rl_saved_line_for_history)
_rl_free_history_entry (_rl_saved_line_for_history);
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
}
/* Search the history list for STRING starting at absolute history position
@ -100,13 +102,19 @@ noninc_search_from_pos (string, pos, dir)
{
int ret, old;
old = where_history ();
history_set_pos (pos);
if (pos < 0)
return -1;
old = where_history ();
if (history_set_pos (pos) == 0)
return -1;
RL_SETSTATE(RL_STATE_SEARCH);
if (*string == '^')
ret = history_search_prefix (string + 1, dir);
else
ret = history_search (string, dir);
RL_UNSETSTATE(RL_STATE_SEARCH);
if (ret != -1)
ret = where_history ();
@ -128,7 +136,7 @@ noninc_dosearch (string, dir)
if (string == 0 || *string == '\0' || noninc_history_pos < 0)
{
ding ();
rl_ding ();
return;
}
@ -136,10 +144,10 @@ noninc_dosearch (string, dir)
if (pos == -1)
{
/* Search failed, current history position unchanged. */
maybe_unsave_line ();
rl_maybe_unsave_line ();
rl_clear_message ();
rl_point = 0;
ding ();
rl_ding ();
return;
}
@ -156,6 +164,8 @@ noninc_dosearch (string, dir)
make_history_line_current (entry);
rl_point = 0;
rl_mark = rl_end;
rl_clear_message ();
}
@ -169,11 +179,15 @@ noninc_search (dir, pchar)
int dir;
int pchar;
{
int saved_point, c;
int saved_point, saved_mark, c;
char *p;
#if defined (HANDLE_MULTIBYTE)
char mb[MB_LEN_MAX];
#endif
maybe_save_line ();
rl_maybe_save_line ();
saved_point = rl_point;
saved_mark = rl_mark;
/* Use the line buffer to read the search string. */
rl_line_buffer[0] = 0;
@ -183,23 +197,37 @@ noninc_search (dir, pchar)
rl_message (p, 0, 0);
free (p);
#define SEARCH_RETURN rl_restore_prompt (); return
#define SEARCH_RETURN rl_restore_prompt (); RL_UNSETSTATE(RL_STATE_NSEARCH); return
RL_SETSTATE(RL_STATE_NSEARCH);
/* Read the search string. */
while (c = rl_read_key ())
while (1)
{
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
c = _rl_read_mbstring (c, mb, MB_LEN_MAX);
#endif
if (c == 0)
break;
switch (c)
{
case CTRL('H'):
case RUBOUT:
if (rl_point == 0)
{
maybe_unsave_line ();
rl_maybe_unsave_line ();
rl_clear_message ();
rl_point = saved_point;
rl_mark = saved_mark;
SEARCH_RETURN;
}
rl_rubout (1, c);
_rl_rubout_char (1, c);
break;
case CTRL('W'):
@ -218,20 +246,28 @@ noninc_search (dir, pchar)
case CTRL('C'):
case CTRL('G'):
maybe_unsave_line ();
rl_maybe_unsave_line ();
rl_clear_message ();
rl_point = saved_point;
ding ();
rl_mark = saved_mark;
rl_ding ();
SEARCH_RETURN;
default:
rl_insert (1, c);
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
rl_insert_text (mb);
else
#endif
_rl_insert_char (1, c);
break;
}
(*rl_redisplay_function) ();
}
dosearch:
rl_mark = saved_mark;
/* If rl_point == 0, we want to re-use the previous search string and
start from the saved history position. If there's no previous search
string, punt. */
@ -239,7 +275,7 @@ noninc_search (dir, pchar)
{
if (!noninc_search_string)
{
ding ();
rl_ding ();
SEARCH_RETURN;
}
}
@ -253,6 +289,7 @@ noninc_search (dir, pchar)
rl_restore_prompt ();
noninc_dosearch (noninc_search_string, dir);
RL_UNSETSTATE(RL_STATE_NSEARCH);
}
/* Search forward through the history list for a string. If the vi-mode
@ -283,7 +320,7 @@ rl_noninc_forward_search_again (count, key)
{
if (!noninc_search_string)
{
ding ();
rl_ding ();
return (-1);
}
noninc_dosearch (noninc_search_string, 1);
@ -298,7 +335,7 @@ rl_noninc_reverse_search_again (count, key)
{
if (!noninc_search_string)
{
ding ();
rl_ding ();
return (-1);
}
noninc_dosearch (noninc_search_string, -1);
@ -312,7 +349,7 @@ rl_history_search_internal (count, dir)
HIST_ENTRY *temp;
int ret, oldpos;
maybe_save_line ();
rl_maybe_save_line ();
temp = (HIST_ENTRY *)NULL;
/* Search COUNT times through the history for a line whose prefix
@ -341,8 +378,8 @@ rl_history_search_internal (count, dir)
/* If we didn't find anything at all, return. */
if (temp == 0)
{
maybe_unsave_line ();
ding ();
rl_maybe_unsave_line ();
rl_ding ();
/* If you don't want the saved history line (last match) to show up
in the line buffer after the search fails, change the #if 0 to
#if 1 */
@ -351,9 +388,11 @@ rl_history_search_internal (count, dir)
{
rl_point = rl_end = rl_history_search_len;
rl_line_buffer[rl_end] = '\0';
rl_mark = 0;
}
#else
rl_point = rl_history_search_len; /* maybe_unsave_line changes it */
rl_point = rl_history_search_len; /* rl_maybe_unsave_line changes it */
rl_mark = rl_end;
#endif
return 1;
}
@ -362,6 +401,8 @@ rl_history_search_internal (count, dir)
make_history_line_current (temp);
rl_point = rl_history_search_len;
rl_mark = rl_end;
return 0;
}
@ -376,12 +417,13 @@ rl_history_search_reinit ()
if (rl_history_search_len >= history_string_size - 2)
{
history_string_size = rl_history_search_len + 2;
history_search_string = xrealloc (history_search_string, history_string_size);
history_search_string = (char *)xrealloc (history_search_string, history_string_size);
}
history_search_string[0] = '^';
strncpy (history_search_string + 1, rl_line_buffer, rl_point);
history_search_string[rl_point + 1] = '\0';
}
_rl_free_saved_history_line ();
}
/* Search forward in the history for the string of characters

View File

@ -45,28 +45,49 @@
# include <strings.h>
#endif /* !HAVE_STRING_H */
#if defined (HAVE_LIMITS_H)
# include <limits.h>
#endif
#include <fcntl.h>
#include <pwd.h>
#include <stdio.h>
#include "rlstdc.h"
#include "rlshell.h"
#include "xmalloc.h"
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid ();
extern struct passwd *getpwuid PARAMS((uid_t));
#endif /* !HAVE_GETPW_DECLS */
#ifndef NULL
# define NULL 0
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
/* Nonzero if the integer type T is signed. */
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
/* Bound on length of the string representing an integer value of type T.
Subtract one for the sign bit if T is signed;
302 / 1000 is log10 (2) rounded up;
add one for integer division truncation;
add one more for a minus sign if t is signed. */
#define INT_STRLEN_BOUND(t) \
((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \
+ 1 + TYPE_SIGNED (t))
/* All of these functions are resolved from bash if we are linking readline
as part of bash. */
/* Does shell-like quoting using single quotes. */
char *
single_quote (string)
sh_single_quote (string)
char *string;
{
register int c;
@ -97,24 +118,24 @@ single_quote (string)
/* Set the environment variables LINES and COLUMNS to lines and cols,
respectively. */
void
set_lines_and_columns (lines, cols)
sh_set_lines_and_columns (lines, cols)
int lines, cols;
{
char *b;
#if defined (HAVE_PUTENV)
b = xmalloc (24);
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
sprintf (b, "LINES=%d", lines);
putenv (b);
b = xmalloc (24);
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1);
sprintf (b, "COLUMNS=%d", cols);
putenv (b);
#else /* !HAVE_PUTENV */
# if defined (HAVE_SETENV)
b = xmalloc (8);
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
sprintf (b, "%d", lines);
setenv ("LINES", b, 1);
b = xmalloc (8);
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
sprintf (b, "%d", cols);
setenv ("COLUMNS", b, 1);
# endif /* HAVE_SETENV */
@ -122,14 +143,14 @@ set_lines_and_columns (lines, cols)
}
char *
get_env_value (varname)
char *varname;
sh_get_env_value (varname)
const char *varname;
{
return ((char *)getenv (varname));
}
char *
get_home_dir ()
sh_get_home_dir ()
{
char *home_dir;
struct passwd *entry;
@ -148,7 +169,7 @@ get_home_dir ()
#endif
int
unset_nodelay_mode (fd)
sh_unset_nodelay_mode (fd)
int fd;
{
int flags, bflags;

View File

@ -36,6 +36,7 @@ ARFLAGS = @ARFLAGS@
RM = rm -f
CP = cp
MV = mv
LN = ln
SHELL = @MAKE_SHELL@
@ -43,8 +44,12 @@ host_os = @host_os@
prefix = @prefix@
exec_prefix = @exec_prefix@
includedir = @includedir@
libdir = @libdir@
# Support an alternate destination root directory for package building
DESTDIR =
CFLAGS = @CFLAGS@
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
CPPFLAGS = @CPPFLAGS@
@ -81,7 +86,7 @@ SHLIB_MAJOR= @SHLIB_MAJOR@
SHLIB_MINOR= .@SHLIB_MINOR@
# For libraries which include headers from other libraries.
INCLUDES = -I. -I.. -I$(topdir) -I$(includedir)
INCLUDES = -I. -I.. -I$(topdir)
CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES) $(LOCAL_CFLAGS) $(CFLAGS)
@ -108,19 +113,23 @@ CSOURCES = $(topdir)/readline.c $(topdir)/funmap.c $(topdir)/keymaps.c \
$(topdir)/callback.c $(topdir)/terminal.c $(topdir)/xmalloc.c \
$(topdir)/history.c $(topdir)/histsearch.c $(topdir)/histexpand.c \
$(topdir)/histfile.c $(topdir)/nls.c $(topdir)/search.c \
$(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c
$(topdir)/shell.c $(topdir)/savestring.c $(topdir)/tilde.c \
$(topdir)/text.c $(topdir)/misc.c $(topdir)/compat.c \
$(topdir)/mbutil.c
# The header files for this library.
HSOURCES = readline.h rldefs.h chardefs.h keymaps.h history.h histlib.h \
posixstat.h posixdir.h posixjmp.h tilde.h rlconf.h rltty.h \
ansi_stdlib.h tcap.h xmalloc.h rlprivate.h rlshell.h
ansi_stdlib.h tcap.h xmalloc.h rlprivate.h rlshell.h rlmbutil.h
SHARED_HISTOBJ = history.so histexpand.so histfile.so histsearch.so shell.so
SHARED_HISTOBJ = history.so histexpand.so histfile.so histsearch.so shell.so \
mbutil.so
SHARED_TILDEOBJ = tilde.so
SHARED_OBJ = readline.so vi_mode.so funmap.so keymaps.so parens.so search.so \
rltty.so complete.so bind.so isearch.so display.so signals.so \
util.so kill.so undo.so macro.so input.so callback.so terminal.so \
nls.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ)
text.so nls.so misc.so xmalloc.so $(SHARED_HISTOBJ) $(SHARED_TILDEOBJ) \
compat.so
##########################################################################
@ -144,17 +153,24 @@ $(SHARED_HISTORY): $(SHARED_HISTOBJ) xmalloc.so
$(RM) $@
$(SHOBJ_LD) ${SHOBJ_LDFLAGS} ${SHLIB_XLDFLAGS} -o $@ $(SHARED_HISTOBJ) xmalloc.so $(SHLIB_LIBS)
# Since tilde.c is shared between readline and bash, make sure we compile
# it with the right flags when it's built as part of readline
tilde.so: tilde.c
${RM} $@
$(SHOBJ_CC) -c $(CCFLAGS) $(SHOBJ_CFLAGS) -DREADLINE_LIBRARY -c -o tilde.o $(topdir)/tilde.c
$(MV) tilde.o $@
installdirs: $(topdir)/support/mkdirs
-$(SHELL) $(topdir)/support/mkdirs $(libdir)
-$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(libdir)
install: installdirs $(SHLIB_STATUS)
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(libdir) -i "$(INSTALL_DATA)" $(SHARED_HISTORY)
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(libdir) -i "$(INSTALL_DATA)" $(SHARED_READLINE)
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -i "$(INSTALL_DATA)" $(SHARED_HISTORY)
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -i "$(INSTALL_DATA)" $(SHARED_READLINE)
@echo install: you may need to run ldconfig
uninstall:
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(libdir) -U $(SHARED_HISTORY)
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(libdir) -U $(SHARED_READLINE)
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -U $(SHARED_HISTORY)
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -U $(SHARED_READLINE)
@echo uninstall: you may need to run ldconfig
clean mostlyclean: force
@ -173,90 +189,114 @@ force:
bind.so: $(topdir)/ansi_stdlib.h $(topdir)/posixstat.h
bind.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
bind.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
bind.so: $(topdir)/rltypedefs.h
bind.so: $(topdir)/tilde.h $(topdir)/history.h
compat.so: $(topdir)/rlstdc.h
callback.so: $(topdir)/rlconf.h
callback.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h
callback.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
callback.so: $(topdir)/rltypedefs.h
callback.so: $(topdir)/tilde.h
complete.so: $(topdir)/ansi_stdlib.h posixdir.h $(topdir)/posixstat.h
complete.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
complete.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
complete.so: $(topdir)/rltypedefs.h
complete.so: $(topdir)/tilde.h
display.so: $(topdir)/ansi_stdlib.h $(topdir)/posixstat.h
display.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
display.so: $(topdir)/tcap.h
display.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
display.so: $(topdir)/rltypedefs.h
display.so: $(topdir)/tilde.h $(topdir)/history.h
funmap.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
funmap.so: $(topdir)/rltypedefs.h
funmap.so: $(topdir)/rlconf.h $(topdir)/ansi_stdlib.h
funmap.so: ${BUILD_DIR}/config.h $(topdir)/tilde.h
histexpand.so: $(topdir)/ansi_stdlib.h
histexpand.so: $(topdir)/history.h histlib.h
histexpand.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
histexpand.so: ${BUILD_DIR}/config.h
histfile.so: $(topdir)/ansi_stdlib.h
histfile.so: $(topdir)/history.h histlib.h
histfile.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
histfile.so: ${BUILD_DIR}/config.h
history.so: $(topdir)/ansi_stdlib.h
history.so: $(topdir)/history.h histlib.h
history.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
history.so: ${BUILD_DIR}/config.h
histsearch.so: $(topdir)/ansi_stdlib.h
histsearch.so: $(topdir)/history.h histlib.h
histsearch.so: $(topdir)/history.h $(topdir)/histlib.h $(topdir)/rltypedefs.h
histsearch.so: ${BUILD_DIR}/config.h
input.so: $(topdir)/ansi_stdlib.h
input.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
input.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
input.so: $(topdir)/rltypedefs.h
input.so: $(topdir)/tilde.h
isearch.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
isearch.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
isearch.so: $(topdir)/rltypedefs.h
isearch.so: $(topdir)/ansi_stdlib.h $(topdir)/history.h $(topdir)/tilde.h
keymaps.so: emacs_keymap.c vi_keymap.c
keymaps.so: $(topdir)/keymaps.h $(topdir)/chardefs.h $(topdir)/rlconf.h
keymaps.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
keymaps.so: $(topdir)/rltypedefs.h
keymaps.so: ${BUILD_DIR}/config.h $(topdir)/ansi_stdlib.h $(topdir)/tilde.h
kill.so: $(topdir)/ansi_stdlib.h
kill.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
kill.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
kill.so: $(topdir)/tilde.h $(topdir)/history.h
kill.so: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rltypedefs.h
macro.so: $(topdir)/ansi_stdlib.h
macro.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
macro.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
macro.so: $(topdir)/tilde.h $(topdir)/history.h
macro.so: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rltypedefs.h
mbutil.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
mbutil.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/rltypedefs.h
mbutil.so: $(topdir)/chardefs.h $(topdir)/rlstdc.h
misc.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
misc.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
misc.so: $(topdir)/rltypedefs.h
misc.so: $(topdir)/history.h $(topdir)/tilde.h $(topdir)/ansi_stdlib.h
nls.so: $(topdir)/ansi_stdlib.h
nls.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
nls.o: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
nls.o: $(topdir)/rltypedefs.h
nls.o: $(topdir)/tilde.h $(topdir)/history.h $(topdir)/rlstdc.h
parens.so: $(topdir)/rlconf.h ${BUILD_DIR}/config.h
parens.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
parens.so: $(topdir)/rltypedefs.h
parens.so: $(topdir)/tilde.h
readline.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
readline.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
readline.so: $(topdir)/history.h $(topdir)/tilde.h
readline.so: $(topdir)/posixstat.h $(topdir)/ansi_stdlib.h $(topdir)/posixjmp.h
rltty.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
rltty.so: $(topdir)/rltty.h $(topdir)/tilde.h
rltty.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
rltty.so: $(topdir)/rltypedefs.h
search.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
search.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
search.so: $(topdir)/ansi_stdlib.h $(topdir)/history.h $(topdir)/tilde.h
search.so: $(topdir)/rltypedefs.h
signals.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
signals.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
signals.so: $(topdir)/history.h $(topdir)/tilde.h
signals.so: $(topdir)/rltypedefs.h
terminal.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
terminal.so: $(topdir)/tcap.h
terminal.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
terminal.so: $(topdir)/tilde.h $(topdir)/history.h
terminal.so: $(topdir)/rltypedefs.h
text.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
text.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
text.so: $(topdir)/rltypedefs.h
text.so: $(topdir)/history.h $(topdir)/tilde.h $(topdir)/ansi_stdlib.h
tilde.so: $(topdir)/ansi_stdlib.h ${BUILD_DIR}/config.h $(topdir)/tilde.h
undo.so: $(topdir)/ansi_stdlib.h
undo.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
undo.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
undo.so: $(topdir)/rltypedefs.h
undo.so: $(topdir)/tilde.h $(topdir)/history.h
util.so: $(topdir)/posixjmp.h $(topdir)/ansi_stdlib.h
util.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
util.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
util.so: $(topdir)/tilde.h
util.so: $(topdir)/rltypedefs.h $(topdir)/tilde.h
vi_mode.so: $(topdir)/rldefs.h ${BUILD_DIR}/config.h $(topdir)/rlconf.h
vi_mode.so: $(topdir)/readline.h $(topdir)/keymaps.h $(topdir)/chardefs.h
vi_mode.so: $(topdir)/history.h $(topdir)/ansi_stdlib.h $(topdir)/tilde.h
vi_mode.so: $(topdir)/rltypedefs.h
xmalloc.so: ${BUILD_DIR}/config.h
xmalloc.so: $(topdir)/ansi_stdlib.h
@ -276,6 +316,8 @@ input.so: $(topdir)/rlprivate.h
isearch.so: $(topdir)/rlprivate.h
kill.so: $(topdir)/rlprivate.h
macro.so: $(topdir)/rlprivate.h
mbutil.so: $(topdir)/rlprivate.h
misc.so: $(topdir)/rlprivate.h
nls.so: $(topdir)/rlprivate.h
parens.so: $(topdir)/rlprivate.h
readline.so: $(topdir)/rlprivate.h
@ -283,6 +325,7 @@ rltty.so: $(topdir)/rlprivate.h
search.so: $(topdir)/rlprivate.h
signals.so: $(topdir)/rlprivate.h
terminal.so: $(topdir)/rlprivate.h
text.so: $(topdir)/rlprivate.h
undo.so: $(topdir)/rlprivate.h
util.so: $(topdir)/rlprivate.h
vi_mode.so: $(topdir)/rlprivate.h
@ -299,69 +342,96 @@ isearch.so: $(topdir)/xmalloc.h
keymaps.so: $(topdir)/xmalloc.h
kill.so: $(topdir)/xmalloc.h
macro.so: $(topdir)/xmalloc.h
mbutil.so: $(topdir)/xmalloc.h
misc.so: $(topdir)/xmalloc.h
readline.so: $(topdir)/xmalloc.h
savestring.so: $(topdir)/xmalloc.h
search.so: $(topdir)/xmalloc.h
shell.so: $(topdir)/xmalloc.h
terminal.so: $(topdir)/xmalloc.h
text.so: $(topdir)/xmalloc.h
tilde.so: $(topdir)/xmalloc.h
tilde.so: $(topdir)/xmalloc.h
undo.so: $(topdir)/xmalloc.h
util.so: $(topdir)/xmalloc.h
vi_mode.so: $(topdir)/xmalloc.h
xmalloc.so: $(topdir)/xmalloc.h
complete.o: $(topdir)/rlmbutil.h
display.o: $(topdir)/rlmbutil.h
histexpand.o: $(topdir)/rlmbutil.h
input.o: $(topdir)/rlmbutil.h
isearch.o: $(topdir)/rlmbutil.h
mbutil.o: $(topdir)/rlmbutil.h
misc.o: $(topdir)/rlmbutil.h
readline.o: $(topdir)/rlmbutil.h
search.o: $(topdir)/rlmbutil.h
text.o: $(topdir)/rlmbutil.h
vi_mode.o: $(topdir)/rlmbutil.h
readline.so: $(topdir)/readline.c
vi_mode.so: $(topdir)/vi_mode.c
funmap.so: $(topdir)/funmap.c
keymaps.so: $(topdir)/keymaps.c
parens.so: $(topdir)/parens.c
search.so: $(topdir)/search.c
rltty.so: $(topdir)/rltty.c
complete.so: $(topdir)/complete.c
bind.so: $(topdir)/bind.c
isearch.so: $(topdir)/isearch.c
display.so: $(topdir)/display.c
signals.so: $(topdir)/signals.c
util.so: $(topdir)/util.c
kill.so: $(topdir)/kill.c
undo.so: $(topdir)/undo.c
macro.so: $(topdir)/macro.c
input.so: $(topdir)/input.c
callback.so: $(topdir)/callback.c
terminal.so: $(topdir)/terminal.c
compat.so: $(topdir)/compat.c
complete.so: $(topdir)/complete.c
display.so: $(topdir)/display.c
funmap.so: $(topdir)/funmap.c
input.so: $(topdir)/input.c
isearch.so: $(topdir)/isearch.c
keymaps.so: $(topdir)/keymaps.c $(topdir)/emacs_keymap.c $(topdir)/vi_keymap.c
kill.so: $(topdir)/kill.c
macro.so: $(topdir)/macro.c
mbutil.so: $(topdir)/mbutil.c
misc.so: $(topdir)/mbutil.c
nls.so: $(topdir)/nls.c
parens.so: $(topdir)/parens.c
readline.so: $(topdir)/readline.c
rltty.so: $(topdir)/rltty.c
savestring.so: $(topdir)/savestring.c
search.so: $(topdir)/search.c
shell.so: $(topdir)/shell.c
signals.so: $(topdir)/signals.c
terminal.so: $(topdir)/terminal.c
text.so: $(topdir)/terminal.c
tilde.so: $(topdir)/tilde.c
undo.so: $(topdir)/undo.c
util.so: $(topdir)/util.c
vi_mode.so: $(topdir)/vi_mode.c
xmalloc.so: $(topdir)/xmalloc.c
history.so: $(topdir)/history.c
histexpand.so: $(topdir)/histexpand.c
histfile.so: $(topdir)/histfile.c
history.so: $(topdir)/history.c
histsearch.so: $(topdir)/histsearch.c
savestring.so: $(topdir)/savestring.c
shell.so: $(topdir)/shell.c
tilde.so: $(topdir)/tilde.c
readline.so: readline.c
vi_mode.so: vi_mode.c
funmap.so: funmap.c
keymaps.so: keymaps.c
parens.so: parens.c
search.so: search.c
rltty.so: rltty.c
complete.so: complete.c
bind.so: bind.c
isearch.so: isearch.c
display.so: display.c
signals.so: signals.c
util.so: util.c
kill.so: kill.c
undo.so: undo.c
macro.so: macro.c
input.so: input.c
callback.so: callback.c
terminal.so: terminal.c
comapt.so: compat.c
complete.so: complete.c
display.so: display.c
funmap.so: funmap.c
input.so: input.c
isearch.so: isearch.c
keymaps.so: keymaps.c emacs_keymap.c vi_keymap.c
kill.so: kill.c
macro.so: macro.c
mbutil.so: mbutil.c
misc.so: misc.c
nls.so: nls.c
parens.so: parens.c
readline.so: readline.c
rltty.so: rltty.c
savestring.so: savestring.c
search.so: search.c
signals.so: signals.c
shell.so: shell.c
terminal.so: terminal.c
text.so: terminal.c
tilde.so: tilde.c
undo.so: undo.c
util.so: util.c
vi_mode.so: vi_mode.c
xmalloc.so: xmalloc.c
history.so: history.c
histexpand.so: histexpand.c
histfile.so: histfile.c
history.so: history.c
histsearch.so: histsearch.c
savestring.so: savestring.c
shell.so: shell.c
tilde.so: tilde.c

View File

@ -61,7 +61,7 @@
# define SIGHANDLER_RETURN return (0)
#endif
/* This typedef is equivalant to the one for Function; it allows us
/* This typedef is equivalent to the one for Function; it allows us
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
typedef RETSIGTYPE SigHandler ();
@ -73,7 +73,8 @@ typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt
# define sigemptyset(m)
#endif /* !HAVE_POSIX_SIGNALS */
static SigHandler *rl_set_sighandler __P((int, SigHandler *, sighandler_cxt *));
static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
/* Exported variables for use by applications. */
@ -121,6 +122,8 @@ rl_signal_handler (sig)
# endif /* !HAVE_BSD_SIGNALS */
#endif /* !HAVE_POSIX_SIGNALS */
RL_SETSTATE(RL_STATE_SIGHANDLER);
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
/* Since the signal will not be blocked while we are in the signal
handler, ignore it until rl_clear_signals resets the catcher. */
@ -171,6 +174,7 @@ rl_signal_handler (sig)
rl_reset_after_signal ();
}
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
SIGHANDLER_RETURN;
}
@ -191,6 +195,7 @@ rl_sigwinch_handler (sig)
rl_set_sighandler (SIGWINCH, rl_sigwinch_handler, &dummy_winch);
#endif
RL_SETSTATE(RL_STATE_SIGHANDLER);
rl_resize_terminal ();
/* If another sigwinch handler has been installed, call it. */
@ -198,6 +203,7 @@ rl_sigwinch_handler (sig)
if (oh && oh != (SigHandler *)SIG_IGN && oh != (SigHandler *)SIG_DFL)
(*oh) (sig);
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
SIGHANDLER_RETURN;
}
#endif /* SIGWINCH */
@ -229,7 +235,7 @@ rl_set_sighandler (sig, handler, ohandler)
struct sigaction act;
act.sa_handler = handler;
act.sa_flags = 0;
act.sa_flags = 0; /* XXX - should we set SA_RESTART for SIGWINCH? */
sigemptyset (&act.sa_mask);
sigemptyset (&ohandler->sa_mask);
sigaction (sig, &act, &old_handler);
@ -360,7 +366,7 @@ rl_cleanup_after_signal ()
_rl_clean_up_for_exit ();
(*rl_deprep_term_function) ();
rl_clear_signals ();
rl_pending_input = 0;
rl_clear_pending_input ();
}
/* Reset the terminal and readline state after a signal handler returns. */
@ -380,7 +386,7 @@ rl_free_line_state ()
{
register HIST_ENTRY *entry;
free_undo_list ();
rl_free_undo_list ();
entry = current_history ();
if (entry)

View File

@ -5,6 +5,18 @@
#
# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
#
# Copyright 1991 by the Massachusetts Institute of Technology
#
# Permission to use, copy, modify, distribute, and sell this software and its
# documentation for any purpose is hereby granted without fee, provided that
# the above copyright notice appear in all copies and that both that
# copyright notice and this permission notice appear in supporting
# documentation, and that the name of M.I.T. not be used in advertising or
# publicity pertaining to distribution of the software without specific,
# written prior permission. M.I.T. makes no representations about the
# suitability of this software for any purpose. It is provided "as is"
# without express or implied warranty.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
#

View File

@ -5,6 +5,22 @@
# Chet Ramey
# chet@po.cwru.edu
# Copyright (C) 1996-2002 Free Software Foundation, Inc.
#
# 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
# the Free Software Foundation; either version 2, or (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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
for dir
do

View File

@ -7,6 +7,24 @@
# SRCDIR defaults to src
# MANIFEST defaults to $SRCDIR/MANIFEST
#
# Chet Ramey
# chet@po.cwru.edu
# Copyright (C) 1996-2002 Free Software Foundation, Inc.
#
# 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
# the Free Software Foundation; either version 2, or (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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
SRCDIR=src
ROOTNAME=bash
@ -68,6 +86,8 @@ do
case "$type" in
d) mkdir $newdir/$fname ;;
f) cp -p $SRCDIR/$fname $newdir/$fname ;;
s) ln -s $mode $newdir/$fname ; mode= ;; # symlink
l) ln $mode $newdir/$fname ; mode= ;; # hard link
*) echo "unknown file type $type" 1>&2 ;;
esac

View File

@ -63,10 +63,11 @@ fi
# post-install/uninstall
# HP-UX requires that a shared library have execute permission
# HP-UX and Darwin/MacOS X require that a shared library have execute permission
case "$host_os" in
hpux*) if [ -z "$uninstall" ]; then
chmod 755 ${INSTALLDIR}/${LIBNAME}
hpux*|darwin*|macosx*)
if [ -z "$uninstall" ]; then
chmod 555 ${INSTALLDIR}/${LIBNAME}
fi ;;
*) ;;
esac
@ -82,54 +83,60 @@ case "$LIBNAME" in
*.[0-9]) # libname.M
LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]:\1:'` # libname
;;
*.[0-9].[0-9].dylib) # libname.M.N.dylib
LINK2=`echo $LIBNAME | sed 's:\(.*\.[0-9]\)\.[0-9]:\1:'` # libname.M.dylib
LINK1=`echo $LIBNAME | sed 's:\(.*\)\.[0-9]\.[0-9]:\1:'` # libname.dylib
esac
INSTALL_LINK1='cd $INSTALLDIR ; ln -s $LIBNAME $LINK1'
INSTALL_LINK2='cd $INSTALLDIR ; ln -s $LIBNAME $LINK2'
#
# Create symlinks to the installed library. This section is incomplete.
#
case "$host_os" in
*linux*|bsdi4*)
*linux*|bsdi4*|*gnu*|darwin*|macosx*)
# libname.so.M -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK2
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK2
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
fi
# libname.so -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
fi
;;
solaris2*|aix4.[2-9]*|osf*|irix[56]*)
solaris2*|aix4.[2-9]*|osf*|irix[56]*|sysv[45]*|dgux*)
# libname.so -> libname.so.M
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
fi
;;
# FreeBSD 3.x can have either a.out or ELF shared libraries
freebsd3*)
# FreeBSD 3.x and above can have either a.out or ELF shared libraries
freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
if [ -x /usr/bin/objformat ] && [ "`/usr/bin/objformat`" = "elf" ]; then
# libname.so -> libname.so.M
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
fi
else
# libname.so.M -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK2
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK2
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK2
fi
# libname.so -> libname.so.M.N
${echo} ${RM} ${INSTALLDIR}/$LINK1
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/$LINK1
${echo} ln -s $LIBNAME ${INSTALLDIR}/$LINK1
fi
fi
;;
@ -138,7 +145,8 @@ hpux1*)
# libname.sl -> libname.M
${echo} ${RM} ${INSTALLDIR}/$LINK1.sl
if [ -z "$uninstall" ]; then
${echo} ln -s $INSTALLDIR/$LIBNAME ${INSTALLDIR}/${LINK1}.sl
# ${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}.sl
${echo} ln -s $LIBNAME ${INSTALLDIR}/${LINK1}
fi
;;

View File

@ -10,6 +10,22 @@
# Chet Ramey
# chet@po.cwru.edu
# Copyright (C) 1996-2002 Free Software Foundation, Inc.
#
# 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
# the Free Software Foundation; either version 2, or (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, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
#
# defaults
#
@ -43,7 +59,7 @@ while [ $# -gt 0 ]; do
done
case "${host_os}-${SHOBJ_CC}" in
sunos4*-gcc*)
sunos4*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD=/usr/bin/ld
SHOBJ_LDFLAGS='-assert pure-text'
@ -59,10 +75,13 @@ sunos4*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
sunos5*-gcc*|solaris2*-gcc*)
sunos5*-*gcc*|solaris2*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
# This line works for the Solaris linker in /usr/ccs/bin/ld
SHOBJ_LDFLAGS='-shared -Wl,-i -Wl,-h,$@'
# This line works for the GNU ld
# SHOBJ_LDFLAGS='-shared -Wl,-h,$@'
# SHLIB_XLDFLAGS='-R $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
@ -77,7 +96,17 @@ sunos5*|solaris2*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
freebsd2* | netbsd* | openbsd*)
# All versions of Linux or the semi-mythical GNU Hurd.
linux*|gnu*)
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir) -Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
freebsd2* | netbsd*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD=ld
SHOBJ_LDFLAGS='-x -Bshareable'
@ -86,18 +115,8 @@ freebsd2* | netbsd* | openbsd*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
# FreeBSD-3.x can have either a.out or ELF object files
#freebsd3*)
# SHOBJ_CFLAGS=-fpic
# SHOBJ_LD='${CC}'
# SHOBJ_LDFLAGS='-shared'
#
# SHLIB_XLDFLAGS='-R$(libdir)'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
# ;;
# FreeBSD-3.x ELF
freebsd3*)
freebsd[3-9]*|freebsdelf[3-9]*|freebsdaout[3-9]*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
@ -114,12 +133,30 @@ freebsd3*)
fi
;;
linux*)
# Darwin/MacOS X
darwin*|macosx*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=supported
SHOBJ_CFLAGS='-dynamic -fno-common'
SHOBJ_LD=/usr/bin/libtool
SHLIB_LIBVERSION='$(SHLIB_MAJOR)$(SHLIB_MINOR).$(SHLIB_LIBSUFF)'
SHLIB_LIBSUFF='dylib'
SHOBJ_LDFLAGS='-dynamic'
SHLIB_XLDFLAGS='-arch_only `/usr/bin/arch` -install_name $(libdir)/$@ -current_version $(SHLIB_MAJOR)$(SHLIB_MINOR) -compatibility_version $(SHLIB_MAJOR) -v'
SHLIB_LIBS='-lSystem'
;;
openbsd*)
SHOBJ_CFLAGS=-fPIC
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHOBJ_LDFLAGS='-shared'
SHLIB_XLDFLAGS='-Wl,-rpath,$(libdir)'
SHLIB_XLDFLAGS='-R$(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
@ -158,10 +195,11 @@ bsdi4*)
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
SHLIB_XLDFLAGS='-Wl,-soname,`basename $@ $(SHLIB_MINOR)`'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)'
;;
osf*-gcc*)
osf*-*gcc*)
# Fix to use gcc linker driver from bfischer@TechFak.Uni-Bielefeld.DE
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
@ -178,7 +216,7 @@ osf*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
aix4.[2-9]*-gcc*) # lightly tested by jik@cisco.com
aix4.[2-9]*-*gcc*) # lightly tested by jik@cisco.com
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='ld'
SHOBJ_LDFLAGS='-bdynamic -bnoentry -bexpall'
@ -203,7 +241,7 @@ aix4.[2-9]*)
#
# THE FOLLOWING ARE UNTESTED -- and some may not support the dlopen interface
#
irix[56]*-gcc*)
irix[56]*-*gcc*)
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared -Wl,-soname,$@'
@ -216,14 +254,15 @@ irix[56]*)
SHOBJ_CFLAGS='-K PIC'
SHOBJ_LD=ld
# SHOBJ_LDFLAGS='-call_shared -hidden_symbol -no_unresolved -soname $@'
# Change from David Kaelbling <drk@sgi.com>
# Change from David Kaelbling <drk@sgi.com>. If you have problems,
# remove the `-no_unresolved'
SHOBJ_LDFLAGS='-shared -no_unresolved -soname $@'
SHLIB_XLDFLAGS='-rpath $(libdir)'
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux9*-gcc*)
hpux9*-*gcc*)
# must use gcc; the bundled cc cannot compile PIC code
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
@ -237,9 +276,23 @@ hpux9*-gcc*)
hpux9*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=unsupported
# If you are using the HP ANSI C compiler, you can uncomment and use
# this code (I have not tested it)
# SHOBJ_STATUS=supported
# SHLIB_STATUS=supported
#
# SHOBJ_CFLAGS='+z'
# SHOBJ_LD='ld'
# SHOBJ_LDFLAGS='-b +s'
#
# SHLIB_XLDFLAGS='+b $(libdir)'
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux10*-gcc*)
hpux10*-*gcc*)
# must use gcc; the bundled cc cannot compile PIC code
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
@ -253,14 +306,28 @@ hpux10*-gcc*)
hpux10*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=unsupported
# If you are using the HP ANSI C compiler, you can uncomment and use
# this code (I have not tested it)
# SHOBJ_STATUS=supported
# SHLIB_STATUS=supported
#
# SHOBJ_CFLAGS='+z'
# SHOBJ_LD='ld'
# SHOBJ_LDFLAGS='-b +s +h $@'
#
# SHLIB_XLDFLAGS='+b $(libdir)'
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
hpux11*-gcc*)
hpux11*-*gcc*)
# must use gcc; the bundled cc cannot compile PIC code
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
# SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,-B,symbolic -Wl,+s -Wl,+std -Wl,+h,$@'
SHOBJ_LDFLAGS='-shared -Wl,-b -Wl,+s -Wl,+h,$@'
SHOBJ_LDFLAGS='-shared -fpic -Wl,-b -Wl,+s -Wl,+h,$@'
SHLIB_XLDFLAGS='-Wl,+b,$(libdir)'
SHLIB_LIBSUFF='sl'
@ -270,9 +337,23 @@ hpux11*-gcc*)
hpux11*)
SHOBJ_STATUS=unsupported
SHLIB_STATUS=unsupported
# If you are using the HP ANSI C compiler, you can uncomment and use
# this code (I have not tested it)
# SHOBJ_STATUS=supported
# SHLIB_STATUS=supported
#
# SHOBJ_CFLAGS='+z'
# SHOBJ_LD='ld'
# SHOBJ_LDFLAGS='-b +s +h $@'
#
# SHLIB_XLDFLAGS='+b $(libdir)'
# SHLIB_LIBSUFF='sl'
# SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv4*-gcc*)
sysv4*-*gcc*)
SHOBJ_CFLAGS=-shared
SHOBJ_LDFLAGS='-shared -h $@'
SHOBJ_LD='${CC}'
@ -288,7 +369,7 @@ sysv4*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sco3.2v5*-gcc*)
sco3.2v5*-*gcc*)
SHOBJ_CFLAGS='-fpic' # DEFAULTS TO ELF
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
@ -304,7 +385,7 @@ sco3.2v5*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
sysv5uw7*-gcc*)
sysv5uw7*-*gcc*)
SHOBJ_CFLAGS='-fpic'
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
@ -320,7 +401,7 @@ sysv5uw7*)
SHLIB_LIBVERSION='$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)'
;;
dgux*-gcc*)
dgux*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'
@ -344,7 +425,7 @@ msdos*)
#
# Rely on correct gcc configuration for everything else
#
*-gcc*)
*-*gcc*)
SHOBJ_CFLAGS=-fpic
SHOBJ_LD='${CC}'
SHOBJ_LDFLAGS='-shared'

236
readline/support/wcwidth.c Normal file
View File

@ -0,0 +1,236 @@
/*
* This is an implementation of wcwidth() and wcswidth() as defined in
* "The Single UNIX Specification, Version 2, The Open Group, 1997"
* <http://www.UNIX-systems.org/online.html>
*
* Markus Kuhn -- 2001-09-08 -- public domain
*/
#include <wchar.h>
struct interval {
unsigned short first;
unsigned short last;
};
/* auxiliary function for binary search in interval table */
static int bisearch(wchar_t ucs, const struct interval *table, int max) {
int min = 0;
int mid;
if (ucs < table[0].first || ucs > table[max].last)
return 0;
while (max >= min) {
mid = (min + max) / 2;
if (ucs > table[mid].last)
min = mid + 1;
else if (ucs < table[mid].first)
max = mid - 1;
else
return 1;
}
return 0;
}
/* The following functions define the column width of an ISO 10646
* character as follows:
*
* - The null character (U+0000) has a column width of 0.
*
* - Other C0/C1 control characters and DEL will lead to a return
* value of -1.
*
* - Non-spacing and enclosing combining characters (general
* category code Mn or Me in the Unicode database) have a
* column width of 0.
*
* - Other format characters (general category code Cf in the Unicode
* database) and ZERO WIDTH SPACE (U+200B) have a column width of 0.
*
* - Hangul Jamo medial vowels and final consonants (U+1160-U+11FF)
* have a column width of 0.
*
* - Spacing characters in the East Asian Wide (W) or East Asian
* FullWidth (F) category as defined in Unicode Technical
* Report #11 have a column width of 2.
*
* - All remaining characters (including all printable
* ISO 8859-1 and WGL4 characters, Unicode control characters,
* etc.) have a column width of 1.
*
* This implementation assumes that wchar_t characters are encoded
* in ISO 10646.
*/
int wcwidth(wchar_t ucs)
{
/* sorted list of non-overlapping intervals of non-spacing characters */
static const struct interval combining[] = {
{ 0x0300, 0x034E }, { 0x0360, 0x0362 }, { 0x0483, 0x0486 },
{ 0x0488, 0x0489 }, { 0x0591, 0x05A1 }, { 0x05A3, 0x05B9 },
{ 0x05BB, 0x05BD }, { 0x05BF, 0x05BF }, { 0x05C1, 0x05C2 },
{ 0x05C4, 0x05C4 }, { 0x064B, 0x0655 }, { 0x0670, 0x0670 },
{ 0x06D6, 0x06E4 }, { 0x06E7, 0x06E8 }, { 0x06EA, 0x06ED },
{ 0x070F, 0x070F }, { 0x0711, 0x0711 }, { 0x0730, 0x074A },
{ 0x07A6, 0x07B0 }, { 0x0901, 0x0902 }, { 0x093C, 0x093C },
{ 0x0941, 0x0948 }, { 0x094D, 0x094D }, { 0x0951, 0x0954 },
{ 0x0962, 0x0963 }, { 0x0981, 0x0981 }, { 0x09BC, 0x09BC },
{ 0x09C1, 0x09C4 }, { 0x09CD, 0x09CD }, { 0x09E2, 0x09E3 },
{ 0x0A02, 0x0A02 }, { 0x0A3C, 0x0A3C }, { 0x0A41, 0x0A42 },
{ 0x0A47, 0x0A48 }, { 0x0A4B, 0x0A4D }, { 0x0A70, 0x0A71 },
{ 0x0A81, 0x0A82 }, { 0x0ABC, 0x0ABC }, { 0x0AC1, 0x0AC5 },
{ 0x0AC7, 0x0AC8 }, { 0x0ACD, 0x0ACD }, { 0x0B01, 0x0B01 },
{ 0x0B3C, 0x0B3C }, { 0x0B3F, 0x0B3F }, { 0x0B41, 0x0B43 },
{ 0x0B4D, 0x0B4D }, { 0x0B56, 0x0B56 }, { 0x0B82, 0x0B82 },
{ 0x0BC0, 0x0BC0 }, { 0x0BCD, 0x0BCD }, { 0x0C3E, 0x0C40 },
{ 0x0C46, 0x0C48 }, { 0x0C4A, 0x0C4D }, { 0x0C55, 0x0C56 },
{ 0x0CBF, 0x0CBF }, { 0x0CC6, 0x0CC6 }, { 0x0CCC, 0x0CCD },
{ 0x0D41, 0x0D43 }, { 0x0D4D, 0x0D4D }, { 0x0DCA, 0x0DCA },
{ 0x0DD2, 0x0DD4 }, { 0x0DD6, 0x0DD6 }, { 0x0E31, 0x0E31 },
{ 0x0E34, 0x0E3A }, { 0x0E47, 0x0E4E }, { 0x0EB1, 0x0EB1 },
{ 0x0EB4, 0x0EB9 }, { 0x0EBB, 0x0EBC }, { 0x0EC8, 0x0ECD },
{ 0x0F18, 0x0F19 }, { 0x0F35, 0x0F35 }, { 0x0F37, 0x0F37 },
{ 0x0F39, 0x0F39 }, { 0x0F71, 0x0F7E }, { 0x0F80, 0x0F84 },
{ 0x0F86, 0x0F87 }, { 0x0F90, 0x0F97 }, { 0x0F99, 0x0FBC },
{ 0x0FC6, 0x0FC6 }, { 0x102D, 0x1030 }, { 0x1032, 0x1032 },
{ 0x1036, 0x1037 }, { 0x1039, 0x1039 }, { 0x1058, 0x1059 },
{ 0x1160, 0x11FF }, { 0x17B7, 0x17BD }, { 0x17C6, 0x17C6 },
{ 0x17C9, 0x17D3 }, { 0x180B, 0x180E }, { 0x18A9, 0x18A9 },
{ 0x200B, 0x200F }, { 0x202A, 0x202E }, { 0x206A, 0x206F },
{ 0x20D0, 0x20E3 }, { 0x302A, 0x302F }, { 0x3099, 0x309A },
{ 0xFB1E, 0xFB1E }, { 0xFE20, 0xFE23 }, { 0xFEFF, 0xFEFF },
{ 0xFFF9, 0xFFFB }
};
/* test for 8-bit control characters */
if (ucs == 0)
return 0;
if (ucs < 32 || (ucs >= 0x7f && ucs < 0xa0))
return -1;
/* binary search in table of non-spacing characters */
if (bisearch(ucs, combining,
sizeof(combining) / sizeof(struct interval) - 1))
return 0;
/* if we arrive here, ucs is not a combining or C0/C1 control character */
return 1 +
(ucs >= 0x1100 &&
(ucs <= 0x115f || /* Hangul Jamo init. consonants */
(ucs >= 0x2e80 && ucs <= 0xa4cf && (ucs & ~0x0011) != 0x300a &&
ucs != 0x303f) || /* CJK ... Yi */
(ucs >= 0xac00 && ucs <= 0xd7a3) || /* Hangul Syllables */
(ucs >= 0xf900 && ucs <= 0xfaff) || /* CJK Compatibility Ideographs */
(ucs >= 0xfe30 && ucs <= 0xfe6f) || /* CJK Compatibility Forms */
(ucs >= 0xff00 && ucs <= 0xff5f) || /* Fullwidth Forms */
(ucs >= 0xffe0 && ucs <= 0xffe6) ||
(ucs >= 0x20000 && ucs <= 0x2ffff)));
}
int wcswidth(const wchar_t *pwcs, size_t n)
{
int w, width = 0;
for (;*pwcs && n-- > 0; pwcs++)
if ((w = wcwidth(*pwcs)) < 0)
return -1;
else
width += w;
return width;
}
/*
* The following function is the same as wcwidth(), except that
* spacing characters in the East Asian Ambiguous (A) category as
* defined in Unicode Technical Report #11 have a column width of 2.
* This experimental variant might be useful for users of CJK legacy
* encodings who want to migrate to UCS. It is not otherwise
* recommended for general use.
*/
static int wcwidth_cjk(wchar_t ucs)
{
/* sorted list of non-overlapping intervals of East Asian Ambiguous
* characters */
static const struct interval ambiguous[] = {
{ 0x00A1, 0x00A1 }, { 0x00A4, 0x00A4 }, { 0x00A7, 0x00A8 },
{ 0x00AA, 0x00AA }, { 0x00AD, 0x00AE }, { 0x00B0, 0x00B4 },
{ 0x00B6, 0x00BA }, { 0x00BC, 0x00BF }, { 0x00C6, 0x00C6 },
{ 0x00D0, 0x00D0 }, { 0x00D7, 0x00D8 }, { 0x00DE, 0x00E1 },
{ 0x00E6, 0x00E6 }, { 0x00E8, 0x00EA }, { 0x00EC, 0x00ED },
{ 0x00F0, 0x00F0 }, { 0x00F2, 0x00F3 }, { 0x00F7, 0x00FA },
{ 0x00FC, 0x00FC }, { 0x00FE, 0x00FE }, { 0x0101, 0x0101 },
{ 0x0111, 0x0111 }, { 0x0113, 0x0113 }, { 0x011B, 0x011B },
{ 0x0126, 0x0127 }, { 0x012B, 0x012B }, { 0x0131, 0x0133 },
{ 0x0138, 0x0138 }, { 0x013F, 0x0142 }, { 0x0144, 0x0144 },
{ 0x0148, 0x014B }, { 0x014D, 0x014D }, { 0x0152, 0x0153 },
{ 0x0166, 0x0167 }, { 0x016B, 0x016B }, { 0x01CE, 0x01CE },
{ 0x01D0, 0x01D0 }, { 0x01D2, 0x01D2 }, { 0x01D4, 0x01D4 },
{ 0x01D6, 0x01D6 }, { 0x01D8, 0x01D8 }, { 0x01DA, 0x01DA },
{ 0x01DC, 0x01DC }, { 0x0251, 0x0251 }, { 0x0261, 0x0261 },
{ 0x02C4, 0x02C4 }, { 0x02C7, 0x02C7 }, { 0x02C9, 0x02CB },
{ 0x02CD, 0x02CD }, { 0x02D0, 0x02D0 }, { 0x02D8, 0x02DB },
{ 0x02DD, 0x02DD }, { 0x02DF, 0x02DF }, { 0x0300, 0x034E },
{ 0x0360, 0x0362 }, { 0x0391, 0x03A1 }, { 0x03A3, 0x03A9 },
{ 0x03B1, 0x03C1 }, { 0x03C3, 0x03C9 }, { 0x0401, 0x0401 },
{ 0x0410, 0x044F }, { 0x0451, 0x0451 }, { 0x2010, 0x2010 },
{ 0x2013, 0x2016 }, { 0x2018, 0x2019 }, { 0x201C, 0x201D },
{ 0x2020, 0x2022 }, { 0x2024, 0x2027 }, { 0x2030, 0x2030 },
{ 0x2032, 0x2033 }, { 0x2035, 0x2035 }, { 0x203B, 0x203B },
{ 0x203E, 0x203E }, { 0x2074, 0x2074 }, { 0x207F, 0x207F },
{ 0x2081, 0x2084 }, { 0x20AC, 0x20AC }, { 0x2103, 0x2103 },
{ 0x2105, 0x2105 }, { 0x2109, 0x2109 }, { 0x2113, 0x2113 },
{ 0x2116, 0x2116 }, { 0x2121, 0x2122 }, { 0x2126, 0x2126 },
{ 0x212B, 0x212B }, { 0x2153, 0x2155 }, { 0x215B, 0x215E },
{ 0x2160, 0x216B }, { 0x2170, 0x2179 }, { 0x2190, 0x2199 },
{ 0x21B8, 0x21B9 }, { 0x21D2, 0x21D2 }, { 0x21D4, 0x21D4 },
{ 0x21E7, 0x21E7 }, { 0x2200, 0x2200 }, { 0x2202, 0x2203 },
{ 0x2207, 0x2208 }, { 0x220B, 0x220B }, { 0x220F, 0x220F },
{ 0x2211, 0x2211 }, { 0x2215, 0x2215 }, { 0x221A, 0x221A },
{ 0x221D, 0x2220 }, { 0x2223, 0x2223 }, { 0x2225, 0x2225 },
{ 0x2227, 0x222C }, { 0x222E, 0x222E }, { 0x2234, 0x2237 },
{ 0x223C, 0x223D }, { 0x2248, 0x2248 }, { 0x224C, 0x224C },
{ 0x2252, 0x2252 }, { 0x2260, 0x2261 }, { 0x2264, 0x2267 },
{ 0x226A, 0x226B }, { 0x226E, 0x226F }, { 0x2282, 0x2283 },
{ 0x2286, 0x2287 }, { 0x2295, 0x2295 }, { 0x2299, 0x2299 },
{ 0x22A5, 0x22A5 }, { 0x22BF, 0x22BF }, { 0x2312, 0x2312 },
{ 0x2329, 0x232A }, { 0x2460, 0x24BF }, { 0x24D0, 0x24E9 },
{ 0x2500, 0x254B }, { 0x2550, 0x2574 }, { 0x2580, 0x258F },
{ 0x2592, 0x2595 }, { 0x25A0, 0x25A1 }, { 0x25A3, 0x25A9 },
{ 0x25B2, 0x25B3 }, { 0x25B6, 0x25B7 }, { 0x25BC, 0x25BD },
{ 0x25C0, 0x25C1 }, { 0x25C6, 0x25C8 }, { 0x25CB, 0x25CB },
{ 0x25CE, 0x25D1 }, { 0x25E2, 0x25E5 }, { 0x25EF, 0x25EF },
{ 0x2605, 0x2606 }, { 0x2609, 0x2609 }, { 0x260E, 0x260F },
{ 0x261C, 0x261C }, { 0x261E, 0x261E }, { 0x2640, 0x2640 },
{ 0x2642, 0x2642 }, { 0x2660, 0x2661 }, { 0x2663, 0x2665 },
{ 0x2667, 0x266A }, { 0x266C, 0x266D }, { 0x266F, 0x266F },
{ 0x273D, 0x273D }, { 0x3008, 0x300B }, { 0x3014, 0x3015 },
{ 0x3018, 0x301B }, { 0xFFFD, 0xFFFD }
};
/* binary search in table of non-spacing characters */
if (bisearch(ucs, ambiguous,
sizeof(ambiguous) / sizeof(struct interval) - 1))
return 2;
return wcwidth(ucs);
}
int wcswidth_cjk(const wchar_t *pwcs, size_t n)
{
int w, width = 0;
for (;*pwcs && n-- > 0; pwcs++)
if ((w = wcwidth_cjk(*pwcs)) < 0)
return -1;
else
width += w;
return width;
}

View File

@ -68,6 +68,10 @@
#include "rlprivate.h"
#include "rlshell.h"
#include "xmalloc.h"
#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
/* **************************************************************** */
/* */
@ -93,27 +97,36 @@ char PC, *BC, *UP;
#endif /* __linux__ */
/* Some strings to control terminal actions. These are output by tputs (). */
char *term_goto, *term_clreol, *term_cr, *term_clrpag, *term_backspace;
char *term_pc;
char *_rl_term_clreol;
char *_rl_term_clrpag;
char *_rl_term_cr;
char *_rl_term_backspace;
char *_rl_term_goto;
char *_rl_term_pc;
/* Non-zero if we determine that the terminal can do character insertion. */
int terminal_can_insert = 0;
int _rl_terminal_can_insert = 0;
/* How to insert characters. */
char *term_im, *term_ei, *term_ic, *term_ip, *term_IC;
char *_rl_term_im;
char *_rl_term_ei;
char *_rl_term_ic;
char *_rl_term_ip;
char *_rl_term_IC;
/* How to delete characters. */
char *term_dc, *term_DC;
char *_rl_term_dc;
char *_rl_term_DC;
#if defined (HACK_TERMCAP_MOTION)
char *term_forward_char;
char *_rl_term_forward_char;
#endif /* HACK_TERMCAP_MOTION */
/* How to go up a line. */
char *term_up;
char *_rl_term_up;
/* A visible bell, if the terminal can be made to flash the screen. */
static char *visible_bell;
/* A visible bell; char if the terminal can be made to flash the screen. */
static char *_rl_visible_bell;
/* Non-zero means the terminal can auto-wrap lines. */
int _rl_term_autowrap;
@ -122,20 +135,36 @@ int _rl_term_autowrap;
static int term_has_meta;
/* The sequences to write to turn on and off the meta key, if this
terminal has one. */
static char *term_mm, *term_mo;
terminal has one. */
static char *_rl_term_mm;
static char *_rl_term_mo;
/* The key sequences output by the arrow keys, if this terminal has any. */
static char *term_ku, *term_kd, *term_kr, *term_kl;
static char *_rl_term_ku;
static char *_rl_term_kd;
static char *_rl_term_kr;
static char *_rl_term_kl;
/* How to initialize and reset the arrow keys, if this terminal has any. */
static char *term_ks, *term_ke;
static char *_rl_term_ks;
static char *_rl_term_ke;
/* The key sequences sent by the Home and End keys, if any. */
static char *term_kh, *term_kH;
static char *_rl_term_kh;
static char *_rl_term_kH;
static char *_rl_term_at7; /* @7 */
/* Insert key */
static char *_rl_term_kI;
/* Cursor control */
static char *_rl_term_vs; /* very visible */
static char *_rl_term_ve; /* normal */
static void bind_termcap_arrow_keys PARAMS((Keymap));
/* Variables that hold the screen dimensions, used by the display code. */
int screenwidth, screenheight, screenchars;
int _rl_screenwidth, _rl_screenheight, _rl_screenchars;
/* Non-zero means the user wants to enable the keypad. */
int _rl_enable_keypad;
@ -175,90 +204,107 @@ _rl_get_screen_size (tty, ignore_env)
#if defined (TIOCGWINSZ)
if (ioctl (tty, TIOCGWINSZ, &window_size) == 0)
{
screenwidth = (int) window_size.ws_col;
screenheight = (int) window_size.ws_row;
_rl_screenwidth = (int) window_size.ws_col;
_rl_screenheight = (int) window_size.ws_row;
}
#endif /* TIOCGWINSZ */
#if defined (__EMX__)
_emx_get_screensize (&screenwidth, &screenheight);
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
#endif
/* Environment variable COLUMNS overrides setting of "co" if IGNORE_ENV
is unset. */
if (screenwidth <= 0)
if (_rl_screenwidth <= 0)
{
if (ignore_env == 0 && (ss = get_env_value ("COLUMNS")))
screenwidth = atoi (ss);
if (ignore_env == 0 && (ss = sh_get_env_value ("COLUMNS")))
_rl_screenwidth = atoi (ss);
#if defined (__DJGPP__)
if (screenwidth <= 0)
screenwidth = ScreenCols ();
#else
if (screenwidth <= 0 && term_string_buffer)
screenwidth = tgetnum ("co");
#if !defined (__DJGPP__)
if (_rl_screenwidth <= 0 && term_string_buffer)
_rl_screenwidth = tgetnum ("co");
#endif
}
/* Environment variable LINES overrides setting of "li" if IGNORE_ENV
is unset. */
if (screenheight <= 0)
if (_rl_screenheight <= 0)
{
if (ignore_env == 0 && (ss = get_env_value ("LINES")))
screenheight = atoi (ss);
if (ignore_env == 0 && (ss = sh_get_env_value ("LINES")))
_rl_screenheight = atoi (ss);
#if defined (__DJGPP__)
if (screenheight <= 0)
screenheight = ScreenRows ();
#else
if (screenheight <= 0 && term_string_buffer)
screenheight = tgetnum ("li");
#if !defined (__DJGPP__)
if (_rl_screenheight <= 0 && term_string_buffer)
_rl_screenheight = tgetnum ("li");
#endif
}
/* If all else fails, default to 80x24 terminal. */
if (screenwidth <= 1)
screenwidth = 80;
if (_rl_screenwidth <= 1)
_rl_screenwidth = 80;
if (screenheight <= 0)
screenheight = 24;
if (_rl_screenheight <= 0)
_rl_screenheight = 24;
/* If we're being compiled as part of bash, set the environment
variables $LINES and $COLUMNS to new values. Otherwise, just
do a pair of putenv () or setenv () calls. */
set_lines_and_columns (screenheight, screenwidth);
sh_set_lines_and_columns (_rl_screenheight, _rl_screenwidth);
if (_rl_term_autowrap == 0)
screenwidth--;
_rl_screenwidth--;
screenchars = screenwidth * screenheight;
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
}
void
_rl_set_screen_size (rows, cols)
int rows, cols;
{
screenheight = rows;
screenwidth = cols;
if (rows == 0 || cols == 0)
return;
_rl_screenheight = rows;
_rl_screenwidth = cols;
if (_rl_term_autowrap == 0)
screenwidth--;
_rl_screenwidth--;
screenchars = screenwidth * screenheight;
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
}
void
rl_set_screen_size (rows, cols)
int rows, cols;
{
_rl_set_screen_size (rows, cols);
}
void
rl_get_screen_size (rows, cols)
int *rows, *cols;
{
if (rows)
*rows = _rl_screenheight;
if (cols)
*cols = _rl_screenwidth;
}
void
rl_resize_terminal ()
{
if (readline_echoing_p)
{
_rl_get_screen_size (fileno (rl_instream), 1);
_rl_redisplay_after_sigwinch ();
if (CUSTOM_REDISPLAY_FUNC ())
rl_forced_update_display ();
else
_rl_redisplay_after_sigwinch ();
}
}
struct _tc_string {
char *tc_var;
const char *tc_var;
char **tc_value;
};
@ -266,32 +312,36 @@ struct _tc_string {
search algorithm to something smarter. */
static struct _tc_string tc_strings[] =
{
{ "DC", &term_DC },
{ "IC", &term_IC },
{ "ce", &term_clreol },
{ "cl", &term_clrpag },
{ "cr", &term_cr },
{ "dc", &term_dc },
{ "ei", &term_ei },
{ "ic", &term_ic },
{ "im", &term_im },
{ "kd", &term_kd },
{ "kh", &term_kh }, /* home */
{ "kH", &term_kH }, /* end */
{ "kl", &term_kl },
{ "kr", &term_kr },
{ "ku", &term_ku },
{ "ks", &term_ks },
{ "ke", &term_ke },
{ "le", &term_backspace },
{ "mm", &term_mm },
{ "mo", &term_mo },
{ "@7", &_rl_term_at7 },
{ "DC", &_rl_term_DC },
{ "IC", &_rl_term_IC },
{ "ce", &_rl_term_clreol },
{ "cl", &_rl_term_clrpag },
{ "cr", &_rl_term_cr },
{ "dc", &_rl_term_dc },
{ "ei", &_rl_term_ei },
{ "ic", &_rl_term_ic },
{ "im", &_rl_term_im },
{ "kH", &_rl_term_kH }, /* home down ?? */
{ "kI", &_rl_term_kI }, /* insert */
{ "kd", &_rl_term_kd },
{ "ke", &_rl_term_ke }, /* end keypad mode */
{ "kh", &_rl_term_kh }, /* home */
{ "kl", &_rl_term_kl },
{ "kr", &_rl_term_kr },
{ "ks", &_rl_term_ks }, /* start keypad mode */
{ "ku", &_rl_term_ku },
{ "le", &_rl_term_backspace },
{ "mm", &_rl_term_mm },
{ "mo", &_rl_term_mo },
#if defined (HACK_TERMCAP_MOTION)
{ "nd", &term_forward_char },
{ "nd", &_rl_term_forward_char },
#endif
{ "pc", &term_pc },
{ "up", &term_up },
{ "vb", &visible_bell },
{ "pc", &_rl_term_pc },
{ "up", &_rl_term_up },
{ "vb", &_rl_visible_bell },
{ "vs", &_rl_term_vs },
{ "ve", &_rl_term_ve },
};
#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string))
@ -306,26 +356,27 @@ get_term_capabilities (bp)
register int i;
for (i = 0; i < NUM_TC_STRINGS; i++)
# ifdef __LCC__
*(tc_strings[i].tc_value) = tgetstr ((char *)tc_strings[i].tc_var, bp);
# else
*(tc_strings[i].tc_value) = tgetstr (tc_strings[i].tc_var, bp);
# endif
#endif
tcap_initialized = 1;
}
#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay)
#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc)
int
_rl_init_terminal_io (terminal_name)
char *terminal_name;
const char *terminal_name;
{
char *term, *buffer;
const char *term;
char *buffer;
int tty, tgetent_ret;
Keymap xkeymap;
term = terminal_name ? terminal_name : get_env_value ("TERM");
term_clrpag = term_cr = term_clreol = (char *)NULL;
term = terminal_name ? terminal_name : sh_get_env_value ("TERM");
_rl_term_clrpag = _rl_term_cr = _rl_term_clreol = (char *)NULL;
tty = rl_instream ? fileno (rl_instream) : 0;
screenwidth = screenheight = 0;
_rl_screenwidth = _rl_screenheight = 0;
if (term == 0)
term = "dumb";
@ -350,10 +401,10 @@ _rl_init_terminal_io (terminal_name)
else
{
if (term_string_buffer == 0)
term_string_buffer = xmalloc(2032);
term_string_buffer = (char *)xmalloc(2032);
if (term_buffer == 0)
term_buffer = xmalloc(4080);
term_buffer = (char *)xmalloc(4080);
buffer = term_string_buffer;
@ -366,41 +417,43 @@ _rl_init_terminal_io (terminal_name)
FREE (term_buffer);
buffer = term_buffer = term_string_buffer = (char *)NULL;
dumb_term = 1;
_rl_term_autowrap = 0; /* used by _rl_get_screen_size */
#if defined (__EMX__)
_emx_get_screensize (&screenwidth, &screenheight);
screenwidth--;
_emx_get_screensize (&_rl_screenwidth, &_rl_screenheight);
_rl_screenwidth--;
#else /* !__EMX__ */
_rl_get_screen_size (tty, 0);
#endif /* !__EMX__ */
/* Defaults. */
if (screenwidth <= 0 || screenheight <= 0)
if (_rl_screenwidth <= 0 || _rl_screenheight <= 0)
{
screenwidth = 79;
screenheight = 24;
_rl_screenwidth = 79;
_rl_screenheight = 24;
}
/* Everything below here is used by the redisplay code (tputs). */
screenchars = screenwidth * screenheight;
term_cr = "\r";
term_im = term_ei = term_ic = term_IC = (char *)NULL;
term_up = term_dc = term_DC = visible_bell = (char *)NULL;
term_ku = term_kd = term_kl = term_kr = (char *)NULL;
term_mm = term_mo = (char *)NULL;
_rl_screenchars = _rl_screenwidth * _rl_screenheight;
_rl_term_cr = "\r";
_rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL;
_rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL;
_rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL;
_rl_term_kh = _rl_term_kH = _rl_term_kI = (char *)NULL;
_rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL;
_rl_term_mm = _rl_term_mo = (char *)NULL;
_rl_term_ve = _rl_term_vs = (char *)NULL;
#if defined (HACK_TERMCAP_MOTION)
term_forward_char = (char *)NULL;
#endif
terminal_can_insert = term_has_meta = 0;
_rl_terminal_can_insert = term_has_meta = 0;
/* Reasonable defaults for tgoto(). Readline currently only uses
tgoto if term_IC or term_DC is defined, but just in case we
tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we
change that later... */
PC = '\0';
BC = term_backspace = "\b";
UP = term_up;
BC = _rl_term_backspace = "\b";
UP = _rl_term_up;
return 0;
}
@ -409,12 +462,12 @@ _rl_init_terminal_io (terminal_name)
/* Set up the variables that the termcap library expects the application
to provide. */
PC = term_pc ? *term_pc : 0;
BC = term_backspace;
UP = term_up;
PC = _rl_term_pc ? *_rl_term_pc : 0;
BC = _rl_term_backspace;
UP = _rl_term_up;
if (!term_cr)
term_cr = "\r";
if (!_rl_term_cr)
_rl_term_cr = "\r";
_rl_term_autowrap = tgetflag ("am") && tgetflag ("xn");
@ -424,48 +477,53 @@ _rl_init_terminal_io (terminal_name)
character insertion if *any one of* the capabilities `IC',
`im', `ic' or `ip' is provided." But we can't do anything if
only `ip' is provided, so... */
terminal_can_insert = (term_IC || term_im || term_ic);
_rl_terminal_can_insert = (_rl_term_IC || _rl_term_im || _rl_term_ic);
/* Check to see if this terminal has a meta key and clear the capability
variables if there is none. */
term_has_meta = (tgetflag ("km") || tgetflag ("MT"));
if (!term_has_meta)
term_mm = term_mo = (char *)NULL;
_rl_term_mm = _rl_term_mo = (char *)NULL;
#endif /* !__MSDOS__ */
/* Attempt to find and bind the arrow keys. Do not override already
bound keys in an overzealous attempt, however. */
xkeymap = _rl_keymap;
_rl_keymap = emacs_standard_keymap;
_rl_bind_if_unbound (term_ku, rl_get_previous_history);
_rl_bind_if_unbound (term_kd, rl_get_next_history);
_rl_bind_if_unbound (term_kr, rl_forward);
_rl_bind_if_unbound (term_kl, rl_backward);
_rl_bind_if_unbound (term_kh, rl_beg_of_line); /* Home */
_rl_bind_if_unbound (term_kH, rl_end_of_line); /* End */
bind_termcap_arrow_keys (emacs_standard_keymap);
#if defined (VI_MODE)
_rl_keymap = vi_movement_keymap;
_rl_bind_if_unbound (term_ku, rl_get_previous_history);
_rl_bind_if_unbound (term_kd, rl_get_next_history);
_rl_bind_if_unbound (term_kr, rl_forward);
_rl_bind_if_unbound (term_kl, rl_backward);
_rl_bind_if_unbound (term_kh, rl_beg_of_line); /* Home */
_rl_bind_if_unbound (term_kH, rl_end_of_line); /* End */
bind_termcap_arrow_keys (vi_movement_keymap);
bind_termcap_arrow_keys (vi_insertion_keymap);
#endif /* VI_MODE */
_rl_keymap = xkeymap;
return 0;
}
/* Bind the arrow key sequences from the termcap description in MAP. */
static void
bind_termcap_arrow_keys (map)
Keymap map;
{
Keymap xkeymap;
xkeymap = _rl_keymap;
_rl_keymap = map;
_rl_bind_if_unbound (_rl_term_ku, rl_get_previous_history);
_rl_bind_if_unbound (_rl_term_kd, rl_get_next_history);
_rl_bind_if_unbound (_rl_term_kr, rl_forward);
_rl_bind_if_unbound (_rl_term_kl, rl_backward);
_rl_bind_if_unbound (_rl_term_kh, rl_beg_of_line); /* Home */
_rl_bind_if_unbound (_rl_term_at7, rl_end_of_line); /* End */
_rl_keymap = xkeymap;
}
char *
rl_get_termcap (cap)
char *cap;
const char *cap;
{
register int i;
@ -483,7 +541,7 @@ rl_get_termcap (cap)
has changed. */
int
rl_reset_terminal (terminal_name)
char *terminal_name;
const char *terminal_name;
{
_rl_init_terminal_io (terminal_name);
return 0;
@ -509,7 +567,7 @@ _rl_output_character_function (c)
/* Write COUNT characters from STRING to the output stream. */
void
_rl_output_some_chars (string, count)
char *string;
const char *string;
int count;
{
fwrite (string, 1, count, _rl_out_stream);
@ -523,9 +581,9 @@ _rl_backspace (count)
register int i;
#ifndef __MSDOS__
if (term_backspace)
if (_rl_term_backspace)
for (i = 0; i < count; i++)
tputs (term_backspace, 1, _rl_output_character_function);
tputs (_rl_term_backspace, 1, _rl_output_character_function);
else
#endif
for (i = 0; i < count; i++)
@ -535,11 +593,11 @@ _rl_backspace (count)
/* Move to the start of the next line. */
int
crlf ()
rl_crlf ()
{
#if defined (NEW_TTY_DRIVER)
if (term_cr)
tputs (term_cr, 1, _rl_output_character_function);
if (_rl_term_cr)
tputs (_rl_term_cr, 1, _rl_output_character_function);
#endif /* NEW_TTY_DRIVER */
putc ('\n', _rl_out_stream);
return 0;
@ -547,7 +605,7 @@ crlf ()
/* Ring the terminal bell. */
int
ding ()
rl_ding ()
{
if (readline_echoing_p)
{
@ -561,9 +619,9 @@ ding ()
ScreenVisualBell ();
break;
#else
if (visible_bell)
if (_rl_visible_bell)
{
tputs (visible_bell, 1, _rl_output_character_function);
tputs (_rl_visible_bell, 1, _rl_output_character_function);
break;
}
#endif
@ -588,8 +646,8 @@ void
_rl_enable_meta_key ()
{
#if !defined (__DJGPP__)
if (term_has_meta && term_mm)
tputs (term_mm, 1, _rl_output_character_function);
if (term_has_meta && _rl_term_mm)
tputs (_rl_term_mm, 1, _rl_output_character_function);
#endif
}
@ -598,9 +656,35 @@ _rl_control_keypad (on)
int on;
{
#if !defined (__DJGPP__)
if (on && term_ks)
tputs (term_ks, 1, _rl_output_character_function);
else if (!on && term_ke)
tputs (term_ke, 1, _rl_output_character_function);
if (on && _rl_term_ks)
tputs (_rl_term_ks, 1, _rl_output_character_function);
else if (!on && _rl_term_ke)
tputs (_rl_term_ke, 1, _rl_output_character_function);
#endif
}
/* **************************************************************** */
/* */
/* Controlling the Cursor */
/* */
/* **************************************************************** */
/* Set the cursor appropriately depending on IM, which is one of the
insert modes (insert or overwrite). Insert mode gets the normal
cursor. Overwrite mode gets a very visible cursor. Only does
anything if we have both capabilities. */
void
_rl_set_cursor (im, force)
int im, force;
{
if (_rl_term_ve && _rl_term_vs)
{
if (force || im != rl_insert_mode)
{
if (im == RL_IM_OVERWRITE)
tputs (_rl_term_vs, 1, _rl_output_character_function);
else
tputs (_rl_term_ve, 1, _rl_output_character_function);
}
}
}

1540
readline/text.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -48,25 +48,18 @@
#include "tilde.h"
#if defined (TEST) || defined (STATIC_MALLOC)
static char *xmalloc (), *xrealloc ();
static void *xmalloc (), *xrealloc ();
#else
# if defined __STDC__
extern char *xmalloc (int);
extern char *xrealloc (void *, int);
# else
extern char *xmalloc (), *xrealloc ();
# endif /* !__STDC__ */
# include "xmalloc.h"
#endif /* TEST || STATIC_MALLOC */
#if !defined (HAVE_GETPW_DECLS)
extern struct passwd *getpwuid (), *getpwnam ();
extern struct passwd *getpwuid PARAMS((uid_t));
extern struct passwd *getpwnam PARAMS((const char *));
#endif /* !HAVE_GETPW_DECLS */
#if !defined (savestring)
# ifndef strcpy
extern char *strcpy ();
# endif
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
#endif /* !savestring */
#if !defined (NULL)
@ -80,49 +73,54 @@ extern char *strcpy ();
/* If being compiled as part of bash, these will be satisfied from
variables.o. If being compiled as part of readline, they will
be satisfied from shell.o. */
extern char *get_home_dir __P((void));
extern char *get_env_value __P((char *));
extern char *sh_get_home_dir PARAMS((void));
extern char *sh_get_env_value PARAMS((const char *));
/* The default value of tilde_additional_prefixes. This is set to
whitespace preceding a tilde so that simple programs which do not
perform any word separation get desired behaviour. */
static char *default_prefixes[] =
{ " ~", "\t~", (char *)NULL };
static const char *default_prefixes[] =
{ " ~", "\t~", (const char *)NULL };
/* The default value of tilde_additional_suffixes. This is set to
whitespace or newline so that simple programs which do not
perform any word separation get desired behaviour. */
static char *default_suffixes[] =
{ " ", "\n", (char *)NULL };
static const char *default_suffixes[] =
{ " ", "\n", (const char *)NULL };
/* If non-null, this contains the address of a function that the application
wants called before trying the standard tilde expansions. The function
is called with the text sans tilde, and returns a malloc()'ed string
which is the expansion, or a NULL pointer if the expansion fails. */
CPFunction *tilde_expansion_preexpansion_hook = (CPFunction *)NULL;
tilde_hook_func_t *tilde_expansion_preexpansion_hook = (tilde_hook_func_t *)NULL;
/* If non-null, this contains the address of a function to call if the
standard meaning for expanding a tilde fails. The function is called
with the text (sans tilde, as in "foo"), and returns a malloc()'ed string
which is the expansion, or a NULL pointer if there is no expansion. */
CPFunction *tilde_expansion_failure_hook = (CPFunction *)NULL;
tilde_hook_func_t *tilde_expansion_failure_hook = (tilde_hook_func_t *)NULL;
/* When non-null, this is a NULL terminated array of strings which
are duplicates for a tilde prefix. Bash uses this to expand
`=~' and `:~'. */
char **tilde_additional_prefixes = default_prefixes;
char **tilde_additional_prefixes = (char **)default_prefixes;
/* When non-null, this is a NULL terminated array of strings which match
the end of a username, instead of just "/". Bash sets this to
`:' and `=~'. */
char **tilde_additional_suffixes = default_suffixes;
char **tilde_additional_suffixes = (char **)default_suffixes;
static int tilde_find_prefix PARAMS((const char *, int *));
static int tilde_find_suffix PARAMS((const char *));
static char *isolate_tilde_prefix PARAMS((const char *, int *));
static char *glue_prefix_and_suffix PARAMS((char *, const char *, int));
/* Find the start of a tilde expansion in STRING, and return the index of
the tilde which starts the expansion. Place the length of the text
which identified this tilde starter in LEN, excluding the tilde itself. */
static int
tilde_find_prefix (string, len)
char *string;
const char *string;
int *len;
{
register int i, j, string_len;
@ -157,7 +155,7 @@ tilde_find_prefix (string, len)
the character which ends the tilde definition. */
static int
tilde_find_suffix (string)
char *string;
const char *string;
{
register int i, j, string_len;
register char **suffixes;
@ -186,16 +184,16 @@ tilde_find_suffix (string)
/* Return a new string which is the result of tilde expanding STRING. */
char *
tilde_expand (string)
char *string;
const char *string;
{
char *result;
int result_size, result_index;
result_index = result_size = 0;
if (result = strchr (string, '~'))
result = xmalloc (result_size = (strlen (string) + 16));
result = (char *)xmalloc (result_size = (strlen (string) + 16));
else
result = xmalloc (result_size = (strlen (string) + 1));
result = (char *)xmalloc (result_size = (strlen (string) + 1));
/* Scan through STRING expanding tildes as we come to them. */
while (1)
@ -209,7 +207,7 @@ tilde_expand (string)
/* Copy the skipped text into the result. */
if ((result_index + start + 1) > result_size)
result = xrealloc (result, 1 + (result_size += (start + 20)));
result = (char *)xrealloc (result, 1 + (result_size += (start + 20)));
strncpy (result + result_index, string, start);
result_index += start;
@ -226,7 +224,7 @@ tilde_expand (string)
break;
/* Expand the entire tilde word, and copy it into RESULT. */
tilde_word = xmalloc (1 + end);
tilde_word = (char *)xmalloc (1 + end);
strncpy (tilde_word, string, end);
tilde_word[end] = '\0';
string += end;
@ -235,14 +233,14 @@ tilde_expand (string)
free (tilde_word);
len = strlen (expansion);
#ifdef __CYGWIN32__
#ifdef __CYGWIN__
/* Fix for Cygwin to prevent ~user/xxx from expanding to //xxx when
$HOME for `user' is /. On cygwin, // denotes a network drive. */
$HOME for `user' is /. On cygwin, // denotes a network drive. */
if (len > 1 || *expansion != '/' || *string != '/')
#endif
{
if ((result_index + len + 1) > result_size)
result = xrealloc (result, 1 + (result_size += (len + 20)));
result = (char *)xrealloc (result, 1 + (result_size += (len + 20)));
strcpy (result + result_index, expansion);
result_index += len;
@ -260,13 +258,13 @@ tilde_expand (string)
the location it points to. */
static char *
isolate_tilde_prefix (fname, lenp)
char *fname;
const char *fname;
int *lenp;
{
char *ret;
int i;
ret = xmalloc (strlen (fname));
ret = (char *)xmalloc (strlen (fname));
#if defined (__MSDOS__)
for (i = 1; fname[i] && fname[i] != '/' && fname[i] != '\\'; i++)
#else
@ -283,7 +281,8 @@ isolate_tilde_prefix (fname, lenp)
SUFFIND. */
static char *
glue_prefix_and_suffix (prefix, suffix, suffind)
char *prefix, *suffix;
char *prefix;
const char *suffix;
int suffind;
{
char *ret;
@ -291,7 +290,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
plen = (prefix && *prefix) ? strlen (prefix) : 0;
slen = strlen (suffix + suffind);
ret = xmalloc (plen + slen + 1);
ret = (char *)xmalloc (plen + slen + 1);
if (plen)
strcpy (ret, prefix);
strcpy (ret + plen, suffix + suffind);
@ -303,7 +302,7 @@ glue_prefix_and_suffix (prefix, suffix, suffind)
This always returns a newly-allocated string, never static storage. */
char *
tilde_expand_word (filename)
char *filename;
const char *filename;
{
char *dirname, *expansion, *username;
int user_len;
@ -321,12 +320,12 @@ tilde_expand_word (filename)
if (filename[1] == '\0' || filename[1] == '/')
{
/* Prefix $HOME to the rest of the string. */
expansion = get_env_value ("HOME");
expansion = sh_get_env_value ("HOME");
/* If there is no HOME variable, look up the directory in
the password database. */
if (expansion == 0)
expansion = get_home_dir ();
expansion = sh_get_home_dir ();
return (glue_prefix_and_suffix (expansion, filename, 1));
}
@ -415,28 +414,28 @@ main (argc, argv)
static void memory_error_and_abort ();
static char *
static void *
xmalloc (bytes)
int bytes;
size_t bytes;
{
char *temp = (char *)malloc (bytes);
void *temp = (char *)malloc (bytes);
if (!temp)
memory_error_and_abort ();
return (temp);
}
static char *
static void *
xrealloc (pointer, bytes)
char *pointer;
void *pointer;
int bytes;
{
char *temp;
void *temp;
if (!pointer)
temp = (char *)malloc (bytes);
temp = malloc (bytes);
else
temp = (char *)realloc (pointer, bytes);
temp = realloc (pointer, bytes);
if (!temp)
memory_error_and_abort ();

View File

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

View File

@ -48,8 +48,7 @@
#include "history.h"
#include "rlprivate.h"
#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
#include "xmalloc.h"
/* Non-zero tells rl_delete_text and rl_insert_text to not add to
the undo list. */
@ -86,7 +85,7 @@ rl_add_undo (what, start, end, text)
/* Free the existing undo list. */
void
free_undo_list ()
rl_free_undo_list ()
{
while (rl_undo_list)
{
@ -107,17 +106,18 @@ int
rl_do_undo ()
{
UNDO_LIST *release;
int waiting_for_begin = 0;
int start, end;
int waiting_for_begin, start, end;
#define TRANS(i) ((i) == -1 ? rl_point : ((i) == -2 ? rl_end : (i)))
start = end = waiting_for_begin = 0;
do
{
if (!rl_undo_list)
return (0);
_rl_doing_an_undo = 1;
RL_SETSTATE(RL_STATE_UNDOING);
/* To better support vi-mode, a start or end value of -1 means
rl_point, and a value of -2 means rl_end. */
@ -152,11 +152,12 @@ rl_do_undo ()
if (waiting_for_begin)
waiting_for_begin--;
else
ding ();
rl_ding ();
break;
}
_rl_doing_an_undo = 0;
RL_UNSETSTATE(RL_STATE_UNDOING);
release = rl_undo_list;
rl_undo_list = rl_undo_list->next;
@ -231,7 +232,7 @@ rl_revert_line (count, key)
int count, key;
{
if (!rl_undo_list)
ding ();
rl_ding ();
else
{
while (rl_undo_list)
@ -254,7 +255,7 @@ rl_undo_command (count, key)
count--;
else
{
ding ();
rl_ding ();
break;
}
}

View File

@ -55,8 +55,6 @@
#include "rlprivate.h"
#include "xmalloc.h"
#define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
/* **************************************************************** */
/* */
/* Utility Functions */
@ -67,10 +65,10 @@
in words, or 1 if it is. */
int _rl_allow_pathname_alphabetic_chars = 0;
static char *pathname_alphabetic_chars = "/-_=~.#$";
static const char *pathname_alphabetic_chars = "/-_=~.#$";
int
alphabetic (c)
rl_alphabetic (c)
int c;
{
if (ALPHABETIC (c))
@ -84,16 +82,16 @@ alphabetic (c)
int
_rl_abort_internal ()
{
ding ();
rl_ding ();
rl_clear_message ();
_rl_init_argument ();
rl_pending_input = 0;
rl_clear_pending_input ();
_rl_defining_kbd_macro = 0;
while (_rl_executing_macro)
RL_UNSETSTATE (RL_STATE_MACRODEF);
while (rl_executing_macro)
_rl_pop_executing_macro ();
rl_last_func = (Function *)NULL;
rl_last_func = (rl_command_func_t *)NULL;
longjmp (readline_top_level, 1);
return (0);
}
@ -113,7 +111,7 @@ rl_tty_status (count, key)
ioctl (1, TIOCSTAT, (char *)0);
rl_refresh_line (count, key);
#else
ding ();
rl_ding ();
#endif
return 0;
}
@ -132,7 +130,7 @@ rl_copy_text (from, to)
SWAP (from, to);
length = to - from;
copy = xmalloc (1 + length);
copy = (char *)xmalloc (1 + length);
strncpy (copy, rl_line_buffer + from, length);
copy[length] = '\0';
return (copy);
@ -147,7 +145,7 @@ rl_extend_line_buffer (len)
while (len >= rl_line_buffer_len)
{
rl_line_buffer_len += DEFAULT_BUFFER_SIZE;
rl_line_buffer = xrealloc (rl_line_buffer, rl_line_buffer_len);
rl_line_buffer = (char *)xrealloc (rl_line_buffer, rl_line_buffer_len);
}
_rl_set_the_line ();
@ -193,7 +191,7 @@ rl_tilde_expand (ignore, key)
if (rl_line_buffer[start] == '~')
{
len = end - start + 1;
temp = xmalloc (len + 1);
temp = (char *)xmalloc (len + 1);
strncpy (temp, rl_line_buffer + start, len);
temp[len] = '\0';
homedir = tilde_expand (temp);
@ -215,16 +213,51 @@ rl_tilde_expand (ignore, key)
match in s1. The compare is case insensitive. */
char *
_rl_strindex (s1, s2)
register char *s1, *s2;
register const char *s1, *s2;
{
register int i, l, len;
for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
if (_rl_strnicmp (s1 + i, s2, l) == 0)
return (s1 + i);
return ((char *) (s1 + i));
return ((char *)NULL);
}
#ifndef HAVE_STRPBRK
/* Find the first occurrence in STRING1 of any character from STRING2.
Return a pointer to the character in STRING1. */
char *
_rl_strpbrk (string1, string2)
const char *string1, *string2;
{
register const char *scan;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
register int i, v;
memset (&ps, 0, sizeof (mbstate_t));
#endif
for (; *string1; string1++)
{
for (scan = string2; *scan; scan++)
{
if (*string1 == *scan)
return ((char *)string1);
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
v = _rl_get_char_len (string1, &ps);
if (v > 1)
string += v - 1; /* -1 to account for auto-increment in loop */
}
#endif
}
return ((char *)NULL);
}
#endif
#if !defined (HAVE_STRCASECMP)
/* Compare at most COUNT characters from string1 to string2. Case
doesn't matter. */
@ -283,69 +316,23 @@ _rl_qsort_string_compare (s1, s2)
#endif
}
/* Function equivalents for the macros defined in chartypes.h. */
#undef _rl_uppercase_p
int
_rl_uppercase_p (c)
int c;
{
return (isupper (c));
}
/* Function equivalents for the macros defined in chardefs.h. */
#define FUNCTION_FOR_MACRO(f) int (f) (c) int c; { return f (c); }
#undef _rl_lowercase_p
int
_rl_lowercase_p (c)
int c;
{
return (islower (c));
}
#undef _rl_pure_alphabetic
int
_rl_pure_alphabetic (c)
int c;
{
return (isupper (c) || islower (c));
}
#undef _rl_digit_p
int
_rl_digit_p (c)
int c;
{
return (isdigit (c));
}
#undef _rl_to_lower
int
_rl_to_lower (c)
int c;
{
return (isupper (c) ? tolower (c) : c);
}
#undef _rl_to_upper
int
_rl_to_upper (c)
int c;
{
return (islower (c) ? toupper (c) : c);
}
#undef _rl_digit_value
int
_rl_digit_value (c)
int c;
{
return (isdigit (c) ? c - '0' : c);
}
FUNCTION_FOR_MACRO (_rl_digit_p)
FUNCTION_FOR_MACRO (_rl_digit_value)
FUNCTION_FOR_MACRO (_rl_lowercase_p)
FUNCTION_FOR_MACRO (_rl_pure_alphabetic)
FUNCTION_FOR_MACRO (_rl_to_lower)
FUNCTION_FOR_MACRO (_rl_to_upper)
FUNCTION_FOR_MACRO (_rl_uppercase_p)
/* Backwards compatibility, now that savestring has been removed from
all `public' readline header files. */
#undef _rl_savestring
char *
_rl_savestring (s)
char *s;
const char *s;
{
return ((char *)strcpy (xmalloc (1 + (int)strlen (s)), (s)));
return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s)));
}

File diff suppressed because it is too large Load Diff

View File

@ -51,37 +51,23 @@
/* Some standard library routines. */
#include "rldefs.h"
#include "rlmbutil.h"
#include "readline.h"
#include "history.h"
#include "rlprivate.h"
#include "xmalloc.h"
#ifndef _rl_digit_p
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
#endif
#ifndef _rl_digit_value
#define _rl_digit_value(c) ((c) - '0')
#endif
#ifndef member
#define member(c, s) ((c) ? (char *)strchr ((s), (c)) != (char *)NULL : 0)
#endif
#ifndef isident
#define isident(c) ((_rl_pure_alphabetic (c) || _rl_digit_p (c) || c == '_'))
#endif
#ifndef exchange
#define exchange(x, y) do {int temp = x; x = y; y = temp;} while (0)
#endif
/* Non-zero means enter insertion mode. */
static int _rl_vi_doing_insert;
/* Command keys which do movement for xxx_to commands. */
static char *vi_motion = " hl^$0ftFt;,%wbeWBE|";
static const char *vi_motion = " hl^$0ftFT;,%wbeWBE|";
/* Keymap used for vi replace characters. Created dynamically since
rarely used. */
@ -101,7 +87,11 @@ static int _rl_vi_last_command = 'i'; /* default `.' puts you in insert mode */
static int _rl_vi_last_repeat = 1;
static int _rl_vi_last_arg_sign = 1;
static int _rl_vi_last_motion;
#if defined (HANDLE_MULTIBYTE)
static char _rl_vi_last_search_mbchar[MB_LEN_MAX];
#else
static int _rl_vi_last_search_char;
#endif
static int _rl_vi_last_replacement;
static int _rl_vi_last_key_before_insert;
@ -109,12 +99,14 @@ static int _rl_vi_last_key_before_insert;
static int vi_redoing;
/* Text modification commands. These are the `redoable' commands. */
static char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
static const char *vi_textmod = "_*\\AaIiCcDdPpYyRrSsXx~";
/* Arrays for the saved marks. */
static int vi_mark_chars[27];
static int vi_mark_chars['z' - 'a' + 1];
static int rl_digit_loop1 __P((void));
static void _rl_vi_stuff_insert PARAMS((int));
static void _rl_vi_save_insert PARAMS((UNDO_LIST *));
static int rl_digit_loop1 PARAMS((void));
void
_rl_vi_initialize_line ()
@ -168,12 +160,15 @@ int
rl_vi_redo (count, c)
int count, c;
{
int r;
if (!rl_explicit_arg)
{
rl_numeric_arg = _rl_vi_last_repeat;
rl_arg_sign = _rl_vi_last_arg_sign;
}
r = 0;
vi_redoing = 1;
/* If we're redoing an insert with `i', stuff in the inserted text
and do not go into insertion mode. */
@ -185,10 +180,10 @@ rl_vi_redo (count, c)
rl_point--;
}
else
_rl_dispatch (_rl_vi_last_command, _rl_keymap);
r = _rl_dispatch (_rl_vi_last_command, _rl_keymap);
vi_redoing = 0;
return (0);
return (r);
}
/* A placeholder for further expansion. */
@ -274,7 +269,7 @@ rl_vi_search (count, key)
break;
default:
ding ();
rl_ding ();
break;
}
return (0);
@ -330,7 +325,7 @@ rl_vi_prev_word (count, key)
if (rl_point == 0)
{
ding ();
rl_ding ();
return (0);
}
@ -352,7 +347,7 @@ rl_vi_next_word (count, key)
if (rl_point >= (rl_end - 1))
{
ding ();
rl_ding ();
return (0);
}
@ -370,7 +365,7 @@ rl_vi_end_word (count, key)
{
if (count < 0)
{
ding ();
rl_ding ();
return -1;
}
@ -460,14 +455,14 @@ rl_vi_fword (count, ignore)
while (count-- && rl_point < (rl_end - 1))
{
/* Move to white space (really non-identifer). */
if (isident (rl_line_buffer[rl_point]))
if (_rl_isident (rl_line_buffer[rl_point]))
{
while (isident (rl_line_buffer[rl_point]) && rl_point < rl_end)
while (_rl_isident (rl_line_buffer[rl_point]) && rl_point < rl_end)
rl_point++;
}
else /* if (!whitespace (rl_line_buffer[rl_point])) */
{
while (!isident (rl_line_buffer[rl_point]) &&
while (!_rl_isident (rl_line_buffer[rl_point]) &&
!whitespace (rl_line_buffer[rl_point]) && rl_point < rl_end)
rl_point++;
}
@ -497,9 +492,9 @@ rl_vi_bword (count, ignore)
back so we don't get messed up by the rl_point++ down there in
the while loop. Without this code, words like `l;' screw up the
function. */
last_is_ident = isident (rl_line_buffer[rl_point - 1]);
if ((isident (rl_line_buffer[rl_point]) && !last_is_ident) ||
(!isident (rl_line_buffer[rl_point]) && last_is_ident))
last_is_ident = _rl_isident (rl_line_buffer[rl_point - 1]);
if ((_rl_isident (rl_line_buffer[rl_point]) && !last_is_ident) ||
(!_rl_isident (rl_line_buffer[rl_point]) && last_is_ident))
rl_point--;
while (rl_point > 0 && whitespace (rl_line_buffer[rl_point]))
@ -507,10 +502,10 @@ rl_vi_bword (count, ignore)
if (rl_point > 0)
{
if (isident (rl_line_buffer[rl_point]))
while (--rl_point >= 0 && isident (rl_line_buffer[rl_point]));
if (_rl_isident (rl_line_buffer[rl_point]))
while (--rl_point >= 0 && _rl_isident (rl_line_buffer[rl_point]));
else
while (--rl_point >= 0 && !isident (rl_line_buffer[rl_point]) &&
while (--rl_point >= 0 && !_rl_isident (rl_line_buffer[rl_point]) &&
!whitespace (rl_line_buffer[rl_point]));
rl_point++;
}
@ -532,10 +527,10 @@ rl_vi_eword (count, ignore)
if (rl_point < rl_end)
{
if (isident (rl_line_buffer[rl_point]))
while (++rl_point < rl_end && isident (rl_line_buffer[rl_point]));
if (_rl_isident (rl_line_buffer[rl_point]))
while (++rl_point < rl_end && _rl_isident (rl_line_buffer[rl_point]));
else
while (++rl_point < rl_end && !isident (rl_line_buffer[rl_point])
while (++rl_point < rl_end && !_rl_isident (rl_line_buffer[rl_point])
&& !whitespace (rl_line_buffer[rl_point]));
}
rl_point--;
@ -557,7 +552,17 @@ rl_vi_append_mode (count, key)
int count, key;
{
if (rl_point < rl_end)
rl_point++;
{
if (MB_CUR_MAX == 1 || rl_byte_oriented)
rl_point++;
else
{
int point = rl_point;
rl_forward_char (1, key);
if (point == rl_point)
rl_point = rl_end;
}
}
rl_vi_insertion_mode (1, key);
return (0);
}
@ -611,7 +616,7 @@ _rl_vi_save_insert (up)
if (len >= vi_insert_buffer_size)
{
vi_insert_buffer_size += (len + 32) - (len % 32);
vi_insert_buffer = xrealloc (vi_insert_buffer, vi_insert_buffer_size);
vi_insert_buffer = (char *)xrealloc (vi_insert_buffer, vi_insert_buffer_size);
}
strncpy (vi_insert_buffer, rl_line_buffer + start, len - 1);
vi_insert_buffer[len-1] = '\0';
@ -622,6 +627,7 @@ _rl_vi_done_inserting ()
{
if (_rl_vi_doing_insert)
{
/* The `C', `s', and `S' commands set this. */
rl_end_undo_group ();
/* Now, the text between rl_undo_list->next->start and
rl_undo_list->next->end is what was inserted while in insert
@ -650,7 +656,7 @@ rl_vi_movement_mode (count, key)
int count, key;
{
if (rl_point > 0)
rl_backward (1, key);
rl_backward_char (1, key);
_rl_keymap = vi_movement_keymap;
_rl_vi_done_inserting ();
@ -667,6 +673,51 @@ rl_vi_arg_digit (count, c)
return (rl_digit_argument (count, c));
}
/* Change the case of the next COUNT characters. */
#if defined (HANDLE_MULTIBYTE)
static int
_rl_vi_change_mbchar_case (count)
int count;
{
wchar_t wc;
char mb[MB_LEN_MAX];
mbstate_t ps;
memset (&ps, 0, sizeof (mbstate_t));
if (_rl_adjust_point (rl_line_buffer, rl_point, &ps) > 0)
count--;
while (count-- && rl_point < rl_end)
{
mbrtowc (&wc, rl_line_buffer + rl_point, rl_end - rl_point, &ps);
if (iswupper (wc))
wc = towlower (wc);
else if (iswlower (wc))
wc = towupper (wc);
else
{
/* Just skip over chars neither upper nor lower case */
rl_forward_char (1, 0);
continue;
}
/* Vi is kind of strange here. */
if (wc)
{
wctomb (mb, wc);
rl_begin_undo_group ();
rl_delete (1, 0);
rl_insert_text (mb);
rl_end_undo_group ();
rl_vi_check ();
}
else
rl_forward_char (1, 0);
}
return 0;
}
#endif
int
rl_vi_change_case (count, ignore)
int count, ignore;
@ -677,6 +728,11 @@ rl_vi_change_case (count, ignore)
if (rl_point >= rl_end)
return (0);
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
return (_rl_vi_change_mbchar_case (count));
#endif
while (count-- && rl_point < rl_end)
{
if (_rl_uppercase_p (rl_line_buffer[rl_point]))
@ -686,7 +742,7 @@ rl_vi_change_case (count, ignore)
else
{
/* Just skip over characters neither upper nor lower case. */
rl_forward (1, c);
rl_forward_char (1, c);
continue;
}
@ -695,12 +751,12 @@ rl_vi_change_case (count, ignore)
{
rl_begin_undo_group ();
rl_delete (1, c);
rl_insert (1, c);
_rl_insert_char (1, c);
rl_end_undo_group ();
rl_vi_check ();
}
else
rl_forward (1, c);
rl_forward_char (1, c);
}
return (0);
}
@ -710,10 +766,10 @@ rl_vi_put (count, key)
int count, key;
{
if (!_rl_uppercase_p (key) && (rl_point + 1 <= rl_end))
rl_point++;
rl_point = _rl_find_next_mbchar (rl_line_buffer, rl_point, 1, MB_FIND_NONZERO);
rl_yank (1, key);
rl_backward (1, key);
rl_backward_char (1, key);
return (0);
}
@ -721,7 +777,12 @@ int
rl_vi_check ()
{
if (rl_point && rl_point == rl_end)
rl_point--;
{
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_NONZERO);
else
rl_point--;
}
return (0);
}
@ -744,7 +805,9 @@ rl_vi_domove (key, nextkey)
int old_end;
rl_mark = rl_point;
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
*nextkey = c;
if (!member (c, vi_motion))
@ -755,7 +818,9 @@ rl_vi_domove (key, nextkey)
rl_numeric_arg = _rl_digit_value (c);
rl_digit_loop1 ();
rl_numeric_arg *= save;
RL_SETSTATE(RL_STATE_MOREINPUT);
c = rl_read_key (); /* real command */
RL_UNSETSTATE(RL_STATE_MOREINPUT);
*nextkey = c;
}
else if (key == c && (key == 'd' || key == 'y' || key == 'c'))
@ -819,24 +884,36 @@ rl_vi_domove (key, nextkey)
}
if (rl_mark < rl_point)
exchange (rl_point, rl_mark);
SWAP (rl_point, rl_mark);
return (0);
}
/* A simplified loop for vi. Don't dispatch key at end.
Don't recognize minus sign? */
Don't recognize minus sign?
Should this do rl_save_prompt/rl_restore_prompt? */
static int
rl_digit_loop1 ()
{
int key, c;
RL_SETSTATE(RL_STATE_NUMERICARG);
while (1)
{
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg, 0);
if (rl_numeric_arg > 1000000)
{
rl_explicit_arg = rl_numeric_arg = 0;
rl_ding ();
rl_clear_message ();
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return 1;
}
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
RL_SETSTATE(RL_STATE_MOREINPUT);
key = c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (_rl_keymap[c].type == ISFUNC &&
if (c >= 0 && _rl_keymap[c].type == ISFUNC &&
_rl_keymap[c].function == rl_universal_argument)
{
rl_numeric_arg *= 4;
@ -859,6 +936,8 @@ rl_digit_loop1 ()
break;
}
}
RL_UNSETSTATE(RL_STATE_NUMERICARG);
return (0);
}
@ -875,7 +954,7 @@ rl_vi_delete_to (count, key)
if (rl_vi_domove (key, &c))
{
ding ();
rl_ding ();
return -1;
}
@ -903,7 +982,7 @@ rl_vi_change_to (count, key)
if (rl_vi_domove (key, &c))
{
ding ();
rl_ding ();
return -1;
}
@ -953,7 +1032,7 @@ rl_vi_yank_to (count, key)
if (rl_vi_domove (key, &c))
{
ding ();
rl_ding ();
return -1;
}
@ -979,11 +1058,14 @@ rl_vi_delete (count, key)
if (rl_end == 0)
{
ding ();
rl_ding ();
return -1;
}
end = rl_point + count;
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
end = _rl_find_next_mbchar (rl_line_buffer, rl_point, count, MB_FIND_NONZERO);
else
end = rl_point + count;
if (end >= rl_end)
end = rl_end;
@ -991,7 +1073,7 @@ rl_vi_delete (count, key)
rl_kill_text (rl_point, end);
if (rl_point > 0 && rl_point == rl_end)
rl_backward (1, key);
rl_backward_char (1, key);
return (0);
}
@ -1016,7 +1098,12 @@ int
rl_vi_char_search (count, key)
int count, key;
{
#if defined (HANDLE_MULTIBYTE)
static char *target;
static int mb_len;
#else
static char target;
#endif
static int orig_dir, dir;
if (key == ';' || key == ',')
@ -1024,9 +1111,22 @@ rl_vi_char_search (count, key)
else
{
if (vi_redoing)
#if defined (HANDLE_MULTIBYTE)
target = _rl_vi_last_search_mbchar;
#else
target = _rl_vi_last_search_char;
#endif
else
_rl_vi_last_search_char = target = (*rl_getc_function) (rl_instream);
{
#if defined (HANDLE_MULTIBYTE)
mb_len = _rl_read_mbchar (_rl_vi_last_search_mbchar, MB_LEN_MAX);
target = _rl_vi_last_search_mbchar;
#else
RL_SETSTATE(RL_STATE_MOREINPUT);
_rl_vi_last_search_char = target = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
#endif
}
switch (key)
{
@ -1048,7 +1148,11 @@ rl_vi_char_search (count, key)
}
}
#if defined (HANDLE_MULTIBYTE)
return (_rl_char_search_internal (count, dir, target, mb_len));
#else
return (_rl_char_search_internal (count, dir, target));
#endif
}
/* Match brackets */
@ -1056,19 +1160,30 @@ int
rl_vi_match (ignore, key)
int ignore, key;
{
int count = 1, brack, pos;
int count = 1, brack, pos, tmp, pre;
pos = rl_point;
if ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0)
{
while ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0 &&
rl_point < rl_end - 1)
rl_forward (1, key);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
while ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0)
{
pre = rl_point;
rl_forward_char (1, key);
if (pre == rl_point)
break;
}
}
else
while ((brack = rl_vi_bracktype (rl_line_buffer[rl_point])) == 0 &&
rl_point < rl_end - 1)
rl_forward_char (1, key);
if (brack <= 0)
{
rl_point = pos;
ding ();
rl_ding ();
return -1;
}
}
@ -1079,7 +1194,16 @@ rl_vi_match (ignore, key)
{
while (count)
{
if (--pos >= 0)
tmp = pos;
if (MB_CUR_MAX == 1 || rl_byte_oriented)
pos--;
else
{
pos = _rl_find_prev_mbchar (rl_line_buffer, pos, MB_FIND_ANY);
if (tmp == pos)
pos--;
}
if (pos >= 0)
{
int b = rl_vi_bracktype (rl_line_buffer[pos]);
if (b == -brack)
@ -1089,7 +1213,7 @@ rl_vi_match (ignore, key)
}
else
{
ding ();
rl_ding ();
return -1;
}
}
@ -1098,7 +1222,12 @@ rl_vi_match (ignore, key)
{ /* brack > 0 */
while (count)
{
if (++pos < rl_end)
if (MB_CUR_MAX == 1 || rl_byte_oriented)
pos++;
else
pos = _rl_find_next_mbchar (rl_line_buffer, pos, 1, MB_FIND_ANY);
if (pos < rl_end)
{
int b = rl_vi_bracktype (rl_line_buffer[pos]);
if (b == -brack)
@ -1108,7 +1237,7 @@ rl_vi_match (ignore, key)
}
else
{
ding ();
rl_ding ();
return -1;
}
}
@ -1133,6 +1262,11 @@ rl_vi_bracktype (c)
}
}
/* XXX - think about reading an entire mbchar with _rl_read_mbchar and
inserting it in one bunch instead of the loop below (like in
rl_vi_char_search or _rl_vi_change_mbchar_case. Set c to mbchar[0]
for test against 033 or ^C. Make sure that _rl_read_mbchar does
this right. */
int
rl_vi_change_char (count, key)
int count, key;
@ -1142,7 +1276,11 @@ rl_vi_change_char (count, key)
if (vi_redoing)
c = _rl_vi_last_replacement;
else
_rl_vi_last_replacement = c = (*rl_getc_function) (rl_instream);
{
RL_SETSTATE(RL_STATE_MOREINPUT);
_rl_vi_last_replacement = c = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
}
if (c == '\033' || c == CTRL ('C'))
return -1;
@ -1152,9 +1290,19 @@ rl_vi_change_char (count, key)
rl_begin_undo_group ();
rl_delete (1, c);
rl_insert (1, c);
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
while (_rl_insert_char (1, c))
{
RL_SETSTATE (RL_STATE_MOREINPUT);
c = rl_read_key ();
RL_UNSETSTATE (RL_STATE_MOREINPUT);
}
else
#endif
_rl_insert_char (1, c);
if (count == 0)
rl_backward (1, c);
rl_backward_char (1, c);
rl_end_undo_group ();
}
@ -1165,66 +1313,29 @@ int
rl_vi_subst (count, key)
int count, key;
{
rl_begin_undo_group ();
/* If we are redoing, rl_vi_change_to will stuff the last motion char */
if (vi_redoing == 0)
rl_stuff_char ((key == 'S') ? 'c' : ' '); /* `S' == `cc', `s' == `c ' */
if (_rl_uppercase_p (key))
{
rl_beg_of_line (1, key);
rl_kill_line (1, key);
}
else
rl_delete_text (rl_point, rl_point+count);
rl_end_undo_group ();
_rl_vi_set_last (key, count, rl_arg_sign);
if (vi_redoing)
{
int o = _rl_doing_an_undo;
_rl_doing_an_undo = 1;
if (vi_insert_buffer && *vi_insert_buffer)
rl_insert_text (vi_insert_buffer);
_rl_doing_an_undo = o;
}
else
{
rl_begin_undo_group ();
_rl_vi_doing_insert = 1;
rl_vi_insertion_mode (1, key);
}
return (0);
return (rl_vi_change_to (count, 'c'));
}
int
rl_vi_overstrike (count, key)
int count, key;
{
int i;
if (_rl_vi_doing_insert == 0)
{
_rl_vi_doing_insert = 1;
rl_begin_undo_group ();
}
for (i = 0; i < count; i++)
if (count > 0)
{
vi_replace_count++;
rl_begin_undo_group ();
if (rl_point < rl_end)
{
rl_delete (1, key);
rl_insert (1, key);
}
else
rl_insert (1, key);
rl_end_undo_group ();
_rl_overwrite_char (count, key);
vi_replace_count += count;
}
return (0);
}
@ -1238,7 +1349,7 @@ rl_vi_overstrike_delete (count, key)
{
if (vi_replace_count == 0)
{
ding ();
rl_ding ();
break;
}
s = rl_point;
@ -1247,7 +1358,7 @@ rl_vi_overstrike_delete (count, key)
vi_replace_count--;
if (rl_point == s)
rl_backward (1, key);
rl_backward_char (1, key);
}
if (vi_replace_count == 0 && _rl_vi_doing_insert)
@ -1308,7 +1419,7 @@ rl_vi_possible_completions()
}
else if (rl_line_buffer[rl_point - 1] == ';')
{
ding ();
rl_ding ();
return (0);
}
@ -1326,10 +1437,13 @@ rl_vi_set_mark (count, key)
{
int ch;
RL_SETSTATE(RL_STATE_MOREINPUT);
ch = rl_read_key ();
if (_rl_lowercase_p (ch) == 0)
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (ch < 'a' || ch > 'z')
{
ding ();
rl_ding ();
return -1;
}
ch -= 'a';
@ -1343,22 +1457,25 @@ rl_vi_goto_mark (count, key)
{
int ch;
RL_SETSTATE(RL_STATE_MOREINPUT);
ch = rl_read_key ();
RL_UNSETSTATE(RL_STATE_MOREINPUT);
if (ch == '`')
{
rl_point = rl_mark;
return 0;
}
else if (_rl_lowercase_p (ch) == 0)
else if (ch < 'a' || ch > 'z')
{
ding ();
rl_ding ();
return -1;
}
ch -= 'a';
if (vi_mark_chars[ch] == -1)
{
ding ();
rl_ding ();
return -1;
}
rl_point = vi_mark_chars[ch];

View File

@ -51,26 +51,26 @@ memory_error_and_abort (fname)
/* Return a pointer to free()able block of memory large enough
to hold BYTES number of bytes. If the memory cannot be allocated,
print an error message and abort. */
char *
PTR_T
xmalloc (bytes)
int bytes;
size_t bytes;
{
char *temp;
PTR_T temp;
temp = (char *)malloc (bytes);
temp = malloc (bytes);
if (temp == 0)
memory_error_and_abort ("xmalloc");
return (temp);
}
char *
PTR_T
xrealloc (pointer, bytes)
PTR_T pointer;
int bytes;
size_t bytes;
{
char *temp;
PTR_T temp;
temp = pointer ? (char *)realloc (pointer, bytes) : (char *)malloc (bytes);
temp = pointer ? realloc (pointer, bytes) : malloc (bytes);
if (temp == 0)
memory_error_and_abort ("xrealloc");

View File

@ -39,8 +39,8 @@
#endif /* !PTR_T */
extern char *xmalloc __P((int));
extern char *xrealloc __P((void *, int));
extern void xfree __P((void *));
extern PTR_T xmalloc PARAMS((size_t));
extern PTR_T xrealloc PARAMS((void *, size_t));
extern void xfree PARAMS((void *));
#endif /* _XMALLOC_H_ */