import of readline-4.3
This commit is contained in:
parent
f9267e152c
commit
84041b4c47
111 changed files with 44048 additions and 22012 deletions
|
@ -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
|
||||
|
|
311
readline/CHANGES
311
readline/CHANGES
|
@ -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.
|
||||
|
||||
|
|
277
readline/INSTALL
277
readline/INSTALL
|
@ -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'.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -171,40 +196,48 @@ 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
|
||||
|
||||
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
|
||||
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) $@; \
|
||||
${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)
|
||||
|
@ -253,90 +286,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
|
||||
|
@ -357,6 +399,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
|
||||
|
@ -364,6 +408,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
|
||||
|
@ -380,69 +425,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
|
||||
|
|
|
@ -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
1557
readline/aclocal.m4
vendored
File diff suppressed because it is too large
Load diff
|
@ -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. */
|
||||
|
|
317
readline/bind.c
317
readline/bind.c
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
113
readline/compat.c
Normal 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
|
@ -1,4 +1,4 @@
|
|||
/* config.h.in. Generated automatically from configure.in by autoheader. */
|
||||
/* config.h.in. Maintained by hand. */
|
||||
|
||||
/* Define if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
@ -6,14 +6,34 @@
|
|||
/* 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
|
||||
|
||||
#undef VOID_SIGHANDLER
|
||||
|
||||
/* Define if you have the isascii function. */
|
||||
#undef HAVE_ISASCII
|
||||
|
||||
/* Define if you have the isxdigit function. */
|
||||
#undef HAVE_ISXDIGIT
|
||||
|
||||
/* Define if you have the lstat function. */
|
||||
#undef HAVE_LSTAT
|
||||
|
||||
/* Define if you have the mbsrtowcs function. */
|
||||
#undef HAVE_MBSRTOWCS
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
|
@ -26,32 +46,59 @@
|
|||
/* Define if you have the setenv function. */
|
||||
#undef HAVE_SETENV
|
||||
|
||||
/* Define if you have the strcasecmp function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define if you have the setlocale function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* Define if you have the tcgetattr function. */
|
||||
#undef HAVE_TCGETATTR
|
||||
/* 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
|
||||
|
||||
/* Define if you have the <stdarg.h> header file. */
|
||||
#undef HAVE_STDARG_H
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* 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
|
||||
|
||||
|
@ -88,10 +135,16 @@
|
|||
/* Define if you have the <varargs.h> header file. */
|
||||
#undef HAVE_VARARGS_H
|
||||
|
||||
/* Define if you have the <stdarg.h> header file. */
|
||||
#undef HAVE_STDARG_H
|
||||
/* Define if you have the <wchar.h> header file. */
|
||||
#undef HAVE_WCHAR_H
|
||||
|
||||
#undef HAVE_LOCALE_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
|
||||
|
@ -124,7 +177,6 @@
|
|||
|
||||
#undef HAVE_POSIX_SIGSETJMP
|
||||
|
||||
/* config.h.bot */
|
||||
/* modify settings or make new ones based on what autoconf tells us. */
|
||||
|
||||
/* Ultrix botches type-ahead when switching from canonical to
|
||||
|
|
6205
readline/configure
vendored
6205
readline/configure
vendored
File diff suppressed because it is too large
Load diff
|
@ -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)
|
||||
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
|
||||
|
@ -40,7 +54,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"
|
||||
|
@ -49,33 +63,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
|
||||
|
@ -86,11 +109,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 ;;
|
||||
esac
|
||||
|
||||
case "$host_os" in
|
||||
|
@ -119,6 +149,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]\)\..*'`]
|
||||
|
@ -127,6 +163,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
|
@ -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
|
||||
|
|
|
@ -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
660
readline/doc/history.0
Normal 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
640
readline/doc/history.3
Normal 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 .
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
This is Info file history.info, produced by Makeinfo version 1.68 from
|
||||
the input file /usr/homes/chet/src/bash/readline-src/doc/hist.texinfo.
|
||||
This is history.info, produced by makeinfo version 4.1 from
|
||||
/usr/homes/chet/src/bash/readline-src/doc/hist.texinfo.
|
||||
|
||||
INFO-DIR-SECTION Libraries
|
||||
START-INFO-DIR-ENTRY
|
||||
|
@ -10,7 +10,7 @@ END-INFO-DIR-ENTRY
|
|||
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 pare
|
||||
|
@ -53,7 +53,7 @@ Using History Interactively
|
|||
This chapter describes how to use the 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, *note Programming with GNU History::..
|
||||
own programs, *note Programming with GNU History::.
|
||||
|
||||
* Menu:
|
||||
|
||||
|
@ -238,7 +238,7 @@ Programming with GNU History
|
|||
This chapter describes how to interface programs that you write with
|
||||
the GNU History Library. It should be considered a technical guide.
|
||||
For information on the interactive use of GNU History, *note Using
|
||||
History Interactively::..
|
||||
History Interactively::.
|
||||
|
||||
* Menu:
|
||||
|
||||
|
@ -293,9 +293,11 @@ History Storage
|
|||
The history list is an array of history entries. A history entry is
|
||||
declared as follows:
|
||||
|
||||
typedef void *histdata_t;
|
||||
|
||||
typedef struct _hist_entry {
|
||||
char *line;
|
||||
char *data;
|
||||
histdata_t data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
The history list itself might therefore be declared as
|
||||
|
@ -305,12 +307,14 @@ declared as follows:
|
|||
The state of the History library is encapsulated into a single
|
||||
structure:
|
||||
|
||||
/* 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;
|
||||
|
||||
|
@ -324,7 +328,7 @@ History Functions
|
|||
=================
|
||||
|
||||
This section describes the calling sequence for the various functions
|
||||
present in GNU History.
|
||||
exported by the GNU History library.
|
||||
|
||||
* Menu:
|
||||
|
||||
|
@ -354,11 +358,11 @@ Initializing History and State Management
|
|||
state of the History library when you want to use the history functions
|
||||
in your program.
|
||||
|
||||
- Function: void using_history ()
|
||||
- Function: void using_history (void)
|
||||
Begin a session in which the history functions might be used. This
|
||||
initializes the interactive variables.
|
||||
|
||||
- Function: HISTORY_STATE * history_get_history_state ()
|
||||
- Function: HISTORY_STATE * history_get_history_state (void)
|
||||
Return a structure describing the current state of the input
|
||||
history.
|
||||
|
||||
|
@ -374,7 +378,7 @@ History List Management
|
|||
These functions manage individual entries on the history list, or set
|
||||
parameters managing the list itself.
|
||||
|
||||
- Function: void add_history (char *string)
|
||||
- Function: void add_history (const char *string)
|
||||
Place STRING at the end of the history list. The associated data
|
||||
field (if any) is set to `NULL'.
|
||||
|
||||
|
@ -383,24 +387,25 @@ parameters managing the list itself.
|
|||
removed element is returned so you can free the line, data, and
|
||||
containing structure.
|
||||
|
||||
- Function: HIST_ENTRY * replace_history_entry (int which, char *line,
|
||||
char *data)
|
||||
- Function: HIST_ENTRY * replace_history_entry (int which, const char
|
||||
*line, histdata_t data)
|
||||
Make the history entry at offset 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.
|
||||
|
||||
- Function: void clear_history ()
|
||||
- Function: void clear_history (void)
|
||||
Clear the history list by deleting all the entries.
|
||||
|
||||
- Function: void stifle_history (int max)
|
||||
Stifle the history list, remembering only the last MAX entries.
|
||||
|
||||
- Function: int unstifle_history ()
|
||||
Stop stifling the history. This returns the previous amount the
|
||||
history was stifled. The value is positive if the history was
|
||||
stifled, negative if it wasn't.
|
||||
- Function: int unstifle_history (void)
|
||||
Stop stifling the history. This returns the previously-set
|
||||
maximum number of history entries (as set by `stifle_history()').
|
||||
The value is positive if the history was stifled, negative if it
|
||||
wasn't.
|
||||
|
||||
- Function: int history_is_stifled ()
|
||||
- Function: int history_is_stifled (void)
|
||||
Returns non-zero if the history is stifled, zero if it is not.
|
||||
|
||||
|
||||
|
@ -412,25 +417,26 @@ Information About the History List
|
|||
These functions return information about the entire history list or
|
||||
individual list entries.
|
||||
|
||||
- Function: HIST_ENTRY ** history_list ()
|
||||
Return a `NULL' terminated array of `HIST_ENTRY' which is the
|
||||
- Function: HIST_ENTRY ** history_list (void)
|
||||
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'.
|
||||
|
||||
- Function: int where_history ()
|
||||
- Function: int where_history (void)
|
||||
Returns the offset of the current history element.
|
||||
|
||||
- Function: HIST_ENTRY * current_history ()
|
||||
- Function: HIST_ENTRY * current_history (void)
|
||||
Return the history entry at the current position, as determined by
|
||||
`where_history ()'. If there is no entry there, return a `NULL'
|
||||
`where_history()'. If there is no entry there, return a `NULL'
|
||||
pointer.
|
||||
|
||||
- Function: HIST_ENTRY * history_get (int offset)
|
||||
Return the history entry at position OFFSET, starting from
|
||||
`history_base'. If there is no entry there, or if OFFSET is
|
||||
greater than the history length, return a `NULL' pointer.
|
||||
`history_base' (*note History Variables::). If there is no entry
|
||||
there, or if OFFSET is greater than the history length, return a
|
||||
`NULL' pointer.
|
||||
|
||||
- Function: int history_total_bytes ()
|
||||
- Function: 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.
|
||||
|
@ -445,15 +451,16 @@ Moving Around the History List
|
|||
set or changed.
|
||||
|
||||
- Function: int history_set_pos (int pos)
|
||||
Set the position in the history list to POS, an absolute index
|
||||
into the list.
|
||||
Set the current history offset to POS, an absolute index into the
|
||||
list. Returns 1 on success, 0 if POS is less than zero or greater
|
||||
than the number of history entries.
|
||||
|
||||
- Function: HIST_ENTRY * previous_history ()
|
||||
- Function: 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 `NULL' pointer.
|
||||
|
||||
- Function: HIST_ENTRY * next_history ()
|
||||
- Function: 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 `NULL' pointer.
|
||||
|
@ -470,24 +477,27 @@ and backward from the current history position. The search may be
|
|||
"anchored", meaning that the string must match at the beginning of the
|
||||
history entry.
|
||||
|
||||
- Function: int history_search (char *string, int direction)
|
||||
- Function: int history_search (const char *string, int direction)
|
||||
Search the history for STRING, starting at the current history
|
||||
offset. If DIRECTION < 0, then the search is through previous
|
||||
entries, else through subsequent. If 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 STRING was
|
||||
found. Otherwise, nothing is changed, and a -1 is returned.
|
||||
offset. If DIRECTION is less than 0, then the search is through
|
||||
previous entries, otherwise through subsequent entries. If 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 STRING was found. Otherwise, nothing is changed, and
|
||||
a -1 is returned.
|
||||
|
||||
- Function: int history_search_prefix (char *string, int direction)
|
||||
- Function: int history_search_prefix (const char *string, int
|
||||
direction)
|
||||
Search the history for STRING, starting at the current history
|
||||
offset. The search is anchored: matching lines must begin with
|
||||
STRING. If DIRECTION < 0, then the search is through previous
|
||||
entries, else through subsequent. If 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.
|
||||
STRING. If DIRECTION is less than 0, then the search is through
|
||||
previous entries, otherwise through subsequent entries. If 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.
|
||||
|
||||
- Function: int history_search_pos (char *string, int direction, int
|
||||
pos)
|
||||
- Function: int history_search_pos (const char *string, int direction,
|
||||
int pos)
|
||||
Search for STRING in the history list, starting at POS, an
|
||||
absolute index into the list. If DIRECTION is negative, the search
|
||||
proceeds backward from POS, otherwise forward. Returns the
|
||||
|
@ -503,29 +513,35 @@ 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.
|
||||
|
||||
- Function: int read_history (char *filename)
|
||||
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.
|
||||
- Function: int read_history (const char *filename)
|
||||
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.
|
||||
|
||||
- Function: int read_history_range (char *filename, int from, int to)
|
||||
- Function: int read_history_range (const char *filename, int from,
|
||||
int to)
|
||||
Read a range of lines from FILENAME, adding them to the history
|
||||
list. Start reading at line FROM and end at TO. If FROM is zero,
|
||||
start at the beginning. If TO is less than FROM, then read until
|
||||
the end of the file. If FILENAME is `NULL', then read from
|
||||
`~/.history'. Returns 0 if successful, or `errno' if not.
|
||||
|
||||
- Function: int write_history (char *filename)
|
||||
- Function: int write_history (const char *filename)
|
||||
Write the current history to FILENAME, overwriting FILENAME if
|
||||
necessary. If FILENAME is `NULL', then write the history list to
|
||||
`~/.history'. Values returned are as in `read_history ()'.
|
||||
`~/.history'. Returns 0 on success, or `errno' on a read or write
|
||||
error.
|
||||
|
||||
- Function: int append_history (int nelements, char *filename)
|
||||
Append the last NELEMENTS of the history list to FILENAME.
|
||||
- Function: int append_history (int nelements, const char *filename)
|
||||
Append the last NELEMENTS of the history list to FILENAME. If
|
||||
FILENAME is `NULL', then append to `~/.history'. Returns 0 on
|
||||
success, or `errno' on a read or write error.
|
||||
|
||||
- Function: int history_truncate_file (char *filename, int nlines)
|
||||
- Function: int history_truncate_file (const char *filename, int
|
||||
nlines)
|
||||
Truncate the history file FILENAME, leaving only the last NLINES
|
||||
lines.
|
||||
lines. If FILENAME is `NULL', then `~/.history' is truncated.
|
||||
Returns 0 on success, or `errno' on failure.
|
||||
|
||||
|
||||
File: history.info, Node: History Expansion, Prev: Managing the History File, Up: History Functions
|
||||
|
@ -533,15 +549,15 @@ File: history.info, Node: History Expansion, Prev: Managing the History File,
|
|||
History Expansion
|
||||
-----------------
|
||||
|
||||
These functions implement `csh'-like history expansion.
|
||||
These functions implement history expansion.
|
||||
|
||||
- Function: int history_expand (char *string, char **output)
|
||||
Expand STRING, placing the result into OUTPUT, a pointer to a
|
||||
string (*note History Interaction::.). Returns:
|
||||
string (*note History Interaction::). Returns:
|
||||
`0'
|
||||
If no expansions took place (or, if the only change in the
|
||||
text was the de-slashifying of the history expansion
|
||||
character);
|
||||
text was the removal of escape characters preceding the
|
||||
history expansion character);
|
||||
|
||||
`1'
|
||||
if expansions did take place;
|
||||
|
@ -551,18 +567,13 @@ History Expansion
|
|||
|
||||
`2'
|
||||
if the returned line should be displayed, but not executed,
|
||||
as with the `:p' modifier (*note Modifiers::.).
|
||||
as with the `:p' modifier (*note Modifiers::).
|
||||
|
||||
If an error ocurred in expansion, then OUTPUT contains a
|
||||
descriptive error message.
|
||||
|
||||
- Function: char * history_arg_extract (int first, int last, char
|
||||
*string)
|
||||
Extract a string segment consisting of the FIRST through LAST
|
||||
arguments present in STRING. Arguments are broken up as in Bash.
|
||||
|
||||
- Function: char * get_history_event (char *string, int *cindex, int
|
||||
qchar)
|
||||
- Function: char * get_history_event (const char *string, int *cindex,
|
||||
int qchar)
|
||||
Returns the text of the history event beginning at STRING +
|
||||
*CINDEX. *CINDEX is modified to point to after the event
|
||||
specifier. At function entry, CINDEX points to the index into
|
||||
|
@ -570,10 +581,17 @@ History Expansion
|
|||
character that is allowed to end the event specification in
|
||||
addition to the "normal" terminating characters.
|
||||
|
||||
- Function: char ** history_tokenize (char *string)
|
||||
- Function: char ** history_tokenize (const char *string)
|
||||
Return an array of tokens parsed out of STRING, much as the shell
|
||||
might. The tokens are split on white space and on the characters
|
||||
`()<>;&|$', and shell quoting conventions are obeyed.
|
||||
might. The tokens are split on the characters in the
|
||||
HISTORY_WORD_DELIMITERS variable, and shell quoting conventions
|
||||
are obeyed.
|
||||
|
||||
- Function: char * history_arg_extract (int first, int last, const
|
||||
char *string)
|
||||
Extract a string segment consisting of the FIRST through LAST
|
||||
arguments present in STRING. Arguments are split using
|
||||
`history_tokenize'.
|
||||
|
||||
|
||||
File: history.info, Node: History Variables, Next: History Programming Example, Prev: History Functions, Up: Programming with GNU History
|
||||
|
@ -581,7 +599,7 @@ File: history.info, Node: History Variables, Next: History Programming Example
|
|||
History Variables
|
||||
=================
|
||||
|
||||
This section describes the externally visible variables exported by
|
||||
This section describes the externally-visible variables exported by
|
||||
the GNU History Library.
|
||||
|
||||
- Variable: int history_base
|
||||
|
@ -590,12 +608,13 @@ the GNU History Library.
|
|||
- Variable: int history_length
|
||||
The number of entries currently stored in the history list.
|
||||
|
||||
- Variable: int max_input_history
|
||||
- Variable: int history_max_entries
|
||||
The maximum number of history entries. This must be changed using
|
||||
`stifle_history ()'.
|
||||
`stifle_history()'.
|
||||
|
||||
- Variable: char history_expansion_char
|
||||
The character that starts a history event. The default is `!'.
|
||||
The character that introduces a history event. The default is `!'.
|
||||
Setting this to 0 inhibits history expansion.
|
||||
|
||||
- Variable: char history_subst_char
|
||||
The character that invokes word substitution if found at the start
|
||||
|
@ -607,28 +626,32 @@ the GNU History Library.
|
|||
newline are ignored, suppressing history expansion for the
|
||||
remainder of the line. This is disabled by default.
|
||||
|
||||
- Variable: char * history_word_delimiters
|
||||
The characters that separate tokens for `history_tokenize()'. The
|
||||
default value is `" \t\n()<>;&|"'.
|
||||
|
||||
- Variable: char * history_no_expand_chars
|
||||
The list of characters which inhibit history expansion if found
|
||||
immediately following HISTORY_EXPANSION_CHAR. The default is
|
||||
whitespace and `='.
|
||||
space, tab, newline, carriage return, and `='.
|
||||
|
||||
- Variable: char * history_search_delimiter_chars
|
||||
The list of additional characters which can delimit a history
|
||||
search string, in addition to whitespace, `:' and `?' in the case
|
||||
search string, in addition to space, TAB, `:' and `?' in the case
|
||||
of a substring search. The default is empty.
|
||||
|
||||
- Variable: int history_quotes_inhibit_expansion
|
||||
If non-zero, single-quoted words are not scanned for the history
|
||||
expansion character. The default value is 0.
|
||||
|
||||
- Variable: Function * history_inhibit_expansion_function
|
||||
- Variable: rl_linebuf_func_t * history_inhibit_expansion_function
|
||||
This should be set to the address of a function that takes two
|
||||
arguments: a `char *' (STRING) and an integer index into that
|
||||
string (I). It should return a non-zero value if the history
|
||||
expansion starting at 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.
|
||||
arguments: a `char *' (STRING) and an `int' index into that string
|
||||
(I). It should return a non-zero value if the history expansion
|
||||
starting at 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'.
|
||||
|
||||
|
||||
File: history.info, Node: History Programming Example, Prev: History Variables, Up: Programming with GNU History
|
||||
|
@ -639,7 +662,12 @@ History Programming Example
|
|||
The following program demonstrates simple use of the GNU History
|
||||
Library.
|
||||
|
||||
main ()
|
||||
#include <stdio.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char line[1024], *t;
|
||||
int len, done = 0;
|
||||
|
@ -758,6 +786,7 @@ Function and Variable Index
|
|||
* history_is_stifled: History List Management.
|
||||
* history_length: History Variables.
|
||||
* history_list: Information About the History List.
|
||||
* history_max_entries: History Variables.
|
||||
* history_no_expand_chars: History Variables.
|
||||
* history_quotes_inhibit_expansion: History Variables.
|
||||
* history_search: Searching the History List.
|
||||
|
@ -770,7 +799,7 @@ Function and Variable Index
|
|||
* history_tokenize: History Expansion.
|
||||
* history_total_bytes: Information About the History List.
|
||||
* history_truncate_file: Managing the History File.
|
||||
* max_input_history: History Variables.
|
||||
* history_word_delimiters: History Variables.
|
||||
* next_history: Moving Around the History List.
|
||||
* previous_history: Moving Around the History List.
|
||||
* read_history: Managing the History File.
|
||||
|
@ -786,26 +815,26 @@ Function and Variable Index
|
|||
|
||||
|
||||
Tag Table:
|
||||
Node: Top1162
|
||||
Node: Using History Interactively1742
|
||||
Node: History Interaction2250
|
||||
Node: Event Designators3669
|
||||
Node: Word Designators4596
|
||||
Node: Modifiers6225
|
||||
Node: Programming with GNU History7363
|
||||
Node: Introduction to History8089
|
||||
Node: History Storage9774
|
||||
Node: History Functions10867
|
||||
Node: Initializing History and State Management11838
|
||||
Node: History List Management12630
|
||||
Node: Information About the History List14151
|
||||
Node: Moving Around the History List15457
|
||||
Node: Searching the History List16342
|
||||
Node: Managing the History File18174
|
||||
Node: History Expansion19680
|
||||
Node: History Variables21519
|
||||
Node: History Programming Example23837
|
||||
Node: Concept Index26441
|
||||
Node: Function and Variable Index26927
|
||||
Node: Top1136
|
||||
Node: Using History Interactively1716
|
||||
Node: History Interaction2223
|
||||
Node: Event Designators3642
|
||||
Node: Word Designators4569
|
||||
Node: Modifiers6198
|
||||
Node: Programming with GNU History7336
|
||||
Node: Introduction to History8061
|
||||
Node: History Storage9746
|
||||
Node: History Functions10857
|
||||
Node: Initializing History and State Management11841
|
||||
Node: History List Management12641
|
||||
Node: Information About the History List14235
|
||||
Node: Moving Around the History List15591
|
||||
Node: Searching the History List16580
|
||||
Node: Managing the History File18498
|
||||
Node: History Expansion20304
|
||||
Node: History Variables22199
|
||||
Node: History Programming Example24766
|
||||
Node: Concept Index27488
|
||||
Node: Function and Variable Index27974
|
||||
|
||||
End Tag Table
|
||||
|
|
File diff suppressed because it is too large
Load diff
800
readline/doc/history_3.ps
Normal file
800
readline/doc/history_3.ps
Normal file
|
@ -0,0 +1,800 @@
|
|||
%!PS-Adobe-3.0
|
||||
%%Creator: groff version 1.16.1
|
||||
%%CreationDate: Mon Mar 18 10:17:27 2002
|
||||
%%DocumentNeededResources: font Times-Roman
|
||||
%%+ font Times-Bold
|
||||
%%+ font Times-Italic
|
||||
%%DocumentSuppliedResources: procset grops 1.16 1
|
||||
%%Pages: 7
|
||||
%%PageOrder: Ascend
|
||||
%%Orientation: Portrait
|
||||
%%EndComments
|
||||
%%BeginProlog
|
||||
%%BeginResource: procset grops 1.16 1
|
||||
/setpacking where{
|
||||
pop
|
||||
currentpacking
|
||||
true setpacking
|
||||
}if
|
||||
/grops 120 dict dup begin
|
||||
/SC 32 def
|
||||
/A/show load def
|
||||
/B{0 SC 3 -1 roll widthshow}bind def
|
||||
/C{0 exch ashow}bind def
|
||||
/D{0 exch 0 SC 5 2 roll awidthshow}bind def
|
||||
/E{0 rmoveto show}bind def
|
||||
/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def
|
||||
/G{0 rmoveto 0 exch ashow}bind def
|
||||
/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
|
||||
/I{0 exch rmoveto show}bind def
|
||||
/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def
|
||||
/K{0 exch rmoveto 0 exch ashow}bind def
|
||||
/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
|
||||
/M{rmoveto show}bind def
|
||||
/N{rmoveto 0 SC 3 -1 roll widthshow}bind def
|
||||
/O{rmoveto 0 exch ashow}bind def
|
||||
/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
|
||||
/Q{moveto show}bind def
|
||||
/R{moveto 0 SC 3 -1 roll widthshow}bind def
|
||||
/S{moveto 0 exch ashow}bind def
|
||||
/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def
|
||||
/SF{
|
||||
findfont exch
|
||||
[exch dup 0 exch 0 exch neg 0 0]makefont
|
||||
dup setfont
|
||||
[exch/setfont cvx]cvx bind def
|
||||
}bind def
|
||||
/MF{
|
||||
findfont
|
||||
[5 2 roll
|
||||
0 3 1 roll
|
||||
neg 0 0]makefont
|
||||
dup setfont
|
||||
[exch/setfont cvx]cvx bind def
|
||||
}bind def
|
||||
/level0 0 def
|
||||
/RES 0 def
|
||||
/PL 0 def
|
||||
/LS 0 def
|
||||
/MANUAL{
|
||||
statusdict begin/manualfeed true store end
|
||||
}bind def
|
||||
/PLG{
|
||||
gsave newpath clippath pathbbox grestore
|
||||
exch pop add exch pop
|
||||
}bind def
|
||||
/BP{
|
||||
/level0 save def
|
||||
1 setlinecap
|
||||
1 setlinejoin
|
||||
72 RES div dup scale
|
||||
LS{
|
||||
90 rotate
|
||||
}{
|
||||
0 PL translate
|
||||
}ifelse
|
||||
1 -1 scale
|
||||
}bind def
|
||||
/EP{
|
||||
level0 restore
|
||||
showpage
|
||||
}bind def
|
||||
/DA{
|
||||
newpath arcn stroke
|
||||
}bind def
|
||||
/SN{
|
||||
transform
|
||||
.25 sub exch .25 sub exch
|
||||
round .25 add exch round .25 add exch
|
||||
itransform
|
||||
}bind def
|
||||
/DL{
|
||||
SN
|
||||
moveto
|
||||
SN
|
||||
lineto stroke
|
||||
}bind def
|
||||
/DC{
|
||||
newpath 0 360 arc closepath
|
||||
}bind def
|
||||
/TM matrix def
|
||||
/DE{
|
||||
TM currentmatrix pop
|
||||
translate scale newpath 0 0 .5 0 360 arc closepath
|
||||
TM setmatrix
|
||||
}bind def
|
||||
/RC/rcurveto load def
|
||||
/RL/rlineto load def
|
||||
/ST/stroke load def
|
||||
/MT/moveto load def
|
||||
/CL/closepath load def
|
||||
/FL{
|
||||
currentgray exch setgray fill setgray
|
||||
}bind def
|
||||
/BL/fill load def
|
||||
/LW/setlinewidth load def
|
||||
/RE{
|
||||
findfont
|
||||
dup maxlength 1 index/FontName known not{1 add}if dict begin
|
||||
{
|
||||
1 index/FID ne{def}{pop pop}ifelse
|
||||
}forall
|
||||
/Encoding exch def
|
||||
dup/FontName exch def
|
||||
currentdict end definefont pop
|
||||
}bind def
|
||||
/DEFS 0 def
|
||||
/EBEGIN{
|
||||
moveto
|
||||
DEFS begin
|
||||
}bind def
|
||||
/EEND/end load def
|
||||
/CNT 0 def
|
||||
/level1 0 def
|
||||
/PBEGIN{
|
||||
/level1 save def
|
||||
translate
|
||||
div 3 1 roll div exch scale
|
||||
neg exch neg exch translate
|
||||
0 setgray
|
||||
0 setlinecap
|
||||
1 setlinewidth
|
||||
0 setlinejoin
|
||||
10 setmiterlimit
|
||||
[]0 setdash
|
||||
/setstrokeadjust where{
|
||||
pop
|
||||
false setstrokeadjust
|
||||
}if
|
||||
/setoverprint where{
|
||||
pop
|
||||
false setoverprint
|
||||
}if
|
||||
newpath
|
||||
/CNT countdictstack def
|
||||
userdict begin
|
||||
/showpage{}def
|
||||
}bind def
|
||||
/PEND{
|
||||
clear
|
||||
countdictstack CNT sub{end}repeat
|
||||
level1 restore
|
||||
}bind def
|
||||
end def
|
||||
/setpacking where{
|
||||
pop
|
||||
setpacking
|
||||
}if
|
||||
%%EndResource
|
||||
%%IncludeResource: font Times-Roman
|
||||
%%IncludeResource: font Times-Bold
|
||||
%%IncludeResource: font Times-Italic
|
||||
grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
|
||||
def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
|
||||
/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef
|
||||
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
|
||||
/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
|
||||
/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
|
||||
/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
|
||||
/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
|
||||
/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
|
||||
/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex
|
||||
/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y
|
||||
/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft
|
||||
/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl
|
||||
/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
|
||||
/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
|
||||
/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen
|
||||
/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft
|
||||
/logicalnot/minus/registered/macron/degree/plusminus/twosuperior
|
||||
/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior
|
||||
/ordmasculine/guilsinglright/onequarter/onehalf/threequarters
|
||||
/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
|
||||
/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
|
||||
/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
|
||||
/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
|
||||
/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
|
||||
/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
|
||||
/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash
|
||||
/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
|
||||
/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE
|
||||
/Times-Roman@0 ENC0/Times-Roman RE
|
||||
%%EndProlog
|
||||
%%Page: 1 1
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
%%EndPageSetup
|
||||
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
|
||||
(OR)-.18 E(Y\(3\))-.65 E/F1 10.95/Times-Bold@0 SF -.219(NA)72 84 S(ME)
|
||||
.219 E F0(history \255 GNU History Library)108 96 Q F1(COPYRIGHT)72
|
||||
112.8 Q F0(The GNU History Library is Cop)108 124.8 Q
|
||||
(yright \251 1989-2002 by the Free Softw)-.1 E(are F)-.1 E
|
||||
(oundation, Inc.)-.15 E F1(DESCRIPTION)72 141.6 Q F0(Man)108 153.6 Q
|
||||
2.81(yp)-.15 G .31(rograms read input from the user a line at a time.)
|
||||
-2.81 F .309(The GNU History library is able to k)5.309 F .309
|
||||
(eep track of)-.1 F .024(those lines, associate arbitrary data with eac\
|
||||
h line, and utilize information from pre)108 165.6 R .024
|
||||
(vious lines in composing)-.25 F(ne)108 177.6 Q 2.5(wo)-.25 G(nes.)-2.5
|
||||
E F1(HIST)72 199.2 Q(OR)-.197 E 2.738(YE)-.383 G(XP)-2.738 E(ANSION)-.81
|
||||
E F0 .823(The history library supports a history e)108 211.2 R .822
|
||||
(xpansion feature that is identical to the history e)-.15 F .822
|
||||
(xpansion in)-.15 F/F2 10/Times-Bold@0 SF(bash.)3.322 E F0
|
||||
(This section describes what syntax features are a)108 223.2 Q -.25(va)
|
||||
-.2 G(ilable.).25 E 1.305(History e)108 240 R 1.305
|
||||
(xpansions introduce w)-.15 F 1.306(ords from the history list into the\
|
||||
input stream, making it easy to repeat)-.1 F .21
|
||||
(commands, insert the ar)108 252 R .21(guments to a pre)-.18 F .209
|
||||
(vious command into the current input line, or \214x errors in pre)-.25
|
||||
F(vious)-.25 E(commands quickly)108 264 Q(.)-.65 E 1.296(History e)108
|
||||
280.8 R 1.297(xpansion is usually performed immediately after a complet\
|
||||
e line is read.)-.15 F 1.297(It tak)6.297 F 1.297(es place in tw)-.1 F
|
||||
(o)-.1 E 2.855(parts. The)108 292.8 R .354(\214rst is to determine whic\
|
||||
h line from the history list to use during substitution.)2.855 F .354
|
||||
(The second is to)5.354 F .116
|
||||
(select portions of that line for inclusion into the current one.)108
|
||||
304.8 R .117(The line selected from the history is the)5.116 F/F3 10
|
||||
/Times-Italic@0 SF -.15(ev)2.617 G(ent).15 E F0(,)A .846
|
||||
(and the portions of that line that are acted upon are)108 316.8 R F3
|
||||
(wor)3.346 E(ds)-.37 E F0 5.846(.V)C(arious)-6.956 E F3(modi\214er)3.346
|
||||
E(s)-.1 E F0 .846(are a)3.346 F -.25(va)-.2 G .845(ilable to manipulate)
|
||||
.25 F .304(the selected w)108 328.8 R 2.804(ords. The)-.1 F .304
|
||||
(line is brok)2.804 F .304(en into w)-.1 F .304(ords in the same f)-.1 F
|
||||
.304(ashion as)-.1 F F2(bash)2.804 E F0 .305
|
||||
(does when reading input, so)2.804 F .539(that se)108 340.8 R -.15(ve)
|
||||
-.25 G .539(ral w).15 F .539(ords that w)-.1 F .539
|
||||
(ould otherwise be separated are considered one w)-.1 F .538
|
||||
(ord when surrounded by quotes)-.1 F .307(\(see the description of)108
|
||||
352.8 R F2(history_tok)2.807 E(enize\(\))-.1 E F0(belo)2.807 E 2.807
|
||||
(w\). History)-.25 F -.15(ex)2.807 G .307
|
||||
(pansions are introduced by the appearance of).15 F .52(the history e)
|
||||
108 364.8 R .52(xpansion character)-.15 F 3.02(,w)-.4 G .52(hich is)
|
||||
-3.02 F F2(!)3.853 E F0 .52(by def)3.853 F 3.02(ault. Only)-.1 F .52
|
||||
(backslash \()3.02 F F2(\\).833 E F0 3.02(\)a).833 G .52
|
||||
(nd single quotes can quote the)-3.02 F(history e)108 376.8 Q
|
||||
(xpansion character)-.15 E(.)-.55 E F2(Ev)87 393.6 Q(ent Designators)-.1
|
||||
E F0(An e)108 405.6 Q -.15(ve)-.25 G(nt designator is a reference to a \
|
||||
command line entry in the history list.).15 E F2(!)108 422.4 Q F0
|
||||
(Start a history substitution, e)32.67 E(xcept when follo)-.15 E
|
||||
(wed by a)-.25 E F2(blank)2.5 E F0 2.5(,n)C -.25(ew)-2.5 G
|
||||
(line, = or \(.).25 E F2(!)108 434.4 Q F3(n)A F0(Refer to command line)
|
||||
27.67 E F3(n)2.5 E F0(.).24 E F2<21ad>108 446.4 Q F3(n)A F0
|
||||
(Refer to the current command line minus)21.97 E F3(n)2.5 E F0(.).24 E
|
||||
F2(!!)108 458.4 Q F0(Refer to the pre)29.34 E(vious command.)-.25 E
|
||||
(This is a synon)5 E(ym for `!\2551'.)-.15 E F2(!)108 470.4 Q F3(string)
|
||||
A F0(Refer to the most recent command starting with)9.33 E F3(string)2.5
|
||||
E F0(.).22 E F2(!?)108 482.4 Q F3(string)A F2([?])A F0 1.057
|
||||
(Refer to the most recent command containing)144 494.4 R F3(string)3.557
|
||||
E F0 6.057(.T).22 G 1.057(he trailing)-6.057 F F2(?)3.557 E F0 1.057
|
||||
(may be omitted if)3.557 F F3(string)3.557 E F0(is)3.557 E(follo)144
|
||||
506.4 Q(wed immediately by a ne)-.25 E(wline.)-.25 E/F4 12/Times-Bold@0
|
||||
SF(^)108 523.4 Q F3(string1)-5 I F4(^)5 I F3(string2)-5 I F4(^)5 I F0
|
||||
2.66(Quick substitution.)144 530.4 R 2.66
|
||||
(Repeat the last command, replacing)7.66 F F3(string1)5.16 E F0(with)
|
||||
5.16 E F3(string2)5.16 E F0 7.66(.E).02 G(qui)-7.66 E -.25(va)-.25 G
|
||||
2.66(lent to).25 F -.74(``)144 542.4 S(!!:s/).74 E F3(string1)A F0(/)A
|
||||
F3(string2)A F0(/')A 2.5('\()-.74 G(see)-2.5 E F2(Modi\214ers)2.5 E F0
|
||||
(belo)2.5 E(w\).)-.25 E F2(!#)108 554.4 Q F0
|
||||
(The entire command line typed so f)27.67 E(ar)-.1 E(.)-.55 E F2 -.75
|
||||
(Wo)87 571.2 S(rd Designators).75 E F0 -.8(Wo)108 583.2 S 1.313
|
||||
(rd designators are used to select desired w).8 F 1.314(ords from the e)
|
||||
-.1 F -.15(ve)-.25 G 3.814(nt. A).15 F F2(:)3.814 E F0 1.314
|
||||
(separates the e)3.814 F -.15(ve)-.25 G 1.314(nt speci\214cation).15 F
|
||||
.53(from the w)108 595.2 R .529(ord designator)-.1 F 5.529(.I)-.55 G
|
||||
3.029(tm)-5.529 G .529(ay be omitted if the w)-3.029 F .529
|
||||
(ord designator be)-.1 F .529(gins with a)-.15 F F2(^)3.029 E F0(,)A F2
|
||||
($)3.029 E F0(,)A F2(*)3.029 E F0(,)A F2<ad>3.029 E F0 3.029(,o)C(r)
|
||||
-3.029 E F2(%)3.029 E F0 5.529(.W)C(ords)-6.329 E 1.3
|
||||
(are numbered from the be)108 607.2 R 1.3
|
||||
(ginning of the line, with the \214rst w)-.15 F 1.301
|
||||
(ord being denoted by 0 \(zero\).)-.1 F -.8(Wo)6.301 G 1.301(rds are).8
|
||||
F(inserted into the current line separated by single spaces.)108 619.2 Q
|
||||
F2 2.5(0\()108 636 S(zer)-2.5 E(o\))-.18 E F0(The zeroth w)144 648 Q 2.5
|
||||
(ord. F)-.1 F(or the shell, this is the command w)-.15 E(ord.)-.1 E F3
|
||||
(n)108 660 Q F0(The)31 E F3(n)2.5 E F0(th w)A(ord.)-.1 E F2(^)108 672 Q
|
||||
F0(The \214rst ar)32.67 E 2.5(gument. That)-.18 F(is, w)2.5 E(ord 1.)-.1
|
||||
E F2($)108 684 Q F0(The last ar)31 E(gument.)-.18 E F2(%)108 696 Q F0
|
||||
(The w)26 E(ord matched by the most recent `?)-.1 E F3(string)A F0
|
||||
(?' search.)A F3(x)108 708 Q F2<ad>A F3(y)A F0 2.5(Ar)21.42 G(ange of w)
|
||||
-2.5 E(ords; `\255)-.1 E F3(y)A F0 2.5('a)C(bbre)-2.5 E(viates `0\255)
|
||||
-.25 E F3(y)A F0('.)A(GNU History 4.3)72 768 Q(2002 January 31)131.79 E
|
||||
(1)195.95 E EP
|
||||
%%Page: 2 2
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
%%EndPageSetup
|
||||
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
|
||||
(OR)-.18 E(Y\(3\))-.65 E/F1 10/Times-Bold@0 SF(*)108 84 Q F0 .316
|
||||
(All of the w)31 F .316(ords b)-.1 F .316(ut the zeroth.)-.2 F .315
|
||||
(This is a synon)5.315 F .315(ym for `)-.15 F/F2 10/Times-Italic@0 SF
|
||||
(1\255$)A F0 2.815('. It)B .315(is not an error to use)2.815 F F1(*)
|
||||
2.815 E F0 .315(if there is)2.815 F(just one w)144 96 Q(ord in the e)-.1
|
||||
E -.15(ve)-.25 G(nt; the empty string is returned in that case.).15 E F1
|
||||
(x*)108 108 Q F0(Abbre)26 E(viates)-.25 E F2(x\255$)2.5 E F0(.)A F1
|
||||
<78ad>108 120 Q F0(Abbre)25.3 E(viates)-.25 E F2(x\255$)2.5 E F0(lik)2.5
|
||||
E(e)-.1 E F1(x*)2.5 E F0 2.5(,b)C(ut omits the last w)-2.7 E(ord.)-.1 E
|
||||
(If a w)108 136.8 Q(ord designator is supplied without an e)-.1 E -.15
|
||||
(ve)-.25 G(nt speci\214cation, the pre).15 E
|
||||
(vious command is used as the e)-.25 E -.15(ve)-.25 G(nt.).15 E F1
|
||||
(Modi\214ers)87 153.6 Q F0 .183(After the optional w)108 165.6 R .183
|
||||
(ord designator)-.1 F 2.683(,t)-.4 G .184
|
||||
(here may appear a sequence of one or more of the follo)-2.683 F .184
|
||||
(wing modi\214ers,)-.25 F(each preceded by a `:'.)108 177.6 Q F1(h)108
|
||||
194.4 Q F0(Remo)30.44 E .3 -.15(ve a t)-.15 H
|
||||
(railing \214le name component, lea).15 E(ving only the head.)-.2 E F1
|
||||
(t)108 206.4 Q F0(Remo)32.67 E .3 -.15(ve a)-.15 H
|
||||
(ll leading \214le name components, lea).15 E(ving the tail.)-.2 E F1(r)
|
||||
108 218.4 Q F0(Remo)31.56 E .3 -.15(ve a t)-.15 H(railing suf).15 E
|
||||
(\214x of the form)-.25 E F2(.xxx)2.5 E F0 2.5(,l)C(ea)-2.5 E
|
||||
(ving the basename.)-.2 E F1(e)108 230.4 Q F0(Remo)31.56 E .3 -.15(ve a)
|
||||
-.15 H(ll b).15 E(ut the trailing suf)-.2 E(\214x.)-.25 E F1(p)108 242.4
|
||||
Q F0(Print the ne)30.44 E 2.5(wc)-.25 G(ommand b)-2.5 E(ut do not e)-.2
|
||||
E -.15(xe)-.15 G(cute it.).15 E F1(q)108 254.4 Q F0
|
||||
(Quote the substituted w)30.44 E(ords, escaping further substitutions.)
|
||||
-.1 E F1(x)108 266.4 Q F0(Quote the substituted w)31 E(ords as with)-.1
|
||||
E F1(q)2.5 E F0 2.5(,b)C(ut break into w)-2.7 E(ords at)-.1 E F1(blanks)
|
||||
2.5 E F0(and ne)2.5 E(wlines.)-.25 E F1(s/)108 278.4 Q F2(old)A F1(/)A
|
||||
F2(ne)A(w)-.15 E F1(/)A F0(Substitute)144 290.4 Q F2(ne)2.814 E(w)-.15 E
|
||||
F0 .314(for the \214rst occurrence of)2.814 F F2(old)2.814 E F0 .314
|
||||
(in the e)2.814 F -.15(ve)-.25 G .314(nt line.).15 F(An)5.314 E 2.814
|
||||
(yd)-.15 G .314(elimiter can be used in place)-2.814 F .616(of /.)144
|
||||
302.4 R .617
|
||||
(The \214nal delimiter is optional if it is the last character of the e)
|
||||
5.616 F -.15(ve)-.25 G .617(nt line.).15 F .617(The delimiter may)5.617
|
||||
F .75(be quoted in)144 314.4 R F2(old)3.25 E F0(and)3.25 E F2(ne)3.25 E
|
||||
(w)-.15 E F0 .75(with a single backslash.)3.25 F .749(If & appears in)
|
||||
5.75 F F2(ne)3.249 E(w)-.15 E F0 3.249(,i).31 G 3.249(ti)-3.249 G 3.249
|
||||
(sr)-3.249 G .749(eplaced by)-3.249 F F2(old)3.249 E F0 5.749(.A).77 G
|
||||
.369(single backslash will quote the &.)144 326.4 R(If)5.369 E F2(old)
|
||||
2.869 E F0 .37(is null, it is set to the last)2.869 F F2(old)2.87 E F0
|
||||
.37(substituted, or)2.87 F 2.87(,i)-.4 G 2.87(fn)-2.87 G 2.87(op)-2.87 G
|
||||
(re)-2.87 E(vi-)-.25 E(ous history substitutions took place, the last)
|
||||
144 338.4 Q F2(string)2.5 E F0(in a)2.5 E F1(!?)2.5 E F2(string)A F1
|
||||
([?])A F0(search.)5 E F1(&)108 350.4 Q F0(Repeat the pre)27.67 E
|
||||
(vious substitution.)-.25 E F1(g)108 362.4 Q F0 .398
|
||||
(Cause changes to be applied o)31 F -.15(ve)-.15 G 2.898(rt).15 G .398
|
||||
(he entire e)-2.898 F -.15(ve)-.25 G .398(nt line.).15 F .397
|
||||
(This is used in conjunction with `)5.398 F F1(:s)A F0 2.897('\()C
|
||||
(e.g.,)-2.897 E(`)144 374.4 Q F1(:gs/)A F2(old)A F1(/)A F2(ne)A(w)-.15 E
|
||||
F1(/)A F0 1.218('\) or `)B F1(:&)A F0 3.718('. If)B 1.218(used with `)
|
||||
3.718 F F1(:s)A F0 1.218(', an)B 3.718(yd)-.15 G 1.219
|
||||
(elimiter can be used in place of /, and the \214nal)-3.718 F
|
||||
(delimiter is optional if it is the last character of the e)144 386.4 Q
|
||||
-.15(ve)-.25 G(nt line.).15 E/F3 10.95/Times-Bold@0 SF(PR)72 403.2 Q
|
||||
(OGRAMMING WITH HIST)-.329 E(OR)-.197 E 2.738(YF)-.383 G(UNCTIONS)-2.738
|
||||
E F0(This section describes ho)108 415.2 Q 2.5(wt)-.25 G 2.5(ou)-2.5 G
|
||||
(se the History library in other programs.)-2.5 E F1(Intr)87 432 Q
|
||||
(oduction to History)-.18 E F0 .797
|
||||
(The programmer using the History library has a)108 444 R -.25(va)-.2 G
|
||||
.796(ilable functions for remembering lines on a history list,).25 F
|
||||
.307(associating arbitrary data with a line, remo)108 456 R .308
|
||||
(ving lines from the list, searching through the list for a line con-)
|
||||
-.15 F .303(taining an arbitrary te)108 468 R .303
|
||||
(xt string, and referencing an)-.15 F 2.803(yl)-.15 G .303
|
||||
(ine in the list directly)-2.803 F 5.303(.I)-.65 G 2.803(na)-5.303 G
|
||||
.303(ddition, a history)-2.803 F F2 -.2(ex)2.802 G(pansion).2 E F0
|
||||
(function is a)108 480 Q -.25(va)-.2 G(ilable which pro).25 E
|
||||
(vides for a consistent user interf)-.15 E(ace across dif)-.1 E
|
||||
(ferent programs.)-.25 E .059(The user using programs written with the \
|
||||
History library has the bene\214t of a consistent user interf)108 496.8
|
||||
R .059(ace with a)-.1 F .918(set of well-kno)108 508.8 R .917
|
||||
(wn commands for manipulating the te)-.25 F .917(xt of pre)-.15 F .917
|
||||
(vious lines and using that te)-.25 F .917(xt in ne)-.15 F 3.417(wc)-.25
|
||||
G(om-)-3.417 E 4.183(mands. The)108 520.8 R 1.684(basic history manipul\
|
||||
ation commands are identical to the history substitution pro)4.183 F
|
||||
1.684(vided by)-.15 F F1(bash)108 532.8 Q F0(.)A .904
|
||||
(If the programmer desires, he can use the Readline library)108 549.6 R
|
||||
3.403(,w)-.65 G .903(hich includes some history manipulation by)-3.403 F
|
||||
(def)108 561.6 Q(ault, and has the added adv)-.1 E
|
||||
(antage of command line editing.)-.25 E .39(Before declaring an)108
|
||||
578.4 R 2.89(yf)-.15 G .39(unctions using an)-2.89 F 2.89(yf)-.15 G .39
|
||||
(unctionality the History library pro)-2.89 F .39
|
||||
(vides in other code, an appli-)-.15 F .067
|
||||
(cation writer should include the \214le)108 590.4 R F2(<r)4.233 E
|
||||
(eadline/history)-.37 E(.h>)-.55 E F0 .067(in an)4.233 F 2.566<798c>-.15
|
||||
G .066(le that uses the History library')-2.566 F 2.566(sf)-.55 G
|
||||
(eatures.)-2.566 E .538(It supplies e)108 602.4 R .538
|
||||
(xtern declarations for all of the library')-.15 F 3.038(sp)-.55 G .538
|
||||
(ublic functions and v)-3.038 F .539(ariables, and declares all of the)
|
||||
-.25 F(public data structures.)108 614.4 Q F1(History Storage)87 643.2 Q
|
||||
F0(The history list is an array of history entries.)108 655.2 Q 2.5(Ah)5
|
||||
G(istory entry is declared as follo)-2.5 E(ws:)-.25 E F2(typedef void *)
|
||||
108 672 Q F1(histdata_t;)2.5 E F0(typedef struct _hist_entry {)108 688.8
|
||||
Q(char *line;)113 700.8 Q(histdata_t data;)113 712.8 Q 2.5(}H)108 724.8
|
||||
S(IST_ENTR)-2.5 E -.92(Y;)-.65 G(GNU History 4.3)72 768 Q
|
||||
(2002 January 31)131.79 E(2)195.95 E EP
|
||||
%%Page: 3 3
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
%%EndPageSetup
|
||||
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
|
||||
(OR)-.18 E(Y\(3\))-.65 E
|
||||
(The history list itself might therefore be declared as)108 84 Q/F1 10
|
||||
/Times-Italic@0 SF(HIST_ENTR)108 100.8 Q 2.5(Y*)-.18 G(*)-2.5 E/F2 10
|
||||
/Times-Bold@0 SF(the_history_list;)2.5 E F0(The state of the History li\
|
||||
brary is encapsulated into a single structure:)108 117.6 Q(/*)108 134.4
|
||||
Q 2.5(*As)110.5 146.4 S
|
||||
(tructure used to pass around the current state of the history)-2.5 E(.)
|
||||
-.65 E(*/)110.5 158.4 Q(typedef struct _hist_state {)108 170.4 Q
|
||||
(HIST_ENTR)113 182.4 Q 2.5(Y*)-.65 G
|
||||
(*entries; /* Pointer to the entries themselv)-2.5 E(es. */)-.15 E
|
||||
(int of)113 194.4 Q 25(fset; /*)-.25 F
|
||||
(The location pointer within this array)2.5 E 2.5(.*)-.65 G(/)-2.5 E
|
||||
(int length;)113 206.4 Q(/* Number of elements within this array)27.5 E
|
||||
2.5(.*)-.65 G(/)-2.5 E(int size;)113 218.4 Q
|
||||
(/* Number of slots allocated to this array)32.5 E 2.5(.*)-.65 G(/)-2.5
|
||||
E(int \215ags;)113 230.4 Q 2.5(}H)108 242.4 S(IST)-2.5 E(OR)-.18 E(Y_ST)
|
||||
-.65 E -1.11(AT)-.93 G(E;)1.11 E(If the \215ags member includes)108
|
||||
259.2 Q F2(HS_STIFLED)2.5 E F0 2.5(,t)C(he history has been sti\215ed.)
|
||||
-2.5 E/F3 10.95/Times-Bold@0 SF(History Functions)72 276 Q F0
|
||||
(This section describes the calling sequence for the v)108 288 Q
|
||||
(arious functions e)-.25 E(xported by the GNU History library)-.15 E(.)
|
||||
-.65 E F2(Initializing History and State Management)87 304.8 Q F0 1.274
|
||||
(This section describes functions used to initialize and manage the sta\
|
||||
te of the History library when you)108 316.8 R -.1(wa)108 328.8 S
|
||||
(nt to use the history functions in your program.).1 E F1(void)108 352.8
|
||||
Q F2(using_history)2.5 E F0(\()4.166 E F1(void)A F0(\))1.666 E(Be)108
|
||||
364.8 Q(gin a session in which the history functions might be used.)-.15
|
||||
E(This initializes the interacti)5 E .3 -.15(ve v)-.25 H(ariables.)-.1 E
|
||||
F1(HIST)108 388.8 Q(OR)-.18 E(Y_ST)-.18 E -.37(AT)-.5 G 2.5(E*).37 G F2
|
||||
(history_get_history_state)A F0(\()4.166 E F1(void)A F0(\))1.666 E
|
||||
(Return a structure describing the current state of the input history)
|
||||
108 400.8 Q(.)-.65 E F1(void)108 424.8 Q F2(history_set_history_state)
|
||||
2.5 E F0(\()4.166 E F1(HIST)A(OR)-.18 E(Y_ST)-.18 E -.37(AT)-.5 G 2.5
|
||||
(E*).37 G(state)-2.5 E F0(\))1.666 E
|
||||
(Set the state of the history list according to)108 436.8 Q F1(state)2.5
|
||||
E F0(.)A F2(History List Management)87 465.6 Q F0
|
||||
(These functions manage indi)108 477.6 Q(vidual entries on the history \
|
||||
list, or set parameters managing the list itself.)-.25 E F1(void)108
|
||||
501.6 Q F2(add_history)2.5 E F0(\()4.166 E F1(const c)A(har *string)-.15
|
||||
E F0(\))1.666 E(Place)108 513.6 Q F1(string)2.5 E F0
|
||||
(at the end of the history list.)2.5 E
|
||||
(The associated data \214eld \(if an)5 E(y\) is set to)-.15 E F2(NULL)
|
||||
2.5 E F0(.)A F1(HIST_ENTR)108 537.6 Q 2.5(Y*)-.18 G F2 -.18(re)C(mo).18
|
||||
E -.1(ve)-.1 G(_history).1 E F0(\()4.166 E F1(int whic)A(h)-.15 E F0(\))
|
||||
1.666 E(Remo)108 549.6 Q .352 -.15(ve h)-.15 H .052(istory entry at of)
|
||||
.15 F(fset)-.25 E F1(whic)2.553 E(h)-.15 E F0 .053(from the history)
|
||||
2.553 F 5.053(.T)-.65 G .053(he remo)-5.053 F -.15(ve)-.15 G 2.553(de)
|
||||
.15 G .053(lement is returned so you can free the)-2.553 F
|
||||
(line, data, and containing structure.)108 561.6 Q F1(HIST_ENTR)108
|
||||
585.6 Q 2.5(Y*)-.18 G F2 -.18(re)C(place_history_entry).18 E F0(\()4.166
|
||||
E F1(int whic)A -.834(h, const)-.15 F -.15(ch)2.5 G(ar *line).15 E 1.666
|
||||
(,h)-.1 G(istdata_t data)-1.666 E F0(\))3.332 E(Mak)108 597.6 Q 2.868
|
||||
(et)-.1 G .368(he history entry at of)-2.868 F(fset)-.25 E F1(whic)2.868
|
||||
E(h)-.15 E F0(ha)2.868 E -.15(ve)-.2 G F1(line)3.018 E F0(and)2.868 E F1
|
||||
(data)2.868 E F0 5.367(.T)C .367
|
||||
(his returns the old entry so you can dispose of)-5.367 F(the data.)108
|
||||
609.6 Q(In the case of an in)5 E -.25(va)-.4 G(lid).25 E F1(whic)2.5 E
|
||||
(h)-.15 E F0 2.5(,a)C F2(NULL)A F0(pointer is returned.)2.5 E F1(void)
|
||||
108 633.6 Q F2(clear_history)2.5 E F0(\()4.166 E F1(void)A F0(\))1.666 E
|
||||
(Clear the history list by deleting all the entries.)108 645.6 Q F1
|
||||
(void)108 669.6 Q F2(sti\215e_history)2.5 E F0(\()4.166 E F1(int max)A
|
||||
F0(\))1.666 E(Sti\215e the history list, remembering only the last)108
|
||||
681.6 Q F1(max)2.5 E F0(entries.)2.5 E F1(int)108 705.6 Q F2
|
||||
(unsti\215e_history)2.5 E F0(\()4.166 E F1(void)A F0(\))1.666 E .46
|
||||
(Stop sti\215ing the history)108 717.6 R 5.46(.T)-.65 G .46
|
||||
(his returns the pre)-5.46 F .46
|
||||
(viously-set maximum number of history entries \(as set by)-.25 F F2
|
||||
(sti-)2.96 E(\215e_history\(\))108 729.6 Q F0 2.5(\). history)B -.1(wa)
|
||||
2.5 G 2.5(ss).1 G 2.5(ti\215ed. The)-2.5 F -.25(va)2.5 G(lue is positi)
|
||||
.25 E .3 -.15(ve i)-.25 H 2.5(ft).15 G(he history w)-2.5 E
|
||||
(as sti\215ed, ne)-.1 E -.05(ga)-.15 G(ti).05 E .3 -.15(ve i)-.25 H 2.5
|
||||
(fi).15 G 2.5(tw)-2.5 G(asn')-2.6 E(t.)-.18 E(GNU History 4.3)72 768 Q
|
||||
(2002 January 31)131.79 E(3)195.95 E EP
|
||||
%%Page: 4 4
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
%%EndPageSetup
|
||||
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
|
||||
(OR)-.18 E(Y\(3\))-.65 E/F1 10/Times-Italic@0 SF(int)108 84 Q/F2 10
|
||||
/Times-Bold@0 SF(history_is_sti\215ed)2.5 E F0(\()4.166 E F1(void)A F0
|
||||
(\))1.666 E
|
||||
(Returns non-zero if the history is sti\215ed, zero if it is not.)108 96
|
||||
Q F2(Inf)87 124.8 Q(ormation About the History List)-.25 E F0(These fun\
|
||||
ctions return information about the entire history list or indi)108
|
||||
136.8 Q(vidual list entries.)-.25 E F1(HIST_ENTR)108 160.8 Q 2.5(Y*)-.18
|
||||
G(*)-2.5 E F2(history_list)2.5 E F0(\()4.166 E F1(void)A F0(\))1.666 E
|
||||
.708(Return a)108 172.8 R F2(NULL)3.208 E F0 .708(terminated array of)
|
||||
3.208 F F1(HIST_ENTR)3.208 E 3.208(Y*)-.18 G F0 .708
|
||||
(which is the current input history)B 5.707(.E)-.65 G .707
|
||||
(lement 0 of this)-5.707 F(list is the be)108 184.8 Q(ginning of time.)
|
||||
-.15 E(If there is no history)5 E 2.5(,r)-.65 G(eturn)-2.5 E F2(NULL)2.5
|
||||
E F0(.)A F1(int)108 208.8 Q F2(wher)2.5 E(e_history)-.18 E F0(\()4.166 E
|
||||
F1(void)A F0(\))1.666 E(Returns the of)108 220.8 Q
|
||||
(fset of the current history element.)-.25 E F1(HIST_ENTR)108 244.8 Q
|
||||
2.5(Y*)-.18 G F2(curr)A(ent_history)-.18 E F0(\()4.166 E F1(void)A F0
|
||||
(\))1.666 E 1.373
|
||||
(Return the history entry at the current position, as determined by)108
|
||||
256.8 R F2(wher)3.873 E(e_history\(\))-.18 E F0 6.373(.I)C 3.873(ft)
|
||||
-6.373 G 1.374(here is no entry)-3.873 F(there, return a)108 268.8 Q F2
|
||||
(NULL)2.5 E F0(pointer)2.5 E(.)-.55 E F1(HIST_ENTR)108 292.8 Q 2.5(Y*)
|
||||
-.18 G F2(history_get)A F0(\()4.166 E F1(int of)A(fset)-.18 E F0(\))
|
||||
1.666 E .288(Return the history entry at position)108 304.8 R F1(of)
|
||||
2.787 E(fset)-.18 E F0 2.787(,s)C .287(tarting from)-2.787 F F2
|
||||
(history_base)2.787 E F0 5.287(.I)C 2.787(ft)-5.287 G .287
|
||||
(here is no entry there, or if)-2.787 F F1(of)2.787 E(fset)-.18 E F0
|
||||
(is greater than the history length, return a)108 316.8 Q F2(NULL)2.5 E
|
||||
F0(pointer)2.5 E(.)-.55 E F1(int)108 340.8 Q F2(history_total_bytes)2.5
|
||||
E F0(\()4.166 E F1(void)A F0(\))1.666 E .391
|
||||
(Return the number of bytes that the primary history entries are using.)
|
||||
108 352.8 R .392(This function returns the sum of the)5.392 F
|
||||
(lengths of all the lines in the history)108 364.8 Q(.)-.65 E F2(Mo)87
|
||||
393.6 Q(ving Ar)-.1 E(ound the History List)-.18 E F0
|
||||
(These functions allo)108 405.6 Q 2.5(wt)-.25 G(he current inde)-2.5 E
|
||||
2.5(xi)-.15 G(nto the history list to be set or changed.)-2.5 E F1(int)
|
||||
108 429.6 Q F2(history_set_pos)2.5 E F0(\()4.166 E F1(int pos)A F0(\))
|
||||
1.666 E .79(Set the current history of)108 441.6 R .79(fset to)-.25 F F1
|
||||
(pos)3.29 E F0 3.29(,a)C 3.29(na)-3.29 G .79(bsolute inde)-3.29 F 3.29
|
||||
(xi)-.15 G .79(nto the list.)-3.29 F .79(Returns 1 on success, 0 if)5.79
|
||||
F F1(pos)3.29 E F0 .79(is less)3.29 F
|
||||
(than zero or greater than the number of history entries.)108 453.6 Q F1
|
||||
(HIST_ENTR)108 477.6 Q 2.5(Y*)-.18 G F2(pr)A -.15(ev)-.18 G
|
||||
(ious_history).15 E F0(\()4.166 E F1(void)A F0(\))1.666 E .207
|
||||
(Back up the current history of)108 489.6 R .207(fset to the pre)-.25 F
|
||||
.207(vious history entry)-.25 F 2.708(,a)-.65 G .208
|
||||
(nd return a pointer to that entry)-2.708 F 5.208(.I)-.65 G 2.708(ft)
|
||||
-5.208 G .208(here is)-2.708 F(no pre)108 501.6 Q(vious entry)-.25 E 2.5
|
||||
(,r)-.65 G(eturn a)-2.5 E F2(NULL)2.5 E F0(pointer)2.5 E(.)-.55 E F1
|
||||
(HIST_ENTR)108 525.6 Q 2.5(Y*)-.18 G F2(next_history)A F0(\()4.166 E F1
|
||||
(void)A F0(\))1.666 E(Mo)108 537.6 Q 1.047 -.15(ve t)-.15 H .747
|
||||
(he current history of).15 F .747(fset forw)-.25 F .746(ard to the ne)
|
||||
-.1 F .746(xt history entry)-.15 F 3.246(,a)-.65 G .746
|
||||
(nd return the a pointer to that entry)-3.246 F 5.746(.I)-.65 G(f)-5.746
|
||||
E(there is no ne)108 549.6 Q(xt entry)-.15 E 2.5(,r)-.65 G(eturn a)-2.5
|
||||
E F2(NULL)2.5 E F0(pointer)2.5 E(.)-.55 E F2(Sear)87 578.4 Q
|
||||
(ching the History List)-.18 E F0 .005(These functions allo)108 590.4 R
|
||||
2.505(ws)-.25 G .006(earching of the history list for entries containin\
|
||||
g a speci\214c string.)-2.505 F .006(Searching may be)5.006 F 1.452
|
||||
(performed both forw)108 602.4 R 1.452(ard and backw)-.1 F 1.451
|
||||
(ard from the current history position.)-.1 F 1.451(The search may be)
|
||||
6.451 F F1(anc)3.951 E(hor)-.15 E(ed)-.37 E F0(,)A
|
||||
(meaning that the string must match at the be)108 614.4 Q
|
||||
(ginning of the history entry)-.15 E(.)-.65 E F1(int)108 638.4 Q F2
|
||||
(history_sear)2.5 E(ch)-.18 E F0(\()4.166 E F1(const c)A(har *string)
|
||||
-.15 E 1.666(,i)-.1 G(nt dir)-1.666 E(ection)-.37 E F0(\))1.666 E .155
|
||||
(Search the history for)108 650.4 R F1(string)2.655 E F0 2.656(,s)C .156
|
||||
(tarting at the current history of)-2.656 F 2.656(fset. If)-.25 F F1
|
||||
(dir)2.656 E(ection)-.37 E F0 .156(is less than 0, then the search)2.656
|
||||
F .802(is through pre)108 662.4 R .802
|
||||
(vious entries, otherwise through subsequent entries.)-.25 F(If)5.801 E
|
||||
F1(string)3.301 E F0 .801(is found, then the current his-)3.301 F .064
|
||||
(tory inde)108 674.4 R 2.564(xi)-.15 G 2.564(ss)-2.564 G .064
|
||||
(et to that history entry)-2.564 F 2.564(,a)-.65 G .064(nd the v)-2.564
|
||||
F .064(alue returned is the of)-.25 F .064
|
||||
(fset in the line of the entry where)-.25 F F1(string)2.565 E F0 -.1(wa)
|
||||
108 686.4 S 2.5(sf).1 G 2.5(ound. Otherwise,)-2.5 F
|
||||
(nothing is changed, and a -1 is returned.)2.5 E F1(int)108 710.4 Q F2
|
||||
(history_sear)2.5 E(ch_pr)-.18 E(e\214x)-.18 E F0(\()4.166 E F1(const c)
|
||||
A(har *string)-.15 E 1.666(,i)-.1 G(nt dir)-1.666 E(ection)-.37 E F0(\))
|
||||
1.666 E .684(Search the history for)108 722.4 R F1(string)3.183 E F0
|
||||
3.183(,s)C .683(tarting at the current history of)-3.183 F 3.183
|
||||
(fset. The)-.25 F .683(search is anchored: matching lines)3.183 F
|
||||
(GNU History 4.3)72 768 Q(2002 January 31)131.79 E(4)195.95 E EP
|
||||
%%Page: 5 5
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
%%EndPageSetup
|
||||
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
|
||||
(OR)-.18 E(Y\(3\))-.65 E 1.063(must be)108 84 R 1.063(gin with)-.15 F/F1
|
||||
10/Times-Italic@0 SF(string)3.563 E F0 6.063(.I)C(f)-6.063 E F1(dir)
|
||||
3.563 E(ection)-.37 E F0 1.064
|
||||
(is less than 0, then the search is through pre)3.563 F 1.064
|
||||
(vious entries, otherwise)-.25 F 1.115(through subsequent entries.)108
|
||||
96 R(If)6.115 E F1(string)3.615 E F0 1.115
|
||||
(is found, then the current history inde)3.615 F 3.614(xi)-.15 G 3.614
|
||||
(ss)-3.614 G 1.114(et to that entry)-3.614 F 3.614(,a)-.65 G 1.114
|
||||
(nd the)-3.614 F(return v)108 108 Q(alue is 0.)-.25 E
|
||||
(Otherwise, nothing is changed, and a -1 is returned.)5 E F1(int)108 132
|
||||
Q/F2 10/Times-Bold@0 SF(history_sear)2.5 E(ch_pos)-.18 E F0(\()4.166 E
|
||||
F1(const c)A(har *string)-.15 E 1.666(,i)-.1 G(nt dir)-1.666 E -.834
|
||||
(ection, int)-.37 F(pos)2.5 E F0(\))3.332 E .603(Search for)108 144 R F1
|
||||
(string)3.103 E F0 .603(in the history list, starting at)3.103 F F1(pos)
|
||||
3.104 E F0 3.104(,a)C 3.104(na)-3.104 G .604(bsolute inde)-3.104 F 3.104
|
||||
(xi)-.15 G .604(nto the list.)-3.104 F(If)5.604 E F1(dir)3.104 E(ection)
|
||||
-.37 E F0 .604(is ne)3.104 F -.05(ga)-.15 G(ti).05 E -.15(ve)-.25 G(,)
|
||||
.15 E .608(the search proceeds backw)108 156 R .608(ard from)-.1 F F1
|
||||
(pos)3.108 E F0 3.108(,o)C .608(therwise forw)-3.108 F 3.108
|
||||
(ard. Returns)-.1 F .608(the absolute inde)3.108 F 3.108(xo)-.15 G 3.108
|
||||
(ft)-3.108 G .608(he history ele-)-3.108 F(ment where)108 168 Q F1
|
||||
(string)2.5 E F0 -.1(wa)2.5 G 2.5(sf).1 G(ound, or -1 otherwise.)-2.5 E
|
||||
F2(Managing the History File)87 196.8 Q F0 .035(The History library can\
|
||||
read the history from and write it to a \214le.)108 208.8 R .036
|
||||
(This section documents the functions for)5.035 F
|
||||
(managing a history \214le.)108 220.8 Q F1(int)108 244.8 Q F2 -.18(re)
|
||||
2.5 G(ad_history).18 E F0(\()4.166 E F1(const c)A(har *\214lename)-.15 E
|
||||
F0(\))1.666 E .151(Add the contents of)108 256.8 R F1(\214lename)2.651 E
|
||||
F0 .151(to the history list, a line at a time.)2.651 F(If)5.15 E F1
|
||||
(\214lename)2.65 E F0(is)2.65 E F2(NULL)2.65 E F0 2.65(,t)C .15
|
||||
(hen read from)-2.65 F F1(~/.his-)2.65 E(tory)108 268.8 Q F0 5(.R)C
|
||||
(eturns 0 if successful, or)-5 E F2(err)2.5 E(no)-.15 E F0(if not.)2.5 E
|
||||
F1(int)108 292.8 Q F2 -.18(re)2.5 G(ad_history_range).18 E F0(\()4.166 E
|
||||
F1(const c)A(har *\214lename)-.15 E 1.666(,i)-.1 G(nt fr)-1.666 E -.834
|
||||
(om, int)-.45 F(to)2.5 E F0(\))3.332 E .052(Read a range of lines from)
|
||||
108 304.8 R F1(\214lename)2.553 E F0 2.553(,a)C .053
|
||||
(dding them to the history list.)-2.553 F .053(Start reading at line)
|
||||
5.053 F F1(fr)2.553 E(om)-.45 E F0 .053(and end at)2.553 F F1(to)2.553 E
|
||||
F0(.)A(If)108 316.8 Q F1(fr)2.889 E(om)-.45 E F0 .389
|
||||
(is zero, start at the be)2.889 F 2.889(ginning. If)-.15 F F1(to)2.889 E
|
||||
F0 .389(is less than)2.889 F F1(fr)2.889 E(om)-.45 E F0 2.889(,t)C .388
|
||||
(hen read until the end of the \214le.)-2.889 F(If)5.388 E F1
|
||||
(\214lename)2.888 E F0(is)108 328.8 Q F2(NULL)2.5 E F0 2.5(,t)C
|
||||
(hen read from)-2.5 E F1(~/.history)2.5 E F0 5(.R)C
|
||||
(eturns 0 if successful, or)-5 E F2(err)2.5 E(no)-.15 E F0(if not.)2.5 E
|
||||
F1(int)108 352.8 Q F2(write_history)2.5 E F0(\()4.166 E F1(const c)A
|
||||
(har *\214lename)-.15 E F0(\))1.666 E .961(Write the current history to)
|
||||
108 364.8 R F1(\214lename)3.461 E F0 3.461(,o)C -.15(ve)-3.611 G
|
||||
(rwriting).15 E F1(\214lename)3.461 E F0 .961(if necessary)3.461 F 5.961
|
||||
(.I)-.65 G(f)-5.961 E F1(\214lename)3.462 E F0(is)3.462 E F2(NULL)3.462
|
||||
E F0 3.462(,t)C .962(hen write)-3.462 F(the history list to)108 376.8 Q
|
||||
F1(~/.history)2.5 E F0 5(.R)C(eturns 0 on success, or)-5 E F2(err)2.5 E
|
||||
(no)-.15 E F0(on a read or write error)2.5 E(.)-.55 E F1(int)108 412.8 Q
|
||||
F2(append_history)2.5 E F0(\()4.166 E F1(int nelements,)A(const c)1.666
|
||||
E(har *\214lename)-.15 E F0(\))1.666 E .839(Append the last)108 424.8 R
|
||||
F1(nelements)3.339 E F0 .839(of the history list to)3.339 F F1
|
||||
(\214lename)3.339 E F0 5.839(.I)C(f)-5.839 E F1(\214lename)3.339 E F0
|
||||
(is)3.339 E F2(NULL)3.339 E F0 3.339(,t)C .838(hen append to)-3.339 F F1
|
||||
(~/.history)3.338 E F0(.)A(Returns 0 on success, or)108 436.8 Q F2(err)
|
||||
2.5 E(no)-.15 E F0(on a read or write error)2.5 E(.)-.55 E F1(int)108
|
||||
460.8 Q F2(history_truncate_\214le)2.5 E F0(\()4.166 E F1(const c)A
|
||||
(har *\214lename)-.15 E 1.666(,i)-.1 G(nt nlines)-1.666 E F0(\))1.666 E
|
||||
-.35(Tr)108 472.8 S .38(uncate the history \214le).35 F F1(\214lename)
|
||||
2.88 E F0 2.88(,l)C(ea)-2.88 E .38(ving only the last)-.2 F F1(nlines)
|
||||
2.881 E F0 2.881(lines. If)2.881 F F1(\214lename)2.881 E F0(is)2.881 E
|
||||
F2(NULL)2.881 E F0 2.881(,t)C(hen)-2.881 E F1(~/.history)2.881 E F0(is)
|
||||
2.881 E 2.5(truncated. Returns)108 484.8 R 2.5(0o)2.5 G 2.5(ns)-2.5 G
|
||||
(uccess, or)-2.5 E F2(err)2.5 E(no)-.15 E F0(on f)2.5 E(ailure.)-.1 E F2
|
||||
(History Expansion)87 513.6 Q F0(These functions implement history e)108
|
||||
525.6 Q(xpansion.)-.15 E F1(int)108 549.6 Q F2(history_expand)2.5 E F0
|
||||
(\()4.166 E F1 -.15(ch)C(ar *string).15 E 1.666(,c)-.1 G(har **output)
|
||||
-1.816 E F0(\))1.666 E(Expand)108 561.6 Q F1(string)2.5 E F0 2.5(,p)C
|
||||
(lacing the result into)-2.5 E F1(output)2.5 E F0 2.5(,ap)C
|
||||
(ointer to a string.)-2.5 E(Returns:)5 E 31(0I)144 573.6 S 3.066(fn)-31
|
||||
G 3.066(oe)-3.066 G .566(xpansions took place \(or)-3.216 F 3.065(,i)-.4
|
||||
G 3.065(ft)-3.065 G .565(he only change in the te)-3.065 F .565(xt w)
|
||||
-.15 F .565(as the remo)-.1 F -.25(va)-.15 G 3.065(lo).25 G 3.065(fe)
|
||||
-3.065 G(scape)-3.065 E(characters preceding the history e)180 585.6 Q
|
||||
(xpansion character\);)-.15 E 31(1i)144 597.6 S 2.5(fe)-31 G
|
||||
(xpansions did tak)-2.65 E 2.5(ep)-.1 G(lace;)-2.5 E 25.17(-1 if)144
|
||||
609.6 R(there w)2.5 E(as an error in e)-.1 E(xpansion;)-.15 E 31(2i)144
|
||||
621.6 S 2.5(ft)-31 G(he returned line should be displayed, b)-2.5 E
|
||||
(ut not e)-.2 E -.15(xe)-.15 G(cuted, as with the).15 E F2(:p)2.5 E F0
|
||||
(modi\214er)2.5 E(.)-.55 E(If an error ocurred in e)108 633.6 Q
|
||||
(xpansion, then)-.15 E F1(output)2.5 E F0(contains a descripti)2.5 E .3
|
||||
-.15(ve e)-.25 H(rror message.).15 E F1 -.15(ch)108 657.6 S(ar *).15 E
|
||||
F2(get_history_e)2.5 E -.1(ve)-.15 G(nt).1 E F0(\()4.166 E F1(const c)A
|
||||
(har *string)-.15 E 1.666(,i)-.1 G(nt *cinde)-1.666 E -.834(x, int)-.2 F
|
||||
(qc)2.5 E(har)-.15 E F0(\))3.332 E .262(Returns the te)108 669.6 R .262
|
||||
(xt of the history e)-.15 F -.15(ve)-.25 G .262(nt be).15 F .263
|
||||
(ginning at)-.15 F F1(string)2.763 E F0(+)2.763 E F1(*cinde)2.763 E(x)
|
||||
-.2 E F0(.)A F1(*cinde)5.263 E(x)-.2 E F0 .263
|
||||
(is modi\214ed to point to after the)2.763 F -2.15 -.25(ev e)108 681.6 T
|
||||
.71(nt speci\214er).25 F 5.71(.A)-.55 G 3.21(tf)-5.71 G .71
|
||||
(unction entry)-3.21 F(,)-.65 E F1(cinde)3.21 E(x)-.2 E F0 .709
|
||||
(points to the inde)3.21 F 3.209(xi)-.15 G(nto)-3.209 E F1(string)3.209
|
||||
E F0 .709(where the history e)3.209 F -.15(ve)-.25 G .709
|
||||
(nt speci\214ca-).15 F .527(tion be)108 693.6 R(gins.)-.15 E F1(qc)5.527
|
||||
E(har)-.15 E F0 .527(is a character that is allo)3.027 F .527
|
||||
(wed to end the e)-.25 F -.15(ve)-.25 G .528
|
||||
(nt speci\214cation in addition to the `).15 F(`normal')-.74 E(')-.74 E
|
||||
(terminating characters.)108 705.6 Q F1 -.15(ch)108 729.6 S(ar **).15 E
|
||||
F2(history_tok)2.5 E(enize)-.1 E F0(\()4.166 E F1(const c)A(har *string)
|
||||
-.15 E F0(\))1.666 E(GNU History 4.3)72 768 Q(2002 January 31)131.79 E
|
||||
(5)195.95 E EP
|
||||
%%Page: 6 6
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
%%EndPageSetup
|
||||
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
|
||||
(OR)-.18 E(Y\(3\))-.65 E .239(Return an array of tok)108 84 R .239
|
||||
(ens parsed out of)-.1 F/F1 10/Times-Italic@0 SF(string)2.739 E F0 2.739
|
||||
(,m)C .238(uch as the shell might.)-2.739 F .238(The tok)5.238 F .238
|
||||
(ens are split on the charac-)-.1 F(ters in the)108 96 Q/F2 10
|
||||
/Times-Bold@0 SF(history_w)2.5 E(ord_delimiters)-.1 E F0 -.25(va)2.5 G
|
||||
(riable, and shell quoting con).25 E -.15(ve)-.4 G(ntions are obe).15 E
|
||||
(yed.)-.15 E F1 -.15(ch)108 120 S(ar *).15 E F2(history_ar)2.5 E
|
||||
(g_extract)-.1 E F0(\()4.166 E F1(int \214r)A -.834(st, int)-.1 F -.834
|
||||
(last, const)2.5 F -.15(ch)2.5 G(ar *string).15 E F0(\))3.332 E .025
|
||||
(Extract a string se)108 132 R .025(gment consisting of the)-.15 F F1
|
||||
<8c72>2.526 E(st)-.1 E F0(through)2.526 E F1(last)2.526 E F0(ar)2.526 E
|
||||
.026(guments present in)-.18 F F1(string)2.526 E F0 5.026(.A)C -.18(rg)
|
||||
-5.026 G .026(uments are split).18 F(using)108 144 Q F2(history_tok)2.5
|
||||
E(enize\(\))-.1 E F0(.)A F2(History V)87 172.8 Q(ariables)-.92 E F0
|
||||
(This section describes the e)108 184.8 Q(xternally-visible v)-.15 E
|
||||
(ariables e)-.25 E(xported by the GNU History Library)-.15 E(.)-.65 E F1
|
||||
(int)108 208.8 Q F2(history_base)2.5 E F0(The logical of)108 220.8 Q
|
||||
(fset of the \214rst entry in the history list.)-.25 E F1(int)108 244.8
|
||||
Q F2(history_length)2.5 E F0
|
||||
(The number of entries currently stored in the history list.)108 256.8 Q
|
||||
F1(int)108 280.8 Q F2(history_max_entries)2.5 E F0
|
||||
(The maximum number of history entries.)108 292.8 Q
|
||||
(This must be changed using)5 E F2(sti\215e_history\(\))2.5 E F0(.)A F1
|
||||
-.15(ch)108 316.8 S(ar).15 E F2(history_expansion_char)2.5 E F0
|
||||
(The character that introduces a history e)108 328.8 Q -.15(ve)-.25 G
|
||||
2.5(nt. The).15 F(def)2.5 E(ault is)-.1 E F2(!)2.5 E F0 5(.S)C
|
||||
(etting this to 0 inhibits history e)-5 E(xpansion.)-.15 E F1 -.15(ch)
|
||||
108 352.8 S(ar).15 E F2(history_subst_char)2.5 E F0
|
||||
(The character that in)108 364.8 Q -.2(vo)-.4 G -.1(ke).2 G 2.5(sw).1 G
|
||||
(ord substitution if found at the start of a line.)-2.6 E(The def)5 E
|
||||
(ault is)-.1 E F2(^)2.5 E F0(.)A F1 -.15(ch)108 388.8 S(ar).15 E F2
|
||||
(history_comment_char)2.5 E F0 .117(During tok)108 400.8 R .117
|
||||
(enization, if this character is seen as the \214rst character of a w)
|
||||
-.1 F .117(ord, then it and all subsequent char)-.1 F(-)-.2 E .276
|
||||
(acters up to a ne)108 412.8 R .276
|
||||
(wline are ignored, suppressing history e)-.25 F .276
|
||||
(xpansion for the remainder of the line.)-.15 F .277(This is dis-)5.276
|
||||
F(abled by def)108 424.8 Q(ault.)-.1 E F1 -.15(ch)108 448.8 S(ar *).15 E
|
||||
F2(history_w)2.5 E(ord_delimiters)-.1 E F0
|
||||
(The characters that separate tok)108 460.8 Q(ens for)-.1 E F2
|
||||
(history_tok)2.5 E(enize\(\))-.1 E F0 5(.T)C(he def)-5 E(ault v)-.1 E
|
||||
(alue is)-.25 E F2 2.5("\\)2.5 G(t\\n\(\)<>;&|")-2.5 E F0(.)A F1 -.15
|
||||
(ch)108 484.8 S(ar *).15 E F2(history_no_expand_chars)2.5 E F0 2.054
|
||||
(The list of characters which inhibit history e)108 496.8 R 2.054
|
||||
(xpansion if found immediately follo)-.15 F(wing)-.25 E F2
|
||||
(history_expan-)4.554 E(sion_char)108 508.8 Q F0 5(.T)C(he def)-5 E
|
||||
(ault is space, tab, ne)-.1 E(wline,)-.25 E F2(\\r)2.5 E F0 2.5(,a)C(nd)
|
||||
-2.5 E F2(=)2.5 E F0(.)A F1 -.15(ch)108 532.8 S(ar *).15 E F2
|
||||
(history_sear)2.5 E(ch_delimiter_chars)-.18 E F0 .401(The list of addit\
|
||||
ional characters which can delimit a history search string, in addition\
|
||||
to space, tab,)108 544.8 R F1(:)2.901 E F0(and)2.901 E F1(?)2.902 E F0
|
||||
(in the case of a substring search.)108 556.8 Q(The def)5 E
|
||||
(ault is empty)-.1 E(.)-.65 E F1(int)108 580.8 Q F2
|
||||
(history_quotes_inhibit_expansion)2.5 E F0 .625
|
||||
(If non-zero, single-quoted w)108 592.8 R .625
|
||||
(ords are not scanned for the history e)-.1 F .624(xpansion character)
|
||||
-.15 F 5.624(.T)-.55 G .624(he def)-5.624 F .624(ault v)-.1 F .624
|
||||
(alue is)-.25 F(0.)108 604.8 Q F1(rl_lineb)108 628.8 Q(uf_func_t *)-.2 E
|
||||
F2(history_inhibit_expansion_function)2.5 E F0 .347
|
||||
(This should be set to the address of a function that tak)108 640.8 R
|
||||
.348(es tw)-.1 F 2.848(oa)-.1 G -.18(rg)-2.848 G .348(uments: a).18 F F2
|
||||
.348(char *)2.848 F F0(\()2.848 E F1(string)A F0 2.848(\)a)C .348(nd an)
|
||||
-2.848 F F2(int)2.848 E F0(inde)2.848 E(x)-.15 E .228
|
||||
(into that string \()108 652.8 R F1(i)A F0 2.728(\). It)B .227
|
||||
(should return a non-zero v)2.727 F .227(alue if the history e)-.25 F
|
||||
.227(xpansion starting at)-.15 F F1(string[i])2.727 E F0 .227
|
||||
(should not)2.727 F .019(be performed; zero if the e)108 664.8 R .019
|
||||
(xpansion should be done.)-.15 F .019
|
||||
(It is intended for use by applications lik)5.019 F(e)-.1 E F2(bash)
|
||||
2.519 E F0 .019(that use)2.519 F(the history e)108 676.8 Q
|
||||
(xpansion character for additional purposes.)-.15 E(By def)5 E
|
||||
(ault, this v)-.1 E(ariable is set to)-.25 E F2(NULL)2.5 E F0(.)A/F3
|
||||
10.95/Times-Bold@0 SF(FILES)72 693.6 Q F1(~/.history)109.666 705.6 Q F0
|
||||
(Def)144 717.6 Q(ault \214lename for reading and writing sa)-.1 E -.15
|
||||
(ve)-.2 G 2.5(dh).15 G(istory)-2.5 E(GNU History 4.3)72 768 Q
|
||||
(2002 January 31)131.79 E(6)195.95 E EP
|
||||
%%Page: 7 7
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
%%EndPageSetup
|
||||
/F0 10/Times-Roman@0 SF(HIST)72 48 Q(OR)-.18 E 357.18(Y\(3\) HIST)-.65 F
|
||||
(OR)-.18 E(Y\(3\))-.65 E/F1 10.95/Times-Bold@0 SF(SEE ALSO)72 84 Q/F2 10
|
||||
/Times-Italic@0 SF(The Gnu Readline Libr)108 96 Q(ary)-.15 E F0 2.5(,B)C
|
||||
(rian F)-2.5 E(ox and Chet Rame)-.15 E(y)-.15 E F2(The Gnu History Libr)
|
||||
108 108 Q(ary)-.15 E F0 2.5(,B)C(rian F)-2.5 E(ox and Chet Rame)-.15 E
|
||||
(y)-.15 E F2(bash)108 120 Q F0(\(1\))A F2 -.37(re)108 132 S(adline).37 E
|
||||
F0(\(3\))A F1 -.548(AU)72 148.8 S(THORS).548 E F0(Brian F)108 160.8 Q
|
||||
(ox, Free Softw)-.15 E(are F)-.1 E(oundation)-.15 E(bfox@gnu.or)108
|
||||
172.8 Q(g)-.18 E(Chet Rame)108 189.6 Q 1.3 -.65(y, C)-.15 H(ase W).65 E
|
||||
(estern Reserv)-.8 E 2.5(eU)-.15 G(ni)-2.5 E -.15(ve)-.25 G(rsity).15 E
|
||||
(chet@ins.CWR)108 201.6 Q(U.Edu)-.4 E F1 -.11(BU)72 218.4 S 2.738(GR).11
|
||||
G(EPOR)-2.738 E(TS)-.438 E F0 .16(If you \214nd a b)108 230.4 R .16
|
||||
(ug in the)-.2 F/F3 10/Times-Bold@0 SF(history)2.66 E F0(library)2.66 E
|
||||
2.66(,y)-.65 G .16(ou should report it.)-2.66 F .16
|
||||
(But \214rst, you should mak)5.16 F 2.66(es)-.1 G .16
|
||||
(ure that it really is)-2.66 F 2.5(ab)108 242.4 S
|
||||
(ug, and that it appears in the latest v)-2.7 E(ersion of the)-.15 E F3
|
||||
(history)2.5 E F0(library that you ha)2.5 E -.15(ve)-.2 G(.).15 E .704
|
||||
(Once you ha)108 259.2 R 1.004 -.15(ve d)-.2 H .704(etermined that a b)
|
||||
.15 F .704(ug actually e)-.2 F .704(xists, mail a b)-.15 F .705
|
||||
(ug report to)-.2 F F2 -.2(bu)3.205 G(g\255r).2 E(eadline)-.37 E F0(@)A
|
||||
F2(gnu.or)A(g)-.37 E F0 5.705(.I)C 3.205(fy)-5.705 G(ou)-3.205 E(ha)108
|
||||
271.2 Q 1.81 -.15(ve a \214)-.2 H 1.51
|
||||
(x, you are welcome to mail that as well!).15 F 1.509
|
||||
(Suggestions and `philosophical' b)6.509 F 1.509(ug reports may be)-.2 F
|
||||
(mailed to)108 283.2 Q F2 -.2(bu)2.5 G(g-r).2 E(eadline)-.37 E F0(@)A F2
|
||||
(gnu.or)A(g)-.37 E F0(or posted to the Usenet ne)2.5 E(wsgroup)-.25 E F3
|
||||
(gnu.bash.b)2.5 E(ug)-.2 E F0(.)A(Comments and b)108 300 Q
|
||||
(ug reports concerning this manual page should be directed to)-.2 E F2
|
||||
-.15(ch)2.5 G(et@ins.CWR).15 E -.25(U.)-.4 G(Edu).25 E F0(.).25 E
|
||||
(GNU History 4.3)72 768 Q(2002 January 31)131.79 E(7)195.95 E EP
|
||||
%%Trailer
|
||||
end
|
||||
%%EOF
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
1294
readline/doc/readline_3.ps
Normal file
1294
readline/doc/readline_3.ps
Normal file
File diff suppressed because it is too large
Load diff
|
@ -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
Binary file not shown.
File diff suppressed because it is too large
Load diff
|
@ -1,17 +1,16 @@
|
|||
This is Info file rluserman.info, produced by Makeinfo version 1.68
|
||||
from the input file
|
||||
This is rluserman.info, produced by makeinfo version 4.1 from
|
||||
/usr/homes/chet/src/bash/readline-src/doc/rluserman.texinfo.
|
||||
|
||||
INFO-DIR-SECTION Libraries
|
||||
START-INFO-DIR-ENTRY
|
||||
* Readline: (readline). The GNU readline library API
|
||||
* RLuserman: (rluserman). The GNU readline library User's Manual.
|
||||
END-INFO-DIR-ENTRY
|
||||
|
||||
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 pare
|
||||
|
@ -69,10 +68,10 @@ Introduction to Line Editing
|
|||
The following paragraphs describe the notation used to represent
|
||||
keystrokes.
|
||||
|
||||
The text <C-k> is read as `Control-K' and describes the character
|
||||
The text `C-k' is read as `Control-K' and describes the character
|
||||
produced when the <k> key is pressed while the Control key is depressed.
|
||||
|
||||
The text <M-k> is read as `Meta-K' and describes the character
|
||||
The text `M-k' is read as `Meta-K' and describes the character
|
||||
produced when the Meta key (if you have one) is depressed, and the <k>
|
||||
key is pressed. The Meta key is labeled <ALT> on many keyboards. On
|
||||
keyboards with two keys labeled <ALT> (usually to either side of the
|
||||
|
@ -83,18 +82,18 @@ Compose key for typing accented characters.
|
|||
|
||||
If you do not have a Meta or <ALT> key, or another key working as a
|
||||
Meta key, the identical keystroke can be generated by typing <ESC>
|
||||
first, and then typing <k>. Either process is known as "metafying" the
|
||||
<k> key.
|
||||
_first_, and then typing <k>. Either process is known as "metafying"
|
||||
the <k> key.
|
||||
|
||||
The text <M-C-k> is read as `Meta-Control-k' and describes the
|
||||
character produced by "metafying" <C-k>.
|
||||
The text `M-C-k' is read as `Meta-Control-k' and describes the
|
||||
character produced by "metafying" `C-k'.
|
||||
|
||||
In addition, several keys have their own names. Specifically,
|
||||
<DEL>, <ESC>, <LFD>, <SPC>, <RET>, and <TAB> all stand for themselves
|
||||
when seen in this text, or in an init file (*note Readline Init
|
||||
File::.). If your keyboard lacks a <LFD> key, typing <C-j> will
|
||||
produce the desired character. The <RET> key may be labeled <Return>
|
||||
or <Enter> on some keyboards.
|
||||
when seen in this text, or in an init file (*note Readline Init File::).
|
||||
If your keyboard lacks a <LFD> key, typing <C-j> will produce the
|
||||
desired character. The <RET> key may be labeled <Return> or <Enter> on
|
||||
some keyboards.
|
||||
|
||||
|
||||
File: rluserman.info, Node: Readline Interaction, Next: Readline Init File, Prev: Introduction and Notation, Up: Command Line Editing
|
||||
|
@ -109,9 +108,9 @@ as you type it in, allowing you to just fix your typo, and not forcing
|
|||
you to retype the majority of the line. Using these editing commands,
|
||||
you move the cursor to the place that needs correction, and delete or
|
||||
insert the text of the corrections. Then, when you are satisfied with
|
||||
the line, you simply press <RETURN>. You do not have to be at the end
|
||||
of the line to press <RETURN>; the entire line is accepted regardless
|
||||
of the location of the cursor within the line.
|
||||
the line, you simply press <RET>. You do not have to be at the end of
|
||||
the line to press <RET>; the entire line is accepted regardless of the
|
||||
location of the cursor within the line.
|
||||
|
||||
* Menu:
|
||||
|
||||
|
@ -134,8 +133,8 @@ erase character to back up and delete the mistyped character.
|
|||
|
||||
Sometimes you may mistype a character, and not notice the error
|
||||
until you have typed several other characters. In that case, you can
|
||||
type <C-b> to move the cursor to the left, and then correct your
|
||||
mistake. Afterwards, you can move the cursor to the right with <C-f>.
|
||||
type `C-b' to move the cursor to the left, and then correct your
|
||||
mistake. Afterwards, you can move the cursor to the right with `C-f'.
|
||||
|
||||
When you add text in the middle of a line, you will notice that
|
||||
characters to the right of the cursor are `pushed over' to make room
|
||||
|
@ -145,28 +144,28 @@ back' to fill in the blank space created by the removal of the text. A
|
|||
list of the bare essentials for editing the text of an input line
|
||||
follows.
|
||||
|
||||
<C-b>
|
||||
`C-b'
|
||||
Move back one character.
|
||||
|
||||
<C-f>
|
||||
`C-f'
|
||||
Move forward one character.
|
||||
|
||||
<DEL> or <Backspace>
|
||||
Delete the character to the left of the cursor.
|
||||
|
||||
<C-d>
|
||||
`C-d'
|
||||
Delete the character underneath the cursor.
|
||||
|
||||
Printing characters
|
||||
Insert the character into the line at the cursor.
|
||||
|
||||
<C-_> or <C-x C-u>
|
||||
`C-_' or `C-x C-u'
|
||||
Undo the last editing command. You can undo all the way back to an
|
||||
empty line.
|
||||
|
||||
(Depending on your configuration, the <Backspace> key be set to delete
|
||||
the character to the left of the cursor and the <DEL> key set to delete
|
||||
the character underneath the cursor, like <C-d>, rather than the
|
||||
the character underneath the cursor, like `C-d', rather than the
|
||||
character to the left of the cursor.)
|
||||
|
||||
|
||||
|
@ -177,26 +176,26 @@ Readline Movement Commands
|
|||
|
||||
The above table describes the most basic keystrokes that you need in
|
||||
order to do editing of the input line. For your convenience, many
|
||||
other commands have been added in addition to <C-b>, <C-f>, <C-d>, and
|
||||
other commands have been added in addition to `C-b', `C-f', `C-d', and
|
||||
<DEL>. Here are some commands for moving more rapidly about the line.
|
||||
|
||||
<C-a>
|
||||
`C-a'
|
||||
Move to the start of the line.
|
||||
|
||||
<C-e>
|
||||
`C-e'
|
||||
Move to the end of the line.
|
||||
|
||||
<M-f>
|
||||
`M-f'
|
||||
Move forward a word, where a word is composed of letters and
|
||||
digits.
|
||||
|
||||
<M-b>
|
||||
`M-b'
|
||||
Move backward a word.
|
||||
|
||||
<C-l>
|
||||
`C-l'
|
||||
Clear the screen, reprinting the current line at the top.
|
||||
|
||||
Notice how <C-f> moves forward a character, while <M-f> moves
|
||||
Notice how `C-f' moves forward a character, while `M-f' moves
|
||||
forward a word. It is a loose convention that control keystrokes
|
||||
operate on characters while meta keystrokes operate on words.
|
||||
|
||||
|
@ -223,34 +222,34 @@ available to be yanked back later, when you are typing another line.
|
|||
|
||||
Here is the list of commands for killing text.
|
||||
|
||||
<C-k>
|
||||
`C-k'
|
||||
Kill the text from the current cursor position to the end of the
|
||||
line.
|
||||
|
||||
<M-d>
|
||||
`M-d'
|
||||
Kill from the cursor to the end of the current word, or, if between
|
||||
words, to the end of the next word. Word boundaries are the same
|
||||
as those used by <M-f>.
|
||||
as those used by `M-f'.
|
||||
|
||||
<M-DEL>
|
||||
Kill from the cursor the start of the previous word, or, if between
|
||||
`M-<DEL>'
|
||||
Kill from the cursor the start of the current word, or, if between
|
||||
words, to the start of the previous word. Word boundaries are the
|
||||
same as those used by <M-b>.
|
||||
same as those used by `M-b'.
|
||||
|
||||
<C-w>
|
||||
`C-w'
|
||||
Kill from the cursor to the previous whitespace. This is
|
||||
different than <M-DEL> because the word boundaries differ.
|
||||
different than `M-<DEL>' because the word boundaries differ.
|
||||
|
||||
Here is how to "yank" the text back into the line. Yanking means to
|
||||
copy the most-recently-killed text from the kill buffer.
|
||||
|
||||
<C-y>
|
||||
`C-y'
|
||||
Yank the most recently killed text back into the buffer at the
|
||||
cursor.
|
||||
|
||||
<M-y>
|
||||
`M-y'
|
||||
Rotate the kill-ring, and yank the new top. You can only do this
|
||||
if the prior command is <C-y> or <M-y>.
|
||||
if the prior command is `C-y' or `M-y'.
|
||||
|
||||
|
||||
File: rluserman.info, Node: Readline Arguments, Next: Searching, Prev: Readline Killing Commands, Up: Readline Interaction
|
||||
|
@ -270,7 +269,8 @@ meta digits before the command. If the first `digit' typed is a minus
|
|||
sign (`-'), then the sign of the argument will be negative. Once you
|
||||
have typed one meta digit to get the argument started, you can type the
|
||||
remainder of the digits, and then the command. For example, to give
|
||||
the <C-d> command an argument of 10, you could type `M-1 0 C-d'.
|
||||
the `C-d' command an argument of 10, you could type `M-1 0 C-d', which
|
||||
will delete the next ten characters on the input line.
|
||||
|
||||
|
||||
File: rluserman.info, Node: Searching, Prev: Readline Arguments, Up: Readline Interaction
|
||||
|
@ -280,29 +280,34 @@ Searching for Commands in the History
|
|||
|
||||
Readline provides commands for searching through the command history
|
||||
for lines containing a specified string. There are two search modes:
|
||||
INCREMENTAL and NON-INCREMENTAL.
|
||||
"incremental" and "non-incremental".
|
||||
|
||||
Incremental searches begin before the user has finished typing the
|
||||
search string. 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. To search backward in the
|
||||
history for a particular string, type <C-r>. Typing <C-s> searches
|
||||
history for a particular string, type `C-r'. Typing `C-s' searches
|
||||
forward through the history. The characters present in the value of
|
||||
the `isearch-terminators' variable are used to terminate an incremental
|
||||
search. If that variable has not been assigned a value, the <ESC> and
|
||||
<C-J> characters will terminate an incremental search. <C-g> will
|
||||
`C-J' characters will terminate an incremental search. `C-g' will
|
||||
abort an incremental search and restore the original line. When the
|
||||
search is terminated, the history entry containing the search string
|
||||
becomes the current line.
|
||||
|
||||
To find other matching entries in the history list, type <C-r> or
|
||||
<C-s> as appropriate. This will search backward or forward in the
|
||||
To find other matching entries in the history list, type `C-r' or
|
||||
`C-s' as appropriate. This will search backward or forward in the
|
||||
history for the next entry matching the search string typed so far.
|
||||
Any other key sequence bound to a Readline command will terminate the
|
||||
search and execute that command. For instance, a <RET> will terminate
|
||||
the search and accept the line, thereby executing the command from the
|
||||
history list.
|
||||
history list. A movement command will terminate the search, make the
|
||||
last line found the current line, and begin editing.
|
||||
|
||||
Readline remembers the last incremental search string. If two
|
||||
`C-r's are typed without any intervening characters defining a new
|
||||
search string, any remembered search string is used.
|
||||
|
||||
Non-incremental searches read the entire search string before
|
||||
starting to search for matching history lines. The search string may be
|
||||
|
@ -345,17 +350,24 @@ Readline Init File Syntax
|
|||
There are only a few basic constructs allowed in the Readline init
|
||||
file. Blank lines are ignored. Lines beginning with a `#' are
|
||||
comments. Lines beginning with a `$' indicate conditional constructs
|
||||
(*note Conditional Init Constructs::.). Other lines denote variable
|
||||
(*note Conditional Init Constructs::). Other lines denote variable
|
||||
settings and key bindings.
|
||||
|
||||
Variable Settings
|
||||
You can modify the run-time behavior of Readline by altering the
|
||||
values of variables in Readline using the `set' command within the
|
||||
init file. Here is how to change from the default Emacs-like key
|
||||
binding to use `vi' line editing commands:
|
||||
init file. The syntax is simple:
|
||||
|
||||
set VARIABLE VALUE
|
||||
|
||||
Here, for example, is how to change from the default Emacs-like
|
||||
key binding to use `vi' line editing commands:
|
||||
|
||||
set editing-mode vi
|
||||
|
||||
Variable names and values, where appropriate, are recognized
|
||||
without regard to case.
|
||||
|
||||
A great deal of run-time behavior is changeable with the following
|
||||
variables.
|
||||
|
||||
|
@ -382,7 +394,8 @@ Variable Settings
|
|||
possibilities. If the number of possible completions is
|
||||
greater than this value, Readline will ask the user whether
|
||||
or not he wishes to view them; otherwise, they are simply
|
||||
listed. The default limit is `100'.
|
||||
listed. This variable must be set to an integer value
|
||||
greater than or equal to 0. The default limit is `100'.
|
||||
|
||||
`convert-meta'
|
||||
If set to `on', Readline will convert characters with the
|
||||
|
@ -410,6 +423,10 @@ Variable Settings
|
|||
If set to `on', tilde expansion is performed when Readline
|
||||
attempts word completion. The default is `off'.
|
||||
|
||||
If set to `on', the history code attempts to place point at
|
||||
the same location on each history line retrived with
|
||||
`previous-history' or `next-history'.
|
||||
|
||||
`horizontal-scroll-mode'
|
||||
This variable can be set to either `on' or `off'. Setting it
|
||||
to `on' means that the text of the lines being edited will
|
||||
|
@ -419,7 +436,7 @@ Variable Settings
|
|||
|
||||
`input-meta'
|
||||
If set to `on', Readline will enable eight-bit input (it will
|
||||
not strip the eighth bit from the characters it reads),
|
||||
not clear the eighth bit in the characters it reads),
|
||||
regardless of what the terminal claims it can support. The
|
||||
default value is `off'. The name `meta-flag' is a synonym
|
||||
for this variable.
|
||||
|
@ -427,14 +444,14 @@ Variable Settings
|
|||
`isearch-terminators'
|
||||
The string of characters that should terminate an incremental
|
||||
search without subsequently executing the character as a
|
||||
command (*note Searching::.). If this variable has not been
|
||||
given a value, the characters <ESC> and <C-J> will terminate
|
||||
command (*note Searching::). If this variable has not been
|
||||
given a value, the characters <ESC> and `C-J' will terminate
|
||||
an incremental search.
|
||||
|
||||
`keymap'
|
||||
Sets Readline's idea of the current keymap for key binding
|
||||
commands. Acceptable `keymap' names are `emacs',
|
||||
`emacs-standard', `emacs-meta', `emacs-ctlx', `vi',
|
||||
`emacs-standard', `emacs-meta', `emacs-ctlx', `vi', `vi-move',
|
||||
`vi-command', and `vi-insert'. `vi' is equivalent to
|
||||
`vi-command'; `emacs' is equivalent to `emacs-standard'. The
|
||||
default value is `emacs'. The value of the `editing-mode'
|
||||
|
@ -449,11 +466,28 @@ Variable Settings
|
|||
asterisk (`*') at the start of history lines which have been
|
||||
modified. This variable is `off' by default.
|
||||
|
||||
`mark-symlinked-directories'
|
||||
If set to `on', completed names which are symbolic links to
|
||||
directories have a slash appended (subject to the value of
|
||||
`mark-directories'). The default is `off'.
|
||||
|
||||
`match-hidden-files'
|
||||
This variable, when set to `on', 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. This
|
||||
variable is `on' by default.
|
||||
|
||||
`output-meta'
|
||||
If set to `on', Readline will display characters with the
|
||||
eighth bit set directly rather than as a meta-prefixed escape
|
||||
sequence. The default is `off'.
|
||||
|
||||
`page-completions'
|
||||
If set to `on', Readline uses an internal `more'-like pager
|
||||
to display a screenful of possible completions at a time.
|
||||
This variable is `on' by default.
|
||||
|
||||
`print-completions-horizontally'
|
||||
If set to `on', Readline will display completions with matches
|
||||
sorted horizontally in alphabetical order, rather than down
|
||||
|
@ -477,11 +511,14 @@ Key Bindings
|
|||
command name, the default keybinding, if any, and a short
|
||||
description of what the command does.
|
||||
|
||||
Once you know the name of the command, simply place the name of
|
||||
the key you wish to bind the command to, a colon, and then the
|
||||
name of the command on a line in the init file. The name of the
|
||||
key can be expressed in different ways, depending on which is most
|
||||
comfortable for you.
|
||||
Once you know the name of the command, simply place on a line in
|
||||
the init file the name of the key you wish to bind the command to,
|
||||
a colon, and then the name of the command. The name of the key
|
||||
can be expressed in different ways, depending on what you find most
|
||||
comfortable.
|
||||
|
||||
In addition to command names, readline allows keys to be bound to
|
||||
a string that is inserted when the key is pressed (a MACRO).
|
||||
|
||||
KEYNAME: FUNCTION-NAME or MACRO
|
||||
KEYNAME is the name of a key spelled out in English. For
|
||||
|
@ -490,11 +527,16 @@ Key Bindings
|
|||
Meta-Rubout: backward-kill-word
|
||||
Control-o: "> output"
|
||||
|
||||
In the above example, <C-u> is bound to the function
|
||||
`universal-argument', and <C-o> is bound to run the macro
|
||||
In the above example, `C-u' is bound to the function
|
||||
`universal-argument', `M-DEL' is bound to the function
|
||||
`backward-kill-word', and `C-o' is bound to run the macro
|
||||
expressed on the right hand side (that is, to insert the text
|
||||
`> output' into the line).
|
||||
|
||||
A number of symbolic character names are recognized while
|
||||
processing this key binding syntax: DEL, ESC, ESCAPE, LFD,
|
||||
NEWLINE, RET, RETURN, RUBOUT, SPACE, SPC, and TAB.
|
||||
|
||||
"KEYSEQ": FUNCTION-NAME or MACRO
|
||||
KEYSEQ differs from KEYNAME above in that strings denoting an
|
||||
entire key sequence can be specified, by placing the key
|
||||
|
@ -506,11 +548,11 @@ Key Bindings
|
|||
"\C-x\C-r": re-read-init-file
|
||||
"\e[11~": "Function Key 1"
|
||||
|
||||
In the above example, <C-u> is bound to the function
|
||||
In the above example, `C-u' is again bound to the function
|
||||
`universal-argument' (just as it was in the first example),
|
||||
`<C-x> <C-r>' is bound to the function `re-read-init-file',
|
||||
and `<ESC> <[> <1> <1> <~>' is bound to insert the text
|
||||
`Function Key 1'.
|
||||
`C-x C-r' is bound to the function `re-read-init-file', and
|
||||
`<ESC> <[> <1> <1> <~>' is bound to insert the text `Function
|
||||
Key 1'.
|
||||
|
||||
The following GNU Emacs style escape sequences are available when
|
||||
specifying key sequences:
|
||||
|
@ -561,13 +603,13 @@ Key Bindings
|
|||
vertical tab
|
||||
|
||||
`\NNN'
|
||||
the character whose `ASCII' code is the octal value NNN (one
|
||||
to three digits)
|
||||
|
||||
`\xNNN'
|
||||
the character whose `ASCII' code is the hexadecimal value NNN
|
||||
the eight-bit character whose value is the octal value NNN
|
||||
(one to three digits)
|
||||
|
||||
`\xHH'
|
||||
the eight-bit character whose value is the hexadecimal value
|
||||
HH (one or two hex digits)
|
||||
|
||||
When entering the text of a macro, single or double quotes must be
|
||||
used to indicate a macro definition. Unquoted text is assumed to
|
||||
be a function name. In the macro body, the backslash escapes
|
||||
|
@ -614,10 +656,10 @@ are four parser directives used.
|
|||
The APPLICATION construct is used to include
|
||||
application-specific settings. Each program using the
|
||||
Readline library sets the APPLICATION NAME, and you can test
|
||||
for it. This could be used to bind key sequences to
|
||||
functions useful for a specific program. For instance, the
|
||||
following command adds a key sequence that quotes the current
|
||||
or previous word in Bash:
|
||||
for a particular value. This could be used to bind key
|
||||
sequences to functions useful for a specific program. For
|
||||
instance, the following command adds a key sequence that
|
||||
quotes the current or previous word in Bash:
|
||||
$if Bash
|
||||
# Quote the current or previous word
|
||||
"\C-xq": "\eb\"\ef\""
|
||||
|
@ -633,7 +675,8 @@ are four parser directives used.
|
|||
|
||||
`$include'
|
||||
This directive takes a single filename as an argument and reads
|
||||
commands and bindings from that file.
|
||||
commands and bindings from that file. For example, the following
|
||||
directive reads from `/etc/inputrc':
|
||||
$include /etc/inputrc
|
||||
|
||||
|
||||
|
@ -642,19 +685,19 @@ File: rluserman.info, Node: Sample Init File, Prev: Conditional Init Construct
|
|||
Sample Init File
|
||||
----------------
|
||||
|
||||
Here is an example of an inputrc file. This illustrates key
|
||||
Here is an example of an INPUTRC file. This illustrates key
|
||||
binding, variable assignment, and conditional syntax.
|
||||
|
||||
|
||||
# This file controls the behaviour of line input editing for
|
||||
# programs that use the Gnu Readline library. Existing programs
|
||||
# include FTP, Bash, and Gdb.
|
||||
# programs that use the GNU Readline library. Existing
|
||||
# programs include FTP, Bash, and GDB.
|
||||
#
|
||||
# You can re-read the inputrc file with C-x C-r.
|
||||
# Lines beginning with '#' are comments.
|
||||
#
|
||||
# First, include any systemwide bindings and variable assignments from
|
||||
# /etc/Inputrc
|
||||
# First, include any systemwide bindings and variable
|
||||
# assignments from /etc/Inputrc
|
||||
$include /etc/Inputrc
|
||||
|
||||
#
|
||||
|
@ -706,10 +749,12 @@ binding, variable assignment, and conditional syntax.
|
|||
$if Bash
|
||||
# edit the path
|
||||
"\C-xp": "PATH=${PATH}\e\C-e\C-a\ef\C-f"
|
||||
# prepare to type a quoted word -- insert open and close double quotes
|
||||
# prepare to type a quoted word --
|
||||
# insert open and close double quotes
|
||||
# and move to just after the open quote
|
||||
"\C-x\"": "\"\"\C-b"
|
||||
# insert a backslash (testing backslash escapes in sequences and macros)
|
||||
# insert a backslash (testing backslash escapes
|
||||
# in sequences and macros)
|
||||
"\C-x\\": "\\"
|
||||
# Quote the current or previous word
|
||||
"\C-xq": "\eb\"\ef\""
|
||||
|
@ -725,16 +770,16 @@ binding, variable assignment, and conditional syntax.
|
|||
# don't strip characters to 7 bits when reading
|
||||
set input-meta on
|
||||
|
||||
# allow iso-latin1 characters to be inserted rather than converted to
|
||||
# prefix-meta sequences
|
||||
# allow iso-latin1 characters to be inserted rather
|
||||
# than converted to prefix-meta sequences
|
||||
set convert-meta off
|
||||
|
||||
# display characters with the eighth bit set directly rather than
|
||||
# as meta-prefixed characters
|
||||
# display characters with the eighth bit set directly
|
||||
# rather than as meta-prefixed characters
|
||||
set output-meta on
|
||||
|
||||
# if there are more than 150 possible completions for a word, ask the
|
||||
# user if he wants to see all of them
|
||||
# if there are more than 150 possible completions for
|
||||
# a word, ask the user if he wants to see all of them
|
||||
set completion-query-items 150
|
||||
|
||||
# For FTP
|
||||
|
@ -762,13 +807,13 @@ Bindable Readline Commands
|
|||
* Miscellaneous Commands:: Other miscellaneous commands.
|
||||
|
||||
This section describes Readline commands that may be bound to key
|
||||
sequences.
|
||||
sequences. Command names without an accompanying key sequence are
|
||||
unbound by default.
|
||||
|
||||
Command names without an accompanying key sequence are unbound by
|
||||
default. In the following descriptions, POINT refers to the current
|
||||
cursor position, and MARK refers to a cursor position saved by the
|
||||
In the following descriptions, "point" refers to the current cursor
|
||||
position, and "mark" refers to a cursor position saved by the
|
||||
`set-mark' command. The text between the point and mark is referred to
|
||||
as the REGION.
|
||||
as the "region".
|
||||
|
||||
|
||||
File: rluserman.info, Node: Commands For Moving, Next: Commands For History, Up: Bindable Readline Commands
|
||||
|
@ -809,16 +854,18 @@ File: rluserman.info, Node: Commands For History, Next: Commands For Text, Pr
|
|||
Commands For Manipulating The History
|
||||
-------------------------------------
|
||||
|
||||
`accept-line (Newline, Return)'
|
||||
`accept-line (Newline or Return)'
|
||||
Accept the line regardless of where the cursor is. If this line is
|
||||
non-empty, add it to the history list. If this line was a history
|
||||
line, then restore the history line to its original state.
|
||||
non-empty, it may be added to the history list for future recall
|
||||
with `add_history()'. If this line is a modified history line,
|
||||
the history line is restored to its original state.
|
||||
|
||||
`previous-history (C-p)'
|
||||
Move `up' through the history list.
|
||||
Move `back' through the history list, fetching the previous
|
||||
command.
|
||||
|
||||
`next-history (C-n)'
|
||||
Move `down' through the history list.
|
||||
Move `forward' through the history list, fetching the next command.
|
||||
|
||||
`beginning-of-history (M-<)'
|
||||
Move to the first line in the history.
|
||||
|
@ -858,12 +905,12 @@ Commands For Manipulating The History
|
|||
|
||||
`yank-nth-arg (M-C-y)'
|
||||
Insert the first argument to the previous command (usually the
|
||||
second word on the previous line). With an argument N, insert the
|
||||
Nth word from the previous command (the words in the previous
|
||||
command begin with word 0). A negative argument inserts the Nth
|
||||
word from the end of the previous command.
|
||||
second word on the previous line) at point. With an argument N,
|
||||
insert the Nth word from the previous command (the words in the
|
||||
previous command begin with word 0). A negative argument inserts
|
||||
the Nth word from the end of the previous command.
|
||||
|
||||
`yank-last-arg (M-., M-_)'
|
||||
`yank-last-arg (M-. or M-_)'
|
||||
Insert last argument to the previous command (the last word of the
|
||||
previous history entry). With an argument, behave exactly like
|
||||
`yank-nth-arg'. Successive calls to `yank-last-arg' move back
|
||||
|
@ -877,10 +924,9 @@ Commands For Changing Text
|
|||
--------------------------
|
||||
|
||||
`delete-char (C-d)'
|
||||
Delete the character under the cursor. If the cursor is at the
|
||||
beginning of the line, there are no characters in the line, and
|
||||
the last character typed was not bound to `delete-char', then
|
||||
return `EOF'.
|
||||
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 `delete-char', then return EOF.
|
||||
|
||||
`backward-delete-char (Rubout)'
|
||||
Delete the character behind the cursor. A numeric argument means
|
||||
|
@ -891,11 +937,11 @@ Commands For Changing Text
|
|||
end of the line, in which case the character behind the cursor is
|
||||
deleted. By default, this is not bound to a key.
|
||||
|
||||
`quoted-insert (C-q, C-v)'
|
||||
`quoted-insert (C-q or C-v)'
|
||||
Add the next character typed to the line verbatim. This is how to
|
||||
insert key sequences like <C-q>, for example.
|
||||
insert key sequences like `C-q', for example.
|
||||
|
||||
`tab-insert (M-TAB)'
|
||||
`tab-insert (M-<TAB>)'
|
||||
Insert a tab character.
|
||||
|
||||
`self-insert (a, b, A, 1, !, ...)'
|
||||
|
@ -909,7 +955,8 @@ Commands For Changing Text
|
|||
|
||||
`transpose-words (M-t)'
|
||||
Drag the word before point past the word after point, moving point
|
||||
past that word as well.
|
||||
past that word as well. If the insertion point is at the end of
|
||||
the line, this transposes the last two words on the line.
|
||||
|
||||
`upcase-word (M-u)'
|
||||
Uppercase the current (or following) word. With a negative
|
||||
|
@ -923,6 +970,20 @@ Commands For Changing Text
|
|||
Capitalize the current (or following) word. With a negative
|
||||
argument, capitalize the previous word, but do not move the cursor.
|
||||
|
||||
`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
|
||||
`emacs' mode; `vi' mode does overwrite differently. Each call to
|
||||
`readline()' starts in insert mode.
|
||||
|
||||
In overwrite mode, characters bound to `self-insert' replace the
|
||||
text at point rather than pushing the text to the right.
|
||||
Characters bound to `backward-delete-char' replace the character
|
||||
before point with a space.
|
||||
|
||||
By default, this command is unbound.
|
||||
|
||||
|
||||
File: rluserman.info, Node: Commands For Killing, Next: Numeric Arguments, Prev: Commands For Text, Up: Bindable Readline Commands
|
||||
|
||||
|
@ -939,15 +1000,15 @@ Killing And Yanking
|
|||
Kill backward from the cursor to the beginning of the current line.
|
||||
|
||||
`kill-whole-line ()'
|
||||
Kill all characters on the current line, no matter point is. By
|
||||
default, this is unbound.
|
||||
Kill all characters on the current line, no matter where point is.
|
||||
By default, this is unbound.
|
||||
|
||||
`kill-word (M-d)'
|
||||
Kill from point to the end of the current word, or if between
|
||||
words, to the end of the next word. Word boundaries are the same
|
||||
as `forward-word'.
|
||||
|
||||
`backward-kill-word (M-DEL)'
|
||||
`backward-kill-word (M-<DEL>)'
|
||||
Kill the word behind point. Word boundaries are the same as
|
||||
`backward-word'.
|
||||
|
||||
|
@ -978,12 +1039,11 @@ Killing And Yanking
|
|||
command is unbound.
|
||||
|
||||
`yank (C-y)'
|
||||
Yank the top of the kill ring into the buffer at the current
|
||||
cursor position.
|
||||
Yank the top of the kill ring into the buffer at point.
|
||||
|
||||
`yank-pop (M-y)'
|
||||
Rotate the kill-ring, and yank the new top. You can only do this
|
||||
if the prior command is yank or yank-pop.
|
||||
if the prior command is `yank' or `yank-pop'.
|
||||
|
||||
|
||||
File: rluserman.info, Node: Numeric Arguments, Next: Commands For Completion, Prev: Commands For Killing, Up: Bindable Readline Commands
|
||||
|
@ -993,7 +1053,7 @@ Specifying Numeric Arguments
|
|||
|
||||
`digit-argument (M-0, M-1, ... M--)'
|
||||
Add this digit to the argument already accumulating, or start a new
|
||||
argument. <M-> starts a negative argument.
|
||||
argument. `M--' starts a negative argument.
|
||||
|
||||
`universal-argument ()'
|
||||
This is another way to specify an argument. If this command is
|
||||
|
@ -1014,17 +1074,13 @@ File: rluserman.info, Node: Commands For Completion, Next: Keyboard Macros, P
|
|||
Letting Readline Type For You
|
||||
-----------------------------
|
||||
|
||||
`complete (TAB)'
|
||||
Attempt to do completion on the text before the cursor. This is
|
||||
application-specific. Generally, if you are typing a filename
|
||||
argument, you can do filename completion; if you are typing a
|
||||
command, you can do command completion; if you are typing in a
|
||||
symbol to GDB, you can do symbol name completion; if you are
|
||||
typing in a variable to Bash, you can do variable name completion,
|
||||
and so on.
|
||||
`complete (<TAB>)'
|
||||
Attempt to perform completion on the text before point. The
|
||||
actual completion performed is application-specific. The default
|
||||
is filename completion.
|
||||
|
||||
`possible-completions (M-?)'
|
||||
List the possible completions of the text before the cursor.
|
||||
List the possible completions of the text before point.
|
||||
|
||||
`insert-completions (M-*)'
|
||||
Insert all completions of the text before point that would have
|
||||
|
@ -1035,10 +1091,11 @@ Letting Readline Type For You
|
|||
a single match from the list of possible completions. Repeated
|
||||
execution of `menu-complete' steps through the list of possible
|
||||
completions, inserting each match in turn. At the end of the list
|
||||
of completions, the bell is rung and the original text is restored.
|
||||
An argument of N moves N positions forward in the list of matches;
|
||||
a negative argument may be used to move backward through the list.
|
||||
This command is intended to be bound to `TAB', but is unbound by
|
||||
of completions, the bell is rung (subject to the setting of
|
||||
`bell-style') and the original text is restored. An argument of N
|
||||
moves N positions forward in the list of matches; a negative
|
||||
argument may be used to move backward through the list. This
|
||||
command is intended to be bound to <TAB>, but is unbound by
|
||||
default.
|
||||
|
||||
`delete-char-or-list ()'
|
||||
|
@ -1082,11 +1139,11 @@ Some Miscellaneous Commands
|
|||
If the metafied character X is lowercase, run the command that is
|
||||
bound to the corresponding uppercase character.
|
||||
|
||||
`prefix-meta (ESC)'
|
||||
Make the next character typed be metafied. This is for keyboards
|
||||
without a meta key. Typing `ESC f' is equivalent to typing `M-f'.
|
||||
`prefix-meta (<ESC>)'
|
||||
Metafy the next character typed. This is for keyboards without a
|
||||
meta key. Typing `<ESC> f' is equivalent to typing `M-f'.
|
||||
|
||||
`undo (C-_, C-x C-u)'
|
||||
`undo (C-_ or C-x C-u)'
|
||||
Incremental undo, separately remembered for each line.
|
||||
|
||||
`revert-line (M-r)'
|
||||
|
@ -1097,8 +1154,8 @@ Some Miscellaneous Commands
|
|||
Perform tilde expansion on the current word.
|
||||
|
||||
`set-mark (C-@)'
|
||||
Set the mark to the current point. If a numeric argument is
|
||||
supplied, the mark is set to that position.
|
||||
Set the mark to the point. If a numeric argument is supplied, the
|
||||
mark is set to that position.
|
||||
|
||||
`exchange-point-and-mark (C-x C-x)'
|
||||
Swap the point with the mark. The current cursor position is set
|
||||
|
@ -1116,9 +1173,14 @@ Some Miscellaneous Commands
|
|||
occurrences.
|
||||
|
||||
`insert-comment (M-#)'
|
||||
The value of the `comment-begin' variable is inserted at the
|
||||
beginning of the current line, and the line is accepted as if a
|
||||
newline had been typed.
|
||||
Without a numeric argument, the value of the `comment-begin'
|
||||
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 `comment-begin', the value is inserted, otherwise the
|
||||
characters in `comment-begin' are deleted from the beginning of
|
||||
the line. In either case, the line is accepted as if a newline
|
||||
had been typed.
|
||||
|
||||
`dump-functions ()'
|
||||
Print all of the functions and their key bindings to the Readline
|
||||
|
@ -1134,9 +1196,17 @@ Some Miscellaneous Commands
|
|||
|
||||
`dump-macros ()'
|
||||
Print all of the Readline key sequences bound to macros and the
|
||||
strings they ouput. If a numeric argument is supplied, the output
|
||||
is formatted in such a way that it can be made part of an INPUTRC
|
||||
file. This command is unbound by default.
|
||||
strings they output. If a numeric argument is supplied, the
|
||||
output is formatted in such a way that it can be made part of an
|
||||
INPUTRC file. This command is unbound by default.
|
||||
|
||||
`emacs-editing-mode (C-e)'
|
||||
When in `vi' command mode, this causes a switch to `emacs' editing
|
||||
mode.
|
||||
|
||||
`vi-editing-mode (M-C-j)'
|
||||
When in `emacs' editing mode, this causes a switch to `vi' editing
|
||||
mode.
|
||||
|
||||
|
||||
File: rluserman.info, Node: Readline vi Mode, Prev: Bindable Readline Commands, Up: Command Line Editing
|
||||
|
@ -1150,7 +1220,8 @@ The Readline `vi' mode behaves as specified in the POSIX 1003.2
|
|||
standard.
|
||||
|
||||
In order to switch interactively between `emacs' and `vi' editing
|
||||
modes, use the command M-C-j (toggle-editing-mode). The Readline
|
||||
modes, use the command `M-C-j' (bound to emacs-editing-mode when in
|
||||
`vi' mode and to vi-editing-mode in `emacs' mode). The Readline
|
||||
default is `emacs' mode.
|
||||
|
||||
When you enter a line in `vi' mode, you are already placed in
|
||||
|
@ -1162,28 +1233,28 @@ the standard `vi' movement keys, move to previous history lines with
|
|||
|
||||
|
||||
Tag Table:
|
||||
Node: Top1221
|
||||
Node: Command Line Editing1617
|
||||
Node: Introduction and Notation2231
|
||||
Node: Readline Interaction3850
|
||||
Node: Readline Bare Essentials5044
|
||||
Node: Readline Movement Commands6826
|
||||
Node: Readline Killing Commands7784
|
||||
Node: Readline Arguments9691
|
||||
Node: Searching10667
|
||||
Node: Readline Init File12511
|
||||
Node: Readline Init File Syntax13573
|
||||
Node: Conditional Init Constructs22839
|
||||
Node: Sample Init File25279
|
||||
Node: Bindable Readline Commands28450
|
||||
Node: Commands For Moving29495
|
||||
Node: Commands For History30345
|
||||
Node: Commands For Text33063
|
||||
Node: Commands For Killing35067
|
||||
Node: Numeric Arguments37035
|
||||
Node: Commands For Completion38163
|
||||
Node: Keyboard Macros39912
|
||||
Node: Miscellaneous Commands40472
|
||||
Node: Readline vi Mode43277
|
||||
Node: Top1208
|
||||
Node: Command Line Editing1604
|
||||
Node: Introduction and Notation2218
|
||||
Node: Readline Interaction3837
|
||||
Node: Readline Bare Essentials5025
|
||||
Node: Readline Movement Commands6807
|
||||
Node: Readline Killing Commands7765
|
||||
Node: Readline Arguments9675
|
||||
Node: Searching10712
|
||||
Node: Readline Init File12856
|
||||
Node: Readline Init File Syntax13918
|
||||
Node: Conditional Init Constructs24802
|
||||
Node: Sample Init File27328
|
||||
Node: Bindable Readline Commands30513
|
||||
Node: Commands For Moving31564
|
||||
Node: Commands For History32414
|
||||
Node: Commands For Text35273
|
||||
Node: Commands For Killing37988
|
||||
Node: Numeric Arguments39940
|
||||
Node: Commands For Completion41069
|
||||
Node: Keyboard Macros42602
|
||||
Node: Miscellaneous Commands43162
|
||||
Node: Readline vi Mode46512
|
||||
|
||||
End Tag Table
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
|
|
|
@ -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
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -153,6 +153,8 @@ process_line(char *line)
|
|||
} else {
|
||||
fprintf(stderr, "|%s|\n", line);
|
||||
}
|
||||
|
||||
free (line);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
139
readline/examples/readlinebuf.h
Normal file
139
readline/examples/readlinebuf.h
Normal 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
|
|
@ -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
174
readline/examples/rlcat.c
Normal 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;
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
173
readline/input.c
173
readline/input.c
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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++)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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
337
readline/mbutil.c
Normal 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
496
readline/misc.c
Normal 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;
|
||||
}
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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_ */
|
||||
|
|
1634
readline/readline.c
1634
readline/readline.c
File diff suppressed because it is too large
Load diff
|
@ -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,9 +728,69 @@ extern int rl_inhibit_completion;
|
|||
#define SINGLE_MATCH 1
|
||||
#define MULT_MATCH 2
|
||||
|
||||
#if !defined (savestring)
|
||||
extern char *savestring __P((char *)); /* XXX backwards compatibility */
|
||||
#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
|
||||
}
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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
108
readline/rlmbutil.h
Normal 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_ */
|
|
@ -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 */
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
112
readline/rltty.c
112
readline/rltty.c
|
@ -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;
|
||||
|
@ -190,7 +203,7 @@ save_tty_chars (tiop)
|
|||
_rl_tty_chars.t_intr = tiop->tchars.t_intrc;
|
||||
_rl_tty_chars.t_quit = tiop->tchars.t_quitc;
|
||||
_rl_tty_chars.t_start = tiop->tchars.t_startc;
|
||||
_rl_tty_chars.t_stop = tiop->tchars.t_stopc
|
||||
_rl_tty_chars.t_stop = tiop->tchars.t_stopc;
|
||||
_rl_tty_chars.t_eof = tiop->tchars.t_eofc;
|
||||
_rl_tty_chars.t_eol = '\n';
|
||||
_rl_tty_chars.t_eol2 = tiop->tchars.t_brkc;
|
||||
|
@ -218,22 +231,23 @@ get_tty_settings (tty, tiop)
|
|||
|
||||
tiop->flags = tiop->lflag = 0;
|
||||
|
||||
ioctl (tty, TIOCGETP, &(tiop->sgttyb));
|
||||
if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
|
||||
return -1;
|
||||
tiop->flags |= SGTTY_SET;
|
||||
|
||||
#if defined (TIOCLGET)
|
||||
ioctl (tty, TIOCLGET, &(tiop->lflag));
|
||||
tiop->flags |= LFLAG_SET;
|
||||
if (ioctl (tty, TIOCLGET, &(tiop->lflag)) == 0)
|
||||
tiop->flags |= LFLAG_SET;
|
||||
#endif
|
||||
|
||||
#if defined (TIOCGETC)
|
||||
ioctl (tty, TIOCGETC, &(tiop->tchars));
|
||||
tiop->flags |= TCHARS_SET;
|
||||
if (ioctl (tty, TIOCGETC, &(tiop->tchars)) == 0)
|
||||
tiop->flags |= TCHARS_SET;
|
||||
#endif
|
||||
|
||||
#if defined (TIOCGLTC)
|
||||
ioctl (tty, TIOCGLTC, &(tiop->ltchars));
|
||||
tiop->flags |= LTCHARS_SET;
|
||||
if (ioctl (tty, TIOCGLTC, &(tiop->ltchars)) == 0)
|
||||
tiop->flags |= LTCHARS_SET;
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
|
@ -279,23 +293,23 @@ set_tty_settings (tty, tiop)
|
|||
}
|
||||
|
||||
static void
|
||||
prepare_terminal_settings (meta_flag, otio, tiop)
|
||||
prepare_terminal_settings (meta_flag, oldtio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE otio, *tiop;
|
||||
TIOTYPE oldtio, *tiop;
|
||||
{
|
||||
readline_echoing_p = (otio.sgttyb.sg_flags & ECHO);
|
||||
readline_echoing_p = (oldtio.sgttyb.sg_flags & ECHO);
|
||||
|
||||
/* Copy the original settings to the structure we're going to use for
|
||||
our settings. */
|
||||
tiop->sgttyb = otio.sgttyb;
|
||||
tiop->lflag = otio.lflag;
|
||||
tiop->sgttyb = oldtio.sgttyb;
|
||||
tiop->lflag = oldtio.lflag;
|
||||
#if defined (TIOCGETC)
|
||||
tiop->tchars = otio.tchars;
|
||||
tiop->tchars = oldtio.tchars;
|
||||
#endif
|
||||
#if defined (TIOCGLTC)
|
||||
tiop->ltchars = otio.ltchars;
|
||||
tiop->ltchars = oldtio.ltchars;
|
||||
#endif
|
||||
tiop->flags = otio.flags;
|
||||
tiop->flags = oldtio.flags;
|
||||
|
||||
/* First, the basic settings to put us into character-at-a-time, no-echo
|
||||
input mode. */
|
||||
|
@ -308,8 +322,8 @@ prepare_terminal_settings (meta_flag, otio, tiop)
|
|||
#if !defined (ANYP)
|
||||
# define ANYP (EVENP | ODDP)
|
||||
#endif
|
||||
if (((otio.sgttyb.sg_flags & ANYP) == ANYP) ||
|
||||
((otio.sgttyb.sg_flags & ANYP) == 0))
|
||||
if (((oldtio.sgttyb.sg_flags & ANYP) == ANYP) ||
|
||||
((oldtio.sgttyb.sg_flags & ANYP) == 0))
|
||||
{
|
||||
tiop->sgttyb.sg_flags |= ANYP;
|
||||
|
||||
|
@ -328,13 +342,13 @@ prepare_terminal_settings (meta_flag, otio, tiop)
|
|||
tiop->tchars.t_startc = -1; /* C-q */
|
||||
|
||||
/* If there is an XON character, bind it to restart the output. */
|
||||
if (otio.tchars.t_startc != -1)
|
||||
rl_bind_key (otio.tchars.t_startc, rl_restart_output);
|
||||
if (oldtio.tchars.t_startc != -1)
|
||||
rl_bind_key (oldtio.tchars.t_startc, rl_restart_output);
|
||||
# endif /* USE_XON_XOFF */
|
||||
|
||||
/* If there is an EOF char, bind _rl_eof_char to it. */
|
||||
if (otio.tchars.t_eofc != -1)
|
||||
_rl_eof_char = otio.tchars.t_eofc;
|
||||
if (oldtio.tchars.t_eofc != -1)
|
||||
_rl_eof_char = oldtio.tchars.t_eofc;
|
||||
|
||||
# if defined (NO_KILL_INTR)
|
||||
/* Get rid of terminal-generated SIGQUIT and SIGINT. */
|
||||
|
@ -373,11 +387,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
|
||||
|
@ -545,16 +567,16 @@ set_tty_settings (tty, tiop)
|
|||
}
|
||||
|
||||
static void
|
||||
prepare_terminal_settings (meta_flag, otio, tiop)
|
||||
prepare_terminal_settings (meta_flag, oldtio, tiop)
|
||||
int meta_flag;
|
||||
TIOTYPE otio, *tiop;
|
||||
TIOTYPE oldtio, *tiop;
|
||||
{
|
||||
readline_echoing_p = (otio.c_lflag & ECHO);
|
||||
readline_echoing_p = (oldtio.c_lflag & ECHO);
|
||||
|
||||
tiop->c_lflag &= ~(ICANON | ECHO);
|
||||
|
||||
if ((unsigned char) otio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
|
||||
_rl_eof_char = otio.c_cc[VEOF];
|
||||
if ((unsigned char) oldtio.c_cc[VEOF] != (unsigned char) _POSIX_VDISABLE)
|
||||
_rl_eof_char = oldtio.c_cc[VEOF];
|
||||
|
||||
#if defined (USE_XON_XOFF)
|
||||
#if defined (IXANY)
|
||||
|
@ -585,7 +607,7 @@ prepare_terminal_settings (meta_flag, otio, tiop)
|
|||
if (OUTPUT_BEING_FLUSHED (tiop))
|
||||
{
|
||||
tiop->c_lflag &= ~FLUSHO;
|
||||
otio.c_lflag &= ~FLUSHO;
|
||||
oldtio.c_lflag &= ~FLUSHO;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -645,6 +667,7 @@ rl_prep_terminal (meta_flag)
|
|||
|
||||
fflush (rl_outstream);
|
||||
terminal_prepped = 1;
|
||||
RL_SETSTATE(RL_STATE_TERMPREPPED);
|
||||
|
||||
release_sigint ();
|
||||
}
|
||||
|
@ -675,6 +698,7 @@ rl_deprep_terminal ()
|
|||
}
|
||||
|
||||
terminal_prepped = 0;
|
||||
RL_UNSETSTATE(RL_STATE_TERMPREPPED);
|
||||
|
||||
release_sigint ();
|
||||
}
|
||||
|
@ -751,6 +775,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;
|
||||
|
@ -765,8 +792,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)
|
||||
|
||||
|
@ -815,6 +842,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)
|
||||
|
@ -846,6 +882,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));
|
||||
|
@ -857,10 +894,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
88
readline/rltypedefs.h
Normal 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_ */
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -44,28 +44,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;
|
||||
|
@ -96,24 +117,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 */
|
||||
|
@ -121,14 +142,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;
|
||||
|
@ -147,7 +168,7 @@ get_home_dir ()
|
|||
#endif
|
||||
|
||||
int
|
||||
unset_nodelay_mode (fd)
|
||||
sh_unset_nodelay_mode (fd)
|
||||
int fd;
|
||||
{
|
||||
int flags, bflags;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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. */
|
||||
|
||||
|
@ -119,6 +120,8 @@ rl_signal_handler (sig)
|
|||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
RL_SETSTATE(RL_STATE_SIGHANDLER);
|
||||
|
||||
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
|
||||
/* Since the signal will not be blocked while we are in the signal
|
||||
handler, ignore it until rl_clear_signals resets the catcher. */
|
||||
|
@ -169,6 +172,7 @@ rl_signal_handler (sig)
|
|||
rl_reset_after_signal ();
|
||||
}
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
|
||||
SIGHANDLER_RETURN;
|
||||
}
|
||||
|
||||
|
@ -189,6 +193,7 @@ rl_sigwinch_handler (sig)
|
|||
rl_set_sighandler (SIGWINCH, rl_sigwinch_handler, &dummy_winch);
|
||||
#endif
|
||||
|
||||
RL_SETSTATE(RL_STATE_SIGHANDLER);
|
||||
rl_resize_terminal ();
|
||||
|
||||
/* If another sigwinch handler has been installed, call it. */
|
||||
|
@ -196,6 +201,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 */
|
||||
|
@ -227,7 +233,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);
|
||||
|
@ -358,7 +364,7 @@ rl_cleanup_after_signal ()
|
|||
_rl_clean_up_for_exit ();
|
||||
(*rl_deprep_term_function) ();
|
||||
rl_clear_signals ();
|
||||
rl_pending_input = 0;
|
||||
rl_clear_pending_input ();
|
||||
}
|
||||
|
||||
/* Reset the terminal and readline state after a signal handler returns. */
|
||||
|
@ -378,7 +384,7 @@ rl_free_line_state ()
|
|||
{
|
||||
register HIST_ENTRY *entry;
|
||||
|
||||
free_undo_list ();
|
||||
rl_free_undo_list ();
|
||||
|
||||
entry = current_history ();
|
||||
if (entry)
|
||||
|
|
1257
readline/support/config.guess
vendored
1257
readline/support/config.guess
vendored
File diff suppressed because it is too large
Load diff
850
readline/support/config.sub
vendored
850
readline/support/config.sub
vendored
File diff suppressed because it is too large
Load diff
|
@ -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.
|
||||
#
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
;;
|
||||
|
||||
|
|
|
@ -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'
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue