import of readlilne 5.1
This commit is contained in:
parent
84041b4c47
commit
b585a9fad5
112 changed files with 57294 additions and 18169 deletions
|
@ -697,3 +697,224 @@ 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
|
||||
|
||||
7/17
|
||||
----
|
||||
[readline-4.3 released]
|
||||
|
||||
7/18
|
||||
----
|
||||
shlib/Makefile.in
|
||||
- fix bad dependency: text.so: terminal.c, make it depend on text.c
|
||||
|
||||
8/7
|
||||
---
|
||||
support/shlib-install
|
||||
- break `linux' out into its own stanza: it seems that linux
|
||||
distributions are all moving to the following scheme:
|
||||
|
||||
libreadline.so.4.3 installed version
|
||||
libreadline.so.4 -> libreadline.so.4.3 symlink
|
||||
libreadline.so -> libreadline.so.4 symlink
|
||||
|
||||
10/29
|
||||
-----
|
||||
support/shlib-install
|
||||
- change INSTALL_LINK[12] to use `&&' instead of `;' so it only
|
||||
tries the link if the cd succeeds; put ${echo} in there, too
|
||||
- use $LN instead of `ln -s' so it works on machines without symlinks
|
||||
- change special linux stanza to use cd before ln also
|
||||
- change to use $INSTALL_LINK1 and $INSTALL_LINK2 appropriately
|
||||
instead of explicit commands in various stanzas
|
||||
|
||||
2/1
|
||||
---
|
||||
config.h.in
|
||||
- add HAVE_MBRTOWC and HAVE_MBRLEN
|
||||
- add NO_MULTIBYTE_SUPPORT for new configure argument
|
||||
- add STDC_HEADERS
|
||||
|
||||
configure.in
|
||||
- new argument --enable-multibyte (enabled by default), allows
|
||||
multibyte support to be turned off even on systems that support it
|
||||
- add check for ansi stdc headers with call to AC_HEADER_STDC
|
||||
|
||||
2/3
|
||||
---
|
||||
configure.in
|
||||
- add call to BASH_FUNC_CTYPE_NONASCII
|
||||
|
||||
config.h.in
|
||||
- add CTYPE_NON_ASCII
|
||||
|
||||
2/20
|
||||
----
|
||||
|
||||
doc/manvers.texinfo
|
||||
- renamed to version.texi to match other GNU software
|
||||
- UPDATE-MONTH variable is now `UPDATED-MONTH'
|
||||
|
||||
doc/{hist,rlman,rluserman}.texinfo
|
||||
- include version.texi
|
||||
|
||||
doc/{rltech,rluser,hstech,hsuser}.texi
|
||||
- changed the suffix from `texinfo' to `texi'
|
||||
|
||||
doc/Makefile.in
|
||||
- made appropriate changes for {{rl,hs}tech,{rl,hs}user}.texi
|
||||
|
||||
doc/{rlman,rluserman}.texinfo
|
||||
- changed the suffix from `texinfo' to `texi'
|
||||
|
||||
doc/hist.texinfo
|
||||
- renamed to history.texi to be more consistent
|
||||
|
||||
6/11
|
||||
----
|
||||
shlib/Makefile.in
|
||||
- have configure substitute value of `@LDFLAGS@' into the assignment
|
||||
to SHLIB_XLDFLAGS
|
||||
|
||||
6/16
|
||||
----
|
||||
configure.in
|
||||
- readline and history libraries are now at version 5.0
|
||||
|
||||
8/18
|
||||
----
|
||||
support/shlib-install
|
||||
- support for FreeBSD-gnu (from Robert Millan)
|
||||
|
||||
12/4
|
||||
----
|
||||
Makefile.in
|
||||
- add variables for localedir and the PACKAGE_* variables, auto-set
|
||||
by configure
|
||||
|
||||
12/9
|
||||
----
|
||||
Makefile.in
|
||||
- use mkinstalldirs instead of mkdirs
|
||||
|
||||
4/22
|
||||
----
|
||||
Makefile.in
|
||||
- separate doc install/uninstall out into two new targets:
|
||||
install-doc and uninstall-doc
|
||||
- make install-doc and uninstall-doc prerequisites of appropriate
|
||||
install and uninstall targets
|
||||
|
||||
examples/rl-fgets.c
|
||||
- new example from Harold Levy that wraps fgets replacement functions
|
||||
that call readline in a shared library that can be interposed with
|
||||
LD_PRELOAD
|
||||
|
||||
7/27
|
||||
----
|
||||
[readline-5.0 released]
|
||||
|
||||
11/15
|
||||
-----
|
||||
examples/rlfe/{ChangeLog,Makefile.in,README,config.h.in,configure,configure.in,extern.h,os.h,pty.c,rlfe.c,screen.h}
|
||||
- new version of rlfe, rlfe-0.4, from Per Bothner; now a standalone
|
||||
application
|
||||
|
||||
11/16
|
||||
-----
|
||||
shlib/Makefile.in
|
||||
- substitute TERMCAP_LIB in from configure
|
||||
|
||||
configure.in
|
||||
- if SHLIB_LIBS doesn't include a termcap library (curses, ncurses,
|
||||
termcap, termlib), append the value of $TERMCAP_LIB to it
|
||||
|
||||
11/30
|
||||
-----
|
||||
configure.in
|
||||
- take out change from 11/16; it doesn't work for some systems (e.g.,
|
||||
SunOS 4.x and Solaris 2.6)
|
||||
- add support for --enable-purify configure argument
|
||||
- pass TERMCAP_LIB in environment when calling shobj-conf
|
||||
|
||||
examples/Makefile.in
|
||||
- add support for building examples with purify
|
||||
|
||||
1/23/2005
|
||||
---------
|
||||
configure.in
|
||||
- set BUILD_DIR to contain backslashes to escape any spaces in the
|
||||
directory name -- this is what make will accept in targets and
|
||||
prerequisites, so it's better than trying to use double quotes
|
||||
|
||||
2/25
|
||||
----
|
||||
configure.in
|
||||
- change check for sys/ptem.h to include sys/stream.h if present, to
|
||||
avoid the `present but cannot be compiled' messages on Solaris and
|
||||
SVR4.2 (does anyone still use SVR4.2?)
|
||||
|
||||
5/7
|
||||
---
|
||||
configure.in
|
||||
- add cross-compiling support from the bash configure.in, which cygwin
|
||||
and mingw have apparently adopted
|
||||
- add check for pwd.h, fcntl.h
|
||||
- add checks for fcntl, kill system calls
|
||||
- add checks for getpw{ent,nam,uid} C library functions
|
||||
- pass a compile-time option through to Makefiles if cross-compiling
|
||||
|
||||
config.h.in
|
||||
- add HAVE_PWD_H for <pwd.h>, HAVE_FCNTL_H for <fcntl.h>
|
||||
- add HAVE_FCNTL, HAVE_KILL for respective system calls
|
||||
- add HAVE_GETPW{ENT,NAM,UID} for passwd functions
|
||||
|
||||
Makefile.in,shlib/Makefile.in
|
||||
- @CROSS_COMPILE@ is substituted into DEFS (equal to -DCROSS_COMPILING
|
||||
if bash is being cross-compiled)
|
||||
|
||||
8/2
|
||||
---
|
||||
examples/Makefile.in
|
||||
- use $(READLINE_LIB) instead of -lreadline to get around MacOS X 10.4's
|
||||
preference for (incompatible) shared libraries over static libraries
|
||||
in the load path
|
||||
|
||||
8/11
|
||||
----
|
||||
support/shobj-conf
|
||||
- new variable: SHLIB_LIBPREF, prefix for shared library name (defaults
|
||||
to `lib'
|
||||
- new variable: SHLIB_DLLVERSION, used on Cygwin to set the library
|
||||
version number
|
||||
- new variable: SHLIB_DOT, separator character between library name and
|
||||
suffix and version information (defaults to `.')
|
||||
- new stanza for cygwin to generate windows-compatible dll
|
||||
|
||||
support/shlib-install
|
||||
- add new option `-b bindir' for systems like cygwin/windows that
|
||||
require it
|
||||
- new stanza for cygwin that installs a dll into $bindir and an implied
|
||||
link library into $libdir
|
||||
|
||||
configure.in
|
||||
- substitute new variables from shobj-conf
|
||||
|
||||
shlib/Makefile.in
|
||||
- substitute bindir, SHLIB_DOT, SHLIB_LIBPREF, SHLIB_DLLVERSION from
|
||||
configure
|
||||
- pass `-b $(bindir)' to shlib-install for install and uninstall targets
|
||||
- library names now use $SHLIB_LIBPREF and $SHLIB_DOT
|
||||
|
||||
INSTALL,README
|
||||
- document new SHLIB_DOT, SHLIB_LIBPREF, and SHLIB_DLLVERSION variables
|
||||
|
||||
10/4
|
||||
----
|
||||
[readline-5.1-beta1 frozen]
|
||||
|
||||
12/1
|
||||
----
|
||||
configure.in
|
||||
- changed release status to `release'
|
||||
|
||||
[readline-5.1 frozen]
|
||||
|
|
309
readline/CHANGES
309
readline/CHANGES
|
@ -1,3 +1,312 @@
|
|||
This document details the changes between this version, readline-5.1,
|
||||
and the previous version, readline-5.0.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. Fixed a bug that caused multiliine prompts to be wrapped and displayed
|
||||
incorrectly.
|
||||
|
||||
b. Fixed a bug that caused ^P/^N in emacs mode to fail to display the current
|
||||
line correctly.
|
||||
|
||||
c. Fixed a problem in computing the number of invisible characters on the first
|
||||
line of a prompt whose length exceeds the screen width.
|
||||
|
||||
d. Fixed vi-mode searching so that failure preserves the current line rather
|
||||
than the last line in the history list.
|
||||
|
||||
e. Fixed the vi-mode `~' command (change-case) to have the correct behavior at
|
||||
end-of-line when manipulating multibyte characters.
|
||||
|
||||
f. Fixed the vi-mode `r' command (change-char) to have the correct behavior at
|
||||
end-of-line when manipulating multibyte characters.
|
||||
|
||||
g. Fixed multiple bugs in the redisplay of multibyte characters: displaying
|
||||
prompts longer than the screen width containing multibyte characters,
|
||||
|
||||
h. Fix the calculation of the number of physical characters in the prompt
|
||||
string when it contains multibyte characters.
|
||||
|
||||
i. A non-zero value for the `rl_complete_suppress_append' variable now causes
|
||||
no `/' to be appended to a directory name.
|
||||
|
||||
j. Fixed forward-word and backward-word to work when words contained
|
||||
multibyte characters.
|
||||
|
||||
k. Fixed a bug in finding the delimiter of a `?' substring when performing
|
||||
history expansion in a locale that supports multibyte characters.
|
||||
|
||||
l. Fixed a memory leak caused by not freeing the timestamp in a history entry.
|
||||
|
||||
m. Fixed a bug that caused "\M-x" style key bindings to not obey the setting
|
||||
of the `convert-meta' variable.
|
||||
|
||||
n. Fixed saving and restoring primary prompt when prompting for incremental
|
||||
and non-incremental searches; search prompts now display multibyte
|
||||
characters correctly.
|
||||
|
||||
o. Fixed a bug that caused keys originally bound to self-insert but shadowed
|
||||
by a multi-character key sequence to not be inserted.
|
||||
|
||||
p. Fixed code so rl_prep_term_function and rl_deprep_term_function aren't
|
||||
dereferenced if NULL (matching the documentation).
|
||||
|
||||
q. Extensive changes to readline to add enough state so that commands
|
||||
requiring additional characters (searches, multi-key sequences, numeric
|
||||
arguments, commands requiring an additional specifier character like
|
||||
vi-mode change-char, etc.) work without synchronously waiting for
|
||||
additional input.
|
||||
|
||||
r. Lots of changes so readline builds and runs on MinGW.
|
||||
|
||||
s. Readline no longer tries to modify the terminal settings when running in
|
||||
callback mode.
|
||||
|
||||
t. The Readline display code no longer sets the location of the last invisible
|
||||
character in the prompt if the \[\] sequence is empty.
|
||||
|
||||
u. The `change-case' command now correctly changes the case of multibyte
|
||||
characters.
|
||||
|
||||
v. Changes to the shared library construction scripts to deal with Windows
|
||||
DLL naming conventions for Cygwin.
|
||||
|
||||
w. Fixed the redisplay code to avoid core dumps resulting from a poorly-timed
|
||||
SIGWINCH.
|
||||
|
||||
x. Fixed the non-incremental search code in vi mode to dispose of any current
|
||||
undo list when copying a line from the history into the current editing
|
||||
buffer.
|
||||
|
||||
y. Fixed a bug that caused reversing the incremental search direction to
|
||||
not work correctly.
|
||||
|
||||
z. Fixed the vi-mode `U' command to only undo up to the first time insert mode
|
||||
was entered, as Posix specifies.
|
||||
|
||||
aa. Fixed a bug in the vi-mode `r' command that left the cursor in the wrong
|
||||
place.
|
||||
|
||||
bb. Fixed a redisplay bug caused by moving the cursor vertically to a line
|
||||
with invisible characters in the prompt in a multibyte locale.
|
||||
|
||||
cc. Fixed a bug that could cause the terminal special chars to be bound in the
|
||||
wrong keymap in vi mode.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. The key sequence sent by the keypad `delete' key is now automatically
|
||||
bound to delete-char.
|
||||
|
||||
b. A negative argument to menu-complete now cycles backward through the
|
||||
completion list.
|
||||
|
||||
c. A new bindable readline variable: bind-tty-special-chars. If non-zero,
|
||||
readline will bind the terminal special characters to their readline
|
||||
equivalents when it's called (on by default).
|
||||
|
||||
d. New bindable command: vi-rubout. Saves deleted text for possible
|
||||
reinsertion, as with any vi-mode `text modification' command; `X' is bound
|
||||
to this in vi command mode.
|
||||
|
||||
e. If the rl_completion_query_items is set to a value < 0, readline never
|
||||
asks the user whether or not to view the possible completions.
|
||||
|
||||
f. The `C-w' binding in incremental search now understands multibyte
|
||||
characters.
|
||||
|
||||
g. New application-callable auxiliary function, rl_variable_value, returns
|
||||
a string corresponding to a readline variable's value.
|
||||
|
||||
h. When parsing inputrc files and variable binding commands, the parser
|
||||
strips trailing whitespace from values assigned to boolean variables
|
||||
before checking them.
|
||||
|
||||
i. A new external application-controllable variable that allows the LINES
|
||||
and COLUMNS environment variables to set the window size regardless of
|
||||
what the kernel returns.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-5.0,
|
||||
and the previous version, readline-4.3.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. Fixes to avoid core dumps because of null pointer references in the
|
||||
multibyte character code.
|
||||
|
||||
b. Fix to avoid infinite recursion caused by certain key combinations.
|
||||
|
||||
c. Fixed a bug that caused the vi-mode `last command' to be set incorrectly.
|
||||
|
||||
d. Readline no longer tries to read ahead more than one line of input, even
|
||||
when more is available.
|
||||
|
||||
e. Fixed the code that adjusts the point to not mishandle null wide
|
||||
characters.
|
||||
|
||||
f. Fixed a bug in the history expansion `g' modifier that caused it to skip
|
||||
every other match.
|
||||
|
||||
g. Fixed a bug that caused the prompt to overwrite previous output when the
|
||||
output doesn't contain a newline and the locale supports multibyte
|
||||
characters. This same change fixes the problem of readline redisplay
|
||||
slowing down dramatically as the line gets longer in multibyte locales.
|
||||
|
||||
h. History traversal with arrow keys in vi insertion mode causes the cursor
|
||||
to be placed at the end of the new line, like in emacs mode.
|
||||
|
||||
i. The locale initialization code does a better job of using the right
|
||||
precedence and defaulting when checking the appropriate environment
|
||||
variables.
|
||||
|
||||
j. Fixed the history word tokenizer to handle <( and >( better when used as
|
||||
part of bash.
|
||||
|
||||
k. The overwrite mode code received several bug fixes to improve undo.
|
||||
|
||||
l. Many speedups to the multibyte character redisplay code.
|
||||
|
||||
m. The callback character reading interface should not hang waiting to read
|
||||
keyboard input.
|
||||
|
||||
n. Fixed a bug with redoing vi-mode `s' command.
|
||||
|
||||
o. The code that initializes the terminal tracks changes made to the terminal
|
||||
special characters with stty(1) (or equivalent), so that these changes
|
||||
are reflected in the readline bindings. New application-callable function
|
||||
to make it work: rl_tty_unset_default_bindings().
|
||||
|
||||
p. Fixed a bug that could cause garbage to be inserted in the buffer when
|
||||
changing character case in vi mode when using a multibyte locale.
|
||||
|
||||
q. Fixed a bug in the redisplay code that caused problems on systems
|
||||
supporting multibyte characters when moving between history lines when the
|
||||
new line has more glyphs but fewer bytes.
|
||||
|
||||
r. Undo and redo now work better after exiting vi insertion mode.
|
||||
|
||||
s. Make sure system calls are restarted after a SIGWINCH is received using
|
||||
SA_RESTART.
|
||||
|
||||
t. Improvements to the code that displays possible completions when using
|
||||
multibyte characters.
|
||||
|
||||
u. Fixed a problem when parsing nested if statements in inputrc files.
|
||||
|
||||
v. The completer now takes multibyte characters into account when looking for
|
||||
quoted substrings on which to perform completion.
|
||||
|
||||
w. The history search functions now perform better bounds checking on the
|
||||
history list.
|
||||
|
||||
x. Change to history expansion functions to treat `^' as equivalent to word
|
||||
one, as the documention states.
|
||||
|
||||
y. Some changes to the display code to improve display and redisplay of
|
||||
multibyte characters.
|
||||
|
||||
z. Changes to speed up the multibyte character redisplay code.
|
||||
|
||||
aa. Fixed a bug in the vi-mode `E' command that caused it to skip over the
|
||||
last character of a word if invoked while point was on the word's
|
||||
next-to-last character.
|
||||
|
||||
bb. Fixed a bug that could cause incorrect filename quoting when
|
||||
case-insensitive completion was enabled and the word being completed
|
||||
contained backslashes quoting word break characters.
|
||||
|
||||
cc. Fixed a bug in redisplay triggered when the prompt string contains
|
||||
invisible characters.
|
||||
|
||||
dd. Fixed some display (and other) bugs encountered in multibyte locales
|
||||
when a non-ascii character was the last character on a line.
|
||||
|
||||
ee. Fixed some display bugs caused by multibyte characters in prompt strings.
|
||||
|
||||
ff. Fixed a problem with history expansion caused by non-whitespace characters
|
||||
used as history word delimiters.
|
||||
|
||||
gg. Fixed a problem that could cause readline to refer to freed memory when
|
||||
moving between history lines while doing searches.
|
||||
|
||||
hh. Improvements to the code that expands and displays prompt strings
|
||||
containing multibyte characters.
|
||||
|
||||
ii. Fixed a problem with vi-mode not correctly remembering the numeric argument
|
||||
to the last `c'hange command for later use with `.'.
|
||||
|
||||
jj. Fixed a bug in vi-mode that caused multi-digit count arguments to work
|
||||
incorrectly.
|
||||
|
||||
kk. Fixed a problem in vi-mode that caused the last text modification command
|
||||
to not be remembered across different command lines.
|
||||
|
||||
ll. Fixed problems with changing characters and changing case at the end of
|
||||
the line.
|
||||
|
||||
mm. Fixed a problem with readline saving the contents of the current line
|
||||
before beginning a non-interactive search.
|
||||
|
||||
nn. Fixed a problem with EOF detection when using rl_event_hook.
|
||||
|
||||
oo. Fixed a problem with the vi mode `p' and `P' commands ignoring numeric
|
||||
arguments.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. History expansion has a new `a' modifier equivalent to the `g' modifier
|
||||
for compatibility with the BSD csh.
|
||||
|
||||
b. History expansion has a new `G' modifier equivalent to the BSD csh `g'
|
||||
modifier, which performs a substitution once per word.
|
||||
|
||||
c. All non-incremental search operations may now undo the operation of
|
||||
replacing the current line with the history line.
|
||||
|
||||
d. The text inserted by an `a' command in vi mode can be reinserted with
|
||||
`.'.
|
||||
|
||||
e. New bindable variable, `show-all-if-unmodified'. If set, the readline
|
||||
completer will list possible completions immediately if there is more
|
||||
than one completion and partial completion cannot be performed.
|
||||
|
||||
f. There is a new application-callable `free_history_entry()' function.
|
||||
|
||||
g. History list entries now contain timestamp information; the history file
|
||||
functions know how to read and write timestamp information associated
|
||||
with each entry.
|
||||
|
||||
h. Four new key binding functions have been added:
|
||||
|
||||
rl_bind_key_if_unbound()
|
||||
rl_bind_key_if_unbound_in_map()
|
||||
rl_bind_keyseq_if_unbound()
|
||||
rl_bind_keyseq_if_unbound_in_map()
|
||||
|
||||
i. New application variable, rl_completion_quote_character, set to any
|
||||
quote character readline finds before it calls the application completion
|
||||
function.
|
||||
|
||||
j. New application variable, rl_completion_suppress_quote, settable by an
|
||||
application completion function. If set to non-zero, readline does not
|
||||
attempt to append a closing quote to a completed word.
|
||||
|
||||
k. New application variable, rl_completion_found_quote, set to a non-zero
|
||||
value if readline determines that the word to be completed is quoted.
|
||||
Set before readline calls any application completion function.
|
||||
|
||||
l. New function hook, rl_completion_word_break_hook, called when readline
|
||||
needs to break a line into words when completion is attempted. Allows
|
||||
the word break characters to vary based on position in the line.
|
||||
|
||||
m. New bindable command: unix-filename-rubout. Does the same thing as
|
||||
unix-word-rubout, but adds `/' to the set of word delimiters.
|
||||
|
||||
n. When listing completions, directories have a `/' appended if the
|
||||
`mark-directories' option has been enabled.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-4.3,
|
||||
and the previous version, readline-4.2a.
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
Basic Installation
|
||||
==================
|
||||
|
||||
These are installation instructions for Readline-4.3.
|
||||
These are installation instructions for Readline-5.1.
|
||||
|
||||
The simplest way to compile readline is:
|
||||
|
||||
|
@ -238,6 +238,9 @@ SHLIB_XLDFLAGS Additional flags to pass to SHOBJ_LD for shared library
|
|||
SHLIB_LIBS Any additional libraries that shared libraries should be
|
||||
linked against when they are created.
|
||||
|
||||
SHLIB_LIBPREF The prefix to use when generating the filename of the shared
|
||||
library. The default is `lib'; Cygwin uses `cyg'.
|
||||
|
||||
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'.
|
||||
|
@ -254,6 +257,17 @@ SHLIB_LIBVERSION The string to append to the filename to indicate the version
|
|||
numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
|
||||
Other Unix versions use different schemes.
|
||||
|
||||
SHLIB_DLLVERSION The version number for shared libraries that determines API
|
||||
compatibility between readline versions and the underlying
|
||||
system. Used only on Cygwin. Defaults to $SHLIB_MAJOR, but
|
||||
can be overridden at configuration time by defining DLLVERSION
|
||||
in the environment.
|
||||
|
||||
SHLIB_DOT The character used to separate the name of the shared library
|
||||
from the suffix and version information. The default is `.';
|
||||
systems like Cygwin which don't separate version information
|
||||
from the library name should set this to the empty string.
|
||||
|
||||
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
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#
|
||||
doc d
|
||||
examples d
|
||||
examples/rlfe d
|
||||
support d
|
||||
shlib d
|
||||
COPYING f
|
||||
|
@ -11,6 +12,7 @@ MANIFEST f
|
|||
INSTALL f
|
||||
CHANGELOG f
|
||||
CHANGES f
|
||||
NEWS f
|
||||
USAGE f
|
||||
aclocal.m4 f
|
||||
config.h.in f
|
||||
|
@ -74,23 +76,26 @@ histfile.c f
|
|||
histsearch.c f
|
||||
shlib/Makefile.in f
|
||||
support/config.guess f
|
||||
support/config.rpath f
|
||||
support/config.sub f
|
||||
support/install.sh f
|
||||
support/mkdirs f
|
||||
support/mkdist f
|
||||
support/mkinstalldirs 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
|
||||
doc/rlman.texinfo f
|
||||
doc/rltech.texinfo f
|
||||
doc/rluser.texinfo f
|
||||
doc/rluserman.texinfo f
|
||||
doc/hist.texinfo f
|
||||
doc/hstech.texinfo f
|
||||
doc/hsuser.texinfo f
|
||||
doc/version.texi f
|
||||
doc/fdl.texi f
|
||||
doc/rlman.texi f
|
||||
doc/rltech.texi f
|
||||
doc/rluser.texi f
|
||||
doc/rluserman.texi f
|
||||
doc/history.texi f
|
||||
doc/hstech.texi f
|
||||
doc/hsuser.texi f
|
||||
doc/readline.3 f
|
||||
doc/history.3 f
|
||||
doc/texi2dvi f
|
||||
|
@ -100,13 +105,25 @@ examples/excallback.c f
|
|||
examples/fileman.c f
|
||||
examples/manexamp.c f
|
||||
examples/readlinebuf.h f
|
||||
examples/rl-fgets.c f
|
||||
examples/rlcat.c f
|
||||
examples/rlfe.c f
|
||||
examples/rltest.c f
|
||||
examples/rl.c f
|
||||
examples/rlptytest.c f
|
||||
examples/rlversion.c f
|
||||
examples/histexamp.c f
|
||||
examples/Inputrc f
|
||||
examples/rlfe/ChangeLog f
|
||||
examples/rlfe/Makefile.in f
|
||||
examples/rlfe/README f
|
||||
examples/rlfe/config.h.in f
|
||||
examples/rlfe/configure f
|
||||
examples/rlfe/configure.in f
|
||||
examples/rlfe/extern.h f
|
||||
examples/rlfe/os.h f
|
||||
examples/rlfe/pty.c f
|
||||
examples/rlfe/rlfe.c f
|
||||
examples/rlfe/screen.h f
|
||||
# formatted documentation, from MANIFEST.doc
|
||||
doc/readline.ps f
|
||||
doc/history.ps f
|
||||
|
@ -124,3 +141,6 @@ doc/readline.0 f
|
|||
doc/history.0 f
|
||||
doc/readline_3.ps f
|
||||
doc/history_3.ps f
|
||||
doc/history.pdf f
|
||||
doc/readline.pdf f
|
||||
doc/rluserman.pdf f
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## -*- text -*- ##
|
||||
# Master Makefile for the GNU readline library.
|
||||
# Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2004 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
|
||||
|
@ -18,6 +18,14 @@
|
|||
RL_LIBRARY_VERSION = @LIBVERSION@
|
||||
RL_LIBRARY_NAME = readline
|
||||
|
||||
PACKAGE = @PACKAGE_NAME@
|
||||
VERSION = @PACKAGE_VERSION@
|
||||
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = .:@srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
|
@ -35,6 +43,8 @@ RM = rm -f
|
|||
CP = cp
|
||||
MV = mv
|
||||
|
||||
PURIFY = @PURIFY@
|
||||
|
||||
@SET_MAKE@
|
||||
SHELL = @MAKE_SHELL@
|
||||
|
||||
|
@ -45,6 +55,8 @@ bindir = @bindir@
|
|||
libdir = @libdir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
datadir = @datadir@
|
||||
localedir = $(datadir)/locale
|
||||
|
||||
infodir = @infodir@
|
||||
|
||||
|
@ -61,7 +73,7 @@ CFLAGS = @CFLAGS@
|
|||
LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
|
||||
DEFS = @DEFS@
|
||||
DEFS = @DEFS@ @CROSS_COMPILE@
|
||||
LOCAL_DEFS = @LOCAL_DEFS@
|
||||
|
||||
TERMCAP_LIB = @TERMCAP_LIB@
|
||||
|
@ -207,37 +219,41 @@ maybe-uninstall-headers: uninstall-headers
|
|||
|
||||
install: $(INSTALL_TARGETS)
|
||||
|
||||
install-static: installdirs $(STATIC_LIBS) install-headers
|
||||
install-static: installdirs $(STATIC_LIBS) install-headers install-doc
|
||||
-$(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
|
||||
|
||||
installdirs: $(srcdir)/support/mkinstalldirs
|
||||
-$(SHELL) $(srcdir)/support/mkinstalldirs $(DESTDIR)$(includedir) \
|
||||
$(DESTDIR)$(includedir)/readline $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(infodir) $(DESTDIR)$(man3dir)
|
||||
|
||||
uninstall: uninstall-headers uninstall-doc
|
||||
-test -n "$(DESTDIR)$(libdir)" && cd $(DESTDIR)$(libdir) && \
|
||||
${RM} libreadline.a libreadline.old libhistory.a libhistory.old $(SHARED_LIBS)
|
||||
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
|
||||
|
||||
install-shared: installdirs install-headers shared install-doc
|
||||
-( cd shlib ; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install )
|
||||
|
||||
uninstall-shared: maybe-uninstall-headers
|
||||
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
|
||||
|
||||
install-doc: installdirs
|
||||
-( if test -d doc ; then \
|
||||
cd doc && \
|
||||
${MAKE} ${MFLAGS} infodir=$(infodir) DESTDIR=${DESTDIR} install; \
|
||||
fi )
|
||||
|
||||
installdirs: $(srcdir)/support/mkdirs
|
||||
-$(SHELL) $(srcdir)/support/mkdirs $(DESTDIR)$(includedir) \
|
||||
$(DESTDIR)$(includedir)/readline $(DESTDIR)$(libdir) \
|
||||
$(DESTDIR)$(infodir) $(DESTDIR)$(man3dir)
|
||||
|
||||
uninstall: uninstall-headers
|
||||
-test -n "$(DESTDIR)$(libdir)" && cd $(DESTDIR)$(libdir) && \
|
||||
${RM} libreadline.a libreadline.old libhistory.a libhistory.old $(SHARED_LIBS)
|
||||
uninstall-doc:
|
||||
-( if test -d doc ; then \
|
||||
cd doc && \
|
||||
${MAKE} ${MFLAGS} infodir=$(infodir) DESTDIR=${DESTDIR} $@; \
|
||||
${MAKE} ${MFLAGS} infodir=$(infodir) DESTDIR=${DESTDIR} uninstall; \
|
||||
fi )
|
||||
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
|
||||
|
||||
install-shared: installdirs install-headers shared
|
||||
-( cd shlib ; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} install )
|
||||
|
||||
uninstall-shared: maybe-uninstall-headers
|
||||
-( cd shlib; ${MAKE} ${MFLAGS} DESTDIR=${DESTDIR} uninstall )
|
||||
|
||||
TAGS: force
|
||||
$(ETAGS) $(CSOURCES) $(HSOURCES)
|
||||
|
|
32
readline/NEWS
Normal file
32
readline/NEWS
Normal file
|
@ -0,0 +1,32 @@
|
|||
This is a terse description of the new features added to readline-5.1 since
|
||||
the release of readline-5.0.
|
||||
|
||||
1. New Features in Readline
|
||||
|
||||
a. The key sequence sent by the keypad `delete' key is now automatically
|
||||
bound to delete-char.
|
||||
|
||||
b. A negative argument to menu-complete now cycles backward through the
|
||||
completion list.
|
||||
|
||||
c. A new bindable readline variable: bind-tty-special-chars. If non-zero,
|
||||
readline will bind the terminal special characters to their readline
|
||||
equivalents when it's called (on by default).
|
||||
|
||||
d. New bindable command: vi-rubout. Saves deleted text for possible
|
||||
reinsertion, as with any vi-mode `text modification' command; `X' is bound
|
||||
to this in vi command mode.
|
||||
|
||||
e. If the rl_completion_query_items is set to a value < 0, readline never
|
||||
asks the user whether or not to view the possible completions.
|
||||
|
||||
f. New application-callable auxiliary function, rl_variable_value, returns
|
||||
a string corresponding to a readline variable's value.
|
||||
|
||||
g. When parsing inputrc files and variable binding commands, the parser
|
||||
strips trailing whitespace from values assigned to boolean variables
|
||||
before checking them.
|
||||
|
||||
h. A new external application-controllable variable that allows the LINES
|
||||
and COLUMNS environment variables to set the window size regardless of
|
||||
what the kernel returns.
|
|
@ -1,7 +1,7 @@
|
|||
Introduction
|
||||
============
|
||||
|
||||
This is the Gnu Readline library, version 4.3.
|
||||
This is the Gnu Readline library, version 5.1.
|
||||
|
||||
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
|
||||
|
@ -102,6 +102,9 @@ SHLIB_XLDFLAGS Additional flags to pass to SHOBJ_LD for shared library
|
|||
SHLIB_LIBS Any additional libraries that shared libraries should be
|
||||
linked against when they are created.
|
||||
|
||||
SHLIB_LIBPREF The prefix to use when generating the filename of the shared
|
||||
library. The default is `lib'; Cygwin uses `cyg'.
|
||||
|
||||
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'.
|
||||
|
@ -118,6 +121,17 @@ SHLIB_LIBVERSION The string to append to the filename to indicate the version
|
|||
numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
|
||||
Other Unix versions use different schemes.
|
||||
|
||||
SHLIB_DLLVERSION The version number for shared libraries that determines API
|
||||
compatibility between readline versions and the underlying
|
||||
system. Used only on Cygwin. Defaults to $SHLIB_MAJOR, but
|
||||
can be overridden at configuration time by defining DLLVERSION
|
||||
in the environment.
|
||||
|
||||
SHLIB_DOT The character used to separate the name of the shared library
|
||||
from the suffix and version information. The default is `.';
|
||||
systems like Cygwin which don't separate version information
|
||||
from the library name should set this to the empty string.
|
||||
|
||||
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.
|
||||
|
|
2309
readline/aclocal.m4
vendored
2309
readline/aclocal.m4
vendored
File diff suppressed because it is too large
Load diff
305
readline/bind.c
305
readline/bind.c
|
@ -1,6 +1,6 @@
|
|||
/* bind.c -- key binding and startup file support for the readline library. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
|
@ -19,8 +19,13 @@
|
|||
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 (__TANDEM)
|
||||
# include <floss.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
@ -72,6 +77,9 @@ 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 find_boolean_var PARAMS((const char *));
|
||||
|
||||
static char *_rl_get_string_variable_value PARAMS((const char *));
|
||||
static int substring_member_of_array PARAMS((char *, const char **));
|
||||
|
||||
static int currently_reading_init_file;
|
||||
|
@ -148,6 +156,34 @@ rl_bind_key_in_map (key, function, map)
|
|||
return (result);
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
int
|
||||
rl_bind_key_if_unbound_in_map (key, default_func, kmap)
|
||||
int key;
|
||||
rl_command_func_t *default_func;
|
||||
Keymap kmap;
|
||||
{
|
||||
char keyseq[2];
|
||||
|
||||
keyseq[0] = (unsigned char)key;
|
||||
keyseq[1] = '\0';
|
||||
return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, kmap));
|
||||
}
|
||||
|
||||
int
|
||||
rl_bind_key_if_unbound (key, default_func)
|
||||
int key;
|
||||
rl_command_func_t *default_func;
|
||||
{
|
||||
char keyseq[2];
|
||||
|
||||
keyseq[0] = (unsigned char)key;
|
||||
keyseq[1] = '\0';
|
||||
return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, _rl_keymap));
|
||||
}
|
||||
|
||||
/* Make KEY do nothing in the currently selected keymap.
|
||||
Returns non-zero in case of error. */
|
||||
int
|
||||
|
@ -199,10 +235,31 @@ rl_unbind_command_in_map (command, map)
|
|||
return (rl_unbind_function_in_map (func, map));
|
||||
}
|
||||
|
||||
/* Bind the key sequence represented by the string KEYSEQ to
|
||||
FUNCTION, starting in the current keymap. This makes new
|
||||
keymaps as necessary. */
|
||||
int
|
||||
rl_bind_keyseq (keyseq, function)
|
||||
const char *keyseq;
|
||||
rl_command_func_t *function;
|
||||
{
|
||||
return (rl_generic_bind (ISFUNC, keyseq, (char *)function, _rl_keymap));
|
||||
}
|
||||
|
||||
/* Bind the key sequence represented by the string KEYSEQ to
|
||||
FUNCTION. This makes new keymaps as necessary. The initial
|
||||
place to do bindings is in MAP. */
|
||||
int
|
||||
rl_bind_keyseq_in_map (keyseq, function, map)
|
||||
const char *keyseq;
|
||||
rl_command_func_t *function;
|
||||
Keymap map;
|
||||
{
|
||||
return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map));
|
||||
}
|
||||
|
||||
/* Backwards compatibility; equivalent to rl_bind_keyseq_in_map() */
|
||||
int
|
||||
rl_set_key (keyseq, function, map)
|
||||
const char *keyseq;
|
||||
rl_command_func_t *function;
|
||||
|
@ -211,6 +268,40 @@ rl_set_key (keyseq, function, map)
|
|||
return (rl_generic_bind (ISFUNC, keyseq, (char *)function, map));
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
int
|
||||
rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, kmap)
|
||||
const char *keyseq;
|
||||
rl_command_func_t *default_func;
|
||||
Keymap kmap;
|
||||
{
|
||||
rl_command_func_t *func;
|
||||
|
||||
if (keyseq)
|
||||
{
|
||||
func = rl_function_of_keyseq (keyseq, kmap, (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
|
||||
return (rl_bind_keyseq_in_map (keyseq, default_func, kmap));
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rl_bind_keyseq_if_unbound (keyseq, default_func)
|
||||
const char *keyseq;
|
||||
rl_command_func_t *default_func;
|
||||
{
|
||||
return (rl_bind_keyseq_if_unbound_in_map (keyseq, default_func, _rl_keymap));
|
||||
}
|
||||
|
||||
/* Bind the key sequence represented by the string KEYSEQ to
|
||||
the string of characters MACRO. This makes new keymaps as
|
||||
necessary. The initial place to do bindings is in MAP. */
|
||||
|
@ -253,7 +344,7 @@ rl_generic_bind (type, keyseq, data, map)
|
|||
k.function = 0;
|
||||
|
||||
/* If no keys to bind to, exit right away. */
|
||||
if (!keyseq || !*keyseq)
|
||||
if (keyseq == 0 || *keyseq == 0)
|
||||
{
|
||||
if (type == ISMACR)
|
||||
free (data);
|
||||
|
@ -281,7 +372,7 @@ rl_generic_bind (type, keyseq, data, map)
|
|||
if (ic < 0 || ic >= KEYMAP_SIZE)
|
||||
return -1;
|
||||
|
||||
if (_rl_convert_meta_chars_to_ascii && META_CHAR (ic))
|
||||
if (META_CHAR (ic) && _rl_convert_meta_chars_to_ascii)
|
||||
{
|
||||
ic = UNMETA (ic);
|
||||
if (map[ESC].type == ISKMAP)
|
||||
|
@ -311,7 +402,7 @@ rl_generic_bind (type, keyseq, data, map)
|
|||
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 */)
|
||||
if (k.function && ((k.type == ISFUNC && k.function != rl_do_lowercase_version) || k.type == ISMACR))
|
||||
{
|
||||
map[ANYOTHERKEY] = k;
|
||||
k.function = 0;
|
||||
|
@ -372,7 +463,14 @@ rl_translate_keyseq (seq, array, len)
|
|||
else if (c == 'M')
|
||||
{
|
||||
i++;
|
||||
array[l++] = ESC; /* ESC is meta-prefix */
|
||||
/* XXX - should obey convert-meta setting? */
|
||||
if (_rl_convert_meta_chars_to_ascii && _rl_keymap[ESC].type == ISKMAP)
|
||||
array[l++] = ESC; /* ESC is meta-prefix */
|
||||
else
|
||||
{
|
||||
i++;
|
||||
array[l++] = META (seq[i]);
|
||||
}
|
||||
}
|
||||
else if (c == 'C')
|
||||
{
|
||||
|
@ -912,9 +1010,15 @@ parser_else (args)
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Check the previous (n - 1) levels of the stack to make sure that
|
||||
we haven't previously turned off parsing. */
|
||||
for (i = 0; i < if_stack_depth - 1; i++)
|
||||
#else
|
||||
/* Check the previous (n) levels of the stack to make sure that
|
||||
we haven't previously turned off parsing. */
|
||||
for (i = 0; i < if_stack_depth; i++)
|
||||
#endif
|
||||
if (if_stack[i] == 1)
|
||||
return 0;
|
||||
|
||||
|
@ -1091,9 +1195,9 @@ rl_parse_and_bind (string)
|
|||
/* If this is a command to set a variable, then do that. */
|
||||
if (_rl_stricmp (string, "set") == 0)
|
||||
{
|
||||
char *var = string + i;
|
||||
char *value;
|
||||
char *var, *value, *e;
|
||||
|
||||
var = string + i;
|
||||
/* Make VAR point to start of variable name. */
|
||||
while (*var && whitespace (*var)) var++;
|
||||
|
||||
|
@ -1104,6 +1208,20 @@ rl_parse_and_bind (string)
|
|||
*value++ = '\0';
|
||||
while (*value && whitespace (*value)) value++;
|
||||
|
||||
/* Strip trailing whitespace from values to boolean variables. Temp
|
||||
fix until I get a real quoted-string parser here. */
|
||||
i = find_boolean_var (var);
|
||||
if (i >= 0)
|
||||
{
|
||||
/* remove trailing whitespace */
|
||||
e = value + strlen (value) - 1;
|
||||
while (e >= value && whitespace (*e))
|
||||
e--;
|
||||
e++; /* skip back to whitespace or EOS */
|
||||
if (*e && e >= value)
|
||||
*e = '\0';
|
||||
}
|
||||
|
||||
rl_variable_bind (var, value);
|
||||
return 0;
|
||||
}
|
||||
|
@ -1124,8 +1242,9 @@ rl_parse_and_bind (string)
|
|||
the quoted string delimiter, like the shell. */
|
||||
if (*funname == '\'' || *funname == '"')
|
||||
{
|
||||
int delimiter = string[i++], passc;
|
||||
int delimiter, passc;
|
||||
|
||||
delimiter = string[i++];
|
||||
for (passc = 0; c = string[i]; i++)
|
||||
{
|
||||
if (passc)
|
||||
|
@ -1161,7 +1280,7 @@ rl_parse_and_bind (string)
|
|||
}
|
||||
|
||||
/* If this is a new-style key-binding, then do the binding with
|
||||
rl_set_key (). Otherwise, let the older code deal with it. */
|
||||
rl_bind_keyseq (). Otherwise, let the older code deal with it. */
|
||||
if (*string == '"')
|
||||
{
|
||||
char *seq;
|
||||
|
@ -1200,7 +1319,7 @@ rl_parse_and_bind (string)
|
|||
rl_macro_bind (seq, &funname[1], _rl_keymap);
|
||||
}
|
||||
else
|
||||
rl_set_key (seq, rl_named_function (funname), _rl_keymap);
|
||||
rl_bind_keyseq (seq, rl_named_function (funname));
|
||||
|
||||
free (seq);
|
||||
return 0;
|
||||
|
@ -1261,6 +1380,7 @@ static struct {
|
|||
int *value;
|
||||
int flags;
|
||||
} boolean_varlist [] = {
|
||||
{ "bind-tty-special-chars", &_rl_bind_stty_chars, 0 },
|
||||
{ "blink-matching-paren", &rl_blink_matching_paren, V_SPECIAL },
|
||||
{ "byte-oriented", &rl_byte_oriented, 0 },
|
||||
{ "completion-ignore-case", &_rl_completion_case_fold, 0 },
|
||||
|
@ -1281,6 +1401,7 @@ static struct {
|
|||
{ "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 },
|
||||
{ "show-all-if-unmodified", &_rl_complete_show_unmodified, 0 },
|
||||
#if defined (VISIBLE_STATS)
|
||||
{ "visible-stats", &rl_visible_stats, 0 },
|
||||
#endif /* VISIBLE_STATS */
|
||||
|
@ -1373,13 +1494,34 @@ find_string_var (name)
|
|||
values result in 0 (false). */
|
||||
static int
|
||||
bool_to_int (value)
|
||||
char *value;
|
||||
const char *value;
|
||||
{
|
||||
return (value == 0 || *value == '\0' ||
|
||||
(_rl_stricmp (value, "on") == 0) ||
|
||||
(value[0] == '1' && value[1] == '\0'));
|
||||
}
|
||||
|
||||
char *
|
||||
rl_variable_value (name)
|
||||
const char *name;
|
||||
{
|
||||
register int i;
|
||||
int v;
|
||||
char *ret;
|
||||
|
||||
/* Check for simple variables first. */
|
||||
i = find_boolean_var (name);
|
||||
if (i >= 0)
|
||||
return (*boolean_varlist[i].value ? "on" : "off");
|
||||
|
||||
i = find_string_var (name);
|
||||
if (i >= 0)
|
||||
return (_rl_get_string_variable_value (string_varlist[i].name));
|
||||
|
||||
/* Unknown variable names return NULL. */
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rl_variable_bind (name, value)
|
||||
const char *name, *value;
|
||||
|
@ -1650,7 +1792,7 @@ rl_get_keymap_name_from_edit_mode ()
|
|||
/* Each of the following functions produces information about the
|
||||
state of keybindings and functions known to Readline. The info
|
||||
is always printed to rl_outstream, and in such a way that it can
|
||||
be read back in (i.e., passed to rl_parse_and_bind (). */
|
||||
be read back in (i.e., passed to rl_parse_and_bind ()). */
|
||||
|
||||
/* Print the names of functions known to Readline. */
|
||||
void
|
||||
|
@ -2022,12 +2164,68 @@ rl_dump_macros (count, key)
|
|||
return (0);
|
||||
}
|
||||
|
||||
static char *
|
||||
_rl_get_string_variable_value (name)
|
||||
const char *name;
|
||||
{
|
||||
static char numbuf[32];
|
||||
char *ret;
|
||||
int n;
|
||||
|
||||
if (_rl_stricmp (name, "bell-style") == 0)
|
||||
{
|
||||
switch (_rl_bell_preference)
|
||||
{
|
||||
case NO_BELL:
|
||||
return "none";
|
||||
case VISIBLE_BELL:
|
||||
return "visible";
|
||||
case AUDIBLE_BELL:
|
||||
default:
|
||||
return "audible";
|
||||
}
|
||||
}
|
||||
else if (_rl_stricmp (name, "comment-begin") == 0)
|
||||
return (_rl_comment_begin ? _rl_comment_begin : RL_COMMENT_BEGIN_DEFAULT);
|
||||
else if (_rl_stricmp (name, "completion-query-items") == 0)
|
||||
{
|
||||
sprintf (numbuf, "%d", rl_completion_query_items);
|
||||
return (numbuf);
|
||||
}
|
||||
else if (_rl_stricmp (name, "editing-mode") == 0)
|
||||
return (rl_get_keymap_name_from_edit_mode ());
|
||||
else if (_rl_stricmp (name, "isearch-terminators") == 0)
|
||||
{
|
||||
if (_rl_isearch_terminators == 0)
|
||||
return 0;
|
||||
ret = _rl_untranslate_macro_value (_rl_isearch_terminators);
|
||||
if (ret)
|
||||
{
|
||||
strncpy (numbuf, ret, sizeof (numbuf) - 1);
|
||||
free (ret);
|
||||
numbuf[sizeof(numbuf) - 1] = '\0';
|
||||
}
|
||||
else
|
||||
numbuf[0] = '\0';
|
||||
return numbuf;
|
||||
}
|
||||
else if (_rl_stricmp (name, "keymap") == 0)
|
||||
{
|
||||
ret = rl_get_keymap_name (_rl_keymap);
|
||||
if (ret == 0)
|
||||
ret = rl_get_keymap_name_from_edit_mode ();
|
||||
return (ret ? ret : "none");
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
rl_variable_dumper (print_readably)
|
||||
int print_readably;
|
||||
{
|
||||
int i;
|
||||
const char *kname;
|
||||
char *v;
|
||||
|
||||
for (i = 0; boolean_varlist[i].name; i++)
|
||||
{
|
||||
|
@ -2039,63 +2237,16 @@ rl_variable_dumper (print_readably)
|
|||
*boolean_varlist[i].value ? "on" : "off");
|
||||
}
|
||||
|
||||
/* bell-style */
|
||||
switch (_rl_bell_preference)
|
||||
for (i = 0; string_varlist[i].name; i++)
|
||||
{
|
||||
case NO_BELL:
|
||||
kname = "none"; break;
|
||||
case VISIBLE_BELL:
|
||||
kname = "visible"; break;
|
||||
case AUDIBLE_BELL:
|
||||
default:
|
||||
kname = "audible"; break;
|
||||
}
|
||||
if (print_readably)
|
||||
fprintf (rl_outstream, "set bell-style %s\n", kname);
|
||||
else
|
||||
fprintf (rl_outstream, "bell-style is set to `%s'\n", kname);
|
||||
|
||||
/* comment-begin */
|
||||
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 : RL_COMMENT_BEGIN_DEFAULT);
|
||||
|
||||
/* completion-query-items */
|
||||
if (print_readably)
|
||||
fprintf (rl_outstream, "set completion-query-items %d\n", rl_completion_query_items);
|
||||
else
|
||||
fprintf (rl_outstream, "completion-query-items is set to `%d'\n", rl_completion_query_items);
|
||||
|
||||
/* editing-mode */
|
||||
if (print_readably)
|
||||
fprintf (rl_outstream, "set editing-mode %s\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi");
|
||||
else
|
||||
fprintf (rl_outstream, "editing-mode is set to `%s'\n", (rl_editing_mode == emacs_mode) ? "emacs" : "vi");
|
||||
|
||||
/* isearch-terminators */
|
||||
if (_rl_isearch_terminators)
|
||||
{
|
||||
char *disp;
|
||||
|
||||
disp = _rl_untranslate_macro_value (_rl_isearch_terminators);
|
||||
|
||||
v = _rl_get_string_variable_value (string_varlist[i].name);
|
||||
if (v == 0) /* _rl_isearch_terminators can be NULL */
|
||||
continue;
|
||||
if (print_readably)
|
||||
fprintf (rl_outstream, "set isearch-terminators \"%s\"\n", disp);
|
||||
fprintf (rl_outstream, "set %s %s\n", string_varlist[i].name, v);
|
||||
else
|
||||
fprintf (rl_outstream, "isearch-terminators is set to \"%s\"\n", disp);
|
||||
|
||||
free (disp);
|
||||
fprintf (rl_outstream, "%s is set to `%s'\n", string_varlist[i].name, v);
|
||||
}
|
||||
|
||||
/* 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
|
||||
|
@ -2112,28 +2263,6 @@ rl_dump_variables (count, key)
|
|||
return (0);
|
||||
}
|
||||
|
||||
/* 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)
|
||||
const char *keyseq;
|
||||
rl_command_func_t *default_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);
|
||||
}
|
||||
}
|
||||
|
||||
/* Return non-zero if any members of ARRAY are a substring in STRING. */
|
||||
static int
|
||||
substring_member_of_array (string, array)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* callback.c -- functions to use readline as an X `callback' mechanism. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
|
@ -44,9 +44,14 @@
|
|||
#include "readline.h"
|
||||
#include "rlprivate.h"
|
||||
|
||||
/* Private data for callback registration functions. See comments in
|
||||
rl_callback_read_char for more details. */
|
||||
_rl_callback_func_t *_rl_callback_func = 0;
|
||||
_rl_callback_generic_arg *_rl_callback_data = 0;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Callback Readline Functions */
|
||||
/* Callback Readline Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
|
@ -72,7 +77,8 @@ _rl_callback_newline ()
|
|||
{
|
||||
in_handler = 1;
|
||||
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
if (rl_prep_term_function)
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_set_signals ();
|
||||
|
@ -89,6 +95,7 @@ rl_callback_handler_install (prompt, linefunc)
|
|||
rl_vcpfunc_t *linefunc;
|
||||
{
|
||||
rl_set_prompt (prompt);
|
||||
RL_SETSTATE (RL_STATE_CALLBACK);
|
||||
rl_linefunc = linefunc;
|
||||
_rl_callback_newline ();
|
||||
}
|
||||
|
@ -98,7 +105,8 @@ void
|
|||
rl_callback_read_char ()
|
||||
{
|
||||
char *line;
|
||||
int eof;
|
||||
int eof, jcode;
|
||||
static procenv_t olevel;
|
||||
|
||||
if (rl_linefunc == NULL)
|
||||
{
|
||||
|
@ -106,7 +114,79 @@ rl_callback_read_char ()
|
|||
abort ();
|
||||
}
|
||||
|
||||
eof = readline_internal_char ();
|
||||
memcpy ((void *)olevel, (void *)readline_top_level, sizeof (procenv_t));
|
||||
jcode = setjmp (readline_top_level);
|
||||
if (jcode)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
memcpy ((void *)readline_top_level, (void *)olevel, sizeof (procenv_t));
|
||||
return;
|
||||
}
|
||||
|
||||
if (RL_ISSTATE (RL_STATE_ISEARCH))
|
||||
{
|
||||
eof = _rl_isearch_callback (_rl_iscxt);
|
||||
if (eof == 0 && (RL_ISSTATE (RL_STATE_ISEARCH) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
|
||||
rl_callback_read_char ();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_NSEARCH))
|
||||
{
|
||||
eof = _rl_nsearch_callback (_rl_nscxt);
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_NUMERICARG))
|
||||
{
|
||||
eof = _rl_arg_callback (_rl_argcxt);
|
||||
if (eof == 0 && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0) && RL_ISSTATE (RL_STATE_INPUTPENDING))
|
||||
rl_callback_read_char ();
|
||||
/* XXX - this should handle _rl_last_command_was_kill better */
|
||||
else if (RL_ISSTATE (RL_STATE_NUMERICARG) == 0)
|
||||
_rl_internal_char_cleanup ();
|
||||
|
||||
return;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_MULTIKEY))
|
||||
{
|
||||
eof = _rl_dispatch_callback (_rl_kscxt); /* For now */
|
||||
while ((eof == -1 || eof == -2) && RL_ISSTATE (RL_STATE_MULTIKEY) && _rl_kscxt && (_rl_kscxt->flags & KSEQ_DISPATCHED))
|
||||
eof = _rl_dispatch_callback (_rl_kscxt);
|
||||
if (RL_ISSTATE (RL_STATE_MULTIKEY) == 0)
|
||||
{
|
||||
_rl_internal_char_cleanup ();
|
||||
_rl_want_redisplay = 1;
|
||||
}
|
||||
}
|
||||
else if (_rl_callback_func)
|
||||
{
|
||||
/* This allows functions that simply need to read an additional character
|
||||
(like quoted-insert) to register a function to be called when input is
|
||||
available. _rl_callback_data is simply a pointer to a struct that has
|
||||
the argument count originally passed to the registering function and
|
||||
space for any additional parameters. */
|
||||
eof = (*_rl_callback_func) (_rl_callback_data);
|
||||
/* If the function `deregisters' itself, make sure the data is cleaned
|
||||
up. */
|
||||
if (_rl_callback_func == 0)
|
||||
{
|
||||
if (_rl_callback_data)
|
||||
{
|
||||
_rl_callback_data_dispose (_rl_callback_data);
|
||||
_rl_callback_data = 0;
|
||||
}
|
||||
_rl_internal_char_cleanup ();
|
||||
}
|
||||
}
|
||||
else
|
||||
eof = readline_internal_char ();
|
||||
|
||||
if (rl_done == 0 && _rl_want_redisplay)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
}
|
||||
|
||||
/* We loop in case some function has pushed input back with rl_execute_next. */
|
||||
for (;;)
|
||||
|
@ -115,7 +195,8 @@ rl_callback_read_char ()
|
|||
{
|
||||
line = readline_internal_teardown (eof);
|
||||
|
||||
(*rl_deprep_term_function) ();
|
||||
if (rl_deprep_term_function)
|
||||
(*rl_deprep_term_function) ();
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_clear_signals ();
|
||||
#endif
|
||||
|
@ -131,10 +212,10 @@ rl_callback_read_char ()
|
|||
if (in_handler == 0 && rl_linefunc)
|
||||
_rl_callback_newline ();
|
||||
}
|
||||
if (rl_pending_input)
|
||||
if (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT))
|
||||
eof = readline_internal_char ();
|
||||
else
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,14 +224,37 @@ void
|
|||
rl_callback_handler_remove ()
|
||||
{
|
||||
rl_linefunc = NULL;
|
||||
RL_UNSETSTATE (RL_STATE_CALLBACK);
|
||||
if (in_handler)
|
||||
{
|
||||
in_handler = 0;
|
||||
(*rl_deprep_term_function) ();
|
||||
if (rl_deprep_term_function)
|
||||
(*rl_deprep_term_function) ();
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_clear_signals ();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
_rl_callback_generic_arg *
|
||||
_rl_callback_data_alloc (count)
|
||||
int count;
|
||||
{
|
||||
_rl_callback_generic_arg *arg;
|
||||
|
||||
arg = (_rl_callback_generic_arg *)xmalloc (sizeof (_rl_callback_generic_arg));
|
||||
arg->count = count;
|
||||
|
||||
arg->i1 = arg->i2 = 0;
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
void _rl_callback_data_dispose (arg)
|
||||
_rl_callback_generic_arg *arg;
|
||||
{
|
||||
if (arg)
|
||||
free (arg);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -77,11 +77,17 @@
|
|||
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
|
||||
#endif
|
||||
|
||||
#define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
|
||||
#if defined (CTYPE_NON_ASCII)
|
||||
# define NON_NEGATIVE(c) 1
|
||||
#else
|
||||
# define NON_NEGATIVE(c) ((unsigned char)(c) == (c))
|
||||
#endif
|
||||
|
||||
/* Some systems define these; we want our definitions. */
|
||||
#undef ISPRINT
|
||||
|
||||
/* Beware: these only work with single-byte ASCII characters. */
|
||||
|
||||
#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))
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* complete.c -- filename completion for readline. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
|
@ -28,7 +28,7 @@
|
|||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#if defined (HAVE_SYS_FILE_H)
|
||||
#include <sys/file.h>
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
|
@ -48,7 +48,9 @@
|
|||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
#if defined (HAVE_PWD_H)
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include "posixdir.h"
|
||||
#include "posixstat.h"
|
||||
|
@ -79,9 +81,9 @@ typedef int QSFUNC ();
|
|||
|
||||
/* Most systems don't declare getpwent in <pwd.h> if _POSIX_SOURCE is
|
||||
defined. */
|
||||
#if !defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE)
|
||||
#if defined (HAVE_GETPWENT) && (!defined (HAVE_GETPW_DECLS) || defined (_POSIX_SOURCE))
|
||||
extern struct passwd *getpwent PARAMS((void));
|
||||
#endif /* !HAVE_GETPW_DECLS || _POSIX_SOURCE */
|
||||
#endif /* HAVE_GETPWENT && (!HAVE_GETPW_DECLS || _POSIX_SOURCE) */
|
||||
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing a word would normally display the list of possible matches.
|
||||
|
@ -99,12 +101,16 @@ rl_compdisp_func_t *rl_completion_display_matches_hook = (rl_compdisp_func_t *)N
|
|||
static int stat_char PARAMS((char *));
|
||||
#endif
|
||||
|
||||
static int path_isdir PARAMS((const char *));
|
||||
|
||||
static char *rl_quote_filename PARAMS((char *, int, char *));
|
||||
|
||||
static void set_completion_defaults PARAMS((int));
|
||||
static int get_y_or_n PARAMS((int));
|
||||
static int _rl_internal_pager PARAMS((int));
|
||||
static char *printable_part PARAMS((char *));
|
||||
static int fnwidth PARAMS((const char *));
|
||||
static int fnprint PARAMS((const char *));
|
||||
static int print_filename PARAMS((char *, char *));
|
||||
|
||||
static char **gen_completion_matches PARAMS((char *, int, int, rl_compentry_func_t *, int, int));
|
||||
|
@ -130,6 +136,10 @@ static char *make_quoted_replacement PARAMS((char *, int, char *));
|
|||
/* If non-zero, non-unique completions always show the list of matches. */
|
||||
int _rl_complete_show_all = 0;
|
||||
|
||||
/* If non-zero, non-unique completions show the list of matches, unless it
|
||||
is not possible to do partial completion and modify the line. */
|
||||
int _rl_complete_show_unmodified = 0;
|
||||
|
||||
/* If non-zero, completed directory names have a slash appended. */
|
||||
int _rl_complete_mark_directories = 1;
|
||||
|
||||
|
@ -198,7 +208,8 @@ int rl_completion_type = 0;
|
|||
|
||||
/* 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. */
|
||||
she is sure she wants to see them all. A negative value means
|
||||
don't ask. */
|
||||
int rl_completion_query_items = 100;
|
||||
|
||||
int _rl_page_completions = 1;
|
||||
|
@ -214,7 +225,12 @@ const char *rl_basic_quote_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. */
|
||||
const char *rl_completer_word_break_characters = (const char *)NULL;
|
||||
/*const*/ char *rl_completer_word_break_characters = (/*const*/ char *)NULL;
|
||||
|
||||
/* Hook function to allow an application to set the completion word
|
||||
break characters before readline breaks up the line. Allows
|
||||
position-dependent word break characters. */
|
||||
rl_cpvfunc_t *rl_completion_word_break_hook = (rl_cpvfunc_t *)NULL;
|
||||
|
||||
/* List of characters which can be used to quote a substring of the line.
|
||||
Completion occurs on the entire substring, and within the substring
|
||||
|
@ -282,6 +298,19 @@ int rl_completion_suppress_append = 0;
|
|||
default is a space. */
|
||||
int rl_completion_append_character = ' ';
|
||||
|
||||
/* If non-zero, the completion functions don't append any closing quote.
|
||||
This is set to 0 by rl_complete_internal and may be changed by an
|
||||
application-specific completion function. */
|
||||
int rl_completion_suppress_quote = 0;
|
||||
|
||||
/* Set to any quote character readline thinks it finds before any application
|
||||
completion function is called. */
|
||||
int rl_completion_quote_character;
|
||||
|
||||
/* Set to a non-zero value if readline found quoting anywhere in the word to
|
||||
be completed; set before any application completion function is called. */
|
||||
int rl_completion_found_quote;
|
||||
|
||||
/* 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
|
||||
|
@ -320,6 +349,8 @@ rl_complete (ignore, invoking_key)
|
|||
return (rl_complete_internal ('?'));
|
||||
else if (_rl_complete_show_all)
|
||||
return (rl_complete_internal ('!'));
|
||||
else if (_rl_complete_show_unmodified)
|
||||
return (rl_complete_internal ('@'));
|
||||
else
|
||||
return (rl_complete_internal (TAB));
|
||||
}
|
||||
|
@ -352,6 +383,8 @@ rl_completion_mode (cfunc)
|
|||
return '?';
|
||||
else if (_rl_complete_show_all)
|
||||
return '!';
|
||||
else if (_rl_complete_show_unmodified)
|
||||
return '@';
|
||||
else
|
||||
return TAB;
|
||||
}
|
||||
|
@ -372,7 +405,7 @@ set_completion_defaults (what_to_do)
|
|||
rl_filename_completion_desired = 0;
|
||||
rl_filename_quoting_desired = 1;
|
||||
rl_completion_type = what_to_do;
|
||||
rl_completion_suppress_append = 0;
|
||||
rl_completion_suppress_append = rl_completion_suppress_quote = 0;
|
||||
|
||||
/* The completion entry function may optionally change this. */
|
||||
rl_completion_mark_symlink_dirs = _rl_complete_mark_symlink_dirs;
|
||||
|
@ -423,6 +456,15 @@ _rl_internal_pager (lines)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
path_isdir (filename)
|
||||
const char *filename;
|
||||
{
|
||||
struct stat finfo;
|
||||
|
||||
return (stat (filename, &finfo) == 0 && S_ISDIR (finfo.st_mode));
|
||||
}
|
||||
|
||||
#if defined (VISIBLE_STATS)
|
||||
/* Return the character which best describes FILENAME.
|
||||
`@' for symbolic links
|
||||
|
@ -520,53 +562,149 @@ printable_part (pathname)
|
|||
return ++temp;
|
||||
}
|
||||
|
||||
/* Compute width of STRING when displayed on screen by print_filename */
|
||||
static int
|
||||
fnwidth (string)
|
||||
const char *string;
|
||||
{
|
||||
int width, pos;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
mbstate_t ps;
|
||||
int left, w;
|
||||
size_t clen;
|
||||
wchar_t wc;
|
||||
|
||||
left = strlen (string) + 1;
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
#endif
|
||||
|
||||
width = pos = 0;
|
||||
while (string[pos])
|
||||
{
|
||||
if (CTRL_CHAR (*string) || *string == RUBOUT)
|
||||
{
|
||||
width += 2;
|
||||
pos++;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
clen = mbrtowc (&wc, string + pos, left - pos, &ps);
|
||||
if (MB_INVALIDCH (clen))
|
||||
{
|
||||
width++;
|
||||
pos++;
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
}
|
||||
else if (MB_NULLWCH (clen))
|
||||
break;
|
||||
else
|
||||
{
|
||||
pos += clen;
|
||||
w = wcwidth (wc);
|
||||
width += (w >= 0) ? w : 1;
|
||||
}
|
||||
#else
|
||||
width++;
|
||||
pos++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return width;
|
||||
}
|
||||
|
||||
static int
|
||||
fnprint (to_print)
|
||||
const char *to_print;
|
||||
{
|
||||
int printed_len;
|
||||
const char *s;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
mbstate_t ps;
|
||||
const char *end;
|
||||
size_t tlen;
|
||||
int width, w;
|
||||
wchar_t wc;
|
||||
|
||||
end = to_print + strlen (to_print) + 1;
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
#endif
|
||||
|
||||
printed_len = 0;
|
||||
s = to_print;
|
||||
while (*s)
|
||||
{
|
||||
if (CTRL_CHAR (*s))
|
||||
{
|
||||
putc ('^', rl_outstream);
|
||||
putc (UNCTRL (*s), rl_outstream);
|
||||
printed_len += 2;
|
||||
s++;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
#endif
|
||||
}
|
||||
else if (*s == RUBOUT)
|
||||
{
|
||||
putc ('^', rl_outstream);
|
||||
putc ('?', rl_outstream);
|
||||
printed_len += 2;
|
||||
s++;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
tlen = mbrtowc (&wc, s, end - s, &ps);
|
||||
if (MB_INVALIDCH (tlen))
|
||||
{
|
||||
tlen = 1;
|
||||
width = 1;
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
}
|
||||
else if (MB_NULLWCH (tlen))
|
||||
break;
|
||||
else
|
||||
{
|
||||
w = wcwidth (wc);
|
||||
width = (w >= 0) ? w : 1;
|
||||
}
|
||||
fwrite (s, 1, tlen, rl_outstream);
|
||||
s += tlen;
|
||||
printed_len += width;
|
||||
#else
|
||||
putc (*s, rl_outstream);
|
||||
s++;
|
||||
printed_len++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return printed_len;
|
||||
}
|
||||
|
||||
/* Output TO_PRINT to rl_outstream. If VISIBLE_STATS is defined and we
|
||||
are using it, check for and output a single character for `special'
|
||||
filenames. Return the number of characters we output. */
|
||||
|
||||
#define PUTX(c) \
|
||||
do { \
|
||||
if (CTRL_CHAR (c)) \
|
||||
{ \
|
||||
putc ('^', rl_outstream); \
|
||||
putc (UNCTRL (c), rl_outstream); \
|
||||
printed_len += 2; \
|
||||
} \
|
||||
else if (c == RUBOUT) \
|
||||
{ \
|
||||
putc ('^', rl_outstream); \
|
||||
putc ('?', rl_outstream); \
|
||||
printed_len += 2; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
putc (c, rl_outstream); \
|
||||
printed_len++; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static int
|
||||
print_filename (to_print, full_pathname)
|
||||
char *to_print, *full_pathname;
|
||||
{
|
||||
int printed_len = 0;
|
||||
#if !defined (VISIBLE_STATS)
|
||||
char *s;
|
||||
int printed_len, extension_char, slen, tlen;
|
||||
char *s, c, *new_full_pathname, *dn;
|
||||
|
||||
for (s = to_print; *s; s++)
|
||||
{
|
||||
PUTX (*s);
|
||||
}
|
||||
#else
|
||||
char *s, c, *new_full_pathname;
|
||||
int extension_char, slen, tlen;
|
||||
extension_char = 0;
|
||||
printed_len = fnprint (to_print);
|
||||
|
||||
for (s = to_print; *s; s++)
|
||||
{
|
||||
PUTX (*s);
|
||||
}
|
||||
|
||||
if (rl_filename_completion_desired && rl_visible_stats)
|
||||
#if defined (VISIBLE_STATS)
|
||||
if (rl_filename_completion_desired && (rl_visible_stats || _rl_complete_mark_directories))
|
||||
#else
|
||||
if (rl_filename_completion_desired && _rl_complete_mark_directories)
|
||||
#endif
|
||||
{
|
||||
/* If to_print != full_pathname, to_print is the basename of the
|
||||
path passed. In this case, we try to expand the directory
|
||||
|
@ -582,7 +720,17 @@ print_filename (to_print, full_pathname)
|
|||
files in the root directory. If we pass a null string to the
|
||||
bash directory completion hook, for example, it will expand it
|
||||
to the current directory. We just want the `/'. */
|
||||
s = tilde_expand (full_pathname && *full_pathname ? full_pathname : "/");
|
||||
if (full_pathname == 0 || *full_pathname == 0)
|
||||
dn = "/";
|
||||
else if (full_pathname[0] != '/')
|
||||
dn = full_pathname;
|
||||
else if (full_pathname[1] == 0)
|
||||
dn = "//"; /* restore trailing slash to `//' */
|
||||
else if (full_pathname[1] == '/' && full_pathname[2] == 0)
|
||||
dn = "/"; /* don't turn /// into // */
|
||||
else
|
||||
dn = full_pathname;
|
||||
s = tilde_expand (dn);
|
||||
if (rl_directory_completion_hook)
|
||||
(*rl_directory_completion_hook) (&s);
|
||||
|
||||
|
@ -590,10 +738,20 @@ print_filename (to_print, full_pathname)
|
|||
tlen = strlen (to_print);
|
||||
new_full_pathname = (char *)xmalloc (slen + tlen + 2);
|
||||
strcpy (new_full_pathname, s);
|
||||
if (s[slen - 1] == '/')
|
||||
slen--;
|
||||
else
|
||||
new_full_pathname[slen] = '/';
|
||||
new_full_pathname[slen] = '/';
|
||||
strcpy (new_full_pathname + slen + 1, to_print);
|
||||
|
||||
extension_char = stat_char (new_full_pathname);
|
||||
#if defined (VISIBLE_STATS)
|
||||
if (rl_visible_stats)
|
||||
extension_char = stat_char (new_full_pathname);
|
||||
else
|
||||
#endif
|
||||
if (path_isdir (new_full_pathname))
|
||||
extension_char = '/';
|
||||
|
||||
free (new_full_pathname);
|
||||
to_print[-1] = c;
|
||||
|
@ -601,7 +759,13 @@ print_filename (to_print, full_pathname)
|
|||
else
|
||||
{
|
||||
s = tilde_expand (full_pathname);
|
||||
extension_char = stat_char (s);
|
||||
#if defined (VISIBLE_STATS)
|
||||
if (rl_visible_stats)
|
||||
extension_char = stat_char (s);
|
||||
else
|
||||
#endif
|
||||
if (path_isdir (s))
|
||||
extension_char = '/';
|
||||
}
|
||||
|
||||
free (s);
|
||||
|
@ -611,7 +775,7 @@ print_filename (to_print, full_pathname)
|
|||
printed_len++;
|
||||
}
|
||||
}
|
||||
#endif /* VISIBLE_STATS */
|
||||
|
||||
return printed_len;
|
||||
}
|
||||
|
||||
|
@ -651,19 +815,25 @@ _rl_find_completion_word (fp, dp)
|
|||
int *fp, *dp;
|
||||
{
|
||||
int scan, end, found_quote, delimiter, pass_next, isbrk;
|
||||
char quote_char;
|
||||
char quote_char, *brkchars;
|
||||
|
||||
end = rl_point;
|
||||
found_quote = delimiter = 0;
|
||||
quote_char = '\0';
|
||||
|
||||
brkchars = 0;
|
||||
if (rl_completion_word_break_hook)
|
||||
brkchars = (*rl_completion_word_break_hook) ();
|
||||
if (brkchars == 0)
|
||||
brkchars = rl_completer_word_break_characters;
|
||||
|
||||
if (rl_completer_quote_characters)
|
||||
{
|
||||
/* We have a list of characters which can be used in pairs to
|
||||
quote substrings for the completer. Try to find the start
|
||||
of an unclosed quoted substring. */
|
||||
/* FOUND_QUOTE is set so we know what kind of quotes we found. */
|
||||
for (scan = pass_next = 0; scan < end; scan++)
|
||||
for (scan = pass_next = 0; scan < end; scan = MB_NEXTCHAR (rl_line_buffer, scan, 1, MB_FIND_ANY))
|
||||
{
|
||||
if (pass_next)
|
||||
{
|
||||
|
@ -713,15 +883,11 @@ _rl_find_completion_word (fp, dp)
|
|||
/* We didn't find an unclosed quoted substring upon which to do
|
||||
completion, so use the word break characters to find the
|
||||
substring on which to complete. */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
while (rl_point = _rl_find_prev_mbchar (rl_line_buffer, rl_point, MB_FIND_ANY))
|
||||
#else
|
||||
while (--rl_point)
|
||||
#endif
|
||||
while (rl_point = MB_PREVCHAR (rl_line_buffer, rl_point, MB_FIND_ANY))
|
||||
{
|
||||
scan = rl_line_buffer[rl_point];
|
||||
|
||||
if (strchr (rl_completer_word_break_characters, scan) == 0)
|
||||
if (strchr (brkchars, scan) == 0)
|
||||
continue;
|
||||
|
||||
/* Call the application-specific function to tell us whether
|
||||
|
@ -749,9 +915,9 @@ _rl_find_completion_word (fp, dp)
|
|||
if (rl_char_is_quoted_p)
|
||||
isbrk = (found_quote == 0 ||
|
||||
(*rl_char_is_quoted_p) (rl_line_buffer, rl_point) == 0) &&
|
||||
strchr (rl_completer_word_break_characters, scan) != 0;
|
||||
strchr (brkchars, scan) != 0;
|
||||
else
|
||||
isbrk = strchr (rl_completer_word_break_characters, scan) != 0;
|
||||
isbrk = strchr (brkchars, scan) != 0;
|
||||
|
||||
if (isbrk)
|
||||
{
|
||||
|
@ -786,6 +952,9 @@ gen_completion_matches (text, start, end, our_func, found_quote, quote_char)
|
|||
{
|
||||
char **matches, *temp;
|
||||
|
||||
rl_completion_found_quote = found_quote;
|
||||
rl_completion_quote_character = quote_char;
|
||||
|
||||
/* If the user wants to TRY to complete, but then wants to give
|
||||
up and use the default completion function, they set the
|
||||
variable rl_attempted_completion_function. */
|
||||
|
@ -889,6 +1058,7 @@ compute_lcd_of_matches (match_list, matches, text)
|
|||
{
|
||||
register int i, c1, c2, si;
|
||||
int low; /* Count of max-matched characters. */
|
||||
char *dtext; /* dequoted TEXT, if needed */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
int v;
|
||||
mbstate_t ps1, ps2;
|
||||
|
@ -980,6 +1150,26 @@ compute_lcd_of_matches (match_list, matches, text)
|
|||
the user typed in the face of multiple matches differing in case. */
|
||||
if (_rl_completion_case_fold)
|
||||
{
|
||||
/* We're making an assumption here:
|
||||
IF we're completing filenames AND
|
||||
the application has defined a filename dequoting function AND
|
||||
we found a quote character AND
|
||||
the application has requested filename quoting
|
||||
THEN
|
||||
we assume that TEXT was dequoted before checking against
|
||||
the file system and needs to be dequoted here before we
|
||||
check against the list of matches
|
||||
FI */
|
||||
dtext = (char *)NULL;
|
||||
if (rl_filename_completion_desired &&
|
||||
rl_filename_dequoting_function &&
|
||||
rl_completion_found_quote &&
|
||||
rl_filename_quoting_desired)
|
||||
{
|
||||
dtext = (*rl_filename_dequoting_function) ((char *)text, rl_completion_quote_character);
|
||||
text = dtext;
|
||||
}
|
||||
|
||||
/* sort the list to get consistent answers. */
|
||||
qsort (match_list+1, matches, sizeof(char *), (QSFUNC *)_rl_qsort_string_compare);
|
||||
|
||||
|
@ -999,6 +1189,8 @@ compute_lcd_of_matches (match_list, matches, text)
|
|||
else
|
||||
/* otherwise, just use the text the user typed. */
|
||||
strncpy (match_list[0], text, low);
|
||||
|
||||
FREE (dtext);
|
||||
}
|
||||
else
|
||||
strncpy (match_list[0], match_list[1], low);
|
||||
|
@ -1203,7 +1395,7 @@ display_matches (matches)
|
|||
for (max = 0, i = 1; matches[i]; i++)
|
||||
{
|
||||
temp = printable_part (matches[i]);
|
||||
len = strlen (temp);
|
||||
len = fnwidth (temp);
|
||||
|
||||
if (len > max)
|
||||
max = len;
|
||||
|
@ -1220,7 +1412,7 @@ display_matches (matches)
|
|||
|
||||
/* If there are many items, then ask the user if she really wants to
|
||||
see them all. */
|
||||
if (len >= rl_completion_query_items)
|
||||
if (rl_completion_query_items > 0 && len >= rl_completion_query_items)
|
||||
{
|
||||
rl_crlf ();
|
||||
fprintf (rl_outstream, "Display all %d possibilities? (y or n)", len);
|
||||
|
@ -1338,7 +1530,8 @@ append_to_match (text, delimiter, quote_char, nontrivial_match)
|
|||
struct stat finfo;
|
||||
|
||||
temp_string_index = 0;
|
||||
if (quote_char && rl_point && rl_line_buffer[rl_point - 1] != quote_char)
|
||||
if (quote_char && rl_point && rl_completion_suppress_quote == 0 &&
|
||||
rl_line_buffer[rl_point - 1] != quote_char)
|
||||
temp_string[temp_string_index++] = quote_char;
|
||||
|
||||
if (delimiter)
|
||||
|
@ -1356,7 +1549,7 @@ append_to_match (text, delimiter, quote_char, nontrivial_match)
|
|||
: stat (filename, &finfo);
|
||||
if (s == 0 && S_ISDIR (finfo.st_mode))
|
||||
{
|
||||
if (_rl_complete_mark_directories)
|
||||
if (_rl_complete_mark_directories /* && rl_completion_suppress_append == 0 */)
|
||||
{
|
||||
/* This is clumsy. Avoid putting in a double slash if point
|
||||
is at the end of the line and the previous character is a
|
||||
|
@ -1449,7 +1642,9 @@ _rl_free_match_list (matches)
|
|||
TAB means do standard completion.
|
||||
`*' means insert all of the possible completions.
|
||||
`!' means to do standard completion, and list all possible completions if
|
||||
there is more than one. */
|
||||
there is more than one.
|
||||
`@' means to do standard completion, and list all possible completions if
|
||||
there is more than one and partial completion is not possible. */
|
||||
int
|
||||
rl_complete_internal (what_to_do)
|
||||
int what_to_do;
|
||||
|
@ -1468,7 +1663,6 @@ rl_complete_internal (what_to_do)
|
|||
our_func = rl_completion_entry_function
|
||||
? rl_completion_entry_function
|
||||
: rl_filename_completion_function;
|
||||
|
||||
/* We now look backwards for the start of a filename/variable word. */
|
||||
end = rl_point;
|
||||
found_quote = delimiter = 0;
|
||||
|
@ -1516,6 +1710,7 @@ rl_complete_internal (what_to_do)
|
|||
{
|
||||
case TAB:
|
||||
case '!':
|
||||
case '@':
|
||||
/* Insert the first match with proper quoting. */
|
||||
if (*matches[0])
|
||||
insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char);
|
||||
|
@ -1535,6 +1730,12 @@ rl_complete_internal (what_to_do)
|
|||
display_matches (matches);
|
||||
break;
|
||||
}
|
||||
else if (what_to_do == '@')
|
||||
{
|
||||
if (nontrivial_lcd == 0)
|
||||
display_matches (matches);
|
||||
break;
|
||||
}
|
||||
else if (rl_editing_mode != vi_mode)
|
||||
rl_ding (); /* There are other matches remaining. */
|
||||
}
|
||||
|
@ -1662,16 +1863,20 @@ rl_username_completion_function (text, state)
|
|||
setpwent ();
|
||||
}
|
||||
|
||||
#if defined (HAVE_GETPWENT)
|
||||
while (entry = getpwent ())
|
||||
{
|
||||
/* Null usernames should result in all users as possible completions. */
|
||||
if (namelen == 0 || (STREQN (username, entry->pw_name, namelen)))
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (entry == 0)
|
||||
{
|
||||
#if defined (HAVE_GETPWENT)
|
||||
endpwent ();
|
||||
#endif
|
||||
return ((char *)NULL);
|
||||
}
|
||||
else
|
||||
|
@ -1983,9 +2188,11 @@ rl_menu_complete (count, ignore)
|
|||
return (0);
|
||||
}
|
||||
|
||||
match_list_index = (match_list_index + count) % match_list_size;
|
||||
match_list_index += count;
|
||||
if (match_list_index < 0)
|
||||
match_list_index += match_list_size;
|
||||
else
|
||||
match_list_index %= match_list_size;
|
||||
|
||||
if (match_list_index == 0 && match_list_size > 1)
|
||||
{
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
/* config.h.in. Maintained by hand. */
|
||||
|
||||
/* Define NO_MULTIBYTE_SUPPORT to not compile in support for multibyte
|
||||
characters, even if the OS supports them. */
|
||||
#undef NO_MULTIBYTE_SUPPORT
|
||||
|
||||
/* Define if on MINIX. */
|
||||
#undef _MINIX
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
#undef VOID_SIGHANDLER
|
||||
|
||||
/* Characteristics of the compiler. */
|
||||
#undef const
|
||||
|
||||
|
@ -20,7 +26,17 @@
|
|||
/* 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 fcntl function. */
|
||||
#undef HAVE_FCNTL
|
||||
|
||||
/* Define if you have the getpwent function. */
|
||||
#undef HAVE_GETPWENT
|
||||
|
||||
/* Define if you have the getpwnam function. */
|
||||
#undef HAVE_GETPWNAM
|
||||
|
||||
/* Define if you have the getpwuid function. */
|
||||
#undef HAVE_GETPWUID
|
||||
|
||||
/* Define if you have the isascii function. */
|
||||
#undef HAVE_ISASCII
|
||||
|
@ -28,9 +44,18 @@
|
|||
/* Define if you have the isxdigit function. */
|
||||
#undef HAVE_ISXDIGIT
|
||||
|
||||
/* Define if you have the kill function. */
|
||||
#undef HAVE_KILL
|
||||
|
||||
/* Define if you have the lstat function. */
|
||||
#undef HAVE_LSTAT
|
||||
|
||||
/* Define if you have the mbrlen function. */
|
||||
#undef HAVE_MBRLEN
|
||||
|
||||
/* Define if you have the mbrtowc function. */
|
||||
#undef HAVE_MBRTOWC
|
||||
|
||||
/* Define if you have the mbsrtowcs function. */
|
||||
#undef HAVE_MBSRTOWCS
|
||||
|
||||
|
@ -66,12 +91,20 @@
|
|||
/* Define if you have the vsnprintf function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/* Define if you have the wctomb function. */
|
||||
#undef HAVE_WCTOMB
|
||||
|
||||
/* Define if you have the wcwidth function. */
|
||||
#undef HAVE_WCWIDTH
|
||||
|
||||
#undef STDC_HEADERS
|
||||
|
||||
/* Define if you have the <dirent.h> header file. */
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
#undef HAVE_FCNTL_H
|
||||
|
||||
/* Define if you have the <langinfo.h> header file. */
|
||||
#undef HAVE_LANGINFO_H
|
||||
|
||||
|
@ -87,6 +120,9 @@
|
|||
/* Define if you have the <ndir.h> header file. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define if you have the <pwd.h> header file. */
|
||||
#undef HAVE_PWD_H
|
||||
|
||||
/* Define if you have the <stdarg.h> header file. */
|
||||
#undef HAVE_STDARG_H
|
||||
|
||||
|
@ -177,6 +213,8 @@
|
|||
|
||||
#undef HAVE_POSIX_SIGSETJMP
|
||||
|
||||
#undef CTYPE_NON_ASCII
|
||||
|
||||
/* modify settings or make new ones based on what autoconf tells us. */
|
||||
|
||||
/* Ultrix botches type-ahead when switching from canonical to
|
||||
|
|
7668
readline/configure
vendored
7668
readline/configure
vendored
File diff suppressed because it is too large
Load diff
|
@ -4,9 +4,27 @@ 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.3, version 2.45, from autoconf version] AC_ACVERSION)
|
||||
|
||||
AC_INIT(readline, 4.3, bug-readline@gnu.org)
|
||||
# Copyright (C) 1987-2005 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-1307, USA.
|
||||
|
||||
AC_REVISION([for Readline 5.1, version 2.59])
|
||||
|
||||
AC_INIT(readline, 5.1-release, bug-readline@gnu.org)
|
||||
|
||||
dnl make sure we are using a recent autoconf version
|
||||
AC_PREREQ(2.50)
|
||||
|
@ -16,27 +34,70 @@ 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
|
||||
LIBVERSION=5.1
|
||||
|
||||
AC_CANONICAL_HOST
|
||||
|
||||
dnl configure defaults
|
||||
opt_curses=no
|
||||
opt_purify=no
|
||||
|
||||
dnl arguments to configure
|
||||
AC_ARG_WITH(curses, AC_HELP_STRING([--with-curses], [use the curses library instead of the termcap library]), opt_curses=$withval)
|
||||
AC_ARG_WITH(purify, AC_HELP_STRING([--with-purify], [configure to postprocess with purify]), opt_purify=$withval)
|
||||
|
||||
if test "$opt_curses" = "yes"; then
|
||||
prefer_curses=yes
|
||||
fi
|
||||
|
||||
if test "$opt_purify" = yes; then
|
||||
PURIFY="purify"
|
||||
else
|
||||
PURIFY=
|
||||
fi
|
||||
|
||||
dnl option parsing for optional features
|
||||
opt_multibyte=yes
|
||||
opt_static_libs=yes
|
||||
opt_shared_libs=yes
|
||||
|
||||
AC_ARG_ENABLE(multibyte, AC_HELP_STRING([--enable-multibyte], [enable multibyte characters if OS supports them]), opt_multibyte=$enableval)
|
||||
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)
|
||||
|
||||
if test $opt_multibyte = no; then
|
||||
AC_DEFINE(NO_MULTIBYTE_SUPPORT)
|
||||
fi
|
||||
|
||||
dnl load up the cross-building cache file -- add more cases and cache
|
||||
dnl files as necessary
|
||||
|
||||
dnl Note that host and target machine are the same, and different than the
|
||||
dnl build machine.
|
||||
|
||||
if test "x$cross_compiling" = "xyes"; then
|
||||
case "${host}" in
|
||||
*-cygwin*)
|
||||
cross_cache=${srcdir}/cross-build/cygwin.cache
|
||||
;;
|
||||
*-mingw*)
|
||||
cross_cache=${srcdir}/cross-build/mingw.cache
|
||||
;;
|
||||
i[[3456]]86-*-beos*)
|
||||
cross_cache=${srcdir}/cross-build/x86-beos.cache
|
||||
;;
|
||||
*) echo "configure: cross-compiling for $host is not supported" >&2
|
||||
;;
|
||||
esac
|
||||
if test -n "${cross_cache}" && test -r "${cross_cache}"; then
|
||||
echo "loading cross-build cache file ${cross_cache}"
|
||||
. ${cross_cache}
|
||||
fi
|
||||
unset cross_cache
|
||||
CROSS_COMPILE='-DCROSS_COMPILING'
|
||||
AC_SUBST(CROSS_COMPILE)
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Beginning configuration for readline-$LIBVERSION for ${host_cpu}-${host_vendor}-${host_os}"
|
||||
echo ""
|
||||
|
@ -72,17 +133,29 @@ AC_TYPE_SIGNAL
|
|||
AC_TYPE_SIZE_T
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
|
||||
AC_HEADER_STDC
|
||||
|
||||
AC_HEADER_STAT
|
||||
AC_HEADER_DIRENT
|
||||
|
||||
AC_CHECK_FUNCS(lstat memmove putenv select setenv setlocale \
|
||||
strcasecmp strpbrk tcgetattr vsnprintf isascii isxdigit)
|
||||
AC_CHECK_FUNCS(fcntl kill lstat)
|
||||
AC_CHECK_FUNCS(memmove putenv select setenv setlocale \
|
||||
strcasecmp strpbrk tcgetattr vsnprintf)
|
||||
AC_CHECK_FUNCS(isascii isxdigit)
|
||||
AC_CHECK_FUNCS(getpwent getpwnam getpwuid)
|
||||
|
||||
AC_FUNC_STRCOLL
|
||||
|
||||
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 )
|
||||
AC_CHECK_HEADERS(fcntl.h unistd.h stdlib.h varargs.h stdarg.h string.h strings.h \
|
||||
limits.h locale.h pwd.h memory.h termcap.h termios.h termio.h)
|
||||
AC_CHECK_HEADERS(sys/pte.h sys/stream.h sys/select.h sys/file.h)
|
||||
|
||||
AC_CHECK_HEADERS(sys/ptem.h,,,
|
||||
[[
|
||||
#if HAVE_SYS_STREAM_H
|
||||
# include <sys/stream.h>
|
||||
#endif
|
||||
]])
|
||||
|
||||
BASH_SYS_SIGNAL_VINTAGE
|
||||
BASH_SYS_REINSTALL_SIGHANDLERS
|
||||
|
@ -90,6 +163,7 @@ BASH_SYS_REINSTALL_SIGHANDLERS
|
|||
BASH_FUNC_POSIX_SETJMP
|
||||
BASH_FUNC_LSTAT
|
||||
BASH_FUNC_STRCOLL
|
||||
BASH_FUNC_CTYPE_NONASCII
|
||||
|
||||
BASH_CHECK_GETPW_FUNCS
|
||||
|
||||
|
@ -134,7 +208,13 @@ esac
|
|||
#
|
||||
if test -f ${srcdir}/support/shobj-conf; then
|
||||
AC_MSG_CHECKING(configuration for building shared libraries)
|
||||
eval `${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
|
||||
eval `TERMCAP_LIB=$TERMCAP_LIB ${CONFIG_SHELL-/bin/sh} ${srcdir}/support/shobj-conf -C "${CC}" -c ${host_cpu} -o ${host_os} -v ${host_vendor}`
|
||||
|
||||
# case "$SHLIB_LIBS" in
|
||||
# *curses*|*termcap*|*termlib*) ;;
|
||||
# *) SHLIB_LIBS="$SHLIB_LIBS $TERMCAP_LIB" ;;
|
||||
# esac
|
||||
|
||||
AC_SUBST(SHOBJ_CC)
|
||||
AC_SUBST(SHOBJ_CFLAGS)
|
||||
AC_SUBST(SHOBJ_LD)
|
||||
|
@ -144,8 +224,11 @@ if test -f ${srcdir}/support/shobj-conf; then
|
|||
AC_SUBST(SHOBJ_STATUS)
|
||||
AC_SUBST(SHLIB_STATUS)
|
||||
AC_SUBST(SHLIB_XLDFLAGS)
|
||||
AC_SUBST(SHLIB_DOT)
|
||||
AC_SUBST(SHLIB_LIBPREF)
|
||||
AC_SUBST(SHLIB_LIBSUFF)
|
||||
AC_SUBST(SHLIB_LIBVERSION)
|
||||
AC_SUBST(SHLIB_DLLVERSION)
|
||||
AC_SUBST(SHLIB_LIBS)
|
||||
AC_MSG_RESULT($SHLIB_STATUS)
|
||||
|
||||
|
@ -182,6 +265,12 @@ msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file
|
|||
*) BUILD_DIR=`pwd` ;;
|
||||
esac
|
||||
|
||||
case "$BUILD_DIR" in
|
||||
*\ *) BUILD_DIR=`echo "$BUILD_DIR" | sed 's: :\\\\ :g'` ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
AC_SUBST(PURIFY)
|
||||
AC_SUBST(BUILD_DIR)
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* display.c -- readline redisplay facility. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
|
@ -70,7 +70,7 @@ static void insert_some_chars PARAMS((char *, int, int));
|
|||
static void cr PARAMS((void));
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
static int _rl_col_width PARAMS((char *, int, int));
|
||||
static int _rl_col_width PARAMS((const char *, int, int));
|
||||
static int *_rl_wrapped_line;
|
||||
#else
|
||||
# define _rl_col_width(l, s, e) (((e) <= (s)) ? 0 : (e) - (s))
|
||||
|
@ -118,16 +118,24 @@ rl_voidfunc_t *rl_redisplay_function = rl_redisplay;
|
|||
int rl_display_fixed = 0;
|
||||
|
||||
int _rl_suppress_redisplay = 0;
|
||||
int _rl_want_redisplay = 0;
|
||||
|
||||
/* The stuff that gets printed out before the actual text of the line.
|
||||
This is usually pointing to rl_prompt. */
|
||||
char *rl_display_prompt = (char *)NULL;
|
||||
|
||||
/* Pseudo-global variables declared here. */
|
||||
|
||||
/* The visible cursor position. If you print some text, adjust this. */
|
||||
/* NOTE: _rl_last_c_pos is used as a buffer index when not in a locale
|
||||
supporting multibyte characters, and an absolute cursor position when
|
||||
in such a locale. This is an artifact of the donated multibyte support.
|
||||
Care must be taken when modifying its value. */
|
||||
int _rl_last_c_pos = 0;
|
||||
int _rl_last_v_pos = 0;
|
||||
|
||||
static int cpos_adjusted;
|
||||
|
||||
/* Number of lines currently on screen minus 1. */
|
||||
int _rl_vis_botlin = 0;
|
||||
|
||||
|
@ -178,12 +186,27 @@ static int prompt_invis_chars_first_line;
|
|||
|
||||
static int prompt_last_screen_line;
|
||||
|
||||
static int prompt_physical_chars;
|
||||
|
||||
/* Variables to save and restore prompt and display information. */
|
||||
|
||||
/* These are getting numerous enough that it's time to create a struct. */
|
||||
|
||||
static char *saved_local_prompt;
|
||||
static char *saved_local_prefix;
|
||||
static int saved_last_invisible;
|
||||
static int saved_visible_length;
|
||||
static int saved_prefix_length;
|
||||
static int saved_invis_chars_first_line;
|
||||
static int saved_physical_chars;
|
||||
|
||||
/* Expand the prompt string S and return the number of visible
|
||||
characters in *LP, if LP is not null. This is currently more-or-less
|
||||
a placeholder for expansion. LIP, if non-null is a place to store the
|
||||
index of the last invisible character in the returned string. NIFLP,
|
||||
if non-zero, is a place to store the number of invisible characters in
|
||||
the first prompt line. */
|
||||
the first prompt line. The previous are used as byte counts -- indexes
|
||||
into a character buffer. */
|
||||
|
||||
/* Current implementation:
|
||||
\001 (^A) start non-visible characters
|
||||
|
@ -193,19 +216,25 @@ static int prompt_last_screen_line;
|
|||
\002 are assumed to be `visible'. */
|
||||
|
||||
static char *
|
||||
expand_prompt (pmt, lp, lip, niflp)
|
||||
expand_prompt (pmt, lp, lip, niflp, vlp)
|
||||
char *pmt;
|
||||
int *lp, *lip, *niflp;
|
||||
int *lp, *lip, *niflp, *vlp;
|
||||
{
|
||||
char *r, *ret, *p;
|
||||
int l, rl, last, ignoring, ninvis, invfl;
|
||||
int l, rl, last, ignoring, ninvis, invfl, invflset, ind, pind, physchars;
|
||||
|
||||
/* Short-circuit if we can. */
|
||||
if (strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
|
||||
if ((MB_CUR_MAX <= 1 || rl_byte_oriented) && strchr (pmt, RL_PROMPT_START_IGNORE) == 0)
|
||||
{
|
||||
r = savestring (pmt);
|
||||
if (lp)
|
||||
*lp = strlen (r);
|
||||
if (lip)
|
||||
*lip = 0;
|
||||
if (niflp)
|
||||
*niflp = 0;
|
||||
if (vlp)
|
||||
*vlp = lp ? *lp : strlen (r);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -213,8 +242,9 @@ expand_prompt (pmt, lp, lip, niflp)
|
|||
r = ret = (char *)xmalloc (l + 1);
|
||||
|
||||
invfl = 0; /* invisible chars in first line of prompt */
|
||||
invflset = 0; /* we only want to set invfl once */
|
||||
|
||||
for (rl = ignoring = last = ninvis = 0, p = pmt; p && *p; p++)
|
||||
for (rl = ignoring = last = ninvis = physchars = 0, p = pmt; p && *p; p++)
|
||||
{
|
||||
/* This code strips the invisible character string markers
|
||||
RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE */
|
||||
|
@ -226,18 +256,47 @@ expand_prompt (pmt, lp, lip, niflp)
|
|||
else if (ignoring && *p == RL_PROMPT_END_IGNORE)
|
||||
{
|
||||
ignoring = 0;
|
||||
last = r - ret - 1;
|
||||
if (p[-1] != RL_PROMPT_START_IGNORE)
|
||||
last = r - ret - 1;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
*r++ = *p;
|
||||
if (!ignoring)
|
||||
rl++;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
pind = p - pmt;
|
||||
ind = _rl_find_next_mbchar (pmt, pind, 1, MB_FIND_NONZERO);
|
||||
l = ind - pind;
|
||||
while (l--)
|
||||
*r++ = *p++;
|
||||
if (!ignoring)
|
||||
{
|
||||
rl += ind - pind;
|
||||
physchars += _rl_col_width (pmt, pind, ind);
|
||||
}
|
||||
else
|
||||
ninvis += ind - pind;
|
||||
p--; /* compensate for later increment */
|
||||
}
|
||||
else
|
||||
ninvis++;
|
||||
if (rl == _rl_screenwidth)
|
||||
invfl = ninvis;
|
||||
#endif
|
||||
{
|
||||
*r++ = *p;
|
||||
if (!ignoring)
|
||||
{
|
||||
rl++; /* visible length byte counter */
|
||||
physchars++;
|
||||
}
|
||||
else
|
||||
ninvis++; /* invisible chars byte counter */
|
||||
}
|
||||
|
||||
if (invflset == 0 && rl >= _rl_screenwidth)
|
||||
{
|
||||
invfl = ninvis;
|
||||
invflset = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -251,6 +310,8 @@ expand_prompt (pmt, lp, lip, niflp)
|
|||
*lip = last;
|
||||
if (niflp)
|
||||
*niflp = invfl;
|
||||
if (vlp)
|
||||
*vlp = physchars;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -262,7 +323,7 @@ _rl_strip_prompt (pmt)
|
|||
{
|
||||
char *ret;
|
||||
|
||||
ret = expand_prompt (pmt, (int *)NULL, (int *)NULL, (int *)NULL);
|
||||
ret = expand_prompt (pmt, (int *)NULL, (int *)NULL, (int *)NULL, (int *)NULL);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -295,7 +356,8 @@ rl_expand_prompt (prompt)
|
|||
FREE (local_prompt_prefix);
|
||||
|
||||
local_prompt = local_prompt_prefix = (char *)0;
|
||||
prompt_last_invisible = prompt_visible_length = 0;
|
||||
prompt_last_invisible = prompt_invis_chars_first_line = 0;
|
||||
prompt_visible_length = prompt_physical_chars = 0;
|
||||
|
||||
if (prompt == 0 || *prompt == 0)
|
||||
return (0);
|
||||
|
@ -306,7 +368,8 @@ rl_expand_prompt (prompt)
|
|||
/* The prompt is only one logical line, though it might wrap. */
|
||||
local_prompt = expand_prompt (prompt, &prompt_visible_length,
|
||||
&prompt_last_invisible,
|
||||
&prompt_invis_chars_first_line);
|
||||
&prompt_invis_chars_first_line,
|
||||
&prompt_physical_chars);
|
||||
local_prompt_prefix = (char *)0;
|
||||
return (prompt_visible_length);
|
||||
}
|
||||
|
@ -316,13 +379,15 @@ rl_expand_prompt (prompt)
|
|||
t = ++p;
|
||||
local_prompt = expand_prompt (p, &prompt_visible_length,
|
||||
&prompt_last_invisible,
|
||||
&prompt_invis_chars_first_line);
|
||||
(int *)NULL,
|
||||
&prompt_physical_chars);
|
||||
c = *t; *t = '\0';
|
||||
/* The portion of the prompt string up to and including the
|
||||
final newline is now null-terminated. */
|
||||
local_prompt_prefix = expand_prompt (prompt, &prompt_prefix_length,
|
||||
(int *)NULL,
|
||||
&prompt_invis_chars_first_line);
|
||||
&prompt_invis_chars_first_line,
|
||||
(int *)NULL);
|
||||
*t = c;
|
||||
return (prompt_prefix_length);
|
||||
}
|
||||
|
@ -380,8 +445,8 @@ rl_redisplay ()
|
|||
{
|
||||
register int in, out, c, linenum, cursor_linenum;
|
||||
register char *line;
|
||||
int c_pos, inv_botlin, lb_botlin, lb_linenum;
|
||||
int newlines, lpos, temp;
|
||||
int c_pos, inv_botlin, lb_botlin, lb_linenum, o_cpos;
|
||||
int newlines, lpos, temp, modmark, n0, num;
|
||||
char *prompt_this_line;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
wchar_t wc;
|
||||
|
@ -397,7 +462,7 @@ rl_redisplay ()
|
|||
if (!rl_display_prompt)
|
||||
rl_display_prompt = "";
|
||||
|
||||
if (invisible_line == 0)
|
||||
if (invisible_line == 0 || vis_lbreaks == 0)
|
||||
{
|
||||
init_line_structures (0);
|
||||
rl_on_new_line ();
|
||||
|
@ -411,10 +476,12 @@ rl_redisplay ()
|
|||
|
||||
/* Mark the line as modified or not. We only do this for history
|
||||
lines. */
|
||||
modmark = 0;
|
||||
if (_rl_mark_modified_lines && current_history () && rl_undo_list)
|
||||
{
|
||||
line[out++] = '*';
|
||||
line[out] = '\0';
|
||||
modmark = 1;
|
||||
}
|
||||
|
||||
/* If someone thought that the redisplay was handled, but the currently
|
||||
|
@ -468,7 +535,7 @@ rl_redisplay ()
|
|||
}
|
||||
}
|
||||
|
||||
pmtlen = strlen (prompt_this_line);
|
||||
prompt_physical_chars = pmtlen = strlen (prompt_this_line);
|
||||
temp = pmtlen + out + 2;
|
||||
if (temp >= line_size)
|
||||
{
|
||||
|
@ -527,9 +594,15 @@ rl_redisplay ()
|
|||
|
||||
/* inv_lbreaks[i] is where line i starts in the buffer. */
|
||||
inv_lbreaks[newlines = 0] = 0;
|
||||
#if 0
|
||||
lpos = out - wrap_offset;
|
||||
#else
|
||||
lpos = prompt_physical_chars + modmark;
|
||||
#endif
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
memset (_rl_wrapped_line, 0, vis_lbsize);
|
||||
num = 0;
|
||||
#endif
|
||||
|
||||
/* prompt_invis_chars_first_line is the number of invisible characters in
|
||||
|
@ -546,17 +619,34 @@ rl_redisplay ()
|
|||
prompt_invis_chars_first_line variable could be made into an array
|
||||
saying how many invisible characters there are per line, but that's
|
||||
probably too much work for the benefit gained. How many people have
|
||||
prompts that exceed two physical lines? */
|
||||
temp = ((newlines + 1) * _rl_screenwidth) +
|
||||
#if 0
|
||||
((newlines == 0) ? prompt_invis_chars_first_line : 0) +
|
||||
prompts that exceed two physical lines?
|
||||
Additional logic fix from Edward Catmur <ed@catmur.co.uk> */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
n0 = num;
|
||||
temp = local_prompt ? strlen (local_prompt) : 0;
|
||||
while (num < temp)
|
||||
{
|
||||
if (_rl_col_width (local_prompt, n0, num) > _rl_screenwidth)
|
||||
{
|
||||
num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
|
||||
break;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
temp = num +
|
||||
#else
|
||||
((newlines == 0 && local_prompt_prefix == 0) ? prompt_invis_chars_first_line : 0) +
|
||||
#endif
|
||||
((newlines == 1) ? wrap_offset : 0);
|
||||
|
||||
temp = ((newlines + 1) * _rl_screenwidth) +
|
||||
#endif /* !HANDLE_MULTIBYTE */
|
||||
((local_prompt_prefix == 0) ? ((newlines == 0) ? prompt_invis_chars_first_line
|
||||
: ((newlines == 1) ? wrap_offset : 0))
|
||||
: ((newlines == 0) ? wrap_offset :0));
|
||||
|
||||
inv_lbreaks[++newlines] = temp;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
lpos -= _rl_col_width (local_prompt, n0, num);
|
||||
#else
|
||||
lpos -= _rl_screenwidth;
|
||||
#endif
|
||||
}
|
||||
|
||||
prompt_last_screen_line = newlines;
|
||||
|
@ -586,7 +676,7 @@ rl_redisplay ()
|
|||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
if (wc_bytes == (size_t)-1 || wc_bytes == (size_t)-2)
|
||||
if (MB_INVALIDCH (wc_bytes))
|
||||
{
|
||||
/* Byte sequence is invalid or shortened. Assume that the
|
||||
first byte represents a character. */
|
||||
|
@ -595,12 +685,12 @@ rl_redisplay ()
|
|||
wc_width = 1;
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
}
|
||||
else if (wc_bytes == (size_t)0)
|
||||
else if (MB_NULLWCH (wc_bytes))
|
||||
break; /* Found '\0' */
|
||||
else
|
||||
{
|
||||
temp = wcwidth (wc);
|
||||
wc_width = (temp < 0) ? 1 : temp;
|
||||
wc_width = (temp >= 0) ? temp : 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -765,7 +855,7 @@ rl_redisplay ()
|
|||
|
||||
if (_rl_horizontal_scroll_mode == 0 && _rl_term_up && *_rl_term_up)
|
||||
{
|
||||
int nleft, pos, changed_screen_line;
|
||||
int nleft, pos, changed_screen_line, tx;
|
||||
|
||||
if (!rl_display_fixed || forced_display)
|
||||
{
|
||||
|
@ -796,9 +886,26 @@ rl_redisplay ()
|
|||
/* For each line in the buffer, do the updating display. */
|
||||
for (linenum = 0; linenum <= inv_botlin; linenum++)
|
||||
{
|
||||
o_cpos = _rl_last_c_pos;
|
||||
cpos_adjusted = 0;
|
||||
update_line (VIS_LINE(linenum), INV_LINE(linenum), linenum,
|
||||
VIS_LLEN(linenum), INV_LLEN(linenum), inv_botlin);
|
||||
|
||||
/* update_line potentially changes _rl_last_c_pos, but doesn't
|
||||
take invisible characters into account, since _rl_last_c_pos
|
||||
is an absolute cursor position in a multibyte locale. See
|
||||
if compensating here is the right thing, or if we have to
|
||||
change update_line itself. There is one case in which
|
||||
update_line adjusts _rl_last_c_pos itself (so it can pass
|
||||
_rl_move_cursor_relative accurate values); it communicates
|
||||
this back by setting cpos_adjusted */
|
||||
if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
|
||||
cpos_adjusted == 0 &&
|
||||
_rl_last_c_pos != o_cpos &&
|
||||
_rl_last_c_pos > wrap_offset &&
|
||||
o_cpos < prompt_last_invisible)
|
||||
_rl_last_c_pos -= wrap_offset;
|
||||
|
||||
/* If this is the line with the prompt, we might need to
|
||||
compensate for invisible characters in the new line. Do
|
||||
this only if there is not more than one new line (which
|
||||
|
@ -810,7 +917,10 @@ rl_redisplay ()
|
|||
(wrap_offset > visible_wrap_offset) &&
|
||||
(_rl_last_c_pos < visible_first_line_len))
|
||||
{
|
||||
nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
nleft = _rl_screenwidth - _rl_last_c_pos;
|
||||
else
|
||||
nleft = _rl_screenwidth + wrap_offset - _rl_last_c_pos;
|
||||
if (nleft)
|
||||
_rl_clear_to_eol (nleft);
|
||||
}
|
||||
|
@ -846,7 +956,7 @@ rl_redisplay ()
|
|||
the physical cursor position on the screen stays the same,
|
||||
but the buffer position needs to be adjusted to account
|
||||
for invisible characters. */
|
||||
if (cursor_linenum == 0 && wrap_offset)
|
||||
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && cursor_linenum == 0 && wrap_offset)
|
||||
_rl_last_c_pos += wrap_offset;
|
||||
}
|
||||
|
||||
|
@ -867,7 +977,7 @@ rl_redisplay ()
|
|||
#endif
|
||||
_rl_output_some_chars (local_prompt, nleft);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_last_c_pos = _rl_col_width(local_prompt, 0, nleft);
|
||||
_rl_last_c_pos = _rl_col_width (local_prompt, 0, nleft) - wrap_offset;
|
||||
else
|
||||
_rl_last_c_pos = nleft;
|
||||
}
|
||||
|
@ -879,18 +989,31 @@ rl_redisplay ()
|
|||
start of the line and the cursor position. */
|
||||
nleft = c_pos - pos;
|
||||
|
||||
/* NLEFT is now a number of characters in a buffer. When in a
|
||||
multibyte locale, however, _rl_last_c_pos is an absolute cursor
|
||||
position that doesn't take invisible characters in the prompt
|
||||
into account. We use a fudge factor to compensate. */
|
||||
|
||||
/* Since _rl_backspace() doesn't know about invisible characters in the
|
||||
prompt, and there's no good way to tell it, we compensate for
|
||||
those characters here and call _rl_backspace() directly. */
|
||||
if (wrap_offset && cursor_linenum == 0 && nleft < _rl_last_c_pos)
|
||||
{
|
||||
_rl_backspace (_rl_last_c_pos - nleft);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_last_c_pos = _rl_col_width (&visible_line[pos], 0, nleft);
|
||||
tx = _rl_col_width (&visible_line[pos], 0, nleft) - visible_wrap_offset;
|
||||
else
|
||||
_rl_last_c_pos = nleft;
|
||||
tx = nleft;
|
||||
if (_rl_last_c_pos > tx)
|
||||
{
|
||||
_rl_backspace (_rl_last_c_pos - tx); /* XXX */
|
||||
_rl_last_c_pos = tx;
|
||||
}
|
||||
}
|
||||
|
||||
/* We need to note that in a multibyte locale we are dealing with
|
||||
_rl_last_c_pos as an absolute cursor position, but moving to a
|
||||
point specified by a buffer position (NLEFT) that doesn't take
|
||||
invisible characters into account. */
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_move_cursor_relative (nleft, &invisible_line[pos]);
|
||||
else if (nleft != _rl_last_c_pos)
|
||||
|
@ -1049,7 +1172,10 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
the exact cursor position and cut-and-paste with certain terminal
|
||||
emulators. In this calculation, TEMP is the physical screen
|
||||
position of the cursor. */
|
||||
temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
temp = _rl_last_c_pos;
|
||||
else
|
||||
temp = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
|
||||
if (temp == _rl_screenwidth && _rl_term_autowrap && !_rl_horizontal_scroll_mode
|
||||
&& _rl_last_v_pos == current_line - 1)
|
||||
{
|
||||
|
@ -1069,12 +1195,12 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
ret = mbrtowc (&wc, new, MB_CUR_MAX, &ps);
|
||||
if (ret == (size_t)-1 || ret == (size_t)-2)
|
||||
if (MB_INVALIDCH (ret))
|
||||
{
|
||||
tempwidth = 1;
|
||||
ret = 1;
|
||||
}
|
||||
else if (ret == 0)
|
||||
else if (MB_NULLWCH (ret))
|
||||
tempwidth = 0;
|
||||
else
|
||||
tempwidth = wcwidth (wc);
|
||||
|
@ -1091,7 +1217,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
ret = mbrtowc (&wc, old, MB_CUR_MAX, &ps);
|
||||
if (ret != 0 && bytes != 0)
|
||||
{
|
||||
if (ret == (size_t)-1 || ret == (size_t)-2)
|
||||
if (MB_INVALIDCH (ret))
|
||||
memmove (old+bytes, old+1, strlen (old+1));
|
||||
else
|
||||
memmove (old+bytes, old+ret, strlen (old+ret));
|
||||
|
@ -1114,7 +1240,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
putc (new[0], rl_outstream);
|
||||
else
|
||||
putc (' ', rl_outstream);
|
||||
_rl_last_c_pos = 1; /* XXX */
|
||||
_rl_last_c_pos = 1;
|
||||
_rl_last_v_pos++;
|
||||
if (old[0] && new[0])
|
||||
old[0] = new[0];
|
||||
|
@ -1126,18 +1252,37 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
memset (&ps_new, 0, sizeof(mbstate_t));
|
||||
memset (&ps_old, 0, sizeof(mbstate_t));
|
||||
|
||||
new_offset = old_offset = 0;
|
||||
for (ofd = old, nfd = new;
|
||||
(ofd - old < omax) && *ofd &&
|
||||
_rl_compare_chars(old, old_offset, &ps_old, new, new_offset, &ps_new); )
|
||||
/* See if the old line is a subset of the new line, so that the
|
||||
only change is adding characters. */
|
||||
temp = (omax < nmax) ? omax : nmax;
|
||||
if (memcmp (old, new, temp) == 0)
|
||||
{
|
||||
old_offset = _rl_find_next_mbchar (old, old_offset, 1, MB_FIND_ANY);
|
||||
new_offset = _rl_find_next_mbchar (new, new_offset, 1, MB_FIND_ANY);
|
||||
ofd = old + old_offset;
|
||||
nfd = new + new_offset;
|
||||
ofd = old + temp;
|
||||
nfd = new + temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset (&ps_new, 0, sizeof(mbstate_t));
|
||||
memset (&ps_old, 0, sizeof(mbstate_t));
|
||||
|
||||
if (omax == nmax && STREQN (new, old, omax))
|
||||
{
|
||||
ofd = old + omax;
|
||||
nfd = new + nmax;
|
||||
}
|
||||
else
|
||||
{
|
||||
new_offset = old_offset = 0;
|
||||
for (ofd = old, nfd = new;
|
||||
(ofd - old < omax) && *ofd &&
|
||||
_rl_compare_chars(old, old_offset, &ps_old, new, new_offset, &ps_new); )
|
||||
{
|
||||
old_offset = _rl_find_next_mbchar (old, old_offset, 1, MB_FIND_ANY);
|
||||
new_offset = _rl_find_next_mbchar (new, new_offset, 1, MB_FIND_ANY);
|
||||
ofd = old + old_offset;
|
||||
nfd = new + new_offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1169,8 +1314,11 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
memset (&ps_old, 0, sizeof (mbstate_t));
|
||||
memset (&ps_new, 0, sizeof (mbstate_t));
|
||||
|
||||
#if 0
|
||||
/* On advice from jir@yamato.ibm.com */
|
||||
_rl_adjust_point (old, ols - old, &ps_old);
|
||||
_rl_adjust_point (new, nls - new, &ps_new);
|
||||
#endif
|
||||
|
||||
if (_rl_compare_chars (old, ols - old, &ps_old, new, nls - new, &ps_new) == 0)
|
||||
break;
|
||||
|
@ -1233,7 +1381,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
if (_rl_last_v_pos != current_line)
|
||||
{
|
||||
_rl_move_vert (current_line);
|
||||
if (current_line == 0 && visible_wrap_offset)
|
||||
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && current_line == 0 && visible_wrap_offset)
|
||||
_rl_last_c_pos += visible_wrap_offset;
|
||||
}
|
||||
|
||||
|
@ -1262,7 +1410,12 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
#endif
|
||||
_rl_output_some_chars (local_prompt, lendiff);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff);
|
||||
{
|
||||
/* We take wrap_offset into account here so we can pass correct
|
||||
information to _rl_move_cursor_relative. */
|
||||
_rl_last_c_pos = _rl_col_width (local_prompt, 0, lendiff) - wrap_offset;
|
||||
cpos_adjusted = 1;
|
||||
}
|
||||
else
|
||||
_rl_last_c_pos = lendiff;
|
||||
}
|
||||
|
@ -1324,7 +1477,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
insert_some_chars (nfd, lendiff, col_lendiff);
|
||||
_rl_last_c_pos += col_lendiff;
|
||||
}
|
||||
else if (*ols == 0)
|
||||
else if ((MB_CUR_MAX == 1 || rl_byte_oriented != 0) && *ols == 0 && lendiff > 0)
|
||||
{
|
||||
/* At the end of a line the characters do not have to
|
||||
be "inserted". They can just be placed on the screen. */
|
||||
|
@ -1347,10 +1500,14 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
if ((temp - lendiff) > 0)
|
||||
{
|
||||
_rl_output_some_chars (nfd + lendiff, temp - lendiff);
|
||||
#if 0
|
||||
_rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff) - col_lendiff;
|
||||
#else
|
||||
#if 1
|
||||
/* XXX -- this bears closer inspection. Fixes a redisplay bug
|
||||
reported against bash-3.0-alpha by Andreas Schwab involving
|
||||
multibyte characters and prompt strings with invisible
|
||||
characters, but was previously disabled. */
|
||||
_rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-col_lendiff);
|
||||
#else
|
||||
_rl_last_c_pos += _rl_col_width (nfd+lendiff, 0, temp-lendiff);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -1359,6 +1516,10 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
/* cannot insert chars, write to EOL */
|
||||
_rl_output_some_chars (nfd, temp);
|
||||
_rl_last_c_pos += col_temp;
|
||||
/* If we're in a multibyte locale and were before the last invisible
|
||||
char in the current line (which implies we just output some invisible
|
||||
characters) we need to adjust _rl_last_c_pos, since it represents
|
||||
a physical character position. */
|
||||
}
|
||||
}
|
||||
else /* Delete characters from line. */
|
||||
|
@ -1390,7 +1551,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
|
|||
if (temp > 0)
|
||||
{
|
||||
_rl_output_some_chars (nfd, temp);
|
||||
_rl_last_c_pos += col_temp;
|
||||
_rl_last_c_pos += col_temp; /* XXX */
|
||||
}
|
||||
lendiff = (oe - old) - (ne - new);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
|
@ -1426,12 +1587,13 @@ rl_on_new_line ()
|
|||
|
||||
/* Tell the update routines that we have moved onto a new line with the
|
||||
prompt already displayed. Code originally from the version of readline
|
||||
distributed with CLISP. */
|
||||
distributed with CLISP. rl_expand_prompt must have already been called
|
||||
(explicitly or implicitly). This still doesn't work exactly right. */
|
||||
int
|
||||
rl_on_new_line_with_prompt ()
|
||||
{
|
||||
int prompt_size, i, l, real_screenwidth, newlines;
|
||||
char *prompt_last_line;
|
||||
char *prompt_last_line, *lprompt;
|
||||
|
||||
/* Initialize visible_line and invisible_line to ensure that they can hold
|
||||
the already-displayed prompt. */
|
||||
|
@ -1440,8 +1602,9 @@ rl_on_new_line_with_prompt ()
|
|||
|
||||
/* Make sure the line structures hold the already-displayed prompt for
|
||||
redisplay. */
|
||||
strcpy (visible_line, rl_prompt);
|
||||
strcpy (invisible_line, rl_prompt);
|
||||
lprompt = local_prompt ? local_prompt : rl_prompt;
|
||||
strcpy (visible_line, lprompt);
|
||||
strcpy (invisible_line, lprompt);
|
||||
|
||||
/* If the prompt contains newlines, take the last tail. */
|
||||
prompt_last_line = strrchr (rl_prompt, '\n');
|
||||
|
@ -1450,7 +1613,7 @@ rl_on_new_line_with_prompt ()
|
|||
|
||||
l = strlen (prompt_last_line);
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l);
|
||||
_rl_last_c_pos = _rl_col_width (prompt_last_line, 0, l); /* XXX */
|
||||
else
|
||||
_rl_last_c_pos = l;
|
||||
|
||||
|
@ -1476,6 +1639,8 @@ rl_on_new_line_with_prompt ()
|
|||
vis_lbreaks[newlines] = l;
|
||||
visible_wrap_offset = 0;
|
||||
|
||||
rl_display_prompt = rl_prompt; /* XXX - make sure it's set */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1497,6 +1662,8 @@ rl_forced_update_display ()
|
|||
}
|
||||
|
||||
/* Move the cursor from _rl_last_c_pos to NEW, which are buffer indices.
|
||||
(Well, when we don't have multibyte characters, _rl_last_c_pos is a
|
||||
buffer index.)
|
||||
DATA is the contents of the screen line of interest; i.e., where
|
||||
the movement is being done. */
|
||||
void
|
||||
|
@ -1505,21 +1672,40 @@ _rl_move_cursor_relative (new, data)
|
|||
const char *data;
|
||||
{
|
||||
register int i;
|
||||
int woff; /* number of invisible chars on current line */
|
||||
int cpos, dpos; /* current and desired cursor positions */
|
||||
|
||||
/* If we don't have to do anything, then return. */
|
||||
woff = W_OFFSET (_rl_last_v_pos, wrap_offset);
|
||||
cpos = _rl_last_c_pos;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
/* If we have multibyte characters, NEW is indexed by the buffer point in
|
||||
a multibyte string, but _rl_last_c_pos is the display position. In
|
||||
this case, NEW's display position is not obvious. */
|
||||
if ((MB_CUR_MAX == 1 || rl_byte_oriented ) && _rl_last_c_pos == new) return;
|
||||
#else
|
||||
if (_rl_last_c_pos == new) return;
|
||||
this case, NEW's display position is not obvious and must be
|
||||
calculated. We need to account for invisible characters in this line,
|
||||
as long as we are past them and they are counted by _rl_col_width. */
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
dpos = _rl_col_width (data, 0, new);
|
||||
if (dpos > woff)
|
||||
dpos -= woff;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
dpos = new;
|
||||
|
||||
/* If we don't have to do anything, then return. */
|
||||
if (cpos == dpos)
|
||||
return;
|
||||
|
||||
/* It may be faster to output a CR, and then move forwards instead
|
||||
of moving backwards. */
|
||||
/* i == current physical cursor position. */
|
||||
i = _rl_last_c_pos - W_OFFSET(_rl_last_v_pos, visible_wrap_offset);
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
i = _rl_last_c_pos;
|
||||
else
|
||||
#endif
|
||||
i = _rl_last_c_pos - woff;
|
||||
if (new == 0 || CR_FASTER (new, _rl_last_c_pos) ||
|
||||
(_rl_term_autowrap && i == _rl_screenwidth))
|
||||
{
|
||||
|
@ -1528,10 +1714,10 @@ _rl_move_cursor_relative (new, data)
|
|||
#else
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
#endif /* !__MSDOS__ */
|
||||
_rl_last_c_pos = 0;
|
||||
cpos = _rl_last_c_pos = 0;
|
||||
}
|
||||
|
||||
if (_rl_last_c_pos < new)
|
||||
if (cpos < dpos)
|
||||
{
|
||||
/* Move the cursor forward. We do it by printing the command
|
||||
to move the cursor forward if there is one, else print that
|
||||
|
@ -1545,31 +1731,11 @@ _rl_move_cursor_relative (new, data)
|
|||
#if defined (HACK_TERMCAP_MOTION)
|
||||
if (_rl_term_forward_char)
|
||||
{
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
int width;
|
||||
width = _rl_col_width (data, _rl_last_c_pos, new);
|
||||
for (i = 0; i < width; i++)
|
||||
tputs (_rl_term_forward_char, 1, _rl_output_character_function);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
tputs (_rl_term_forward_char, 1, _rl_output_character_function);
|
||||
}
|
||||
}
|
||||
else if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
for (i = 0; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
for (i = cpos; i < dpos; i++)
|
||||
tputs (_rl_term_forward_char, 1, _rl_output_character_function);
|
||||
}
|
||||
else
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
|
||||
#else /* !HACK_TERMCAP_MOTION */
|
||||
|
||||
#endif /* HACK_TERMCAP_MOTION */
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
|
@ -1577,36 +1743,20 @@ _rl_move_cursor_relative (new, data)
|
|||
putc (data[i], rl_outstream);
|
||||
}
|
||||
else
|
||||
for (i = _rl_last_c_pos; i < new; i++)
|
||||
for (i = cpos; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
|
||||
#endif /* !HACK_TERMCAP_MOTION */
|
||||
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
/* NEW points to the buffer point, but _rl_last_c_pos is the display point.
|
||||
The byte length of the string is probably bigger than the column width
|
||||
of the string, which means that if NEW == _rl_last_c_pos, then NEW's
|
||||
display point is less than _rl_last_c_pos. */
|
||||
else if (_rl_last_c_pos >= new)
|
||||
#else
|
||||
else if (_rl_last_c_pos > new)
|
||||
#endif
|
||||
{
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
tputs (_rl_term_cr, 1, _rl_output_character_function);
|
||||
for (i = 0; i < new; i++)
|
||||
putc (data[i], rl_outstream);
|
||||
}
|
||||
else
|
||||
_rl_backspace (_rl_last_c_pos - new);
|
||||
}
|
||||
else if (cpos > dpos)
|
||||
_rl_backspace (cpos - dpos);
|
||||
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
_rl_last_c_pos = _rl_col_width (data, 0, new);
|
||||
else
|
||||
_rl_last_c_pos = new;
|
||||
_rl_last_c_pos = dpos;
|
||||
}
|
||||
|
||||
/* PWP: move the cursor up or down. */
|
||||
|
@ -1695,9 +1845,9 @@ rl_character_len (c, pos)
|
|||
|
||||
return ((ISPRINT (uc)) ? 1 : 2);
|
||||
}
|
||||
|
||||
/* How to print things in the "echo-area". The prompt is treated as a
|
||||
mini-modeline. */
|
||||
static int msg_saved_prompt = 0;
|
||||
|
||||
#if defined (USE_VARARGS)
|
||||
int
|
||||
|
@ -1728,8 +1878,19 @@ rl_message (va_alist)
|
|||
#endif
|
||||
va_end (args);
|
||||
|
||||
if (saved_local_prompt == 0)
|
||||
{
|
||||
rl_save_prompt ();
|
||||
msg_saved_prompt = 1;
|
||||
}
|
||||
rl_display_prompt = msg_buf;
|
||||
local_prompt = expand_prompt (msg_buf, &prompt_visible_length,
|
||||
&prompt_last_invisible,
|
||||
&prompt_invis_chars_first_line,
|
||||
&prompt_physical_chars);
|
||||
local_prompt_prefix = (char *)NULL;
|
||||
(*rl_redisplay_function) ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#else /* !USE_VARARGS */
|
||||
|
@ -1739,8 +1900,20 @@ rl_message (format, arg1, arg2)
|
|||
{
|
||||
sprintf (msg_buf, format, arg1, arg2);
|
||||
msg_buf[sizeof(msg_buf) - 1] = '\0'; /* overflow? */
|
||||
|
||||
rl_display_prompt = msg_buf;
|
||||
if (saved_local_prompt == 0)
|
||||
{
|
||||
rl_save_prompt ();
|
||||
msg_saved_prompt = 1;
|
||||
}
|
||||
local_prompt = expand_prompt (msg_buf, &prompt_visible_length,
|
||||
&prompt_last_invisible,
|
||||
&prompt_invis_chars_first_line,
|
||||
&prompt_physical_chars);
|
||||
local_prompt_prefix = (char *)NULL;
|
||||
(*rl_redisplay_function) ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* !USE_VARARGS */
|
||||
|
@ -1750,6 +1923,11 @@ int
|
|||
rl_clear_message ()
|
||||
{
|
||||
rl_display_prompt = rl_prompt;
|
||||
if (msg_saved_prompt)
|
||||
{
|
||||
rl_restore_prompt ();
|
||||
msg_saved_prompt = 0;
|
||||
}
|
||||
(*rl_redisplay_function) ();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1764,21 +1942,20 @@ rl_reset_line_state ()
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char *saved_local_prompt;
|
||||
static char *saved_local_prefix;
|
||||
static int saved_last_invisible;
|
||||
static int saved_visible_length;
|
||||
|
||||
void
|
||||
rl_save_prompt ()
|
||||
{
|
||||
saved_local_prompt = local_prompt;
|
||||
saved_local_prefix = local_prompt_prefix;
|
||||
saved_prefix_length = prompt_prefix_length;
|
||||
saved_last_invisible = prompt_last_invisible;
|
||||
saved_visible_length = prompt_visible_length;
|
||||
saved_invis_chars_first_line = prompt_invis_chars_first_line;
|
||||
saved_physical_chars = prompt_physical_chars;
|
||||
|
||||
local_prompt = local_prompt_prefix = (char *)0;
|
||||
prompt_last_invisible = prompt_visible_length = 0;
|
||||
prompt_last_invisible = prompt_visible_length = prompt_prefix_length = 0;
|
||||
prompt_invis_chars_first_line = prompt_physical_chars = 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1789,8 +1966,16 @@ rl_restore_prompt ()
|
|||
|
||||
local_prompt = saved_local_prompt;
|
||||
local_prompt_prefix = saved_local_prefix;
|
||||
prompt_prefix_length = saved_prefix_length;
|
||||
prompt_last_invisible = saved_last_invisible;
|
||||
prompt_visible_length = saved_visible_length;
|
||||
prompt_invis_chars_first_line = saved_invis_chars_first_line;
|
||||
prompt_physical_chars = saved_physical_chars;
|
||||
|
||||
/* can test saved_local_prompt to see if prompt info has been saved. */
|
||||
saved_local_prompt = saved_local_prefix = (char *)0;
|
||||
saved_last_invisible = saved_visible_length = saved_prefix_length = 0;
|
||||
saved_invis_chars_first_line = saved_physical_chars = 0;
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -1823,6 +2008,9 @@ _rl_make_prompt_for_search (pchar)
|
|||
prompt_last_invisible = saved_last_invisible;
|
||||
prompt_visible_length = saved_visible_length + 1;
|
||||
}
|
||||
|
||||
prompt_physical_chars = saved_physical_chars + 1;
|
||||
|
||||
return pmt;
|
||||
}
|
||||
|
||||
|
@ -1883,6 +2071,9 @@ insert_some_chars (string, count, col)
|
|||
char *string;
|
||||
int count, col;
|
||||
{
|
||||
#if defined (__MSDOS__) || defined (__MINGW32__)
|
||||
_rl_output_some_chars (string, count);
|
||||
#else
|
||||
/* DEBUGGING */
|
||||
if (MB_CUR_MAX == 1 || rl_byte_oriented)
|
||||
if (count != col)
|
||||
|
@ -1921,6 +2112,7 @@ insert_some_chars (string, count, col)
|
|||
if (_rl_term_ei && *_rl_term_ei)
|
||||
tputs (_rl_term_ei, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* __MSDOS__ || __MINGW32__ */
|
||||
}
|
||||
|
||||
/* Delete COUNT characters from the display line. */
|
||||
|
@ -1931,6 +2123,7 @@ delete_chars (count)
|
|||
if (count > _rl_screenwidth) /* XXX */
|
||||
return;
|
||||
|
||||
#if !defined (__MSDOS__) && !defined (__MINGW32__)
|
||||
if (_rl_term_DC && *_rl_term_DC)
|
||||
{
|
||||
char *buffer;
|
||||
|
@ -1943,6 +2136,7 @@ delete_chars (count)
|
|||
while (count--)
|
||||
tputs (_rl_term_dc, 1, _rl_output_character_function);
|
||||
}
|
||||
#endif /* !__MSDOS__ && !__MINGW32__ */
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1998,32 +2192,22 @@ static void
|
|||
redraw_prompt (t)
|
||||
char *t;
|
||||
{
|
||||
char *oldp, *oldl, *oldlprefix;
|
||||
int oldlen, oldlast, oldplen, oldninvis;
|
||||
char *oldp;
|
||||
|
||||
/* Geez, I should make this a struct. */
|
||||
oldp = rl_display_prompt;
|
||||
oldl = local_prompt;
|
||||
oldlprefix = local_prompt_prefix;
|
||||
oldlen = prompt_visible_length;
|
||||
oldplen = prompt_prefix_length;
|
||||
oldlast = prompt_last_invisible;
|
||||
oldninvis = prompt_invis_chars_first_line;
|
||||
rl_save_prompt ();
|
||||
|
||||
rl_display_prompt = t;
|
||||
local_prompt = expand_prompt (t, &prompt_visible_length,
|
||||
&prompt_last_invisible,
|
||||
&prompt_invis_chars_first_line);
|
||||
&prompt_invis_chars_first_line,
|
||||
&prompt_physical_chars);
|
||||
local_prompt_prefix = (char *)NULL;
|
||||
|
||||
rl_forced_update_display ();
|
||||
|
||||
rl_display_prompt = oldp;
|
||||
local_prompt = oldl;
|
||||
local_prompt_prefix = oldlprefix;
|
||||
prompt_visible_length = oldlen;
|
||||
prompt_prefix_length = oldplen;
|
||||
prompt_last_invisible = oldlast;
|
||||
prompt_invis_chars_first_line = oldninvis;
|
||||
rl_restore_prompt();
|
||||
}
|
||||
|
||||
/* Redisplay the current line after a SIGWINCH is received. */
|
||||
|
@ -2117,7 +2301,7 @@ _rl_current_display_line ()
|
|||
scan from the beginning of the string to take the state into account. */
|
||||
static int
|
||||
_rl_col_width (str, start, end)
|
||||
char *str;
|
||||
const char *str;
|
||||
int start, end;
|
||||
{
|
||||
wchar_t wc;
|
||||
|
@ -2133,7 +2317,7 @@ _rl_col_width (str, start, end)
|
|||
while (point < start)
|
||||
{
|
||||
tmp = mbrlen (str + point, max, &ps);
|
||||
if ((size_t)tmp == (size_t)-1 || (size_t)tmp == (size_t)-2)
|
||||
if (MB_INVALIDCH ((size_t)tmp))
|
||||
{
|
||||
/* In this case, the bytes are invalid or too short to compose a
|
||||
multibyte character, so we assume that the first byte represents
|
||||
|
@ -2145,8 +2329,8 @@ _rl_col_width (str, start, end)
|
|||
effect of mbstate is undefined. */
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
}
|
||||
else if (tmp == 0)
|
||||
break; /* Found '\0' */
|
||||
else if (MB_NULLWCH (tmp))
|
||||
break; /* Found '\0' */
|
||||
else
|
||||
{
|
||||
point += tmp;
|
||||
|
@ -2162,7 +2346,7 @@ _rl_col_width (str, start, end)
|
|||
while (point < end)
|
||||
{
|
||||
tmp = mbrtowc (&wc, str + point, max, &ps);
|
||||
if ((size_t)tmp == (size_t)-1 || (size_t)tmp == (size_t)-2)
|
||||
if (MB_INVALIDCH ((size_t)tmp))
|
||||
{
|
||||
/* In this case, the bytes are invalid or too short to compose a
|
||||
multibyte character, so we assume that the first byte represents
|
||||
|
@ -2177,8 +2361,8 @@ _rl_col_width (str, start, end)
|
|||
effect of mbstate is undefined. */
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
}
|
||||
else if (tmp == 0)
|
||||
break; /* Found '\0' */
|
||||
else if (MB_NULLWCH (tmp))
|
||||
break; /* Found '\0' */
|
||||
else
|
||||
{
|
||||
point += tmp;
|
||||
|
@ -2193,4 +2377,3 @@ _rl_col_width (str, start, end)
|
|||
return width;
|
||||
}
|
||||
#endif /* HANDLE_MULTIBYTE */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This makefile for Readline library documentation is in -*- text -*- mode.
|
||||
# Emacs likes it that way.
|
||||
|
||||
# Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2004 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
|
||||
|
@ -52,14 +52,18 @@ TEXI2DVI = $(srcdir)/texi2dvi
|
|||
TEXI2HTML = $(srcdir)/texi2html
|
||||
QUIETPS = #set this to -q to shut up dvips
|
||||
PAPERSIZE = letter
|
||||
PSDPI = 300 # I don't have any 600-dpi printers
|
||||
PSDPI = 600
|
||||
DVIPS = dvips -D ${PSDPI} $(QUIETPS) -t ${PAPERSIZE} -o $@ # tricky
|
||||
|
||||
RLSRC = $(srcdir)/rlman.texinfo $(srcdir)/rluser.texinfo \
|
||||
$(srcdir)/rltech.texinfo $(srcdir)/manvers.texinfo \
|
||||
$(srcdir)/rluserman.texinfo
|
||||
HISTSRC = $(srcdir)/hist.texinfo $(srcdir)/hsuser.texinfo \
|
||||
$(srcdir)/hstech.texinfo $(srcdir)/manvers.texinfo
|
||||
# These tools might not be available; they're not required
|
||||
DVIPDF = dvipdfm -o $@ -p ${PAPERSIZE}
|
||||
PSPDF = gs -sPAPERSIZE=${PAPERSIZE} -sDEVICE=pdfwrite -dNOPAUSE -dBATCH -sOutputFile=$@
|
||||
|
||||
RLSRC = $(srcdir)/rlman.texi $(srcdir)/rluser.texi \
|
||||
$(srcdir)/rltech.texi $(srcdir)/version.texi \
|
||||
$(srcdir)/rluserman.texi
|
||||
HISTSRC = $(srcdir)/history.texi $(srcdir)/hsuser.texi \
|
||||
$(srcdir)/hstech.texi $(srcdir)/version.texi
|
||||
|
||||
# This should be a program that converts troff to an ascii-readable format
|
||||
NROFF = groff -Tascii
|
||||
|
@ -72,39 +76,54 @@ INFOOBJ = readline.info history.info rluserman.info
|
|||
PSOBJ = readline.ps history.ps rluserman.ps readline_3.ps history_3.ps
|
||||
HTMLOBJ = readline.html history.html rluserman.html
|
||||
TEXTOBJ = readline.0 history.0
|
||||
PDFOBJ = readline.pdf history.pdf rluserman.pdf
|
||||
|
||||
INTERMEDIATE_OBJ = rlman.dvi hist.dvi rluserman.dvi
|
||||
INTERMEDIATE_OBJ = rlman.dvi
|
||||
|
||||
DIST_DOCS = $(DVIOBJ) $(PSOBJ) $(HTMLOBJ) $(INFOOBJ) $(TEXTOBJ)
|
||||
|
||||
.SUFFIXES: .0 .3 .ps .txt .dvi
|
||||
.SUFFIXES: .0 .3 .ps .txt .dvi .html .pdf
|
||||
|
||||
.3.0:
|
||||
$(RM) $@
|
||||
-${NROFF} -man $< > $@
|
||||
|
||||
.ps.pdf:
|
||||
$(RM) $@
|
||||
-${PSPDF} $<
|
||||
|
||||
.dvi.pdf:
|
||||
$(RM) $@
|
||||
-${DVIPDF} $<
|
||||
|
||||
all: info dvi html ps text
|
||||
nodvi: info html text
|
||||
|
||||
info: $(INFOOBJ)
|
||||
dvi: $(DVIOBJ)
|
||||
ps: $(PSOBJ)
|
||||
html: $(HTMLOBJ)
|
||||
text: $(TEXTOBJ)
|
||||
pdf: $(PDFOBJ)
|
||||
|
||||
readline.dvi: $(RLSRC)
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rlman.texinfo
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rlman.texi
|
||||
mv rlman.dvi readline.dvi
|
||||
|
||||
readline.info: $(RLSRC)
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rlman.texinfo
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rlman.texi
|
||||
|
||||
rluserman.dvi: $(RLSRC)
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rluserman.texinfo
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/rluserman.texi
|
||||
|
||||
rluserman.info: $(RLSRC)
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rluserman.texinfo
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/rluserman.texi
|
||||
|
||||
history.dvi: ${HISTSRC}
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/hist.texinfo
|
||||
mv hist.dvi history.dvi
|
||||
TEXINPUTS=.:$(TEXINPUTDIR):$$TEXINPUTS $(TEXI2DVI) $(srcdir)/history.texi
|
||||
|
||||
history.info: ${HISTSRC}
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/hist.texinfo
|
||||
$(MAKEINFO) --no-split -I $(TEXINPUTDIR) -o $@ $(srcdir)/history.texi
|
||||
|
||||
readline.ps: readline.dvi
|
||||
$(RM) $@
|
||||
|
@ -122,22 +141,15 @@ history.ps: 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
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rlman.texi
|
||||
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
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/rluserman.texi
|
||||
|
||||
history.html: ${HISTSRC}
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/hist.texinfo
|
||||
sed -e 's:hist.html:history.html:g' hist.html > history.html
|
||||
$(RM) hist.html
|
||||
|
||||
info: $(INFOOBJ)
|
||||
dvi: $(DVIOBJ)
|
||||
ps: $(PSOBJ)
|
||||
html: $(HTMLOBJ)
|
||||
text: $(TEXTOBJ)
|
||||
$(TEXI2HTML) -menu -monolithic -I $(TEXINPUTDIR) $(srcdir)/history.texi
|
||||
|
||||
readline.0: readline.3
|
||||
|
||||
|
@ -151,9 +163,14 @@ history_3.ps: history.3
|
|||
${RM} $@
|
||||
${GROFF} -man < $(srcdir)/history.3 > $@
|
||||
|
||||
readline.pdf: readline.dvi
|
||||
history.pdf: history.dvi
|
||||
rluserman.pdf: rluserman.dvi
|
||||
|
||||
clean:
|
||||
$(RM) *.aux *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps *.pgs \
|
||||
*.fns *.kys *.tps *.vrs *.bt *.bts *.o core *.core
|
||||
$(RM) *.aux *.bak *.cp *.fn *.ky *.log *.pg *.toc *.tp *.vr *.cps \
|
||||
*.pgs *.bt *.bts *.rw *.rws *.fns *.kys *.tps *.vrs *.o \
|
||||
core *.core
|
||||
|
||||
mostlyclean: clean
|
||||
|
||||
|
@ -169,6 +186,7 @@ maybe-clean:
|
|||
maintainer-clean: clean
|
||||
$(RM) $(DIST_DOCS)
|
||||
$(RM) $(INTERMEDIATE_OBJ)
|
||||
$(RM) $(PDFOBJ)
|
||||
$(RM) Makefile
|
||||
|
||||
installdirs: $(topdir)/support/mkdirs
|
||||
|
|
452
readline/doc/fdl.texi
Normal file
452
readline/doc/fdl.texi
Normal file
|
@ -0,0 +1,452 @@
|
|||
|
||||
@node GNU Free Documentation License
|
||||
@appendixsec GNU Free Documentation License
|
||||
|
||||
@cindex FDL, GNU Free Documentation License
|
||||
@center Version 1.2, November 2002
|
||||
|
||||
@display
|
||||
Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
@end display
|
||||
|
||||
@enumerate 0
|
||||
@item
|
||||
PREAMBLE
|
||||
|
||||
The purpose of this License is to make a manual, textbook, or other
|
||||
functional and useful document @dfn{free} in the sense of freedom: to
|
||||
assure everyone the effective freedom to copy and redistribute it,
|
||||
with or without modifying it, either commercially or noncommercially.
|
||||
Secondarily, this License preserves for the author and publisher a way
|
||||
to get credit for their work, while not being considered responsible
|
||||
for modifications made by others.
|
||||
|
||||
This License is a kind of ``copyleft'', which means that derivative
|
||||
works of the document must themselves be free in the same sense. It
|
||||
complements the GNU General Public License, which is a copyleft
|
||||
license designed for free software.
|
||||
|
||||
We have designed this License in order to use it for manuals for free
|
||||
software, because free software needs free documentation: a free
|
||||
program should come with manuals providing the same freedoms that the
|
||||
software does. But this License is not limited to software manuals;
|
||||
it can be used for any textual work, regardless of subject matter or
|
||||
whether it is published as a printed book. We recommend this License
|
||||
principally for works whose purpose is instruction or reference.
|
||||
|
||||
@item
|
||||
APPLICABILITY AND DEFINITIONS
|
||||
|
||||
This License applies to any manual or other work, in any medium, that
|
||||
contains a notice placed by the copyright holder saying it can be
|
||||
distributed under the terms of this License. Such a notice grants a
|
||||
world-wide, royalty-free license, unlimited in duration, to use that
|
||||
work under the conditions stated herein. The ``Document'', below,
|
||||
refers to any such manual or work. Any member of the public is a
|
||||
licensee, and is addressed as ``you''. You accept the license if you
|
||||
copy, modify or distribute the work in a way requiring permission
|
||||
under copyright law.
|
||||
|
||||
A ``Modified Version'' of the Document means any work containing the
|
||||
Document or a portion of it, either copied verbatim, or with
|
||||
modifications and/or translated into another language.
|
||||
|
||||
A ``Secondary Section'' is a named appendix or a front-matter section
|
||||
of the Document that deals exclusively with the relationship of the
|
||||
publishers or authors of the Document to the Document's overall
|
||||
subject (or to related matters) and contains nothing that could fall
|
||||
directly within that overall subject. (Thus, if the Document is in
|
||||
part a textbook of mathematics, a Secondary Section may not explain
|
||||
any mathematics.) The relationship could be a matter of historical
|
||||
connection with the subject or with related matters, or of legal,
|
||||
commercial, philosophical, ethical or political position regarding
|
||||
them.
|
||||
|
||||
The ``Invariant Sections'' are certain Secondary Sections whose titles
|
||||
are designated, as being those of Invariant Sections, in the notice
|
||||
that says that the Document is released under this License. If a
|
||||
section does not fit the above definition of Secondary then it is not
|
||||
allowed to be designated as Invariant. The Document may contain zero
|
||||
Invariant Sections. If the Document does not identify any Invariant
|
||||
Sections then there are none.
|
||||
|
||||
The ``Cover Texts'' are certain short passages of text that are listed,
|
||||
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
||||
the Document is released under this License. A Front-Cover Text may
|
||||
be at most 5 words, and a Back-Cover Text may be at most 25 words.
|
||||
|
||||
A ``Transparent'' copy of the Document means a machine-readable copy,
|
||||
represented in a format whose specification is available to the
|
||||
general public, that is suitable for revising the document
|
||||
straightforwardly with generic text editors or (for images composed of
|
||||
pixels) generic paint programs or (for drawings) some widely available
|
||||
drawing editor, and that is suitable for input to text formatters or
|
||||
for automatic translation to a variety of formats suitable for input
|
||||
to text formatters. A copy made in an otherwise Transparent file
|
||||
format whose markup, or absence of markup, has been arranged to thwart
|
||||
or discourage subsequent modification by readers is not Transparent.
|
||||
An image format is not Transparent if used for any substantial amount
|
||||
of text. A copy that is not ``Transparent'' is called ``Opaque''.
|
||||
|
||||
Examples of suitable formats for Transparent copies include plain
|
||||
@sc{ascii} without markup, Texinfo input format, La@TeX{} input
|
||||
format, @acronym{SGML} or @acronym{XML} using a publicly available
|
||||
@acronym{DTD}, and standard-conforming simple @acronym{HTML},
|
||||
PostScript or @acronym{PDF} designed for human modification. Examples
|
||||
of transparent image formats include @acronym{PNG}, @acronym{XCF} and
|
||||
@acronym{JPG}. Opaque formats include proprietary formats that can be
|
||||
read and edited only by proprietary word processors, @acronym{SGML} or
|
||||
@acronym{XML} for which the @acronym{DTD} and/or processing tools are
|
||||
not generally available, and the machine-generated @acronym{HTML},
|
||||
PostScript or @acronym{PDF} produced by some word processors for
|
||||
output purposes only.
|
||||
|
||||
The ``Title Page'' means, for a printed book, the title page itself,
|
||||
plus such following pages as are needed to hold, legibly, the material
|
||||
this License requires to appear in the title page. For works in
|
||||
formats which do not have any title page as such, ``Title Page'' means
|
||||
the text near the most prominent appearance of the work's title,
|
||||
preceding the beginning of the body of the text.
|
||||
|
||||
A section ``Entitled XYZ'' means a named subunit of the Document whose
|
||||
title either is precisely XYZ or contains XYZ in parentheses following
|
||||
text that translates XYZ in another language. (Here XYZ stands for a
|
||||
specific section name mentioned below, such as ``Acknowledgements'',
|
||||
``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title''
|
||||
of such a section when you modify the Document means that it remains a
|
||||
section ``Entitled XYZ'' according to this definition.
|
||||
|
||||
The Document may include Warranty Disclaimers next to the notice which
|
||||
states that this License applies to the Document. These Warranty
|
||||
Disclaimers are considered to be included by reference in this
|
||||
License, but only as regards disclaiming warranties: any other
|
||||
implication that these Warranty Disclaimers may have is void and has
|
||||
no effect on the meaning of this License.
|
||||
|
||||
@item
|
||||
VERBATIM COPYING
|
||||
|
||||
You may copy and distribute the Document in any medium, either
|
||||
commercially or noncommercially, provided that this License, the
|
||||
copyright notices, and the license notice saying this License applies
|
||||
to the Document are reproduced in all copies, and that you add no other
|
||||
conditions whatsoever to those of this License. You may not use
|
||||
technical measures to obstruct or control the reading or further
|
||||
copying of the copies you make or distribute. However, you may accept
|
||||
compensation in exchange for copies. If you distribute a large enough
|
||||
number of copies you must also follow the conditions in section 3.
|
||||
|
||||
You may also lend copies, under the same conditions stated above, and
|
||||
you may publicly display copies.
|
||||
|
||||
@item
|
||||
COPYING IN QUANTITY
|
||||
|
||||
If you publish printed copies (or copies in media that commonly have
|
||||
printed covers) of the Document, numbering more than 100, and the
|
||||
Document's license notice requires Cover Texts, you must enclose the
|
||||
copies in covers that carry, clearly and legibly, all these Cover
|
||||
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
||||
the back cover. Both covers must also clearly and legibly identify
|
||||
you as the publisher of these copies. The front cover must present
|
||||
the full title with all words of the title equally prominent and
|
||||
visible. You may add other material on the covers in addition.
|
||||
Copying with changes limited to the covers, as long as they preserve
|
||||
the title of the Document and satisfy these conditions, can be treated
|
||||
as verbatim copying in other respects.
|
||||
|
||||
If the required texts for either cover are too voluminous to fit
|
||||
legibly, you should put the first ones listed (as many as fit
|
||||
reasonably) on the actual cover, and continue the rest onto adjacent
|
||||
pages.
|
||||
|
||||
If you publish or distribute Opaque copies of the Document numbering
|
||||
more than 100, you must either include a machine-readable Transparent
|
||||
copy along with each Opaque copy, or state in or with each Opaque copy
|
||||
a computer-network location from which the general network-using
|
||||
public has access to download using public-standard network protocols
|
||||
a complete Transparent copy of the Document, free of added material.
|
||||
If you use the latter option, you must take reasonably prudent steps,
|
||||
when you begin distribution of Opaque copies in quantity, to ensure
|
||||
that this Transparent copy will remain thus accessible at the stated
|
||||
location until at least one year after the last time you distribute an
|
||||
Opaque copy (directly or through your agents or retailers) of that
|
||||
edition to the public.
|
||||
|
||||
It is requested, but not required, that you contact the authors of the
|
||||
Document well before redistributing any large number of copies, to give
|
||||
them a chance to provide you with an updated version of the Document.
|
||||
|
||||
@item
|
||||
MODIFICATIONS
|
||||
|
||||
You may copy and distribute a Modified Version of the Document under
|
||||
the conditions of sections 2 and 3 above, provided that you release
|
||||
the Modified Version under precisely this License, with the Modified
|
||||
Version filling the role of the Document, thus licensing distribution
|
||||
and modification of the Modified Version to whoever possesses a copy
|
||||
of it. In addition, you must do these things in the Modified Version:
|
||||
|
||||
@enumerate A
|
||||
@item
|
||||
Use in the Title Page (and on the covers, if any) a title distinct
|
||||
from that of the Document, and from those of previous versions
|
||||
(which should, if there were any, be listed in the History section
|
||||
of the Document). You may use the same title as a previous version
|
||||
if the original publisher of that version gives permission.
|
||||
|
||||
@item
|
||||
List on the Title Page, as authors, one or more persons or entities
|
||||
responsible for authorship of the modifications in the Modified
|
||||
Version, together with at least five of the principal authors of the
|
||||
Document (all of its principal authors, if it has fewer than five),
|
||||
unless they release you from this requirement.
|
||||
|
||||
@item
|
||||
State on the Title page the name of the publisher of the
|
||||
Modified Version, as the publisher.
|
||||
|
||||
@item
|
||||
Preserve all the copyright notices of the Document.
|
||||
|
||||
@item
|
||||
Add an appropriate copyright notice for your modifications
|
||||
adjacent to the other copyright notices.
|
||||
|
||||
@item
|
||||
Include, immediately after the copyright notices, a license notice
|
||||
giving the public permission to use the Modified Version under the
|
||||
terms of this License, in the form shown in the Addendum below.
|
||||
|
||||
@item
|
||||
Preserve in that license notice the full lists of Invariant Sections
|
||||
and required Cover Texts given in the Document's license notice.
|
||||
|
||||
@item
|
||||
Include an unaltered copy of this License.
|
||||
|
||||
@item
|
||||
Preserve the section Entitled ``History'', Preserve its Title, and add
|
||||
to it an item stating at least the title, year, new authors, and
|
||||
publisher of the Modified Version as given on the Title Page. If
|
||||
there is no section Entitled ``History'' in the Document, create one
|
||||
stating the title, year, authors, and publisher of the Document as
|
||||
given on its Title Page, then add an item describing the Modified
|
||||
Version as stated in the previous sentence.
|
||||
|
||||
@item
|
||||
Preserve the network location, if any, given in the Document for
|
||||
public access to a Transparent copy of the Document, and likewise
|
||||
the network locations given in the Document for previous versions
|
||||
it was based on. These may be placed in the ``History'' section.
|
||||
You may omit a network location for a work that was published at
|
||||
least four years before the Document itself, or if the original
|
||||
publisher of the version it refers to gives permission.
|
||||
|
||||
@item
|
||||
For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve
|
||||
the Title of the section, and preserve in the section all the
|
||||
substance and tone of each of the contributor acknowledgements and/or
|
||||
dedications given therein.
|
||||
|
||||
@item
|
||||
Preserve all the Invariant Sections of the Document,
|
||||
unaltered in their text and in their titles. Section numbers
|
||||
or the equivalent are not considered part of the section titles.
|
||||
|
||||
@item
|
||||
Delete any section Entitled ``Endorsements''. Such a section
|
||||
may not be included in the Modified Version.
|
||||
|
||||
@item
|
||||
Do not retitle any existing section to be Entitled ``Endorsements'' or
|
||||
to conflict in title with any Invariant Section.
|
||||
|
||||
@item
|
||||
Preserve any Warranty Disclaimers.
|
||||
@end enumerate
|
||||
|
||||
If the Modified Version includes new front-matter sections or
|
||||
appendices that qualify as Secondary Sections and contain no material
|
||||
copied from the Document, you may at your option designate some or all
|
||||
of these sections as invariant. To do this, add their titles to the
|
||||
list of Invariant Sections in the Modified Version's license notice.
|
||||
These titles must be distinct from any other section titles.
|
||||
|
||||
You may add a section Entitled ``Endorsements'', provided it contains
|
||||
nothing but endorsements of your Modified Version by various
|
||||
parties---for example, statements of peer review or that the text has
|
||||
been approved by an organization as the authoritative definition of a
|
||||
standard.
|
||||
|
||||
You may add a passage of up to five words as a Front-Cover Text, and a
|
||||
passage of up to 25 words as a Back-Cover Text, to the end of the list
|
||||
of Cover Texts in the Modified Version. Only one passage of
|
||||
Front-Cover Text and one of Back-Cover Text may be added by (or
|
||||
through arrangements made by) any one entity. If the Document already
|
||||
includes a cover text for the same cover, previously added by you or
|
||||
by arrangement made by the same entity you are acting on behalf of,
|
||||
you may not add another; but you may replace the old one, on explicit
|
||||
permission from the previous publisher that added the old one.
|
||||
|
||||
The author(s) and publisher(s) of the Document do not by this License
|
||||
give permission to use their names for publicity for or to assert or
|
||||
imply endorsement of any Modified Version.
|
||||
|
||||
@item
|
||||
COMBINING DOCUMENTS
|
||||
|
||||
You may combine the Document with other documents released under this
|
||||
License, under the terms defined in section 4 above for modified
|
||||
versions, provided that you include in the combination all of the
|
||||
Invariant Sections of all of the original documents, unmodified, and
|
||||
list them all as Invariant Sections of your combined work in its
|
||||
license notice, and that you preserve all their Warranty Disclaimers.
|
||||
|
||||
The combined work need only contain one copy of this License, and
|
||||
multiple identical Invariant Sections may be replaced with a single
|
||||
copy. If there are multiple Invariant Sections with the same name but
|
||||
different contents, make the title of each such section unique by
|
||||
adding at the end of it, in parentheses, the name of the original
|
||||
author or publisher of that section if known, or else a unique number.
|
||||
Make the same adjustment to the section titles in the list of
|
||||
Invariant Sections in the license notice of the combined work.
|
||||
|
||||
In the combination, you must combine any sections Entitled ``History''
|
||||
in the various original documents, forming one section Entitled
|
||||
``History''; likewise combine any sections Entitled ``Acknowledgements'',
|
||||
and any sections Entitled ``Dedications''. You must delete all
|
||||
sections Entitled ``Endorsements.''
|
||||
|
||||
@item
|
||||
COLLECTIONS OF DOCUMENTS
|
||||
|
||||
You may make a collection consisting of the Document and other documents
|
||||
released under this License, and replace the individual copies of this
|
||||
License in the various documents with a single copy that is included in
|
||||
the collection, provided that you follow the rules of this License for
|
||||
verbatim copying of each of the documents in all other respects.
|
||||
|
||||
You may extract a single document from such a collection, and distribute
|
||||
it individually under this License, provided you insert a copy of this
|
||||
License into the extracted document, and follow this License in all
|
||||
other respects regarding verbatim copying of that document.
|
||||
|
||||
@item
|
||||
AGGREGATION WITH INDEPENDENT WORKS
|
||||
|
||||
A compilation of the Document or its derivatives with other separate
|
||||
and independent documents or works, in or on a volume of a storage or
|
||||
distribution medium, is called an ``aggregate'' if the copyright
|
||||
resulting from the compilation is not used to limit the legal rights
|
||||
of the compilation's users beyond what the individual works permit.
|
||||
When the Document is included an aggregate, this License does not
|
||||
apply to the other works in the aggregate which are not themselves
|
||||
derivative works of the Document.
|
||||
|
||||
If the Cover Text requirement of section 3 is applicable to these
|
||||
copies of the Document, then if the Document is less than one half of
|
||||
the entire aggregate, the Document's Cover Texts may be placed on
|
||||
covers that bracket the Document within the aggregate, or the
|
||||
electronic equivalent of covers if the Document is in electronic form.
|
||||
Otherwise they must appear on printed covers that bracket the whole
|
||||
aggregate.
|
||||
|
||||
@item
|
||||
TRANSLATION
|
||||
|
||||
Translation is considered a kind of modification, so you may
|
||||
distribute translations of the Document under the terms of section 4.
|
||||
Replacing Invariant Sections with translations requires special
|
||||
permission from their copyright holders, but you may include
|
||||
translations of some or all Invariant Sections in addition to the
|
||||
original versions of these Invariant Sections. You may include a
|
||||
translation of this License, and all the license notices in the
|
||||
Document, and any Warranty Disclaimers, provided that you also include
|
||||
the original English version of this License and the original versions
|
||||
of those notices and disclaimers. In case of a disagreement between
|
||||
the translation and the original version of this License or a notice
|
||||
or disclaimer, the original version will prevail.
|
||||
|
||||
If a section in the Document is Entitled ``Acknowledgements'',
|
||||
``Dedications'', or ``History'', the requirement (section 4) to Preserve
|
||||
its Title (section 1) will typically require changing the actual
|
||||
title.
|
||||
|
||||
@item
|
||||
TERMINATION
|
||||
|
||||
You may not copy, modify, sublicense, or distribute the Document except
|
||||
as expressly provided for under this License. Any other attempt to
|
||||
copy, modify, sublicense or distribute the Document is void, and will
|
||||
automatically terminate your rights under this License. However,
|
||||
parties who have received copies, or rights, from you under this
|
||||
License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
@item
|
||||
FUTURE REVISIONS OF THIS LICENSE
|
||||
|
||||
The Free Software Foundation may publish new, revised versions
|
||||
of the GNU Free Documentation License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns. See
|
||||
@uref{http://www.gnu.org/copyleft/}.
|
||||
|
||||
Each version of the License is given a distinguishing version number.
|
||||
If the Document specifies that a particular numbered version of this
|
||||
License ``or any later version'' applies to it, you have the option of
|
||||
following the terms and conditions either of that specified version or
|
||||
of any later version that has been published (not as a draft) by the
|
||||
Free Software Foundation. If the Document does not specify a version
|
||||
number of this License, you may choose any version ever published (not
|
||||
as a draft) by the Free Software Foundation.
|
||||
@end enumerate
|
||||
|
||||
@page
|
||||
@appendixsubsec ADDENDUM: How to use this License for your documents
|
||||
|
||||
To use this License in a document you have written, include a copy of
|
||||
the License in the document and put the following copyright and
|
||||
license notices just after the title page:
|
||||
|
||||
@smallexample
|
||||
@group
|
||||
Copyright (C) @var{year} @var{your name}.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.2
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled ``GNU
|
||||
Free Documentation License''.
|
||||
@end group
|
||||
@end smallexample
|
||||
|
||||
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
|
||||
replace the ``with...Texts.'' line with this:
|
||||
|
||||
@smallexample
|
||||
@group
|
||||
with the Invariant Sections being @var{list their titles}, with
|
||||
the Front-Cover Texts being @var{list}, and with the Back-Cover Texts
|
||||
being @var{list}.
|
||||
@end group
|
||||
@end smallexample
|
||||
|
||||
If you have Invariant Sections without Cover Texts, or some other
|
||||
combination of the three, merge those two alternatives to suit the
|
||||
situation.
|
||||
|
||||
If your document contains nontrivial examples of program code, we
|
||||
recommend releasing these examples in parallel under your choice of
|
||||
free software license, such as the GNU General Public License,
|
||||
to permit their use in free software.
|
||||
|
||||
@c Local Variables:
|
||||
@c ispell-local-pdict: "ispell-dict"
|
||||
@c End:
|
||||
|
|
@ -1,219 +1,160 @@
|
|||
HISTORY(3) HISTORY(3)
|
||||
|
||||
|
||||
|
||||
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.
|
||||
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.
|
||||
Many programs read input from the user a line at a time. The GNU His-
|
||||
tory 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.
|
||||
|
||||
|
||||
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.
|
||||
The history library supports a history expansion feature that is iden-
|
||||
tical 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 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.
|
||||
|
||||
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.
|
||||
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 sec-
|
||||
ond 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 sev-
|
||||
eral words that would otherwise be separated are considered one word
|
||||
when surrounded by quotes (see the description of hhiissttoorryy__ttookkeenniizzee(())
|
||||
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.
|
||||
An event designator is a reference to a command line entry in the his-
|
||||
tory list.
|
||||
|
||||
!! Start a history substitution, except when followed
|
||||
by a bbllaannkk, newline, = or (.
|
||||
!! 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)
|
||||
|
||||
|
||||
!!!! Refer to the previous command. This is a synonym for `!-1'.
|
||||
!!_s_t_r_i_n_g
|
||||
Refer to the most recent command starting with
|
||||
_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.
|
||||
Refer to the most recent command containing _s_t_r_i_n_g. The trail-
|
||||
ing ?? may be omitted if _s_t_r_i_n_g is followed immediately by a new-
|
||||
line.
|
||||
^^_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).
|
||||
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 MMoodd--
|
||||
iiffiieerrss 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.
|
||||
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 sepa-
|
||||
rated by single spaces.
|
||||
|
||||
00 ((zzeerroo))
|
||||
The zeroth word. For the shell, this is the com-
|
||||
mand word.
|
||||
The zeroth word. For the shell, this is the command 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.
|
||||
%% 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.
|
||||
** 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.
|
||||
If a word designator is supplied without an event specification, 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 `:'.
|
||||
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.
|
||||
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.
|
||||
qq Quote the substituted words, escaping further substitutions.
|
||||
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.
|
||||
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
|
||||
backslash. If & appears in _n_e_w, it is replaced by _o_l_d. A sin-
|
||||
gle 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 substitu-
|
||||
tions 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.
|
||||
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. An aa may be used as a synonym for gg.
|
||||
GG Apply the following `ss' modifier once to each word in the event
|
||||
line.
|
||||
|
||||
PPRROOGGRRAAMMMMIINNGG WWIITTHH HHIISSTTOORRYY FFUUNNCCTTIIOONNSS
|
||||
This section describes how to use the History library in
|
||||
other programs.
|
||||
This section describes how to use the History library in other pro-
|
||||
grams.
|
||||
|
||||
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 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 _e_x_p_a_n_s_i_o_n function is avail-
|
||||
able which provides for a consistent user interface 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.
|
||||
The user using programs written with the History library has the bene-
|
||||
fit 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 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.
|
||||
If the programmer desires, he can use the Readline library, which
|
||||
includes some history manipulation by default, and has the added advan-
|
||||
tage of command line editing.
|
||||
|
||||
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.
|
||||
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 supplies extern declarations for all of the
|
||||
library's public functions and variables, and declares all of the pub-
|
||||
lic data structures.
|
||||
|
||||
|
||||
HHiissttoorryy SSttoorraaggee
|
||||
The history list is an array of history entries. A his-
|
||||
tory entry is declared as follows:
|
||||
The history list is an array of history entries. A history entry is
|
||||
declared as follows:
|
||||
|
||||
_t_y_p_e_d_e_f _v_o_i_d _* hhiissttddaattaa__tt;;
|
||||
|
||||
typedef struct _hist_entry {
|
||||
char *line;
|
||||
char *timestamp;
|
||||
histdata_t data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
|
@ -221,8 +162,8 @@ HISTORY(3) HISTORY(3)
|
|||
|
||||
_H_I_S_T___E_N_T_R_Y _*_* tthhee__hhiissttoorryy__lliisstt;;
|
||||
|
||||
The state of the History library is encapsulated into a
|
||||
single structure:
|
||||
The state of the History library is encapsulated into a single struc-
|
||||
ture:
|
||||
|
||||
/*
|
||||
* A structure used to pass around the current state of the history.
|
||||
|
@ -235,368 +176,285 @@ HISTORY(3) HISTORY(3)
|
|||
int flags;
|
||||
} HISTORY_STATE;
|
||||
|
||||
If the flags member includes HHSS__SSTTIIFFLLEEDD, the history has
|
||||
been stifled.
|
||||
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.
|
||||
This section describes the calling sequence for the various 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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
Place _s_t_r_i_n_g at the end of the history list. The associated data field
|
||||
(if any) is set to NNUULLLL.
|
||||
|
||||
_v_o_i_d aadddd__hhiissttoorryy__ttiimmee (_c_o_n_s_t _c_h_a_r _*_s_t_r_i_n_g)
|
||||
Change the time stamp associated with the most recent history entry to
|
||||
_s_t_r_i_n_g.
|
||||
|
||||
_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.
|
||||
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
|
||||
_h_i_s_t_d_a_t_a___t ffrreeee__hhiissttoorryy__eennttrryy (_H_I_S_T___E_N_T_R_Y _*_h_i_s_t_e_n_t)
|
||||
Free the history entry _h_i_s_t_e_n_t and any history library private data
|
||||
associated with it. Returns the application-specific data so the
|
||||
caller can dispose of it.
|
||||
|
||||
_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 the caller can dispose of any application-spe-
|
||||
cific 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.
|
||||
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.
|
||||
Stop stifling the history. This returns the previously-set maximum
|
||||
number of history entries (as set by ssttiiffllee__hhiissttoorryy(())). history was
|
||||
stifled. The value is positive 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.
|
||||
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.
|
||||
These functions return information about the entire history 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.
|
||||
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.
|
||||
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.
|
||||
Return the history entry at position _o_f_f_s_e_t, starting from hhiiss--
|
||||
ttoorryy__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.
|
||||
|
||||
_t_i_m_e___t hhiissttoorryy__ggeett__ttiimmee (_H_I_S_T___E_N_T_R_Y _*)
|
||||
Return the time stamp associated with the history entry passed as the
|
||||
argument.
|
||||
|
||||
_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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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.
|
||||
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 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.
|
||||
These functions allow searching of the history list for entries con-
|
||||
taining a specific string. Searching may be performed both forward and
|
||||
backward from the current history 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.
|
||||
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 subsequent 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
|
||||
_i_n_t hhiissttoorryy__sseeaarrcchh__pprreeffiixx (_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.
|
||||
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.
|
||||
|
||||
|
||||
|
||||
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.
|
||||
_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.
|
||||
The History library can read the history from and write it to a file.
|
||||
This section documents the functions for managing 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.
|
||||
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
|
||||
_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.
|
||||
Write the current history to _f_i_l_e_n_a_m_e, overwriting _f_i_l_e_n_a_m_e if neces-
|
||||
sary. 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.
|
||||
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.
|
||||
_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 truncated. Returns 0 on suc-
|
||||
cess, 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);
|
||||
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.
|
||||
2 if the returned line should be displayed, but not exe-
|
||||
cuted, 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 _* 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'' terminating charac-
|
||||
ters.
|
||||
|
||||
_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.
|
||||
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 hhiiss--
|
||||
ttoorryy__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(()).
|
||||
_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.
|
||||
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)
|
||||
|
||||
The number of entries currently stored in the history list.
|
||||
|
||||
_i_n_t hhiissttoorryy__mmaaxx__eennttrriieess
|
||||
The maximum number of history entries. This must be
|
||||
changed using ssttiiffllee__hhiissttoorryy(()).
|
||||
The maximum number of history entries. This must be changed using ssttii--
|
||||
ffllee__hhiissttoorryy(()).
|
||||
|
||||
_i_n_t hhiissttoorryy__wwrriittee__ttiimmeessttaammppss
|
||||
If non-zero, timestamps are written to the history file, so they can be
|
||||
preserved between sessions. The default value is 0, meaning that
|
||||
timestamps are not saved.
|
||||
|
||||
_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.
|
||||
The character that introduces a history event. The default is !!. Set-
|
||||
ting this to 0 inhibits history expansion.
|
||||
|
||||
_c_h_a_r hhiissttoorryy__ssuubbsstt__cchhaarr
|
||||
The character that invokes word substitution if found at
|
||||
the start of a line. The default is ^^.
|
||||
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.
|
||||
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.
|
||||
|
||||
_c_h_a_r _* hhiissttoorryy__wwoorrdd__ddeelliimmiitteerrss
|
||||
The characters that separate tokens for hhiissttoorryy__ttookk--
|
||||
eenniizzee(()). The default value is "" \\tt\\nn(())<<>>;;&&||"".
|
||||
The characters that separate tokens for hhiissttoorryy__ttookkeenniizzee(()). 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 ==.
|
||||
The list of characters which inhibit history expansion if found immedi-
|
||||
ately 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.
|
||||
The list of additional characters which can delimit a history 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.
|
||||
If non-zero, single-quoted words are not scanned for the history expan-
|
||||
sion 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.
|
||||
This should be set to the address of a function that takes two argu-
|
||||
ments: 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 performed; 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)
|
||||
|
||||
Default filename for reading and writing saved history
|
||||
|
||||
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
|
||||
|
@ -612,49 +470,19 @@ AAUUTTHHOORRSS
|
|||
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.
|
||||
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
|
||||
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.
|
||||
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
|
||||
|
||||
|
||||
GNU History 5.0 2003 July 31 HISTORY(3)
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
.\" Case Western Reserve University
|
||||
.\" chet@ins.CWRU.Edu
|
||||
.\"
|
||||
.\" Last Change: Thu Jan 31 16:08:07 EST 2002
|
||||
.\" Last Change: Thu Jul 31 08:46:08 EDT 2003
|
||||
.\"
|
||||
.TH HISTORY 3 "2002 January 31" "GNU History 4.3"
|
||||
.TH HISTORY 3 "2003 July 31" "GNU History 5.0"
|
||||
.\"
|
||||
.\" File Name macro. This used to be `.PN', for Path Name,
|
||||
.\" but Sun doesn't seem to like that very much.
|
||||
|
@ -249,6 +249,10 @@ 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.
|
||||
An \fBa\fP may be used as a synonym for \fBg\fP.
|
||||
.TP
|
||||
.B G
|
||||
Apply the following `\fBs\fP' modifier once to each word in the event line.
|
||||
.PD
|
||||
.SH "PROGRAMMING WITH HISTORY FUNCTIONS"
|
||||
This section describes how to use the History library in other programs.
|
||||
|
@ -292,6 +296,7 @@ declared as follows:
|
|||
.nf
|
||||
typedef struct _hist_entry {
|
||||
char *line;
|
||||
char *timestamp;
|
||||
histdata_t data;
|
||||
} HIST_ENTRY;
|
||||
.fi
|
||||
|
@ -345,14 +350,24 @@ parameters managing the list itself.
|
|||
Place \fIstring\fP at the end of the history list. The associated data
|
||||
field (if any) is set to \fBNULL\fP.
|
||||
|
||||
.Fn1 void add_history_time "const char *string"
|
||||
Change the time stamp associated with the most recent history entry to
|
||||
\fIstring\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.
|
||||
|
||||
.Fn1 "histdata_t" free_history_entry "HIST_ENTRY *histent"
|
||||
Free the history entry \fIhistent\fP and any history library private
|
||||
data associated with it. Returns the application-specific data
|
||||
so the caller can dispose of it.
|
||||
|
||||
.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
|
||||
This returns the old entry so the caller can dispose of any
|
||||
application-specific data. In the case
|
||||
of an invalid \fIwhich\fP, a \fBNULL\fP pointer is returned.
|
||||
|
||||
.Fn1 void clear_history "void"
|
||||
|
@ -394,6 +409,9 @@ Return the history entry at position \fIoffset\fP, starting from
|
|||
If there is no entry there, or if \fIoffset\fP
|
||||
is greater than the history length, return a \fBNULL\fP pointer.
|
||||
|
||||
.Fn1 "time_t" history_get_time "HIST_ENTRY *"
|
||||
Return the time stamp associated with the history entry passed as the argument.
|
||||
|
||||
.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
|
||||
|
@ -551,6 +569,11 @@ The number of entries currently stored in the history list.
|
|||
The maximum number of history entries. This must be changed using
|
||||
\fBstifle_history()\fP.
|
||||
|
||||
.Vb int history_write_timestamps
|
||||
If non-zero, timestamps are written to the history file, so they can be
|
||||
preserved between sessions. The default value is 0, meaning that
|
||||
timestamps are not saved.
|
||||
|
||||
.Vb char history_expansion_char
|
||||
The character that introduces a history event. The default is \fB!\fP.
|
||||
Setting this to 0 inhibits history expansion.
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
BIN
readline/doc/history.pdf
Normal file
BIN
readline/doc/history.pdf
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load diff
104
readline/doc/history.texi
Normal file
104
readline/doc/history.texi
Normal file
|
@ -0,0 +1,104 @@
|
|||
\input texinfo @c -*-texinfo-*-
|
||||
@c %**start of header (This is for running Texinfo on a region.)
|
||||
@setfilename history.info
|
||||
@settitle GNU History Library
|
||||
@c %**end of header (This is for running Texinfo on a region.)
|
||||
|
||||
@setchapternewpage odd
|
||||
|
||||
@include version.texi
|
||||
|
||||
@copying
|
||||
This document describes the GNU History library
|
||||
(version @value{VERSION}, @value{UPDATED}),
|
||||
a programming tool that provides a consistent user interface for
|
||||
recalling lines of previously typed input.
|
||||
|
||||
Copyright @copyright{} 1988-2004 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
are preserved on all copies.
|
||||
|
||||
@quotation
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.1 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
|
||||
and with the Back-Cover Texts as in (a) below. A copy of the license is
|
||||
included in the section entitled ``GNU Free Documentation License.''
|
||||
|
||||
(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
|
||||
this GNU Manual, like GNU software. Copies published by the Free
|
||||
Software Foundation raise funds for GNU development.''
|
||||
@end quotation
|
||||
@end copying
|
||||
|
||||
@dircategory Libraries
|
||||
@direntry
|
||||
* History: (history). The GNU history library API.
|
||||
@end direntry
|
||||
|
||||
@titlepage
|
||||
@title GNU History Library
|
||||
@subtitle Edition @value{EDITION}, for @code{History Library} Version @value{VERSION}.
|
||||
@subtitle @value{UPDATED-MONTH}
|
||||
@author Chet Ramey, Case Western Reserve University
|
||||
@author Brian Fox, Free Software Foundation
|
||||
|
||||
@page
|
||||
|
||||
@vskip 0pt plus 1filll
|
||||
@insertcopying
|
||||
|
||||
@sp 1
|
||||
Published by the Free Software Foundation @*
|
||||
59 Temple Place, Suite 330, @*
|
||||
Boston, MA 02111-1307 @*
|
||||
USA @*
|
||||
|
||||
@end titlepage
|
||||
|
||||
@contents
|
||||
|
||||
@ifnottex
|
||||
@node Top
|
||||
@top GNU History Library
|
||||
|
||||
This document describes the GNU History library, a programming tool that
|
||||
provides a consistent user interface for recalling lines of previously
|
||||
typed input.
|
||||
|
||||
@menu
|
||||
* Using History Interactively:: GNU History User's Manual.
|
||||
* Programming with GNU History:: GNU History Programmer's Manual.
|
||||
* Copying This Manual:: Copying This Manual.
|
||||
* Concept Index:: Index of concepts described in this manual.
|
||||
* Function and Variable Index:: Index of externally visible functions
|
||||
and variables.
|
||||
@end menu
|
||||
@end ifnottex
|
||||
|
||||
@syncodeindex fn vr
|
||||
|
||||
@include hsuser.texi
|
||||
@include hstech.texi
|
||||
|
||||
@node Copying This Manual
|
||||
@appendix Copying This Manual
|
||||
|
||||
@menu
|
||||
* GNU Free Documentation License:: License for copying this manual.
|
||||
@end menu
|
||||
|
||||
@include fdl.texi
|
||||
|
||||
@node Concept Index
|
||||
@appendix Concept Index
|
||||
@printindex cp
|
||||
|
||||
@node Function and Variable Index
|
||||
@appendix Function and Variable Index
|
||||
@printindex vr
|
||||
|
||||
@bye
|
|
@ -1,16 +1,16 @@
|
|||
%!PS-Adobe-3.0
|
||||
%%Creator: groff version 1.16.1
|
||||
%%CreationDate: Mon Mar 18 10:17:27 2002
|
||||
%%Creator: groff version 1.18.1
|
||||
%%CreationDate: Mon Sep 22 09:15:44 2003
|
||||
%%DocumentNeededResources: font Times-Roman
|
||||
%%+ font Times-Bold
|
||||
%%+ font Times-Italic
|
||||
%%DocumentSuppliedResources: procset grops 1.16 1
|
||||
%%DocumentSuppliedResources: procset grops 1.18 1
|
||||
%%Pages: 7
|
||||
%%PageOrder: Ascend
|
||||
%%Orientation: Portrait
|
||||
%%EndComments
|
||||
%%BeginProlog
|
||||
%%BeginResource: procset grops 1.16 1
|
||||
%%BeginResource: procset grops 1.18 1
|
||||
/setpacking where{
|
||||
pop
|
||||
currentpacking
|
||||
|
@ -108,11 +108,20 @@ TM setmatrix
|
|||
/ST/stroke load def
|
||||
/MT/moveto load def
|
||||
/CL/closepath load def
|
||||
/FL{
|
||||
currentgray exch setgray fill setgray
|
||||
/Fr{
|
||||
setrgbcolor fill
|
||||
}bind def
|
||||
/BL/fill load def
|
||||
/Fk{
|
||||
setcmykcolor fill
|
||||
}bind def
|
||||
/Fg{
|
||||
setgray fill
|
||||
}bind def
|
||||
/FL/fill load def
|
||||
/LW/setlinewidth load def
|
||||
/Cr/setrgbcolor load def
|
||||
/Ck/setcmykcolor load def
|
||||
/Cg/setgray load def
|
||||
/RE{
|
||||
findfont
|
||||
dup maxlength 1 index/FontName known not{1 add}if dict begin
|
||||
|
@ -171,7 +180,7 @@ setpacking
|
|||
%%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
|
||||
/scaron/zcaron/Ydieresis/trademark/quotesingle/Euro/.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
|
||||
|
@ -262,16 +271,16 @@ command line entry in the history list.).15 E F2(!)108 422.4 Q F0
|
|||
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
|
||||
E F0(.).22 E F2(!?)108 482.4 Q F3(string)A F2([?])A F0 1.022
|
||||
(Refer to the most recent command containing)144 494.4 R F3(string)3.522
|
||||
E F0 6.022(.T).22 G 1.022(he trailing)-6.022 F F2(?)3.522 E F0 1.022
|
||||
(may be omitted if)3.522 F F3(string)3.862 E F0(is)3.742 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
|
||||
2.63(Quick substitution.)144 530.4 R 2.629
|
||||
(Repeat the last command, replacing)7.629 F F3(string1)5.469 E F0(with)
|
||||
5.129 E F3(string2)5.129 E F0 7.629(.E).02 G(qui)-7.629 E -.25(va)-.25 G
|
||||
2.629(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
|
||||
|
@ -290,14 +299,14 @@ F3(string2)A F0(/')A 2.5('\()-.74 G(see)-2.5 E F2(Modi\214ers)2.5 E F0
|
|||
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
|
||||
(n)108.36 660 Q F0(The)30.64 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.77 708 Q F2<ad>A F3(y)A F0 2.5(Ar)20.65 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 5.0)72 768 Q
|
||||
(2003 July 31)139.005 E(1)203.165 E 0 Cg EP
|
||||
%%Page: 2 2
|
||||
%%BeginPageSetup
|
||||
BP
|
||||
|
@ -333,468 +342,488 @@ E -.15(xe)-.15 G(cute it.).15 E F1(q)108 254.4 Q F0
|
|||
-.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
|
||||
F2(ne)A(w)-.15 E F1(/)A F0(Substitute)144 290.4 Q F2(ne)3.082 E(w)-.15 E
|
||||
F0 .221(for the \214rst occurrence of)3.032 F F2(old)2.951 E F0 .221
|
||||
(in the e)3.491 F -.15(ve)-.25 G .221(nt line.).15 F(An)5.221 E 2.721
|
||||
(yd)-.15 G .221(elimiter can be used in place)-2.721 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
|
||||
F .666(be quoted in)144 314.4 R F2(old)3.396 E F0(and)3.936 E F2(ne)
|
||||
3.526 E(w)-.15 E F0 .666(with a single backslash.)3.476 F .666
|
||||
(If & appears in)5.666 F F2(ne)3.166 E(w)-.15 E F0 3.166(,i).31 G 3.166
|
||||
(ti)-3.166 G 3.166(sr)-3.166 G .666(eplaced by)-3.166 F F2(old)3.166 E
|
||||
F0 5.666(.A).77 G .274(single backslash will quote the &.)144 326.4 R
|
||||
(If)5.274 E F2(old)3.004 E F0 .274(is null, it is set to the last)3.544
|
||||
F F2(old)3.005 E F0 .275(substituted, or)3.545 F 2.775(,i)-.4 G 2.775
|
||||
(fn)-2.775 G 2.775(op)-2.775 G(re)-2.775 E(vi-)-.25 E
|
||||
(ous history substitutions took place, the last)144 338.4 Q F2(string)
|
||||
2.84 E F0(in a)2.72 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 .09
|
||||
(delimiter is optional if it is the last character of the e)144 386.4 R
|
||||
-.15(ve)-.25 G .089(nt line.).15 F(An)5.089 E F1(a)2.589 E F0 .089
|
||||
(may be used as a synon)2.589 F .089(ym for)-.15 F F1(g)144 398.4 Q F0
|
||||
(.)A F1(G)108 410.4 Q F0(Apply the follo)28.22 E(wing `)-.25 E F1(s)A F0
|
||||
2.5('m)C(odi\214er once to each w)-2.5 E(ord in the e)-.1 E -.15(ve)-.25
|
||||
G(nt line.).15 E/F3 10.95/Times-Bold@0 SF(PR)72 427.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
|
||||
E F0(This section describes ho)108 439.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 456 Q
|
||||
(oduction to History)-.18 E F0 .796
|
||||
(The programmer using the History library has a)108 468 R -.25(va)-.2 G
|
||||
.797(ilable functions for remembering lines on a history list,).25 F
|
||||
.308(associating arbitrary data with a line, remo)108 480 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
|
||||
-.15 F .303(taining an arbitrary te)108 492 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
|
||||
.303(ddition, a history)-2.803 F F2 -.2(ex)2.803 G(pansion).2 E F0
|
||||
(function is a)108 504 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
|
||||
History library has the bene\214t of a consistent user interf)108 520.8
|
||||
R .058(ace with a)-.1 F .917(set of well-kno)108 532.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
|
||||
(vious lines and using that te)-.25 F .917(xt in ne)-.15 F 3.418(wc)-.25
|
||||
G(om-)-3.418 E 4.184(mands. The)108 544.8 R 1.684(basic history manipul\
|
||||
ation commands are identical to the history substitution pro)4.184 F
|
||||
1.683(vided by)-.15 F F1(bash)108 556.8 Q F0(.)A .903
|
||||
(If the programmer desires, he can use the Readline library)108 573.6 R
|
||||
3.403(,w)-.65 G .904(hich includes some history manipulation by)-3.403 F
|
||||
(def)108 585.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
|
||||
602.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
|
||||
(vides in other code, an appli-)-.15 F .066
|
||||
(cation writer should include the \214le)108 614.4 R F2(<r)4.232 E
|
||||
(eadline/history)-.37 E(.h>)-.55 E F0 .067(in an)4.232 F 2.567<798c>-.15
|
||||
G .067(le that uses the History library')-2.567 F 2.567(sf)-.55 G
|
||||
(eatures.)-2.567 E .539(It supplies e)108 626.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
|
||||
(ublic functions and v)-3.038 F .538(ariables, and declares all of the)
|
||||
-.25 F(public data structures.)108 638.4 Q F1(History Storage)87 667.2 Q
|
||||
F0(The history list is an array of history entries.)108 679.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
|
||||
108 696 Q F1(histdata_t;)2.5 E F0(typedef struct _hist_entry {)108 712.8
|
||||
Q(char *line;)113 724.8 Q(GNU History 5.0)72 768 Q(2003 July 31)139.005
|
||||
E(2)203.165 E 0 Cg 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
|
||||
(OR)-.18 E(Y\(3\))-.65 E(char *timestamp;)113 84 Q(histdata_t data;)113
|
||||
96 Q 2.5(}H)108 108 S(IST_ENTR)-2.5 E -.92(Y;)-.65 G
|
||||
(The history list itself might therefore be declared as)108 124.8 Q/F1
|
||||
10/Times-Italic@0 SF(HIST_ENTR)108 141.6 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
|
||||
brary is encapsulated into a single structure:)108 158.4 Q(/*)108 175.2
|
||||
Q 2.5(*As)110.5 187.2 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
|
||||
-.65 E(*/)110.5 199.2 Q(typedef struct _hist_state {)108 211.2 Q
|
||||
(HIST_ENTR)113 223.2 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
|
||||
(int of)113 235.2 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
|
||||
(int length;)113 247.2 Q(/* Number of elements within this array)27.5 E
|
||||
2.5(.*)-.65 G(/)-2.5 E(int size;)113 259.2 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
|
||||
E(int \215ags;)113 271.2 Q 2.5(}H)108 283.2 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 300
|
||||
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 316.8 Q F0
|
||||
(This section describes the calling sequence for the v)108 328.8 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
|
||||
-.65 E F2(Initializing History and State Management)87 345.6 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
|
||||
te of the History library when you)108 357.6 R -.1(wa)108 369.6 S
|
||||
(nt to use the history functions in your program.).1 E F1(void)108 393.6
|
||||
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
|
||||
405.6 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
|
||||
F1(HIST)108 429.6 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)
|
||||
108 441.6 Q(.)-.65 E F1(void)108 465.6 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 \
|
||||
(Set the state of the history list according to)108 477.6 Q F1(state)2.5
|
||||
E F0(.)A F2(History List Management)87 506.4 Q F0
|
||||
(These functions manage indi)108 518.4 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
|
||||
542.4 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 554.4 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
|
||||
2.5 E F0(.)A F1(void)108 578.4 Q F2(add_history_time)2.5 E F0(\()4.166 E
|
||||
F1(const c)A(har *string)-.15 E F0(\))1.666 E
|
||||
(Change the time stamp associated with the most recent history entry to)
|
||||
108 590.4 Q F1(string)2.5 E F0(.)A F1(HIST_ENTR)108 614.4 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 626.4 Q .353 -.15(ve h)-.15
|
||||
H .053(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 .052(lement is returned so you can free the)
|
||||
-2.553 F(line, data, and containing structure.)108 638.4 Q F1
|
||||
(histdata_t)108 662.4 Q F2(fr)2.5 E(ee_history_entry)-.18 E F0(\()4.166
|
||||
E F1(HIST_ENTR)A 2.5(Y*)-.18 G(histent)-2.5 E F0(\))1.666 E .933
|
||||
(Free the history entry)108 674.4 R F1(histent)3.433 E F0 .933(and an)
|
||||
3.433 F 3.433(yh)-.15 G .933(istory library pri)-3.433 F -.25(va)-.25 G
|
||||
.933(te data associated with it.).25 F .934(Returns the applica-)5.933 F
|
||||
(tion-speci\214c data so the caller can dispose of it.)108 686.4 Q F1
|
||||
(HIST_ENTR)108 710.4 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 722.4 Q 4.014(et)-.1 G 1.514(he history entry at of)-4.014 F
|
||||
(fset)-.25 E F1(whic)4.013 E(h)-.15 E F0(ha)4.013 E -.15(ve)-.2 G F1
|
||||
(line)4.163 E F0(and)4.013 E F1(data)4.013 E F0 6.513(.T)C 1.513
|
||||
(his returns the old entry so the caller can)-6.513 F(GNU History 5.0)72
|
||||
768 Q(2003 July 31)139.005 E(3)203.165 E 0 Cg 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
|
||||
(OR)-.18 E(Y\(3\))-.65 E(dispose of an)108 84 Q 2.5(ya)-.15 G
|
||||
(pplication-speci\214c data.)-2.5 E(In the case of an in)5 E -.25(va)-.4
|
||||
G(lid).25 E/F1 10/Times-Italic@0 SF(whic)2.5 E(h)-.15 E F0 2.5(,a)C/F2
|
||||
10/Times-Bold@0 SF(NULL)A F0(pointer is returned.)2.5 E F1(void)108 108
|
||||
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 120 Q F1(void)
|
||||
108 144 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 156 Q
|
||||
F1(max)2.5 E F0(entries.)2.5 E F1(int)108 180 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 192 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 204 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 F1(int)108 228 Q F2(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
|
||||
240 Q F2(Inf)87 268.8 Q(ormation About the History List)-.25 E F0(These\
|
||||
functions return information about the entire history list or indi)108
|
||||
280.8 Q(vidual list entries.)-.25 E F1(HIST_ENTR)108 304.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)
|
||||
.708(Return a)108 316.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.)
|
||||
(lement 0 of this)-5.707 F(list is the be)108 328.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
|
||||
E F0(.)A F1(int)108 352.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 364.8 Q
|
||||
(fset of the current history element.)-.25 E F1(HIST_ENTR)108 388.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*)
|
||||
400.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 412.8 Q F2
|
||||
(NULL)2.5 E F0(pointer)2.5 E(.)-.55 E F1(HIST_ENTR)108 436.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)
|
||||
1.666 E .288(Return the history entry at position)108 448.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
|
||||
(is greater than the history length, return a)108 460.8 Q F2(NULL)2.5 E
|
||||
F0(pointer)2.5 E(.)-.55 E F1(time_t)108 484.8 Q F2(history_get_time)2.5
|
||||
E F0(\()4.166 E F1(HIST_ENTR)A 2.5(Y*)-.18 G F0(\))-.834 E(Return the t\
|
||||
ime stamp associated with the history entry passed as the ar)108 496.8 Q
|
||||
(gument.)-.18 E F1(int)108 520.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
|
||||
108 532.8 R .392(This function returns the sum of the)5.392 F
|
||||
(lengths of all the lines in the history)108 544.8 Q(.)-.65 E F2(Mo)87
|
||||
573.6 Q(ving Ar)-.1 E(ound the History List)-.18 E F0
|
||||
(These functions allo)108 585.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
|
||||
108 609.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 621.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
|
||||
(than zero or greater than the number of history entries.)108 633.6 Q F1
|
||||
(HIST_ENTR)108 657.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
|
||||
(Back up the current history of)108 669.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
|
||||
-5.208 G .208(here is)-2.708 F(no pre)108 681.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
|
||||
(HIST_ENTR)108 705.6 Q 2.5(Y*)-.18 G F2(next_history)A F0(\()4.166 E F1
|
||||
(void)A F0(\))1.666 E(Mo)108 717.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
|
||||
E(there is no ne)108 729.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(GNU History 5.0)72 768 Q
|
||||
(2003 July 31)139.005 E(4)203.165 E 0 Cg 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
|
||||
(OR)-.18 E(Y\(3\))-.65 E/F1 10/Times-Bold@0 SF(Sear)87 84 Q
|
||||
(ching the History List)-.18 E F0 .005(These functions allo)108 96 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 108 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/F2 10/Times-Italic@0 SF(anc)3.951 E(hor)-.15 E(ed)-.37 E F0(,)A
|
||||
(meaning that the string must match at the be)108 120 Q
|
||||
(ginning of the history entry)-.15 E(.)-.65 E F2(int)108 144 Q F1
|
||||
(history_sear)2.5 E(ch)-.18 E F0(\()4.166 E F2(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 156 R F2(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 F2
|
||||
(dir)2.656 E(ection)-.37 E F0 .156(is less than 0, then the search)2.656
|
||||
F .802(is through pre)108 168 R .802
|
||||
(vious entries, otherwise through subsequent entries.)-.25 F(If)5.801 E
|
||||
F2(string)3.301 E F0 .801(is found, then the current his-)3.301 F .064
|
||||
(tory inde)108 180 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 F2(string)2.565 E F0 -.1(wa)
|
||||
108 192 S 2.5(sf).1 G 2.5(ound. Otherwise,)-2.5 F
|
||||
(nothing is changed, and a -1 is returned.)2.5 E F2(int)108 216 Q F1
|
||||
(history_sear)2.5 E(ch_pr)-.18 E(e\214x)-.18 E F0(\()4.166 E F2(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 228 R F2(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 1.063(must be)108
|
||||
240 R 1.063(gin with)-.15 F F2(string)3.563 E F0 6.063(.I)C(f)-6.063 E
|
||||
F2(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
|
||||
252 R(If)6.115 E F2(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
|
||||
(nd the)-3.614 F(return v)108 264 Q(alue is 0.)-.25 E
|
||||
(Otherwise, nothing is changed, and a -1 is returned.)5 E F2(int)108 288
|
||||
Q F1(history_sear)2.5 E(ch_pos)-.18 E F0(\()4.166 E F2(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 300 R F2(string)3.103
|
||||
E F0 .603(in the history list, starting at)3.103 F F2(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 F2(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 312 R .608(ard from)-.1 F F2(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 324 Q F2(string)2.5 E F0 -.1
|
||||
(wa)2.5 G 2.5(sf).1 G(ound, or -1 otherwise.)-2.5 E F1
|
||||
(Managing the History File)87 352.8 Q F0 .035(The History library can r\
|
||||
ead the history from and write it to a \214le.)108 364.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
|
||||
(managing a history \214le.)108 376.8 Q F2(int)108 400.8 Q F1 -.18(re)
|
||||
2.5 G(ad_history).18 E F0(\()4.166 E F2(const c)A(har *\214lename)-.15 E
|
||||
F0(\))1.666 E .151(Add the contents of)108 412.8 R F2(\214lename)2.651 E
|
||||
F0 .151(to the history list, a line at a time.)2.651 F(If)5.15 E F2
|
||||
(\214lename)2.65 E F0(is)2.65 E F1(NULL)2.65 E F0 2.65(,t)C .15
|
||||
(hen read from)-2.65 F F2(~/.his-)2.65 E(tory)108 424.8 Q F0 5(.R)C
|
||||
(eturns 0 if successful, or)-5 E F1(err)2.5 E(no)-.15 E F0(if not.)2.5 E
|
||||
F2(int)108 448.8 Q F1 -.18(re)2.5 G(ad_history_range).18 E F0(\()4.166 E
|
||||
F2(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
|
||||
108 460.8 R F2(\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
|
||||
5.053 F F2(fr)2.553 E(om)-.45 E F0 .053(and end at)2.553 F F2(to)2.553 E
|
||||
F0(.)A(If)108 472.8 Q F2(fr)2.889 E(om)-.45 E F0 .389
|
||||
(is zero, start at the be)2.889 F 2.889(ginning. If)-.15 F F2(to)2.889 E
|
||||
F0 .389(is less than)2.889 F F2(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 F2
|
||||
(\214lename)2.888 E F0(is)108 484.8 Q F1(NULL)2.5 E F0 2.5(,t)C
|
||||
(hen read from)-2.5 E F2(~/.history)2.5 E F0 5(.R)C
|
||||
(eturns 0 if successful, or)-5 E F1(err)2.5 E(no)-.15 E F0(if not.)2.5 E
|
||||
F2(int)108 508.8 Q F1(write_history)2.5 E F0(\()4.166 E F2(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
|
||||
108 520.8 R F2(\214lename)3.461 E F0 3.461(,o)C -.15(ve)-3.611 G
|
||||
(rwriting).15 E F2(\214lename)3.461 E F0 .961(if necessary)3.461 F 5.961
|
||||
(.I)-.65 G(f)-5.961 E F2(\214lename)3.462 E F0(is)3.462 E F1(NULL)3.462
|
||||
E F0 3.462(,t)C .962(hen write)-3.462 F(the history list to)108 532.8 Q
|
||||
F2(~/.history)2.5 E F0 5(.R)C(eturns 0 on success, or)-5 E F1(err)2.5 E
|
||||
(no)-.15 E F0(on a read or write error)2.5 E(.)-.55 E F2(int)108 568.8 Q
|
||||
F1(append_history)2.5 E F0(\()4.166 E F2(int nelements,)A(const c)1.666
|
||||
E(har *\214lename)-.15 E F0(\))1.666 E .839(Append the last)108 580.8 R
|
||||
F2(nelements)3.339 E F0 .839(of the history list to)3.339 F F2
|
||||
(\214lename)3.339 E F0 5.839(.I)C(f)-5.839 E F2(\214lename)3.339 E F0
|
||||
(is)3.339 E F1(NULL)3.339 E F0 3.339(,t)C .838(hen append to)-3.339 F F2
|
||||
(~/.history)3.338 E F0(.)A(Returns 0 on success, or)108 592.8 Q F1(err)
|
||||
2.5 E(no)-.15 E F0(on a read or write error)2.5 E(.)-.55 E F2(int)108
|
||||
616.8 Q F1(history_truncate_\214le)2.5 E F0(\()4.166 E F2(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
|
||||
-.35(Tr)108 628.8 S .38(uncate the history \214le).35 F F2(\214lename)
|
||||
2.88 E F0 2.88(,l)C(ea)-2.88 E .38(ving only the last)-.2 F F2(nlines)
|
||||
2.881 E F0 2.881(lines. If)2.881 F F2(\214lename)2.881 E F0(is)2.881 E
|
||||
F1(NULL)2.881 E F0 2.881(,t)C(hen)-2.881 E F2(~/.history)2.881 E F0(is)
|
||||
2.881 E 2.5(truncated. Returns)108 640.8 R 2.5(0o)2.5 G 2.5(ns)-2.5 G
|
||||
(uccess, or)-2.5 E F1(err)2.5 E(no)-.15 E F0(on f)2.5 E(ailure.)-.1 E F1
|
||||
(History Expansion)87 669.6 Q F0(These functions implement history e)108
|
||||
681.6 Q(xpansion.)-.15 E F2(int)108 705.6 Q F1(history_expand)2.5 E F0
|
||||
(\()4.166 E F2 -.15(ch)C(ar *string).15 E 1.666(,c)-.1 G(har **output)
|
||||
-1.816 E F0(\))1.666 E(Expand)108 717.6 Q F2(string)2.5 E F0 2.5(,p)C
|
||||
(lacing the result into)-2.5 E F2(output)2.5 E F0 2.5(,ap)C
|
||||
(ointer to a string.)-2.5 E(Returns:)5 E(GNU History 5.0)72 768 Q
|
||||
(2003 July 31)139.005 E(5)203.165 E 0 Cg 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
|
||||
(OR)-.18 E(Y\(3\))-.65 E 31(0I)144 84 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 96 Q
|
||||
(xpansion character\);)-.15 E 31(1i)144 108 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 120
|
||||
R(there w)2.5 E(as an error in e)-.1 E(xpansion;)-.15 E 31(2i)144 132 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/F1 10/Times-Bold@0 SF(:p)2.5 E
|
||||
F0(modi\214er)2.5 E(.)-.55 E(If an error ocurred in e)108 144 Q
|
||||
(xpansion, then)-.15 E/F2 10/Times-Italic@0 SF(output)2.5 E F0
|
||||
(contains a descripti)2.5 E .3 -.15(ve e)-.25 H(rror message.).15 E F2
|
||||
-.15(ch)108 168 S(ar *).15 E F1(get_history_e)2.5 E -.1(ve)-.15 G(nt).1
|
||||
E F0(\()4.166 E F2(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 180 R .262(xt of the history e)-.15 F -.15(ve)
|
||||
-.25 G .262(nt be).15 F .263(ginning at)-.15 F F2(string)2.763 E F0(+)
|
||||
2.763 E F2(*cinde)2.763 E(x)-.2 E F0(.)A F2(*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 192
|
||||
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 F2(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 F2(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 204 R(gins.)-.15 E F2(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 216 Q F2 -.15(ch)108 240 S(ar **).15 E F1
|
||||
(history_tok)2.5 E(enize)-.1 E F0(\()4.166 E F2(const c)A(har *string)
|
||||
-.15 E F0(\))1.666 E .239(Return an array of tok)108 252 R .239
|
||||
(ens parsed out of)-.1 F F2(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 264 Q F1(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
|
||||
(yed.)-.15 E F2 -.15(ch)108 288 S(ar *).15 E F1(history_ar)2.5 E
|
||||
(g_extract)-.1 E F0(\()4.166 E F2(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
|
||||
(Extract a string se)108 300 R .025(gment consisting of the)-.15 F F2
|
||||
<8c72>2.526 E(st)-.1 E F0(through)2.526 E F2(last)2.526 E F0(ar)2.526 E
|
||||
.026(guments present in)-.18 F F2(string)2.526 E F0 5.026(.A)C -.18(rg)
|
||||
-5.026 G .026(uments are split).18 F(using)108 312 Q F1(history_tok)2.5
|
||||
E(enize\(\))-.1 E F0(.)A F1(History V)87 340.8 Q(ariables)-.92 E F0
|
||||
(This section describes the e)108 352.8 Q(xternally-visible v)-.15 E
|
||||
(ariables e)-.25 E(xported by the GNU History Library)-.15 E(.)-.65 E F2
|
||||
(int)108 376.8 Q F1(history_base)2.5 E F0(The logical of)108 388.8 Q
|
||||
(fset of the \214rst entry in the history list.)-.25 E F2(int)108 412.8
|
||||
Q F1(history_length)2.5 E F0
|
||||
(The number of entries currently stored in the history list.)108 424.8 Q
|
||||
F2(int)108 448.8 Q F1(history_max_entries)2.5 E F0
|
||||
(The maximum number of history entries.)108 460.8 Q
|
||||
(This must be changed using)5 E F1(sti\215e_history\(\))2.5 E F0(.)A F2
|
||||
(int)108 484.8 Q F1(history_write_timestamps)2.5 E F0 1.468
|
||||
(If non-zero, timestamps are written to the history \214le, so the)108
|
||||
496.8 R 3.968(yc)-.15 G 1.468(an be preserv)-3.968 F 1.468
|
||||
(ed between sessions.)-.15 F(The)6.468 E(def)108 508.8 Q(ault v)-.1 E
|
||||
(alue is 0, meaning that timestamps are not sa)-.25 E -.15(ve)-.2 G(d.)
|
||||
.15 E F2 -.15(ch)108 532.8 S(ar).15 E F1(history_expansion_char)2.5 E F0
|
||||
(The character that introduces a history e)108 544.8 Q -.15(ve)-.25 G
|
||||
2.5(nt. The).15 F(def)2.5 E(ault is)-.1 E F1(!)2.5 E F0 5(.S)C
|
||||
(etting this to 0 inhibits history e)-5 E(xpansion.)-.15 E F2 -.15(ch)
|
||||
108 568.8 S(ar).15 E F1(history_subst_char)2.5 E F0
|
||||
(The character that in)108 580.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
|
||||
(ault is)-.1 E F1(^)2.5 E F0(.)A F2 -.15(ch)108 604.8 S(ar).15 E F1
|
||||
(history_comment_char)2.5 E F0 .116(During tok)108 616.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
|
||||
-.1 F .117(ord, then it and all subsequent char)-.1 F(-)-.2 E .277
|
||||
(acters up to a ne)108 628.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
|
||||
(xpansion for the remainder of the line.)-.15 F .276(This is dis-)5.276
|
||||
F(abled by def)108 640.8 Q(ault.)-.1 E F2 -.15(ch)108 664.8 S(ar *).15 E
|
||||
F1(history_w)2.5 E(ord_delimiters)-.1 E F0
|
||||
(The characters that separate tok)108 676.8 Q(ens for)-.1 E F1
|
||||
(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
|
||||
(alue is)-.25 E F1 2.5("\\)2.5 G(t\\n\(\)<>;&|")-2.5 E F0(.)A F2 -.15
|
||||
(ch)108 700.8 S(ar *).15 E F1(history_no_expand_chars)2.5 E F0 2.054
|
||||
(The list of characters which inhibit history e)108 712.8 R 2.054
|
||||
(xpansion if found immediately follo)-.15 F(wing)-.25 E F1
|
||||
(history_expan-)4.555 E(sion_char)108 724.8 Q F0 5(.T)C(he def)-5 E
|
||||
(ault is space, tab, ne)-.1 E(wline,)-.25 E F1(\\r)2.5 E F0 2.5(,a)C(nd)
|
||||
-2.5 E F1(=)2.5 E F0(.)A(GNU History 5.0)72 768 Q(2003 July 31)139.005 E
|
||||
(6)203.165 E 0 Cg 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
|
||||
(OR)-.18 E(Y\(3\))-.65 E/F1 10/Times-Italic@0 SF -.15(ch)108 84 S(ar *)
|
||||
.15 E/F2 10/Times-Bold@0 SF(history_sear)2.5 E(ch_delimiter_chars)-.18 E
|
||||
F0 .401(The list of additional characters which can delimit a history s\
|
||||
earch string, in addition to space, tab,)108 96 R F1(:)2.901 E F0(and)
|
||||
2.901 E F1(?)2.901 E F0(in the case of a substring search.)108 108 Q
|
||||
(The def)5 E(ault is empty)-.1 E(.)-.65 E F1(int)108 132 Q F2
|
||||
(history_quotes_inhibit_expansion)2.5 E F0 .624
|
||||
(If non-zero, single-quoted w)108 144 R .625
|
||||
(ords are not scanned for the history e)-.1 F .625(xpansion character)
|
||||
-.15 F 5.625(.T)-.55 G .625(he def)-5.625 F .625(ault v)-.1 F .625
|
||||
(alue is)-.25 F(0.)108 156 Q F1(rl_lineb)108 180 Q(uf_func_t *)-.2 E F2
|
||||
(history_inhibit_expansion_function)2.5 E F0 .348
|
||||
(This should be set to the address of a function that tak)108 192 R .348
|
||||
(es tw)-.1 F 2.848(oa)-.1 G -.18(rg)-2.848 G .347(uments: a).18 F F2
|
||||
.347(char *)2.847 F F0(\()2.847 E F1(string)A F0 2.847(\)a)C .347(nd an)
|
||||
-2.847 F F2(int)2.847 E F0(inde)2.847 E(x)-.15 E .227
|
||||
(into that string \()108 204 R F1(i)A F0 2.727(\). 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.728 E F0 .228
|
||||
(should not)2.728 F .019(be performed; zero if the e)108 216 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 .018(that use)2.519 F(the history e)108 228 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 244.8 Q F1(~/.history)109.666 256.8 Q F0
|
||||
(Def)144 268.8 Q(ault \214lename for reading and writing sa)-.1 E -.15
|
||||
(ve)-.2 G 2.5(dh).15 G(istory)-2.5 E F3(SEE ALSO)72 285.6 Q F1
|
||||
(The Gnu Readline Libr)108 297.6 Q(ary)-.15 E F0 2.5(,B)C(rian F)-2.5 E
|
||||
(ox and Chet Rame)-.15 E(y)-.15 E F1(The Gnu History Libr)108 309.6 Q
|
||||
(ary)-.15 E F0 2.5(,B)C(rian F)-2.5 E(ox and Chet Rame)-.15 E(y)-.15 E
|
||||
F1(bash)108 321.6 Q F0(\(1\))A F1 -.37(re)108 333.6 S(adline).37 E F0
|
||||
(\(3\))A F3 -.548(AU)72 350.4 S(THORS).548 E F0(Brian F)108 362.4 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
|
||||
374.4 Q(g)-.18 E(Chet Rame)108 391.2 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
|
||||
(chet@ins.CWR)108 403.2 Q(U.Edu)-.4 E F3 -.11(BU)72 420 S 2.738(GR).11 G
|
||||
(EPOR)-2.738 E(TS)-.438 E F0 .16(If you \214nd a b)108 432 R .16
|
||||
(ug in the)-.2 F F2(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 444 S
|
||||
(ug, and that it appears in the latest v)-2.7 E(ersion of the)-.15 E F2
|
||||
(history)2.5 E F0(library that you ha)2.5 E -.15(ve)-.2 G(.).15 E .705
|
||||
(Once you ha)108 460.8 R 1.005 -.15(ve d)-.2 H .705(etermined that a b)
|
||||
.15 F .704(ug actually e)-.2 F .704(xists, mail a b)-.15 F .704
|
||||
(ug report to)-.2 F F1 -.2(bu)3.204 G(g\255r).2 E(eadline)-.37 E F0(@)A
|
||||
F1(gnu.or)A(g)-.37 E F0 5.704(.I)C 3.204(fy)-5.704 G(ou)-3.204 E(ha)108
|
||||
472.8 Q 1.809 -.15(ve a \214)-.2 H 1.509
|
||||
(x, you are welcome to mail that as well!).15 F 1.51
|
||||
(Suggestions and `philosophical' b)6.51 F 1.51(ug reports may be)-.2 F
|
||||
(mailed to)108 484.8 Q F1 -.2(bu)2.5 G(g-r).2 E(eadline)-.37 E F0(@)A F1
|
||||
(gnu.or)A(g)-.37 E F0(or posted to the Usenet ne)2.5 E(wsgroup)-.25 E F2
|
||||
(gnu.bash.b)2.5 E(ug)-.2 E F0(.)A(Comments and b)108 501.6 Q
|
||||
(ug reports concerning this manual page should be directed to)-.2 E F1
|
||||
-.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
|
||||
(GNU History 5.0)72 768 Q(2003 July 31)139.005 E(7)203.165 E 0 Cg EP
|
||||
%%Trailer
|
||||
end
|
||||
%%EOF
|
||||
|
|
573
readline/doc/hstech.texi
Normal file
573
readline/doc/hstech.texi
Normal file
|
@ -0,0 +1,573 @@
|
|||
@ignore
|
||||
This file documents the user interface to the GNU History library.
|
||||
|
||||
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
|
||||
provided the copyright notice and this permission notice are preserved on
|
||||
all copies.
|
||||
|
||||
Permission is granted to process this file through Tex and print the
|
||||
results, provided the printed document carries copying permission notice
|
||||
identical to this one except for the removal of this paragraph (this
|
||||
paragraph not being relevant to the printed manual).
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided also that the
|
||||
GNU Copyright statement is available to the distributee, and provided that
|
||||
the entire resulting derived work is distributed under the terms of a
|
||||
permission notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions.
|
||||
@end ignore
|
||||
|
||||
@node Programming with GNU History
|
||||
@chapter Programming with GNU History
|
||||
|
||||
This chapter describes how to interface programs that you write
|
||||
with the @sc{gnu} History Library.
|
||||
It should be considered a technical guide.
|
||||
For information on the interactive use of @sc{gnu} History, @pxref{Using
|
||||
History Interactively}.
|
||||
|
||||
@menu
|
||||
* Introduction to History:: What is the GNU History library for?
|
||||
* History Storage:: How information is stored.
|
||||
* History Functions:: Functions that you can use.
|
||||
* History Variables:: Variables that control behaviour.
|
||||
* History Programming Example:: Example of using the GNU History Library.
|
||||
@end menu
|
||||
|
||||
@node Introduction to History
|
||||
@section Introduction to History
|
||||
|
||||
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
|
||||
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 @dfn{expansion} function
|
||||
is available which provides for a consistent user interface 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 previous lines and using that text
|
||||
in new commands. The basic history manipulation commands are similar to
|
||||
the history substitution provided by @code{csh}.
|
||||
|
||||
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.
|
||||
|
||||
Before declaring any functions using any functionality the History
|
||||
library provides in other code, an application writer should include
|
||||
the file @code{<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.
|
||||
|
||||
@node History Storage
|
||||
@section History Storage
|
||||
|
||||
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 *timestamp;
|
||||
histdata_t data;
|
||||
@} HIST_ENTRY;
|
||||
@end example
|
||||
|
||||
The history list itself might therefore be declared as
|
||||
|
||||
@example
|
||||
HIST_ENTRY **the_history_list;
|
||||
@end example
|
||||
|
||||
The state of the History library is encapsulated into a single structure:
|
||||
|
||||
@example
|
||||
/*
|
||||
* 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;
|
||||
@end example
|
||||
|
||||
If the flags member includes @code{HS_STIFLED}, the history has been
|
||||
stifled.
|
||||
|
||||
@node History Functions
|
||||
@section History Functions
|
||||
|
||||
This section describes the calling sequence for the various functions
|
||||
exported by the @sc{gnu} History library.
|
||||
|
||||
@menu
|
||||
* Initializing History and State Management:: Functions to call when you
|
||||
want to use history in a
|
||||
program.
|
||||
* History List Management:: Functions used to manage the list
|
||||
of history entries.
|
||||
* Information About the History List:: Functions returning information about
|
||||
the history list.
|
||||
* Moving Around the History List:: Functions used to change the position
|
||||
in the history list.
|
||||
* Searching the History List:: Functions to search the history list
|
||||
for entries containing a string.
|
||||
* Managing the History File:: Functions that read and write a file
|
||||
containing the history list.
|
||||
* History Expansion:: Functions to perform csh-like history
|
||||
expansion.
|
||||
@end menu
|
||||
|
||||
@node Initializing History and State Management
|
||||
@subsection 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.
|
||||
|
||||
@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 (void)
|
||||
Return a structure describing the current state of the input history.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void history_set_history_state (HISTORY_STATE *state)
|
||||
Set the state of the history list according to @var{state}.
|
||||
@end deftypefun
|
||||
|
||||
@node History List Management
|
||||
@subsection History List Management
|
||||
|
||||
These functions manage individual entries on the history list, or set
|
||||
parameters managing the list itself.
|
||||
|
||||
@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
|
||||
|
||||
@deftypefun void add_history_time (const char *string)
|
||||
Change the time stamp associated with the most recent history entry to
|
||||
@var{string}.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {HIST_ENTRY *} remove_history (int which)
|
||||
Remove history entry at offset @var{which} from the history. The
|
||||
removed element is returned so you can free the line, data,
|
||||
and containing structure.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {histdata_t} free_history_entry (HIST_ENTRY *histent)
|
||||
Free the history entry @var{histent} and any history library private
|
||||
data associated with it. Returns the application-specific data
|
||||
so the caller can dispose of it.
|
||||
@end deftypefun
|
||||
|
||||
@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 the caller can dispose of any
|
||||
application-specific data. In the case
|
||||
of an invalid @var{which}, a @code{NULL} pointer is returned.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void clear_history (void)
|
||||
Clear the history list by deleting all the entries.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun void stifle_history (int max)
|
||||
Stifle the history list, remembering only the last @var{max} entries.
|
||||
@end deftypefun
|
||||
|
||||
@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 (void)
|
||||
Returns non-zero if the history is stifled, zero if it is not.
|
||||
@end deftypefun
|
||||
|
||||
@node Information About the History List
|
||||
@subsection Information About the History List
|
||||
|
||||
These functions return information about the entire history list or
|
||||
individual list entries.
|
||||
|
||||
@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 (void)
|
||||
Returns the offset of the current history element.
|
||||
@end deftypefun
|
||||
|
||||
@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}
|
||||
pointer.
|
||||
@end deftypefun
|
||||
|
||||
@deftypefun {HIST_ENTRY *} history_get (int offset)
|
||||
Return the history entry at position @var{offset}, starting from
|
||||
@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 time_t history_get_time (HIST_ENTRY *entry)
|
||||
Return the time stamp associated with the history entry @var{entry}.
|
||||
@end deftypefun
|
||||
|
||||
@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.
|
||||
@end deftypefun
|
||||
|
||||
@node Moving Around the History List
|
||||
@subsection Moving Around the History List
|
||||
|
||||
These functions allow the current index into the history list to be
|
||||
set or changed.
|
||||
|
||||
@deftypefun int history_set_pos (int pos)
|
||||
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 (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 (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.
|
||||
@end deftypefun
|
||||
|
||||
@node Searching the History List
|
||||
@subsection Searching the History List
|
||||
@cindex History Searching
|
||||
|
||||
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 @dfn{anchored},
|
||||
meaning that the string must match at the beginning of the history entry.
|
||||
@cindex anchored search
|
||||
|
||||
@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 (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} 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 (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
|
||||
index of the history element where @var{string} was found, or -1 otherwise.
|
||||
@end deftypefun
|
||||
|
||||
@node Managing the History File
|
||||
@subsection 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.
|
||||
|
||||
@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 (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
|
||||
@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 (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}.
|
||||
Returns 0 on success, or @code{errno} on a read or write error.
|
||||
@end deftypefun
|
||||
|
||||
@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 (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 history expansion.
|
||||
|
||||
@deftypefun int history_expand (char *string, char **output)
|
||||
Expand @var{string}, placing the result into @var{output}, a pointer
|
||||
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 removal of escape characters preceding the history expansion
|
||||
character);
|
||||
@item 1
|
||||
if expansions did take place;
|
||||
@item -1
|
||||
if there was an error in expansion;
|
||||
@item 2
|
||||
if the returned line should be displayed, but not executed,
|
||||
as with the @code{:p} modifier (@pxref{Modifiers}).
|
||||
@end table
|
||||
|
||||
If an error ocurred in expansion, then @var{output} contains a descriptive
|
||||
error message.
|
||||
@end deftypefun
|
||||
|
||||
@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
|
||||
@var{string} where the history event specification begins. @var{qchar}
|
||||
is a character that is allowed to end the event specification in addition
|
||||
to the ``normal'' terminating characters.
|
||||
@end deftypefun
|
||||
|
||||
@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 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 @sc{gnu} History Library.
|
||||
|
||||
@deftypevar int history_base
|
||||
The logical offset of the first entry in the history list.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int history_length
|
||||
The number of entries currently stored in the history list.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int history_max_entries
|
||||
The maximum number of history entries. This must be changed using
|
||||
@code{stifle_history()}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int history_write_timestamps
|
||||
If non-zero, timestamps are written to the history file, so they can be
|
||||
preserved between sessions. The default value is 0, meaning that
|
||||
timestamps are not saved.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar char history_expansion_char
|
||||
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
|
||||
The character that invokes word substitution if found at the start of
|
||||
a line. The default is @samp{^}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar 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.
|
||||
@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_search_delimiter_chars
|
||||
The list of additional characters which can delimit a history search
|
||||
string, in addition to space, TAB, @samp{:} and @samp{?} in the case of
|
||||
a substring search. The default is empty.
|
||||
@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 space, tab, newline,
|
||||
carriage return, and @samp{=}.
|
||||
@end deftypevar
|
||||
|
||||
@deftypevar int history_quotes_inhibit_expansion
|
||||
If non-zero, single-quoted words are not scanned for the history expansion
|
||||
character. The default value is 0.
|
||||
@end deftypevar
|
||||
|
||||
@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 @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 @code{NULL}.
|
||||
@end deftypevar
|
||||
|
||||
@node History Programming Example
|
||||
@section History Programming Example
|
||||
|
||||
The following program demonstrates simple use of the @sc{gnu} History Library.
|
||||
|
||||
@smallexample
|
||||
#include <stdio.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
@{
|
||||
char line[1024], *t;
|
||||
int len, done = 0;
|
||||
|
||||
line[0] = 0;
|
||||
|
||||
using_history ();
|
||||
while (!done)
|
||||
@{
|
||||
printf ("history$ ");
|
||||
fflush (stdout);
|
||||
t = fgets (line, sizeof (line) - 1, stdin);
|
||||
if (t && *t)
|
||||
@{
|
||||
len = strlen (t);
|
||||
if (t[len - 1] == '\n')
|
||||
t[len - 1] = '\0';
|
||||
@}
|
||||
|
||||
if (!t)
|
||||
strcpy (line, "quit");
|
||||
|
||||
if (line[0])
|
||||
@{
|
||||
char *expansion;
|
||||
int result;
|
||||
|
||||
result = history_expand (line, &expansion);
|
||||
if (result)
|
||||
fprintf (stderr, "%s\n", expansion);
|
||||
|
||||
if (result < 0 || result == 2)
|
||||
@{
|
||||
free (expansion);
|
||||
continue;
|
||||
@}
|
||||
|
||||
add_history (expansion);
|
||||
strncpy (line, expansion, sizeof (line) - 1);
|
||||
free (expansion);
|
||||
@}
|
||||
|
||||
if (strcmp (line, "quit") == 0)
|
||||
done = 1;
|
||||
else if (strcmp (line, "save") == 0)
|
||||
write_history ("history_file");
|
||||
else if (strcmp (line, "read") == 0)
|
||||
read_history ("history_file");
|
||||
else if (strcmp (line, "list") == 0)
|
||||
@{
|
||||
register HIST_ENTRY **the_list;
|
||||
register int i;
|
||||
|
||||
the_list = history_list ();
|
||||
if (the_list)
|
||||
for (i = 0; the_list[i]; i++)
|
||||
printf ("%d: %s\n", i + history_base, the_list[i]->line);
|
||||
@}
|
||||
else if (strncmp (line, "delete", 6) == 0)
|
||||
@{
|
||||
int which;
|
||||
if ((sscanf (line + 6, "%d", &which)) == 1)
|
||||
@{
|
||||
HIST_ENTRY *entry = remove_history (which);
|
||||
if (!entry)
|
||||
fprintf (stderr, "No such entry %d\n", which);
|
||||
else
|
||||
@{
|
||||
free (entry->line);
|
||||
free (entry);
|
||||
@}
|
||||
@}
|
||||
else
|
||||
@{
|
||||
fprintf (stderr, "non-numeric arg given to `delete'\n");
|
||||
@}
|
||||
@}
|
||||
@}
|
||||
@}
|
||||
@end smallexample
|
457
readline/doc/hsuser.texi
Normal file
457
readline/doc/hsuser.texi
Normal file
|
@ -0,0 +1,457 @@
|
|||
@ignore
|
||||
This file documents the user interface to the GNU History library.
|
||||
|
||||
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
|
||||
provided the copyright notice and this permission notice are preserved on
|
||||
all copies.
|
||||
|
||||
Permission is granted to process this file through Tex and print the
|
||||
results, provided the printed document carries copying permission notice
|
||||
identical to this one except for the removal of this paragraph (this
|
||||
paragraph not being relevant to the printed manual).
|
||||
|
||||
Permission is granted to copy and distribute modified versions of this
|
||||
manual under the conditions for verbatim copying, provided also that the
|
||||
GNU Copyright statement is available to the distributee, and provided that
|
||||
the entire resulting derived work is distributed under the terms of a
|
||||
permission notice identical to this one.
|
||||
|
||||
Permission is granted to copy and distribute translations of this manual
|
||||
into another language, under the above conditions for modified versions.
|
||||
@end ignore
|
||||
|
||||
@node Using History Interactively
|
||||
@chapter Using History Interactively
|
||||
|
||||
@ifclear BashFeatures
|
||||
@defcodeindex bt
|
||||
@end ifclear
|
||||
|
||||
@ifset BashFeatures
|
||||
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 @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 @sc{gnu} History Library interactively,
|
||||
from a user's standpoint. It should be considered a user's guide. For
|
||||
information on using the @sc{gnu} History Library in your own programs,
|
||||
@pxref{Programming with GNU History}.
|
||||
@end ifclear
|
||||
|
||||
@ifset BashFeatures
|
||||
@menu
|
||||
* Bash History Facilities:: How Bash lets you manipulate your command
|
||||
history.
|
||||
* Bash History Builtins:: The Bash builtin commands that manipulate
|
||||
the command history.
|
||||
* History Interaction:: What it feels like using History as a user.
|
||||
@end menu
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
@menu
|
||||
* History Interaction:: What it feels like using History as a user.
|
||||
@end menu
|
||||
@end ifclear
|
||||
|
||||
@ifset BashFeatures
|
||||
@node Bash History Facilities
|
||||
@section Bash History Facilities
|
||||
@cindex command history
|
||||
@cindex history list
|
||||
|
||||
When the @option{-o history} option to the @code{set} builtin
|
||||
is enabled (@pxref{The Set Builtin}),
|
||||
the shell provides access to the @dfn{command history},
|
||||
the list of commands previously typed.
|
||||
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 @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
|
||||
@env{HISTIGNORE} and @env{HISTCONTROL}.
|
||||
|
||||
When the shell starts up, the history is initialized from the
|
||||
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 @env{HISTFILESIZE} variable.
|
||||
When an interactive shell exits, the last
|
||||
@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 @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 @env{$HISTFILESIZE}
|
||||
lines. If @env{HISTFILESIZE} is not set, no truncation is performed.
|
||||
|
||||
If the @env{HISTTIMEFORMAT} is set, the time stamp information
|
||||
associated with each history entry is written to the history file.
|
||||
|
||||
The builtin command @code{fc} may be used to list or edit and re-execute
|
||||
a portion of the history list.
|
||||
The @code{history} builtin may be used to display or modify the history
|
||||
list and manipulate the history file.
|
||||
When using command-line editing, search commands
|
||||
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 @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}
|
||||
shell option, if enabled, causes the shell to attempt to save each
|
||||
line of a multi-line command in the same history entry, adding
|
||||
semicolons where necessary to preserve syntactic correctness.
|
||||
The @code{lithist}
|
||||
shell option causes the shell to save the command with embedded newlines
|
||||
instead of semicolons.
|
||||
The @code{shopt} builtin is used to set these options.
|
||||
@xref{Bash Builtins}, for a description of @code{shopt}.
|
||||
|
||||
@node Bash History Builtins
|
||||
@section Bash History Builtins
|
||||
@cindex history builtins
|
||||
|
||||
Bash provides two builtin commands which manipulate the
|
||||
history list and history file.
|
||||
|
||||
@table @code
|
||||
|
||||
@item fc
|
||||
@btindex fc
|
||||
@example
|
||||
@code{fc [-e @var{ename}] [-nlr] [@var{first}] [@var{last}]}
|
||||
@code{fc -s [@var{pat}=@var{rep}] [@var{command}]}
|
||||
@end example
|
||||
|
||||
Fix Command. In the first form, a range of commands from @var{first} to
|
||||
@var{last} is selected from the history list. Both @var{first} and
|
||||
@var{last} may be specified as a string (to locate the most recent
|
||||
command beginning with that string) or as a number (an index into the
|
||||
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 @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 @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
|
||||
of @var{pat} in the selected command is replaced by @var{rep}.
|
||||
|
||||
A useful alias to use with the @code{fc} command is @code{r='fc -s'}, so
|
||||
that typing @samp{r cc} runs the last command beginning with @code{cc}
|
||||
and typing @samp{r} re-executes the last command (@pxref{Aliases}).
|
||||
|
||||
@item history
|
||||
@btindex history
|
||||
@example
|
||||
history [@var{n}]
|
||||
history -c
|
||||
history -d @var{offset}
|
||||
history [-anrw] [@var{filename}]
|
||||
history -ps @var{arg}
|
||||
@end example
|
||||
|
||||
With no options, display the history list with line numbers.
|
||||
Lines prefixed with a @samp{*} have been modified.
|
||||
An argument of @var{n} lists only the last @var{n} lines.
|
||||
If the shell variable @env{HISTTIMEFORMAT} is set and not null,
|
||||
it is used as a format string for @var{strftime} to display
|
||||
the time stamp associated with each displayed history entry.
|
||||
No intervening blank is printed between the formatted time stamp
|
||||
and the history line.
|
||||
|
||||
Options, if supplied, have the following meanings:
|
||||
|
||||
@table @code
|
||||
@item -c
|
||||
Clear the history list. This may be combined
|
||||
with the other options to replace the history list completely.
|
||||
|
||||
@item -d @var{offset}
|
||||
Delete the history entry at position @var{offset}.
|
||||
@var{offset} should be specified as it appears when the history is
|
||||
displayed.
|
||||
|
||||
@item -a
|
||||
Append the new
|
||||
history lines (history lines entered since the beginning of the
|
||||
current Bash session) to the history file.
|
||||
|
||||
@item -n
|
||||
Append the history lines not already read from the history file
|
||||
to the current history list. These are lines appended to the history
|
||||
file since the beginning of the current Bash session.
|
||||
|
||||
@item -r
|
||||
Read the current history file and append its contents to
|
||||
the history list.
|
||||
|
||||
@item -w
|
||||
Write out the current history to the history file.
|
||||
|
||||
@item -p
|
||||
Perform history substitution on the @var{arg}s and display the result
|
||||
on the standard output, without storing the results in the history list.
|
||||
|
||||
@item -s
|
||||
The @var{arg}s are added to the end of
|
||||
the history list as a single entry.
|
||||
|
||||
@end table
|
||||
|
||||
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 @env{HISTFILE} variable is used.
|
||||
|
||||
@end table
|
||||
@end ifset
|
||||
|
||||
@node History Interaction
|
||||
@section History Expansion
|
||||
@cindex history expansion
|
||||
|
||||
The History library provides a history expansion feature that is similar
|
||||
to the history expansion provided by @code{csh}. This section
|
||||
describes the syntax used to manipulate the history information.
|
||||
|
||||
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.
|
||||
|
||||
History expansion takes place in two parts. The first is to determine
|
||||
which line from the history list should be used during substitution.
|
||||
The second is to select portions of that line for inclusion into the
|
||||
current one. The line selected from the history is called the
|
||||
@dfn{event}, and the portions of that line that are acted upon are
|
||||
called @dfn{words}. Various @dfn{modifiers} are available to manipulate
|
||||
the selected words. The line is broken into words in the same fashion
|
||||
that Bash does, so that several words
|
||||
surrounded by quotes are considered one word.
|
||||
History expansions are introduced by the appearance of the
|
||||
history expansion character, which is @samp{!} by default.
|
||||
@ifset BashFeatures
|
||||
Only @samp{\} and @samp{'} may be used to escape the history expansion
|
||||
character.
|
||||
@end ifset
|
||||
|
||||
@ifset BashFeatures
|
||||
Several shell options settable with the @code{shopt}
|
||||
builtin (@pxref{Bash Builtins}) may be used to tailor
|
||||
the behavior of history expansion. If the
|
||||
@code{histverify} shell option is enabled, and Readline
|
||||
is being used, history substitutions are not immediately passed to
|
||||
the shell parser.
|
||||
Instead, the expanded line is reloaded into the Readline
|
||||
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 @option{-p} option to the @code{history} builtin command
|
||||
may be used to see what a history expansion will do before using it.
|
||||
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.
|
||||
|
||||
The shell allows control of the various characters used by the
|
||||
history expansion mechanism with the @code{histchars} variable.
|
||||
@end ifset
|
||||
|
||||
@menu
|
||||
* Event Designators:: How to specify which history line to use.
|
||||
* Word Designators:: Specifying which words are of interest.
|
||||
* Modifiers:: Modifying the results of substitution.
|
||||
@end menu
|
||||
|
||||
@node Event Designators
|
||||
@subsection Event Designators
|
||||
@cindex event designators
|
||||
|
||||
An event designator is a reference to a command line entry in the
|
||||
history list.
|
||||
@cindex history events
|
||||
|
||||
@table @asis
|
||||
|
||||
@item @code{!}
|
||||
@ifset BashFeatures
|
||||
Start a history substitution, except when followed by a space, tab,
|
||||
the end of the line, @samp{=} or @samp{(} (when the
|
||||
@code{extglob} shell option is enabled using the @code{shopt} builtin).
|
||||
@end ifset
|
||||
@ifclear BashFeatures
|
||||
Start a history substitution, except when followed by a space, tab,
|
||||
the end of the line, or @samp{=}.
|
||||
@end ifclear
|
||||
|
||||
@item @code{!@var{n}}
|
||||
Refer to command line @var{n}.
|
||||
|
||||
@item @code{!-@var{n}}
|
||||
Refer to the command @var{n} lines back.
|
||||
|
||||
@item @code{!!}
|
||||
Refer to the previous command. This is a synonym for @samp{!-1}.
|
||||
|
||||
@item @code{!@var{string}}
|
||||
Refer to the most recent command starting with @var{string}.
|
||||
|
||||
@item @code{!?@var{string}[?]}
|
||||
Refer to the most recent command containing @var{string}. The trailing
|
||||
@samp{?} may be omitted if the @var{string} is followed immediately by
|
||||
a newline.
|
||||
|
||||
@item @code{^@var{string1}^@var{string2}^}
|
||||
Quick Substitution. Repeat the last command, replacing @var{string1}
|
||||
with @var{string2}. Equivalent to
|
||||
@code{!!:s/@var{string1}/@var{string2}/}.
|
||||
|
||||
@item @code{!#}
|
||||
The entire command line typed so far.
|
||||
|
||||
@end table
|
||||
|
||||
@node Word Designators
|
||||
@subsection Word Designators
|
||||
|
||||
Word designators are used to select desired words from the event.
|
||||
A @samp{:} separates the event specification from the word designator. It
|
||||
may be omitted if the word designator begins with a @samp{^}, @samp{$},
|
||||
@samp{*}, @samp{-}, or @samp{%}. 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.
|
||||
|
||||
@need 0.75
|
||||
For example,
|
||||
|
||||
@table @code
|
||||
@item !!
|
||||
designates the preceding command. When you type this, the preceding
|
||||
command is repeated in toto.
|
||||
|
||||
@item !!:$
|
||||
designates the last argument of the preceding command. This may be
|
||||
shortened to @code{!$}.
|
||||
|
||||
@item !fi:2
|
||||
designates the second argument of the most recent command starting with
|
||||
the letters @code{fi}.
|
||||
@end table
|
||||
|
||||
@need 0.75
|
||||
Here are the word designators:
|
||||
|
||||
@table @code
|
||||
|
||||
@item 0 (zero)
|
||||
The @code{0}th word. For many applications, this is the command word.
|
||||
|
||||
@item @var{n}
|
||||
The @var{n}th word.
|
||||
|
||||
@item ^
|
||||
The first argument; that is, word 1.
|
||||
|
||||
@item $
|
||||
The last argument.
|
||||
|
||||
@item %
|
||||
The word matched by the most recent @samp{?@var{string}?} search.
|
||||
|
||||
@item @var{x}-@var{y}
|
||||
A range of words; @samp{-@var{y}} abbreviates @samp{0-@var{y}}.
|
||||
|
||||
@item *
|
||||
All of the words, except the @code{0}th. This is a synonym for @samp{1-$}.
|
||||
It is not an error to use @samp{*} if there is just one word in the event;
|
||||
the empty string is returned in that case.
|
||||
|
||||
@item @var{x}*
|
||||
Abbreviates @samp{@var{x}-$}
|
||||
|
||||
@item @var{x}-
|
||||
Abbreviates @samp{@var{x}-$} like @samp{@var{x}*}, but omits the last word.
|
||||
|
||||
@end table
|
||||
|
||||
If a word designator is supplied without an event specification, the
|
||||
previous command is used as the event.
|
||||
|
||||
@node Modifiers
|
||||
@subsection Modifiers
|
||||
|
||||
After the optional word designator, you can add a sequence of one or more
|
||||
of the following modifiers, each preceded by a @samp{:}.
|
||||
|
||||
@table @code
|
||||
|
||||
@item h
|
||||
Remove a trailing pathname component, leaving only the head.
|
||||
|
||||
@item t
|
||||
Remove all leading pathname components, leaving the tail.
|
||||
|
||||
@item r
|
||||
Remove a trailing suffix of the form @samp{.@var{suffix}}, leaving
|
||||
the basename.
|
||||
|
||||
@item e
|
||||
Remove all but the trailing suffix.
|
||||
|
||||
@item p
|
||||
Print the new command but do not execute it.
|
||||
|
||||
@ifset BashFeatures
|
||||
@item q
|
||||
Quote the substituted words, escaping further substitutions.
|
||||
|
||||
@item x
|
||||
Quote the substituted words as with @samp{q},
|
||||
but break into words at spaces, tabs, and newlines.
|
||||
@end ifset
|
||||
|
||||
@item s/@var{old}/@var{new}/
|
||||
Substitute @var{new} for the first occurrence of @var{old} in the
|
||||
event line. Any delimiter may be used in place of @samp{/}.
|
||||
The delimiter may be quoted in @var{old} and @var{new}
|
||||
with a single backslash. If @samp{&} appears in @var{new},
|
||||
it is replaced by @var{old}. A single backslash will quote
|
||||
the @samp{&}. The final delimiter is optional if it is the last
|
||||
character on the input line.
|
||||
|
||||
@item &
|
||||
Repeat the previous substitution.
|
||||
|
||||
@item g
|
||||
@itemx a
|
||||
Cause changes to be applied over the entire event line. Used in
|
||||
conjunction with @samp{s}, as in @code{gs/@var{old}/@var{new}/},
|
||||
or with @samp{&}.
|
||||
|
||||
@item G
|
||||
Apply the following @samp{s} modifier once to each word in the event.
|
||||
|
||||
@end table
|
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 Jan 22 09:18:25 EST 2002
|
||||
.\" Last Change: Tue Sep 13 12:07:26 EDT 2005
|
||||
.\"
|
||||
.TH READLINE 3 "2002 January 22" "GNU Readline 4.3"
|
||||
.TH READLINE 3 "2005 Sep 13" "GNU Readline 5.1-beta1"
|
||||
.\"
|
||||
.\" File Name macro. This used to be `.PN', for Path Name,
|
||||
.\" but Sun doesn't seem to like that very much.
|
||||
|
@ -34,8 +34,8 @@ readline \- get a line from a user with editing
|
|||
\fBreadline\fP (\fIconst char *prompt\fP);
|
||||
.fi
|
||||
.SH COPYRIGHT
|
||||
.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.
|
||||
.if n Readline is Copyright (C) 1989\-2004 by the Free Software Foundation, Inc.
|
||||
.if t Readline is Copyright \(co 1989\-2004 by the Free Software Foundation, Inc.
|
||||
.SH DESCRIPTION
|
||||
.LP
|
||||
.B readline
|
||||
|
@ -328,6 +328,10 @@ Except where noted, readline variables can take the values
|
|||
or
|
||||
.B Off
|
||||
(without regard to case).
|
||||
Unrecognized variable names are ignored.
|
||||
When a variable value is read, empty or null values, "on" (case-insensitive),
|
||||
and "1" are equivalent to \fBOn\fP. All other values are equivalent to
|
||||
\fBOff\fP.
|
||||
The variables and their default values are:
|
||||
.PP
|
||||
.PD 0
|
||||
|
@ -338,6 +342,11 @@ If set to \fBnone\fP, readline never rings the bell. If set to
|
|||
\fBvisible\fP, readline uses a visible bell if one is available.
|
||||
If set to \fBaudible\fP, readline attempts to ring the terminal's bell.
|
||||
.TP
|
||||
.B bind\-tty\-special\-chars (On)
|
||||
If set to \fBOn\fP, readline attempts to bind the control characters
|
||||
treated specially by the kernel's terminal driver to their readline
|
||||
equivalents.
|
||||
.TP
|
||||
.B comment\-begin (``#'')
|
||||
The string that is inserted in \fBvi\fP mode when the
|
||||
.B insert\-comment
|
||||
|
@ -360,7 +369,7 @@ It may be set to any integer value greater than or equal to
|
|||
zero. If the number of possible completions is greater than
|
||||
or equal to the value of this variable, the user is asked whether
|
||||
or not he wishes to view them; otherwise they are simply listed
|
||||
on the terminal.
|
||||
on the terminal. A negative value causes readline to never ask.
|
||||
.TP
|
||||
.B convert\-meta (On)
|
||||
If set to \fBOn\fP, readline will convert characters with the
|
||||
|
@ -391,9 +400,9 @@ arrow keys.
|
|||
If set to \fBon\fP, tilde expansion is performed when readline
|
||||
attempts word completion.
|
||||
.TP
|
||||
.B history-preserve-point
|
||||
.B history\-preserve\-point (Off)
|
||||
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
|
||||
same location on each history line retrieved with \fBprevious-history\fP
|
||||
or \fBnext-history\fP.
|
||||
.TP
|
||||
.B horizontal\-scroll\-mode (Off)
|
||||
|
@ -465,6 +474,16 @@ set to
|
|||
words which have more than one possible completion cause the
|
||||
matches to be listed immediately instead of ringing the bell.
|
||||
.TP
|
||||
.B show\-all\-if\-unmodified (Off)
|
||||
This alters the default behavior of the completion functions in
|
||||
a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
|
||||
If set to
|
||||
.BR on ,
|
||||
words which have more than one possible completion without any
|
||||
possible partial completion (the possible completions don't share
|
||||
a common prefix) cause the 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 \fIstat\fP(2) is appended to the filename when listing possible
|
||||
|
@ -681,6 +700,8 @@ With an argument
|
|||
insert the \fIn\fPth word from the previous command (the words
|
||||
in the previous command begin with word 0). A negative argument
|
||||
inserts the \fIn\fPth word from the end of the previous command.
|
||||
Once the argument \fIn\fP is computed, the argument is extracted
|
||||
as if the "!\fIn\fP" history expansion had been specified.
|
||||
.TP
|
||||
.B
|
||||
yank\-last\-arg (M\-.\^, M\-_\^)
|
||||
|
@ -689,6 +710,8 @@ the previous history entry). With an argument,
|
|||
behave exactly like \fByank\-nth\-arg\fP.
|
||||
Successive calls to \fByank\-last\-arg\fP move back through the history
|
||||
list, inserting the last argument of each line in turn.
|
||||
The history expansion facilities are used to extract the last argument,
|
||||
as if the "!$" history expansion had been specified.
|
||||
.PD
|
||||
.SS Commands for Changing Text
|
||||
.PP
|
||||
|
@ -787,6 +810,11 @@ Word boundaries are the same as those used by \fBbackward\-word\fP.
|
|||
Kill the word behind point, using white space as a word boundary.
|
||||
The killed text is saved on the kill-ring.
|
||||
.TP
|
||||
.B unix\-filename\-rubout
|
||||
Kill the word behind point, using white space and the slash character
|
||||
as the word boundaries.
|
||||
The killed text is saved on the kill-ring.
|
||||
.TP
|
||||
.B delete\-horizontal\-space (M\-\e)
|
||||
Delete all spaces and tabs around point.
|
||||
.TP
|
||||
|
@ -868,7 +896,7 @@ 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
|
||||
(subject to the setting of \Bbell\-style\fP)
|
||||
(subject to the setting of \fBbell\-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
|
||||
|
@ -979,7 +1007,7 @@ of an \fIinputrc\fP file.
|
|||
.TP
|
||||
.B dump\-macros
|
||||
Print all of the readline key sequences bound to macros and the
|
||||
strings they ouput. If a numeric argument is supplied,
|
||||
strings they output. If a numeric argument is supplied,
|
||||
the output is formatted in such a way that it can be made part
|
||||
of an \fIinputrc\fP file.
|
||||
.TP
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
BIN
readline/doc/readline.pdf
Normal file
BIN
readline/doc/readline.pdf
Normal file
Binary file not shown.
14234
readline/doc/readline.ps
14234
readline/doc/readline.ps
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
101
readline/doc/rlman.texi
Normal file
101
readline/doc/rlman.texi
Normal file
|
@ -0,0 +1,101 @@
|
|||
\input texinfo @c -*-texinfo-*-
|
||||
@comment %**start of header (This is for running Texinfo on a region.)
|
||||
@setfilename readline.info
|
||||
@settitle GNU Readline Library
|
||||
@comment %**end of header (This is for running Texinfo on a region.)
|
||||
@synindex vr fn
|
||||
@setchapternewpage odd
|
||||
|
||||
@include version.texi
|
||||
|
||||
@copying
|
||||
This manual describes the GNU Readline Library
|
||||
(version @value{VERSION}, @value{UPDATED}), a library which aids in the
|
||||
consistency of user interface across discrete programs which provide
|
||||
a command line interface.
|
||||
|
||||
Copyright @copyright{} 1988-2004 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
are preserved on all copies.
|
||||
|
||||
@quotation
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.1 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
|
||||
and with the Back-Cover Texts as in (a) below. A copy of the license is
|
||||
included in the section entitled ``GNU Free Documentation License.''
|
||||
|
||||
(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
|
||||
this GNU Manual, like GNU software. Copies published by the Free
|
||||
Software Foundation raise funds for GNU development.''
|
||||
@end quotation
|
||||
@end copying
|
||||
|
||||
@dircategory Libraries
|
||||
@direntry
|
||||
* Readline: (readline). The GNU readline library API.
|
||||
@end direntry
|
||||
|
||||
@titlepage
|
||||
@title GNU Readline Library
|
||||
@subtitle Edition @value{EDITION}, for @code{Readline Library} Version @value{VERSION}.
|
||||
@subtitle @value{UPDATED-MONTH}
|
||||
@author Chet Ramey, Case Western Reserve University
|
||||
@author Brian Fox, Free Software Foundation
|
||||
|
||||
@page
|
||||
@vskip 0pt plus 1filll
|
||||
@insertcopying
|
||||
|
||||
@sp 1
|
||||
Published by the Free Software Foundation @*
|
||||
59 Temple Place, Suite 330, @*
|
||||
Boston, MA 02111-1307 @*
|
||||
USA @*
|
||||
|
||||
@end titlepage
|
||||
|
||||
@contents
|
||||
|
||||
@ifnottex
|
||||
@node Top
|
||||
@top GNU Readline Library
|
||||
|
||||
This document describes the GNU Readline Library, a utility which aids
|
||||
in the consistency of user interface across discrete programs which
|
||||
provide a command line interface.
|
||||
|
||||
@menu
|
||||
* Command Line Editing:: GNU Readline User's Manual.
|
||||
* Programming with GNU Readline:: GNU Readline Programmer's Manual.
|
||||
* Copying This Manual:: Copying this manual.
|
||||
* Concept Index:: Index of concepts described in this manual.
|
||||
* Function and Variable Index:: Index of externally visible functions
|
||||
and variables.
|
||||
@end menu
|
||||
@end ifnottex
|
||||
|
||||
@include rluser.texi
|
||||
@include rltech.texi
|
||||
|
||||
@node Copying This Manual
|
||||
@appendix Copying This Manual
|
||||
|
||||
@menu
|
||||
* GNU Free Documentation License:: License for copying this manual.
|
||||
@end menu
|
||||
|
||||
@include fdl.texi
|
||||
|
||||
@node Concept Index
|
||||
@unnumbered Concept Index
|
||||
@printindex cp
|
||||
|
||||
@node Function and Variable Index
|
||||
@unnumbered Function and Variable Index
|
||||
@printindex fn
|
||||
|
||||
@bye
|
2285
readline/doc/rltech.texi
Normal file
2285
readline/doc/rltech.texi
Normal file
File diff suppressed because it is too large
Load diff
1846
readline/doc/rluser.texi
Normal file
1846
readline/doc/rluser.texi
Normal file
File diff suppressed because it is too large
Load diff
Binary file not shown.
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
BIN
readline/doc/rluserman.pdf
Normal file
BIN
readline/doc/rluserman.pdf
Normal file
Binary file not shown.
File diff suppressed because it is too large
Load diff
88
readline/doc/rluserman.texi
Normal file
88
readline/doc/rluserman.texi
Normal file
|
@ -0,0 +1,88 @@
|
|||
\input texinfo @c -*-texinfo-*-
|
||||
@comment %**start of header (This is for running Texinfo on a region.)
|
||||
@setfilename rluserman.info
|
||||
@settitle GNU Readline Library
|
||||
@comment %**end of header (This is for running Texinfo on a region.)
|
||||
|
||||
@setchapternewpage odd
|
||||
|
||||
@include version.texi
|
||||
|
||||
@copying
|
||||
This manual describes the end user interface of the GNU Readline Library
|
||||
(version @value{VERSION}, @value{UPDATED}), a library which aids in the
|
||||
consistency of user interface across discrete programs which provide
|
||||
a command line interface.
|
||||
|
||||
Copyright @copyright{} 1988-2005 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to make and distribute verbatim copies of
|
||||
this manual provided the copyright notice and this permission notice
|
||||
are preserved on all copies.
|
||||
|
||||
@quotation
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.1 or
|
||||
any later version published by the Free Software Foundation; with no
|
||||
Invariant Sections, with the Front-Cover texts being ``A GNU Manual,''
|
||||
and with the Back-Cover Texts as in (a) below. A copy of the license is
|
||||
included in the section entitled ``GNU Free Documentation License.''
|
||||
|
||||
(a) The FSF's Back-Cover Text is: ``You have freedom to copy and modify
|
||||
this GNU Manual, like GNU software. Copies published by the Free
|
||||
Software Foundation raise funds for GNU development.''
|
||||
@end quotation
|
||||
@end copying
|
||||
|
||||
@dircategory Libraries
|
||||
@direntry
|
||||
* RLuserman: (rluserman). The GNU readline library User's Manual.
|
||||
@end direntry
|
||||
|
||||
@titlepage
|
||||
@title GNU Readline Library User Interface
|
||||
@subtitle Edition @value{EDITION}, for @code{Readline Library} Version @value{VERSION}.
|
||||
@subtitle @value{UPDATED-MONTH}
|
||||
@author Chet Ramey, Case Western Reserve University
|
||||
@author Brian Fox, Free Software Foundation
|
||||
|
||||
@page
|
||||
@vskip 0pt plus 1filll
|
||||
@insertcopying
|
||||
|
||||
@sp 1
|
||||
Published by the Free Software Foundation @*
|
||||
59 Temple Place, Suite 330, @*
|
||||
Boston, MA 02111-1307 @*
|
||||
USA @*
|
||||
|
||||
@end titlepage
|
||||
|
||||
@contents
|
||||
|
||||
@ifnottex
|
||||
@node Top
|
||||
@top GNU Readline Library
|
||||
|
||||
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 which provide a command line interface.
|
||||
|
||||
@menu
|
||||
* Command Line Editing:: GNU Readline User's Manual.
|
||||
* Copying This Manual:: Copying This Manual.
|
||||
@end menu
|
||||
@end ifnottex
|
||||
|
||||
@include rluser.texi
|
||||
|
||||
@node Copying This Manual
|
||||
@appendix Copying This Manual
|
||||
|
||||
@menu
|
||||
* GNU Free Documentation License:: License for copying this manual.
|
||||
@end menu
|
||||
|
||||
@include fdl.texi
|
||||
|
||||
@bye
|
|
@ -2,7 +2,8 @@
|
|||
# texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources.
|
||||
# $Id$
|
||||
#
|
||||
# Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001,
|
||||
# 2002, 2003 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
|
||||
|
@ -29,9 +30,9 @@
|
|||
rcs_revision='$Revision$'
|
||||
rcs_version=`set - $rcs_revision; echo $2`
|
||||
program=`echo $0 | sed -e 's!.*/!!'`
|
||||
version="texi2dvi (GNU Texinfo 4.0) $rcs_version
|
||||
version="texi2dvi (GNU Texinfo 4.5) $rcs_version
|
||||
|
||||
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
Copyright (C) 2003 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."
|
||||
|
@ -46,46 +47,52 @@ 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.
|
||||
Operation modes:
|
||||
-b, --batch no interaction
|
||||
-c, --clean remove all auxiliary files
|
||||
-D, --debug turn on shell debugging (set -x)
|
||||
-h, --help display this help and exit successfully
|
||||
-o, --output=OFILE leave output in OFILE (implies --clean);
|
||||
Only one input FILE may be specified in this case
|
||||
-q, --quiet no output unless errors (implies --batch)
|
||||
-s, --silent same as --quiet
|
||||
-v, --version display version information and exit successfully
|
||||
-V, --verbose report on what is done
|
||||
|
||||
TeX tuning:
|
||||
-@ use @input instead of \input; for preloaded Texinfo
|
||||
-e, -E, --expand force macro expansion using makeinfo
|
||||
-I DIR search DIR for Texinfo files
|
||||
-l, --language=LANG specify the LANG of FILE (LaTeX or Texinfo)
|
||||
-p, --pdf use pdftex or pdflatex for processing
|
||||
-t, --texinfo=CMD insert CMD after @setfilename in copy of input file
|
||||
multiple values accumulate
|
||||
|
||||
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>."
|
||||
general questions and discussion to <help-texinfo@gnu.org>.
|
||||
Texinfo home page: http://www.gnu.org/software/texinfo/"
|
||||
|
||||
# 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=
|
||||
escape='\'
|
||||
expand= # t for expansion via makeinfo
|
||||
oformat=dvi
|
||||
set_language=
|
||||
miincludes= # makeinfo include path
|
||||
oformat=dvi
|
||||
oname= # --output
|
||||
quiet= # by default let the tools' message be displayed
|
||||
set_language=
|
||||
textra=
|
||||
tmpdir=${TMPDIR:-/tmp}/t2d$$ # avoid collisions on 8.3 filesystems.
|
||||
txincludes= # TEXINPUTS extensions
|
||||
txincludes= # TEXINPUTS extensions, with trailing colon
|
||||
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`
|
||||
|
@ -98,6 +105,12 @@ else
|
|||
path_sep=":"
|
||||
fi
|
||||
|
||||
# Pacify verbose cds.
|
||||
CDPATH=${ZSH_VERSION+.}$path_sep
|
||||
|
||||
# In case someone crazy insists on using grep -E.
|
||||
: ${EGREP=egrep}
|
||||
|
||||
# Save this so we can construct a new TEXINPUTS path for each file.
|
||||
TEXINPUTS_orig="$TEXINPUTS"
|
||||
# Unfortunately makeindex does not read TEXINPUTS.
|
||||
|
@ -136,14 +149,21 @@ while test x"$1" != x"$arg_sep"; do
|
|||
-q | -s | --q* | --s*) quiet=t; batch=eval;;
|
||||
-c | --c*) clean=t;;
|
||||
-D | --d*) debug=t;;
|
||||
-e | --e*) expand=t;;
|
||||
-e | -E | --e*) expand=t;;
|
||||
-h | --h*) echo "$usage"; exit 0;;
|
||||
-I | --I*)
|
||||
shift
|
||||
miincludes="$miincludes -I $1"
|
||||
txincludes="$txincludes$path_sep$1"
|
||||
txincludes="$txincludes$1$path_sep"
|
||||
;;
|
||||
-l | --l*) shift; set_language=$1;;
|
||||
-o | --o*)
|
||||
shift
|
||||
clean=t
|
||||
case "$1" in
|
||||
/* | ?:/*) oname=$1;;
|
||||
*) oname="$orig_pwd/$1";;
|
||||
esac;;
|
||||
-p | --p*) oformat=pdf;;
|
||||
-t | --t*) shift; textra="$textra\\
|
||||
$1";;
|
||||
|
@ -168,11 +188,20 @@ done
|
|||
shift
|
||||
|
||||
# Interpret remaining command line args as filenames.
|
||||
if test $# = 0; then
|
||||
case $# in
|
||||
0)
|
||||
echo "$0: Missing file arguments." >&2
|
||||
echo "$0: Try \`--help' for more information." >&2
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
1) ;;
|
||||
*)
|
||||
if test -n "$oname"; then
|
||||
echo "$0: Can't use option \`--output' with more than one argument." >&2
|
||||
exit 2
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# Prepare the temporary directory. Remove it at exit, unless debugging.
|
||||
if test -z "$debug"; then
|
||||
|
@ -205,14 +234,23 @@ cat <<EOF >$comment_iftex_sed
|
|||
s/^@c texi2dvi//
|
||||
}
|
||||
}
|
||||
/^@html/,/^@end html/d
|
||||
/^@ifhtml/,/^@end ifhtml/d
|
||||
/^@ifnottex/,/^@end ifnottex/d
|
||||
/^@html/,/^@end html/{
|
||||
s/^/@c (texi2dvi)/
|
||||
}
|
||||
/^@ifhtml/,/^@end ifhtml/{
|
||||
s/^/@c (texi2dvi)/
|
||||
}
|
||||
/^@ifnottex/,/^@end ifnottex/{
|
||||
s/^/@c (texi2dvi)/
|
||||
}
|
||||
/^@ifinfo/,/^@end ifinfo/{
|
||||
/^@node/p
|
||||
/^@menu/,/^@end menu/p
|
||||
d
|
||||
t
|
||||
s/^/@c (texi2dvi)/
|
||||
}
|
||||
s/^@ifnotinfo/@c texi2dvi@ifnotinfo/
|
||||
s/^@end ifnotinfo/@c texi2dvi@end ifnotinfo/
|
||||
EOF
|
||||
# Uncommenting is simple: Remove any leading `@c texi2dvi'.
|
||||
uncomment_iftex_sed=$utildir/uncomment.sed
|
||||
|
@ -230,7 +268,7 @@ cat <<\EOF >$get_xref_files
|
|||
# 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.
|
||||
# many files: .toc, .log, LaTeX tables and lists, FiXme's .lox, maybe more.
|
||||
for this_file in "$1".?o? "$1".aux "$1".?? "$1".idx; do
|
||||
# If file is empty, skip it.
|
||||
test -s "$this_file" || continue
|
||||
|
@ -273,7 +311,7 @@ for command_line_filename in ${1+"$@"}; do
|
|||
|
||||
# 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 \
|
||||
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
|
||||
|
@ -314,22 +352,67 @@ for command_line_filename in ${1+"$@"}; do
|
|||
# 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,
|
||||
# Source file might include additional sources.
|
||||
# We want `.:$orig_pwd' before anything else. (We'll add `.:' later
|
||||
# after all other directories have been turned into absolute paths.)
|
||||
# `.' 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"
|
||||
common="$orig_pwd$path_sep$filename_dir$path_sep$txincludes"
|
||||
TEXINPUTS="$common$TEXINPUTS_orig"
|
||||
INDEXSTYLE="$common$INDEXSTYLE_orig"
|
||||
|
||||
# Convert relative paths to absolute paths, so we can run in another
|
||||
# directory (e.g., in --clean mode, or during the macro-support
|
||||
# detection.)
|
||||
#
|
||||
# Empty path components are meaningful to tex. We rewrite them
|
||||
# as `EMPTY' so they don't get lost when we split on $path_sep.
|
||||
TEXINPUTS=`echo $TEXINPUTS |sed 's/^:/EMPTY:/;s/:$/:EMPTY/;s/::/:EMPTY:/g'`
|
||||
INDEXSTYLE=`echo $INDEXSTYLE |sed 's/^:/EMPTY:/;s/:$/:EMPTY/;s/::/:EMPTY:/g'`
|
||||
save_IFS=$IFS
|
||||
IFS=$path_sep
|
||||
set x $TEXINPUTS; shift
|
||||
TEXINPUTS=.
|
||||
for dir
|
||||
do
|
||||
case $dir in
|
||||
EMPTY)
|
||||
TEXINPUTS=$TEXINPUTS$path_sep
|
||||
;;
|
||||
[\\/]* | ?:[\\/]*) # Absolute paths don't need to be expansed.
|
||||
TEXINPUTS=$TEXINPUTS$path_sep$dir
|
||||
;;
|
||||
*)
|
||||
abs=`cd "$dir" && pwd` && TEXINPUTS=$TEXINPUTS$path_sep$abs
|
||||
;;
|
||||
esac
|
||||
done
|
||||
set x $INDEXSTYLE; shift
|
||||
INDEXSTYLE=.
|
||||
for dir
|
||||
do
|
||||
case $dir in
|
||||
EMPTY)
|
||||
INDEXSTYLE=$INDEXSTYLE$path_sep
|
||||
;;
|
||||
[\\/]* | ?:[\\/]*) # Absolute paths don't need to be expansed.
|
||||
INDEXSTYLE=$INDEXSTYLE$path_sep$dir
|
||||
;;
|
||||
*)
|
||||
abs=`cd "$dir" && pwd` && INDEXSTYLE=$INDEXSTYLE$path_sep$abs
|
||||
;;
|
||||
esac
|
||||
done
|
||||
IFS=$save_IFS
|
||||
|
||||
# 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
|
||||
elif sed 1q "$command_line_filename" | grep 'input texinfo' >/dev/null; then
|
||||
language=texinfo
|
||||
else
|
||||
language=
|
||||
|
@ -373,9 +456,9 @@ for command_line_filename in ${1+"$@"}; do
|
|||
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'`
|
||||
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=
|
||||
|
@ -467,10 +550,14 @@ for command_line_filename in ${1+"$@"}; do
|
|||
|
||||
# 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?.
|
||||
# before .aux and .?o?. But don't really do <anything>o<anything>
|
||||
# -- don't match whitespace as <anything>.
|
||||
# Otherwise, if orig_xref_files contains something like
|
||||
# foo.xo foo.whatever
|
||||
# the space after the o will get matched.
|
||||
index_files=`echo "$orig_xref_files" \
|
||||
| sed "s!.*\.aux!!g;
|
||||
s!./$filename_noext\..o.!!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
|
||||
|
@ -489,8 +576,8 @@ for command_line_filename in ${1+"$@"}; do
|
|||
# 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"
|
||||
$verbose "Running $cmd ..."
|
||||
if $cmd >&5; then :; else
|
||||
echo "$0: $tex exited with bad status, quitting." >&2
|
||||
echo "$0: see $filename_noext.log for errors." >&2
|
||||
|
@ -508,7 +595,7 @@ for command_line_filename in ${1+"$@"}; do
|
|||
# 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
|
||||
if grep "Rerun to get" "$filename_noext.log" >/dev/null 2>&1; then
|
||||
finished=
|
||||
fi
|
||||
|
||||
|
@ -550,8 +637,13 @@ for command_line_filename in ${1+"$@"}; do
|
|||
# - the next file is processed in correct conditions
|
||||
# - the temporary file can be removed
|
||||
if test -n "$clean"; then
|
||||
$verbose "Copying $oformat file from `pwd` to $orig_pwd"
|
||||
cp -p "./$filename_noext.$oformat" "$orig_pwd"
|
||||
if test -n "$oname"; then
|
||||
dest=$oname
|
||||
else
|
||||
dest=$orig_pwd
|
||||
fi
|
||||
$verbose "Copying $oformat file from `pwd` to $dest"
|
||||
cp -p "./$filename_noext.$oformat" "$dest"
|
||||
cd / # in case $orig_pwd is on a different drive (for DOS)
|
||||
cd $orig_pwd || exit 1
|
||||
fi
|
||||
|
|
File diff suppressed because it is too large
Load diff
10
readline/doc/version.texi
Normal file
10
readline/doc/version.texi
Normal file
|
@ -0,0 +1,10 @@
|
|||
@ignore
|
||||
Copyright (C) 1988-2005 Free Software Foundation, Inc.
|
||||
@end ignore
|
||||
|
||||
@set EDITION 5.1-beta1
|
||||
@set VERSION 5.1-beta1
|
||||
@set UPDATED 11 November 2005
|
||||
@set UPDATED-MONTH November 2005
|
||||
|
||||
@set LASTCHANGE Fri Nov 11 19:50:51 EST 2005
|
|
@ -40,6 +40,8 @@ INCLUDES = -I$(srcdir) -I$(top_srcdir) -I..
|
|||
CCFLAGS = $(DEFS) $(LOCAL_CFLAGS) $(CPPFLAGS) $(INCLUDES) $(CFLAGS)
|
||||
LDFLAGS = -g -L.. @LDFLAGS@
|
||||
|
||||
PURIFY = @PURIFY@
|
||||
|
||||
READLINE_LIB = ../libreadline.a
|
||||
HISTORY_LIB = ../libhistory.a
|
||||
|
||||
|
@ -50,33 +52,35 @@ TERMCAP_LIB = @TERMCAP_LIB@
|
|||
$(CC) $(CCFLAGS) -c $<
|
||||
|
||||
EXECUTABLES = fileman rltest rl rlcat rlversion histexamp
|
||||
OBJECTS = fileman.o rltest.o rl.o rlversion.o histexamp.o
|
||||
OBJECTS = fileman.o rltest.o rl.o rlcat.o rlversion.o histexamp.o
|
||||
|
||||
all: $(EXECUTABLES)
|
||||
everything: all rlfe
|
||||
everything: all
|
||||
|
||||
rl: rl.o $(READLINE_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rl.o -lreadline $(TERMCAP_LIB)
|
||||
$(PURIFY) $(CC) $(LDFLAGS) -o $@ rl.o $(READLINE_LIB) $(TERMCAP_LIB)
|
||||
|
||||
rlcat: rlcat.o $(READLINE_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rlcat.o -lreadline $(TERMCAP_LIB)
|
||||
$(PURIFY) $(CC) $(LDFLAGS) -o $@ rlcat.o $(READLINE_LIB) $(TERMCAP_LIB)
|
||||
|
||||
fileman: fileman.o $(READLINE_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ fileman.o -lreadline $(TERMCAP_LIB)
|
||||
$(PURIFY) $(CC) $(LDFLAGS) -o $@ fileman.o $(READLINE_LIB) $(TERMCAP_LIB)
|
||||
|
||||
rltest: rltest.o $(READLINE_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rltest.o -lreadline $(TERMCAP_LIB)
|
||||
$(PURIFY) $(CC) $(LDFLAGS) -o $@ rltest.o $(READLINE_LIB) $(TERMCAP_LIB)
|
||||
|
||||
rlptytest: rlptytest.o $(READLINE_LIB)
|
||||
$(PURIFY) $(CC) $(LDFLAGS) -o $@ rlptytest.o $(READLINE_LIB) $(TERMCAP_LIB)
|
||||
|
||||
rlversion: rlversion.o $(READLINE_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rlversion.o -lreadline $(TERMCAP_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rlversion.o $(READLINE_LIB) $(TERMCAP_LIB)
|
||||
|
||||
histexamp: histexamp.o $(HISTORY_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ histexamp.o -lhistory $(TERMCAP_LIB)
|
||||
$(PURIFY) $(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
|
||||
|
@ -86,19 +90,13 @@ rltest.o: rltest.c
|
|||
rl.o: rl.c
|
||||
rlversion.o: rlversion.c
|
||||
histexamp.o: histexamp.c
|
||||
rlcat.o: rlcat.c
|
||||
rlptytest.o: rlptytest.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
|
||||
|
||||
rlfe: rlfe.o $(READLINE_LIB) $(HISTORY_LIB)
|
||||
$(CC) $(LDFLAGS) -o $@ rlfe.o -lreadline -lhistory ${TERMCAP_LIB}
|
||||
|
||||
rlfe.o: rlfe.c
|
||||
|
||||
rlfe.o: $(top_srcdir)/readline.h
|
||||
rlfe.o: $(top_srcdir)/history.h
|
||||
rlcat.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
|
||||
rlptytest.o: $(top_srcdir)/readline.h $(top_srcdir)/history.h
|
||||
|
|
|
@ -26,14 +26,17 @@
|
|||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
#include <string.h>
|
||||
|
||||
main (argc, argv)
|
||||
int argc;
|
||||
char **argv;
|
||||
{
|
||||
char line[1024], *t;
|
||||
int len, done = 0;
|
||||
int len, done;
|
||||
|
||||
line[0] = 0;
|
||||
done = 0;
|
||||
|
||||
using_history ();
|
||||
while (!done)
|
||||
|
@ -42,71 +45,80 @@ main (argc, argv)
|
|||
fflush (stdout);
|
||||
t = fgets (line, sizeof (line) - 1, stdin);
|
||||
if (t && *t)
|
||||
{
|
||||
len = strlen (t);
|
||||
if (t[len - 1] == '\n')
|
||||
t[len - 1] = '\0';
|
||||
}
|
||||
{
|
||||
len = strlen (t);
|
||||
if (t[len - 1] == '\n')
|
||||
t[len - 1] = '\0';
|
||||
}
|
||||
|
||||
if (!t)
|
||||
strcpy (line, "quit");
|
||||
strcpy (line, "quit");
|
||||
|
||||
if (line[0])
|
||||
{
|
||||
char *expansion;
|
||||
int result;
|
||||
{
|
||||
char *expansion;
|
||||
int result;
|
||||
|
||||
using_history ();
|
||||
using_history ();
|
||||
|
||||
result = history_expand (line, &expansion);
|
||||
if (result)
|
||||
fprintf (stderr, "%s\n", expansion);
|
||||
result = history_expand (line, &expansion);
|
||||
if (result)
|
||||
fprintf (stderr, "%s\n", expansion);
|
||||
|
||||
if (result < 0 || result == 2)
|
||||
{
|
||||
free (expansion);
|
||||
continue;
|
||||
}
|
||||
if (result < 0 || result == 2)
|
||||
{
|
||||
free (expansion);
|
||||
continue;
|
||||
}
|
||||
|
||||
add_history (expansion);
|
||||
strncpy (line, expansion, sizeof (line) - 1);
|
||||
free (expansion);
|
||||
}
|
||||
add_history (expansion);
|
||||
strncpy (line, expansion, sizeof (line) - 1);
|
||||
free (expansion);
|
||||
}
|
||||
|
||||
if (strcmp (line, "quit") == 0)
|
||||
done = 1;
|
||||
done = 1;
|
||||
else if (strcmp (line, "save") == 0)
|
||||
write_history ("history_file");
|
||||
write_history ("history_file");
|
||||
else if (strcmp (line, "read") == 0)
|
||||
read_history ("history_file");
|
||||
read_history ("history_file");
|
||||
else if (strcmp (line, "list") == 0)
|
||||
{
|
||||
register HIST_ENTRY **the_list;
|
||||
register int i;
|
||||
{
|
||||
register HIST_ENTRY **the_list;
|
||||
register int i;
|
||||
time_t tt;
|
||||
char timestr[128];
|
||||
|
||||
the_list = history_list ();
|
||||
if (the_list)
|
||||
for (i = 0; the_list[i]; i++)
|
||||
printf ("%d: %s\n", i + history_base, the_list[i]->line);
|
||||
}
|
||||
the_list = history_list ();
|
||||
if (the_list)
|
||||
for (i = 0; the_list[i]; i++)
|
||||
{
|
||||
tt = history_get_time (the_list[i]);
|
||||
if (tt)
|
||||
strftime (timestr, sizeof (timestr), "%a %R", localtime(&tt));
|
||||
else
|
||||
strcpy (timestr, "??");
|
||||
printf ("%d: %s: %s\n", i + history_base, timestr, the_list[i]->line);
|
||||
}
|
||||
}
|
||||
else if (strncmp (line, "delete", 6) == 0)
|
||||
{
|
||||
int which;
|
||||
if ((sscanf (line + 6, "%d", &which)) == 1)
|
||||
{
|
||||
HIST_ENTRY *entry = remove_history (which);
|
||||
if (!entry)
|
||||
fprintf (stderr, "No such entry %d\n", which);
|
||||
else
|
||||
{
|
||||
free (entry->line);
|
||||
free (entry);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "non-numeric arg given to `delete'\n");
|
||||
}
|
||||
}
|
||||
{
|
||||
int which;
|
||||
if ((sscanf (line + 6, "%d", &which)) == 1)
|
||||
{
|
||||
HIST_ENTRY *entry = remove_history (which);
|
||||
if (!entry)
|
||||
fprintf (stderr, "No such entry %d\n", which);
|
||||
else
|
||||
{
|
||||
free (entry->line);
|
||||
free (entry);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf (stderr, "non-numeric arg given to `delete'\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
374
readline/examples/rl-fgets.c
Normal file
374
readline/examples/rl-fgets.c
Normal file
|
@ -0,0 +1,374 @@
|
|||
/*
|
||||
Date: Tue, 16 Mar 2004 19:38:40 -0800
|
||||
From: Harold Levy <Harold.Levy@synopsys.com>
|
||||
Subject: fgets(stdin) --> readline() redirector
|
||||
To: chet@po.cwru.edu
|
||||
|
||||
Hi Chet,
|
||||
|
||||
Here is something you may find useful enough to include in the readline
|
||||
distribution. It is a shared library that redirects calls to fgets(stdin)
|
||||
to readline() via LD_PRELOAD, and it supports a custom prompt and list of
|
||||
command names. Many people have asked me for this file, so I thought I'd
|
||||
pass it your way in hope of just including it with readline to begin with.
|
||||
|
||||
Best Regards,
|
||||
|
||||
-Harold
|
||||
*/
|
||||
|
||||
/******************************************************************************
|
||||
*******************************************************************************
|
||||
|
||||
FILE NAME: fgets.c TARGET: libfgets.so
|
||||
AUTHOR: Harold Levy VERSION: 1.0
|
||||
hlevy@synopsys.com
|
||||
|
||||
ABSTRACT: Customize fgets() behavior via LD_PRELOAD in the following ways:
|
||||
|
||||
-- If fgets(stdin) is called, redirect to GNU readline() to obtain
|
||||
command-line editing, file-name completion, history, etc.
|
||||
|
||||
-- A list of commands for command-name completion can be configured by
|
||||
setting the environment-variable FGETS_COMMAND_FILE to a file containing
|
||||
the list of commands to be used.
|
||||
|
||||
-- Command-line editing with readline() works best when the prompt string
|
||||
is known; you can set this with the FGETS_PROMPT environment variable.
|
||||
|
||||
-- There special strings that libfgets will interpret as internal commands:
|
||||
|
||||
_fgets_reset_ reset the command list
|
||||
|
||||
_fgets_dump_ dump status
|
||||
|
||||
_fgets_debug_ toggle debug messages
|
||||
|
||||
HOW TO BUILD: Here are examples of how to build libfgets.so on various
|
||||
platforms; you will have to add -I and -L flags to configure access to
|
||||
the readline header and library files.
|
||||
|
||||
(32-bit builds with gcc)
|
||||
AIX: gcc -fPIC fgets.c -shared -o libfgets.so -lc -ldl -lreadline -ltermcap
|
||||
HP-UX: gcc -fPIC fgets.c -shared -o libfgets.so -lc -ldld -lreadline
|
||||
Linux: gcc -fPIC fgets.c -shared -o libfgets.so -lc -ldl -lreadline
|
||||
SunOS: gcc -fPIC fgets.c -shared -o libfgets.so -lc -ldl -lgen -lreadline
|
||||
|
||||
(64-bit builds without gcc)
|
||||
SunOS: SUNWspro/bin/cc -D_LARGEFILE64_SOURCE=1 -xtarget=ultra -xarch=v9 \
|
||||
-KPIC fgets.c -Bdynamic -lc -ldl -lgen -ltermcap -lreadline
|
||||
|
||||
HOW TO USE: Different operating systems have different levels of support
|
||||
for the LD_PRELOAD concept. The generic method for 32-bit platforms is to
|
||||
put libtermcap.so, libfgets.so, and libreadline.so (with absolute paths)
|
||||
in the LD_PRELOAD environment variable, and to put their parent directories
|
||||
in the LD_LIBRARY_PATH environment variable. Unfortunately there is no
|
||||
generic method for 64-bit platforms; e.g. for 64-bit SunOS, you would have
|
||||
to build both 32-bit and 64-bit libfgets and libreadline libraries, and
|
||||
use the LD_FLAGS_32 and LD_FLAGS_64 environment variables with preload and
|
||||
library_path configurations (a mix of 32-bit and 64-bit calls are made under
|
||||
64-bit SunOS).
|
||||
|
||||
EXAMPLE WRAPPER: Here is an example shell script wrapper around the
|
||||
program "foo" that uses fgets() for command-line input:
|
||||
|
||||
#!/bin/csh
|
||||
#### replace this with the libtermcap.so directory:
|
||||
set dir1 = "/usr/lib"
|
||||
#### replace this with the libfgets.so directory:
|
||||
set dir2 = "/usr/fgets"
|
||||
#### replace this with the libreadline.so directory:
|
||||
set dir3 = "/usr/local/lib"
|
||||
set lib1 = "${dir1}/libtermcap.so"
|
||||
set lib2 = "${dir2}/libfgets.so"
|
||||
set lib3 = "${dir3}/libreadline.so"
|
||||
if ( "${?LD_PRELOAD}" ) then
|
||||
setenv LD_PRELOAD "${lib1}:${lib2}:${lib3}:${LD_PRELOAD}"
|
||||
else
|
||||
setenv LD_PRELOAD "${lib1}:${lib2}:${lib3}"
|
||||
endif
|
||||
if ( "${?LD_LIBRARY_PATH}" ) then
|
||||
setenv LD_LIBRARY_PATH "${dir1}:${dir2}:${dir3}:${LD_LIBRARY_PATH}"
|
||||
else
|
||||
setenv LD_LIBRARY_PATH "${dir1}:${dir2}:${dir3}"
|
||||
endif
|
||||
setenv FGETS_COMMAND_FILE "${dir2}/foo.commands"
|
||||
setenv FGETS_PROMPT "foo> "
|
||||
exec "foo" $*
|
||||
|
||||
Copyright (C)©2003-2004 Harold Levy.
|
||||
|
||||
This code links to the GNU readline library, and as such is bound by 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 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.
|
||||
|
||||
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.
|
||||
|
||||
*******************************************************************************
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#include <strings.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
|
||||
|
||||
|
||||
/* for dynamically connecting to the native fgets() */
|
||||
#if defined(RTLD_NEXT)
|
||||
#define REAL_LIBC RTLD_NEXT
|
||||
#else
|
||||
#define REAL_LIBC ((void *) -1L)
|
||||
#endif
|
||||
typedef char * ( * fgets_t ) ( char * s, int n, FILE * stream ) ;
|
||||
|
||||
|
||||
|
||||
/* private data */
|
||||
/* -- writeable data is stored in the shared library's data segment
|
||||
-- every process that uses the shared library gets a private memory copy of
|
||||
its entire data segment
|
||||
-- static data in the shared library is not copied to the application
|
||||
-- only read-only (i.e. 'const') data is stored in the shared library's
|
||||
text segment
|
||||
*/
|
||||
static char ** my_fgets_names = NULL ;
|
||||
static int my_fgets_number_of_names = 0 ;
|
||||
static int my_fgets_debug_flag = 0 ;
|
||||
|
||||
|
||||
|
||||
/* invoked with _fgets_reset_ */
|
||||
static void
|
||||
my_fgets_reset (
|
||||
void
|
||||
) {
|
||||
if ( my_fgets_names && (my_fgets_number_of_names > 0) ) {
|
||||
int i ;
|
||||
if ( my_fgets_debug_flag ) {
|
||||
printf ( "libfgets: removing command list\n" ) ;
|
||||
}
|
||||
for ( i = 0 ; i < my_fgets_number_of_names ; i ++ ) {
|
||||
if ( my_fgets_names[i] ) free ( my_fgets_names[i] ) ;
|
||||
}
|
||||
free ( my_fgets_names ) ;
|
||||
}
|
||||
my_fgets_names = NULL ;
|
||||
my_fgets_number_of_names = 0 ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* invoked with _fgets_dump_ */
|
||||
static void
|
||||
my_fgets_dump (
|
||||
void
|
||||
) {
|
||||
char * s ;
|
||||
printf ( "\n" ) ;
|
||||
s = getenv ( "FGETS_PROMPT" ) ;
|
||||
printf ( "FGETS_PROMPT = %s\n", s ? s : "" ) ;
|
||||
s = getenv ( "FGETS_COMMAND_FILE" ) ;
|
||||
printf ( "FGETS_COMMAND_FILE = %s\n", s ? s : "" ) ;
|
||||
printf ( "debug flag = %d\n", my_fgets_debug_flag ) ;
|
||||
printf ( "#commands = %d\n", my_fgets_number_of_names ) ;
|
||||
if ( my_fgets_debug_flag ) {
|
||||
if ( my_fgets_names && (my_fgets_number_of_names > 0) ) {
|
||||
int i ;
|
||||
for ( i = 0 ; i < my_fgets_number_of_names ; i ++ ) {
|
||||
printf ( "%s\n", my_fgets_names[i] ) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
printf ( "\n" ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* invoked with _fgets_debug_ */
|
||||
static void
|
||||
my_fgets_debug_toggle (
|
||||
void
|
||||
) {
|
||||
my_fgets_debug_flag = my_fgets_debug_flag ? 0 : 1 ;
|
||||
if ( my_fgets_debug_flag ) {
|
||||
printf ( "libfgets: debug flag = %d\n", my_fgets_debug_flag ) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* read the command list if needed, return the i-th name */
|
||||
static char *
|
||||
my_fgets_lookup (
|
||||
int index
|
||||
) {
|
||||
if ( (! my_fgets_names) || (! my_fgets_number_of_names) ) {
|
||||
char * fname ;
|
||||
FILE * fp ;
|
||||
fgets_t _fgets ;
|
||||
int i ;
|
||||
char buf1[256], buf2[256] ;
|
||||
fname = getenv ( "FGETS_COMMAND_FILE" ) ;
|
||||
if ( ! fname ) {
|
||||
if ( my_fgets_debug_flag ) {
|
||||
printf ( "libfgets: empty or unset FGETS_COMMAND_FILE\n" ) ;
|
||||
}
|
||||
return NULL ;
|
||||
}
|
||||
fp = fopen ( fname, "r" ) ;
|
||||
if ( ! fp ) {
|
||||
if ( my_fgets_debug_flag ) {
|
||||
printf ( "libfgets: cannot open '%s' for reading\n", fname ) ;
|
||||
}
|
||||
return NULL ;
|
||||
}
|
||||
_fgets = (fgets_t) dlsym ( REAL_LIBC, "fgets" ) ;
|
||||
if ( ! _fgets ) {
|
||||
fprintf ( stderr,
|
||||
"libfgets: failed to dynamically link to native fgets()\n"
|
||||
) ;
|
||||
return NULL ;
|
||||
}
|
||||
for ( i = 0 ; _fgets(buf1,255,fp) ; i ++ ) ;
|
||||
if ( ! i ) { fclose(fp) ; return NULL ; }
|
||||
my_fgets_names = (char**) calloc ( i, sizeof(char*) ) ;
|
||||
rewind ( fp ) ;
|
||||
i = 0 ;
|
||||
while ( _fgets(buf1,255,fp) ) {
|
||||
buf1[255] = 0 ;
|
||||
if ( 1 == sscanf(buf1,"%s",buf2) ) {
|
||||
my_fgets_names[i] = strdup(buf2) ;
|
||||
i ++ ;
|
||||
}
|
||||
}
|
||||
fclose ( fp ) ;
|
||||
my_fgets_number_of_names = i ;
|
||||
if ( my_fgets_debug_flag ) {
|
||||
printf ( "libfgets: successfully read %d commands\n", i ) ;
|
||||
}
|
||||
}
|
||||
if ( index < my_fgets_number_of_names ) {
|
||||
return my_fgets_names[index] ;
|
||||
} else {
|
||||
return NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* generate a list of partial name matches for readline() */
|
||||
static char *
|
||||
my_fgets_generator (
|
||||
const char * text,
|
||||
int state
|
||||
)
|
||||
{
|
||||
static int list_index, len ;
|
||||
char * name ;
|
||||
if ( ! state ) {
|
||||
list_index = 0 ;
|
||||
len = strlen ( text ) ;
|
||||
}
|
||||
while ( ( name = my_fgets_lookup(list_index) ) ) {
|
||||
list_index ++ ;
|
||||
if ( ! strncmp ( name, text, len ) ) {
|
||||
return ( strdup ( name ) ) ;
|
||||
}
|
||||
}
|
||||
return ( NULL ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* partial name completion callback for readline() */
|
||||
static char **
|
||||
my_fgets_completion (
|
||||
const char * text,
|
||||
int start,
|
||||
int end
|
||||
)
|
||||
{
|
||||
char ** matches ;
|
||||
matches = NULL ;
|
||||
if ( ! start ) {
|
||||
matches = rl_completion_matches ( text, my_fgets_generator ) ;
|
||||
}
|
||||
return ( matches ) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* fgets() intercept */
|
||||
char *
|
||||
fgets (
|
||||
char * s,
|
||||
int n,
|
||||
FILE * stream
|
||||
)
|
||||
{
|
||||
if ( ! s ) return NULL ;
|
||||
if ( stream == stdin ) {
|
||||
char * prompt ;
|
||||
char * my_fgets_line ;
|
||||
rl_already_prompted = 1 ;
|
||||
rl_attempted_completion_function = my_fgets_completion ;
|
||||
rl_catch_signals = 1 ;
|
||||
rl_catch_sigwinch = 1 ;
|
||||
rl_set_signals () ;
|
||||
prompt = getenv ( "FGETS_PROMPT" ) ;
|
||||
for (
|
||||
my_fgets_line = 0 ; ! my_fgets_line ; my_fgets_line=readline(prompt)
|
||||
) ;
|
||||
if ( ! strncmp(my_fgets_line, "_fgets_reset_", 13) ) {
|
||||
my_fgets_reset () ;
|
||||
free ( my_fgets_line ) ;
|
||||
strcpy ( s, "\n" ) ;
|
||||
return ( s ) ;
|
||||
}
|
||||
if ( ! strncmp(my_fgets_line, "_fgets_dump_", 12) ) {
|
||||
my_fgets_dump () ;
|
||||
free ( my_fgets_line ) ;
|
||||
strcpy ( s, "\n" ) ;
|
||||
return ( s ) ;
|
||||
}
|
||||
if ( ! strncmp(my_fgets_line, "_fgets_debug_", 13) ) {
|
||||
my_fgets_debug_toggle () ;
|
||||
free ( my_fgets_line ) ;
|
||||
strcpy ( s, "\n" ) ;
|
||||
return ( s ) ;
|
||||
}
|
||||
(void) strncpy ( s, my_fgets_line, n-1 ) ;
|
||||
(void) strcat ( s, "\n" ) ;
|
||||
if ( *my_fgets_line ) add_history ( my_fgets_line ) ;
|
||||
free ( my_fgets_line ) ;
|
||||
return ( s ) ;
|
||||
} else {
|
||||
static fgets_t _fgets ;
|
||||
_fgets = (fgets_t) dlsym ( REAL_LIBC, "fgets" ) ;
|
||||
if ( ! _fgets ) {
|
||||
fprintf ( stderr,
|
||||
"libfgets: failed to dynamically link to native fgets()\n"
|
||||
) ;
|
||||
strcpy ( s, "\n" ) ;
|
||||
return ( s ) ;
|
||||
}
|
||||
return (
|
||||
_fgets ( s, n, stream )
|
||||
) ;
|
||||
}
|
||||
}
|
|
@ -31,12 +31,19 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include "posixstat.h"
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
extern void exit();
|
||||
#endif
|
||||
|
||||
#if defined (READLINE_LIBRARY)
|
||||
# include "posixstat.h"
|
||||
# include "readline.h"
|
||||
# include "history.h"
|
||||
#else
|
||||
# include <sys/stat.h>
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
|
|
@ -40,6 +40,12 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
extern void exit();
|
||||
#endif
|
||||
|
||||
#ifndef errno
|
||||
extern int errno;
|
||||
#endif
|
||||
|
|
37
readline/examples/rlfe/ChangeLog
Normal file
37
readline/examples/rlfe/ChangeLog
Normal file
|
@ -0,0 +1,37 @@
|
|||
2004-11-04 Per Bothner <per@bothner.com>
|
||||
|
||||
* pty.c: Import from screen-4.0.2.
|
||||
* configure.in, Makefile.in, config.h.in: Set up autoconf handling,
|
||||
copying a bunk of stuff over from screen.
|
||||
* rlfe.c: Use OpenPTY from pty.c instead of get_master_pty.
|
||||
|
||||
2004-11-03 Per Bothner <per@bothner.com>
|
||||
|
||||
* rlfe.c: Get input emphasis (boldening) more robust.
|
||||
|
||||
* rlfe.c: Various cleanups on comments and names.
|
||||
|
||||
2003-11-07 Wolfgang Taeuber <wolfgang_taeuber@agilent.com>
|
||||
|
||||
* Specify a history file and the size of the history file with command
|
||||
* line options; use EDITOR/VISUAL to set vi/emacs preference.
|
||||
|
||||
1999-09-03 Chet Ramey <chet@nike.ins.cwru.edu>
|
||||
|
||||
* fep.c: Memmove is not universally available. This patch assumes
|
||||
that an autoconf test has been performed, and that memcpy is
|
||||
available without checking.
|
||||
|
||||
* fep.c: VDISCARD is not universally available, even when termios is.
|
||||
|
||||
* fep.c: If a system doesn't have TIOCSCTTY, the first `open'
|
||||
performed after setsid allocates a controlling terminal. The
|
||||
original code would leave the child process running on the slave pty
|
||||
without a controlling tty if TIOCSCTTY was not available.
|
||||
|
||||
* fep.c: Most versions of SVR4, including solaris, don't allow
|
||||
terminal ioctl calls on the master side of the pty.
|
||||
|
||||
1999-08-28 Per Bothner <per@bothner.com>
|
||||
|
||||
* fep.c: Initial release.
|
176
readline/examples/rlfe/Makefile.in
Normal file
176
readline/examples/rlfe/Makefile.in
Normal file
|
@ -0,0 +1,176 @@
|
|||
#
|
||||
# Makefile template for rlfe
|
||||
#
|
||||
# See machine dependant config.h for more configuration options.
|
||||
#
|
||||
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
DESTDIR =
|
||||
|
||||
# Where to install screen.
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
# don't forget to change mandir and infodir in doc/Makefile.
|
||||
bindir = $(exec_prefix)/bin
|
||||
|
||||
VERSION = @VERSION@
|
||||
SCREEN = screen-$(VERSION)
|
||||
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
#LDFLAGS = -L$(READLINE_DIR)
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = -lreadline -lhistory -lncurses
|
||||
|
||||
CPP=@CPP@
|
||||
CPP_DEPEND=$(CC) -MM
|
||||
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
|
||||
AWK = @AWK@
|
||||
|
||||
OPTIONS=
|
||||
#OPTIONS= -DDEBUG
|
||||
|
||||
SHELL=/bin/sh
|
||||
|
||||
CFILES= rlfe.c pty.c
|
||||
HFILES= extern.h os.h screen.h
|
||||
EXTRA_DIST=configure.in configure Makefile.in config.h.in ChangeLog README
|
||||
OFILES= rlfe.o pty.o
|
||||
|
||||
all: rlfe
|
||||
|
||||
rlfe: $(OFILES)
|
||||
$(CC) $(LDFLAGS) -o $@ $(OFILES) $(LIBS)
|
||||
|
||||
rlfe-$(VERSION).tar.gz:
|
||||
tar czf $@ $(CFILES) $(HFILES) $(EXTRA_DIST)
|
||||
|
||||
.c.o:
|
||||
$(CC) -c -I. -I$(srcdir) $(M_CFLAGS) $(DEFS) $(OPTIONS) $(CFLAGS) $<
|
||||
|
||||
install_bin: .version screen
|
||||
-if [ -f $(DESTDIR)$(bindir)/$(SCREEN) ] && [ ! -f $(DESTDIR)$(bindir)/$(SCREEN).old ]; \
|
||||
then mv $(DESTDIR)$(bindir)/$(SCREEN) $(DESTDIR)$(bindir)/$(SCREEN).old; fi
|
||||
$(INSTALL_PROGRAM) screen $(DESTDIR)$(bindir)/$(SCREEN)
|
||||
-chown root $(DESTDIR)$(bindir)/$(SCREEN) && chmod 4755 $(DESTDIR)$(bindir)/$(SCREEN)
|
||||
# This doesn't work if $(bindir)/screen is a symlink
|
||||
-if [ -f $(DESTDIR)$(bindir)/screen ] && [ ! -f $(DESTDIR)$(bindir)/screen.old ]; then mv $(DESTDIR)$(bindir)/screen $(DESTDIR)$(bindir)/screen.old; fi
|
||||
rm -f $(DESTDIR)$(bindir)/screen
|
||||
(cd $(DESTDIR)$(bindir) && ln -sf $(SCREEN) screen)
|
||||
cp $(srcdir)/utf8encodings/?? $(DESTDIR)$(SCREENENCODINGS)
|
||||
|
||||
|
||||
uninstall: .version
|
||||
rm -f $(DESTDIR)$(bindir)/$(SCREEN)
|
||||
rm -f $(DESTDIR)$(bindir)/screen
|
||||
-mv $(DESTDIR)$(bindir)/screen.old $(DESTDIR)$(bindir)/screen
|
||||
rm -f $(DESTDIR)$(ETCSCREENRC)
|
||||
cd doc; $(MAKE) uninstall
|
||||
|
||||
shadow:
|
||||
mkdir shadow;
|
||||
cd shadow; ln -s ../*.[ch] ../*.in ../*.sh ../configure ../doc ../terminfo ../etc .
|
||||
rm -f shadow/term.h shadow/tty.c shadow/comm.h shadow/osdef.h
|
||||
echo "install all Makefiles and config:" > shadow/Makefile
|
||||
echo " rm -f config.cache" >> shadow/Makefile
|
||||
echo " sh ./configure" >> shadow/Makefile
|
||||
|
||||
term.h: term.c term.sh
|
||||
AWK=$(AWK) srcdir=$(srcdir) sh $(srcdir)/term.sh
|
||||
|
||||
kmapdef.c: term.h
|
||||
|
||||
tty.c: tty.sh
|
||||
sh $(srcdir)/tty.sh tty.c
|
||||
|
||||
mostlyclean:
|
||||
rm -f $(OFILES) rlfe *.o
|
||||
|
||||
clean celan: mostlyclean
|
||||
rm -f tty.c term.h comm.h osdef.h kmapdef.c core
|
||||
|
||||
# Delete all files from the current directory that are created by
|
||||
# configuring or building the program.
|
||||
# building of term.h/comm.h requires awk. Keep it in the distribution
|
||||
# we keep config.h, as this file knows where 'make dist' finds the ETCSCREENRC.
|
||||
#distclean: mostlyclean
|
||||
# rm -f $(SCREEN).tar $(SCREEN).tar.gz
|
||||
# rm -f config.status Makefile
|
||||
# rm -f osdef.h doc/Makefile
|
||||
|
||||
maintainer-clean:
|
||||
@echo "This command is not even intended for maintainers to use;"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
|
||||
|
||||
# Delete everything from the current directory that can be
|
||||
# reconstructed with this Makefile.
|
||||
realclean: .version mostlyclean
|
||||
rm -f $(SCREEN).tar $(SCREEN).tar.gz
|
||||
rm -f config.status Makefile doc/Makefile
|
||||
rm -f tty.c term.h comm.h osdef.h kmapdef.c
|
||||
rm -f config.h
|
||||
echo "install all Makefiles and config:" > Makefile
|
||||
echo " sh ./configure" >> Makefile
|
||||
|
||||
tags TAGS: $(CFILES)
|
||||
-ctags *.sh $(CFILES) *.h
|
||||
-ctags -e *.sh $(CFILES) *.h
|
||||
|
||||
dist: .version $(SCREEN).tar.gz
|
||||
|
||||
|
||||
# Perform self-tests (if any).
|
||||
check:
|
||||
|
||||
config:
|
||||
rm -f config.cache
|
||||
sh ./configure
|
||||
|
||||
|
||||
###############################################################################
|
||||
|
||||
.version:
|
||||
@rev=`sed < $(srcdir)/patchlevel.h -n -e '/#define REV/s/#define REV *//p'`; \
|
||||
vers=`sed < $(srcdir)/patchlevel.h -n -e '/#define VERS/s/#define VERS *//p'`; \
|
||||
pat=`sed < $(srcdir)/patchlevel.h -n -e '/#define PATCHLEVEL/s/#define PATCHLEVEL *//p'`; \
|
||||
if [ "$${rev}.$${vers}.$${pat}" != "$(VERSION)" ]; then \
|
||||
echo "This distribution is screen-$${rev}.$${vers}.$${pat}, but"; \
|
||||
echo "the Makefile is from $(VERSION). Please update!"; exit 1; fi
|
||||
|
||||
###############################################################################
|
||||
|
||||
mdepend: $(CFILES) term.h
|
||||
@rm -f DEPEND ; \
|
||||
for i in ${CFILES} ; do \
|
||||
echo "$$i" ; \
|
||||
echo `echo "$$i" | sed -e 's/.c$$/.o/'`": $$i" `\
|
||||
cc -E $$i |\
|
||||
grep '^# .*"\./.*\.h"' |\
|
||||
(sort -t'"' -u -k 2,2 2>/dev/null || sort -t'"' -u +1 -2) |\
|
||||
sed -e 's/.*"\.\/\(.*\)".*/\1/'\
|
||||
` >> DEPEND ; \
|
||||
done
|
||||
|
||||
depend: depend.in
|
||||
./config.status || ./configure
|
||||
|
||||
depend.in: $(CFILES) term.h
|
||||
cp Makefile.in Makefile.in~
|
||||
sed -e '/\#\#\# Dependencies/q' < Makefile.in > tmp_make
|
||||
for i in $(CFILES); do echo $$i; $(CPP_DEPEND) $$i >> tmp_make; done
|
||||
mv tmp_make Makefile.in
|
||||
|
||||
###############################################################################
|
||||
|
||||
### Dependencies:
|
||||
pty.o: pty.c config.h
|
78
readline/examples/rlfe/README
Normal file
78
readline/examples/rlfe/README
Normal file
|
@ -0,0 +1,78 @@
|
|||
rlfe (ReadLine Front-End) is a "universal wrapper" around readline.
|
||||
You specify an interactive program to run (typically a shell), and
|
||||
readline is used to edit input lines.
|
||||
|
||||
There are other such front-ends; what distinguishes this one is that
|
||||
it monitors the state of the inferior pty, and if the inferior program
|
||||
switches its terminal to raw mode, then rlfe passes your characters
|
||||
through directly. This basically means you can run your entire
|
||||
session (including bash and terminal-mode emacs) under rlfe.
|
||||
|
||||
FEATURES
|
||||
|
||||
* Can use all readline commands (and history) in commands that
|
||||
read input lines in "canonical mode" - even 'cat'!
|
||||
|
||||
* Automatically switches between "readline-editing mode" and "raw mode"
|
||||
depending on the terminal mode. If the inferior program invokes
|
||||
readline itself, it will do its own line editing. (The inferior
|
||||
readline will not know about rlfe, and it will have its own history.)
|
||||
You can even run programs like 'emavs -nw' and 'vi' under rlfe.
|
||||
The goal is you could leave rlfe always on without even knowing
|
||||
about it. (We're not quite there, but it works tolerably well.)
|
||||
|
||||
* The input line (after any prompt) is changed to bold-face.
|
||||
|
||||
INSTALL
|
||||
|
||||
The usual: ./configure && make && make install
|
||||
|
||||
Note so far rlfe has only been tested on GNU Linux (Fedora Core 2)
|
||||
and Mac OS X (10.3).
|
||||
|
||||
This assumes readline header files and libraries are in the default
|
||||
places. If not, you can create a link named readline pointing to the
|
||||
readline sources. To link with libreadline.a and libhistory.a
|
||||
you can copy or link them, or add LDFLAGS='-/path/to/readline' to
|
||||
the make command-line.
|
||||
|
||||
USAGE
|
||||
|
||||
Just run it. That by default runs bash. You can run some other
|
||||
command by giving it as command-line arguments.
|
||||
|
||||
There are a few tweaks: -h allows you to name the history file,
|
||||
and -s allows you to specify its size. It default to "emacs" mode,
|
||||
but if the the environment variable EDITOR is set to "vi" that
|
||||
mode is chosen.
|
||||
|
||||
ISSUES
|
||||
|
||||
* The mode switching depends on the terminal mode set by the inferior
|
||||
program. Thus ssh/telnet/screen-type programs will typically be in
|
||||
raw mode, so rlfe won't be much use, even if remote programs run in
|
||||
canonical mode. The work-around is to run rlfe on the remote end.
|
||||
|
||||
* Echo supression and prompt recognition are somewhat fragile.
|
||||
(A protocol so that the o/s tty code can reliably communicate its
|
||||
state to rlfe could solve this problem, and the previous one.)
|
||||
|
||||
* See the intro to rlfe.c for more notes.
|
||||
|
||||
* Assumes a VT100-compatible terminal, though that could be generalized
|
||||
if anybody cares.
|
||||
|
||||
* Requires ncurses.
|
||||
|
||||
* It would be useful to integrate rlfe's logic in a terminal emulator.
|
||||
That would make it easier to reposition the edit position with a mouse,
|
||||
integrate cut-and-paste with the system clipboard, and more robustly
|
||||
handle escape sequence and multi-byte characters more robustly.
|
||||
|
||||
AUTHOR
|
||||
|
||||
Per Bothner <per@bothner.com>
|
||||
|
||||
LICENSE
|
||||
|
||||
GPL.
|
375
readline/examples/rlfe/config.h.in
Normal file
375
readline/examples/rlfe/config.h.in
Normal file
|
@ -0,0 +1,375 @@
|
|||
/* Copyright 2004 Per Bothner <per@bothner.com>
|
||||
* Based on config.h from screen-4.0.2.
|
||||
* Copyright (c) 1993-2000
|
||||
* Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
|
||||
* Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
|
||||
* Copyright (c) 1987 Oliver Laumann
|
||||
*
|
||||
* 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 (see the file COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
****************************************************************
|
||||
* $Id$ FAU
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* User Configuration Section
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* define PTYMODE if you do not like the default of 0622, which allows
|
||||
* public write to your pty.
|
||||
* define PTYGROUP to some numerical group-id if you do not want the
|
||||
* tty to be in "your" group.
|
||||
* Note, screen is unable to change mode or group of the pty if it
|
||||
* is not installed with sufficient privilege. (e.g. set-uid-root)
|
||||
* define PTYROFS if the /dev/pty devices are mounted on a read-only
|
||||
* filesystem so screen should not even attempt to set mode or group
|
||||
* even if running as root (e.g. on TiVo).
|
||||
*/
|
||||
#undef PTYMODE
|
||||
#undef PTYGROUP
|
||||
#undef PTYROFS
|
||||
|
||||
/*
|
||||
* If screen is NOT installed set-uid root, screen can provide tty
|
||||
* security by exclusively locking the ptys. While this keeps other
|
||||
* users from opening your ptys, it also keeps your own subprocesses
|
||||
* from being able to open /dev/tty. Define LOCKPTY to add this
|
||||
* exclusive locking.
|
||||
*/
|
||||
#undef LOCKPTY
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
*
|
||||
* End of User Configuration Section
|
||||
*
|
||||
* Rest of this file is modified by 'configure'
|
||||
* Change at your own risk!
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Some defines to identify special unix variants
|
||||
*/
|
||||
#ifndef SVR4
|
||||
#undef SVR4
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
#undef _POSIX_SOURCE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define POSIX if your system supports IEEE Std 1003.1-1988 (POSIX).
|
||||
*/
|
||||
#undef POSIX
|
||||
|
||||
/*
|
||||
* Define TERMIO if you have struct termio instead of struct sgttyb.
|
||||
* This is usually the case for SVID systems, where BSD uses sgttyb.
|
||||
* POSIX systems should define this anyway, even though they use
|
||||
* struct termios.
|
||||
*/
|
||||
#undef TERMIO
|
||||
|
||||
/*
|
||||
* Define CYTERMIO if you have cyrillic termio modes.
|
||||
*/
|
||||
#undef CYTERMIO
|
||||
|
||||
/*
|
||||
* Define TERMINFO if your machine emulates the termcap routines
|
||||
* with the terminfo database.
|
||||
* Thus the .screenrc file is parsed for
|
||||
* the command 'terminfo' and not 'termcap'.
|
||||
*/
|
||||
#undef TERMINFO
|
||||
|
||||
/*
|
||||
* If your library does not define ospeed, define this.
|
||||
*/
|
||||
#undef NEED_OSPEED
|
||||
|
||||
/*
|
||||
* Define SYSV if your machine is SYSV complient (Sys V, HPUX, A/UX)
|
||||
*/
|
||||
#ifndef SYSV
|
||||
#undef SYSV
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define SIGVOID if your signal handlers return void. On older
|
||||
* systems, signal returns int, but on newer ones, it returns void.
|
||||
*/
|
||||
#undef SIGVOID
|
||||
|
||||
/*
|
||||
* Define USESIGSET if you have sigset for BSD 4.1 reliable signals.
|
||||
*/
|
||||
#undef USESIGSET
|
||||
|
||||
/*
|
||||
* Define SYSVSIGS if signal handlers must be reinstalled after
|
||||
* they have been called.
|
||||
*/
|
||||
#undef SYSVSIGS
|
||||
|
||||
/*
|
||||
* Define BSDWAIT if your system defines a 'union wait' in <sys/wait.h>
|
||||
*
|
||||
* Only allow BSDWAIT i.e. wait3 on nonposix systems, since
|
||||
* posix implies wait(3) and waitpid(3). vdlinden@fwi.uva.nl
|
||||
*
|
||||
*/
|
||||
#ifndef POSIX
|
||||
#undef BSDWAIT
|
||||
#endif
|
||||
|
||||
/*
|
||||
* On RISCOS we prefer wait2() over wait3(). rouilj@sni-usa.com
|
||||
*/
|
||||
#ifdef BSDWAIT
|
||||
#undef USE_WAIT2
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define if you have the utempter utmp helper program
|
||||
*/
|
||||
#undef HAVE_UTEMPTER
|
||||
|
||||
/*
|
||||
* If ttyslot() breaks getlogin() by returning indexes to utmp entries
|
||||
* of type DEAD_PROCESS, then our getlogin() replacement should be
|
||||
* selected by defining BUGGYGETLOGIN.
|
||||
*/
|
||||
#undef BUGGYGETLOGIN
|
||||
|
||||
/*
|
||||
* If your system has the calls setreuid() and setregid(),
|
||||
* define HAVE_SETREUID. Otherwise screen will use a forked process to
|
||||
* safely create output files without retaining any special privileges.
|
||||
*/
|
||||
#undef HAVE_SETREUID
|
||||
|
||||
/*
|
||||
* If your system supports BSD4.4's seteuid() and setegid(), define
|
||||
* HAVE_SETEUID.
|
||||
*/
|
||||
#undef HAVE_SETEUID
|
||||
|
||||
/*
|
||||
* If you want the "time" command to display the current load average
|
||||
* define LOADAV. Maybe you must install screen with the needed
|
||||
* privileges to read /dev/kmem.
|
||||
* Note that NLIST_ stuff is only checked, when getloadavg() is not available.
|
||||
*/
|
||||
#undef LOADAV
|
||||
|
||||
#undef LOADAV_NUM
|
||||
#undef LOADAV_TYPE
|
||||
#undef LOADAV_SCALE
|
||||
#undef LOADAV_GETLOADAVG
|
||||
#undef LOADAV_UNIX
|
||||
#undef LOADAV_AVENRUN
|
||||
#undef LOADAV_USE_NLIST64
|
||||
|
||||
#undef NLIST_DECLARED
|
||||
#undef NLIST_STRUCT
|
||||
#undef NLIST_NAME_UNION
|
||||
|
||||
/*
|
||||
* If your system has the new format /etc/ttys (like 4.3 BSD) and the
|
||||
* getttyent(3) library functions, define GETTTYENT.
|
||||
*/
|
||||
#undef GETTTYENT
|
||||
|
||||
/*
|
||||
* Define USEBCOPY if the bcopy/memcpy from your system's C library
|
||||
* supports the overlapping of source and destination blocks. When
|
||||
* undefined, screen uses its own (probably slower) version of bcopy().
|
||||
*
|
||||
* SYSV machines may have a working memcpy() -- Oh, this is
|
||||
* quite unlikely. Tell me if you see one.
|
||||
* "But then, memmove() should work, if at all available" he thought...
|
||||
* Boing, never say "works everywhere" unless you checked SCO UNIX.
|
||||
* Their memove fails the test in the configure script. Sigh. (Juergen)
|
||||
*/
|
||||
#undef USEBCOPY
|
||||
#undef USEMEMCPY
|
||||
#undef USEMEMMOVE
|
||||
|
||||
/*
|
||||
* If your system has vsprintf() and requires the use of the macros in
|
||||
* "varargs.h" to use functions with variable arguments,
|
||||
* define USEVARARGS.
|
||||
*/
|
||||
#undef USEVARARGS
|
||||
|
||||
/*
|
||||
* If your system has strerror() define this.
|
||||
*/
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/*
|
||||
* If the select return value doesn't treat a descriptor that is
|
||||
* usable for reading and writing as two hits, define SELECT_BROKEN.
|
||||
*/
|
||||
#undef SELECT_BROKEN
|
||||
|
||||
/*
|
||||
* Define this if your system supports named pipes.
|
||||
*/
|
||||
#undef NAMEDPIPE
|
||||
|
||||
/*
|
||||
* Define this if your system exits select() immediatly if a pipe is
|
||||
* opened read-only and no writer has opened it.
|
||||
*/
|
||||
#undef BROKEN_PIPE
|
||||
|
||||
/*
|
||||
* Define this if the unix-domain socket implementation doesn't
|
||||
* create a socket in the filesystem.
|
||||
*/
|
||||
#undef SOCK_NOT_IN_FS
|
||||
|
||||
/*
|
||||
* If your system has setenv() and unsetenv() define USESETENV
|
||||
*/
|
||||
#undef USESETENV
|
||||
|
||||
/*
|
||||
* If your system does not come with a setenv()/putenv()/getenv()
|
||||
* functions, you may bring in our own code by defining NEEDPUTENV.
|
||||
*/
|
||||
#undef NEEDPUTENV
|
||||
|
||||
/*
|
||||
* If the passwords are stored in a shadow file and you want the
|
||||
* builtin lock to work properly, define SHADOWPW.
|
||||
*/
|
||||
#undef SHADOWPW
|
||||
|
||||
/*
|
||||
* If you are on a SYS V machine that restricts filename length to 14
|
||||
* characters, you may need to enforce that by setting NAME_MAX to 14
|
||||
*/
|
||||
#undef NAME_MAX /* KEEP_UNDEF_HERE override system value */
|
||||
#undef NAME_MAX
|
||||
|
||||
/*
|
||||
* define HAVE_RENAME if your system has a rename() function
|
||||
*/
|
||||
#undef HAVE_RENAME
|
||||
|
||||
/*
|
||||
* define HAVE__EXIT if your system has the _exit() call.
|
||||
*/
|
||||
#undef HAVE__EXIT
|
||||
|
||||
/*
|
||||
* define HAVE_LSTAT if your system has symlinks and the lstat() call.
|
||||
*/
|
||||
#undef HAVE_LSTAT
|
||||
|
||||
/*
|
||||
* define HAVE_UTIMES if your system has the utimes() call.
|
||||
*/
|
||||
#undef HAVE_UTIMES
|
||||
|
||||
/*
|
||||
* define HAVE_FCHOWN if your system has the fchown() call.
|
||||
*/
|
||||
#undef HAVE_FCHOWN
|
||||
|
||||
/*
|
||||
* define HAVE_FCHMOD if your system has the fchmod() call.
|
||||
*/
|
||||
#undef HAVE_FCHMOD
|
||||
|
||||
/*
|
||||
* define HAVE_VSNPRINTF if your system has vsnprintf() (GNU lib).
|
||||
*/
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/*
|
||||
* define HAVE_GETCWD if your system has the getcwd() call.
|
||||
*/
|
||||
#undef HAVE_GETCWD
|
||||
|
||||
/*
|
||||
* define HAVE_SETLOCALE if your system has the setlocale() call.
|
||||
*/
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/*
|
||||
* define HAVE_STRFTIME if your system has the strftime() call.
|
||||
*/
|
||||
#undef HAVE_STRFTIME
|
||||
|
||||
/*
|
||||
* define HAVE_NL_LANGINFO if your system has the nl_langinfo() call
|
||||
* and <langinfo.h> defines CODESET.
|
||||
*/
|
||||
#undef HAVE_NL_LANGINFO
|
||||
|
||||
/*
|
||||
* Newer versions of Solaris include fdwalk, which can greatly improve
|
||||
* the startup time of screen; otherwise screen spends a lot of time
|
||||
* closing file descriptors.
|
||||
*/
|
||||
#undef HAVE_FDWALK
|
||||
|
||||
/*
|
||||
* define HAVE_DEV_PTC if you have a /dev/ptc character special
|
||||
* device.
|
||||
*/
|
||||
#undef HAVE_DEV_PTC
|
||||
|
||||
/*
|
||||
* define HAVE_SVR4_PTYS if you have a /dev/ptmx character special
|
||||
* device and support the ptsname(), grantpt(), unlockpt() functions.
|
||||
*/
|
||||
#undef HAVE_SVR4_PTYS
|
||||
|
||||
/*
|
||||
* define HAVE_GETPT if you have the getpt() function.
|
||||
*/
|
||||
#undef HAVE_GETPT
|
||||
|
||||
/*
|
||||
* define HAVE_OPENPTY if your system has the openpty() call.
|
||||
*/
|
||||
#undef HAVE_OPENPTY
|
||||
|
||||
/*
|
||||
* define PTYRANGE0 and or PTYRANGE1 if you want to adapt screen
|
||||
* to unusual environments. E.g. For SunOs the defaults are "qpr" and
|
||||
* "0123456789abcdef". For SunOs 4.1.2
|
||||
* #define PTYRANGE0 "pqrstuvwxyzPQRST"
|
||||
* is recommended by Dan Jacobson.
|
||||
*/
|
||||
#undef PTYRANGE0
|
||||
#undef PTYRANGE1
|
||||
|
||||
#define USEVARARGS
|
5400
readline/examples/rlfe/configure
vendored
Executable file
5400
readline/examples/rlfe/configure
vendored
Executable file
File diff suppressed because it is too large
Load diff
438
readline/examples/rlfe/configure.in
Normal file
438
readline/examples/rlfe/configure.in
Normal file
|
@ -0,0 +1,438 @@
|
|||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT(rlfe.c)
|
||||
AC_CONFIG_HEADER(config.h)
|
||||
VERSION=0.4
|
||||
AC_SUBST(VERSION)
|
||||
|
||||
dnl
|
||||
dnl Define some useful macros
|
||||
dnl
|
||||
AC_DEFUN(AC_PROGRAM_SOURCE,
|
||||
[AC_REQUIRE([AC_PROG_CPP])AC_PROVIDE([$0])cat > conftest.c <<EOF
|
||||
#include "confdefs.h"
|
||||
[$1]
|
||||
_CUT_HERE_
|
||||
[$2]
|
||||
EOF
|
||||
eval "$ac_cpp conftest.c 2>&5 | sed -e '1,/_CUT_HERE_/d' -e 's/ //g' > conftest.out"
|
||||
. ./conftest.out
|
||||
rm -f conftest*
|
||||
])dnl
|
||||
dnl
|
||||
define(AC_NOTE,
|
||||
[echo "$1" 1>&AC_FD_MSG
|
||||
])dnl
|
||||
|
||||
old_CFLAGS="$CFLAGS"
|
||||
AC_PROG_CC
|
||||
AC_PROG_CPP
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_ISC_POSIX
|
||||
|
||||
AC_TRY_RUN(main(){exit(0);},,[
|
||||
if test $CC != cc ; then
|
||||
AC_NOTE(Your $CC failed - restarting with CC=cc)
|
||||
AC_NOTE()
|
||||
CC=cc
|
||||
export CC
|
||||
exec $0 $configure_args
|
||||
fi
|
||||
])
|
||||
|
||||
AC_TRY_RUN(main(){exit(0);},,
|
||||
exec 5>&2
|
||||
eval $ac_link
|
||||
AC_NOTE(CC=$CC; CFLAGS=$CFLAGS; LIBS=$LIBS;)
|
||||
AC_NOTE($ac_compile)
|
||||
AC_MSG_ERROR(Can't run the compiler - sorry))
|
||||
|
||||
AC_TRY_RUN([
|
||||
main()
|
||||
{
|
||||
int __something_strange_();
|
||||
__something_strange_(0);
|
||||
}
|
||||
],AC_MSG_ERROR(Your compiler does not set the exit status - sorry))
|
||||
|
||||
AC_PROG_AWK
|
||||
|
||||
if test -f etc/toolcheck; then
|
||||
AC_CHECKING(for buggy tools)
|
||||
sh etc/toolcheck 1>&AC_FD_MSG
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl **** special unix variants ****
|
||||
dnl
|
||||
|
||||
AC_CHECKING(for System V)
|
||||
AC_TRY_COMPILE(
|
||||
[#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>], [int x = SIGCHLD | FNDELAY;], , AC_DEFINE(SYSV))
|
||||
|
||||
AC_CHECKING(for Solaris 2.x)
|
||||
AC_EGREP_CPP(yes,
|
||||
[#if defined(SVR4) && defined(sun)
|
||||
yes
|
||||
#endif
|
||||
], LIBS="$LIBS -lsocket -lnsl -lkstat")
|
||||
|
||||
dnl
|
||||
dnl **** select() ****
|
||||
dnl
|
||||
|
||||
AC_CHECKING(select)
|
||||
AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],,
|
||||
LIBS="$LIBS -lnet -lnsl"
|
||||
AC_CHECKING(select with $LIBS)
|
||||
AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],,
|
||||
AC_MSG_ERROR(!!! no select - no screen))
|
||||
)
|
||||
dnl
|
||||
dnl **** check the select implementation ****
|
||||
dnl
|
||||
|
||||
AC_CHECKING(select return value)
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
char *nam = "/tmp/conftest$$";
|
||||
|
||||
#ifdef NAMEDPIPE
|
||||
|
||||
#ifndef O_NONBLOCK
|
||||
#define O_NONBLOCK O_NDELAY
|
||||
#endif
|
||||
#ifndef S_IFIFO
|
||||
#define S_IFIFO 0010000
|
||||
#endif
|
||||
|
||||
|
||||
main()
|
||||
{
|
||||
#ifdef FD_SET
|
||||
fd_set f;
|
||||
#else
|
||||
int f;
|
||||
#endif
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
/* From Andrew A. Chernov (ache@astral.msk.su):
|
||||
* opening RDWR fifo fails in BSD 4.4, but select return values are
|
||||
* right.
|
||||
*/
|
||||
exit(0);
|
||||
#endif
|
||||
(void)alarm(5);
|
||||
#ifdef POSIX
|
||||
if (mkfifo(nam, 0777))
|
||||
#else
|
||||
if (mknod(nam, S_IFIFO|0777, 0))
|
||||
#endif
|
||||
exit(1);
|
||||
close(0);
|
||||
if (open(nam, O_RDWR | O_NONBLOCK))
|
||||
exit(1);
|
||||
if (write(0, "TEST", 4) == -1)
|
||||
exit(1);
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
main()
|
||||
{
|
||||
int s1, s2, l;
|
||||
struct sockaddr_un a;
|
||||
#ifdef FD_SET
|
||||
fd_set f;
|
||||
#else
|
||||
int f;
|
||||
#endif
|
||||
|
||||
(void)alarm(5);
|
||||
if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
||||
exit(1);
|
||||
a.sun_family = AF_UNIX;
|
||||
strcpy(a.sun_path, nam);
|
||||
(void) unlink(nam);
|
||||
if (bind(s1, (struct sockaddr *) &a, strlen(nam)+2) == -1)
|
||||
exit(1);
|
||||
if (listen(s1, 2))
|
||||
exit(1);
|
||||
if (fork() == 0)
|
||||
{
|
||||
if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
||||
kill(getppid(), 3);
|
||||
(void)connect(s2, (struct sockaddr *)&a, strlen(nam) + 2);
|
||||
if (write(s2, "HELLO", 5) == -1)
|
||||
kill(getppid(), 3);
|
||||
exit(0);
|
||||
}
|
||||
l = sizeof(a);
|
||||
close(0);
|
||||
if (accept(s1, (struct sockaddr *)&a, &l))
|
||||
exit(1);
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef FD_SET
|
||||
FD_SET(0, &f);
|
||||
#else
|
||||
f = 1;
|
||||
#endif
|
||||
if (select(1, &f, 0, 0, 0) == -1)
|
||||
exit(1);
|
||||
if (select(1, &f, &f, 0, 0) != 2)
|
||||
exit(1);
|
||||
exit(0);
|
||||
}
|
||||
],AC_NOTE(- select is ok),
|
||||
AC_NOTE(- select can't count) AC_DEFINE(SELECT_BROKEN))
|
||||
|
||||
dnl
|
||||
dnl **** termcap or terminfo ****
|
||||
dnl
|
||||
AC_CHECKING(for tgetent)
|
||||
AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
|
||||
olibs="$LIBS"
|
||||
LIBS="-lcurses $olibs"
|
||||
AC_CHECKING(libcurses)
|
||||
AC_TRY_LINK(,[
|
||||
#ifdef __hpux
|
||||
__sorry_hpux_libcurses_is_totally_broken_in_10_10();
|
||||
#else
|
||||
tgetent((char *)0, (char *)0);
|
||||
#endif
|
||||
],,
|
||||
LIBS="-ltermcap $olibs"
|
||||
AC_CHECKING(libtermcap)
|
||||
AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
|
||||
LIBS="-ltermlib $olibs"
|
||||
AC_CHECKING(libtermlib)
|
||||
AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
|
||||
LIBS="-lncurses $olibs"
|
||||
AC_CHECKING(libncurses)
|
||||
AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
|
||||
AC_MSG_ERROR(!!! no tgetent - no screen))))))
|
||||
|
||||
AC_TRY_RUN([
|
||||
main()
|
||||
{
|
||||
exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);
|
||||
}], AC_NOTE(- you use the termcap database),
|
||||
AC_NOTE(- you use the terminfo database) AC_DEFINE(TERMINFO))
|
||||
AC_CHECKING(ospeed)
|
||||
AC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED))
|
||||
|
||||
dnl
|
||||
dnl **** PTY specific things ****
|
||||
dnl
|
||||
AC_CHECKING(for /dev/ptc)
|
||||
if test -r /dev/ptc; then
|
||||
AC_DEFINE(HAVE_DEV_PTC)
|
||||
fi
|
||||
|
||||
AC_CHECKING(for SVR4 ptys)
|
||||
sysvr4ptys=
|
||||
if test -c /dev/ptmx ; then
|
||||
AC_TRY_LINK([],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS)
|
||||
sysvr4ptys=1])
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS(getpt)
|
||||
|
||||
dnl check for openpty()
|
||||
if test -z "$sysvr4ptys"; then
|
||||
AC_CHECK_FUNCS(openpty,,
|
||||
[AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"])])
|
||||
fi
|
||||
|
||||
AC_CHECKING(for ptyranges)
|
||||
if test -d /dev/ptym ; then
|
||||
pdir='/dev/ptym'
|
||||
else
|
||||
pdir='/dev'
|
||||
fi
|
||||
dnl SCO uses ptyp%d
|
||||
AC_EGREP_CPP(yes,
|
||||
[#ifdef M_UNIX
|
||||
yes;
|
||||
#endif
|
||||
], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
|
||||
dnl if test -c /dev/ptyp19; then
|
||||
dnl ptys=`echo /dev/ptyp??`
|
||||
dnl else
|
||||
dnl ptys=`echo $pdir/pty??`
|
||||
dnl fi
|
||||
if test "$ptys" != "$pdir/pty??" ; then
|
||||
p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
|
||||
p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
|
||||
AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
|
||||
AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
|
||||
fi
|
||||
|
||||
dnl **** pty mode/group handling ****
|
||||
dnl
|
||||
dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
|
||||
AC_ARG_WITH(pty-mode, [ --with-pty-mode=mode default mode for ptys], [ ptymode="${withval}" ])
|
||||
AC_ARG_WITH(pty-group, [ --with-pty-group=group default group for ptys], [ ptygrp="${withval}" ])
|
||||
test -n "$ptymode" || ptymode=0620
|
||||
if test -n "$ptygrp" ; then
|
||||
AC_DEFINE_UNQUOTED(PTYMODE, $ptymode)
|
||||
AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp)
|
||||
else
|
||||
|
||||
AC_CHECKING(default tty permissions/group)
|
||||
rm -f conftest_grp
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
main()
|
||||
{
|
||||
struct stat sb;
|
||||
char *x,*ttyname();
|
||||
int om, m;
|
||||
FILE *fp;
|
||||
|
||||
if (!(x = ttyname(0))) exit(1);
|
||||
if (stat(x, &sb)) exit(1);
|
||||
om = sb.st_mode;
|
||||
if (om & 002) exit(0);
|
||||
m = system("mesg y");
|
||||
if (m == -1 || m == 127) exit(1);
|
||||
if (stat(x, &sb)) exit(1);
|
||||
m = sb.st_mode;
|
||||
if (chmod(x, om)) exit(1);
|
||||
if (m & 002) exit(0);
|
||||
if (sb.st_gid == getgid()) exit(1);
|
||||
if (!(fp=fopen("conftest_grp", "w")))
|
||||
exit(1);
|
||||
fprintf(fp, "%d\n", sb.st_gid);
|
||||
fclose(fp);
|
||||
exit(0);
|
||||
}
|
||||
],[
|
||||
if test -f conftest_grp; then
|
||||
ptygrp=`cat conftest_grp`
|
||||
AC_NOTE([- pty mode: $ptymode, group: $ptygrp])
|
||||
AC_DEFINE_UNQUOTED(PTYMODE, $ptymode)
|
||||
AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp)
|
||||
else
|
||||
AC_NOTE(- ptys are world accessable)
|
||||
fi
|
||||
],[
|
||||
WRITEPATH=''
|
||||
XTERMPATH=''
|
||||
AC_PATH_PROG(WRITEPATH, write)
|
||||
AC_PATH_PROG(XTERMPATH, xterm)
|
||||
found=
|
||||
if test -n "$WRITEPATH$XTERMPATH"; then
|
||||
findfollow=
|
||||
lsfollow=
|
||||
found=`find $WRITEPATH $XTERMPATH -follow -print 2>/dev/null`
|
||||
if test -n "$found"; then
|
||||
findfollow=-follow
|
||||
lsfollow=L
|
||||
fi
|
||||
if test -n "$XTERMPATH"; then
|
||||
ptygrpn=`ls -l$lsfollow $XTERMPATH | sed -n -e 1p | $AWK '{print $4}'`
|
||||
if test tty != "$ptygrpn"; then
|
||||
XTERMPATH=
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if test -n "$WRITEPATH$XTERMPATH"; then
|
||||
found=`find $WRITEPATH $XTERMPATH $findfollow -perm -2000 -print`
|
||||
if test -n "$found"; then
|
||||
ptygrp=`ls -ln$lsfollow $found | sed -n -e 1p | $AWK '{print $4}'`
|
||||
AC_NOTE([- pty mode: $ptymode, group: $ptygrp])
|
||||
AC_DEFINE_UNQUOTED(PTYMODE, $ptymode)
|
||||
AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp)
|
||||
else
|
||||
AC_NOTE(- ptys are world accessable)
|
||||
fi
|
||||
else
|
||||
AC_NOTE(- can't determine - assume ptys are world accessable)
|
||||
fi
|
||||
]
|
||||
)
|
||||
rm -f conftest_grp
|
||||
fi
|
||||
|
||||
dnl
|
||||
dnl **** signal handling ****
|
||||
dnl
|
||||
if test -n "$posix" ; then
|
||||
|
||||
dnl POSIX has reliable signals with void return type.
|
||||
AC_NOTE(assuming posix signal definition)
|
||||
AC_DEFINE(SIGVOID)
|
||||
|
||||
else
|
||||
|
||||
AC_CHECKING(return type of signal handlers)
|
||||
AC_TRY_COMPILE(
|
||||
[#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
#ifdef signal
|
||||
#undef signal
|
||||
#endif
|
||||
extern void (*signal ()) ();], [int i;], AC_DEFINE(SIGVOID))
|
||||
AC_CHECKING(sigset)
|
||||
AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
],[
|
||||
#ifdef SIGVOID
|
||||
sigset(0, (void (*)())0);
|
||||
#else
|
||||
sigset(0, (int (*)())0);
|
||||
#endif
|
||||
], AC_DEFINE(USESIGSET))
|
||||
AC_CHECKING(signal implementation)
|
||||
AC_TRY_RUN([
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
#ifndef SIGCLD
|
||||
#define SIGCLD SIGCHLD
|
||||
#endif
|
||||
#ifdef USESIGSET
|
||||
#define signal sigset
|
||||
#endif
|
||||
|
||||
int got;
|
||||
|
||||
#ifdef SIGVOID
|
||||
void
|
||||
#endif
|
||||
hand()
|
||||
{
|
||||
got++;
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
/* on hpux we use sigvec to get bsd signals */
|
||||
#ifdef __hpux
|
||||
(void)signal(SIGCLD, hand);
|
||||
kill(getpid(), SIGCLD);
|
||||
kill(getpid(), SIGCLD);
|
||||
if (got < 2)
|
||||
exit(1);
|
||||
#endif
|
||||
exit(0);
|
||||
}
|
||||
],,AC_DEFINE(SYSVSIGS))
|
||||
|
||||
fi
|
||||
|
||||
AC_OUTPUT(Makefile)
|
33
readline/examples/rlfe/extern.h
Normal file
33
readline/examples/rlfe/extern.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/* Copyright (c) 1993-2002
|
||||
* Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
|
||||
* Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
|
||||
* Copyright (c) 1987 Oliver Laumann
|
||||
*
|
||||
* 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 (see the file COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
****************************************************************
|
||||
* $Id$ FAU
|
||||
*/
|
||||
|
||||
#if !defined(__GNUC__) || __GNUC__ < 2
|
||||
#undef __attribute__
|
||||
#define __attribute__(x)
|
||||
#endif
|
||||
|
||||
/* pty.c */
|
||||
extern int OpenPTY __P((char **));
|
||||
extern void InitPTY __P((int));
|
||||
|
530
readline/examples/rlfe/os.h
Normal file
530
readline/examples/rlfe/os.h
Normal file
|
@ -0,0 +1,530 @@
|
|||
/* Copyright (c) 1993-2002
|
||||
* Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
|
||||
* Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
|
||||
* Copyright (c) 1987 Oliver Laumann
|
||||
*
|
||||
* 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 (see the file COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
****************************************************************
|
||||
* $Id$ FAU
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
/* In strict ANSI mode, HP-UX machines define __hpux but not hpux */
|
||||
#if defined(__hpux) && !defined(hpux)
|
||||
# define hpux
|
||||
#endif
|
||||
|
||||
#if defined(__bsdi__) || defined(__386BSD__) || defined(_CX_UX) || defined(hpux) || defined(_IBMR2) || defined(linux)
|
||||
# include <signal.h>
|
||||
#endif /* __bsdi__ || __386BSD__ || _CX_UX || hpux || _IBMR2 || linux */
|
||||
|
||||
#ifdef ISC
|
||||
# ifdef ENAMETOOLONG
|
||||
# undef ENAMETOOLONG
|
||||
# endif
|
||||
# ifdef ENOTEMPTY
|
||||
# undef ENOTEMPTY
|
||||
# endif
|
||||
# include <sys/bsdtypes.h>
|
||||
# include <net/errno.h>
|
||||
#endif
|
||||
|
||||
#ifdef sun
|
||||
# define getpgrp __getpgrp
|
||||
# define exit __exit
|
||||
#endif
|
||||
#ifdef POSIX
|
||||
# include <unistd.h>
|
||||
# if defined(__STDC__)
|
||||
# include <stdlib.h>
|
||||
# endif /* __STDC__ */
|
||||
#endif /* POSIX */
|
||||
#ifdef sun
|
||||
# undef getpgrp
|
||||
# undef exit
|
||||
#endif /* sun */
|
||||
|
||||
#ifndef linux /* all done in <errno.h> */
|
||||
extern int errno;
|
||||
#endif /* linux */
|
||||
#ifndef HAVE_STRERROR
|
||||
/* No macros, please */
|
||||
#undef strerror
|
||||
#endif
|
||||
|
||||
#if !defined(SYSV) && !defined(linux)
|
||||
# ifdef NEWSOS
|
||||
# define strlen ___strlen___
|
||||
# include <strings.h>
|
||||
# undef strlen
|
||||
# else /* NEWSOS */
|
||||
# include <strings.h>
|
||||
# endif /* NEWSOS */
|
||||
#else /* SYSV */
|
||||
# if defined(SVR4) || defined(NEWSOS)
|
||||
# define strlen ___strlen___
|
||||
# include <string.h>
|
||||
# undef strlen
|
||||
# if !defined(NEWSOS) && !defined(__hpux)
|
||||
extern size_t strlen(const char *);
|
||||
# endif
|
||||
# else /* SVR4 */
|
||||
# include <string.h>
|
||||
# endif /* SVR4 */
|
||||
#endif /* SYSV */
|
||||
|
||||
#ifdef USEVARARGS
|
||||
# if defined(__STDC__)
|
||||
# include <stdarg.h>
|
||||
# define VA_LIST(var) va_list var;
|
||||
# define VA_DOTS ...
|
||||
# define VA_DECL
|
||||
# define VA_START(ap, fmt) va_start(ap, fmt)
|
||||
# define VA_ARGS(ap) ap
|
||||
# define VA_END(ap) va_end(ap)
|
||||
# else
|
||||
# include <varargs.h>
|
||||
# define VA_LIST(var) va_list var;
|
||||
# define VA_DOTS va_alist
|
||||
# define VA_DECL va_dcl
|
||||
# define VA_START(ap, fmt) va_start(ap)
|
||||
# define VA_ARGS(ap) ap
|
||||
# define VA_END(ap) va_end(ap)
|
||||
# endif
|
||||
#else
|
||||
# define VA_LIST(var)
|
||||
# define VA_DOTS p1, p2, p3, p4, p5, p6
|
||||
# define VA_DECL unsigned long VA_DOTS;
|
||||
# define VA_START(ap, fmt)
|
||||
# define VA_ARGS(ap) VA_DOTS
|
||||
# define VA_END(ap)
|
||||
# undef vsnprintf
|
||||
# define vsnprintf xsnprintf
|
||||
#endif
|
||||
|
||||
#if !defined(sun) && !defined(B43) && !defined(ISC) && !defined(pyr) && !defined(_CX_UX)
|
||||
# include <time.h>
|
||||
#endif
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef M_UNIX /* SCO */
|
||||
# include <sys/stream.h>
|
||||
# include <sys/ptem.h>
|
||||
# define ftruncate(fd, s) chsize(fd, s)
|
||||
#endif
|
||||
|
||||
#ifdef SYSV
|
||||
# define index strchr
|
||||
# define rindex strrchr
|
||||
# define bzero(poi,len) memset(poi,0,len)
|
||||
# define bcmp memcmp
|
||||
# define killpg(pgrp,sig) kill( -(pgrp), sig)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_GETCWD
|
||||
# define getcwd(b,l) getwd(b)
|
||||
#endif
|
||||
|
||||
#ifndef USEBCOPY
|
||||
# ifdef USEMEMMOVE
|
||||
# define bcopy(s,d,len) memmove(d,s,len)
|
||||
# else
|
||||
# ifdef USEMEMCPY
|
||||
# define bcopy(s,d,len) memcpy(d,s,len)
|
||||
# else
|
||||
# define NEED_OWN_BCOPY
|
||||
# define bcopy xbcopy
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef hpux
|
||||
# define setreuid(ruid, euid) setresuid(ruid, euid, -1)
|
||||
# define setregid(rgid, egid) setresgid(rgid, egid, -1)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_SETEUID) || defined(HAVE_SETREUID)
|
||||
# define USE_SETEUID
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE__EXIT) && !defined(_exit)
|
||||
#define _exit(x) exit(x)
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_UTIMES
|
||||
# define utimes utime
|
||||
#endif
|
||||
|
||||
#ifdef BUILTIN_TELNET
|
||||
# include <netinet/in.h>
|
||||
# include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#if defined(USE_LOCALE) && (!defined(HAVE_SETLOCALE) || !defined(HAVE_STRFTIME))
|
||||
# undef USE_LOCALE
|
||||
#endif
|
||||
|
||||
/*****************************************************************
|
||||
* terminal handling
|
||||
*/
|
||||
|
||||
#ifdef POSIX
|
||||
# include <termios.h>
|
||||
# ifdef hpux
|
||||
# include <bsdtty.h>
|
||||
# endif /* hpux */
|
||||
# ifdef NCCS
|
||||
# define MAXCC NCCS
|
||||
# else
|
||||
# define MAXCC 256
|
||||
# endif
|
||||
#else /* POSIX */
|
||||
# ifdef TERMIO
|
||||
# include <termio.h>
|
||||
# ifdef NCC
|
||||
# define MAXCC NCC
|
||||
# else
|
||||
# define MAXCC 256
|
||||
# endif
|
||||
# ifdef CYTERMIO
|
||||
# include <cytermio.h>
|
||||
# endif
|
||||
# else /* TERMIO */
|
||||
# include <sgtty.h>
|
||||
# endif /* TERMIO */
|
||||
#endif /* POSIX */
|
||||
|
||||
#ifndef VDISABLE
|
||||
# ifdef _POSIX_VDISABLE
|
||||
# define VDISABLE _POSIX_VDISABLE
|
||||
# else
|
||||
# define VDISABLE 0377
|
||||
# endif /* _POSIX_VDISABLE */
|
||||
#endif /* !VDISABLE */
|
||||
|
||||
|
||||
/* on sgi, regardless of the stream head's read mode (RNORM/RMSGN/RMSGD)
|
||||
* TIOCPKT mode causes data loss if our buffer is too small (IOSIZE)
|
||||
* to hold the whole packet at first read().
|
||||
* (Marc Boucher)
|
||||
*
|
||||
* matthew green:
|
||||
* TIOCPKT is broken on dgux 5.4.1 generic AViiON mc88100
|
||||
*
|
||||
* Joe Traister: On AIX4, programs like irc won't work if screen
|
||||
* uses TIOCPKT (select fails to return on pty read).
|
||||
*/
|
||||
#if defined(sgi) || defined(DGUX) || defined(_IBMR2)
|
||||
# undef TIOCPKT
|
||||
#endif
|
||||
|
||||
/* linux ncurses is broken, we have to use our own tputs */
|
||||
#if defined(linux) && defined(TERMINFO)
|
||||
# define tputs xtputs
|
||||
#endif
|
||||
|
||||
/* Alexandre Oliva: SVR4 style ptys don't work with osf */
|
||||
#ifdef __osf__
|
||||
# undef HAVE_SVR4_PTYS
|
||||
#endif
|
||||
|
||||
/*****************************************************************
|
||||
* utmp handling
|
||||
*/
|
||||
|
||||
#ifdef GETUTENT
|
||||
typedef char *slot_t;
|
||||
#else
|
||||
typedef int slot_t;
|
||||
#endif
|
||||
|
||||
#if defined(UTMPOK) || defined(BUGGYGETLOGIN)
|
||||
# if defined(SVR4) && !defined(DGUX) && !defined(__hpux) && !defined(linux)
|
||||
# include <utmpx.h>
|
||||
# define UTMPFILE UTMPX_FILE
|
||||
# define utmp utmpx
|
||||
# define getutent getutxent
|
||||
# define getutid getutxid
|
||||
# define getutline getutxline
|
||||
# define pututline pututxline
|
||||
# define setutent setutxent
|
||||
# define endutent endutxent
|
||||
# define ut_time ut_xtime
|
||||
# else /* SVR4 */
|
||||
# include <utmp.h>
|
||||
# endif /* SVR4 */
|
||||
# ifdef apollo
|
||||
/*
|
||||
* We don't have GETUTENT, so we dig into utmp ourselves.
|
||||
* But we save the permanent filedescriptor and
|
||||
* open utmp just when we need to.
|
||||
* This code supports an unsorted utmp. jw.
|
||||
*/
|
||||
# define UTNOKEEP
|
||||
# endif /* apollo */
|
||||
|
||||
# ifndef UTMPFILE
|
||||
# ifdef UTMP_FILE
|
||||
# define UTMPFILE UTMP_FILE
|
||||
# else
|
||||
# ifdef _PATH_UTMP
|
||||
# define UTMPFILE _PATH_UTMP
|
||||
# else
|
||||
# define UTMPFILE "/etc/utmp"
|
||||
# endif /* _PATH_UTMP */
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif /* UTMPOK || BUGGYGETLOGIN */
|
||||
|
||||
#if !defined(UTMPOK) && defined(USRLIMIT)
|
||||
# undef USRLIMIT
|
||||
#endif
|
||||
|
||||
#ifdef LOGOUTOK
|
||||
# ifndef LOGINDEFAULT
|
||||
# define LOGINDEFAULT 0
|
||||
# endif
|
||||
#else
|
||||
# ifdef LOGINDEFAULT
|
||||
# undef LOGINDEFAULT
|
||||
# endif
|
||||
# define LOGINDEFAULT 1
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
* file stuff
|
||||
*/
|
||||
|
||||
#ifndef F_OK
|
||||
#define F_OK 0
|
||||
#endif
|
||||
#ifndef X_OK
|
||||
#define X_OK 1
|
||||
#endif
|
||||
#ifndef W_OK
|
||||
#define W_OK 2
|
||||
#endif
|
||||
#ifndef R_OK
|
||||
#define R_OK 4
|
||||
#endif
|
||||
|
||||
#ifndef S_IFIFO
|
||||
#define S_IFIFO 0010000
|
||||
#endif
|
||||
#ifndef S_IREAD
|
||||
#define S_IREAD 0000400
|
||||
#endif
|
||||
#ifndef S_IWRITE
|
||||
#define S_IWRITE 0000200
|
||||
#endif
|
||||
#ifndef S_IEXEC
|
||||
#define S_IEXEC 0000100
|
||||
#endif
|
||||
|
||||
#if defined(S_IFIFO) && defined(S_IFMT) && !defined(S_ISFIFO)
|
||||
#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
|
||||
#endif
|
||||
#if defined(S_IFSOCK) && defined(S_IFMT) && !defined(S_ISSOCK)
|
||||
#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
|
||||
#endif
|
||||
#if defined(S_IFCHR) && defined(S_IFMT) && !defined(S_ISCHR)
|
||||
#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
|
||||
#endif
|
||||
#if defined(S_IFDIR) && defined(S_IFMT) && !defined(S_ISDIR)
|
||||
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
#if defined(S_IFLNK) && defined(S_IFMT) && !defined(S_ISLNK)
|
||||
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* SunOS 4.1.3: `man 2V open' has only one line that mentions O_NOBLOCK:
|
||||
*
|
||||
* O_NONBLOCK Same as O_NDELAY above.
|
||||
*
|
||||
* on the very same SunOS 4.1.3, I traced the open system call and found
|
||||
* that an open("/dev/ttyy08", O_RDWR|O_NONBLOCK|O_NOCTTY) was blocked,
|
||||
* whereas open("/dev/ttyy08", O_RDWR|O_NDELAY |O_NOCTTY) went through.
|
||||
*
|
||||
* For this simple reason I now favour O_NDELAY. jw. 4.5.95
|
||||
*/
|
||||
#if defined(sun) && !defined(SVR4)
|
||||
# undef O_NONBLOCK
|
||||
#endif
|
||||
|
||||
#if !defined(O_NONBLOCK) && defined(O_NDELAY)
|
||||
# define O_NONBLOCK O_NDELAY
|
||||
#endif
|
||||
|
||||
#if !defined(FNBLOCK) && defined(FNONBLOCK)
|
||||
# define FNBLOCK FNONBLOCK
|
||||
#endif
|
||||
#if !defined(FNBLOCK) && defined(FNDELAY)
|
||||
# define FNBLOCK FNDELAY
|
||||
#endif
|
||||
#if !defined(FNBLOCK) && defined(O_NONBLOCK)
|
||||
# define FNBLOCK O_NONBLOCK
|
||||
#endif
|
||||
|
||||
#ifndef POSIX
|
||||
#undef mkfifo
|
||||
#define mkfifo(n,m) mknod(n,S_IFIFO|(m),0)
|
||||
#endif
|
||||
|
||||
#if !defined(HAVE_LSTAT) && !defined(lstat)
|
||||
# define lstat stat
|
||||
#endif
|
||||
|
||||
/*****************************************************************
|
||||
* signal handling
|
||||
*/
|
||||
|
||||
#ifdef SIGVOID
|
||||
# define SIGRETURN
|
||||
# define sigret_t void
|
||||
#else
|
||||
# define SIGRETURN return 0;
|
||||
# define sigret_t int
|
||||
#endif
|
||||
|
||||
/* Geeeee, reverse it? */
|
||||
#if defined(SVR4) || (defined(SYSV) && defined(ISC)) || defined(_AIX) || defined(linux) || defined(ultrix) || defined(__386BSD__) || defined(__bsdi__) || defined(POSIX) || defined(NeXT)
|
||||
# define SIGHASARG
|
||||
#endif
|
||||
|
||||
#ifdef SIGHASARG
|
||||
# define SIGPROTOARG (int)
|
||||
# define SIGDEFARG (sigsig) int sigsig;
|
||||
# define SIGARG 0
|
||||
#else
|
||||
# define SIGPROTOARG (void)
|
||||
# define SIGDEFARG ()
|
||||
# define SIGARG
|
||||
#endif
|
||||
|
||||
#ifndef SIGCHLD
|
||||
#define SIGCHLD SIGCLD
|
||||
#endif
|
||||
|
||||
#if defined(POSIX) || defined(hpux)
|
||||
# define signal xsignal
|
||||
#else
|
||||
# ifdef USESIGSET
|
||||
# define signal sigset
|
||||
# endif /* USESIGSET */
|
||||
#endif
|
||||
|
||||
/* used in screen.c and attacher.c */
|
||||
#ifndef NSIG /* kbeal needs these w/o SYSV */
|
||||
# define NSIG 32
|
||||
#endif /* !NSIG */
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
* Wait stuff
|
||||
*/
|
||||
|
||||
#if (!defined(sysV68) && !defined(M_XENIX)) || defined(NeXT) || defined(M_UNIX)
|
||||
# include <sys/wait.h>
|
||||
#endif
|
||||
|
||||
#ifndef WTERMSIG
|
||||
# ifndef BSDWAIT /* if wait is NOT a union: */
|
||||
# define WTERMSIG(status) (status & 0177)
|
||||
# else
|
||||
# define WTERMSIG(status) status.w_T.w_Termsig
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef WSTOPSIG
|
||||
# ifndef BSDWAIT /* if wait is NOT a union: */
|
||||
# define WSTOPSIG(status) ((status >> 8) & 0377)
|
||||
# else
|
||||
# define WSTOPSIG(status) status.w_S.w_Stopsig
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* NET-2 uses WCOREDUMP */
|
||||
#if defined(WCOREDUMP) && !defined(WIFCORESIG)
|
||||
# define WIFCORESIG(status) WCOREDUMP(status)
|
||||
#endif
|
||||
|
||||
#ifndef WIFCORESIG
|
||||
# ifndef BSDWAIT /* if wait is NOT a union: */
|
||||
# define WIFCORESIG(status) (status & 0200)
|
||||
# else
|
||||
# define WIFCORESIG(status) status.w_T.w_Coredump
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef WEXITSTATUS
|
||||
# ifndef BSDWAIT /* if wait is NOT a union: */
|
||||
# define WEXITSTATUS(status) ((status >> 8) & 0377)
|
||||
# else
|
||||
# define WEXITSTATUS(status) status.w_T.w_Retcode
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
* select stuff
|
||||
*/
|
||||
|
||||
#if defined(M_XENIX) || defined(M_UNIX) || defined(_SEQUENT_)
|
||||
#include <sys/select.h> /* for timeval + FD... */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* SunOS 3.5 - Tom Schmidt - Micron Semiconductor, Inc - 27-Jul-93
|
||||
* tschmidt@vax.micron.com
|
||||
*/
|
||||
#ifndef FD_SET
|
||||
# ifndef SUNOS3
|
||||
typedef struct fd_set { int fds_bits[1]; } fd_set;
|
||||
# endif
|
||||
# define FD_ZERO(fd) ((fd)->fds_bits[0] = 0)
|
||||
# define FD_SET(b, fd) ((fd)->fds_bits[0] |= 1 << (b))
|
||||
# define FD_ISSET(b, fd) ((fd)->fds_bits[0] & 1 << (b))
|
||||
# define FD_SETSIZE 32
|
||||
#endif
|
||||
|
||||
|
||||
/*****************************************************************
|
||||
* user defineable stuff
|
||||
*/
|
||||
|
||||
#ifndef TERMCAP_BUFSIZE
|
||||
# define TERMCAP_BUFSIZE 2048
|
||||
#endif
|
||||
|
||||
#ifndef MAXPATHLEN
|
||||
# define MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
/*
|
||||
* you may try to vary this value. Use low values if your (VMS) system
|
||||
* tends to choke when pasting. Use high values if you want to test
|
||||
* how many characters your pty's can buffer.
|
||||
*/
|
||||
#define IOSIZE 4096
|
||||
|
387
readline/examples/rlfe/pty.c
Normal file
387
readline/examples/rlfe/pty.c
Normal file
|
@ -0,0 +1,387 @@
|
|||
/* Copyright (c) 1993-2002
|
||||
* Juergen Weigert (jnweiger@immd4.informatik.uni-erlangen.de)
|
||||
* Michael Schroeder (mlschroe@immd4.informatik.uni-erlangen.de)
|
||||
* Copyright (c) 1987 Oliver Laumann
|
||||
*
|
||||
* 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 (see the file COPYING); if not, write to the
|
||||
* Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*
|
||||
****************************************************************
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "screen.h"
|
||||
|
||||
#ifndef sun
|
||||
# include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
/* for solaris 2.1, Unixware (SVR4.2) and possibly others */
|
||||
#ifdef HAVE_SVR4_PTYS
|
||||
# include <sys/stropts.h>
|
||||
#endif
|
||||
|
||||
#if defined(sun) && defined(LOCKPTY) && !defined(TIOCEXCL)
|
||||
# include <sys/ttold.h>
|
||||
#endif
|
||||
|
||||
#ifdef ISC
|
||||
# include <sys/tty.h>
|
||||
# include <sys/sioctl.h>
|
||||
# include <sys/pty.h>
|
||||
#endif
|
||||
|
||||
#ifdef sgi
|
||||
# include <sys/sysmacros.h>
|
||||
#endif /* sgi */
|
||||
|
||||
#include "extern.h"
|
||||
|
||||
/*
|
||||
* if no PTYRANGE[01] is in the config file, we pick a default
|
||||
*/
|
||||
#ifndef PTYRANGE0
|
||||
# define PTYRANGE0 "qpr"
|
||||
#endif
|
||||
#ifndef PTYRANGE1
|
||||
# define PTYRANGE1 "0123456789abcdef"
|
||||
#endif
|
||||
|
||||
/* SVR4 pseudo ttys don't seem to work with SCO-5 */
|
||||
#ifdef M_UNIX
|
||||
# undef HAVE_SVR4_PTYS
|
||||
#endif
|
||||
|
||||
extern int eff_uid;
|
||||
|
||||
/* used for opening a new pty-pair: */
|
||||
static char PtyName[32], TtyName[32];
|
||||
|
||||
#if !(defined(sequent) || defined(_SEQUENT_) || defined(HAVE_SVR4_PTYS))
|
||||
# ifdef hpux
|
||||
static char PtyProto[] = "/dev/ptym/ptyXY";
|
||||
static char TtyProto[] = "/dev/pty/ttyXY";
|
||||
# else
|
||||
# ifdef M_UNIX
|
||||
static char PtyProto[] = "/dev/ptypXY";
|
||||
static char TtyProto[] = "/dev/ttypXY";
|
||||
# else
|
||||
static char PtyProto[] = "/dev/ptyXY";
|
||||
static char TtyProto[] = "/dev/ttyXY";
|
||||
# endif
|
||||
# endif /* hpux */
|
||||
#endif
|
||||
|
||||
static void initmaster __P((int));
|
||||
|
||||
#if defined(sun)
|
||||
/* sun's utmp_update program opens the salve side, thus corrupting
|
||||
*/
|
||||
int pty_preopen = 1;
|
||||
#else
|
||||
int pty_preopen = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Open all ptys with O_NOCTTY, just to be on the safe side
|
||||
* (RISCos mips breaks otherwise)
|
||||
*/
|
||||
#ifndef O_NOCTTY
|
||||
# define O_NOCTTY 0
|
||||
#endif
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
static void
|
||||
initmaster(f)
|
||||
int f;
|
||||
{
|
||||
#ifdef POSIX
|
||||
tcflush(f, TCIOFLUSH);
|
||||
#else
|
||||
# ifdef TIOCFLUSH
|
||||
(void) ioctl(f, TIOCFLUSH, (char *) 0);
|
||||
# endif
|
||||
#endif
|
||||
#ifdef LOCKPTY
|
||||
(void) ioctl(f, TIOCEXCL, (char *) 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
InitPTY(f)
|
||||
int f;
|
||||
{
|
||||
if (f < 0)
|
||||
return;
|
||||
#if defined(I_PUSH) && defined(HAVE_SVR4_PTYS) && !defined(sgi) && !defined(linux) && !defined(__osf__) && !defined(M_UNIX)
|
||||
if (ioctl(f, I_PUSH, "ptem"))
|
||||
Panic(errno, "InitPTY: cannot I_PUSH ptem");
|
||||
if (ioctl(f, I_PUSH, "ldterm"))
|
||||
Panic(errno, "InitPTY: cannot I_PUSH ldterm");
|
||||
# ifdef sun
|
||||
if (ioctl(f, I_PUSH, "ttcompat"))
|
||||
Panic(errno, "InitPTY: cannot I_PUSH ttcompat");
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#if defined(OSX) && !defined(PTY_DONE)
|
||||
#define PTY_DONE
|
||||
int
|
||||
OpenPTY(ttyn)
|
||||
char **ttyn;
|
||||
{
|
||||
register int f;
|
||||
if ((f = open_controlling_pty(TtyName)) < 0)
|
||||
return -1;
|
||||
initmaster(f);
|
||||
*ttyn = TtyName;
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#if (defined(sequent) || defined(_SEQUENT_)) && !defined(PTY_DONE)
|
||||
#define PTY_DONE
|
||||
int
|
||||
OpenPTY(ttyn)
|
||||
char **ttyn;
|
||||
{
|
||||
char *m, *s;
|
||||
register int f;
|
||||
|
||||
if ((f = getpseudotty(&s, &m)) < 0)
|
||||
return -1;
|
||||
#ifdef _SEQUENT_
|
||||
fvhangup(s);
|
||||
#endif
|
||||
strncpy(PtyName, m, sizeof(PtyName));
|
||||
strncpy(TtyName, s, sizeof(TtyName));
|
||||
initmaster(f);
|
||||
*ttyn = TtyName;
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#if defined(__sgi) && !defined(PTY_DONE)
|
||||
#define PTY_DONE
|
||||
int
|
||||
OpenPTY(ttyn)
|
||||
char **ttyn;
|
||||
{
|
||||
int f;
|
||||
char *name, *_getpty();
|
||||
sigret_t (*sigcld)__P(SIGPROTOARG);
|
||||
|
||||
/*
|
||||
* SIGCHLD set to SIG_DFL for _getpty() because it may fork() and
|
||||
* exec() /usr/adm/mkpts
|
||||
*/
|
||||
sigcld = signal(SIGCHLD, SIG_DFL);
|
||||
name = _getpty(&f, O_RDWR | O_NONBLOCK, 0600, 0);
|
||||
signal(SIGCHLD, sigcld);
|
||||
|
||||
if (name == 0)
|
||||
return -1;
|
||||
initmaster(f);
|
||||
*ttyn = name;
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#if defined(MIPS) && defined(HAVE_DEV_PTC) && !defined(PTY_DONE)
|
||||
#define PTY_DONE
|
||||
int
|
||||
OpenPTY(ttyn)
|
||||
char **ttyn;
|
||||
{
|
||||
register int f;
|
||||
struct stat buf;
|
||||
|
||||
strcpy(PtyName, "/dev/ptc");
|
||||
if ((f = open(PtyName, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0)
|
||||
return -1;
|
||||
if (fstat(f, &buf) < 0)
|
||||
{
|
||||
close(f);
|
||||
return -1;
|
||||
}
|
||||
sprintf(TtyName, "/dev/ttyq%d", minor(buf.st_rdev));
|
||||
initmaster(f);
|
||||
*ttyn = TtyName;
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#if defined(HAVE_SVR4_PTYS) && !defined(PTY_DONE)
|
||||
#define PTY_DONE
|
||||
int
|
||||
OpenPTY(ttyn)
|
||||
char **ttyn;
|
||||
{
|
||||
register int f;
|
||||
char *m, *ptsname();
|
||||
int unlockpt __P((int)), grantpt __P((int));
|
||||
#if defined(HAVE_GETPT) && defined(linux)
|
||||
int getpt __P((void));
|
||||
#endif
|
||||
sigret_t (*sigcld)__P(SIGPROTOARG);
|
||||
|
||||
strcpy(PtyName, "/dev/ptmx");
|
||||
#if defined(HAVE_GETPT) && defined(linux)
|
||||
if ((f = getpt()) == -1)
|
||||
#else
|
||||
if ((f = open(PtyName, O_RDWR | O_NOCTTY)) == -1)
|
||||
#endif
|
||||
return -1;
|
||||
|
||||
/*
|
||||
* SIGCHLD set to SIG_DFL for grantpt() because it fork()s and
|
||||
* exec()s pt_chmod
|
||||
*/
|
||||
sigcld = signal(SIGCHLD, SIG_DFL);
|
||||
if ((m = ptsname(f)) == NULL || grantpt(f) || unlockpt(f))
|
||||
{
|
||||
signal(SIGCHLD, sigcld);
|
||||
close(f);
|
||||
return -1;
|
||||
}
|
||||
signal(SIGCHLD, sigcld);
|
||||
strncpy(TtyName, m, sizeof(TtyName));
|
||||
initmaster(f);
|
||||
*ttyn = TtyName;
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#if defined(_AIX) && defined(HAVE_DEV_PTC) && !defined(PTY_DONE)
|
||||
#define PTY_DONE
|
||||
|
||||
int
|
||||
OpenPTY(ttyn)
|
||||
char **ttyn;
|
||||
{
|
||||
register int f;
|
||||
|
||||
/* a dumb looking loop replaced by mycrofts code: */
|
||||
strcpy (PtyName, "/dev/ptc");
|
||||
if ((f = open (PtyName, O_RDWR | O_NOCTTY)) < 0)
|
||||
return -1;
|
||||
strncpy(TtyName, ttyname(f), sizeof(TtyName));
|
||||
if (eff_uid && access(TtyName, R_OK | W_OK))
|
||||
{
|
||||
close(f);
|
||||
return -1;
|
||||
}
|
||||
initmaster(f);
|
||||
# ifdef _IBMR2
|
||||
pty_preopen = 1;
|
||||
# endif
|
||||
*ttyn = TtyName;
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#if defined(HAVE_OPENPTY) && !defined(PTY_DONE)
|
||||
#define PTY_DONE
|
||||
int
|
||||
OpenPTY(ttyn)
|
||||
char **ttyn;
|
||||
{
|
||||
int f, s;
|
||||
if (openpty(&f, &s, TtyName, NULL, NULL) != 0)
|
||||
return -1;
|
||||
close(s);
|
||||
initmaster(f);
|
||||
pty_preopen = 1;
|
||||
*ttyn = TtyName;
|
||||
return f;
|
||||
}
|
||||
#endif
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
#ifndef PTY_DONE
|
||||
int
|
||||
OpenPTY(ttyn)
|
||||
char **ttyn;
|
||||
{
|
||||
register char *p, *q, *l, *d;
|
||||
register int f;
|
||||
|
||||
debug("OpenPTY: Using BSD style ptys.\n");
|
||||
strcpy(PtyName, PtyProto);
|
||||
strcpy(TtyName, TtyProto);
|
||||
for (p = PtyName; *p != 'X'; p++)
|
||||
;
|
||||
for (q = TtyName; *q != 'X'; q++)
|
||||
;
|
||||
for (l = PTYRANGE0; (*p = *l) != '\0'; l++)
|
||||
{
|
||||
for (d = PTYRANGE1; (p[1] = *d) != '\0'; d++)
|
||||
{
|
||||
debug1("OpenPTY tries '%s'\n", PtyName);
|
||||
if ((f = open(PtyName, O_RDWR | O_NOCTTY)) == -1)
|
||||
continue;
|
||||
q[0] = *l;
|
||||
q[1] = *d;
|
||||
if (eff_uid && access(TtyName, R_OK | W_OK))
|
||||
{
|
||||
close(f);
|
||||
continue;
|
||||
}
|
||||
#if defined(sun) && defined(TIOCGPGRP) && !defined(SUNOS3)
|
||||
/* Hack to ensure that the slave side of the pty is
|
||||
* unused. May not work in anything other than SunOS4.1
|
||||
*/
|
||||
{
|
||||
int pgrp;
|
||||
|
||||
/* tcgetpgrp does not work (uses TIOCGETPGRP)! */
|
||||
if (ioctl(f, TIOCGPGRP, (char *)&pgrp) != -1 || errno != EIO)
|
||||
{
|
||||
close(f);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
initmaster(f);
|
||||
*ttyn = TtyName;
|
||||
return f;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
780
readline/examples/rlfe/rlfe.c
Normal file
780
readline/examples/rlfe/rlfe.c
Normal file
|
@ -0,0 +1,780 @@
|
|||
/* A front-end using readline to "cook" input lines.
|
||||
*
|
||||
* Copyright (C) 2004, 1999 Per Bothner
|
||||
*
|
||||
* This front-end 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.
|
||||
*
|
||||
* Some code from Johnson & Troan: "Linux Application Development"
|
||||
* (Addison-Wesley, 1998) was used directly or for inspiration.
|
||||
*
|
||||
* 2003-11-07 Wolfgang Taeuber <wolfgang_taeuber@agilent.com>
|
||||
* Specify a history file and the size of the history file with command
|
||||
* line options; use EDITOR/VISUAL to set vi/emacs preference.
|
||||
*/
|
||||
|
||||
/* PROBLEMS/TODO:
|
||||
*
|
||||
* Only tested under GNU/Linux and Mac OS 10.x; needs to be ported.
|
||||
*
|
||||
* Switching between line-editing-mode vs raw-char-mode depending on
|
||||
* what tcgetattr returns is inherently not robust, plus it doesn't
|
||||
* work when ssh/telnetting in. A better solution is possible if the
|
||||
* tty system can send in-line escape sequences indicating the current
|
||||
* mode, echo'd input, etc. That would also allow a user preference
|
||||
* to set different colors for prompt, input, stdout, and stderr.
|
||||
*
|
||||
* When running mc -c under the Linux console, mc does not recognize
|
||||
* mouse clicks, which mc does when not running under rlfe.
|
||||
*
|
||||
* Pasting selected text containing tabs is like hitting the tab character,
|
||||
* which invokes readline completion. We don't want this. I don't know
|
||||
* if this is fixable without integrating rlfe into a terminal emulator.
|
||||
*
|
||||
* Echo suppression is a kludge, but can only be avoided with better kernel
|
||||
* support: We need a tty mode to disable "real" echoing, while still
|
||||
* letting the inferior think its tty driver to doing echoing.
|
||||
* Stevens's book claims SCR$ and BSD4.3+ have TIOCREMOTE.
|
||||
*
|
||||
* The latest readline may have some hooks we can use to avoid having
|
||||
* to back up the prompt. (See HAVE_ALREADY_PROMPTED.)
|
||||
*
|
||||
* Desirable readline feature: When in cooked no-echo mode (e.g. password),
|
||||
* echo characters are they are types with '*', but remove them when done.
|
||||
*
|
||||
* Asynchronous output while we're editing an input line should be
|
||||
* inserted in the output view *before* the input line, so that the
|
||||
* lines being edited (with the prompt) float at the end of the input.
|
||||
*
|
||||
* A "page mode" option to emulate more/less behavior: At each page of
|
||||
* output, pause for a user command. This required parsing the output
|
||||
* to keep track of line lengths. It also requires remembering the
|
||||
* output, if we want an option to scroll back, which suggests that
|
||||
* this should be integrated with a terminal emulator like xterm.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <signal.h>
|
||||
#include <netdb.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef READLINE_LIBRARY
|
||||
# include "readline.h"
|
||||
# include "history.h"
|
||||
#else
|
||||
# include <readline/readline.h>
|
||||
# include <readline/history.h>
|
||||
#endif
|
||||
|
||||
#ifndef COMMAND
|
||||
#define COMMAND "/bin/bash"
|
||||
#endif
|
||||
#ifndef COMMAND_ARGS
|
||||
#define COMMAND_ARGS COMMAND
|
||||
#endif
|
||||
|
||||
#ifndef ALT_COMMAND
|
||||
#define ALT_COMMAND "/bin/sh"
|
||||
#endif
|
||||
#ifndef ALT_COMMAND_ARGS
|
||||
#define ALT_COMMAND_ARGS ALT_COMMAND
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MEMMOVE
|
||||
# if __GNUC__ > 1
|
||||
# define memmove(d, s, n) __builtin_memcpy(d, s, n)
|
||||
# else
|
||||
# define memmove(d, s, n) memcpy(d, s, n)
|
||||
# endif
|
||||
#else
|
||||
# define memmove(d, s, n) memcpy(d, s, n)
|
||||
#endif
|
||||
|
||||
#define APPLICATION_NAME "rlfe"
|
||||
|
||||
static int in_from_inferior_fd;
|
||||
static int out_to_inferior_fd;
|
||||
static void set_edit_mode ();
|
||||
static void usage_exit ();
|
||||
static char *hist_file = 0;
|
||||
static int hist_size = 0;
|
||||
|
||||
/* Unfortunately, we cannot safely display echo from the inferior process.
|
||||
The reason is that the echo bit in the pty is "owned" by the inferior,
|
||||
and if we try to turn it off, we could confuse the inferior.
|
||||
Thus, when echoing, we get echo twice: First readline echoes while
|
||||
we're actually editing. Then we send the line to the inferior, and the
|
||||
terminal driver send back an extra echo.
|
||||
The work-around is to remember the input lines, and when we see that
|
||||
line come back, we supress the output.
|
||||
A better solution (supposedly available on SVR4) would be a smarter
|
||||
terminal driver, with more flags ... */
|
||||
#define ECHO_SUPPRESS_MAX 1024
|
||||
char echo_suppress_buffer[ECHO_SUPPRESS_MAX];
|
||||
int echo_suppress_start = 0;
|
||||
int echo_suppress_limit = 0;
|
||||
|
||||
/*#define DEBUG*/
|
||||
|
||||
#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))
|
||||
#else
|
||||
#define DPRINT0(FMT) ((void) 0) /* Do nothing */
|
||||
#define DPRINT1(FMT, V1) ((void) 0) /* Do nothing */
|
||||
#define DPRINT2(FMT, V1, V2) ((void) 0) /* Do nothing */
|
||||
#endif
|
||||
|
||||
struct termios orig_term;
|
||||
|
||||
/* Pid of child process. */
|
||||
static pid_t child = -1;
|
||||
|
||||
static void
|
||||
sig_child (int signo)
|
||||
{
|
||||
int status;
|
||||
wait (&status);
|
||||
if (hist_file != 0)
|
||||
{
|
||||
write_history (hist_file);
|
||||
if (hist_size)
|
||||
history_truncate_file (hist_file, hist_size);
|
||||
}
|
||||
DPRINT0 ("(Child process died.)\n");
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &orig_term);
|
||||
exit (0);
|
||||
}
|
||||
|
||||
volatile int propagate_sigwinch = 0;
|
||||
|
||||
/* sigwinch_handler
|
||||
* propagate window size changes from input file descriptor to
|
||||
* master side of pty.
|
||||
*/
|
||||
void sigwinch_handler(int signal) {
|
||||
propagate_sigwinch = 1;
|
||||
}
|
||||
|
||||
|
||||
/* get_slave_pty() returns an integer file descriptor.
|
||||
* If it returns < 0, an error has occurred.
|
||||
* Otherwise, it has returned the slave file descriptor.
|
||||
*/
|
||||
|
||||
int get_slave_pty(char *name) {
|
||||
struct group *gptr;
|
||||
gid_t gid;
|
||||
int slave = -1;
|
||||
|
||||
/* chown/chmod the corresponding pty, if possible.
|
||||
* This will only work if the process has root permissions.
|
||||
* Alternatively, write and exec a small setuid program that
|
||||
* does just this.
|
||||
*/
|
||||
if ((gptr = getgrnam("tty")) != 0) {
|
||||
gid = gptr->gr_gid;
|
||||
} else {
|
||||
/* if the tty group does not exist, don't change the
|
||||
* group on the slave pty, only the owner
|
||||
*/
|
||||
gid = -1;
|
||||
}
|
||||
|
||||
/* Note that we do not check for errors here. If this is code
|
||||
* where these actions are critical, check for errors!
|
||||
*/
|
||||
chown(name, getuid(), gid);
|
||||
/* This code only makes the slave read/writeable for the user.
|
||||
* If this is for an interactive shell that will want to
|
||||
* receive "write" and "wall" messages, OR S_IWGRP into the
|
||||
* second argument below.
|
||||
*/
|
||||
chmod(name, S_IRUSR|S_IWUSR);
|
||||
|
||||
/* open the corresponding slave pty */
|
||||
slave = open(name, O_RDWR);
|
||||
return (slave);
|
||||
}
|
||||
|
||||
/* Certain special characters, such as ctrl/C, we want to pass directly
|
||||
to the inferior, rather than letting readline handle them. */
|
||||
|
||||
static char special_chars[20];
|
||||
static int special_chars_count;
|
||||
|
||||
static void
|
||||
add_special_char(int ch)
|
||||
{
|
||||
if (ch != 0)
|
||||
special_chars[special_chars_count++] = ch;
|
||||
}
|
||||
|
||||
static int eof_char;
|
||||
|
||||
static int
|
||||
is_special_char(int ch)
|
||||
{
|
||||
int i;
|
||||
#if 0
|
||||
if (ch == eof_char && rl_point == rl_end)
|
||||
return 1;
|
||||
#endif
|
||||
for (i = special_chars_count; --i >= 0; )
|
||||
if (special_chars[i] == ch)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char buf[1024];
|
||||
/* buf[0 .. buf_count-1] is the what has been emitted on the current line.
|
||||
It is used as the readline prompt. */
|
||||
static int buf_count = 0;
|
||||
|
||||
int do_emphasize_input = 1;
|
||||
int current_emphasize_input;
|
||||
|
||||
char *start_input_mode = "\033[1m";
|
||||
char *end_input_mode = "\033[0m";
|
||||
|
||||
int num_keys = 0;
|
||||
|
||||
static void maybe_emphasize_input (int on)
|
||||
{
|
||||
if (on == current_emphasize_input
|
||||
|| (on && ! do_emphasize_input))
|
||||
return;
|
||||
fprintf (rl_outstream, on ? start_input_mode : end_input_mode);
|
||||
fflush (rl_outstream);
|
||||
current_emphasize_input = on;
|
||||
}
|
||||
|
||||
static void
|
||||
null_prep_terminal (int meta)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
null_deprep_terminal ()
|
||||
{
|
||||
maybe_emphasize_input (0);
|
||||
}
|
||||
|
||||
static int
|
||||
pre_input_change_mode (void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
char pending_special_char;
|
||||
|
||||
static void
|
||||
line_handler (char *line)
|
||||
{
|
||||
if (line == NULL)
|
||||
{
|
||||
char buf[1];
|
||||
DPRINT0("saw eof!\n");
|
||||
buf[0] = '\004'; /* ctrl/d */
|
||||
write (out_to_inferior_fd, buf, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
static char enter[] = "\r";
|
||||
/* Send line to inferior: */
|
||||
int length = strlen (line);
|
||||
if (length > ECHO_SUPPRESS_MAX-2)
|
||||
{
|
||||
echo_suppress_start = 0;
|
||||
echo_suppress_limit = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (echo_suppress_limit + length > ECHO_SUPPRESS_MAX - 2)
|
||||
{
|
||||
if (echo_suppress_limit - echo_suppress_start + length
|
||||
<= ECHO_SUPPRESS_MAX - 2)
|
||||
{
|
||||
memmove (echo_suppress_buffer,
|
||||
echo_suppress_buffer + echo_suppress_start,
|
||||
echo_suppress_limit - echo_suppress_start);
|
||||
echo_suppress_limit -= echo_suppress_start;
|
||||
echo_suppress_start = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
echo_suppress_limit = 0;
|
||||
}
|
||||
echo_suppress_start = 0;
|
||||
}
|
||||
memcpy (echo_suppress_buffer + echo_suppress_limit,
|
||||
line, length);
|
||||
echo_suppress_limit += length;
|
||||
echo_suppress_buffer[echo_suppress_limit++] = '\r';
|
||||
echo_suppress_buffer[echo_suppress_limit++] = '\n';
|
||||
}
|
||||
write (out_to_inferior_fd, line, length);
|
||||
if (pending_special_char == 0)
|
||||
{
|
||||
write (out_to_inferior_fd, enter, sizeof(enter)-1);
|
||||
if (*line)
|
||||
add_history (line);
|
||||
}
|
||||
free (line);
|
||||
}
|
||||
rl_callback_handler_remove ();
|
||||
buf_count = 0;
|
||||
num_keys = 0;
|
||||
if (pending_special_char != 0)
|
||||
{
|
||||
write (out_to_inferior_fd, &pending_special_char, 1);
|
||||
pending_special_char = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* Value of rl_getc_function.
|
||||
Use this because readline should read from stdin, not rl_instream,
|
||||
points to the pty (so readline has monitor its terminal modes). */
|
||||
|
||||
int
|
||||
my_rl_getc (FILE *dummy)
|
||||
{
|
||||
int ch = rl_getc (stdin);
|
||||
if (is_special_char (ch))
|
||||
{
|
||||
pending_special_char = ch;
|
||||
return '\r';
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char** argv)
|
||||
{
|
||||
char *path;
|
||||
int i;
|
||||
int master;
|
||||
char *name;
|
||||
int in_from_tty_fd;
|
||||
struct sigaction act;
|
||||
struct winsize ws;
|
||||
struct termios t;
|
||||
int maxfd;
|
||||
fd_set in_set;
|
||||
static char empty_string[1] = "";
|
||||
char *prompt = empty_string;
|
||||
int ioctl_err = 0;
|
||||
int arg_base = 1;
|
||||
|
||||
#ifdef DEBUG
|
||||
logfile = fopen("/tmp/rlfe.log", "w");
|
||||
#endif
|
||||
|
||||
while (arg_base<argc)
|
||||
{
|
||||
if (argv[arg_base][0] != '-')
|
||||
break;
|
||||
if (arg_base+1 >= argc )
|
||||
usage_exit();
|
||||
switch(argv[arg_base][1])
|
||||
{
|
||||
case 'h':
|
||||
arg_base++;
|
||||
hist_file = argv[arg_base];
|
||||
break;
|
||||
case 's':
|
||||
arg_base++;
|
||||
hist_size = atoi(argv[arg_base]);
|
||||
if (hist_size<0)
|
||||
usage_exit();
|
||||
break;
|
||||
default:
|
||||
usage_exit();
|
||||
}
|
||||
arg_base++;
|
||||
}
|
||||
if (hist_file)
|
||||
read_history (hist_file);
|
||||
|
||||
set_edit_mode ();
|
||||
|
||||
rl_readline_name = APPLICATION_NAME;
|
||||
|
||||
if ((master = OpenPTY (&name)) < 0)
|
||||
{
|
||||
perror("ptypair: could not open master pty");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
DPRINT1("pty name: '%s'\n", name);
|
||||
|
||||
/* set up SIGWINCH handler */
|
||||
act.sa_handler = sigwinch_handler;
|
||||
sigemptyset(&(act.sa_mask));
|
||||
act.sa_flags = 0;
|
||||
if (sigaction(SIGWINCH, &act, NULL) < 0)
|
||||
{
|
||||
perror("ptypair: could not handle SIGWINCH ");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (ioctl(STDIN_FILENO, TIOCGWINSZ, &ws) < 0)
|
||||
{
|
||||
perror("ptypair: could not get window size");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if ((child = fork()) < 0)
|
||||
{
|
||||
perror("cannot fork");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (child == 0)
|
||||
{
|
||||
int slave; /* file descriptor for slave pty */
|
||||
|
||||
/* We are in the child process */
|
||||
close(master);
|
||||
|
||||
#ifdef TIOCSCTTY
|
||||
if ((slave = get_slave_pty(name)) < 0)
|
||||
{
|
||||
perror("ptypair: could not open slave pty");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* We need to make this process a session group leader, because
|
||||
* it is on a new PTY, and things like job control simply will
|
||||
* not work correctly unless there is a session group leader
|
||||
* and process group leader (which a session group leader
|
||||
* automatically is). This also disassociates us from our old
|
||||
* controlling tty.
|
||||
*/
|
||||
if (setsid() < 0)
|
||||
{
|
||||
perror("could not set session leader");
|
||||
}
|
||||
|
||||
/* Tie us to our new controlling tty. */
|
||||
#ifdef TIOCSCTTY
|
||||
if (ioctl(slave, TIOCSCTTY, NULL))
|
||||
{
|
||||
perror("could not set new controlling tty");
|
||||
}
|
||||
#else
|
||||
if ((slave = get_slave_pty(name)) < 0)
|
||||
{
|
||||
perror("ptypair: could not open slave pty");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* make slave pty be standard in, out, and error */
|
||||
dup2(slave, STDIN_FILENO);
|
||||
dup2(slave, STDOUT_FILENO);
|
||||
dup2(slave, STDERR_FILENO);
|
||||
|
||||
/* at this point the slave pty should be standard input */
|
||||
if (slave > 2)
|
||||
{
|
||||
close(slave);
|
||||
}
|
||||
|
||||
/* Try to restore window size; failure isn't critical */
|
||||
if (ioctl(STDOUT_FILENO, TIOCSWINSZ, &ws) < 0)
|
||||
{
|
||||
perror("could not restore window size");
|
||||
}
|
||||
|
||||
/* now start the shell */
|
||||
{
|
||||
static char* command_args[] = { COMMAND_ARGS, NULL };
|
||||
static char* alt_command_args[] = { ALT_COMMAND_ARGS, NULL };
|
||||
if (argc <= 1)
|
||||
{
|
||||
execvp (COMMAND, command_args);
|
||||
execvp (ALT_COMMAND, alt_command_args);
|
||||
}
|
||||
else
|
||||
execvp (argv[arg_base], &argv[arg_base]);
|
||||
}
|
||||
|
||||
/* should never be reached */
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* parent */
|
||||
signal (SIGCHLD, sig_child);
|
||||
|
||||
/* Note that we only set termios settings for standard input;
|
||||
* the master side of a pty is NOT a tty.
|
||||
*/
|
||||
tcgetattr(STDIN_FILENO, &orig_term);
|
||||
|
||||
t = orig_term;
|
||||
eof_char = t.c_cc[VEOF];
|
||||
/* add_special_char(t.c_cc[VEOF]);*/
|
||||
add_special_char(t.c_cc[VINTR]);
|
||||
add_special_char(t.c_cc[VQUIT]);
|
||||
add_special_char(t.c_cc[VSUSP]);
|
||||
#if defined (VDISCARD)
|
||||
add_special_char(t.c_cc[VDISCARD]);
|
||||
#endif
|
||||
|
||||
t.c_lflag &= ~(ICANON | ISIG | ECHO | ECHOCTL | ECHOE | \
|
||||
ECHOK | ECHOKE | ECHONL | ECHOPRT );
|
||||
t.c_iflag &= ~ICRNL;
|
||||
t.c_iflag |= IGNBRK;
|
||||
t.c_cc[VMIN] = 1;
|
||||
t.c_cc[VTIME] = 0;
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &t);
|
||||
in_from_inferior_fd = master;
|
||||
out_to_inferior_fd = master;
|
||||
rl_instream = fdopen (master, "r");
|
||||
rl_getc_function = my_rl_getc;
|
||||
|
||||
rl_prep_term_function = null_prep_terminal;
|
||||
rl_deprep_term_function = null_deprep_terminal;
|
||||
rl_pre_input_hook = pre_input_change_mode;
|
||||
rl_callback_handler_install (prompt, line_handler);
|
||||
|
||||
in_from_tty_fd = STDIN_FILENO;
|
||||
FD_ZERO (&in_set);
|
||||
maxfd = in_from_inferior_fd > in_from_tty_fd ? in_from_inferior_fd
|
||||
: in_from_tty_fd;
|
||||
for (;;)
|
||||
{
|
||||
int num;
|
||||
FD_SET (in_from_inferior_fd, &in_set);
|
||||
FD_SET (in_from_tty_fd, &in_set);
|
||||
|
||||
num = select(maxfd+1, &in_set, NULL, NULL, NULL);
|
||||
|
||||
if (propagate_sigwinch)
|
||||
{
|
||||
struct winsize ws;
|
||||
if (ioctl (STDIN_FILENO, TIOCGWINSZ, &ws) >= 0)
|
||||
{
|
||||
ioctl (master, TIOCSWINSZ, &ws);
|
||||
}
|
||||
propagate_sigwinch = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (num <= 0)
|
||||
{
|
||||
perror ("select");
|
||||
exit (-1);
|
||||
}
|
||||
if (FD_ISSET (in_from_tty_fd, &in_set))
|
||||
{
|
||||
extern int readline_echoing_p;
|
||||
struct termios term_master;
|
||||
int do_canon = 1;
|
||||
int do_icrnl = 1;
|
||||
int ioctl_ret;
|
||||
|
||||
DPRINT1("[tty avail num_keys:%d]\n", num_keys);
|
||||
|
||||
/* If we can't get tty modes for the master side of the pty, we
|
||||
can't handle non-canonical-mode programs. Always assume the
|
||||
master is in canonical echo mode if we can't tell. */
|
||||
ioctl_ret = tcgetattr(master, &term_master);
|
||||
|
||||
if (ioctl_ret >= 0)
|
||||
{
|
||||
do_canon = (term_master.c_lflag & ICANON) != 0;
|
||||
do_icrnl = (term_master.c_lflag & ICRNL) != 0;
|
||||
readline_echoing_p = (term_master.c_lflag & ECHO) != 0;
|
||||
DPRINT1 ("echo,canon,crnl:%03d\n",
|
||||
100 * readline_echoing_p
|
||||
+ 10 * do_canon
|
||||
+ 1 * do_icrnl);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ioctl_err == 0)
|
||||
DPRINT1("tcgetattr on master fd failed: errno = %d\n", errno);
|
||||
ioctl_err = 1;
|
||||
}
|
||||
|
||||
if (do_canon == 0 && num_keys == 0)
|
||||
{
|
||||
char ch[10];
|
||||
int count = read (STDIN_FILENO, ch, sizeof(ch));
|
||||
DPRINT1("[read %d chars from stdin: ", count);
|
||||
DPRINT2(" \"%.*s\"]\n", count, ch);
|
||||
if (do_icrnl)
|
||||
{
|
||||
int i = count;
|
||||
while (--i >= 0)
|
||||
{
|
||||
if (ch[i] == '\r')
|
||||
ch[i] = '\n';
|
||||
}
|
||||
}
|
||||
maybe_emphasize_input (1);
|
||||
write (out_to_inferior_fd, ch, count);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (num_keys == 0)
|
||||
{
|
||||
int i;
|
||||
/* Re-install callback handler for new prompt. */
|
||||
if (prompt != empty_string)
|
||||
free (prompt);
|
||||
if (prompt == NULL)
|
||||
{
|
||||
DPRINT0("New empty prompt\n");
|
||||
prompt = empty_string;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (do_emphasize_input && buf_count > 0)
|
||||
{
|
||||
prompt = malloc (buf_count + strlen (end_input_mode)
|
||||
+ strlen (start_input_mode) + 5);
|
||||
sprintf (prompt, "\001%s\002%.*s\001%s\002",
|
||||
end_input_mode,
|
||||
buf_count, buf,
|
||||
start_input_mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
prompt = malloc (buf_count + 1);
|
||||
memcpy (prompt, buf, buf_count);
|
||||
prompt[buf_count] = '\0';
|
||||
}
|
||||
DPRINT1("New prompt '%s'\n", prompt);
|
||||
#if 0 /* ifdef HAVE_RL_ALREADY_PROMPTED */
|
||||
/* Doesn't quite work when do_emphasize_input is 1. */
|
||||
rl_already_prompted = buf_count > 0;
|
||||
#else
|
||||
if (buf_count > 0)
|
||||
write (1, "\r", 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
rl_callback_handler_install (prompt, line_handler);
|
||||
}
|
||||
num_keys++;
|
||||
maybe_emphasize_input (1);
|
||||
rl_callback_read_char ();
|
||||
}
|
||||
}
|
||||
else /* output from inferior. */
|
||||
{
|
||||
int i;
|
||||
int count;
|
||||
int old_count;
|
||||
if (buf_count > (sizeof(buf) >> 2))
|
||||
buf_count = 0;
|
||||
count = read (in_from_inferior_fd, buf+buf_count,
|
||||
sizeof(buf) - buf_count);
|
||||
DPRINT2("read %d from inferior, buf_count=%d", count, buf_count);
|
||||
DPRINT2(": \"%.*s\"", count, buf+buf_count);
|
||||
maybe_emphasize_input (0);
|
||||
if (count <= 0)
|
||||
{
|
||||
DPRINT0 ("(Connection closed by foreign host.)\n");
|
||||
tcsetattr(STDIN_FILENO, TCSANOW, &orig_term);
|
||||
exit (0);
|
||||
}
|
||||
old_count = buf_count;
|
||||
|
||||
/* Look for any pending echo that we need to suppress. */
|
||||
while (echo_suppress_start < echo_suppress_limit
|
||||
&& count > 0
|
||||
&& buf[buf_count] == echo_suppress_buffer[echo_suppress_start])
|
||||
{
|
||||
count--;
|
||||
buf_count++;
|
||||
echo_suppress_start++;
|
||||
}
|
||||
DPRINT1("suppressed %d characters of echo.\n", buf_count-old_count);
|
||||
|
||||
/* Write to the terminal anything that was not suppressed. */
|
||||
if (count > 0)
|
||||
write (1, buf + buf_count, count);
|
||||
|
||||
/* Finally, look for a prompt candidate.
|
||||
* When we get around to going input (from the keyboard),
|
||||
* we will consider the prompt to be anything since the last
|
||||
* line terminator. So we need to save that text in the
|
||||
* initial part of buf. However, anything before the
|
||||
* most recent end-of-line is not interesting. */
|
||||
buf_count += count;
|
||||
#if 1
|
||||
for (i = buf_count; --i >= old_count; )
|
||||
#else
|
||||
for (i = buf_count - 1; i-- >= buf_count - count; )
|
||||
#endif
|
||||
{
|
||||
if (buf[i] == '\n' || buf[i] == '\r')
|
||||
{
|
||||
i++;
|
||||
memmove (buf, buf+i, buf_count - i);
|
||||
buf_count -= i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
DPRINT2("-> i: %d, buf_count: %d\n", i, buf_count);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void set_edit_mode ()
|
||||
{
|
||||
int vi = 0;
|
||||
char *shellopts;
|
||||
|
||||
shellopts = getenv ("SHELLOPTS");
|
||||
while (shellopts != 0)
|
||||
{
|
||||
if (strncmp ("vi", shellopts, 2) == 0)
|
||||
{
|
||||
vi = 1;
|
||||
break;
|
||||
}
|
||||
shellopts = index (shellopts + 1, ':');
|
||||
}
|
||||
|
||||
if (!vi)
|
||||
{
|
||||
if (getenv ("EDITOR") != 0)
|
||||
vi |= strcmp (getenv ("EDITOR"), "vi") == 0;
|
||||
}
|
||||
|
||||
if (vi)
|
||||
rl_variable_bind ("editing-mode", "vi");
|
||||
else
|
||||
rl_variable_bind ("editing-mode", "emacs");
|
||||
}
|
||||
|
||||
|
||||
static void usage_exit ()
|
||||
{
|
||||
fprintf (stderr, "Usage: rlfe [-h histfile] [-s size] cmd [arg1] [arg2] ...\n\n");
|
||||
exit (1);
|
||||
}
|
2
readline/examples/rlfe/screen.h
Normal file
2
readline/examples/rlfe/screen.h
Normal file
|
@ -0,0 +1,2 @@
|
|||
/* Dummy header to avoid modifying pty.c */
|
||||
#include "os.h"
|
337
readline/examples/rlptytest.c
Normal file
337
readline/examples/rlptytest.c
Normal file
|
@ -0,0 +1,337 @@
|
|||
/*
|
||||
*
|
||||
* Another test harness for the readline callback interface.
|
||||
*
|
||||
* Author: Bob Rossi <bob@brasko.net>
|
||||
*/
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <errno.h>
|
||||
#include <curses.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#if 0 /* LINUX */
|
||||
#include <pty.h>
|
||||
#else
|
||||
#include <util.h>
|
||||
#endif
|
||||
|
||||
#ifdef READLINE_LIBRARY
|
||||
# include "readline.h"
|
||||
#else
|
||||
# include <readline/readline.h>
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Master/Slave PTY used to keep readline off of stdin/stdout.
|
||||
*/
|
||||
static int masterfd = -1;
|
||||
static int slavefd;
|
||||
|
||||
void
|
||||
sigint (s)
|
||||
int s;
|
||||
{
|
||||
tty_reset (STDIN_FILENO);
|
||||
close (masterfd);
|
||||
close (slavefd);
|
||||
printf ("\n");
|
||||
exit (0);
|
||||
}
|
||||
|
||||
static int
|
||||
user_input()
|
||||
{
|
||||
int size;
|
||||
const int MAX = 1024;
|
||||
char *buf = (char *)malloc(MAX+1);
|
||||
|
||||
size = read (STDIN_FILENO, buf, MAX);
|
||||
if (size == -1)
|
||||
return -1;
|
||||
|
||||
size = write (masterfd, buf, size);
|
||||
if (size == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
readline_input()
|
||||
{
|
||||
const int MAX = 1024;
|
||||
char *buf = (char *)malloc(MAX+1);
|
||||
int size;
|
||||
|
||||
size = read (masterfd, buf, MAX);
|
||||
if (size == -1)
|
||||
{
|
||||
free( buf );
|
||||
buf = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf[size] = 0;
|
||||
|
||||
/* Display output from readline */
|
||||
if ( size > 0 )
|
||||
fprintf(stderr, "%s", buf);
|
||||
|
||||
free( buf );
|
||||
buf = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
rlctx_send_user_command(char *line)
|
||||
{
|
||||
/* This happens when rl_callback_read_char gets EOF */
|
||||
if ( line == NULL )
|
||||
return;
|
||||
|
||||
if (strcmp (line, "exit") == 0) {
|
||||
tty_reset (STDIN_FILENO);
|
||||
close (masterfd);
|
||||
close (slavefd);
|
||||
printf ("\n");
|
||||
exit (0);
|
||||
}
|
||||
|
||||
/* Don't add the enter command */
|
||||
if ( line && *line != '\0' )
|
||||
add_history(line);
|
||||
}
|
||||
|
||||
static void
|
||||
custom_deprep_term_function ()
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
init_readline (int inputfd, int outputfd)
|
||||
{
|
||||
FILE *inputFILE, *outputFILE;
|
||||
|
||||
inputFILE = fdopen (inputfd, "r");
|
||||
if (!inputFILE)
|
||||
return -1;
|
||||
|
||||
outputFILE = fdopen (outputfd, "w");
|
||||
if (!outputFILE)
|
||||
return -1;
|
||||
|
||||
rl_instream = inputFILE;
|
||||
rl_outstream = outputFILE;
|
||||
|
||||
/* Tell readline what the prompt is if it needs to put it back */
|
||||
rl_callback_handler_install("(rltest): ", rlctx_send_user_command);
|
||||
|
||||
/* Set the terminal type to dumb so the output of readline can be
|
||||
* understood by tgdb */
|
||||
if ( rl_reset_terminal("dumb") == -1 )
|
||||
return -1;
|
||||
|
||||
/* For some reason, readline can not deprep the terminal.
|
||||
* However, it doesn't matter because no other application is working on
|
||||
* the terminal besides readline */
|
||||
rl_deprep_term_function = custom_deprep_term_function;
|
||||
|
||||
using_history();
|
||||
read_history(".history");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
main_loop(void)
|
||||
{
|
||||
fd_set rset;
|
||||
int max;
|
||||
|
||||
max = (masterfd > STDIN_FILENO) ? masterfd : STDIN_FILENO;
|
||||
max = (max > slavefd) ? max : slavefd;
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Reset the fd_set, and watch for input from GDB or stdin */
|
||||
FD_ZERO(&rset);
|
||||
|
||||
FD_SET(STDIN_FILENO, &rset);
|
||||
FD_SET(slavefd, &rset);
|
||||
FD_SET(masterfd, &rset);
|
||||
|
||||
/* Wait for input */
|
||||
if (select(max + 1, &rset, NULL, NULL, NULL) == -1)
|
||||
{
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Input received through the pty: Handle it
|
||||
* Wrote to masterfd, slave fd has that input, alert readline to read it.
|
||||
*/
|
||||
if (FD_ISSET(slavefd, &rset))
|
||||
rl_callback_read_char();
|
||||
|
||||
/* Input received through the pty.
|
||||
* Readline read from slavefd, and it wrote to the masterfd.
|
||||
*/
|
||||
if (FD_ISSET(masterfd, &rset))
|
||||
if ( readline_input() == -1 )
|
||||
return -1;
|
||||
|
||||
/* Input received: Handle it, write to masterfd (input to readline) */
|
||||
if (FD_ISSET(STDIN_FILENO, &rset))
|
||||
if ( user_input() == -1 )
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The terminal attributes before calling tty_cbreak */
|
||||
static struct termios save_termios;
|
||||
static struct winsize size;
|
||||
static enum { RESET, TCBREAK } ttystate = RESET;
|
||||
|
||||
/* tty_cbreak: Sets terminal to cbreak mode. Also known as noncanonical mode.
|
||||
* 1. Signal handling is still turned on, so the user can still type those.
|
||||
* 2. echo is off
|
||||
* 3. Read in one char at a time.
|
||||
*
|
||||
* fd - The file descriptor of the terminal
|
||||
*
|
||||
* Returns: 0 on sucess, -1 on error
|
||||
*/
|
||||
int tty_cbreak(int fd){
|
||||
struct termios buf;
|
||||
int ttysavefd = -1;
|
||||
|
||||
if(tcgetattr(fd, &save_termios) < 0)
|
||||
return -1;
|
||||
|
||||
buf = save_termios;
|
||||
buf.c_lflag &= ~(ECHO | ICANON);
|
||||
buf.c_iflag &= ~(ICRNL | INLCR);
|
||||
buf.c_cc[VMIN] = 1;
|
||||
buf.c_cc[VTIME] = 0;
|
||||
|
||||
#if defined (VLNEXT) && defined (_POSIX_VDISABLE)
|
||||
buf.c_cc[VLNEXT] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
|
||||
#if defined (VDSUSP) && defined (_POSIX_VDISABLE)
|
||||
buf.c_cc[VDSUSP] = _POSIX_VDISABLE;
|
||||
#endif
|
||||
|
||||
/* enable flow control; only stty start char can restart output */
|
||||
#if 0
|
||||
buf.c_iflag |= (IXON|IXOFF);
|
||||
#ifdef IXANY
|
||||
buf.c_iflag &= ~IXANY;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* disable flow control; let ^S and ^Q through to pty */
|
||||
buf.c_iflag &= ~(IXON|IXOFF);
|
||||
#ifdef IXANY
|
||||
buf.c_iflag &= ~IXANY;
|
||||
#endif
|
||||
|
||||
if(tcsetattr(fd, TCSAFLUSH, &buf) < 0)
|
||||
return -1;
|
||||
|
||||
ttystate = TCBREAK;
|
||||
ttysavefd = fd;
|
||||
|
||||
/* set size */
|
||||
if(ioctl(fd, TIOCGWINSZ, (char *)&size) < 0)
|
||||
return -1;
|
||||
|
||||
#ifdef DEBUG
|
||||
err_msg("%d rows and %d cols\n", size.ws_row, size.ws_col);
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
tty_off_xon_xoff (int fd)
|
||||
{
|
||||
struct termios buf;
|
||||
int ttysavefd = -1;
|
||||
|
||||
if(tcgetattr(fd, &buf) < 0)
|
||||
return -1;
|
||||
|
||||
buf.c_iflag &= ~(IXON|IXOFF);
|
||||
|
||||
if(tcsetattr(fd, TCSAFLUSH, &buf) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* tty_reset: Sets the terminal attributes back to their previous state.
|
||||
* PRE: tty_cbreak must have already been called.
|
||||
*
|
||||
* fd - The file descrioptor of the terminal to reset.
|
||||
*
|
||||
* Returns: 0 on success, -1 on error
|
||||
*/
|
||||
int tty_reset(int fd)
|
||||
{
|
||||
if(ttystate != TCBREAK)
|
||||
return (0);
|
||||
|
||||
if(tcsetattr(fd, TCSAFLUSH, &save_termios) < 0)
|
||||
return (-1);
|
||||
|
||||
ttystate = RESET;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main()
|
||||
{
|
||||
int val;
|
||||
val = openpty (&masterfd, &slavefd, NULL, NULL, NULL);
|
||||
if (val == -1)
|
||||
return -1;
|
||||
|
||||
val = tty_off_xon_xoff (masterfd);
|
||||
if (val == -1)
|
||||
return -1;
|
||||
|
||||
val = init_readline (slavefd, slavefd);
|
||||
if (val == -1)
|
||||
return -1;
|
||||
|
||||
val = tty_cbreak (STDIN_FILENO);
|
||||
if (val == -1)
|
||||
return -1;
|
||||
|
||||
signal (SIGINT, sigint);
|
||||
|
||||
val = main_loop ();
|
||||
|
||||
tty_reset (STDIN_FILENO);
|
||||
|
||||
if (val == -1)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -31,6 +31,12 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
extern void exit();
|
||||
#endif
|
||||
|
||||
#ifdef READLINE_LIBRARY
|
||||
# include "readline.h"
|
||||
# include "history.h"
|
||||
|
|
|
@ -30,6 +30,12 @@
|
|||
#include <sys/types.h>
|
||||
#include "posixstat.h"
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
extern void exit();
|
||||
#endif
|
||||
|
||||
#ifdef READLINE_LIBRARY
|
||||
# include "readline.h"
|
||||
#else
|
||||
|
|
|
@ -131,6 +131,7 @@ static FUNMAP default_funmap[] = {
|
|||
{ "tty-status", rl_tty_status },
|
||||
{ "undo", rl_undo_command },
|
||||
{ "universal-argument", rl_universal_argument },
|
||||
{ "unix-filename-rubout", rl_unix_filename_rubout },
|
||||
{ "unix-line-discard", rl_unix_line_discard },
|
||||
{ "unix-word-rubout", rl_unix_word_rubout },
|
||||
{ "upcase-word", rl_upcase_word },
|
||||
|
@ -175,6 +176,7 @@ static FUNMAP default_funmap[] = {
|
|||
{ "vi-put", rl_vi_put },
|
||||
{ "vi-redo", rl_vi_redo },
|
||||
{ "vi-replace", rl_vi_replace },
|
||||
{ "vi-rubout", rl_vi_rubout },
|
||||
{ "vi-search", rl_vi_search },
|
||||
{ "vi-search-again", rl_vi_search_again },
|
||||
{ "vi-set-mark", rl_vi_set_mark },
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* histexpand.c -- history expansion. */
|
||||
|
||||
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2004 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
@ -52,6 +52,8 @@
|
|||
#define HISTORY_WORD_DELIMITERS " \t\n;&()|<>"
|
||||
#define HISTORY_QUOTE_CHARACTERS "\"'`"
|
||||
|
||||
#define slashify_in_quotes "\\`\"$"
|
||||
|
||||
typedef int _hist_search_func_t PARAMS((const char *, int));
|
||||
|
||||
extern int rl_byte_oriented; /* declared in mbutil.c */
|
||||
|
@ -65,6 +67,8 @@ static int subst_rhs_len;
|
|||
|
||||
static char *get_history_word_specifier PARAMS((char *, char *, int *));
|
||||
static char *history_find_word PARAMS((char *, int));
|
||||
static int history_tokenize_word PARAMS((const char *, int));
|
||||
static char *history_substring PARAMS((const char *, int, int));
|
||||
|
||||
static char *quote_breaks PARAMS((char *));
|
||||
|
||||
|
@ -202,23 +206,24 @@ 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 defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
int v;
|
||||
mbstate_t ps;
|
||||
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 ((char *)string, i, &ps);
|
||||
if ((v = _rl_get_char_len ((char *)string + i, &ps)) > 1)
|
||||
{
|
||||
i += v - 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
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)) ||
|
||||
|
@ -226,6 +231,7 @@ get_history_event (string, caller_index, delimiting_quote)
|
|||
string[i] == '\n' ||
|
||||
(substring_okay && string[i] == '?'))
|
||||
break;
|
||||
}
|
||||
|
||||
which = i - local_index;
|
||||
temp = (char *)xmalloc (1 + which);
|
||||
|
@ -517,7 +523,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
|
|||
char *current_line; /* for !# */
|
||||
{
|
||||
int i, n, starting_index;
|
||||
int substitute_globally, want_quotes, print_only;
|
||||
int substitute_globally, subst_bywords, want_quotes, print_only;
|
||||
char *event, *temp, *result, *tstr, *t, c, *word_spec;
|
||||
int result_len;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
|
@ -599,19 +605,25 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
|
|||
FREE (word_spec);
|
||||
|
||||
/* Perhaps there are other modifiers involved. Do what they say. */
|
||||
want_quotes = substitute_globally = print_only = 0;
|
||||
want_quotes = substitute_globally = subst_bywords = print_only = 0;
|
||||
starting_index = i;
|
||||
|
||||
while (string[i] == ':')
|
||||
{
|
||||
c = string[i + 1];
|
||||
|
||||
if (c == 'g')
|
||||
if (c == 'g' || c == 'a')
|
||||
{
|
||||
substitute_globally = 1;
|
||||
i++;
|
||||
c = string[i + 1];
|
||||
}
|
||||
else if (c == 'G')
|
||||
{
|
||||
subst_bywords = 1;
|
||||
i++;
|
||||
c = string[i + 1];
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
|
@ -683,7 +695,7 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
|
|||
case 's':
|
||||
{
|
||||
char *new_event;
|
||||
int delimiter, failed, si, l_temp;
|
||||
int delimiter, failed, si, l_temp, ws, we;
|
||||
|
||||
if (c == 's')
|
||||
{
|
||||
|
@ -760,33 +772,67 @@ history_expand_internal (string, start, end_index_ptr, ret_string, current_line)
|
|||
}
|
||||
|
||||
/* Find the first occurrence of THIS in TEMP. */
|
||||
si = 0;
|
||||
/* Substitute SUBST_RHS for SUBST_LHS in TEMP. There are three
|
||||
cases to consider:
|
||||
|
||||
1. substitute_globally == subst_bywords == 0
|
||||
2. substitute_globally == 1 && subst_bywords == 0
|
||||
3. substitute_globally == 0 && subst_bywords == 1
|
||||
|
||||
In the first case, we substitute for the first occurrence only.
|
||||
In the second case, we substitute for every occurrence.
|
||||
In the third case, we tokenize into words and substitute the
|
||||
first occurrence of each word. */
|
||||
|
||||
si = we = 0;
|
||||
for (failed = 1; (si + subst_lhs_len) <= l_temp; si++)
|
||||
if (STREQN (temp+si, subst_lhs, subst_lhs_len))
|
||||
{
|
||||
int len = subst_rhs_len - subst_lhs_len + l_temp;
|
||||
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,
|
||||
temp + si + subst_lhs_len,
|
||||
l_temp - (si + subst_lhs_len));
|
||||
new_event[len] = '\0';
|
||||
free (temp);
|
||||
temp = new_event;
|
||||
{
|
||||
/* First skip whitespace and find word boundaries if
|
||||
we're past the end of the word boundary we found
|
||||
the last time. */
|
||||
if (subst_bywords && si > we)
|
||||
{
|
||||
for (; temp[si] && whitespace (temp[si]); si++)
|
||||
;
|
||||
ws = si;
|
||||
we = history_tokenize_word (temp, si);
|
||||
}
|
||||
|
||||
failed = 0;
|
||||
if (STREQN (temp+si, subst_lhs, subst_lhs_len))
|
||||
{
|
||||
int len = subst_rhs_len - subst_lhs_len + l_temp;
|
||||
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,
|
||||
temp + si + subst_lhs_len,
|
||||
l_temp - (si + subst_lhs_len));
|
||||
new_event[len] = '\0';
|
||||
free (temp);
|
||||
temp = new_event;
|
||||
|
||||
if (substitute_globally)
|
||||
{
|
||||
si += subst_rhs_len;
|
||||
l_temp = strlen (temp);
|
||||
substitute_globally++;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
failed = 0;
|
||||
|
||||
if (substitute_globally)
|
||||
{
|
||||
/* Reported to fix a bug that causes it to skip every
|
||||
other match when matching a single character. Was
|
||||
si += subst_rhs_len previously. */
|
||||
si += subst_rhs_len - 1;
|
||||
l_temp = strlen (temp);
|
||||
substitute_globally++;
|
||||
continue;
|
||||
}
|
||||
else if (subst_bywords)
|
||||
{
|
||||
si = we;
|
||||
l_temp = strlen (temp);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (substitute_globally > 1)
|
||||
{
|
||||
|
@ -879,7 +925,7 @@ history_expand (hstring, output)
|
|||
char **output;
|
||||
{
|
||||
register int j;
|
||||
int i, r, l, passc, cc, modified, eindex, only_printing;
|
||||
int i, r, l, passc, cc, modified, eindex, only_printing, dquote;
|
||||
char *string;
|
||||
|
||||
/* The output string, and its length. */
|
||||
|
@ -942,7 +988,7 @@ history_expand (hstring, output)
|
|||
|
||||
/* `!' followed by one of the characters in history_no_expand_chars
|
||||
is NOT an expansion. */
|
||||
for (i = 0; string[i]; i++)
|
||||
for (i = dquote = 0; string[i]; i++)
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
|
@ -984,9 +1030,19 @@ history_expand (hstring, output)
|
|||
else
|
||||
break;
|
||||
}
|
||||
/* XXX - at some point, might want to extend this to handle
|
||||
double quotes as well. */
|
||||
else if (history_quotes_inhibit_expansion && string[i] == '\'')
|
||||
/* Shell-like quoting: allow backslashes to quote double quotes
|
||||
inside a double-quoted string. */
|
||||
else if (dquote && string[i] == '\\' && cc == '"')
|
||||
i++;
|
||||
/* More shell-like quoting: if we're paying attention to single
|
||||
quotes and letting them quote the history expansion character,
|
||||
then we need to pay attention to double quotes, because single
|
||||
quotes are not special inside double-quoted strings. */
|
||||
else if (history_quotes_inhibit_expansion && string[i] == '"')
|
||||
{
|
||||
dquote = 1 - dquote;
|
||||
}
|
||||
else if (dquote == 0 && history_quotes_inhibit_expansion && string[i] == '\'')
|
||||
{
|
||||
/* If this is bash, single quotes inhibit history expansion. */
|
||||
i++;
|
||||
|
@ -999,6 +1055,7 @@ history_expand (hstring, output)
|
|||
if (cc == '\'' || cc == history_expansion_char)
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (string[i] != history_expansion_char)
|
||||
|
@ -1010,7 +1067,7 @@ history_expand (hstring, output)
|
|||
}
|
||||
|
||||
/* Extract and perform the substitution. */
|
||||
for (passc = i = j = 0; i < l; i++)
|
||||
for (passc = dquote = i = j = 0; i < l; i++)
|
||||
{
|
||||
int tchar = string[i];
|
||||
|
||||
|
@ -1061,11 +1118,16 @@ history_expand (hstring, output)
|
|||
ADD_CHAR (tchar);
|
||||
break;
|
||||
|
||||
case '"':
|
||||
dquote = 1 - dquote;
|
||||
ADD_CHAR (tchar);
|
||||
break;
|
||||
|
||||
case '\'':
|
||||
{
|
||||
/* If history_quotes_inhibit_expansion is set, single quotes
|
||||
inhibit history expansion. */
|
||||
if (history_quotes_inhibit_expansion)
|
||||
if (dquote == 0 && history_quotes_inhibit_expansion)
|
||||
{
|
||||
int quote, slen;
|
||||
|
||||
|
@ -1160,7 +1222,9 @@ history_expand (hstring, output)
|
|||
|
||||
if (only_printing)
|
||||
{
|
||||
#if 0
|
||||
add_history (result);
|
||||
#endif
|
||||
return (2);
|
||||
}
|
||||
|
||||
|
@ -1223,7 +1287,10 @@ get_history_word_specifier (spec, from, caller_index)
|
|||
if (spec[i] == '-')
|
||||
first = 0;
|
||||
else if (spec[i] == '^')
|
||||
first = 1;
|
||||
{
|
||||
first = 1;
|
||||
i++;
|
||||
}
|
||||
else if (_rl_digit_p (spec[i]) && expecting_word_spec)
|
||||
{
|
||||
for (first = 0; _rl_digit_p (spec[i]); i++)
|
||||
|
@ -1338,7 +1405,103 @@ history_arg_extract (first, last, string)
|
|||
return (result);
|
||||
}
|
||||
|
||||
#define slashify_in_quotes "\\`\"$"
|
||||
static int
|
||||
history_tokenize_word (string, ind)
|
||||
const char *string;
|
||||
int ind;
|
||||
{
|
||||
register int i;
|
||||
int delimiter;
|
||||
|
||||
i = ind;
|
||||
delimiter = 0;
|
||||
|
||||
if (member (string[i], "()\n"))
|
||||
{
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
|
||||
if (member (string[i], "<>;&|$"))
|
||||
{
|
||||
int peek = string[i + 1];
|
||||
|
||||
if (peek == string[i] && peek != '$')
|
||||
{
|
||||
if (peek == '<' && string[i + 2] == '-')
|
||||
i++;
|
||||
i += 2;
|
||||
return i;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((peek == '&' && (string[i] == '>' || string[i] == '<')) ||
|
||||
(peek == '>' && string[i] == '&') ||
|
||||
(peek == '(' && (string[i] == '>' || string[i] == '<')) || /* ) */
|
||||
(peek == '(' && string[i] == '$')) /* ) */
|
||||
{
|
||||
i += 2;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
if (string[i] != '$')
|
||||
{
|
||||
i++;
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get word from string + i; */
|
||||
|
||||
if (member (string[i], HISTORY_QUOTE_CHARACTERS))
|
||||
delimiter = string[i++];
|
||||
|
||||
for (; string[i]; i++)
|
||||
{
|
||||
if (string[i] == '\\' && string[i + 1] == '\n')
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string[i] == '\\' && delimiter != '\'' &&
|
||||
(delimiter != '"' || member (string[i], slashify_in_quotes)))
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (delimiter && string[i] == delimiter)
|
||||
{
|
||||
delimiter = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!delimiter && (member (string[i], history_word_delimiters)))
|
||||
break;
|
||||
|
||||
if (!delimiter && member (string[i], HISTORY_QUOTE_CHARACTERS))
|
||||
delimiter = string[i];
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static char *
|
||||
history_substring (string, start, end)
|
||||
const char *string;
|
||||
int start, end;
|
||||
{
|
||||
register int len;
|
||||
register char *result;
|
||||
|
||||
len = end - start;
|
||||
result = (char *)xmalloc (len + 1);
|
||||
strncpy (result, string + start, len);
|
||||
result[len] = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
/* Parse STRING into tokens and return an array of strings. If WIND is
|
||||
not -1 and INDP is not null, we also want the word surrounding index
|
||||
|
@ -1351,7 +1514,6 @@ history_tokenize_internal (string, 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. */
|
||||
|
@ -1362,8 +1524,6 @@ history_tokenize_internal (string, wind, indp)
|
|||
exactly where the shell would split them. */
|
||||
for (i = result_index = size = 0, result = (char **)NULL; string[i]; )
|
||||
{
|
||||
delimiter = 0;
|
||||
|
||||
/* Skip leading whitespace. */
|
||||
for (; string[i] && whitespace (string[i]); i++)
|
||||
;
|
||||
|
@ -1371,88 +1531,30 @@ history_tokenize_internal (string, wind, indp)
|
|||
return (result);
|
||||
|
||||
start = i;
|
||||
|
||||
if (member (string[i], "()\n"))
|
||||
|
||||
i = history_tokenize_word (string, start);
|
||||
|
||||
/* If we have a non-whitespace delimiter character (which would not be
|
||||
skipped by the loop above), use it and any adjacent delimiters to
|
||||
make a separate field. Any adjacent white space will be skipped the
|
||||
next time through the loop. */
|
||||
if (i == start && history_word_delimiters)
|
||||
{
|
||||
i++;
|
||||
goto got_token;
|
||||
while (string[i] && member (string[i], history_word_delimiters))
|
||||
i++;
|
||||
}
|
||||
|
||||
if (member (string[i], "<>;&|$"))
|
||||
{
|
||||
int peek = string[i + 1];
|
||||
|
||||
if (peek == string[i] && peek != '$')
|
||||
{
|
||||
if (peek == '<' && string[i + 2] == '-')
|
||||
i++;
|
||||
i += 2;
|
||||
goto got_token;
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((peek == '&' && (string[i] == '>' || string[i] == '<')) ||
|
||||
((peek == '>') && (string[i] == '&')) ||
|
||||
((peek == '(') && (string[i] == '$')))
|
||||
{
|
||||
i += 2;
|
||||
goto got_token;
|
||||
}
|
||||
}
|
||||
if (string[i] != '$')
|
||||
{
|
||||
i++;
|
||||
goto got_token;
|
||||
}
|
||||
}
|
||||
|
||||
/* Get word from string + i; */
|
||||
|
||||
if (member (string[i], HISTORY_QUOTE_CHARACTERS))
|
||||
delimiter = string[i++];
|
||||
|
||||
for (; string[i]; i++)
|
||||
{
|
||||
if (string[i] == '\\' && string[i + 1] == '\n')
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (string[i] == '\\' && delimiter != '\'' &&
|
||||
(delimiter != '"' || member (string[i], slashify_in_quotes)))
|
||||
{
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (delimiter && string[i] == delimiter)
|
||||
{
|
||||
delimiter = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!delimiter && (member (string[i], history_word_delimiters)))
|
||||
break;
|
||||
|
||||
if (!delimiter && member (string[i], HISTORY_QUOTE_CHARACTERS))
|
||||
delimiter = string[i];
|
||||
}
|
||||
|
||||
got_token:
|
||||
|
||||
/* If we are looking for the word in which the character at a
|
||||
particular index falls, remember it. */
|
||||
if (indp && wind != -1 && wind >= start && wind < i)
|
||||
*indp = result_index;
|
||||
|
||||
len = i - start;
|
||||
if (result_index + 2 >= size)
|
||||
result = (char **)xrealloc (result, ((size += 10) * sizeof (char *)));
|
||||
result[result_index] = (char *)xmalloc (1 + len);
|
||||
strncpy (result[result_index], string + start, len);
|
||||
result[result_index][len] = '\0';
|
||||
result[++result_index] = (char *)NULL;
|
||||
|
||||
result[result_index++] = history_substring (string, start, i);
|
||||
result[result_index] = (char *)NULL;
|
||||
}
|
||||
|
||||
return (result);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* histfile.c - functions to manipulate the history file. */
|
||||
|
||||
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2003 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
@ -23,8 +23,13 @@
|
|||
/* The goal is to make the implementation transparent, so that you
|
||||
don't have to know what data types are used, just what functions
|
||||
you can call. I think I have done that. */
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (__TANDEM)
|
||||
# include <floss.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
@ -32,7 +37,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#ifndef _MINIX
|
||||
#if ! defined (_MINIX) && defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
#include "posixstat.h"
|
||||
|
@ -52,7 +57,7 @@
|
|||
# undef HAVE_MMAP
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
#ifdef HISTORY_USE_MMAP
|
||||
# include <sys/mman.h>
|
||||
|
||||
# ifdef MAP_FILE
|
||||
|
@ -67,7 +72,7 @@
|
|||
# define MAP_FAILED ((void *)-1)
|
||||
# endif
|
||||
|
||||
#endif /* HAVE_MMAP */
|
||||
#endif /* HISTORY_USE_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
|
||||
|
@ -93,6 +98,13 @@ extern int errno;
|
|||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* If non-zero, we write timestamps to the history file in history_do_write() */
|
||||
int history_write_timestamps = 0;
|
||||
|
||||
/* Does S look like the beginning of a history timestamp entry? Placeholder
|
||||
for more extensive tests. */
|
||||
#define HIST_TIMESTAMP_START(s) (*(s) == history_comment_char)
|
||||
|
||||
/* Return the string that should be used in the place of this
|
||||
filename. This only matters when you don't specify the
|
||||
filename to read_history (), or write_history (). */
|
||||
|
@ -151,13 +163,20 @@ read_history_range (filename, from, to)
|
|||
const char *filename;
|
||||
int from, to;
|
||||
{
|
||||
register char *line_start, *line_end;
|
||||
char *input, *buffer, *bufend;
|
||||
register char *line_start, *line_end, *p;
|
||||
char *input, *buffer, *bufend, *last_ts;
|
||||
int file, current_line, chars_read;
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
#if defined (EFBIG)
|
||||
int overflow_errno = EFBIG;
|
||||
#elif defined (EOVERFLOW)
|
||||
int overflow_errno = EOVERFLOW;
|
||||
#else
|
||||
int overflow_errno = EIO;
|
||||
#endif
|
||||
|
||||
buffer = (char *)NULL;
|
||||
buffer = last_ts = (char *)NULL;
|
||||
input = history_filename (filename);
|
||||
file = open (input, O_RDONLY|O_BINARY, 0666);
|
||||
|
||||
|
@ -169,37 +188,42 @@ read_history_range (filename, from, to)
|
|||
/* check for overflow on very large files */
|
||||
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
||||
{
|
||||
#if defined (EFBIG)
|
||||
errno = EFBIG;
|
||||
#elif defined (EOVERFLOW)
|
||||
errno = EOVERFLOW;
|
||||
#endif
|
||||
errno = overflow_errno;
|
||||
goto error_and_exit;
|
||||
}
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
#ifdef HISTORY_USE_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;
|
||||
{
|
||||
errno = overflow_errno;
|
||||
goto error_and_exit;
|
||||
}
|
||||
chars_read = file_size;
|
||||
#else
|
||||
buffer = (char *)malloc (file_size + 1);
|
||||
if (buffer == 0)
|
||||
goto error_and_exit;
|
||||
{
|
||||
errno = overflow_errno;
|
||||
goto error_and_exit;
|
||||
}
|
||||
|
||||
chars_read = read (file, buffer, file_size);
|
||||
#endif
|
||||
if (chars_read < 0)
|
||||
{
|
||||
error_and_exit:
|
||||
chars_read = errno;
|
||||
if (errno != 0)
|
||||
chars_read = errno;
|
||||
else
|
||||
chars_read = EIO;
|
||||
if (file >= 0)
|
||||
close (file);
|
||||
|
||||
FREE (input);
|
||||
#ifndef HAVE_MMAP
|
||||
#ifndef HISTORY_USE_MMAP
|
||||
FREE (buffer);
|
||||
#endif
|
||||
|
||||
|
@ -220,8 +244,12 @@ read_history_range (filename, from, to)
|
|||
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;
|
||||
p = line_end + 1;
|
||||
/* If we see something we think is a timestamp, continue with this
|
||||
line. We should check more extensively here... */
|
||||
if (HIST_TIMESTAMP_START(p) == 0)
|
||||
current_line++;
|
||||
line_start = p;
|
||||
}
|
||||
|
||||
/* If there are lines left to gobble, then gobble them now. */
|
||||
|
@ -231,7 +259,22 @@ read_history_range (filename, from, to)
|
|||
*line_end = '\0';
|
||||
|
||||
if (*line_start)
|
||||
add_history (line_start);
|
||||
{
|
||||
if (HIST_TIMESTAMP_START(line_start) == 0)
|
||||
{
|
||||
add_history (line_start);
|
||||
if (last_ts)
|
||||
{
|
||||
add_history_time (last_ts);
|
||||
last_ts = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
last_ts = line_start;
|
||||
current_line--;
|
||||
}
|
||||
}
|
||||
|
||||
current_line++;
|
||||
|
||||
|
@ -242,7 +285,7 @@ read_history_range (filename, from, to)
|
|||
}
|
||||
|
||||
FREE (input);
|
||||
#ifndef HAVE_MMAP
|
||||
#ifndef HISTORY_USE_MMAP
|
||||
FREE (buffer);
|
||||
#else
|
||||
munmap (buffer, file_size);
|
||||
|
@ -259,7 +302,7 @@ history_truncate_file (fname, lines)
|
|||
const char *fname;
|
||||
int lines;
|
||||
{
|
||||
char *buffer, *filename, *bp;
|
||||
char *buffer, *filename, *bp, *bp1; /* bp1 == bp+1 */
|
||||
int file, chars_read, rv;
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
|
@ -322,11 +365,14 @@ history_truncate_file (fname, lines)
|
|||
}
|
||||
|
||||
/* Count backwards from the end of buffer until we have passed
|
||||
LINES lines. */
|
||||
for (bp = buffer + chars_read - 1; lines && bp > buffer; bp--)
|
||||
LINES lines. bp1 is set funny initially. But since bp[1] can't
|
||||
be a comment character (since it's off the end) and *bp can't be
|
||||
both a newline and the history comment character, it should be OK. */
|
||||
for (bp1 = bp = buffer + chars_read - 1; lines && bp > buffer; bp--)
|
||||
{
|
||||
if (*bp == '\n')
|
||||
if (*bp == '\n' && HIST_TIMESTAMP_START(bp1) == 0)
|
||||
lines--;
|
||||
bp1 = bp;
|
||||
}
|
||||
|
||||
/* If this is the first line, then the file contains exactly the
|
||||
|
@ -335,11 +381,14 @@ history_truncate_file (fname, lines)
|
|||
the current value of i and 0. Otherwise, write from the start of
|
||||
this line until the end of the buffer. */
|
||||
for ( ; bp > buffer; bp--)
|
||||
if (*bp == '\n')
|
||||
{
|
||||
bp++;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (*bp == '\n' && HIST_TIMESTAMP_START(bp1) == 0)
|
||||
{
|
||||
bp++;
|
||||
break;
|
||||
}
|
||||
bp1 = bp;
|
||||
}
|
||||
|
||||
/* Write only if there are more lines in the file than we want to
|
||||
truncate to. */
|
||||
|
@ -374,9 +423,9 @@ history_do_write (filename, nelements, overwrite)
|
|||
register int i;
|
||||
char *output;
|
||||
int file, mode, rv;
|
||||
#ifdef HISTORY_USE_MMAP
|
||||
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;
|
||||
|
@ -390,7 +439,7 @@ history_do_write (filename, nelements, overwrite)
|
|||
return (errno);
|
||||
}
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
#ifdef HISTORY_USE_MMAP
|
||||
cursize = overwrite ? 0 : lseek (file, 0, SEEK_END);
|
||||
#endif
|
||||
|
||||
|
@ -408,10 +457,18 @@ history_do_write (filename, nelements, overwrite)
|
|||
the_history = history_list ();
|
||||
/* Calculate the total number of bytes to write. */
|
||||
for (buffer_size = 0, i = history_length - nelements; i < history_length; i++)
|
||||
buffer_size += 1 + strlen (the_history[i]->line);
|
||||
#if 0
|
||||
buffer_size += 2 + HISTENT_BYTES (the_history[i]);
|
||||
#else
|
||||
{
|
||||
if (history_write_timestamps && the_history[i]->timestamp && the_history[i]->timestamp[0])
|
||||
buffer_size += strlen (the_history[i]->timestamp) + 1;
|
||||
buffer_size += strlen (the_history[i]->line) + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Allocate the buffer, and fill it. */
|
||||
#ifdef HAVE_MMAP
|
||||
#ifdef HISTORY_USE_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);
|
||||
|
@ -436,12 +493,18 @@ mmap_error:
|
|||
|
||||
for (j = 0, i = history_length - nelements; i < history_length; i++)
|
||||
{
|
||||
if (history_write_timestamps && the_history[i]->timestamp && the_history[i]->timestamp[0])
|
||||
{
|
||||
strcpy (buffer + j, the_history[i]->timestamp);
|
||||
j += strlen (the_history[i]->timestamp);
|
||||
buffer[j++] = '\n';
|
||||
}
|
||||
strcpy (buffer + j, the_history[i]->line);
|
||||
j += strlen (the_history[i]->line);
|
||||
buffer[j++] = '\n';
|
||||
}
|
||||
|
||||
#ifdef HAVE_MMAP
|
||||
#ifdef HISTORY_USE_MMAP
|
||||
if (msync (buffer, buffer_size, 0) != 0 || munmap (buffer, buffer_size) != 0)
|
||||
rv = errno;
|
||||
#else
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* History.c -- standalone history library */
|
||||
/* history.c -- standalone history library */
|
||||
|
||||
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1989-2005 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
@ -52,6 +52,8 @@
|
|||
/* The number of slots to increase the_history by. */
|
||||
#define DEFAULT_HISTORY_GROW_SIZE 50
|
||||
|
||||
static char *hist_inittime PARAMS((void));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* History Functions */
|
||||
|
@ -123,14 +125,15 @@ using_history ()
|
|||
}
|
||||
|
||||
/* Return the number of bytes that the primary history entries are using.
|
||||
This just adds up the lengths of the_history->lines. */
|
||||
This just adds up the lengths of the_history->lines and the associated
|
||||
timestamps. */
|
||||
int
|
||||
history_total_bytes ()
|
||||
{
|
||||
register int i, result;
|
||||
|
||||
for (i = result = 0; the_history && the_history[i]; i++)
|
||||
result += strlen (the_history[i]->line);
|
||||
result += HISTENT_BYTES (the_history[i]);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
@ -201,11 +204,45 @@ history_get (offset)
|
|||
int local_index;
|
||||
|
||||
local_index = offset - history_base;
|
||||
return (local_index >= history_length || local_index < 0 || !the_history)
|
||||
return (local_index >= history_length || local_index < 0 || the_history == 0)
|
||||
? (HIST_ENTRY *)NULL
|
||||
: the_history[local_index];
|
||||
}
|
||||
|
||||
time_t
|
||||
history_get_time (hist)
|
||||
HIST_ENTRY *hist;
|
||||
{
|
||||
char *ts;
|
||||
time_t t;
|
||||
|
||||
if (hist == 0 || hist->timestamp == 0)
|
||||
return 0;
|
||||
ts = hist->timestamp;
|
||||
if (ts[0] != history_comment_char)
|
||||
return 0;
|
||||
t = (time_t) atol (ts + 1); /* XXX - should use strtol() here */
|
||||
return t;
|
||||
}
|
||||
|
||||
static char *
|
||||
hist_inittime ()
|
||||
{
|
||||
time_t t;
|
||||
char ts[64], *ret;
|
||||
|
||||
t = (time_t) time ((time_t *)0);
|
||||
#if defined (HAVE_VSNPRINTF) /* assume snprintf if vsnprintf exists */
|
||||
snprintf (ts, sizeof (ts) - 1, "X%lu", (unsigned long) t);
|
||||
#else
|
||||
sprintf (ts, "X%lu", (unsigned long) t);
|
||||
#endif
|
||||
ret = savestring (ts);
|
||||
ret[0] = history_comment_char;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Place STRING at the end of the history list. The data field
|
||||
is set to NULL. */
|
||||
void
|
||||
|
@ -225,10 +262,7 @@ add_history (string)
|
|||
|
||||
/* If there is something in the slot, then remove it. */
|
||||
if (the_history[0])
|
||||
{
|
||||
free (the_history[0]->line);
|
||||
free (the_history[0]);
|
||||
}
|
||||
(void) free_history_entry (the_history[0]);
|
||||
|
||||
/* Copy the rest of the entries, moving down one slot. */
|
||||
for (i = 0; i < history_length; i++)
|
||||
|
@ -260,10 +294,41 @@ add_history (string)
|
|||
temp->line = savestring (string);
|
||||
temp->data = (char *)NULL;
|
||||
|
||||
temp->timestamp = hist_inittime ();
|
||||
|
||||
the_history[history_length] = (HIST_ENTRY *)NULL;
|
||||
the_history[history_length - 1] = temp;
|
||||
}
|
||||
|
||||
/* Change the time stamp of the most recent history entry to STRING. */
|
||||
void
|
||||
add_history_time (string)
|
||||
const char *string;
|
||||
{
|
||||
HIST_ENTRY *hs;
|
||||
|
||||
hs = the_history[history_length - 1];
|
||||
FREE (hs->timestamp);
|
||||
hs->timestamp = savestring (string);
|
||||
}
|
||||
|
||||
/* Free HIST and return the data so the calling application can free it
|
||||
if necessary and desired. */
|
||||
histdata_t
|
||||
free_history_entry (hist)
|
||||
HIST_ENTRY *hist;
|
||||
{
|
||||
histdata_t x;
|
||||
|
||||
if (hist == 0)
|
||||
return ((histdata_t) 0);
|
||||
FREE (hist->line);
|
||||
FREE (hist->timestamp);
|
||||
x = hist->data;
|
||||
free (hist);
|
||||
return (x);
|
||||
}
|
||||
|
||||
/* 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. */
|
||||
|
@ -275,7 +340,7 @@ replace_history_entry (which, line, data)
|
|||
{
|
||||
HIST_ENTRY *temp, *old_value;
|
||||
|
||||
if (which >= history_length)
|
||||
if (which < 0 || which >= history_length)
|
||||
return ((HIST_ENTRY *)NULL);
|
||||
|
||||
temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
|
||||
|
@ -283,6 +348,7 @@ replace_history_entry (which, line, data)
|
|||
|
||||
temp->line = savestring (line);
|
||||
temp->data = data;
|
||||
temp->timestamp = savestring (old_value->timestamp);
|
||||
the_history[which] = temp;
|
||||
|
||||
return (old_value);
|
||||
|
@ -298,17 +364,15 @@ remove_history (which)
|
|||
HIST_ENTRY *return_value;
|
||||
register int i;
|
||||
|
||||
if (which >= history_length || !history_length)
|
||||
return_value = (HIST_ENTRY *)NULL;
|
||||
else
|
||||
{
|
||||
return_value = the_history[which];
|
||||
if (which < 0 || which >= history_length || history_length == 0 || the_history == 0)
|
||||
return ((HIST_ENTRY *)NULL);
|
||||
|
||||
for (i = which; i < history_length; i++)
|
||||
the_history[i] = the_history[i + 1];
|
||||
return_value = the_history[which];
|
||||
|
||||
history_length--;
|
||||
}
|
||||
for (i = which; i < history_length; i++)
|
||||
the_history[i] = the_history[i + 1];
|
||||
|
||||
history_length--;
|
||||
|
||||
return (return_value);
|
||||
}
|
||||
|
@ -327,10 +391,7 @@ stifle_history (max)
|
|||
{
|
||||
/* This loses because we cannot free the data. */
|
||||
for (i = 0, j = history_length - max; i < j; i++)
|
||||
{
|
||||
free (the_history[i]->line);
|
||||
free (the_history[i]);
|
||||
}
|
||||
free_history_entry (the_history[i]);
|
||||
|
||||
history_base = i;
|
||||
for (j = 0, i = history_length - max; j < max; i++, j++)
|
||||
|
@ -372,8 +433,7 @@ clear_history ()
|
|||
/* This loses because we cannot free the data. */
|
||||
for (i = 0; i < history_length; i++)
|
||||
{
|
||||
free (the_history[i]->line);
|
||||
free (the_history[i]);
|
||||
free_history_entry (the_history[i]);
|
||||
the_history[i] = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* History.h -- the names of functions that you can call in history. */
|
||||
/* Copyright (C) 1989, 1992 Free Software Foundation, Inc.
|
||||
/* history.h -- the names of functions that you can call in history. */
|
||||
/* Copyright (C) 1989-2003 Free Software Foundation, Inc.
|
||||
|
||||
This file contains the GNU History Library (the Library), a set of
|
||||
routines for managing the text of previously typed lines.
|
||||
|
@ -26,6 +26,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <time.h> /* XXX - for history timestamp code */
|
||||
|
||||
#if defined READLINE_LIBRARY
|
||||
# include "rlstdc.h"
|
||||
# include "rltypedefs.h"
|
||||
|
@ -43,9 +45,13 @@ typedef char *histdata_t;
|
|||
/* The structure used to store a history entry. */
|
||||
typedef struct _hist_entry {
|
||||
char *line;
|
||||
char *timestamp; /* char * rather than time_t for read/write */
|
||||
histdata_t data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
/* Size of the history-library-managed space in history entry HS. */
|
||||
#define HISTENT_BYTES(hs) (strlen ((hs)->line) + strlen ((hs)->timestamp))
|
||||
|
||||
/* A structure used to pass the current state of the history stuff around. */
|
||||
typedef struct _hist_state {
|
||||
HIST_ENTRY **entries; /* Pointer to the entries themselves. */
|
||||
|
@ -76,11 +82,19 @@ extern void history_set_history_state PARAMS((HISTORY_STATE *));
|
|||
The associated data field (if any) is set to NULL. */
|
||||
extern void add_history PARAMS((const char *));
|
||||
|
||||
/* Change the timestamp associated with the most recent history entry to
|
||||
STRING. */
|
||||
extern void add_history_time 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 PARAMS((int));
|
||||
|
||||
/* Free the history entry H and return any application-specific data
|
||||
associated with it. */
|
||||
extern histdata_t free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
||||
/* 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. */
|
||||
|
@ -119,6 +133,10 @@ extern HIST_ENTRY *current_history PARAMS((void));
|
|||
array. OFFSET is relative to history_base. */
|
||||
extern HIST_ENTRY *history_get PARAMS((int));
|
||||
|
||||
/* Return the timestamp associated with the HIST_ENTRY * passed as an
|
||||
argument */
|
||||
extern time_t history_get_time PARAMS((HIST_ENTRY *));
|
||||
|
||||
/* 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 PARAMS((void));
|
||||
|
@ -231,6 +249,8 @@ extern char *history_no_expand_chars;
|
|||
extern char *history_search_delimiter_chars;
|
||||
extern int history_quotes_inhibit_expansion;
|
||||
|
||||
extern int history_write_timestamps;
|
||||
|
||||
/* Backwards compatibility */
|
||||
extern int max_input_history;
|
||||
|
||||
|
|
|
@ -77,11 +77,11 @@ history_search_internal (string, direction, anchored)
|
|||
if (string == 0 || *string == '\0')
|
||||
return (-1);
|
||||
|
||||
if (!history_length || ((i == history_length) && !reverse))
|
||||
if (!history_length || ((i >= history_length) && !reverse))
|
||||
return (-1);
|
||||
|
||||
if (reverse && (i == history_length))
|
||||
i--;
|
||||
if (reverse && (i >= history_length))
|
||||
i = history_length - 1;
|
||||
|
||||
#define NEXT_LINE() do { if (reverse) i--; else i++; } while (0)
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* input.c -- character input functions for readline. */
|
||||
|
||||
/* Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1994-2005 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.
|
||||
|
@ -21,6 +21,10 @@
|
|||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (__TANDEM)
|
||||
# include <floss.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
@ -154,6 +158,12 @@ _rl_unget_char (key)
|
|||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
_rl_pushed_input_available ()
|
||||
{
|
||||
return (push_index != pop_index);
|
||||
}
|
||||
|
||||
/* 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). */
|
||||
|
@ -162,7 +172,7 @@ rl_gather_tyi ()
|
|||
{
|
||||
int tty;
|
||||
register int tem, result;
|
||||
int chars_avail;
|
||||
int chars_avail, k;
|
||||
char input;
|
||||
#if defined(HAVE_SELECT)
|
||||
fd_set readfds, exceptfds;
|
||||
|
@ -202,6 +212,11 @@ rl_gather_tyi ()
|
|||
fcntl (tty, F_SETFL, tem);
|
||||
if (chars_avail == -1 && errno == EAGAIN)
|
||||
return 0;
|
||||
if (chars_avail == 0) /* EOF */
|
||||
{
|
||||
rl_stuff_char (EOF);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
#endif /* O_NDELAY */
|
||||
|
||||
|
@ -225,7 +240,12 @@ rl_gather_tyi ()
|
|||
if (result != -1)
|
||||
{
|
||||
while (chars_avail--)
|
||||
rl_stuff_char ((*rl_getc_function) (rl_instream));
|
||||
{
|
||||
k = (*rl_getc_function) (rl_instream);
|
||||
rl_stuff_char (k);
|
||||
if (k == NEWLINE || k == RETURN)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -424,6 +444,10 @@ rl_getc (stream)
|
|||
|
||||
while (1)
|
||||
{
|
||||
#if defined (__MINGW32__)
|
||||
if (isatty (fileno (stream)))
|
||||
return (getch ());
|
||||
#endif
|
||||
result = read (fileno (stream), &c, sizeof (unsigned char));
|
||||
|
||||
if (result == sizeof (unsigned char))
|
||||
|
@ -499,6 +523,12 @@ _rl_read_mbchar (mbchar, size)
|
|||
ps = ps_back;
|
||||
continue;
|
||||
}
|
||||
else if (mbchar_bytes_length == 0)
|
||||
{
|
||||
mbchar[0] = '\0'; /* null wide character */
|
||||
mb_len = 1;
|
||||
break;
|
||||
}
|
||||
else if (mbchar_bytes_length > (size_t)(0))
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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
|
||||
|
@ -56,12 +56,17 @@
|
|||
/* Variables exported to other files in the readline library. */
|
||||
char *_rl_isearch_terminators = (char *)NULL;
|
||||
|
||||
_rl_search_cxt *_rl_iscxt = 0;
|
||||
|
||||
/* Variables imported from other files in the readline library. */
|
||||
extern HIST_ENTRY *_rl_saved_line_for_history;
|
||||
|
||||
/* Forward declarations */
|
||||
static int rl_search_history PARAMS((int, int));
|
||||
|
||||
static _rl_search_cxt *_rl_isearch_init PARAMS((int));
|
||||
static void _rl_isearch_fini PARAMS((_rl_search_cxt *));
|
||||
static int _rl_isearch_cleanup PARAMS((_rl_search_cxt *, 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;
|
||||
|
@ -72,6 +77,57 @@ static int last_isearch_string_len;
|
|||
|
||||
static char *default_isearch_terminators = "\033\012";
|
||||
|
||||
_rl_search_cxt *
|
||||
_rl_scxt_alloc (type, flags)
|
||||
int type, flags;
|
||||
{
|
||||
_rl_search_cxt *cxt;
|
||||
|
||||
cxt = (_rl_search_cxt *)xmalloc (sizeof (_rl_search_cxt));
|
||||
|
||||
cxt->type = type;
|
||||
cxt->sflags = flags;
|
||||
|
||||
cxt->search_string = 0;
|
||||
cxt->search_string_size = cxt->search_string_index = 0;
|
||||
|
||||
cxt->lines = 0;
|
||||
cxt->allocated_line = 0;
|
||||
cxt->hlen = cxt->hindex = 0;
|
||||
|
||||
cxt->save_point = rl_point;
|
||||
cxt->save_mark = rl_mark;
|
||||
cxt->save_line = where_history ();
|
||||
cxt->last_found_line = cxt->save_line;
|
||||
cxt->prev_line_found = 0;
|
||||
|
||||
cxt->save_undo_list = 0;
|
||||
|
||||
cxt->history_pos = 0;
|
||||
cxt->direction = 0;
|
||||
|
||||
cxt->lastc = 0;
|
||||
|
||||
cxt->sline = 0;
|
||||
cxt->sline_len = cxt->sline_index = 0;
|
||||
|
||||
cxt->search_terminators = 0;
|
||||
|
||||
return cxt;
|
||||
}
|
||||
|
||||
void
|
||||
_rl_scxt_dispose (cxt, flags)
|
||||
_rl_search_cxt *cxt;
|
||||
int flags;
|
||||
{
|
||||
FREE (cxt->search_string);
|
||||
FREE (cxt->allocated_line);
|
||||
FREE (cxt->lines);
|
||||
|
||||
free (cxt);
|
||||
}
|
||||
|
||||
/* Search backwards through the history looking for a string which is typed
|
||||
interactively. Start with the current line. */
|
||||
int
|
||||
|
@ -92,7 +148,7 @@ rl_forward_search_history (sign, key)
|
|||
|
||||
/* Display the current state of the search in the echo-area.
|
||||
SEARCH_STRING contains the string that is being searched for,
|
||||
DIRECTION is zero for forward, or 1 for reverse,
|
||||
DIRECTION is zero for forward, or non-zero for reverse,
|
||||
WHERE is the history list number of the current line. If it is
|
||||
-1, then this line is the starting one. */
|
||||
static void
|
||||
|
@ -140,6 +196,418 @@ rl_display_search (search_string, reverse_p, where)
|
|||
(*rl_redisplay_function) ();
|
||||
}
|
||||
|
||||
static _rl_search_cxt *
|
||||
_rl_isearch_init (direction)
|
||||
int direction;
|
||||
{
|
||||
_rl_search_cxt *cxt;
|
||||
register int i;
|
||||
HIST_ENTRY **hlist;
|
||||
|
||||
cxt = _rl_scxt_alloc (RL_SEARCH_ISEARCH, 0);
|
||||
if (direction < 0)
|
||||
cxt->sflags |= SF_REVERSE;
|
||||
|
||||
cxt->search_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
|
||||
: default_isearch_terminators;
|
||||
|
||||
/* Create an arrary of pointers to the lines that we want to search. */
|
||||
hlist = history_list ();
|
||||
rl_maybe_replace_line ();
|
||||
i = 0;
|
||||
if (hlist)
|
||||
for (i = 0; hlist[i]; i++);
|
||||
|
||||
/* Allocate space for this many lines, +1 for the current input line,
|
||||
and remember those lines. */
|
||||
cxt->lines = (char **)xmalloc ((1 + (cxt->hlen = i)) * sizeof (char *));
|
||||
for (i = 0; i < cxt->hlen; i++)
|
||||
cxt->lines[i] = hlist[i]->line;
|
||||
|
||||
if (_rl_saved_line_for_history)
|
||||
cxt->lines[i] = _rl_saved_line_for_history->line;
|
||||
else
|
||||
{
|
||||
/* Keep track of this so we can free it. */
|
||||
cxt->allocated_line = (char *)xmalloc (1 + strlen (rl_line_buffer));
|
||||
strcpy (cxt->allocated_line, &rl_line_buffer[0]);
|
||||
cxt->lines[i] = cxt->allocated_line;
|
||||
}
|
||||
|
||||
cxt->hlen++;
|
||||
|
||||
/* The line where we start the search. */
|
||||
cxt->history_pos = cxt->save_line;
|
||||
|
||||
rl_save_prompt ();
|
||||
|
||||
/* Initialize search parameters. */
|
||||
cxt->search_string = (char *)xmalloc (cxt->search_string_size = 128);
|
||||
cxt->search_string[cxt->search_string_index = 0] = '\0';
|
||||
|
||||
/* Normalize DIRECTION into 1 or -1. */
|
||||
cxt->direction = (direction >= 0) ? 1 : -1;
|
||||
|
||||
cxt->sline = rl_line_buffer;
|
||||
cxt->sline_len = strlen (cxt->sline);
|
||||
cxt->sline_index = rl_point;
|
||||
|
||||
_rl_iscxt = cxt; /* save globally */
|
||||
|
||||
return cxt;
|
||||
}
|
||||
|
||||
static void
|
||||
_rl_isearch_fini (cxt)
|
||||
_rl_search_cxt *cxt;
|
||||
{
|
||||
/* First put back the original state. */
|
||||
strcpy (rl_line_buffer, cxt->lines[cxt->save_line]);
|
||||
|
||||
rl_restore_prompt ();
|
||||
|
||||
/* Save the search string for possible later use. */
|
||||
FREE (last_isearch_string);
|
||||
last_isearch_string = cxt->search_string;
|
||||
last_isearch_string_len = cxt->search_string_index;
|
||||
cxt->search_string = 0;
|
||||
|
||||
if (cxt->last_found_line < cxt->save_line)
|
||||
rl_get_previous_history (cxt->save_line - cxt->last_found_line, 0);
|
||||
else
|
||||
rl_get_next_history (cxt->last_found_line - cxt->save_line, 0);
|
||||
|
||||
/* 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 (cxt->sline_index < 0)
|
||||
{
|
||||
if (cxt->last_found_line == cxt->save_line)
|
||||
cxt->sline_index = cxt->save_point;
|
||||
else
|
||||
cxt->sline_index = strlen (rl_line_buffer);
|
||||
rl_mark = cxt->save_mark;
|
||||
}
|
||||
|
||||
rl_point = cxt->sline_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 ();
|
||||
}
|
||||
|
||||
int
|
||||
_rl_search_getchar (cxt)
|
||||
_rl_search_cxt *cxt;
|
||||
{
|
||||
int c;
|
||||
|
||||
/* Read a key and decide how to proceed. */
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
c = cxt->lastc = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
c = cxt->lastc = _rl_read_mbstring (cxt->lastc, cxt->mb, MB_LEN_MAX);
|
||||
#endif
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Process just-read character C according to isearch context CXT. Return
|
||||
-1 if the caller should just free the context and return, 0 if we should
|
||||
break out of the loop, and 1 if we should continue to read characters. */
|
||||
int
|
||||
_rl_isearch_dispatch (cxt, c)
|
||||
_rl_search_cxt *cxt;
|
||||
int c;
|
||||
{
|
||||
int n, wstart, wlen, limit, cval;
|
||||
rl_command_func_t *f;
|
||||
|
||||
f = (rl_command_func_t *)NULL;
|
||||
|
||||
/* Translate the keys we do something with to opcodes. */
|
||||
if (c >= 0 && _rl_keymap[c].type == ISFUNC)
|
||||
{
|
||||
f = _rl_keymap[c].function;
|
||||
|
||||
if (f == rl_reverse_search_history)
|
||||
cxt->lastc = (cxt->sflags & SF_REVERSE) ? -1 : -2;
|
||||
else if (f == rl_forward_search_history)
|
||||
cxt->lastc = (cxt->sflags & SF_REVERSE) ? -2 : -1;
|
||||
else if (f == rl_rubout)
|
||||
cxt->lastc = -3;
|
||||
else if (c == CTRL ('G'))
|
||||
cxt->lastc = -4;
|
||||
else if (c == CTRL ('W')) /* XXX */
|
||||
cxt->lastc = -5;
|
||||
else if (c == CTRL ('Y')) /* XXX */
|
||||
cxt->lastc = -6;
|
||||
}
|
||||
|
||||
/* 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 (cxt->search_terminators, cxt->lastc))
|
||||
{
|
||||
/* 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.
|
||||
XXX - since _rl_input_available depends on the application-
|
||||
settable keyboard timeout value, this could alternatively
|
||||
use _rl_input_queued(100000) */
|
||||
if (cxt->lastc == ESC && _rl_input_available ())
|
||||
rl_execute_next (ESC);
|
||||
return (0);
|
||||
}
|
||||
|
||||
#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 (cxt->lastc >= 0 && (cxt->mb[0] && cxt->mb[1] == '\0') && ENDSRCH_CHAR (cxt->lastc))
|
||||
{
|
||||
/* This sets rl_pending_input to c; it will be picked up the next
|
||||
time rl_read_key is called. */
|
||||
rl_execute_next (cxt->lastc);
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if (cxt->lastc >= 0 && ENDSRCH_CHAR (cxt->lastc))
|
||||
{
|
||||
/* This sets rl_pending_input to LASTC; it will be picked up the next
|
||||
time rl_read_key is called. */
|
||||
rl_execute_next (cxt->lastc);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Now dispatch on the character. `Opcodes' affect the search string or
|
||||
state. Other characters are added to the string. */
|
||||
switch (cxt->lastc)
|
||||
{
|
||||
/* search again */
|
||||
case -1:
|
||||
if (cxt->search_string_index == 0)
|
||||
{
|
||||
if (last_isearch_string)
|
||||
{
|
||||
cxt->search_string_size = 64 + last_isearch_string_len;
|
||||
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
|
||||
strcpy (cxt->search_string, last_isearch_string);
|
||||
cxt->search_string_index = last_isearch_string_len;
|
||||
rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), -1);
|
||||
break;
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
else if (cxt->sflags & SF_REVERSE)
|
||||
cxt->sline_index--;
|
||||
else if (cxt->sline_index != cxt->sline_len)
|
||||
cxt->sline_index++;
|
||||
else
|
||||
rl_ding ();
|
||||
break;
|
||||
|
||||
/* switch directions */
|
||||
case -2:
|
||||
cxt->direction = -cxt->direction;
|
||||
if (cxt->direction < 0)
|
||||
cxt->sflags |= SF_REVERSE;
|
||||
else
|
||||
cxt->sflags &= ~SF_REVERSE;
|
||||
break;
|
||||
|
||||
/* 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 (cxt->search_string_index == 0)
|
||||
rl_ding ();
|
||||
else
|
||||
cxt->search_string[--cxt->search_string_index] = '\0';
|
||||
break;
|
||||
|
||||
case -4: /* C-G, abort */
|
||||
rl_replace_line (cxt->lines[cxt->save_line], 0);
|
||||
rl_point = cxt->save_point;
|
||||
rl_mark = cxt->save_mark;
|
||||
rl_restore_prompt();
|
||||
rl_clear_message ();
|
||||
|
||||
return -1;
|
||||
|
||||
case -5: /* C-W */
|
||||
/* skip over portion of line we already matched and yank word */
|
||||
wstart = rl_point + cxt->search_string_index;
|
||||
if (wstart >= rl_end)
|
||||
{
|
||||
rl_ding ();
|
||||
break;
|
||||
}
|
||||
|
||||
/* if not in a word, move to one. */
|
||||
cval = _rl_char_value (rl_line_buffer, wstart);
|
||||
if (_rl_walphabetic (cval) == 0)
|
||||
{
|
||||
rl_ding ();
|
||||
break;
|
||||
}
|
||||
n = MB_NEXTCHAR (rl_line_buffer, wstart, 1, MB_FIND_NONZERO);;
|
||||
while (n < rl_end)
|
||||
{
|
||||
cval = _rl_char_value (rl_line_buffer, n);
|
||||
if (_rl_walphabetic (cval) == 0)
|
||||
break;
|
||||
n = MB_NEXTCHAR (rl_line_buffer, n, 1, MB_FIND_NONZERO);;
|
||||
}
|
||||
wlen = n - wstart + 1;
|
||||
if (cxt->search_string_index + wlen + 1 >= cxt->search_string_size)
|
||||
{
|
||||
cxt->search_string_size += wlen + 1;
|
||||
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
|
||||
}
|
||||
for (; wstart < n; wstart++)
|
||||
cxt->search_string[cxt->search_string_index++] = rl_line_buffer[wstart];
|
||||
cxt->search_string[cxt->search_string_index] = '\0';
|
||||
break;
|
||||
|
||||
case -6: /* C-Y */
|
||||
/* skip over portion of line we already matched and yank rest */
|
||||
wstart = rl_point + cxt->search_string_index;
|
||||
if (wstart >= rl_end)
|
||||
{
|
||||
rl_ding ();
|
||||
break;
|
||||
}
|
||||
n = rl_end - wstart + 1;
|
||||
if (cxt->search_string_index + n + 1 >= cxt->search_string_size)
|
||||
{
|
||||
cxt->search_string_size += n + 1;
|
||||
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
|
||||
}
|
||||
for (n = wstart; n < rl_end; n++)
|
||||
cxt->search_string[cxt->search_string_index++] = rl_line_buffer[n];
|
||||
cxt->search_string[cxt->search_string_index] = '\0';
|
||||
break;
|
||||
|
||||
/* Add character to search string and continue search. */
|
||||
default:
|
||||
if (cxt->search_string_index + 2 >= cxt->search_string_size)
|
||||
{
|
||||
cxt->search_string_size += 128;
|
||||
cxt->search_string = (char *)xrealloc (cxt->search_string, cxt->search_string_size);
|
||||
}
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
{
|
||||
int j, l;
|
||||
for (j = 0, l = strlen (cxt->mb); j < l; )
|
||||
cxt->search_string[cxt->search_string_index++] = cxt->mb[j++];
|
||||
}
|
||||
else
|
||||
#endif
|
||||
cxt->search_string[cxt->search_string_index++] = c;
|
||||
cxt->search_string[cxt->search_string_index] = '\0';
|
||||
break;
|
||||
}
|
||||
|
||||
for (cxt->sflags &= ~(SF_FOUND|SF_FAILED);; )
|
||||
{
|
||||
limit = cxt->sline_len - cxt->search_string_index + 1;
|
||||
|
||||
/* Search the current line. */
|
||||
while ((cxt->sflags & SF_REVERSE) ? (cxt->sline_index >= 0) : (cxt->sline_index < limit))
|
||||
{
|
||||
if (STREQN (cxt->search_string, cxt->sline + cxt->sline_index, cxt->search_string_index))
|
||||
{
|
||||
cxt->sflags |= SF_FOUND;
|
||||
break;
|
||||
}
|
||||
else
|
||||
cxt->sline_index += cxt->direction;
|
||||
}
|
||||
if (cxt->sflags & SF_FOUND)
|
||||
break;
|
||||
|
||||
/* Move to the next line, but skip new copies of the line
|
||||
we just found and lines shorter than the string we're
|
||||
searching for. */
|
||||
do
|
||||
{
|
||||
/* Move to the next line. */
|
||||
cxt->history_pos += cxt->direction;
|
||||
|
||||
/* At limit for direction? */
|
||||
if ((cxt->sflags & SF_REVERSE) ? (cxt->history_pos < 0) : (cxt->history_pos == cxt->hlen))
|
||||
{
|
||||
cxt->sflags |= SF_FAILED;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We will need these later. */
|
||||
cxt->sline = cxt->lines[cxt->history_pos];
|
||||
cxt->sline_len = strlen (cxt->sline);
|
||||
}
|
||||
while ((cxt->prev_line_found && STREQ (cxt->prev_line_found, cxt->lines[cxt->history_pos])) ||
|
||||
(cxt->search_string_index > cxt->sline_len));
|
||||
|
||||
if (cxt->sflags & SF_FAILED)
|
||||
break;
|
||||
|
||||
/* Now set up the line for searching... */
|
||||
cxt->sline_index = (cxt->sflags & SF_REVERSE) ? cxt->sline_len - cxt->search_string_index : 0;
|
||||
}
|
||||
|
||||
if (cxt->sflags & SF_FAILED)
|
||||
{
|
||||
/* We cannot find the search string. Ding the bell. */
|
||||
rl_ding ();
|
||||
cxt->history_pos = cxt->last_found_line;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* We have found the search string. Just display it. But don't
|
||||
actually move there in the history list until the user accepts
|
||||
the location. */
|
||||
if (cxt->sflags & SF_FOUND)
|
||||
{
|
||||
cxt->prev_line_found = cxt->lines[cxt->history_pos];
|
||||
rl_replace_line (cxt->lines[cxt->history_pos], 0);
|
||||
rl_point = cxt->sline_index;
|
||||
cxt->last_found_line = cxt->history_pos;
|
||||
rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), (cxt->history_pos == cxt->save_line) ? -1 : cxt->history_pos);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_rl_isearch_cleanup (cxt, r)
|
||||
_rl_search_cxt *cxt;
|
||||
int r;
|
||||
{
|
||||
if (r >= 0)
|
||||
_rl_isearch_fini (cxt);
|
||||
_rl_scxt_dispose (cxt, 0);
|
||||
_rl_iscxt = 0;
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_ISEARCH);
|
||||
|
||||
return (r != 0);
|
||||
}
|
||||
|
||||
/* Search through the history looking for an interactively typed string.
|
||||
This is analogous to i-search. We start the search in the current line.
|
||||
DIRECTION is which direction to search; >= 0 means forward, < 0 means
|
||||
|
@ -148,413 +616,51 @@ static int
|
|||
rl_search_history (direction, invoking_key)
|
||||
int direction, invoking_key;
|
||||
{
|
||||
/* The string that the user types in to search for. */
|
||||
char *search_string;
|
||||
|
||||
/* The current length of SEARCH_STRING. */
|
||||
int search_string_index;
|
||||
|
||||
/* The amount of space that SEARCH_STRING has allocated to it. */
|
||||
int search_string_size;
|
||||
|
||||
/* The list of lines to search through. */
|
||||
char **lines, *allocated_line;
|
||||
|
||||
/* The length of LINES. */
|
||||
int hlen;
|
||||
|
||||
/* Where we get LINES from. */
|
||||
HIST_ENTRY **hlist;
|
||||
|
||||
register int i;
|
||||
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;
|
||||
|
||||
/* Offset in that line. */
|
||||
int line_index;
|
||||
|
||||
/* Non-zero if we are doing a reverse search. */
|
||||
int reverse;
|
||||
|
||||
/* The list of characters which terminate the search, but are not
|
||||
subsequently executed. If the variable isearch-terminators has
|
||||
been set, we use that value, otherwise we use ESC and C-J. */
|
||||
char *isearch_terminators;
|
||||
_rl_search_cxt *cxt; /* local for now, but saved globally */
|
||||
int c, r;
|
||||
|
||||
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;
|
||||
cxt = _rl_isearch_init (direction);
|
||||
|
||||
isearch_terminators = _rl_isearch_terminators ? _rl_isearch_terminators
|
||||
: default_isearch_terminators;
|
||||
rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), -1);
|
||||
|
||||
/* Create an arrary of pointers to the lines that we want to search. */
|
||||
rl_maybe_replace_line ();
|
||||
i = 0;
|
||||
if (hlist)
|
||||
for (i = 0; hlist[i]; i++);
|
||||
/* If we are using the callback interface, all we do is set up here and
|
||||
return. The key is that we leave RL_STATE_ISEARCH set. */
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
return (0);
|
||||
|
||||
/* Allocate space for this many lines, +1 for the current input line,
|
||||
and remember those lines. */
|
||||
lines = (char **)xmalloc ((1 + (hlen = i)) * sizeof (char *));
|
||||
for (i = 0; i < hlen; i++)
|
||||
lines[i] = hlist[i]->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 = (char *)xmalloc (1 + strlen (rl_line_buffer));
|
||||
strcpy (allocated_line, &rl_line_buffer[0]);
|
||||
lines[i] = allocated_line;
|
||||
}
|
||||
|
||||
hlen++;
|
||||
|
||||
/* The line where we start the search. */
|
||||
i = orig_line;
|
||||
|
||||
rl_save_prompt ();
|
||||
|
||||
/* Initialize search parameters. */
|
||||
search_string = (char *)xmalloc (search_string_size = 128);
|
||||
*search_string = '\0';
|
||||
search_string_index = 0;
|
||||
prev_line_found = (char *)0; /* XXX */
|
||||
|
||||
/* Normalize DIRECTION into 1 or -1. */
|
||||
direction = (direction >= 0) ? 1 : -1;
|
||||
|
||||
rl_display_search (search_string, reverse, -1);
|
||||
|
||||
sline = rl_line_buffer;
|
||||
sline_len = strlen (sline);
|
||||
line_index = rl_point;
|
||||
|
||||
found = failed = 0;
|
||||
r = -1;
|
||||
for (;;)
|
||||
{
|
||||
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 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;
|
||||
|
||||
if (f == rl_reverse_search_history)
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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))
|
||||
{
|
||||
/* 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.
|
||||
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;
|
||||
}
|
||||
|
||||
#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;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case -1:
|
||||
if (search_string_index == 0)
|
||||
{
|
||||
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
|
||||
rl_ding ();
|
||||
break;
|
||||
|
||||
/* switch directions */
|
||||
case -2:
|
||||
direction = -direction;
|
||||
reverse = direction < 0;
|
||||
break;
|
||||
|
||||
/* 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_mark = orig_mark;
|
||||
rl_restore_prompt();
|
||||
rl_clear_message ();
|
||||
if (allocated_line)
|
||||
free (allocated_line);
|
||||
free (lines);
|
||||
RL_UNSETSTATE(RL_STATE_ISEARCH);
|
||||
return 0;
|
||||
|
||||
case -5: /* C-W */
|
||||
/* skip over portion of line we already matched */
|
||||
wstart = rl_point + search_string_index;
|
||||
if (wstart >= rl_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;
|
||||
|
||||
default:
|
||||
/* Add character to search string and continue search. */
|
||||
if (search_string_index + 2 >= search_string_size)
|
||||
{
|
||||
search_string_size += 128;
|
||||
search_string = (char *)xrealloc (search_string, search_string_size);
|
||||
}
|
||||
#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;
|
||||
}
|
||||
|
||||
for (found = failed = 0;;)
|
||||
{
|
||||
int limit = sline_len - search_string_index + 1;
|
||||
|
||||
/* Search the current line. */
|
||||
while (reverse ? (line_index >= 0) : (line_index < limit))
|
||||
{
|
||||
if (STREQN (search_string, sline + line_index, search_string_index))
|
||||
{
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
else
|
||||
line_index += direction;
|
||||
}
|
||||
if (found)
|
||||
break;
|
||||
|
||||
/* Move to the next line, but skip new copies of the line
|
||||
we just found and lines shorter than the string we're
|
||||
searching for. */
|
||||
do
|
||||
{
|
||||
/* Move to the next line. */
|
||||
i += direction;
|
||||
|
||||
/* At limit for direction? */
|
||||
if (reverse ? (i < 0) : (i == hlen))
|
||||
{
|
||||
failed++;
|
||||
break;
|
||||
}
|
||||
|
||||
/* We will need these later. */
|
||||
sline = lines[i];
|
||||
sline_len = strlen (sline);
|
||||
}
|
||||
while ((prev_line_found && STREQ (prev_line_found, lines[i])) ||
|
||||
(search_string_index > sline_len));
|
||||
|
||||
if (failed)
|
||||
break;
|
||||
|
||||
/* Now set up the line for searching... */
|
||||
line_index = reverse ? sline_len - search_string_index : 0;
|
||||
}
|
||||
|
||||
if (failed)
|
||||
{
|
||||
/* We cannot find the search string. Ding the bell. */
|
||||
rl_ding ();
|
||||
i = last_found_line;
|
||||
continue; /* XXX - was break */
|
||||
}
|
||||
|
||||
/* We have found the search string. Just display it. But don't
|
||||
actually move there in the history list until the user accepts
|
||||
the location. */
|
||||
if (found)
|
||||
{
|
||||
prev_line_found = lines[i];
|
||||
rl_replace_line (lines[i], 0);
|
||||
rl_point = line_index;
|
||||
last_found_line = i;
|
||||
rl_display_search (search_string, reverse, (i == orig_line) ? -1 : i);
|
||||
}
|
||||
c = _rl_search_getchar (cxt);
|
||||
/* We might want to handle EOF here (c == 0) */
|
||||
r = _rl_isearch_dispatch (cxt, cxt->lastc);
|
||||
if (r <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
/* The searching is over. The user may have found the string that she
|
||||
was looking for, or else she may have exited a failing search. If
|
||||
LINE_INDEX is -1, then that shows that the string searched for was
|
||||
not found. We use this to determine where to place rl_point. */
|
||||
|
||||
/* First put back the original state. */
|
||||
strcpy (rl_line_buffer, lines[orig_line]);
|
||||
|
||||
rl_restore_prompt ();
|
||||
|
||||
/* 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 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)
|
||||
{
|
||||
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 ();
|
||||
|
||||
FREE (allocated_line);
|
||||
free (lines);
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_ISEARCH);
|
||||
|
||||
return 0;
|
||||
return (_rl_isearch_cleanup (cxt, r));
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
/* Called from the callback functions when we are ready to read a key. The
|
||||
callback functions know to call this because RL_ISSTATE(RL_STATE_ISEARCH).
|
||||
If _rl_isearch_dispatch finishes searching, this function is responsible
|
||||
for turning off RL_STATE_ISEARCH, which it does using _rl_isearch_cleanup. */
|
||||
int
|
||||
_rl_isearch_callback (cxt)
|
||||
_rl_search_cxt *cxt;
|
||||
{
|
||||
int c, r;
|
||||
|
||||
c = _rl_search_getchar (cxt);
|
||||
/* We might want to handle EOF here */
|
||||
r = _rl_isearch_dispatch (cxt, cxt->lastc);
|
||||
|
||||
return (r <= 0) ? _rl_isearch_cleanup (cxt, r) : 0;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -64,11 +64,13 @@ rl_make_bare_keymap ()
|
|||
keymap[i].function = (rl_command_func_t *)NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
for (i = 'A'; i < ('Z' + 1); i++)
|
||||
{
|
||||
keymap[i].type = ISFUNC;
|
||||
keymap[i].function = rl_do_lowercase_version;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (keymap);
|
||||
}
|
||||
|
@ -79,8 +81,9 @@ rl_copy_keymap (map)
|
|||
Keymap map;
|
||||
{
|
||||
register int i;
|
||||
Keymap temp = rl_make_bare_keymap ();
|
||||
Keymap temp;
|
||||
|
||||
temp = rl_make_bare_keymap ();
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
temp[i].type = map[i].type;
|
||||
|
@ -109,12 +112,8 @@ rl_make_keymap ()
|
|||
newmap[CTRL('H')].function = rl_rubout;
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Printing characters in some 8-bit character sets. */
|
||||
for (i = 128; i < 160; i++)
|
||||
newmap[i].function = rl_insert;
|
||||
|
||||
/* ISO Latin-1 printing characters should self-insert. */
|
||||
for (i = 160; i < 256; i++)
|
||||
/* Printing characters in ISO Latin-1 and some 8-bit character sets. */
|
||||
for (i = 128; i < 256; i++)
|
||||
newmap[i].function = rl_insert;
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
|
||||
|
|
|
@ -339,6 +339,47 @@ rl_unix_word_rubout (count, key)
|
|||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This deletes one filename component in a Unix pathname. That is, it
|
||||
deletes backward to directory separator (`/') or whitespace. */
|
||||
int
|
||||
rl_unix_filename_rubout (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int orig_point, c;
|
||||
|
||||
if (rl_point == 0)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
if (count <= 0)
|
||||
count = 1;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
c = rl_line_buffer[rl_point - 1];
|
||||
while (rl_point && (whitespace (c) || c == '/'))
|
||||
{
|
||||
rl_point--;
|
||||
c = rl_line_buffer[rl_point - 1];
|
||||
}
|
||||
|
||||
while (rl_point && (whitespace (c) == 0) && c != '/')
|
||||
{
|
||||
rl_point--;
|
||||
c = rl_line_buffer[rl_point - 1];
|
||||
}
|
||||
}
|
||||
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -100,6 +100,8 @@ _rl_with_macro_input (string)
|
|||
int
|
||||
_rl_next_macro_key ()
|
||||
{
|
||||
int c;
|
||||
|
||||
if (rl_executing_macro == 0)
|
||||
return (0);
|
||||
|
||||
|
@ -109,7 +111,14 @@ _rl_next_macro_key ()
|
|||
return (_rl_next_macro_key ());
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
c = rl_executing_macro[executing_macro_index++];
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK) && RL_ISSTATE (RL_STATE_READCMD) && rl_executing_macro[executing_macro_index] == 0)
|
||||
_rl_pop_executing_macro ();
|
||||
return c;
|
||||
#else
|
||||
return (rl_executing_macro[executing_macro_index++]);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Save the currently executing macro on a stack of saved macros. */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* mbutil.c -- readline multibyte character utility functions */
|
||||
|
||||
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2001-2005 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.
|
||||
|
@ -77,27 +77,29 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
|
|||
char *string;
|
||||
int seed, count, find_non_zero;
|
||||
{
|
||||
size_t tmp = 0;
|
||||
size_t tmp;
|
||||
mbstate_t ps;
|
||||
int point = 0;
|
||||
int point;
|
||||
wchar_t wc;
|
||||
|
||||
tmp = 0;
|
||||
|
||||
memset(&ps, 0, sizeof (mbstate_t));
|
||||
if (seed < 0)
|
||||
seed = 0;
|
||||
if (count <= 0)
|
||||
return seed;
|
||||
|
||||
point = seed + _rl_adjust_point(string, seed, &ps);
|
||||
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 --;
|
||||
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)
|
||||
if (MB_INVALIDCH ((size_t)tmp))
|
||||
{
|
||||
/* invalid bytes. asume a byte represents a character */
|
||||
point++;
|
||||
|
@ -105,9 +107,8 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
|
|||
/* reset states. */
|
||||
memset(&ps, 0, sizeof(mbstate_t));
|
||||
}
|
||||
else if (tmp == (size_t)0)
|
||||
/* found '\0' char */
|
||||
break;
|
||||
else if (MB_NULLWCH (tmp))
|
||||
break; /* found wide '\0' */
|
||||
else
|
||||
{
|
||||
/* valid bytes */
|
||||
|
@ -127,15 +128,16 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
|
|||
if (find_non_zero)
|
||||
{
|
||||
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
|
||||
while (wcwidth (wc) == 0)
|
||||
while (tmp > 0 && 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))
|
||||
if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp))
|
||||
break;
|
||||
}
|
||||
}
|
||||
return point;
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -160,7 +162,7 @@ _rl_find_prev_mbchar_internal (string, seed, find_non_zero)
|
|||
while (point < seed)
|
||||
{
|
||||
tmp = mbrtowc (&wc, string + point, length - point, &ps);
|
||||
if ((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
|
||||
if (MB_INVALIDCH ((size_t)tmp))
|
||||
{
|
||||
/* in this case, bytes are invalid or shorted to compose
|
||||
multibyte char, so assume that the first byte represents
|
||||
|
@ -169,8 +171,12 @@ _rl_find_prev_mbchar_internal (string, seed, find_non_zero)
|
|||
/* clear the state of the byte sequence, because
|
||||
in this case effect of mbstate is undefined */
|
||||
memset(&ps, 0, sizeof (mbstate_t));
|
||||
|
||||
/* Since we're assuming that this byte represents a single
|
||||
non-zero-width character, don't forget about it. */
|
||||
prev = point;
|
||||
}
|
||||
else if (tmp == 0)
|
||||
else if (MB_NULLWCH (tmp))
|
||||
break; /* Found '\0' char. Can this happen? */
|
||||
else
|
||||
{
|
||||
|
@ -205,14 +211,16 @@ _rl_get_char_len (src, ps)
|
|||
if (tmp == (size_t)(-2))
|
||||
{
|
||||
/* shorted to compose multibyte char */
|
||||
memset (ps, 0, sizeof(mbstate_t));
|
||||
if (ps)
|
||||
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));
|
||||
if (ps)
|
||||
memset (ps, 0, sizeof(mbstate_t));
|
||||
return -1;
|
||||
}
|
||||
else if (tmp == (size_t)0)
|
||||
|
@ -225,9 +233,12 @@ _rl_get_char_len (src, ps)
|
|||
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;
|
||||
char *buf1;
|
||||
int pos1;
|
||||
mbstate_t *ps1;
|
||||
char *buf2;
|
||||
int pos2;
|
||||
mbstate_t *ps2;
|
||||
{
|
||||
int i, w1, w2;
|
||||
|
||||
|
@ -268,7 +279,7 @@ _rl_adjust_point(string, point, ps)
|
|||
while (pos < point)
|
||||
{
|
||||
tmp = mbrlen (string + pos, length - pos, ps);
|
||||
if((size_t)(tmp) == (size_t)-1 || (size_t)(tmp) == (size_t)-2)
|
||||
if (MB_INVALIDCH ((size_t)tmp))
|
||||
{
|
||||
/* in this case, bytes are invalid or shorted to compose
|
||||
multibyte char, so assume that the first byte represents
|
||||
|
@ -276,8 +287,11 @@ _rl_adjust_point(string, point, ps)
|
|||
pos++;
|
||||
/* clear the state of the byte sequence, because
|
||||
in this case effect of mbstate is undefined */
|
||||
memset (ps, 0, sizeof (mbstate_t));
|
||||
if (ps)
|
||||
memset (ps, 0, sizeof (mbstate_t));
|
||||
}
|
||||
else if (MB_NULLWCH (tmp))
|
||||
pos++;
|
||||
else
|
||||
pos += tmp;
|
||||
}
|
||||
|
@ -302,6 +316,28 @@ _rl_is_mbchar_matched (string, seed, end, mbchar, length)
|
|||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
wchar_t
|
||||
_rl_char_value (buf, ind)
|
||||
char *buf;
|
||||
int ind;
|
||||
{
|
||||
size_t tmp;
|
||||
wchar_t wc;
|
||||
mbstate_t ps;
|
||||
int l;
|
||||
|
||||
if (MB_LEN_MAX == 1 || rl_byte_oriented)
|
||||
return ((wchar_t) buf[ind]);
|
||||
l = strlen (buf);
|
||||
if (ind >= l - 1)
|
||||
return ((wchar_t) buf[ind]);
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
tmp = mbrtowc (&wc, buf + ind, l - ind, &ps);
|
||||
if (MB_INVALIDCH (tmp) || MB_NULLWCH (tmp))
|
||||
return ((wchar_t) buf[ind]);
|
||||
return wc;
|
||||
}
|
||||
#endif /* HANDLE_MULTIBYTE */
|
||||
|
||||
/* Find next `count' characters started byte point of the specified seed.
|
||||
|
|
289
readline/misc.c
289
readline/misc.c
|
@ -1,6 +1,6 @@
|
|||
/* misc.c -- miscellaneous bindable readline functions. */
|
||||
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
|
@ -63,6 +63,8 @@ void _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
|||
to preserve the value of rl_point from line to line. */
|
||||
int _rl_history_preserve_point = 0;
|
||||
|
||||
_rl_arg_cxt _rl_argcxt;
|
||||
|
||||
/* 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;
|
||||
|
@ -73,77 +75,74 @@ int _rl_history_saved_point = -1;
|
|||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Handle C-u style numeric args, as well as M--, and M-digits. */
|
||||
static int
|
||||
rl_digit_loop ()
|
||||
int
|
||||
_rl_arg_overflow ()
|
||||
{
|
||||
int key, c, sawminus, sawdigits;
|
||||
|
||||
rl_save_prompt ();
|
||||
|
||||
RL_SETSTATE(RL_STATE_NUMERICARG);
|
||||
sawminus = sawdigits = 0;
|
||||
while (1)
|
||||
if (rl_numeric_arg > 1000000)
|
||||
{
|
||||
if (rl_numeric_arg > 1000000)
|
||||
_rl_argcxt = 0;
|
||||
rl_explicit_arg = rl_numeric_arg = 0;
|
||||
rl_ding ();
|
||||
rl_restore_prompt ();
|
||||
rl_clear_message ();
|
||||
RL_UNSETSTATE(RL_STATE_NUMERICARG);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
_rl_arg_init ()
|
||||
{
|
||||
rl_save_prompt ();
|
||||
_rl_argcxt = 0;
|
||||
RL_SETSTATE(RL_STATE_NUMERICARG);
|
||||
}
|
||||
|
||||
int
|
||||
_rl_arg_getchar ()
|
||||
{
|
||||
int c;
|
||||
|
||||
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Process C as part of the current numeric argument. Return -1 if the
|
||||
argument should be aborted, 0 if we should not read any more chars, and
|
||||
1 if we should continue to read chars. */
|
||||
int
|
||||
_rl_arg_dispatch (cxt, c)
|
||||
_rl_arg_cxt cxt;
|
||||
int c;
|
||||
{
|
||||
int key, r;
|
||||
|
||||
key = c;
|
||||
|
||||
/* 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 ((cxt & NUM_SAWDIGITS) == 0)
|
||||
{
|
||||
sawdigits = rl_explicit_arg = rl_numeric_arg = 0;
|
||||
rl_ding ();
|
||||
rl_restore_prompt ();
|
||||
rl_clear_message ();
|
||||
RL_UNSETSTATE(RL_STATE_NUMERICARG);
|
||||
rl_numeric_arg *= 4;
|
||||
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 if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
{
|
||||
_rl_argcxt |= NUM_READONE;
|
||||
return 0; /* XXX */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make M-- command equivalent to M--1 command. */
|
||||
if (sawminus && rl_numeric_arg == 1 && rl_explicit_arg == 0)
|
||||
rl_explicit_arg = 1;
|
||||
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);
|
||||
|
@ -151,35 +150,96 @@ rl_digit_loop ()
|
|||
}
|
||||
}
|
||||
|
||||
/*NOTREACHED*/
|
||||
c = UNMETA (c);
|
||||
|
||||
if (_rl_digit_p (c))
|
||||
{
|
||||
r = _rl_digit_value (c);
|
||||
rl_numeric_arg = rl_explicit_arg ? (rl_numeric_arg * 10) + r : r;
|
||||
rl_explicit_arg = 1;
|
||||
_rl_argcxt |= NUM_SAWDIGITS;
|
||||
}
|
||||
else if (c == '-' && rl_explicit_arg == 0)
|
||||
{
|
||||
rl_numeric_arg = 1;
|
||||
_rl_argcxt |= NUM_SAWMINUS;
|
||||
rl_arg_sign = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Make M-- command equivalent to M--1 command. */
|
||||
if ((_rl_argcxt & NUM_SAWMINUS) && rl_numeric_arg == 1 && rl_explicit_arg == 0)
|
||||
rl_explicit_arg = 1;
|
||||
rl_restore_prompt ();
|
||||
rl_clear_message ();
|
||||
RL_UNSETSTATE(RL_STATE_NUMERICARG);
|
||||
|
||||
r = _rl_dispatch (key, _rl_keymap);
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
{
|
||||
/* At worst, this will cause an extra redisplay. Otherwise,
|
||||
we have to wait until the next character comes in. */
|
||||
if (rl_done == 0)
|
||||
(*rl_redisplay_function) ();
|
||||
r = 0;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Add the current digit to the argument in progress. */
|
||||
/* Handle C-u style numeric args, as well as M--, and M-digits. */
|
||||
static int
|
||||
rl_digit_loop ()
|
||||
{
|
||||
int c, r;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if (_rl_arg_overflow ())
|
||||
return 1;
|
||||
|
||||
c = _rl_arg_getchar ();
|
||||
|
||||
if (c < 0)
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
r = _rl_arg_dispatch (_rl_argcxt, c);
|
||||
if (r <= 0 || (RL_ISSTATE (RL_STATE_NUMERICARG) == 0))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a default argument. */
|
||||
void
|
||||
_rl_reset_argument ()
|
||||
{
|
||||
rl_numeric_arg = rl_arg_sign = 1;
|
||||
rl_explicit_arg = 0;
|
||||
_rl_argcxt = 0;
|
||||
}
|
||||
|
||||
/* Start a numeric argument with initial value KEY */
|
||||
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;
|
||||
_rl_arg_init ();
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
{
|
||||
_rl_arg_dispatch (_rl_argcxt, key);
|
||||
rl_message ("(arg: %d) ", rl_arg_sign * rl_numeric_arg);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
rl_execute_next (key);
|
||||
return (rl_digit_loop ());
|
||||
}
|
||||
}
|
||||
|
||||
/* C-u, universal argument. Multiply the current argument by 4.
|
||||
|
@ -189,8 +249,43 @@ int
|
|||
rl_universal_argument (count, key)
|
||||
int count, key;
|
||||
{
|
||||
_rl_arg_init ();
|
||||
rl_numeric_arg *= 4;
|
||||
return (rl_digit_loop ());
|
||||
|
||||
return (RL_ISSTATE (RL_STATE_CALLBACK) ? 0 : rl_digit_loop ());
|
||||
}
|
||||
|
||||
int
|
||||
_rl_arg_callback (cxt)
|
||||
_rl_arg_cxt cxt;
|
||||
{
|
||||
int c, r;
|
||||
|
||||
c = _rl_arg_getchar ();
|
||||
|
||||
if (_rl_argcxt & NUM_READONE)
|
||||
{
|
||||
_rl_argcxt &= ~NUM_READONE;
|
||||
rl_restore_prompt ();
|
||||
rl_clear_message ();
|
||||
RL_UNSETSTATE(RL_STATE_NUMERICARG);
|
||||
rl_execute_next (c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = _rl_arg_dispatch (cxt, c);
|
||||
return (r != 1);
|
||||
}
|
||||
|
||||
/* What to do when you abort reading an argument. */
|
||||
int
|
||||
rl_discard_argument ()
|
||||
{
|
||||
rl_ding ();
|
||||
rl_clear_message ();
|
||||
_rl_reset_argument ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
@ -225,8 +320,10 @@ _rl_free_history_entry (entry)
|
|||
{
|
||||
if (entry == 0)
|
||||
return;
|
||||
if (entry->line)
|
||||
free (entry->line);
|
||||
|
||||
FREE (entry->line);
|
||||
FREE (entry->timestamp);
|
||||
|
||||
free (entry);
|
||||
}
|
||||
|
||||
|
@ -242,6 +339,7 @@ rl_maybe_replace_line ()
|
|||
{
|
||||
temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
|
||||
free (temp->line);
|
||||
FREE (temp->timestamp);
|
||||
free (temp);
|
||||
}
|
||||
return 0;
|
||||
|
@ -253,6 +351,8 @@ rl_maybe_unsave_line ()
|
|||
{
|
||||
if (_rl_saved_line_for_history)
|
||||
{
|
||||
/* Can't call with `1' because rl_undo_list might point to an undo
|
||||
list from a history entry, as in rl_replace_from_history() below. */
|
||||
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);
|
||||
|
@ -272,8 +372,10 @@ rl_maybe_save_line ()
|
|||
{
|
||||
_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->timestamp = (char *)NULL;
|
||||
_rl_saved_line_for_history->data = (char *)rl_undo_list;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -298,7 +400,7 @@ _rl_history_set_point ()
|
|||
rl_point = rl_end;
|
||||
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode)
|
||||
if (rl_editing_mode == vi_mode && _rl_keymap != vi_insertion_keymap)
|
||||
rl_point = 0;
|
||||
#endif /* VI_MODE */
|
||||
|
||||
|
@ -311,6 +413,8 @@ rl_replace_from_history (entry, flags)
|
|||
HIST_ENTRY *entry;
|
||||
int flags; /* currently unused */
|
||||
{
|
||||
/* Can't call with `1' because rl_undo_list might point to an undo list
|
||||
from a history entry, just like we're setting up here. */
|
||||
rl_replace_line (entry->line, 0);
|
||||
rl_undo_list = (UNDO_LIST *)entry->data;
|
||||
rl_point = rl_end;
|
||||
|
@ -435,6 +539,7 @@ rl_get_previous_history (count, key)
|
|||
rl_replace_from_history (temp, 0);
|
||||
_rl_history_set_point ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -75,6 +75,23 @@ static char *normalize_codeset PARAMS((char *));
|
|||
static char *find_codeset PARAMS((char *, size_t *));
|
||||
#endif /* !HAVE_SETLOCALE */
|
||||
|
||||
static char *_rl_get_locale_var PARAMS((const char *));
|
||||
|
||||
static char *
|
||||
_rl_get_locale_var (v)
|
||||
const char *v;
|
||||
{
|
||||
char *lspec;
|
||||
|
||||
lspec = sh_get_env_value ("LC_ALL");
|
||||
if (lspec == 0 || *lspec == 0)
|
||||
lspec = sh_get_env_value (v);
|
||||
if (lspec == 0 || *lspec == 0)
|
||||
lspec = sh_get_env_value ("LANG");
|
||||
|
||||
return lspec;
|
||||
}
|
||||
|
||||
/* Check for LC_ALL, LC_CTYPE, and LANG and use the first with a value
|
||||
to decide the defaults for 8-bit character input and output. Returns
|
||||
1 if we set eight-bit mode. */
|
||||
|
@ -84,10 +101,21 @@ _rl_init_eightbit ()
|
|||
/* If we have setlocale(3), just check the current LC_CTYPE category
|
||||
value, and go into eight-bit mode if it's not C or POSIX. */
|
||||
#if defined (HAVE_SETLOCALE)
|
||||
char *t;
|
||||
char *lspec, *t;
|
||||
|
||||
/* Set the LC_CTYPE locale category from environment variables. */
|
||||
t = setlocale (LC_CTYPE, "");
|
||||
lspec = _rl_get_locale_var ("LC_CTYPE");
|
||||
/* Since _rl_get_locale_var queries the right environment variables,
|
||||
we query the current locale settings with setlocale(), and, if
|
||||
that doesn't return anything, we set lspec to the empty string to
|
||||
force the subsequent call to setlocale() to define the `native'
|
||||
environment. */
|
||||
if (lspec == 0 || *lspec == 0)
|
||||
lspec = setlocale (LC_CTYPE, (char *)NULL);
|
||||
if (lspec == 0)
|
||||
lspec = "";
|
||||
t = setlocale (LC_CTYPE, lspec);
|
||||
|
||||
if (t && *t && (t[0] != 'C' || t[1]) && (STREQ (t, "POSIX") == 0))
|
||||
{
|
||||
_rl_meta_flag = 1;
|
||||
|
@ -105,9 +133,8 @@ _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 = 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");
|
||||
lspec = _rl_get_locale_var ("LC_CTYPE");
|
||||
|
||||
if (lspec == 0 || (t = normalize_codeset (lspec)) == 0)
|
||||
return (0);
|
||||
for (i = 0; t && legal_lang_values[i]; i++)
|
||||
|
|
|
@ -21,6 +21,10 @@
|
|||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (__TANDEM)
|
||||
# include <floss.h>
|
||||
#endif
|
||||
|
||||
#include "rlconf.h"
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
|
|
|
@ -25,7 +25,11 @@
|
|||
|
||||
#if defined (HAVE_DIRENT_H)
|
||||
# include <dirent.h>
|
||||
# define D_NAMLEN(d) (strlen ((d)->d_name))
|
||||
# if defined (HAVE_STRUCT_DIRENT_D_NAMLEN)
|
||||
# define D_NAMLEN(d) ((d)->d_namlen)
|
||||
# else
|
||||
# define D_NAMLEN(d) (strlen ((d)->d_name))
|
||||
# endif /* !HAVE_STRUCT_DIRENT_D_NAMLEN */
|
||||
#else
|
||||
# if defined (HAVE_SYS_NDIR_H)
|
||||
# include <sys/ndir.h>
|
||||
|
@ -42,11 +46,11 @@
|
|||
# define D_NAMLEN(d) ((d)->d_namlen)
|
||||
#endif /* !HAVE_DIRENT_H */
|
||||
|
||||
#if defined (STRUCT_DIRENT_HAS_D_INO) && !defined (STRUCT_DIRENT_HAS_D_FILENO)
|
||||
#if defined (HAVE_STRUCT_DIRENT_D_INO) && !defined (HAVE_STRUCT_DIRENT_D_FILENO)
|
||||
# define d_fileno d_ino
|
||||
#endif
|
||||
|
||||
#if defined (_POSIX_SOURCE) && (!defined (STRUCT_DIRENT_HAS_D_INO) || defined (BROKEN_DIRENT_D_INO))
|
||||
#if defined (_POSIX_SOURCE) && (!defined (HAVE_STRUCT_DIRENT_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
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* readline.c -- a general facility for reading lines of input
|
||||
with emacs style editing and completion. */
|
||||
|
||||
/* Copyright (C) 1987-2002 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
|
@ -68,11 +68,11 @@
|
|||
#include "xmalloc.h"
|
||||
|
||||
#ifndef RL_LIBRARY_VERSION
|
||||
# define RL_LIBRARY_VERSION "4.3"
|
||||
# define RL_LIBRARY_VERSION "5.1"
|
||||
#endif
|
||||
|
||||
#ifndef RL_READLINE_VERSION
|
||||
# define RL_READLINE_VERSION 0x0403
|
||||
# define RL_READLINE_VERSION 0x0501
|
||||
#endif
|
||||
|
||||
extern void _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
@ -85,6 +85,10 @@ static void bind_arrow_keys_internal PARAMS((Keymap));
|
|||
static void bind_arrow_keys PARAMS((void));
|
||||
|
||||
static void readline_default_bindings PARAMS((void));
|
||||
static void reset_default_bindings PARAMS((void));
|
||||
|
||||
static int _rl_subseq_result PARAMS((int, Keymap, int, int));
|
||||
static int _rl_subseq_getchar PARAMS((int));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
|
@ -103,6 +107,7 @@ int rl_gnu_readline_p = 1;
|
|||
By default, it is the standard emacs keymap. */
|
||||
Keymap _rl_keymap = emacs_standard_keymap;
|
||||
|
||||
|
||||
/* The current style of editing. */
|
||||
int rl_editing_mode = emacs_mode;
|
||||
|
||||
|
@ -218,6 +223,9 @@ char *_rl_comment_begin;
|
|||
/* Keymap holding the function currently being executed. */
|
||||
Keymap rl_executing_keymap;
|
||||
|
||||
/* Keymap we're currently using to dispatch. */
|
||||
Keymap _rl_dispatching_keymap;
|
||||
|
||||
/* Non-zero means to erase entire line, including prompt, on empty input lines. */
|
||||
int rl_erase_empty_line = 0;
|
||||
|
||||
|
@ -229,6 +237,9 @@ int rl_num_chars_to_read;
|
|||
char *rl_line_buffer = (char *)NULL;
|
||||
int rl_line_buffer_len = 0;
|
||||
|
||||
/* Key sequence `contexts' */
|
||||
_rl_keyseq_cxt *_rl_kscxt = 0;
|
||||
|
||||
/* Forward declarations used by the display, termcap, and history code. */
|
||||
|
||||
/* **************************************************************** */
|
||||
|
@ -250,6 +261,10 @@ int _rl_convert_meta_chars_to_ascii = 1;
|
|||
rather than as a meta-prefixed escape sequence. */
|
||||
int _rl_output_meta_chars = 0;
|
||||
|
||||
/* Non-zero means to look at the termios special characters and bind
|
||||
them to equivalent readline functions at startup. */
|
||||
int _rl_bind_stty_chars = 1;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Top Level Functions */
|
||||
|
@ -290,14 +305,16 @@ readline (prompt)
|
|||
rl_set_prompt (prompt);
|
||||
|
||||
rl_initialize ();
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
if (rl_prep_term_function)
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_set_signals ();
|
||||
#endif
|
||||
|
||||
value = readline_internal ();
|
||||
(*rl_deprep_term_function) ();
|
||||
if (rl_deprep_term_function)
|
||||
(*rl_deprep_term_function) ();
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_clear_signals ();
|
||||
|
@ -347,7 +364,7 @@ readline_internal_setup ()
|
|||
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode)
|
||||
rl_vi_insertion_mode (1, 0);
|
||||
rl_vi_insertion_mode (1, 'i');
|
||||
#endif /* VI_MODE */
|
||||
|
||||
if (rl_pre_input_hook)
|
||||
|
@ -387,6 +404,36 @@ readline_internal_teardown (eof)
|
|||
return (eof ? (char *)NULL : savestring (the_line));
|
||||
}
|
||||
|
||||
void
|
||||
_rl_internal_char_cleanup ()
|
||||
{
|
||||
#if defined (VI_MODE)
|
||||
/* In vi mode, when you exit insert mode, the cursor moves back
|
||||
over the previous character. We explicitly check for that here. */
|
||||
if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
|
||||
rl_vi_check ();
|
||||
#endif /* VI_MODE */
|
||||
|
||||
if (rl_num_chars_to_read && rl_end >= rl_num_chars_to_read)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
rl_newline (1, '\n');
|
||||
}
|
||||
|
||||
if (rl_done == 0)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
}
|
||||
|
||||
/* If the application writer has told us to erase the entire line if
|
||||
the only character typed was something bound to rl_newline, do so. */
|
||||
if (rl_erase_empty_line && rl_done && rl_last_func == rl_newline &&
|
||||
rl_point == 0 && rl_end == 0)
|
||||
_rl_erase_entire_line ();
|
||||
}
|
||||
|
||||
STATIC_CALLBACK int
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
readline_internal_char ()
|
||||
|
@ -409,12 +456,21 @@ readline_internal_charloop ()
|
|||
code = setjmp (readline_top_level);
|
||||
|
||||
if (code)
|
||||
(*rl_redisplay_function) ();
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
_rl_want_redisplay = 0;
|
||||
/* If we get here, we're not being called from something dispatched
|
||||
from _rl_callback_read_char(), which sets up its own value of
|
||||
readline_top_level (saving and restoring the old, of course), so
|
||||
we can just return here. */
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (rl_pending_input == 0)
|
||||
{
|
||||
/* Then initialize the argument and number of keys read. */
|
||||
_rl_init_argument ();
|
||||
_rl_reset_argument ();
|
||||
rl_key_sequence_length = 0;
|
||||
}
|
||||
|
||||
|
@ -448,27 +504,7 @@ readline_internal_charloop ()
|
|||
if (rl_pending_input == 0 && lk == _rl_last_command_was_kill)
|
||||
_rl_last_command_was_kill = 0;
|
||||
|
||||
#if defined (VI_MODE)
|
||||
/* In vi mode, when you exit insert mode, the cursor moves back
|
||||
over the previous character. We explicitly check for that here. */
|
||||
if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap)
|
||||
rl_vi_check ();
|
||||
#endif /* VI_MODE */
|
||||
|
||||
if (rl_num_chars_to_read && rl_end >= rl_num_chars_to_read)
|
||||
{
|
||||
(*rl_redisplay_function) ();
|
||||
rl_newline (1, '\n');
|
||||
}
|
||||
|
||||
if (rl_done == 0)
|
||||
(*rl_redisplay_function) ();
|
||||
|
||||
/* If the application writer has told us to erase the entire line if
|
||||
the only character typed was something bound to rl_newline, do so. */
|
||||
if (rl_erase_empty_line && rl_done && rl_last_func == rl_newline &&
|
||||
rl_point == 0 && rl_end == 0)
|
||||
_rl_erase_entire_line ();
|
||||
_rl_internal_char_cleanup ();
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
return 0;
|
||||
|
@ -518,6 +554,107 @@ _rl_set_the_line ()
|
|||
the_line = rl_line_buffer;
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
_rl_keyseq_cxt *
|
||||
_rl_keyseq_cxt_alloc ()
|
||||
{
|
||||
_rl_keyseq_cxt *cxt;
|
||||
|
||||
cxt = (_rl_keyseq_cxt *)xmalloc (sizeof (_rl_keyseq_cxt));
|
||||
|
||||
cxt->flags = cxt->subseq_arg = cxt->subseq_retval = 0;
|
||||
|
||||
cxt->okey = 0;
|
||||
cxt->ocxt = _rl_kscxt;
|
||||
cxt->childval = 42; /* sentinel value */
|
||||
|
||||
return cxt;
|
||||
}
|
||||
|
||||
void
|
||||
_rl_keyseq_cxt_dispose (cxt)
|
||||
_rl_keyseq_cxt *cxt;
|
||||
{
|
||||
free (cxt);
|
||||
}
|
||||
|
||||
void
|
||||
_rl_keyseq_chain_dispose ()
|
||||
{
|
||||
_rl_keyseq_cxt *cxt;
|
||||
|
||||
while (_rl_kscxt)
|
||||
{
|
||||
cxt = _rl_kscxt;
|
||||
_rl_kscxt = _rl_kscxt->ocxt;
|
||||
_rl_keyseq_cxt_dispose (cxt);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
_rl_subseq_getchar (key)
|
||||
int key;
|
||||
{
|
||||
int k;
|
||||
|
||||
if (key == ESC)
|
||||
RL_SETSTATE(RL_STATE_METANEXT);
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
k = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
if (key == ESC)
|
||||
RL_UNSETSTATE(RL_STATE_METANEXT);
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
int
|
||||
_rl_dispatch_callback (cxt)
|
||||
_rl_keyseq_cxt *cxt;
|
||||
{
|
||||
int nkey, r;
|
||||
|
||||
/* For now */
|
||||
#if 1
|
||||
/* The first time this context is used, we want to read input and dispatch
|
||||
on it. When traversing the chain of contexts back `up', we want to use
|
||||
the value from the next context down. We're simulating recursion using
|
||||
a chain of contexts. */
|
||||
if ((cxt->flags & KSEQ_DISPATCHED) == 0)
|
||||
{
|
||||
nkey = _rl_subseq_getchar (cxt->okey);
|
||||
r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
|
||||
cxt->flags |= KSEQ_DISPATCHED;
|
||||
}
|
||||
else
|
||||
r = cxt->childval;
|
||||
#else
|
||||
r = _rl_dispatch_subseq (nkey, cxt->dmap, cxt->subseq_arg);
|
||||
#endif
|
||||
|
||||
/* For now */
|
||||
r = _rl_subseq_result (r, cxt->oldmap, cxt->okey, (cxt->flags & KSEQ_SUBSEQ));
|
||||
|
||||
if (r == 0) /* success! */
|
||||
{
|
||||
_rl_keyseq_chain_dispose ();
|
||||
RL_UNSETSTATE (RL_STATE_MULTIKEY);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (r != -3) /* magic value that says we added to the chain */
|
||||
_rl_kscxt = cxt->ocxt;
|
||||
if (_rl_kscxt)
|
||||
_rl_kscxt->childval = r;
|
||||
if (r != -3)
|
||||
_rl_keyseq_cxt_dispose (cxt);
|
||||
|
||||
return r;
|
||||
}
|
||||
#endif /* READLINE_CALLBACKS */
|
||||
|
||||
/* Do the command associated with KEY in MAP.
|
||||
If the associated command is really a keymap, then read
|
||||
another key, and dispatch into that map. */
|
||||
|
@ -526,6 +663,7 @@ _rl_dispatch (key, map)
|
|||
register int key;
|
||||
Keymap map;
|
||||
{
|
||||
_rl_dispatching_keymap = map;
|
||||
return _rl_dispatch_subseq (key, map, 0);
|
||||
}
|
||||
|
||||
|
@ -538,6 +676,9 @@ _rl_dispatch_subseq (key, map, got_subseq)
|
|||
int r, newkey;
|
||||
char *macro;
|
||||
rl_command_func_t *func;
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
_rl_keyseq_cxt *cxt;
|
||||
#endif
|
||||
|
||||
if (META_CHAR (key) && _rl_convert_meta_chars_to_ascii)
|
||||
{
|
||||
|
@ -571,10 +712,6 @@ _rl_dispatch_subseq (key, map, got_subseq)
|
|||
|
||||
rl_executing_keymap = map;
|
||||
|
||||
#if 0
|
||||
_rl_suppress_redisplay = (map[key].function == rl_insert) && _rl_input_available ();
|
||||
#endif
|
||||
|
||||
rl_dispatching = 1;
|
||||
RL_SETSTATE(RL_STATE_DISPATCHING);
|
||||
r = (*map[key].function)(rl_numeric_arg * rl_arg_sign, key);
|
||||
|
@ -606,6 +743,10 @@ _rl_dispatch_subseq (key, map, got_subseq)
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
RL_UNSETSTATE (RL_STATE_MULTIKEY);
|
||||
_rl_keyseq_chain_dispose ();
|
||||
#endif
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
@ -627,44 +768,43 @@ _rl_dispatch_subseq (key, map, got_subseq)
|
|||
#endif
|
||||
|
||||
rl_key_sequence_length++;
|
||||
_rl_dispatching_keymap = FUNCTION_TO_KEYMAP (map, key);
|
||||
|
||||
if (key == ESC)
|
||||
RL_SETSTATE(RL_STATE_METANEXT);
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
newkey = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
if (key == ESC)
|
||||
RL_UNSETSTATE(RL_STATE_METANEXT);
|
||||
/* Allocate new context here. Use linked contexts (linked through
|
||||
cxt->ocxt) to simulate recursion */
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
{
|
||||
/* Return 0 only the first time, to indicate success to
|
||||
_rl_callback_read_char. The rest of the time, we're called
|
||||
from _rl_dispatch_callback, so we return 3 to indicate
|
||||
special handling is necessary. */
|
||||
r = RL_ISSTATE (RL_STATE_MULTIKEY) ? -3 : 0;
|
||||
cxt = _rl_keyseq_cxt_alloc ();
|
||||
|
||||
if (got_subseq)
|
||||
cxt->flags |= KSEQ_SUBSEQ;
|
||||
cxt->okey = key;
|
||||
cxt->oldmap = map;
|
||||
cxt->dmap = _rl_dispatching_keymap;
|
||||
cxt->subseq_arg = got_subseq || cxt->dmap[ANYOTHERKEY].function;
|
||||
|
||||
RL_SETSTATE (RL_STATE_MULTIKEY);
|
||||
_rl_kscxt = cxt;
|
||||
|
||||
return r; /* don't indicate immediate success */
|
||||
}
|
||||
#endif
|
||||
|
||||
newkey = _rl_subseq_getchar (key);
|
||||
if (newkey < 0)
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
r = _rl_dispatch_subseq (newkey, FUNCTION_TO_KEYMAP (map, key), got_subseq || map[ANYOTHERKEY].function);
|
||||
|
||||
if (r == -2)
|
||||
/* We didn't match anything, and the keymap we're indexed into
|
||||
shadowed a function previously bound to that prefix. Call
|
||||
the function. The recursive call to _rl_dispatch_subseq has
|
||||
already taken care of pushing any necessary input back onto
|
||||
the input queue with _rl_unget_char. */
|
||||
r = _rl_dispatch (ANYOTHERKEY, FUNCTION_TO_KEYMAP (map, key));
|
||||
else if (r && map[ANYOTHERKEY].function)
|
||||
{
|
||||
/* We didn't match (r is probably -1), so return something to
|
||||
tell the caller that it should try ANYOTHERKEY for an
|
||||
overridden function. */
|
||||
_rl_unget_char (key);
|
||||
return -2;
|
||||
}
|
||||
else if (r && got_subseq)
|
||||
{
|
||||
/* OK, back up the chain. */
|
||||
_rl_unget_char (key);
|
||||
return -1;
|
||||
}
|
||||
r = _rl_dispatch_subseq (newkey, _rl_dispatching_keymap, got_subseq || map[ANYOTHERKEY].function);
|
||||
return _rl_subseq_result (r, map, key, got_subseq);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -684,12 +824,73 @@ _rl_dispatch_subseq (key, map, got_subseq)
|
|||
}
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
|
||||
key != ANYOTHERKEY &&
|
||||
_rl_vi_textmod_command (key))
|
||||
_rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
|
||||
#endif
|
||||
|
||||
return (r);
|
||||
}
|
||||
|
||||
static int
|
||||
_rl_subseq_result (r, map, key, got_subseq)
|
||||
int r;
|
||||
Keymap map;
|
||||
int key, got_subseq;
|
||||
{
|
||||
Keymap m;
|
||||
int type, nt;
|
||||
rl_command_func_t *func, *nf;
|
||||
|
||||
if (r == -2)
|
||||
/* We didn't match anything, and the keymap we're indexed into
|
||||
shadowed a function previously bound to that prefix. Call
|
||||
the function. The recursive call to _rl_dispatch_subseq has
|
||||
already taken care of pushing any necessary input back onto
|
||||
the input queue with _rl_unget_char. */
|
||||
{
|
||||
m = _rl_dispatching_keymap;
|
||||
type = m[ANYOTHERKEY].type;
|
||||
func = m[ANYOTHERKEY].function;
|
||||
if (type == ISFUNC && func == rl_do_lowercase_version)
|
||||
r = _rl_dispatch (_rl_to_lower (key), map);
|
||||
else if (type == ISFUNC && func == rl_insert)
|
||||
{
|
||||
/* If the function that was shadowed was self-insert, we
|
||||
somehow need a keymap with map[key].func == self-insert.
|
||||
Let's use this one. */
|
||||
nt = m[key].type;
|
||||
nf = m[key].function;
|
||||
|
||||
m[key].type = type;
|
||||
m[key].function = func;
|
||||
r = _rl_dispatch (key, m);
|
||||
m[key].type = nt;
|
||||
m[key].function = nf;
|
||||
}
|
||||
else
|
||||
r = _rl_dispatch (ANYOTHERKEY, m);
|
||||
}
|
||||
else if (r && map[ANYOTHERKEY].function)
|
||||
{
|
||||
/* We didn't match (r is probably -1), so return something to
|
||||
tell the caller that it should try ANYOTHERKEY for an
|
||||
overridden function. */
|
||||
_rl_unget_char (key);
|
||||
_rl_dispatching_keymap = map;
|
||||
return -2;
|
||||
}
|
||||
else if (r && got_subseq)
|
||||
{
|
||||
/* OK, back up the chain. */
|
||||
_rl_unget_char (key);
|
||||
_rl_dispatching_keymap = map;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Initializations */
|
||||
|
@ -838,7 +1039,7 @@ readline_initialize_everything ()
|
|||
/* If the completion parser's default word break characters haven't
|
||||
been set yet, then do so now. */
|
||||
if (rl_completer_word_break_characters == (char *)NULL)
|
||||
rl_completer_word_break_characters = rl_basic_word_break_characters;
|
||||
rl_completer_word_break_characters = (char *)rl_basic_word_break_characters;
|
||||
}
|
||||
|
||||
/* If this system allows us to look at the values of the regular
|
||||
|
@ -847,7 +1048,20 @@ readline_initialize_everything ()
|
|||
static void
|
||||
readline_default_bindings ()
|
||||
{
|
||||
rl_tty_set_default_bindings (_rl_keymap);
|
||||
if (_rl_bind_stty_chars)
|
||||
rl_tty_set_default_bindings (_rl_keymap);
|
||||
}
|
||||
|
||||
/* Reset the default bindings for the terminal special characters we're
|
||||
interested in back to rl_insert and read the new ones. */
|
||||
static void
|
||||
reset_default_bindings ()
|
||||
{
|
||||
if (_rl_bind_stty_chars)
|
||||
{
|
||||
rl_tty_unset_default_bindings (_rl_keymap);
|
||||
rl_tty_set_default_bindings (_rl_keymap);
|
||||
}
|
||||
}
|
||||
|
||||
/* Bind some common arrow key sequences in MAP. */
|
||||
|
@ -861,25 +1075,32 @@ bind_arrow_keys_internal (map)
|
|||
_rl_keymap = map;
|
||||
|
||||
#if defined (__MSDOS__)
|
||||
_rl_bind_if_unbound ("\033[0A", rl_get_previous_history);
|
||||
_rl_bind_if_unbound ("\033[0B", rl_backward_char);
|
||||
_rl_bind_if_unbound ("\033[0C", rl_forward_char);
|
||||
_rl_bind_if_unbound ("\033[0D", rl_get_next_history);
|
||||
rl_bind_keyseq_if_unbound ("\033[0A", rl_get_previous_history);
|
||||
rl_bind_keyseq_if_unbound ("\033[0B", rl_backward_char);
|
||||
rl_bind_keyseq_if_unbound ("\033[0C", rl_forward_char);
|
||||
rl_bind_keyseq_if_unbound ("\033[0D", rl_get_next_history);
|
||||
#endif
|
||||
|
||||
_rl_bind_if_unbound ("\033[A", rl_get_previous_history);
|
||||
_rl_bind_if_unbound ("\033[B", rl_get_next_history);
|
||||
_rl_bind_if_unbound ("\033[C", rl_forward_char);
|
||||
_rl_bind_if_unbound ("\033[D", rl_backward_char);
|
||||
_rl_bind_if_unbound ("\033[H", rl_beg_of_line);
|
||||
_rl_bind_if_unbound ("\033[F", rl_end_of_line);
|
||||
rl_bind_keyseq_if_unbound ("\033[A", rl_get_previous_history);
|
||||
rl_bind_keyseq_if_unbound ("\033[B", rl_get_next_history);
|
||||
rl_bind_keyseq_if_unbound ("\033[C", rl_forward_char);
|
||||
rl_bind_keyseq_if_unbound ("\033[D", rl_backward_char);
|
||||
rl_bind_keyseq_if_unbound ("\033[H", rl_beg_of_line);
|
||||
rl_bind_keyseq_if_unbound ("\033[F", rl_end_of_line);
|
||||
|
||||
_rl_bind_if_unbound ("\033OA", rl_get_previous_history);
|
||||
_rl_bind_if_unbound ("\033OB", rl_get_next_history);
|
||||
_rl_bind_if_unbound ("\033OC", rl_forward_char);
|
||||
_rl_bind_if_unbound ("\033OD", rl_backward_char);
|
||||
_rl_bind_if_unbound ("\033OH", rl_beg_of_line);
|
||||
_rl_bind_if_unbound ("\033OF", rl_end_of_line);
|
||||
rl_bind_keyseq_if_unbound ("\033OA", rl_get_previous_history);
|
||||
rl_bind_keyseq_if_unbound ("\033OB", rl_get_next_history);
|
||||
rl_bind_keyseq_if_unbound ("\033OC", rl_forward_char);
|
||||
rl_bind_keyseq_if_unbound ("\033OD", rl_backward_char);
|
||||
rl_bind_keyseq_if_unbound ("\033OH", rl_beg_of_line);
|
||||
rl_bind_keyseq_if_unbound ("\033OF", rl_end_of_line);
|
||||
|
||||
#if defined (__MINGW32__)
|
||||
rl_bind_keyseq_if_unbound ("\340H", rl_get_previous_history);
|
||||
rl_bind_keyseq_if_unbound ("\340P", rl_get_next_history);
|
||||
rl_bind_keyseq_if_unbound ("\340M", rl_forward_char);
|
||||
rl_bind_keyseq_if_unbound ("\340K", rl_backward_char);
|
||||
#endif
|
||||
|
||||
_rl_keymap = xkeymap;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* Readline.h -- the names of functions callable from within readline. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
|
@ -40,9 +40,9 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/* Hex-encoded Readline version number. */
|
||||
#define RL_READLINE_VERSION 0x0403 /* Readline 4.3 */
|
||||
#define RL_VERSION_MAJOR 4
|
||||
#define RL_VERSION_MINOR 3
|
||||
#define RL_READLINE_VERSION 0x0501 /* Readline 5.1 */
|
||||
#define RL_VERSION_MAJOR 5
|
||||
#define RL_VERSION_MINOR 1
|
||||
|
||||
/* Readline data structures. */
|
||||
|
||||
|
@ -160,6 +160,7 @@ 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_filename_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));
|
||||
|
@ -240,6 +241,7 @@ 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_rubout 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));
|
||||
|
@ -258,6 +260,8 @@ extern int rl_vi_check PARAMS((void));
|
|||
extern int rl_vi_domove PARAMS((int, int *));
|
||||
extern int rl_vi_bracktype PARAMS((int));
|
||||
|
||||
extern void rl_vi_start_inserting PARAMS((int, int, int));
|
||||
|
||||
/* VI-mode pseudo-bindable commands, used as utility functions. */
|
||||
extern int rl_vi_fWord PARAMS((int, int));
|
||||
extern int rl_vi_bWord PARAMS((int, int));
|
||||
|
@ -290,12 +294,22 @@ 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_bind_key_if_unbound PARAMS((int, rl_command_func_t *));
|
||||
extern int rl_bind_key_if_unbound_in_map PARAMS((int, rl_command_func_t *, 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_bind_keyseq PARAMS((const char *, rl_command_func_t *));
|
||||
extern int rl_bind_keyseq_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
|
||||
extern int rl_bind_keyseq_if_unbound PARAMS((const char *, rl_command_func_t *));
|
||||
extern int rl_bind_keyseq_if_unbound_in_map PARAMS((const char *, rl_command_func_t *, Keymap));
|
||||
extern int rl_generic_bind PARAMS((int, const char *, char *, Keymap));
|
||||
|
||||
extern char *rl_variable_value PARAMS((const char *));
|
||||
extern int rl_variable_bind PARAMS((const char *, const char *));
|
||||
|
||||
/* Backwards compatibility, use rl_bind_keyseq_in_map instead. */
|
||||
extern int rl_set_key PARAMS((const char *, rl_command_func_t *, Keymap));
|
||||
|
||||
/* Backwards compatibility, use rl_generic_bind instead. */
|
||||
extern int rl_macro_bind PARAMS((const char *, const char *, Keymap));
|
||||
|
||||
|
@ -358,7 +372,7 @@ 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)
|
||||
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
|
||||
extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
|
||||
#else
|
||||
extern int rl_message ();
|
||||
|
@ -384,11 +398,13 @@ extern char *rl_copy_text PARAMS((int, int));
|
|||
extern void rl_prep_terminal PARAMS((int));
|
||||
extern void rl_deprep_terminal PARAMS((void));
|
||||
extern void rl_tty_set_default_bindings PARAMS((Keymap));
|
||||
extern void rl_tty_unset_default_bindings PARAMS((Keymap));
|
||||
|
||||
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 *));
|
||||
extern void rl_reset_screen_size PARAMS((void));
|
||||
|
||||
extern char *rl_get_termcap PARAMS((const char *));
|
||||
|
||||
|
@ -516,6 +532,11 @@ extern const char *rl_terminal_name;
|
|||
extern FILE *rl_instream;
|
||||
extern FILE *rl_outstream;
|
||||
|
||||
/* If non-zero, Readline gives values of LINES and COLUMNS from the environment
|
||||
greater precedence than values fetched from the kernel when computing the
|
||||
screen dimensions. */
|
||||
extern int rl_prefer_env_winsize;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call just
|
||||
before readline_internal () prints the first prompt. */
|
||||
extern rl_hook_func_t *rl_startup_hook;
|
||||
|
@ -603,7 +624,12 @@ 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 const char *rl_completer_word_break_characters;
|
||||
extern /*const*/ char *rl_completer_word_break_characters;
|
||||
|
||||
/* Hook function to allow an application to set the completion word
|
||||
break characters before readline breaks up the line. Allows
|
||||
position-dependent word break characters. */
|
||||
extern rl_cpvfunc_t *rl_completion_word_break_hook;
|
||||
|
||||
/* List of characters which can be used to quote a substring of the line.
|
||||
Completion occurs on the entire substring, and within the substring
|
||||
|
@ -687,6 +713,11 @@ extern int rl_attempted_completion_over;
|
|||
functions. */
|
||||
extern int rl_completion_type;
|
||||
|
||||
/* 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;
|
||||
|
||||
/* Character appended to completed words when at the end of the line. The
|
||||
default is a space. Nothing is added if this is '\0'. */
|
||||
extern int rl_completion_append_character;
|
||||
|
@ -695,10 +726,18 @@ extern int rl_completion_append_character;
|
|||
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;
|
||||
/* Set to any quote character readline thinks it finds before any application
|
||||
completion function is called. */
|
||||
extern int rl_completion_quote_character;
|
||||
|
||||
/* Set to a non-zero value if readline found quoting anywhere in the word to
|
||||
be completed; set before any application completion function is called. */
|
||||
extern int rl_completion_found_quote;
|
||||
|
||||
/* If non-zero, the completion functions don't append any closing quote.
|
||||
This is set to 0 by rl_complete_internal and may be changed by an
|
||||
application-specific completion function. */
|
||||
extern int rl_completion_suppress_quote;
|
||||
|
||||
/* If non-zero, a slash will be appended to completed filenames that are
|
||||
symbolic links to directory names, subject to the value of the
|
||||
|
@ -729,28 +768,33 @@ extern int rl_inhibit_completion;
|
|||
#define MULT_MATCH 2
|
||||
|
||||
/* Possible state values for rl_readline_state */
|
||||
#define RL_STATE_NONE 0x00000 /* no state; before first call */
|
||||
#define RL_STATE_NONE 0x000000 /* 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_INITIALIZING 0x000001 /* initializing */
|
||||
#define RL_STATE_INITIALIZED 0x000002 /* initialization done */
|
||||
#define RL_STATE_TERMPREPPED 0x000004 /* terminal is prepped */
|
||||
#define RL_STATE_READCMD 0x000008 /* reading a command key */
|
||||
#define RL_STATE_METANEXT 0x000010 /* reading input after ESC */
|
||||
#define RL_STATE_DISPATCHING 0x000020 /* dispatching to a command */
|
||||
#define RL_STATE_MOREINPUT 0x000040 /* reading more input in a command function */
|
||||
#define RL_STATE_ISEARCH 0x000080 /* doing incremental search */
|
||||
#define RL_STATE_NSEARCH 0x000100 /* doing non-inc search */
|
||||
#define RL_STATE_SEARCH 0x000200 /* doing a history search */
|
||||
#define RL_STATE_NUMERICARG 0x000400 /* reading numeric argument */
|
||||
#define RL_STATE_MACROINPUT 0x000800 /* getting input from a macro */
|
||||
#define RL_STATE_MACRODEF 0x001000 /* defining keyboard macro */
|
||||
#define RL_STATE_OVERWRITE 0x002000 /* overwrite mode */
|
||||
#define RL_STATE_COMPLETING 0x004000 /* doing completion */
|
||||
#define RL_STATE_SIGHANDLER 0x008000 /* in readline sighandler */
|
||||
#define RL_STATE_UNDOING 0x010000 /* doing an undo */
|
||||
#define RL_STATE_INPUTPENDING 0x020000 /* rl_execute_next called */
|
||||
#define RL_STATE_TTYCSAVED 0x040000 /* tty special chars saved */
|
||||
#define RL_STATE_CALLBACK 0x080000 /* using the callback interface */
|
||||
#define RL_STATE_VIMOTION 0x100000 /* reading vi motion arg */
|
||||
#define RL_STATE_MULTIKEY 0x200000 /* reading multiple-key command */
|
||||
#define RL_STATE_VICMDONCE 0x400000 /* entered vi command mode at least once */
|
||||
|
||||
#define RL_STATE_DONE 0x80000 /* done; accepted line */
|
||||
#define RL_STATE_DONE 0x800000 /* done; accepted line */
|
||||
|
||||
#define RL_SETSTATE(x) (rl_readline_state |= (x))
|
||||
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
|
||||
|
@ -785,6 +829,12 @@ struct readline_state {
|
|||
int catchsigs;
|
||||
int catchsigwinch;
|
||||
|
||||
/* search state */
|
||||
|
||||
/* completion state */
|
||||
|
||||
/* options state */
|
||||
|
||||
/* reserved for future expansion, so the struct size doesn't change */
|
||||
char reserved[64];
|
||||
};
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
for readline. This should be included after any files that define
|
||||
system-specific constants like _POSIX_VERSION or USG. */
|
||||
|
||||
/* Copyright (C) 1987,1989 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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
|
||||
|
@ -38,7 +38,11 @@
|
|||
# if defined (HAVE_TERMIO_H)
|
||||
# define TERMIO_TTY_DRIVER
|
||||
# else
|
||||
# define NEW_TTY_DRIVER
|
||||
# if !defined (__MINGW32__)
|
||||
# define NEW_TTY_DRIVER
|
||||
# else
|
||||
# define NO_TTY_DRIVER
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
@ -77,7 +81,7 @@ extern int _rl_stricmp PARAMS((char *, char *));
|
|||
extern int _rl_strnicmp PARAMS((char *, char *, int));
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STRPBRK)
|
||||
#if defined (HAVE_STRPBRK) && !defined (HAVE_MULTIBYTE)
|
||||
# define _rl_strpbrk(a,b) strpbrk((a),(b))
|
||||
#else
|
||||
extern char *_rl_strpbrk PARAMS((const char *, const char *));
|
||||
|
|
|
@ -35,11 +35,18 @@
|
|||
#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 */
|
||||
# if defined (HAVE_MBSRTOWCS) && defined (HAVE_MBRTOWC) && defined (HAVE_MBRLEN) && defined (HAVE_WCWIDTH)
|
||||
/* system is supposed to support XPG5 */
|
||||
# define HANDLE_MULTIBYTE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If we don't want multibyte chars even on a system that supports them, let
|
||||
the configuring user turn multibyte support off. */
|
||||
#if defined (NO_MULTIBYTE_SUPPORT)
|
||||
# undef HANDLE_MULTIBYTE
|
||||
#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)
|
||||
|
@ -90,6 +97,24 @@ extern int _rl_read_mbstring PARAMS((int, char *, int));
|
|||
|
||||
extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
|
||||
|
||||
extern wchar_t _rl_char_value PARAMS((char *, int));
|
||||
extern int _rl_walphabetic PARAMS((wchar_t));
|
||||
|
||||
#define _rl_to_wupper(wc) (iswlower (wc) ? towupper (wc) : (wc))
|
||||
#define _rl_to_wlower(wc) (iswupper (wc) ? towlower (wc) : (wc))
|
||||
|
||||
#define MB_NEXTCHAR(b,s,c,f) \
|
||||
((MB_CUR_MAX > 1 && rl_byte_oriented == 0) \
|
||||
? _rl_find_next_mbchar ((b), (s), (c), (f)) \
|
||||
: ((s) + (c)))
|
||||
#define MB_PREVCHAR(b,s,f) \
|
||||
((MB_CUR_MAX > 1 && rl_byte_oriented == 0) \
|
||||
? _rl_find_prev_mbchar ((b), (s), (f)) \
|
||||
: ((s) - 1))
|
||||
|
||||
#define MB_INVALIDCH(x) ((x) == (size_t)-1 || (x) == (size_t)-2)
|
||||
#define MB_NULLWCH(x) ((x) == 0)
|
||||
|
||||
#else /* !HANDLE_MULTIBYTE */
|
||||
|
||||
#undef MB_LEN_MAX
|
||||
|
@ -101,6 +126,19 @@ extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
|
|||
#define _rl_find_prev_mbchar(b, i, f) (((i) == 0) ? (i) : ((i) - 1))
|
||||
#define _rl_find_next_mbchar(b, i1, i2, f) ((i1) + (i2))
|
||||
|
||||
#define _rl_char_value(buf,ind) ((buf)[(ind)])
|
||||
|
||||
#define _rl_walphabetic(c) (rl_alphabetic (c))
|
||||
|
||||
#define _rl_to_wupper(c) (_rl_to_upper (c))
|
||||
#define _rl_to_wlower(c) (_rl_to_lower (c))
|
||||
|
||||
#define MB_NEXTCHAR(b,s,c,f) ((s) + (c))
|
||||
#define MB_PREVCHAR(b,s,f) ((s) - 1)
|
||||
|
||||
#define MB_INVALIDCH(x) (0)
|
||||
#define MB_NULLWCH(x) (0)
|
||||
|
||||
#endif /* !HANDLE_MULTIBYTE */
|
||||
|
||||
extern int rl_byte_oriented;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* rlprivate.h -- functions and variables global to the readline library,
|
||||
but not intended for use by applications. */
|
||||
|
||||
/* Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1999-2005 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.
|
||||
|
@ -28,6 +28,95 @@
|
|||
#include "rlstdc.h"
|
||||
#include "posixjmp.h" /* defines procenv_t */
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Global structs undocumented in texinfo manual and not in readline.h *
|
||||
* *
|
||||
*************************************************************************/
|
||||
/* search types */
|
||||
#define RL_SEARCH_ISEARCH 0x01 /* incremental search */
|
||||
#define RL_SEARCH_NSEARCH 0x02 /* non-incremental search */
|
||||
#define RL_SEARCH_CSEARCH 0x04 /* intra-line char search */
|
||||
|
||||
/* search flags */
|
||||
#define SF_REVERSE 0x01
|
||||
#define SF_FOUND 0x02
|
||||
#define SF_FAILED 0x04
|
||||
|
||||
typedef struct __rl_search_context
|
||||
{
|
||||
int type;
|
||||
int sflags;
|
||||
|
||||
char *search_string;
|
||||
int search_string_index;
|
||||
int search_string_size;
|
||||
|
||||
char **lines;
|
||||
char *allocated_line;
|
||||
int hlen;
|
||||
int hindex;
|
||||
|
||||
int save_point;
|
||||
int save_mark;
|
||||
int save_line;
|
||||
int last_found_line;
|
||||
char *prev_line_found;
|
||||
|
||||
UNDO_LIST *save_undo_list;
|
||||
|
||||
int history_pos;
|
||||
int direction;
|
||||
|
||||
int lastc;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
char mb[MB_LEN_MAX];
|
||||
#endif
|
||||
|
||||
char *sline;
|
||||
int sline_len;
|
||||
int sline_index;
|
||||
|
||||
char *search_terminators;
|
||||
} _rl_search_cxt;
|
||||
|
||||
/* Callback data for reading numeric arguments */
|
||||
#define NUM_SAWMINUS 0x01
|
||||
#define NUM_SAWDIGITS 0x02
|
||||
#define NUM_READONE 0x04
|
||||
|
||||
typedef int _rl_arg_cxt;
|
||||
|
||||
/* A context for reading key sequences longer than a single character when
|
||||
using the callback interface. */
|
||||
#define KSEQ_DISPATCHED 0x01
|
||||
#define KSEQ_SUBSEQ 0x02
|
||||
#define KSEQ_RECURSIVE 0x04
|
||||
|
||||
typedef struct __rl_keyseq_context
|
||||
{
|
||||
int flags;
|
||||
int subseq_arg;
|
||||
int subseq_retval; /* XXX */
|
||||
Keymap dmap;
|
||||
|
||||
Keymap oldmap;
|
||||
int okey;
|
||||
struct __rl_keyseq_context *ocxt;
|
||||
int childval;
|
||||
} _rl_keyseq_cxt;
|
||||
|
||||
/* fill in more as needed */
|
||||
/* `Generic' callback data and functions */
|
||||
typedef struct __rl_callback_generic_arg
|
||||
{
|
||||
int count;
|
||||
int i1, i2;
|
||||
/* add here as needed */
|
||||
} _rl_callback_generic_arg;
|
||||
|
||||
typedef int _rl_callback_func_t PARAMS((_rl_callback_generic_arg *));
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Global functions undocumented in texinfo manual and not in readline.h *
|
||||
|
@ -54,6 +143,8 @@ extern int readline_echoing_p;
|
|||
extern int rl_key_sequence_length;
|
||||
extern int rl_byte_oriented;
|
||||
|
||||
extern _rl_keyseq_cxt *_rl_kscxt;
|
||||
|
||||
/* display.c */
|
||||
extern int rl_display_fixed;
|
||||
|
||||
|
@ -100,10 +191,19 @@ extern void readline_internal_setup PARAMS((void));
|
|||
extern char *readline_internal_teardown PARAMS((int));
|
||||
extern int readline_internal_char PARAMS((void));
|
||||
|
||||
extern _rl_keyseq_cxt *_rl_keyseq_cxt_alloc PARAMS((void));
|
||||
extern void _rl_keyseq_cxt_dispose PARAMS((_rl_keyseq_cxt *));
|
||||
extern void _rl_keyseq_chain_dispose PARAMS((void));
|
||||
|
||||
extern int _rl_dispatch_callback PARAMS((_rl_keyseq_cxt *));
|
||||
|
||||
/* callback.c */
|
||||
extern _rl_callback_generic_arg *_rl_callback_data_alloc PARAMS((int));
|
||||
extern void _rl_callback_data_dispose PARAMS((_rl_callback_generic_arg *));
|
||||
|
||||
#endif /* READLINE_CALLBACKS */
|
||||
|
||||
/* bind.c */
|
||||
extern void _rl_bind_if_unbound PARAMS((const char *, rl_command_func_t *));
|
||||
|
||||
/* complete.c */
|
||||
extern char _rl_find_completion_word PARAMS((int *, int *));
|
||||
|
@ -131,6 +231,16 @@ 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));
|
||||
extern int _rl_pushed_input_available PARAMS((void));
|
||||
|
||||
/* isearch.c */
|
||||
extern _rl_search_cxt *_rl_scxt_alloc PARAMS((int, int));
|
||||
extern void _rl_scxt_dispose PARAMS((_rl_search_cxt *, int));
|
||||
|
||||
extern int _rl_isearch_dispatch PARAMS((_rl_search_cxt *, int));
|
||||
extern int _rl_isearch_callback PARAMS((_rl_search_cxt *));
|
||||
|
||||
extern int _rl_search_getchar PARAMS((_rl_search_cxt *));
|
||||
|
||||
/* macro.c */
|
||||
extern void _rl_with_macro_input PARAMS((char *));
|
||||
|
@ -141,7 +251,12 @@ 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 int _rl_arg_overflow PARAMS((void));
|
||||
extern void _rl_arg_init PARAMS((void));
|
||||
extern int _rl_arg_getchar PARAMS((void));
|
||||
extern int _rl_arg_callback PARAMS((_rl_arg_cxt));
|
||||
extern void _rl_reset_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));
|
||||
|
@ -157,11 +272,15 @@ 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));
|
||||
extern void _rl_internal_char_cleanup PARAMS((void));
|
||||
|
||||
/* rltty.c */
|
||||
extern int _rl_disable_tty_signals PARAMS((void));
|
||||
extern int _rl_restore_tty_signals PARAMS((void));
|
||||
|
||||
/* search.c */
|
||||
extern int _rl_nsearch_callback PARAMS((_rl_search_cxt *));
|
||||
|
||||
/* terminal.c */
|
||||
extern void _rl_get_screen_size PARAMS((int, int));
|
||||
extern int _rl_init_terminal_io PARAMS((const char *));
|
||||
|
@ -217,8 +336,13 @@ extern void _rl_vi_done_inserting PARAMS((void));
|
|||
extern const char *_rl_possible_control_prefixes[];
|
||||
extern const char *_rl_possible_meta_prefixes[];
|
||||
|
||||
/* callback.c */
|
||||
extern _rl_callback_func_t *_rl_callback_func;
|
||||
extern _rl_callback_generic_arg *_rl_callback_data;
|
||||
|
||||
/* complete.c */
|
||||
extern int _rl_complete_show_all;
|
||||
extern int _rl_complete_show_unmodified;
|
||||
extern int _rl_complete_mark_directories;
|
||||
extern int _rl_complete_mark_symlink_dirs;
|
||||
extern int _rl_print_completions_horizontally;
|
||||
|
@ -230,11 +354,14 @@ extern int _rl_page_completions;
|
|||
extern int _rl_vis_botlin;
|
||||
extern int _rl_last_c_pos;
|
||||
extern int _rl_suppress_redisplay;
|
||||
extern int _rl_want_redisplay;
|
||||
extern char *rl_display_prompt;
|
||||
|
||||
/* isearch.c */
|
||||
extern char *_rl_isearch_terminators;
|
||||
|
||||
extern _rl_search_cxt *_rl_iscxt;
|
||||
|
||||
/* macro.c */
|
||||
extern char *_rl_executing_macro;
|
||||
|
||||
|
@ -242,6 +369,8 @@ extern char *_rl_executing_macro;
|
|||
extern int _rl_history_preserve_point;
|
||||
extern int _rl_history_saved_point;
|
||||
|
||||
extern _rl_arg_cxt _rl_argcxt;
|
||||
|
||||
/* readline.c */
|
||||
extern int _rl_horizontal_scroll_mode;
|
||||
extern int _rl_mark_modified_lines;
|
||||
|
@ -249,6 +378,7 @@ extern int _rl_bell_preference;
|
|||
extern int _rl_meta_flag;
|
||||
extern int _rl_convert_meta_chars_to_ascii;
|
||||
extern int _rl_output_meta_chars;
|
||||
extern int _rl_bind_stty_chars;
|
||||
extern char *_rl_comment_begin;
|
||||
extern unsigned char _rl_parsing_conditionalized_out;
|
||||
extern Keymap _rl_keymap;
|
||||
|
@ -258,6 +388,9 @@ extern int _rl_last_command_was_kill;
|
|||
extern int _rl_eof_char;
|
||||
extern procenv_t readline_top_level;
|
||||
|
||||
/* search.c */
|
||||
extern _rl_search_cxt *_rl_nscxt;
|
||||
|
||||
/* terminal.c */
|
||||
extern int _rl_enable_keypad;
|
||||
extern int _rl_enable_meta;
|
||||
|
@ -281,4 +414,7 @@ extern int _rl_term_autowrap;
|
|||
extern int _rl_doing_an_undo;
|
||||
extern int _rl_undo_group_level;
|
||||
|
||||
/* vi_mode.c */
|
||||
extern int _rl_vi_last_command;
|
||||
|
||||
#endif /* _RL_PRIVATE_H_ */
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
|
240
readline/rltty.c
240
readline/rltty.c
|
@ -1,7 +1,7 @@
|
|||
/* rltty.c -- functions to prepare and restore the terminal for readline's
|
||||
use. */
|
||||
|
||||
/* Copyright (C) 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1992-2005 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.
|
||||
|
@ -152,7 +152,9 @@ set_winsize (tty)
|
|||
#endif /* TIOCGWINSZ */
|
||||
}
|
||||
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
#if defined (NO_TTY_DRIVER)
|
||||
/* Nothing */
|
||||
#elif defined (NEW_TTY_DRIVER)
|
||||
|
||||
/* Values for the `flags' field of a struct bsdtty. This tells which
|
||||
elements of the struct bsdtty have been fetched from the system and
|
||||
|
@ -186,6 +188,8 @@ static int set_tty_settings PARAMS((int, TIOTYPE *));
|
|||
|
||||
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
|
||||
|
||||
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
|
||||
|
||||
static void
|
||||
save_tty_chars (tiop)
|
||||
TIOTYPE *tiop;
|
||||
|
@ -231,6 +235,7 @@ get_tty_settings (tty, tiop)
|
|||
|
||||
tiop->flags = tiop->lflag = 0;
|
||||
|
||||
errno = 0;
|
||||
if (ioctl (tty, TIOCGETP, &(tiop->sgttyb)) < 0)
|
||||
return -1;
|
||||
tiop->flags |= SGTTY_SET;
|
||||
|
@ -400,6 +405,9 @@ static int set_tty_settings PARAMS((int, TIOTYPE *));
|
|||
|
||||
static void prepare_terminal_settings PARAMS((int, TIOTYPE, TIOTYPE *));
|
||||
|
||||
static void set_special_char PARAMS((Keymap, TIOTYPE *, int, rl_command_func_t));
|
||||
static void _rl_bind_tty_special_chars PARAMS((Keymap, TIOTYPE));
|
||||
|
||||
#if defined (FLUSHO)
|
||||
# define OUTPUT_BEING_FLUSHED(tp) (tp->c_lflag & FLUSHO)
|
||||
#else
|
||||
|
@ -513,6 +521,7 @@ get_tty_settings (tty, tiop)
|
|||
{
|
||||
set_winsize (tty);
|
||||
|
||||
errno = 0;
|
||||
if (_get_tty_settings (tty, tiop) < 0)
|
||||
return -1;
|
||||
|
||||
|
@ -626,9 +635,23 @@ prepare_terminal_settings (meta_flag, oldtio, tiop)
|
|||
|
||||
#endif /* TERMIOS_TTY_DRIVER && _POSIX_VDISABLE */
|
||||
}
|
||||
#endif /* NEW_TTY_DRIVER */
|
||||
#endif /* !NEW_TTY_DRIVER */
|
||||
|
||||
/* Put the terminal in CBREAK mode so that we can detect key presses. */
|
||||
#if defined (NO_TTY_DRIVER)
|
||||
void
|
||||
rl_prep_terminal (meta_flag)
|
||||
int meta_flag;
|
||||
{
|
||||
readline_echoing_p = 1;
|
||||
}
|
||||
|
||||
void
|
||||
rl_deprep_terminal ()
|
||||
{
|
||||
}
|
||||
|
||||
#else /* ! NO_TTY_DRIVER */
|
||||
void
|
||||
rl_prep_terminal (meta_flag)
|
||||
int meta_flag;
|
||||
|
@ -646,13 +669,43 @@ rl_prep_terminal (meta_flag)
|
|||
|
||||
if (get_tty_settings (tty, &tio) < 0)
|
||||
{
|
||||
#if defined (ENOTSUP)
|
||||
/* MacOS X, at least, lies about the value of errno if tcgetattr fails. */
|
||||
if (errno == ENOTTY || errno == ENOTSUP)
|
||||
#else
|
||||
if (errno == ENOTTY)
|
||||
#endif
|
||||
readline_echoing_p = 1; /* XXX */
|
||||
release_sigint ();
|
||||
return;
|
||||
}
|
||||
|
||||
otio = tio;
|
||||
|
||||
if (_rl_bind_stty_chars)
|
||||
{
|
||||
#if defined (VI_MODE)
|
||||
/* If editing in vi mode, make sure we restore the bindings in the
|
||||
insertion keymap no matter what keymap we ended up in. */
|
||||
if (rl_editing_mode == vi_mode)
|
||||
rl_tty_unset_default_bindings (vi_insertion_keymap);
|
||||
else
|
||||
#endif
|
||||
rl_tty_unset_default_bindings (_rl_keymap);
|
||||
}
|
||||
save_tty_chars (&otio);
|
||||
RL_SETSTATE(RL_STATE_TTYCSAVED);
|
||||
if (_rl_bind_stty_chars)
|
||||
{
|
||||
#if defined (VI_MODE)
|
||||
/* If editing in vi mode, make sure we set the bindings in the
|
||||
insertion keymap no matter what keymap we ended up in. */
|
||||
if (rl_editing_mode == vi_mode)
|
||||
_rl_bind_tty_special_chars (vi_insertion_keymap, tio);
|
||||
else
|
||||
#endif
|
||||
_rl_bind_tty_special_chars (_rl_keymap, tio);
|
||||
}
|
||||
|
||||
prepare_terminal_settings (meta_flag, otio, &tio);
|
||||
|
||||
|
@ -702,6 +755,7 @@ rl_deprep_terminal ()
|
|||
|
||||
release_sigint ();
|
||||
}
|
||||
#endif /* !NO_TTY_DRIVER */
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
|
@ -713,6 +767,10 @@ int
|
|||
rl_restart_output (count, key)
|
||||
int count, key;
|
||||
{
|
||||
#if defined (__MINGW32__)
|
||||
return 0;
|
||||
#else /* !__MING32__ */
|
||||
|
||||
int fildes = fileno (rl_outstream);
|
||||
#if defined (TIOCSTART)
|
||||
#if defined (apollo)
|
||||
|
@ -740,12 +798,17 @@ rl_restart_output (count, key)
|
|||
#endif /* !TIOCSTART */
|
||||
|
||||
return 0;
|
||||
#endif /* !__MINGW32__ */
|
||||
}
|
||||
|
||||
int
|
||||
rl_stop_output (count, key)
|
||||
int count, key;
|
||||
{
|
||||
#if defined (__MINGW32__)
|
||||
return 0;
|
||||
#else
|
||||
|
||||
int fildes = fileno (rl_instream);
|
||||
|
||||
#if defined (TIOCSTOP)
|
||||
|
@ -768,6 +831,7 @@ rl_stop_output (count, key)
|
|||
#endif /* !TIOCSTOP */
|
||||
|
||||
return 0;
|
||||
#endif /* !__MINGW32__ */
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
|
@ -776,70 +840,106 @@ rl_stop_output (count, key)
|
|||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if !defined (NO_TTY_DRIVER)
|
||||
#define SET_SPECIAL(sc, func) set_special_char(kmap, &ttybuff, sc, func)
|
||||
#endif
|
||||
|
||||
#if defined (NO_TTY_DRIVER)
|
||||
|
||||
#define SET_SPECIAL(sc, func)
|
||||
#define RESET_SPECIAL(c)
|
||||
|
||||
#elif defined (NEW_TTY_DRIVER)
|
||||
static void
|
||||
set_special_char (kmap, tiop, sc, func)
|
||||
Keymap kmap;
|
||||
TIOTYPE *tiop;
|
||||
int sc;
|
||||
rl_command_func_t *func;
|
||||
{
|
||||
if (sc != -1 && kmap[(unsigned char)sc].type == ISFUNC)
|
||||
kmap[(unsigned char)sc].function = func;
|
||||
}
|
||||
|
||||
#define RESET_SPECIAL(c) \
|
||||
if (c != -1 && kmap[(unsigned char)c].type == ISFUNC)
|
||||
kmap[(unsigned char)c].function = rl_insert;
|
||||
|
||||
static void
|
||||
_rl_bind_tty_special_chars (kmap, ttybuff)
|
||||
Keymap kmap;
|
||||
TIOTYPE ttybuff;
|
||||
{
|
||||
if (ttybuff.flags & SGTTY_SET)
|
||||
{
|
||||
SET_SPECIAL (ttybuff.sgttyb.sg_erase, rl_rubout);
|
||||
SET_SPECIAL (ttybuff.sgttyb.sg_kill, rl_unix_line_discard);
|
||||
}
|
||||
|
||||
# if defined (TIOCGLTC)
|
||||
if (ttybuff.flags & LTCHARS_SET)
|
||||
{
|
||||
SET_SPECIAL (ttybuff.ltchars.t_werasc, rl_unix_word_rubout);
|
||||
SET_SPECIAL (ttybuff.ltchars.t_lnextc, rl_quoted_insert);
|
||||
}
|
||||
# endif /* TIOCGLTC */
|
||||
}
|
||||
|
||||
#else /* !NEW_TTY_DRIVER */
|
||||
static void
|
||||
set_special_char (kmap, tiop, sc, func)
|
||||
Keymap kmap;
|
||||
TIOTYPE *tiop;
|
||||
int sc;
|
||||
rl_command_func_t *func;
|
||||
{
|
||||
unsigned char uc;
|
||||
|
||||
uc = tiop->c_cc[sc];
|
||||
if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC)
|
||||
kmap[uc].function = func;
|
||||
}
|
||||
|
||||
/* used later */
|
||||
#define RESET_SPECIAL(uc) \
|
||||
if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC) \
|
||||
kmap[uc].function = rl_insert;
|
||||
|
||||
static void
|
||||
_rl_bind_tty_special_chars (kmap, ttybuff)
|
||||
Keymap kmap;
|
||||
TIOTYPE ttybuff;
|
||||
{
|
||||
SET_SPECIAL (VERASE, rl_rubout);
|
||||
SET_SPECIAL (VKILL, rl_unix_line_discard);
|
||||
|
||||
# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
|
||||
SET_SPECIAL (VLNEXT, rl_quoted_insert);
|
||||
# endif /* VLNEXT && TERMIOS_TTY_DRIVER */
|
||||
|
||||
# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
|
||||
SET_SPECIAL (VWERASE, rl_unix_word_rubout);
|
||||
# endif /* VWERASE && TERMIOS_TTY_DRIVER */
|
||||
}
|
||||
|
||||
#endif /* !NEW_TTY_DRIVER */
|
||||
|
||||
/* 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;
|
||||
{
|
||||
#if !defined (NO_TTY_DRIVER)
|
||||
TIOTYPE ttybuff;
|
||||
int tty = fileno (rl_instream);
|
||||
int tty;
|
||||
static int called = 0;
|
||||
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
|
||||
#define SET_SPECIAL(sc, func) \
|
||||
do \
|
||||
{ \
|
||||
int ic; \
|
||||
ic = sc; \
|
||||
if (ic != -1 && kmap[(unsigned char)ic].type == ISFUNC) \
|
||||
kmap[(unsigned char)ic].function = func; \
|
||||
} \
|
||||
while (0)
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
if (get_tty_settings (tty, &ttybuff) == 0)
|
||||
{
|
||||
if (ttybuff.flags & SGTTY_SET)
|
||||
{
|
||||
SET_SPECIAL (ttybuff.sgttyb.sg_erase, rl_rubout);
|
||||
SET_SPECIAL (ttybuff.sgttyb.sg_kill, rl_unix_line_discard);
|
||||
}
|
||||
|
||||
# if defined (TIOCGLTC)
|
||||
if (ttybuff.flags & LTCHARS_SET)
|
||||
{
|
||||
SET_SPECIAL (ttybuff.ltchars.t_werasc, rl_unix_word_rubout);
|
||||
SET_SPECIAL (ttybuff.ltchars.t_lnextc, rl_quoted_insert);
|
||||
}
|
||||
# endif /* TIOCGLTC */
|
||||
}
|
||||
|
||||
#else /* !NEW_TTY_DRIVER */
|
||||
|
||||
#define SET_SPECIAL(sc, func) \
|
||||
do \
|
||||
{ \
|
||||
unsigned char uc; \
|
||||
uc = ttybuff.c_cc[sc]; \
|
||||
if (uc != (unsigned char)_POSIX_VDISABLE && kmap[uc].type == ISFUNC) \
|
||||
kmap[uc].function = func; \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
if (get_tty_settings (tty, &ttybuff) == 0)
|
||||
{
|
||||
SET_SPECIAL (VERASE, rl_rubout);
|
||||
SET_SPECIAL (VKILL, rl_unix_line_discard);
|
||||
|
||||
# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
|
||||
SET_SPECIAL (VLNEXT, rl_quoted_insert);
|
||||
# endif /* VLNEXT && TERMIOS_TTY_DRIVER */
|
||||
|
||||
# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
|
||||
SET_SPECIAL (VWERASE, rl_unix_word_rubout);
|
||||
# endif /* VWERASE && TERMIOS_TTY_DRIVER */
|
||||
}
|
||||
#endif /* !NEW_TTY_DRIVER */
|
||||
_rl_bind_tty_special_chars (kmap, ttybuff);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* New public way to set the system default editing chars to their readline
|
||||
|
@ -851,9 +951,33 @@ rl_tty_set_default_bindings (kmap)
|
|||
rltty_set_default_bindings (kmap);
|
||||
}
|
||||
|
||||
/* Rebind all of the tty special chars that readline worries about back
|
||||
to self-insert. Call this before saving the current terminal special
|
||||
chars with save_tty_chars(). This only works on POSIX termios or termio
|
||||
systems. */
|
||||
void
|
||||
rl_tty_unset_default_bindings (kmap)
|
||||
Keymap kmap;
|
||||
{
|
||||
/* Don't bother before we've saved the tty special chars at least once. */
|
||||
if (RL_ISSTATE(RL_STATE_TTYCSAVED) == 0)
|
||||
return;
|
||||
|
||||
RESET_SPECIAL (_rl_tty_chars.t_erase);
|
||||
RESET_SPECIAL (_rl_tty_chars.t_kill);
|
||||
|
||||
# if defined (VLNEXT) && defined (TERMIOS_TTY_DRIVER)
|
||||
RESET_SPECIAL (_rl_tty_chars.t_lnext);
|
||||
# endif /* VLNEXT && TERMIOS_TTY_DRIVER */
|
||||
|
||||
# if defined (VWERASE) && defined (TERMIOS_TTY_DRIVER)
|
||||
RESET_SPECIAL (_rl_tty_chars.t_werase);
|
||||
# endif /* VWERASE && TERMIOS_TTY_DRIVER */
|
||||
}
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
#if defined (NEW_TTY_DRIVER) || defined (NO_TTY_DRIVER)
|
||||
int
|
||||
_rl_disable_tty_signals ()
|
||||
{
|
||||
|
|
|
@ -61,22 +61,22 @@
|
|||
#endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
|
||||
|
||||
typedef struct _rl_tty_chars {
|
||||
char t_eof;
|
||||
char t_eol;
|
||||
char t_eol2;
|
||||
char t_erase;
|
||||
char t_werase;
|
||||
char t_kill;
|
||||
char t_reprint;
|
||||
char t_intr;
|
||||
char t_quit;
|
||||
char t_susp;
|
||||
char t_dsusp;
|
||||
char t_start;
|
||||
char t_stop;
|
||||
char t_lnext;
|
||||
char t_flush;
|
||||
char t_status;
|
||||
unsigned char t_eof;
|
||||
unsigned char t_eol;
|
||||
unsigned char t_eol2;
|
||||
unsigned char t_erase;
|
||||
unsigned char t_werase;
|
||||
unsigned char t_kill;
|
||||
unsigned char t_reprint;
|
||||
unsigned char t_intr;
|
||||
unsigned char t_quit;
|
||||
unsigned char t_susp;
|
||||
unsigned char t_dsusp;
|
||||
unsigned char t_start;
|
||||
unsigned char t_stop;
|
||||
unsigned char t_lnext;
|
||||
unsigned char t_flush;
|
||||
unsigned char t_status;
|
||||
} _RL_TTY_CHARS;
|
||||
|
||||
#endif /* _RLTTY_H_ */
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* rltypedefs.h -- Type declarations for readline functions. */
|
||||
|
||||
/* Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 2000-2004 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.
|
||||
|
@ -79,6 +79,12 @@ 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 **));
|
||||
|
||||
typedef char *rl_cpvfunc_t PARAMS((void));
|
||||
typedef char *rl_cpifunc_t PARAMS((int));
|
||||
typedef char *rl_cpcpfunc_t PARAMS((char *));
|
||||
typedef char *rl_cpcppfunc_t PARAMS((char **));
|
||||
|
||||
#endif /* _RL_FUNCTION_TYPEDEF */
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* savestring.c */
|
||||
|
||||
/* Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1998,2003 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.
|
||||
|
@ -19,6 +19,7 @@
|
|||
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
|
||||
|
||||
#include <config.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* search.c - code for non-incremental searching in emacs and vi modes. */
|
||||
|
||||
/* Copyright (C) 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1992-2005 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the Readline Library (the Library), a set of
|
||||
routines for providing Emacs style line input to programs that ask
|
||||
|
@ -53,6 +53,8 @@
|
|||
#endif
|
||||
#define abs(x) (((x) >= 0) ? (x) : -(x))
|
||||
|
||||
_rl_search_cxt *_rl_nscxt = 0;
|
||||
|
||||
extern HIST_ENTRY *_rl_saved_line_for_history;
|
||||
|
||||
/* Functions imported from the rest of the library. */
|
||||
|
@ -68,13 +70,19 @@ static int rl_history_search_pos;
|
|||
static char *history_search_string;
|
||||
static int history_string_size;
|
||||
|
||||
static UNDO_LIST *noninc_saved_undo_list;
|
||||
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 noninc_dosearch PARAMS((char *, int));
|
||||
static int noninc_search PARAMS((int, int));
|
||||
static int rl_history_search_internal PARAMS((int, int));
|
||||
static void rl_history_search_reinit PARAMS((void));
|
||||
|
||||
static _rl_search_cxt *_rl_nsearch_init PARAMS((int, int));
|
||||
static int _rl_nsearch_cleanup PARAMS((_rl_search_cxt *, int));
|
||||
static void _rl_nsearch_abort PARAMS((_rl_search_cxt *));
|
||||
static int _rl_nsearch_dispatch PARAMS((_rl_search_cxt *, int));
|
||||
|
||||
/* 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. */
|
||||
|
@ -82,8 +90,16 @@ static void
|
|||
make_history_line_current (entry)
|
||||
HIST_ENTRY *entry;
|
||||
{
|
||||
rl_replace_line (entry->line, 0);
|
||||
rl_undo_list = (UNDO_LIST *)entry->data;
|
||||
_rl_replace_text (entry->line, 0, rl_end);
|
||||
_rl_fix_point (1);
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode)
|
||||
/* POSIX.2 says that the `U' command doesn't affect the copy of any
|
||||
command lines to the edit line. We're going to implement that by
|
||||
making the undo list start after the matching line is copied to the
|
||||
current editing buffer. */
|
||||
rl_free_undo_list ();
|
||||
#endif
|
||||
|
||||
if (_rl_saved_line_for_history)
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
|
@ -125,8 +141,8 @@ noninc_search_from_pos (string, pos, dir)
|
|||
|
||||
/* Search for a line in the history containing STRING. If DIR is < 0, the
|
||||
search is backwards through previous entries, else through subsequent
|
||||
entries. */
|
||||
static void
|
||||
entries. Returns 1 if the search was successful, 0 otherwise. */
|
||||
static int
|
||||
noninc_dosearch (string, dir)
|
||||
char *string;
|
||||
int dir;
|
||||
|
@ -137,7 +153,7 @@ noninc_dosearch (string, dir)
|
|||
if (string == 0 || *string == '\0' || noninc_history_pos < 0)
|
||||
{
|
||||
rl_ding ();
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir);
|
||||
|
@ -148,7 +164,7 @@ noninc_dosearch (string, dir)
|
|||
rl_clear_message ();
|
||||
rl_point = 0;
|
||||
rl_ding ();
|
||||
return;
|
||||
return 0;
|
||||
}
|
||||
|
||||
noninc_history_pos = pos;
|
||||
|
@ -159,7 +175,7 @@ noninc_dosearch (string, dir)
|
|||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode != vi_mode)
|
||||
#endif
|
||||
history_set_pos (oldpos);
|
||||
history_set_pos (oldpos);
|
||||
|
||||
make_history_line_current (entry);
|
||||
|
||||
|
@ -167,27 +183,29 @@ noninc_dosearch (string, dir)
|
|||
rl_mark = rl_end;
|
||||
|
||||
rl_clear_message ();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Search non-interactively through the history list. DIR < 0 means to
|
||||
search backwards through the history of previous commands; otherwise
|
||||
the search is for commands subsequent to the current position in the
|
||||
history list. PCHAR is the character to use for prompting when reading
|
||||
the search string; if not specified (0), it defaults to `:'. */
|
||||
static void
|
||||
noninc_search (dir, pchar)
|
||||
int dir;
|
||||
int pchar;
|
||||
static _rl_search_cxt *
|
||||
_rl_nsearch_init (dir, pchar)
|
||||
int dir, pchar;
|
||||
{
|
||||
int saved_point, saved_mark, c;
|
||||
_rl_search_cxt *cxt;
|
||||
char *p;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
char mb[MB_LEN_MAX];
|
||||
#endif
|
||||
|
||||
cxt = _rl_scxt_alloc (RL_SEARCH_NSEARCH, 0);
|
||||
if (dir < 0)
|
||||
cxt->sflags |= SF_REVERSE; /* not strictly needed */
|
||||
|
||||
cxt->direction = dir;
|
||||
cxt->history_pos = cxt->save_line;
|
||||
|
||||
rl_maybe_save_line ();
|
||||
saved_point = rl_point;
|
||||
saved_mark = rl_mark;
|
||||
|
||||
/* Clear the undo list, since reading the search string should create its
|
||||
own undo list, and the whole list will end up being freed when we
|
||||
finish reading the search string. */
|
||||
rl_undo_list = 0;
|
||||
|
||||
/* Use the line buffer to read the search string. */
|
||||
rl_line_buffer[0] = 0;
|
||||
|
@ -197,99 +215,169 @@ noninc_search (dir, pchar)
|
|||
rl_message (p, 0, 0);
|
||||
free (p);
|
||||
|
||||
#define SEARCH_RETURN rl_restore_prompt (); RL_UNSETSTATE(RL_STATE_NSEARCH); return
|
||||
|
||||
RL_SETSTATE(RL_STATE_NSEARCH);
|
||||
/* Read the search string. */
|
||||
while (1)
|
||||
{
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
_rl_nscxt = cxt;
|
||||
|
||||
return cxt;
|
||||
}
|
||||
|
||||
static int
|
||||
_rl_nsearch_cleanup (cxt, r)
|
||||
_rl_search_cxt *cxt;
|
||||
int r;
|
||||
{
|
||||
_rl_scxt_dispose (cxt, 0);
|
||||
_rl_nscxt = 0;
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_NSEARCH);
|
||||
|
||||
return (r != 1);
|
||||
}
|
||||
|
||||
static void
|
||||
_rl_nsearch_abort (cxt)
|
||||
_rl_search_cxt *cxt;
|
||||
{
|
||||
rl_maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = cxt->save_point;
|
||||
rl_mark = cxt->save_mark;
|
||||
rl_restore_prompt ();
|
||||
|
||||
RL_UNSETSTATE (RL_STATE_NSEARCH);
|
||||
}
|
||||
|
||||
/* Process just-read character C according to search context CXT. Return -1
|
||||
if the caller should abort the search, 0 if we should break out of the
|
||||
loop, and 1 if we should continue to read characters. */
|
||||
static int
|
||||
_rl_nsearch_dispatch (cxt, c)
|
||||
_rl_search_cxt *cxt;
|
||||
int c;
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case CTRL('W'):
|
||||
rl_unix_word_rubout (1, c);
|
||||
break;
|
||||
|
||||
case CTRL('U'):
|
||||
rl_unix_line_discard (1, c);
|
||||
break;
|
||||
|
||||
case RETURN:
|
||||
case NEWLINE:
|
||||
return 0;
|
||||
|
||||
case CTRL('H'):
|
||||
case RUBOUT:
|
||||
if (rl_point == 0)
|
||||
{
|
||||
_rl_nsearch_abort (cxt);
|
||||
return -1;
|
||||
}
|
||||
_rl_rubout_char (1, c);
|
||||
break;
|
||||
|
||||
case CTRL('C'):
|
||||
case CTRL('G'):
|
||||
rl_ding ();
|
||||
_rl_nsearch_abort (cxt);
|
||||
return -1;
|
||||
|
||||
default:
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
|
||||
c = _rl_read_mbstring (c, mb, MB_LEN_MAX);
|
||||
rl_insert_text (cxt->mb);
|
||||
else
|
||||
#endif
|
||||
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
switch (c)
|
||||
{
|
||||
case CTRL('H'):
|
||||
case RUBOUT:
|
||||
if (rl_point == 0)
|
||||
{
|
||||
rl_maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = saved_point;
|
||||
rl_mark = saved_mark;
|
||||
SEARCH_RETURN;
|
||||
}
|
||||
_rl_rubout_char (1, c);
|
||||
break;
|
||||
|
||||
case CTRL('W'):
|
||||
rl_unix_word_rubout (1, c);
|
||||
break;
|
||||
|
||||
case CTRL('U'):
|
||||
rl_unix_line_discard (1, c);
|
||||
break;
|
||||
|
||||
case RETURN:
|
||||
case NEWLINE:
|
||||
goto dosearch;
|
||||
/* NOTREACHED */
|
||||
break;
|
||||
|
||||
case CTRL('C'):
|
||||
case CTRL('G'):
|
||||
rl_maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = saved_point;
|
||||
rl_mark = saved_mark;
|
||||
rl_ding ();
|
||||
SEARCH_RETURN;
|
||||
|
||||
default:
|
||||
#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) ();
|
||||
_rl_insert_char (1, c);
|
||||
break;
|
||||
}
|
||||
|
||||
dosearch:
|
||||
rl_mark = saved_mark;
|
||||
(*rl_redisplay_function) ();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Perform one search according to CXT, using NONINC_SEARCH_STRING. Return
|
||||
-1 if the search should be aborted, any other value means to clean up
|
||||
using _rl_nsearch_cleanup (). Returns 1 if the search was successful,
|
||||
0 otherwise. */
|
||||
static int
|
||||
_rl_nsearch_dosearch (cxt)
|
||||
_rl_search_cxt *cxt;
|
||||
{
|
||||
rl_mark = cxt->save_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. */
|
||||
if (rl_point == 0)
|
||||
{
|
||||
if (!noninc_search_string)
|
||||
if (noninc_search_string == 0)
|
||||
{
|
||||
rl_ding ();
|
||||
SEARCH_RETURN;
|
||||
rl_restore_prompt ();
|
||||
RL_UNSETSTATE (RL_STATE_NSEARCH);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We want to start the search from the current history position. */
|
||||
noninc_history_pos = where_history ();
|
||||
noninc_history_pos = cxt->save_line;
|
||||
FREE (noninc_search_string);
|
||||
noninc_search_string = savestring (rl_line_buffer);
|
||||
|
||||
/* If we don't want the subsequent undo list generated by the search
|
||||
matching a history line to include the contents of the search string,
|
||||
we need to clear rl_line_buffer here. For now, we just clear the
|
||||
undo list generated by reading the search string. (If the search
|
||||
fails, the old undo list will be restored by rl_maybe_unsave_line.) */
|
||||
rl_free_undo_list ();
|
||||
}
|
||||
|
||||
rl_restore_prompt ();
|
||||
noninc_dosearch (noninc_search_string, dir);
|
||||
RL_UNSETSTATE(RL_STATE_NSEARCH);
|
||||
return (noninc_dosearch (noninc_search_string, cxt->direction));
|
||||
}
|
||||
|
||||
/* Search non-interactively through the history list. DIR < 0 means to
|
||||
search backwards through the history of previous commands; otherwise
|
||||
the search is for commands subsequent to the current position in the
|
||||
history list. PCHAR is the character to use for prompting when reading
|
||||
the search string; if not specified (0), it defaults to `:'. */
|
||||
static int
|
||||
noninc_search (dir, pchar)
|
||||
int dir;
|
||||
int pchar;
|
||||
{
|
||||
_rl_search_cxt *cxt;
|
||||
int c, r;
|
||||
|
||||
cxt = _rl_nsearch_init (dir, pchar);
|
||||
|
||||
if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
return (0);
|
||||
|
||||
/* Read the search string. */
|
||||
r = 0;
|
||||
while (1)
|
||||
{
|
||||
c = _rl_search_getchar (cxt);
|
||||
|
||||
if (c == 0)
|
||||
break;
|
||||
|
||||
r = _rl_nsearch_dispatch (cxt, c);
|
||||
if (r < 0)
|
||||
return 1;
|
||||
else if (r == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
r = _rl_nsearch_dosearch (cxt);
|
||||
return ((r >= 0) ? _rl_nsearch_cleanup (cxt, r) : (r != 1));
|
||||
}
|
||||
|
||||
/* Search forward through the history list for a string. If the vi-mode
|
||||
|
@ -298,8 +386,7 @@ int
|
|||
rl_noninc_forward_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
noninc_search (1, (key == '?') ? '?' : 0);
|
||||
return 0;
|
||||
return noninc_search (1, (key == '?') ? '?' : 0);
|
||||
}
|
||||
|
||||
/* Reverse search the history list for a string. If the vi-mode code
|
||||
|
@ -308,8 +395,7 @@ int
|
|||
rl_noninc_reverse_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
noninc_search (-1, (key == '/') ? '/' : 0);
|
||||
return 0;
|
||||
return noninc_search (-1, (key == '/') ? '/' : 0);
|
||||
}
|
||||
|
||||
/* Search forward through the history list for the last string searched
|
||||
|
@ -318,13 +404,15 @@ int
|
|||
rl_noninc_forward_search_again (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
rl_ding ();
|
||||
return (-1);
|
||||
}
|
||||
noninc_dosearch (noninc_search_string, 1);
|
||||
return 0;
|
||||
r = noninc_dosearch (noninc_search_string, 1);
|
||||
return (r != 1);
|
||||
}
|
||||
|
||||
/* Reverse search in the history list for the last string searched
|
||||
|
@ -333,15 +421,34 @@ int
|
|||
rl_noninc_reverse_search_again (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
rl_ding ();
|
||||
return (-1);
|
||||
}
|
||||
noninc_dosearch (noninc_search_string, -1);
|
||||
return 0;
|
||||
r = noninc_dosearch (noninc_search_string, -1);
|
||||
return (r != 1);
|
||||
}
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
int
|
||||
_rl_nsearch_callback (cxt)
|
||||
_rl_search_cxt *cxt;
|
||||
{
|
||||
int c, r;
|
||||
|
||||
c = _rl_search_getchar (cxt);
|
||||
r = _rl_nsearch_dispatch (cxt, c);
|
||||
if (r != 0)
|
||||
return 1;
|
||||
|
||||
r = _rl_nsearch_dosearch (cxt);
|
||||
return ((r >= 0) ? _rl_nsearch_cleanup (cxt, r) : (r != 1));
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
rl_history_search_internal (count, dir)
|
||||
int count, dir;
|
||||
|
|
|
@ -48,8 +48,12 @@
|
|||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_FCNTL_H)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#if defined (HAVE_PWD_H)
|
||||
#include <pwd.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -57,9 +61,9 @@
|
|||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#if !defined (HAVE_GETPW_DECLS)
|
||||
#if defined (HAVE_GETPWUID) && !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwuid PARAMS((uid_t));
|
||||
#endif /* !HAVE_GETPW_DECLS */
|
||||
#endif /* HAVE_GETPWUID && !HAVE_GETPW_DECLS */
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
|
@ -122,23 +126,27 @@ sh_set_lines_and_columns (lines, cols)
|
|||
{
|
||||
char *b;
|
||||
|
||||
#if defined (HAVE_PUTENV)
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
|
||||
sprintf (b, "LINES=%d", lines);
|
||||
putenv (b);
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1);
|
||||
sprintf (b, "COLUMNS=%d", cols);
|
||||
putenv (b);
|
||||
#else /* !HAVE_PUTENV */
|
||||
# if defined (HAVE_SETENV)
|
||||
#if defined (HAVE_SETENV)
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
|
||||
sprintf (b, "%d", lines);
|
||||
setenv ("LINES", b, 1);
|
||||
free (b);
|
||||
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + 1);
|
||||
sprintf (b, "%d", cols);
|
||||
setenv ("COLUMNS", b, 1);
|
||||
# endif /* HAVE_SETENV */
|
||||
#endif /* !HAVE_PUTENV */
|
||||
free (b);
|
||||
#else /* !HAVE_SETENV */
|
||||
# if defined (HAVE_PUTENV)
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("LINES=") + 1);
|
||||
sprintf (b, "LINES=%d", lines);
|
||||
putenv (b);
|
||||
|
||||
b = (char *)xmalloc (INT_STRLEN_BOUND (int) + sizeof ("COLUMNS=") + 1);
|
||||
sprintf (b, "COLUMNS=%d", cols);
|
||||
putenv (b);
|
||||
# endif /* HAVE_PUTENV */
|
||||
#endif /* !HAVE_SETENV */
|
||||
}
|
||||
|
||||
char *
|
||||
|
@ -155,9 +163,11 @@ sh_get_home_dir ()
|
|||
struct passwd *entry;
|
||||
|
||||
home_dir = (char *)NULL;
|
||||
#if defined (HAVE_GETPWUID)
|
||||
entry = getpwuid (getuid ());
|
||||
if (entry)
|
||||
home_dir = entry->pw_dir;
|
||||
#endif
|
||||
return (home_dir);
|
||||
}
|
||||
|
||||
|
@ -171,6 +181,7 @@ int
|
|||
sh_unset_nodelay_mode (fd)
|
||||
int fd;
|
||||
{
|
||||
#if defined (HAVE_FCNTL)
|
||||
int flags, bflags;
|
||||
|
||||
if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
|
||||
|
@ -191,6 +202,7 @@ sh_unset_nodelay_mode (fd)
|
|||
flags &= ~bflags;
|
||||
return (fcntl (fd, F_SETFL, flags));
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
## -*- text -*- ##
|
||||
# Makefile for the GNU readline library shared library support.
|
||||
#
|
||||
# Copyright (C) 1998 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1998-2003 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
|
||||
|
@ -17,6 +17,14 @@
|
|||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA.
|
||||
|
||||
PACKAGE = @PACKAGE_NAME@
|
||||
VERSION = @PACKAGE_VERSION@
|
||||
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
|
||||
RL_LIBRARY_VERSION = @LIBVERSION@
|
||||
RL_LIBRARY_NAME = readline
|
||||
|
||||
|
@ -45,7 +53,10 @@ host_os = @host_os@
|
|||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
includedir = @includedir@
|
||||
bindir = @bindir@
|
||||
libdir = @libdir@
|
||||
datadir = @datadir@
|
||||
localedir = $(datadir)/locale
|
||||
|
||||
# Support an alternate destination root directory for package building
|
||||
DESTDIR =
|
||||
|
@ -55,7 +66,7 @@ LOCAL_CFLAGS = @LOCAL_CFLAGS@ -DRL_LIBRARY_VERSION='"$(RL_LIBRARY_VERSION)"'
|
|||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@ @LOCAL_LDFLAGS@ @CFLAGS@
|
||||
|
||||
DEFS = @DEFS@
|
||||
DEFS = @DEFS@ @CROSS_COMPILE@
|
||||
LOCAL_DEFS = @LOCAL_DEFS@
|
||||
|
||||
#
|
||||
|
@ -72,14 +83,20 @@ SHOBJ_LDFLAGS = @SHOBJ_LDFLAGS@
|
|||
SHOBJ_XLDFLAGS = @SHOBJ_XLDFLAGS@
|
||||
SHOBJ_LIBS = @SHOBJ_LIBS@
|
||||
|
||||
SHLIB_XLDFLAGS = @SHLIB_XLDFLAGS@
|
||||
SHLIB_XLDFLAGS = @LDFLAGS@ @SHLIB_XLDFLAGS@
|
||||
SHLIB_LIBS = @SHLIB_LIBS@
|
||||
|
||||
SHLIB_DOT = @SHLIB_DOT@
|
||||
SHLIB_LIBPREF = @SHLIB_LIBPREF@
|
||||
SHLIB_LIBSUFF = @SHLIB_LIBSUFF@
|
||||
|
||||
SHLIB_LIBVERSION = @SHLIB_LIBVERSION@
|
||||
SHLIB_DLLVERSION = @SHLIB_DLLVERSION@
|
||||
|
||||
SHLIB_STATUS = @SHLIB_STATUS@
|
||||
|
||||
TERMCAP_LIB = @TERMCAP_LIB@
|
||||
|
||||
# shared library versioning
|
||||
SHLIB_MAJOR= @SHLIB_MAJOR@
|
||||
# shared library systems like SVR4's do not use minor versions
|
||||
|
@ -99,8 +116,8 @@ CCFLAGS = $(DEFS) $(LOCAL_DEFS) $(CPPFLAGS) $(INCLUDES) $(LOCAL_CFLAGS) $(CFLAGS
|
|||
|
||||
# The name of the main library target.
|
||||
|
||||
SHARED_READLINE = libreadline.$(SHLIB_LIBVERSION)
|
||||
SHARED_HISTORY = libhistory.$(SHLIB_LIBVERSION)
|
||||
SHARED_READLINE = $(SHLIB_LIBPREF)readline$(SHLIB_DOT)$(SHLIB_LIBVERSION)
|
||||
SHARED_HISTORY = $(SHLIB_LIBPREF)history$(SHLIB_DOT)$(SHLIB_LIBVERSION)
|
||||
SHARED_LIBS = $(SHARED_READLINE) $(SHARED_HISTORY)
|
||||
|
||||
# The C code source files for this library.
|
||||
|
@ -164,13 +181,13 @@ installdirs: $(topdir)/support/mkdirs
|
|||
-$(SHELL) $(topdir)/support/mkdirs $(DESTDIR)$(libdir)
|
||||
|
||||
install: installdirs $(SHLIB_STATUS)
|
||||
$(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)
|
||||
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -i "$(INSTALL_DATA)" $(SHARED_HISTORY)
|
||||
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -i "$(INSTALL_DATA)" $(SHARED_READLINE)
|
||||
@echo install: you may need to run ldconfig
|
||||
|
||||
uninstall:
|
||||
$(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)
|
||||
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -U $(SHARED_HISTORY)
|
||||
$(SHELL) $(topdir)/support/shlib-install -O $(host_os) -d $(DESTDIR)$(libdir) -b $(DESTDIR)$(bindir) -U $(SHARED_READLINE)
|
||||
@echo uninstall: you may need to run ldconfig
|
||||
|
||||
clean mostlyclean: force
|
||||
|
@ -390,7 +407,7 @@ 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
|
||||
text.so: $(topdir)/text.c
|
||||
tilde.so: $(topdir)/tilde.c
|
||||
undo.so: $(topdir)/undo.c
|
||||
util.so: $(topdir)/util.c
|
||||
|
@ -424,7 +441,7 @@ search.so: search.c
|
|||
signals.so: signals.c
|
||||
shell.so: shell.c
|
||||
terminal.so: terminal.c
|
||||
text.so: terminal.c
|
||||
text.so: text.c
|
||||
tilde.so: tilde.c
|
||||
undo.so: undo.c
|
||||
util.so: util.c
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* signals.c -- signal handling support for readline. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1987-2005 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.
|
||||
|
@ -73,6 +73,10 @@ typedef struct { SigHandler *sa_handler; int sa_mask, sa_flags; } sighandler_cxt
|
|||
# define sigemptyset(m)
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
#ifndef SA_RESTART
|
||||
# define SA_RESTART 0
|
||||
#endif
|
||||
|
||||
static SigHandler *rl_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
|
||||
static void rl_maybe_set_sighandler PARAMS((int, SigHandler *, sighandler_cxt *));
|
||||
|
||||
|
@ -85,6 +89,8 @@ int rl_catch_signals = 1;
|
|||
/* If non-zero, readline will install a signal handler for SIGWINCH. */
|
||||
#ifdef SIGWINCH
|
||||
int rl_catch_sigwinch = 1;
|
||||
#else
|
||||
int rl_catch_sigwinch = 0; /* for the readline state struct in readline.c */
|
||||
#endif
|
||||
|
||||
static int signals_set_flag;
|
||||
|
@ -125,7 +131,11 @@ rl_signal_handler (sig)
|
|||
#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. */
|
||||
# if defined (SIGALRM)
|
||||
if (sig == SIGINT || sig == SIGALRM)
|
||||
# else
|
||||
if (sig == SIGINT)
|
||||
# endif
|
||||
rl_set_sighandler (sig, SIG_IGN, &dummy_cxt);
|
||||
#endif /* !HAVE_BSD_SIGNALS && !HAVE_POSIX_SIGNALS */
|
||||
|
||||
|
@ -135,14 +145,18 @@ rl_signal_handler (sig)
|
|||
rl_free_line_state ();
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case SIGTERM:
|
||||
#if defined (SIGTSTP)
|
||||
case SIGTSTP:
|
||||
case SIGTTOU:
|
||||
case SIGTTIN:
|
||||
#endif /* SIGTSTP */
|
||||
#if defined (SIGALRM)
|
||||
case SIGALRM:
|
||||
case SIGTERM:
|
||||
#endif
|
||||
#if defined (SIGQUIT)
|
||||
case SIGQUIT:
|
||||
#endif
|
||||
rl_cleanup_after_signal ();
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
|
@ -158,7 +172,11 @@ rl_signal_handler (sig)
|
|||
signal (sig, SIG_ACK);
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_KILL)
|
||||
kill (getpid (), sig);
|
||||
#else
|
||||
raise (sig); /* assume we have raise */
|
||||
#endif
|
||||
|
||||
/* Let the signal that we just sent through. */
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
|
@ -233,7 +251,7 @@ rl_set_sighandler (sig, handler, ohandler)
|
|||
struct sigaction act;
|
||||
|
||||
act.sa_handler = handler;
|
||||
act.sa_flags = 0; /* XXX - should we set SA_RESTART for SIGWINCH? */
|
||||
act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0;
|
||||
sigemptyset (&act.sa_mask);
|
||||
sigemptyset (&ohandler->sa_mask);
|
||||
sigaction (sig, &act, &old_handler);
|
||||
|
@ -275,8 +293,11 @@ rl_set_signals ()
|
|||
{
|
||||
rl_maybe_set_sighandler (SIGINT, rl_signal_handler, &old_int);
|
||||
rl_maybe_set_sighandler (SIGTERM, rl_signal_handler, &old_term);
|
||||
#if defined (SIGQUIT)
|
||||
rl_maybe_set_sighandler (SIGQUIT, rl_signal_handler, &old_quit);
|
||||
#endif
|
||||
|
||||
#if defined (SIGALRM)
|
||||
oh = rl_set_sighandler (SIGALRM, rl_signal_handler, &old_alrm);
|
||||
if (oh == (SigHandler *)SIG_IGN)
|
||||
rl_sigaction (SIGALRM, &old_alrm, &dummy);
|
||||
|
@ -288,6 +309,7 @@ rl_set_signals ()
|
|||
if (oh != (SigHandler *)SIG_DFL && (old_alrm.sa_flags & SA_RESTART))
|
||||
rl_sigaction (SIGALRM, &old_alrm, &dummy);
|
||||
#endif /* HAVE_POSIX_SIGNALS */
|
||||
#endif /* SIGALRM */
|
||||
|
||||
#if defined (SIGTSTP)
|
||||
rl_maybe_set_sighandler (SIGTSTP, rl_signal_handler, &old_tstp);
|
||||
|
@ -326,8 +348,12 @@ rl_clear_signals ()
|
|||
|
||||
rl_sigaction (SIGINT, &old_int, &dummy);
|
||||
rl_sigaction (SIGTERM, &old_term, &dummy);
|
||||
#if defined (SIGQUIT)
|
||||
rl_sigaction (SIGQUIT, &old_quit, &dummy);
|
||||
#endif
|
||||
#if defined (SIGALRM)
|
||||
rl_sigaction (SIGALRM, &old_alrm, &dummy);
|
||||
#endif
|
||||
|
||||
#if defined (SIGTSTP)
|
||||
rl_sigaction (SIGTSTP, &old_tstp, &dummy);
|
||||
|
@ -362,7 +388,8 @@ void
|
|||
rl_cleanup_after_signal ()
|
||||
{
|
||||
_rl_clean_up_for_exit ();
|
||||
(*rl_deprep_term_function) ();
|
||||
if (rl_deprep_term_function)
|
||||
(*rl_deprep_term_function) ();
|
||||
rl_clear_signals ();
|
||||
rl_clear_pending_input ();
|
||||
}
|
||||
|
@ -371,7 +398,8 @@ rl_cleanup_after_signal ()
|
|||
void
|
||||
rl_reset_after_signal ()
|
||||
{
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
if (rl_prep_term_function)
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
rl_set_signals ();
|
||||
}
|
||||
|
||||
|
@ -392,7 +420,7 @@ rl_free_line_state ()
|
|||
|
||||
_rl_kill_kbd_macro ();
|
||||
rl_clear_message ();
|
||||
_rl_init_argument ();
|
||||
_rl_reset_argument ();
|
||||
}
|
||||
|
||||
#endif /* HANDLE_SIGNALS */
|
||||
|
|
270
readline/support/config.guess
vendored
270
readline/support/config.guess
vendored
|
@ -3,7 +3,7 @@
|
|||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2002-03-20'
|
||||
timestamp='2002-11-30'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
|
@ -88,40 +88,47 @@ if test $# != 0; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
trap 'exit 1' 1 2 15
|
||||
|
||||
dummy=dummy-$$
|
||||
trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
|
||||
# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
|
||||
# compiler to aid in system detection is discouraged as it requires
|
||||
# temporary files to be created and, as you can see below, it is a
|
||||
# headache to deal with in a portable fashion.
|
||||
|
||||
# CC_FOR_BUILD -- compiler used by this script.
|
||||
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
|
||||
# use `HOST_CC' if defined, but it is deprecated.
|
||||
|
||||
set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
|
||||
,,) echo "int dummy(){}" > $dummy.c ;
|
||||
# This shell variable is my proudest work .. or something. --bje
|
||||
|
||||
set_cc_for_build='tmpdir=${TMPDIR-/tmp}/config-guess-$$ ;
|
||||
(old=`umask` && umask 077 && mkdir $tmpdir && umask $old && unset old)
|
||||
|| (echo "$me: cannot create $tmpdir" >&2 && exit 1) ;
|
||||
dummy=$tmpdir/dummy ;
|
||||
files="$dummy.c $dummy.o $dummy.rel $dummy" ;
|
||||
trap '"'"'rm -f $files; rmdir $tmpdir; exit 1'"'"' 1 2 15 ;
|
||||
case $CC_FOR_BUILD,$HOST_CC,$CC in
|
||||
,,) echo "int x;" > $dummy.c ;
|
||||
for c in cc gcc c89 c99 ; do
|
||||
($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
|
||||
if test $? = 0 ; then
|
||||
if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
|
||||
CC_FOR_BUILD="$c"; break ;
|
||||
fi ;
|
||||
done ;
|
||||
rm -f $dummy.c $dummy.o $dummy.rel ;
|
||||
rm -f $files ;
|
||||
if test x"$CC_FOR_BUILD" = x ; then
|
||||
CC_FOR_BUILD=no_compiler_found ;
|
||||
fi
|
||||
;;
|
||||
,,*) CC_FOR_BUILD=$CC ;;
|
||||
,*,*) CC_FOR_BUILD=$HOST_CC ;;
|
||||
esac'
|
||||
esac ;
|
||||
unset files'
|
||||
|
||||
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
|
||||
# (ghazi@noc.rutgers.edu 1994-08-24)
|
||||
if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
|
||||
PATH=$PATH:/.attbin ; export PATH
|
||||
elif (test -f /usr/5bin/uname) >/dev/null 2>&1 ; then # bash
|
||||
PATH=$PATH:/usr/5bin
|
||||
fi
|
||||
|
||||
UNAME=`(uname) 2>/dev/null` || UNAME=unknown # bash
|
||||
UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
|
||||
UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
|
||||
UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
|
||||
|
@ -130,61 +137,6 @@ UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
|
|||
# Note: order is significant - the case branches are not exclusive.
|
||||
|
||||
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
# NOTE -- begin cases added for bash (mostly legacy) -- NOTE
|
||||
mac68k:machten:*:*)
|
||||
echo mac68k-apple-machten${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
concurrent*:*:*:*)
|
||||
if test "`(/bin/universe) 2>/dev/null`" = att ; then
|
||||
echo concurrent-concurrent-sysv3
|
||||
else
|
||||
echo concurrent-concurrent-bsd
|
||||
fi
|
||||
exit 0 ;;
|
||||
ppc*:SunOS:5.*:*)
|
||||
echo ppc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
sparc:UNIX_SV:4.*:*)
|
||||
echo sparc-unknown-sysv${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mips:UNIX_SV:4.*:*)
|
||||
echo mips-mips-sysv${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mips:OSF*1:*:*)
|
||||
echo mips-mips-osf1
|
||||
exit 0 ;;
|
||||
mips:4.4BSD:*:*)
|
||||
echo mips-mips-bsd4.4
|
||||
exit 0 ;;
|
||||
MIS*:SMP_DC.OSx:*:dcosx) # not the same as below
|
||||
echo pyramid-pyramid-sysv4
|
||||
exit 0 ;;
|
||||
news*:NEWS*:*:*)
|
||||
echo mips-sony-newsos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*370:AIX:*:*)
|
||||
echo ibm370-ibm-aix${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
ksr1:OSF*1:*:*)
|
||||
echo ksr1-ksr-osf1
|
||||
exit 0 ;;
|
||||
esa:OSF*1:*:* | ESA:OSF*:*:*)
|
||||
echo esa-ibm-osf1
|
||||
exit 0 ;;
|
||||
DNP*:DNIX:*:*)
|
||||
echo m68k-dnix-sysv
|
||||
exit 0 ;;
|
||||
*3b2*:*:*:*)
|
||||
echo we32k-att-sysv3
|
||||
exit 0 ;;
|
||||
Alpha*:Windows_NT:*:SP*)
|
||||
echo alpha-pc-opennt
|
||||
exit 0 ;;
|
||||
*:Windows_NT:*:SP*)
|
||||
echo i386-pc-opennt
|
||||
exit 0 ;;
|
||||
|
||||
# NOTE -- end legacy cases added for bash -- NOTE
|
||||
*:NetBSD:*:*)
|
||||
# NetBSD (nbsd) targets should (where applicable) match one or
|
||||
# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
|
||||
|
@ -200,6 +152,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
|||
UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
|
||||
/usr/sbin/$sysctl 2>/dev/null || echo unknown)`
|
||||
case "${UNAME_MACHINE_ARCH}" in
|
||||
armeb) machine=armeb-unknown ;;
|
||||
arm*) machine=arm-unknown ;;
|
||||
sh3el) machine=shl-unknown ;;
|
||||
sh3eb) machine=sh-unknown ;;
|
||||
|
@ -225,7 +178,18 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
|||
;;
|
||||
esac
|
||||
# The OS release
|
||||
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
# Debian GNU/NetBSD machines have a different userland, and
|
||||
# thus, need a distinct triplet. However, they do not need
|
||||
# kernel version information, so it can be replaced with a
|
||||
# suitable tag, in the style of linux-gnu.
|
||||
case "${UNAME_VERSION}" in
|
||||
Debian*)
|
||||
release='-gnu'
|
||||
;;
|
||||
*)
|
||||
release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
|
||||
;;
|
||||
esac
|
||||
# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
|
||||
# contains redundant information, the shorter form:
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
|
||||
|
@ -264,9 +228,6 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
|||
sun3:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
vax:OpenBSD:*:*) # bash
|
||||
echo vax-dec-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
wgrisc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
|
@ -281,6 +242,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
|||
# A Tn.n version is a released field test version.
|
||||
# A Xn.n version is an unreleased experimental baselevel.
|
||||
# 1.2 uses "1.2" for uname -r.
|
||||
eval $set_cc_for_build
|
||||
cat <<EOF >$dummy.s
|
||||
.data
|
||||
\$Lformat:
|
||||
|
@ -306,10 +268,9 @@ main:
|
|||
jsr \$26,exit
|
||||
.end main
|
||||
EOF
|
||||
eval $set_cc_for_build
|
||||
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
|
||||
$CC_FOR_BUILD -o $dummy $dummy.s 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
case `./$dummy` in
|
||||
case `$dummy` in
|
||||
0-0)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
|
@ -331,9 +292,12 @@ EOF
|
|||
2-1307)
|
||||
UNAME_MACHINE="alphaev68"
|
||||
;;
|
||||
3-1307)
|
||||
UNAME_MACHINE="alphaev7"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -f $dummy.s $dummy
|
||||
rm -f $dummy.s $dummy && rmdir $tmpdir
|
||||
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
||||
exit 0 ;;
|
||||
Alpha\ *:Windows_NT*:*)
|
||||
|
@ -374,6 +338,10 @@ EOF
|
|||
NILE*:*:*:dcosx)
|
||||
echo pyramid-pyramid-svr4
|
||||
exit 0 ;;
|
||||
DRS?6000:UNIX_SV:4.2*:7*)
|
||||
case `/usr/bin/uname -p` in
|
||||
sparc) echo sparc-icl-nx7 && exit 0 ;;
|
||||
esac ;;
|
||||
sun4H:SunOS:5.*:*)
|
||||
echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
|
@ -480,15 +448,21 @@ EOF
|
|||
exit (-1);
|
||||
}
|
||||
EOF
|
||||
$CC_FOR_BUILD $dummy.c -o $dummy \
|
||||
&& ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
|
||||
&& rm -f $dummy.c $dummy && exit 0
|
||||
rm -f $dummy.c $dummy
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c \
|
||||
&& $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
|
||||
&& rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
echo mips-mips-riscos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
Motorola:PowerMAX_OS:*:*)
|
||||
echo powerpc-motorola-powermax
|
||||
exit 0 ;;
|
||||
Motorola:*:4.3:PL8-*)
|
||||
echo powerpc-harris-powermax
|
||||
exit 0 ;;
|
||||
Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
|
||||
echo powerpc-harris-powermax
|
||||
exit 0 ;;
|
||||
Night_Hawk:Power_UNIX:*:*)
|
||||
echo powerpc-harris-powerunix
|
||||
exit 0 ;;
|
||||
|
@ -561,8 +535,8 @@ EOF
|
|||
exit(0);
|
||||
}
|
||||
EOF
|
||||
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
|
||||
rm -f $dummy.c $dummy
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
echo rs6000-ibm-aix3.2.5
|
||||
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
echo rs6000-ibm-aix3.2.4
|
||||
|
@ -660,9 +634,9 @@ EOF
|
|||
exit (0);
|
||||
}
|
||||
EOF
|
||||
(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy`
|
||||
(CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
|
||||
if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
|
||||
rm -f $dummy.c $dummy
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
fi ;;
|
||||
esac
|
||||
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
|
||||
|
@ -698,8 +672,8 @@ EOF
|
|||
exit (0);
|
||||
}
|
||||
EOF
|
||||
$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
|
||||
rm -f $dummy.c $dummy
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
echo unknown-hitachi-hiuxwe2
|
||||
exit 0 ;;
|
||||
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
|
||||
|
@ -781,8 +755,23 @@ EOF
|
|||
*:BSD/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
amd64:FreeBSD:*:*)
|
||||
echo x86_64-unknown-freebsd
|
||||
exit 0 ;;
|
||||
*:FreeBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
# Determine whether the default compiler uses glibc.
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#include <features.h>
|
||||
#if __GLIBC__ >= 2
|
||||
LIBC=gnu
|
||||
#else
|
||||
LIBC=
|
||||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
|
||||
rm -f $dummy.c && rmdir $tmpdir
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
|
||||
exit 0 ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-cygwin
|
||||
|
@ -794,13 +783,16 @@ EOF
|
|||
echo ${UNAME_MACHINE}-pc-pw32
|
||||
exit 0 ;;
|
||||
x86:Interix*:3*)
|
||||
echo i386-pc-interix3
|
||||
echo i586-pc-interix3
|
||||
exit 0 ;;
|
||||
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
|
||||
echo i${UNAME_MACHINE}-pc-mks
|
||||
exit 0 ;;
|
||||
i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
|
||||
# How do we know it's Interix rather than the generic POSIX subsystem?
|
||||
# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
|
||||
# UNAME_MACHINE based on the output of uname instead of i386?
|
||||
echo i386-pc-interix
|
||||
echo i586-pc-interix
|
||||
exit 0 ;;
|
||||
i*:UWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-uwin
|
||||
|
@ -843,8 +835,28 @@ EOF
|
|||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
|
||||
rm -f $dummy.c
|
||||
test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0
|
||||
rm -f $dummy.c && rmdir $tmpdir
|
||||
test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
|
||||
;;
|
||||
mips64:Linux:*:*)
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
#undef CPU
|
||||
#undef mips64
|
||||
#undef mips64el
|
||||
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
|
||||
CPU=mips64el
|
||||
#else
|
||||
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
|
||||
CPU=mips64
|
||||
#else
|
||||
CPU=
|
||||
#endif
|
||||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
|
||||
rm -f $dummy.c && rmdir $tmpdir
|
||||
test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
|
||||
;;
|
||||
ppc:Linux:*:*)
|
||||
echo powerpc-unknown-linux-gnu
|
||||
|
@ -906,7 +918,7 @@ EOF
|
|||
;;
|
||||
a.out-i386-linux)
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
|
||||
exit 0 ;;
|
||||
exit 0 ;;
|
||||
coff-i386)
|
||||
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
|
||||
exit 0 ;;
|
||||
|
@ -939,7 +951,7 @@ EOF
|
|||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
|
||||
rm -f $dummy.c
|
||||
rm -f $dummy.c && rmdir $tmpdir
|
||||
test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
|
||||
test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
|
||||
;;
|
||||
|
@ -957,6 +969,23 @@ EOF
|
|||
# Use sysv4.2uw... so that sysv4* matches it.
|
||||
echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
|
||||
exit 0 ;;
|
||||
i*86:OS/2:*:*)
|
||||
# If we were able to find `uname', then EMX Unix compatibility
|
||||
# is probably installed.
|
||||
echo ${UNAME_MACHINE}-pc-os2-emx
|
||||
exit 0 ;;
|
||||
i*86:XTS-300:*:STOP)
|
||||
echo ${UNAME_MACHINE}-unknown-stop
|
||||
exit 0 ;;
|
||||
i*86:atheos:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-atheos
|
||||
exit 0 ;;
|
||||
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
i*86:*DOS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-msdosdjgpp
|
||||
exit 0 ;;
|
||||
i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
|
||||
UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
|
||||
if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
|
||||
|
@ -978,22 +1007,19 @@ EOF
|
|||
UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
|
||||
echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
|
||||
elif /bin/uname -X 2>/dev/null >/dev/null ; then
|
||||
UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
|
||||
(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
|
||||
(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
|
||||
UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
|
||||
(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
|
||||
(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
|
||||
&& UNAME_MACHINE=i586
|
||||
(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
|
||||
(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
|
||||
&& UNAME_MACHINE=i686
|
||||
(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
|
||||
(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
|
||||
&& UNAME_MACHINE=i686
|
||||
echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
|
||||
else
|
||||
echo ${UNAME_MACHINE}-pc-sysv32
|
||||
fi
|
||||
exit 0 ;;
|
||||
i*86:*DOS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-msdosdjgpp
|
||||
exit 0 ;;
|
||||
pc:*:*:*)
|
||||
# Left here for compatibility:
|
||||
# uname -m prints for DJGPP always 'pc', but it prints nothing about
|
||||
|
@ -1017,9 +1043,15 @@ EOF
|
|||
# "miniframe"
|
||||
echo m68010-convergent-sysv
|
||||
exit 0 ;;
|
||||
mc68k:UNIX:SYSTEM5:3.51m)
|
||||
echo m68k-convergent-sysv
|
||||
exit 0 ;;
|
||||
M680?0:D-NIX:5.3:*)
|
||||
echo m68k-diab-dnix
|
||||
exit 0 ;;
|
||||
M68*:*:R3V[567]*:*)
|
||||
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
|
||||
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0)
|
||||
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0)
|
||||
OS_REL=''
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
|
@ -1036,9 +1068,6 @@ EOF
|
|||
mc68030:UNIX_System_V:4.*:*)
|
||||
echo m68k-atari-sysv4
|
||||
exit 0 ;;
|
||||
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
TSUNAMI:LynxOS:2.*:*)
|
||||
echo sparc-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
|
@ -1110,6 +1139,9 @@ EOF
|
|||
SX-5:SUPER-UX:*:*)
|
||||
echo sx5-nec-superux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
SX-6:SUPER-UX:*:*)
|
||||
echo sx6-nec-superux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
Power*:Rhapsody:*:*)
|
||||
echo powerpc-apple-rhapsody${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
|
@ -1130,7 +1162,7 @@ EOF
|
|||
*:QNX:*:4*)
|
||||
echo i386-pc-qnx
|
||||
exit 0 ;;
|
||||
NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*)
|
||||
NSR-[DGKLNPTVWXY]:NONSTOP_KERNEL:*:*)
|
||||
echo nsr-tandem-nsk${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:NonStop-UX:*:*)
|
||||
|
@ -1153,11 +1185,6 @@ EOF
|
|||
fi
|
||||
echo ${UNAME_MACHINE}-unknown-plan9
|
||||
exit 0 ;;
|
||||
i*86:OS/2:*:*)
|
||||
# If we were able to find `uname', then EMX Unix compatibility
|
||||
# is probably installed.
|
||||
echo ${UNAME_MACHINE}-pc-os2-emx
|
||||
exit 0 ;;
|
||||
*:TOPS-10:*:*)
|
||||
echo pdp10-unknown-tops10
|
||||
exit 0 ;;
|
||||
|
@ -1176,12 +1203,6 @@ EOF
|
|||
*:ITS:*:*)
|
||||
echo pdp10-unknown-its
|
||||
exit 0 ;;
|
||||
i*86:XTS-300:*:STOP)
|
||||
echo ${UNAME_MACHINE}-unknown-stop
|
||||
exit 0 ;;
|
||||
i*86:atheos:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-atheos
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
|
@ -1302,8 +1323,8 @@ main ()
|
|||
}
|
||||
EOF
|
||||
|
||||
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
|
||||
rm -f $dummy.c $dummy
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
|
||||
# Apollos put the system type in the environment.
|
||||
|
||||
|
@ -1335,17 +1356,6 @@ then
|
|||
esac
|
||||
fi
|
||||
|
||||
# NOTE -- Begin fallback cases added for bash -- NOTE
|
||||
case "$UNAME" in
|
||||
uts) echo uts-amdahl-sysv${UNAME_RELEASE}; exit 0 ;;
|
||||
esac
|
||||
|
||||
if [ -f /bin/fxc.info ]; then
|
||||
echo fxc-alliant-concentrix
|
||||
exit 0
|
||||
fi
|
||||
# NOTE -- End fallback cases added for bash -- NOTE
|
||||
|
||||
cat >&2 <<EOF
|
||||
$0: unable to guess system type
|
||||
|
||||
|
|
548
readline/support/config.rpath
Executable file
548
readline/support/config.rpath
Executable file
|
@ -0,0 +1,548 @@
|
|||
#! /bin/sh
|
||||
# Output a system dependent set of variables, describing how to set the
|
||||
# run time search path of shared libraries in an executable.
|
||||
#
|
||||
# Copyright 1996-2003 Free Software Foundation, Inc.
|
||||
# Taken from GNU libtool, 2001
|
||||
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
#
|
||||
# The first argument passed to this file is the canonical host specification,
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
|
||||
# or
|
||||
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
|
||||
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
|
||||
# should be set by the caller.
|
||||
#
|
||||
# The set of defined variables is at the end of this script.
|
||||
|
||||
# Known limitations:
|
||||
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
|
||||
# than 256 bytes, otherwise the compiler driver will dump core. The only
|
||||
# known workaround is to choose shorter directory names for the build
|
||||
# directory and/or the installation directory.
|
||||
|
||||
# All known linkers require a `.a' archive for static linking (except M$VC,
|
||||
# which needs '.lib').
|
||||
libext=a
|
||||
shrext=.so
|
||||
|
||||
host="$1"
|
||||
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
|
||||
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
|
||||
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
|
||||
|
||||
# Code taken from libtool.m4's AC_LIBTOOL_PROG_COMPILER_PIC.
|
||||
|
||||
wl=
|
||||
if test "$GCC" = yes; then
|
||||
wl='-Wl,'
|
||||
else
|
||||
case "$host_os" in
|
||||
aix*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
mingw* | pw32* | os2*)
|
||||
;;
|
||||
hpux9* | hpux10* | hpux11*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
irix5* | irix6* | nonstopux*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
newsos6)
|
||||
;;
|
||||
linux*)
|
||||
case $CC in
|
||||
icc|ecc)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
ccc)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
osf3* | osf4* | osf5*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
sco3.2v5*)
|
||||
;;
|
||||
solaris*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
sunos4*)
|
||||
wl='-Qoption ld '
|
||||
;;
|
||||
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
|
||||
wl='-Wl,'
|
||||
;;
|
||||
sysv4*MP*)
|
||||
;;
|
||||
uts4*)
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Code taken from libtool.m4's AC_LIBTOOL_PROG_LD_SHLIBS.
|
||||
|
||||
hardcode_libdir_flag_spec=
|
||||
hardcode_libdir_separator=
|
||||
hardcode_direct=no
|
||||
hardcode_minus_L=no
|
||||
|
||||
case "$host_os" in
|
||||
cygwin* | mingw* | pw32*)
|
||||
# FIXME: the MSVC++ port hasn't been tested in a loooong time
|
||||
# When not using gcc, we currently assume that we are using
|
||||
# Microsoft Visual C++.
|
||||
if test "$GCC" != yes; then
|
||||
with_gnu_ld=no
|
||||
fi
|
||||
;;
|
||||
openbsd*)
|
||||
with_gnu_ld=no
|
||||
;;
|
||||
esac
|
||||
|
||||
ld_shlibs=yes
|
||||
if test "$with_gnu_ld" = yes; then
|
||||
case "$host_os" in
|
||||
aix3* | aix4* | aix5*)
|
||||
# On AIX/PPC, the GNU linker is very broken
|
||||
if test "$host_cpu" != ia64; then
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
amigaos*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
# Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
|
||||
# that the semantics of dynamic libraries on AmigaOS, at least up
|
||||
# to version 4, is to share data among multiple programs linked
|
||||
# with the same dynamic library. Since this doesn't match the
|
||||
# behavior of shared libraries on other platforms, we can use
|
||||
# them.
|
||||
ld_shlibs=no
|
||||
;;
|
||||
beos*)
|
||||
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
cygwin* | mingw* | pw32*)
|
||||
# hardcode_libdir_flag_spec is actually meaningless, as there is
|
||||
# no search path for DLLs.
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
netbsd*)
|
||||
;;
|
||||
solaris* | sysv5*)
|
||||
if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
|
||||
ld_shlibs=no
|
||||
elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
sunos4*)
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
*)
|
||||
if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
|
||||
:
|
||||
else
|
||||
ld_shlibs=no
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if test "$ld_shlibs" = yes; then
|
||||
# Unlike libtool, we use -rpath here, not --rpath, since the documented
|
||||
# option of GNU ld is called -rpath, not --rpath.
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
fi
|
||||
else
|
||||
case "$host_os" in
|
||||
aix3*)
|
||||
# Note: this linker hardcodes the directories in LIBPATH if there
|
||||
# are no directories specified by -L.
|
||||
hardcode_minus_L=yes
|
||||
if test "$GCC" = yes; then
|
||||
# Neither direct hardcoding nor static linking is supported with a
|
||||
# broken collect2.
|
||||
hardcode_direct=unsupported
|
||||
fi
|
||||
;;
|
||||
aix4* | aix5*)
|
||||
if test "$host_cpu" = ia64; then
|
||||
# On IA64, the linker does run time linking by default, so we don't
|
||||
# have to do anything special.
|
||||
aix_use_runtimelinking=no
|
||||
else
|
||||
aix_use_runtimelinking=no
|
||||
# Test if we are trying to use run time linking or normal
|
||||
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
|
||||
# need to do runtime linking.
|
||||
case $host_os in aix4.[23]|aix4.[23].*|aix5*)
|
||||
for ld_flag in $LDFLAGS; do
|
||||
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
|
||||
aix_use_runtimelinking=yes
|
||||
break
|
||||
fi
|
||||
done
|
||||
esac
|
||||
fi
|
||||
hardcode_direct=yes
|
||||
hardcode_libdir_separator=':'
|
||||
if test "$GCC" = yes; then
|
||||
case $host_os in aix4.[012]|aix4.[012].*)
|
||||
collect2name=`${CC} -print-prog-name=collect2`
|
||||
if test -f "$collect2name" && \
|
||||
strings "$collect2name" | grep resolve_lib_name >/dev/null
|
||||
then
|
||||
# We have reworked collect2
|
||||
hardcode_direct=yes
|
||||
else
|
||||
# We have old collect2
|
||||
hardcode_direct=unsupported
|
||||
hardcode_minus_L=yes
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_libdir_separator=
|
||||
fi
|
||||
esac
|
||||
fi
|
||||
# Begin _LT_AC_SYS_LIBPATH_AIX.
|
||||
echo 'int main () { return 0; }' > conftest.c
|
||||
${CC} ${LDFLAGS} conftest.c -o conftest
|
||||
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
|
||||
}'`
|
||||
if test -z "$aix_libpath"; then
|
||||
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
|
||||
}'`
|
||||
fi
|
||||
if test -z "$aix_libpath"; then
|
||||
aix_libpath="/usr/lib:/lib"
|
||||
fi
|
||||
rm -f conftest.c conftest
|
||||
# End _LT_AC_SYS_LIBPATH_AIX.
|
||||
if test "$aix_use_runtimelinking" = yes; then
|
||||
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
|
||||
else
|
||||
if test "$host_cpu" = ia64; then
|
||||
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
|
||||
else
|
||||
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
amigaos*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
# see comment about different semantics on the GNU ld section
|
||||
ld_shlibs=no
|
||||
;;
|
||||
bsdi4*)
|
||||
;;
|
||||
cygwin* | mingw* | pw32*)
|
||||
# When not using gcc, we currently assume that we are using
|
||||
# Microsoft Visual C++.
|
||||
# hardcode_libdir_flag_spec is actually meaningless, as there is
|
||||
# no search path for DLLs.
|
||||
hardcode_libdir_flag_spec=' '
|
||||
libext=lib
|
||||
;;
|
||||
darwin* | rhapsody*)
|
||||
if $CC -v 2>&1 | grep 'Apple' >/dev/null ; then
|
||||
hardcode_direct=no
|
||||
fi
|
||||
;;
|
||||
dgux*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
;;
|
||||
freebsd1*)
|
||||
ld_shlibs=no
|
||||
;;
|
||||
freebsd2.2*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
freebsd2*)
|
||||
hardcode_direct=yes
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
freebsd*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
hpux9*)
|
||||
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
hardcode_direct=yes
|
||||
# hardcode_minus_L: Not really in the search PATH,
|
||||
# but as the default location of the library.
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
hpux10* | hpux11*)
|
||||
if test "$with_gnu_ld" = no; then
|
||||
case "$host_cpu" in
|
||||
hppa*64*)
|
||||
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
hardcode_direct=no
|
||||
;;
|
||||
ia64*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_direct=no
|
||||
# hardcode_minus_L: Not really in the search PATH,
|
||||
# but as the default location of the library.
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
*)
|
||||
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
hardcode_direct=yes
|
||||
# hardcode_minus_L: Not really in the search PATH,
|
||||
# but as the default location of the library.
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
irix5* | irix6* | nonstopux*)
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
netbsd*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
hardcode_direct=yes
|
||||
;;
|
||||
newsos6)
|
||||
hardcode_direct=yes
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
openbsd*)
|
||||
hardcode_direct=yes
|
||||
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
|
||||
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
|
||||
else
|
||||
case "$host_os" in
|
||||
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
;;
|
||||
*)
|
||||
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
;;
|
||||
os2*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
osf3*)
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
osf4* | osf5*)
|
||||
if test "$GCC" = yes; then
|
||||
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
|
||||
else
|
||||
# Both cc and cxx compiler support -rpath directly
|
||||
hardcode_libdir_flag_spec='-rpath $libdir'
|
||||
fi
|
||||
hardcode_libdir_separator=:
|
||||
;;
|
||||
sco3.2v5*)
|
||||
;;
|
||||
solaris*)
|
||||
hardcode_libdir_flag_spec='-R$libdir'
|
||||
;;
|
||||
sunos4*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
hardcode_direct=yes
|
||||
hardcode_minus_L=yes
|
||||
;;
|
||||
sysv4)
|
||||
case $host_vendor in
|
||||
sni)
|
||||
hardcode_direct=yes # is this really true???
|
||||
;;
|
||||
siemens)
|
||||
hardcode_direct=no
|
||||
;;
|
||||
motorola)
|
||||
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
sysv4.3*)
|
||||
;;
|
||||
sysv4*MP*)
|
||||
if test -d /usr/nec; then
|
||||
ld_shlibs=yes
|
||||
fi
|
||||
;;
|
||||
sysv4.2uw2*)
|
||||
hardcode_direct=yes
|
||||
hardcode_minus_L=no
|
||||
;;
|
||||
sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7*)
|
||||
;;
|
||||
sysv5*)
|
||||
hardcode_libdir_flag_spec=
|
||||
;;
|
||||
uts4*)
|
||||
hardcode_libdir_flag_spec='-L$libdir'
|
||||
;;
|
||||
*)
|
||||
ld_shlibs=no
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Check dynamic linker characteristics
|
||||
# Code taken from libtool.m4's AC_LIBTOOL_SYS_DYNAMIC_LINKER.
|
||||
libname_spec='lib$name'
|
||||
case "$host_os" in
|
||||
aix3*)
|
||||
;;
|
||||
aix4* | aix5*)
|
||||
;;
|
||||
amigaos*)
|
||||
;;
|
||||
beos*)
|
||||
;;
|
||||
bsdi4*)
|
||||
;;
|
||||
cygwin* | mingw* | pw32*)
|
||||
shrext=.dll
|
||||
;;
|
||||
darwin* | rhapsody*)
|
||||
shrext=.dylib
|
||||
;;
|
||||
dgux*)
|
||||
;;
|
||||
freebsd1*)
|
||||
;;
|
||||
freebsd*)
|
||||
;;
|
||||
gnu*)
|
||||
;;
|
||||
hpux9* | hpux10* | hpux11*)
|
||||
case "$host_cpu" in
|
||||
ia64*)
|
||||
shrext=.so
|
||||
;;
|
||||
hppa*64*)
|
||||
shrext=.sl
|
||||
;;
|
||||
*)
|
||||
shrext=.sl
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
irix5* | irix6* | nonstopux*)
|
||||
case "$host_os" in
|
||||
irix5* | nonstopux*)
|
||||
libsuff= shlibsuff=
|
||||
;;
|
||||
*)
|
||||
case $LD in
|
||||
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
|
||||
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
|
||||
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
|
||||
*) libsuff= shlibsuff= ;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
linux*oldld* | linux*aout* | linux*coff*)
|
||||
;;
|
||||
linux*)
|
||||
;;
|
||||
netbsd*)
|
||||
;;
|
||||
newsos6)
|
||||
;;
|
||||
nto-qnx)
|
||||
;;
|
||||
openbsd*)
|
||||
;;
|
||||
os2*)
|
||||
libname_spec='$name'
|
||||
shrext=.dll
|
||||
;;
|
||||
osf3* | osf4* | osf5*)
|
||||
;;
|
||||
sco3.2v5*)
|
||||
;;
|
||||
solaris*)
|
||||
;;
|
||||
sunos4*)
|
||||
;;
|
||||
sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
|
||||
;;
|
||||
sysv4*MP*)
|
||||
;;
|
||||
uts4*)
|
||||
;;
|
||||
esac
|
||||
|
||||
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
|
||||
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
|
||||
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
|
||||
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
|
||||
|
||||
sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
|
||||
|
||||
# How to pass a linker flag through the compiler.
|
||||
wl="$escaped_wl"
|
||||
|
||||
# Static library suffix (normally "a").
|
||||
libext="$libext"
|
||||
|
||||
# Shared library suffix (normally "so").
|
||||
shlibext="$shlibext"
|
||||
|
||||
# Flag to hardcode \$libdir into a binary during linking.
|
||||
# This must work even if \$libdir does not exist.
|
||||
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
|
||||
|
||||
# Whether we need a single -rpath flag with a separated argument.
|
||||
hardcode_libdir_separator="$hardcode_libdir_separator"
|
||||
|
||||
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
|
||||
# resulting binary.
|
||||
hardcode_direct="$hardcode_direct"
|
||||
|
||||
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
|
||||
# resulting binary.
|
||||
hardcode_minus_L="$hardcode_minus_L"
|
||||
|
||||
EOF
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue