mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-22 16:43:03 +01:00
replaced by library with compatible license
This commit is contained in:
parent
bbe5524d48
commit
6bf77ed0c0
1126
extern/editline/CHANGELOG
vendored
1126
extern/editline/CHANGELOG
vendored
File diff suppressed because it is too large
Load Diff
921
extern/editline/CHANGES
vendored
921
extern/editline/CHANGES
vendored
@ -1,921 +0,0 @@
|
||||
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. Changes to Readline
|
||||
|
||||
a. Fixed output of comment-begin character when listing variable values.
|
||||
|
||||
b. Added some default key bindings for common escape sequences produced by
|
||||
HOME and END keys.
|
||||
|
||||
c. Fixed the mark handling code to be more emacs-compatible.
|
||||
|
||||
d. A bug was fixed in the code that prints possible completions to keep it
|
||||
from printing empty strings in certain circumstances.
|
||||
|
||||
e. Change the key sequence printing code to print ESC as M\- if ESC is a
|
||||
meta-prefix character -- it's easier for users to understand than \e.
|
||||
|
||||
f. Fixed unstifle_history() to return values that match the documentation.
|
||||
|
||||
g. Fixed the event loop (rl_event_hook) to handle the case where the input
|
||||
file descriptor is invalidated.
|
||||
|
||||
h. Fixed the prompt display code to work better when the application has a
|
||||
custom redisplay function.
|
||||
|
||||
i. Changes to make reading and writing the history file a little faster, and
|
||||
to cope with huge history files without calling abort(3) from xmalloc.
|
||||
|
||||
j. The vi-mode `S' and `s' commands are now undone correctly.
|
||||
|
||||
k. Fixed a problem which caused the display to be messed up when the last
|
||||
line of a multi-line prompt (possibly containing invisible characters)
|
||||
was longer than the screen width.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. Support for key `subsequences': allows, e.g., ESC and ESC-a to both
|
||||
be bound to readline functions. Now the arrow keys may be used in vi
|
||||
insert mode.
|
||||
|
||||
b. When listing completions, and the number of lines displayed is more than
|
||||
the screen length, readline uses an internal pager to display the results.
|
||||
This is controlled by the `page-completions' variable (default on).
|
||||
|
||||
c. New code to handle editing and displaying multibyte characters.
|
||||
|
||||
d. The behavior introduced in bash-2.05a of deciding whether or not to
|
||||
append a slash to a completed name that is a symlink to a directory has
|
||||
been made optional, controlled by the `mark-symlinked-directories'
|
||||
variable (default is the 2.05a behavior).
|
||||
|
||||
e. The `insert-comment' command now acts as a toggle if given a numeric
|
||||
argument: if the first characters on the line don't specify a
|
||||
comment, insert one; if they do, delete the comment text
|
||||
|
||||
f. New application-settable completion variable:
|
||||
rl_completion_mark_symlink_dirs, allows an application's completion
|
||||
function to temporarily override the user's preference for appending
|
||||
slashes to names which are symlinks to directories.
|
||||
|
||||
g. New function available to application completion functions:
|
||||
rl_completion_mode, to tell how the completion function was invoked
|
||||
and decide which argument to supply to rl_complete_internal (to list
|
||||
completions, etc.).
|
||||
|
||||
h. Readline now has an overwrite mode, toggled by the `overwrite-mode'
|
||||
bindable command, which could be bound to `Insert'.
|
||||
|
||||
i. New application-settable completion variable:
|
||||
rl_completion_suppress_append, inhibits appending of
|
||||
rl_completion_append_character to completed words.
|
||||
|
||||
j. New key bindings when reading an incremental search string: ^W yanks
|
||||
the currently-matched word out of the current line into the search
|
||||
string; ^Y yanks the rest of the current line into the search string,
|
||||
DEL or ^H deletes characters from the search string.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-4.2a,
|
||||
and the previous version, readline-4.2.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. More `const' and type casting fixes.
|
||||
|
||||
b. Changed rl_message() to use vsnprintf(3) (if available) to fix buffer
|
||||
overflow problems.
|
||||
|
||||
c. The completion code no longer appends a `/' or ` ' to a match when
|
||||
completing a symbolic link that resolves to a directory name, unless
|
||||
the match does not add anything to the word being completed. This
|
||||
means that a tab will complete the word up to the full name, but not
|
||||
add anything, and a subsequent tab will add a slash.
|
||||
|
||||
d. Fixed a trivial typo that made the vi-mode `dT' command not work.
|
||||
|
||||
e. Fixed the tty code so that ^S and ^Q can be inserted with rl_quoted_insert.
|
||||
|
||||
f. Fixed the tty code so that ^V works more than once.
|
||||
|
||||
g. Changed the use of __P((...)) for function prototypes to PARAMS((...))
|
||||
because the use of __P in typedefs conflicted g++ and glibc.
|
||||
|
||||
h. The completion code now attempts to do a better job of preserving the
|
||||
case of the word the user typed if ignoring case in completions.
|
||||
|
||||
i. Readline defaults to not echoing the input and lets the terminal
|
||||
initialization code enable echoing if there is a controlling terminal.
|
||||
|
||||
j. The key binding code now processes only two hex digits after a `\x'
|
||||
escape sequence, and the documentation was changed to note that the
|
||||
octal and hex escape sequences result in an eight-bit value rather
|
||||
than strict ASCII.
|
||||
|
||||
k. Fixed a few places where negative array subscripts could have occurred.
|
||||
|
||||
l. Fixed the vi-mode code to use a better method to determine the bounds of
|
||||
the array used to hold the marks, and to avoid out-of-bounds references.
|
||||
|
||||
m. Fixed the defines in chardefs.h to work better when chars are signed.
|
||||
|
||||
n. Fixed configure.in to use the new names for bash autoconf macros.
|
||||
|
||||
o. Readline no longer attempts to define its own versions of some ctype
|
||||
macros if they are implemented as functions in libc but not as macros in
|
||||
<ctype.h>.
|
||||
|
||||
p. Fixed a problem where rl_backward could possibly set point to before
|
||||
the beginning of the line.
|
||||
|
||||
q. Fixed Makefile to not put -I/usr/include into CFLAGS, since it can cause
|
||||
include file problems.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. Added extern declaration for rl_get_termcap to readline.h, making it a
|
||||
public function (it was always there, just not in readline.h).
|
||||
|
||||
b. New #defines in readline.h: RL_READLINE_VERSION, currently 0x0402,
|
||||
RL_VERSION_MAJOR, currently 4, and RL_VERSION_MINOR, currently 2.
|
||||
|
||||
c. New readline variable: rl_readline_version, mirrors RL_READLINE_VERSION.
|
||||
|
||||
d. New bindable boolean readline variable: match-hidden-files. Controls
|
||||
completion of files beginning with a `.' (on Unix). Enabled by default.
|
||||
|
||||
e. The history expansion code now allows any character to terminate a
|
||||
`:first-' modifier, like csh.
|
||||
|
||||
f. The incremental search code remembers the last search string and uses
|
||||
it if ^R^R is typed without a search string.
|
||||
|
||||
h. New bindable variable `history-preserve-point'. If set, the history
|
||||
code attempts to place the user at the same location on each history
|
||||
line retrived with previous-history or next-history.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-4.2,
|
||||
and the previous version, readline-4.1.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. When setting the terminal attributes on systems using `struct termio',
|
||||
readline waits for output to drain before changing the attributes.
|
||||
|
||||
b. A fix was made to the history word tokenization code to avoid attempts to
|
||||
dereference a null pointer.
|
||||
|
||||
c. Readline now defaults rl_terminal_name to $TERM if the calling application
|
||||
has left it unset, and tries to initialize with the resultant value.
|
||||
|
||||
d. Instead of calling (*rl_getc_function)() directly to get input in certain
|
||||
places, readline now calls rl_read_key() consistently.
|
||||
|
||||
e. Fixed a bug in the completion code that allowed a backslash to quote a
|
||||
single quote inside a single-quoted string.
|
||||
|
||||
f. rl_prompt is no longer assigned directly from the argument to readline(),
|
||||
but uses memory allocated by readline. This allows constant strings to
|
||||
be passed to readline without problems arising when the prompt processing
|
||||
code wants to modify the string.
|
||||
|
||||
g. Fixed a bug that caused non-interactive history searches to return the
|
||||
wrong line when performing multiple searches backward for the same string.
|
||||
|
||||
h. Many variables, function arguments, and function return values are now
|
||||
declared `const' where appropriate, to improve behavior when linking with
|
||||
C++ code.
|
||||
|
||||
i. The control character detection code now works better on systems where
|
||||
`char' is unsigned by default.
|
||||
|
||||
j. The vi-mode numeric argument is now capped at 999999, just like emacs mode.
|
||||
|
||||
k. The Function, CPFunction, CPPFunction, and VFunction typedefs have been
|
||||
replaced with a set of specific prototyped typedefs, though they are
|
||||
still in the readline header files for backwards compatibility.
|
||||
|
||||
m. Nearly all of the (undocumented) internal global variables in the library
|
||||
now have an _rl_ prefix -- there were a number that did not, like
|
||||
screenheight, screenwidth, alphabetic, etc.
|
||||
|
||||
n. The ding() convenience function has been renamed to rl_ding(), though the
|
||||
old function is still defined for backwards compatibility.
|
||||
|
||||
o. The completion convenience functions filename_completion_function,
|
||||
username_completion_function, and completion_matches now have an rl_
|
||||
prefix, though the old names are still defined for backwards compatibility.
|
||||
|
||||
p. The functions shared by readline and bash (linkage is satisfied from bash
|
||||
when compiling with bash, and internally otherwise) now have an sh_ prefix.
|
||||
|
||||
q. Changed the shared library creation procedure on Linux and BSD/OS 4.x so
|
||||
that the `soname' contains only the major version number rather than the
|
||||
major and minor numbers.
|
||||
|
||||
r. Fixed a redisplay bug that occurred when the prompt spanned more than one
|
||||
physical line and contained invisible characters.
|
||||
|
||||
s. Added a missing `includedir' variable to the Makefile.
|
||||
|
||||
t. When installing the shared libraries, make sure symbolic links are relative.
|
||||
|
||||
u. Added configure test so that it can set `${MAKE}' appropriately.
|
||||
|
||||
v. Fixed a bug in rl_forward that could cause the point to be set to before
|
||||
the beginning of the line in vi mode.
|
||||
|
||||
w. Fixed a bug in the callback read-char interface to make it work when a
|
||||
readline function pushes some input onto the input stream with
|
||||
rl_execute_next (like the incremental search functions).
|
||||
|
||||
x. Fixed a file descriptor leak in the history file manipulation code that
|
||||
was tripped when attempting to truncate a non-regular file (like
|
||||
/dev/null).
|
||||
|
||||
y. Changes to make all of the exported readline functions declared in
|
||||
readline.h have an rl_ prefix (rltty_set_default_bindings is now
|
||||
rl_tty_set_default_bindings, crlf is now rl_crlf, etc.)
|
||||
|
||||
z. The formatted documentation included in the base readline distribution
|
||||
is no longer removed on a `make distclean'.
|
||||
|
||||
aa. Some changes were made to avoid gcc warnings with -Wall.
|
||||
|
||||
bb. rl_get_keymap_by_name now finds keymaps case-insensitively, so
|
||||
`set keymap EMACS' works.
|
||||
|
||||
cc. The history file writing and truncation functions now return a useful
|
||||
status on error.
|
||||
|
||||
dd. Fixed a bug that could cause applications to dereference a NULL pointer
|
||||
if a NULL second argument was passed to history_expand().
|
||||
|
||||
ee. If a hook function assigned to rl_event_hook sets rl_done to a non-zero
|
||||
value, rl_read_key() now immediately returns '\n' (which is assumed to
|
||||
be bound to accept-line).
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. The blink timeout for paren matching is now settable by applications,
|
||||
via the rl_set_paren_blink_timeout() function.
|
||||
|
||||
b. _rl_executing_macro has been renamed to rl_executing_macro, which means
|
||||
it's now part of the public interface.
|
||||
|
||||
c. Readline has a new variable, rl_readline_state, which is a bitmap that
|
||||
encapsulates the current state of the library; intended for use by
|
||||
callbacks and hook functions.
|
||||
|
||||
d. rlfe has a new -l option to log input and output (-a appends to logfile),
|
||||
a new -n option to set the readline application name, and -v and -h
|
||||
options for version and help information.
|
||||
|
||||
e. rlfe can now perform filename completion for the inferior process if the
|
||||
OS has a /proc/<PID>/cwd that can be read with readlink(2) to get the
|
||||
inferior's current working directory.
|
||||
|
||||
f. A new file, rltypedefs.h, contains the new typedefs for function pointers
|
||||
and is installed by `make install'.
|
||||
|
||||
g. New application-callable function rl_set_prompt(const char *prompt):
|
||||
expands its prompt string argument and sets rl_prompt to the result.
|
||||
|
||||
h. New application-callable function rl_set_screen_size(int rows, int cols):
|
||||
public method for applications to set readline's idea of the screen
|
||||
dimensions.
|
||||
|
||||
i. The history example program (examples/histexamp.c) is now built as one
|
||||
of the examples.
|
||||
|
||||
j. The documentation has been updated to cover nearly all of the public
|
||||
functions and variables declared in readline.h.
|
||||
|
||||
k. New function, rl_get_screen_size (int *rows, int *columns), returns
|
||||
readline's idea of the screen dimensions.
|
||||
|
||||
l. The timeout in rl_gather_tyi (readline keyboard input polling function)
|
||||
is now settable via a function (rl_set_keyboard_input_timeout()).
|
||||
|
||||
m. Renamed the max_input_history variable to history_max_entries; the old
|
||||
variable is maintained for backwards compatibility.
|
||||
|
||||
n. The list of characters that separate words for the history tokenizer is
|
||||
now settable with a variable: history_word_delimiters. The default
|
||||
value is as before.
|
||||
|
||||
o. There is a new history.3 manual page documenting the history library.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-4.1,
|
||||
and the previous version, readline-4.0.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. Changed the HTML documents so that the table-of-contents is no longer
|
||||
a separate file.
|
||||
|
||||
b. Changes to the shared object configuration for: Irix 5.x, Irix 6.x,
|
||||
OSF/1.
|
||||
|
||||
c. The shared library major and minor versions are now constructed
|
||||
automatically by configure and substituted into the makefiles.
|
||||
|
||||
d. It's now possible to install the shared libraries separately from the
|
||||
static libraries.
|
||||
|
||||
e. The history library tries to truncate the history file only if it is a
|
||||
regular file.
|
||||
|
||||
f. A bug that caused _rl_dispatch to address negative array indices on
|
||||
systems with signed chars was fixed.
|
||||
|
||||
g. rl-yank-nth-arg now leaves the history position the same as when it was
|
||||
called.
|
||||
|
||||
h. Changes to the completion code to handle MS-DOS drive-letter:pathname
|
||||
filenames.
|
||||
|
||||
i. Completion is now case-insensitive by default on MS-DOS.
|
||||
|
||||
j. Fixes to the history file manipulation code for MS-DOS.
|
||||
|
||||
k. Readline attempts to bind the arrow keys to appropriate defaults on MS-DOS.
|
||||
|
||||
l. Some fixes were made to the redisplay code for better operation on MS-DOS.
|
||||
|
||||
m. The quoted-insert code will now insert tty special chars like ^C.
|
||||
|
||||
n. A bug was fixed that caused the display code to reference memory before
|
||||
the start of the prompt string.
|
||||
|
||||
o. More support for __EMX__ (OS/2).
|
||||
|
||||
p. A bug was fixed in readline's signal handling that could cause infinite
|
||||
recursion in signal handlers.
|
||||
|
||||
q. A bug was fixed that caused the point to be less than zero when rl_forward
|
||||
was given a very large numeric argument.
|
||||
|
||||
r. The vi-mode code now gets characters via the application-settable value
|
||||
of rl_getc_function rather than calling rl_getc directly.
|
||||
|
||||
s. The history file code now uses O_BINARY mode when reading and writing
|
||||
the history file on cygwin32.
|
||||
|
||||
t. Fixed a bug in the redisplay code for lines with more than 256 line
|
||||
breaks.
|
||||
|
||||
u. A bug was fixed which caused invisible character markers to not be
|
||||
stripped from the prompt string if the terminal was in no-echo mode.
|
||||
|
||||
v. Readline no longer tries to get the variables it needs for redisplay
|
||||
from the termcap entry if the calling application has specified its
|
||||
own redisplay function. Readline treats the terminal as `dumb' in
|
||||
this case.
|
||||
|
||||
w. Fixes to the SIGWINCH code so that a multiple-line prompt with escape
|
||||
sequences is redrawn correctly.
|
||||
|
||||
x. Changes to the install and install-shared targets so that the libraries
|
||||
and header files are installed separately.
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. A new Readline `user manual' is in doc/rluserman.texinfo.
|
||||
|
||||
b. Parentheses matching is now always compiled into readline, and enabled
|
||||
or disabled when the value of the `blink-matching-paren' variable is
|
||||
changed.
|
||||
|
||||
c. MS-DOS systems now use ~/_inputrc as the last-ditch inputrc filename.
|
||||
|
||||
d. MS-DOS systems now use ~/_history as the default history file.
|
||||
|
||||
e. history-search-{forward,backward} now leave the point at the end of the
|
||||
line when the string to search for is empty, like
|
||||
{reverse,forward}-search-history.
|
||||
|
||||
f. history-search-{forward,backward} now leave the last history line found
|
||||
in the readline buffer if the second or subsequent search fails.
|
||||
|
||||
g. New function for use by applications: rl_on_new_line_with_prompt, used
|
||||
when an application displays the prompt itself before calling readline().
|
||||
|
||||
h. New variable for use by applications: rl_already_prompted. An application
|
||||
that displays the prompt itself before calling readline() must set this to
|
||||
a non-zero value.
|
||||
|
||||
i. A new variable, rl_gnu_readline_p, always 1. The intent is that an
|
||||
application can verify whether or not it is linked with the `real'
|
||||
readline library or some substitute.
|
||||
|
||||
j. Per Bothner's `rlfe' (pronounced `Ralphie') readline front-end program
|
||||
is included in the examples subdirectory, though it is not built
|
||||
by default.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-4.0,
|
||||
and the previous version, readline-2.2.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. The version number is now 4.0, to match the major and minor version
|
||||
numbers on the shared readline and history libraries. Future
|
||||
releases will maintain the identical numbering.
|
||||
|
||||
b. Fixed a typo in the `make install' recipe that copied libreadline.a
|
||||
to libhistory.old right after installing it.
|
||||
|
||||
c. The readline and history info files are now installed out of the source
|
||||
directory if they are not found in the build directory.
|
||||
|
||||
d. The library no longer exports a function named `savestring' -- backwards
|
||||
compatibility be damned.
|
||||
|
||||
e. There is no longer any #ifdef SHELL code in the source files.
|
||||
|
||||
f. Some changes were made to the key binding code to fix memory leaks and
|
||||
better support Win32 systems.
|
||||
|
||||
g. Fixed a silly typo in the paren matching code -- it's microseconds, not
|
||||
milliseconds.
|
||||
|
||||
h. The readline library should be compilable by C++ compilers.
|
||||
|
||||
i. The readline.h public header file now includes function prototypes for
|
||||
all readline functions, and some changes were made to fix errors in the
|
||||
source files uncovered by the use of prototypes.
|
||||
|
||||
j. The maximum numeric argument is now clamped at 1000000.
|
||||
|
||||
k. Fixes to rl_yank_last_arg to make it behave better.
|
||||
|
||||
l. Fixed a bug in the display code that caused core dumps if the prompt
|
||||
string length exceeded 1024 characters.
|
||||
|
||||
m. The menu completion code was fixed to properly insert a single completion
|
||||
if there is only one match.
|
||||
|
||||
n. A bug was fixed that caused the display code to improperly display tabs
|
||||
after newlines.
|
||||
|
||||
o. A fix was made to the completion code in which a typo caused the wrong
|
||||
value to be passed to the function that computed the longest common
|
||||
prefix of the list of matches.
|
||||
|
||||
p. The completion code now checks the value of rl_filename_completion_desired,
|
||||
which is set by application-supplied completion functions to indicate
|
||||
that filename completion is being performed, to decide whether or not to
|
||||
call an application-supplied `ignore completions' function.
|
||||
|
||||
q. Code was added to the history library to catch history substitutions
|
||||
using `&' without a previous history substitution or search having been
|
||||
performed.
|
||||
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. There is a new script, support/shobj-conf, to do system-specific shared
|
||||
object and library configuration. It generates variables for configure
|
||||
to substitute into makefiles. The README file provides a detailed
|
||||
explanation of the shared library creation process.
|
||||
|
||||
b. Shared libraries and objects are now built in the `shlib' subdirectory.
|
||||
There is a shlib/Makefile.in to control the build process. `make shared'
|
||||
from the top-level directory is still the right way to build shared
|
||||
versions of the libraries.
|
||||
|
||||
c. rlconf.h is now installed, so applications can find out which features
|
||||
have been compiled into the installed readline and history libraries.
|
||||
|
||||
d. rlstdc.h is now an installed header file.
|
||||
|
||||
e. Many changes to the signal handling:
|
||||
o Readline now catches SIGQUIT and cleans up the tty before returning;
|
||||
o A new variable, rl_catch_signals, is available to application writers
|
||||
to indicate to readline whether or not it should install its own
|
||||
signal handlers for SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP,
|
||||
SIGTTIN, and SIGTTOU;
|
||||
o A new variable, rl_catch_sigwinch, is available to application
|
||||
writers to indicate to readline whether or not it should install its
|
||||
own signal handler for SIGWINCH, which will chain to the calling
|
||||
applications's SIGWINCH handler, if one is installed;
|
||||
o There is a new function, rl_free_line_state, for application signal
|
||||
handlers to call to free up the state associated with the current
|
||||
line after receiving a signal;
|
||||
o There is a new function, rl_cleanup_after_signal, to clean up the
|
||||
display and terminal state after receiving a signal;
|
||||
o There is a new function, rl_reset_after_signal, to reinitialize the
|
||||
terminal and display state after an application signal handler
|
||||
returns and readline continues
|
||||
|
||||
f. There is a new function, rl_resize_terminal, to reset readline's idea of
|
||||
the screen size after a SIGWINCH.
|
||||
|
||||
g. New public functions: rl_save_prompt and rl_restore_prompt. These were
|
||||
previously private functions with a `_' prefix. These functions are
|
||||
used when an application wants to write a message to the `message area'
|
||||
with rl_message and have the prompt restored correctly when the message
|
||||
is erased.
|
||||
|
||||
h. New function hook: rl_pre_input_hook, called just before readline starts
|
||||
reading input, after initialization.
|
||||
|
||||
i. New function hook: rl_display_matches_hook, called when readline would
|
||||
display the list of completion matches. The new function
|
||||
rl_display_match_list is what readline uses internally, and is available
|
||||
for use by application functions called via this hook.
|
||||
|
||||
j. New bindable function, delete-char-or-list, like tcsh.
|
||||
|
||||
k. A new variable, rl_erase_empty_line, which, if set by an application using
|
||||
readline, will cause readline to erase, prompt and all, lines on which the
|
||||
only thing typed was a newline.
|
||||
|
||||
l. There is a new script, support/shlib-install, to install and uninstall
|
||||
the shared readline and history libraries.
|
||||
|
||||
m. A new bindable variable, `isearch-terminators', which is a string
|
||||
containing the set of characters that should terminate an incremental
|
||||
search without being executed as a command.
|
||||
|
||||
n. A new bindable function, forward-backward-delete-char.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
This document details the changes between this version, readline-2.2,
|
||||
and the previous version, readline-2.1.
|
||||
|
||||
1. Changes to Readline
|
||||
|
||||
a. Added a missing `extern' to a declaration in readline.h that kept
|
||||
readline from compiling cleanly on some systems.
|
||||
|
||||
b. The history file is now opened with mode 0600 when it is written for
|
||||
better security.
|
||||
|
||||
c. Changes were made to the SIGWINCH handling code so that prompt redisplay
|
||||
is done better.
|
||||
|
||||
d. ^G now interrupts incremental searches correctly.
|
||||
|
||||
e. A bug that caused a core dump when the set of characters to be quoted
|
||||
when completing words was empty was fixed.
|
||||
|
||||
f. Fixed a problem in the readline test program rltest.c that caused a core
|
||||
dump.
|
||||
|
||||
g. The code that handles parser directives in inputrc files now displays
|
||||
more error messages.
|
||||
|
||||
h. The history expansion code was fixed so that the appearance of the
|
||||
history comment character at the beginning of a word inhibits history
|
||||
expansion for that word and the rest of the input line.
|
||||
|
||||
i. The code that prints completion listings now behaves better if one or
|
||||
more of the filenames contains non-printable characters.
|
||||
|
||||
j. The time delay when showing matching parentheses is now 0.5 seconds.
|
||||
|
||||
|
||||
2. New Features in Readline
|
||||
|
||||
a. There is now an option for `iterative' yank-last-arg handline, so a user
|
||||
can keep entering `M-.', yanking the last argument of successive history
|
||||
lines.
|
||||
|
||||
b. New variable, `print-completions-horizontally', which causes completion
|
||||
matches to be displayed across the screen (like `ls -x') rather than up
|
||||
and down the screen (like `ls').
|
||||
|
||||
c. New variable, `completion-ignore-case', which causes filename completion
|
||||
and matching to be performed case-insensitively.
|
||||
|
||||
d. There is a new bindable command, `magic-space', which causes history
|
||||
expansion to be performed on the current readline buffer and a space to
|
||||
be inserted into the result.
|
||||
|
||||
e. There is a new bindable command, `menu-complete', which enables tcsh-like
|
||||
menu completion (successive executions of menu-complete insert a single
|
||||
completion match, cycling through the list of possible completions).
|
||||
|
||||
f. There is a new bindable command, `paste-from-clipboard', for use on Win32
|
||||
systems, to insert the text from the Win32 clipboard into the editing
|
||||
buffer.
|
||||
|
||||
g. The key sequence translation code now understands printf-style backslash
|
||||
escape sequences, including \NNN octal escapes. These escape sequences
|
||||
may be used in key sequence definitions or macro values.
|
||||
|
||||
h. An `$include' inputrc file parser directive has been added.
|
360
extern/editline/COPYING
vendored
360
extern/editline/COPYING
vendored
@ -1,339 +1,23 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. Neither the name of the University nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program 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.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public 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.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Appendix: How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) 19yy <name of author>
|
||||
|
||||
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
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) 19yy name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
378
extern/editline/INSTALL
vendored
378
extern/editline/INSTALL
vendored
@ -1,81 +1,88 @@
|
||||
Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This file is free documentation; the Free Software Foundation gives
|
||||
unlimited permission to copy, distribute and modify it.
|
||||
|
||||
Basic Installation
|
||||
==================
|
||||
|
||||
These are installation instructions for Readline-5.1.
|
||||
These are generic installation instructions.
|
||||
|
||||
The simplest way to compile readline is:
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, and a
|
||||
file `config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
1. `cd' to the directory containing the readline source code and type
|
||||
`./configure' to configure readline for your system. If you're
|
||||
It can also use an optional file (typically called `config.cache'
|
||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
||||
the results of its tests to speed up reconfiguring. (Caching is
|
||||
disabled by default to prevent problems with accidental use of stale
|
||||
cache files.)
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If you are using the cache, and at
|
||||
some point `config.cache' contains results you don't want to keep, you
|
||||
may remove or edit it.
|
||||
|
||||
The file `configure.ac' (or `configure.in') is used to create
|
||||
`configure' by a program called `autoconf'. You only need
|
||||
`configure.ac' if you want to change it or regenerate `configure' using
|
||||
a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes some time. While running, it prints some
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile readline and build the static readline
|
||||
and history libraries. If supported, the shared readline and history
|
||||
libraries will be built also. See below for instructions on compiling
|
||||
the other parts of the distribution. Typing `make everything' will
|
||||
cause the static and shared libraries (if supported) and the example
|
||||
programs to be built.
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Type `make install' to install the static readline and history
|
||||
libraries, the readline include files, the documentation, and, if
|
||||
supported, the shared readline and history libraries.
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. You can remove the created libraries and object files from the
|
||||
build directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile readline for
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the readline developers, and should be used with care.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It
|
||||
uses those values to create a `Makefile' in the build directory,
|
||||
and Makefiles in the `doc', `shlib', and `examples'
|
||||
subdirectories. It also creates a `config.h' file containing
|
||||
system-dependent definitions. Finally, it creates a shell script
|
||||
`config.status' that you can run in the future to recreate the
|
||||
current configuration, a file `config.cache' that saves the
|
||||
results of its tests to speed up reconfiguring, and a file
|
||||
`config.log' containing compiler output (useful mainly for
|
||||
debugging `configure').
|
||||
|
||||
If you need to do unusual things to compile readline, please try
|
||||
to figure out how `configure' could check whether to do them, and
|
||||
mail diffs or instructions to <bug-readline@gnu.org> so they can
|
||||
be considered for the next release. If at some point
|
||||
`config.cache' contains results you don't want to keep, you may
|
||||
remove or edit it.
|
||||
|
||||
The file `configure.in' is used to create `configure' by a
|
||||
program called `autoconf'. You only need `configure.in' if you
|
||||
want to change it or regenerate `configure' using a newer version
|
||||
of `autoconf'. The readline `configure.in' requires autoconf
|
||||
version 2.50 or newer.
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. You can give `configure'
|
||||
initial values for variables by setting them in the environment. Using
|
||||
a Bourne-compatible shell, you can do that on the command line like
|
||||
this:
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. Run `./configure --help'
|
||||
for details on some of the pertinent environment variables.
|
||||
|
||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||
You can give `configure' initial values for configuration parameters
|
||||
by setting variables in the command line or in the environment. Here
|
||||
is an example:
|
||||
|
||||
Or on systems that have the `env' program, you can do it like this:
|
||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
||||
|
||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||
*Note Defining Variables::, for more details.
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile readline for more than one kind of computer at the
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
@ -83,205 +90,140 @@ directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not supports the `VPATH'
|
||||
variable, you have to compile readline for one architecture at a
|
||||
time in the source code directory. After you have installed
|
||||
readline for one architecture, use `make distclean' before
|
||||
reconfiguring for another architecture.
|
||||
If you have to use a `make' that does not support the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a
|
||||
time in the source code directory. After you have installed the
|
||||
package for one architecture, use `make distclean' before reconfiguring
|
||||
for another architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the readline libraries in
|
||||
`/usr/local/lib', the include files in
|
||||
`/usr/local/include/readline', the man pages in `/usr/local/man',
|
||||
and the info files in `/usr/local/info'. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure'
|
||||
the option `--prefix=PATH' or by supplying a value for the
|
||||
DESTDIR variable when running `make install'.
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files.
|
||||
If you give `configure' the option `--exec-prefix=PATH', the
|
||||
readline Makefiles will use PATH as the prefix for installing the
|
||||
libraries. Documentation and other data files will still use the
|
||||
regular prefix.
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' can not figure out
|
||||
automatically, but need to determine by the type of host readline
|
||||
will run on. Usually `configure' can figure that out, but if it
|
||||
prints a message saying it can not guess the host type, give it
|
||||
the `--host=TYPE' option. TYPE can either be a short name for
|
||||
the system type, such as `sun4', or a canonical name with three
|
||||
fields: CPU-COMPANY-SYSTEM (e.g., i386-unknown-freebsd4.2).
|
||||
There may be some features `configure' cannot figure out
|
||||
automatically, but needs to determine by the type of machine the package
|
||||
will run on. Usually, assuming the package is built to be run on the
|
||||
_same_ architectures, `configure' can figure that out, but if it prints
|
||||
a message saying it cannot guess the machine type, give it the
|
||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name which has the form:
|
||||
|
||||
See the file `config.sub' for the possible values of each field.
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
where SYSTEM can have one of these forms:
|
||||
|
||||
OS KERNEL-OS
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the machine type.
|
||||
|
||||
If you are _building_ compiler tools for cross-compiling, you should
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for.
|
||||
|
||||
If you want to _use_ a cross compiler, that generates code for a
|
||||
platform different from the build platform, you should specify the
|
||||
"host" platform (i.e., that on which the generated programs will
|
||||
eventually be run) with `--host=TYPE'.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: the readline `configure' looks for a site script, but not
|
||||
all `configure' scripts do.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Operation Controls
|
||||
Defining Variables
|
||||
==================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
Variables not defined in a site shell script can be set in the
|
||||
environment passed to `configure'. However, some packages may run
|
||||
configure again during the build, and the customized values of these
|
||||
variables may be lost. In order to avoid this problem, you should set
|
||||
them in the `configure' command line, using `VAR=value'. For example:
|
||||
|
||||
./configure CC=/usr/local2/bin/gcc
|
||||
|
||||
will cause the specified gcc to be used as the C compiler (unless it is
|
||||
overridden in the site shell script).
|
||||
|
||||
`configure' Invocation
|
||||
======================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Use and save the results of the tests in FILE instead of
|
||||
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
||||
debugging `configure'.
|
||||
|
||||
`--help'
|
||||
`-h'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--version'
|
||||
`-V'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Enable the cache: use and save the results of the tests in FILE,
|
||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
||||
disable caching.
|
||||
|
||||
`--config-cache'
|
||||
`-C'
|
||||
Alias for `--cache-file=config.cache'.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made.
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`--version'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
`configure' also accepts some other, not widely useful, options. Run
|
||||
`configure --help' for more details.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
The readline `configure' recognizes a single `--with-PACKAGE' option:
|
||||
|
||||
`--with-curses'
|
||||
This tells readline that it can find the termcap library functions
|
||||
(tgetent, et al.) in the curses library, rather than a separate
|
||||
termcap library. Readline uses the termcap functions, but does not
|
||||
link with the termcap or curses library itself, allowing applications
|
||||
which link with readline the to choose an appropriate library.
|
||||
This option tells readline to link the example programs with the
|
||||
curses library rather than libtermcap.
|
||||
|
||||
`configure' also recognizes two `--enable-FEATURE' options:
|
||||
|
||||
`--enable-shared'
|
||||
Build the shared libraries by default on supported platforms. The
|
||||
default is `yes'.
|
||||
|
||||
`--enable-static'
|
||||
Build the static libraries by default. The default is `yes'.
|
||||
|
||||
Shared Libraries
|
||||
================
|
||||
|
||||
There is support for building shared versions of the readline and
|
||||
history libraries. The configure script creates a Makefile in
|
||||
the `shlib' subdirectory, and typing `make shared' will cause
|
||||
shared versions of the readline and history libraries to be built
|
||||
on supported platforms.
|
||||
|
||||
If `configure' is given the `--enable-shared' option, it will attempt
|
||||
to build the shared libraries by default on supported platforms.
|
||||
|
||||
Configure calls the script support/shobj-conf to test whether or
|
||||
not shared library creation is supported and to generate the values
|
||||
of variables that are substituted into shlib/Makefile. If you
|
||||
try to build shared libraries on an unsupported platform, `make'
|
||||
will display a message asking you to update support/shobj-conf for
|
||||
your platform.
|
||||
|
||||
If you need to update support/shobj-conf, you will need to create
|
||||
a `stanza' for your operating system and compiler. The script uses
|
||||
the value of host_os and ${CC} as determined by configure. For
|
||||
instance, FreeBSD 4.2 with any version of gcc is identified as
|
||||
`freebsd4.2-gcc*'.
|
||||
|
||||
In the stanza for your operating system-compiler pair, you will need to
|
||||
define several variables. They are:
|
||||
|
||||
SHOBJ_CC The C compiler used to compile source files into shareable
|
||||
object files. This is normally set to the value of ${CC}
|
||||
by configure, and should not need to be changed.
|
||||
|
||||
SHOBJ_CFLAGS Flags to pass to the C compiler ($SHOBJ_CC) to create
|
||||
position-independent code. If you are using gcc, this
|
||||
should probably be set to `-fpic'.
|
||||
|
||||
SHOBJ_LD The link editor to be used to create the shared library from
|
||||
the object files created by $SHOBJ_CC. If you are using
|
||||
gcc, a value of `gcc' will probably work.
|
||||
|
||||
SHOBJ_LDFLAGS Flags to pass to SHOBJ_LD to enable shared object creation.
|
||||
If you are using gcc, `-shared' may be all that is necessary.
|
||||
These should be the flags needed for generic shared object
|
||||
creation.
|
||||
|
||||
SHLIB_XLDFLAGS Additional flags to pass to SHOBJ_LD for shared library
|
||||
creation. Many systems use the -R option to the link
|
||||
editor to embed a path within the library for run-time
|
||||
library searches. A reasonable value for such systems would
|
||||
be `-R$(libdir)'.
|
||||
|
||||
SHLIB_LIBS Any additional libraries that shared libraries should be
|
||||
linked against when they are created.
|
||||
|
||||
SHLIB_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'.
|
||||
|
||||
SHLIB_LIBVERSION The string to append to the filename to indicate the version
|
||||
of the shared library. It should begin with $(SHLIB_LIBSUFF),
|
||||
and possibly include version information that allows the
|
||||
run-time loader to load the version of the shared library
|
||||
appropriate for a particular program. Systems using shared
|
||||
libraries similar to SunOS 4.x use major and minor library
|
||||
version numbers; for those systems a value of
|
||||
`$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' is appropriate.
|
||||
Systems based on System V Release 4 don't use minor version
|
||||
numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
|
||||
Other Unix versions use different schemes.
|
||||
|
||||
SHLIB_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
|
||||
shared libraries are not supported, this will be set to
|
||||
`unsupported'.
|
||||
|
||||
You should look at the existing stanzas in support/shobj-conf for ideas.
|
||||
|
||||
Once you have updated support/shobj-conf, re-run configure and type
|
||||
`make shared' or `make'. The shared libraries will be created in the
|
||||
shlib subdirectory.
|
||||
|
||||
If shared libraries are created, `make install' will install them.
|
||||
You may install only the shared libraries by running `make
|
||||
install-shared' from the top-level build directory. Running `make
|
||||
install' in the shlib subdirectory will also work. If you don't want
|
||||
to install any created shared libraries, run `make install-static'.
|
||||
|
146
extern/editline/MANIFEST
vendored
146
extern/editline/MANIFEST
vendored
@ -1,146 +0,0 @@
|
||||
#
|
||||
# Master distribution manifest for the standalone readline distribution
|
||||
#
|
||||
doc d
|
||||
examples d
|
||||
examples/rlfe d
|
||||
support d
|
||||
shlib d
|
||||
COPYING f
|
||||
README f
|
||||
MANIFEST f
|
||||
INSTALL f
|
||||
CHANGELOG f
|
||||
CHANGES f
|
||||
NEWS f
|
||||
USAGE f
|
||||
aclocal.m4 f
|
||||
config.h.in f
|
||||
configure f
|
||||
configure.in f
|
||||
Makefile.in f
|
||||
ansi_stdlib.h f
|
||||
chardefs.h f
|
||||
history.h f
|
||||
histlib.h f
|
||||
keymaps.h f
|
||||
posixdir.h f
|
||||
posixjmp.h f
|
||||
posixstat.h f
|
||||
readline.h f
|
||||
rlconf.h f
|
||||
rldefs.h f
|
||||
rlmbutil.h f
|
||||
rlprivate.h f
|
||||
rlshell.h f
|
||||
rlstdc.h f
|
||||
rltty.h f
|
||||
rltypedefs.h f
|
||||
rlwinsize.h f
|
||||
tcap.h f
|
||||
tilde.h f
|
||||
xmalloc.h f
|
||||
bind.c f
|
||||
callback.c f
|
||||
compat.c f
|
||||
complete.c f
|
||||
display.c f
|
||||
emacs_keymap.c f
|
||||
funmap.c f
|
||||
input.c f
|
||||
isearch.c f
|
||||
keymaps.c f
|
||||
kill.c f
|
||||
macro.c f
|
||||
mbutil.c f
|
||||
misc.c f
|
||||
nls.c f
|
||||
parens.c f
|
||||
readline.c f
|
||||
rltty.c f
|
||||
savestring.c f
|
||||
search.c f
|
||||
shell.c f
|
||||
signals.c f
|
||||
terminal.c f
|
||||
text.c f
|
||||
tilde.c f
|
||||
undo.c f
|
||||
util.c f
|
||||
vi_keymap.c f
|
||||
vi_mode.c f
|
||||
xmalloc.c f
|
||||
history.c f
|
||||
histexpand.c f
|
||||
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/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
|
||||
doc/texi2html f
|
||||
examples/Makefile.in f
|
||||
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/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
|
||||
doc/rluserman.ps f
|
||||
doc/readline.dvi f
|
||||
doc/history.dvi f
|
||||
doc/rluserman.dvi f
|
||||
doc/readline.info f
|
||||
doc/history.info f
|
||||
doc/rluserman.info f
|
||||
doc/readline.html f
|
||||
doc/history.html f
|
||||
doc/rluserman.html f
|
||||
doc/readline.0 f
|
||||
doc/history.0 f
|
||||
doc/readline_3.ps f
|
||||
doc/history_3.ps f
|
||||
doc/history.pdf f
|
||||
doc/readline.pdf f
|
||||
doc/rluserman.pdf f
|
4
extern/editline/Makefile.am
vendored
Normal file
4
extern/editline/Makefile.am
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
AUTOMAKE_OPTIONS = foreign
|
||||
|
||||
SUBDIRS = src
|
1064
extern/editline/Makefile.in
vendored
1064
extern/editline/Makefile.in
vendored
File diff suppressed because it is too large
Load Diff
32
extern/editline/NEWS
vendored
32
extern/editline/NEWS
vendored
@ -1,32 +0,0 @@
|
||||
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.
|
186
extern/editline/README
vendored
186
extern/editline/README
vendored
@ -1,186 +0,0 @@
|
||||
Introduction
|
||||
============
|
||||
|
||||
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
|
||||
Emacs and vi editing modes are available. The Readline library includes
|
||||
additional functions to maintain a list of previously-entered command
|
||||
lines, to recall and perhaps reedit those lines, and perform csh-like
|
||||
history expansion on previous commands.
|
||||
|
||||
The history facilites are also placed into a separate library, the
|
||||
History library, as part of the build process. The History library
|
||||
may be used without Readline in applications which desire its
|
||||
capabilities.
|
||||
|
||||
The Readline library is free software, distributed under the terms of
|
||||
the [GNU] General Public License, version 2. For more information, see
|
||||
the file COPYING.
|
||||
|
||||
To build the library, try typing `./configure', then `make'. The
|
||||
configuration process is automated, so no further intervention should
|
||||
be necessary. Readline builds with `gcc' by default if it is
|
||||
available. If you want to use `cc' instead, type
|
||||
|
||||
CC=cc ./configure
|
||||
|
||||
if you are using a Bourne-style shell. If you are not, the following
|
||||
may work:
|
||||
|
||||
env CC=cc ./configure
|
||||
|
||||
Read the file INSTALL in this directory for more information about how
|
||||
to customize and control the build process.
|
||||
|
||||
The file rlconf.h contains C preprocessor defines that enable and disable
|
||||
certain Readline features.
|
||||
|
||||
The special make target `everything' will build the static and shared
|
||||
libraries (if the target platform supports them) and the examples.
|
||||
|
||||
Examples
|
||||
========
|
||||
|
||||
There are several example programs that use Readline features in the
|
||||
examples directory. The `rl' program is of particular interest. It
|
||||
is a command-line interface to Readline, suitable for use in shell
|
||||
scripts in place of `read'.
|
||||
|
||||
Shared Libraries
|
||||
================
|
||||
|
||||
There is skeletal support for building shared versions of the
|
||||
Readline and History libraries. The configure script creates
|
||||
a Makefile in the `shlib' subdirectory, and typing `make shared'
|
||||
will cause shared versions of the Readline and History libraries
|
||||
to be built on supported platforms.
|
||||
|
||||
If `configure' is given the `--enable-shared' option, it will attempt
|
||||
to build the shared libraries by default on supported platforms.
|
||||
|
||||
Configure calls the script support/shobj-conf to test whether or
|
||||
not shared library creation is supported and to generate the values
|
||||
of variables that are substituted into shlib/Makefile. If you
|
||||
try to build shared libraries on an unsupported platform, `make'
|
||||
will display a message asking you to update support/shobj-conf for
|
||||
your platform.
|
||||
|
||||
If you need to update support/shobj-conf, you will need to create
|
||||
a `stanza' for your operating system and compiler. The script uses
|
||||
the value of host_os and ${CC} as determined by configure. For
|
||||
instance, FreeBSD 4.2 with any version of gcc is identified as
|
||||
`freebsd4.2-gcc*'.
|
||||
|
||||
In the stanza for your operating system-compiler pair, you will need to
|
||||
define several variables. They are:
|
||||
|
||||
SHOBJ_CC The C compiler used to compile source files into shareable
|
||||
object files. This is normally set to the value of ${CC}
|
||||
by configure, and should not need to be changed.
|
||||
|
||||
SHOBJ_CFLAGS Flags to pass to the C compiler ($SHOBJ_CC) to create
|
||||
position-independent code. If you are using gcc, this
|
||||
should probably be set to `-fpic'.
|
||||
|
||||
SHOBJ_LD The link editor to be used to create the shared library from
|
||||
the object files created by $SHOBJ_CC. If you are using
|
||||
gcc, a value of `gcc' will probably work.
|
||||
|
||||
SHOBJ_LDFLAGS Flags to pass to SHOBJ_LD to enable shared object creation.
|
||||
If you are using gcc, `-shared' may be all that is necessary.
|
||||
These should be the flags needed for generic shared object
|
||||
creation.
|
||||
|
||||
SHLIB_XLDFLAGS Additional flags to pass to SHOBJ_LD for shared library
|
||||
creation. Many systems use the -R option to the link
|
||||
editor to embed a path within the library for run-time
|
||||
library searches. A reasonable value for such systems would
|
||||
be `-R$(libdir)'.
|
||||
|
||||
SHLIB_LIBS Any additional libraries that shared libraries should be
|
||||
linked against when they are created.
|
||||
|
||||
SHLIB_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'.
|
||||
|
||||
SHLIB_LIBVERSION The string to append to the filename to indicate the version
|
||||
of the shared library. It should begin with $(SHLIB_LIBSUFF),
|
||||
and possibly include version information that allows the
|
||||
run-time loader to load the version of the shared library
|
||||
appropriate for a particular program. Systems using shared
|
||||
libraries similar to SunOS 4.x use major and minor library
|
||||
version numbers; for those systems a value of
|
||||
`$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)$(SHLIB_MINOR)' is appropriate.
|
||||
Systems based on System V Release 4 don't use minor version
|
||||
numbers; use `$(SHLIB_LIBSUFF).$(SHLIB_MAJOR)' on those systems.
|
||||
Other Unix versions use different schemes.
|
||||
|
||||
SHLIB_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.
|
||||
|
||||
You should look at the existing stanzas in support/shobj-conf for ideas.
|
||||
|
||||
Once you have updated support/shobj-conf, re-run configure and type
|
||||
`make shared'. The shared libraries will be created in the shlib
|
||||
subdirectory.
|
||||
|
||||
If shared libraries are created, `make install' will install them.
|
||||
You may install only the shared libraries by running `make
|
||||
install-shared' from the top-level build directory. Running `make
|
||||
install' in the shlib subdirectory will also work. If you don't want
|
||||
to install any created shared libraries, run `make install-static'.
|
||||
|
||||
Documentation
|
||||
=============
|
||||
|
||||
The documentation for the Readline and History libraries appears in
|
||||
the `doc' subdirectory. There are three texinfo files and a
|
||||
Unix-style manual page describing the facilities available in the
|
||||
Readline library. The texinfo files include both user and
|
||||
programmer's manuals. HTML versions of the manuals appear in the
|
||||
`doc' subdirectory as well.
|
||||
|
||||
Reporting Bugs
|
||||
==============
|
||||
|
||||
Bug reports for Readline should be sent to:
|
||||
|
||||
bug-readline@gnu.org
|
||||
|
||||
When reporting a bug, please include the following information:
|
||||
|
||||
* the version number and release status of Readline (e.g., 4.2-release)
|
||||
* the machine and OS that it is running on
|
||||
* a list of the compilation flags or the contents of `config.h', if
|
||||
appropriate
|
||||
* a description of the bug
|
||||
* a recipe for recreating the bug reliably
|
||||
* a fix for the bug if you have one!
|
||||
|
||||
If you would like to contact the Readline maintainer directly, send mail
|
||||
to bash-maintainers@gnu.org.
|
||||
|
||||
Since Readline is developed along with bash, the bug-bash@gnu.org mailing
|
||||
list (mirrored to the Usenet newsgroup gnu.bash.bug) often contains
|
||||
Readline bug reports and fixes.
|
||||
|
||||
Chet Ramey
|
||||
chet@po.cwru.edu
|
1
extern/editline/THANKS
vendored
Normal file
1
extern/editline/THANKS
vendored
Normal file
@ -0,0 +1 @@
|
||||
Thanks to the NetBSD Project maintainers of libedit!
|
37
extern/editline/USAGE
vendored
37
extern/editline/USAGE
vendored
@ -1,37 +0,0 @@
|
||||
From rms@gnu.org Thu Jul 22 20:37:55 1999
|
||||
Flags: 10
|
||||
Return-Path: rms@gnu.org
|
||||
Received: from arthur.INS.CWRU.Edu (root@arthur.INS.CWRU.Edu [129.22.8.215]) by odin.INS.CWRU.Edu with ESMTP (8.8.6+cwru/CWRU-2.4-ins)
|
||||
id UAA25349; Thu, 22 Jul 1999 20:37:54 -0400 (EDT) (from rms@gnu.org for <chet@odin.INS.CWRU.Edu>)
|
||||
Received: from nike.ins.cwru.edu (root@nike.INS.CWRU.Edu [129.22.8.219]) by arthur.INS.CWRU.Edu with ESMTP (8.8.8+cwru/CWRU-3.6)
|
||||
id UAA05311; Thu, 22 Jul 1999 20:37:51 -0400 (EDT) (from rms@gnu.org for <chet@po.cwru.edu>)
|
||||
Received: from pele.santafe.edu (pele.santafe.edu [192.12.12.119]) by nike.ins.cwru.edu with ESMTP (8.8.7/CWRU-2.5-bsdi)
|
||||
id UAA13350; Thu, 22 Jul 1999 20:37:50 -0400 (EDT) (from rms@gnu.org for <chet@nike.ins.cwru.edu>)
|
||||
Received: from wijiji.santafe.edu (wijiji [192.12.12.5])
|
||||
by pele.santafe.edu (8.9.1/8.9.1) with ESMTP id SAA10831
|
||||
for <chet@nike.ins.cwru.edu>; Thu, 22 Jul 1999 18:37:47 -0600 (MDT)
|
||||
Received: (from rms@localhost)
|
||||
by wijiji.santafe.edu (8.9.1b+Sun/8.9.1) id SAA01089;
|
||||
Thu, 22 Jul 1999 18:37:46 -0600 (MDT)
|
||||
Date: Thu, 22 Jul 1999 18:37:46 -0600 (MDT)
|
||||
Message-Id: <199907230037.SAA01089@wijiji.santafe.edu>
|
||||
X-Authentication-Warning: wijiji.santafe.edu: rms set sender to rms@gnu.org using -f
|
||||
From: Richard Stallman <rms@gnu.org>
|
||||
To: chet@nike.ins.cwru.edu
|
||||
Subject: Use of Readline
|
||||
Reply-to: rms@gnu.org
|
||||
|
||||
I think Allbery's suggestion is a good one. So please add this text
|
||||
in a suitable place. Please don't put it in the GPL itself; that
|
||||
should be the same as the GPL everywhere else. Putting it in the
|
||||
README and/or the documentation would be a good idea.
|
||||
|
||||
|
||||
======================================================================
|
||||
Our position on the use of Readline through a shared-library linking
|
||||
mechanism is that there is no legal difference between shared-library
|
||||
linking and static linking--either kind of linking combines various
|
||||
modules into a single larger work. The conditions for using Readline
|
||||
in a larger work are stated in section 3 of the GNU GPL.
|
||||
|
||||
|
67
extern/editline/acinclude.m4
vendored
Normal file
67
extern/editline/acinclude.m4
vendored
Normal file
@ -0,0 +1,67 @@
|
||||
|
||||
dnl
|
||||
dnl read lib version from file (and trim trailing newline)
|
||||
dnl
|
||||
define([EL_RELEASE], [patsubst(esyscmd([. src/shlib_version; echo $major.$minor]), [
|
||||
])])
|
||||
|
||||
dnl
|
||||
dnl read cvsexport timestamp from file (and trim trailing newline)
|
||||
dnl
|
||||
dnl define([EL_TIMESTAMP_CVSEXPORT], [patsubst(esyscmd([cat patches/timestamp.cvsexport]), [
|
||||
define([EL_TIMESTAMP_CVSEXPORT], [patsubst(esyscmd([date +"%Y%m%d"]), [
|
||||
])])
|
||||
|
||||
|
||||
dnl
|
||||
dnl NetBSD use the -mdoc macro package for manpages, but e.g.
|
||||
dnl AIX and Solaris only support the -man package.
|
||||
dnl
|
||||
AC_DEFUN([EL_MANTYPE],
|
||||
[
|
||||
MANTYPE=
|
||||
TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
|
||||
AC_PATH_PROGS(NROFF, nroff awf, /bin/false, $TestPath)
|
||||
if ${NROFF} -mdoc ${srcdir}/doc/editrc.5.roff >/dev/null 2>&1; then
|
||||
MANTYPE=mdoc
|
||||
fi
|
||||
AC_SUBST(MANTYPE)
|
||||
])
|
||||
|
||||
|
||||
dnl
|
||||
dnl Check if getpwnam_r and getpwuid_r are POSIX.1 compatible
|
||||
dnl POSIX draft version returns 'struct passwd *' (used on Solaris)
|
||||
dnl NOTE: getpwent_r is not POSIX so we always use getpwent
|
||||
dnl
|
||||
AC_DEFUN([EL_GETPW_R_POSIX],
|
||||
[
|
||||
AC_MSG_CHECKING([whether getpwnam_r and getpwuid_r are posix like])
|
||||
# The prototype for the POSIX version is:
|
||||
# int getpwnam_r(char *, struct passwd *, char *, size_t, struct passwd **)
|
||||
# int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **);
|
||||
AC_TRY_LINK([#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>],
|
||||
[getpwnam_r(NULL, NULL, NULL, (size_t)0, NULL);
|
||||
getpwuid_r((uid_t)0, NULL, NULL, (size_t)0, NULL);],
|
||||
[AC_DEFINE([HAVE_GETPW_R_POSIX], 1, [Define to 1 if you have getpwnam_r and getpwuid_r that are POSIX.1 compatible.])
|
||||
AC_MSG_RESULT(yes)],
|
||||
[AC_MSG_RESULT(no)])
|
||||
])
|
||||
|
||||
AC_DEFUN([EL_GETPW_R_DRAFT],
|
||||
[
|
||||
AC_MSG_CHECKING([whether getpwnam_r and getpwuid_r are posix _draft_ like])
|
||||
# The prototype for the POSIX draft version is:
|
||||
# struct passwd *getpwuid_r(uid_t, struct passwd *, char *, int);
|
||||
# struct passwd *getpwnam_r(char *, struct passwd *, char *, int);
|
||||
AC_TRY_LINK([#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>],
|
||||
[getpwnam_r(NULL, NULL, NULL, (size_t)0);
|
||||
getpwuid_r((uid_t)0, NULL, NULL, (size_t)0);],
|
||||
[AC_DEFINE([HAVE_GETPW_R_DRAFT], 1, [Define to 1 if you have getpwnam_r and getpwuid_r that are draft POSIX.1 versions.])
|
||||
AC_MSG_RESULT(yes)],
|
||||
[AC_MSG_RESULT(no)])
|
||||
])
|
10955
extern/editline/aclocal.m4
vendored
10955
extern/editline/aclocal.m4
vendored
File diff suppressed because it is too large
Load Diff
54
extern/editline/ansi_stdlib.h
vendored
54
extern/editline/ansi_stdlib.h
vendored
@ -1,54 +0,0 @@
|
||||
/* ansi_stdlib.h -- An ANSI Standard stdlib.h. */
|
||||
/* A minimal stdlib.h containing extern declarations for those functions
|
||||
that bash uses. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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.
|
||||
|
||||
Bash 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 Bash; see the file COPYING. If not, write to the Free Software
|
||||
Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_STDLIB_H_)
|
||||
#define _STDLIB_H_ 1
|
||||
|
||||
/* String conversion functions. */
|
||||
extern int atoi ();
|
||||
|
||||
extern double atof ();
|
||||
extern double strtod ();
|
||||
|
||||
/* Memory allocation functions. */
|
||||
/* Generic pointer type. */
|
||||
#ifndef PTR_T
|
||||
|
||||
#if defined (__STDC__)
|
||||
# define PTR_T void *
|
||||
#else
|
||||
# define PTR_T char *
|
||||
#endif
|
||||
|
||||
#endif /* PTR_T */
|
||||
|
||||
extern PTR_T malloc ();
|
||||
extern PTR_T realloc ();
|
||||
extern void free ();
|
||||
|
||||
/* Other miscellaneous functions. */
|
||||
extern void abort ();
|
||||
extern void exit ();
|
||||
extern char *getenv ();
|
||||
extern void qsort ();
|
||||
|
||||
#endif /* _STDLIB_H */
|
2279
extern/editline/bind.c
vendored
2279
extern/editline/bind.c
vendored
File diff suppressed because it is too large
Load Diff
260
extern/editline/callback.c
vendored
260
extern/editline/callback.c
vendored
@ -1,260 +0,0 @@
|
||||
/* callback.c -- functions to use readline as an X `callback' mechanism. */
|
||||
|
||||
/* 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.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include "rlconf.h"
|
||||
|
||||
#if defined (READLINE_CALLBACKS)
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#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 */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Allow using readline in situations where a program may have multiple
|
||||
things to handle at once, and dispatches them via select(). Call
|
||||
rl_callback_handler_install() with the prompt and a function to call
|
||||
whenever a complete line of input is ready. The user must then
|
||||
call rl_callback_read_char() every time some input is available, and
|
||||
rl_callback_read_char() will call the user's function with the complete
|
||||
text read in at each end of line. The terminal is kept prepped and
|
||||
signals handled all the time, except during calls to the user's function. */
|
||||
|
||||
rl_vcpfunc_t *rl_linefunc; /* user callback function */
|
||||
static int in_handler; /* terminal_prepped and signals set? */
|
||||
|
||||
/* Make sure the terminal is set up, initialize readline, and prompt. */
|
||||
static void
|
||||
_rl_callback_newline ()
|
||||
{
|
||||
rl_initialize ();
|
||||
|
||||
if (in_handler == 0)
|
||||
{
|
||||
in_handler = 1;
|
||||
|
||||
if (rl_prep_term_function)
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_set_signals ();
|
||||
#endif
|
||||
}
|
||||
|
||||
readline_internal_setup ();
|
||||
}
|
||||
|
||||
/* Install a readline handler, set up the terminal, and issue the prompt. */
|
||||
void
|
||||
rl_callback_handler_install (prompt, linefunc)
|
||||
const char *prompt;
|
||||
rl_vcpfunc_t *linefunc;
|
||||
{
|
||||
rl_set_prompt (prompt);
|
||||
RL_SETSTATE (RL_STATE_CALLBACK);
|
||||
rl_linefunc = linefunc;
|
||||
_rl_callback_newline ();
|
||||
}
|
||||
|
||||
/* Read one character, and dispatch to the handler if it ends the line. */
|
||||
void
|
||||
rl_callback_read_char ()
|
||||
{
|
||||
char *line;
|
||||
int eof, jcode;
|
||||
static procenv_t olevel;
|
||||
|
||||
if (rl_linefunc == NULL)
|
||||
{
|
||||
fprintf (stderr, "readline: readline_callback_read_char() called with no handler!\r\n");
|
||||
abort ();
|
||||
}
|
||||
|
||||
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 (;;)
|
||||
{
|
||||
if (rl_done)
|
||||
{
|
||||
line = readline_internal_teardown (eof);
|
||||
|
||||
if (rl_deprep_term_function)
|
||||
(*rl_deprep_term_function) ();
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
rl_clear_signals ();
|
||||
#endif
|
||||
in_handler = 0;
|
||||
(*rl_linefunc) (line);
|
||||
|
||||
/* If the user did not clear out the line, do it for him. */
|
||||
if (rl_line_buffer[0])
|
||||
_rl_init_line_state ();
|
||||
|
||||
/* Redisplay the prompt if readline_handler_{install,remove}
|
||||
not called. */
|
||||
if (in_handler == 0 && rl_linefunc)
|
||||
_rl_callback_newline ();
|
||||
}
|
||||
if (rl_pending_input || _rl_pushed_input_available () || RL_ISSTATE (RL_STATE_MACROINPUT))
|
||||
eof = readline_internal_char ();
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove the handler, and make sure the terminal is in its normal state. */
|
||||
void
|
||||
rl_callback_handler_remove ()
|
||||
{
|
||||
rl_linefunc = NULL;
|
||||
RL_UNSETSTATE (RL_STATE_CALLBACK);
|
||||
if (in_handler)
|
||||
{
|
||||
in_handler = 0;
|
||||
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
|
165
extern/editline/chardefs.h
vendored
165
extern/editline/chardefs.h
vendored
@ -1,165 +0,0 @@
|
||||
/* chardefs.h -- Character definitions for readline. */
|
||||
|
||||
/* Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#ifndef _CHARDEFS_H_
|
||||
#define _CHARDEFS_H_
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# if defined (HAVE_STRING_H)
|
||||
# if ! defined (STDC_HEADERS) && defined (HAVE_MEMORY_H)
|
||||
# include <memory.h>
|
||||
# endif
|
||||
# include <string.h>
|
||||
# endif /* HAVE_STRING_H */
|
||||
# if defined (HAVE_STRINGS_H)
|
||||
# include <strings.h>
|
||||
# endif /* HAVE_STRINGS_H */
|
||||
#else
|
||||
# include <string.h>
|
||||
#endif /* !HAVE_CONFIG_H */
|
||||
|
||||
#ifndef whitespace
|
||||
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
|
||||
#endif
|
||||
|
||||
#ifdef CTRL
|
||||
# undef CTRL
|
||||
#endif
|
||||
#ifdef UNCTRL
|
||||
# undef UNCTRL
|
||||
#endif
|
||||
|
||||
/* Some character stuff. */
|
||||
#define control_character_threshold 0x020 /* Smaller than this is control. */
|
||||
#define control_character_mask 0x1f /* 0x20 - 1 */
|
||||
#define meta_character_threshold 0x07f /* Larger than this is Meta. */
|
||||
#define control_character_bit 0x40 /* 0x000000, must be off. */
|
||||
#define meta_character_bit 0x080 /* x0000000, must be on. */
|
||||
#define largest_char 255 /* Largest character value. */
|
||||
|
||||
#define CTRL_CHAR(c) ((c) < control_character_threshold && (((c) & 0x80) == 0))
|
||||
#define META_CHAR(c) ((c) > meta_character_threshold && (c) <= largest_char)
|
||||
|
||||
#define CTRL(c) ((c) & control_character_mask)
|
||||
#define META(c) ((c) | meta_character_bit)
|
||||
|
||||
#define UNMETA(c) ((c) & (~meta_character_bit))
|
||||
#define UNCTRL(c) _rl_to_upper(((c)|control_character_bit))
|
||||
|
||||
#if defined STDC_HEADERS || (!defined (isascii) && !defined (HAVE_ISASCII))
|
||||
# define IN_CTYPE_DOMAIN(c) 1
|
||||
#else
|
||||
# define IN_CTYPE_DOMAIN(c) isascii(c)
|
||||
#endif
|
||||
|
||||
#if !defined (isxdigit) && !defined (HAVE_ISXDIGIT)
|
||||
# define isxdigit(c) (isdigit((c)) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F'))
|
||||
#endif
|
||||
|
||||
#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))
|
||||
#define ISLOWER(c) (IN_CTYPE_DOMAIN (c) && islower (c))
|
||||
#define ISPRINT(c) (IN_CTYPE_DOMAIN (c) && isprint (c))
|
||||
#define ISUPPER(c) (IN_CTYPE_DOMAIN (c) && isupper (c))
|
||||
#define ISXDIGIT(c) (IN_CTYPE_DOMAIN (c) && isxdigit (c))
|
||||
|
||||
#define _rl_lowercase_p(c) (NON_NEGATIVE(c) && ISLOWER(c))
|
||||
#define _rl_uppercase_p(c) (NON_NEGATIVE(c) && ISUPPER(c))
|
||||
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
|
||||
|
||||
#define _rl_pure_alphabetic(c) (NON_NEGATIVE(c) && ISALPHA(c))
|
||||
#define ALPHABETIC(c) (NON_NEGATIVE(c) && ISALNUM(c))
|
||||
|
||||
#ifndef _rl_to_upper
|
||||
# define _rl_to_upper(c) (_rl_lowercase_p(c) ? toupper((unsigned char)c) : (c))
|
||||
# define _rl_to_lower(c) (_rl_uppercase_p(c) ? tolower((unsigned char)c) : (c))
|
||||
#endif
|
||||
|
||||
#ifndef _rl_digit_value
|
||||
# define _rl_digit_value(x) ((x) - '0')
|
||||
#endif
|
||||
|
||||
#ifndef _rl_isident
|
||||
# define _rl_isident(c) (ISALNUM(c) || (c) == '_')
|
||||
#endif
|
||||
|
||||
#ifndef ISOCTAL
|
||||
# define ISOCTAL(c) ((c) >= '0' && (c) <= '7')
|
||||
#endif
|
||||
#define OCTVALUE(c) ((c) - '0')
|
||||
|
||||
#define HEXVALUE(c) \
|
||||
(((c) >= 'a' && (c) <= 'f') \
|
||||
? (c)-'a'+10 \
|
||||
: (c) >= 'A' && (c) <= 'F' ? (c)-'A'+10 : (c)-'0')
|
||||
|
||||
#ifndef NEWLINE
|
||||
#define NEWLINE '\n'
|
||||
#endif
|
||||
|
||||
#ifndef RETURN
|
||||
#define RETURN CTRL('M')
|
||||
#endif
|
||||
|
||||
#ifndef RUBOUT
|
||||
#define RUBOUT 0x7f
|
||||
#endif
|
||||
|
||||
#ifndef TAB
|
||||
#define TAB '\t'
|
||||
#endif
|
||||
|
||||
#ifdef ABORT_CHAR
|
||||
#undef ABORT_CHAR
|
||||
#endif
|
||||
#define ABORT_CHAR CTRL('G')
|
||||
|
||||
#ifdef PAGE
|
||||
#undef PAGE
|
||||
#endif
|
||||
#define PAGE CTRL('L')
|
||||
|
||||
#ifdef SPACE
|
||||
#undef SPACE
|
||||
#endif
|
||||
#define SPACE ' ' /* XXX - was 0x20 */
|
||||
|
||||
#ifdef ESC
|
||||
#undef ESC
|
||||
#endif
|
||||
#define ESC CTRL('[')
|
||||
|
||||
#endif /* _CHARDEFS_H_ */
|
113
extern/editline/compat.c
vendored
113
extern/editline/compat.c
vendored
@ -1,113 +0,0 @@
|
||||
/* compat.c -- backwards compatibility functions. */
|
||||
|
||||
/* Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "rlstdc.h"
|
||||
#include "rltypedefs.h"
|
||||
|
||||
extern void rl_free_undo_list PARAMS((void));
|
||||
extern int rl_maybe_save_line PARAMS((void));
|
||||
extern int rl_maybe_unsave_line PARAMS((void));
|
||||
extern int rl_maybe_replace_line PARAMS((void));
|
||||
|
||||
extern int rl_crlf PARAMS((void));
|
||||
extern int rl_ding PARAMS((void));
|
||||
extern int rl_alphabetic PARAMS((int));
|
||||
|
||||
extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
|
||||
extern char *rl_username_completion_function PARAMS((const char *, int));
|
||||
extern char *rl_filename_completion_function PARAMS((const char *, int));
|
||||
|
||||
/* Provide backwards-compatible entry points for old function names. */
|
||||
|
||||
void
|
||||
free_undo_list ()
|
||||
{
|
||||
rl_free_undo_list ();
|
||||
}
|
||||
|
||||
int
|
||||
maybe_replace_line ()
|
||||
{
|
||||
return rl_maybe_replace_line ();
|
||||
}
|
||||
|
||||
int
|
||||
maybe_save_line ()
|
||||
{
|
||||
return rl_maybe_save_line ();
|
||||
}
|
||||
|
||||
int
|
||||
maybe_unsave_line ()
|
||||
{
|
||||
return rl_maybe_unsave_line ();
|
||||
}
|
||||
|
||||
int
|
||||
ding ()
|
||||
{
|
||||
return rl_ding ();
|
||||
}
|
||||
|
||||
int
|
||||
crlf ()
|
||||
{
|
||||
return rl_crlf ();
|
||||
}
|
||||
|
||||
int
|
||||
alphabetic (c)
|
||||
int c;
|
||||
{
|
||||
return rl_alphabetic (c);
|
||||
}
|
||||
|
||||
char **
|
||||
completion_matches (s, f)
|
||||
const char *s;
|
||||
rl_compentry_func_t *f;
|
||||
{
|
||||
return rl_completion_matches (s, f);
|
||||
}
|
||||
|
||||
char *
|
||||
username_completion_function (s, i)
|
||||
const char *s;
|
||||
int i;
|
||||
{
|
||||
return rl_username_completion_function (s, i);
|
||||
}
|
||||
|
||||
char *
|
||||
filename_completion_function (s, i)
|
||||
const char *s;
|
||||
int i;
|
||||
{
|
||||
return rl_filename_completion_function (s, i);
|
||||
}
|
2211
extern/editline/complete.c
vendored
2211
extern/editline/complete.c
vendored
File diff suppressed because it is too large
Load Diff
276
extern/editline/support/config.guess → extern/editline/config.guess
vendored
Executable file → Normal file
276
extern/editline/support/config.guess → extern/editline/config.guess
vendored
Executable file → Normal file
@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# Attempt to guess a canonical system name.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2002-11-30'
|
||||
timestamp='2004-08-13'
|
||||
|
||||
# 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
|
||||
@ -53,7 +53,7 @@ version="\
|
||||
GNU config.guess ($timestamp)
|
||||
|
||||
Originally written by Per Bothner.
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
@ -98,14 +98,18 @@ trap 'exit 1' 1 2 15
|
||||
# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
|
||||
# use `HOST_CC' if defined, but it is deprecated.
|
||||
|
||||
# This shell variable is my proudest work .. or something. --bje
|
||||
# Portable tmp directory creation inspired by the Autoconf team.
|
||||
|
||||
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 ;
|
||||
set_cc_for_build='
|
||||
trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
|
||||
trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
|
||||
: ${TMPDIR=/tmp} ;
|
||||
{ tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
|
||||
{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
|
||||
{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
|
||||
{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
|
||||
dummy=$tmp/dummy ;
|
||||
tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
|
||||
case $CC_FOR_BUILD,$HOST_CC,$CC in
|
||||
,,) echo "int x;" > $dummy.c ;
|
||||
for c in cc gcc c89 c99 ; do
|
||||
@ -113,15 +117,13 @@ case $CC_FOR_BUILD,$HOST_CC,$CC in
|
||||
CC_FOR_BUILD="$c"; break ;
|
||||
fi ;
|
||||
done ;
|
||||
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 ;
|
||||
unset files'
|
||||
esac ;'
|
||||
|
||||
# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
|
||||
# (ghazi@noc.rutgers.edu 1994-08-24)
|
||||
@ -195,15 +197,21 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
|
||||
echo "${machine}-${os}${release}"
|
||||
exit 0 ;;
|
||||
amd64:OpenBSD:*:*)
|
||||
echo x86_64-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
amiga:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
arc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
cats:OpenBSD:*:*)
|
||||
echo arm-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
hp300:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
luna88k:OpenBSD:*:*)
|
||||
echo m88k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
mac68k:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@ -219,86 +227,76 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
mvmeppc:OpenBSD:*:*)
|
||||
echo powerpc-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
pmax:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sgi:OpenBSD:*:*)
|
||||
echo mipseb-unknown-openbsd${UNAME_RELEASE}
|
||||
echo mips64-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
sun3:OpenBSD:*:*)
|
||||
echo m68k-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
wgrisc:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:OpenBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:ekkoBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
macppc:MirBSD:*:*)
|
||||
echo powerppc-unknown-mirbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:MirBSD:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
alpha:OSF1:*:*)
|
||||
if test $UNAME_RELEASE = "V4.0"; then
|
||||
case $UNAME_RELEASE in
|
||||
*4.0)
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
|
||||
fi
|
||||
;;
|
||||
*5.*)
|
||||
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
|
||||
;;
|
||||
esac
|
||||
# According to Compaq, /usr/sbin/psrinfo has been available on
|
||||
# OSF/1 and Tru64 systems produced since 1995. I hope that
|
||||
# covers most systems running today. This code pipes the CPU
|
||||
# types through head -n 1, so we only detect the type of CPU 0.
|
||||
ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
|
||||
case "$ALPHA_CPU_TYPE" in
|
||||
"EV4 (21064)")
|
||||
UNAME_MACHINE="alpha" ;;
|
||||
"EV4.5 (21064)")
|
||||
UNAME_MACHINE="alpha" ;;
|
||||
"LCA4 (21066/21068)")
|
||||
UNAME_MACHINE="alpha" ;;
|
||||
"EV5 (21164)")
|
||||
UNAME_MACHINE="alphaev5" ;;
|
||||
"EV5.6 (21164A)")
|
||||
UNAME_MACHINE="alphaev56" ;;
|
||||
"EV5.6 (21164PC)")
|
||||
UNAME_MACHINE="alphapca56" ;;
|
||||
"EV5.7 (21164PC)")
|
||||
UNAME_MACHINE="alphapca57" ;;
|
||||
"EV6 (21264)")
|
||||
UNAME_MACHINE="alphaev6" ;;
|
||||
"EV6.7 (21264A)")
|
||||
UNAME_MACHINE="alphaev67" ;;
|
||||
"EV6.8CB (21264C)")
|
||||
UNAME_MACHINE="alphaev68" ;;
|
||||
"EV6.8AL (21264B)")
|
||||
UNAME_MACHINE="alphaev68" ;;
|
||||
"EV6.8CX (21264D)")
|
||||
UNAME_MACHINE="alphaev68" ;;
|
||||
"EV6.9A (21264/EV69A)")
|
||||
UNAME_MACHINE="alphaev69" ;;
|
||||
"EV7 (21364)")
|
||||
UNAME_MACHINE="alphaev7" ;;
|
||||
"EV7.9 (21364A)")
|
||||
UNAME_MACHINE="alphaev79" ;;
|
||||
esac
|
||||
# A Pn.n version is a patched version.
|
||||
# A Vn.n version is a released version.
|
||||
# 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:
|
||||
.byte 37,100,45,37,120,10,0 # "%d-%x\n"
|
||||
|
||||
.text
|
||||
.globl main
|
||||
.align 4
|
||||
.ent main
|
||||
main:
|
||||
.frame \$30,16,\$26,0
|
||||
ldgp \$29,0(\$27)
|
||||
.prologue 1
|
||||
.long 0x47e03d80 # implver \$0
|
||||
lda \$2,-1
|
||||
.long 0x47e20c21 # amask \$2,\$1
|
||||
lda \$16,\$Lformat
|
||||
mov \$0,\$17
|
||||
not \$1,\$18
|
||||
jsr \$26,printf
|
||||
ldgp \$29,0(\$26)
|
||||
mov 0,\$16
|
||||
jsr \$26,exit
|
||||
.end main
|
||||
EOF
|
||||
$CC_FOR_BUILD -o $dummy $dummy.s 2>/dev/null
|
||||
if test "$?" = 0 ; then
|
||||
case `$dummy` in
|
||||
0-0)
|
||||
UNAME_MACHINE="alpha"
|
||||
;;
|
||||
1-0)
|
||||
UNAME_MACHINE="alphaev5"
|
||||
;;
|
||||
1-1)
|
||||
UNAME_MACHINE="alphaev56"
|
||||
;;
|
||||
1-101)
|
||||
UNAME_MACHINE="alphapca56"
|
||||
;;
|
||||
2-303)
|
||||
UNAME_MACHINE="alphaev6"
|
||||
;;
|
||||
2-307)
|
||||
UNAME_MACHINE="alphaev67"
|
||||
;;
|
||||
2-1307)
|
||||
UNAME_MACHINE="alphaev68"
|
||||
;;
|
||||
3-1307)
|
||||
UNAME_MACHINE="alphaev7"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
rm -f $dummy.s $dummy && rmdir $tmpdir
|
||||
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
||||
echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
||||
exit 0 ;;
|
||||
Alpha\ *:Windows_NT*:*)
|
||||
# How do we know it's Interix rather than the generic POSIX subsystem?
|
||||
@ -321,6 +319,9 @@ EOF
|
||||
*:OS/390:*:*)
|
||||
echo i370-ibm-openedition
|
||||
exit 0 ;;
|
||||
*:OS400:*:*)
|
||||
echo powerpc-ibm-os400
|
||||
exit 0 ;;
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
exit 0;;
|
||||
@ -338,6 +339,9 @@ EOF
|
||||
NILE*:*:*:dcosx)
|
||||
echo pyramid-pyramid-svr4
|
||||
exit 0 ;;
|
||||
DRS?6000:unix:4.0:6*)
|
||||
echo sparc-icl-nx6
|
||||
exit 0 ;;
|
||||
DRS?6000:UNIX_SV:4.2*:7*)
|
||||
case `/usr/bin/uname -p` in
|
||||
sparc) echo sparc-icl-nx7 && exit 0 ;;
|
||||
@ -410,6 +414,9 @@ EOF
|
||||
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
|
||||
echo m68k-unknown-mint${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
m68k:machten:*:*)
|
||||
echo m68k-apple-machten${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
powerpc:machten:*:*)
|
||||
echo powerpc-apple-machten${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@ -450,8 +457,7 @@ EOF
|
||||
EOF
|
||||
$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
|
||||
&& exit 0
|
||||
echo mips-mips-riscos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
Motorola:PowerMAX_OS:*:*)
|
||||
@ -535,8 +541,7 @@ EOF
|
||||
exit(0);
|
||||
}
|
||||
EOF
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
|
||||
echo rs6000-ibm-aix3.2.5
|
||||
elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
|
||||
echo rs6000-ibm-aix3.2.4
|
||||
@ -635,10 +640,20 @@ EOF
|
||||
}
|
||||
EOF
|
||||
(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 && rmdir $tmpdir
|
||||
test -z "$HP_ARCH" && HP_ARCH=hppa
|
||||
fi ;;
|
||||
esac
|
||||
if [ ${HP_ARCH} = "hppa2.0w" ]
|
||||
then
|
||||
# avoid double evaluation of $set_cc_for_build
|
||||
test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
|
||||
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
|
||||
then
|
||||
HP_ARCH="hppa2.0w"
|
||||
else
|
||||
HP_ARCH="hppa64"
|
||||
fi
|
||||
fi
|
||||
echo ${HP_ARCH}-hp-hpux${HPUX_REV}
|
||||
exit 0 ;;
|
||||
ia64:HP-UX:*:*)
|
||||
@ -672,8 +687,7 @@ EOF
|
||||
exit (0);
|
||||
}
|
||||
EOF
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && rm -f $dummy.c $dummy && rmdir $tmpdir && exit 0
|
||||
rm -f $dummy.c $dummy && rmdir $tmpdir
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
|
||||
echo unknown-hitachi-hiuxwe2
|
||||
exit 0 ;;
|
||||
9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
|
||||
@ -731,21 +745,26 @@ EOF
|
||||
CRAY*TS:*:*:*)
|
||||
echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
|
||||
exit 0 ;;
|
||||
CRAY*T3D:*:*:*)
|
||||
echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
|
||||
exit 0 ;;
|
||||
CRAY*T3E:*:*:*)
|
||||
echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
|
||||
exit 0 ;;
|
||||
CRAY*SV1:*:*:*)
|
||||
echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
|
||||
exit 0 ;;
|
||||
*:UNICOS/mp:*:*)
|
||||
echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
|
||||
exit 0 ;;
|
||||
F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
|
||||
FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit 0 ;;
|
||||
5000:UNIX_System_V:4.*:*)
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
|
||||
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit 0 ;;
|
||||
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@ -755,23 +774,8 @@ EOF
|
||||
*:BSD/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
amd64:FreeBSD:*:*)
|
||||
echo x86_64-unknown-freebsd
|
||||
exit 0 ;;
|
||||
*:FreeBSD:*:*)
|
||||
# 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}
|
||||
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
exit 0 ;;
|
||||
i*:CYGWIN*:*)
|
||||
echo ${UNAME_MACHINE}-pc-cygwin
|
||||
@ -782,8 +786,8 @@ EOF
|
||||
i*:PW*:*)
|
||||
echo ${UNAME_MACHINE}-pc-pw32
|
||||
exit 0 ;;
|
||||
x86:Interix*:3*)
|
||||
echo i586-pc-interix3
|
||||
x86:Interix*:[34]*)
|
||||
echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
|
||||
exit 0 ;;
|
||||
[345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
|
||||
echo i${UNAME_MACHINE}-pc-mks
|
||||
@ -804,17 +808,28 @@ EOF
|
||||
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
*:GNU:*:*)
|
||||
# the GNU system
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
exit 0 ;;
|
||||
*:GNU/*:*:*)
|
||||
# other systems with GNU libc and userland
|
||||
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
|
||||
exit 0 ;;
|
||||
i*86:Minix:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-minix
|
||||
exit 0 ;;
|
||||
arm*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit 0 ;;
|
||||
cris:Linux:*:*)
|
||||
echo cris-axis-linux-gnu
|
||||
exit 0 ;;
|
||||
ia64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit 0 ;;
|
||||
m32r*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit 0 ;;
|
||||
m68*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit 0 ;;
|
||||
@ -835,7 +850,6 @@ EOF
|
||||
#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
|
||||
;;
|
||||
mips64:Linux:*:*)
|
||||
@ -855,7 +869,6 @@ EOF
|
||||
#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:*:*)
|
||||
@ -892,6 +905,9 @@ EOF
|
||||
s390:Linux:*:* | s390x:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-ibm-linux
|
||||
exit 0 ;;
|
||||
sh64*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit 0 ;;
|
||||
sh*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-gnu
|
||||
exit 0 ;;
|
||||
@ -949,9 +965,11 @@ EOF
|
||||
LIBC=gnuaout
|
||||
#endif
|
||||
#endif
|
||||
#ifdef __dietlibc__
|
||||
LIBC=dietlibc
|
||||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
|
||||
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
|
||||
;;
|
||||
@ -980,6 +998,9 @@ EOF
|
||||
i*86:atheos:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-atheos
|
||||
exit 0 ;;
|
||||
i*86:syllable:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-syllable
|
||||
exit 0 ;;
|
||||
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@ -1049,9 +1070,9 @@ EOF
|
||||
M680?0:D-NIX:5.3:*)
|
||||
echo m68k-diab-dnix
|
||||
exit 0 ;;
|
||||
M68*:*:R3V[567]*:*)
|
||||
M68*:*:R3V[5678]*:*)
|
||||
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 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0)
|
||||
3[345]??:*: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 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
|
||||
OS_REL=''
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
@ -1149,7 +1170,12 @@ EOF
|
||||
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:Darwin:*:*)
|
||||
echo `uname -p`-apple-darwin${UNAME_RELEASE}
|
||||
UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
|
||||
case $UNAME_PROCESSOR in
|
||||
*86) UNAME_PROCESSOR=i686 ;;
|
||||
unknown) UNAME_PROCESSOR=powerpc ;;
|
||||
esac
|
||||
echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:procnto*:*:* | *:QNX:[0123456789]*:*)
|
||||
UNAME_PROCESSOR=`uname -p`
|
||||
@ -1162,7 +1188,7 @@ EOF
|
||||
*:QNX:*:4*)
|
||||
echo i386-pc-qnx
|
||||
exit 0 ;;
|
||||
NSR-[DGKLNPTVWXY]:NONSTOP_KERNEL:*:*)
|
||||
NSR-?:NONSTOP_KERNEL:*:*)
|
||||
echo nsr-tandem-nsk${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:NonStop-UX:*:*)
|
||||
@ -1203,6 +1229,19 @@ EOF
|
||||
*:ITS:*:*)
|
||||
echo pdp10-unknown-its
|
||||
exit 0 ;;
|
||||
SEI:*:*:SEIUX)
|
||||
echo mips-sei-seiux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:DragonFly:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
|
||||
exit 0 ;;
|
||||
*:*VMS:*:*)
|
||||
UNAME_MACHINE=`(uname -p) 2>/dev/null`
|
||||
case "${UNAME_MACHINE}" in
|
||||
A*) echo alpha-dec-vms && exit 0 ;;
|
||||
I*) echo ia64-dec-vms && exit 0 ;;
|
||||
V*) echo vax-dec-vms && exit 0 ;;
|
||||
esac
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
@ -1323,8 +1362,7 @@ main ()
|
||||
}
|
||||
EOF
|
||||
|
||||
$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
|
||||
$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
|
||||
|
||||
# Apollos put the system type in the environment.
|
||||
|
351
extern/editline/config.h.in
vendored
351
extern/editline/config.h.in
vendored
@ -1,238 +1,235 @@
|
||||
/* config.h.in. Maintained by hand. */
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* Define NO_MULTIBYTE_SUPPORT to not compile in support for multibyte
|
||||
characters, even if the OS supports them. */
|
||||
#undef NO_MULTIBYTE_SUPPORT
|
||||
/* Define to 1 if the `closedir' function returns void instead of `int'. */
|
||||
#undef CLOSEDIR_VOID
|
||||
|
||||
/* Define if on MINIX. */
|
||||
#undef _MINIX
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
#undef CRAY_STACKSEG_END
|
||||
|
||||
/* Define as the return type of signal handlers (int or void). */
|
||||
#undef RETSIGTYPE
|
||||
/* Define to 1 if using `alloca.c'. */
|
||||
#undef C_ALLOCA
|
||||
|
||||
#undef VOID_SIGHANDLER
|
||||
/* Define to 1 if you have `alloca', as a function or macro. */
|
||||
#undef HAVE_ALLOCA
|
||||
|
||||
/* Characteristics of the compiler. */
|
||||
#undef const
|
||||
/* Define to 1 if you have <alloca.h> and it should be used (not on Ultrix).
|
||||
*/
|
||||
#undef HAVE_ALLOCA_H
|
||||
|
||||
#undef size_t
|
||||
/* Define to 1 if you have the <curses.h> header file. */
|
||||
#undef HAVE_CURSES_H
|
||||
|
||||
#undef ssize_t
|
||||
|
||||
#undef PROTOTYPES
|
||||
|
||||
#undef __CHAR_UNSIGNED__
|
||||
|
||||
/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
|
||||
#undef STAT_MACROS_BROKEN
|
||||
|
||||
/* 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
|
||||
|
||||
/* 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
|
||||
|
||||
/* Define if you have the memmove function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define if you have the putenv function. */
|
||||
#undef HAVE_PUTENV
|
||||
|
||||
/* Define if you have the select function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
/* Define if you have the setenv function. */
|
||||
#undef HAVE_SETENV
|
||||
|
||||
/* Define if you have the setlocale function. */
|
||||
#undef HAVE_SETLOCALE
|
||||
|
||||
/* Define if you have the strcasecmp function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define if you have the strcoll function. */
|
||||
#undef HAVE_STRCOLL
|
||||
|
||||
#undef STRCOLL_BROKEN
|
||||
|
||||
/* Define if you have the strpbrk function. */
|
||||
#undef HAVE_STRPBRK
|
||||
|
||||
/* Define if you have the tcgetattr function. */
|
||||
#undef HAVE_TCGETATTR
|
||||
|
||||
/* Define if you have the vsnprintf function. */
|
||||
#undef HAVE_VSNPRINTF
|
||||
|
||||
/* Define if you have the 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. */
|
||||
/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_DIRENT_H
|
||||
|
||||
/* Define if you have the <fcntl.h> header file. */
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the `endpwent' function. */
|
||||
#undef HAVE_ENDPWENT
|
||||
|
||||
/* Define to 1 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
|
||||
/* Define to 1 if you have the `fork' function. */
|
||||
#undef HAVE_FORK
|
||||
|
||||
/* Define if you have the <limits.h> header file. */
|
||||
/* Define to 1 if you have getpwnam_r and getpwuid_r that are draft POSIX.1
|
||||
versions. */
|
||||
#undef HAVE_GETPW_R_DRAFT
|
||||
|
||||
/* Define to 1 if you have getpwnam_r and getpwuid_r that are POSIX.1
|
||||
compatible. */
|
||||
#undef HAVE_GETPW_R_POSIX
|
||||
|
||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||
#undef HAVE_INTTYPES_H
|
||||
|
||||
/* Define to 1 if you have the `isascii' function. */
|
||||
#undef HAVE_ISASCII
|
||||
|
||||
/* Define to 1 if you have the `issetugid' function. */
|
||||
#undef HAVE_ISSETUGID
|
||||
|
||||
/* Define to 1 if you have the `curses' library (-lcurses). */
|
||||
#undef HAVE_LIBCURSES
|
||||
|
||||
/* Define to 1 if you have the `ncurses' library (-lncurses). */
|
||||
#undef HAVE_LIBNCURSES
|
||||
|
||||
/* Define to 1 if you have the <limits.h> header file. */
|
||||
#undef HAVE_LIMITS_H
|
||||
|
||||
/* Define if you have the <locale.h> header file. */
|
||||
#undef HAVE_LOCALE_H
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#undef HAVE_MALLOC_H
|
||||
|
||||
/* Define if you have the <memory.h> header file. */
|
||||
/* Define to 1 if you have the `memchr' function. */
|
||||
#undef HAVE_MEMCHR
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
/* Define if you have the <ndir.h> header file. */
|
||||
/* Define to 1 if you have the `memset' function. */
|
||||
#undef HAVE_MEMSET
|
||||
|
||||
/* Define to 1 if you have the <ncurses.h> header file. */
|
||||
#undef HAVE_NCURSES_H
|
||||
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define if you have the <pwd.h> header file. */
|
||||
#undef HAVE_PWD_H
|
||||
/* Define to 1 if you have the `regcomp' function. */
|
||||
#undef HAVE_REGCOMP
|
||||
|
||||
/* Define if you have the <stdarg.h> header file. */
|
||||
#undef HAVE_STDARG_H
|
||||
/* Define to 1 if you have the `re_comp' function. */
|
||||
#undef HAVE_RE_COMP
|
||||
|
||||
/* Define if you have the <stdlib.h> header file. */
|
||||
/* Define to 1 if `stat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
#undef HAVE_STAT_EMPTY_STRING_BUG
|
||||
|
||||
/* Define to 1 if you have the <stdint.h> header file. */
|
||||
#undef HAVE_STDINT_H
|
||||
|
||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||
#undef HAVE_STDLIB_H
|
||||
|
||||
/* Define if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
/* Define to 1 if you have the `strcasecmp' function. */
|
||||
#undef HAVE_STRCASECMP
|
||||
|
||||
/* Define if you have the <strings.h> header file. */
|
||||
/* Define to 1 if you have the `strchr' function. */
|
||||
#undef HAVE_STRCHR
|
||||
|
||||
/* Define to 1 if you have the `strcspn' function. */
|
||||
#undef HAVE_STRCSPN
|
||||
|
||||
/* Define to 1 if you have the `strdup' function. */
|
||||
#undef HAVE_STRDUP
|
||||
|
||||
/* Define to 1 if you have the `strerror' function. */
|
||||
#undef HAVE_STRERROR
|
||||
|
||||
/* Define to 1 if you have the <strings.h> header file. */
|
||||
#undef HAVE_STRINGS_H
|
||||
|
||||
/* Define if you have the <sys/dir.h> header file. */
|
||||
/* Define to 1 if you have the <string.h> header file. */
|
||||
#undef HAVE_STRING_H
|
||||
|
||||
/* Define to 1 if you have the `strrchr' function. */
|
||||
#undef HAVE_STRRCHR
|
||||
|
||||
/* Define to 1 if you have the `strstr' function. */
|
||||
#undef HAVE_STRSTR
|
||||
|
||||
/* Define to 1 if you have the `strtol' function. */
|
||||
#undef HAVE_STRTOL
|
||||
|
||||
/* Define to 1 if you have the <sys/cdefs.h> header file. */
|
||||
#undef HAVE_SYS_CDEFS_H
|
||||
|
||||
/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_DIR_H
|
||||
|
||||
/* Define if you have the <sys/file.h> header file. */
|
||||
#undef HAVE_SYS_FILE_H
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#undef HAVE_SYS_IOCTL_H
|
||||
|
||||
/* Define if you have the <sys/ndir.h> header file. */
|
||||
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
|
||||
/* Define if you have the <sys/pte.h> header file. */
|
||||
#undef HAVE_SYS_PTE_H
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define if you have the <sys/ptem.h> header file. */
|
||||
#undef HAVE_SYS_PTEM_H
|
||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||
#undef HAVE_SYS_STAT_H
|
||||
|
||||
/* Define if you have the <sys/select.h> header file. */
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define if you have the <sys/stream.h> header file. */
|
||||
#undef HAVE_SYS_STREAM_H
|
||||
/* Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible. */
|
||||
#undef HAVE_SYS_WAIT_H
|
||||
|
||||
/* Define if you have the <termcap.h> header file. */
|
||||
#undef HAVE_TERMCAP_H
|
||||
/* Define to 1 if you have the <term.h> header file. */
|
||||
#undef HAVE_TERM_H
|
||||
|
||||
/* Define if you have the <termio.h> header file. */
|
||||
#undef HAVE_TERMIO_H
|
||||
|
||||
/* Define if you have the <termios.h> header file. */
|
||||
#undef HAVE_TERMIOS_H
|
||||
|
||||
/* Define if you have the <unistd.h> header file. */
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define if you have the <varargs.h> header file. */
|
||||
#undef HAVE_VARARGS_H
|
||||
/* Define to 1 if the system has the type `u_int32_t'. */
|
||||
#undef HAVE_U_INT32_T
|
||||
|
||||
/* Define if you have the <wchar.h> header file. */
|
||||
#undef HAVE_WCHAR_H
|
||||
/* Define to 1 if you have the `vfork' function. */
|
||||
#undef HAVE_VFORK
|
||||
|
||||
/* Define if you have the <varargs.h> header file. */
|
||||
#undef HAVE_WCTYPE_H
|
||||
/* Define to 1 if you have the <vfork.h> header file. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
#undef HAVE_MBSTATE_T
|
||||
/* Define to 1 if `fork' works. */
|
||||
#undef HAVE_WORKING_FORK
|
||||
|
||||
/* Define if you have <langinfo.h> and nl_langinfo(CODESET). */
|
||||
#undef HAVE_LANGINFO_CODESET
|
||||
/* Define to 1 if `vfork' works. */
|
||||
#undef HAVE_WORKING_VFORK
|
||||
|
||||
/* Definitions pulled in from aclocal.m4. */
|
||||
#undef VOID_SIGHANDLER
|
||||
/* Define to 1 if `lstat' dereferences a symlink specified with a trailing
|
||||
slash. */
|
||||
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
|
||||
|
||||
#undef GWINSZ_IN_SYS_IOCTL
|
||||
/* Name of package */
|
||||
#undef PACKAGE
|
||||
|
||||
#undef STRUCT_WINSIZE_IN_SYS_IOCTL
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
#undef PACKAGE_BUGREPORT
|
||||
|
||||
#undef STRUCT_WINSIZE_IN_TERMIOS
|
||||
/* Define to the full name of this package. */
|
||||
#undef PACKAGE_NAME
|
||||
|
||||
#undef TIOCSTAT_IN_SYS_IOCTL
|
||||
/* Define to the full name and version of this package. */
|
||||
#undef PACKAGE_STRING
|
||||
|
||||
#undef FIONREAD_IN_SYS_IOCTL
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#undef PACKAGE_TARNAME
|
||||
|
||||
#undef SPEED_T_IN_SYS_TYPES
|
||||
/* Define to the version of this package. */
|
||||
#undef PACKAGE_VERSION
|
||||
|
||||
#undef HAVE_GETPW_DECLS
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
#undef STRUCT_DIRENT_HAS_D_INO
|
||||
/* If using the C implementation of alloca, define if you know the
|
||||
direction of stack growth for your system; otherwise it will be
|
||||
automatically deduced at runtime.
|
||||
STACK_DIRECTION > 0 => grows toward higher addresses
|
||||
STACK_DIRECTION < 0 => grows toward lower addresses
|
||||
STACK_DIRECTION = 0 => direction of growth unknown */
|
||||
#undef STACK_DIRECTION
|
||||
|
||||
#undef STRUCT_DIRENT_HAS_D_FILENO
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#undef STDC_HEADERS
|
||||
|
||||
#undef HAVE_BSD_SIGNALS
|
||||
/* Version number of package */
|
||||
#undef VERSION
|
||||
|
||||
#undef HAVE_POSIX_SIGNALS
|
||||
/* Solaris's term.h does horrid things. */
|
||||
#undef _SUNOS
|
||||
|
||||
#undef HAVE_USG_SIGHOLD
|
||||
/* Define to empty if `const' does not conform to ANSI C. */
|
||||
#undef const
|
||||
|
||||
#undef MUST_REINSTALL_SIGHANDLERS
|
||||
/* Define to `int' if <sys/types.h> does not define. */
|
||||
#undef pid_t
|
||||
|
||||
#undef HAVE_POSIX_SIGSETJMP
|
||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||
#undef size_t
|
||||
|
||||
#undef CTYPE_NON_ASCII
|
||||
/* Define as `fork' if `vfork' does not work. */
|
||||
#undef vfork
|
||||
|
||||
/* modify settings or make new ones based on what autoconf tells us. */
|
||||
|
||||
/* Ultrix botches type-ahead when switching from canonical to
|
||||
non-canonical mode, at least through version 4.3 */
|
||||
#if !defined (HAVE_TERMIOS_H) || !defined (HAVE_TCGETATTR) || defined (ultrix)
|
||||
# define TERMIOS_MISSING
|
||||
#endif
|
||||
#include <sys.h>
|
||||
#define SCCSID
|
||||
#undef LIBC_SCCS
|
||||
|
||||
#if defined (STRCOLL_BROKEN)
|
||||
# undef HAVE_STRCOLL
|
||||
#endif
|
||||
|
||||
#if defined (__STDC__) && defined (HAVE_STDARG_H)
|
||||
# define PREFER_STDARG
|
||||
# define USE_VARARGS
|
||||
#else
|
||||
# if defined (HAVE_VARARGS_H)
|
||||
# define PREFER_VARARGS
|
||||
# define USE_VARARGS
|
||||
# endif
|
||||
#endif
|
||||
|
164
extern/editline/support/config.sub → extern/editline/config.sub
vendored
Executable file → Normal file
164
extern/editline/support/config.sub → extern/editline/config.sub
vendored
Executable file → Normal file
@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002 Free Software Foundation, Inc.
|
||||
# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2002-11-30'
|
||||
timestamp='2004-06-24'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
@ -70,7 +70,7 @@ Report bugs and patches to <config-patches@gnu.org>."
|
||||
version="\
|
||||
GNU config.sub ($timestamp)
|
||||
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
|
||||
Free Software Foundation, Inc.
|
||||
|
||||
This is free software; see the source for copying conditions. There is NO
|
||||
@ -118,7 +118,8 @@ esac
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
|
||||
nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
|
||||
kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
@ -144,7 +145,7 @@ case $os in
|
||||
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
|
||||
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
|
||||
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
|
||||
-apple | -axis)
|
||||
-apple | -axis | -knuth | -cray)
|
||||
os=
|
||||
basic_machine=$1
|
||||
;;
|
||||
@ -228,14 +229,15 @@ case $basic_machine in
|
||||
| a29k \
|
||||
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
|
||||
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
|
||||
| am33_2.0 \
|
||||
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
|
||||
| clipper \
|
||||
| c4x | clipper \
|
||||
| d10v | d30v | dlx | dsp16xx \
|
||||
| fr30 | frv \
|
||||
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
||||
| i370 | i860 | i960 | ia64 \
|
||||
| ip2k \
|
||||
| m32r | m68000 | m68k | m88k | mcore \
|
||||
| ip2k | iq2000 \
|
||||
| m32r | m32rle | m68000 | m68k | m88k | mcore \
|
||||
| mips | mipsbe | mipseb | mipsel | mipsle \
|
||||
| mips16 \
|
||||
| mips64 | mips64el \
|
||||
@ -245,21 +247,24 @@ case $basic_machine in
|
||||
| mips64vr4300 | mips64vr4300el \
|
||||
| mips64vr5000 | mips64vr5000el \
|
||||
| mipsisa32 | mipsisa32el \
|
||||
| mipsisa32r2 | mipsisa32r2el \
|
||||
| mipsisa64 | mipsisa64el \
|
||||
| mipsisa64r2 | mipsisa64r2el \
|
||||
| mipsisa64sb1 | mipsisa64sb1el \
|
||||
| mipsisa64sr71k | mipsisa64sr71kel \
|
||||
| mipstx39 | mipstx39el \
|
||||
| mn10200 | mn10300 \
|
||||
| msp430 \
|
||||
| ns16k | ns32k \
|
||||
| openrisc | or32 \
|
||||
| pdp10 | pdp11 | pj | pjl \
|
||||
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
|
||||
| pyramid \
|
||||
| sh | sh[1234] | sh3e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
|
||||
| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
|
||||
| sh64 | sh64le \
|
||||
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
|
||||
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \
|
||||
| strongarm \
|
||||
| tahoe | thumb | tic80 | tron \
|
||||
| tahoe | thumb | tic4x | tic80 | tron \
|
||||
| v850 | v850e \
|
||||
| we32k \
|
||||
| x86 | xscale | xstormy16 | xtensa \
|
||||
@ -277,7 +282,7 @@ case $basic_machine in
|
||||
# We use `pc' rather than `unknown'
|
||||
# because (1) that's what they normally are, and
|
||||
# (2) the word "unknown" tends to confuse beginning users.
|
||||
i*86 | x86_64 | amd64)
|
||||
i*86 | x86_64)
|
||||
basic_machine=$basic_machine-pc
|
||||
;;
|
||||
# Object if more than one company name word.
|
||||
@ -291,20 +296,19 @@ case $basic_machine in
|
||||
| alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
|
||||
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
|
||||
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
|
||||
| amd64-* \
|
||||
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
|
||||
| avr-* \
|
||||
| bs2000-* \
|
||||
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* \
|
||||
| clipper-* | cydra-* \
|
||||
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
|
||||
| clipper-* | craynv-* | cydra-* \
|
||||
| d10v-* | d30v-* | dlx-* \
|
||||
| elxsi-* \
|
||||
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
|
||||
| h8300-* | h8500-* \
|
||||
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
|
||||
| i*86-* | i860-* | i960-* | ia64-* \
|
||||
| ip2k-* \
|
||||
| m32r-* \
|
||||
| ip2k-* | iq2000-* \
|
||||
| m32r-* | m32rle-* \
|
||||
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
|
||||
| m88110-* | m88k-* | mcore-* \
|
||||
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
|
||||
@ -316,21 +320,27 @@ case $basic_machine in
|
||||
| mips64vr4300-* | mips64vr4300el-* \
|
||||
| mips64vr5000-* | mips64vr5000el-* \
|
||||
| mipsisa32-* | mipsisa32el-* \
|
||||
| mipsisa32r2-* | mipsisa32r2el-* \
|
||||
| mipsisa64-* | mipsisa64el-* \
|
||||
| mipsisa64r2-* | mipsisa64r2el-* \
|
||||
| mipsisa64sb1-* | mipsisa64sb1el-* \
|
||||
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
|
||||
| mipstx39 | mipstx39el \
|
||||
| mipstx39-* | mipstx39el-* \
|
||||
| mmix-* \
|
||||
| msp430-* \
|
||||
| none-* | np1-* | ns16k-* | ns32k-* \
|
||||
| orion-* \
|
||||
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
|
||||
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
|
||||
| pyramid-* \
|
||||
| romp-* | rs6000-* \
|
||||
| sh-* | sh[1234]-* | sh3e-* | sh[34]eb-* | shbe-* \
|
||||
| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \
|
||||
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
|
||||
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
|
||||
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
|
||||
| tahoe-* | thumb-* | tic30-* | tic4x-* | tic54x-* | tic80-* | tron-* \
|
||||
| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
|
||||
| tahoe-* | thumb-* \
|
||||
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
|
||||
| tron-* \
|
||||
| v850-* | v850e-* | vax-* \
|
||||
| we32k-* \
|
||||
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
|
||||
@ -354,6 +364,9 @@ case $basic_machine in
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
;;
|
||||
abacus)
|
||||
basic_machine=abacus-unknown
|
||||
;;
|
||||
adobe68k)
|
||||
basic_machine=m68010-adobe
|
||||
os=-scout
|
||||
@ -368,6 +381,12 @@ case $basic_machine in
|
||||
basic_machine=a29k-none
|
||||
os=-bsd
|
||||
;;
|
||||
amd64)
|
||||
basic_machine=x86_64-pc
|
||||
;;
|
||||
amd64-*)
|
||||
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
amdahl)
|
||||
basic_machine=580-amdahl
|
||||
os=-sysv
|
||||
@ -427,12 +446,24 @@ case $basic_machine in
|
||||
basic_machine=j90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
craynv)
|
||||
basic_machine=craynv-cray
|
||||
os=-unicosmp
|
||||
;;
|
||||
cr16c)
|
||||
basic_machine=cr16c-unknown
|
||||
os=-elf
|
||||
;;
|
||||
crds | unos)
|
||||
basic_machine=m68k-crds
|
||||
;;
|
||||
cris | cris-* | etrax*)
|
||||
basic_machine=cris-axis
|
||||
;;
|
||||
crx)
|
||||
basic_machine=crx-unknown
|
||||
os=-elf
|
||||
;;
|
||||
da30 | da30-*)
|
||||
basic_machine=m68k-da30
|
||||
;;
|
||||
@ -633,10 +664,6 @@ case $basic_machine in
|
||||
mips3*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
|
||||
;;
|
||||
mmix*)
|
||||
basic_machine=mmix-knuth
|
||||
os=-mmixware
|
||||
;;
|
||||
monitor)
|
||||
basic_machine=m68k-rom68k
|
||||
os=-coff
|
||||
@ -728,6 +755,10 @@ case $basic_machine in
|
||||
basic_machine=or32-unknown
|
||||
os=-coff
|
||||
;;
|
||||
os400)
|
||||
basic_machine=powerpc-ibm
|
||||
os=-os400
|
||||
;;
|
||||
OSE68000 | ose68000)
|
||||
basic_machine=m68000-ericsson
|
||||
os=-ose
|
||||
@ -759,18 +790,24 @@ case $basic_machine in
|
||||
pentiumpro | p6 | 6x86 | athlon | athlon_*)
|
||||
basic_machine=i686-pc
|
||||
;;
|
||||
pentiumii | pentium2)
|
||||
pentiumii | pentium2 | pentiumiii | pentium3)
|
||||
basic_machine=i686-pc
|
||||
;;
|
||||
pentium4)
|
||||
basic_machine=i786-pc
|
||||
;;
|
||||
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
|
||||
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentiumpro-* | p6-* | 6x86-* | athlon-*)
|
||||
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentiumii-* | pentium2-*)
|
||||
pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
|
||||
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pentium4-*)
|
||||
basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
|
||||
;;
|
||||
pn)
|
||||
basic_machine=pn-gould
|
||||
;;
|
||||
@ -829,6 +866,10 @@ case $basic_machine in
|
||||
sb1el)
|
||||
basic_machine=mipsisa64sb1el-unknown
|
||||
;;
|
||||
sei)
|
||||
basic_machine=mips-sei
|
||||
os=-seiux
|
||||
;;
|
||||
sequent)
|
||||
basic_machine=i386-sequent
|
||||
;;
|
||||
@ -836,6 +877,9 @@ case $basic_machine in
|
||||
basic_machine=sh-hitachi
|
||||
os=-hms
|
||||
;;
|
||||
sh64)
|
||||
basic_machine=sh64-unknown
|
||||
;;
|
||||
sparclite-wrs | simso-wrs)
|
||||
basic_machine=sparclite-wrs
|
||||
os=-vxworks
|
||||
@ -902,10 +946,6 @@ case $basic_machine in
|
||||
basic_machine=i386-sequent
|
||||
os=-dynix
|
||||
;;
|
||||
t3d)
|
||||
basic_machine=alpha-cray
|
||||
os=-unicos
|
||||
;;
|
||||
t3e)
|
||||
basic_machine=alphaev5-cray
|
||||
os=-unicos
|
||||
@ -914,14 +954,18 @@ case $basic_machine in
|
||||
basic_machine=t90-cray
|
||||
os=-unicos
|
||||
;;
|
||||
tic4x | c4x*)
|
||||
basic_machine=tic4x-unknown
|
||||
os=-coff
|
||||
;;
|
||||
tic54x | c54x*)
|
||||
basic_machine=tic54x-unknown
|
||||
os=-coff
|
||||
;;
|
||||
tic55x | c55x*)
|
||||
basic_machine=tic55x-unknown
|
||||
os=-coff
|
||||
;;
|
||||
tic6x | c6x*)
|
||||
basic_machine=tic6x-unknown
|
||||
os=-coff
|
||||
;;
|
||||
tx39)
|
||||
basic_machine=mipstx39-unknown
|
||||
;;
|
||||
@ -935,6 +979,10 @@ case $basic_machine in
|
||||
tower | tower-32)
|
||||
basic_machine=m68k-ncr
|
||||
;;
|
||||
tpf)
|
||||
basic_machine=s390x-ibm
|
||||
os=-tpf
|
||||
;;
|
||||
udi29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
@ -1008,6 +1056,9 @@ case $basic_machine in
|
||||
romp)
|
||||
basic_machine=romp-ibm
|
||||
;;
|
||||
mmix)
|
||||
basic_machine=mmix-knuth
|
||||
;;
|
||||
rs6000)
|
||||
basic_machine=rs6000-ibm
|
||||
;;
|
||||
@ -1024,13 +1075,13 @@ case $basic_machine in
|
||||
we32k)
|
||||
basic_machine=we32k-att
|
||||
;;
|
||||
sh3 | sh4 | sh3eb | sh4eb | sh[1234]le | sh3ele)
|
||||
sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele)
|
||||
basic_machine=sh-unknown
|
||||
;;
|
||||
sh64)
|
||||
basic_machine=sh64-unknown
|
||||
;;
|
||||
sparc | sparcv9 | sparcv9b)
|
||||
sparc | sparcv8 | sparcv9 | sparcv9b)
|
||||
basic_machine=sparc-sun
|
||||
;;
|
||||
cydra)
|
||||
@ -1103,19 +1154,20 @@ case $os in
|
||||
| -aos* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
|
||||
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
|
||||
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
|
||||
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
|
||||
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -chorusos* | -chorusrdb* \
|
||||
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
|
||||
| -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
|
||||
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
|
||||
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
|
||||
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
|
||||
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
||||
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
||||
| -powermax* | -dnix*)
|
||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-qnx*)
|
||||
@ -1139,6 +1191,9 @@ case $os in
|
||||
-mac*)
|
||||
os=`echo $os | sed -e 's|mac|macos|'`
|
||||
;;
|
||||
-linux-dietlibc)
|
||||
os=-linux-dietlibc
|
||||
;;
|
||||
-linux*)
|
||||
os=`echo $os | sed -e 's|linux|linux-gnu|'`
|
||||
;;
|
||||
@ -1151,6 +1206,9 @@ case $os in
|
||||
-opened*)
|
||||
os=-openedition
|
||||
;;
|
||||
-os400*)
|
||||
os=-os400
|
||||
;;
|
||||
-wince*)
|
||||
os=-wince
|
||||
;;
|
||||
@ -1172,6 +1230,9 @@ case $os in
|
||||
-atheos*)
|
||||
os=-atheos
|
||||
;;
|
||||
-syllable*)
|
||||
os=-syllable
|
||||
;;
|
||||
-386bsd)
|
||||
os=-bsd
|
||||
;;
|
||||
@ -1194,6 +1255,9 @@ case $os in
|
||||
-sinix*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-tpf*)
|
||||
os=-tpf
|
||||
;;
|
||||
-triton*)
|
||||
os=-sysv3
|
||||
;;
|
||||
@ -1224,6 +1288,12 @@ case $os in
|
||||
-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
|
||||
os=-mint
|
||||
;;
|
||||
-aros*)
|
||||
os=-aros
|
||||
;;
|
||||
-kaos*)
|
||||
os=-kaos
|
||||
;;
|
||||
-none)
|
||||
;;
|
||||
*)
|
||||
@ -1255,6 +1325,9 @@ case $basic_machine in
|
||||
arm*-semi)
|
||||
os=-aout
|
||||
;;
|
||||
c4x-* | tic4x-*)
|
||||
os=-coff
|
||||
;;
|
||||
# This must come before the *-dec entry.
|
||||
pdp10-*)
|
||||
os=-tops20
|
||||
@ -1301,6 +1374,9 @@ case $basic_machine in
|
||||
*-ibm)
|
||||
os=-aix
|
||||
;;
|
||||
*-knuth)
|
||||
os=-mmixware
|
||||
;;
|
||||
*-wec)
|
||||
os=-proelf
|
||||
;;
|
||||
@ -1433,9 +1509,15 @@ case $basic_machine in
|
||||
-mvs* | -opened*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-os400*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-ptx*)
|
||||
vendor=sequent
|
||||
;;
|
||||
-tpf*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-vxsim* | -vxworks* | -windiss*)
|
||||
vendor=wrs
|
||||
;;
|
23113
extern/editline/configure
vendored
23113
extern/editline/configure
vendored
File diff suppressed because it is too large
Load Diff
75
extern/editline/configure.ac
vendored
Normal file
75
extern/editline/configure.ac
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
# -*- Autoconf -*-
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_INIT(libedit, [EL_RELEASE],, libedit-[EL_TIMESTAMP_CVSEXPORT])
|
||||
AC_CONFIG_SRCDIR([src/strlcat.c])
|
||||
AC_CONFIG_HEADER([config.h])
|
||||
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_PROG_LIBTOOL
|
||||
|
||||
# libtool -version-info
|
||||
AC_SUBST(LT_VERSION, [0:24:0])
|
||||
|
||||
# AC_PROG_LIBTOOL runs AC_CANONICAL_HOST
|
||||
case $host in
|
||||
*-sun-*) AC_DEFINE([_SUNOS], [], [Solaris's term.h does horrid things.]);;
|
||||
esac
|
||||
|
||||
# Checks for programs.
|
||||
AC_PROG_CXX
|
||||
AC_PROG_CC
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_AWK
|
||||
EL_MANTYPE
|
||||
|
||||
AC_CHECK_LIB(curses, tgetent,,
|
||||
[AC_CHECK_LIB(ncurses, tgetent,,
|
||||
[AC_MSG_ERROR([libtermcap, libcurses or libncurses are required!])] )] )
|
||||
|
||||
# Checks for header files.
|
||||
AC_FUNC_ALLOCA
|
||||
AC_HEADER_DIRENT
|
||||
AC_HEADER_STDC
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_CHECK_HEADERS([fcntl.h limits.h malloc.h stdlib.h string.h sys/ioctl.h sys/param.h unistd.h curses.h ncurses.h sys/cdefs.h])
|
||||
|
||||
AC_CHECK_HEADER([termios.h], [], [AC_MSG_ERROR([termios.h is required!])],[])
|
||||
|
||||
## include curses.h to prevent "Present But Cannot Be Compiled"
|
||||
AC_CHECK_HEADERS([term.h],,,
|
||||
[[#if HAVE_CURSES_H
|
||||
# include <curses.h>
|
||||
#elif HAVE_NCURSES_H
|
||||
# include <ncurses.h>
|
||||
#endif
|
||||
]])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_TYPE_PID_T
|
||||
AC_TYPE_SIZE_T
|
||||
AC_CHECK_TYPES([u_int32_t])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_CLOSEDIR_VOID
|
||||
AC_FUNC_FORK
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
## _AIX is offended by rpl_malloc and rpl_realloc
|
||||
#AC_FUNC_MALLOC
|
||||
#AC_FUNC_REALLOC
|
||||
AC_TYPE_SIGNAL
|
||||
AC_FUNC_STAT
|
||||
AC_CHECK_FUNCS([endpwent isascii memchr memset re_comp regcomp strcasecmp strchr strcspn strdup strerror strrchr strstr strtol issetugid])
|
||||
EL_GETPW_R_POSIX
|
||||
EL_GETPW_R_DRAFT
|
||||
|
||||
AH_BOTTOM([
|
||||
#include <sys.h>
|
||||
#define SCCSID
|
||||
#undef LIBC_SCCS
|
||||
])
|
||||
|
||||
AC_CONFIG_FILES([Makefile
|
||||
src/Makefile])
|
||||
AC_OUTPUT
|
295
extern/editline/configure.in
vendored
295
extern/editline/configure.in
vendored
@ -1,295 +0,0 @@
|
||||
dnl
|
||||
dnl Configure script for readline library
|
||||
dnl
|
||||
dnl report bugs to chet@po.cwru.edu
|
||||
dnl
|
||||
dnl Process this file with autoconf to produce a configure script.
|
||||
|
||||
# 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)
|
||||
|
||||
AC_CONFIG_SRCDIR(readline.h)
|
||||
AC_CONFIG_AUX_DIR(./support)
|
||||
AC_CONFIG_HEADERS(config.h)
|
||||
|
||||
dnl update the value of RL_READLINE_VERSION in readline.h when this changes
|
||||
LIBVERSION=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 ""
|
||||
|
||||
# We want these before the checks, so the checks can modify their values.
|
||||
test -z "$CFLAGS" && CFLAGS=-g auto_cflags=1
|
||||
|
||||
AC_PROG_MAKE_SET
|
||||
AC_PROG_CC
|
||||
dnl AC_AIX
|
||||
AC_MINIX
|
||||
|
||||
# If we're using gcc and the user hasn't specified CFLAGS, add -O to CFLAGS.
|
||||
test -n "$GCC" && test -n "$auto_cflags" && CFLAGS="$CFLAGS -O"
|
||||
|
||||
AC_PROG_GCC_TRADITIONAL
|
||||
AC_PROG_INSTALL
|
||||
AC_CHECK_PROG(AR, ar, , ar)
|
||||
dnl Set default for ARFLAGS, since autoconf does not have a macro for it.
|
||||
dnl This allows people to set it when running configure or make
|
||||
test -n "$ARFLAGS" || ARFLAGS="cr"
|
||||
AC_PROG_RANLIB
|
||||
|
||||
MAKE_SHELL=/bin/sh
|
||||
AC_SUBST(MAKE_SHELL)
|
||||
|
||||
AC_C_CONST
|
||||
AC_C_PROTOTYPES
|
||||
AC_C_CHAR_UNSIGNED
|
||||
|
||||
AC_TYPE_SIGNAL
|
||||
|
||||
AC_TYPE_SIZE_T
|
||||
AC_CHECK_TYPE(ssize_t, int)
|
||||
|
||||
AC_HEADER_STDC
|
||||
|
||||
AC_HEADER_STAT
|
||||
AC_HEADER_DIRENT
|
||||
|
||||
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(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
|
||||
|
||||
BASH_FUNC_POSIX_SETJMP
|
||||
BASH_FUNC_LSTAT
|
||||
BASH_FUNC_STRCOLL
|
||||
BASH_FUNC_CTYPE_NONASCII
|
||||
|
||||
BASH_CHECK_GETPW_FUNCS
|
||||
|
||||
AC_HEADER_TIOCGWINSZ
|
||||
|
||||
BASH_TYPE_SIGHANDLER
|
||||
BASH_HAVE_TIOCSTAT
|
||||
BASH_HAVE_FIONREAD
|
||||
BASH_CHECK_SPEED_T
|
||||
BASH_STRUCT_WINSIZE
|
||||
BASH_STRUCT_DIRENT_D_INO
|
||||
BASH_STRUCT_DIRENT_D_FILENO
|
||||
|
||||
dnl yuck
|
||||
case "$host_os" in
|
||||
aix*) prefer_curses=yes ;;
|
||||
esac
|
||||
BASH_CHECK_LIB_TERMCAP
|
||||
if test "$TERMCAP_LIB" = "./lib/termcap/libtermcap.a"; then
|
||||
if test "$prefer_curses" = yes; then
|
||||
TERMCAP_LIB=-lcurses
|
||||
else
|
||||
TERMCAP_LIB=-ltermcap #default
|
||||
fi
|
||||
fi
|
||||
|
||||
BASH_CHECK_MULTIBYTE
|
||||
|
||||
case "$host_cpu" in
|
||||
*cray*) LOCAL_CFLAGS=-DCRAY ;;
|
||||
*s390*) LOCAL_CFLAGS=-fsigned-char ;;
|
||||
esac
|
||||
|
||||
case "$host_os" in
|
||||
isc*) LOCAL_CFLAGS=-Disc386 ;;
|
||||
esac
|
||||
|
||||
# shared library configuration section
|
||||
#
|
||||
# Shared object configuration section. These values are generated by
|
||||
# ${srcdir}/support/shobj-conf
|
||||
#
|
||||
if test -f ${srcdir}/support/shobj-conf; then
|
||||
AC_MSG_CHECKING(configuration for building shared libraries)
|
||||
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)
|
||||
AC_SUBST(SHOBJ_LDFLAGS)
|
||||
AC_SUBST(SHOBJ_XLDFLAGS)
|
||||
AC_SUBST(SHOBJ_LIBS)
|
||||
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)
|
||||
|
||||
# SHLIB_STATUS is either `supported' or `unsupported'. If it's
|
||||
# `unsupported', turn off any default shared library building
|
||||
if test "$SHLIB_STATUS" = 'unsupported'; then
|
||||
opt_shared_libs=no
|
||||
fi
|
||||
|
||||
# shared library versioning
|
||||
# quoted for m4 so I can use character classes
|
||||
SHLIB_MAJOR=[`expr "$LIBVERSION" : '\([0-9]\)\..*'`]
|
||||
SHLIB_MINOR=[`expr "$LIBVERSION" : '[0-9]\.\([0-9]\).*'`]
|
||||
AC_SUBST(SHLIB_MAJOR)
|
||||
AC_SUBST(SHLIB_MINOR)
|
||||
fi
|
||||
|
||||
if test "$opt_static_libs" = "yes"; then
|
||||
STATIC_TARGET=static
|
||||
STATIC_INSTALL_TARGET=install-static
|
||||
fi
|
||||
if test "$opt_shared_libs" = "yes"; then
|
||||
SHARED_TARGET=shared
|
||||
SHARED_INSTALL_TARGET=install-shared
|
||||
fi
|
||||
|
||||
AC_SUBST(STATIC_TARGET)
|
||||
AC_SUBST(SHARED_TARGET)
|
||||
AC_SUBST(STATIC_INSTALL_TARGET)
|
||||
AC_SUBST(SHARED_INSTALL_TARGET)
|
||||
|
||||
case "$host_os" in
|
||||
msdosdjgpp*) BUILD_DIR=`pwd.exe` ;; # to prevent //d/path/file
|
||||
*) BUILD_DIR=`pwd` ;;
|
||||
esac
|
||||
|
||||
case "$BUILD_DIR" in
|
||||
*\ *) BUILD_DIR=`echo "$BUILD_DIR" | sed 's: :\\\\ :g'` ;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
AC_SUBST(PURIFY)
|
||||
AC_SUBST(BUILD_DIR)
|
||||
|
||||
AC_SUBST(CFLAGS)
|
||||
AC_SUBST(LOCAL_CFLAGS)
|
||||
AC_SUBST(LOCAL_LDFLAGS)
|
||||
AC_SUBST(LOCAL_DEFS)
|
||||
|
||||
AC_SUBST(AR)
|
||||
AC_SUBST(ARFLAGS)
|
||||
|
||||
AC_SUBST(host_cpu)
|
||||
AC_SUBST(host_os)
|
||||
|
||||
AC_SUBST(LIBVERSION)
|
||||
|
||||
AC_SUBST(TERMCAP_LIB)
|
||||
|
||||
AC_OUTPUT([Makefile],
|
||||
[
|
||||
# Makefile uses this timestamp file to record whether config.h is up to date.
|
||||
echo > stamp-h
|
||||
])
|
522
extern/editline/depcomp
vendored
Executable file
522
extern/editline/depcomp
vendored
Executable file
@ -0,0 +1,522 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2004-05-31.23
|
||||
|
||||
# Copyright (C) 1999, 2000, 2003, 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
|
||||
# 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.
|
||||
|
||||
# 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.
|
||||
|
||||
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
|
||||
|
||||
case $1 in
|
||||
'')
|
||||
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
|
||||
exit 1;
|
||||
;;
|
||||
-h | --h*)
|
||||
cat <<\EOF
|
||||
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
|
||||
|
||||
Run PROGRAMS ARGS to compile a file, generating dependencies
|
||||
as side-effects.
|
||||
|
||||
Environment variables:
|
||||
depmode Dependency tracking mode.
|
||||
source Source file read by `PROGRAMS ARGS'.
|
||||
object Object file output by `PROGRAMS ARGS'.
|
||||
DEPDIR directory where to store dependencies.
|
||||
depfile Dependency file to output.
|
||||
tmpdepfile Temporary file to use when outputing dependencies.
|
||||
libtool Whether libtool is used (yes/no).
|
||||
|
||||
Report bugs to <bug-automake@gnu.org>.
|
||||
EOF
|
||||
exit 0
|
||||
;;
|
||||
-v | --v*)
|
||||
echo "depcomp $scriptversion"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
|
||||
echo "depcomp: Variables source, object and depmode must be set" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
|
||||
depfile=${depfile-`echo "$object" |
|
||||
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
|
||||
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
|
||||
|
||||
rm -f "$tmpdepfile"
|
||||
|
||||
# Some modes work just like other modes, but use different flags. We
|
||||
# parameterize here, but still list the modes in the big case below,
|
||||
# to make depend.m4 easier to write. Note that we *cannot* use a case
|
||||
# here, because this file can only contain one case statement.
|
||||
if test "$depmode" = hp; then
|
||||
# HP compiler uses -M and no extra arg.
|
||||
gccflag=-M
|
||||
depmode=gcc
|
||||
fi
|
||||
|
||||
if test "$depmode" = dashXmstdout; then
|
||||
# This is just like dashmstdout with a different argument.
|
||||
dashmflag=-xM
|
||||
depmode=dashmstdout
|
||||
fi
|
||||
|
||||
case "$depmode" in
|
||||
gcc3)
|
||||
## gcc 3 implements dependency tracking that does exactly what
|
||||
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
|
||||
## it if -MD -MP comes after the -MF stuff. Hmm.
|
||||
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
mv "$tmpdepfile" "$depfile"
|
||||
;;
|
||||
|
||||
gcc)
|
||||
## There are various ways to get dependency output from gcc. Here's
|
||||
## why we pick this rather obscure method:
|
||||
## - Don't want to use -MD because we'd like the dependencies to end
|
||||
## up in a subdir. Having to rename by hand is ugly.
|
||||
## (We might end up doing this anyway to support other compilers.)
|
||||
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
|
||||
## -MM, not -M (despite what the docs say).
|
||||
## - Using -M directly means running the compiler twice (even worse
|
||||
## than renaming).
|
||||
if test -z "$gccflag"; then
|
||||
gccflag=-MD,
|
||||
fi
|
||||
"$@" -Wp,"$gccflag$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
|
||||
## The second -e expression handles DOS-style file names with drive letters.
|
||||
sed -e 's/^[^:]*: / /' \
|
||||
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
|
||||
## This next piece of magic avoids the `deleted header file' problem.
|
||||
## The problem is that when a header file which appears in a .P file
|
||||
## is deleted, the dependency causes make to die (because there is
|
||||
## typically no way to rebuild the header). We avoid this by adding
|
||||
## dummy dependencies for each header file. Too bad gcc doesn't do
|
||||
## this for us directly.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" |
|
||||
## Some versions of gcc put a space before the `:'. On the theory
|
||||
## that the space means something, we add a space to the output as
|
||||
## well.
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
hp)
|
||||
# This case exists only to let depend.m4 do its work. It works by
|
||||
# looking at the text of this script. This case will never be run,
|
||||
# since it is checked for above.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
sgi)
|
||||
if test "$libtool" = yes; then
|
||||
"$@" "-Wp,-MDupdate,$tmpdepfile"
|
||||
else
|
||||
"$@" -MDupdate "$tmpdepfile"
|
||||
fi
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
|
||||
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
|
||||
echo "$object : \\" > "$depfile"
|
||||
|
||||
# Clip off the initial element (the dependent). Don't try to be
|
||||
# clever and replace this with sed code, as IRIX sed won't handle
|
||||
# lines with more than a fixed number of characters (4096 in
|
||||
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
|
||||
# the IRIX cc adds comments like `#:fec' to the end of the
|
||||
# dependency line.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
|
||||
tr '
|
||||
' ' ' >> $depfile
|
||||
echo >> $depfile
|
||||
|
||||
# The second pass generates a dummy entry for each header file.
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" \
|
||||
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
|
||||
>> $depfile
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
aix)
|
||||
# The C for AIX Compiler uses -M and outputs the dependencies
|
||||
# in a .u file. In older versions, this file always lives in the
|
||||
# current directory. Also, the AIX compiler puts `$object:' at the
|
||||
# start of each line; $object doesn't have directory information.
|
||||
# Version 6 uses the directory in both cases.
|
||||
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
|
||||
tmpdepfile="$stripped.u"
|
||||
if test "$libtool" = yes; then
|
||||
"$@" -Wc,-M
|
||||
else
|
||||
"$@" -M
|
||||
fi
|
||||
stat=$?
|
||||
|
||||
if test -f "$tmpdepfile"; then :
|
||||
else
|
||||
stripped=`echo "$stripped" | sed 's,^.*/,,'`
|
||||
tmpdepfile="$stripped.u"
|
||||
fi
|
||||
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
if test -f "$tmpdepfile"; then
|
||||
outname="$stripped.o"
|
||||
# Each line is of the form `foo.o: dependent.h'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
# The sourcefile does not contain any dependencies, so just
|
||||
# store a dummy comment line, to avoid errors with the Makefile
|
||||
# "include basename.Plo" scheme.
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
icc)
|
||||
# Intel's C compiler understands `-MD -MF file'. However on
|
||||
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
|
||||
# ICC 7.0 will fill foo.d with something like
|
||||
# foo.o: sub/foo.c
|
||||
# foo.o: sub/foo.h
|
||||
# which is wrong. We want:
|
||||
# sub/foo.o: sub/foo.c
|
||||
# sub/foo.o: sub/foo.h
|
||||
# sub/foo.c:
|
||||
# sub/foo.h:
|
||||
# ICC 7.1 will output
|
||||
# foo.o: sub/foo.c sub/foo.h
|
||||
# and will wrap long lines using \ :
|
||||
# foo.o: sub/foo.c ... \
|
||||
# sub/foo.h ... \
|
||||
# ...
|
||||
|
||||
"$@" -MD -MF "$tmpdepfile"
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile"
|
||||
exit $stat
|
||||
fi
|
||||
rm -f "$depfile"
|
||||
# Each line is of the form `foo.o: dependent.h',
|
||||
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
|
||||
# Do two passes, one to just change these to
|
||||
# `$object: dependent.h' and one to simply `dependent.h:'.
|
||||
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
|
||||
# Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
# correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
|
||||
sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
tru64)
|
||||
# The Tru64 compiler uses -MD to generate dependencies as a side
|
||||
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
|
||||
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
|
||||
# dependencies in `foo.d' instead, so we check for that too.
|
||||
# Subdirectories are respected.
|
||||
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
|
||||
test "x$dir" = "x$object" && dir=
|
||||
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
|
||||
|
||||
if test "$libtool" = yes; then
|
||||
# Dependencies are output in .lo.d with libtool 1.4.
|
||||
# With libtool 1.5 they are output both in $dir.libs/$base.o.d
|
||||
# and in $dir.libs/$base.o.d and $dir$base.o.d. We process the
|
||||
# latter, because the former will be cleaned when $dir.libs is
|
||||
# erased.
|
||||
tmpdepfile1="$dir.libs/$base.lo.d"
|
||||
tmpdepfile2="$dir$base.o.d"
|
||||
tmpdepfile3="$dir.libs/$base.d"
|
||||
"$@" -Wc,-MD
|
||||
else
|
||||
tmpdepfile1="$dir$base.o.d"
|
||||
tmpdepfile2="$dir$base.d"
|
||||
tmpdepfile3="$dir$base.d"
|
||||
"$@" -MD
|
||||
fi
|
||||
|
||||
stat=$?
|
||||
if test $stat -eq 0; then :
|
||||
else
|
||||
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
|
||||
exit $stat
|
||||
fi
|
||||
|
||||
if test -f "$tmpdepfile1"; then
|
||||
tmpdepfile="$tmpdepfile1"
|
||||
elif test -f "$tmpdepfile2"; then
|
||||
tmpdepfile="$tmpdepfile2"
|
||||
else
|
||||
tmpdepfile="$tmpdepfile3"
|
||||
fi
|
||||
if test -f "$tmpdepfile"; then
|
||||
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
|
||||
# That's a tab and a space in the [].
|
||||
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
|
||||
else
|
||||
echo "#dummy" > "$depfile"
|
||||
fi
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
#nosideeffect)
|
||||
# This comment above is used by automake to tell side-effect
|
||||
# dependency tracking mechanisms from slower ones.
|
||||
|
||||
dashmstdout)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
test -z "$dashmflag" && dashmflag=-M
|
||||
# Require at least two characters before searching for `:'
|
||||
# in the target name. This is to cope with DOS-style filenames:
|
||||
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
|
||||
"$@" $dashmflag |
|
||||
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
tr ' ' '
|
||||
' < "$tmpdepfile" | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
dashXmstdout)
|
||||
# This case only exists to satisfy depend.m4. It is never actually
|
||||
# run, as this mode is specially recognized in the preamble.
|
||||
exit 1
|
||||
;;
|
||||
|
||||
makedepend)
|
||||
"$@" || exit $?
|
||||
# Remove any Libtool call
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
# X makedepend
|
||||
shift
|
||||
cleared=no
|
||||
for arg in "$@"; do
|
||||
case $cleared in
|
||||
no)
|
||||
set ""; shift
|
||||
cleared=yes ;;
|
||||
esac
|
||||
case "$arg" in
|
||||
-D*|-I*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
# Strip any option that makedepend may not understand. Remove
|
||||
# the object too, otherwise makedepend will parse it as a source file.
|
||||
-*|$object)
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"; shift ;;
|
||||
esac
|
||||
done
|
||||
obj_suffix="`echo $object | sed 's/^.*\././'`"
|
||||
touch "$tmpdepfile"
|
||||
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
|
||||
rm -f "$depfile"
|
||||
cat < "$tmpdepfile" > "$depfile"
|
||||
sed '1,2d' "$tmpdepfile" | tr ' ' '
|
||||
' | \
|
||||
## Some versions of the HPUX 10.20 sed can't process this invocation
|
||||
## correctly. Breaking it into two sed invocations is a workaround.
|
||||
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile" "$tmpdepfile".bak
|
||||
;;
|
||||
|
||||
cpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout.
|
||||
"$@" || exit $?
|
||||
|
||||
# Remove the call to Libtool.
|
||||
if test "$libtool" = yes; then
|
||||
while test $1 != '--mode=compile'; do
|
||||
shift
|
||||
done
|
||||
shift
|
||||
fi
|
||||
|
||||
# Remove `-o $object'.
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case $arg in
|
||||
-o)
|
||||
shift
|
||||
;;
|
||||
$object)
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift # fnord
|
||||
shift # $arg
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
"$@" -E |
|
||||
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
|
||||
sed '$ s: \\$::' > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
cat < "$tmpdepfile" >> "$depfile"
|
||||
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
msvisualcpp)
|
||||
# Important note: in order to support this mode, a compiler *must*
|
||||
# always write the preprocessed file to stdout, regardless of -o,
|
||||
# because we must use -o when running libtool.
|
||||
"$@" || exit $?
|
||||
IFS=" "
|
||||
for arg
|
||||
do
|
||||
case "$arg" in
|
||||
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
|
||||
set fnord "$@"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
set fnord "$@" "$arg"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
"$@" -E |
|
||||
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
|
||||
rm -f "$depfile"
|
||||
echo "$object : \\" > "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
|
||||
echo " " >> "$depfile"
|
||||
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
|
||||
rm -f "$tmpdepfile"
|
||||
;;
|
||||
|
||||
none)
|
||||
exec "$@"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Unknown depmode $depmode" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
2379
extern/editline/display.c
vendored
2379
extern/editline/display.c
vendored
File diff suppressed because it is too large
Load Diff
873
extern/editline/emacs_keymap.c
vendored
873
extern/editline/emacs_keymap.c
vendored
@ -1,873 +0,0 @@
|
||||
/* emacs_keymap.c -- the keymap for emacs_mode in readline (). */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (BUFSIZ)
|
||||
#include <stdio.h>
|
||||
#endif /* !BUFSIZ */
|
||||
|
||||
#include "readline.h"
|
||||
|
||||
/* An array of function pointers, one for each possible key.
|
||||
If the type byte is ISKMAP, then the pointer is the address of
|
||||
a keymap. */
|
||||
|
||||
KEYMAP_ENTRY_ARRAY emacs_standard_keymap = {
|
||||
|
||||
/* Control keys. */
|
||||
{ ISFUNC, rl_set_mark }, /* Control-@ */
|
||||
{ ISFUNC, rl_beg_of_line }, /* Control-a */
|
||||
{ ISFUNC, rl_backward_char }, /* Control-b */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-c */
|
||||
{ ISFUNC, rl_delete }, /* Control-d */
|
||||
{ ISFUNC, rl_end_of_line }, /* Control-e */
|
||||
{ ISFUNC, rl_forward_char }, /* Control-f */
|
||||
{ ISFUNC, rl_abort }, /* Control-g */
|
||||
{ ISFUNC, rl_rubout }, /* Control-h */
|
||||
{ ISFUNC, rl_complete }, /* Control-i */
|
||||
{ ISFUNC, rl_newline }, /* Control-j */
|
||||
{ ISFUNC, rl_kill_line }, /* Control-k */
|
||||
{ ISFUNC, rl_clear_screen }, /* Control-l */
|
||||
{ ISFUNC, rl_newline }, /* Control-m */
|
||||
{ ISFUNC, rl_get_next_history }, /* Control-n */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-o */
|
||||
{ ISFUNC, rl_get_previous_history }, /* Control-p */
|
||||
{ ISFUNC, rl_quoted_insert }, /* Control-q */
|
||||
{ ISFUNC, rl_reverse_search_history }, /* Control-r */
|
||||
{ ISFUNC, rl_forward_search_history }, /* Control-s */
|
||||
{ ISFUNC, rl_transpose_chars }, /* Control-t */
|
||||
{ ISFUNC, rl_unix_line_discard }, /* Control-u */
|
||||
{ ISFUNC, rl_quoted_insert }, /* Control-v */
|
||||
{ ISFUNC, rl_unix_word_rubout }, /* Control-w */
|
||||
{ ISKMAP, (rl_command_func_t *)emacs_ctlx_keymap }, /* Control-x */
|
||||
{ ISFUNC, rl_yank }, /* Control-y */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-z */
|
||||
{ ISKMAP, (rl_command_func_t *)emacs_meta_keymap }, /* Control-[ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-\ */
|
||||
{ ISFUNC, rl_char_search }, /* Control-] */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-^ */
|
||||
{ ISFUNC, rl_undo_command }, /* Control-_ */
|
||||
|
||||
/* The start of printing characters. */
|
||||
{ ISFUNC, rl_insert }, /* SPACE */
|
||||
{ ISFUNC, rl_insert }, /* ! */
|
||||
{ ISFUNC, rl_insert }, /* " */
|
||||
{ ISFUNC, rl_insert }, /* # */
|
||||
{ ISFUNC, rl_insert }, /* $ */
|
||||
{ ISFUNC, rl_insert }, /* % */
|
||||
{ ISFUNC, rl_insert }, /* & */
|
||||
{ ISFUNC, rl_insert }, /* ' */
|
||||
{ ISFUNC, rl_insert }, /* ( */
|
||||
{ ISFUNC, rl_insert }, /* ) */
|
||||
{ ISFUNC, rl_insert }, /* * */
|
||||
{ ISFUNC, rl_insert }, /* + */
|
||||
{ ISFUNC, rl_insert }, /* , */
|
||||
{ ISFUNC, rl_insert }, /* - */
|
||||
{ ISFUNC, rl_insert }, /* . */
|
||||
{ ISFUNC, rl_insert }, /* / */
|
||||
|
||||
/* Regular digits. */
|
||||
{ ISFUNC, rl_insert }, /* 0 */
|
||||
{ ISFUNC, rl_insert }, /* 1 */
|
||||
{ ISFUNC, rl_insert }, /* 2 */
|
||||
{ ISFUNC, rl_insert }, /* 3 */
|
||||
{ ISFUNC, rl_insert }, /* 4 */
|
||||
{ ISFUNC, rl_insert }, /* 5 */
|
||||
{ ISFUNC, rl_insert }, /* 6 */
|
||||
{ ISFUNC, rl_insert }, /* 7 */
|
||||
{ ISFUNC, rl_insert }, /* 8 */
|
||||
{ ISFUNC, rl_insert }, /* 9 */
|
||||
|
||||
/* A little more punctuation. */
|
||||
{ ISFUNC, rl_insert }, /* : */
|
||||
{ ISFUNC, rl_insert }, /* ; */
|
||||
{ ISFUNC, rl_insert }, /* < */
|
||||
{ ISFUNC, rl_insert }, /* = */
|
||||
{ ISFUNC, rl_insert }, /* > */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* @ */
|
||||
|
||||
/* Uppercase alphabet. */
|
||||
{ ISFUNC, rl_insert }, /* A */
|
||||
{ ISFUNC, rl_insert }, /* B */
|
||||
{ ISFUNC, rl_insert }, /* C */
|
||||
{ ISFUNC, rl_insert }, /* D */
|
||||
{ ISFUNC, rl_insert }, /* E */
|
||||
{ ISFUNC, rl_insert }, /* F */
|
||||
{ ISFUNC, rl_insert }, /* G */
|
||||
{ ISFUNC, rl_insert }, /* H */
|
||||
{ ISFUNC, rl_insert }, /* I */
|
||||
{ ISFUNC, rl_insert }, /* J */
|
||||
{ ISFUNC, rl_insert }, /* K */
|
||||
{ ISFUNC, rl_insert }, /* L */
|
||||
{ ISFUNC, rl_insert }, /* M */
|
||||
{ ISFUNC, rl_insert }, /* N */
|
||||
{ ISFUNC, rl_insert }, /* O */
|
||||
{ ISFUNC, rl_insert }, /* P */
|
||||
{ ISFUNC, rl_insert }, /* Q */
|
||||
{ ISFUNC, rl_insert }, /* R */
|
||||
{ ISFUNC, rl_insert }, /* S */
|
||||
{ ISFUNC, rl_insert }, /* T */
|
||||
{ ISFUNC, rl_insert }, /* U */
|
||||
{ ISFUNC, rl_insert }, /* V */
|
||||
{ ISFUNC, rl_insert }, /* W */
|
||||
{ ISFUNC, rl_insert }, /* X */
|
||||
{ ISFUNC, rl_insert }, /* Y */
|
||||
{ ISFUNC, rl_insert }, /* Z */
|
||||
|
||||
/* Some more punctuation. */
|
||||
{ ISFUNC, rl_insert }, /* [ */
|
||||
{ ISFUNC, rl_insert }, /* \ */
|
||||
{ ISFUNC, rl_insert }, /* ] */
|
||||
{ ISFUNC, rl_insert }, /* ^ */
|
||||
{ ISFUNC, rl_insert }, /* _ */
|
||||
{ ISFUNC, rl_insert }, /* ` */
|
||||
|
||||
/* Lowercase alphabet. */
|
||||
{ ISFUNC, rl_insert }, /* a */
|
||||
{ ISFUNC, rl_insert }, /* b */
|
||||
{ ISFUNC, rl_insert }, /* c */
|
||||
{ ISFUNC, rl_insert }, /* d */
|
||||
{ ISFUNC, rl_insert }, /* e */
|
||||
{ ISFUNC, rl_insert }, /* f */
|
||||
{ ISFUNC, rl_insert }, /* g */
|
||||
{ ISFUNC, rl_insert }, /* h */
|
||||
{ ISFUNC, rl_insert }, /* i */
|
||||
{ ISFUNC, rl_insert }, /* j */
|
||||
{ ISFUNC, rl_insert }, /* k */
|
||||
{ ISFUNC, rl_insert }, /* l */
|
||||
{ ISFUNC, rl_insert }, /* m */
|
||||
{ ISFUNC, rl_insert }, /* n */
|
||||
{ ISFUNC, rl_insert }, /* o */
|
||||
{ ISFUNC, rl_insert }, /* p */
|
||||
{ ISFUNC, rl_insert }, /* q */
|
||||
{ ISFUNC, rl_insert }, /* r */
|
||||
{ ISFUNC, rl_insert }, /* s */
|
||||
{ ISFUNC, rl_insert }, /* t */
|
||||
{ ISFUNC, rl_insert }, /* u */
|
||||
{ ISFUNC, rl_insert }, /* v */
|
||||
{ ISFUNC, rl_insert }, /* w */
|
||||
{ ISFUNC, rl_insert }, /* x */
|
||||
{ ISFUNC, rl_insert }, /* y */
|
||||
{ ISFUNC, rl_insert }, /* z */
|
||||
|
||||
/* Final punctuation. */
|
||||
{ ISFUNC, rl_insert }, /* { */
|
||||
{ ISFUNC, rl_insert }, /* | */
|
||||
{ ISFUNC, rl_insert }, /* } */
|
||||
{ ISFUNC, rl_insert }, /* ~ */
|
||||
{ ISFUNC, rl_rubout }, /* RUBOUT */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Pure 8-bit characters (128 - 159).
|
||||
These might be used in some
|
||||
character sets. */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
{ ISFUNC, rl_insert }, /* ? */
|
||||
|
||||
/* ISO Latin-1 characters (160 - 255) */
|
||||
{ ISFUNC, rl_insert }, /* No-break space */
|
||||
{ ISFUNC, rl_insert }, /* Inverted exclamation mark */
|
||||
{ ISFUNC, rl_insert }, /* Cent sign */
|
||||
{ ISFUNC, rl_insert }, /* Pound sign */
|
||||
{ ISFUNC, rl_insert }, /* Currency sign */
|
||||
{ ISFUNC, rl_insert }, /* Yen sign */
|
||||
{ ISFUNC, rl_insert }, /* Broken bar */
|
||||
{ ISFUNC, rl_insert }, /* Section sign */
|
||||
{ ISFUNC, rl_insert }, /* Diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Copyright sign */
|
||||
{ ISFUNC, rl_insert }, /* Feminine ordinal indicator */
|
||||
{ ISFUNC, rl_insert }, /* Left pointing double angle quotation mark */
|
||||
{ ISFUNC, rl_insert }, /* Not sign */
|
||||
{ ISFUNC, rl_insert }, /* Soft hyphen */
|
||||
{ ISFUNC, rl_insert }, /* Registered sign */
|
||||
{ ISFUNC, rl_insert }, /* Macron */
|
||||
{ ISFUNC, rl_insert }, /* Degree sign */
|
||||
{ ISFUNC, rl_insert }, /* Plus-minus sign */
|
||||
{ ISFUNC, rl_insert }, /* Superscript two */
|
||||
{ ISFUNC, rl_insert }, /* Superscript three */
|
||||
{ ISFUNC, rl_insert }, /* Acute accent */
|
||||
{ ISFUNC, rl_insert }, /* Micro sign */
|
||||
{ ISFUNC, rl_insert }, /* Pilcrow sign */
|
||||
{ ISFUNC, rl_insert }, /* Middle dot */
|
||||
{ ISFUNC, rl_insert }, /* Cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Superscript one */
|
||||
{ ISFUNC, rl_insert }, /* Masculine ordinal indicator */
|
||||
{ ISFUNC, rl_insert }, /* Right pointing double angle quotation mark */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction one quarter */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction one half */
|
||||
{ ISFUNC, rl_insert }, /* Vulgar fraction three quarters */
|
||||
{ ISFUNC, rl_insert }, /* Inverted questionk mark */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter a with ring above */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter ae */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter c with cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter e with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter i with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter eth (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter n with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Multiplication sign */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter o with stroke */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter u with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter Y with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin capital letter thorn (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter sharp s (German) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter a with ring above */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter ae */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter c with cedilla */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter e with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter i with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter eth (Icelandic) */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter n with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with tilde */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Division sign */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter o with stroke */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with grave */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with circumflex */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter u with diaeresis */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter y with acute */
|
||||
{ ISFUNC, rl_insert }, /* Latin small letter thorn (Icelandic) */
|
||||
{ ISFUNC, rl_insert } /* Latin small letter y with diaeresis */
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
||||
KEYMAP_ENTRY_ARRAY emacs_meta_keymap = {
|
||||
|
||||
/* Meta keys. Just like above, but the high bit is set. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-@ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-a */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-b */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-c */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-d */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-e */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-f */
|
||||
{ ISFUNC, rl_abort }, /* Meta-Control-g */
|
||||
{ ISFUNC, rl_backward_kill_word }, /* Meta-Control-h */
|
||||
{ ISFUNC, rl_tab_insert }, /* Meta-Control-i */
|
||||
{ ISFUNC, rl_vi_editing_mode }, /* Meta-Control-j */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-k */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-l */
|
||||
{ ISFUNC, rl_vi_editing_mode }, /* Meta-Control-m */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-n */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-o */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-p */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-q */
|
||||
{ ISFUNC, rl_revert_line }, /* Meta-Control-r */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-s */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-t */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-u */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-v */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-w */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-x */
|
||||
{ ISFUNC, rl_yank_nth_arg }, /* Meta-Control-y */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-z */
|
||||
|
||||
{ ISFUNC, rl_complete }, /* Meta-Control-[ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-\ */
|
||||
{ ISFUNC, rl_backward_char_search }, /* Meta-Control-] */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-^ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-Control-_ */
|
||||
|
||||
/* The start of printing characters. */
|
||||
{ ISFUNC, rl_set_mark }, /* Meta-SPACE */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-! */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-" */
|
||||
{ ISFUNC, rl_insert_comment }, /* Meta-# */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-$ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-% */
|
||||
{ ISFUNC, rl_tilde_expand }, /* Meta-& */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-' */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-( */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-) */
|
||||
{ ISFUNC, rl_insert_completions }, /* Meta-* */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-+ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-, */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-- */
|
||||
{ ISFUNC, rl_yank_last_arg}, /* Meta-. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-/ */
|
||||
|
||||
/* Regular digits. */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-0 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-1 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-2 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-3 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-4 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-5 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-6 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-7 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-8 */
|
||||
{ ISFUNC, rl_digit_argument }, /* Meta-9 */
|
||||
|
||||
/* A little more punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-: */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-; */
|
||||
{ ISFUNC, rl_beginning_of_history }, /* Meta-< */
|
||||
{ ISFUNC, rl_possible_completions }, /* Meta-= */
|
||||
{ ISFUNC, rl_end_of_history }, /* Meta-> */
|
||||
{ ISFUNC, rl_possible_completions }, /* Meta-? */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-@ */
|
||||
|
||||
/* Uppercase alphabet. */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-A */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-B */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-C */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-D */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-E */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-F */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-G */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-H */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-I */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-J */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-K */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-L */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-M */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-N */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-O */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-P */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-Q */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-R */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-S */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-T */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-U */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-V */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-W */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-X */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-Y */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Meta-Z */
|
||||
|
||||
/* Some more punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-[ */ /* was rl_arrow_keys */
|
||||
{ ISFUNC, rl_delete_horizontal_space }, /* Meta-\ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-] */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-^ */
|
||||
{ ISFUNC, rl_yank_last_arg }, /* Meta-_ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-` */
|
||||
|
||||
/* Lowercase alphabet. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-a */
|
||||
{ ISFUNC, rl_backward_word }, /* Meta-b */
|
||||
{ ISFUNC, rl_capitalize_word }, /* Meta-c */
|
||||
{ ISFUNC, rl_kill_word }, /* Meta-d */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-e */
|
||||
{ ISFUNC, rl_forward_word }, /* Meta-f */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-g */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-h */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-i */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-j */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-k */
|
||||
{ ISFUNC, rl_downcase_word }, /* Meta-l */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-m */
|
||||
{ ISFUNC, rl_noninc_forward_search }, /* Meta-n */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-o */ /* was rl_arrow_keys */
|
||||
{ ISFUNC, rl_noninc_reverse_search }, /* Meta-p */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-q */
|
||||
{ ISFUNC, rl_revert_line }, /* Meta-r */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-s */
|
||||
{ ISFUNC, rl_transpose_words }, /* Meta-t */
|
||||
{ ISFUNC, rl_upcase_word }, /* Meta-u */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-v */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-w */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-x */
|
||||
{ ISFUNC, rl_yank_pop }, /* Meta-y */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-z */
|
||||
|
||||
/* Final punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-{ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-| */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Meta-} */
|
||||
{ ISFUNC, rl_tilde_expand }, /* Meta-~ */
|
||||
{ ISFUNC, rl_backward_kill_word }, /* Meta-rubout */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Undefined keys. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
||||
|
||||
KEYMAP_ENTRY_ARRAY emacs_ctlx_keymap = {
|
||||
|
||||
/* Control keys. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-@ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-a */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-b */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-c */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-d */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-e */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-f */
|
||||
{ ISFUNC, rl_abort }, /* Control-g */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-h */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-i */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-j */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-k */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-l */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-m */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-n */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-o */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-p */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-q */
|
||||
{ ISFUNC, rl_re_read_init_file }, /* Control-r */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-s */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-t */
|
||||
{ ISFUNC, rl_undo_command }, /* Control-u */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-v */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-w */
|
||||
{ ISFUNC, rl_exchange_point_and_mark }, /* Control-x */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-y */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-z */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-[ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-\ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-] */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-^ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* Control-_ */
|
||||
|
||||
/* The start of printing characters. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* SPACE */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ! */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* " */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* # */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* $ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* % */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* & */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ' */
|
||||
{ ISFUNC, rl_start_kbd_macro }, /* ( */
|
||||
{ ISFUNC, rl_end_kbd_macro }, /* ) */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* * */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* + */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* , */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* - */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* . */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* / */
|
||||
|
||||
/* Regular digits. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 0 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 1 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 2 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 3 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 4 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 5 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 6 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 7 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 8 */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* 9 */
|
||||
|
||||
/* A little more punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* : */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ; */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* < */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* = */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* > */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ? */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* @ */
|
||||
|
||||
/* Uppercase alphabet. */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* A */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* B */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* C */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* D */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* E */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* F */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* G */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* H */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* I */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* J */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* K */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* L */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* M */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* N */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* O */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* P */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Q */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* R */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* S */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* T */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* U */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* V */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* W */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* X */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Y */
|
||||
{ ISFUNC, rl_do_lowercase_version }, /* Z */
|
||||
|
||||
/* Some more punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* [ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* \ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ] */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ^ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* _ */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ` */
|
||||
|
||||
/* Lowercase alphabet. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* a */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* b */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* c */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* d */
|
||||
{ ISFUNC, rl_call_last_kbd_macro }, /* e */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* f */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* g */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* h */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* i */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* j */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* k */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* l */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* m */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* n */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* o */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* p */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* q */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* r */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* s */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* t */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* u */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* v */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* w */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* x */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* y */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* z */
|
||||
|
||||
/* Final punctuation. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* { */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* | */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* } */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }, /* ~ */
|
||||
{ ISFUNC, rl_backward_kill_line }, /* RUBOUT */
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* Undefined keys. */
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 },
|
||||
{ ISFUNC, (rl_command_func_t *)0x0 }
|
||||
#endif /* KEYMAP_SIZE > 128 */
|
||||
};
|
255
extern/editline/funmap.c
vendored
255
extern/editline/funmap.c
vendored
@ -1,255 +0,0 @@
|
||||
/* funmap.c -- attach names to functions. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if !defined (BUFSIZ)
|
||||
#include <stdio.h>
|
||||
#endif /* BUFSIZ */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include "rlconf.h"
|
||||
#include "readline.h"
|
||||
|
||||
#include "xmalloc.h"
|
||||
|
||||
#ifdef __STDC__
|
||||
typedef int QSFUNC (const void *, const void *);
|
||||
#else
|
||||
typedef int QSFUNC ();
|
||||
#endif
|
||||
|
||||
extern int _rl_qsort_string_compare PARAMS((char **, char **));
|
||||
|
||||
FUNMAP **funmap;
|
||||
static int funmap_size;
|
||||
static int funmap_entry;
|
||||
|
||||
/* After initializing the function map, this is the index of the first
|
||||
program specific function. */
|
||||
int funmap_program_specific_entry_start;
|
||||
|
||||
static FUNMAP default_funmap[] = {
|
||||
{ "abort", rl_abort },
|
||||
{ "accept-line", rl_newline },
|
||||
{ "arrow-key-prefix", rl_arrow_keys },
|
||||
{ "backward-byte", rl_backward_byte },
|
||||
{ "backward-char", rl_backward_char },
|
||||
{ "backward-delete-char", rl_rubout },
|
||||
{ "backward-kill-line", rl_backward_kill_line },
|
||||
{ "backward-kill-word", rl_backward_kill_word },
|
||||
{ "backward-word", rl_backward_word },
|
||||
{ "beginning-of-history", rl_beginning_of_history },
|
||||
{ "beginning-of-line", rl_beg_of_line },
|
||||
{ "call-last-kbd-macro", rl_call_last_kbd_macro },
|
||||
{ "capitalize-word", rl_capitalize_word },
|
||||
{ "character-search", rl_char_search },
|
||||
{ "character-search-backward", rl_backward_char_search },
|
||||
{ "clear-screen", rl_clear_screen },
|
||||
{ "complete", rl_complete },
|
||||
{ "copy-backward-word", rl_copy_backward_word },
|
||||
{ "copy-forward-word", rl_copy_forward_word },
|
||||
{ "copy-region-as-kill", rl_copy_region_to_kill },
|
||||
{ "delete-char", rl_delete },
|
||||
{ "delete-char-or-list", rl_delete_or_show_completions },
|
||||
{ "delete-horizontal-space", rl_delete_horizontal_space },
|
||||
{ "digit-argument", rl_digit_argument },
|
||||
{ "do-lowercase-version", rl_do_lowercase_version },
|
||||
{ "downcase-word", rl_downcase_word },
|
||||
{ "dump-functions", rl_dump_functions },
|
||||
{ "dump-macros", rl_dump_macros },
|
||||
{ "dump-variables", rl_dump_variables },
|
||||
{ "emacs-editing-mode", rl_emacs_editing_mode },
|
||||
{ "end-kbd-macro", rl_end_kbd_macro },
|
||||
{ "end-of-history", rl_end_of_history },
|
||||
{ "end-of-line", rl_end_of_line },
|
||||
{ "exchange-point-and-mark", rl_exchange_point_and_mark },
|
||||
{ "forward-backward-delete-char", rl_rubout_or_delete },
|
||||
{ "forward-byte", rl_forward_byte },
|
||||
{ "forward-char", rl_forward_char },
|
||||
{ "forward-search-history", rl_forward_search_history },
|
||||
{ "forward-word", rl_forward_word },
|
||||
{ "history-search-backward", rl_history_search_backward },
|
||||
{ "history-search-forward", rl_history_search_forward },
|
||||
{ "insert-comment", rl_insert_comment },
|
||||
{ "insert-completions", rl_insert_completions },
|
||||
{ "kill-whole-line", rl_kill_full_line },
|
||||
{ "kill-line", rl_kill_line },
|
||||
{ "kill-region", rl_kill_region },
|
||||
{ "kill-word", rl_kill_word },
|
||||
{ "menu-complete", rl_menu_complete },
|
||||
{ "next-history", rl_get_next_history },
|
||||
{ "non-incremental-forward-search-history", rl_noninc_forward_search },
|
||||
{ "non-incremental-reverse-search-history", rl_noninc_reverse_search },
|
||||
{ "non-incremental-forward-search-history-again", rl_noninc_forward_search_again },
|
||||
{ "non-incremental-reverse-search-history-again", rl_noninc_reverse_search_again },
|
||||
{ "overwrite-mode", rl_overwrite_mode },
|
||||
#ifdef __CYGWIN__
|
||||
{ "paste-from-clipboard", rl_paste_from_clipboard },
|
||||
#endif
|
||||
{ "possible-completions", rl_possible_completions },
|
||||
{ "previous-history", rl_get_previous_history },
|
||||
{ "quoted-insert", rl_quoted_insert },
|
||||
{ "re-read-init-file", rl_re_read_init_file },
|
||||
{ "redraw-current-line", rl_refresh_line},
|
||||
{ "reverse-search-history", rl_reverse_search_history },
|
||||
{ "revert-line", rl_revert_line },
|
||||
{ "self-insert", rl_insert },
|
||||
{ "set-mark", rl_set_mark },
|
||||
{ "start-kbd-macro", rl_start_kbd_macro },
|
||||
{ "tab-insert", rl_tab_insert },
|
||||
{ "tilde-expand", rl_tilde_expand },
|
||||
{ "transpose-chars", rl_transpose_chars },
|
||||
{ "transpose-words", rl_transpose_words },
|
||||
{ "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 },
|
||||
{ "yank", rl_yank },
|
||||
{ "yank-last-arg", rl_yank_last_arg },
|
||||
{ "yank-nth-arg", rl_yank_nth_arg },
|
||||
{ "yank-pop", rl_yank_pop },
|
||||
|
||||
#if defined (VI_MODE)
|
||||
{ "vi-append-eol", rl_vi_append_eol },
|
||||
{ "vi-append-mode", rl_vi_append_mode },
|
||||
{ "vi-arg-digit", rl_vi_arg_digit },
|
||||
{ "vi-back-to-indent", rl_vi_back_to_indent },
|
||||
{ "vi-bWord", rl_vi_bWord },
|
||||
{ "vi-bword", rl_vi_bword },
|
||||
{ "vi-change-case", rl_vi_change_case },
|
||||
{ "vi-change-char", rl_vi_change_char },
|
||||
{ "vi-change-to", rl_vi_change_to },
|
||||
{ "vi-char-search", rl_vi_char_search },
|
||||
{ "vi-column", rl_vi_column },
|
||||
{ "vi-complete", rl_vi_complete },
|
||||
{ "vi-delete", rl_vi_delete },
|
||||
{ "vi-delete-to", rl_vi_delete_to },
|
||||
{ "vi-eWord", rl_vi_eWord },
|
||||
{ "vi-editing-mode", rl_vi_editing_mode },
|
||||
{ "vi-end-word", rl_vi_end_word },
|
||||
{ "vi-eof-maybe", rl_vi_eof_maybe },
|
||||
{ "vi-eword", rl_vi_eword },
|
||||
{ "vi-fWord", rl_vi_fWord },
|
||||
{ "vi-fetch-history", rl_vi_fetch_history },
|
||||
{ "vi-first-print", rl_vi_first_print },
|
||||
{ "vi-fword", rl_vi_fword },
|
||||
{ "vi-goto-mark", rl_vi_goto_mark },
|
||||
{ "vi-insert-beg", rl_vi_insert_beg },
|
||||
{ "vi-insertion-mode", rl_vi_insertion_mode },
|
||||
{ "vi-match", rl_vi_match },
|
||||
{ "vi-movement-mode", rl_vi_movement_mode },
|
||||
{ "vi-next-word", rl_vi_next_word },
|
||||
{ "vi-overstrike", rl_vi_overstrike },
|
||||
{ "vi-overstrike-delete", rl_vi_overstrike_delete },
|
||||
{ "vi-prev-word", rl_vi_prev_word },
|
||||
{ "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 },
|
||||
{ "vi-subst", rl_vi_subst },
|
||||
{ "vi-tilde-expand", rl_vi_tilde_expand },
|
||||
{ "vi-yank-arg", rl_vi_yank_arg },
|
||||
{ "vi-yank-to", rl_vi_yank_to },
|
||||
#endif /* VI_MODE */
|
||||
|
||||
{(char *)NULL, (rl_command_func_t *)NULL }
|
||||
};
|
||||
|
||||
int
|
||||
rl_add_funmap_entry (name, function)
|
||||
const char *name;
|
||||
rl_command_func_t *function;
|
||||
{
|
||||
if (funmap_entry + 2 >= funmap_size)
|
||||
{
|
||||
funmap_size += 64;
|
||||
funmap = (FUNMAP **)xrealloc (funmap, funmap_size * sizeof (FUNMAP *));
|
||||
}
|
||||
|
||||
funmap[funmap_entry] = (FUNMAP *)xmalloc (sizeof (FUNMAP));
|
||||
funmap[funmap_entry]->name = name;
|
||||
funmap[funmap_entry]->function = function;
|
||||
|
||||
funmap[++funmap_entry] = (FUNMAP *)NULL;
|
||||
return funmap_entry;
|
||||
}
|
||||
|
||||
static int funmap_initialized;
|
||||
|
||||
/* Make the funmap contain all of the default entries. */
|
||||
void
|
||||
rl_initialize_funmap ()
|
||||
{
|
||||
register int i;
|
||||
|
||||
if (funmap_initialized)
|
||||
return;
|
||||
|
||||
for (i = 0; default_funmap[i].name; i++)
|
||||
rl_add_funmap_entry (default_funmap[i].name, default_funmap[i].function);
|
||||
|
||||
funmap_initialized = 1;
|
||||
funmap_program_specific_entry_start = i;
|
||||
}
|
||||
|
||||
/* Produce a NULL terminated array of known function names. The array
|
||||
is sorted. The array itself is allocated, but not the strings inside.
|
||||
You should free () the array when you done, but not the pointrs. */
|
||||
const char **
|
||||
rl_funmap_names ()
|
||||
{
|
||||
const char **result;
|
||||
int result_size, result_index;
|
||||
|
||||
/* Make sure that the function map has been initialized. */
|
||||
rl_initialize_funmap ();
|
||||
|
||||
for (result_index = result_size = 0, result = (const char **)NULL; funmap[result_index]; result_index++)
|
||||
{
|
||||
if (result_index + 2 > result_size)
|
||||
{
|
||||
result_size += 20;
|
||||
result = (const char **)xrealloc (result, result_size * sizeof (char *));
|
||||
}
|
||||
|
||||
result[result_index] = funmap[result_index]->name;
|
||||
result[result_index + 1] = (char *)NULL;
|
||||
}
|
||||
|
||||
qsort (result, result_index, sizeof (char *), (QSFUNC *)_rl_qsort_string_compare);
|
||||
return (result);
|
||||
}
|
1593
extern/editline/histexpand.c
vendored
1593
extern/editline/histexpand.c
vendored
File diff suppressed because it is too large
Load Diff
542
extern/editline/histfile.c
vendored
542
extern/editline/histfile.c
vendored
@ -1,542 +0,0 @@
|
||||
/* histfile.c - functions to manipulate the history file. */
|
||||
|
||||
/* 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.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
/* 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
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#if ! defined (_MINIX) && defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
#include "posixstat.h"
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (__EMX__) || defined (__CYGWIN__)
|
||||
# undef HAVE_MMAP
|
||||
#endif
|
||||
|
||||
#ifdef HISTORY_USE_MMAP
|
||||
# include <sys/mman.h>
|
||||
|
||||
# ifdef MAP_FILE
|
||||
# define MAP_RFLAGS (MAP_FILE|MAP_PRIVATE)
|
||||
# define MAP_WFLAGS (MAP_FILE|MAP_SHARED)
|
||||
# else
|
||||
# define MAP_RFLAGS MAP_PRIVATE
|
||||
# define MAP_WFLAGS MAP_SHARED
|
||||
# endif
|
||||
|
||||
# ifndef MAP_FAILED
|
||||
# define MAP_FAILED ((void *)-1)
|
||||
# endif
|
||||
|
||||
#endif /* 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
|
||||
is no \n -> \r\n conversion performed. On other systems, we don't want to
|
||||
mess around with O_BINARY at all, so we ensure that it's defined to 0. */
|
||||
#if defined (__EMX__) || defined (__CYGWIN__)
|
||||
# ifndef O_BINARY
|
||||
# define O_BINARY 0
|
||||
# endif
|
||||
#else /* !__EMX__ && !__CYGWIN__ */
|
||||
# undef O_BINARY
|
||||
# define O_BINARY 0
|
||||
#endif /* !__EMX__ && !__CYGWIN__ */
|
||||
|
||||
#include <errno.h>
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
#include "history.h"
|
||||
#include "histlib.h"
|
||||
|
||||
#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 (). */
|
||||
static char *
|
||||
history_filename (filename)
|
||||
const char *filename;
|
||||
{
|
||||
char *return_val;
|
||||
const char *home;
|
||||
int home_len;
|
||||
|
||||
return_val = filename ? savestring (filename) : (char *)NULL;
|
||||
|
||||
if (return_val)
|
||||
return (return_val);
|
||||
|
||||
home = sh_get_env_value ("HOME");
|
||||
|
||||
if (home == 0)
|
||||
{
|
||||
home = ".";
|
||||
home_len = 1;
|
||||
}
|
||||
else
|
||||
home_len = strlen (home);
|
||||
|
||||
return_val = (char *)xmalloc (2 + home_len + 8); /* strlen(".history") == 8 */
|
||||
strcpy (return_val, home);
|
||||
return_val[home_len] = '/';
|
||||
#if defined (__MSDOS__)
|
||||
strcpy (return_val + home_len + 1, "_history");
|
||||
#else
|
||||
strcpy (return_val + home_len + 1, ".history");
|
||||
#endif
|
||||
|
||||
return (return_val);
|
||||
}
|
||||
|
||||
/* Add the contents of FILENAME to the history list, a line at a time.
|
||||
If FILENAME is NULL, then read from ~/.history. Returns 0 if
|
||||
successful, or errno if not. */
|
||||
int
|
||||
read_history (filename)
|
||||
const char *filename;
|
||||
{
|
||||
return (read_history_range (filename, 0, -1));
|
||||
}
|
||||
|
||||
/* Read a range of lines from FILENAME, adding them to the history list.
|
||||
Start reading at the FROM'th line and end at the TO'th. If FROM
|
||||
is zero, start at the beginning. If TO is less than FROM, read
|
||||
until the end of the file. If FILENAME is NULL, then read from
|
||||
~/.history. Returns 0 if successful, or errno if not. */
|
||||
int
|
||||
read_history_range (filename, from, to)
|
||||
const char *filename;
|
||||
int from, to;
|
||||
{
|
||||
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 = last_ts = (char *)NULL;
|
||||
input = history_filename (filename);
|
||||
file = open (input, O_RDONLY|O_BINARY, 0666);
|
||||
|
||||
if ((file < 0) || (fstat (file, &finfo) == -1))
|
||||
goto error_and_exit;
|
||||
|
||||
file_size = (size_t)finfo.st_size;
|
||||
|
||||
/* check for overflow on very large files */
|
||||
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
||||
{
|
||||
errno = overflow_errno;
|
||||
goto error_and_exit;
|
||||
}
|
||||
|
||||
#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)
|
||||
{
|
||||
errno = overflow_errno;
|
||||
goto error_and_exit;
|
||||
}
|
||||
chars_read = file_size;
|
||||
#else
|
||||
buffer = (char *)malloc (file_size + 1);
|
||||
if (buffer == 0)
|
||||
{
|
||||
errno = overflow_errno;
|
||||
goto error_and_exit;
|
||||
}
|
||||
|
||||
chars_read = read (file, buffer, file_size);
|
||||
#endif
|
||||
if (chars_read < 0)
|
||||
{
|
||||
error_and_exit:
|
||||
if (errno != 0)
|
||||
chars_read = errno;
|
||||
else
|
||||
chars_read = EIO;
|
||||
if (file >= 0)
|
||||
close (file);
|
||||
|
||||
FREE (input);
|
||||
#ifndef HISTORY_USE_MMAP
|
||||
FREE (buffer);
|
||||
#endif
|
||||
|
||||
return (chars_read);
|
||||
}
|
||||
|
||||
close (file);
|
||||
|
||||
/* Set TO to larger than end of file if negative. */
|
||||
if (to < 0)
|
||||
to = chars_read;
|
||||
|
||||
/* Start at beginning of file, work to end. */
|
||||
bufend = buffer + chars_read;
|
||||
current_line = 0;
|
||||
|
||||
/* Skip lines until we are at FROM. */
|
||||
for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
|
||||
if (*line_end == '\n')
|
||||
{
|
||||
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. */
|
||||
for (line_end = line_start; line_end < bufend; line_end++)
|
||||
if (*line_end == '\n')
|
||||
{
|
||||
*line_end = '\0';
|
||||
|
||||
if (*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++;
|
||||
|
||||
if (current_line >= to)
|
||||
break;
|
||||
|
||||
line_start = line_end + 1;
|
||||
}
|
||||
|
||||
FREE (input);
|
||||
#ifndef HISTORY_USE_MMAP
|
||||
FREE (buffer);
|
||||
#else
|
||||
munmap (buffer, file_size);
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Truncate the history file FNAME, leaving only LINES trailing lines.
|
||||
If FNAME is NULL, then use ~/.history. Returns 0 on success, errno
|
||||
on failure. */
|
||||
int
|
||||
history_truncate_file (fname, lines)
|
||||
const char *fname;
|
||||
int lines;
|
||||
{
|
||||
char *buffer, *filename, *bp, *bp1; /* bp1 == bp+1 */
|
||||
int file, chars_read, rv;
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
|
||||
buffer = (char *)NULL;
|
||||
filename = history_filename (fname);
|
||||
file = open (filename, O_RDONLY|O_BINARY, 0666);
|
||||
rv = 0;
|
||||
|
||||
/* Don't try to truncate non-regular files. */
|
||||
if (file == -1 || fstat (file, &finfo) == -1)
|
||||
{
|
||||
rv = errno;
|
||||
if (file != -1)
|
||||
close (file);
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
if (S_ISREG (finfo.st_mode) == 0)
|
||||
{
|
||||
close (file);
|
||||
#ifdef EFTYPE
|
||||
rv = EFTYPE;
|
||||
#else
|
||||
rv = EINVAL;
|
||||
#endif
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
file_size = (size_t)finfo.st_size;
|
||||
|
||||
/* check for overflow on very large files */
|
||||
if (file_size != finfo.st_size || file_size + 1 < file_size)
|
||||
{
|
||||
close (file);
|
||||
#if defined (EFBIG)
|
||||
rv = errno = EFBIG;
|
||||
#elif defined (EOVERFLOW)
|
||||
rv = errno = EOVERFLOW;
|
||||
#else
|
||||
rv = errno = EINVAL;
|
||||
#endif
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
buffer = (char *)malloc (file_size + 1);
|
||||
if (buffer == 0)
|
||||
{
|
||||
close (file);
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
chars_read = read (file, buffer, file_size);
|
||||
close (file);
|
||||
|
||||
if (chars_read <= 0)
|
||||
{
|
||||
rv = (chars_read < 0) ? errno : 0;
|
||||
goto truncate_exit;
|
||||
}
|
||||
|
||||
/* Count backwards from the end of buffer until we have passed
|
||||
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' && HIST_TIMESTAMP_START(bp1) == 0)
|
||||
lines--;
|
||||
bp1 = bp;
|
||||
}
|
||||
|
||||
/* If this is the first line, then the file contains exactly the
|
||||
number of lines we want to truncate to, so we don't need to do
|
||||
anything. It's the first line if we don't find a newline between
|
||||
the current value of i and 0. Otherwise, write from the start of
|
||||
this line until the end of the buffer. */
|
||||
for ( ; bp > buffer; bp--)
|
||||
{
|
||||
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. */
|
||||
if (bp > buffer && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
|
||||
{
|
||||
write (file, bp, chars_read - (bp - buffer));
|
||||
|
||||
#if defined (__BEOS__)
|
||||
/* BeOS ignores O_TRUNC. */
|
||||
ftruncate (file, chars_read - (bp - buffer));
|
||||
#endif
|
||||
|
||||
close (file);
|
||||
}
|
||||
|
||||
truncate_exit:
|
||||
|
||||
FREE (buffer);
|
||||
|
||||
free (filename);
|
||||
return rv;
|
||||
}
|
||||
|
||||
/* Workhorse function for writing history. Writes NELEMENT entries
|
||||
from the history list to FILENAME. OVERWRITE is non-zero if you
|
||||
wish to replace FILENAME with the entries. */
|
||||
static int
|
||||
history_do_write (filename, nelements, overwrite)
|
||||
const char *filename;
|
||||
int nelements, overwrite;
|
||||
{
|
||||
register int i;
|
||||
char *output;
|
||||
int file, mode, rv;
|
||||
#ifdef HISTORY_USE_MMAP
|
||||
size_t cursize;
|
||||
|
||||
mode = overwrite ? O_RDWR|O_CREAT|O_TRUNC|O_BINARY : O_RDWR|O_APPEND|O_BINARY;
|
||||
#else
|
||||
mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
|
||||
#endif
|
||||
output = history_filename (filename);
|
||||
rv = 0;
|
||||
|
||||
if ((file = open (output, mode, 0600)) == -1)
|
||||
{
|
||||
FREE (output);
|
||||
return (errno);
|
||||
}
|
||||
|
||||
#ifdef HISTORY_USE_MMAP
|
||||
cursize = overwrite ? 0 : lseek (file, 0, SEEK_END);
|
||||
#endif
|
||||
|
||||
if (nelements > history_length)
|
||||
nelements = history_length;
|
||||
|
||||
/* Build a buffer of all the lines to write, and write them in one syscall.
|
||||
Suggested by Peter Ho (peter@robosts.oxford.ac.uk). */
|
||||
{
|
||||
HIST_ENTRY **the_history; /* local */
|
||||
register int j;
|
||||
int buffer_size;
|
||||
char *buffer;
|
||||
|
||||
the_history = history_list ();
|
||||
/* Calculate the total number of bytes to write. */
|
||||
for (buffer_size = 0, i = history_length - nelements; i < history_length; i++)
|
||||
#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 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);
|
||||
if ((void *)buffer == MAP_FAILED)
|
||||
{
|
||||
mmap_error:
|
||||
rv = errno;
|
||||
FREE (output);
|
||||
close (file);
|
||||
return rv;
|
||||
}
|
||||
#else
|
||||
buffer = (char *)malloc (buffer_size);
|
||||
if (buffer == 0)
|
||||
{
|
||||
rv = errno;
|
||||
FREE (output);
|
||||
close (file);
|
||||
return rv;
|
||||
}
|
||||
#endif
|
||||
|
||||
for (j = 0, i = history_length - nelements; i < history_length; i++)
|
||||
{
|
||||
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 HISTORY_USE_MMAP
|
||||
if (msync (buffer, buffer_size, 0) != 0 || munmap (buffer, buffer_size) != 0)
|
||||
rv = errno;
|
||||
#else
|
||||
if (write (file, buffer, buffer_size) < 0)
|
||||
rv = errno;
|
||||
free (buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
close (file);
|
||||
|
||||
FREE (output);
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
||||
/* Append NELEMENT entries to FILENAME. The entries appended are from
|
||||
the end of the list minus NELEMENTs up to the end of the list. */
|
||||
int
|
||||
append_history (nelements, filename)
|
||||
int nelements;
|
||||
const char *filename;
|
||||
{
|
||||
return (history_do_write (filename, nelements, HISTORY_APPEND));
|
||||
}
|
||||
|
||||
/* Overwrite FILENAME with the current history. If FILENAME is NULL,
|
||||
then write the history list to ~/.history. Values returned
|
||||
are as in read_history ().*/
|
||||
int
|
||||
write_history (filename)
|
||||
const char *filename;
|
||||
{
|
||||
return (history_do_write (filename, history_length, HISTORY_OVERWRITE));
|
||||
}
|
82
extern/editline/histlib.h
vendored
82
extern/editline/histlib.h
vendored
@ -1,82 +0,0 @@
|
||||
/* histlib.h -- internal definitions for the history library. */
|
||||
/* Copyright (C) 1989, 1992 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.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_HISTLIB_H_)
|
||||
#define _HISTLIB_H_
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if !defined (STREQ)
|
||||
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
|
||||
#define STREQN(a, b, n) (((n) == 0) ? (1) \
|
||||
: ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
|
||||
#endif
|
||||
|
||||
#ifndef savestring
|
||||
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
|
||||
#endif
|
||||
|
||||
#ifndef whitespace
|
||||
#define whitespace(c) (((c) == ' ') || ((c) == '\t'))
|
||||
#endif
|
||||
|
||||
#ifndef _rl_digit_p
|
||||
#define _rl_digit_p(c) ((c) >= '0' && (c) <= '9')
|
||||
#endif
|
||||
|
||||
#ifndef _rl_digit_value
|
||||
#define _rl_digit_value(c) ((c) - '0')
|
||||
#endif
|
||||
|
||||
#ifndef member
|
||||
# ifndef strchr
|
||||
extern char *strchr ();
|
||||
# endif
|
||||
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
|
||||
#endif
|
||||
|
||||
#ifndef FREE
|
||||
# define FREE(x) if (x) free (x)
|
||||
#endif
|
||||
|
||||
/* Possible history errors passed to hist_error. */
|
||||
#define EVENT_NOT_FOUND 0
|
||||
#define BAD_WORD_SPEC 1
|
||||
#define SUBST_FAILED 2
|
||||
#define BAD_MODIFIER 3
|
||||
#define NO_PREV_SUBST 4
|
||||
|
||||
/* Possible definitions for history starting point specification. */
|
||||
#define ANCHORED_SEARCH 1
|
||||
#define NON_ANCHORED_SEARCH 0
|
||||
|
||||
/* Possible definitions for what style of writing the history file we want. */
|
||||
#define HISTORY_APPEND 0
|
||||
#define HISTORY_OVERWRITE 1
|
||||
|
||||
/* Some variable definitions shared across history source files. */
|
||||
extern int history_offset;
|
||||
|
||||
#endif /* !_HISTLIB_H_ */
|
441
extern/editline/history.c
vendored
441
extern/editline/history.c
vendored
@ -1,441 +0,0 @@
|
||||
/* history.c -- standalone history library */
|
||||
|
||||
/* 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.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
/* 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 (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "history.h"
|
||||
#include "histlib.h"
|
||||
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* The number of slots to increase the_history by. */
|
||||
#define DEFAULT_HISTORY_GROW_SIZE 50
|
||||
|
||||
static char *hist_inittime PARAMS((void));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* History Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* An array of HIST_ENTRY. This is where we store the history. */
|
||||
static HIST_ENTRY **the_history = (HIST_ENTRY **)NULL;
|
||||
|
||||
/* Non-zero means that we have enforced a limit on the amount of
|
||||
history that we save. */
|
||||
static int history_stifled;
|
||||
|
||||
/* The current number of slots allocated to the input_history. */
|
||||
static int history_size;
|
||||
|
||||
/* If HISTORY_STIFLED is non-zero, then this is the maximum number of
|
||||
entries to remember. */
|
||||
int history_max_entries;
|
||||
int max_input_history; /* backwards compatibility */
|
||||
|
||||
/* The current location of the interactive history pointer. Just makes
|
||||
life easier for outside callers. */
|
||||
int history_offset;
|
||||
|
||||
/* The number of strings currently stored in the history list. */
|
||||
int history_length;
|
||||
|
||||
/* The logical `base' of the history array. It defaults to 1. */
|
||||
int history_base = 1;
|
||||
|
||||
/* Return the current HISTORY_STATE of the history. */
|
||||
HISTORY_STATE *
|
||||
history_get_history_state ()
|
||||
{
|
||||
HISTORY_STATE *state;
|
||||
|
||||
state = (HISTORY_STATE *)xmalloc (sizeof (HISTORY_STATE));
|
||||
state->entries = the_history;
|
||||
state->offset = history_offset;
|
||||
state->length = history_length;
|
||||
state->size = history_size;
|
||||
state->flags = 0;
|
||||
if (history_stifled)
|
||||
state->flags |= HS_STIFLED;
|
||||
|
||||
return (state);
|
||||
}
|
||||
|
||||
/* Set the state of the current history array to STATE. */
|
||||
void
|
||||
history_set_history_state (state)
|
||||
HISTORY_STATE *state;
|
||||
{
|
||||
the_history = state->entries;
|
||||
history_offset = state->offset;
|
||||
history_length = state->length;
|
||||
history_size = state->size;
|
||||
if (state->flags & HS_STIFLED)
|
||||
history_stifled = 1;
|
||||
}
|
||||
|
||||
/* Begin a session in which the history functions might be used. This
|
||||
initializes interactive variables. */
|
||||
void
|
||||
using_history ()
|
||||
{
|
||||
history_offset = history_length;
|
||||
}
|
||||
|
||||
/* Return the number of bytes that the primary history entries are using.
|
||||
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 += HISTENT_BYTES (the_history[i]);
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Returns the magic number which says what history element we are
|
||||
looking at now. In this implementation, it returns history_offset. */
|
||||
int
|
||||
where_history ()
|
||||
{
|
||||
return (history_offset);
|
||||
}
|
||||
|
||||
/* Make the current history item be the one at POS, an absolute index.
|
||||
Returns zero if POS is out of range, else non-zero. */
|
||||
int
|
||||
history_set_pos (pos)
|
||||
int pos;
|
||||
{
|
||||
if (pos > history_length || pos < 0 || !the_history)
|
||||
return (0);
|
||||
history_offset = pos;
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Return the current history array. The caller has to be carefull, since this
|
||||
is the actual array of data, and could be bashed or made corrupt easily.
|
||||
The array is terminated with a NULL pointer. */
|
||||
HIST_ENTRY **
|
||||
history_list ()
|
||||
{
|
||||
return (the_history);
|
||||
}
|
||||
|
||||
/* Return the history entry at the current position, as determined by
|
||||
history_offset. If there is no entry there, return a NULL pointer. */
|
||||
HIST_ENTRY *
|
||||
current_history ()
|
||||
{
|
||||
return ((history_offset == history_length) || the_history == 0)
|
||||
? (HIST_ENTRY *)NULL
|
||||
: the_history[history_offset];
|
||||
}
|
||||
|
||||
/* Back up history_offset to the previous history entry, and return
|
||||
a pointer to that entry. If there is no previous entry then return
|
||||
a NULL pointer. */
|
||||
HIST_ENTRY *
|
||||
previous_history ()
|
||||
{
|
||||
return history_offset ? the_history[--history_offset] : (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
/* Move history_offset forward to the next history entry, and return
|
||||
a pointer to that entry. If there is no next entry then return a
|
||||
NULL pointer. */
|
||||
HIST_ENTRY *
|
||||
next_history ()
|
||||
{
|
||||
return (history_offset == history_length) ? (HIST_ENTRY *)NULL : the_history[++history_offset];
|
||||
}
|
||||
|
||||
/* Return the history entry which is logically at OFFSET in the history array.
|
||||
OFFSET is relative to history_base. */
|
||||
HIST_ENTRY *
|
||||
history_get (offset)
|
||||
int offset;
|
||||
{
|
||||
int local_index;
|
||||
|
||||
local_index = offset - history_base;
|
||||
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
|
||||
add_history (string)
|
||||
const char *string;
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
|
||||
if (history_stifled && (history_length == history_max_entries))
|
||||
{
|
||||
register int i;
|
||||
|
||||
/* If the history is stifled, and history_length is zero,
|
||||
and it equals history_max_entries, we don't save items. */
|
||||
if (history_length == 0)
|
||||
return;
|
||||
|
||||
/* If there is something in the slot, then remove it. */
|
||||
if (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++)
|
||||
the_history[i] = the_history[i + 1];
|
||||
|
||||
history_base++;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (history_size == 0)
|
||||
{
|
||||
history_size = DEFAULT_HISTORY_GROW_SIZE;
|
||||
the_history = (HIST_ENTRY **)xmalloc (history_size * sizeof (HIST_ENTRY *));
|
||||
history_length = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (history_length == (history_size - 1))
|
||||
{
|
||||
history_size += DEFAULT_HISTORY_GROW_SIZE;
|
||||
the_history = (HIST_ENTRY **)
|
||||
xrealloc (the_history, history_size * sizeof (HIST_ENTRY *));
|
||||
}
|
||||
history_length++;
|
||||
}
|
||||
}
|
||||
|
||||
temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
|
||||
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. */
|
||||
HIST_ENTRY *
|
||||
replace_history_entry (which, line, data)
|
||||
int which;
|
||||
const char *line;
|
||||
histdata_t data;
|
||||
{
|
||||
HIST_ENTRY *temp, *old_value;
|
||||
|
||||
if (which < 0 || which >= history_length)
|
||||
return ((HIST_ENTRY *)NULL);
|
||||
|
||||
temp = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
|
||||
old_value = the_history[which];
|
||||
|
||||
temp->line = savestring (line);
|
||||
temp->data = data;
|
||||
temp->timestamp = savestring (old_value->timestamp);
|
||||
the_history[which] = temp;
|
||||
|
||||
return (old_value);
|
||||
}
|
||||
|
||||
/* Remove history element WHICH from the history. The removed
|
||||
element is returned to you so you can free the line, data,
|
||||
and containing structure. */
|
||||
HIST_ENTRY *
|
||||
remove_history (which)
|
||||
int which;
|
||||
{
|
||||
HIST_ENTRY *return_value;
|
||||
register int i;
|
||||
|
||||
if (which < 0 || which >= history_length || history_length == 0 || the_history == 0)
|
||||
return ((HIST_ENTRY *)NULL);
|
||||
|
||||
return_value = the_history[which];
|
||||
|
||||
for (i = which; i < history_length; i++)
|
||||
the_history[i] = the_history[i + 1];
|
||||
|
||||
history_length--;
|
||||
|
||||
return (return_value);
|
||||
}
|
||||
|
||||
/* Stifle the history list, remembering only MAX number of lines. */
|
||||
void
|
||||
stifle_history (max)
|
||||
int max;
|
||||
{
|
||||
register int i, j;
|
||||
|
||||
if (max < 0)
|
||||
max = 0;
|
||||
|
||||
if (history_length > max)
|
||||
{
|
||||
/* This loses because we cannot free the data. */
|
||||
for (i = 0, j = history_length - max; i < j; i++)
|
||||
free_history_entry (the_history[i]);
|
||||
|
||||
history_base = i;
|
||||
for (j = 0, i = history_length - max; j < max; i++, j++)
|
||||
the_history[j] = the_history[i];
|
||||
the_history[j] = (HIST_ENTRY *)NULL;
|
||||
history_length = j;
|
||||
}
|
||||
|
||||
history_stifled = 1;
|
||||
max_input_history = history_max_entries = max;
|
||||
}
|
||||
|
||||
/* Stop stifling the history. This returns the previous maximum
|
||||
number of history entries. The value is positive if the history
|
||||
was stifled, negative if it wasn't. */
|
||||
int
|
||||
unstifle_history ()
|
||||
{
|
||||
if (history_stifled)
|
||||
{
|
||||
history_stifled = 0;
|
||||
return (history_max_entries);
|
||||
}
|
||||
else
|
||||
return (-history_max_entries);
|
||||
}
|
||||
|
||||
int
|
||||
history_is_stifled ()
|
||||
{
|
||||
return (history_stifled);
|
||||
}
|
||||
|
||||
void
|
||||
clear_history ()
|
||||
{
|
||||
register int i;
|
||||
|
||||
/* This loses because we cannot free the data. */
|
||||
for (i = 0; i < history_length; i++)
|
||||
{
|
||||
free_history_entry (the_history[i]);
|
||||
the_history[i] = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
history_offset = history_length = 0;
|
||||
}
|
266
extern/editline/history.h
vendored
266
extern/editline/history.h
vendored
@ -1,266 +0,0 @@
|
||||
/* 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.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#ifndef _HISTORY_H_
|
||||
#define _HISTORY_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <time.h> /* XXX - for history timestamp code */
|
||||
|
||||
#if defined READLINE_LIBRARY
|
||||
# include "rlstdc.h"
|
||||
# include "rltypedefs.h"
|
||||
#else
|
||||
# include <readline/rlstdc.h>
|
||||
# include <readline/rltypedefs.h>
|
||||
#endif
|
||||
|
||||
#ifdef __STDC__
|
||||
typedef void *histdata_t;
|
||||
#else
|
||||
typedef char *histdata_t;
|
||||
#endif
|
||||
|
||||
/* 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. */
|
||||
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;
|
||||
|
||||
/* Flag values for the `flags' member of HISTORY_STATE. */
|
||||
#define HS_STIFLED 0x01
|
||||
|
||||
/* Initialization and state management. */
|
||||
|
||||
/* Begin a session in which the history functions might be used. This
|
||||
just initializes the interactive variables. */
|
||||
extern void using_history PARAMS((void));
|
||||
|
||||
/* Return the current HISTORY_STATE of the history. */
|
||||
extern HISTORY_STATE *history_get_history_state PARAMS((void));
|
||||
|
||||
/* Set the state of the current history array to STATE. */
|
||||
extern void history_set_history_state PARAMS((HISTORY_STATE *));
|
||||
|
||||
/* Manage the history list. */
|
||||
|
||||
/* Place STRING at the end of the history list.
|
||||
The associated data field (if any) is set to NULL. */
|
||||
extern void add_history 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. */
|
||||
extern HIST_ENTRY *replace_history_entry PARAMS((int, const char *, histdata_t));
|
||||
|
||||
/* Clear the history list and start over. */
|
||||
extern void clear_history PARAMS((void));
|
||||
|
||||
/* Stifle the history list, remembering only MAX number of entries. */
|
||||
extern void stifle_history PARAMS((int));
|
||||
|
||||
/* Stop stifling the history. This returns the previous amount the
|
||||
history was stifled by. The value is positive if the history was
|
||||
stifled, negative if it wasn't. */
|
||||
extern int unstifle_history PARAMS((void));
|
||||
|
||||
/* Return 1 if the history is stifled, 0 if it is not. */
|
||||
extern int history_is_stifled PARAMS((void));
|
||||
|
||||
/* Information about the history list. */
|
||||
|
||||
/* Return a NULL terminated array of HIST_ENTRY which is the current input
|
||||
history. Element 0 of this list is the beginning of time. If there
|
||||
is no history, return NULL. */
|
||||
extern HIST_ENTRY **history_list PARAMS((void));
|
||||
|
||||
/* Returns the number which says what history element we are now
|
||||
looking at. */
|
||||
extern int where_history PARAMS((void));
|
||||
|
||||
/* Return the history entry at the current position, as determined by
|
||||
history_offset. If there is no entry there, return a NULL pointer. */
|
||||
extern HIST_ENTRY *current_history PARAMS((void));
|
||||
|
||||
/* Return the history entry which is logically at OFFSET in the history
|
||||
array. OFFSET is relative to history_base. */
|
||||
extern HIST_ENTRY *history_get 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));
|
||||
|
||||
/* Moving around the history list. */
|
||||
|
||||
/* Set the position in the history list to POS. */
|
||||
extern int history_set_pos PARAMS((int));
|
||||
|
||||
/* Back up history_offset to the previous history entry, and return
|
||||
a pointer to that entry. If there is no previous entry, return
|
||||
a NULL pointer. */
|
||||
extern HIST_ENTRY *previous_history PARAMS((void));
|
||||
|
||||
/* Move history_offset forward to the next item in the input_history,
|
||||
and return the a pointer to that entry. If there is no next entry,
|
||||
return a NULL pointer. */
|
||||
extern HIST_ENTRY *next_history PARAMS((void));
|
||||
|
||||
/* Searching the history list. */
|
||||
|
||||
/* Search the history for STRING, starting at history_offset.
|
||||
If DIRECTION < 0, then the search is through previous entries,
|
||||
else through subsequent. If the string is found, then
|
||||
current_history () is the history entry, and the value of this function
|
||||
is the offset in the line of that history entry that the string was
|
||||
found in. Otherwise, nothing is changed, and a -1 is returned. */
|
||||
extern int history_search PARAMS((const char *, int));
|
||||
|
||||
/* Search the history for STRING, starting at history_offset.
|
||||
The search is anchored: matching lines must begin with string.
|
||||
DIRECTION is as in history_search(). */
|
||||
extern int history_search_prefix PARAMS((const char *, int));
|
||||
|
||||
/* Search for STRING in the history list, starting at POS, an
|
||||
absolute index into the list. DIR, if negative, says to search
|
||||
backwards from POS, else forwards.
|
||||
Returns the absolute index of the history element where STRING
|
||||
was found, or -1 otherwise. */
|
||||
extern int history_search_pos PARAMS((const char *, int, int));
|
||||
|
||||
/* Managing the history file. */
|
||||
|
||||
/* Add the contents of FILENAME to the history list, a line at a time.
|
||||
If FILENAME is NULL, then read from ~/.history. Returns 0 if
|
||||
successful, or errno if not. */
|
||||
extern int read_history PARAMS((const char *));
|
||||
|
||||
/* Read a range of lines from FILENAME, adding them to the history list.
|
||||
Start reading at the FROM'th line and end at the TO'th. If FROM
|
||||
is zero, start at the beginning. If TO is less than FROM, read
|
||||
until the end of the file. If FILENAME is NULL, then read from
|
||||
~/.history. Returns 0 if successful, or errno if not. */
|
||||
extern int read_history_range PARAMS((const char *, int, int));
|
||||
|
||||
/* Write the current history to FILENAME. If FILENAME is NULL,
|
||||
then write the history list to ~/.history. Values returned
|
||||
are as in read_history (). */
|
||||
extern int write_history PARAMS((const char *));
|
||||
|
||||
/* Append NELEMENT entries to FILENAME. The entries appended are from
|
||||
the end of the list minus NELEMENTs up to the end of the list. */
|
||||
extern int append_history PARAMS((int, const char *));
|
||||
|
||||
/* Truncate the history file, leaving only the last NLINES lines. */
|
||||
extern int history_truncate_file PARAMS((const char *, int));
|
||||
|
||||
/* History expansion. */
|
||||
|
||||
/* Expand the string STRING, placing the result into OUTPUT, a pointer
|
||||
to a string. Returns:
|
||||
|
||||
0) If no expansions took place (or, if the only change in
|
||||
the text was the de-slashifying of the history expansion
|
||||
character)
|
||||
1) If expansions did take place
|
||||
-1) If there was an error in expansion.
|
||||
2) If the returned line should just be printed.
|
||||
|
||||
If an error ocurred in expansion, then OUTPUT contains a descriptive
|
||||
error message. */
|
||||
extern int history_expand PARAMS((char *, char **));
|
||||
|
||||
/* Extract a string segment consisting of the FIRST through LAST
|
||||
arguments present in STRING. Arguments are broken up as in
|
||||
the shell. */
|
||||
extern char *history_arg_extract PARAMS((int, int, const char *));
|
||||
|
||||
/* Return the text of the history event beginning at the current
|
||||
offset into STRING. Pass STRING with *INDEX equal to the
|
||||
history_expansion_char that begins this specification.
|
||||
DELIMITING_QUOTE is a character that is allowed to end the string
|
||||
specification for what to search for in addition to the normal
|
||||
characters `:', ` ', `\t', `\n', and sometimes `?'. */
|
||||
extern char *get_history_event PARAMS((const char *, int *, int));
|
||||
|
||||
/* Return an array of tokens, much as the shell might. The tokens are
|
||||
parsed out of STRING. */
|
||||
extern char **history_tokenize PARAMS((const char *));
|
||||
|
||||
/* Exported history variables. */
|
||||
extern int history_base;
|
||||
extern int history_length;
|
||||
extern int history_max_entries;
|
||||
extern char history_expansion_char;
|
||||
extern char history_subst_char;
|
||||
extern char *history_word_delimiters;
|
||||
extern char history_comment_char;
|
||||
extern char *history_no_expand_chars;
|
||||
extern char *history_search_delimiter_chars;
|
||||
extern int history_quotes_inhibit_expansion;
|
||||
|
||||
extern int history_write_timestamps;
|
||||
|
||||
/* Backwards compatibility */
|
||||
extern int max_input_history;
|
||||
|
||||
/* If set, this function is called to decide whether or not a particular
|
||||
history expansion should be treated as a special case for the calling
|
||||
application and not expanded. */
|
||||
extern rl_linebuf_func_t *history_inhibit_expansion_function;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* !_HISTORY_H_ */
|
195
extern/editline/histsearch.c
vendored
195
extern/editline/histsearch.c
vendored
@ -1,195 +0,0 @@
|
||||
/* histsearch.c -- searching the history list. */
|
||||
|
||||
/* Copyright (C) 1989, 1992 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.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# ifdef _MINIX
|
||||
# include <sys/types.h>
|
||||
# endif
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "history.h"
|
||||
#include "histlib.h"
|
||||
|
||||
/* The list of alternate characters that can delimit a history search
|
||||
string. */
|
||||
char *history_search_delimiter_chars = (char *)NULL;
|
||||
|
||||
static int history_search_internal PARAMS((const char *, int, int));
|
||||
|
||||
/* Search the history for STRING, starting at history_offset.
|
||||
If DIRECTION < 0, then the search is through previous entries, else
|
||||
through subsequent. If ANCHORED is non-zero, the string must
|
||||
appear at the beginning of a history line, otherwise, the string
|
||||
may appear anywhere in the line. If the string is found, then
|
||||
current_history () is the history entry, and the value of this
|
||||
function is the offset in the line of that history entry that the
|
||||
string was found in. Otherwise, nothing is changed, and a -1 is
|
||||
returned. */
|
||||
|
||||
static int
|
||||
history_search_internal (string, direction, anchored)
|
||||
const char *string;
|
||||
int direction, anchored;
|
||||
{
|
||||
register int i, reverse;
|
||||
register char *line;
|
||||
register int line_index;
|
||||
int string_len;
|
||||
HIST_ENTRY **the_history; /* local */
|
||||
|
||||
i = history_offset;
|
||||
reverse = (direction < 0);
|
||||
|
||||
/* Take care of trivial cases first. */
|
||||
if (string == 0 || *string == '\0')
|
||||
return (-1);
|
||||
|
||||
if (!history_length || ((i >= history_length) && !reverse))
|
||||
return (-1);
|
||||
|
||||
if (reverse && (i >= history_length))
|
||||
i = history_length - 1;
|
||||
|
||||
#define NEXT_LINE() do { if (reverse) i--; else i++; } while (0)
|
||||
|
||||
the_history = history_list ();
|
||||
string_len = strlen (string);
|
||||
while (1)
|
||||
{
|
||||
/* Search each line in the history list for STRING. */
|
||||
|
||||
/* At limit for direction? */
|
||||
if ((reverse && i < 0) || (!reverse && i == history_length))
|
||||
return (-1);
|
||||
|
||||
line = the_history[i]->line;
|
||||
line_index = strlen (line);
|
||||
|
||||
/* If STRING is longer than line, no match. */
|
||||
if (string_len > line_index)
|
||||
{
|
||||
NEXT_LINE ();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Handle anchored searches first. */
|
||||
if (anchored == ANCHORED_SEARCH)
|
||||
{
|
||||
if (STREQN (string, line, string_len))
|
||||
{
|
||||
history_offset = i;
|
||||
return (0);
|
||||
}
|
||||
|
||||
NEXT_LINE ();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Do substring search. */
|
||||
if (reverse)
|
||||
{
|
||||
line_index -= string_len;
|
||||
|
||||
while (line_index >= 0)
|
||||
{
|
||||
if (STREQN (string, line + line_index, string_len))
|
||||
{
|
||||
history_offset = i;
|
||||
return (line_index);
|
||||
}
|
||||
line_index--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
register int limit;
|
||||
|
||||
limit = line_index - string_len + 1;
|
||||
line_index = 0;
|
||||
|
||||
while (line_index < limit)
|
||||
{
|
||||
if (STREQN (string, line + line_index, string_len))
|
||||
{
|
||||
history_offset = i;
|
||||
return (line_index);
|
||||
}
|
||||
line_index++;
|
||||
}
|
||||
}
|
||||
NEXT_LINE ();
|
||||
}
|
||||
}
|
||||
|
||||
/* Do a non-anchored search for STRING through the history in DIRECTION. */
|
||||
int
|
||||
history_search (string, direction)
|
||||
const char *string;
|
||||
int direction;
|
||||
{
|
||||
return (history_search_internal (string, direction, NON_ANCHORED_SEARCH));
|
||||
}
|
||||
|
||||
/* Do an anchored search for string through the history in DIRECTION. */
|
||||
int
|
||||
history_search_prefix (string, direction)
|
||||
const char *string;
|
||||
int direction;
|
||||
{
|
||||
return (history_search_internal (string, direction, ANCHORED_SEARCH));
|
||||
}
|
||||
|
||||
/* Search for STRING in the history list. DIR is < 0 for searching
|
||||
backwards. POS is an absolute index into the history list at
|
||||
which point to begin searching. */
|
||||
int
|
||||
history_search_pos (string, dir, pos)
|
||||
const char *string;
|
||||
int dir, pos;
|
||||
{
|
||||
int ret, old;
|
||||
|
||||
old = where_history ();
|
||||
history_set_pos (pos);
|
||||
if (history_search (string, dir) == -1)
|
||||
{
|
||||
history_set_pos (old);
|
||||
return (-1);
|
||||
}
|
||||
ret = where_history ();
|
||||
history_set_pos (old);
|
||||
return ret;
|
||||
}
|
570
extern/editline/input.c
vendored
570
extern/editline/input.c
vendored
@ -1,570 +0,0 @@
|
||||
/* input.c -- character input functions for readline. */
|
||||
|
||||
/* 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.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (__TANDEM)
|
||||
# include <floss.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#if defined (HAVE_SYS_FILE_H)
|
||||
# include <sys/file.h>
|
||||
#endif /* HAVE_SYS_FILE_H */
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
# if !defined (HAVE_SYS_SELECT_H) || !defined (M_UNIX)
|
||||
# include <sys/time.h>
|
||||
# endif
|
||||
#endif /* HAVE_SELECT */
|
||||
#if defined (HAVE_SYS_SELECT_H)
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if defined (FIONREAD_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if !defined (errno)
|
||||
extern int errno;
|
||||
#endif /* !errno */
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* What kind of non-blocking I/O do we have? */
|
||||
#if !defined (O_NDELAY) && defined (O_NONBLOCK)
|
||||
# define O_NDELAY O_NONBLOCK /* Posix style */
|
||||
#endif
|
||||
|
||||
/* Non-null means it is a pointer to a function to run while waiting for
|
||||
character input. */
|
||||
rl_hook_func_t *rl_event_hook = (rl_hook_func_t *)NULL;
|
||||
|
||||
rl_getc_func_t *rl_getc_function = rl_getc;
|
||||
|
||||
static int _keyboard_input_timeout = 100000; /* 0.1 seconds; it's in usec */
|
||||
|
||||
static int ibuffer_space PARAMS((void));
|
||||
static int rl_get_char PARAMS((int *));
|
||||
static int rl_gather_tyi PARAMS((void));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Character Input Buffering */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
static int pop_index, push_index;
|
||||
static unsigned char ibuffer[512];
|
||||
static int ibuffer_len = sizeof (ibuffer) - 1;
|
||||
|
||||
#define any_typein (push_index != pop_index)
|
||||
|
||||
int
|
||||
_rl_any_typein ()
|
||||
{
|
||||
return any_typein;
|
||||
}
|
||||
|
||||
/* Return the amount of space available in the buffer for stuffing
|
||||
characters. */
|
||||
static int
|
||||
ibuffer_space ()
|
||||
{
|
||||
if (pop_index > push_index)
|
||||
return (pop_index - push_index - 1);
|
||||
else
|
||||
return (ibuffer_len - (push_index - pop_index));
|
||||
}
|
||||
|
||||
/* Get a key from the buffer of characters to be read.
|
||||
Return the key in KEY.
|
||||
Result is KEY if there was a key, or 0 if there wasn't. */
|
||||
static int
|
||||
rl_get_char (key)
|
||||
int *key;
|
||||
{
|
||||
if (push_index == pop_index)
|
||||
return (0);
|
||||
|
||||
*key = ibuffer[pop_index++];
|
||||
|
||||
if (pop_index >= ibuffer_len)
|
||||
pop_index = 0;
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Stuff KEY into the *front* of the input buffer.
|
||||
Returns non-zero if successful, zero if there is
|
||||
no space left in the buffer. */
|
||||
int
|
||||
_rl_unget_char (key)
|
||||
int key;
|
||||
{
|
||||
if (ibuffer_space ())
|
||||
{
|
||||
pop_index--;
|
||||
if (pop_index < 0)
|
||||
pop_index = ibuffer_len - 1;
|
||||
ibuffer[pop_index] = key;
|
||||
return (1);
|
||||
}
|
||||
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). */
|
||||
static int
|
||||
rl_gather_tyi ()
|
||||
{
|
||||
int tty;
|
||||
register int tem, result;
|
||||
int chars_avail, k;
|
||||
char input;
|
||||
#if defined(HAVE_SELECT)
|
||||
fd_set readfds, exceptfds;
|
||||
struct timeval timeout;
|
||||
#endif
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
FD_ZERO (&readfds);
|
||||
FD_ZERO (&exceptfds);
|
||||
FD_SET (tty, &readfds);
|
||||
FD_SET (tty, &exceptfds);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = _keyboard_input_timeout;
|
||||
result = select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout);
|
||||
if (result <= 0)
|
||||
return 0; /* Nothing to read. */
|
||||
#endif
|
||||
|
||||
result = -1;
|
||||
#if defined (FIONREAD)
|
||||
errno = 0;
|
||||
result = ioctl (tty, FIONREAD, &chars_avail);
|
||||
if (result == -1 && errno == EIO)
|
||||
return -1;
|
||||
#endif
|
||||
|
||||
#if defined (O_NDELAY)
|
||||
if (result == -1)
|
||||
{
|
||||
tem = fcntl (tty, F_GETFL, 0);
|
||||
|
||||
fcntl (tty, F_SETFL, (tem | O_NDELAY));
|
||||
chars_avail = read (tty, &input, 1);
|
||||
|
||||
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 */
|
||||
|
||||
/* If there's nothing available, don't waste time trying to read
|
||||
something. */
|
||||
if (chars_avail <= 0)
|
||||
return 0;
|
||||
|
||||
tem = ibuffer_space ();
|
||||
|
||||
if (chars_avail > tem)
|
||||
chars_avail = tem;
|
||||
|
||||
/* One cannot read all of the available input. I can only read a single
|
||||
character at a time, or else programs which require input can be
|
||||
thwarted. If the buffer is larger than one character, I lose.
|
||||
Damn! */
|
||||
if (tem < ibuffer_len)
|
||||
chars_avail = 0;
|
||||
|
||||
if (result != -1)
|
||||
{
|
||||
while (chars_avail--)
|
||||
{
|
||||
k = (*rl_getc_function) (rl_instream);
|
||||
rl_stuff_char (k);
|
||||
if (k == NEWLINE || k == RETURN)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (chars_avail)
|
||||
rl_stuff_char (input);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
rl_set_keyboard_input_timeout (u)
|
||||
int u;
|
||||
{
|
||||
int o;
|
||||
|
||||
o = _keyboard_input_timeout;
|
||||
if (u > 0)
|
||||
_keyboard_input_timeout = u;
|
||||
return (o);
|
||||
}
|
||||
|
||||
/* Is there input available to be read on the readline input file
|
||||
descriptor? Only works if the system has select(2) or FIONREAD.
|
||||
Uses the value of _keyboard_input_timeout as the timeout; if another
|
||||
readline function wants to specify a timeout and not leave it up to
|
||||
the user, it should use _rl_input_queued(timeout_value_in_microseconds)
|
||||
instead. */
|
||||
int
|
||||
_rl_input_available ()
|
||||
{
|
||||
#if defined(HAVE_SELECT)
|
||||
fd_set readfds, exceptfds;
|
||||
struct timeval timeout;
|
||||
#endif
|
||||
#if !defined (HAVE_SELECT) && defined(FIONREAD)
|
||||
int chars_avail;
|
||||
#endif
|
||||
int tty;
|
||||
|
||||
tty = fileno (rl_instream);
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
FD_ZERO (&readfds);
|
||||
FD_ZERO (&exceptfds);
|
||||
FD_SET (tty, &readfds);
|
||||
FD_SET (tty, &exceptfds);
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = _keyboard_input_timeout;
|
||||
return (select (tty + 1, &readfds, (fd_set *)NULL, &exceptfds, &timeout) > 0);
|
||||
#else
|
||||
|
||||
#if defined (FIONREAD)
|
||||
if (ioctl (tty, FIONREAD, &chars_avail) == 0)
|
||||
return (chars_avail);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_input_queued (t)
|
||||
int t;
|
||||
{
|
||||
int old_timeout, r;
|
||||
|
||||
old_timeout = rl_set_keyboard_input_timeout (t);
|
||||
r = _rl_input_available ();
|
||||
rl_set_keyboard_input_timeout (old_timeout);
|
||||
return r;
|
||||
}
|
||||
|
||||
void
|
||||
_rl_insert_typein (c)
|
||||
int c;
|
||||
{
|
||||
int key, t, i;
|
||||
char *string;
|
||||
|
||||
i = key = 0;
|
||||
string = (char *)xmalloc (ibuffer_len + 1);
|
||||
string[i++] = (char) c;
|
||||
|
||||
while ((t = rl_get_char (&key)) &&
|
||||
_rl_keymap[key].type == ISFUNC &&
|
||||
_rl_keymap[key].function == rl_insert)
|
||||
string[i++] = key;
|
||||
|
||||
if (t)
|
||||
_rl_unget_char (key);
|
||||
|
||||
string[i] = '\0';
|
||||
rl_insert_text (string);
|
||||
free (string);
|
||||
}
|
||||
|
||||
/* Add KEY to the buffer of characters to be read. Returns 1 if the
|
||||
character was stuffed correctly; 0 otherwise. */
|
||||
int
|
||||
rl_stuff_char (key)
|
||||
int key;
|
||||
{
|
||||
if (ibuffer_space () == 0)
|
||||
return 0;
|
||||
|
||||
if (key == EOF)
|
||||
{
|
||||
key = NEWLINE;
|
||||
rl_pending_input = EOF;
|
||||
RL_SETSTATE (RL_STATE_INPUTPENDING);
|
||||
}
|
||||
ibuffer[push_index++] = key;
|
||||
if (push_index >= ibuffer_len)
|
||||
push_index = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Make C be the next command to be executed. */
|
||||
int
|
||||
rl_execute_next (c)
|
||||
int c;
|
||||
{
|
||||
rl_pending_input = c;
|
||||
RL_SETSTATE (RL_STATE_INPUTPENDING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Clear any pending input pushed with rl_execute_next() */
|
||||
int
|
||||
rl_clear_pending_input ()
|
||||
{
|
||||
rl_pending_input = 0;
|
||||
RL_UNSETSTATE (RL_STATE_INPUTPENDING);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Character Input */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Read a key, including pending input. */
|
||||
int
|
||||
rl_read_key ()
|
||||
{
|
||||
int c;
|
||||
|
||||
rl_key_sequence_length++;
|
||||
|
||||
if (rl_pending_input)
|
||||
{
|
||||
c = rl_pending_input;
|
||||
rl_clear_pending_input ();
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If input is coming from a macro, then use that. */
|
||||
if (c = _rl_next_macro_key ())
|
||||
return (c);
|
||||
|
||||
/* If the user has an event function, then call it periodically. */
|
||||
if (rl_event_hook)
|
||||
{
|
||||
while (rl_event_hook && rl_get_char (&c) == 0)
|
||||
{
|
||||
(*rl_event_hook) ();
|
||||
if (rl_done) /* XXX - experimental */
|
||||
return ('\n');
|
||||
if (rl_gather_tyi () < 0) /* XXX - EIO */
|
||||
{
|
||||
rl_done = 1;
|
||||
return ('\n');
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rl_get_char (&c) == 0)
|
||||
c = (*rl_getc_function) (rl_instream);
|
||||
}
|
||||
}
|
||||
|
||||
return (c);
|
||||
}
|
||||
|
||||
int
|
||||
rl_getc (stream)
|
||||
FILE *stream;
|
||||
{
|
||||
int result;
|
||||
unsigned char c;
|
||||
|
||||
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))
|
||||
return (c);
|
||||
|
||||
/* If zero characters are returned, then the file that we are
|
||||
reading from is empty! Return EOF in that case. */
|
||||
if (result == 0)
|
||||
return (EOF);
|
||||
|
||||
#if defined (__BEOS__)
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
#endif
|
||||
|
||||
#if defined (EWOULDBLOCK)
|
||||
# define X_EWOULDBLOCK EWOULDBLOCK
|
||||
#else
|
||||
# define X_EWOULDBLOCK -99
|
||||
#endif
|
||||
|
||||
#if defined (EAGAIN)
|
||||
# define X_EAGAIN EAGAIN
|
||||
#else
|
||||
# define X_EAGAIN -99
|
||||
#endif
|
||||
|
||||
if (errno == X_EWOULDBLOCK || errno == X_EAGAIN)
|
||||
{
|
||||
if (sh_unset_nodelay_mode (fileno (stream)) < 0)
|
||||
return (EOF);
|
||||
continue;
|
||||
}
|
||||
|
||||
#undef X_EWOULDBLOCK
|
||||
#undef X_EAGAIN
|
||||
|
||||
/* If the error that we received was SIGINT, then try again,
|
||||
this is simply an interrupted system call to read ().
|
||||
Otherwise, some error ocurred, also signifying EOF. */
|
||||
if (errno != EINTR)
|
||||
return (EOF);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
/* read multibyte char */
|
||||
int
|
||||
_rl_read_mbchar (mbchar, size)
|
||||
char *mbchar;
|
||||
int size;
|
||||
{
|
||||
int mb_len = 0;
|
||||
size_t mbchar_bytes_length;
|
||||
wchar_t wc;
|
||||
mbstate_t ps, ps_back;
|
||||
|
||||
memset(&ps, 0, sizeof (mbstate_t));
|
||||
memset(&ps_back, 0, sizeof (mbstate_t));
|
||||
|
||||
while (mb_len < size)
|
||||
{
|
||||
RL_SETSTATE(RL_STATE_MOREINPUT);
|
||||
mbchar[mb_len++] = rl_read_key ();
|
||||
RL_UNSETSTATE(RL_STATE_MOREINPUT);
|
||||
|
||||
mbchar_bytes_length = mbrtowc (&wc, mbchar, mb_len, &ps);
|
||||
if (mbchar_bytes_length == (size_t)(-1))
|
||||
break; /* invalid byte sequence for the current locale */
|
||||
else if (mbchar_bytes_length == (size_t)(-2))
|
||||
{
|
||||
/* shorted bytes */
|
||||
ps = ps_back;
|
||||
continue;
|
||||
}
|
||||
else if (mbchar_bytes_length == 0)
|
||||
{
|
||||
mbchar[0] = '\0'; /* null wide character */
|
||||
mb_len = 1;
|
||||
break;
|
||||
}
|
||||
else if (mbchar_bytes_length > (size_t)(0))
|
||||
break;
|
||||
}
|
||||
|
||||
return mb_len;
|
||||
}
|
||||
|
||||
/* Read a multibyte-character string whose first character is FIRST into
|
||||
the buffer MB of length MBLEN. Returns the last character read, which
|
||||
may be FIRST. Used by the search functions, among others. Very similar
|
||||
to _rl_read_mbchar. */
|
||||
int
|
||||
_rl_read_mbstring (first, mb, mblen)
|
||||
int first;
|
||||
char *mb;
|
||||
int mblen;
|
||||
{
|
||||
int i, c;
|
||||
mbstate_t ps;
|
||||
|
||||
c = first;
|
||||
memset (mb, 0, mblen);
|
||||
for (i = 0; i < mblen; i++)
|
||||
{
|
||||
mb[i] = (char)c;
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
if (_rl_get_char_len (mb, &ps) == -2)
|
||||
{
|
||||
/* Read more for multibyte character */
|
||||
RL_SETSTATE (RL_STATE_MOREINPUT);
|
||||
c = rl_read_key ();
|
||||
RL_UNSETSTATE (RL_STATE_MOREINPUT);
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
return c;
|
||||
}
|
||||
#endif /* HANDLE_MULTIBYTE */
|
323
extern/editline/install-sh
vendored
Normal file
323
extern/editline/install-sh
vendored
Normal file
@ -0,0 +1,323 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2004-10-22.00
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
# following copyright and license.
|
||||
#
|
||||
# Copyright (C) 1994 X Consortium
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to
|
||||
# deal in the Software without restriction, including without limitation the
|
||||
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
# sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in
|
||||
# all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
|
||||
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
#
|
||||
# Except as contained in this notice, the name of the X Consortium shall not
|
||||
# be used in advertising or otherwise to promote the sale, use or other deal-
|
||||
# ings in this Software without prior written authorization from the X Consor-
|
||||
# tium.
|
||||
#
|
||||
#
|
||||
# FSF changes to this file are in the public domain.
|
||||
#
|
||||
# Calling this script install-sh is preferred over install.sh, to prevent
|
||||
# `make' implicit rules from creating a file called install from it
|
||||
# when there is no Makefile.
|
||||
#
|
||||
# This script is compatible with the BSD install script, but was written
|
||||
# from scratch. It can only install one file at a time, a restriction
|
||||
# shared with many OS's install programs.
|
||||
|
||||
# set DOITPROG to echo to test this script
|
||||
|
||||
# Don't use :- since 4.3BSD and earlier shells don't like it.
|
||||
doit="${DOITPROG-}"
|
||||
|
||||
# put in absolute paths if you don't have them in your path; or use env. vars.
|
||||
|
||||
mvprog="${MVPROG-mv}"
|
||||
cpprog="${CPPROG-cp}"
|
||||
chmodprog="${CHMODPROG-chmod}"
|
||||
chownprog="${CHOWNPROG-chown}"
|
||||
chgrpprog="${CHGRPPROG-chgrp}"
|
||||
stripprog="${STRIPPROG-strip}"
|
||||
rmprog="${RMPROG-rm}"
|
||||
mkdirprog="${MKDIRPROG-mkdir}"
|
||||
|
||||
chmodcmd="$chmodprog 0755"
|
||||
chowncmd=
|
||||
chgrpcmd=
|
||||
stripcmd=
|
||||
rmcmd="$rmprog -f"
|
||||
mvcmd="$mvprog"
|
||||
src=
|
||||
dst=
|
||||
dir_arg=
|
||||
dstarg=
|
||||
no_target_directory=
|
||||
|
||||
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
|
||||
or: $0 [OPTION]... SRCFILES... DIRECTORY
|
||||
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
|
||||
or: $0 [OPTION]... -d DIRECTORIES...
|
||||
|
||||
In the 1st form, copy SRCFILE to DSTFILE.
|
||||
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
|
||||
In the 4th, create DIRECTORIES.
|
||||
|
||||
Options:
|
||||
-c (ignored)
|
||||
-d create directories instead of installing files.
|
||||
-g GROUP $chgrpprog installed files to GROUP.
|
||||
-m MODE $chmodprog installed files to MODE.
|
||||
-o USER $chownprog installed files to USER.
|
||||
-s $stripprog installed files.
|
||||
-t DIRECTORY install into DIRECTORY.
|
||||
-T report an error if DSTFILE is a directory.
|
||||
--help display this help and exit.
|
||||
--version display version info and exit.
|
||||
|
||||
Environment variables override the default commands:
|
||||
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
|
||||
"
|
||||
|
||||
while test -n "$1"; do
|
||||
case $1 in
|
||||
-c) shift
|
||||
continue;;
|
||||
|
||||
-d) dir_arg=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-g) chgrpcmd="$chgrpprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
--help) echo "$usage"; exit 0;;
|
||||
|
||||
-m) chmodcmd="$chmodprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-o) chowncmd="$chownprog $2"
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-s) stripcmd=$stripprog
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-t) dstarg=$2
|
||||
shift
|
||||
shift
|
||||
continue;;
|
||||
|
||||
-T) no_target_directory=true
|
||||
shift
|
||||
continue;;
|
||||
|
||||
--version) echo "$0 $scriptversion"; exit 0;;
|
||||
|
||||
*) # When -d is used, all remaining arguments are directories to create.
|
||||
# When -t is used, the destination is already specified.
|
||||
test -n "$dir_arg$dstarg" && break
|
||||
# Otherwise, the last argument is the destination. Remove it from $@.
|
||||
for arg
|
||||
do
|
||||
if test -n "$dstarg"; then
|
||||
# $@ is not empty: it contains at least $arg.
|
||||
set fnord "$@" "$dstarg"
|
||||
shift # fnord
|
||||
fi
|
||||
shift # arg
|
||||
dstarg=$arg
|
||||
done
|
||||
break;;
|
||||
esac
|
||||
done
|
||||
|
||||
if test -z "$1"; then
|
||||
if test -z "$dir_arg"; then
|
||||
echo "$0: no input file specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
# It's OK to call `install-sh -d' without argument.
|
||||
# This can happen when creating conditional directories.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for src
|
||||
do
|
||||
# Protect names starting with `-'.
|
||||
case $src in
|
||||
-*) src=./$src ;;
|
||||
esac
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
dst=$src
|
||||
src=
|
||||
|
||||
if test -d "$dst"; then
|
||||
mkdircmd=:
|
||||
chmodcmd=
|
||||
else
|
||||
mkdircmd=$mkdirprog
|
||||
fi
|
||||
else
|
||||
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
|
||||
# might cause directories to be created, which would be especially bad
|
||||
# if $src (and thus $dsttmp) contains '*'.
|
||||
if test ! -f "$src" && test ! -d "$src"; then
|
||||
echo "$0: $src does not exist." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test -z "$dstarg"; then
|
||||
echo "$0: no destination specified." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dst=$dstarg
|
||||
# Protect names starting with `-'.
|
||||
case $dst in
|
||||
-*) dst=./$dst ;;
|
||||
esac
|
||||
|
||||
# If destination is a directory, append the input filename; won't work
|
||||
# if double slashes aren't ignored.
|
||||
if test -d "$dst"; then
|
||||
if test -n "$no_target_directory"; then
|
||||
echo "$0: $dstarg: Is a directory" >&2
|
||||
exit 1
|
||||
fi
|
||||
dst=$dst/`basename "$src"`
|
||||
fi
|
||||
fi
|
||||
|
||||
# This sed command emulates the dirname command.
|
||||
dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
|
||||
|
||||
# Make sure that the destination directory exists.
|
||||
|
||||
# Skip lots of stat calls in the usual case.
|
||||
if test ! -d "$dstdir"; then
|
||||
defaultIFS='
|
||||
'
|
||||
IFS="${IFS-$defaultIFS}"
|
||||
|
||||
oIFS=$IFS
|
||||
# Some sh's can't handle IFS=/ for some reason.
|
||||
IFS='%'
|
||||
set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
|
||||
shift
|
||||
IFS=$oIFS
|
||||
|
||||
pathcomp=
|
||||
|
||||
while test $# -ne 0 ; do
|
||||
pathcomp=$pathcomp$1
|
||||
shift
|
||||
if test ! -d "$pathcomp"; then
|
||||
$mkdirprog "$pathcomp"
|
||||
# mkdir can fail with a `File exist' error in case several
|
||||
# install-sh are creating the directory concurrently. This
|
||||
# is OK.
|
||||
test -d "$pathcomp" || exit
|
||||
fi
|
||||
pathcomp=$pathcomp/
|
||||
done
|
||||
fi
|
||||
|
||||
if test -n "$dir_arg"; then
|
||||
$doit $mkdircmd "$dst" \
|
||||
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
|
||||
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
|
||||
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
|
||||
|
||||
else
|
||||
dstfile=`basename "$dst"`
|
||||
|
||||
# Make a couple of temp file names in the proper directory.
|
||||
dsttmp=$dstdir/_inst.$$_
|
||||
rmtmp=$dstdir/_rm.$$_
|
||||
|
||||
# Trap to clean up those temp files at exit.
|
||||
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
|
||||
trap '(exit $?); exit' 1 2 13 15
|
||||
|
||||
# Copy the file name to the temp name.
|
||||
$doit $cpprog "$src" "$dsttmp" &&
|
||||
|
||||
# and set any options; do chmod last to preserve setuid bits.
|
||||
#
|
||||
# If any of these fail, we abort the whole thing. If we want to
|
||||
# ignore errors from any of these, just make sure not to ignore
|
||||
# errors from the above "$doit $cpprog $src $dsttmp" command.
|
||||
#
|
||||
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
|
||||
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
|
||||
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
|
||||
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|
||||
|| {
|
||||
# The rename failed, perhaps because mv can't rename something else
|
||||
# to itself, or perhaps because mv is so ancient that it does not
|
||||
# support -f.
|
||||
|
||||
# Now remove or move aside any old file at destination location.
|
||||
# We try this two ways since rm can't unlink itself on some
|
||||
# systems and the destination file might be busy for other
|
||||
# reasons. In this case, the final cleanup might fail but the new
|
||||
# file should still install successfully.
|
||||
{
|
||||
if test -f "$dstdir/$dstfile"; then
|
||||
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|
||||
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|
||||
|| {
|
||||
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
|
||||
(exit 1); exit
|
||||
}
|
||||
else
|
||||
:
|
||||
fi
|
||||
} &&
|
||||
|
||||
# Now rename the file to the real destination.
|
||||
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
|
||||
}
|
||||
}
|
||||
fi || { (exit 1); exit; }
|
||||
done
|
||||
|
||||
# The final little trick to "correctly" pass the exit status to the exit trap.
|
||||
{
|
||||
(exit 0); exit
|
||||
}
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
666
extern/editline/isearch.c
vendored
666
extern/editline/isearch.c
vendored
@ -1,666 +0,0 @@
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* I-Search and Searching */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* 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
|
||||
for it.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif
|
||||
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* 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;
|
||||
|
||||
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;
|
||||
|
||||
/* Last search string and its length. */
|
||||
static char *last_isearch_string;
|
||||
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
|
||||
rl_reverse_search_history (sign, key)
|
||||
int sign, key;
|
||||
{
|
||||
return (rl_search_history (-sign, key));
|
||||
}
|
||||
|
||||
/* Search forwards through the history looking for a string which is typed
|
||||
interactively. Start with the current line. */
|
||||
int
|
||||
rl_forward_search_history (sign, key)
|
||||
int sign, key;
|
||||
{
|
||||
return (rl_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 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
|
||||
rl_display_search (search_string, reverse_p, where)
|
||||
char *search_string;
|
||||
int reverse_p, where;
|
||||
{
|
||||
char *message;
|
||||
int msglen, searchlen;
|
||||
|
||||
searchlen = (search_string && *search_string) ? strlen (search_string) : 0;
|
||||
|
||||
message = (char *)xmalloc (searchlen + 33);
|
||||
msglen = 0;
|
||||
|
||||
#if defined (NOTDEF)
|
||||
if (where != -1)
|
||||
{
|
||||
sprintf (message, "[%d]", where + history_base);
|
||||
msglen = strlen (message);
|
||||
}
|
||||
#endif /* NOTDEF */
|
||||
|
||||
message[msglen++] = '(';
|
||||
|
||||
if (reverse_p)
|
||||
{
|
||||
strcpy (message + msglen, "reverse-");
|
||||
msglen += 8;
|
||||
}
|
||||
|
||||
strcpy (message + msglen, "i-search)`");
|
||||
msglen += 10;
|
||||
|
||||
if (search_string)
|
||||
{
|
||||
strcpy (message + msglen, search_string);
|
||||
msglen += searchlen;
|
||||
}
|
||||
|
||||
strcpy (message + msglen, "': ");
|
||||
|
||||
rl_message ("%s", message);
|
||||
free (message);
|
||||
(*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
|
||||
backwards. */
|
||||
static int
|
||||
rl_search_history (direction, invoking_key)
|
||||
int direction, invoking_key;
|
||||
{
|
||||
_rl_search_cxt *cxt; /* local for now, but saved globally */
|
||||
int c, r;
|
||||
|
||||
RL_SETSTATE(RL_STATE_ISEARCH);
|
||||
cxt = _rl_isearch_init (direction);
|
||||
|
||||
rl_display_search (cxt->search_string, (cxt->sflags & SF_REVERSE), -1);
|
||||
|
||||
/* 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);
|
||||
|
||||
r = -1;
|
||||
for (;;)
|
||||
{
|
||||
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. */
|
||||
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
|
149
extern/editline/keymaps.c
vendored
149
extern/editline/keymaps.c
vendored
@ -1,149 +0,0 @@
|
||||
/* keymaps.c -- Functions and keymaps for the GNU Readline library. */
|
||||
|
||||
/* Copyright (C) 1988,1989 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Readline, a library for reading lines
|
||||
of text with interactive input and history editing.
|
||||
|
||||
Readline 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.
|
||||
|
||||
Readline 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 Readline; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <stdio.h> /* for FILE * definition for readline.h */
|
||||
|
||||
#include "readline.h"
|
||||
#include "rlconf.h"
|
||||
|
||||
#include "emacs_keymap.c"
|
||||
|
||||
#if defined (VI_MODE)
|
||||
#include "vi_keymap.c"
|
||||
#endif
|
||||
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Functions for manipulating Keymaps. */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
|
||||
/* Return a new, empty keymap.
|
||||
Free it with free() when you are done. */
|
||||
Keymap
|
||||
rl_make_bare_keymap ()
|
||||
{
|
||||
register int i;
|
||||
Keymap keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
|
||||
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
keymap[i].type = ISFUNC;
|
||||
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);
|
||||
}
|
||||
|
||||
/* Return a new keymap which is a copy of MAP. */
|
||||
Keymap
|
||||
rl_copy_keymap (map)
|
||||
Keymap map;
|
||||
{
|
||||
register int i;
|
||||
Keymap temp;
|
||||
|
||||
temp = rl_make_bare_keymap ();
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
temp[i].type = map[i].type;
|
||||
temp[i].function = map[i].function;
|
||||
}
|
||||
return (temp);
|
||||
}
|
||||
|
||||
/* Return a new keymap with the printing characters bound to rl_insert,
|
||||
the uppercase Meta characters bound to run their lowercase equivalents,
|
||||
and the Meta digits bound to produce numeric arguments. */
|
||||
Keymap
|
||||
rl_make_keymap ()
|
||||
{
|
||||
register int i;
|
||||
Keymap newmap;
|
||||
|
||||
newmap = rl_make_bare_keymap ();
|
||||
|
||||
/* All ASCII printing characters are self-inserting. */
|
||||
for (i = ' '; i < 127; i++)
|
||||
newmap[i].function = rl_insert;
|
||||
|
||||
newmap[TAB].function = rl_insert;
|
||||
newmap[RUBOUT].function = rl_rubout; /* RUBOUT == 127 */
|
||||
newmap[CTRL('H')].function = rl_rubout;
|
||||
|
||||
#if KEYMAP_SIZE > 128
|
||||
/* 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 */
|
||||
|
||||
return (newmap);
|
||||
}
|
||||
|
||||
/* Free the storage associated with MAP. */
|
||||
void
|
||||
rl_discard_keymap (map)
|
||||
Keymap map;
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!map)
|
||||
return;
|
||||
|
||||
for (i = 0; i < KEYMAP_SIZE; i++)
|
||||
{
|
||||
switch (map[i].type)
|
||||
{
|
||||
case ISFUNC:
|
||||
break;
|
||||
|
||||
case ISKMAP:
|
||||
rl_discard_keymap ((Keymap)map[i].function);
|
||||
break;
|
||||
|
||||
case ISMACR:
|
||||
free ((char *)map[i].function);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
103
extern/editline/keymaps.h
vendored
103
extern/editline/keymaps.h
vendored
@ -1,103 +0,0 @@
|
||||
/* keymaps.h -- Manipulation of readline keymaps. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#ifndef _KEYMAPS_H_
|
||||
#define _KEYMAPS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined (READLINE_LIBRARY)
|
||||
# include "rlstdc.h"
|
||||
# include "chardefs.h"
|
||||
# include "rltypedefs.h"
|
||||
#else
|
||||
# include <readline/rlstdc.h>
|
||||
# include <readline/chardefs.h>
|
||||
# include <readline/rltypedefs.h>
|
||||
#endif
|
||||
|
||||
/* A keymap contains one entry for each key in the ASCII set.
|
||||
Each entry consists of a type and a pointer.
|
||||
FUNCTION is the address of a function to run, or the
|
||||
address of a keymap to indirect through.
|
||||
TYPE says which kind of thing FUNCTION is. */
|
||||
typedef struct _keymap_entry {
|
||||
char type;
|
||||
rl_command_func_t *function;
|
||||
} KEYMAP_ENTRY;
|
||||
|
||||
/* This must be large enough to hold bindings for all of the characters
|
||||
in a desired character set (e.g, 128 for ASCII, 256 for ISO Latin-x,
|
||||
and so on) plus one for subsequence matching. */
|
||||
#define KEYMAP_SIZE 257
|
||||
#define ANYOTHERKEY KEYMAP_SIZE-1
|
||||
|
||||
/* I wanted to make the above structure contain a union of:
|
||||
union { rl_command_func_t *function; struct _keymap_entry *keymap; } value;
|
||||
but this made it impossible for me to create a static array.
|
||||
Maybe I need C lessons. */
|
||||
|
||||
typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
|
||||
typedef KEYMAP_ENTRY *Keymap;
|
||||
|
||||
/* The values that TYPE can have in a keymap entry. */
|
||||
#define ISFUNC 0
|
||||
#define ISKMAP 1
|
||||
#define ISMACR 2
|
||||
|
||||
extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap, emacs_meta_keymap, emacs_ctlx_keymap;
|
||||
extern KEYMAP_ENTRY_ARRAY vi_insertion_keymap, vi_movement_keymap;
|
||||
|
||||
/* Return a new, empty keymap.
|
||||
Free it with free() when you are done. */
|
||||
extern Keymap rl_make_bare_keymap PARAMS((void));
|
||||
|
||||
/* Return a new keymap which is a copy of MAP. */
|
||||
extern Keymap rl_copy_keymap PARAMS((Keymap));
|
||||
|
||||
/* Return a new keymap with the printing characters bound to rl_insert,
|
||||
the lowercase Meta characters bound to run their equivalents, and
|
||||
the Meta digits bound to produce numeric arguments. */
|
||||
extern Keymap rl_make_keymap PARAMS((void));
|
||||
|
||||
/* Free the storage associated with a keymap. */
|
||||
extern void rl_discard_keymap PARAMS((Keymap));
|
||||
|
||||
/* These functions actually appear in bind.c */
|
||||
|
||||
/* Return the keymap corresponding to a given name. Names look like
|
||||
`emacs' or `emacs-meta' or `vi-insert'. */
|
||||
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
|
||||
|
||||
/* Return the current keymap. */
|
||||
extern Keymap rl_get_keymap PARAMS((void));
|
||||
|
||||
/* Set the current keymap to MAP. */
|
||||
extern void rl_set_keymap PARAMS((Keymap));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _KEYMAPS_H_ */
|
693
extern/editline/kill.c
vendored
693
extern/editline/kill.c
vendored
@ -1,693 +0,0 @@
|
||||
/* kill.c -- kill ring management. */
|
||||
|
||||
/* Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h> /* for _POSIX_VERSION */
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Killing Mechanism */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* What we assume for a max number of kills. */
|
||||
#define DEFAULT_MAX_KILLS 10
|
||||
|
||||
/* The real variable to look at to find out when to flush kills. */
|
||||
static int rl_max_kills = DEFAULT_MAX_KILLS;
|
||||
|
||||
/* Where to store killed text. */
|
||||
static char **rl_kill_ring = (char **)NULL;
|
||||
|
||||
/* Where we are in the kill ring. */
|
||||
static int rl_kill_index;
|
||||
|
||||
/* How many slots we have in the kill ring. */
|
||||
static int rl_kill_ring_length;
|
||||
|
||||
static int _rl_copy_to_kill_ring PARAMS((char *, int));
|
||||
static int region_kill_internal PARAMS((int));
|
||||
static int _rl_copy_word_as_kill PARAMS((int, int));
|
||||
static int rl_yank_nth_arg_internal PARAMS((int, int, int));
|
||||
|
||||
/* How to say that you only want to save a certain amount
|
||||
of kill material. */
|
||||
int
|
||||
rl_set_retained_kills (num)
|
||||
int num;
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Add TEXT to the kill ring, allocating a new kill ring slot as necessary.
|
||||
This uses TEXT directly, so the caller must not free it. If APPEND is
|
||||
non-zero, and the last command was a kill, the text is appended to the
|
||||
current kill ring slot, otherwise prepended. */
|
||||
static int
|
||||
_rl_copy_to_kill_ring (text, append)
|
||||
char *text;
|
||||
int append;
|
||||
{
|
||||
char *old, *new;
|
||||
int slot;
|
||||
|
||||
/* First, find the slot to work with. */
|
||||
if (_rl_last_command_was_kill == 0)
|
||||
{
|
||||
/* Get a new slot. */
|
||||
if (rl_kill_ring == 0)
|
||||
{
|
||||
/* If we don't have any defined, then make one. */
|
||||
rl_kill_ring = (char **)
|
||||
xmalloc (((rl_kill_ring_length = 1) + 1) * sizeof (char *));
|
||||
rl_kill_ring[slot = 0] = (char *)NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* We have to add a new slot on the end, unless we have
|
||||
exceeded the max limit for remembering kills. */
|
||||
slot = rl_kill_ring_length;
|
||||
if (slot == rl_max_kills)
|
||||
{
|
||||
register int i;
|
||||
free (rl_kill_ring[0]);
|
||||
for (i = 0; i < slot; i++)
|
||||
rl_kill_ring[i] = rl_kill_ring[i + 1];
|
||||
}
|
||||
else
|
||||
{
|
||||
slot = rl_kill_ring_length += 1;
|
||||
rl_kill_ring = (char **)xrealloc (rl_kill_ring, slot * sizeof (char *));
|
||||
}
|
||||
rl_kill_ring[--slot] = (char *)NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
slot = rl_kill_ring_length - 1;
|
||||
|
||||
/* If the last command was a kill, prepend or append. */
|
||||
if (_rl_last_command_was_kill && rl_editing_mode != vi_mode)
|
||||
{
|
||||
old = rl_kill_ring[slot];
|
||||
new = (char *)xmalloc (1 + strlen (old) + strlen (text));
|
||||
|
||||
if (append)
|
||||
{
|
||||
strcpy (new, old);
|
||||
strcat (new, text);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy (new, text);
|
||||
strcat (new, old);
|
||||
}
|
||||
free (old);
|
||||
free (text);
|
||||
rl_kill_ring[slot] = new;
|
||||
}
|
||||
else
|
||||
rl_kill_ring[slot] = text;
|
||||
|
||||
rl_kill_index = slot;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The way to kill something. This appends or prepends to the last
|
||||
kill, if the last command was a kill command. if FROM is less
|
||||
than TO, then the text is appended, otherwise prepended. If the
|
||||
last command was not a kill command, then a new slot is made for
|
||||
this kill. */
|
||||
int
|
||||
rl_kill_text (from, to)
|
||||
int from, to;
|
||||
{
|
||||
char *text;
|
||||
|
||||
/* Is there anything to kill? */
|
||||
if (from == to)
|
||||
{
|
||||
_rl_last_command_was_kill++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
text = rl_copy_text (from, to);
|
||||
|
||||
/* Delete the copied text from the line. */
|
||||
rl_delete_text (from, to);
|
||||
|
||||
_rl_copy_to_kill_ring (text, from < to);
|
||||
|
||||
_rl_last_command_was_kill++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Now REMEMBER! In order to do prepending or appending correctly, kill
|
||||
commands always make rl_point's original position be the FROM argument,
|
||||
and rl_point's extent be the TO argument. */
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Killing Commands */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Delete the word at point, saving the text in the kill ring. */
|
||||
int
|
||||
rl_kill_word (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
if (count < 0)
|
||||
return (rl_backward_kill_word (-count, key));
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
rl_forward_word (count, key);
|
||||
|
||||
if (rl_point != orig_point)
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
|
||||
rl_point = orig_point;
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Rubout the word before point, placing it on the kill ring. */
|
||||
int
|
||||
rl_backward_kill_word (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
if (count < 0)
|
||||
return (rl_kill_word (-count, ignore));
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
rl_backward_word (count, ignore);
|
||||
|
||||
if (rl_point != orig_point)
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Kill from here to the end of the line. If DIRECTION is negative, kill
|
||||
back to the line start instead. */
|
||||
int
|
||||
rl_kill_line (direction, ignore)
|
||||
int direction, ignore;
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
if (direction < 0)
|
||||
return (rl_backward_kill_line (1, ignore));
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
rl_end_of_line (1, ignore);
|
||||
if (orig_point != rl_point)
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
rl_point = orig_point;
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Kill backwards to the start of the line. If DIRECTION is negative, kill
|
||||
forwards to the line end instead. */
|
||||
int
|
||||
rl_backward_kill_line (direction, ignore)
|
||||
int direction, ignore;
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
if (direction < 0)
|
||||
return (rl_kill_line (1, ignore));
|
||||
else
|
||||
{
|
||||
if (!rl_point)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
rl_beg_of_line (1, ignore);
|
||||
if (rl_point != orig_point)
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Kill the whole line, no matter where point is. */
|
||||
int
|
||||
rl_kill_full_line (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
rl_begin_undo_group ();
|
||||
rl_point = 0;
|
||||
rl_kill_text (rl_point, rl_end);
|
||||
rl_mark = 0;
|
||||
rl_end_undo_group ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* The next two functions mimic unix line editing behaviour, except they
|
||||
save the deleted text on the kill ring. This is safer than not saving
|
||||
it, and since we have a ring, nobody should get screwed. */
|
||||
|
||||
/* This does what C-w does in Unix. We can't prevent people from
|
||||
using behaviour that they expect. */
|
||||
int
|
||||
rl_unix_word_rubout (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int orig_point;
|
||||
|
||||
if (rl_point == 0)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
orig_point = rl_point;
|
||||
if (count <= 0)
|
||||
count = 1;
|
||||
|
||||
while (count--)
|
||||
{
|
||||
while (rl_point && whitespace (rl_line_buffer[rl_point - 1]))
|
||||
rl_point--;
|
||||
|
||||
while (rl_point && (whitespace (rl_line_buffer[rl_point - 1]) == 0))
|
||||
rl_point--;
|
||||
}
|
||||
|
||||
rl_kill_text (orig_point, rl_point);
|
||||
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;
|
||||
}
|
||||
|
||||
/* Here is C-u doing what Unix does. You don't *have* to use these
|
||||
key-bindings. We have a choice of killing the entire line, or
|
||||
killing from where we are to the start of the line. We choose the
|
||||
latter, because if you are a Unix weenie, then you haven't backspaced
|
||||
into the line at all, and if you aren't, then you know what you are
|
||||
doing. */
|
||||
int
|
||||
rl_unix_line_discard (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (rl_point == 0)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
rl_kill_text (rl_point, 0);
|
||||
rl_point = 0;
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = rl_point;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy the text in the `region' to the kill ring. If DELETE is non-zero,
|
||||
delete the text from the line as well. */
|
||||
static int
|
||||
region_kill_internal (delete)
|
||||
int delete;
|
||||
{
|
||||
char *text;
|
||||
|
||||
if (rl_mark != rl_point)
|
||||
{
|
||||
text = rl_copy_text (rl_point, rl_mark);
|
||||
if (delete)
|
||||
rl_delete_text (rl_point, rl_mark);
|
||||
_rl_copy_to_kill_ring (text, rl_point < rl_mark);
|
||||
}
|
||||
|
||||
_rl_last_command_was_kill++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Copy the text in the region to the kill ring. */
|
||||
int
|
||||
rl_copy_region_to_kill (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
return (region_kill_internal (0));
|
||||
}
|
||||
|
||||
/* Kill the text between the point and mark. */
|
||||
int
|
||||
rl_kill_region (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
int r, npoint;
|
||||
|
||||
npoint = (rl_point < rl_mark) ? rl_point : rl_mark;
|
||||
r = region_kill_internal (1);
|
||||
_rl_fix_point (1);
|
||||
rl_point = npoint;
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Copy COUNT words to the kill ring. DIR says which direction we look
|
||||
to find the words. */
|
||||
static int
|
||||
_rl_copy_word_as_kill (count, dir)
|
||||
int count, dir;
|
||||
{
|
||||
int om, op, r;
|
||||
|
||||
om = rl_mark;
|
||||
op = rl_point;
|
||||
|
||||
if (dir > 0)
|
||||
rl_forward_word (count, 0);
|
||||
else
|
||||
rl_backward_word (count, 0);
|
||||
|
||||
rl_mark = rl_point;
|
||||
|
||||
if (dir > 0)
|
||||
rl_backward_word (count, 0);
|
||||
else
|
||||
rl_forward_word (count, 0);
|
||||
|
||||
r = region_kill_internal (0);
|
||||
|
||||
rl_mark = om;
|
||||
rl_point = op;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
rl_copy_forward_word (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (count < 0)
|
||||
return (rl_copy_backward_word (-count, key));
|
||||
|
||||
return (_rl_copy_word_as_kill (count, 1));
|
||||
}
|
||||
|
||||
int
|
||||
rl_copy_backward_word (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (count < 0)
|
||||
return (rl_copy_forward_word (-count, key));
|
||||
|
||||
return (_rl_copy_word_as_kill (count, -1));
|
||||
}
|
||||
|
||||
/* Yank back the last killed text. This ignores arguments. */
|
||||
int
|
||||
rl_yank (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (rl_kill_ring == 0)
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
_rl_set_mark_at_pos (rl_point);
|
||||
rl_insert_text (rl_kill_ring[rl_kill_index]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If the last command was yank, or yank_pop, and the text just
|
||||
before point is identical to the current kill item, then
|
||||
delete that text from the line, rotate the index down, and
|
||||
yank back some other text. */
|
||||
int
|
||||
rl_yank_pop (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int l, n;
|
||||
|
||||
if (((rl_last_func != rl_yank_pop) && (rl_last_func != rl_yank)) ||
|
||||
!rl_kill_ring)
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
l = strlen (rl_kill_ring[rl_kill_index]);
|
||||
n = rl_point - l;
|
||||
if (n >= 0 && STREQN (rl_line_buffer + n, rl_kill_ring[rl_kill_index], l))
|
||||
{
|
||||
rl_delete_text (n, rl_point);
|
||||
rl_point = n;
|
||||
rl_kill_index--;
|
||||
if (rl_kill_index < 0)
|
||||
rl_kill_index = rl_kill_ring_length - 1;
|
||||
rl_yank (1, 0);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Yank the COUNTh argument from the previous history line, skipping
|
||||
HISTORY_SKIP lines before looking for the `previous line'. */
|
||||
static int
|
||||
rl_yank_nth_arg_internal (count, ignore, history_skip)
|
||||
int count, ignore, history_skip;
|
||||
{
|
||||
register HIST_ENTRY *entry;
|
||||
char *arg;
|
||||
int i, pos;
|
||||
|
||||
pos = where_history ();
|
||||
|
||||
if (history_skip)
|
||||
{
|
||||
for (i = 0; i < history_skip; i++)
|
||||
entry = previous_history ();
|
||||
}
|
||||
|
||||
entry = previous_history ();
|
||||
|
||||
history_set_pos (pos);
|
||||
|
||||
if (entry == 0)
|
||||
{
|
||||
rl_ding ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
arg = history_arg_extract (count, count, entry->line);
|
||||
if (!arg || !*arg)
|
||||
{
|
||||
rl_ding ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
rl_begin_undo_group ();
|
||||
|
||||
_rl_set_mark_at_pos (rl_point);
|
||||
|
||||
#if defined (VI_MODE)
|
||||
/* Vi mode always inserts a space before yanking the argument, and it
|
||||
inserts it right *after* rl_point. */
|
||||
if (rl_editing_mode == vi_mode)
|
||||
{
|
||||
rl_vi_append_mode (1, ignore);
|
||||
rl_insert_text (" ");
|
||||
}
|
||||
#endif /* VI_MODE */
|
||||
|
||||
rl_insert_text (arg);
|
||||
free (arg);
|
||||
|
||||
rl_end_undo_group ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Yank the COUNTth argument from the previous history line. */
|
||||
int
|
||||
rl_yank_nth_arg (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
return (rl_yank_nth_arg_internal (count, ignore, 0));
|
||||
}
|
||||
|
||||
/* Yank the last argument from the previous history line. This `knows'
|
||||
how rl_yank_nth_arg treats a count of `$'. With an argument, this
|
||||
behaves the same as rl_yank_nth_arg. */
|
||||
int
|
||||
rl_yank_last_arg (count, key)
|
||||
int count, key;
|
||||
{
|
||||
static int history_skip = 0;
|
||||
static int explicit_arg_p = 0;
|
||||
static int count_passed = 1;
|
||||
static int direction = 1;
|
||||
static int undo_needed = 0;
|
||||
int retval;
|
||||
|
||||
if (rl_last_func != rl_yank_last_arg)
|
||||
{
|
||||
history_skip = 0;
|
||||
explicit_arg_p = rl_explicit_arg;
|
||||
count_passed = count;
|
||||
direction = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (undo_needed)
|
||||
rl_do_undo ();
|
||||
if (count < 1)
|
||||
direction = -direction;
|
||||
history_skip += direction;
|
||||
if (history_skip < 0)
|
||||
history_skip = 0;
|
||||
}
|
||||
|
||||
if (explicit_arg_p)
|
||||
retval = rl_yank_nth_arg_internal (count_passed, key, history_skip);
|
||||
else
|
||||
retval = rl_yank_nth_arg_internal ('$', key, history_skip);
|
||||
|
||||
undo_needed = retval == 0;
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* A special paste command for users of Cygnus's cygwin32. */
|
||||
#if defined (__CYGWIN__)
|
||||
#include <windows.h>
|
||||
|
||||
int
|
||||
rl_paste_from_clipboard (count, key)
|
||||
int count, key;
|
||||
{
|
||||
char *data, *ptr;
|
||||
int len;
|
||||
|
||||
if (OpenClipboard (NULL) == 0)
|
||||
return (0);
|
||||
|
||||
data = (char *)GetClipboardData (CF_TEXT);
|
||||
if (data)
|
||||
{
|
||||
ptr = strchr (data, '\r');
|
||||
if (ptr)
|
||||
{
|
||||
len = ptr - data;
|
||||
ptr = (char *)xmalloc (len + 1);
|
||||
ptr[len] = '\0';
|
||||
strncpy (ptr, data, len);
|
||||
}
|
||||
else
|
||||
ptr = data;
|
||||
_rl_set_mark_at_pos (rl_point);
|
||||
rl_insert_text (ptr);
|
||||
if (ptr != data)
|
||||
free (ptr);
|
||||
CloseClipboard ();
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
#endif /* __CYGWIN__ */
|
6426
extern/editline/ltmain.sh
vendored
Normal file
6426
extern/editline/ltmain.sh
vendored
Normal file
File diff suppressed because it is too large
Load Diff
271
extern/editline/macro.c
vendored
271
extern/editline/macro.c
vendored
@ -1,271 +0,0 @@
|
||||
/* macro.c -- keyboard macros for readline. */
|
||||
|
||||
/* Copyright (C) 1994 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h> /* for _POSIX_VERSION */
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Hacking Keyboard Macros */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* The currently executing macro string. If this is non-zero,
|
||||
then it is a malloc ()'ed string where input is coming from. */
|
||||
char *rl_executing_macro = (char *)NULL;
|
||||
|
||||
/* The offset in the above string to the next character to be read. */
|
||||
static int executing_macro_index;
|
||||
|
||||
/* The current macro string being built. Characters get stuffed
|
||||
in here by add_macro_char (). */
|
||||
static char *current_macro = (char *)NULL;
|
||||
|
||||
/* The size of the buffer allocated to current_macro. */
|
||||
static int current_macro_size;
|
||||
|
||||
/* The index at which characters are being added to current_macro. */
|
||||
static int current_macro_index;
|
||||
|
||||
/* A structure used to save nested macro strings.
|
||||
It is a linked list of string/index for each saved macro. */
|
||||
struct saved_macro {
|
||||
struct saved_macro *next;
|
||||
char *string;
|
||||
int sindex;
|
||||
};
|
||||
|
||||
/* The list of saved macros. */
|
||||
static struct saved_macro *macro_list = (struct saved_macro *)NULL;
|
||||
|
||||
/* Set up to read subsequent input from STRING.
|
||||
STRING is free ()'ed when we are done with it. */
|
||||
void
|
||||
_rl_with_macro_input (string)
|
||||
char *string;
|
||||
{
|
||||
_rl_push_executing_macro ();
|
||||
rl_executing_macro = string;
|
||||
executing_macro_index = 0;
|
||||
RL_SETSTATE(RL_STATE_MACROINPUT);
|
||||
}
|
||||
|
||||
/* Return the next character available from a macro, or 0 if
|
||||
there are no macro characters. */
|
||||
int
|
||||
_rl_next_macro_key ()
|
||||
{
|
||||
int c;
|
||||
|
||||
if (rl_executing_macro == 0)
|
||||
return (0);
|
||||
|
||||
if (rl_executing_macro[executing_macro_index] == 0)
|
||||
{
|
||||
_rl_pop_executing_macro ();
|
||||
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. */
|
||||
void
|
||||
_rl_push_executing_macro ()
|
||||
{
|
||||
struct saved_macro *saver;
|
||||
|
||||
saver = (struct saved_macro *)xmalloc (sizeof (struct saved_macro));
|
||||
saver->next = macro_list;
|
||||
saver->sindex = executing_macro_index;
|
||||
saver->string = rl_executing_macro;
|
||||
|
||||
macro_list = saver;
|
||||
}
|
||||
|
||||
/* Discard the current macro, replacing it with the one
|
||||
on the top of the stack of saved macros. */
|
||||
void
|
||||
_rl_pop_executing_macro ()
|
||||
{
|
||||
struct saved_macro *macro;
|
||||
|
||||
FREE (rl_executing_macro);
|
||||
rl_executing_macro = (char *)NULL;
|
||||
executing_macro_index = 0;
|
||||
|
||||
if (macro_list)
|
||||
{
|
||||
macro = macro_list;
|
||||
rl_executing_macro = macro_list->string;
|
||||
executing_macro_index = macro_list->sindex;
|
||||
macro_list = macro_list->next;
|
||||
free (macro);
|
||||
}
|
||||
|
||||
if (rl_executing_macro == 0)
|
||||
RL_UNSETSTATE(RL_STATE_MACROINPUT);
|
||||
}
|
||||
|
||||
/* Add a character to the macro being built. */
|
||||
void
|
||||
_rl_add_macro_char (c)
|
||||
int c;
|
||||
{
|
||||
if (current_macro_index + 1 >= current_macro_size)
|
||||
{
|
||||
if (current_macro == 0)
|
||||
current_macro = (char *)xmalloc (current_macro_size = 25);
|
||||
else
|
||||
current_macro = (char *)xrealloc (current_macro, current_macro_size += 25);
|
||||
}
|
||||
|
||||
current_macro[current_macro_index++] = c;
|
||||
current_macro[current_macro_index] = '\0';
|
||||
}
|
||||
|
||||
void
|
||||
_rl_kill_kbd_macro ()
|
||||
{
|
||||
if (current_macro)
|
||||
{
|
||||
free (current_macro);
|
||||
current_macro = (char *) NULL;
|
||||
}
|
||||
current_macro_size = current_macro_index = 0;
|
||||
|
||||
FREE (rl_executing_macro);
|
||||
rl_executing_macro = (char *) NULL;
|
||||
executing_macro_index = 0;
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_MACRODEF);
|
||||
}
|
||||
|
||||
/* Begin defining a keyboard macro.
|
||||
Keystrokes are recorded as they are executed.
|
||||
End the definition with rl_end_kbd_macro ().
|
||||
If a numeric argument was explicitly typed, then append this
|
||||
definition to the end of the existing macro, and start by
|
||||
re-executing the existing macro. */
|
||||
int
|
||||
rl_start_kbd_macro (ignore1, ignore2)
|
||||
int ignore1, ignore2;
|
||||
{
|
||||
if (RL_ISSTATE (RL_STATE_MACRODEF))
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rl_explicit_arg)
|
||||
{
|
||||
if (current_macro)
|
||||
_rl_with_macro_input (savestring (current_macro));
|
||||
}
|
||||
else
|
||||
current_macro_index = 0;
|
||||
|
||||
RL_SETSTATE(RL_STATE_MACRODEF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Stop defining a keyboard macro.
|
||||
A numeric argument says to execute the macro right now,
|
||||
that many times, counting the definition as the first time. */
|
||||
int
|
||||
rl_end_kbd_macro (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (RL_ISSTATE (RL_STATE_MACRODEF) == 0)
|
||||
{
|
||||
_rl_abort_internal ();
|
||||
return -1;
|
||||
}
|
||||
|
||||
current_macro_index -= rl_key_sequence_length - 1;
|
||||
current_macro[current_macro_index] = '\0';
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_MACRODEF);
|
||||
|
||||
return (rl_call_last_kbd_macro (--count, 0));
|
||||
}
|
||||
|
||||
/* Execute the most recently defined keyboard macro.
|
||||
COUNT says how many times to execute it. */
|
||||
int
|
||||
rl_call_last_kbd_macro (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (current_macro == 0)
|
||||
_rl_abort_internal ();
|
||||
|
||||
if (RL_ISSTATE (RL_STATE_MACRODEF))
|
||||
{
|
||||
rl_ding (); /* no recursive macros */
|
||||
current_macro[--current_macro_index] = '\0'; /* erase this char */
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (count--)
|
||||
_rl_with_macro_input (savestring (current_macro));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
rl_push_macro_input (macro)
|
||||
char *macro;
|
||||
{
|
||||
_rl_with_macro_input (macro);
|
||||
}
|
373
extern/editline/mbutil.c
vendored
373
extern/editline/mbutil.c
vendored
@ -1,373 +0,0 @@
|
||||
/* mbutil.c -- readline multibyte character utility functions */
|
||||
|
||||
/* 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.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include "posixjmp.h"
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h> /* for _POSIX_VERSION */
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
#if defined (TIOCSTAT_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* TIOCSTAT_IN_SYS_IOCTL */
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* Declared here so it can be shared between the readline and history
|
||||
libraries. */
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
int rl_byte_oriented = 0;
|
||||
#else
|
||||
int rl_byte_oriented = 1;
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Multibyte Character Utility Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
#if defined(HANDLE_MULTIBYTE)
|
||||
|
||||
static int
|
||||
_rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
|
||||
char *string;
|
||||
int seed, count, find_non_zero;
|
||||
{
|
||||
size_t tmp;
|
||||
mbstate_t ps;
|
||||
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);
|
||||
/* if this is true, means that seed was not pointed character
|
||||
started byte. So correct the point and consume count */
|
||||
if (seed < point)
|
||||
count--;
|
||||
|
||||
while (count > 0)
|
||||
{
|
||||
tmp = mbrtowc (&wc, string+point, strlen(string + point), &ps);
|
||||
if (MB_INVALIDCH ((size_t)tmp))
|
||||
{
|
||||
/* invalid bytes. asume a byte represents a character */
|
||||
point++;
|
||||
count--;
|
||||
/* reset states. */
|
||||
memset(&ps, 0, sizeof(mbstate_t));
|
||||
}
|
||||
else if (MB_NULLWCH (tmp))
|
||||
break; /* found wide '\0' */
|
||||
else
|
||||
{
|
||||
/* valid bytes */
|
||||
point += tmp;
|
||||
if (find_non_zero)
|
||||
{
|
||||
if (wcwidth (wc) == 0)
|
||||
continue;
|
||||
else
|
||||
count--;
|
||||
}
|
||||
else
|
||||
count--;
|
||||
}
|
||||
}
|
||||
|
||||
if (find_non_zero)
|
||||
{
|
||||
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
|
||||
while (tmp > 0 && wcwidth (wc) == 0)
|
||||
{
|
||||
point += tmp;
|
||||
tmp = mbrtowc (&wc, string + point, strlen (string + point), &ps);
|
||||
if (MB_NULLWCH (tmp) || MB_INVALIDCH (tmp))
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return point;
|
||||
}
|
||||
|
||||
static int
|
||||
_rl_find_prev_mbchar_internal (string, seed, find_non_zero)
|
||||
char *string;
|
||||
int seed, find_non_zero;
|
||||
{
|
||||
mbstate_t ps;
|
||||
int prev, non_zero_prev, point, length;
|
||||
size_t tmp;
|
||||
wchar_t wc;
|
||||
|
||||
memset(&ps, 0, sizeof(mbstate_t));
|
||||
length = strlen(string);
|
||||
|
||||
if (seed < 0)
|
||||
return 0;
|
||||
else if (length < seed)
|
||||
return length;
|
||||
|
||||
prev = non_zero_prev = point = 0;
|
||||
while (point < seed)
|
||||
{
|
||||
tmp = mbrtowc (&wc, string + point, length - point, &ps);
|
||||
if (MB_INVALIDCH ((size_t)tmp))
|
||||
{
|
||||
/* in this case, bytes are invalid or shorted to compose
|
||||
multibyte char, so assume that the first byte represents
|
||||
a single character anyway. */
|
||||
tmp = 1;
|
||||
/* clear the state of the byte sequence, because
|
||||
in this case effect of mbstate is undefined */
|
||||
memset(&ps, 0, sizeof (mbstate_t));
|
||||
|
||||
/* Since we're assuming that this byte represents a single
|
||||
non-zero-width character, don't forget about it. */
|
||||
prev = point;
|
||||
}
|
||||
else if (MB_NULLWCH (tmp))
|
||||
break; /* Found '\0' char. Can this happen? */
|
||||
else
|
||||
{
|
||||
if (find_non_zero)
|
||||
{
|
||||
if (wcwidth (wc) != 0)
|
||||
prev = point;
|
||||
}
|
||||
else
|
||||
prev = point;
|
||||
}
|
||||
|
||||
point += tmp;
|
||||
}
|
||||
|
||||
return prev;
|
||||
}
|
||||
|
||||
/* return the number of bytes parsed from the multibyte sequence starting
|
||||
at src, if a non-L'\0' wide character was recognized. It returns 0,
|
||||
if a L'\0' wide character was recognized. It returns (size_t)(-1),
|
||||
if an invalid multibyte sequence was encountered. It returns (size_t)(-2)
|
||||
if it couldn't parse a complete multibyte character. */
|
||||
int
|
||||
_rl_get_char_len (src, ps)
|
||||
char *src;
|
||||
mbstate_t *ps;
|
||||
{
|
||||
size_t tmp;
|
||||
|
||||
tmp = mbrlen((const char *)src, (size_t)strlen (src), ps);
|
||||
if (tmp == (size_t)(-2))
|
||||
{
|
||||
/* shorted to compose multibyte char */
|
||||
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 */
|
||||
if (ps)
|
||||
memset (ps, 0, sizeof(mbstate_t));
|
||||
return -1;
|
||||
}
|
||||
else if (tmp == (size_t)0)
|
||||
return 0;
|
||||
else
|
||||
return (int)tmp;
|
||||
}
|
||||
|
||||
/* compare the specified two characters. If the characters matched,
|
||||
return 1. Otherwise return 0. */
|
||||
int
|
||||
_rl_compare_chars (buf1, pos1, ps1, buf2, pos2, ps2)
|
||||
char *buf1;
|
||||
int pos1;
|
||||
mbstate_t *ps1;
|
||||
char *buf2;
|
||||
int pos2;
|
||||
mbstate_t *ps2;
|
||||
{
|
||||
int i, w1, w2;
|
||||
|
||||
if ((w1 = _rl_get_char_len (&buf1[pos1], ps1)) <= 0 ||
|
||||
(w2 = _rl_get_char_len (&buf2[pos2], ps2)) <= 0 ||
|
||||
(w1 != w2) ||
|
||||
(buf1[pos1] != buf2[pos2]))
|
||||
return 0;
|
||||
|
||||
for (i = 1; i < w1; i++)
|
||||
if (buf1[pos1+i] != buf2[pos2+i])
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* adjust pointed byte and find mbstate of the point of string.
|
||||
adjusted point will be point <= adjusted_point, and returns
|
||||
differences of the byte(adjusted_point - point).
|
||||
if point is invalied (point < 0 || more than string length),
|
||||
it returns -1 */
|
||||
int
|
||||
_rl_adjust_point(string, point, ps)
|
||||
char *string;
|
||||
int point;
|
||||
mbstate_t *ps;
|
||||
{
|
||||
size_t tmp = 0;
|
||||
int length;
|
||||
int pos = 0;
|
||||
|
||||
length = strlen(string);
|
||||
if (point < 0)
|
||||
return -1;
|
||||
if (length < point)
|
||||
return -1;
|
||||
|
||||
while (pos < point)
|
||||
{
|
||||
tmp = mbrlen (string + pos, length - pos, ps);
|
||||
if (MB_INVALIDCH ((size_t)tmp))
|
||||
{
|
||||
/* in this case, bytes are invalid or shorted to compose
|
||||
multibyte char, so assume that the first byte represents
|
||||
a single character anyway. */
|
||||
pos++;
|
||||
/* clear the state of the byte sequence, because
|
||||
in this case effect of mbstate is undefined */
|
||||
if (ps)
|
||||
memset (ps, 0, sizeof (mbstate_t));
|
||||
}
|
||||
else if (MB_NULLWCH (tmp))
|
||||
pos++;
|
||||
else
|
||||
pos += tmp;
|
||||
}
|
||||
|
||||
return (pos - point);
|
||||
}
|
||||
|
||||
int
|
||||
_rl_is_mbchar_matched (string, seed, end, mbchar, length)
|
||||
char *string;
|
||||
int seed, end;
|
||||
char *mbchar;
|
||||
int length;
|
||||
{
|
||||
int i;
|
||||
|
||||
if ((end - seed) < length)
|
||||
return 0;
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
if (string[seed + i] != mbchar[i])
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
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.
|
||||
If flags is MB_FIND_NONZERO, we look for non-zero-width multibyte
|
||||
characters. */
|
||||
#undef _rl_find_next_mbchar
|
||||
int
|
||||
_rl_find_next_mbchar (string, seed, count, flags)
|
||||
char *string;
|
||||
int seed, count, flags;
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
return _rl_find_next_mbchar_internal (string, seed, count, flags);
|
||||
#else
|
||||
return (seed + count);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Find previous character started byte point of the specified seed.
|
||||
Returned point will be point <= seed. If flags is MB_FIND_NONZERO,
|
||||
we look for non-zero-width multibyte characters. */
|
||||
#undef _rl_find_prev_mbchar
|
||||
int
|
||||
_rl_find_prev_mbchar (string, seed, flags)
|
||||
char *string;
|
||||
int seed, flags;
|
||||
{
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
return _rl_find_prev_mbchar_internal (string, seed, flags);
|
||||
#else
|
||||
return ((seed == 0) ? seed : seed - 1);
|
||||
#endif
|
||||
}
|
601
extern/editline/misc.c
vendored
601
extern/editline/misc.c
vendored
@ -1,601 +0,0 @@
|
||||
/* misc.c -- miscellaneous bindable readline functions. */
|
||||
|
||||
/* 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.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_LOCALE_H)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
static int rl_digit_loop PARAMS((void));
|
||||
static void _rl_history_set_point PARAMS((void));
|
||||
|
||||
/* Forward declarations used in this file */
|
||||
void _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
||||
/* If non-zero, rl_get_previous_history and rl_get_next_history attempt
|
||||
to preserve the value of rl_point from line to line. */
|
||||
int _rl_history_preserve_point = 0;
|
||||
|
||||
_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;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Numeric Arguments */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
int
|
||||
_rl_arg_overflow ()
|
||||
{
|
||||
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)
|
||||
{
|
||||
rl_numeric_arg *= 4;
|
||||
return 1;
|
||||
}
|
||||
else if (RL_ISSTATE (RL_STATE_CALLBACK))
|
||||
{
|
||||
_rl_argcxt |= NUM_READONE;
|
||||
return 0; /* XXX */
|
||||
}
|
||||
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))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/* 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_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.
|
||||
Read a key. If the key has nothing to do with arguments, then
|
||||
dispatch on it. If the key is the abort character then abort. */
|
||||
int
|
||||
rl_universal_argument (count, key)
|
||||
int count, key;
|
||||
{
|
||||
_rl_arg_init ();
|
||||
rl_numeric_arg *= 4;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* History Utilities */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* We already have a history library, and that is what we use to control
|
||||
the history features of readline. This is our local interface to
|
||||
the history mechanism. */
|
||||
|
||||
/* While we are editing the history, this is the saved
|
||||
version of the original line. */
|
||||
HIST_ENTRY *_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
|
||||
/* Set the history pointer back to the last entry in the history. */
|
||||
void
|
||||
_rl_start_using_history ()
|
||||
{
|
||||
using_history ();
|
||||
if (_rl_saved_line_for_history)
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
/* Free the contents (and containing structure) of a HIST_ENTRY. */
|
||||
void
|
||||
_rl_free_history_entry (entry)
|
||||
HIST_ENTRY *entry;
|
||||
{
|
||||
if (entry == 0)
|
||||
return;
|
||||
|
||||
FREE (entry->line);
|
||||
FREE (entry->timestamp);
|
||||
|
||||
free (entry);
|
||||
}
|
||||
|
||||
/* Perhaps put back the current line if it has changed. */
|
||||
int
|
||||
rl_maybe_replace_line ()
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
|
||||
temp = current_history ();
|
||||
/* If the current line has changed, save the changes. */
|
||||
if (temp && ((UNDO_LIST *)(temp->data) != rl_undo_list))
|
||||
{
|
||||
temp = replace_history_entry (where_history (), rl_line_buffer, (histdata_t)rl_undo_list);
|
||||
free (temp->line);
|
||||
FREE (temp->timestamp);
|
||||
free (temp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Restore the _rl_saved_line_for_history if there is one. */
|
||||
int
|
||||
rl_maybe_unsave_line ()
|
||||
{
|
||||
if (_rl_saved_line_for_history)
|
||||
{
|
||||
/* 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);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
rl_point = rl_end; /* rl_replace_line sets rl_end */
|
||||
}
|
||||
else
|
||||
rl_ding ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Save the current line in _rl_saved_line_for_history. */
|
||||
int
|
||||
rl_maybe_save_line ()
|
||||
{
|
||||
if (_rl_saved_line_for_history == 0)
|
||||
{
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)xmalloc (sizeof (HIST_ENTRY));
|
||||
_rl_saved_line_for_history->line = savestring (rl_line_buffer);
|
||||
_rl_saved_line_for_history->timestamp = (char *)NULL;
|
||||
_rl_saved_line_for_history->data = (char *)rl_undo_list;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
_rl_free_saved_history_line ()
|
||||
{
|
||||
if (_rl_saved_line_for_history)
|
||||
{
|
||||
_rl_free_history_entry (_rl_saved_line_for_history);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_rl_history_set_point ()
|
||||
{
|
||||
rl_point = (_rl_history_preserve_point && _rl_history_saved_point != -1)
|
||||
? _rl_history_saved_point
|
||||
: rl_end;
|
||||
if (rl_point > rl_end)
|
||||
rl_point = rl_end;
|
||||
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode && _rl_keymap != vi_insertion_keymap)
|
||||
rl_point = 0;
|
||||
#endif /* VI_MODE */
|
||||
|
||||
if (rl_editing_mode == emacs_mode)
|
||||
rl_mark = (rl_point == rl_end ? 0 : rl_end);
|
||||
}
|
||||
|
||||
void
|
||||
rl_replace_from_history (entry, flags)
|
||||
HIST_ENTRY *entry;
|
||||
int flags; /* currently unused */
|
||||
{
|
||||
/* 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;
|
||||
rl_mark = 0;
|
||||
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode == vi_mode)
|
||||
{
|
||||
rl_point = 0;
|
||||
rl_mark = rl_end;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* History Commands */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Meta-< goes to the start of the history. */
|
||||
int
|
||||
rl_beginning_of_history (count, key)
|
||||
int count, key;
|
||||
{
|
||||
return (rl_get_previous_history (1 + where_history (), key));
|
||||
}
|
||||
|
||||
/* Meta-> goes to the end of the history. (The current line). */
|
||||
int
|
||||
rl_end_of_history (count, key)
|
||||
int count, key;
|
||||
{
|
||||
rl_maybe_replace_line ();
|
||||
using_history ();
|
||||
rl_maybe_unsave_line ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Move down to the next history line. */
|
||||
int
|
||||
rl_get_next_history (count, key)
|
||||
int count, key;
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
|
||||
if (count < 0)
|
||||
return (rl_get_previous_history (-count, key));
|
||||
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
rl_maybe_replace_line ();
|
||||
|
||||
/* either not saved by rl_newline or at end of line, so set appropriately. */
|
||||
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
|
||||
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
|
||||
|
||||
temp = (HIST_ENTRY *)NULL;
|
||||
while (count)
|
||||
{
|
||||
temp = next_history ();
|
||||
if (!temp)
|
||||
break;
|
||||
--count;
|
||||
}
|
||||
|
||||
if (temp == 0)
|
||||
rl_maybe_unsave_line ();
|
||||
else
|
||||
{
|
||||
rl_replace_from_history (temp, 0);
|
||||
_rl_history_set_point ();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get the previous item out of our interactive history, making it the current
|
||||
line. If there is no previous history, just ding. */
|
||||
int
|
||||
rl_get_previous_history (count, key)
|
||||
int count, key;
|
||||
{
|
||||
HIST_ENTRY *old_temp, *temp;
|
||||
|
||||
if (count < 0)
|
||||
return (rl_get_next_history (-count, key));
|
||||
|
||||
if (count == 0)
|
||||
return 0;
|
||||
|
||||
/* either not saved by rl_newline or at end of line, so set appropriately. */
|
||||
if (_rl_history_saved_point == -1 && (rl_point || rl_end))
|
||||
_rl_history_saved_point = (rl_point == rl_end) ? -1 : rl_point;
|
||||
|
||||
/* If we don't have a line saved, then save this one. */
|
||||
rl_maybe_save_line ();
|
||||
|
||||
/* If the current line has changed, save the changes. */
|
||||
rl_maybe_replace_line ();
|
||||
|
||||
temp = old_temp = (HIST_ENTRY *)NULL;
|
||||
while (count)
|
||||
{
|
||||
temp = previous_history ();
|
||||
if (temp == 0)
|
||||
break;
|
||||
|
||||
old_temp = temp;
|
||||
--count;
|
||||
}
|
||||
|
||||
/* If there was a large argument, and we moved back to the start of the
|
||||
history, that is not an error. So use the last value found. */
|
||||
if (!temp && old_temp)
|
||||
temp = old_temp;
|
||||
|
||||
if (temp == 0)
|
||||
rl_ding ();
|
||||
else
|
||||
{
|
||||
rl_replace_from_history (temp, 0);
|
||||
_rl_history_set_point ();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Editing Modes */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
/* How to toggle back and forth between editing modes. */
|
||||
int
|
||||
rl_vi_editing_mode (count, key)
|
||||
int count, key;
|
||||
{
|
||||
#if defined (VI_MODE)
|
||||
_rl_set_insert_mode (RL_IM_INSERT, 1); /* vi mode ignores insert mode */
|
||||
rl_editing_mode = vi_mode;
|
||||
rl_vi_insertion_mode (1, key);
|
||||
#endif /* VI_MODE */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rl_emacs_editing_mode (count, key)
|
||||
int count, key;
|
||||
{
|
||||
rl_editing_mode = emacs_mode;
|
||||
_rl_set_insert_mode (RL_IM_INSERT, 1); /* emacs mode default is insert mode */
|
||||
_rl_keymap = emacs_standard_keymap;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Function for the rest of the library to use to set insert/overwrite mode. */
|
||||
void
|
||||
_rl_set_insert_mode (im, force)
|
||||
int im, force;
|
||||
{
|
||||
#ifdef CURSOR_MODE
|
||||
_rl_set_cursor (im, force);
|
||||
#endif
|
||||
|
||||
rl_insert_mode = im;
|
||||
}
|
||||
|
||||
/* Toggle overwrite mode. A positive explicit argument selects overwrite
|
||||
mode. A negative or zero explicit argument selects insert mode. */
|
||||
int
|
||||
rl_overwrite_mode (count, key)
|
||||
int count, key;
|
||||
{
|
||||
if (rl_explicit_arg == 0)
|
||||
_rl_set_insert_mode (rl_insert_mode ^ 1, 0);
|
||||
else if (count > 0)
|
||||
_rl_set_insert_mode (RL_IM_OVERWRITE, 0);
|
||||
else
|
||||
_rl_set_insert_mode (RL_IM_INSERT, 0);
|
||||
|
||||
return 0;
|
||||
}
|
353
extern/editline/missing
vendored
Executable file
353
extern/editline/missing
vendored
Executable file
@ -0,0 +1,353 @@
|
||||
#! /bin/sh
|
||||
# Common stub for a few missing GNU programs while installing.
|
||||
|
||||
scriptversion=2004-09-07.08
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
|
||||
# Free Software Foundation, Inc.
|
||||
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 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, 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.
|
||||
|
||||
if test $# -eq 0; then
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run=:
|
||||
|
||||
# In the cases where this matters, `missing' is being run in the
|
||||
# srcdir already.
|
||||
if test -f configure.ac; then
|
||||
configure_ac=configure.ac
|
||||
else
|
||||
configure_ac=configure.in
|
||||
fi
|
||||
|
||||
msg="missing on your system"
|
||||
|
||||
case "$1" in
|
||||
--run)
|
||||
# Try to run requested program, and just exit if it succeeds.
|
||||
run=
|
||||
shift
|
||||
"$@" && exit 0
|
||||
# Exit code 63 means version mismatch. This often happens
|
||||
# when the user try to use an ancient version of a tool on
|
||||
# a file that requires a minimum version. In this case we
|
||||
# we should proceed has if the program had been absent, or
|
||||
# if --run hadn't been passed.
|
||||
if test $? = 63; then
|
||||
run=:
|
||||
msg="probably too old"
|
||||
fi
|
||||
;;
|
||||
|
||||
-h|--h|--he|--hel|--help)
|
||||
echo "\
|
||||
$0 [OPTION]... PROGRAM [ARGUMENT]...
|
||||
|
||||
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
|
||||
error status if there is no known handling for PROGRAM.
|
||||
|
||||
Options:
|
||||
-h, --help display this help and exit
|
||||
-v, --version output version information and exit
|
||||
--run try to run the given command, and emulate it if it fails
|
||||
|
||||
Supported PROGRAM values:
|
||||
aclocal touch file \`aclocal.m4'
|
||||
autoconf touch file \`configure'
|
||||
autoheader touch file \`config.h.in'
|
||||
automake touch all \`Makefile.in' files
|
||||
bison create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
flex create \`lex.yy.c', if possible, from existing .c
|
||||
help2man touch the output file
|
||||
lex create \`lex.yy.c', if possible, from existing .c
|
||||
makeinfo touch the output file
|
||||
tar try tar, gnutar, gtar, then tar without non-portable flags
|
||||
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
|
||||
|
||||
Send bug reports to <bug-automake@gnu.org>."
|
||||
exit 0
|
||||
;;
|
||||
|
||||
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
|
||||
echo "missing $scriptversion (GNU Automake)"
|
||||
exit 0
|
||||
;;
|
||||
|
||||
-*)
|
||||
echo 1>&2 "$0: Unknown \`$1' option"
|
||||
echo 1>&2 "Try \`$0 --help' for more information"
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
# Now exit if we have it, but it failed. Also exit now if we
|
||||
# don't have it and --version was passed (most likely to detect
|
||||
# the program).
|
||||
case "$1" in
|
||||
lex|yacc)
|
||||
# Not GNU programs, they don't have --version.
|
||||
;;
|
||||
|
||||
tar)
|
||||
if test -n "$run"; then
|
||||
echo 1>&2 "ERROR: \`tar' requires --run"
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
*)
|
||||
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
|
||||
# We have it, but it failed.
|
||||
exit 1
|
||||
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
|
||||
# Could not run --version or --help. This is probably someone
|
||||
# running `$TOOL --version' or `$TOOL --help' to check whether
|
||||
# $TOOL exists and not knowing $TOOL uses missing.
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
# If it does not exist, or fails to run (possibly an outdated version),
|
||||
# try to emulate it.
|
||||
case "$1" in
|
||||
aclocal*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
|
||||
to install the \`Automake' and \`Perl' packages. Grab them from
|
||||
any GNU archive site."
|
||||
touch aclocal.m4
|
||||
;;
|
||||
|
||||
autoconf)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`${configure_ac}'. You might want to install the
|
||||
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
|
||||
archive site."
|
||||
touch configure
|
||||
;;
|
||||
|
||||
autoheader)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`acconfig.h' or \`${configure_ac}'. You might want
|
||||
to install the \`Autoconf' and \`GNU m4' packages. Grab them
|
||||
from any GNU archive site."
|
||||
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
|
||||
test -z "$files" && files="config.h"
|
||||
touch_files=
|
||||
for f in $files; do
|
||||
case "$f" in
|
||||
*:*) touch_files="$touch_files "`echo "$f" |
|
||||
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
|
||||
*) touch_files="$touch_files $f.in";;
|
||||
esac
|
||||
done
|
||||
touch $touch_files
|
||||
;;
|
||||
|
||||
automake*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
|
||||
You might want to install the \`Automake' and \`Perl' packages.
|
||||
Grab them from any GNU archive site."
|
||||
find . -type f -name Makefile.am -print |
|
||||
sed 's/\.am$/.in/' |
|
||||
while read f; do touch "$f"; done
|
||||
;;
|
||||
|
||||
autom4te)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, but is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them.
|
||||
You can get \`$1' as part of \`Autoconf' from any GNU
|
||||
archive site."
|
||||
|
||||
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
|
||||
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
|
||||
if test -f "$file"; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo "#! /bin/sh"
|
||||
echo "# Created by GNU Automake missing as a replacement of"
|
||||
echo "# $ $@"
|
||||
echo "exit 0"
|
||||
chmod +x $file
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
bison|yacc)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' $msg. You should only need it if
|
||||
you modified a \`.y' file. You may need the \`Bison' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Bison' from any GNU archive site."
|
||||
rm -f y.tab.c y.tab.h
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.y)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.c
|
||||
fi
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" y.tab.h
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f y.tab.h ]; then
|
||||
echo >y.tab.h
|
||||
fi
|
||||
if [ ! -f y.tab.c ]; then
|
||||
echo 'main() { return 0; }' >y.tab.c
|
||||
fi
|
||||
;;
|
||||
|
||||
lex|flex)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.l' file. You may need the \`Flex' package
|
||||
in order for those modifications to take effect. You can get
|
||||
\`Flex' from any GNU archive site."
|
||||
rm -f lex.yy.c
|
||||
if [ $# -ne 1 ]; then
|
||||
eval LASTARG="\${$#}"
|
||||
case "$LASTARG" in
|
||||
*.l)
|
||||
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
|
||||
if [ -f "$SRCFILE" ]; then
|
||||
cp "$SRCFILE" lex.yy.c
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
if [ ! -f lex.yy.c ]; then
|
||||
echo 'main() { return 0; }' >lex.yy.c
|
||||
fi
|
||||
;;
|
||||
|
||||
help2man)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a dependency of a manual page. You may need the
|
||||
\`Help2man' package in order for those modifications to take
|
||||
effect. You can get \`Help2man' from any GNU archive site."
|
||||
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
|
||||
fi
|
||||
if [ -f "$file" ]; then
|
||||
touch $file
|
||||
else
|
||||
test -z "$file" || exec >$file
|
||||
echo ".ab help2man is required to generate this page"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
|
||||
makeinfo)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is $msg. You should only need it if
|
||||
you modified a \`.texi' or \`.texinfo' file, or any other file
|
||||
indirectly affecting the aspect of the manual. The spurious
|
||||
call might also be the consequence of using a buggy \`make' (AIX,
|
||||
DU, IRIX). You might want to install the \`Texinfo' package or
|
||||
the \`GNU make' package. Grab either from any GNU archive site."
|
||||
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
|
||||
if test -z "$file"; then
|
||||
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
|
||||
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
|
||||
fi
|
||||
touch $file
|
||||
;;
|
||||
|
||||
tar)
|
||||
shift
|
||||
|
||||
# We have already tried tar in the generic part.
|
||||
# Look for gnutar/gtar before invocation to avoid ugly error
|
||||
# messages.
|
||||
if (gnutar --version > /dev/null 2>&1); then
|
||||
gnutar "$@" && exit 0
|
||||
fi
|
||||
if (gtar --version > /dev/null 2>&1); then
|
||||
gtar "$@" && exit 0
|
||||
fi
|
||||
firstarg="$1"
|
||||
if shift; then
|
||||
case "$firstarg" in
|
||||
*o*)
|
||||
firstarg=`echo "$firstarg" | sed s/o//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
case "$firstarg" in
|
||||
*h*)
|
||||
firstarg=`echo "$firstarg" | sed s/h//`
|
||||
tar "$firstarg" "$@" && exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo 1>&2 "\
|
||||
WARNING: I can't seem to be able to run \`tar' with the given arguments.
|
||||
You may want to install GNU tar or Free paxutils, or check the
|
||||
command line arguments."
|
||||
exit 1
|
||||
;;
|
||||
|
||||
*)
|
||||
echo 1>&2 "\
|
||||
WARNING: \`$1' is needed, and is $msg.
|
||||
You might have modified some files without having the
|
||||
proper tools for further handling them. Check the \`README' file,
|
||||
it often tells you about the needed prerequisites for installing
|
||||
this package. You may also peek at any GNU archive site, in case
|
||||
some other package would contain this missing \`$1' program."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-end: "$"
|
||||
# End:
|
252
extern/editline/nls.c
vendored
252
extern/editline/nls.c
vendored
@ -1,252 +0,0 @@
|
||||
/* nls.c -- skeletal internationalization code. */
|
||||
|
||||
/* Copyright (C) 1996 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_LOCALE_H)
|
||||
# include <locale.h>
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
#include "rldefs.h"
|
||||
#include "readline.h"
|
||||
#include "rlshell.h"
|
||||
#include "rlprivate.h"
|
||||
|
||||
#if !defined (HAVE_SETLOCALE)
|
||||
/* A list of legal values for the LANG or LC_CTYPE environment variables.
|
||||
If a locale name in this list is the value for the LC_ALL, LC_CTYPE,
|
||||
or LANG environment variable (using the first of those with a value),
|
||||
readline eight-bit mode is enabled. */
|
||||
static char *legal_lang_values[] =
|
||||
{
|
||||
"iso88591",
|
||||
"iso88592",
|
||||
"iso88593",
|
||||
"iso88594",
|
||||
"iso88595",
|
||||
"iso88596",
|
||||
"iso88597",
|
||||
"iso88598",
|
||||
"iso88599",
|
||||
"iso885910",
|
||||
"koi8r",
|
||||
0
|
||||
};
|
||||
|
||||
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. */
|
||||
int
|
||||
_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 *lspec, *t;
|
||||
|
||||
/* Set the LC_CTYPE locale category from environment variables. */
|
||||
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;
|
||||
_rl_convert_meta_chars_to_ascii = 0;
|
||||
_rl_output_meta_chars = 1;
|
||||
return (1);
|
||||
}
|
||||
else
|
||||
return (0);
|
||||
|
||||
#else /* !HAVE_SETLOCALE */
|
||||
char *lspec, *t;
|
||||
int i;
|
||||
|
||||
/* 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 = _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++)
|
||||
if (STREQ (t, legal_lang_values[i]))
|
||||
{
|
||||
_rl_meta_flag = 1;
|
||||
_rl_convert_meta_chars_to_ascii = 0;
|
||||
_rl_output_meta_chars = 1;
|
||||
break;
|
||||
}
|
||||
free (t);
|
||||
return (legal_lang_values[i] ? 1 : 0);
|
||||
|
||||
#endif /* !HAVE_SETLOCALE */
|
||||
}
|
||||
|
||||
#if !defined (HAVE_SETLOCALE)
|
||||
static char *
|
||||
normalize_codeset (codeset)
|
||||
char *codeset;
|
||||
{
|
||||
size_t namelen, i;
|
||||
int len, all_digits;
|
||||
char *wp, *retval;
|
||||
|
||||
codeset = find_codeset (codeset, &namelen);
|
||||
|
||||
if (codeset == 0)
|
||||
return (codeset);
|
||||
|
||||
all_digits = 1;
|
||||
for (len = 0, i = 0; i < namelen; i++)
|
||||
{
|
||||
if (ISALNUM ((unsigned char)codeset[i]))
|
||||
{
|
||||
len++;
|
||||
all_digits &= _rl_digit_p (codeset[i]);
|
||||
}
|
||||
}
|
||||
|
||||
retval = (char *)malloc ((all_digits ? 3 : 0) + len + 1);
|
||||
if (retval == 0)
|
||||
return ((char *)0);
|
||||
|
||||
wp = retval;
|
||||
/* Add `iso' to beginning of an all-digit codeset */
|
||||
if (all_digits)
|
||||
{
|
||||
*wp++ = 'i';
|
||||
*wp++ = 's';
|
||||
*wp++ = 'o';
|
||||
}
|
||||
|
||||
for (i = 0; i < namelen; i++)
|
||||
if (ISALPHA ((unsigned char)codeset[i]))
|
||||
*wp++ = _rl_to_lower (codeset[i]);
|
||||
else if (_rl_digit_p (codeset[i]))
|
||||
*wp++ = codeset[i];
|
||||
*wp = '\0';
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Isolate codeset portion of locale specification. */
|
||||
static char *
|
||||
find_codeset (name, lenp)
|
||||
char *name;
|
||||
size_t *lenp;
|
||||
{
|
||||
char *cp, *language, *result;
|
||||
|
||||
cp = language = name;
|
||||
result = (char *)0;
|
||||
|
||||
while (*cp && *cp != '_' && *cp != '@' && *cp != '+' && *cp != ',')
|
||||
cp++;
|
||||
|
||||
/* This does not make sense: language has to be specified. As
|
||||
an exception we allow the variable to contain only the codeset
|
||||
name. Perhaps there are funny codeset names. */
|
||||
if (language == cp)
|
||||
{
|
||||
*lenp = strlen (language);
|
||||
result = language;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Next is the territory. */
|
||||
if (*cp == '_')
|
||||
do
|
||||
++cp;
|
||||
while (*cp && *cp != '.' && *cp != '@' && *cp != '+' && *cp != ',' && *cp != '_');
|
||||
|
||||
/* Now, finally, is the codeset. */
|
||||
result = cp;
|
||||
if (*cp == '.')
|
||||
do
|
||||
++cp;
|
||||
while (*cp && *cp != '@');
|
||||
|
||||
if (cp - result > 2)
|
||||
{
|
||||
result++;
|
||||
*lenp = cp - result;
|
||||
}
|
||||
else
|
||||
{
|
||||
*lenp = strlen (language);
|
||||
result = language;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* !HAVE_SETLOCALE */
|
183
extern/editline/parens.c
vendored
183
extern/editline/parens.c
vendored
@ -1,183 +0,0 @@
|
||||
/* parens.c -- Implementation of matching parentheses feature. */
|
||||
|
||||
/* Copyright (C) 1987, 1989, 1992 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (__TANDEM)
|
||||
# include <floss.h>
|
||||
#endif
|
||||
|
||||
#include "rlconf.h"
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (FD_SET) && !defined (HAVE_SELECT)
|
||||
# define HAVE_SELECT
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_SELECT)
|
||||
# include <sys/time.h>
|
||||
#endif /* HAVE_SELECT */
|
||||
#if defined (HAVE_SYS_SELECT_H)
|
||||
# include <sys/select.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else /* !HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if !defined (strchr) && !defined (__STDC__)
|
||||
extern char *strchr (), *strrchr ();
|
||||
#endif /* !strchr && !__STDC__ */
|
||||
|
||||
#include "readline.h"
|
||||
#include "rlprivate.h"
|
||||
|
||||
static int find_matching_open PARAMS((char *, int, int));
|
||||
|
||||
/* Non-zero means try to blink the matching open parenthesis when the
|
||||
close parenthesis is inserted. */
|
||||
#if defined (HAVE_SELECT)
|
||||
int rl_blink_matching_paren = 1;
|
||||
#else /* !HAVE_SELECT */
|
||||
int rl_blink_matching_paren = 0;
|
||||
#endif /* !HAVE_SELECT */
|
||||
|
||||
static int _paren_blink_usec = 500000;
|
||||
|
||||
/* Change emacs_standard_keymap to have bindings for paren matching when
|
||||
ON_OR_OFF is 1, change them back to self_insert when ON_OR_OFF == 0. */
|
||||
void
|
||||
_rl_enable_paren_matching (on_or_off)
|
||||
int on_or_off;
|
||||
{
|
||||
if (on_or_off)
|
||||
{ /* ([{ */
|
||||
rl_bind_key_in_map (')', rl_insert_close, emacs_standard_keymap);
|
||||
rl_bind_key_in_map (']', rl_insert_close, emacs_standard_keymap);
|
||||
rl_bind_key_in_map ('}', rl_insert_close, emacs_standard_keymap);
|
||||
}
|
||||
else
|
||||
{ /* ([{ */
|
||||
rl_bind_key_in_map (')', rl_insert, emacs_standard_keymap);
|
||||
rl_bind_key_in_map (']', rl_insert, emacs_standard_keymap);
|
||||
rl_bind_key_in_map ('}', rl_insert, emacs_standard_keymap);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
rl_set_paren_blink_timeout (u)
|
||||
int u;
|
||||
{
|
||||
int o;
|
||||
|
||||
o = _paren_blink_usec;
|
||||
if (u > 0)
|
||||
_paren_blink_usec = u;
|
||||
return (o);
|
||||
}
|
||||
|
||||
int
|
||||
rl_insert_close (count, invoking_key)
|
||||
int count, invoking_key;
|
||||
{
|
||||
if (rl_explicit_arg || !rl_blink_matching_paren)
|
||||
_rl_insert_char (count, invoking_key);
|
||||
else
|
||||
{
|
||||
#if defined (HAVE_SELECT)
|
||||
int orig_point, match_point, ready;
|
||||
struct timeval timer;
|
||||
fd_set readfds;
|
||||
|
||||
_rl_insert_char (1, invoking_key);
|
||||
(*rl_redisplay_function) ();
|
||||
match_point =
|
||||
find_matching_open (rl_line_buffer, rl_point - 2, invoking_key);
|
||||
|
||||
/* Emacs might message or ring the bell here, but I don't. */
|
||||
if (match_point < 0)
|
||||
return -1;
|
||||
|
||||
FD_ZERO (&readfds);
|
||||
FD_SET (fileno (rl_instream), &readfds);
|
||||
timer.tv_sec = 0;
|
||||
timer.tv_usec = _paren_blink_usec;
|
||||
|
||||
orig_point = rl_point;
|
||||
rl_point = match_point;
|
||||
(*rl_redisplay_function) ();
|
||||
ready = select (1, &readfds, (fd_set *)NULL, (fd_set *)NULL, &timer);
|
||||
rl_point = orig_point;
|
||||
#else /* !HAVE_SELECT */
|
||||
_rl_insert_char (count, invoking_key);
|
||||
#endif /* !HAVE_SELECT */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
find_matching_open (string, from, closer)
|
||||
char *string;
|
||||
int from, closer;
|
||||
{
|
||||
register int i;
|
||||
int opener, level, delimiter;
|
||||
|
||||
switch (closer)
|
||||
{
|
||||
case ']': opener = '['; break;
|
||||
case '}': opener = '{'; break;
|
||||
case ')': opener = '('; break;
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
|
||||
level = 1; /* The closer passed in counts as 1. */
|
||||
delimiter = 0; /* Delimited state unknown. */
|
||||
|
||||
for (i = from; i > -1; i--)
|
||||
{
|
||||
if (delimiter && (string[i] == delimiter))
|
||||
delimiter = 0;
|
||||
else if (rl_basic_quote_characters && strchr (rl_basic_quote_characters, string[i]))
|
||||
delimiter = string[i];
|
||||
else if (!delimiter && (string[i] == closer))
|
||||
level++;
|
||||
else if (!delimiter && (string[i] == opener))
|
||||
level--;
|
||||
|
||||
if (!level)
|
||||
break;
|
||||
}
|
||||
return (i);
|
||||
}
|
61
extern/editline/posixdir.h
vendored
61
extern/editline/posixdir.h
vendored
@ -1,61 +0,0 @@
|
||||
/* posixdir.h -- Posix directory reading includes and defines. */
|
||||
|
||||
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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.
|
||||
|
||||
Bash 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 Bash; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
/* This file should be included instead of <dirent.h> or <sys/dir.h>. */
|
||||
|
||||
#if !defined (_POSIXDIR_H_)
|
||||
#define _POSIXDIR_H_
|
||||
|
||||
#if defined (HAVE_DIRENT_H)
|
||||
# include <dirent.h>
|
||||
# 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>
|
||||
# endif
|
||||
# if defined (HAVE_SYS_DIR_H)
|
||||
# include <sys/dir.h>
|
||||
# endif
|
||||
# if defined (HAVE_NDIR_H)
|
||||
# include <ndir.h>
|
||||
# endif
|
||||
# if !defined (dirent)
|
||||
# define dirent direct
|
||||
# endif /* !dirent */
|
||||
# define D_NAMLEN(d) ((d)->d_namlen)
|
||||
#endif /* !HAVE_DIRENT_H */
|
||||
|
||||
#if defined (HAVE_STRUCT_DIRENT_D_INO) && !defined (HAVE_STRUCT_DIRENT_D_FILENO)
|
||||
# define d_fileno d_ino
|
||||
#endif
|
||||
|
||||
#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
|
||||
#else
|
||||
# define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
|
||||
#endif /* _POSIX_SOURCE */
|
||||
|
||||
#endif /* !_POSIXDIR_H_ */
|
40
extern/editline/posixjmp.h
vendored
40
extern/editline/posixjmp.h
vendored
@ -1,40 +0,0 @@
|
||||
/* posixjmp.h -- wrapper for setjmp.h with changes for POSIX systems. */
|
||||
|
||||
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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.
|
||||
|
||||
Bash 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 Bash; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#ifndef _POSIXJMP_H_
|
||||
#define _POSIXJMP_H_
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
/* This *must* be included *after* config.h */
|
||||
|
||||
#if defined (HAVE_POSIX_SIGSETJMP)
|
||||
# define procenv_t sigjmp_buf
|
||||
# if !defined (__OPENNT)
|
||||
# undef setjmp
|
||||
# define setjmp(x) sigsetjmp((x), 1)
|
||||
# undef longjmp
|
||||
# define longjmp(x, n) siglongjmp((x), (n))
|
||||
# endif /* !__OPENNT */
|
||||
#else
|
||||
# define procenv_t jmp_buf
|
||||
#endif
|
||||
|
||||
#endif /* _POSIXJMP_H_ */
|
142
extern/editline/posixstat.h
vendored
142
extern/editline/posixstat.h
vendored
@ -1,142 +0,0 @@
|
||||
/* posixstat.h -- Posix stat(2) definitions for systems that
|
||||
don't have them. */
|
||||
|
||||
/* Copyright (C) 1987,1991 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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.
|
||||
|
||||
Bash 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 Bash; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
/* This file should be included instead of <sys/stat.h>.
|
||||
It relies on the local sys/stat.h to work though. */
|
||||
#if !defined (_POSIXSTAT_H_)
|
||||
#define _POSIXSTAT_H_
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if defined (STAT_MACROS_BROKEN)
|
||||
# undef S_ISBLK
|
||||
# undef S_ISCHR
|
||||
# undef S_ISDIR
|
||||
# undef S_ISFIFO
|
||||
# undef S_ISREG
|
||||
# undef S_ISLNK
|
||||
#endif /* STAT_MACROS_BROKEN */
|
||||
|
||||
/* These are guaranteed to work only on isc386 */
|
||||
#if !defined (S_IFDIR) && !defined (S_ISDIR)
|
||||
# define S_IFDIR 0040000
|
||||
#endif /* !S_IFDIR && !S_ISDIR */
|
||||
#if !defined (S_IFMT)
|
||||
# define S_IFMT 0170000
|
||||
#endif /* !S_IFMT */
|
||||
|
||||
/* Posix 1003.1 5.6.1.1 <sys/stat.h> file types */
|
||||
|
||||
/* Some Posix-wannabe systems define _S_IF* macros instead of S_IF*, but
|
||||
do not provide the S_IS* macros that Posix requires. */
|
||||
|
||||
#if defined (_S_IFMT) && !defined (S_IFMT)
|
||||
#define S_IFMT _S_IFMT
|
||||
#endif
|
||||
#if defined (_S_IFIFO) && !defined (S_IFIFO)
|
||||
#define S_IFIFO _S_IFIFO
|
||||
#endif
|
||||
#if defined (_S_IFCHR) && !defined (S_IFCHR)
|
||||
#define S_IFCHR _S_IFCHR
|
||||
#endif
|
||||
#if defined (_S_IFDIR) && !defined (S_IFDIR)
|
||||
#define S_IFDIR _S_IFDIR
|
||||
#endif
|
||||
#if defined (_S_IFBLK) && !defined (S_IFBLK)
|
||||
#define S_IFBLK _S_IFBLK
|
||||
#endif
|
||||
#if defined (_S_IFREG) && !defined (S_IFREG)
|
||||
#define S_IFREG _S_IFREG
|
||||
#endif
|
||||
#if defined (_S_IFLNK) && !defined (S_IFLNK)
|
||||
#define S_IFLNK _S_IFLNK
|
||||
#endif
|
||||
#if defined (_S_IFSOCK) && !defined (S_IFSOCK)
|
||||
#define S_IFSOCK _S_IFSOCK
|
||||
#endif
|
||||
|
||||
/* Test for each symbol individually and define the ones necessary (some
|
||||
systems claiming Posix compatibility define some but not all). */
|
||||
|
||||
#if defined (S_IFBLK) && !defined (S_ISBLK)
|
||||
#define S_ISBLK(m) (((m)&S_IFMT) == S_IFBLK) /* block device */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFCHR) && !defined (S_ISCHR)
|
||||
#define S_ISCHR(m) (((m)&S_IFMT) == S_IFCHR) /* character device */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFDIR) && !defined (S_ISDIR)
|
||||
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) /* directory */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFREG) && !defined (S_ISREG)
|
||||
#define S_ISREG(m) (((m)&S_IFMT) == S_IFREG) /* file */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFIFO) && !defined (S_ISFIFO)
|
||||
#define S_ISFIFO(m) (((m)&S_IFMT) == S_IFIFO) /* fifo - named pipe */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFLNK) && !defined (S_ISLNK)
|
||||
#define S_ISLNK(m) (((m)&S_IFMT) == S_IFLNK) /* symbolic link */
|
||||
#endif
|
||||
|
||||
#if defined (S_IFSOCK) && !defined (S_ISSOCK)
|
||||
#define S_ISSOCK(m) (((m)&S_IFMT) == S_IFSOCK) /* socket */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* POSIX 1003.1 5.6.1.2 <sys/stat.h> File Modes
|
||||
*/
|
||||
|
||||
#if !defined (S_IRWXU)
|
||||
# if !defined (S_IREAD)
|
||||
# define S_IREAD 00400
|
||||
# define S_IWRITE 00200
|
||||
# define S_IEXEC 00100
|
||||
# endif /* S_IREAD */
|
||||
|
||||
# if !defined (S_IRUSR)
|
||||
# define S_IRUSR S_IREAD /* read, owner */
|
||||
# define S_IWUSR S_IWRITE /* write, owner */
|
||||
# define S_IXUSR S_IEXEC /* execute, owner */
|
||||
|
||||
# define S_IRGRP (S_IREAD >> 3) /* read, group */
|
||||
# define S_IWGRP (S_IWRITE >> 3) /* write, group */
|
||||
# define S_IXGRP (S_IEXEC >> 3) /* execute, group */
|
||||
|
||||
# define S_IROTH (S_IREAD >> 6) /* read, other */
|
||||
# define S_IWOTH (S_IWRITE >> 6) /* write, other */
|
||||
# define S_IXOTH (S_IEXEC >> 6) /* execute, other */
|
||||
# endif /* !S_IRUSR */
|
||||
|
||||
# define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR)
|
||||
# define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
|
||||
# define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
|
||||
#endif /* !S_IRWXU */
|
||||
|
||||
/* These are non-standard, but are used in builtins.c$symbolic_umask() */
|
||||
#define S_IRUGO (S_IRUSR | S_IRGRP | S_IROTH)
|
||||
#define S_IWUGO (S_IWUSR | S_IWGRP | S_IWOTH)
|
||||
#define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
|
||||
|
||||
#endif /* _POSIXSTAT_H_ */
|
1194
extern/editline/readline.c
vendored
1194
extern/editline/readline.c
vendored
File diff suppressed because it is too large
Load Diff
849
extern/editline/readline.h
vendored
849
extern/editline/readline.h
vendored
@ -1,849 +0,0 @@
|
||||
/* Readline.h -- the names of functions callable from within readline. */
|
||||
|
||||
/* 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.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_READLINE_H_)
|
||||
#define _READLINE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined (READLINE_LIBRARY)
|
||||
# include "rlstdc.h"
|
||||
# include "rltypedefs.h"
|
||||
# include "keymaps.h"
|
||||
# include "tilde.h"
|
||||
#else
|
||||
# include <readline/rlstdc.h>
|
||||
# include <readline/rltypedefs.h>
|
||||
# include <readline/keymaps.h>
|
||||
# include <readline/tilde.h>
|
||||
#endif
|
||||
|
||||
/* Hex-encoded Readline version number. */
|
||||
#define RL_READLINE_VERSION 0x0501 /* Readline 5.1 */
|
||||
#define RL_VERSION_MAJOR 5
|
||||
#define RL_VERSION_MINOR 1
|
||||
|
||||
/* Readline data structures. */
|
||||
|
||||
/* Maintaining the state of undo. We remember individual deletes and inserts
|
||||
on a chain of things to do. */
|
||||
|
||||
/* The actions that undo knows how to undo. Notice that UNDO_DELETE means
|
||||
to insert some text, and UNDO_INSERT means to delete some text. I.e.,
|
||||
the code tells undo what to undo, not how to undo it. */
|
||||
enum undo_code { UNDO_DELETE, UNDO_INSERT, UNDO_BEGIN, UNDO_END };
|
||||
|
||||
/* What an element of THE_UNDO_LIST looks like. */
|
||||
typedef struct undo_list {
|
||||
struct undo_list *next;
|
||||
int start, end; /* Where the change took place. */
|
||||
char *text; /* The text to insert, if undoing a delete. */
|
||||
enum undo_code what; /* Delete, Insert, Begin, End. */
|
||||
} UNDO_LIST;
|
||||
|
||||
/* The current undo list for RL_LINE_BUFFER. */
|
||||
extern UNDO_LIST *rl_undo_list;
|
||||
|
||||
/* The data structure for mapping textual names to code addresses. */
|
||||
typedef struct _funmap {
|
||||
const char *name;
|
||||
rl_command_func_t *function;
|
||||
} FUNMAP;
|
||||
|
||||
extern FUNMAP **funmap;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Functions available to bind to key sequences */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Bindable commands for numeric arguments. */
|
||||
extern int rl_digit_argument PARAMS((int, int));
|
||||
extern int rl_universal_argument PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for moving the cursor. */
|
||||
extern int rl_forward_byte PARAMS((int, int));
|
||||
extern int rl_forward_char PARAMS((int, int));
|
||||
extern int rl_forward PARAMS((int, int));
|
||||
extern int rl_backward_byte PARAMS((int, int));
|
||||
extern int rl_backward_char PARAMS((int, int));
|
||||
extern int rl_backward PARAMS((int, int));
|
||||
extern int rl_beg_of_line PARAMS((int, int));
|
||||
extern int rl_end_of_line PARAMS((int, int));
|
||||
extern int rl_forward_word PARAMS((int, int));
|
||||
extern int rl_backward_word PARAMS((int, int));
|
||||
extern int rl_refresh_line PARAMS((int, int));
|
||||
extern int rl_clear_screen PARAMS((int, int));
|
||||
extern int rl_arrow_keys PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for inserting and deleting text. */
|
||||
extern int rl_insert PARAMS((int, int));
|
||||
extern int rl_quoted_insert PARAMS((int, int));
|
||||
extern int rl_tab_insert PARAMS((int, int));
|
||||
extern int rl_newline PARAMS((int, int));
|
||||
extern int rl_do_lowercase_version PARAMS((int, int));
|
||||
extern int rl_rubout PARAMS((int, int));
|
||||
extern int rl_delete PARAMS((int, int));
|
||||
extern int rl_rubout_or_delete PARAMS((int, int));
|
||||
extern int rl_delete_horizontal_space PARAMS((int, int));
|
||||
extern int rl_delete_or_show_completions PARAMS((int, int));
|
||||
extern int rl_insert_comment PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for changing case. */
|
||||
extern int rl_upcase_word PARAMS((int, int));
|
||||
extern int rl_downcase_word PARAMS((int, int));
|
||||
extern int rl_capitalize_word PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for transposing characters and words. */
|
||||
extern int rl_transpose_words PARAMS((int, int));
|
||||
extern int rl_transpose_chars PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for searching within a line. */
|
||||
extern int rl_char_search PARAMS((int, int));
|
||||
extern int rl_backward_char_search PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for readline's interface to the command history. */
|
||||
extern int rl_beginning_of_history PARAMS((int, int));
|
||||
extern int rl_end_of_history PARAMS((int, int));
|
||||
extern int rl_get_next_history PARAMS((int, int));
|
||||
extern int rl_get_previous_history PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for managing the mark and region. */
|
||||
extern int rl_set_mark PARAMS((int, int));
|
||||
extern int rl_exchange_point_and_mark PARAMS((int, int));
|
||||
|
||||
/* Bindable commands to set the editing mode (emacs or vi). */
|
||||
extern int rl_vi_editing_mode PARAMS((int, int));
|
||||
extern int rl_emacs_editing_mode PARAMS((int, int));
|
||||
|
||||
/* Bindable commands to change the insert mode (insert or overwrite) */
|
||||
extern int rl_overwrite_mode PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for managing key bindings. */
|
||||
extern int rl_re_read_init_file PARAMS((int, int));
|
||||
extern int rl_dump_functions PARAMS((int, int));
|
||||
extern int rl_dump_macros PARAMS((int, int));
|
||||
extern int rl_dump_variables PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for word completion. */
|
||||
extern int rl_complete PARAMS((int, int));
|
||||
extern int rl_possible_completions PARAMS((int, int));
|
||||
extern int rl_insert_completions PARAMS((int, int));
|
||||
extern int rl_menu_complete PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for killing and yanking text, and managing the kill ring. */
|
||||
extern int rl_kill_word PARAMS((int, int));
|
||||
extern int rl_backward_kill_word PARAMS((int, int));
|
||||
extern int rl_kill_line PARAMS((int, int));
|
||||
extern int rl_backward_kill_line PARAMS((int, int));
|
||||
extern int rl_kill_full_line PARAMS((int, int));
|
||||
extern int rl_unix_word_rubout PARAMS((int, int));
|
||||
extern int rl_unix_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));
|
||||
extern int rl_copy_forward_word PARAMS((int, int));
|
||||
extern int rl_copy_backward_word PARAMS((int, int));
|
||||
extern int rl_yank PARAMS((int, int));
|
||||
extern int rl_yank_pop PARAMS((int, int));
|
||||
extern int rl_yank_nth_arg PARAMS((int, int));
|
||||
extern int rl_yank_last_arg PARAMS((int, int));
|
||||
/* Not available unless __CYGWIN__ is defined. */
|
||||
#ifdef __CYGWIN__
|
||||
extern int rl_paste_from_clipboard PARAMS((int, int));
|
||||
#endif
|
||||
|
||||
/* Bindable commands for incremental searching. */
|
||||
extern int rl_reverse_search_history PARAMS((int, int));
|
||||
extern int rl_forward_search_history PARAMS((int, int));
|
||||
|
||||
/* Bindable keyboard macro commands. */
|
||||
extern int rl_start_kbd_macro PARAMS((int, int));
|
||||
extern int rl_end_kbd_macro PARAMS((int, int));
|
||||
extern int rl_call_last_kbd_macro PARAMS((int, int));
|
||||
|
||||
/* Bindable undo commands. */
|
||||
extern int rl_revert_line PARAMS((int, int));
|
||||
extern int rl_undo_command PARAMS((int, int));
|
||||
|
||||
/* Bindable tilde expansion commands. */
|
||||
extern int rl_tilde_expand PARAMS((int, int));
|
||||
|
||||
/* Bindable terminal control commands. */
|
||||
extern int rl_restart_output PARAMS((int, int));
|
||||
extern int rl_stop_output PARAMS((int, int));
|
||||
|
||||
/* Miscellaneous bindable commands. */
|
||||
extern int rl_abort PARAMS((int, int));
|
||||
extern int rl_tty_status PARAMS((int, int));
|
||||
|
||||
/* Bindable commands for incremental and non-incremental history searching. */
|
||||
extern int rl_history_search_forward PARAMS((int, int));
|
||||
extern int rl_history_search_backward PARAMS((int, int));
|
||||
extern int rl_noninc_forward_search PARAMS((int, int));
|
||||
extern int rl_noninc_reverse_search PARAMS((int, int));
|
||||
extern int rl_noninc_forward_search_again PARAMS((int, int));
|
||||
extern int rl_noninc_reverse_search_again PARAMS((int, int));
|
||||
|
||||
/* Bindable command used when inserting a matching close character. */
|
||||
extern int rl_insert_close PARAMS((int, int));
|
||||
|
||||
/* Not available unless READLINE_CALLBACKS is defined. */
|
||||
extern void rl_callback_handler_install PARAMS((const char *, rl_vcpfunc_t *));
|
||||
extern void rl_callback_read_char PARAMS((void));
|
||||
extern void rl_callback_handler_remove PARAMS((void));
|
||||
|
||||
/* Things for vi mode. Not available unless readline is compiled -DVI_MODE. */
|
||||
/* VI-mode bindable commands. */
|
||||
extern int rl_vi_redo PARAMS((int, int));
|
||||
extern int rl_vi_undo PARAMS((int, int));
|
||||
extern int rl_vi_yank_arg PARAMS((int, int));
|
||||
extern int rl_vi_fetch_history PARAMS((int, int));
|
||||
extern int rl_vi_search_again PARAMS((int, int));
|
||||
extern int rl_vi_search PARAMS((int, int));
|
||||
extern int rl_vi_complete PARAMS((int, int));
|
||||
extern int rl_vi_tilde_expand PARAMS((int, int));
|
||||
extern int rl_vi_prev_word PARAMS((int, int));
|
||||
extern int rl_vi_next_word PARAMS((int, int));
|
||||
extern int rl_vi_end_word PARAMS((int, int));
|
||||
extern int rl_vi_insert_beg PARAMS((int, int));
|
||||
extern int rl_vi_append_mode PARAMS((int, int));
|
||||
extern int rl_vi_append_eol PARAMS((int, int));
|
||||
extern int rl_vi_eof_maybe PARAMS((int, int));
|
||||
extern int rl_vi_insertion_mode PARAMS((int, int));
|
||||
extern int rl_vi_movement_mode PARAMS((int, int));
|
||||
extern int rl_vi_arg_digit PARAMS((int, int));
|
||||
extern int rl_vi_change_case PARAMS((int, int));
|
||||
extern int rl_vi_put PARAMS((int, int));
|
||||
extern int rl_vi_column PARAMS((int, int));
|
||||
extern int rl_vi_delete_to PARAMS((int, int));
|
||||
extern int rl_vi_change_to PARAMS((int, int));
|
||||
extern int rl_vi_yank_to PARAMS((int, int));
|
||||
extern int rl_vi_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));
|
||||
extern int rl_vi_char_search PARAMS((int, int));
|
||||
extern int rl_vi_match PARAMS((int, int));
|
||||
extern int rl_vi_change_char PARAMS((int, int));
|
||||
extern int rl_vi_subst PARAMS((int, int));
|
||||
extern int rl_vi_overstrike PARAMS((int, int));
|
||||
extern int rl_vi_overstrike_delete PARAMS((int, int));
|
||||
extern int rl_vi_replace PARAMS((int, int));
|
||||
extern int rl_vi_set_mark PARAMS((int, int));
|
||||
extern int rl_vi_goto_mark PARAMS((int, int));
|
||||
|
||||
/* VI-mode utility functions. */
|
||||
extern int rl_vi_check 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));
|
||||
extern int rl_vi_eWord PARAMS((int, int));
|
||||
extern int rl_vi_fword PARAMS((int, int));
|
||||
extern int rl_vi_bword PARAMS((int, int));
|
||||
extern int rl_vi_eword PARAMS((int, int));
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Well Published Functions */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* Readline functions. */
|
||||
/* Read a line of input. Prompt with PROMPT. A NULL PROMPT means none. */
|
||||
extern char *readline PARAMS((const char *));
|
||||
|
||||
extern int rl_set_prompt PARAMS((const char *));
|
||||
extern int rl_expand_prompt PARAMS((char *));
|
||||
|
||||
extern int rl_initialize PARAMS((void));
|
||||
|
||||
/* Undocumented; unused by readline */
|
||||
extern int rl_discard_argument PARAMS((void));
|
||||
|
||||
/* Utility functions to bind keys to readline commands. */
|
||||
extern int rl_add_defun PARAMS((const char *, rl_command_func_t *, int));
|
||||
extern int rl_bind_key PARAMS((int, rl_command_func_t *));
|
||||
extern int rl_bind_key_in_map PARAMS((int, rl_command_func_t *, Keymap));
|
||||
extern int rl_unbind_key PARAMS((int));
|
||||
extern int rl_unbind_key_in_map PARAMS((int, Keymap));
|
||||
extern int rl_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_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));
|
||||
|
||||
/* Undocumented in the texinfo manual; not really useful to programs. */
|
||||
extern int rl_translate_keyseq PARAMS((const char *, char *, int *));
|
||||
extern char *rl_untranslate_keyseq PARAMS((int));
|
||||
|
||||
extern rl_command_func_t *rl_named_function PARAMS((const char *));
|
||||
extern rl_command_func_t *rl_function_of_keyseq PARAMS((const char *, Keymap, int *));
|
||||
|
||||
extern void rl_list_funmap_names PARAMS((void));
|
||||
extern char **rl_invoking_keyseqs_in_map PARAMS((rl_command_func_t *, Keymap));
|
||||
extern char **rl_invoking_keyseqs PARAMS((rl_command_func_t *));
|
||||
|
||||
extern void rl_function_dumper PARAMS((int));
|
||||
extern void rl_macro_dumper PARAMS((int));
|
||||
extern void rl_variable_dumper PARAMS((int));
|
||||
|
||||
extern int rl_read_init_file PARAMS((const char *));
|
||||
extern int rl_parse_and_bind PARAMS((char *));
|
||||
|
||||
/* Functions for manipulating keymaps. */
|
||||
extern Keymap rl_make_bare_keymap PARAMS((void));
|
||||
extern Keymap rl_copy_keymap PARAMS((Keymap));
|
||||
extern Keymap rl_make_keymap PARAMS((void));
|
||||
extern void rl_discard_keymap PARAMS((Keymap));
|
||||
|
||||
extern Keymap rl_get_keymap_by_name PARAMS((const char *));
|
||||
extern char *rl_get_keymap_name PARAMS((Keymap));
|
||||
extern void rl_set_keymap PARAMS((Keymap));
|
||||
extern Keymap rl_get_keymap PARAMS((void));
|
||||
/* Undocumented; used internally only. */
|
||||
extern void rl_set_keymap_from_edit_mode PARAMS((void));
|
||||
extern char *rl_get_keymap_name_from_edit_mode PARAMS((void));
|
||||
|
||||
/* Functions for manipulating the funmap, which maps command names to functions. */
|
||||
extern int rl_add_funmap_entry PARAMS((const char *, rl_command_func_t *));
|
||||
extern const char **rl_funmap_names PARAMS((void));
|
||||
/* Undocumented, only used internally -- there is only one funmap, and this
|
||||
function may be called only once. */
|
||||
extern void rl_initialize_funmap PARAMS((void));
|
||||
|
||||
/* Utility functions for managing keyboard macros. */
|
||||
extern void rl_push_macro_input PARAMS((char *));
|
||||
|
||||
/* Functions for undoing, from undo.c */
|
||||
extern void rl_add_undo PARAMS((enum undo_code, int, int, char *));
|
||||
extern void rl_free_undo_list PARAMS((void));
|
||||
extern int rl_do_undo PARAMS((void));
|
||||
extern int rl_begin_undo_group PARAMS((void));
|
||||
extern int rl_end_undo_group PARAMS((void));
|
||||
extern int rl_modifying PARAMS((int, int));
|
||||
|
||||
/* Functions for redisplay. */
|
||||
extern void rl_redisplay PARAMS((void));
|
||||
extern int rl_on_new_line PARAMS((void));
|
||||
extern int rl_on_new_line_with_prompt PARAMS((void));
|
||||
extern int rl_forced_update_display PARAMS((void));
|
||||
extern int rl_clear_message PARAMS((void));
|
||||
extern int rl_reset_line_state PARAMS((void));
|
||||
extern int rl_crlf PARAMS((void));
|
||||
|
||||
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
|
||||
extern int rl_message (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
|
||||
#else
|
||||
extern int rl_message ();
|
||||
#endif
|
||||
|
||||
extern int rl_show_char PARAMS((int));
|
||||
|
||||
/* Undocumented in texinfo manual. */
|
||||
extern int rl_character_len PARAMS((int, int));
|
||||
|
||||
/* Save and restore internal prompt redisplay information. */
|
||||
extern void rl_save_prompt PARAMS((void));
|
||||
extern void rl_restore_prompt PARAMS((void));
|
||||
|
||||
/* Modifying text. */
|
||||
extern void rl_replace_line PARAMS((const char *, int));
|
||||
extern int rl_insert_text PARAMS((const char *));
|
||||
extern int rl_delete_text PARAMS((int, int));
|
||||
extern int rl_kill_text PARAMS((int, int));
|
||||
extern char *rl_copy_text PARAMS((int, int));
|
||||
|
||||
/* Terminal and tty mode management. */
|
||||
extern void rl_prep_terminal 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 *));
|
||||
|
||||
/* Functions for character input. */
|
||||
extern int rl_stuff_char PARAMS((int));
|
||||
extern int rl_execute_next PARAMS((int));
|
||||
extern int rl_clear_pending_input PARAMS((void));
|
||||
extern int rl_read_key PARAMS((void));
|
||||
extern int rl_getc PARAMS((FILE *));
|
||||
extern int rl_set_keyboard_input_timeout PARAMS((int));
|
||||
|
||||
/* `Public' utility functions . */
|
||||
extern void rl_extend_line_buffer PARAMS((int));
|
||||
extern int rl_ding PARAMS((void));
|
||||
extern int rl_alphabetic PARAMS((int));
|
||||
|
||||
/* Readline signal handling, from signals.c */
|
||||
extern int rl_set_signals PARAMS((void));
|
||||
extern int rl_clear_signals PARAMS((void));
|
||||
extern void rl_cleanup_after_signal PARAMS((void));
|
||||
extern void rl_reset_after_signal PARAMS((void));
|
||||
extern void rl_free_line_state PARAMS((void));
|
||||
|
||||
extern int rl_set_paren_blink_timeout PARAMS((int));
|
||||
|
||||
/* Undocumented. */
|
||||
extern int rl_maybe_save_line PARAMS((void));
|
||||
extern int rl_maybe_unsave_line PARAMS((void));
|
||||
extern int rl_maybe_replace_line PARAMS((void));
|
||||
|
||||
/* Completion functions. */
|
||||
extern int rl_complete_internal PARAMS((int));
|
||||
extern void rl_display_match_list PARAMS((char **, int, int));
|
||||
|
||||
extern char **rl_completion_matches PARAMS((const char *, rl_compentry_func_t *));
|
||||
extern char *rl_username_completion_function PARAMS((const char *, int));
|
||||
extern char *rl_filename_completion_function PARAMS((const char *, int));
|
||||
|
||||
extern int rl_completion_mode PARAMS((rl_command_func_t *));
|
||||
|
||||
#if 0
|
||||
/* Backwards compatibility (compat.c). These will go away sometime. */
|
||||
extern void free_undo_list PARAMS((void));
|
||||
extern int maybe_save_line PARAMS((void));
|
||||
extern int maybe_unsave_line PARAMS((void));
|
||||
extern int maybe_replace_line PARAMS((void));
|
||||
|
||||
extern int ding PARAMS((void));
|
||||
extern int alphabetic PARAMS((int));
|
||||
extern int crlf PARAMS((void));
|
||||
|
||||
extern char **completion_matches PARAMS((char *, rl_compentry_func_t *));
|
||||
extern char *username_completion_function PARAMS((const char *, int));
|
||||
extern char *filename_completion_function PARAMS((const char *, int));
|
||||
#endif
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Well Published Variables */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
/* The version of this incarnation of the readline library. */
|
||||
extern const char *rl_library_version; /* e.g., "4.2" */
|
||||
extern int rl_readline_version; /* e.g., 0x0402 */
|
||||
|
||||
/* True if this is real GNU readline. */
|
||||
extern int rl_gnu_readline_p;
|
||||
|
||||
/* Flags word encapsulating the current readline state. */
|
||||
extern int rl_readline_state;
|
||||
|
||||
/* Says which editing mode readline is currently using. 1 means emacs mode;
|
||||
0 means vi mode. */
|
||||
extern int rl_editing_mode;
|
||||
|
||||
/* Insert or overwrite mode for emacs mode. 1 means insert mode; 0 means
|
||||
overwrite mode. Reset to insert mode on each input line. */
|
||||
extern int rl_insert_mode;
|
||||
|
||||
/* The name of the calling program. You should initialize this to
|
||||
whatever was in argv[0]. It is used when parsing conditionals. */
|
||||
extern const char *rl_readline_name;
|
||||
|
||||
/* The prompt readline uses. This is set from the argument to
|
||||
readline (), and should not be assigned to directly. */
|
||||
extern char *rl_prompt;
|
||||
|
||||
/* The line buffer that is in use. */
|
||||
extern char *rl_line_buffer;
|
||||
|
||||
/* The location of point, and end. */
|
||||
extern int rl_point;
|
||||
extern int rl_end;
|
||||
|
||||
/* The mark, or saved cursor position. */
|
||||
extern int rl_mark;
|
||||
|
||||
/* Flag to indicate that readline has finished with the current input
|
||||
line and should return it. */
|
||||
extern int rl_done;
|
||||
|
||||
/* If set to a character value, that will be the next keystroke read. */
|
||||
extern int rl_pending_input;
|
||||
|
||||
/* Non-zero if we called this function from _rl_dispatch(). It's present
|
||||
so functions can find out whether they were called from a key binding
|
||||
or directly from an application. */
|
||||
extern int rl_dispatching;
|
||||
|
||||
/* Non-zero if the user typed a numeric argument before executing the
|
||||
current function. */
|
||||
extern int rl_explicit_arg;
|
||||
|
||||
/* The current value of the numeric argument specified by the user. */
|
||||
extern int rl_numeric_arg;
|
||||
|
||||
/* The address of the last command function Readline executed. */
|
||||
extern rl_command_func_t *rl_last_func;
|
||||
|
||||
/* The name of the terminal to use. */
|
||||
extern const char *rl_terminal_name;
|
||||
|
||||
/* The input and output streams. */
|
||||
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;
|
||||
|
||||
/* If non-zero, this is the address of a function to call just before
|
||||
readline_internal_setup () returns and readline_internal starts
|
||||
reading input characters. */
|
||||
extern rl_hook_func_t *rl_pre_input_hook;
|
||||
|
||||
/* The address of a function to call periodically while Readline is
|
||||
awaiting character input, or NULL, for no event handling. */
|
||||
extern rl_hook_func_t *rl_event_hook;
|
||||
|
||||
/* The address of the function to call to fetch a character from the current
|
||||
Readline input stream */
|
||||
extern rl_getc_func_t *rl_getc_function;
|
||||
|
||||
extern rl_voidfunc_t *rl_redisplay_function;
|
||||
|
||||
extern rl_vintfunc_t *rl_prep_term_function;
|
||||
extern rl_voidfunc_t *rl_deprep_term_function;
|
||||
|
||||
/* Dispatch variables. */
|
||||
extern Keymap rl_executing_keymap;
|
||||
extern Keymap rl_binding_keymap;
|
||||
|
||||
/* Display variables. */
|
||||
/* If non-zero, readline will erase the entire line, including any prompt,
|
||||
if the only thing typed on an otherwise-blank line is something bound to
|
||||
rl_newline. */
|
||||
extern int rl_erase_empty_line;
|
||||
|
||||
/* If non-zero, the application has already printed the prompt (rl_prompt)
|
||||
before calling readline, so readline should not output it the first time
|
||||
redisplay is done. */
|
||||
extern int rl_already_prompted;
|
||||
|
||||
/* A non-zero value means to read only this many characters rather than
|
||||
up to a character bound to accept-line. */
|
||||
extern int rl_num_chars_to_read;
|
||||
|
||||
/* The text of a currently-executing keyboard macro. */
|
||||
extern char *rl_executing_macro;
|
||||
|
||||
/* Variables to control readline signal handling. */
|
||||
/* If non-zero, readline will install its own signal handlers for
|
||||
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
|
||||
extern int rl_catch_signals;
|
||||
|
||||
/* If non-zero, readline will install a signal handler for SIGWINCH
|
||||
that also attempts to call any calling application's SIGWINCH signal
|
||||
handler. Note that the terminal is not cleaned up before the
|
||||
application's signal handler is called; use rl_cleanup_after_signal()
|
||||
to do that. */
|
||||
extern int rl_catch_sigwinch;
|
||||
|
||||
/* Completion variables. */
|
||||
/* Pointer to the generator function for completion_matches ().
|
||||
NULL means to use rl_filename_completion_function (), the default
|
||||
filename completer. */
|
||||
extern rl_compentry_func_t *rl_completion_entry_function;
|
||||
|
||||
/* If rl_ignore_some_completions_function is non-NULL it is the address
|
||||
of a function to call after all of the possible matches have been
|
||||
generated, but before the actual completion is done to the input line.
|
||||
The function is called with one argument; a NULL terminated array
|
||||
of (char *). If your function removes any of the elements, they
|
||||
must be free()'ed. */
|
||||
extern rl_compignore_func_t *rl_ignore_some_completions_function;
|
||||
|
||||
/* Pointer to alternative function to create matches.
|
||||
Function is called with TEXT, START, and END.
|
||||
START and END are indices in RL_LINE_BUFFER saying what the boundaries
|
||||
of TEXT are.
|
||||
If this function exists and returns NULL then call the value of
|
||||
rl_completion_entry_function to try to match, otherwise use the
|
||||
array of strings returned. */
|
||||
extern rl_completion_func_t *rl_attempted_completion_function;
|
||||
|
||||
/* The basic list of characters that signal a break between words for the
|
||||
completer routine. The initial contents of this variable is what
|
||||
breaks words in the shell, i.e. "n\"\\'`@$>". */
|
||||
extern 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;
|
||||
|
||||
/* 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
|
||||
rl_completer_word_break_characters are treated as any other character,
|
||||
unless they also appear within this list. */
|
||||
extern const char *rl_completer_quote_characters;
|
||||
|
||||
/* List of quote characters which cause a word break. */
|
||||
extern const char *rl_basic_quote_characters;
|
||||
|
||||
/* List of characters that need to be quoted in filenames by the completer. */
|
||||
extern const char *rl_filename_quote_characters;
|
||||
|
||||
/* List of characters that are word break characters, but should be left
|
||||
in TEXT when it is passed to the completion function. The shell uses
|
||||
this to help determine what kind of completing to do. */
|
||||
extern const char *rl_special_prefixes;
|
||||
|
||||
/* If non-zero, then this is the address of a function to call when
|
||||
completing on a directory name. The function is called with
|
||||
the address of a string (the current directory name) as an arg. It
|
||||
changes what is displayed when the possible completions are printed
|
||||
or inserted. */
|
||||
extern rl_icppfunc_t *rl_directory_completion_hook;
|
||||
|
||||
/* If non-zero, this is the address of a function to call when completing
|
||||
a directory name. This function takes the address of the directory name
|
||||
to be modified as an argument. Unlike rl_directory_completion_hook, it
|
||||
only modifies the directory name used in opendir(2), not what is displayed
|
||||
when the possible completions are printed or inserted. It is called
|
||||
before rl_directory_completion_hook. I'm not happy with how this works
|
||||
yet, so it's undocumented. */
|
||||
extern rl_icppfunc_t *rl_directory_rewrite_hook;
|
||||
|
||||
/* Backwards compatibility with previous versions of readline. */
|
||||
#define rl_symbolic_link_hook rl_directory_completion_hook
|
||||
|
||||
/* 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.
|
||||
This function is called instead of actually doing the display.
|
||||
It takes three arguments: (char **matches, int num_matches, int max_length)
|
||||
where MATCHES is the array of strings that matched, NUM_MATCHES is the
|
||||
number of strings in that array, and MAX_LENGTH is the length of the
|
||||
longest string in that array. */
|
||||
extern rl_compdisp_func_t *rl_completion_display_matches_hook;
|
||||
|
||||
/* Non-zero means that the results of the matches are to be treated
|
||||
as filenames. This is ALWAYS zero on entry, and can only be changed
|
||||
within a completion entry finder function. */
|
||||
extern int rl_filename_completion_desired;
|
||||
|
||||
/* Non-zero means that the results of the matches are to be quoted using
|
||||
double quotes (or an application-specific quoting mechanism) if the
|
||||
filename contains any characters in rl_word_break_chars. This is
|
||||
ALWAYS non-zero on entry, and can only be changed within a completion
|
||||
entry finder function. */
|
||||
extern int rl_filename_quoting_desired;
|
||||
|
||||
/* Set to a function to quote a filename in an application-specific fashion.
|
||||
Called with the text to quote, the type of match found (single or multiple)
|
||||
and a pointer to the quoting character to be used, which the function can
|
||||
reset if desired. */
|
||||
extern rl_quote_func_t *rl_filename_quoting_function;
|
||||
|
||||
/* Function to call to remove quoting characters from a filename. Called
|
||||
before completion is attempted, so the embedded quotes do not interfere
|
||||
with matching names in the file system. */
|
||||
extern rl_dequote_func_t *rl_filename_dequoting_function;
|
||||
|
||||
/* Function to call to decide whether or not a word break character is
|
||||
quoted. If a character is quoted, it does not break words for the
|
||||
completer. */
|
||||
extern rl_linebuf_func_t *rl_char_is_quoted_p;
|
||||
|
||||
/* Non-zero means to suppress normal filename completion after the
|
||||
user-specified completion function has been called. */
|
||||
extern int rl_attempted_completion_over;
|
||||
|
||||
/* Set to a character describing the type of completion being attempted by
|
||||
rl_complete_internal; available for use by application completion
|
||||
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;
|
||||
|
||||
/* If set to non-zero by an application completion function,
|
||||
rl_completion_append_character will not be appended. */
|
||||
extern int rl_completion_suppress_append;
|
||||
|
||||
/* 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
|
||||
mark-directories variable (which is user-settable). This exists so
|
||||
that application completion functions can override the user's preference
|
||||
(set via the mark-symlinked-directories variable) if appropriate.
|
||||
It's set to the value of _rl_complete_mark_symlink_dirs in
|
||||
rl_complete_internal before any application-specific completion
|
||||
function is called, so without that function doing anything, the user's
|
||||
preferences are honored. */
|
||||
extern int rl_completion_mark_symlink_dirs;
|
||||
|
||||
/* If non-zero, then disallow duplicates in the matches. */
|
||||
extern int rl_ignore_completion_duplicates;
|
||||
|
||||
/* If this is non-zero, completion is (temporarily) inhibited, and the
|
||||
completion character will be inserted as any other. */
|
||||
extern int rl_inhibit_completion;
|
||||
|
||||
/* Definitions available for use by readline clients. */
|
||||
#define RL_PROMPT_START_IGNORE '\001'
|
||||
#define RL_PROMPT_END_IGNORE '\002'
|
||||
|
||||
/* Possible values for do_replace argument to rl_filename_quoting_function,
|
||||
called by rl_complete_internal. */
|
||||
#define NO_MATCH 0
|
||||
#define SINGLE_MATCH 1
|
||||
#define MULT_MATCH 2
|
||||
|
||||
/* Possible state values for rl_readline_state */
|
||||
#define RL_STATE_NONE 0x000000 /* no state; before first call */
|
||||
|
||||
#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 0x800000 /* done; accepted line */
|
||||
|
||||
#define RL_SETSTATE(x) (rl_readline_state |= (x))
|
||||
#define RL_UNSETSTATE(x) (rl_readline_state &= ~(x))
|
||||
#define RL_ISSTATE(x) (rl_readline_state & (x))
|
||||
|
||||
struct readline_state {
|
||||
/* line state */
|
||||
int point;
|
||||
int end;
|
||||
int mark;
|
||||
char *buffer;
|
||||
int buflen;
|
||||
UNDO_LIST *ul;
|
||||
char *prompt;
|
||||
|
||||
/* global state */
|
||||
int rlstate;
|
||||
int done;
|
||||
Keymap kmap;
|
||||
|
||||
/* input state */
|
||||
rl_command_func_t *lastfunc;
|
||||
int insmode;
|
||||
int edmode;
|
||||
int kseqlen;
|
||||
FILE *inf;
|
||||
FILE *outf;
|
||||
int pendingin;
|
||||
char *macro;
|
||||
|
||||
/* signal state */
|
||||
int catchsigs;
|
||||
int catchsigwinch;
|
||||
|
||||
/* search state */
|
||||
|
||||
/* completion state */
|
||||
|
||||
/* options state */
|
||||
|
||||
/* reserved for future expansion, so the struct size doesn't change */
|
||||
char reserved[64];
|
||||
};
|
||||
|
||||
extern int rl_save_state PARAMS((struct readline_state *));
|
||||
extern int rl_restore_state PARAMS((struct readline_state *));
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _READLINE_H_ */
|
60
extern/editline/rlconf.h
vendored
60
extern/editline/rlconf.h
vendored
@ -1,60 +0,0 @@
|
||||
/* rlconf.h -- readline configuration definitions */
|
||||
|
||||
/* Copyright (C) 1994 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
|
||||
for it.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_RLCONF_H_)
|
||||
#define _RLCONF_H_
|
||||
|
||||
/* Define this if you want the vi-mode editing available. */
|
||||
#define VI_MODE
|
||||
|
||||
/* Define this to get an indication of file type when listing completions. */
|
||||
#define VISIBLE_STATS
|
||||
|
||||
/* This definition is needed by readline.c, rltty.c, and signals.c. */
|
||||
/* If on, then readline handles signals in a way that doesn't screw. */
|
||||
#define HANDLE_SIGNALS
|
||||
|
||||
/* Ugly but working hack for binding prefix meta. */
|
||||
#define PREFIX_META_HACK
|
||||
|
||||
/* The final, last-ditch effort file name for an init file. */
|
||||
#define DEFAULT_INPUTRC "~/.inputrc"
|
||||
|
||||
/* If defined, expand tabs to spaces. */
|
||||
#define DISPLAY_TABS
|
||||
|
||||
/* If defined, use the terminal escape sequence to move the cursor forward
|
||||
over a character when updating the line rather than rewriting it. */
|
||||
/* #define HACK_TERMCAP_MOTION */
|
||||
|
||||
/* The string inserted by the `insert comment' command. */
|
||||
#define RL_COMMENT_BEGIN_DEFAULT "#"
|
||||
|
||||
/* Define this if you want code that allows readline to be used in an
|
||||
X `callback' style. */
|
||||
#define READLINE_CALLBACKS
|
||||
|
||||
/* Define this if you want the cursor to indicate insert or overwrite mode. */
|
||||
/* #define CURSOR_MODE */
|
||||
|
||||
#endif /* _RLCONF_H_ */
|
160
extern/editline/rldefs.h
vendored
160
extern/editline/rldefs.h
vendored
@ -1,160 +0,0 @@
|
||||
/* rldefs.h -- an attempt to isolate some of the system-specific defines
|
||||
for readline. This should be included after any files that define
|
||||
system-specific constants like _POSIX_VERSION or USG. */
|
||||
|
||||
/* 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
|
||||
for it.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_RLDEFS_H_)
|
||||
#define _RLDEFS_H_
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "rlstdc.h"
|
||||
|
||||
#if defined (_POSIX_VERSION) && !defined (TERMIOS_MISSING)
|
||||
# define TERMIOS_TTY_DRIVER
|
||||
#else
|
||||
# if defined (HAVE_TERMIO_H)
|
||||
# define TERMIO_TTY_DRIVER
|
||||
# else
|
||||
# if !defined (__MINGW32__)
|
||||
# define NEW_TTY_DRIVER
|
||||
# else
|
||||
# define NO_TTY_DRIVER
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Posix macro to check file in statbuf for directory-ness.
|
||||
This requires that <sys/stat.h> be included before this test. */
|
||||
#if defined (S_IFDIR) && !defined (S_ISDIR)
|
||||
# define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
|
||||
#endif
|
||||
|
||||
/* Decide which flavor of the header file describing the C library
|
||||
string functions to include and include it. */
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else /* !HAVE_STRING_H */
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if !defined (strchr) && !defined (__STDC__)
|
||||
extern char *strchr (), *strrchr ();
|
||||
#endif /* !strchr && !__STDC__ */
|
||||
|
||||
#if defined (PREFER_STDARG)
|
||||
# include <stdarg.h>
|
||||
#else
|
||||
# if defined (PREFER_VARARGS)
|
||||
# include <varargs.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STRCASECMP)
|
||||
#define _rl_stricmp strcasecmp
|
||||
#define _rl_strnicmp strncasecmp
|
||||
#else
|
||||
extern int _rl_stricmp PARAMS((char *, char *));
|
||||
extern int _rl_strnicmp PARAMS((char *, char *, int));
|
||||
#endif
|
||||
|
||||
#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 *));
|
||||
#endif
|
||||
|
||||
#if !defined (emacs_mode)
|
||||
# define no_mode -1
|
||||
# define vi_mode 0
|
||||
# define emacs_mode 1
|
||||
#endif
|
||||
|
||||
#if !defined (RL_IM_INSERT)
|
||||
# define RL_IM_INSERT 1
|
||||
# define RL_IM_OVERWRITE 0
|
||||
#
|
||||
# define RL_IM_DEFAULT RL_IM_INSERT
|
||||
#endif
|
||||
|
||||
/* If you cast map[key].function to type (Keymap) on a Cray,
|
||||
the compiler takes the value of map[key].function and
|
||||
divides it by 4 to convert between pointer types (pointers
|
||||
to functions and pointers to structs are different sizes).
|
||||
This is not what is wanted. */
|
||||
#if defined (CRAY)
|
||||
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)((int)map[key].function)
|
||||
# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)((int)(data))
|
||||
#else
|
||||
# define FUNCTION_TO_KEYMAP(map, key) (Keymap)(map[key].function)
|
||||
# define KEYMAP_TO_FUNCTION(data) (rl_command_func_t *)(data)
|
||||
#endif
|
||||
|
||||
#ifndef savestring
|
||||
#define savestring(x) strcpy ((char *)xmalloc (1 + strlen (x)), (x))
|
||||
#endif
|
||||
|
||||
/* Possible values for _rl_bell_preference. */
|
||||
#define NO_BELL 0
|
||||
#define AUDIBLE_BELL 1
|
||||
#define VISIBLE_BELL 2
|
||||
|
||||
/* Definitions used when searching the line for characters. */
|
||||
/* NOTE: it is necessary that opposite directions are inverses */
|
||||
#define FTO 1 /* forward to */
|
||||
#define BTO -1 /* backward to */
|
||||
#define FFIND 2 /* forward find */
|
||||
#define BFIND -2 /* backward find */
|
||||
|
||||
/* Possible values for the found_quote flags word used by the completion
|
||||
functions. It says what kind of (shell-like) quoting we found anywhere
|
||||
in the line. */
|
||||
#define RL_QF_SINGLE_QUOTE 0x01
|
||||
#define RL_QF_DOUBLE_QUOTE 0x02
|
||||
#define RL_QF_BACKSLASH 0x04
|
||||
#define RL_QF_OTHER_QUOTE 0x08
|
||||
|
||||
/* Default readline line buffer length. */
|
||||
#define DEFAULT_BUFFER_SIZE 256
|
||||
|
||||
#if !defined (STREQ)
|
||||
#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp ((a), (b)) == 0))
|
||||
#define STREQN(a, b, n) (((n) == 0) ? (1) \
|
||||
: ((a)[0] == (b)[0]) && (strncmp ((a), (b), (n)) == 0))
|
||||
#endif
|
||||
|
||||
#if !defined (FREE)
|
||||
# define FREE(x) if (x) free (x)
|
||||
#endif
|
||||
|
||||
#if !defined (SWAP)
|
||||
# define SWAP(s, e) do { int t; t = s; s = e; e = t; } while (0)
|
||||
#endif
|
||||
|
||||
/* CONFIGURATION SECTION */
|
||||
#include "rlconf.h"
|
||||
|
||||
#endif /* !_RLDEFS_H_ */
|
146
extern/editline/rlmbutil.h
vendored
146
extern/editline/rlmbutil.h
vendored
@ -1,146 +0,0 @@
|
||||
/* rlmbutil.h -- utility functions for multibyte characters. */
|
||||
|
||||
/* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_RL_MBUTIL_H_)
|
||||
#define _RL_MBUTIL_H_
|
||||
|
||||
#include "rlstdc.h"
|
||||
|
||||
/************************************************/
|
||||
/* check multibyte capability for I18N code */
|
||||
/************************************************/
|
||||
|
||||
/* For platforms which support the ISO C amendement 1 functionality we
|
||||
support user defined character classes. */
|
||||
/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
|
||||
#if defined (HAVE_WCTYPE_H) && defined (HAVE_WCHAR_H)
|
||||
# include <wchar.h>
|
||||
# include <wctype.h>
|
||||
# if defined (HAVE_MBSRTOWCS) && 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)
|
||||
# define mbsrtowcs(dest, src, len, ps) (mbsrtowcs) (dest, src, len, 0)
|
||||
# define wcrtomb(s, wc, ps) (wcrtomb) (s, wc, 0)
|
||||
# define mbrtowc(pwc, s, n, ps) (mbrtowc) (pwc, s, n, 0)
|
||||
# define mbrlen(s, n, ps) (mbrlen) (s, n, 0)
|
||||
# define mbstate_t int
|
||||
#endif
|
||||
|
||||
/* Make sure MB_LEN_MAX is at least 16 on systems that claim to be able to
|
||||
handle multibyte chars (some systems define MB_LEN_MAX as 1) */
|
||||
#ifdef HANDLE_MULTIBYTE
|
||||
# include <limits.h>
|
||||
# if defined(MB_LEN_MAX) && (MB_LEN_MAX < 16)
|
||||
# undef MB_LEN_MAX
|
||||
# endif
|
||||
# if !defined (MB_LEN_MAX)
|
||||
# define MB_LEN_MAX 16
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/************************************************/
|
||||
/* end of multibyte capability checks for I18N */
|
||||
/************************************************/
|
||||
|
||||
/*
|
||||
* Flags for _rl_find_prev_mbchar and _rl_find_next_mbchar:
|
||||
*
|
||||
* MB_FIND_ANY find any multibyte character
|
||||
* MB_FIND_NONZERO find a non-zero-width multibyte character
|
||||
*/
|
||||
|
||||
#define MB_FIND_ANY 0x00
|
||||
#define MB_FIND_NONZERO 0x01
|
||||
|
||||
extern int _rl_find_prev_mbchar PARAMS((char *, int, int));
|
||||
extern int _rl_find_next_mbchar PARAMS((char *, int, int, int));
|
||||
|
||||
#ifdef HANDLE_MULTIBYTE
|
||||
|
||||
extern int _rl_compare_chars PARAMS((char *, int, mbstate_t *, char *, int, mbstate_t *));
|
||||
extern int _rl_get_char_len PARAMS((char *, mbstate_t *));
|
||||
extern int _rl_adjust_point PARAMS((char *, int, mbstate_t *));
|
||||
|
||||
extern int _rl_read_mbchar PARAMS((char *, int));
|
||||
extern int _rl_read_mbstring PARAMS((int, char *, int));
|
||||
|
||||
extern int _rl_is_mbchar_matched PARAMS((char *, int, int, char *, int));
|
||||
|
||||
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
|
||||
#undef MB_CUR_MAX
|
||||
|
||||
#define MB_LEN_MAX 1
|
||||
#define MB_CUR_MAX 1
|
||||
|
||||
#define _rl_find_prev_mbchar(b, i, f) (((i) == 0) ? (i) : ((i) - 1))
|
||||
#define _rl_find_next_mbchar(b, i1, i2, f) ((i1) + (i2))
|
||||
|
||||
#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;
|
||||
|
||||
#endif /* _RL_MBUTIL_H_ */
|
420
extern/editline/rlprivate.h
vendored
420
extern/editline/rlprivate.h
vendored
@ -1,420 +0,0 @@
|
||||
/* rlprivate.h -- functions and variables global to the readline library,
|
||||
but not intended for use by applications. */
|
||||
|
||||
/* 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.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_RL_PRIVATE_H_)
|
||||
#define _RL_PRIVATE_H_
|
||||
|
||||
#include "rlconf.h" /* for VISIBLE_STATS */
|
||||
#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 *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Global variables undocumented in texinfo manual and not in readline.h *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* complete.c */
|
||||
extern int rl_complete_with_tilde_expansion;
|
||||
#if defined (VISIBLE_STATS)
|
||||
extern int rl_visible_stats;
|
||||
#endif /* VISIBLE_STATS */
|
||||
|
||||
/* readline.c */
|
||||
extern int rl_line_buffer_len;
|
||||
extern int rl_arg_sign;
|
||||
extern int rl_visible_prompt_length;
|
||||
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;
|
||||
|
||||
/* parens.c */
|
||||
extern int rl_blink_matching_paren;
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Global functions and variables unsed and undocumented *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* kill.c */
|
||||
extern int rl_set_retained_kills PARAMS((int));
|
||||
|
||||
/* terminal.c */
|
||||
extern void _rl_set_screen_size PARAMS((int, int));
|
||||
|
||||
/* undo.c */
|
||||
extern int _rl_fix_last_undo_of_type PARAMS((int, int, int));
|
||||
|
||||
/* util.c */
|
||||
extern char *_rl_savestring PARAMS((const char *));
|
||||
|
||||
/*************************************************************************
|
||||
* *
|
||||
* Functions and variables private to the readline library *
|
||||
* *
|
||||
*************************************************************************/
|
||||
|
||||
/* NOTE: Functions and variables prefixed with `_rl_' are
|
||||
pseudo-global: they are global so they can be shared
|
||||
between files in the readline library, but are not intended
|
||||
to be visible to readline callers. */
|
||||
|
||||
/*************************************************************************
|
||||
* Undocumented private functions *
|
||||
*************************************************************************/
|
||||
|
||||
#if defined(READLINE_CALLBACKS)
|
||||
|
||||
/* readline.c */
|
||||
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 */
|
||||
|
||||
/* complete.c */
|
||||
extern char _rl_find_completion_word PARAMS((int *, int *));
|
||||
extern void _rl_free_match_list PARAMS((char **));
|
||||
|
||||
/* display.c */
|
||||
extern char *_rl_strip_prompt PARAMS((char *));
|
||||
extern void _rl_move_cursor_relative PARAMS((int, const char *));
|
||||
extern void _rl_move_vert PARAMS((int));
|
||||
extern void _rl_save_prompt PARAMS((void));
|
||||
extern void _rl_restore_prompt PARAMS((void));
|
||||
extern char *_rl_make_prompt_for_search PARAMS((int));
|
||||
extern void _rl_erase_at_end_of_line PARAMS((int));
|
||||
extern void _rl_clear_to_eol PARAMS((int));
|
||||
extern void _rl_clear_screen PARAMS((void));
|
||||
extern void _rl_update_final PARAMS((void));
|
||||
extern void _rl_redisplay_after_sigwinch PARAMS((void));
|
||||
extern void _rl_clean_up_for_exit PARAMS((void));
|
||||
extern void _rl_erase_entire_line PARAMS((void));
|
||||
extern int _rl_current_display_line PARAMS((void));
|
||||
|
||||
/* input.c */
|
||||
extern int _rl_any_typein PARAMS((void));
|
||||
extern int _rl_input_available PARAMS((void));
|
||||
extern int _rl_input_queued PARAMS((int));
|
||||
extern void _rl_insert_typein PARAMS((int));
|
||||
extern int _rl_unget_char PARAMS((int));
|
||||
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 *));
|
||||
extern int _rl_next_macro_key PARAMS((void));
|
||||
extern void _rl_push_executing_macro PARAMS((void));
|
||||
extern void _rl_pop_executing_macro PARAMS((void));
|
||||
extern void _rl_add_macro_char PARAMS((int));
|
||||
extern void _rl_kill_kbd_macro PARAMS((void));
|
||||
|
||||
/* misc.c */
|
||||
extern int _rl_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));
|
||||
|
||||
/* nls.c */
|
||||
extern int _rl_init_eightbit PARAMS((void));
|
||||
|
||||
/* parens.c */
|
||||
extern void _rl_enable_paren_matching PARAMS((int));
|
||||
|
||||
/* readline.c */
|
||||
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 *));
|
||||
#ifdef _MINIX
|
||||
extern void _rl_output_character_function PARAMS((int));
|
||||
#else
|
||||
extern int _rl_output_character_function PARAMS((int));
|
||||
#endif
|
||||
extern void _rl_output_some_chars PARAMS((const char *, int));
|
||||
extern int _rl_backspace PARAMS((int));
|
||||
extern void _rl_enable_meta_key PARAMS((void));
|
||||
extern void _rl_control_keypad PARAMS((int));
|
||||
extern void _rl_set_cursor PARAMS((int, int));
|
||||
|
||||
/* text.c */
|
||||
extern void _rl_fix_point PARAMS((int));
|
||||
extern int _rl_replace_text PARAMS((const char *, int, int));
|
||||
extern int _rl_insert_char PARAMS((int, int));
|
||||
extern int _rl_overwrite_char PARAMS((int, int));
|
||||
extern int _rl_overwrite_rubout PARAMS((int, int));
|
||||
extern int _rl_rubout_char PARAMS((int, int));
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
extern int _rl_char_search_internal PARAMS((int, int, char *, int));
|
||||
#else
|
||||
extern int _rl_char_search_internal PARAMS((int, int, int));
|
||||
#endif
|
||||
extern int _rl_set_mark_at_pos PARAMS((int));
|
||||
|
||||
/* util.c */
|
||||
extern int _rl_abort_internal PARAMS((void));
|
||||
extern char *_rl_strindex PARAMS((const char *, const char *));
|
||||
extern int _rl_qsort_string_compare PARAMS((char **, char **));
|
||||
extern int (_rl_uppercase_p) PARAMS((int));
|
||||
extern int (_rl_lowercase_p) PARAMS((int));
|
||||
extern int (_rl_pure_alphabetic) PARAMS((int));
|
||||
extern int (_rl_digit_p) PARAMS((int));
|
||||
extern int (_rl_to_lower) PARAMS((int));
|
||||
extern int (_rl_to_upper) PARAMS((int));
|
||||
extern int (_rl_digit_value) PARAMS((int));
|
||||
|
||||
/* vi_mode.c */
|
||||
extern void _rl_vi_initialize_line PARAMS((void));
|
||||
extern void _rl_vi_reset_last PARAMS((void));
|
||||
extern void _rl_vi_set_last PARAMS((int, int, int));
|
||||
extern int _rl_vi_textmod_command PARAMS((int));
|
||||
extern void _rl_vi_done_inserting PARAMS((void));
|
||||
|
||||
/*************************************************************************
|
||||
* Undocumented private variables *
|
||||
*************************************************************************/
|
||||
|
||||
/* bind.c */
|
||||
extern const char *_rl_possible_control_prefixes[];
|
||||
extern const char *_rl_possible_meta_prefixes[];
|
||||
|
||||
/* 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;
|
||||
extern int _rl_completion_case_fold;
|
||||
extern int _rl_match_hidden_files;
|
||||
extern int _rl_page_completions;
|
||||
|
||||
/* display.c */
|
||||
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;
|
||||
|
||||
/* misc.c */
|
||||
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;
|
||||
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;
|
||||
extern FILE *_rl_in_stream;
|
||||
extern FILE *_rl_out_stream;
|
||||
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;
|
||||
extern char *_rl_term_clreol;
|
||||
extern char *_rl_term_clrpag;
|
||||
extern char *_rl_term_im;
|
||||
extern char *_rl_term_ic;
|
||||
extern char *_rl_term_ei;
|
||||
extern char *_rl_term_DC;
|
||||
extern char *_rl_term_up;
|
||||
extern char *_rl_term_dc;
|
||||
extern char *_rl_term_cr;
|
||||
extern char *_rl_term_IC;
|
||||
extern int _rl_screenheight;
|
||||
extern int _rl_screenwidth;
|
||||
extern int _rl_screenchars;
|
||||
extern int _rl_terminal_can_insert;
|
||||
extern int _rl_term_autowrap;
|
||||
|
||||
/* undo.c */
|
||||
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_ */
|
34
extern/editline/rlshell.h
vendored
34
extern/editline/rlshell.h
vendored
@ -1,34 +0,0 @@
|
||||
/* rlshell.h -- utility functions normally provided by bash. */
|
||||
|
||||
/* Copyright (C) 1999 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_RL_SHELL_H_)
|
||||
#define _RL_SHELL_H_
|
||||
|
||||
#include "rlstdc.h"
|
||||
|
||||
extern char *sh_single_quote PARAMS((char *));
|
||||
extern void sh_set_lines_and_columns PARAMS((int, int));
|
||||
extern char *sh_get_env_value PARAMS((const char *));
|
||||
extern char *sh_get_home_dir PARAMS((void));
|
||||
extern int sh_unset_nodelay_mode PARAMS((int));
|
||||
|
||||
#endif /* _RL_SHELL_H_ */
|
45
extern/editline/rlstdc.h
vendored
45
extern/editline/rlstdc.h
vendored
@ -1,45 +0,0 @@
|
||||
/* stdc.h -- macros to make source compile on both ANSI C and K&R C
|
||||
compilers. */
|
||||
|
||||
/* Copyright (C) 1993 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Bash, the Bourne Again SHell.
|
||||
|
||||
Bash 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.
|
||||
|
||||
Bash 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 Bash; see the file COPYING. If not, write to the Free
|
||||
Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_RL_STDC_H_)
|
||||
#define _RL_STDC_H_
|
||||
|
||||
/* Adapted from BSD /usr/include/sys/cdefs.h. */
|
||||
|
||||
/* A function can be defined using prototypes and compile on both ANSI C
|
||||
and traditional C compilers with something like this:
|
||||
extern char *func PARAMS((char *, char *, int)); */
|
||||
|
||||
#if !defined (PARAMS)
|
||||
# if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
|
||||
# define PARAMS(protos) protos
|
||||
# else
|
||||
# define PARAMS(protos) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef __attribute__
|
||||
# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
|
||||
# define __attribute__(x)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* !_RL_STDC_H_ */
|
1035
extern/editline/rltty.c
vendored
1035
extern/editline/rltty.c
vendored
File diff suppressed because it is too large
Load Diff
82
extern/editline/rltty.h
vendored
82
extern/editline/rltty.h
vendored
@ -1,82 +0,0 @@
|
||||
/* rltty.h - tty driver-related definitions used by some library files. */
|
||||
|
||||
/* Copyright (C) 1995 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
|
||||
for it.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_RLTTY_H_)
|
||||
#define _RLTTY_H_
|
||||
|
||||
/* Posix systems use termios and the Posix signal functions. */
|
||||
#if defined (TERMIOS_TTY_DRIVER)
|
||||
# include <termios.h>
|
||||
#endif /* TERMIOS_TTY_DRIVER */
|
||||
|
||||
/* System V machines use termio. */
|
||||
#if defined (TERMIO_TTY_DRIVER)
|
||||
# include <termio.h>
|
||||
# if !defined (TCOON)
|
||||
# define TCOON 1
|
||||
# endif
|
||||
#endif /* TERMIO_TTY_DRIVER */
|
||||
|
||||
/* Other (BSD) machines use sgtty. */
|
||||
#if defined (NEW_TTY_DRIVER)
|
||||
# include <sgtty.h>
|
||||
#endif
|
||||
|
||||
#include "rlwinsize.h"
|
||||
|
||||
/* Define _POSIX_VDISABLE if we are not using the `new' tty driver and
|
||||
it is not already defined. It is used both to determine if a
|
||||
special character is disabled and to disable certain special
|
||||
characters. Posix systems should set to 0, USG systems to -1. */
|
||||
#if !defined (NEW_TTY_DRIVER) && !defined (_POSIX_VDISABLE)
|
||||
# if defined (_SVR4_VDISABLE)
|
||||
# define _POSIX_VDISABLE _SVR4_VDISABLE
|
||||
# else
|
||||
# if defined (_POSIX_VERSION)
|
||||
# define _POSIX_VDISABLE 0
|
||||
# else /* !_POSIX_VERSION */
|
||||
# define _POSIX_VDISABLE -1
|
||||
# endif /* !_POSIX_VERSION */
|
||||
# endif /* !_SVR4_DISABLE */
|
||||
#endif /* !NEW_TTY_DRIVER && !_POSIX_VDISABLE */
|
||||
|
||||
typedef struct _rl_tty_chars {
|
||||
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_ */
|
94
extern/editline/rltypedefs.h
vendored
94
extern/editline/rltypedefs.h
vendored
@ -1,94 +0,0 @@
|
||||
/* rltypedefs.h -- Type declarations for readline functions. */
|
||||
|
||||
/* 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.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#ifndef _RL_TYPEDEFS_H_
|
||||
#define _RL_TYPEDEFS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Old-style */
|
||||
|
||||
#if !defined (_FUNCTION_DEF)
|
||||
# define _FUNCTION_DEF
|
||||
|
||||
typedef int Function ();
|
||||
typedef void VFunction ();
|
||||
typedef char *CPFunction ();
|
||||
typedef char **CPPFunction ();
|
||||
|
||||
#endif /* _FUNCTION_DEF */
|
||||
|
||||
/* New style. */
|
||||
|
||||
#if !defined (_RL_FUNCTION_TYPEDEF)
|
||||
# define _RL_FUNCTION_TYPEDEF
|
||||
|
||||
/* Bindable functions */
|
||||
typedef int rl_command_func_t PARAMS((int, int));
|
||||
|
||||
/* Typedefs for the completion system */
|
||||
typedef char *rl_compentry_func_t PARAMS((const char *, int));
|
||||
typedef char **rl_completion_func_t PARAMS((const char *, int, int));
|
||||
|
||||
typedef char *rl_quote_func_t PARAMS((char *, int, char *));
|
||||
typedef char *rl_dequote_func_t PARAMS((char *, int));
|
||||
|
||||
typedef int rl_compignore_func_t PARAMS((char **));
|
||||
|
||||
typedef void rl_compdisp_func_t PARAMS((char **, int, int));
|
||||
|
||||
/* Type for input and pre-read hook functions like rl_event_hook */
|
||||
typedef int rl_hook_func_t PARAMS((void));
|
||||
|
||||
/* Input function type */
|
||||
typedef int rl_getc_func_t PARAMS((FILE *));
|
||||
|
||||
/* Generic function that takes a character buffer (which could be the readline
|
||||
line buffer) and an index into it (which could be rl_point) and returns
|
||||
an int. */
|
||||
typedef int rl_linebuf_func_t PARAMS((char *, int));
|
||||
|
||||
/* `Generic' function pointer typedefs */
|
||||
typedef int rl_intfunc_t PARAMS((int));
|
||||
#define rl_ivoidfunc_t rl_hook_func_t
|
||||
typedef int rl_icpfunc_t PARAMS((char *));
|
||||
typedef int rl_icppfunc_t PARAMS((char **));
|
||||
|
||||
typedef void rl_voidfunc_t PARAMS((void));
|
||||
typedef void rl_vintfunc_t PARAMS((int));
|
||||
typedef void rl_vcpfunc_t PARAMS((char *));
|
||||
typedef void rl_vcppfunc_t PARAMS((char **));
|
||||
|
||||
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
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _RL_TYPEDEFS_H_ */
|
57
extern/editline/rlwinsize.h
vendored
57
extern/editline/rlwinsize.h
vendored
@ -1,57 +0,0 @@
|
||||
/* rlwinsize.h -- an attempt to isolate some of the system-specific defines
|
||||
for `struct winsize' and TIOCGWINSZ. */
|
||||
|
||||
/* Copyright (C) 1997 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
|
||||
for it.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
|
||||
#if !defined (_RLWINSIZE_H_)
|
||||
#define _RLWINSIZE_H_
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
/* Try to find the definitions of `struct winsize' and TIOGCWINSZ */
|
||||
|
||||
#if defined (GWINSZ_IN_SYS_IOCTL) && !defined (TIOCGWINSZ)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* GWINSZ_IN_SYS_IOCTL && !TIOCGWINSZ */
|
||||
|
||||
#if defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
# include <termios.h>
|
||||
#endif /* STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
|
||||
|
||||
/* Not in either of the standard places, look around. */
|
||||
#if !defined (STRUCT_WINSIZE_IN_TERMIOS) && !defined (STRUCT_WINSIZE_IN_SYS_IOCTL)
|
||||
# if defined (HAVE_SYS_STREAM_H)
|
||||
# include <sys/stream.h>
|
||||
# endif /* HAVE_SYS_STREAM_H */
|
||||
# if defined (HAVE_SYS_PTEM_H) /* SVR4.2, at least, has it here */
|
||||
# include <sys/ptem.h>
|
||||
# define _IO_PTEM_H /* work around SVR4.2 1.1.4 bug */
|
||||
# endif /* HAVE_SYS_PTEM_H */
|
||||
# if defined (HAVE_SYS_PTE_H) /* ??? */
|
||||
# include <sys/pte.h>
|
||||
# endif /* HAVE_SYS_PTE_H */
|
||||
#endif /* !STRUCT_WINSIZE_IN_TERMIOS && !STRUCT_WINSIZE_IN_SYS_IOCTL */
|
||||
|
||||
#endif /* _RL_WINSIZE_H */
|
||||
|
37
extern/editline/savestring.c
vendored
37
extern/editline/savestring.c
vendored
@ -1,37 +0,0 @@
|
||||
/* savestring.c */
|
||||
|
||||
/* 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.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#include <config.h>
|
||||
#ifdef HAVE_STRING_H
|
||||
# include <string.h>
|
||||
#endif
|
||||
#include "xmalloc.h"
|
||||
|
||||
/* Backwards compatibility, now that savestring has been removed from
|
||||
all `public' readline header files. */
|
||||
char *
|
||||
savestring (s)
|
||||
const char *s;
|
||||
{
|
||||
return ((char *)strcpy ((char *)xmalloc (1 + strlen (s)), (s)));
|
||||
}
|
572
extern/editline/search.c
vendored
572
extern/editline/search.c
vendored
@ -1,572 +0,0 @@
|
||||
/* search.c - code for non-incremental searching in emacs and vi modes. */
|
||||
|
||||
/* 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
|
||||
for it.
|
||||
|
||||
The Library is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
The Library is distributed in the hope that it will be useful, but
|
||||
WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif
|
||||
|
||||
#include "rldefs.h"
|
||||
#include "rlmbutil.h"
|
||||
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#ifdef abs
|
||||
# undef abs
|
||||
#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. */
|
||||
extern int _rl_free_history_entry PARAMS((HIST_ENTRY *));
|
||||
|
||||
static char *noninc_search_string = (char *) NULL;
|
||||
static int noninc_history_pos;
|
||||
|
||||
static char *prev_line_found = (char *) NULL;
|
||||
|
||||
static int rl_history_search_len;
|
||||
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 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. */
|
||||
static void
|
||||
make_history_line_current (entry)
|
||||
HIST_ENTRY *entry;
|
||||
{
|
||||
_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);
|
||||
_rl_saved_line_for_history = (HIST_ENTRY *)NULL;
|
||||
}
|
||||
|
||||
/* Search the history list for STRING starting at absolute history position
|
||||
POS. If STRING begins with `^', the search must match STRING at the
|
||||
beginning of a history line, otherwise a full substring match is performed
|
||||
for STRING. DIR < 0 means to search backwards through the history list,
|
||||
DIR >= 0 means to search forward. */
|
||||
static int
|
||||
noninc_search_from_pos (string, pos, dir)
|
||||
char *string;
|
||||
int pos, dir;
|
||||
{
|
||||
int ret, old;
|
||||
|
||||
if (pos < 0)
|
||||
return -1;
|
||||
|
||||
old = where_history ();
|
||||
if (history_set_pos (pos) == 0)
|
||||
return -1;
|
||||
|
||||
RL_SETSTATE(RL_STATE_SEARCH);
|
||||
if (*string == '^')
|
||||
ret = history_search_prefix (string + 1, dir);
|
||||
else
|
||||
ret = history_search (string, dir);
|
||||
RL_UNSETSTATE(RL_STATE_SEARCH);
|
||||
|
||||
if (ret != -1)
|
||||
ret = where_history ();
|
||||
|
||||
history_set_pos (old);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/* Search for a line in the history containing STRING. If DIR is < 0, the
|
||||
search is backwards through previous entries, else through subsequent
|
||||
entries. Returns 1 if the search was successful, 0 otherwise. */
|
||||
static int
|
||||
noninc_dosearch (string, dir)
|
||||
char *string;
|
||||
int dir;
|
||||
{
|
||||
int oldpos, pos;
|
||||
HIST_ENTRY *entry;
|
||||
|
||||
if (string == 0 || *string == '\0' || noninc_history_pos < 0)
|
||||
{
|
||||
rl_ding ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
pos = noninc_search_from_pos (string, noninc_history_pos + dir, dir);
|
||||
if (pos == -1)
|
||||
{
|
||||
/* Search failed, current history position unchanged. */
|
||||
rl_maybe_unsave_line ();
|
||||
rl_clear_message ();
|
||||
rl_point = 0;
|
||||
rl_ding ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
noninc_history_pos = pos;
|
||||
|
||||
oldpos = where_history ();
|
||||
history_set_pos (noninc_history_pos);
|
||||
entry = current_history ();
|
||||
#if defined (VI_MODE)
|
||||
if (rl_editing_mode != vi_mode)
|
||||
#endif
|
||||
history_set_pos (oldpos);
|
||||
|
||||
make_history_line_current (entry);
|
||||
|
||||
rl_point = 0;
|
||||
rl_mark = rl_end;
|
||||
|
||||
rl_clear_message ();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static _rl_search_cxt *
|
||||
_rl_nsearch_init (dir, pchar)
|
||||
int dir, pchar;
|
||||
{
|
||||
_rl_search_cxt *cxt;
|
||||
char *p;
|
||||
|
||||
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 ();
|
||||
|
||||
/* 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;
|
||||
rl_end = rl_point = 0;
|
||||
|
||||
p = _rl_make_prompt_for_search (pchar ? pchar : ':');
|
||||
rl_message (p, 0, 0);
|
||||
free (p);
|
||||
|
||||
RL_SETSTATE(RL_STATE_NSEARCH);
|
||||
|
||||
_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)
|
||||
rl_insert_text (cxt->mb);
|
||||
else
|
||||
#endif
|
||||
_rl_insert_char (1, c);
|
||||
break;
|
||||
}
|
||||
|
||||
(*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 == 0)
|
||||
{
|
||||
rl_ding ();
|
||||
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 = 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 ();
|
||||
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
|
||||
code calls this, KEY will be `?'. */
|
||||
int
|
||||
rl_noninc_forward_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
return noninc_search (1, (key == '?') ? '?' : 0);
|
||||
}
|
||||
|
||||
/* Reverse search the history list for a string. If the vi-mode code
|
||||
calls this, KEY will be `/'. */
|
||||
int
|
||||
rl_noninc_reverse_search (count, key)
|
||||
int count, key;
|
||||
{
|
||||
return noninc_search (-1, (key == '/') ? '/' : 0);
|
||||
}
|
||||
|
||||
/* Search forward through the history list for the last string searched
|
||||
for. If there is no saved search string, abort. */
|
||||
int
|
||||
rl_noninc_forward_search_again (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
rl_ding ();
|
||||
return (-1);
|
||||
}
|
||||
r = noninc_dosearch (noninc_search_string, 1);
|
||||
return (r != 1);
|
||||
}
|
||||
|
||||
/* Reverse search in the history list for the last string searched
|
||||
for. If there is no saved search string, abort. */
|
||||
int
|
||||
rl_noninc_reverse_search_again (count, key)
|
||||
int count, key;
|
||||
{
|
||||
int r;
|
||||
|
||||
if (!noninc_search_string)
|
||||
{
|
||||
rl_ding ();
|
||||
return (-1);
|
||||
}
|
||||
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;
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
int ret, oldpos;
|
||||
|
||||
rl_maybe_save_line ();
|
||||
temp = (HIST_ENTRY *)NULL;
|
||||
|
||||
/* Search COUNT times through the history for a line whose prefix
|
||||
matches history_search_string. When this loop finishes, TEMP,
|
||||
if non-null, is the history line to copy into the line buffer. */
|
||||
while (count)
|
||||
{
|
||||
ret = noninc_search_from_pos (history_search_string, rl_history_search_pos + dir, dir);
|
||||
if (ret == -1)
|
||||
break;
|
||||
|
||||
/* Get the history entry we found. */
|
||||
rl_history_search_pos = ret;
|
||||
oldpos = where_history ();
|
||||
history_set_pos (rl_history_search_pos);
|
||||
temp = current_history ();
|
||||
history_set_pos (oldpos);
|
||||
|
||||
/* Don't find multiple instances of the same line. */
|
||||
if (prev_line_found && STREQ (prev_line_found, temp->line))
|
||||
continue;
|
||||
prev_line_found = temp->line;
|
||||
count--;
|
||||
}
|
||||
|
||||
/* If we didn't find anything at all, return. */
|
||||
if (temp == 0)
|
||||
{
|
||||
rl_maybe_unsave_line ();
|
||||
rl_ding ();
|
||||
/* If you don't want the saved history line (last match) to show up
|
||||
in the line buffer after the search fails, change the #if 0 to
|
||||
#if 1 */
|
||||
#if 0
|
||||
if (rl_point > rl_history_search_len)
|
||||
{
|
||||
rl_point = rl_end = rl_history_search_len;
|
||||
rl_line_buffer[rl_end] = '\0';
|
||||
rl_mark = 0;
|
||||
}
|
||||
#else
|
||||
rl_point = rl_history_search_len; /* rl_maybe_unsave_line changes it */
|
||||
rl_mark = rl_end;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Copy the line we found into the current line buffer. */
|
||||
make_history_line_current (temp);
|
||||
|
||||
rl_point = rl_history_search_len;
|
||||
rl_mark = rl_end;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
rl_history_search_reinit ()
|
||||
{
|
||||
rl_history_search_pos = where_history ();
|
||||
rl_history_search_len = rl_point;
|
||||
prev_line_found = (char *)NULL;
|
||||
if (rl_point)
|
||||
{
|
||||
if (rl_history_search_len >= history_string_size - 2)
|
||||
{
|
||||
history_string_size = rl_history_search_len + 2;
|
||||
history_search_string = (char *)xrealloc (history_search_string, history_string_size);
|
||||
}
|
||||
history_search_string[0] = '^';
|
||||
strncpy (history_search_string + 1, rl_line_buffer, rl_point);
|
||||
history_search_string[rl_point + 1] = '\0';
|
||||
}
|
||||
_rl_free_saved_history_line ();
|
||||
}
|
||||
|
||||
/* Search forward in the history for the string of characters
|
||||
from the start of the line to rl_point. This is a non-incremental
|
||||
search. */
|
||||
int
|
||||
rl_history_search_forward (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (count == 0)
|
||||
return (0);
|
||||
|
||||
if (rl_last_func != rl_history_search_forward &&
|
||||
rl_last_func != rl_history_search_backward)
|
||||
rl_history_search_reinit ();
|
||||
|
||||
if (rl_history_search_len == 0)
|
||||
return (rl_get_next_history (count, ignore));
|
||||
return (rl_history_search_internal (abs (count), (count > 0) ? 1 : -1));
|
||||
}
|
||||
|
||||
/* Search backward through the history for the string of characters
|
||||
from the start of the line to rl_point. This is a non-incremental
|
||||
search. */
|
||||
int
|
||||
rl_history_search_backward (count, ignore)
|
||||
int count, ignore;
|
||||
{
|
||||
if (count == 0)
|
||||
return (0);
|
||||
|
||||
if (rl_last_func != rl_history_search_forward &&
|
||||
rl_last_func != rl_history_search_backward)
|
||||
rl_history_search_reinit ();
|
||||
|
||||
if (rl_history_search_len == 0)
|
||||
return (rl_get_previous_history (count, ignore));
|
||||
return (rl_history_search_internal (abs (count), (count > 0) ? -1 : 1));
|
||||
}
|
208
extern/editline/shell.c
vendored
208
extern/editline/shell.c
vendored
@ -1,208 +0,0 @@
|
||||
/* shell.c -- readline utility functions that are normally provided by
|
||||
bash when readline is linked as part of the shell. */
|
||||
|
||||
/* Copyright (C) 1997 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of the GNU Readline Library, a library for
|
||||
reading lines of text with interactive input and history editing.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
#if defined (HAVE_STDLIB_H)
|
||||
# include <stdlib.h>
|
||||
#else
|
||||
# include "ansi_stdlib.h"
|
||||
#endif /* HAVE_STDLIB_H */
|
||||
|
||||
#if defined (HAVE_STRING_H)
|
||||
# include <string.h>
|
||||
#else
|
||||
# include <strings.h>
|
||||
#endif /* !HAVE_STRING_H */
|
||||
|
||||
#if defined (HAVE_LIMITS_H)
|
||||
# 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>
|
||||
|
||||
#include "rlstdc.h"
|
||||
#include "rlshell.h"
|
||||
#include "xmalloc.h"
|
||||
|
||||
#if defined (HAVE_GETPWUID) && !defined (HAVE_GETPW_DECLS)
|
||||
extern struct passwd *getpwuid PARAMS((uid_t));
|
||||
#endif /* HAVE_GETPWUID && !HAVE_GETPW_DECLS */
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
#ifndef CHAR_BIT
|
||||
# define CHAR_BIT 8
|
||||
#endif
|
||||
|
||||
/* Nonzero if the integer type T is signed. */
|
||||
#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
|
||||
|
||||
/* Bound on length of the string representing an integer value of type T.
|
||||
Subtract one for the sign bit if T is signed;
|
||||
302 / 1000 is log10 (2) rounded up;
|
||||
add one for integer division truncation;
|
||||
add one more for a minus sign if t is signed. */
|
||||
#define INT_STRLEN_BOUND(t) \
|
||||
((sizeof (t) * CHAR_BIT - TYPE_SIGNED (t)) * 302 / 1000 \
|
||||
+ 1 + TYPE_SIGNED (t))
|
||||
|
||||
/* All of these functions are resolved from bash if we are linking readline
|
||||
as part of bash. */
|
||||
|
||||
/* Does shell-like quoting using single quotes. */
|
||||
char *
|
||||
sh_single_quote (string)
|
||||
char *string;
|
||||
{
|
||||
register int c;
|
||||
char *result, *r, *s;
|
||||
|
||||
result = (char *)xmalloc (3 + (4 * strlen (string)));
|
||||
r = result;
|
||||
*r++ = '\'';
|
||||
|
||||
for (s = string; s && (c = *s); s++)
|
||||
{
|
||||
*r++ = c;
|
||||
|
||||
if (c == '\'')
|
||||
{
|
||||
*r++ = '\\'; /* insert escaped single quote */
|
||||
*r++ = '\'';
|
||||
*r++ = '\''; /* start new quoted string */
|
||||
}
|
||||
}
|
||||
|
||||
*r++ = '\'';
|
||||
*r = '\0';
|
||||
|
||||
return (result);
|
||||
}
|
||||
|
||||
/* Set the environment variables LINES and COLUMNS to lines and cols,
|
||||
respectively. */
|
||||
void
|
||||
sh_set_lines_and_columns (lines, cols)
|
||||
int lines, cols;
|
||||
{
|
||||
char *b;
|
||||
|
||||
#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);
|
||||
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 *
|
||||
sh_get_env_value (varname)
|
||||
const char *varname;
|
||||
{
|
||||
return ((char *)getenv (varname));
|
||||
}
|
||||
|
||||
char *
|
||||
sh_get_home_dir ()
|
||||
{
|
||||
char *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);
|
||||
}
|
||||
|
||||
#if !defined (O_NDELAY)
|
||||
# if defined (FNDELAY)
|
||||
# define O_NDELAY FNDELAY
|
||||
# endif
|
||||
#endif
|
||||
|
||||
int
|
||||
sh_unset_nodelay_mode (fd)
|
||||
int fd;
|
||||
{
|
||||
#if defined (HAVE_FCNTL)
|
||||
int flags, bflags;
|
||||
|
||||
if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
|
||||
return -1;
|
||||
|
||||
bflags = 0;
|
||||
|
||||
#ifdef O_NONBLOCK
|
||||
bflags |= O_NONBLOCK;
|
||||
#endif
|
||||
|
||||
#ifdef O_NDELAY
|
||||
bflags |= O_NDELAY;
|
||||
#endif
|
||||
|
||||
if (flags & bflags)
|
||||
{
|
||||
flags &= ~bflags;
|
||||
return (fcntl (fd, F_SETFL, flags));
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
426
extern/editline/signals.c
vendored
426
extern/editline/signals.c
vendored
@ -1,426 +0,0 @@
|
||||
/* signals.c -- signal handling support for readline. */
|
||||
|
||||
/* 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.
|
||||
|
||||
The GNU Readline Library is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2, or
|
||||
(at your option) any later version.
|
||||
|
||||
The GNU Readline Library is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
The GNU General Public License is often shipped with GNU software, and
|
||||
is generally kept in a file called COPYING or LICENSE. If you do not
|
||||
have a copy of the license, write to the Free Software Foundation,
|
||||
59 Temple Place, Suite 330, Boston, MA 02111 USA. */
|
||||
#define READLINE_LIBRARY
|
||||
|
||||
#if defined (HAVE_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h> /* Just for NULL. Yuck. */
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
|
||||
#if defined (HAVE_UNISTD_H)
|
||||
# include <unistd.h>
|
||||
#endif /* HAVE_UNISTD_H */
|
||||
|
||||
/* System-specific feature definitions and include files. */
|
||||
#include "rldefs.h"
|
||||
|
||||
#if defined (GWINSZ_IN_SYS_IOCTL)
|
||||
# include <sys/ioctl.h>
|
||||
#endif /* GWINSZ_IN_SYS_IOCTL */
|
||||
|
||||
#if defined (HANDLE_SIGNALS)
|
||||
/* Some standard library routines. */
|
||||
#include "readline.h"
|
||||
#include "history.h"
|
||||
|
||||
#include "rlprivate.h"
|
||||
|
||||
#if !defined (RETSIGTYPE)
|
||||
# if defined (VOID_SIGHANDLER)
|
||||
# define RETSIGTYPE void
|
||||
# else
|
||||
# define RETSIGTYPE int
|
||||
# endif /* !VOID_SIGHANDLER */
|
||||
#endif /* !RETSIGTYPE */
|
||||
|
||||
#if defined (VOID_SIGHANDLER)
|
||||
# define SIGHANDLER_RETURN return
|
||||
#else
|
||||
# define SIGHANDLER_RETURN return (0)
|
||||
#endif
|
||||
|
||||
/* This typedef is equivalent to the one for Function; it allows us
|
||||
to say SigHandler *foo = signal (SIGKILL, SIG_IGN); */
|
||||
typedef RETSIGTYPE SigHandler ();
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
typedef struct sigaction sighandler_cxt;
|
||||
# define rl_sigaction(s, nh, oh) sigaction(s, nh, oh)
|
||||
#else
|
||||
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 *));
|
||||
|
||||
/* Exported variables for use by applications. */
|
||||
|
||||
/* If non-zero, readline will install its own signal handlers for
|
||||
SIGINT, SIGTERM, SIGQUIT, SIGALRM, SIGTSTP, SIGTTIN, and SIGTTOU. */
|
||||
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;
|
||||
static int sigwinch_set_flag;
|
||||
|
||||
/* **************************************************************** */
|
||||
/* */
|
||||
/* Signal Handling */
|
||||
/* */
|
||||
/* **************************************************************** */
|
||||
|
||||
static sighandler_cxt old_int, old_term, old_alrm, old_quit;
|
||||
#if defined (SIGTSTP)
|
||||
static sighandler_cxt old_tstp, old_ttou, old_ttin;
|
||||
#endif
|
||||
#if defined (SIGWINCH)
|
||||
static sighandler_cxt old_winch;
|
||||
#endif
|
||||
|
||||
/* Readline signal handler functions. */
|
||||
|
||||
static RETSIGTYPE
|
||||
rl_signal_handler (sig)
|
||||
int sig;
|
||||
{
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigset_t set;
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
long omask;
|
||||
# else /* !HAVE_BSD_SIGNALS */
|
||||
sighandler_cxt dummy_cxt; /* needed for rl_set_sighandler call */
|
||||
# endif /* !HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
RL_SETSTATE(RL_STATE_SIGHANDLER);
|
||||
|
||||
#if !defined (HAVE_BSD_SIGNALS) && !defined (HAVE_POSIX_SIGNALS)
|
||||
/* Since the signal will not be blocked while we are in the signal
|
||||
handler, ignore it until rl_clear_signals resets the catcher. */
|
||||
# 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 */
|
||||
|
||||
switch (sig)
|
||||
{
|
||||
case SIGINT:
|
||||
rl_free_line_state ();
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case SIGTERM:
|
||||
#if defined (SIGTSTP)
|
||||
case SIGTSTP:
|
||||
case SIGTTOU:
|
||||
case SIGTTIN:
|
||||
#endif /* SIGTSTP */
|
||||
#if defined (SIGALRM)
|
||||
case SIGALRM:
|
||||
#endif
|
||||
#if defined (SIGQUIT)
|
||||
case SIGQUIT:
|
||||
#endif
|
||||
rl_cleanup_after_signal ();
|
||||
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
sigprocmask (SIG_BLOCK, (sigset_t *)NULL, &set);
|
||||
sigdelset (&set, sig);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
omask = sigblock (0);
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
#if defined (__EMX__)
|
||||
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)
|
||||
sigprocmask (SIG_SETMASK, &set, (sigset_t *)NULL);
|
||||
#else /* !HAVE_POSIX_SIGNALS */
|
||||
# if defined (HAVE_BSD_SIGNALS)
|
||||
sigsetmask (omask & ~(sigmask (sig)));
|
||||
# endif /* HAVE_BSD_SIGNALS */
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
rl_reset_after_signal ();
|
||||
}
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
|
||||
SIGHANDLER_RETURN;
|
||||
}
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
static RETSIGTYPE
|
||||
rl_sigwinch_handler (sig)
|
||||
int sig;
|
||||
{
|
||||
SigHandler *oh;
|
||||
|
||||
#if defined (MUST_REINSTALL_SIGHANDLERS)
|
||||
sighandler_cxt dummy_winch;
|
||||
|
||||
/* We don't want to change old_winch -- it holds the state of SIGWINCH
|
||||
disposition set by the calling application. We need this state
|
||||
because we call the application's SIGWINCH handler after updating
|
||||
our own idea of the screen size. */
|
||||
rl_set_sighandler (SIGWINCH, rl_sigwinch_handler, &dummy_winch);
|
||||
#endif
|
||||
|
||||
RL_SETSTATE(RL_STATE_SIGHANDLER);
|
||||
rl_resize_terminal ();
|
||||
|
||||
/* If another sigwinch handler has been installed, call it. */
|
||||
oh = (SigHandler *)old_winch.sa_handler;
|
||||
if (oh && oh != (SigHandler *)SIG_IGN && oh != (SigHandler *)SIG_DFL)
|
||||
(*oh) (sig);
|
||||
|
||||
RL_UNSETSTATE(RL_STATE_SIGHANDLER);
|
||||
SIGHANDLER_RETURN;
|
||||
}
|
||||
#endif /* SIGWINCH */
|
||||
|
||||
/* Functions to manage signal handling. */
|
||||
|
||||
#if !defined (HAVE_POSIX_SIGNALS)
|
||||
static int
|
||||
rl_sigaction (sig, nh, oh)
|
||||
int sig;
|
||||
sighandler_cxt *nh, *oh;
|
||||
{
|
||||
oh->sa_handler = signal (sig, nh->sa_handler);
|
||||
return 0;
|
||||
}
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
/* Set up a readline-specific signal handler, saving the old signal
|
||||
information in OHANDLER. Return the old signal handler, like
|
||||
signal(). */
|
||||
static SigHandler *
|
||||
rl_set_sighandler (sig, handler, ohandler)
|
||||
int sig;
|
||||
SigHandler *handler;
|
||||
sighandler_cxt *ohandler;
|
||||
{
|
||||
sighandler_cxt old_handler;
|
||||
#if defined (HAVE_POSIX_SIGNALS)
|
||||
struct sigaction act;
|
||||
|
||||
act.sa_handler = handler;
|
||||
act.sa_flags = (sig == SIGWINCH) ? SA_RESTART : 0;
|
||||
sigemptyset (&act.sa_mask);
|
||||
sigemptyset (&ohandler->sa_mask);
|
||||
sigaction (sig, &act, &old_handler);
|
||||
#else
|
||||
old_handler.sa_handler = (SigHandler *)signal (sig, handler);
|
||||
#endif /* !HAVE_POSIX_SIGNALS */
|
||||
|
||||
/* XXX -- assume we have memcpy */
|
||||
/* If rl_set_signals is called twice in a row, don't set the old handler to
|
||||
rl_signal_handler, because that would cause infinite recursion. */
|
||||
if (handler != rl_signal_handler || old_handler.sa_handler != rl_signal_handler)
|
||||
memcpy (ohandler, &old_handler, sizeof (sighandler_cxt));
|
||||
|
||||
return (ohandler->sa_handler);
|
||||
}
|
||||
|
||||
static void
|
||||
rl_maybe_set_sighandler (sig, handler, ohandler)
|
||||
int sig;
|
||||
SigHandler *handler;
|
||||
sighandler_cxt *ohandler;
|
||||
{
|
||||
sighandler_cxt dummy;
|
||||
SigHandler *oh;
|
||||
|
||||
sigemptyset (&dummy.sa_mask);
|
||||
oh = rl_set_sighandler (sig, handler, ohandler);
|
||||
if (oh == (SigHandler *)SIG_IGN)
|
||||
rl_sigaction (sig, ohandler, &dummy);
|
||||
}
|
||||
|
||||
int
|
||||
rl_set_signals ()
|
||||
{
|
||||
sighandler_cxt dummy;
|
||||
SigHandler *oh;
|
||||
|
||||
if (rl_catch_signals && signals_set_flag == 0)
|
||||
{
|
||||
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);
|
||||
#if defined (HAVE_POSIX_SIGNALS) && defined (SA_RESTART)
|
||||
/* If the application using readline has already installed a signal
|
||||
handler with SA_RESTART, SIGALRM will cause reads to be restarted
|
||||
automatically, so readline should just get out of the way. Since
|
||||
we tested for SIG_IGN above, we can just test for SIG_DFL here. */
|
||||
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);
|
||||
#endif /* SIGTSTP */
|
||||
|
||||
#if defined (SIGTTOU)
|
||||
rl_maybe_set_sighandler (SIGTTOU, rl_signal_handler, &old_ttou);
|
||||
#endif /* SIGTTOU */
|
||||
|
||||
#if defined (SIGTTIN)
|
||||
rl_maybe_set_sighandler (SIGTTIN, rl_signal_handler, &old_ttin);
|
||||
#endif /* SIGTTIN */
|
||||
|
||||
signals_set_flag = 1;
|
||||
}
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
if (rl_catch_sigwinch && sigwinch_set_flag == 0)
|
||||
{
|
||||
rl_maybe_set_sighandler (SIGWINCH, rl_sigwinch_handler, &old_winch);
|
||||
sigwinch_set_flag = 1;
|
||||
}
|
||||
#endif /* SIGWINCH */
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
rl_clear_signals ()
|
||||
{
|
||||
sighandler_cxt dummy;
|
||||
|
||||
if (rl_catch_signals && signals_set_flag == 1)
|
||||
{
|
||||
sigemptyset (&dummy.sa_mask);
|
||||
|
||||
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);
|
||||
#endif /* SIGTSTP */
|
||||
|
||||
#if defined (SIGTTOU)
|
||||
rl_sigaction (SIGTTOU, &old_ttou, &dummy);
|
||||
#endif /* SIGTTOU */
|
||||
|
||||
#if defined (SIGTTIN)
|
||||
rl_sigaction (SIGTTIN, &old_ttin, &dummy);
|
||||
#endif /* SIGTTIN */
|
||||
|
||||
signals_set_flag = 0;
|
||||
}
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
if (rl_catch_sigwinch && sigwinch_set_flag == 1)
|
||||
{
|
||||
sigemptyset (&dummy.sa_mask);
|
||||
rl_sigaction (SIGWINCH, &old_winch, &dummy);
|
||||
sigwinch_set_flag = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Clean up the terminal and readline state after catching a signal, before
|
||||
resending it to the calling application. */
|
||||
void
|
||||
rl_cleanup_after_signal ()
|
||||
{
|
||||
_rl_clean_up_for_exit ();
|
||||
if (rl_deprep_term_function)
|
||||
(*rl_deprep_term_function) ();
|
||||
rl_clear_signals ();
|
||||
rl_clear_pending_input ();
|
||||
}
|
||||
|
||||
/* Reset the terminal and readline state after a signal handler returns. */
|
||||
void
|
||||
rl_reset_after_signal ()
|
||||
{
|
||||
if (rl_prep_term_function)
|
||||
(*rl_prep_term_function) (_rl_meta_flag);
|
||||
rl_set_signals ();
|
||||
}
|
||||
|
||||
/* Free up the readline variable line state for the current line (undo list,
|
||||
any partial history entry, any keyboard macros in progress, and any
|
||||
numeric arguments in process) after catching a signal, before calling
|
||||
rl_cleanup_after_signal(). */
|
||||
void
|
||||
rl_free_line_state ()
|
||||
{
|
||||
register HIST_ENTRY *entry;
|
||||
|
||||
rl_free_undo_list ();
|
||||
|
||||
entry = current_history ();
|
||||
if (entry)
|
||||
entry->data = (char *)NULL;
|
||||
|
||||
_rl_kill_kbd_macro ();
|
||||
rl_clear_message ();
|
||||
_rl_reset_argument ();
|
||||
}
|
||||
|
||||
#endif /* HANDLE_SIGNALS */
|
46
extern/editline/src/Makefile.am
vendored
Normal file
46
extern/editline/src/Makefile.am
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
|
||||
BUILT_SOURCES = vi.h emacs.h common.h fcns.h help.h fcns.c help.c
|
||||
|
||||
AHDR= vi.h emacs.h common.h
|
||||
ASRC= $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c
|
||||
|
||||
vi.h: Makefile $(srcdir)/vi.c
|
||||
sh $(srcdir)/makelist -h $(srcdir)/vi.c > $@
|
||||
|
||||
emacs.h: Makefile $(srcdir)/emacs.c
|
||||
sh $(srcdir)/makelist -h $(srcdir)/emacs.c > $@
|
||||
|
||||
common.h: Makefile $(srcdir)/common.c
|
||||
sh $(srcdir)/makelist -h $(srcdir)/common.c > $@
|
||||
|
||||
fcns.h: Makefile $(AHDR)
|
||||
sh $(srcdir)/makelist -fh $(AHDR) > $@
|
||||
|
||||
help.h: Makefile $(ASRC)
|
||||
sh $(srcdir)/makelist -bh $(ASRC) > $@
|
||||
|
||||
fcns.c: Makefile $(AHDR)
|
||||
sh $(srcdir)/makelist -fc $(AHDR) > $@
|
||||
|
||||
help.c: Makefile $(ASRC)
|
||||
sh $(srcdir)/makelist -bc $(ASRC) > $@
|
||||
|
||||
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
|
||||
lib_LTLIBRARIES = libedit.la
|
||||
libedit_la_SOURCES = chared.c common.c el.c emacs.c hist.c key.c map.c parse.c \
|
||||
prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c \
|
||||
fgetln.c strlcat.c strlcpy.c unvis.c vis.c tokenizer.c \
|
||||
history.c filecomplete.c readline.c chared.h el.h hist.h \
|
||||
histedit.h key.h map.h parse.h prompt.h read.h refresh.h \
|
||||
search.h sig.h sys.h el_term.h tty.h vis.h filecomplete.h \
|
||||
editline/readline.h
|
||||
|
||||
EXTRA_DIST = makelist shlib_version
|
||||
nobase_include_HEADERS = histedit.h editline/readline.h
|
||||
|
||||
nodist_libedit_la_SOURCES = $(BUILT_SOURCES)
|
||||
|
||||
libedit_la_LDFLAGS = -no-undefined -version-info $(LT_VERSION)
|
||||
|
558
extern/editline/src/Makefile.in
vendored
Normal file
558
extern/editline/src/Makefile.in
vendored
Normal file
@ -0,0 +1,558 @@
|
||||
# Makefile.in generated by automake 1.9.6 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
|
||||
# 2003, 2004, 2005 Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
# PARTICULAR PURPOSE.
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
top_builddir = ..
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
INSTALL = @INSTALL@
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
build_triplet = @build@
|
||||
host_triplet = @host@
|
||||
subdir = src
|
||||
DIST_COMMON = $(nobase_include_HEADERS) $(srcdir)/Makefile.am \
|
||||
$(srcdir)/Makefile.in
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
|
||||
$(top_srcdir)/configure.ac
|
||||
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
|
||||
$(ACLOCAL_M4)
|
||||
mkinstalldirs = $(install_sh) -d
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
|
||||
am__vpath_adj = case $$p in \
|
||||
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
*) f=$$p;; \
|
||||
esac;
|
||||
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
|
||||
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"
|
||||
libLTLIBRARIES_INSTALL = $(INSTALL)
|
||||
LTLIBRARIES = $(lib_LTLIBRARIES)
|
||||
libedit_la_LIBADD =
|
||||
am_libedit_la_OBJECTS = chared.lo common.lo el.lo emacs.lo hist.lo \
|
||||
key.lo map.lo parse.lo prompt.lo read.lo refresh.lo search.lo \
|
||||
sig.lo term.lo tty.lo vi.lo fgetln.lo strlcat.lo strlcpy.lo \
|
||||
unvis.lo vis.lo tokenizer.lo history.lo filecomplete.lo \
|
||||
readline.lo
|
||||
am__objects_1 = fcns.lo help.lo
|
||||
nodist_libedit_la_OBJECTS = $(am__objects_1)
|
||||
libedit_la_OBJECTS = $(am_libedit_la_OBJECTS) \
|
||||
$(nodist_libedit_la_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
am__depfiles_maybe = depfiles
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
|
||||
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
|
||||
$(AM_CFLAGS) $(CFLAGS)
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
SOURCES = $(libedit_la_SOURCES) $(nodist_libedit_la_SOURCES)
|
||||
DIST_SOURCES = $(libedit_la_SOURCES)
|
||||
nobase_includeHEADERS_INSTALL = $(install_sh_DATA)
|
||||
HEADERS = $(nobase_include_HEADERS)
|
||||
ETAGS = etags
|
||||
CTAGS = ctags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
ACLOCAL = @ACLOCAL@
|
||||
ALLOCA = @ALLOCA@
|
||||
AMDEP_FALSE = @AMDEP_FALSE@
|
||||
AMDEP_TRUE = @AMDEP_TRUE@
|
||||
AMTAR = @AMTAR@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
DEFS = @DEFS@
|
||||
DEPDIR = @DEPDIR@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
GREP = @GREP@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBS = @LIBS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
LT_VERSION = @LT_VERSION@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MANTYPE = @MANTYPE@
|
||||
NROFF = @NROFF@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
RANLIB = @RANLIB@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
VERSION = @VERSION@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_F77 = @ac_ct_F77@
|
||||
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
|
||||
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
|
||||
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
|
||||
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
am__tar = @am__tar@
|
||||
am__untar = @am__untar@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
datadir = @datadir@
|
||||
datarootdir = @datarootdir@
|
||||
docdir = @docdir@
|
||||
dvidir = @dvidir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
htmldir = @htmldir@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localedir = @localedir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
mkdir_p = @mkdir_p@
|
||||
oldincludedir = @oldincludedir@
|
||||
pdfdir = @pdfdir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
psdir = @psdir@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
BUILT_SOURCES = vi.h emacs.h common.h fcns.h help.h fcns.c help.c
|
||||
AHDR = vi.h emacs.h common.h
|
||||
ASRC = $(srcdir)/vi.c $(srcdir)/emacs.c $(srcdir)/common.c
|
||||
CLEANFILES = $(BUILT_SOURCES)
|
||||
lib_LTLIBRARIES = libedit.la
|
||||
libedit_la_SOURCES = chared.c common.c el.c emacs.c hist.c key.c map.c parse.c \
|
||||
prompt.c read.c refresh.c search.c sig.c term.c tty.c vi.c \
|
||||
fgetln.c strlcat.c strlcpy.c unvis.c vis.c tokenizer.c \
|
||||
history.c filecomplete.c readline.c chared.h el.h hist.h \
|
||||
histedit.h key.h map.h parse.h prompt.h read.h refresh.h \
|
||||
search.h sig.h sys.h el_term.h tty.h vis.h filecomplete.h \
|
||||
editline/readline.h
|
||||
|
||||
EXTRA_DIST = makelist shlib_version
|
||||
nobase_include_HEADERS = histedit.h editline/readline.h
|
||||
nodist_libedit_la_SOURCES = $(BUILT_SOURCES)
|
||||
libedit_la_LDFLAGS = -no-undefined -version-info $(LT_VERSION)
|
||||
all: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
|
||||
@for dep in $?; do \
|
||||
case '$(am__configure_deps)' in \
|
||||
*$$dep*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
|
||||
&& exit 0; \
|
||||
exit 1;; \
|
||||
esac; \
|
||||
done; \
|
||||
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --foreign src/Makefile
|
||||
.PRECIOUS: Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
@case '$?' in \
|
||||
*config.status*) \
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
|
||||
*) \
|
||||
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
|
||||
esac;
|
||||
|
||||
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
|
||||
$(top_srcdir)/configure: $(am__configure_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
|
||||
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
|
||||
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
f=$(am__strip_dir) \
|
||||
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
|
||||
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-libLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
p=$(am__strip_dir) \
|
||||
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
|
||||
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
|
||||
done
|
||||
|
||||
clean-libLTLIBRARIES:
|
||||
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" != "$$p" || dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libedit.la: $(libedit_la_OBJECTS) $(libedit_la_DEPENDENCIES)
|
||||
$(LINK) -rpath $(libdir) $(libedit_la_LDFLAGS) $(libedit_la_OBJECTS) $(libedit_la_LIBADD) $(LIBS)
|
||||
|
||||
mostlyclean-compile:
|
||||
-rm -f *.$(OBJEXT)
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chared.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/el.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emacs.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcns.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fgetln.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filecomplete.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/help.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hist.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/history.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/key.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prompt.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/read.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/readline.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refresh.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/search.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sig.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcat.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strlcpy.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/term.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tokenizer.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tty.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unvis.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vi.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vis.Plo@am__quote@
|
||||
|
||||
.c.o:
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
|
||||
|
||||
.c.obj:
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
|
||||
|
||||
.c.lo:
|
||||
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool
|
||||
uninstall-info-am:
|
||||
install-nobase_includeHEADERS: $(nobase_include_HEADERS)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(includedir)" || $(mkdir_p) "$(DESTDIR)$(includedir)"
|
||||
@$(am__vpath_adj_setup) \
|
||||
list='$(nobase_include_HEADERS)'; for p in $$list; do \
|
||||
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
|
||||
$(am__vpath_adj) \
|
||||
echo " $(nobase_includeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(includedir)/$$f'"; \
|
||||
$(nobase_includeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(includedir)/$$f"; \
|
||||
done
|
||||
|
||||
uninstall-nobase_includeHEADERS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@$(am__vpath_adj_setup) \
|
||||
list='$(nobase_include_HEADERS)'; for p in $$list; do \
|
||||
$(am__vpath_adj) \
|
||||
echo " rm -f '$(DESTDIR)$(includedir)/$$f'"; \
|
||||
rm -f "$(DESTDIR)$(includedir)/$$f"; \
|
||||
done
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
mkid -fID $$unique
|
||||
tags: TAGS
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
|
||||
test -n "$$unique" || unique=$$empty_fix; \
|
||||
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique; \
|
||||
fi
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
||||
GTAGS:
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& cd $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) $$here
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
$(mkdir_p) $(distdir)/editline
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
|
||||
list='$(DISTFILES)'; for file in $$list; do \
|
||||
case $$file in \
|
||||
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
|
||||
esac; \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
|
||||
dir="/$$dir"; \
|
||||
$(mkdir_p) "$(distdir)$$dir"; \
|
||||
else \
|
||||
dir=''; \
|
||||
fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
|| exit 1; \
|
||||
fi; \
|
||||
done
|
||||
check-am: all-am
|
||||
check: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) check-am
|
||||
all-am: Makefile $(LTLIBRARIES) $(HEADERS)
|
||||
installdirs:
|
||||
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(includedir)"; do \
|
||||
test -z "$$dir" || $(mkdir_p) "$$dir"; \
|
||||
done
|
||||
install: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
uninstall: uninstall-am
|
||||
|
||||
install-am: all-am
|
||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
||||
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
|
||||
clean-generic:
|
||||
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
|
||||
|
||||
distclean-generic:
|
||||
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
dvi-am:
|
||||
|
||||
html: html-am
|
||||
|
||||
info: info-am
|
||||
|
||||
info-am:
|
||||
|
||||
install-data-am: install-nobase_includeHEADERS
|
||||
|
||||
install-exec-am: install-libLTLIBRARIES
|
||||
|
||||
install-info: install-info-am
|
||||
|
||||
install-man:
|
||||
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \
|
||||
uninstall-nobase_includeHEADERS
|
||||
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libLTLIBRARIES clean-libtool ctags distclean \
|
||||
distclean-compile distclean-generic distclean-libtool \
|
||||
distclean-tags distdir dvi dvi-am html html-am info info-am \
|
||||
install install-am install-data install-data-am install-exec \
|
||||
install-exec-am install-info install-info-am \
|
||||
install-libLTLIBRARIES install-man \
|
||||
install-nobase_includeHEADERS install-strip installcheck \
|
||||
installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags uninstall uninstall-am uninstall-info-am \
|
||||
uninstall-libLTLIBRARIES uninstall-nobase_includeHEADERS
|
||||
|
||||
|
||||
vi.h: Makefile $(srcdir)/vi.c
|
||||
sh $(srcdir)/makelist -h $(srcdir)/vi.c > $@
|
||||
|
||||
emacs.h: Makefile $(srcdir)/emacs.c
|
||||
sh $(srcdir)/makelist -h $(srcdir)/emacs.c > $@
|
||||
|
||||
common.h: Makefile $(srcdir)/common.c
|
||||
sh $(srcdir)/makelist -h $(srcdir)/common.c > $@
|
||||
|
||||
fcns.h: Makefile $(AHDR)
|
||||
sh $(srcdir)/makelist -fh $(AHDR) > $@
|
||||
|
||||
help.h: Makefile $(ASRC)
|
||||
sh $(srcdir)/makelist -bh $(ASRC) > $@
|
||||
|
||||
fcns.c: Makefile $(AHDR)
|
||||
sh $(srcdir)/makelist -fc $(AHDR) > $@
|
||||
|
||||
help.c: Makefile $(ASRC)
|
||||
sh $(srcdir)/makelist -bc $(ASRC) > $@
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
.NOEXPORT:
|
777
extern/editline/src/chared.c
vendored
Normal file
777
extern/editline/src/chared.c
vendored
Normal file
@ -0,0 +1,777 @@
|
||||
/* $NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: chared.c,v 1.25 2005/08/08 01:41:30 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* chared.c: Character editor utilities
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "el.h"
|
||||
|
||||
private void ch__clearmacro __P((EditLine *));
|
||||
|
||||
/* value to leave unused in line buffer */
|
||||
#define EL_LEAVE 2
|
||||
|
||||
/* cv_undo():
|
||||
* Handle state for the vi undo command
|
||||
*/
|
||||
protected void
|
||||
cv_undo(EditLine *el)
|
||||
{
|
||||
c_undo_t *vu = &el->el_chared.c_undo;
|
||||
c_redo_t *r = &el->el_chared.c_redo;
|
||||
unsigned int size;
|
||||
|
||||
/* Save entire line for undo */
|
||||
size = el->el_line.lastchar - el->el_line.buffer;
|
||||
vu->len = size;
|
||||
vu->cursor = el->el_line.cursor - el->el_line.buffer;
|
||||
memcpy(vu->buf, el->el_line.buffer, size);
|
||||
|
||||
/* save command info for redo */
|
||||
r->count = el->el_state.doingarg ? el->el_state.argument : 0;
|
||||
r->action = el->el_chared.c_vcmd.action;
|
||||
r->pos = r->buf;
|
||||
r->cmd = el->el_state.thiscmd;
|
||||
r->ch = el->el_state.thisch;
|
||||
}
|
||||
|
||||
/* cv_yank():
|
||||
* Save yank/delete data for paste
|
||||
*/
|
||||
protected void
|
||||
cv_yank(EditLine *el, const char *ptr, int size)
|
||||
{
|
||||
c_kill_t *k = &el->el_chared.c_kill;
|
||||
|
||||
memcpy(k->buf, ptr, size +0u);
|
||||
k->last = k->buf + size;
|
||||
}
|
||||
|
||||
|
||||
/* c_insert():
|
||||
* Insert num characters
|
||||
*/
|
||||
protected void
|
||||
c_insert(EditLine *el, int num)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if (el->el_line.lastchar + num >= el->el_line.limit) {
|
||||
if (!ch_enlargebufs(el, num +0u))
|
||||
return; /* can't go past end of buffer */
|
||||
}
|
||||
|
||||
if (el->el_line.cursor < el->el_line.lastchar) {
|
||||
/* if I must move chars */
|
||||
for (cp = el->el_line.lastchar; cp >= el->el_line.cursor; cp--)
|
||||
cp[num] = *cp;
|
||||
}
|
||||
el->el_line.lastchar += num;
|
||||
}
|
||||
|
||||
|
||||
/* c_delafter():
|
||||
* Delete num characters after the cursor
|
||||
*/
|
||||
protected void
|
||||
c_delafter(EditLine *el, int num)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor + num > el->el_line.lastchar)
|
||||
num = el->el_line.lastchar - el->el_line.cursor;
|
||||
|
||||
if (el->el_map.current != el->el_map.emacs) {
|
||||
cv_undo(el);
|
||||
cv_yank(el, el->el_line.cursor, num);
|
||||
}
|
||||
|
||||
if (num > 0) {
|
||||
char *cp;
|
||||
|
||||
for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
|
||||
*cp = cp[num];
|
||||
|
||||
el->el_line.lastchar -= num;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* c_delafter1():
|
||||
* Delete the character after the cursor, do not yank
|
||||
*/
|
||||
protected void
|
||||
c_delafter1(EditLine *el)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
for (cp = el->el_line.cursor; cp <= el->el_line.lastchar; cp++)
|
||||
*cp = cp[1];
|
||||
|
||||
el->el_line.lastchar--;
|
||||
}
|
||||
|
||||
|
||||
/* c_delbefore():
|
||||
* Delete num characters before the cursor
|
||||
*/
|
||||
protected void
|
||||
c_delbefore(EditLine *el, int num)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor - num < el->el_line.buffer)
|
||||
num = el->el_line.cursor - el->el_line.buffer;
|
||||
|
||||
if (el->el_map.current != el->el_map.emacs) {
|
||||
cv_undo(el);
|
||||
cv_yank(el, el->el_line.cursor - num, num);
|
||||
}
|
||||
|
||||
if (num > 0) {
|
||||
char *cp;
|
||||
|
||||
for (cp = el->el_line.cursor - num;
|
||||
cp <= el->el_line.lastchar;
|
||||
cp++)
|
||||
*cp = cp[num];
|
||||
|
||||
el->el_line.lastchar -= num;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* c_delbefore1():
|
||||
* Delete the character before the cursor, do not yank
|
||||
*/
|
||||
protected void
|
||||
c_delbefore1(EditLine *el)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
for (cp = el->el_line.cursor - 1; cp <= el->el_line.lastchar; cp++)
|
||||
*cp = cp[1];
|
||||
|
||||
el->el_line.lastchar--;
|
||||
}
|
||||
|
||||
|
||||
/* ce__isword():
|
||||
* Return if p is part of a word according to emacs
|
||||
*/
|
||||
protected int
|
||||
ce__isword(int p)
|
||||
{
|
||||
return (isalnum(p) || strchr("*?_-.[]~=", p) != NULL);
|
||||
}
|
||||
|
||||
|
||||
/* cv__isword():
|
||||
* Return if p is part of a word according to vi
|
||||
*/
|
||||
protected int
|
||||
cv__isword(int p)
|
||||
{
|
||||
if (isalnum(p) || p == '_')
|
||||
return 1;
|
||||
if (isgraph(p))
|
||||
return 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* cv__isWord():
|
||||
* Return if p is part of a big word according to vi
|
||||
*/
|
||||
protected int
|
||||
cv__isWord(int p)
|
||||
{
|
||||
return (!isspace(p));
|
||||
}
|
||||
|
||||
|
||||
/* c__prev_word():
|
||||
* Find the previous word
|
||||
*/
|
||||
protected char *
|
||||
c__prev_word(char *p, char *low, int n, int (*wtest)(int))
|
||||
{
|
||||
p--;
|
||||
|
||||
while (n--) {
|
||||
while ((p >= low) && !(*wtest)((unsigned char) *p))
|
||||
p--;
|
||||
while ((p >= low) && (*wtest)((unsigned char) *p))
|
||||
p--;
|
||||
}
|
||||
|
||||
/* cp now points to one character before the word */
|
||||
p++;
|
||||
if (p < low)
|
||||
p = low;
|
||||
/* cp now points where we want it */
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
/* c__next_word():
|
||||
* Find the next word
|
||||
*/
|
||||
protected char *
|
||||
c__next_word(char *p, char *high, int n, int (*wtest)(int))
|
||||
{
|
||||
while (n--) {
|
||||
while ((p < high) && !(*wtest)((unsigned char) *p))
|
||||
p++;
|
||||
while ((p < high) && (*wtest)((unsigned char) *p))
|
||||
p++;
|
||||
}
|
||||
if (p > high)
|
||||
p = high;
|
||||
/* p now points where we want it */
|
||||
return (p);
|
||||
}
|
||||
|
||||
/* cv_next_word():
|
||||
* Find the next word vi style
|
||||
*/
|
||||
protected char *
|
||||
cv_next_word(EditLine *el, char *p, char *high, int n, int (*wtest)(int))
|
||||
{
|
||||
int test;
|
||||
|
||||
while (n--) {
|
||||
test = (*wtest)((unsigned char) *p);
|
||||
while ((p < high) && (*wtest)((unsigned char) *p) == test)
|
||||
p++;
|
||||
/*
|
||||
* vi historically deletes with cw only the word preserving the
|
||||
* trailing whitespace! This is not what 'w' does..
|
||||
*/
|
||||
if (n || el->el_chared.c_vcmd.action != (DELETE|INSERT))
|
||||
while ((p < high) && isspace((unsigned char) *p))
|
||||
p++;
|
||||
}
|
||||
|
||||
/* p now points where we want it */
|
||||
if (p > high)
|
||||
return (high);
|
||||
else
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
/* cv_prev_word():
|
||||
* Find the previous word vi style
|
||||
*/
|
||||
protected char *
|
||||
cv_prev_word(char *p, char *low, int n, int (*wtest)(int))
|
||||
{
|
||||
int test;
|
||||
|
||||
p--;
|
||||
while (n--) {
|
||||
while ((p > low) && isspace((unsigned char) *p))
|
||||
p--;
|
||||
test = (*wtest)((unsigned char) *p);
|
||||
while ((p >= low) && (*wtest)((unsigned char) *p) == test)
|
||||
p--;
|
||||
}
|
||||
p++;
|
||||
|
||||
/* p now points where we want it */
|
||||
if (p < low)
|
||||
return (low);
|
||||
else
|
||||
return (p);
|
||||
}
|
||||
|
||||
|
||||
#ifdef notdef
|
||||
/* c__number():
|
||||
* Ignore character p points to, return number appearing after that.
|
||||
* A '$' by itself means a big number; "$-" is for negative; '^' means 1.
|
||||
* Return p pointing to last char used.
|
||||
*/
|
||||
protected char *
|
||||
c__number(
|
||||
char *p, /* character position */
|
||||
int *num, /* Return value */
|
||||
int dval) /* dval is the number to subtract from like $-3 */
|
||||
{
|
||||
int i;
|
||||
int sign = 1;
|
||||
|
||||
if (*++p == '^') {
|
||||
*num = 1;
|
||||
return (p);
|
||||
}
|
||||
if (*p == '$') {
|
||||
if (*++p != '-') {
|
||||
*num = 0x7fffffff; /* Handle $ */
|
||||
return (--p);
|
||||
}
|
||||
sign = -1; /* Handle $- */
|
||||
++p;
|
||||
}
|
||||
for (i = 0; isdigit((unsigned char) *p); i = 10 * i + *p++ - '0')
|
||||
continue;
|
||||
*num = (sign < 0 ? dval - i : i);
|
||||
return (--p);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* cv_delfini():
|
||||
* Finish vi delete action
|
||||
*/
|
||||
protected void
|
||||
cv_delfini(EditLine *el)
|
||||
{
|
||||
int size;
|
||||
int action = el->el_chared.c_vcmd.action;
|
||||
|
||||
if (action & INSERT)
|
||||
el->el_map.current = el->el_map.key;
|
||||
|
||||
if (el->el_chared.c_vcmd.pos == 0)
|
||||
/* sanity */
|
||||
return;
|
||||
|
||||
size = el->el_line.cursor - el->el_chared.c_vcmd.pos;
|
||||
if (size == 0)
|
||||
size = 1;
|
||||
el->el_line.cursor = el->el_chared.c_vcmd.pos;
|
||||
if (action & YANK) {
|
||||
if (size > 0)
|
||||
cv_yank(el, el->el_line.cursor, size);
|
||||
else
|
||||
cv_yank(el, el->el_line.cursor + size, -size);
|
||||
} else {
|
||||
if (size > 0) {
|
||||
c_delafter(el, size);
|
||||
re_refresh_cursor(el);
|
||||
} else {
|
||||
c_delbefore(el, -size);
|
||||
el->el_line.cursor += size;
|
||||
}
|
||||
}
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
}
|
||||
|
||||
|
||||
#ifdef notdef
|
||||
/* ce__endword():
|
||||
* Go to the end of this word according to emacs
|
||||
*/
|
||||
protected char *
|
||||
ce__endword(char *p, char *high, int n)
|
||||
{
|
||||
p++;
|
||||
|
||||
while (n--) {
|
||||
while ((p < high) && isspace((unsigned char) *p))
|
||||
p++;
|
||||
while ((p < high) && !isspace((unsigned char) *p))
|
||||
p++;
|
||||
}
|
||||
|
||||
p--;
|
||||
return (p);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* cv__endword():
|
||||
* Go to the end of this word according to vi
|
||||
*/
|
||||
protected char *
|
||||
cv__endword(char *p, char *high, int n, int (*wtest)(int))
|
||||
{
|
||||
int test;
|
||||
|
||||
p++;
|
||||
|
||||
while (n--) {
|
||||
while ((p < high) && isspace((unsigned char) *p))
|
||||
p++;
|
||||
|
||||
test = (*wtest)((unsigned char) *p);
|
||||
while ((p < high) && (*wtest)((unsigned char) *p) == test)
|
||||
p++;
|
||||
}
|
||||
p--;
|
||||
return (p);
|
||||
}
|
||||
|
||||
/* ch_init():
|
||||
* Initialize the character editor
|
||||
*/
|
||||
protected int
|
||||
ch_init(EditLine *el)
|
||||
{
|
||||
c_macro_t *ma = &el->el_chared.c_macro;
|
||||
|
||||
el->el_line.buffer = (char *) el_malloc(EL_BUFSIZ);
|
||||
if (el->el_line.buffer == NULL)
|
||||
return (-1);
|
||||
|
||||
(void) memset(el->el_line.buffer, 0, EL_BUFSIZ);
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
el->el_line.limit = &el->el_line.buffer[EL_BUFSIZ - EL_LEAVE];
|
||||
|
||||
el->el_chared.c_undo.buf = (char *) el_malloc(EL_BUFSIZ);
|
||||
if (el->el_chared.c_undo.buf == NULL)
|
||||
return (-1);
|
||||
(void) memset(el->el_chared.c_undo.buf, 0, EL_BUFSIZ);
|
||||
el->el_chared.c_undo.len = -1;
|
||||
el->el_chared.c_undo.cursor = 0;
|
||||
el->el_chared.c_redo.buf = (char *) el_malloc(EL_BUFSIZ);
|
||||
if (el->el_chared.c_redo.buf == NULL)
|
||||
return (-1);
|
||||
el->el_chared.c_redo.pos = el->el_chared.c_redo.buf;
|
||||
el->el_chared.c_redo.lim = el->el_chared.c_redo.buf + EL_BUFSIZ;
|
||||
el->el_chared.c_redo.cmd = ED_UNASSIGNED;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_vcmd.pos = el->el_line.buffer;
|
||||
|
||||
el->el_chared.c_kill.buf = (char *) el_malloc(EL_BUFSIZ);
|
||||
if (el->el_chared.c_kill.buf == NULL)
|
||||
return (-1);
|
||||
(void) memset(el->el_chared.c_kill.buf, 0, EL_BUFSIZ);
|
||||
el->el_chared.c_kill.mark = el->el_line.buffer;
|
||||
el->el_chared.c_kill.last = el->el_chared.c_kill.buf;
|
||||
|
||||
el->el_map.current = el->el_map.key;
|
||||
|
||||
el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */
|
||||
el->el_state.doingarg = 0;
|
||||
el->el_state.metanext = 0;
|
||||
el->el_state.argument = 1;
|
||||
el->el_state.lastcmd = ED_UNASSIGNED;
|
||||
|
||||
ma->level = -1;
|
||||
ma->offset = 0;
|
||||
ma->macro = (char **) el_malloc(EL_MAXMACRO * sizeof(char *));
|
||||
if (ma->macro == NULL)
|
||||
return (-1);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* ch_reset():
|
||||
* Reset the character editor
|
||||
*/
|
||||
protected void
|
||||
ch_reset(EditLine *el, int mclear)
|
||||
{
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
|
||||
el->el_chared.c_undo.len = -1;
|
||||
el->el_chared.c_undo.cursor = 0;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_vcmd.pos = el->el_line.buffer;
|
||||
|
||||
el->el_chared.c_kill.mark = el->el_line.buffer;
|
||||
|
||||
el->el_map.current = el->el_map.key;
|
||||
|
||||
el->el_state.inputmode = MODE_INSERT; /* XXX: save a default */
|
||||
el->el_state.doingarg = 0;
|
||||
el->el_state.metanext = 0;
|
||||
el->el_state.argument = 1;
|
||||
el->el_state.lastcmd = ED_UNASSIGNED;
|
||||
|
||||
el->el_history.eventno = 0;
|
||||
|
||||
if (mclear)
|
||||
ch__clearmacro(el);
|
||||
}
|
||||
|
||||
private void
|
||||
ch__clearmacro(el)
|
||||
EditLine *el;
|
||||
{
|
||||
c_macro_t *ma = &el->el_chared.c_macro;
|
||||
while (ma->level >= 0)
|
||||
el_free((ptr_t)ma->macro[ma->level--]);
|
||||
}
|
||||
|
||||
/* ch_enlargebufs():
|
||||
* Enlarge line buffer to be able to hold twice as much characters.
|
||||
* Returns 1 if successful, 0 if not.
|
||||
*/
|
||||
protected int
|
||||
ch_enlargebufs(el, addlen)
|
||||
EditLine *el;
|
||||
size_t addlen;
|
||||
{
|
||||
size_t sz, newsz;
|
||||
char *newbuffer, *oldbuf, *oldkbuf;
|
||||
|
||||
sz = el->el_line.limit - el->el_line.buffer + EL_LEAVE;
|
||||
newsz = sz * 2;
|
||||
/*
|
||||
* If newly required length is longer than current buffer, we need
|
||||
* to make the buffer big enough to hold both old and new stuff.
|
||||
*/
|
||||
if (addlen > sz) {
|
||||
while(newsz - sz < addlen)
|
||||
newsz *= 2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reallocate line buffer.
|
||||
*/
|
||||
newbuffer = el_realloc(el->el_line.buffer, newsz);
|
||||
if (!newbuffer)
|
||||
return 0;
|
||||
|
||||
/* zero the newly added memory, leave old data in */
|
||||
(void) memset(&newbuffer[sz], 0, newsz - sz);
|
||||
|
||||
oldbuf = el->el_line.buffer;
|
||||
|
||||
el->el_line.buffer = newbuffer;
|
||||
el->el_line.cursor = newbuffer + (el->el_line.cursor - oldbuf);
|
||||
el->el_line.lastchar = newbuffer + (el->el_line.lastchar - oldbuf);
|
||||
/* don't set new size until all buffers are enlarged */
|
||||
el->el_line.limit = &newbuffer[sz - EL_LEAVE];
|
||||
|
||||
/*
|
||||
* Reallocate kill buffer.
|
||||
*/
|
||||
newbuffer = el_realloc(el->el_chared.c_kill.buf, newsz);
|
||||
if (!newbuffer)
|
||||
return 0;
|
||||
|
||||
/* zero the newly added memory, leave old data in */
|
||||
(void) memset(&newbuffer[sz], 0, newsz - sz);
|
||||
|
||||
oldkbuf = el->el_chared.c_kill.buf;
|
||||
|
||||
el->el_chared.c_kill.buf = newbuffer;
|
||||
el->el_chared.c_kill.last = newbuffer +
|
||||
(el->el_chared.c_kill.last - oldkbuf);
|
||||
el->el_chared.c_kill.mark = el->el_line.buffer +
|
||||
(el->el_chared.c_kill.mark - oldbuf);
|
||||
|
||||
/*
|
||||
* Reallocate undo buffer.
|
||||
*/
|
||||
newbuffer = el_realloc(el->el_chared.c_undo.buf, newsz);
|
||||
if (!newbuffer)
|
||||
return 0;
|
||||
|
||||
/* zero the newly added memory, leave old data in */
|
||||
(void) memset(&newbuffer[sz], 0, newsz - sz);
|
||||
el->el_chared.c_undo.buf = newbuffer;
|
||||
|
||||
newbuffer = el_realloc(el->el_chared.c_redo.buf, newsz);
|
||||
if (!newbuffer)
|
||||
return 0;
|
||||
el->el_chared.c_redo.pos = newbuffer +
|
||||
(el->el_chared.c_redo.pos - el->el_chared.c_redo.buf);
|
||||
el->el_chared.c_redo.lim = newbuffer +
|
||||
(el->el_chared.c_redo.lim - el->el_chared.c_redo.buf);
|
||||
el->el_chared.c_redo.buf = newbuffer;
|
||||
|
||||
if (!hist_enlargebuf(el, sz, newsz))
|
||||
return 0;
|
||||
|
||||
/* Safe to set enlarged buffer size */
|
||||
el->el_line.limit = &el->el_line.buffer[newsz - EL_LEAVE];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* ch_end():
|
||||
* Free the data structures used by the editor
|
||||
*/
|
||||
protected void
|
||||
ch_end(EditLine *el)
|
||||
{
|
||||
el_free((ptr_t) el->el_line.buffer);
|
||||
el->el_line.buffer = NULL;
|
||||
el->el_line.limit = NULL;
|
||||
el_free((ptr_t) el->el_chared.c_undo.buf);
|
||||
el->el_chared.c_undo.buf = NULL;
|
||||
el_free((ptr_t) el->el_chared.c_redo.buf);
|
||||
el->el_chared.c_redo.buf = NULL;
|
||||
el->el_chared.c_redo.pos = NULL;
|
||||
el->el_chared.c_redo.lim = NULL;
|
||||
el->el_chared.c_redo.cmd = ED_UNASSIGNED;
|
||||
el_free((ptr_t) el->el_chared.c_kill.buf);
|
||||
el->el_chared.c_kill.buf = NULL;
|
||||
ch_reset(el, 1);
|
||||
el_free((ptr_t) el->el_chared.c_macro.macro);
|
||||
el->el_chared.c_macro.macro = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* el_insertstr():
|
||||
* Insert string at cursorI
|
||||
*/
|
||||
public int
|
||||
el_insertstr(EditLine *el, const char *s)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if ((len = strlen(s)) == 0)
|
||||
return (-1);
|
||||
if (el->el_line.lastchar + len >= el->el_line.limit) {
|
||||
if (!ch_enlargebufs(el, len))
|
||||
return (-1);
|
||||
}
|
||||
|
||||
c_insert(el, (int)len);
|
||||
while (*s)
|
||||
*el->el_line.cursor++ = *s++;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* el_deletestr():
|
||||
* Delete num characters before the cursor
|
||||
*/
|
||||
public void
|
||||
el_deletestr(EditLine *el, int n)
|
||||
{
|
||||
if (n <= 0)
|
||||
return;
|
||||
|
||||
if (el->el_line.cursor < &el->el_line.buffer[n])
|
||||
return;
|
||||
|
||||
c_delbefore(el, n); /* delete before dot */
|
||||
el->el_line.cursor -= n;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
}
|
||||
|
||||
/* c_gets():
|
||||
* Get a string
|
||||
*/
|
||||
protected int
|
||||
c_gets(EditLine *el, char *buf, const char *prompt)
|
||||
{
|
||||
char ch;
|
||||
int len;
|
||||
char *cp = el->el_line.buffer;
|
||||
|
||||
if (prompt) {
|
||||
len = strlen(prompt);
|
||||
memcpy(cp, prompt, len + 0u);
|
||||
cp += len;
|
||||
}
|
||||
len = 0;
|
||||
|
||||
for (;;) {
|
||||
el->el_line.cursor = cp;
|
||||
*cp = ' ';
|
||||
el->el_line.lastchar = cp + 1;
|
||||
re_refresh(el);
|
||||
|
||||
if (el_getc(el, &ch) != 1) {
|
||||
ed_end_of_file(el, 0);
|
||||
len = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (ch) {
|
||||
|
||||
case 0010: /* Delete and backspace */
|
||||
case 0177:
|
||||
if (len <= 0) {
|
||||
len = -1;
|
||||
break;
|
||||
}
|
||||
cp--;
|
||||
continue;
|
||||
|
||||
case 0033: /* ESC */
|
||||
case '\r': /* Newline */
|
||||
case '\n':
|
||||
buf[len] = ch;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (len >= EL_BUFSIZ - 16)
|
||||
term_beep(el);
|
||||
else {
|
||||
buf[len++] = ch;
|
||||
*cp++ = ch;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
el->el_line.buffer[0] = '\0';
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return len;
|
||||
}
|
||||
|
||||
|
||||
/* c_hpos():
|
||||
* Return the current horizontal position of the cursor
|
||||
*/
|
||||
protected int
|
||||
c_hpos(EditLine *el)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
/*
|
||||
* Find how many characters till the beginning of this line.
|
||||
*/
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
return (0);
|
||||
else {
|
||||
for (ptr = el->el_line.cursor - 1;
|
||||
ptr >= el->el_line.buffer && *ptr != '\n';
|
||||
ptr--)
|
||||
continue;
|
||||
return (el->el_line.cursor - ptr - 1);
|
||||
}
|
||||
}
|
167
extern/editline/src/chared.h
vendored
Normal file
167
extern/editline/src/chared.h
vendored
Normal file
@ -0,0 +1,167 @@
|
||||
/* $NetBSD: chared.h,v 1.17 2006/03/06 21:11:56 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)chared.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.chared.h: Character editor interface
|
||||
*/
|
||||
#ifndef _h_el_chared
|
||||
#define _h_el_chared
|
||||
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
#define EL_MAXMACRO 10
|
||||
|
||||
/*
|
||||
* This is an issue of basic "vi" look-and-feel. Defining VI_MOVE works
|
||||
* like real vi: i.e. the transition from command<->insert modes moves
|
||||
* the cursor.
|
||||
*
|
||||
* On the other hand we really don't want to move the cursor, because
|
||||
* all the editing commands don't include the character under the cursor.
|
||||
* Probably the best fix is to make all the editing commands aware of
|
||||
* this fact.
|
||||
*/
|
||||
#define VI_MOVE
|
||||
|
||||
|
||||
typedef struct c_macro_t {
|
||||
int level;
|
||||
int offset;
|
||||
char **macro;
|
||||
} c_macro_t;
|
||||
|
||||
/*
|
||||
* Undo information for vi - no undo in emacs (yet)
|
||||
*/
|
||||
typedef struct c_undo_t {
|
||||
int len; /* length of saved line */
|
||||
int cursor; /* position of saved cursor */
|
||||
char *buf; /* full saved text */
|
||||
} c_undo_t;
|
||||
|
||||
/* redo for vi */
|
||||
typedef struct c_redo_t {
|
||||
char *buf; /* redo insert key sequence */
|
||||
char *pos;
|
||||
char *lim;
|
||||
el_action_t cmd; /* command to redo */
|
||||
char ch; /* char that invoked it */
|
||||
int count;
|
||||
int action; /* from cv_action() */
|
||||
} c_redo_t;
|
||||
|
||||
/*
|
||||
* Current action information for vi
|
||||
*/
|
||||
typedef struct c_vcmd_t {
|
||||
int action;
|
||||
char *pos;
|
||||
} c_vcmd_t;
|
||||
|
||||
/*
|
||||
* Kill buffer for emacs
|
||||
*/
|
||||
typedef struct c_kill_t {
|
||||
char *buf;
|
||||
char *last;
|
||||
char *mark;
|
||||
} c_kill_t;
|
||||
|
||||
/*
|
||||
* Note that we use both data structures because the user can bind
|
||||
* commands from both editors!
|
||||
*/
|
||||
typedef struct el_chared_t {
|
||||
c_undo_t c_undo;
|
||||
c_kill_t c_kill;
|
||||
c_redo_t c_redo;
|
||||
c_vcmd_t c_vcmd;
|
||||
c_macro_t c_macro;
|
||||
} el_chared_t;
|
||||
|
||||
|
||||
#define STRQQ "\"\""
|
||||
|
||||
#define isglob(a) (strchr("*[]?", (a)) != NULL)
|
||||
#define isword(a) (isprint(a))
|
||||
|
||||
#define NOP 0x00
|
||||
#define DELETE 0x01
|
||||
#define INSERT 0x02
|
||||
#define YANK 0x04
|
||||
|
||||
#define CHAR_FWD (+1)
|
||||
#define CHAR_BACK (-1)
|
||||
|
||||
#define MODE_INSERT 0
|
||||
#define MODE_REPLACE 1
|
||||
#define MODE_REPLACE_1 2
|
||||
|
||||
#include "common.h"
|
||||
#include "vi.h"
|
||||
#include "emacs.h"
|
||||
#include "search.h"
|
||||
#include "fcns.h"
|
||||
|
||||
|
||||
protected int cv__isword(int);
|
||||
protected int cv__isWord(int);
|
||||
protected void cv_delfini(EditLine *);
|
||||
protected char *cv__endword(char *, char *, int, int (*)(int));
|
||||
protected int ce__isword(int);
|
||||
protected void cv_undo(EditLine *);
|
||||
protected void cv_yank(EditLine *, const char *, int);
|
||||
protected char *cv_next_word(EditLine*, char *, char *, int, int (*)(int));
|
||||
protected char *cv_prev_word(char *, char *, int, int (*)(int));
|
||||
protected char *c__next_word(char *, char *, int, int (*)(int));
|
||||
protected char *c__prev_word(char *, char *, int, int (*)(int));
|
||||
protected void c_insert(EditLine *, int);
|
||||
protected void c_delbefore(EditLine *, int);
|
||||
protected void c_delbefore1(EditLine *);
|
||||
protected void c_delafter(EditLine *, int);
|
||||
protected void c_delafter1(EditLine *);
|
||||
protected int c_gets(EditLine *, char *, const char *);
|
||||
protected int c_hpos(EditLine *);
|
||||
|
||||
protected int ch_init(EditLine *);
|
||||
protected void ch_reset(EditLine *, int);
|
||||
protected int ch_enlargebufs(EditLine *, size_t);
|
||||
protected void ch_end(EditLine *);
|
||||
|
||||
#endif /* _h_el_chared */
|
921
extern/editline/src/common.c
vendored
Normal file
921
extern/editline/src/common.c
vendored
Normal file
@ -0,0 +1,921 @@
|
||||
/* $NetBSD: common.c,v 1.19 2006/03/06 21:11:56 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)common.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: common.c,v 1.19 2006/03/06 21:11:56 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* common.c: Common Editor functions
|
||||
*/
|
||||
#include "el.h"
|
||||
|
||||
/* ed_end_of_file():
|
||||
* Indicate end of file
|
||||
* [^D]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_end_of_file(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
re_goto_bottom(el);
|
||||
*el->el_line.lastchar = '\0';
|
||||
return (CC_EOF);
|
||||
}
|
||||
|
||||
|
||||
/* ed_insert():
|
||||
* Add character to the line
|
||||
* Insert a character [bound to all insert keys]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_insert(EditLine *el, int c)
|
||||
{
|
||||
int count = el->el_state.argument;
|
||||
|
||||
if (c == '\0')
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_line.lastchar + el->el_state.argument >=
|
||||
el->el_line.limit) {
|
||||
/* end of buffer space, try to allocate more */
|
||||
if (!ch_enlargebufs(el, (size_t) count))
|
||||
return CC_ERROR; /* error allocating more */
|
||||
}
|
||||
|
||||
if (count == 1) {
|
||||
if (el->el_state.inputmode == MODE_INSERT
|
||||
|| el->el_line.cursor >= el->el_line.lastchar)
|
||||
c_insert(el, 1);
|
||||
|
||||
*el->el_line.cursor++ = c;
|
||||
re_fastaddc(el); /* fast refresh for one char. */
|
||||
} else {
|
||||
if (el->el_state.inputmode != MODE_REPLACE_1)
|
||||
c_insert(el, el->el_state.argument);
|
||||
|
||||
while (count-- && el->el_line.cursor < el->el_line.lastchar)
|
||||
*el->el_line.cursor++ = c;
|
||||
re_refresh(el);
|
||||
}
|
||||
|
||||
if (el->el_state.inputmode == MODE_REPLACE_1)
|
||||
return vi_command_mode(el, 0);
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_delete_prev_word():
|
||||
* Delete from beginning of current word to cursor
|
||||
* [M-^?] [^W]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_prev_word(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *p, *kp;
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
for (p = cp, kp = el->el_chared.c_kill.buf; p < el->el_line.cursor; p++)
|
||||
*kp++ = *p;
|
||||
el->el_chared.c_kill.last = kp;
|
||||
|
||||
c_delbefore(el, el->el_line.cursor - cp); /* delete before dot */
|
||||
el->el_line.cursor = cp;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer; /* bounds check */
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_delete_next_char():
|
||||
* Delete character under cursor
|
||||
* [^D] [x]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_next_char(EditLine *el, int c)
|
||||
{
|
||||
#ifdef notdef /* XXX */
|
||||
#define EL el->el_line
|
||||
(void) fprintf(el->el_errlfile,
|
||||
"\nD(b: %x(%s) c: %x(%s) last: %x(%s) limit: %x(%s)\n",
|
||||
EL.buffer, EL.buffer, EL.cursor, EL.cursor, EL.lastchar,
|
||||
EL.lastchar, EL.limit, EL.limit);
|
||||
#endif
|
||||
if (el->el_line.cursor == el->el_line.lastchar) {
|
||||
/* if I'm at the end */
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
if (el->el_line.cursor == el->el_line.buffer) {
|
||||
/* if I'm also at the beginning */
|
||||
#ifdef KSHVI
|
||||
return (CC_ERROR);
|
||||
#else
|
||||
/* then do an EOF */
|
||||
term_writechar(el, c);
|
||||
return (CC_EOF);
|
||||
#endif
|
||||
} else {
|
||||
#ifdef KSHVI
|
||||
el->el_line.cursor--;
|
||||
#else
|
||||
return (CC_ERROR);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (el->el_line.cursor != el->el_line.buffer)
|
||||
el->el_line.cursor--;
|
||||
else
|
||||
return (CC_ERROR);
|
||||
}
|
||||
}
|
||||
c_delafter(el, el->el_state.argument); /* delete after dot */
|
||||
if (el->el_line.cursor >= el->el_line.lastchar &&
|
||||
el->el_line.cursor > el->el_line.buffer)
|
||||
/* bounds check */
|
||||
el->el_line.cursor = el->el_line.lastchar - 1;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_kill_line():
|
||||
* Cut to the end of line
|
||||
* [^K] [^K]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_kill_line(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *kp, *cp;
|
||||
|
||||
cp = el->el_line.cursor;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_line.lastchar)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
/* zap! -- delete to end */
|
||||
el->el_line.lastchar = el->el_line.cursor;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_move_to_end():
|
||||
* Move cursor to the end of line
|
||||
* [^E] [^E]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_move_to_end(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
#ifdef VI_MOVE
|
||||
el->el_line.cursor--;
|
||||
#endif
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_move_to_beg():
|
||||
* Move cursor to the beginning of line
|
||||
* [^A] [^A]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_move_to_beg(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
/* We want FIRST non space character */
|
||||
while (isspace((unsigned char) *el->el_line.cursor))
|
||||
el->el_line.cursor++;
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_transpose_chars():
|
||||
* Exchange the character to the left of the cursor with the one under it
|
||||
* [^T] [^T]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_transpose_chars(EditLine *el, int c)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor < el->el_line.lastchar) {
|
||||
if (el->el_line.lastchar <= &el->el_line.buffer[1])
|
||||
return (CC_ERROR);
|
||||
else
|
||||
el->el_line.cursor++;
|
||||
}
|
||||
if (el->el_line.cursor > &el->el_line.buffer[1]) {
|
||||
/* must have at least two chars entered */
|
||||
c = el->el_line.cursor[-2];
|
||||
el->el_line.cursor[-2] = el->el_line.cursor[-1];
|
||||
el->el_line.cursor[-1] = c;
|
||||
return (CC_REFRESH);
|
||||
} else
|
||||
return (CC_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_next_char():
|
||||
* Move to the right one character
|
||||
* [^F] [^F]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *lim = el->el_line.lastchar;
|
||||
|
||||
if (el->el_line.cursor >= lim ||
|
||||
(el->el_line.cursor == lim - 1 &&
|
||||
el->el_map.type == MAP_VI &&
|
||||
el->el_chared.c_vcmd.action == NOP))
|
||||
return (CC_ERROR);
|
||||
|
||||
el->el_line.cursor += el->el_state.argument;
|
||||
if (el->el_line.cursor > lim)
|
||||
el->el_line.cursor = lim;
|
||||
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_prev_word():
|
||||
* Move to the beginning of the current word
|
||||
* [M-b] [b]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_word(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
el->el_line.cursor = c__prev_word(el->el_line.cursor,
|
||||
el->el_line.buffer,
|
||||
el->el_state.argument,
|
||||
ce__isword);
|
||||
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_prev_char():
|
||||
* Move to the left one character
|
||||
* [^B] [^B]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor > el->el_line.buffer) {
|
||||
el->el_line.cursor -= el->el_state.argument;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
} else
|
||||
return (CC_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_quoted_insert():
|
||||
* Add the next character typed verbatim
|
||||
* [^V] [^V]
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_quoted_insert(EditLine *el, int c)
|
||||
{
|
||||
int num;
|
||||
char tc;
|
||||
|
||||
tty_quotemode(el);
|
||||
num = el_getc(el, &tc);
|
||||
c = (unsigned char) tc;
|
||||
tty_noquotemode(el);
|
||||
if (num == 1)
|
||||
return (ed_insert(el, c));
|
||||
else
|
||||
return (ed_end_of_file(el, 0));
|
||||
}
|
||||
|
||||
|
||||
/* ed_digit():
|
||||
* Adds to argument or enters a digit
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_digit(EditLine *el, int c)
|
||||
{
|
||||
|
||||
if (!isdigit(c))
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_state.doingarg) {
|
||||
/* if doing an arg, add this in... */
|
||||
if (el->el_state.lastcmd == EM_UNIVERSAL_ARGUMENT)
|
||||
el->el_state.argument = c - '0';
|
||||
else {
|
||||
if (el->el_state.argument > 1000000)
|
||||
return (CC_ERROR);
|
||||
el->el_state.argument =
|
||||
(el->el_state.argument * 10) + (c - '0');
|
||||
}
|
||||
return (CC_ARGHACK);
|
||||
}
|
||||
|
||||
return ed_insert(el, c);
|
||||
}
|
||||
|
||||
|
||||
/* ed_argument_digit():
|
||||
* Digit that starts argument
|
||||
* For ESC-n
|
||||
*/
|
||||
protected el_action_t
|
||||
ed_argument_digit(EditLine *el, int c)
|
||||
{
|
||||
|
||||
if (!isdigit(c))
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_state.doingarg) {
|
||||
if (el->el_state.argument > 1000000)
|
||||
return (CC_ERROR);
|
||||
el->el_state.argument = (el->el_state.argument * 10) +
|
||||
(c - '0');
|
||||
} else { /* else starting an argument */
|
||||
el->el_state.argument = c - '0';
|
||||
el->el_state.doingarg = 1;
|
||||
}
|
||||
return (CC_ARGHACK);
|
||||
}
|
||||
|
||||
|
||||
/* ed_unassigned():
|
||||
* Indicates unbound character
|
||||
* Bound to keys that are not assigned
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_unassigned(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
** TTY key handling.
|
||||
**/
|
||||
|
||||
/* ed_tty_sigint():
|
||||
* Tty interrupt character
|
||||
* [^C]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigint(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_dsusp():
|
||||
* Tty delayed suspend character
|
||||
* [^Y]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_dsusp(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_flush_output():
|
||||
* Tty flush output characters
|
||||
* [^O]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_flush_output(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_sigquit():
|
||||
* Tty quit character
|
||||
* [^\]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigquit(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_sigtstp():
|
||||
* Tty suspend character
|
||||
* [^Z]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_sigtstp(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_stop_output():
|
||||
* Tty disallow output characters
|
||||
* [^S]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_stop_output(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_tty_start_output():
|
||||
* Tty allow output characters
|
||||
* [^Q]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_tty_start_output(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_newline():
|
||||
* Execute command
|
||||
* [^J]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_newline(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
re_goto_bottom(el);
|
||||
*el->el_line.lastchar++ = '\n';
|
||||
*el->el_line.lastchar = '\0';
|
||||
return (CC_NEWLINE);
|
||||
}
|
||||
|
||||
|
||||
/* ed_delete_prev_char():
|
||||
* Delete the character to the left of the cursor
|
||||
* [^?]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor <= el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
c_delbefore(el, el->el_state.argument);
|
||||
el->el_line.cursor -= el->el_state.argument;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_clear_screen():
|
||||
* Clear screen leaving current line at the top
|
||||
* [^L]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_clear_screen(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
term_clear_screen(el); /* clear the whole real screen */
|
||||
re_clear_display(el); /* reset everything */
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_redisplay():
|
||||
* Redisplay everything
|
||||
* ^R
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_redisplay(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_REDISPLAY);
|
||||
}
|
||||
|
||||
|
||||
/* ed_start_over():
|
||||
* Erase current line and start from scratch
|
||||
* [^G]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_start_over(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
ch_reset(el, 0);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ed_sequence_lead_in():
|
||||
* First character in a bound sequence
|
||||
* Placeholder for external keys
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_sequence_lead_in(EditLine *el __attribute__((__unused__)),
|
||||
int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* ed_prev_history():
|
||||
* Move to the previous history line
|
||||
* [^P] [k]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_history(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char beep = 0;
|
||||
int sv_event = el->el_history.eventno;
|
||||
|
||||
el->el_chared.c_undo.len = -1;
|
||||
*el->el_line.lastchar = '\0'; /* just in case */
|
||||
|
||||
if (el->el_history.eventno == 0) { /* save the current buffer
|
||||
* away */
|
||||
(void) strncpy(el->el_history.buf, el->el_line.buffer,
|
||||
EL_BUFSIZ);
|
||||
el->el_history.last = el->el_history.buf +
|
||||
(el->el_line.lastchar - el->el_line.buffer);
|
||||
}
|
||||
el->el_history.eventno += el->el_state.argument;
|
||||
|
||||
if (hist_get(el) == CC_ERROR) {
|
||||
if (el->el_map.type == MAP_VI) {
|
||||
el->el_history.eventno = sv_event;
|
||||
return CC_ERROR;
|
||||
}
|
||||
beep = 1;
|
||||
/* el->el_history.eventno was fixed by first call */
|
||||
(void) hist_get(el);
|
||||
}
|
||||
if (beep)
|
||||
return CC_REFRESH_BEEP;
|
||||
return CC_REFRESH;
|
||||
}
|
||||
|
||||
|
||||
/* ed_next_history():
|
||||
* Move to the next history line
|
||||
* [^N] [j]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_history(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
el_action_t beep = CC_REFRESH, rval;
|
||||
|
||||
el->el_chared.c_undo.len = -1;
|
||||
*el->el_line.lastchar = '\0'; /* just in case */
|
||||
|
||||
el->el_history.eventno -= el->el_state.argument;
|
||||
|
||||
if (el->el_history.eventno < 0) {
|
||||
el->el_history.eventno = 0;
|
||||
beep = CC_REFRESH_BEEP;
|
||||
}
|
||||
rval = hist_get(el);
|
||||
if (rval == CC_REFRESH)
|
||||
return beep;
|
||||
return rval;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* ed_search_prev_history():
|
||||
* Search previous in history for a line matching the current
|
||||
* next search history [M-P] [K]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_search_prev_history(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
const char *hp;
|
||||
int h;
|
||||
bool_t found = 0;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_undo.len = -1;
|
||||
*el->el_line.lastchar = '\0'; /* just in case */
|
||||
if (el->el_history.eventno < 0) {
|
||||
#ifdef DEBUG_EDIT
|
||||
(void) fprintf(el->el_errfile,
|
||||
"e_prev_search_hist(): eventno < 0;\n");
|
||||
#endif
|
||||
el->el_history.eventno = 0;
|
||||
return (CC_ERROR);
|
||||
}
|
||||
if (el->el_history.eventno == 0) {
|
||||
(void) strncpy(el->el_history.buf, el->el_line.buffer,
|
||||
EL_BUFSIZ);
|
||||
el->el_history.last = el->el_history.buf +
|
||||
(el->el_line.lastchar - el->el_line.buffer);
|
||||
}
|
||||
if (el->el_history.ref == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
hp = HIST_FIRST(el);
|
||||
if (hp == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
c_setpat(el); /* Set search pattern !! */
|
||||
|
||||
for (h = 1; h <= el->el_history.eventno; h++)
|
||||
hp = HIST_NEXT(el);
|
||||
|
||||
while (hp != NULL) {
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
|
||||
#endif
|
||||
if ((strncmp(hp, el->el_line.buffer, (size_t)
|
||||
(el->el_line.lastchar - el->el_line.buffer)) ||
|
||||
hp[el->el_line.lastchar - el->el_line.buffer]) &&
|
||||
c_hmatch(el, hp)) {
|
||||
found++;
|
||||
break;
|
||||
}
|
||||
h++;
|
||||
hp = HIST_NEXT(el);
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "not found\n");
|
||||
#endif
|
||||
return (CC_ERROR);
|
||||
}
|
||||
el->el_history.eventno = h;
|
||||
|
||||
return (hist_get(el));
|
||||
}
|
||||
|
||||
|
||||
/* ed_search_next_history():
|
||||
* Search next in history for a line matching the current
|
||||
* [M-N] [J]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_search_next_history(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
const char *hp;
|
||||
int h;
|
||||
bool_t found = 0;
|
||||
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
el->el_chared.c_undo.len = -1;
|
||||
*el->el_line.lastchar = '\0'; /* just in case */
|
||||
|
||||
if (el->el_history.eventno == 0)
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_history.ref == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
hp = HIST_FIRST(el);
|
||||
if (hp == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
c_setpat(el); /* Set search pattern !! */
|
||||
|
||||
for (h = 1; h < el->el_history.eventno && hp; h++) {
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "Comparing with \"%s\"\n", hp);
|
||||
#endif
|
||||
if ((strncmp(hp, el->el_line.buffer, (size_t)
|
||||
(el->el_line.lastchar - el->el_line.buffer)) ||
|
||||
hp[el->el_line.lastchar - el->el_line.buffer]) &&
|
||||
c_hmatch(el, hp))
|
||||
found = h;
|
||||
hp = HIST_NEXT(el);
|
||||
}
|
||||
|
||||
if (!found) { /* is it the current history number? */
|
||||
if (!c_hmatch(el, el->el_history.buf)) {
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "not found\n");
|
||||
#endif
|
||||
return (CC_ERROR);
|
||||
}
|
||||
}
|
||||
el->el_history.eventno = found;
|
||||
|
||||
return (hist_get(el));
|
||||
}
|
||||
|
||||
|
||||
/* ed_prev_line():
|
||||
* Move up one line
|
||||
* Could be [k] [^p]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_prev_line(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *ptr;
|
||||
int nchars = c_hpos(el);
|
||||
|
||||
/*
|
||||
* Move to the line requested
|
||||
*/
|
||||
if (*(ptr = el->el_line.cursor) == '\n')
|
||||
ptr--;
|
||||
|
||||
for (; ptr >= el->el_line.buffer; ptr--)
|
||||
if (*ptr == '\n' && --el->el_state.argument <= 0)
|
||||
break;
|
||||
|
||||
if (el->el_state.argument > 0)
|
||||
return (CC_ERROR);
|
||||
|
||||
/*
|
||||
* Move to the beginning of the line
|
||||
*/
|
||||
for (ptr--; ptr >= el->el_line.buffer && *ptr != '\n'; ptr--)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Move to the character requested
|
||||
*/
|
||||
for (ptr++;
|
||||
nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
|
||||
ptr++)
|
||||
continue;
|
||||
|
||||
el->el_line.cursor = ptr;
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_next_line():
|
||||
* Move down one line
|
||||
* Could be [j] [^n]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_next_line(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *ptr;
|
||||
int nchars = c_hpos(el);
|
||||
|
||||
/*
|
||||
* Move to the line requested
|
||||
*/
|
||||
for (ptr = el->el_line.cursor; ptr < el->el_line.lastchar; ptr++)
|
||||
if (*ptr == '\n' && --el->el_state.argument <= 0)
|
||||
break;
|
||||
|
||||
if (el->el_state.argument > 0)
|
||||
return (CC_ERROR);
|
||||
|
||||
/*
|
||||
* Move to the character requested
|
||||
*/
|
||||
for (ptr++;
|
||||
nchars-- > 0 && ptr < el->el_line.lastchar && *ptr != '\n';
|
||||
ptr++)
|
||||
continue;
|
||||
|
||||
el->el_line.cursor = ptr;
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* ed_command():
|
||||
* Editline extended command
|
||||
* [M-X] [:]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
ed_command(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char tmpbuf[EL_BUFSIZ];
|
||||
int tmplen;
|
||||
|
||||
tmplen = c_gets(el, tmpbuf, "\n: ");
|
||||
term__putc('\n');
|
||||
|
||||
if (tmplen < 0 || (tmpbuf[tmplen] = 0, parse_line(el, tmpbuf)) == -1)
|
||||
term_beep(el);
|
||||
|
||||
el->el_map.current = el->el_map.key;
|
||||
re_clear_display(el);
|
||||
return CC_REFRESH;
|
||||
}
|
202
extern/editline/src/editline/readline.h
vendored
Normal file
202
extern/editline/src/editline/readline.h
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
/* $NetBSD: readline.h,v 1.19 2006/11/24 00:01:17 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jaromir Dolecek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _READLINE_H_
|
||||
#define _READLINE_H_
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
/* list of readline stuff supported by editline library's readline wrapper */
|
||||
|
||||
/* typedefs */
|
||||
typedef int Function(const char *, int);
|
||||
typedef void VFunction(void);
|
||||
typedef void VCPFunction(char *);
|
||||
typedef char *CPFunction(const char *, int);
|
||||
typedef char **CPPFunction(const char *, int, int);
|
||||
|
||||
typedef void *histdata_t;
|
||||
|
||||
typedef struct _hist_entry {
|
||||
const char *line;
|
||||
histdata_t *data;
|
||||
} HIST_ENTRY;
|
||||
|
||||
typedef struct _keymap_entry {
|
||||
char type;
|
||||
#define ISFUNC 0
|
||||
#define ISKMAP 1
|
||||
#define ISMACR 2
|
||||
Function *function;
|
||||
} KEYMAP_ENTRY;
|
||||
|
||||
#define KEYMAP_SIZE 256
|
||||
|
||||
typedef KEYMAP_ENTRY KEYMAP_ENTRY_ARRAY[KEYMAP_SIZE];
|
||||
typedef KEYMAP_ENTRY *Keymap;
|
||||
|
||||
#define control_character_threshold 0x20
|
||||
#define control_character_bit 0x40
|
||||
|
||||
#ifndef CTRL
|
||||
#include <sys/ioctl.h>
|
||||
#ifdef __GLIBC__
|
||||
#include <sys/ttydefaults.h>
|
||||
#endif
|
||||
#ifndef CTRL
|
||||
#define CTRL(c) ((c) & 037)
|
||||
#endif
|
||||
#endif
|
||||
#ifndef UNCTRL
|
||||
#define UNCTRL(c) (((c) - 'a' + 'A')|control_character_bit)
|
||||
#endif
|
||||
|
||||
#define RUBOUT 0x7f
|
||||
#define ABORT_CHAR CTRL('G')
|
||||
|
||||
/* global variables used by readline enabled applications */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
extern const char *rl_library_version;
|
||||
extern char *rl_readline_name;
|
||||
extern FILE *rl_instream;
|
||||
extern FILE *rl_outstream;
|
||||
extern char *rl_line_buffer;
|
||||
extern int rl_point, rl_end;
|
||||
extern int history_base, history_length;
|
||||
extern int max_input_history;
|
||||
extern char *rl_basic_word_break_characters;
|
||||
extern char *rl_completer_word_break_characters;
|
||||
extern char *rl_completer_quote_characters;
|
||||
extern Function *rl_completion_entry_function;
|
||||
extern CPPFunction *rl_attempted_completion_function;
|
||||
extern int rl_attempted_completion_over;
|
||||
extern int rl_completion_type;
|
||||
extern int rl_completion_query_items;
|
||||
extern char *rl_special_prefixes;
|
||||
extern int rl_completion_append_character;
|
||||
extern int rl_inhibit_completion;
|
||||
extern Function *rl_pre_input_hook;
|
||||
extern Function *rl_startup_hook;
|
||||
extern char *rl_terminal_name;
|
||||
extern int rl_already_prompted;
|
||||
extern char *rl_prompt;
|
||||
/*
|
||||
* The following is not implemented
|
||||
*/
|
||||
extern KEYMAP_ENTRY_ARRAY emacs_standard_keymap,
|
||||
emacs_meta_keymap,
|
||||
emacs_ctlx_keymap;
|
||||
extern int rl_filename_completion_desired;
|
||||
extern int rl_ignore_completion_duplicates;
|
||||
extern Function *rl_getc_function;
|
||||
extern VFunction *rl_redisplay_function;
|
||||
extern VFunction *rl_completion_display_matches_hook;
|
||||
extern VFunction *rl_prep_term_function;
|
||||
extern VFunction *rl_deprep_term_function;
|
||||
extern int readline_echoing_p;
|
||||
extern int _rl_print_completions_horizontally;
|
||||
|
||||
/* supported functions */
|
||||
char *readline(const char *);
|
||||
int rl_initialize(void);
|
||||
|
||||
void using_history(void);
|
||||
int add_history(const char *);
|
||||
void clear_history(void);
|
||||
void stifle_history(int);
|
||||
int unstifle_history(void);
|
||||
int history_is_stifled(void);
|
||||
int where_history(void);
|
||||
HIST_ENTRY *current_history(void);
|
||||
HIST_ENTRY *history_get(int);
|
||||
HIST_ENTRY *remove_history(int);
|
||||
int history_total_bytes(void);
|
||||
int history_set_pos(int);
|
||||
HIST_ENTRY *previous_history(void);
|
||||
HIST_ENTRY *next_history(void);
|
||||
int history_search(const char *, int);
|
||||
int history_search_prefix(const char *, int);
|
||||
int history_search_pos(const char *, int, int);
|
||||
int read_history(const char *);
|
||||
int write_history(const char *);
|
||||
int history_expand(char *, char **);
|
||||
char **history_tokenize(const char *);
|
||||
const char *get_history_event(const char *, int *, int);
|
||||
char *history_arg_extract(int, int, const char *);
|
||||
|
||||
char *tilde_expand(char *);
|
||||
char *filename_completion_function(const char *, int);
|
||||
char *username_completion_function(const char *, int);
|
||||
int rl_complete(int, int);
|
||||
int rl_read_key(void);
|
||||
char **completion_matches(const char *, CPFunction *);
|
||||
void rl_display_match_list(char **, int, int);
|
||||
|
||||
int rl_insert(int, int);
|
||||
void rl_reset_terminal(const char *);
|
||||
int rl_bind_key(int, int (*)(int, int));
|
||||
int rl_newline(int, int);
|
||||
void rl_callback_read_char(void);
|
||||
void rl_callback_handler_install(const char *, VCPFunction *);
|
||||
void rl_callback_handler_remove(void);
|
||||
void rl_redisplay(void);
|
||||
int rl_get_previous_history(int, int);
|
||||
void rl_prep_terminal(int);
|
||||
void rl_deprep_terminal(void);
|
||||
int rl_read_init_file(const char *);
|
||||
int rl_parse_and_bind(const char *);
|
||||
int rl_variable_bind(const char *, const char *);
|
||||
void rl_stuff_char(int);
|
||||
int rl_add_defun(const char *, Function *, int);
|
||||
void rl_get_screen_size(int *, int *);
|
||||
void rl_set_screen_size(int, int);
|
||||
char *rl_filename_completion_function (const char *, int);
|
||||
int _rl_abort_internal(void);
|
||||
int _rl_qsort_string_compare(char **, char **);
|
||||
|
||||
/*
|
||||
* The following are not implemented
|
||||
*/
|
||||
int rl_kill_text(int, int);
|
||||
Keymap rl_get_keymap(void);
|
||||
void rl_set_keymap(Keymap);
|
||||
Keymap rl_make_bare_keymap(void);
|
||||
int rl_generic_bind(int, const char *, const char *, Keymap);
|
||||
int rl_bind_key_in_map(int, Function *, Keymap);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _READLINE_H_ */
|
572
extern/editline/src/el.c
vendored
Normal file
572
extern/editline/src/el.c
vendored
Normal file
@ -0,0 +1,572 @@
|
||||
/* $NetBSD: el.c,v 1.44 2006/12/15 22:13:33 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
|
||||
#else
|
||||
__RCSID("$NetBSD: el.c,v 1.44 2006/12/15 22:13:33 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* el.c: EditLine interface functions
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include "el.h"
|
||||
|
||||
/* el_init():
|
||||
* Initialize editline and set default parameters.
|
||||
*/
|
||||
public EditLine *
|
||||
el_init(const char *prog, FILE *fin, FILE *fout, FILE *ferr)
|
||||
{
|
||||
|
||||
EditLine *el = (EditLine *) el_malloc(sizeof(EditLine));
|
||||
|
||||
if (el == NULL)
|
||||
return (NULL);
|
||||
|
||||
memset(el, 0, sizeof(EditLine));
|
||||
|
||||
el->el_infile = fin;
|
||||
el->el_outfile = fout;
|
||||
el->el_errfile = ferr;
|
||||
|
||||
el->el_infd = fileno(fin);
|
||||
|
||||
if ((el->el_prog = el_strdup(prog)) == NULL) {
|
||||
el_free(el);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize all the modules. Order is important!!!
|
||||
*/
|
||||
el->el_flags = 0;
|
||||
|
||||
if (term_init(el) == -1) {
|
||||
el_free(el->el_prog);
|
||||
el_free(el);
|
||||
return NULL;
|
||||
}
|
||||
(void) key_init(el);
|
||||
(void) map_init(el);
|
||||
if (tty_init(el) == -1)
|
||||
el->el_flags |= NO_TTY;
|
||||
(void) ch_init(el);
|
||||
(void) search_init(el);
|
||||
(void) hist_init(el);
|
||||
(void) prompt_init(el);
|
||||
(void) sig_init(el);
|
||||
(void) read_init(el);
|
||||
|
||||
return (el);
|
||||
}
|
||||
|
||||
|
||||
/* el_end():
|
||||
* Clean up.
|
||||
*/
|
||||
public void
|
||||
el_end(EditLine *el)
|
||||
{
|
||||
|
||||
if (el == NULL)
|
||||
return;
|
||||
|
||||
el_reset(el);
|
||||
|
||||
term_end(el);
|
||||
key_end(el);
|
||||
map_end(el);
|
||||
tty_end(el);
|
||||
ch_end(el);
|
||||
search_end(el);
|
||||
hist_end(el);
|
||||
prompt_end(el);
|
||||
sig_end(el);
|
||||
|
||||
el_free((ptr_t) el->el_prog);
|
||||
el_free((ptr_t) el);
|
||||
}
|
||||
|
||||
|
||||
/* el_reset():
|
||||
* Reset the tty and the parser
|
||||
*/
|
||||
public void
|
||||
el_reset(EditLine *el)
|
||||
{
|
||||
|
||||
tty_cookedmode(el);
|
||||
ch_reset(el, 0); /* XXX: Do we want that? */
|
||||
}
|
||||
|
||||
|
||||
/* el_set():
|
||||
* set the editline parameters
|
||||
*/
|
||||
public int
|
||||
el_set(EditLine *el, int op, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int rv = 0;
|
||||
|
||||
if (el == NULL)
|
||||
return (-1);
|
||||
va_start(ap, op);
|
||||
|
||||
switch (op) {
|
||||
case EL_PROMPT:
|
||||
case EL_RPROMPT:
|
||||
rv = prompt_set(el, va_arg(ap, el_pfunc_t), op);
|
||||
break;
|
||||
|
||||
case EL_TERMINAL:
|
||||
rv = term_set(el, va_arg(ap, char *));
|
||||
break;
|
||||
|
||||
case EL_EDITOR:
|
||||
rv = map_set_editor(el, va_arg(ap, char *));
|
||||
break;
|
||||
|
||||
case EL_SIGNAL:
|
||||
if (va_arg(ap, int))
|
||||
el->el_flags |= HANDLE_SIGNALS;
|
||||
else
|
||||
el->el_flags &= ~HANDLE_SIGNALS;
|
||||
break;
|
||||
|
||||
case EL_BIND:
|
||||
case EL_TELLTC:
|
||||
case EL_SETTC:
|
||||
case EL_GETTC:
|
||||
case EL_ECHOTC:
|
||||
case EL_SETTY:
|
||||
{
|
||||
const char *argv[20];
|
||||
int i;
|
||||
|
||||
for (i = 1; i < 20; i++)
|
||||
if ((argv[i] = va_arg(ap, char *)) == NULL)
|
||||
break;
|
||||
|
||||
switch (op) {
|
||||
case EL_BIND:
|
||||
argv[0] = "bind";
|
||||
rv = map_bind(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_TELLTC:
|
||||
argv[0] = "telltc";
|
||||
rv = term_telltc(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_SETTC:
|
||||
argv[0] = "settc";
|
||||
rv = term_settc(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_ECHOTC:
|
||||
argv[0] = "echotc";
|
||||
rv = term_echotc(el, i, argv);
|
||||
break;
|
||||
|
||||
case EL_SETTY:
|
||||
argv[0] = "setty";
|
||||
rv = tty_stty(el, i, argv);
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = -1;
|
||||
EL_ABORT((el->el_errfile, "Bad op %d\n", op));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_ADDFN:
|
||||
{
|
||||
char *name = va_arg(ap, char *);
|
||||
char *help = va_arg(ap, char *);
|
||||
el_func_t func = va_arg(ap, el_func_t);
|
||||
|
||||
rv = map_addfunc(el, name, help, func);
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_HIST:
|
||||
{
|
||||
hist_fun_t func = va_arg(ap, hist_fun_t);
|
||||
ptr_t ptr = va_arg(ap, char *);
|
||||
|
||||
rv = hist_set(el, func, ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_EDITMODE:
|
||||
if (va_arg(ap, int))
|
||||
el->el_flags &= ~EDIT_DISABLED;
|
||||
else
|
||||
el->el_flags |= EDIT_DISABLED;
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_GETCFN:
|
||||
{
|
||||
el_rfunc_t rc = va_arg(ap, el_rfunc_t);
|
||||
rv = el_read_setfn(el, rc);
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_CLIENTDATA:
|
||||
el->el_data = va_arg(ap, void *);
|
||||
break;
|
||||
|
||||
case EL_UNBUFFERED:
|
||||
rv = va_arg(ap, int);
|
||||
if (rv && !(el->el_flags & UNBUFFERED)) {
|
||||
el->el_flags |= UNBUFFERED;
|
||||
read_prepare(el);
|
||||
} else if (!rv && (el->el_flags & UNBUFFERED)) {
|
||||
el->el_flags &= ~UNBUFFERED;
|
||||
read_finish(el);
|
||||
}
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_PREP_TERM:
|
||||
rv = va_arg(ap, int);
|
||||
if (rv)
|
||||
(void) tty_rawmode(el);
|
||||
else
|
||||
(void) tty_cookedmode(el);
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_SETFP:
|
||||
{
|
||||
FILE *fp;
|
||||
int what;
|
||||
|
||||
what = va_arg(ap, int);
|
||||
fp = va_arg(ap, FILE *);
|
||||
|
||||
rv = 0;
|
||||
switch (what) {
|
||||
case 0:
|
||||
el->el_infile = fp;
|
||||
el->el_infd = fileno(fp);
|
||||
break;
|
||||
case 1:
|
||||
el->el_outfile = fp;
|
||||
break;
|
||||
case 2:
|
||||
el->el_errfile = fp;
|
||||
break;
|
||||
default:
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
return (rv);
|
||||
}
|
||||
|
||||
|
||||
/* el_get():
|
||||
* retrieve the editline parameters
|
||||
*/
|
||||
public int
|
||||
el_get(EditLine *el, int op, ...)
|
||||
{
|
||||
va_list ap;
|
||||
int rv;
|
||||
|
||||
if (el == NULL)
|
||||
return -1;
|
||||
|
||||
va_start(ap, op);
|
||||
|
||||
switch (op) {
|
||||
case EL_PROMPT:
|
||||
case EL_RPROMPT:
|
||||
rv = prompt_get(el, va_arg(ap, el_pfunc_t *), op);
|
||||
break;
|
||||
|
||||
case EL_EDITOR:
|
||||
rv = map_get_editor(el, va_arg(ap, const char **));
|
||||
break;
|
||||
|
||||
case EL_SIGNAL:
|
||||
*va_arg(ap, int *) = (el->el_flags & HANDLE_SIGNALS);
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_EDITMODE:
|
||||
*va_arg(ap, int *) = !(el->el_flags & EDIT_DISABLED);
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_TERMINAL:
|
||||
term_get(el, va_arg(ap, const char **));
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_GETTC:
|
||||
{
|
||||
static char name[] = "gettc";
|
||||
char *argv[20];
|
||||
int i;
|
||||
|
||||
for (i = 1; i < sizeof(argv) / sizeof(argv[0]); i++)
|
||||
if ((argv[i] = va_arg(ap, char *)) == NULL)
|
||||
break;
|
||||
|
||||
switch (op) {
|
||||
case EL_GETTC:
|
||||
argv[0] = name;
|
||||
rv = term_gettc(el, i, argv);
|
||||
break;
|
||||
|
||||
default:
|
||||
rv = -1;
|
||||
EL_ABORT((el->el_errfile, "Bad op %d\n", op));
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
#if 0 /* XXX */
|
||||
case EL_ADDFN:
|
||||
{
|
||||
char *name = va_arg(ap, char *);
|
||||
char *help = va_arg(ap, char *);
|
||||
el_func_t func = va_arg(ap, el_func_t);
|
||||
|
||||
rv = map_addfunc(el, name, help, func);
|
||||
break;
|
||||
}
|
||||
|
||||
case EL_HIST:
|
||||
{
|
||||
hist_fun_t func = va_arg(ap, hist_fun_t);
|
||||
ptr_t ptr = va_arg(ap, char *);
|
||||
rv = hist_set(el, func, ptr);
|
||||
}
|
||||
break;
|
||||
#endif /* XXX */
|
||||
|
||||
case EL_GETCFN:
|
||||
*va_arg(ap, el_rfunc_t *) = el_read_getfn(el);
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_CLIENTDATA:
|
||||
*va_arg(ap, void **) = el->el_data;
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_UNBUFFERED:
|
||||
*va_arg(ap, int *) = (!(el->el_flags & UNBUFFERED));
|
||||
rv = 0;
|
||||
break;
|
||||
|
||||
case EL_GETFP:
|
||||
{
|
||||
int what;
|
||||
FILE **fpp;
|
||||
|
||||
what = va_arg(ap, int);
|
||||
fpp = va_arg(ap, FILE **);
|
||||
rv = 0;
|
||||
switch (what) {
|
||||
case 0:
|
||||
*fpp = el->el_infile;
|
||||
break;
|
||||
case 1:
|
||||
*fpp = el->el_outfile;
|
||||
break;
|
||||
case 2:
|
||||
*fpp = el->el_errfile;
|
||||
break;
|
||||
default:
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
rv = -1;
|
||||
break;
|
||||
}
|
||||
va_end(ap);
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
||||
|
||||
/* el_line():
|
||||
* Return editing info
|
||||
*/
|
||||
public const LineInfo *
|
||||
el_line(EditLine *el)
|
||||
{
|
||||
|
||||
return (const LineInfo *) (void *) &el->el_line;
|
||||
}
|
||||
|
||||
|
||||
/* el_source():
|
||||
* Source a file
|
||||
*/
|
||||
public int
|
||||
el_source(EditLine *el, const char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
size_t len;
|
||||
char *ptr;
|
||||
|
||||
fp = NULL;
|
||||
if (fname == NULL) {
|
||||
static const char elpath[] = "/.editrc";
|
||||
#ifdef MAXPATHLEN
|
||||
char path[MAXPATHLEN];
|
||||
#else
|
||||
char path[4096];
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ISSETUGID
|
||||
if (issetugid())
|
||||
return (-1);
|
||||
#endif
|
||||
if ((ptr = getenv("HOME")) == NULL)
|
||||
return (-1);
|
||||
if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path))
|
||||
return (-1);
|
||||
if (strlcat(path, elpath, sizeof(path)) >= sizeof(path))
|
||||
return (-1);
|
||||
fname = path;
|
||||
}
|
||||
if (fp == NULL)
|
||||
fp = fopen(fname, "r");
|
||||
if (fp == NULL)
|
||||
return (-1);
|
||||
|
||||
while ((ptr = fgetln(fp, &len)) != NULL) {
|
||||
if (len > 0 && ptr[len - 1] == '\n')
|
||||
--len;
|
||||
ptr[len] = '\0';
|
||||
if (parse_line(el, ptr) == -1) {
|
||||
(void) fclose(fp);
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
(void) fclose(fp);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* el_resize():
|
||||
* Called from program when terminal is resized
|
||||
*/
|
||||
public void
|
||||
el_resize(EditLine *el)
|
||||
{
|
||||
int lins, cols;
|
||||
sigset_t oset, nset;
|
||||
|
||||
(void) sigemptyset(&nset);
|
||||
(void) sigaddset(&nset, SIGWINCH);
|
||||
(void) sigprocmask(SIG_BLOCK, &nset, &oset);
|
||||
|
||||
/* get the correct window size */
|
||||
if (term_get_size(el, &lins, &cols))
|
||||
term_change_size(el, lins, cols);
|
||||
|
||||
(void) sigprocmask(SIG_SETMASK, &oset, NULL);
|
||||
}
|
||||
|
||||
|
||||
/* el_beep():
|
||||
* Called from the program to beep
|
||||
*/
|
||||
public void
|
||||
el_beep(EditLine *el)
|
||||
{
|
||||
|
||||
term_beep(el);
|
||||
}
|
||||
|
||||
|
||||
/* el_editmode()
|
||||
* Set the state of EDIT_DISABLED from the `edit' command.
|
||||
*/
|
||||
protected int
|
||||
/*ARGSUSED*/
|
||||
el_editmode(EditLine *el, int argc, const char **argv)
|
||||
{
|
||||
const char *how;
|
||||
|
||||
if (argv == NULL || argc != 2 || argv[1] == NULL)
|
||||
return (-1);
|
||||
|
||||
how = argv[1];
|
||||
if (strcmp(how, "on") == 0) {
|
||||
el->el_flags &= ~EDIT_DISABLED;
|
||||
tty_rawmode(el);
|
||||
} else if (strcmp(how, "off") == 0) {
|
||||
tty_cookedmode(el);
|
||||
el->el_flags |= EDIT_DISABLED;
|
||||
}
|
||||
else {
|
||||
(void) fprintf(el->el_errfile, "edit: Bad value `%s'.\n", how);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
150
extern/editline/src/el.h
vendored
Normal file
150
extern/editline/src/el.h
vendored
Normal file
@ -0,0 +1,150 @@
|
||||
/* $NetBSD: el.h,v 1.17 2006/12/15 22:13:33 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)el.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.h: Internal structures.
|
||||
*/
|
||||
#ifndef _h_el
|
||||
#define _h_el
|
||||
/*
|
||||
* Local defaults
|
||||
*/
|
||||
#define KSHVI
|
||||
#define VIDEFAULT
|
||||
#define ANCHOR
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define EL_BUFSIZ 1024 /* Maximum line size */
|
||||
|
||||
#define HANDLE_SIGNALS 0x01
|
||||
#define NO_TTY 0x02
|
||||
#define EDIT_DISABLED 0x04
|
||||
#define UNBUFFERED 0x08
|
||||
|
||||
typedef int bool_t; /* True or not */
|
||||
|
||||
typedef unsigned char el_action_t; /* Index to command array */
|
||||
|
||||
typedef struct coord_t { /* Position on the screen */
|
||||
int h;
|
||||
int v;
|
||||
} coord_t;
|
||||
|
||||
typedef struct el_line_t {
|
||||
char *buffer; /* Input line */
|
||||
char *cursor; /* Cursor position */
|
||||
char *lastchar; /* Last character */
|
||||
const char *limit; /* Max position */
|
||||
} el_line_t;
|
||||
|
||||
/*
|
||||
* Editor state
|
||||
*/
|
||||
typedef struct el_state_t {
|
||||
int inputmode; /* What mode are we in? */
|
||||
int doingarg; /* Are we getting an argument? */
|
||||
int argument; /* Numeric argument */
|
||||
int metanext; /* Is the next char a meta char */
|
||||
el_action_t lastcmd; /* Previous command */
|
||||
el_action_t thiscmd; /* this command */
|
||||
char thisch; /* char that generated it */
|
||||
} el_state_t;
|
||||
|
||||
/*
|
||||
* Until we come up with something better...
|
||||
*/
|
||||
#define el_strdup(a) strdup(a)
|
||||
#define el_malloc(a) malloc(a)
|
||||
#define el_realloc(a,b) realloc(a, b)
|
||||
#define el_free(a) free(a)
|
||||
|
||||
#include "tty.h"
|
||||
#include "prompt.h"
|
||||
#include "key.h"
|
||||
#include "el_term.h"
|
||||
#include "refresh.h"
|
||||
#include "chared.h"
|
||||
#include "common.h"
|
||||
#include "search.h"
|
||||
#include "hist.h"
|
||||
#include "map.h"
|
||||
#include "parse.h"
|
||||
#include "sig.h"
|
||||
#include "help.h"
|
||||
#include "read.h"
|
||||
|
||||
struct editline {
|
||||
char *el_prog; /* the program name */
|
||||
FILE *el_infile; /* Stdio stuff */
|
||||
FILE *el_outfile; /* Stdio stuff */
|
||||
FILE *el_errfile; /* Stdio stuff */
|
||||
int el_infd; /* Input file descriptor */
|
||||
int el_flags; /* Various flags. */
|
||||
coord_t el_cursor; /* Cursor location */
|
||||
char **el_display; /* Real screen image = what is there */
|
||||
char **el_vdisplay; /* Virtual screen image = what we see */
|
||||
void *el_data; /* Client data */
|
||||
el_line_t el_line; /* The current line information */
|
||||
el_state_t el_state; /* Current editor state */
|
||||
el_term_t el_term; /* Terminal dependent stuff */
|
||||
el_tty_t el_tty; /* Tty dependent stuff */
|
||||
el_refresh_t el_refresh; /* Refresh stuff */
|
||||
el_prompt_t el_prompt; /* Prompt stuff */
|
||||
el_prompt_t el_rprompt; /* Prompt stuff */
|
||||
el_chared_t el_chared; /* Characted editor stuff */
|
||||
el_map_t el_map; /* Key mapping stuff */
|
||||
el_key_t el_key; /* Key binding stuff */
|
||||
el_history_t el_history; /* History stuff */
|
||||
el_search_t el_search; /* Search stuff */
|
||||
el_signal_t el_signal; /* Signal handling stuff */
|
||||
el_read_t el_read; /* Character reading stuff */
|
||||
};
|
||||
|
||||
protected int el_editmode(EditLine *, int, const char **);
|
||||
|
||||
#ifdef DEBUG
|
||||
#define EL_ABORT(a) do { \
|
||||
fprintf(el->el_errfile, "%s, %d: ", \
|
||||
__FILE__, __LINE__); \
|
||||
fprintf a; \
|
||||
abort(); \
|
||||
} while( /*CONSTCOND*/0);
|
||||
#else
|
||||
#define EL_ABORT(a) abort()
|
||||
#endif
|
||||
#endif /* _h_el */
|
135
extern/editline/src/el_term.h
vendored
Normal file
135
extern/editline/src/el_term.h
vendored
Normal file
@ -0,0 +1,135 @@
|
||||
/* $NetBSD: term.h,v 1.18 2006/11/24 00:01:17 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)term.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.term.h: Termcap header
|
||||
*/
|
||||
#ifndef _h_el_term
|
||||
#define _h_el_term
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef struct { /* Symbolic function key bindings */
|
||||
const char *name; /* name of the key */
|
||||
int key; /* Index in termcap table */
|
||||
key_value_t fun; /* Function bound to it */
|
||||
int type; /* Type of function */
|
||||
} fkey_t;
|
||||
|
||||
typedef struct {
|
||||
const char *t_name; /* the terminal name */
|
||||
coord_t t_size; /* # lines and cols */
|
||||
int t_flags;
|
||||
#define TERM_CAN_INSERT 0x001 /* Has insert cap */
|
||||
#define TERM_CAN_DELETE 0x002 /* Has delete cap */
|
||||
#define TERM_CAN_CEOL 0x004 /* Has CEOL cap */
|
||||
#define TERM_CAN_TAB 0x008 /* Can use tabs */
|
||||
#define TERM_CAN_ME 0x010 /* Can turn all attrs. */
|
||||
#define TERM_CAN_UP 0x020 /* Can move up */
|
||||
#define TERM_HAS_META 0x040 /* Has a meta key */
|
||||
#define TERM_HAS_AUTO_MARGINS 0x080 /* Has auto margins */
|
||||
#define TERM_HAS_MAGIC_MARGINS 0x100 /* Has magic margins */
|
||||
char *t_buf; /* Termcap buffer */
|
||||
int t_loc; /* location used */
|
||||
char **t_str; /* termcap strings */
|
||||
int *t_val; /* termcap values */
|
||||
char *t_cap; /* Termcap buffer */
|
||||
fkey_t *t_fkey; /* Array of keys */
|
||||
} el_term_t;
|
||||
|
||||
/*
|
||||
* fKey indexes
|
||||
*/
|
||||
#define A_K_DN 0
|
||||
#define A_K_UP 1
|
||||
#define A_K_LT 2
|
||||
#define A_K_RT 3
|
||||
#define A_K_HO 4
|
||||
#define A_K_EN 5
|
||||
#define A_K_DE 6
|
||||
#define A_K_NKEYS 7
|
||||
|
||||
#ifdef _SUNOS
|
||||
extern int tgetent(char *, const char *);
|
||||
extern int tgetflag(char *);
|
||||
extern int tgetnum(char *);
|
||||
extern int tputs(const char *, int, int (*)(int));
|
||||
extern char* tgoto(const char*, int, int);
|
||||
extern char* tgetstr(char*, char**);
|
||||
#endif
|
||||
|
||||
protected void term_move_to_line(EditLine *, int);
|
||||
protected void term_move_to_char(EditLine *, int);
|
||||
protected void term_clear_EOL(EditLine *, int);
|
||||
protected void term_overwrite(EditLine *, const char *, int);
|
||||
protected void term_insertwrite(EditLine *, char *, int);
|
||||
protected void term_deletechars(EditLine *, int);
|
||||
protected void term_clear_screen(EditLine *);
|
||||
protected void term_beep(EditLine *);
|
||||
protected int term_change_size(EditLine *, int, int);
|
||||
protected int term_get_size(EditLine *, int *, int *);
|
||||
protected int term_init(EditLine *);
|
||||
protected void term_bind_arrow(EditLine *);
|
||||
protected void term_print_arrow(EditLine *, const char *);
|
||||
protected int term_clear_arrow(EditLine *, const char *);
|
||||
protected int term_set_arrow(EditLine *, const char *, key_value_t *, int);
|
||||
protected void term_end(EditLine *);
|
||||
protected void term_get(EditLine *, const char **);
|
||||
protected int term_set(EditLine *, const char *);
|
||||
protected int term_settc(EditLine *, int, const char **);
|
||||
protected int term_gettc(EditLine *, int, char **);
|
||||
protected int term_telltc(EditLine *, int, const char **);
|
||||
protected int term_echotc(EditLine *, int, const char **);
|
||||
protected void term_writec(EditLine *, int);
|
||||
protected int term__putc(int);
|
||||
protected void term__flush(void);
|
||||
|
||||
/*
|
||||
* Easy access macros
|
||||
*/
|
||||
#define EL_FLAGS (el)->el_term.t_flags
|
||||
|
||||
#define EL_CAN_INSERT (EL_FLAGS & TERM_CAN_INSERT)
|
||||
#define EL_CAN_DELETE (EL_FLAGS & TERM_CAN_DELETE)
|
||||
#define EL_CAN_CEOL (EL_FLAGS & TERM_CAN_CEOL)
|
||||
#define EL_CAN_TAB (EL_FLAGS & TERM_CAN_TAB)
|
||||
#define EL_CAN_ME (EL_FLAGS & TERM_CAN_ME)
|
||||
#define EL_CAN_UP (EL_FLAGS & TERM_CAN_UP)
|
||||
#define EL_HAS_META (EL_FLAGS & TERM_HAS_META)
|
||||
#define EL_HAS_AUTO_MARGINS (EL_FLAGS & TERM_HAS_AUTO_MARGINS)
|
||||
#define EL_HAS_MAGIC_MARGINS (EL_FLAGS & TERM_HAS_MAGIC_MARGINS)
|
||||
|
||||
#endif /* _h_el_term */
|
507
extern/editline/src/emacs.c
vendored
Normal file
507
extern/editline/src/emacs.c
vendored
Normal file
@ -0,0 +1,507 @@
|
||||
/* $NetBSD: emacs.c,v 1.21 2006/03/06 21:11:56 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)emacs.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: emacs.c,v 1.21 2006/03/06 21:11:56 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* emacs.c: Emacs functions
|
||||
*/
|
||||
#include "el.h"
|
||||
|
||||
/* em_delete_or_list():
|
||||
* Delete character under cursor or list completions if at end of line
|
||||
* [^D]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_delete_or_list(EditLine *el, int c)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor == el->el_line.lastchar) {
|
||||
/* if I'm at the end */
|
||||
if (el->el_line.cursor == el->el_line.buffer) {
|
||||
/* and the beginning */
|
||||
term_writec(el, c); /* then do an EOF */
|
||||
return (CC_EOF);
|
||||
} else {
|
||||
/*
|
||||
* Here we could list completions, but it is an
|
||||
* error right now
|
||||
*/
|
||||
term_beep(el);
|
||||
return (CC_ERROR);
|
||||
}
|
||||
} else {
|
||||
if (el->el_state.doingarg)
|
||||
c_delafter(el, el->el_state.argument);
|
||||
else
|
||||
c_delafter1(el);
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
/* bounds check */
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* em_delete_next_word():
|
||||
* Cut from cursor to end of current word
|
||||
* [M-d]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_delete_next_word(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *p, *kp;
|
||||
|
||||
if (el->el_line.cursor == el->el_line.lastchar)
|
||||
return (CC_ERROR);
|
||||
|
||||
cp = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
for (p = el->el_line.cursor, kp = el->el_chared.c_kill.buf; p < cp; p++)
|
||||
/* save the text */
|
||||
*kp++ = *p;
|
||||
el->el_chared.c_kill.last = kp;
|
||||
|
||||
c_delafter(el, cp - el->el_line.cursor); /* delete after dot */
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
/* bounds check */
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_yank():
|
||||
* Paste cut buffer at cursor position
|
||||
* [^Y]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_yank(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *kp, *cp;
|
||||
|
||||
if (el->el_chared.c_kill.last == el->el_chared.c_kill.buf)
|
||||
return (CC_NORM);
|
||||
|
||||
if (el->el_line.lastchar +
|
||||
(el->el_chared.c_kill.last - el->el_chared.c_kill.buf) >=
|
||||
el->el_line.limit)
|
||||
return (CC_ERROR);
|
||||
|
||||
el->el_chared.c_kill.mark = el->el_line.cursor;
|
||||
cp = el->el_line.cursor;
|
||||
|
||||
/* open the space, */
|
||||
c_insert(el, el->el_chared.c_kill.last - el->el_chared.c_kill.buf);
|
||||
/* copy the chars */
|
||||
for (kp = el->el_chared.c_kill.buf; kp < el->el_chared.c_kill.last; kp++)
|
||||
*cp++ = *kp;
|
||||
|
||||
/* if an arg, cursor at beginning else cursor at end */
|
||||
if (el->el_state.argument == 1)
|
||||
el->el_line.cursor = cp;
|
||||
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_kill_line():
|
||||
* Cut the entire line and save in cut buffer
|
||||
* [^U]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_kill_line(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *kp, *cp;
|
||||
|
||||
cp = el->el_line.buffer;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_line.lastchar)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
/* zap! -- delete all of it */
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_kill_region():
|
||||
* Cut area between mark and cursor and save in cut buffer
|
||||
* [^W]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_kill_region(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *kp, *cp;
|
||||
|
||||
if (!el->el_chared.c_kill.mark)
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_chared.c_kill.mark > el->el_line.cursor) {
|
||||
cp = el->el_line.cursor;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_chared.c_kill.mark)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
c_delafter(el, cp - el->el_line.cursor);
|
||||
} else { /* mark is before cursor */
|
||||
cp = el->el_chared.c_kill.mark;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_line.cursor)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
c_delbefore(el, cp - el->el_chared.c_kill.mark);
|
||||
el->el_line.cursor = el->el_chared.c_kill.mark;
|
||||
}
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_copy_region():
|
||||
* Copy area between mark and cursor to cut buffer
|
||||
* [M-W]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_copy_region(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *kp, *cp;
|
||||
|
||||
if (!el->el_chared.c_kill.mark)
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_chared.c_kill.mark > el->el_line.cursor) {
|
||||
cp = el->el_line.cursor;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_chared.c_kill.mark)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
} else {
|
||||
cp = el->el_chared.c_kill.mark;
|
||||
kp = el->el_chared.c_kill.buf;
|
||||
while (cp < el->el_line.cursor)
|
||||
*kp++ = *cp++; /* copy it */
|
||||
el->el_chared.c_kill.last = kp;
|
||||
}
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* em_gosmacs_transpose():
|
||||
* Exchange the two characters before the cursor
|
||||
* Gosling emacs transpose chars [^T]
|
||||
*/
|
||||
protected el_action_t
|
||||
em_gosmacs_transpose(EditLine *el, int c)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor > &el->el_line.buffer[1]) {
|
||||
/* must have at least two chars entered */
|
||||
c = el->el_line.cursor[-2];
|
||||
el->el_line.cursor[-2] = el->el_line.cursor[-1];
|
||||
el->el_line.cursor[-1] = c;
|
||||
return (CC_REFRESH);
|
||||
} else
|
||||
return (CC_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/* em_next_word():
|
||||
* Move next to end of current word
|
||||
* [M-f]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_next_word(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
if (el->el_line.cursor == el->el_line.lastchar)
|
||||
return (CC_ERROR);
|
||||
|
||||
el->el_line.cursor = c__next_word(el->el_line.cursor,
|
||||
el->el_line.lastchar,
|
||||
el->el_state.argument,
|
||||
ce__isword);
|
||||
|
||||
if (el->el_map.type == MAP_VI)
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
cv_delfini(el);
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* em_upper_case():
|
||||
* Uppercase the characters from cursor to end of current word
|
||||
* [M-u]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_upper_case(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *ep;
|
||||
|
||||
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
for (cp = el->el_line.cursor; cp < ep; cp++)
|
||||
if (islower((unsigned char)*cp))
|
||||
*cp = toupper((unsigned char)*cp);
|
||||
|
||||
el->el_line.cursor = ep;
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_capitol_case():
|
||||
* Capitalize the characters from cursor to end of current word
|
||||
* [M-c]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_capitol_case(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *ep;
|
||||
|
||||
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
for (cp = el->el_line.cursor; cp < ep; cp++) {
|
||||
if (isalpha((unsigned char)*cp)) {
|
||||
if (islower((unsigned char)*cp))
|
||||
*cp = toupper((unsigned char)*cp);
|
||||
cp++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (; cp < ep; cp++)
|
||||
if (isupper((unsigned char)*cp))
|
||||
*cp = tolower((unsigned char)*cp);
|
||||
|
||||
el->el_line.cursor = ep;
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_lower_case():
|
||||
* Lowercase the characters from cursor to end of current word
|
||||
* [M-l]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_lower_case(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *ep;
|
||||
|
||||
ep = c__next_word(el->el_line.cursor, el->el_line.lastchar,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
for (cp = el->el_line.cursor; cp < ep; cp++)
|
||||
if (isupper((unsigned char)*cp))
|
||||
*cp = tolower((unsigned char)*cp);
|
||||
|
||||
el->el_line.cursor = ep;
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_set_mark():
|
||||
* Set the mark at cursor
|
||||
* [^@]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_set_mark(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_chared.c_kill.mark = el->el_line.cursor;
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* em_exchange_mark():
|
||||
* Exchange the cursor and mark
|
||||
* [^X^X]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_exchange_mark(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp;
|
||||
|
||||
cp = el->el_line.cursor;
|
||||
el->el_line.cursor = el->el_chared.c_kill.mark;
|
||||
el->el_chared.c_kill.mark = cp;
|
||||
return (CC_CURSOR);
|
||||
}
|
||||
|
||||
|
||||
/* em_universal_argument():
|
||||
* Universal argument (argument times 4)
|
||||
* [^U]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_universal_argument(EditLine *el, int c __attribute__((__unused__)))
|
||||
{ /* multiply current argument by 4 */
|
||||
|
||||
if (el->el_state.argument > 1000000)
|
||||
return (CC_ERROR);
|
||||
el->el_state.doingarg = 1;
|
||||
el->el_state.argument *= 4;
|
||||
return (CC_ARGHACK);
|
||||
}
|
||||
|
||||
|
||||
/* em_meta_next():
|
||||
* Add 8th bit to next character typed
|
||||
* [<ESC>]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_meta_next(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_state.metanext = 1;
|
||||
return (CC_ARGHACK);
|
||||
}
|
||||
|
||||
|
||||
/* em_toggle_overwrite():
|
||||
* Switch from insert to overwrite mode or vice versa
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_toggle_overwrite(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_state.inputmode = (el->el_state.inputmode == MODE_INSERT) ?
|
||||
MODE_REPLACE : MODE_INSERT;
|
||||
return (CC_NORM);
|
||||
}
|
||||
|
||||
|
||||
/* em_copy_prev_word():
|
||||
* Copy current word to cursor
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_copy_prev_word(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
char *cp, *oldc, *dp;
|
||||
|
||||
if (el->el_line.cursor == el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
oldc = el->el_line.cursor;
|
||||
/* does a bounds check */
|
||||
cp = c__prev_word(el->el_line.cursor, el->el_line.buffer,
|
||||
el->el_state.argument, ce__isword);
|
||||
|
||||
c_insert(el, oldc - cp);
|
||||
for (dp = oldc; cp < oldc && dp < el->el_line.lastchar; cp++)
|
||||
*dp++ = *cp;
|
||||
|
||||
el->el_line.cursor = dp;/* put cursor at end */
|
||||
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* em_inc_search_next():
|
||||
* Emacs incremental next search
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_inc_search_next(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_search.patlen = 0;
|
||||
return (ce_inc_search(el, ED_SEARCH_NEXT_HISTORY));
|
||||
}
|
||||
|
||||
|
||||
/* em_inc_search_prev():
|
||||
* Emacs incremental reverse search
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_inc_search_prev(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
el->el_search.patlen = 0;
|
||||
return (ce_inc_search(el, ED_SEARCH_PREV_HISTORY));
|
||||
}
|
||||
|
||||
|
||||
/* em_delete_prev_char():
|
||||
* Delete the character to the left of the cursor
|
||||
* [^?]
|
||||
*/
|
||||
protected el_action_t
|
||||
/*ARGSUSED*/
|
||||
em_delete_prev_char(EditLine *el, int c __attribute__((__unused__)))
|
||||
{
|
||||
|
||||
if (el->el_line.cursor <= el->el_line.buffer)
|
||||
return (CC_ERROR);
|
||||
|
||||
if (el->el_state.doingarg)
|
||||
c_delbefore(el, el->el_state.argument);
|
||||
else
|
||||
c_delbefore1(el);
|
||||
el->el_line.cursor -= el->el_state.argument;
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
return (CC_REFRESH);
|
||||
}
|
110
extern/editline/src/fgetln.c
vendored
Normal file
110
extern/editline/src/fgetln.c
vendored
Normal file
@ -0,0 +1,110 @@
|
||||
/* $NetBSD: fgetln.c,v 1.8 2006/10/18 15:17:38 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Christos Zoulas.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_NBTOOL_CONFIG_H
|
||||
#include "nbtool_config.h"
|
||||
#endif
|
||||
|
||||
#if !HAVE_FGETLN
|
||||
#include <config.h>
|
||||
#include <stdlib.h>
|
||||
#ifndef HAVE_NBTOOL_CONFIG_H
|
||||
/* These headers are required, but included from nbtool_config.h */
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
char *
|
||||
fgetln(FILE *fp, size_t *len)
|
||||
{
|
||||
static char *buf = NULL;
|
||||
static size_t bufsiz = 0;
|
||||
char *ptr;
|
||||
|
||||
|
||||
if (buf == NULL) {
|
||||
bufsiz = BUFSIZ;
|
||||
if ((buf = malloc(bufsiz)) == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (fgets(buf, bufsiz, fp) == NULL)
|
||||
return NULL;
|
||||
|
||||
*len = 0;
|
||||
while ((ptr = strchr(&buf[*len], '\n')) == NULL) {
|
||||
size_t nbufsiz = bufsiz + BUFSIZ;
|
||||
char *nbuf = realloc(buf, nbufsiz);
|
||||
|
||||
if (nbuf == NULL) {
|
||||
int oerrno = errno;
|
||||
free(buf);
|
||||
errno = oerrno;
|
||||
buf = NULL;
|
||||
return NULL;
|
||||
} else
|
||||
buf = nbuf;
|
||||
|
||||
if (fgets(&buf[bufsiz], BUFSIZ, fp) == NULL) {
|
||||
buf[bufsiz] = '\0';
|
||||
*len = strlen(buf);
|
||||
return buf;
|
||||
}
|
||||
|
||||
*len = bufsiz;
|
||||
bufsiz = nbufsiz;
|
||||
}
|
||||
|
||||
*len = (ptr - buf) + 1;
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef TEST
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
char *p;
|
||||
size_t len;
|
||||
|
||||
while ((p = fgetln(stdin, &len)) != NULL) {
|
||||
(void)printf("%zu %s", len, p);
|
||||
free(p);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
561
extern/editline/src/filecomplete.c
vendored
Normal file
561
extern/editline/src/filecomplete.c
vendored
Normal file
@ -0,0 +1,561 @@
|
||||
/* $NetBSD: filecomplete.c,v 1.10 2006/11/09 16:58:38 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jaromir Dolecek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* AIX requires this to be the first thing in the file. */
|
||||
#if defined (_AIX) && !defined (__GNUC__)
|
||||
#pragma alloca
|
||||
#endif
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUC__
|
||||
# undef alloca
|
||||
# define alloca(n) __builtin_alloca (n)
|
||||
#else
|
||||
# ifdef HAVE_ALLOCA_H
|
||||
# include <alloca.h>
|
||||
# else
|
||||
# ifndef _AIX
|
||||
extern char *alloca ();
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
__RCSID("$NetBSD: filecomplete.c,v 1.10 2006/11/09 16:58:38 christos Exp $");
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <pwd.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <vis.h>
|
||||
|
||||
#include "el.h"
|
||||
#include "fcns.h" /* for EL_NUM_FCNS */
|
||||
#include "histedit.h"
|
||||
#include "filecomplete.h"
|
||||
|
||||
static char break_chars[] = { ' ', '\t', '\n', '"', '\\', '\'', '`', '@', '$',
|
||||
'>', '<', '=', ';', '|', '&', '{', '(', '\0' };
|
||||
|
||||
|
||||
/********************************/
|
||||
/* completion functions */
|
||||
|
||||
/*
|
||||
* does tilde expansion of strings of type ``~user/foo''
|
||||
* if ``user'' isn't valid user name or ``txt'' doesn't start
|
||||
* w/ '~', returns pointer to strdup()ed copy of ``txt''
|
||||
*
|
||||
* it's callers's responsibility to free() returned string
|
||||
*/
|
||||
char *
|
||||
fn_tilde_expand(const char *txt)
|
||||
{
|
||||
struct passwd pwres, *pass;
|
||||
char *temp;
|
||||
size_t len = 0;
|
||||
char pwbuf[1024];
|
||||
|
||||
if (txt[0] != '~')
|
||||
return (strdup(txt));
|
||||
|
||||
temp = strchr(txt + 1, '/');
|
||||
if (temp == NULL) {
|
||||
temp = strdup(txt + 1);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
} else {
|
||||
len = temp - txt + 1; /* text until string after slash */
|
||||
temp = malloc(len);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
(void)strncpy(temp, txt + 1, len - 2);
|
||||
temp[len - 2] = '\0';
|
||||
}
|
||||
if (temp[0] == 0) {
|
||||
#ifdef HAVE_GETPW_R_POSIX
|
||||
if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf), &pass) != 0)
|
||||
pass = NULL;
|
||||
#elif HAVE_GETPW_R_DRAFT
|
||||
pass = getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf));
|
||||
#else
|
||||
pass = getpwuid(getuid());
|
||||
#endif
|
||||
} else {
|
||||
#ifdef HAVE_GETPW_R_POSIX
|
||||
if (getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf), &pass) != 0)
|
||||
pass = NULL;
|
||||
#elif HAVE_GETPW_R_DRAFT
|
||||
pass = getpwnam_r(temp, &pwres, pwbuf, sizeof(pwbuf));
|
||||
#else
|
||||
pass = getpwnam(temp);
|
||||
#endif
|
||||
}
|
||||
free(temp); /* value no more needed */
|
||||
if (pass == NULL)
|
||||
return (strdup(txt));
|
||||
|
||||
/* update pointer txt to point at string immedially following */
|
||||
/* first slash */
|
||||
txt += len;
|
||||
|
||||
temp = malloc(strlen(pass->pw_dir) + 1 + strlen(txt) + 1);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
(void)sprintf(temp, "%s/%s", pass->pw_dir, txt);
|
||||
|
||||
return (temp);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* return first found file name starting by the ``text'' or NULL if no
|
||||
* such file can be found
|
||||
* value of ``state'' is ignored
|
||||
*
|
||||
* it's caller's responsibility to free returned string
|
||||
*/
|
||||
char *
|
||||
fn_filename_completion_function(const char *text, int state)
|
||||
{
|
||||
static DIR *dir = NULL;
|
||||
static char *filename = NULL, *dirname = NULL, *dirpath = NULL;
|
||||
static size_t filename_len = 0;
|
||||
struct dirent *entry;
|
||||
char *temp;
|
||||
size_t len;
|
||||
|
||||
if (state == 0 || dir == NULL) {
|
||||
temp = strrchr(text, '/');
|
||||
if (temp) {
|
||||
char *nptr;
|
||||
temp++;
|
||||
nptr = realloc(filename, strlen(temp) + 1);
|
||||
if (nptr == NULL) {
|
||||
free(filename);
|
||||
return NULL;
|
||||
}
|
||||
filename = nptr;
|
||||
(void)strcpy(filename, temp);
|
||||
len = temp - text; /* including last slash */
|
||||
nptr = realloc(dirname, len + 1);
|
||||
if (nptr == NULL) {
|
||||
free(filename);
|
||||
return NULL;
|
||||
}
|
||||
dirname = nptr;
|
||||
(void)strncpy(dirname, text, len);
|
||||
dirname[len] = '\0';
|
||||
} else {
|
||||
if (*text == 0)
|
||||
filename = NULL;
|
||||
else {
|
||||
filename = strdup(text);
|
||||
if (filename == NULL)
|
||||
return NULL;
|
||||
}
|
||||
dirname = NULL;
|
||||
}
|
||||
|
||||
if (dir != NULL) {
|
||||
(void)closedir(dir);
|
||||
dir = NULL;
|
||||
}
|
||||
|
||||
/* support for ``~user'' syntax */
|
||||
free(dirpath);
|
||||
|
||||
if (dirname == NULL && (dirname = strdup("./")) == NULL)
|
||||
return NULL;
|
||||
|
||||
if (*dirname == '~')
|
||||
dirpath = fn_tilde_expand(dirname);
|
||||
else
|
||||
dirpath = strdup(dirname);
|
||||
|
||||
if (dirpath == NULL)
|
||||
return NULL;
|
||||
|
||||
dir = opendir(dirpath);
|
||||
if (!dir)
|
||||
return (NULL); /* cannot open the directory */
|
||||
|
||||
/* will be used in cycle */
|
||||
filename_len = filename ? strlen(filename) : 0;
|
||||
}
|
||||
|
||||
/* find the match */
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
/* skip . and .. */
|
||||
if (entry->d_name[0] == '.' && (!entry->d_name[1]
|
||||
|| (entry->d_name[1] == '.' && !entry->d_name[2])))
|
||||
continue;
|
||||
if (filename_len == 0)
|
||||
break;
|
||||
/* otherwise, get first entry where first */
|
||||
/* filename_len characters are equal */
|
||||
if (entry->d_name[0] == filename[0]
|
||||
/* Some dirents have d_namlen, but it is not portable. */
|
||||
&& strlen(entry->d_name) >= filename_len
|
||||
&& strncmp(entry->d_name, filename,
|
||||
filename_len) == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
if (entry) { /* match found */
|
||||
|
||||
/* Some dirents have d_namlen, but it is not portable. */
|
||||
len = strlen(entry->d_name);
|
||||
temp = malloc(strlen(dirname) + len + 1);
|
||||
if (temp == NULL)
|
||||
return NULL;
|
||||
(void)sprintf(temp, "%s%s", dirname, entry->d_name);
|
||||
} else {
|
||||
(void)closedir(dir);
|
||||
dir = NULL;
|
||||
temp = NULL;
|
||||
}
|
||||
|
||||
return (temp);
|
||||
}
|
||||
|
||||
|
||||
static const char *
|
||||
append_char_function(const char *name)
|
||||
{
|
||||
struct stat stbuf;
|
||||
char *expname = *name == '~' ? fn_tilde_expand(name) : NULL;
|
||||
const char *rs = "";
|
||||
|
||||
if (stat(expname ? expname : name, &stbuf) == -1)
|
||||
goto out;
|
||||
if (S_ISDIR(stbuf.st_mode))
|
||||
rs = "/";
|
||||
out:
|
||||
if (expname)
|
||||
free(expname);
|
||||
return rs;
|
||||
}
|
||||
/*
|
||||
* returns list of completions for text given
|
||||
* non-static for readline.
|
||||
*/
|
||||
char ** completion_matches(const char *, char *(*)(const char *, int));
|
||||
char **
|
||||
completion_matches(const char *text, char *(*genfunc)(const char *, int))
|
||||
{
|
||||
char **match_list = NULL, *retstr, *prevstr;
|
||||
size_t match_list_len, max_equal, which, i;
|
||||
size_t matches;
|
||||
|
||||
matches = 0;
|
||||
match_list_len = 1;
|
||||
while ((retstr = (*genfunc) (text, (int)matches)) != NULL) {
|
||||
/* allow for list terminator here */
|
||||
if (matches + 3 >= match_list_len) {
|
||||
char **nmatch_list;
|
||||
while (matches + 3 >= match_list_len)
|
||||
match_list_len <<= 1;
|
||||
nmatch_list = realloc(match_list,
|
||||
match_list_len * sizeof(char *));
|
||||
if (nmatch_list == NULL) {
|
||||
free(match_list);
|
||||
return NULL;
|
||||
}
|
||||
match_list = nmatch_list;
|
||||
|
||||
}
|
||||
match_list[++matches] = retstr;
|
||||
}
|
||||
|
||||
if (!match_list)
|
||||
return NULL; /* nothing found */
|
||||
|
||||
/* find least denominator and insert it to match_list[0] */
|
||||
which = 2;
|
||||
prevstr = match_list[1];
|
||||
max_equal = strlen(prevstr);
|
||||
for (; which <= matches; which++) {
|
||||
for (i = 0; i < max_equal &&
|
||||
prevstr[i] == match_list[which][i]; i++)
|
||||
continue;
|
||||
max_equal = i;
|
||||
}
|
||||
|
||||
retstr = malloc(max_equal + 1);
|
||||
if (retstr == NULL) {
|
||||
free(match_list);
|
||||
return NULL;
|
||||
}
|
||||
(void)strncpy(retstr, match_list[1], max_equal);
|
||||
retstr[max_equal] = '\0';
|
||||
match_list[0] = retstr;
|
||||
|
||||
/* add NULL as last pointer to the array */
|
||||
match_list[matches + 1] = (char *) NULL;
|
||||
|
||||
return (match_list);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sort function for qsort(). Just wrapper around strcasecmp().
|
||||
*/
|
||||
static int
|
||||
_fn_qsort_string_compare(const void *i1, const void *i2)
|
||||
{
|
||||
const char *s1 = ((const char * const *)i1)[0];
|
||||
const char *s2 = ((const char * const *)i2)[0];
|
||||
|
||||
return strcasecmp(s1, s2);
|
||||
}
|
||||
|
||||
/*
|
||||
* Display list of strings in columnar format on readline's output stream.
|
||||
* 'matches' is list of strings, 'len' is number of strings in 'matches',
|
||||
* 'max' is maximum length of string in 'matches'.
|
||||
*/
|
||||
void
|
||||
fn_display_match_list (EditLine *el, char **matches, int len, int max)
|
||||
{
|
||||
int i, idx, limit, count;
|
||||
int screenwidth = el->el_term.t_size.h;
|
||||
|
||||
/*
|
||||
* Find out how many entries can be put on one line, count
|
||||
* with two spaces between strings.
|
||||
*/
|
||||
limit = screenwidth / (max + 2);
|
||||
if (limit == 0)
|
||||
limit = 1;
|
||||
|
||||
/* how many lines of output */
|
||||
count = len / limit;
|
||||
if (count * limit < len)
|
||||
count++;
|
||||
|
||||
/* Sort the items if they are not already sorted. */
|
||||
qsort(&matches[1], (size_t)(len - 1), sizeof(char *),
|
||||
_fn_qsort_string_compare);
|
||||
|
||||
idx = 1;
|
||||
for(; count > 0; count--) {
|
||||
for(i = 0; i < limit && matches[idx]; i++, idx++)
|
||||
(void)fprintf(el->el_outfile, "%-*s ", max,
|
||||
matches[idx]);
|
||||
(void)fprintf(el->el_outfile, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Complete the word at or before point,
|
||||
* 'what_to_do' says what to do with the completion.
|
||||
* \t means do standard completion.
|
||||
* `?' means list the possible completions.
|
||||
* `*' means insert all of the possible completions.
|
||||
* `!' means to do standard completion, and list all possible completions if
|
||||
* there is more than one.
|
||||
*
|
||||
* Note: '*' support is not implemented
|
||||
* '!' could never be invoked
|
||||
*/
|
||||
int
|
||||
fn_complete(EditLine *el,
|
||||
char *(*complet_func)(const char *, int),
|
||||
char **(*attempted_completion_function)(const char *, int, int),
|
||||
const char *word_break, const char *special_prefixes,
|
||||
const char *(*app_func)(const char *), int query_items,
|
||||
int *completion_type, int *over, int *point, int *end)
|
||||
{
|
||||
const LineInfo *li;
|
||||
char *temp, **matches;
|
||||
const char *ctemp;
|
||||
size_t len;
|
||||
int what_to_do = '\t';
|
||||
int retval = CC_NORM;
|
||||
|
||||
if (el->el_state.lastcmd == el->el_state.thiscmd)
|
||||
what_to_do = '?';
|
||||
|
||||
/* readline's rl_complete() has to be told what we did... */
|
||||
if (completion_type != NULL)
|
||||
*completion_type = what_to_do;
|
||||
|
||||
if (!complet_func)
|
||||
complet_func = fn_filename_completion_function;
|
||||
if (!app_func)
|
||||
app_func = append_char_function;
|
||||
|
||||
/* We now look backwards for the start of a filename/variable word */
|
||||
li = el_line(el);
|
||||
ctemp = (const char *) li->cursor;
|
||||
while (ctemp > li->buffer
|
||||
&& !strchr(word_break, ctemp[-1])
|
||||
&& (!special_prefixes || !strchr(special_prefixes, ctemp[-1]) ) )
|
||||
ctemp--;
|
||||
|
||||
len = li->cursor - ctemp;
|
||||
#if defined(__SSP__) || defined(__SSP_ALL__)
|
||||
temp = malloc(len + 1);
|
||||
#else
|
||||
temp = alloca(len + 1);
|
||||
#endif
|
||||
(void)strncpy(temp, ctemp, len);
|
||||
temp[len] = '\0';
|
||||
|
||||
/* these can be used by function called in completion_matches() */
|
||||
/* or (*attempted_completion_function)() */
|
||||
if (point != 0)
|
||||
*point = li->cursor - li->buffer;
|
||||
if (end != NULL)
|
||||
*end = li->lastchar - li->buffer;
|
||||
|
||||
if (attempted_completion_function) {
|
||||
int cur_off = li->cursor - li->buffer;
|
||||
matches = (*attempted_completion_function) (temp,
|
||||
(int)(cur_off - len), cur_off);
|
||||
} else
|
||||
matches = 0;
|
||||
if (!attempted_completion_function ||
|
||||
(over != NULL && !*over && !matches))
|
||||
matches = completion_matches(temp, complet_func);
|
||||
|
||||
if (over != NULL)
|
||||
*over = 0;
|
||||
|
||||
if (matches) {
|
||||
int i;
|
||||
int matches_num, maxlen, match_len, match_display=1;
|
||||
|
||||
retval = CC_REFRESH;
|
||||
/*
|
||||
* Only replace the completed string with common part of
|
||||
* possible matches if there is possible completion.
|
||||
*/
|
||||
if (matches[0][0] != '\0') {
|
||||
el_deletestr(el, (int) len);
|
||||
el_insertstr(el, matches[0]);
|
||||
}
|
||||
|
||||
if (what_to_do == '?')
|
||||
goto display_matches;
|
||||
|
||||
if (matches[2] == NULL && strcmp(matches[0], matches[1]) == 0) {
|
||||
/*
|
||||
* We found exact match. Add a space after
|
||||
* it, unless we do filename completion and the
|
||||
* object is a directory.
|
||||
*/
|
||||
el_insertstr(el, (*append_char_function)(matches[0]));
|
||||
} else if (what_to_do == '!') {
|
||||
display_matches:
|
||||
/*
|
||||
* More than one match and requested to list possible
|
||||
* matches.
|
||||
*/
|
||||
|
||||
for(i=1, maxlen=0; matches[i]; i++) {
|
||||
match_len = strlen(matches[i]);
|
||||
if (match_len > maxlen)
|
||||
maxlen = match_len;
|
||||
}
|
||||
matches_num = i - 1;
|
||||
|
||||
/* newline to get on next line from command line */
|
||||
(void)fprintf(el->el_outfile, "\n");
|
||||
|
||||
/*
|
||||
* If there are too many items, ask user for display
|
||||
* confirmation.
|
||||
*/
|
||||
if (matches_num > query_items) {
|
||||
(void)fprintf(el->el_outfile,
|
||||
"Display all %d possibilities? (y or n) ",
|
||||
matches_num);
|
||||
(void)fflush(el->el_outfile);
|
||||
if (getc(stdin) != 'y')
|
||||
match_display = 0;
|
||||
(void)fprintf(el->el_outfile, "\n");
|
||||
}
|
||||
|
||||
if (match_display)
|
||||
fn_display_match_list(el, matches, matches_num,
|
||||
maxlen);
|
||||
retval = CC_REDISPLAY;
|
||||
} else if (matches[0][0]) {
|
||||
/*
|
||||
* There was some common match, but the name was
|
||||
* not complete enough. Next tab will print possible
|
||||
* completions.
|
||||
*/
|
||||
el_beep(el);
|
||||
} else {
|
||||
/* lcd is not a valid object - further specification */
|
||||
/* is needed */
|
||||
el_beep(el);
|
||||
retval = CC_NORM;
|
||||
}
|
||||
|
||||
/* free elements of array and the array itself */
|
||||
for (i = 0; matches[i]; i++)
|
||||
free(matches[i]);
|
||||
free(matches);
|
||||
matches = NULL;
|
||||
}
|
||||
#if defined(__SSP__) || defined(__SSP_ALL__)
|
||||
free(temp);
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
/*
|
||||
* el-compatible wrapper around rl_complete; needed for key binding
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
unsigned char
|
||||
_el_fn_complete(EditLine *el, int ch __attribute__((__unused__)))
|
||||
{
|
||||
return (unsigned char)fn_complete(el, NULL, NULL,
|
||||
break_chars, NULL, NULL, 100,
|
||||
NULL, NULL, NULL, NULL);
|
||||
}
|
47
extern/editline/src/filecomplete.h
vendored
Normal file
47
extern/editline/src/filecomplete.h
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/* $NetBSD: filecomplete.h,v 1.5 2006/08/21 12:45:30 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jaromir Dolecek.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef _FILECOMPLETE_H_
|
||||
#define _FILECOMPLETE_H_
|
||||
|
||||
int fn_complete(EditLine *,
|
||||
char *(*)(const char *, int),
|
||||
char **(*)(const char *, int, int),
|
||||
const char *, const char *, const char *(*)(const char *), int,
|
||||
int *, int *, int *, int *);
|
||||
|
||||
void fn_display_match_list(EditLine *, char **, int, int);
|
||||
char *fn_tilde_expand(const char *);
|
||||
char *fn_filename_completion_function(const char *, int);
|
||||
|
||||
#endif
|
210
extern/editline/src/hist.c
vendored
Normal file
210
extern/editline/src/hist.c
vendored
Normal file
@ -0,0 +1,210 @@
|
||||
/* $NetBSD: hist.c,v 1.15 2003/11/01 23:36:39 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: hist.c,v 1.15 2003/11/01 23:36:39 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* hist.c: History access functions
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include "el.h"
|
||||
|
||||
/* hist_init():
|
||||
* Initialization function.
|
||||
*/
|
||||
protected int
|
||||
hist_init(EditLine *el)
|
||||
{
|
||||
|
||||
el->el_history.fun = NULL;
|
||||
el->el_history.ref = NULL;
|
||||
el->el_history.buf = (char *) el_malloc(EL_BUFSIZ);
|
||||
el->el_history.sz = EL_BUFSIZ;
|
||||
if (el->el_history.buf == NULL)
|
||||
return (-1);
|
||||
el->el_history.last = el->el_history.buf;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* hist_end():
|
||||
* clean up history;
|
||||
*/
|
||||
protected void
|
||||
hist_end(EditLine *el)
|
||||
{
|
||||
|
||||
el_free((ptr_t) el->el_history.buf);
|
||||
el->el_history.buf = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* hist_set():
|
||||
* Set new history interface
|
||||
*/
|
||||
protected int
|
||||
hist_set(EditLine *el, hist_fun_t fun, ptr_t ptr)
|
||||
{
|
||||
|
||||
el->el_history.ref = ptr;
|
||||
el->el_history.fun = fun;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* hist_get():
|
||||
* Get a history line and update it in the buffer.
|
||||
* eventno tells us the event to get.
|
||||
*/
|
||||
protected el_action_t
|
||||
hist_get(EditLine *el)
|
||||
{
|
||||
const char *hp;
|
||||
int h;
|
||||
|
||||
if (el->el_history.eventno == 0) { /* if really the current line */
|
||||
(void) strncpy(el->el_line.buffer, el->el_history.buf,
|
||||
el->el_history.sz);
|
||||
el->el_line.lastchar = el->el_line.buffer +
|
||||
(el->el_history.last - el->el_history.buf);
|
||||
|
||||
#ifdef KSHVI
|
||||
if (el->el_map.type == MAP_VI)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
else
|
||||
#endif /* KSHVI */
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
if (el->el_history.ref == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
hp = HIST_FIRST(el);
|
||||
|
||||
if (hp == NULL)
|
||||
return (CC_ERROR);
|
||||
|
||||
for (h = 1; h < el->el_history.eventno; h++)
|
||||
if ((hp = HIST_NEXT(el)) == NULL) {
|
||||
el->el_history.eventno = h;
|
||||
return (CC_ERROR);
|
||||
}
|
||||
(void) strlcpy(el->el_line.buffer, hp,
|
||||
(size_t)(el->el_line.limit - el->el_line.buffer));
|
||||
el->el_line.lastchar = el->el_line.buffer + strlen(el->el_line.buffer);
|
||||
|
||||
if (el->el_line.lastchar > el->el_line.buffer
|
||||
&& el->el_line.lastchar[-1] == '\n')
|
||||
el->el_line.lastchar--;
|
||||
if (el->el_line.lastchar > el->el_line.buffer
|
||||
&& el->el_line.lastchar[-1] == ' ')
|
||||
el->el_line.lastchar--;
|
||||
#ifdef KSHVI
|
||||
if (el->el_map.type == MAP_VI)
|
||||
el->el_line.cursor = el->el_line.buffer;
|
||||
else
|
||||
#endif /* KSHVI */
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* hist_command()
|
||||
* process a history command
|
||||
*/
|
||||
protected int
|
||||
hist_command(EditLine *el, int argc, const char **argv)
|
||||
{
|
||||
const char *str;
|
||||
int num;
|
||||
HistEvent ev;
|
||||
|
||||
if (el->el_history.ref == NULL)
|
||||
return (-1);
|
||||
|
||||
if (argc == 1 || strcmp(argv[1], "list") == 0) {
|
||||
/* List history entries */
|
||||
|
||||
for (str = HIST_LAST(el); str != NULL; str = HIST_PREV(el))
|
||||
(void) fprintf(el->el_outfile, "%d %s",
|
||||
el->el_history.ev.num, str);
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (argc != 3)
|
||||
return (-1);
|
||||
|
||||
num = (int)strtol(argv[2], NULL, 0);
|
||||
|
||||
if (strcmp(argv[1], "size") == 0)
|
||||
return history(el->el_history.ref, &ev, H_SETSIZE, num);
|
||||
|
||||
if (strcmp(argv[1], "unique") == 0)
|
||||
return history(el->el_history.ref, &ev, H_SETUNIQUE, num);
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* hist_enlargebuf()
|
||||
* Enlarge history buffer to specified value. Called from el_enlargebufs().
|
||||
* Return 0 for failure, 1 for success.
|
||||
*/
|
||||
protected int
|
||||
/*ARGSUSED*/
|
||||
hist_enlargebuf(EditLine *el, size_t oldsz, size_t newsz)
|
||||
{
|
||||
char *newbuf;
|
||||
|
||||
newbuf = realloc(el->el_history.buf, newsz);
|
||||
if (!newbuf)
|
||||
return 0;
|
||||
|
||||
(void) memset(&newbuf[oldsz], '\0', newsz - oldsz);
|
||||
|
||||
el->el_history.last = newbuf +
|
||||
(el->el_history.last - el->el_history.buf);
|
||||
el->el_history.buf = newbuf;
|
||||
el->el_history.sz = newsz;
|
||||
|
||||
return 1;
|
||||
}
|
76
extern/editline/src/hist.h
vendored
Normal file
76
extern/editline/src/hist.h
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
/* $NetBSD: hist.h,v 1.10 2003/08/07 16:44:31 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)hist.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.hist.c: History functions
|
||||
*/
|
||||
#ifndef _h_el_hist
|
||||
#define _h_el_hist
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef int (*hist_fun_t)(ptr_t, HistEvent *, int, ...);
|
||||
|
||||
typedef struct el_history_t {
|
||||
char *buf; /* The history buffer */
|
||||
size_t sz; /* Size of history buffer */
|
||||
char *last; /* The last character */
|
||||
int eventno; /* Event we are looking for */
|
||||
ptr_t ref; /* Argument for history fcns */
|
||||
hist_fun_t fun; /* Event access */
|
||||
HistEvent ev; /* Event cookie */
|
||||
} el_history_t;
|
||||
|
||||
#define HIST_FUN(el, fn, arg) \
|
||||
((((*(el)->el_history.fun) ((el)->el_history.ref, &(el)->el_history.ev, \
|
||||
fn, arg)) == -1) ? NULL : (el)->el_history.ev.str)
|
||||
|
||||
#define HIST_NEXT(el) HIST_FUN(el, H_NEXT, NULL)
|
||||
#define HIST_FIRST(el) HIST_FUN(el, H_FIRST, NULL)
|
||||
#define HIST_LAST(el) HIST_FUN(el, H_LAST, NULL)
|
||||
#define HIST_PREV(el) HIST_FUN(el, H_PREV, NULL)
|
||||
#define HIST_SET(el, num) HIST_FUN(el, H_SET, num)
|
||||
#define HIST_LOAD(el, fname) HIST_FUN(el, H_LOAD fname)
|
||||
#define HIST_SAVE(el, fname) HIST_FUN(el, H_SAVE fname)
|
||||
|
||||
protected int hist_init(EditLine *);
|
||||
protected void hist_end(EditLine *);
|
||||
protected el_action_t hist_get(EditLine *);
|
||||
protected int hist_set(EditLine *, hist_fun_t, ptr_t);
|
||||
protected int hist_command(EditLine *, int, const char **);
|
||||
protected int hist_enlargebuf(EditLine *, size_t, size_t);
|
||||
|
||||
#endif /* _h_el_hist */
|
227
extern/editline/src/histedit.h
vendored
Normal file
227
extern/editline/src/histedit.h
vendored
Normal file
@ -0,0 +1,227 @@
|
||||
/* $NetBSD: histedit.h,v 1.31 2006/12/15 22:13:33 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)histedit.h 8.2 (Berkeley) 1/3/94
|
||||
*/
|
||||
|
||||
/*
|
||||
* histedit.h: Line editor and history interface.
|
||||
*/
|
||||
#ifndef _HISTEDIT_H_
|
||||
#define _HISTEDIT_H_
|
||||
|
||||
#define LIBEDIT_MAJOR 2
|
||||
#define LIBEDIT_MINOR 10
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ==== Editing ====
|
||||
*/
|
||||
|
||||
typedef struct editline EditLine;
|
||||
|
||||
/*
|
||||
* For user-defined function interface
|
||||
*/
|
||||
typedef struct lineinfo {
|
||||
const char *buffer;
|
||||
const char *cursor;
|
||||
const char *lastchar;
|
||||
} LineInfo;
|
||||
|
||||
/*
|
||||
* EditLine editor function return codes.
|
||||
* For user-defined function interface
|
||||
*/
|
||||
#define CC_NORM 0
|
||||
#define CC_NEWLINE 1
|
||||
#define CC_EOF 2
|
||||
#define CC_ARGHACK 3
|
||||
#define CC_REFRESH 4
|
||||
#define CC_CURSOR 5
|
||||
#define CC_ERROR 6
|
||||
#define CC_FATAL 7
|
||||
#define CC_REDISPLAY 8
|
||||
#define CC_REFRESH_BEEP 9
|
||||
|
||||
/*
|
||||
* Initialization, cleanup, and resetting
|
||||
*/
|
||||
EditLine *el_init(const char *, FILE *, FILE *, FILE *);
|
||||
void el_end(EditLine *);
|
||||
void el_reset(EditLine *);
|
||||
|
||||
/*
|
||||
* Get a line, a character or push a string back in the input queue
|
||||
*/
|
||||
const char *el_gets(EditLine *, int *);
|
||||
int el_getc(EditLine *, char *);
|
||||
void el_push(EditLine *, char *);
|
||||
|
||||
/*
|
||||
* Beep!
|
||||
*/
|
||||
void el_beep(EditLine *);
|
||||
|
||||
/*
|
||||
* High level function internals control
|
||||
* Parses argc, argv array and executes builtin editline commands
|
||||
*/
|
||||
int el_parse(EditLine *, int, const char **);
|
||||
|
||||
/*
|
||||
* Low level editline access functions
|
||||
*/
|
||||
int el_set(EditLine *, int, ...);
|
||||
int el_get(EditLine *, int, ...);
|
||||
unsigned char _el_fn_complete(EditLine *, int);
|
||||
|
||||
/*
|
||||
* el_set/el_get parameters
|
||||
*/
|
||||
#define EL_PROMPT 0 /* , el_pfunc_t); */
|
||||
#define EL_TERMINAL 1 /* , const char *); */
|
||||
#define EL_EDITOR 2 /* , const char *); */
|
||||
#define EL_SIGNAL 3 /* , int); */
|
||||
#define EL_BIND 4 /* , const char *, ..., NULL); */
|
||||
#define EL_TELLTC 5 /* , const char *, ..., NULL); */
|
||||
#define EL_SETTC 6 /* , const char *, ..., NULL); */
|
||||
#define EL_ECHOTC 7 /* , const char *, ..., NULL); */
|
||||
#define EL_SETTY 8 /* , const char *, ..., NULL); */
|
||||
#define EL_ADDFN 9 /* , const char *, const char * */
|
||||
/* , el_func_t); */
|
||||
#define EL_HIST 10 /* , hist_fun_t, const char *); */
|
||||
#define EL_EDITMODE 11 /* , int); */
|
||||
#define EL_RPROMPT 12 /* , el_pfunc_t); */
|
||||
#define EL_GETCFN 13 /* , el_rfunc_t); */
|
||||
#define EL_CLIENTDATA 14 /* , void *); */
|
||||
#define EL_UNBUFFERED 15 /* , int); */
|
||||
#define EL_PREP_TERM 16 /* , int); */
|
||||
#define EL_GETTC 17 /* , const char *, ..., NULL); */
|
||||
#define EL_GETFP 18 /* , int, FILE **) */
|
||||
#define EL_SETFP 19 /* , int, FILE *) */
|
||||
|
||||
#define EL_BUILTIN_GETCFN (NULL)
|
||||
|
||||
/*
|
||||
* Source named file or $PWD/.editrc or $HOME/.editrc
|
||||
*/
|
||||
int el_source(EditLine *, const char *);
|
||||
|
||||
/*
|
||||
* Must be called when the terminal changes size; If EL_SIGNAL
|
||||
* is set this is done automatically otherwise it is the responsibility
|
||||
* of the application
|
||||
*/
|
||||
void el_resize(EditLine *);
|
||||
|
||||
/*
|
||||
* User-defined function interface.
|
||||
*/
|
||||
const LineInfo *el_line(EditLine *);
|
||||
int el_insertstr(EditLine *, const char *);
|
||||
void el_deletestr(EditLine *, int);
|
||||
|
||||
|
||||
/*
|
||||
* ==== History ====
|
||||
*/
|
||||
|
||||
typedef struct history History;
|
||||
|
||||
typedef struct HistEvent {
|
||||
int num;
|
||||
const char *str;
|
||||
} HistEvent;
|
||||
|
||||
/*
|
||||
* History access functions.
|
||||
*/
|
||||
History * history_init(void);
|
||||
void history_end(History *);
|
||||
|
||||
int history(History *, HistEvent *, int, ...);
|
||||
|
||||
#define H_FUNC 0 /* , UTSL */
|
||||
#define H_SETSIZE 1 /* , const int); */
|
||||
#define H_GETSIZE 2 /* , void); */
|
||||
#define H_FIRST 3 /* , void); */
|
||||
#define H_LAST 4 /* , void); */
|
||||
#define H_PREV 5 /* , void); */
|
||||
#define H_NEXT 6 /* , void); */
|
||||
#define H_CURR 8 /* , const int); */
|
||||
#define H_SET 7 /* , int); */
|
||||
#define H_ADD 9 /* , const char *); */
|
||||
#define H_ENTER 10 /* , const char *); */
|
||||
#define H_APPEND 11 /* , const char *); */
|
||||
#define H_END 12 /* , void); */
|
||||
#define H_NEXT_STR 13 /* , const char *); */
|
||||
#define H_PREV_STR 14 /* , const char *); */
|
||||
#define H_NEXT_EVENT 15 /* , const int); */
|
||||
#define H_PREV_EVENT 16 /* , const int); */
|
||||
#define H_LOAD 17 /* , const char *); */
|
||||
#define H_SAVE 18 /* , const char *); */
|
||||
#define H_CLEAR 19 /* , void); */
|
||||
#define H_SETUNIQUE 20 /* , int); */
|
||||
#define H_GETUNIQUE 21 /* , void); */
|
||||
#define H_DEL 22 /* , int); */
|
||||
|
||||
|
||||
/*
|
||||
* ==== Tokenization ====
|
||||
*/
|
||||
|
||||
typedef struct tokenizer Tokenizer;
|
||||
|
||||
/*
|
||||
* String tokenization functions, using simplified sh(1) quoting rules
|
||||
*/
|
||||
Tokenizer *tok_init(const char *);
|
||||
void tok_end(Tokenizer *);
|
||||
void tok_reset(Tokenizer *);
|
||||
int tok_line(Tokenizer *, const LineInfo *,
|
||||
int *, const char ***, int *, int *);
|
||||
int tok_str(Tokenizer *, const char *,
|
||||
int *, const char ***);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _HISTEDIT_H_ */
|
987
extern/editline/src/history.c
vendored
Normal file
987
extern/editline/src/history.c
vendored
Normal file
@ -0,0 +1,987 @@
|
||||
/* $NetBSD: history.c,v 1.32 2006/09/28 13:52:51 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)history.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: history.c,v 1.32 2006/09/28 13:52:51 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* hist.c: History access functions
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <vis.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
static const char hist_cookie[] = "_HiStOrY_V2_\n";
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef int (*history_gfun_t)(ptr_t, HistEvent *);
|
||||
typedef int (*history_efun_t)(ptr_t, HistEvent *, const char *);
|
||||
typedef void (*history_vfun_t)(ptr_t, HistEvent *);
|
||||
typedef int (*history_sfun_t)(ptr_t, HistEvent *, const int);
|
||||
|
||||
struct history {
|
||||
ptr_t h_ref; /* Argument for history fcns */
|
||||
int h_ent; /* Last entry point for history */
|
||||
history_gfun_t h_first; /* Get the first element */
|
||||
history_gfun_t h_next; /* Get the next element */
|
||||
history_gfun_t h_last; /* Get the last element */
|
||||
history_gfun_t h_prev; /* Get the previous element */
|
||||
history_gfun_t h_curr; /* Get the current element */
|
||||
history_sfun_t h_set; /* Set the current element */
|
||||
history_sfun_t h_del; /* Set the given element */
|
||||
history_vfun_t h_clear; /* Clear the history list */
|
||||
history_efun_t h_enter; /* Add an element */
|
||||
history_efun_t h_add; /* Append to an element */
|
||||
};
|
||||
|
||||
#define HNEXT(h, ev) (*(h)->h_next)((h)->h_ref, ev)
|
||||
#define HFIRST(h, ev) (*(h)->h_first)((h)->h_ref, ev)
|
||||
#define HPREV(h, ev) (*(h)->h_prev)((h)->h_ref, ev)
|
||||
#define HLAST(h, ev) (*(h)->h_last)((h)->h_ref, ev)
|
||||
#define HCURR(h, ev) (*(h)->h_curr)((h)->h_ref, ev)
|
||||
#define HSET(h, ev, n) (*(h)->h_set)((h)->h_ref, ev, n)
|
||||
#define HCLEAR(h, ev) (*(h)->h_clear)((h)->h_ref, ev)
|
||||
#define HENTER(h, ev, str) (*(h)->h_enter)((h)->h_ref, ev, str)
|
||||
#define HADD(h, ev, str) (*(h)->h_add)((h)->h_ref, ev, str)
|
||||
#define HDEL(h, ev, n) (*(h)->h_del)((h)->h_ref, ev, n)
|
||||
|
||||
#define h_strdup(a) strdup(a)
|
||||
#define h_malloc(a) malloc(a)
|
||||
#define h_realloc(a, b) realloc((a), (b))
|
||||
#define h_free(a) free(a)
|
||||
|
||||
typedef struct {
|
||||
int num;
|
||||
char *str;
|
||||
} HistEventPrivate;
|
||||
|
||||
|
||||
|
||||
private int history_setsize(History *, HistEvent *, int);
|
||||
private int history_getsize(History *, HistEvent *);
|
||||
private int history_setunique(History *, HistEvent *, int);
|
||||
private int history_getunique(History *, HistEvent *);
|
||||
private int history_set_fun(History *, History *);
|
||||
private int history_load(History *, const char *);
|
||||
private int history_save(History *, const char *);
|
||||
private int history_prev_event(History *, HistEvent *, int);
|
||||
private int history_next_event(History *, HistEvent *, int);
|
||||
private int history_next_string(History *, HistEvent *, const char *);
|
||||
private int history_prev_string(History *, HistEvent *, const char *);
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
|
||||
/*
|
||||
* Builtin- history implementation
|
||||
*/
|
||||
typedef struct hentry_t {
|
||||
HistEvent ev; /* What we return */
|
||||
struct hentry_t *next; /* Next entry */
|
||||
struct hentry_t *prev; /* Previous entry */
|
||||
} hentry_t;
|
||||
|
||||
typedef struct history_t {
|
||||
hentry_t list; /* Fake list header element */
|
||||
hentry_t *cursor; /* Current element in the list */
|
||||
int max; /* Maximum number of events */
|
||||
int cur; /* Current number of events */
|
||||
int eventid; /* For generation of unique event id */
|
||||
int flags; /* History flags */
|
||||
#define H_UNIQUE 1 /* Store only unique elements */
|
||||
} history_t;
|
||||
|
||||
private int history_def_next(ptr_t, HistEvent *);
|
||||
private int history_def_first(ptr_t, HistEvent *);
|
||||
private int history_def_prev(ptr_t, HistEvent *);
|
||||
private int history_def_last(ptr_t, HistEvent *);
|
||||
private int history_def_curr(ptr_t, HistEvent *);
|
||||
private int history_def_set(ptr_t, HistEvent *, const int);
|
||||
private void history_def_clear(ptr_t, HistEvent *);
|
||||
private int history_def_enter(ptr_t, HistEvent *, const char *);
|
||||
private int history_def_add(ptr_t, HistEvent *, const char *);
|
||||
private int history_def_del(ptr_t, HistEvent *, const int);
|
||||
|
||||
private int history_def_init(ptr_t *, HistEvent *, int);
|
||||
private int history_def_insert(history_t *, HistEvent *, const char *);
|
||||
private void history_def_delete(history_t *, HistEvent *, hentry_t *);
|
||||
|
||||
#define history_def_setsize(p, num)(void) (((history_t *)p)->max = (num))
|
||||
#define history_def_getsize(p) (((history_t *)p)->cur)
|
||||
#define history_def_getunique(p) (((((history_t *)p)->flags) & H_UNIQUE) != 0)
|
||||
#define history_def_setunique(p, uni) \
|
||||
if (uni) \
|
||||
(((history_t *)p)->flags) |= H_UNIQUE; \
|
||||
else \
|
||||
(((history_t *)p)->flags) &= ~H_UNIQUE
|
||||
|
||||
#define he_strerror(code) he_errlist[code]
|
||||
#define he_seterrev(evp, code) {\
|
||||
evp->num = code;\
|
||||
evp->str = he_strerror(code);\
|
||||
}
|
||||
|
||||
/* error messages */
|
||||
static const char *const he_errlist[] = {
|
||||
"OK",
|
||||
"unknown error",
|
||||
"malloc() failed",
|
||||
"first event not found",
|
||||
"last event not found",
|
||||
"empty list",
|
||||
"no next event",
|
||||
"no previous event",
|
||||
"current event is invalid",
|
||||
"event not found",
|
||||
"can't read history from file",
|
||||
"can't write history",
|
||||
"required parameter(s) not supplied",
|
||||
"history size negative",
|
||||
"function not allowed with other history-functions-set the default",
|
||||
"bad parameters"
|
||||
};
|
||||
/* error codes */
|
||||
#define _HE_OK 0
|
||||
#define _HE_UNKNOWN 1
|
||||
#define _HE_MALLOC_FAILED 2
|
||||
#define _HE_FIRST_NOTFOUND 3
|
||||
#define _HE_LAST_NOTFOUND 4
|
||||
#define _HE_EMPTY_LIST 5
|
||||
#define _HE_END_REACHED 6
|
||||
#define _HE_START_REACHED 7
|
||||
#define _HE_CURR_INVALID 8
|
||||
#define _HE_NOT_FOUND 9
|
||||
#define _HE_HIST_READ 10
|
||||
#define _HE_HIST_WRITE 11
|
||||
#define _HE_PARAM_MISSING 12
|
||||
#define _HE_SIZE_NEGATIVE 13
|
||||
#define _HE_NOT_ALLOWED 14
|
||||
#define _HE_BAD_PARAM 15
|
||||
|
||||
/* history_def_first():
|
||||
* Default function to return the first event in the history.
|
||||
*/
|
||||
private int
|
||||
history_def_first(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
h->cursor = h->list.next;
|
||||
if (h->cursor != &h->list)
|
||||
*ev = h->cursor->ev;
|
||||
else {
|
||||
he_seterrev(ev, _HE_FIRST_NOTFOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_last():
|
||||
* Default function to return the last event in the history.
|
||||
*/
|
||||
private int
|
||||
history_def_last(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
h->cursor = h->list.prev;
|
||||
if (h->cursor != &h->list)
|
||||
*ev = h->cursor->ev;
|
||||
else {
|
||||
he_seterrev(ev, _HE_LAST_NOTFOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_next():
|
||||
* Default function to return the next event in the history.
|
||||
*/
|
||||
private int
|
||||
history_def_next(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
if (h->cursor == &h->list) {
|
||||
he_seterrev(ev, _HE_EMPTY_LIST);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (h->cursor->next == &h->list) {
|
||||
he_seterrev(ev, _HE_END_REACHED);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
h->cursor = h->cursor->next;
|
||||
*ev = h->cursor->ev;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_prev():
|
||||
* Default function to return the previous event in the history.
|
||||
*/
|
||||
private int
|
||||
history_def_prev(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
if (h->cursor == &h->list) {
|
||||
he_seterrev(ev,
|
||||
(h->cur > 0) ? _HE_END_REACHED : _HE_EMPTY_LIST);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
if (h->cursor->prev == &h->list) {
|
||||
he_seterrev(ev, _HE_START_REACHED);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
h->cursor = h->cursor->prev;
|
||||
*ev = h->cursor->ev;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_curr():
|
||||
* Default function to return the current event in the history.
|
||||
*/
|
||||
private int
|
||||
history_def_curr(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
if (h->cursor != &h->list)
|
||||
*ev = h->cursor->ev;
|
||||
else {
|
||||
he_seterrev(ev,
|
||||
(h->cur > 0) ? _HE_CURR_INVALID : _HE_EMPTY_LIST);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_set():
|
||||
* Default function to set the current event in the history to the
|
||||
* given one.
|
||||
*/
|
||||
private int
|
||||
history_def_set(ptr_t p, HistEvent *ev, const int n)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
if (h->cur == 0) {
|
||||
he_seterrev(ev, _HE_EMPTY_LIST);
|
||||
return (-1);
|
||||
}
|
||||
if (h->cursor == &h->list || h->cursor->ev.num != n) {
|
||||
for (h->cursor = h->list.next; h->cursor != &h->list;
|
||||
h->cursor = h->cursor->next)
|
||||
if (h->cursor->ev.num == n)
|
||||
break;
|
||||
}
|
||||
if (h->cursor == &h->list) {
|
||||
he_seterrev(ev, _HE_NOT_FOUND);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_add():
|
||||
* Append string to element
|
||||
*/
|
||||
private int
|
||||
history_def_add(ptr_t p, HistEvent *ev, const char *str)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
size_t len;
|
||||
char *s;
|
||||
HistEventPrivate *evp = (void *)&h->cursor->ev;
|
||||
|
||||
if (h->cursor == &h->list)
|
||||
return (history_def_enter(p, ev, str));
|
||||
len = strlen(evp->str) + strlen(str) + 1;
|
||||
s = (char *) h_malloc(len);
|
||||
if (s == NULL) {
|
||||
he_seterrev(ev, _HE_MALLOC_FAILED);
|
||||
return (-1);
|
||||
}
|
||||
(void) strlcpy(s, h->cursor->ev.str, len);
|
||||
(void) strlcat(s, str, len);
|
||||
h_free((ptr_t)evp->str);
|
||||
evp->str = s;
|
||||
*ev = h->cursor->ev;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_del():
|
||||
* Delete element hp of the h list
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
private int
|
||||
history_def_del(ptr_t p, HistEvent *ev __attribute__((__unused__)),
|
||||
const int num)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
if (history_def_set(h, ev, num) != 0)
|
||||
return (-1);
|
||||
ev->str = strdup(h->cursor->ev.str);
|
||||
ev->num = h->cursor->ev.num;
|
||||
history_def_delete(h, ev, h->cursor);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_delete():
|
||||
* Delete element hp of the h list
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
private void
|
||||
history_def_delete(history_t *h,
|
||||
HistEvent *ev __attribute__((__unused__)), hentry_t *hp)
|
||||
{
|
||||
HistEventPrivate *evp = (void *)&hp->ev;
|
||||
if (hp == &h->list)
|
||||
abort();
|
||||
if (h->cursor == hp)
|
||||
h->cursor = hp->prev;
|
||||
hp->prev->next = hp->next;
|
||||
hp->next->prev = hp->prev;
|
||||
h_free((ptr_t) evp->str);
|
||||
h_free(hp);
|
||||
h->cur--;
|
||||
}
|
||||
|
||||
|
||||
/* history_def_insert():
|
||||
* Insert element with string str in the h list
|
||||
*/
|
||||
private int
|
||||
history_def_insert(history_t *h, HistEvent *ev, const char *str)
|
||||
{
|
||||
|
||||
h->cursor = (hentry_t *) h_malloc(sizeof(hentry_t));
|
||||
if (h->cursor == NULL)
|
||||
goto oomem;
|
||||
if ((h->cursor->ev.str = h_strdup(str)) == NULL) {
|
||||
h_free((ptr_t)h->cursor);
|
||||
goto oomem;
|
||||
}
|
||||
h->cursor->ev.num = ++h->eventid;
|
||||
h->cursor->next = h->list.next;
|
||||
h->cursor->prev = &h->list;
|
||||
h->list.next->prev = h->cursor;
|
||||
h->list.next = h->cursor;
|
||||
h->cur++;
|
||||
|
||||
*ev = h->cursor->ev;
|
||||
return (0);
|
||||
oomem:
|
||||
he_seterrev(ev, _HE_MALLOC_FAILED);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_enter():
|
||||
* Default function to enter an item in the history
|
||||
*/
|
||||
private int
|
||||
history_def_enter(ptr_t p, HistEvent *ev, const char *str)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
if ((h->flags & H_UNIQUE) != 0 && h->list.next != &h->list &&
|
||||
strcmp(h->list.next->ev.str, str) == 0)
|
||||
return (0);
|
||||
|
||||
if (history_def_insert(h, ev, str) == -1)
|
||||
return (-1); /* error, keep error message */
|
||||
|
||||
/*
|
||||
* Always keep at least one entry.
|
||||
* This way we don't have to check for the empty list.
|
||||
*/
|
||||
while (h->cur > h->max && h->cur > 0)
|
||||
history_def_delete(h, ev, h->list.prev);
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/* history_def_init():
|
||||
* Default history initialization function
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
private int
|
||||
history_def_init(ptr_t *p, HistEvent *ev __attribute__((__unused__)), int n)
|
||||
{
|
||||
history_t *h = (history_t *) h_malloc(sizeof(history_t));
|
||||
if (h == NULL)
|
||||
return -1;
|
||||
|
||||
if (n <= 0)
|
||||
n = 0;
|
||||
h->eventid = 0;
|
||||
h->cur = 0;
|
||||
h->max = n;
|
||||
h->list.next = h->list.prev = &h->list;
|
||||
h->list.ev.str = NULL;
|
||||
h->list.ev.num = 0;
|
||||
h->cursor = &h->list;
|
||||
h->flags = 0;
|
||||
*p = (ptr_t) h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* history_def_clear():
|
||||
* Default history cleanup function
|
||||
*/
|
||||
private void
|
||||
history_def_clear(ptr_t p, HistEvent *ev)
|
||||
{
|
||||
history_t *h = (history_t *) p;
|
||||
|
||||
while (h->list.prev != &h->list)
|
||||
history_def_delete(h, ev, h->list.prev);
|
||||
h->eventid = 0;
|
||||
h->cur = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************/
|
||||
|
||||
/* history_init():
|
||||
* Initialization function.
|
||||
*/
|
||||
public History *
|
||||
history_init(void)
|
||||
{
|
||||
HistEvent ev;
|
||||
History *h = (History *) h_malloc(sizeof(History));
|
||||
if (h == NULL)
|
||||
return NULL;
|
||||
|
||||
if (history_def_init(&h->h_ref, &ev, 0) == -1) {
|
||||
h_free((ptr_t)h);
|
||||
return NULL;
|
||||
}
|
||||
h->h_ent = -1;
|
||||
h->h_next = history_def_next;
|
||||
h->h_first = history_def_first;
|
||||
h->h_last = history_def_last;
|
||||
h->h_prev = history_def_prev;
|
||||
h->h_curr = history_def_curr;
|
||||
h->h_set = history_def_set;
|
||||
h->h_clear = history_def_clear;
|
||||
h->h_enter = history_def_enter;
|
||||
h->h_add = history_def_add;
|
||||
h->h_del = history_def_del;
|
||||
|
||||
return (h);
|
||||
}
|
||||
|
||||
|
||||
/* history_end():
|
||||
* clean up history;
|
||||
*/
|
||||
public void
|
||||
history_end(History *h)
|
||||
{
|
||||
HistEvent ev;
|
||||
|
||||
if (h->h_next == history_def_next)
|
||||
history_def_clear(h->h_ref, &ev);
|
||||
h_free(h->h_ref);
|
||||
h_free(h);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* history_setsize():
|
||||
* Set history number of events
|
||||
*/
|
||||
private int
|
||||
history_setsize(History *h, HistEvent *ev, int num)
|
||||
{
|
||||
|
||||
if (h->h_next != history_def_next) {
|
||||
he_seterrev(ev, _HE_NOT_ALLOWED);
|
||||
return (-1);
|
||||
}
|
||||
if (num < 0) {
|
||||
he_seterrev(ev, _HE_BAD_PARAM);
|
||||
return (-1);
|
||||
}
|
||||
history_def_setsize(h->h_ref, num);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_getsize():
|
||||
* Get number of events currently in history
|
||||
*/
|
||||
private int
|
||||
history_getsize(History *h, HistEvent *ev)
|
||||
{
|
||||
if (h->h_next != history_def_next) {
|
||||
he_seterrev(ev, _HE_NOT_ALLOWED);
|
||||
return (-1);
|
||||
}
|
||||
ev->num = history_def_getsize(h->h_ref);
|
||||
if (ev->num < -1) {
|
||||
he_seterrev(ev, _HE_SIZE_NEGATIVE);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_setunique():
|
||||
* Set if adjacent equal events should not be entered in history.
|
||||
*/
|
||||
private int
|
||||
history_setunique(History *h, HistEvent *ev, int uni)
|
||||
{
|
||||
|
||||
if (h->h_next != history_def_next) {
|
||||
he_seterrev(ev, _HE_NOT_ALLOWED);
|
||||
return (-1);
|
||||
}
|
||||
history_def_setunique(h->h_ref, uni);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_getunique():
|
||||
* Get if adjacent equal events should not be entered in history.
|
||||
*/
|
||||
private int
|
||||
history_getunique(History *h, HistEvent *ev)
|
||||
{
|
||||
if (h->h_next != history_def_next) {
|
||||
he_seterrev(ev, _HE_NOT_ALLOWED);
|
||||
return (-1);
|
||||
}
|
||||
ev->num = history_def_getunique(h->h_ref);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_set_fun():
|
||||
* Set history functions
|
||||
*/
|
||||
private int
|
||||
history_set_fun(History *h, History *nh)
|
||||
{
|
||||
HistEvent ev;
|
||||
|
||||
if (nh->h_first == NULL || nh->h_next == NULL || nh->h_last == NULL ||
|
||||
nh->h_prev == NULL || nh->h_curr == NULL || nh->h_set == NULL ||
|
||||
nh->h_enter == NULL || nh->h_add == NULL || nh->h_clear == NULL ||
|
||||
nh->h_del == NULL || nh->h_ref == NULL) {
|
||||
if (h->h_next != history_def_next) {
|
||||
history_def_init(&h->h_ref, &ev, 0);
|
||||
h->h_first = history_def_first;
|
||||
h->h_next = history_def_next;
|
||||
h->h_last = history_def_last;
|
||||
h->h_prev = history_def_prev;
|
||||
h->h_curr = history_def_curr;
|
||||
h->h_set = history_def_set;
|
||||
h->h_clear = history_def_clear;
|
||||
h->h_enter = history_def_enter;
|
||||
h->h_add = history_def_add;
|
||||
h->h_del = history_def_del;
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
if (h->h_next == history_def_next)
|
||||
history_def_clear(h->h_ref, &ev);
|
||||
|
||||
h->h_ent = -1;
|
||||
h->h_first = nh->h_first;
|
||||
h->h_next = nh->h_next;
|
||||
h->h_last = nh->h_last;
|
||||
h->h_prev = nh->h_prev;
|
||||
h->h_curr = nh->h_curr;
|
||||
h->h_set = nh->h_set;
|
||||
h->h_clear = nh->h_clear;
|
||||
h->h_enter = nh->h_enter;
|
||||
h->h_add = nh->h_add;
|
||||
h->h_del = nh->h_del;
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* history_load():
|
||||
* History load function
|
||||
*/
|
||||
private int
|
||||
history_load(History *h, const char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
char *line;
|
||||
size_t sz, max_size;
|
||||
char *ptr;
|
||||
int i = -1;
|
||||
HistEvent ev;
|
||||
|
||||
if ((fp = fopen(fname, "r")) == NULL)
|
||||
return (i);
|
||||
|
||||
if ((line = fgetln(fp, &sz)) == NULL)
|
||||
goto done;
|
||||
|
||||
if (strncmp(line, hist_cookie, sz) != 0)
|
||||
goto done;
|
||||
|
||||
ptr = h_malloc(max_size = 1024);
|
||||
if (ptr == NULL)
|
||||
goto done;
|
||||
for (i = 0; (line = fgetln(fp, &sz)) != NULL; i++) {
|
||||
char c = line[sz];
|
||||
|
||||
if (sz != 0 && line[sz - 1] == '\n')
|
||||
line[--sz] = '\0';
|
||||
else
|
||||
line[sz] = '\0';
|
||||
|
||||
if (max_size < sz) {
|
||||
char *nptr;
|
||||
max_size = (sz + 1024) & ~1023;
|
||||
nptr = h_realloc(ptr, max_size);
|
||||
if (nptr == NULL) {
|
||||
i = -1;
|
||||
goto oomem;
|
||||
}
|
||||
ptr = nptr;
|
||||
}
|
||||
(void) strunvis(ptr, line);
|
||||
line[sz] = c;
|
||||
if (HENTER(h, &ev, ptr) == -1) {
|
||||
h_free((ptr_t)ptr);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
oomem:
|
||||
h_free((ptr_t)ptr);
|
||||
done:
|
||||
(void) fclose(fp);
|
||||
return (i);
|
||||
}
|
||||
|
||||
|
||||
/* history_save():
|
||||
* History save function
|
||||
*/
|
||||
private int
|
||||
history_save(History *h, const char *fname)
|
||||
{
|
||||
FILE *fp;
|
||||
HistEvent ev;
|
||||
int i = -1, retval;
|
||||
size_t len, max_size;
|
||||
char *ptr;
|
||||
|
||||
if ((fp = fopen(fname, "w")) == NULL)
|
||||
return (-1);
|
||||
|
||||
if (fchmod(fileno(fp), S_IRUSR|S_IWUSR) == -1)
|
||||
goto done;
|
||||
if (fputs(hist_cookie, fp) == EOF)
|
||||
goto done;
|
||||
ptr = h_malloc(max_size = 1024);
|
||||
if (ptr == NULL)
|
||||
goto done;
|
||||
for (i = 0, retval = HLAST(h, &ev);
|
||||
retval != -1;
|
||||
retval = HPREV(h, &ev), i++) {
|
||||
len = strlen(ev.str) * 4;
|
||||
if (len >= max_size) {
|
||||
char *nptr;
|
||||
max_size = (len + 1024) & ~1023;
|
||||
nptr = h_realloc(ptr, max_size);
|
||||
if (nptr == NULL) {
|
||||
i = -1;
|
||||
goto oomem;
|
||||
}
|
||||
ptr = nptr;
|
||||
}
|
||||
(void) strvis(ptr, ev.str, VIS_WHITE);
|
||||
(void) fprintf(fp, "%s\n", ptr);
|
||||
}
|
||||
oomem:
|
||||
h_free((ptr_t)ptr);
|
||||
done:
|
||||
(void) fclose(fp);
|
||||
return (i);
|
||||
}
|
||||
|
||||
|
||||
/* history_prev_event():
|
||||
* Find the previous event, with number given
|
||||
*/
|
||||
private int
|
||||
history_prev_event(History *h, HistEvent *ev, int num)
|
||||
{
|
||||
int retval;
|
||||
|
||||
for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev))
|
||||
if (ev->num == num)
|
||||
return (0);
|
||||
|
||||
he_seterrev(ev, _HE_NOT_FOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* history_next_event():
|
||||
* Find the next event, with number given
|
||||
*/
|
||||
private int
|
||||
history_next_event(History *h, HistEvent *ev, int num)
|
||||
{
|
||||
int retval;
|
||||
|
||||
for (retval = HCURR(h, ev); retval != -1; retval = HNEXT(h, ev))
|
||||
if (ev->num == num)
|
||||
return (0);
|
||||
|
||||
he_seterrev(ev, _HE_NOT_FOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* history_prev_string():
|
||||
* Find the previous event beginning with string
|
||||
*/
|
||||
private int
|
||||
history_prev_string(History *h, HistEvent *ev, const char *str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
int retval;
|
||||
|
||||
for (retval = HCURR(h, ev); retval != -1; retval = HNEXT(h, ev))
|
||||
if (strncmp(str, ev->str, len) == 0)
|
||||
return (0);
|
||||
|
||||
he_seterrev(ev, _HE_NOT_FOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* history_next_string():
|
||||
* Find the next event beginning with string
|
||||
*/
|
||||
private int
|
||||
history_next_string(History *h, HistEvent *ev, const char *str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
int retval;
|
||||
|
||||
for (retval = HCURR(h, ev); retval != -1; retval = HPREV(h, ev))
|
||||
if (strncmp(str, ev->str, len) == 0)
|
||||
return (0);
|
||||
|
||||
he_seterrev(ev, _HE_NOT_FOUND);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* history():
|
||||
* User interface to history functions.
|
||||
*/
|
||||
int
|
||||
history(History *h, HistEvent *ev, int fun, ...)
|
||||
{
|
||||
va_list va;
|
||||
const char *str;
|
||||
int retval;
|
||||
|
||||
va_start(va, fun);
|
||||
|
||||
he_seterrev(ev, _HE_OK);
|
||||
|
||||
switch (fun) {
|
||||
case H_GETSIZE:
|
||||
retval = history_getsize(h, ev);
|
||||
break;
|
||||
|
||||
case H_SETSIZE:
|
||||
retval = history_setsize(h, ev, va_arg(va, int));
|
||||
break;
|
||||
|
||||
case H_GETUNIQUE:
|
||||
retval = history_getunique(h, ev);
|
||||
break;
|
||||
|
||||
case H_SETUNIQUE:
|
||||
retval = history_setunique(h, ev, va_arg(va, int));
|
||||
break;
|
||||
|
||||
case H_ADD:
|
||||
str = va_arg(va, const char *);
|
||||
retval = HADD(h, ev, str);
|
||||
break;
|
||||
|
||||
case H_DEL:
|
||||
retval = HDEL(h, ev, va_arg(va, const int));
|
||||
break;
|
||||
|
||||
case H_ENTER:
|
||||
str = va_arg(va, const char *);
|
||||
if ((retval = HENTER(h, ev, str)) != -1)
|
||||
h->h_ent = ev->num;
|
||||
break;
|
||||
|
||||
case H_APPEND:
|
||||
str = va_arg(va, const char *);
|
||||
if ((retval = HSET(h, ev, h->h_ent)) != -1)
|
||||
retval = HADD(h, ev, str);
|
||||
break;
|
||||
|
||||
case H_FIRST:
|
||||
retval = HFIRST(h, ev);
|
||||
break;
|
||||
|
||||
case H_NEXT:
|
||||
retval = HNEXT(h, ev);
|
||||
break;
|
||||
|
||||
case H_LAST:
|
||||
retval = HLAST(h, ev);
|
||||
break;
|
||||
|
||||
case H_PREV:
|
||||
retval = HPREV(h, ev);
|
||||
break;
|
||||
|
||||
case H_CURR:
|
||||
retval = HCURR(h, ev);
|
||||
break;
|
||||
|
||||
case H_SET:
|
||||
retval = HSET(h, ev, va_arg(va, const int));
|
||||
break;
|
||||
|
||||
case H_CLEAR:
|
||||
HCLEAR(h, ev);
|
||||
retval = 0;
|
||||
break;
|
||||
|
||||
case H_LOAD:
|
||||
retval = history_load(h, va_arg(va, const char *));
|
||||
if (retval == -1)
|
||||
he_seterrev(ev, _HE_HIST_READ);
|
||||
break;
|
||||
|
||||
case H_SAVE:
|
||||
retval = history_save(h, va_arg(va, const char *));
|
||||
if (retval == -1)
|
||||
he_seterrev(ev, _HE_HIST_WRITE);
|
||||
break;
|
||||
|
||||
case H_PREV_EVENT:
|
||||
retval = history_prev_event(h, ev, va_arg(va, int));
|
||||
break;
|
||||
|
||||
case H_NEXT_EVENT:
|
||||
retval = history_next_event(h, ev, va_arg(va, int));
|
||||
break;
|
||||
|
||||
case H_PREV_STR:
|
||||
retval = history_prev_string(h, ev, va_arg(va, const char *));
|
||||
break;
|
||||
|
||||
case H_NEXT_STR:
|
||||
retval = history_next_string(h, ev, va_arg(va, const char *));
|
||||
break;
|
||||
|
||||
case H_FUNC:
|
||||
{
|
||||
History hf;
|
||||
|
||||
hf.h_ref = va_arg(va, ptr_t);
|
||||
h->h_ent = -1;
|
||||
hf.h_first = va_arg(va, history_gfun_t);
|
||||
hf.h_next = va_arg(va, history_gfun_t);
|
||||
hf.h_last = va_arg(va, history_gfun_t);
|
||||
hf.h_prev = va_arg(va, history_gfun_t);
|
||||
hf.h_curr = va_arg(va, history_gfun_t);
|
||||
hf.h_set = va_arg(va, history_sfun_t);
|
||||
hf.h_clear = va_arg(va, history_vfun_t);
|
||||
hf.h_enter = va_arg(va, history_efun_t);
|
||||
hf.h_add = va_arg(va, history_efun_t);
|
||||
hf.h_del = va_arg(va, history_sfun_t);
|
||||
|
||||
if ((retval = history_set_fun(h, &hf)) == -1)
|
||||
he_seterrev(ev, _HE_PARAM_MISSING);
|
||||
break;
|
||||
}
|
||||
|
||||
case H_END:
|
||||
history_end(h);
|
||||
retval = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
retval = -1;
|
||||
he_seterrev(ev, _HE_UNKNOWN);
|
||||
break;
|
||||
}
|
||||
va_end(va);
|
||||
return (retval);
|
||||
}
|
705
extern/editline/src/key.c
vendored
Normal file
705
extern/editline/src/key.c
vendored
Normal file
@ -0,0 +1,705 @@
|
||||
/* $NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)key.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: key.c,v 1.19 2006/03/23 20:22:51 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* key.c: This module contains the procedures for maintaining
|
||||
* the extended-key map.
|
||||
*
|
||||
* An extended-key (key) is a sequence of keystrokes introduced
|
||||
* with a sequence introducer and consisting of an arbitrary
|
||||
* number of characters. This module maintains a map (the el->el_key.map)
|
||||
* to convert these extended-key sequences into input strs
|
||||
* (XK_STR), editor functions (XK_CMD), or unix commands (XK_EXE).
|
||||
*
|
||||
* Warning:
|
||||
* If key is a substr of some other keys, then the longer
|
||||
* keys are lost!! That is, if the keys "abcd" and "abcef"
|
||||
* are in el->el_key.map, adding the key "abc" will cause the first two
|
||||
* definitions to be lost.
|
||||
*
|
||||
* Restrictions:
|
||||
* -------------
|
||||
* 1) It is not possible to have one key that is a
|
||||
* substr of another.
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "el.h"
|
||||
|
||||
/*
|
||||
* The Nodes of the el->el_key.map. The el->el_key.map is a linked list
|
||||
* of these node elements
|
||||
*/
|
||||
struct key_node_t {
|
||||
char ch; /* single character of key */
|
||||
int type; /* node type */
|
||||
key_value_t val; /* command code or pointer to str, */
|
||||
/* if this is a leaf */
|
||||
struct key_node_t *next; /* ptr to next char of this key */
|
||||
struct key_node_t *sibling; /* ptr to another key with same prefix*/
|
||||
};
|
||||
|
||||
private int node_trav(EditLine *, key_node_t *, char *,
|
||||
key_value_t *);
|
||||
private int node__try(EditLine *, key_node_t *, const char *,
|
||||
key_value_t *, int);
|
||||
private key_node_t *node__get(int);
|
||||
private void node__free(key_node_t *);
|
||||
private void node__put(EditLine *, key_node_t *);
|
||||
private int node__delete(EditLine *, key_node_t **, const char *);
|
||||
private int node_lookup(EditLine *, const char *, key_node_t *,
|
||||
int);
|
||||
private int node_enum(EditLine *, key_node_t *, int);
|
||||
|
||||
#define KEY_BUFSIZ EL_BUFSIZ
|
||||
|
||||
|
||||
/* key_init():
|
||||
* Initialize the key maps
|
||||
*/
|
||||
protected int
|
||||
key_init(EditLine *el)
|
||||
{
|
||||
|
||||
el->el_key.buf = (char *) el_malloc(KEY_BUFSIZ);
|
||||
if (el->el_key.buf == NULL)
|
||||
return (-1);
|
||||
el->el_key.map = NULL;
|
||||
key_reset(el);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* key_end():
|
||||
* Free the key maps
|
||||
*/
|
||||
protected void
|
||||
key_end(EditLine *el)
|
||||
{
|
||||
|
||||
el_free((ptr_t) el->el_key.buf);
|
||||
el->el_key.buf = NULL;
|
||||
node__free(el->el_key.map);
|
||||
}
|
||||
|
||||
|
||||
/* key_map_cmd():
|
||||
* Associate cmd with a key value
|
||||
*/
|
||||
protected key_value_t *
|
||||
key_map_cmd(EditLine *el, int cmd)
|
||||
{
|
||||
|
||||
el->el_key.val.cmd = (el_action_t) cmd;
|
||||
return (&el->el_key.val);
|
||||
}
|
||||
|
||||
|
||||
/* key_map_str():
|
||||
* Associate str with a key value
|
||||
*/
|
||||
protected key_value_t *
|
||||
key_map_str(EditLine *el, char *str)
|
||||
{
|
||||
|
||||
el->el_key.val.str = str;
|
||||
return (&el->el_key.val);
|
||||
}
|
||||
|
||||
|
||||
/* key_reset():
|
||||
* Takes all nodes on el->el_key.map and puts them on free list. Then
|
||||
* initializes el->el_key.map with arrow keys
|
||||
* [Always bind the ansi arrow keys?]
|
||||
*/
|
||||
protected void
|
||||
key_reset(EditLine *el)
|
||||
{
|
||||
|
||||
node__put(el, el->el_key.map);
|
||||
el->el_key.map = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* key_get():
|
||||
* Calls the recursive function with entry point el->el_key.map
|
||||
* Looks up *ch in map and then reads characters until a
|
||||
* complete match is found or a mismatch occurs. Returns the
|
||||
* type of the match found (XK_STR, XK_CMD, or XK_EXE).
|
||||
* Returns NULL in val.str and XK_STR for no match.
|
||||
* The last character read is returned in *ch.
|
||||
*/
|
||||
protected int
|
||||
key_get(EditLine *el, char *ch, key_value_t *val)
|
||||
{
|
||||
return node_trav(el, el->el_key.map, ch, val);
|
||||
}
|
||||
|
||||
|
||||
/* key_add():
|
||||
* Adds key to the el->el_key.map and associates the value in val with it.
|
||||
* If key is already is in el->el_key.map, the new code is applied to the
|
||||
* existing key. Ntype specifies if code is a command, an
|
||||
* out str or a unix command.
|
||||
*/
|
||||
protected void
|
||||
key_add(EditLine *el, const char *key, key_value_t *val, int ntype)
|
||||
{
|
||||
|
||||
if (key[0] == '\0') {
|
||||
(void) fprintf(el->el_errfile,
|
||||
"key_add: Null extended-key not allowed.\n");
|
||||
return;
|
||||
}
|
||||
if (ntype == XK_CMD && val->cmd == ED_SEQUENCE_LEAD_IN) {
|
||||
(void) fprintf(el->el_errfile,
|
||||
"key_add: sequence-lead-in command not allowed\n");
|
||||
return;
|
||||
}
|
||||
if (el->el_key.map == NULL)
|
||||
/* tree is initially empty. Set up new node to match key[0] */
|
||||
el->el_key.map = node__get(key[0]);
|
||||
/* it is properly initialized */
|
||||
|
||||
/* Now recurse through el->el_key.map */
|
||||
(void) node__try(el, el->el_key.map, key, val, ntype);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* key_clear():
|
||||
*
|
||||
*/
|
||||
protected void
|
||||
key_clear(EditLine *el, el_action_t *map, const char *in)
|
||||
{
|
||||
|
||||
if ((map[(unsigned char)*in] == ED_SEQUENCE_LEAD_IN) &&
|
||||
((map == el->el_map.key &&
|
||||
el->el_map.alt[(unsigned char)*in] != ED_SEQUENCE_LEAD_IN) ||
|
||||
(map == el->el_map.alt &&
|
||||
el->el_map.key[(unsigned char)*in] != ED_SEQUENCE_LEAD_IN)))
|
||||
(void) key_delete(el, in);
|
||||
}
|
||||
|
||||
|
||||
/* key_delete():
|
||||
* Delete the key and all longer keys staring with key, if
|
||||
* they exists.
|
||||
*/
|
||||
protected int
|
||||
key_delete(EditLine *el, const char *key)
|
||||
{
|
||||
|
||||
if (key[0] == '\0') {
|
||||
(void) fprintf(el->el_errfile,
|
||||
"key_delete: Null extended-key not allowed.\n");
|
||||
return (-1);
|
||||
}
|
||||
if (el->el_key.map == NULL)
|
||||
return (0);
|
||||
|
||||
(void) node__delete(el, &el->el_key.map, key);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* key_print():
|
||||
* Print the binding associated with key key.
|
||||
* Print entire el->el_key.map if null
|
||||
*/
|
||||
protected void
|
||||
key_print(EditLine *el, const char *key)
|
||||
{
|
||||
|
||||
/* do nothing if el->el_key.map is empty and null key specified */
|
||||
if (el->el_key.map == NULL && *key == 0)
|
||||
return;
|
||||
|
||||
el->el_key.buf[0] = '"';
|
||||
if (node_lookup(el, key, el->el_key.map, 1) <= -1)
|
||||
/* key is not bound */
|
||||
(void) fprintf(el->el_errfile, "Unbound extended key \"%s\"\n",
|
||||
key);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* node_trav():
|
||||
* recursively traverses node in tree until match or mismatch is
|
||||
* found. May read in more characters.
|
||||
*/
|
||||
private int
|
||||
node_trav(EditLine *el, key_node_t *ptr, char *ch, key_value_t *val)
|
||||
{
|
||||
|
||||
if (ptr->ch == *ch) {
|
||||
/* match found */
|
||||
if (ptr->next) {
|
||||
/* key not complete so get next char */
|
||||
if (el_getc(el, ch) != 1) { /* if EOF or error */
|
||||
val->cmd = ED_END_OF_FILE;
|
||||
return (XK_CMD);
|
||||
/* PWP: Pretend we just read an end-of-file */
|
||||
}
|
||||
return (node_trav(el, ptr->next, ch, val));
|
||||
} else {
|
||||
*val = ptr->val;
|
||||
if (ptr->type != XK_CMD)
|
||||
*ch = '\0';
|
||||
return (ptr->type);
|
||||
}
|
||||
} else {
|
||||
/* no match found here */
|
||||
if (ptr->sibling) {
|
||||
/* try next sibling */
|
||||
return (node_trav(el, ptr->sibling, ch, val));
|
||||
} else {
|
||||
/* no next sibling -- mismatch */
|
||||
val->str = NULL;
|
||||
return (XK_STR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* node__try():
|
||||
* Find a node that matches *str or allocate a new one
|
||||
*/
|
||||
private int
|
||||
node__try(EditLine *el, key_node_t *ptr, const char *str, key_value_t *val, int ntype)
|
||||
{
|
||||
|
||||
if (ptr->ch != *str) {
|
||||
key_node_t *xm;
|
||||
|
||||
for (xm = ptr; xm->sibling != NULL; xm = xm->sibling)
|
||||
if (xm->sibling->ch == *str)
|
||||
break;
|
||||
if (xm->sibling == NULL)
|
||||
xm->sibling = node__get(*str); /* setup new node */
|
||||
ptr = xm->sibling;
|
||||
}
|
||||
if (*++str == '\0') {
|
||||
/* we're there */
|
||||
if (ptr->next != NULL) {
|
||||
node__put(el, ptr->next);
|
||||
/* lose longer keys with this prefix */
|
||||
ptr->next = NULL;
|
||||
}
|
||||
switch (ptr->type) {
|
||||
case XK_CMD:
|
||||
case XK_NOD:
|
||||
break;
|
||||
case XK_STR:
|
||||
case XK_EXE:
|
||||
if (ptr->val.str)
|
||||
el_free((ptr_t) ptr->val.str);
|
||||
break;
|
||||
default:
|
||||
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n",
|
||||
ptr->type));
|
||||
break;
|
||||
}
|
||||
|
||||
switch (ptr->type = ntype) {
|
||||
case XK_CMD:
|
||||
ptr->val = *val;
|
||||
break;
|
||||
case XK_STR:
|
||||
case XK_EXE:
|
||||
if ((ptr->val.str = el_strdup(val->str)) == NULL)
|
||||
return -1;
|
||||
break;
|
||||
default:
|
||||
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* still more chars to go */
|
||||
if (ptr->next == NULL)
|
||||
ptr->next = node__get(*str); /* setup new node */
|
||||
(void) node__try(el, ptr->next, str, val, ntype);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* node__delete():
|
||||
* Delete node that matches str
|
||||
*/
|
||||
private int
|
||||
node__delete(EditLine *el, key_node_t **inptr, const char *str)
|
||||
{
|
||||
key_node_t *ptr;
|
||||
key_node_t *prev_ptr = NULL;
|
||||
|
||||
ptr = *inptr;
|
||||
|
||||
if (ptr->ch != *str) {
|
||||
key_node_t *xm;
|
||||
|
||||
for (xm = ptr; xm->sibling != NULL; xm = xm->sibling)
|
||||
if (xm->sibling->ch == *str)
|
||||
break;
|
||||
if (xm->sibling == NULL)
|
||||
return (0);
|
||||
prev_ptr = xm;
|
||||
ptr = xm->sibling;
|
||||
}
|
||||
if (*++str == '\0') {
|
||||
/* we're there */
|
||||
if (prev_ptr == NULL)
|
||||
*inptr = ptr->sibling;
|
||||
else
|
||||
prev_ptr->sibling = ptr->sibling;
|
||||
ptr->sibling = NULL;
|
||||
node__put(el, ptr);
|
||||
return (1);
|
||||
} else if (ptr->next != NULL &&
|
||||
node__delete(el, &ptr->next, str) == 1) {
|
||||
if (ptr->next != NULL)
|
||||
return (0);
|
||||
if (prev_ptr == NULL)
|
||||
*inptr = ptr->sibling;
|
||||
else
|
||||
prev_ptr->sibling = ptr->sibling;
|
||||
ptr->sibling = NULL;
|
||||
node__put(el, ptr);
|
||||
return (1);
|
||||
} else {
|
||||
return (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* node__put():
|
||||
* Puts a tree of nodes onto free list using free(3).
|
||||
*/
|
||||
private void
|
||||
node__put(EditLine *el, key_node_t *ptr)
|
||||
{
|
||||
if (ptr == NULL)
|
||||
return;
|
||||
|
||||
if (ptr->next != NULL) {
|
||||
node__put(el, ptr->next);
|
||||
ptr->next = NULL;
|
||||
}
|
||||
node__put(el, ptr->sibling);
|
||||
|
||||
switch (ptr->type) {
|
||||
case XK_CMD:
|
||||
case XK_NOD:
|
||||
break;
|
||||
case XK_EXE:
|
||||
case XK_STR:
|
||||
if (ptr->val.str != NULL)
|
||||
el_free((ptr_t) ptr->val.str);
|
||||
break;
|
||||
default:
|
||||
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ptr->type));
|
||||
break;
|
||||
}
|
||||
el_free((ptr_t) ptr);
|
||||
}
|
||||
|
||||
|
||||
/* node__get():
|
||||
* Returns pointer to a key_node_t for ch.
|
||||
*/
|
||||
private key_node_t *
|
||||
node__get(int ch)
|
||||
{
|
||||
key_node_t *ptr;
|
||||
|
||||
ptr = (key_node_t *) el_malloc((size_t) sizeof(key_node_t));
|
||||
if (ptr == NULL)
|
||||
return NULL;
|
||||
ptr->ch = ch;
|
||||
ptr->type = XK_NOD;
|
||||
ptr->val.str = NULL;
|
||||
ptr->next = NULL;
|
||||
ptr->sibling = NULL;
|
||||
return (ptr);
|
||||
}
|
||||
|
||||
private void
|
||||
node__free(key_node_t *k)
|
||||
{
|
||||
if (k == NULL)
|
||||
return;
|
||||
node__free(k->sibling);
|
||||
node__free(k->next);
|
||||
el_free((ptr_t) k);
|
||||
}
|
||||
|
||||
/* node_lookup():
|
||||
* look for the str starting at node ptr.
|
||||
* Print if last node
|
||||
*/
|
||||
private int
|
||||
node_lookup(EditLine *el, const char *str, key_node_t *ptr, int cnt)
|
||||
{
|
||||
int ncnt;
|
||||
|
||||
if (ptr == NULL)
|
||||
return (-1); /* cannot have null ptr */
|
||||
|
||||
if (*str == 0) {
|
||||
/* no more chars in str. node_enum from here. */
|
||||
(void) node_enum(el, ptr, cnt);
|
||||
return (0);
|
||||
} else {
|
||||
/* If match put this char into el->el_key.buf. Recurse */
|
||||
if (ptr->ch == *str) {
|
||||
/* match found */
|
||||
ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt,
|
||||
(unsigned char) ptr->ch);
|
||||
if (ptr->next != NULL)
|
||||
/* not yet at leaf */
|
||||
return (node_lookup(el, str + 1, ptr->next,
|
||||
ncnt + 1));
|
||||
else {
|
||||
/* next node is null so key should be complete */
|
||||
if (str[1] == 0) {
|
||||
el->el_key.buf[ncnt + 1] = '"';
|
||||
el->el_key.buf[ncnt + 2] = '\0';
|
||||
key_kprint(el, el->el_key.buf,
|
||||
&ptr->val, ptr->type);
|
||||
return (0);
|
||||
} else
|
||||
return (-1);
|
||||
/* mismatch -- str still has chars */
|
||||
}
|
||||
} else {
|
||||
/* no match found try sibling */
|
||||
if (ptr->sibling)
|
||||
return (node_lookup(el, str, ptr->sibling,
|
||||
cnt));
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* node_enum():
|
||||
* Traverse the node printing the characters it is bound in buffer
|
||||
*/
|
||||
private int
|
||||
node_enum(EditLine *el, key_node_t *ptr, int cnt)
|
||||
{
|
||||
int ncnt;
|
||||
|
||||
if (cnt >= KEY_BUFSIZ - 5) { /* buffer too small */
|
||||
el->el_key.buf[++cnt] = '"';
|
||||
el->el_key.buf[++cnt] = '\0';
|
||||
(void) fprintf(el->el_errfile,
|
||||
"Some extended keys too long for internal print buffer");
|
||||
(void) fprintf(el->el_errfile, " \"%s...\"\n", el->el_key.buf);
|
||||
return (0);
|
||||
}
|
||||
if (ptr == NULL) {
|
||||
#ifdef DEBUG_EDIT
|
||||
(void) fprintf(el->el_errfile,
|
||||
"node_enum: BUG!! Null ptr passed\n!");
|
||||
#endif
|
||||
return (-1);
|
||||
}
|
||||
/* put this char at end of str */
|
||||
ncnt = key__decode_char(el->el_key.buf, KEY_BUFSIZ, cnt,
|
||||
(unsigned char)ptr->ch);
|
||||
if (ptr->next == NULL) {
|
||||
/* print this key and function */
|
||||
el->el_key.buf[ncnt + 1] = '"';
|
||||
el->el_key.buf[ncnt + 2] = '\0';
|
||||
key_kprint(el, el->el_key.buf, &ptr->val, ptr->type);
|
||||
} else
|
||||
(void) node_enum(el, ptr->next, ncnt + 1);
|
||||
|
||||
/* go to sibling if there is one */
|
||||
if (ptr->sibling)
|
||||
(void) node_enum(el, ptr->sibling, cnt);
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* key_kprint():
|
||||
* Print the specified key and its associated
|
||||
* function specified by val
|
||||
*/
|
||||
protected void
|
||||
key_kprint(EditLine *el, const char *key, key_value_t *val, int ntype)
|
||||
{
|
||||
el_bindings_t *fp;
|
||||
char unparsbuf[EL_BUFSIZ];
|
||||
static const char fmt[] = "%-15s-> %s\n";
|
||||
|
||||
if (val != NULL)
|
||||
switch (ntype) {
|
||||
case XK_STR:
|
||||
case XK_EXE:
|
||||
(void) key__decode_str(val->str, unparsbuf,
|
||||
sizeof(unparsbuf),
|
||||
ntype == XK_STR ? "\"\"" : "[]");
|
||||
(void) fprintf(el->el_outfile, fmt, key, unparsbuf);
|
||||
break;
|
||||
case XK_CMD:
|
||||
for (fp = el->el_map.help; fp->name; fp++)
|
||||
if (val->cmd == fp->func) {
|
||||
(void) fprintf(el->el_outfile, fmt,
|
||||
key, fp->name);
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG_KEY
|
||||
if (fp->name == NULL)
|
||||
(void) fprintf(el->el_outfile,
|
||||
"BUG! Command not found.\n");
|
||||
#endif
|
||||
|
||||
break;
|
||||
default:
|
||||
EL_ABORT((el->el_errfile, "Bad XK_ type %d\n", ntype));
|
||||
break;
|
||||
}
|
||||
else
|
||||
(void) fprintf(el->el_outfile, fmt, key, "no input");
|
||||
}
|
||||
|
||||
|
||||
#define ADDC(c) \
|
||||
if (b < eb) \
|
||||
*b++ = c; \
|
||||
else \
|
||||
b++
|
||||
/* key__decode_char():
|
||||
* Put a printable form of char in buf.
|
||||
*/
|
||||
protected int
|
||||
key__decode_char(char *buf, int cnt, int off, int ch)
|
||||
{
|
||||
char *sb = buf + off;
|
||||
char *eb = buf + cnt;
|
||||
char *b = sb;
|
||||
if (ch == 0) {
|
||||
ADDC('^');
|
||||
ADDC('@');
|
||||
return b - sb;
|
||||
}
|
||||
if (iscntrl(ch)) {
|
||||
ADDC('^');
|
||||
if (ch == '\177')
|
||||
ADDC('?');
|
||||
else
|
||||
ADDC(ch | 0100);
|
||||
} else if (ch == '^') {
|
||||
ADDC('\\');
|
||||
ADDC('^');
|
||||
} else if (ch == '\\') {
|
||||
ADDC('\\');
|
||||
ADDC('\\');
|
||||
} else if (ch == ' ' || (isprint(ch) && !isspace(ch))) {
|
||||
ADDC(ch);
|
||||
} else {
|
||||
ADDC('\\');
|
||||
ADDC((((unsigned int) ch >> 6) & 7) + '0');
|
||||
ADDC((((unsigned int) ch >> 3) & 7) + '0');
|
||||
ADDC((ch & 7) + '0');
|
||||
}
|
||||
return b - sb;
|
||||
}
|
||||
|
||||
|
||||
/* key__decode_str():
|
||||
* Make a printable version of the ey
|
||||
*/
|
||||
protected int
|
||||
key__decode_str(const char *str, char *buf, int len, const char *sep)
|
||||
{
|
||||
char *b = buf, *eb = b + len;
|
||||
const char *p;
|
||||
|
||||
b = buf;
|
||||
if (sep[0] != '\0') {
|
||||
ADDC(sep[0]);
|
||||
}
|
||||
if (*str == '\0') {
|
||||
ADDC('^');
|
||||
ADDC('@');
|
||||
if (sep[0] != '\0' && sep[1] != '\0') {
|
||||
ADDC(sep[1]);
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
for (p = str; *p != 0; p++) {
|
||||
if (iscntrl((unsigned char) *p)) {
|
||||
ADDC('^');
|
||||
if (*p == '\177') {
|
||||
ADDC('?');
|
||||
} else {
|
||||
ADDC(*p | 0100);
|
||||
}
|
||||
} else if (*p == '^' || *p == '\\') {
|
||||
ADDC('\\');
|
||||
ADDC(*p);
|
||||
} else if (*p == ' ' || (isprint((unsigned char) *p) &&
|
||||
!isspace((unsigned char) *p))) {
|
||||
ADDC(*p);
|
||||
} else {
|
||||
ADDC('\\');
|
||||
ADDC((((unsigned int) *p >> 6) & 7) + '0');
|
||||
ADDC((((unsigned int) *p >> 3) & 7) + '0');
|
||||
ADDC((*p & 7) + '0');
|
||||
}
|
||||
}
|
||||
if (sep[0] != '\0' && sep[1] != '\0') {
|
||||
ADDC(sep[1]);
|
||||
}
|
||||
done:
|
||||
ADDC('\0');
|
||||
if (b - buf >= len)
|
||||
buf[len - 1] = '\0';
|
||||
return b - buf;
|
||||
}
|
81
extern/editline/src/key.h
vendored
Normal file
81
extern/editline/src/key.h
vendored
Normal file
@ -0,0 +1,81 @@
|
||||
/* $NetBSD: key.h,v 1.10 2006/03/23 20:22:51 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)key.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.key.h: Key macro header
|
||||
*/
|
||||
#ifndef _h_el_key
|
||||
#define _h_el_key
|
||||
|
||||
typedef union key_value_t {
|
||||
el_action_t cmd; /* If it is a command the # */
|
||||
char *str; /* If it is a string... */
|
||||
} key_value_t;
|
||||
|
||||
typedef struct key_node_t key_node_t;
|
||||
|
||||
typedef struct el_key_t {
|
||||
char *buf; /* Key print buffer */
|
||||
key_node_t *map; /* Key map */
|
||||
key_value_t val; /* Local conversion buffer */
|
||||
} el_key_t;
|
||||
|
||||
#define XK_CMD 0
|
||||
#define XK_STR 1
|
||||
#define XK_NOD 2
|
||||
#define XK_EXE 3
|
||||
|
||||
#undef key_end
|
||||
#undef key_clear
|
||||
#undef key_print
|
||||
|
||||
protected int key_init(EditLine *);
|
||||
protected void key_end(EditLine *);
|
||||
protected key_value_t *key_map_cmd(EditLine *, int);
|
||||
protected key_value_t *key_map_str(EditLine *, char *);
|
||||
protected void key_reset(EditLine *);
|
||||
protected int key_get(EditLine *, char *, key_value_t *);
|
||||
protected void key_add(EditLine *, const char *, key_value_t *, int);
|
||||
protected void key_clear(EditLine *, el_action_t *, const char *);
|
||||
protected int key_delete(EditLine *, const char *);
|
||||
protected void key_print(EditLine *, const char *);
|
||||
protected void key_kprint(EditLine *, const char *, key_value_t *,
|
||||
int);
|
||||
protected int key__decode_str(const char *, char *, int,
|
||||
const char *);
|
||||
protected int key__decode_char(char *, int, int, int);
|
||||
|
||||
#endif /* _h_el_key */
|
249
extern/editline/src/makelist
vendored
Normal file
249
extern/editline/src/makelist
vendored
Normal file
@ -0,0 +1,249 @@
|
||||
#!/bin/sh -
|
||||
# $NetBSD: makelist,v 1.11 2005/10/22 16:45:03 christos Exp $
|
||||
#
|
||||
# Copyright (c) 1992, 1993
|
||||
# The Regents of the University of California. All rights reserved.
|
||||
#
|
||||
# This code is derived from software contributed to Berkeley by
|
||||
# Christos Zoulas of Cornell University.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions
|
||||
# are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the University nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
# SUCH DAMAGE.
|
||||
#
|
||||
# @(#)makelist 5.3 (Berkeley) 6/4/93
|
||||
|
||||
# makelist.sh: Automatically generate header files...
|
||||
|
||||
AWK=awk
|
||||
USAGE="Usage: $0 -h|-e|-fc|-fh|-bc|-bh|-m <filenames>"
|
||||
|
||||
if [ "x$1" = "x" ]
|
||||
then
|
||||
echo $USAGE 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
FLAG="$1"
|
||||
shift
|
||||
|
||||
FILES="$@"
|
||||
|
||||
case $FLAG in
|
||||
|
||||
# generate foo.h file from foo.c
|
||||
#
|
||||
-h)
|
||||
set - `echo $FILES | sed -e 's/\\./_/g'`
|
||||
hdr="_h_`basename $1`"
|
||||
cat $FILES | $AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#ifndef %s\n#define %s\n", "'$hdr'", "'$hdr'");
|
||||
}
|
||||
/\(\):/ {
|
||||
pr = substr($2, 1, 2);
|
||||
if (pr == "vi" || pr == "em" || pr == "ed") {
|
||||
name = substr($2, 1, length($2) - 3);
|
||||
#
|
||||
# XXX: need a space between name and prototype so that -fc and -fh
|
||||
# parsing is much easier
|
||||
#
|
||||
printf("protected el_action_t\t%s (EditLine *, int);\n", name);
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("#endif /* %s */\n", "'$hdr'");
|
||||
}'
|
||||
;;
|
||||
|
||||
# generate help.c from various .c files
|
||||
#
|
||||
-bc)
|
||||
cat $FILES | $AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#include \"sys.h\"\n#include \"el.h\"\n");
|
||||
printf("private const struct el_bindings_t el_func_help[] = {\n");
|
||||
low = "abcdefghijklmnopqrstuvwxyz_";
|
||||
high = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_";
|
||||
for (i = 1; i <= length(low); i++)
|
||||
tr[substr(low, i, 1)] = substr(high, i, 1);
|
||||
}
|
||||
/\(\):/ {
|
||||
pr = substr($2, 1, 2);
|
||||
if (pr == "vi" || pr == "em" || pr == "ed") {
|
||||
name = substr($2, 1, length($2) - 3);
|
||||
uname = "";
|
||||
fname = "";
|
||||
for (i = 1; i <= length(name); i++) {
|
||||
s = substr(name, i, 1);
|
||||
uname = uname tr[s];
|
||||
if (s == "_")
|
||||
s = "-";
|
||||
fname = fname s;
|
||||
}
|
||||
|
||||
printf(" { %-30.30s %-30.30s\n","\"" fname "\",", uname ",");
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
/^ \*/ {
|
||||
if (ok) {
|
||||
printf(" \"");
|
||||
for (i = 2; i < NF; i++)
|
||||
printf("%s ", $i);
|
||||
printf("%s\" },\n", $i);
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf("};\n");
|
||||
printf("\nprotected const el_bindings_t* help__get()");
|
||||
printf("{ return el_func_help; }\n");
|
||||
}'
|
||||
;;
|
||||
|
||||
# generate help.h from various .c files
|
||||
#
|
||||
-bh)
|
||||
$AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#ifndef _h_help_c\n#define _h_help_c\n");
|
||||
printf("protected const el_bindings_t *help__get(void);\n");
|
||||
printf("#endif /* _h_help_c */\n");
|
||||
}' /dev/null
|
||||
;;
|
||||
|
||||
# generate fcns.h from various .h files
|
||||
#
|
||||
-fh)
|
||||
cat $FILES | $AWK '/el_action_t/ { print $3 }' | \
|
||||
sort | tr '[:lower:]' '[:upper:]' | $AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#ifndef _h_fcns_c\n#define _h_fcns_c\n");
|
||||
count = 0;
|
||||
}
|
||||
{
|
||||
printf("#define\t%-30.30s\t%3d\n", $1, count++);
|
||||
}
|
||||
END {
|
||||
printf("#define\t%-30.30s\t%3d\n", "EL_NUM_FCNS", count);
|
||||
|
||||
printf("typedef el_action_t (*el_func_t)(EditLine *, int);");
|
||||
printf("\nprotected const el_func_t* func__get(void);\n");
|
||||
printf("#endif /* _h_fcns_c */\n");
|
||||
}'
|
||||
;;
|
||||
|
||||
# generate fcns.c from various .h files
|
||||
#
|
||||
-fc)
|
||||
cat $FILES | $AWK '/el_action_t/ { print $3 }' | sort | $AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#include \"sys.h\"\n#include \"el.h\"\n");
|
||||
printf("private const el_func_t el_func[] = {");
|
||||
maxlen = 80;
|
||||
needn = 1;
|
||||
len = 0;
|
||||
}
|
||||
{
|
||||
clen = 25 + 2;
|
||||
len += clen;
|
||||
if (len >= maxlen)
|
||||
needn = 1;
|
||||
if (needn) {
|
||||
printf("\n ");
|
||||
needn = 0;
|
||||
len = 4 + clen;
|
||||
}
|
||||
s = $1 ",";
|
||||
printf("%-26.26s ", s);
|
||||
}
|
||||
END {
|
||||
printf("\n};\n");
|
||||
printf("\nprotected const el_func_t* func__get() { return el_func; }\n");
|
||||
}'
|
||||
;;
|
||||
|
||||
# generate editline.c from various .c files
|
||||
#
|
||||
-e)
|
||||
echo "$FILES" | tr ' ' '\012' | $AWK '
|
||||
BEGIN {
|
||||
printf("/* Automatically generated file, do not edit */\n");
|
||||
printf("#define protected static\n");
|
||||
printf("#define SCCSID\n");
|
||||
}
|
||||
{
|
||||
printf("#include \"%s\"\n", $1);
|
||||
}'
|
||||
;;
|
||||
|
||||
# generate man page fragment from various .c files
|
||||
#
|
||||
-m)
|
||||
cat $FILES | $AWK '
|
||||
BEGIN {
|
||||
printf(".\\\" Section automatically generated with makelist\n");
|
||||
printf(".Bl -tag -width 4n\n");
|
||||
}
|
||||
/\(\):/ {
|
||||
pr = substr($2, 1, 2);
|
||||
if (pr == "vi" || pr == "em" || pr == "ed") {
|
||||
name = substr($2, 1, length($2) - 3);
|
||||
fname = "";
|
||||
for (i = 1; i <= length(name); i++) {
|
||||
s = substr(name, i, 1);
|
||||
if (s == "_")
|
||||
s = "-";
|
||||
fname = fname s;
|
||||
}
|
||||
|
||||
printf(".It Ic %s\n", fname);
|
||||
ok = 1;
|
||||
}
|
||||
}
|
||||
/^ \*/ {
|
||||
if (ok) {
|
||||
for (i = 2; i < NF; i++)
|
||||
printf("%s ", $i);
|
||||
printf("%s.\n", $i);
|
||||
ok = 0;
|
||||
}
|
||||
}
|
||||
END {
|
||||
printf(".El\n");
|
||||
printf(".\\\" End of section automatically generated with makelist\n");
|
||||
}'
|
||||
;;
|
||||
|
||||
*)
|
||||
echo $USAGE 1>&2
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
1422
extern/editline/src/map.c
vendored
Normal file
1422
extern/editline/src/map.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
75
extern/editline/src/map.h
vendored
Normal file
75
extern/editline/src/map.h
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
/* $NetBSD: map.h,v 1.8 2003/08/07 16:44:32 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)map.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.map.h: Editor maps
|
||||
*/
|
||||
#ifndef _h_el_map
|
||||
#define _h_el_map
|
||||
|
||||
typedef struct el_bindings_t { /* for the "bind" shell command */
|
||||
const char *name; /* function name for bind command */
|
||||
int func; /* function numeric value */
|
||||
const char *description; /* description of function */
|
||||
} el_bindings_t;
|
||||
|
||||
|
||||
typedef struct el_map_t {
|
||||
el_action_t *alt; /* The current alternate key map */
|
||||
el_action_t *key; /* The current normal key map */
|
||||
el_action_t *current; /* The keymap we are using */
|
||||
const el_action_t *emacs; /* The default emacs key map */
|
||||
const el_action_t *vic; /* The vi command mode key map */
|
||||
const el_action_t *vii; /* The vi insert mode key map */
|
||||
int type; /* Emacs or vi */
|
||||
el_bindings_t *help; /* The help for the editor functions */
|
||||
el_func_t *func; /* List of available functions */
|
||||
int nfunc; /* The number of functions/help items */
|
||||
} el_map_t;
|
||||
|
||||
#define MAP_EMACS 0
|
||||
#define MAP_VI 1
|
||||
|
||||
protected int map_bind(EditLine *, int, const char **);
|
||||
protected int map_init(EditLine *);
|
||||
protected void map_end(EditLine *);
|
||||
protected void map_init_vi(EditLine *);
|
||||
protected void map_init_emacs(EditLine *);
|
||||
protected int map_set_editor(EditLine *, char *);
|
||||
protected int map_get_editor(EditLine *, const char **);
|
||||
protected int map_addfunc(EditLine *, const char *, const char *, el_func_t);
|
||||
|
||||
#endif /* _h_el_map */
|
263
extern/editline/src/parse.c
vendored
Normal file
263
extern/editline/src/parse.c
vendored
Normal file
@ -0,0 +1,263 @@
|
||||
/* $NetBSD: parse.c,v 1.22 2005/05/29 04:58:15 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: parse.c,v 1.22 2005/05/29 04:58:15 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* parse.c: parse an editline extended command
|
||||
*
|
||||
* commands are:
|
||||
*
|
||||
* bind
|
||||
* echotc
|
||||
* edit
|
||||
* gettc
|
||||
* history
|
||||
* settc
|
||||
* setty
|
||||
*/
|
||||
#include "el.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
private const struct {
|
||||
const char *name;
|
||||
int (*func)(EditLine *, int, const char **);
|
||||
} cmds[] = {
|
||||
{ "bind", map_bind },
|
||||
{ "echotc", term_echotc },
|
||||
{ "edit", el_editmode },
|
||||
{ "history", hist_command },
|
||||
{ "telltc", term_telltc },
|
||||
{ "settc", term_settc },
|
||||
{ "setty", tty_stty },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
/* parse_line():
|
||||
* Parse a line and dispatch it
|
||||
*/
|
||||
protected int
|
||||
parse_line(EditLine *el, const char *line)
|
||||
{
|
||||
const char **argv;
|
||||
int argc;
|
||||
Tokenizer *tok;
|
||||
|
||||
tok = tok_init(NULL);
|
||||
tok_str(tok, line, &argc, &argv);
|
||||
argc = el_parse(el, argc, argv);
|
||||
tok_end(tok);
|
||||
return (argc);
|
||||
}
|
||||
|
||||
|
||||
/* el_parse():
|
||||
* Command dispatcher
|
||||
*/
|
||||
public int
|
||||
el_parse(EditLine *el, int argc, const char *argv[])
|
||||
{
|
||||
const char *ptr;
|
||||
int i;
|
||||
|
||||
if (argc < 1)
|
||||
return (-1);
|
||||
ptr = strchr(argv[0], ':');
|
||||
if (ptr != NULL) {
|
||||
char *tprog;
|
||||
size_t l;
|
||||
|
||||
if (ptr == argv[0])
|
||||
return (0);
|
||||
l = ptr - argv[0] - 1;
|
||||
tprog = (char *) el_malloc(l + 1);
|
||||
if (tprog == NULL)
|
||||
return (0);
|
||||
(void) strncpy(tprog, argv[0], l);
|
||||
tprog[l] = '\0';
|
||||
ptr++;
|
||||
l = el_match(el->el_prog, tprog);
|
||||
el_free(tprog);
|
||||
if (!l)
|
||||
return (0);
|
||||
} else
|
||||
ptr = argv[0];
|
||||
|
||||
for (i = 0; cmds[i].name != NULL; i++)
|
||||
if (strcmp(cmds[i].name, ptr) == 0) {
|
||||
i = (*cmds[i].func) (el, argc, argv);
|
||||
return (-i);
|
||||
}
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
||||
/* parse__escape():
|
||||
* Parse a string of the form ^<char> \<odigit> \<char> and return
|
||||
* the appropriate character or -1 if the escape is not valid
|
||||
*/
|
||||
protected int
|
||||
parse__escape(const char **ptr)
|
||||
{
|
||||
const char *p;
|
||||
int c;
|
||||
|
||||
p = *ptr;
|
||||
|
||||
if (p[1] == 0)
|
||||
return (-1);
|
||||
|
||||
if (*p == '\\') {
|
||||
p++;
|
||||
switch (*p) {
|
||||
case 'a':
|
||||
c = '\007'; /* Bell */
|
||||
break;
|
||||
case 'b':
|
||||
c = '\010'; /* Backspace */
|
||||
break;
|
||||
case 't':
|
||||
c = '\011'; /* Horizontal Tab */
|
||||
break;
|
||||
case 'n':
|
||||
c = '\012'; /* New Line */
|
||||
break;
|
||||
case 'v':
|
||||
c = '\013'; /* Vertical Tab */
|
||||
break;
|
||||
case 'f':
|
||||
c = '\014'; /* Form Feed */
|
||||
break;
|
||||
case 'r':
|
||||
c = '\015'; /* Carriage Return */
|
||||
break;
|
||||
case 'e':
|
||||
c = '\033'; /* Escape */
|
||||
break;
|
||||
case '0':
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
{
|
||||
int cnt, ch;
|
||||
|
||||
for (cnt = 0, c = 0; cnt < 3; cnt++) {
|
||||
ch = *p++;
|
||||
if (ch < '0' || ch > '7') {
|
||||
p--;
|
||||
break;
|
||||
}
|
||||
c = (c << 3) | (ch - '0');
|
||||
}
|
||||
if ((c & 0xffffff00) != 0)
|
||||
return (-1);
|
||||
--p;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
c = *p;
|
||||
break;
|
||||
}
|
||||
} else if (*p == '^') {
|
||||
p++;
|
||||
c = (*p == '?') ? '\177' : (*p & 0237);
|
||||
} else
|
||||
c = *p;
|
||||
*ptr = ++p;
|
||||
return (c);
|
||||
}
|
||||
|
||||
/* parse__string():
|
||||
* Parse the escapes from in and put the raw string out
|
||||
*/
|
||||
protected char *
|
||||
parse__string(char *out, const char *in)
|
||||
{
|
||||
char *rv = out;
|
||||
int n;
|
||||
|
||||
for (;;)
|
||||
switch (*in) {
|
||||
case '\0':
|
||||
*out = '\0';
|
||||
return (rv);
|
||||
|
||||
case '\\':
|
||||
case '^':
|
||||
if ((n = parse__escape(&in)) == -1)
|
||||
return (NULL);
|
||||
*out++ = n;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
if (in[1] == '-' && in[2] != '\0') {
|
||||
*out++ = '\033';
|
||||
in += 2;
|
||||
break;
|
||||
}
|
||||
/*FALLTHROUGH*/
|
||||
|
||||
default:
|
||||
*out++ = *in++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* parse_cmd():
|
||||
* Return the command number for the command string given
|
||||
* or -1 if one is not found
|
||||
*/
|
||||
protected int
|
||||
parse_cmd(EditLine *el, const char *cmd)
|
||||
{
|
||||
el_bindings_t *b;
|
||||
|
||||
for (b = el->el_map.help; b->name != NULL; b++)
|
||||
if (strcmp(b->name, cmd) == 0)
|
||||
return (b->func);
|
||||
return (-1);
|
||||
}
|
48
extern/editline/src/parse.h
vendored
Normal file
48
extern/editline/src/parse.h
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/* $NetBSD: parse.h,v 1.6 2005/05/29 04:58:15 lukem Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)parse.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.parse.h: Parser functions
|
||||
*/
|
||||
#ifndef _h_el_parse
|
||||
#define _h_el_parse
|
||||
|
||||
protected int parse_line(EditLine *, const char *);
|
||||
protected int parse__escape(const char **);
|
||||
protected char *parse__string(char *, const char *);
|
||||
protected int parse_cmd(EditLine *, const char *);
|
||||
|
||||
#endif /* _h_el_parse */
|
170
extern/editline/src/prompt.c
vendored
Normal file
170
extern/editline/src/prompt.c
vendored
Normal file
@ -0,0 +1,170 @@
|
||||
/* $NetBSD: prompt.c,v 1.11 2003/08/07 16:44:32 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)prompt.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: prompt.c,v 1.11 2003/08/07 16:44:32 agc Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* prompt.c: Prompt printing functions
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include "el.h"
|
||||
|
||||
private char *prompt_default(EditLine *);
|
||||
private char *prompt_default_r(EditLine *);
|
||||
|
||||
/* prompt_default():
|
||||
* Just a default prompt, in case the user did not provide one
|
||||
*/
|
||||
private char *
|
||||
/*ARGSUSED*/
|
||||
prompt_default(EditLine *el __attribute__((__unused__)))
|
||||
{
|
||||
static char a[3] = {'?', ' ', '\0'};
|
||||
|
||||
return (a);
|
||||
}
|
||||
|
||||
|
||||
/* prompt_default_r():
|
||||
* Just a default rprompt, in case the user did not provide one
|
||||
*/
|
||||
private char *
|
||||
/*ARGSUSED*/
|
||||
prompt_default_r(EditLine *el __attribute__((__unused__)))
|
||||
{
|
||||
static char a[1] = {'\0'};
|
||||
|
||||
return (a);
|
||||
}
|
||||
|
||||
|
||||
/* prompt_print():
|
||||
* Print the prompt and update the prompt position.
|
||||
* We use an array of integers in case we want to pass
|
||||
* literal escape sequences in the prompt and we want a
|
||||
* bit to flag them
|
||||
*/
|
||||
protected void
|
||||
prompt_print(EditLine *el, int op)
|
||||
{
|
||||
el_prompt_t *elp;
|
||||
char *p;
|
||||
|
||||
if (op == EL_PROMPT)
|
||||
elp = &el->el_prompt;
|
||||
else
|
||||
elp = &el->el_rprompt;
|
||||
p = (elp->p_func) (el);
|
||||
while (*p)
|
||||
re_putc(el, *p++, 1);
|
||||
|
||||
elp->p_pos.v = el->el_refresh.r_cursor.v;
|
||||
elp->p_pos.h = el->el_refresh.r_cursor.h;
|
||||
}
|
||||
|
||||
|
||||
/* prompt_init():
|
||||
* Initialize the prompt stuff
|
||||
*/
|
||||
protected int
|
||||
prompt_init(EditLine *el)
|
||||
{
|
||||
|
||||
el->el_prompt.p_func = prompt_default;
|
||||
el->el_prompt.p_pos.v = 0;
|
||||
el->el_prompt.p_pos.h = 0;
|
||||
el->el_rprompt.p_func = prompt_default_r;
|
||||
el->el_rprompt.p_pos.v = 0;
|
||||
el->el_rprompt.p_pos.h = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* prompt_end():
|
||||
* Clean up the prompt stuff
|
||||
*/
|
||||
protected void
|
||||
/*ARGSUSED*/
|
||||
prompt_end(EditLine *el __attribute__((__unused__)))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/* prompt_set():
|
||||
* Install a prompt printing function
|
||||
*/
|
||||
protected int
|
||||
prompt_set(EditLine *el, el_pfunc_t prf, int op)
|
||||
{
|
||||
el_prompt_t *p;
|
||||
|
||||
if (op == EL_PROMPT)
|
||||
p = &el->el_prompt;
|
||||
else
|
||||
p = &el->el_rprompt;
|
||||
if (prf == NULL) {
|
||||
if (op == EL_PROMPT)
|
||||
p->p_func = prompt_default;
|
||||
else
|
||||
p->p_func = prompt_default_r;
|
||||
} else
|
||||
p->p_func = prf;
|
||||
p->p_pos.v = 0;
|
||||
p->p_pos.h = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* prompt_get():
|
||||
* Retrieve the prompt printing function
|
||||
*/
|
||||
protected int
|
||||
prompt_get(EditLine *el, el_pfunc_t *prf, int op)
|
||||
{
|
||||
|
||||
if (prf == NULL)
|
||||
return (-1);
|
||||
if (op == EL_PROMPT)
|
||||
*prf = el->el_prompt.p_func;
|
||||
else
|
||||
*prf = el->el_rprompt.p_func;
|
||||
return (0);
|
||||
}
|
58
extern/editline/src/prompt.h
vendored
Normal file
58
extern/editline/src/prompt.h
vendored
Normal file
@ -0,0 +1,58 @@
|
||||
/* $NetBSD: prompt.h,v 1.6 2003/08/07 16:44:32 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)prompt.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.prompt.h: Prompt printing stuff
|
||||
*/
|
||||
#ifndef _h_el_prompt
|
||||
#define _h_el_prompt
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef char * (*el_pfunc_t)(EditLine*);
|
||||
|
||||
typedef struct el_prompt_t {
|
||||
el_pfunc_t p_func; /* Function to return the prompt */
|
||||
coord_t p_pos; /* position in the line after prompt */
|
||||
} el_prompt_t;
|
||||
|
||||
protected void prompt_print(EditLine *, int);
|
||||
protected int prompt_set(EditLine *, el_pfunc_t, int);
|
||||
protected int prompt_get(EditLine *, el_pfunc_t *, int);
|
||||
protected int prompt_init(EditLine *);
|
||||
protected void prompt_end(EditLine *);
|
||||
|
||||
#endif /* _h_el_prompt */
|
628
extern/editline/src/read.c
vendored
Normal file
628
extern/editline/src/read.c
vendored
Normal file
@ -0,0 +1,628 @@
|
||||
/* $NetBSD: read.c,v 1.40 2007/03/01 21:41:45 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)read.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: read.c,v 1.40 2007/03/01 21:41:45 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* read.c: Clean this junk up! This is horrible code.
|
||||
* Terminal read functions
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include "el.h"
|
||||
|
||||
#define OKCMD -1
|
||||
|
||||
private int read__fixio(int, int);
|
||||
private int read_preread(EditLine *);
|
||||
private int read_char(EditLine *, char *);
|
||||
private int read_getcmd(EditLine *, el_action_t *, char *);
|
||||
private void read_pop(c_macro_t *);
|
||||
|
||||
/* read_init():
|
||||
* Initialize the read stuff
|
||||
*/
|
||||
protected int
|
||||
read_init(EditLine *el)
|
||||
{
|
||||
/* builtin read_char */
|
||||
el->el_read.read_char = read_char;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* el_read_setfn():
|
||||
* Set the read char function to the one provided.
|
||||
* If it is set to EL_BUILTIN_GETCFN, then reset to the builtin one.
|
||||
*/
|
||||
protected int
|
||||
el_read_setfn(EditLine *el, el_rfunc_t rc)
|
||||
{
|
||||
el->el_read.read_char = (rc == EL_BUILTIN_GETCFN) ? read_char : rc;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* el_read_getfn():
|
||||
* return the current read char function, or EL_BUILTIN_GETCFN
|
||||
* if it is the default one
|
||||
*/
|
||||
protected el_rfunc_t
|
||||
el_read_getfn(EditLine *el)
|
||||
{
|
||||
return (el->el_read.read_char == read_char) ?
|
||||
EL_BUILTIN_GETCFN : el->el_read.read_char;
|
||||
}
|
||||
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_EDIT
|
||||
private void
|
||||
read_debug(EditLine *el)
|
||||
{
|
||||
|
||||
if (el->el_line.cursor > el->el_line.lastchar)
|
||||
(void) fprintf(el->el_errfile, "cursor > lastchar\r\n");
|
||||
if (el->el_line.cursor < el->el_line.buffer)
|
||||
(void) fprintf(el->el_errfile, "cursor < buffer\r\n");
|
||||
if (el->el_line.cursor > el->el_line.limit)
|
||||
(void) fprintf(el->el_errfile, "cursor > limit\r\n");
|
||||
if (el->el_line.lastchar > el->el_line.limit)
|
||||
(void) fprintf(el->el_errfile, "lastchar > limit\r\n");
|
||||
if (el->el_line.limit != &el->el_line.buffer[EL_BUFSIZ - 2])
|
||||
(void) fprintf(el->el_errfile, "limit != &buffer[EL_BUFSIZ-2]\r\n");
|
||||
}
|
||||
#endif /* DEBUG_EDIT */
|
||||
|
||||
|
||||
/* read__fixio():
|
||||
* Try to recover from a read error
|
||||
*/
|
||||
/* ARGSUSED */
|
||||
private int
|
||||
read__fixio(int fd __attribute__((__unused__)), int e)
|
||||
{
|
||||
|
||||
switch (e) {
|
||||
case -1: /* Make sure that the code is reachable */
|
||||
|
||||
#ifdef EWOULDBLOCK
|
||||
case EWOULDBLOCK:
|
||||
#ifndef TRY_AGAIN
|
||||
#define TRY_AGAIN
|
||||
#endif
|
||||
#endif /* EWOULDBLOCK */
|
||||
|
||||
#if defined(POSIX) && defined(EAGAIN)
|
||||
#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
|
||||
case EAGAIN:
|
||||
#ifndef TRY_AGAIN
|
||||
#define TRY_AGAIN
|
||||
#endif
|
||||
#endif /* EWOULDBLOCK && EWOULDBLOCK != EAGAIN */
|
||||
#endif /* POSIX && EAGAIN */
|
||||
|
||||
e = 0;
|
||||
#ifdef TRY_AGAIN
|
||||
#if defined(F_SETFL) && defined(O_NDELAY)
|
||||
if ((e = fcntl(fd, F_GETFL, 0)) == -1)
|
||||
return (-1);
|
||||
|
||||
if (fcntl(fd, F_SETFL, e & ~O_NDELAY) == -1)
|
||||
return (-1);
|
||||
else
|
||||
e = 1;
|
||||
#endif /* F_SETFL && O_NDELAY */
|
||||
|
||||
#ifdef FIONBIO
|
||||
{
|
||||
int zero = 0;
|
||||
|
||||
if (ioctl(fd, FIONBIO, (ioctl_t) & zero) == -1)
|
||||
return (-1);
|
||||
else
|
||||
e = 1;
|
||||
}
|
||||
#endif /* FIONBIO */
|
||||
|
||||
#endif /* TRY_AGAIN */
|
||||
return (e ? 0 : -1);
|
||||
|
||||
case EINTR:
|
||||
return (0);
|
||||
|
||||
default:
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* read_preread():
|
||||
* Try to read the stuff in the input queue;
|
||||
*/
|
||||
private int
|
||||
read_preread(EditLine *el)
|
||||
{
|
||||
int chrs = 0;
|
||||
|
||||
if (el->el_tty.t_mode == ED_IO)
|
||||
return (0);
|
||||
|
||||
#ifdef FIONREAD
|
||||
(void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
|
||||
if (chrs > 0) {
|
||||
char buf[EL_BUFSIZ];
|
||||
|
||||
chrs = read(el->el_infd, buf,
|
||||
(size_t) MIN(chrs, EL_BUFSIZ - 1));
|
||||
if (chrs > 0) {
|
||||
buf[chrs] = '\0';
|
||||
el_push(el, buf);
|
||||
}
|
||||
}
|
||||
#endif /* FIONREAD */
|
||||
|
||||
return (chrs > 0);
|
||||
}
|
||||
|
||||
|
||||
/* el_push():
|
||||
* Push a macro
|
||||
*/
|
||||
public void
|
||||
el_push(EditLine *el, char *str)
|
||||
{
|
||||
c_macro_t *ma = &el->el_chared.c_macro;
|
||||
|
||||
if (str != NULL && ma->level + 1 < EL_MAXMACRO) {
|
||||
ma->level++;
|
||||
if ((ma->macro[ma->level] = el_strdup(str)) != NULL)
|
||||
return;
|
||||
ma->level--;
|
||||
}
|
||||
term_beep(el);
|
||||
term__flush();
|
||||
}
|
||||
|
||||
|
||||
/* read_getcmd():
|
||||
* Return next command from the input stream.
|
||||
*/
|
||||
private int
|
||||
read_getcmd(EditLine *el, el_action_t *cmdnum, char *ch)
|
||||
{
|
||||
el_action_t cmd;
|
||||
int num;
|
||||
|
||||
do {
|
||||
if ((num = el_getc(el, ch)) != 1) /* if EOF or error */
|
||||
return (num);
|
||||
|
||||
#ifdef KANJI
|
||||
if ((*ch & 0200)) {
|
||||
el->el_state.metanext = 0;
|
||||
cmd = CcViMap[' '];
|
||||
break;
|
||||
} else
|
||||
#endif /* KANJI */
|
||||
|
||||
if (el->el_state.metanext) {
|
||||
el->el_state.metanext = 0;
|
||||
*ch |= 0200;
|
||||
}
|
||||
cmd = el->el_map.current[(unsigned char) *ch];
|
||||
if (cmd == ED_SEQUENCE_LEAD_IN) {
|
||||
key_value_t val;
|
||||
switch (key_get(el, ch, &val)) {
|
||||
case XK_CMD:
|
||||
cmd = val.cmd;
|
||||
break;
|
||||
case XK_STR:
|
||||
el_push(el, val.str);
|
||||
break;
|
||||
#ifdef notyet
|
||||
case XK_EXE:
|
||||
/* XXX: In the future to run a user function */
|
||||
RunCommand(val.str);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
EL_ABORT((el->el_errfile, "Bad XK_ type \n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (el->el_map.alt == NULL)
|
||||
el->el_map.current = el->el_map.key;
|
||||
} while (cmd == ED_SEQUENCE_LEAD_IN);
|
||||
*cmdnum = cmd;
|
||||
return (OKCMD);
|
||||
}
|
||||
|
||||
|
||||
/* read_char():
|
||||
* Read a character from the tty.
|
||||
*/
|
||||
private int
|
||||
read_char(EditLine *el, char *cp)
|
||||
{
|
||||
int num_read;
|
||||
int tried = 0;
|
||||
|
||||
while ((num_read = read(el->el_infd, cp, 1)) == -1)
|
||||
if (!tried && read__fixio(el->el_infd, errno) == 0)
|
||||
tried = 1;
|
||||
else {
|
||||
*cp = '\0';
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return (num_read);
|
||||
}
|
||||
|
||||
/* read_pop():
|
||||
* Pop a macro from the stack
|
||||
*/
|
||||
private void
|
||||
read_pop(c_macro_t *ma)
|
||||
{
|
||||
int i;
|
||||
|
||||
el_free(ma->macro[0]);
|
||||
for (i = ma->level--; i > 0; i--)
|
||||
ma->macro[i - 1] = ma->macro[i];
|
||||
ma->offset = 0;
|
||||
}
|
||||
|
||||
/* el_getc():
|
||||
* Read a character
|
||||
*/
|
||||
public int
|
||||
el_getc(EditLine *el, char *cp)
|
||||
{
|
||||
int num_read;
|
||||
c_macro_t *ma = &el->el_chared.c_macro;
|
||||
|
||||
term__flush();
|
||||
for (;;) {
|
||||
if (ma->level < 0) {
|
||||
if (!read_preread(el))
|
||||
break;
|
||||
}
|
||||
|
||||
if (ma->level < 0)
|
||||
break;
|
||||
|
||||
if (ma->macro[0][ma->offset] == '\0') {
|
||||
read_pop(ma);
|
||||
continue;
|
||||
}
|
||||
|
||||
*cp = ma->macro[0][ma->offset++] & 0377;
|
||||
|
||||
if (ma->macro[0][ma->offset] == '\0') {
|
||||
/* Needed for QuoteMode On */
|
||||
read_pop(ma);
|
||||
}
|
||||
|
||||
return (1);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile, "Turning raw mode on\n");
|
||||
#endif /* DEBUG_READ */
|
||||
if (tty_rawmode(el) < 0)/* make sure the tty is set up correctly */
|
||||
return (0);
|
||||
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile, "Reading a character\n");
|
||||
#endif /* DEBUG_READ */
|
||||
num_read = (*el->el_read.read_char)(el, cp);
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile, "Got it %c\n", *cp);
|
||||
#endif /* DEBUG_READ */
|
||||
return (num_read);
|
||||
}
|
||||
|
||||
protected void
|
||||
read_prepare(EditLine *el)
|
||||
{
|
||||
if (el->el_flags & HANDLE_SIGNALS)
|
||||
sig_set(el);
|
||||
if (el->el_flags & NO_TTY)
|
||||
return;
|
||||
if ((el->el_flags & (UNBUFFERED|EDIT_DISABLED)) == UNBUFFERED)
|
||||
tty_rawmode(el);
|
||||
|
||||
/* This is relatively cheap, and things go terribly wrong if
|
||||
we have the wrong size. */
|
||||
el_resize(el);
|
||||
re_clear_display(el); /* reset the display stuff */
|
||||
ch_reset(el, 0);
|
||||
re_refresh(el); /* print the prompt */
|
||||
|
||||
if (el->el_flags & UNBUFFERED)
|
||||
term__flush();
|
||||
}
|
||||
|
||||
protected void
|
||||
read_finish(EditLine *el)
|
||||
{
|
||||
if ((el->el_flags & UNBUFFERED) == 0)
|
||||
(void) tty_cookedmode(el);
|
||||
if (el->el_flags & HANDLE_SIGNALS)
|
||||
sig_clr(el);
|
||||
}
|
||||
|
||||
public const char *
|
||||
el_gets(EditLine *el, int *nread)
|
||||
{
|
||||
int retval;
|
||||
el_action_t cmdnum = 0;
|
||||
int num; /* how many chars we have read at NL */
|
||||
char ch;
|
||||
int crlf = 0;
|
||||
#ifdef FIONREAD
|
||||
c_macro_t *ma = &el->el_chared.c_macro;
|
||||
#endif /* FIONREAD */
|
||||
|
||||
if (el->el_flags & NO_TTY) {
|
||||
char *cp = el->el_line.buffer;
|
||||
size_t idx;
|
||||
|
||||
while ((*el->el_read.read_char)(el, cp) == 1) {
|
||||
/* make sure there is space for next character */
|
||||
if (cp + 1 >= el->el_line.limit) {
|
||||
idx = (cp - el->el_line.buffer);
|
||||
if (!ch_enlargebufs(el, 2))
|
||||
break;
|
||||
cp = &el->el_line.buffer[idx];
|
||||
}
|
||||
cp++;
|
||||
if (el->el_flags & UNBUFFERED)
|
||||
break;
|
||||
if (cp[-1] == '\r' || cp[-1] == '\n')
|
||||
break;
|
||||
}
|
||||
|
||||
el->el_line.cursor = el->el_line.lastchar = cp;
|
||||
*cp = '\0';
|
||||
if (nread)
|
||||
*nread = el->el_line.cursor - el->el_line.buffer;
|
||||
return (el->el_line.buffer);
|
||||
}
|
||||
|
||||
|
||||
#ifdef FIONREAD
|
||||
if (el->el_tty.t_mode == EX_IO && ma->level < 0) {
|
||||
long chrs = 0;
|
||||
|
||||
(void) ioctl(el->el_infd, FIONREAD, (ioctl_t) & chrs);
|
||||
if (chrs == 0) {
|
||||
if (tty_rawmode(el) < 0) {
|
||||
if (nread)
|
||||
*nread = 0;
|
||||
return (NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* FIONREAD */
|
||||
|
||||
if ((el->el_flags & UNBUFFERED) == 0)
|
||||
read_prepare(el);
|
||||
|
||||
if (el->el_flags & EDIT_DISABLED) {
|
||||
char *cp;
|
||||
size_t idx;
|
||||
if ((el->el_flags & UNBUFFERED) == 0)
|
||||
cp = el->el_line.buffer;
|
||||
else
|
||||
cp = el->el_line.lastchar;
|
||||
|
||||
term__flush();
|
||||
|
||||
while ((*el->el_read.read_char)(el, cp) == 1) {
|
||||
/* make sure there is space next character */
|
||||
if (cp + 1 >= el->el_line.limit) {
|
||||
idx = (cp - el->el_line.buffer);
|
||||
if (!ch_enlargebufs(el, 2))
|
||||
break;
|
||||
cp = &el->el_line.buffer[idx];
|
||||
}
|
||||
if (*cp == 4) /* ought to be stty eof */
|
||||
break;
|
||||
cp++;
|
||||
crlf = cp[-1] == '\r' || cp[-1] == '\n';
|
||||
if (el->el_flags & UNBUFFERED)
|
||||
break;
|
||||
if (crlf)
|
||||
break;
|
||||
}
|
||||
|
||||
el->el_line.cursor = el->el_line.lastchar = cp;
|
||||
*cp = '\0';
|
||||
if (nread)
|
||||
*nread = el->el_line.cursor - el->el_line.buffer;
|
||||
return (el->el_line.buffer);
|
||||
}
|
||||
|
||||
for (num = OKCMD; num == OKCMD;) { /* while still editing this
|
||||
* line */
|
||||
#ifdef DEBUG_EDIT
|
||||
read_debug(el);
|
||||
#endif /* DEBUG_EDIT */
|
||||
/* if EOF or error */
|
||||
if ((num = read_getcmd(el, &cmdnum, &ch)) != OKCMD) {
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile,
|
||||
"Returning from el_gets %d\n", num);
|
||||
#endif /* DEBUG_READ */
|
||||
break;
|
||||
}
|
||||
if ((unsigned int)cmdnum >= el->el_map.nfunc) { /* BUG CHECK command */
|
||||
#ifdef DEBUG_EDIT
|
||||
(void) fprintf(el->el_errfile,
|
||||
"ERROR: illegal command from key 0%o\r\n", ch);
|
||||
#endif /* DEBUG_EDIT */
|
||||
continue; /* try again */
|
||||
}
|
||||
/* now do the real command */
|
||||
#ifdef DEBUG_READ
|
||||
{
|
||||
el_bindings_t *b;
|
||||
for (b = el->el_map.help; b->name; b++)
|
||||
if (b->func == cmdnum)
|
||||
break;
|
||||
if (b->name)
|
||||
(void) fprintf(el->el_errfile,
|
||||
"Executing %s\n", b->name);
|
||||
else
|
||||
(void) fprintf(el->el_errfile,
|
||||
"Error command = %d\n", cmdnum);
|
||||
}
|
||||
#endif /* DEBUG_READ */
|
||||
/* vi redo needs these way down the levels... */
|
||||
el->el_state.thiscmd = cmdnum;
|
||||
el->el_state.thisch = ch;
|
||||
if (el->el_map.type == MAP_VI &&
|
||||
el->el_map.current == el->el_map.key &&
|
||||
el->el_chared.c_redo.pos < el->el_chared.c_redo.lim) {
|
||||
if (cmdnum == VI_DELETE_PREV_CHAR &&
|
||||
el->el_chared.c_redo.pos != el->el_chared.c_redo.buf
|
||||
&& isprint((unsigned char)el->el_chared.c_redo.pos[-1]))
|
||||
el->el_chared.c_redo.pos--;
|
||||
else
|
||||
*el->el_chared.c_redo.pos++ = ch;
|
||||
}
|
||||
retval = (*el->el_map.func[cmdnum]) (el, ch);
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile,
|
||||
"Returned state %d\n", retval );
|
||||
#endif /* DEBUG_READ */
|
||||
|
||||
/* save the last command here */
|
||||
el->el_state.lastcmd = cmdnum;
|
||||
|
||||
/* use any return value */
|
||||
switch (retval) {
|
||||
case CC_CURSOR:
|
||||
re_refresh_cursor(el);
|
||||
break;
|
||||
|
||||
case CC_REDISPLAY:
|
||||
re_clear_lines(el);
|
||||
re_clear_display(el);
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case CC_REFRESH:
|
||||
re_refresh(el);
|
||||
break;
|
||||
|
||||
case CC_REFRESH_BEEP:
|
||||
re_refresh(el);
|
||||
term_beep(el);
|
||||
break;
|
||||
|
||||
case CC_NORM: /* normal char */
|
||||
break;
|
||||
|
||||
case CC_ARGHACK: /* Suggested by Rich Salz */
|
||||
/* <rsalz@pineapple.bbn.com> */
|
||||
continue; /* keep going... */
|
||||
|
||||
case CC_EOF: /* end of file typed */
|
||||
if ((el->el_flags & UNBUFFERED) == 0)
|
||||
num = 0;
|
||||
else if (num == -1) {
|
||||
*el->el_line.lastchar++ = CONTROL('d');
|
||||
el->el_line.cursor = el->el_line.lastchar;
|
||||
num = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case CC_NEWLINE: /* normal end of line */
|
||||
num = el->el_line.lastchar - el->el_line.buffer;
|
||||
break;
|
||||
|
||||
case CC_FATAL: /* fatal error, reset to known state */
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile,
|
||||
"*** editor fatal ERROR ***\r\n\n");
|
||||
#endif /* DEBUG_READ */
|
||||
/* put (real) cursor in a known place */
|
||||
re_clear_display(el); /* reset the display stuff */
|
||||
ch_reset(el, 1); /* reset the input pointers */
|
||||
re_refresh(el); /* print the prompt again */
|
||||
break;
|
||||
|
||||
case CC_ERROR:
|
||||
default: /* functions we don't know about */
|
||||
#ifdef DEBUG_READ
|
||||
(void) fprintf(el->el_errfile,
|
||||
"*** editor ERROR ***\r\n\n");
|
||||
#endif /* DEBUG_READ */
|
||||
term_beep(el);
|
||||
term__flush();
|
||||
break;
|
||||
}
|
||||
el->el_state.argument = 1;
|
||||
el->el_state.doingarg = 0;
|
||||
el->el_chared.c_vcmd.action = NOP;
|
||||
if (el->el_flags & UNBUFFERED)
|
||||
break;
|
||||
}
|
||||
|
||||
term__flush(); /* flush any buffered output */
|
||||
/* make sure the tty is set up correctly */
|
||||
if ((el->el_flags & UNBUFFERED) == 0) {
|
||||
read_finish(el);
|
||||
if (nread)
|
||||
*nread = num;
|
||||
} else {
|
||||
if (nread)
|
||||
*nread = el->el_line.lastchar - el->el_line.buffer;
|
||||
}
|
||||
return (num ? el->el_line.buffer : NULL);
|
||||
}
|
53
extern/editline/src/read.h
vendored
Normal file
53
extern/editline/src/read.h
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/* $NetBSD: read.h,v 1.5 2006/08/21 12:45:30 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2001 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Anthony Mallet.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.read.h: Character reading functions
|
||||
*/
|
||||
#ifndef _h_el_read
|
||||
#define _h_el_read
|
||||
|
||||
typedef int (*el_rfunc_t)(EditLine *, char *);
|
||||
|
||||
typedef struct el_read_t {
|
||||
el_rfunc_t read_char; /* Function to read a character */
|
||||
} el_read_t;
|
||||
|
||||
protected int read_init(EditLine *);
|
||||
protected void read_prepare(EditLine *);
|
||||
protected void read_finish(EditLine *);
|
||||
protected int el_read_setfn(EditLine *, el_rfunc_t);
|
||||
protected el_rfunc_t el_read_getfn(EditLine *);
|
||||
|
||||
#endif /* _h_el_read */
|
1907
extern/editline/src/readline.c
vendored
Normal file
1907
extern/editline/src/readline.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
1139
extern/editline/src/refresh.c
vendored
Normal file
1139
extern/editline/src/refresh.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
59
extern/editline/src/refresh.h
vendored
Normal file
59
extern/editline/src/refresh.h
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
/* $NetBSD: refresh.h,v 1.5 2003/08/07 16:44:33 agc Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)refresh.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.refresh.h: Screen refresh functions
|
||||
*/
|
||||
#ifndef _h_el_refresh
|
||||
#define _h_el_refresh
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef struct {
|
||||
coord_t r_cursor; /* Refresh cursor position */
|
||||
int r_oldcv; /* Vertical locations */
|
||||
int r_newcv;
|
||||
} el_refresh_t;
|
||||
|
||||
protected void re_putc(EditLine *, int, int);
|
||||
protected void re_clear_lines(EditLine *);
|
||||
protected void re_clear_display(EditLine *);
|
||||
protected void re_refresh(EditLine *);
|
||||
protected void re_refresh_cursor(EditLine *);
|
||||
protected void re_fastaddc(EditLine *);
|
||||
protected void re_goto_bottom(EditLine *);
|
||||
|
||||
#endif /* _h_el_refresh */
|
634
extern/editline/src/search.c
vendored
Normal file
634
extern/editline/src/search.c
vendored
Normal file
@ -0,0 +1,634 @@
|
||||
/* $NetBSD: search.c,v 1.20 2004/11/04 01:16:03 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#if !defined(lint) && !defined(SCCSID)
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)search.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: search.c,v 1.20 2004/11/04 01:16:03 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
/*
|
||||
* search.c: History and character search functions
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
||||
#if defined(REGEX)
|
||||
#include <regex.h>
|
||||
#elif defined(REGEXP)
|
||||
#include <regexp.h>
|
||||
#endif
|
||||
#include "el.h"
|
||||
|
||||
/*
|
||||
* Adjust cursor in vi mode to include the character under it
|
||||
*/
|
||||
#define EL_CURSOR(el) \
|
||||
((el)->el_line.cursor + (((el)->el_map.type == MAP_VI) && \
|
||||
((el)->el_map.current == (el)->el_map.alt)))
|
||||
|
||||
/* search_init():
|
||||
* Initialize the search stuff
|
||||
*/
|
||||
protected int
|
||||
search_init(EditLine *el)
|
||||
{
|
||||
|
||||
el->el_search.patbuf = (char *) el_malloc(EL_BUFSIZ);
|
||||
if (el->el_search.patbuf == NULL)
|
||||
return (-1);
|
||||
el->el_search.patlen = 0;
|
||||
el->el_search.patdir = -1;
|
||||
el->el_search.chacha = '\0';
|
||||
el->el_search.chadir = CHAR_FWD;
|
||||
el->el_search.chatflg = 0;
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
||||
/* search_end():
|
||||
* Initialize the search stuff
|
||||
*/
|
||||
protected void
|
||||
search_end(EditLine *el)
|
||||
{
|
||||
|
||||
el_free((ptr_t) el->el_search.patbuf);
|
||||
el->el_search.patbuf = NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef REGEXP
|
||||
/* regerror():
|
||||
* Handle regular expression errors
|
||||
*/
|
||||
public void
|
||||
/*ARGSUSED*/
|
||||
regerror(const char *msg)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* el_match():
|
||||
* Return if string matches pattern
|
||||
*/
|
||||
protected int
|
||||
el_match(const char *str, const char *pat)
|
||||
{
|
||||
#if defined (REGEX)
|
||||
regex_t re;
|
||||
int rv;
|
||||
#elif defined (REGEXP)
|
||||
regexp *rp;
|
||||
int rv;
|
||||
#else
|
||||
extern char *re_comp(const char *);
|
||||
extern int re_exec(const char *);
|
||||
#endif
|
||||
|
||||
if (strstr(str, pat) != NULL)
|
||||
return (1);
|
||||
|
||||
#if defined(REGEX)
|
||||
if (regcomp(&re, pat, 0) == 0) {
|
||||
rv = regexec(&re, str, 0, NULL, 0) == 0;
|
||||
regfree(&re);
|
||||
} else {
|
||||
rv = 0;
|
||||
}
|
||||
return (rv);
|
||||
#elif defined(REGEXP)
|
||||
if ((re = regcomp(pat)) != NULL) {
|
||||
rv = regexec(re, str);
|
||||
free((ptr_t) re);
|
||||
} else {
|
||||
rv = 0;
|
||||
}
|
||||
return (rv);
|
||||
#else
|
||||
if (re_comp(pat) != NULL)
|
||||
return (0);
|
||||
else
|
||||
return (re_exec(str) == 1);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* c_hmatch():
|
||||
* return True if the pattern matches the prefix
|
||||
*/
|
||||
protected int
|
||||
c_hmatch(EditLine *el, const char *str)
|
||||
{
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "match `%s' with `%s'\n",
|
||||
el->el_search.patbuf, str);
|
||||
#endif /* SDEBUG */
|
||||
|
||||
return (el_match(str, el->el_search.patbuf));
|
||||
}
|
||||
|
||||
|
||||
/* c_setpat():
|
||||
* Set the history seatch pattern
|
||||
*/
|
||||
protected void
|
||||
c_setpat(EditLine *el)
|
||||
{
|
||||
if (el->el_state.lastcmd != ED_SEARCH_PREV_HISTORY &&
|
||||
el->el_state.lastcmd != ED_SEARCH_NEXT_HISTORY) {
|
||||
el->el_search.patlen = EL_CURSOR(el) - el->el_line.buffer;
|
||||
if (el->el_search.patlen >= EL_BUFSIZ)
|
||||
el->el_search.patlen = EL_BUFSIZ - 1;
|
||||
if (el->el_search.patlen != 0) {
|
||||
(void) strncpy(el->el_search.patbuf, el->el_line.buffer,
|
||||
el->el_search.patlen);
|
||||
el->el_search.patbuf[el->el_search.patlen] = '\0';
|
||||
} else
|
||||
el->el_search.patlen = strlen(el->el_search.patbuf);
|
||||
}
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "\neventno = %d\n",
|
||||
el->el_history.eventno);
|
||||
(void) fprintf(el->el_errfile, "patlen = %d\n", el->el_search.patlen);
|
||||
(void) fprintf(el->el_errfile, "patbuf = \"%s\"\n",
|
||||
el->el_search.patbuf);
|
||||
(void) fprintf(el->el_errfile, "cursor %d lastchar %d\n",
|
||||
EL_CURSOR(el) - el->el_line.buffer,
|
||||
el->el_line.lastchar - el->el_line.buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/* ce_inc_search():
|
||||
* Emacs incremental search
|
||||
*/
|
||||
protected el_action_t
|
||||
ce_inc_search(EditLine *el, int dir)
|
||||
{
|
||||
static const char STRfwd[] = {'f', 'w', 'd', '\0'},
|
||||
STRbck[] = {'b', 'c', 'k', '\0'};
|
||||
static char pchar = ':';/* ':' = normal, '?' = failed */
|
||||
static char endcmd[2] = {'\0', '\0'};
|
||||
char ch, *ocursor = el->el_line.cursor, oldpchar = pchar;
|
||||
const char *cp;
|
||||
|
||||
el_action_t ret = CC_NORM;
|
||||
|
||||
int ohisteventno = el->el_history.eventno;
|
||||
int oldpatlen = el->el_search.patlen;
|
||||
int newdir = dir;
|
||||
int done, redo;
|
||||
|
||||
if (el->el_line.lastchar + sizeof(STRfwd) / sizeof(char) + 2 +
|
||||
el->el_search.patlen >= el->el_line.limit)
|
||||
return (CC_ERROR);
|
||||
|
||||
for (;;) {
|
||||
|
||||
if (el->el_search.patlen == 0) { /* first round */
|
||||
pchar = ':';
|
||||
#ifdef ANCHOR
|
||||
#define LEN 2
|
||||
el->el_search.patbuf[el->el_search.patlen++] = '.';
|
||||
el->el_search.patbuf[el->el_search.patlen++] = '*';
|
||||
#else
|
||||
#define LEN 0
|
||||
#endif
|
||||
}
|
||||
done = redo = 0;
|
||||
*el->el_line.lastchar++ = '\n';
|
||||
for (cp = (newdir == ED_SEARCH_PREV_HISTORY) ? STRbck : STRfwd;
|
||||
*cp; *el->el_line.lastchar++ = *cp++)
|
||||
continue;
|
||||
*el->el_line.lastchar++ = pchar;
|
||||
for (cp = &el->el_search.patbuf[LEN];
|
||||
cp < &el->el_search.patbuf[el->el_search.patlen];
|
||||
*el->el_line.lastchar++ = *cp++)
|
||||
continue;
|
||||
*el->el_line.lastchar = '\0';
|
||||
re_refresh(el);
|
||||
|
||||
if (el_getc(el, &ch) != 1)
|
||||
return (ed_end_of_file(el, 0));
|
||||
|
||||
switch (el->el_map.current[(unsigned char) ch]) {
|
||||
case ED_INSERT:
|
||||
case ED_DIGIT:
|
||||
if (el->el_search.patlen >= EL_BUFSIZ - LEN)
|
||||
term_beep(el);
|
||||
else {
|
||||
el->el_search.patbuf[el->el_search.patlen++] =
|
||||
ch;
|
||||
*el->el_line.lastchar++ = ch;
|
||||
*el->el_line.lastchar = '\0';
|
||||
re_refresh(el);
|
||||
}
|
||||
break;
|
||||
|
||||
case EM_INC_SEARCH_NEXT:
|
||||
newdir = ED_SEARCH_NEXT_HISTORY;
|
||||
redo++;
|
||||
break;
|
||||
|
||||
case EM_INC_SEARCH_PREV:
|
||||
newdir = ED_SEARCH_PREV_HISTORY;
|
||||
redo++;
|
||||
break;
|
||||
|
||||
case EM_DELETE_PREV_CHAR:
|
||||
case ED_DELETE_PREV_CHAR:
|
||||
if (el->el_search.patlen > LEN)
|
||||
done++;
|
||||
else
|
||||
term_beep(el);
|
||||
break;
|
||||
|
||||
default:
|
||||
switch (ch) {
|
||||
case 0007: /* ^G: Abort */
|
||||
ret = CC_ERROR;
|
||||
done++;
|
||||
break;
|
||||
|
||||
case 0027: /* ^W: Append word */
|
||||
/* No can do if globbing characters in pattern */
|
||||
for (cp = &el->el_search.patbuf[LEN];; cp++)
|
||||
if (cp >= &el->el_search.patbuf[
|
||||
el->el_search.patlen]) {
|
||||
el->el_line.cursor +=
|
||||
el->el_search.patlen - LEN - 1;
|
||||
cp = c__next_word(el->el_line.cursor,
|
||||
el->el_line.lastchar, 1,
|
||||
ce__isword);
|
||||
while (el->el_line.cursor < cp &&
|
||||
*el->el_line.cursor != '\n') {
|
||||
if (el->el_search.patlen >=
|
||||
EL_BUFSIZ - LEN) {
|
||||
term_beep(el);
|
||||
break;
|
||||
}
|
||||
el->el_search.patbuf[el->el_search.patlen++] =
|
||||
*el->el_line.cursor;
|
||||
*el->el_line.lastchar++ =
|
||||
*el->el_line.cursor++;
|
||||
}
|
||||
el->el_line.cursor = ocursor;
|
||||
*el->el_line.lastchar = '\0';
|
||||
re_refresh(el);
|
||||
break;
|
||||
} else if (isglob(*cp)) {
|
||||
term_beep(el);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* Terminate and execute cmd */
|
||||
endcmd[0] = ch;
|
||||
el_push(el, endcmd);
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 0033: /* ESC: Terminate */
|
||||
ret = CC_REFRESH;
|
||||
done++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
while (el->el_line.lastchar > el->el_line.buffer &&
|
||||
*el->el_line.lastchar != '\n')
|
||||
*el->el_line.lastchar-- = '\0';
|
||||
*el->el_line.lastchar = '\0';
|
||||
|
||||
if (!done) {
|
||||
|
||||
/* Can't search if unmatched '[' */
|
||||
for (cp = &el->el_search.patbuf[el->el_search.patlen-1],
|
||||
ch = ']';
|
||||
cp >= &el->el_search.patbuf[LEN];
|
||||
cp--)
|
||||
if (*cp == '[' || *cp == ']') {
|
||||
ch = *cp;
|
||||
break;
|
||||
}
|
||||
if (el->el_search.patlen > LEN && ch != '[') {
|
||||
if (redo && newdir == dir) {
|
||||
if (pchar == '?') { /* wrap around */
|
||||
el->el_history.eventno =
|
||||
newdir == ED_SEARCH_PREV_HISTORY ? 0 : 0x7fffffff;
|
||||
if (hist_get(el) == CC_ERROR)
|
||||
/* el->el_history.event
|
||||
* no was fixed by
|
||||
* first call */
|
||||
(void) hist_get(el);
|
||||
el->el_line.cursor = newdir ==
|
||||
ED_SEARCH_PREV_HISTORY ?
|
||||
el->el_line.lastchar :
|
||||
el->el_line.buffer;
|
||||
} else
|
||||
el->el_line.cursor +=
|
||||
newdir ==
|
||||
ED_SEARCH_PREV_HISTORY ?
|
||||
-1 : 1;
|
||||
}
|
||||
#ifdef ANCHOR
|
||||
el->el_search.patbuf[el->el_search.patlen++] =
|
||||
'.';
|
||||
el->el_search.patbuf[el->el_search.patlen++] =
|
||||
'*';
|
||||
#endif
|
||||
el->el_search.patbuf[el->el_search.patlen] =
|
||||
'\0';
|
||||
if (el->el_line.cursor < el->el_line.buffer ||
|
||||
el->el_line.cursor > el->el_line.lastchar ||
|
||||
(ret = ce_search_line(el, newdir))
|
||||
== CC_ERROR) {
|
||||
/* avoid c_setpat */
|
||||
el->el_state.lastcmd =
|
||||
(el_action_t) newdir;
|
||||
ret = newdir == ED_SEARCH_PREV_HISTORY ?
|
||||
ed_search_prev_history(el, 0) :
|
||||
ed_search_next_history(el, 0);
|
||||
if (ret != CC_ERROR) {
|
||||
el->el_line.cursor = newdir ==
|
||||
ED_SEARCH_PREV_HISTORY ?
|
||||
el->el_line.lastchar :
|
||||
el->el_line.buffer;
|
||||
(void) ce_search_line(el,
|
||||
newdir);
|
||||
}
|
||||
}
|
||||
el->el_search.patlen -= LEN;
|
||||
el->el_search.patbuf[el->el_search.patlen] =
|
||||
'\0';
|
||||
if (ret == CC_ERROR) {
|
||||
term_beep(el);
|
||||
if (el->el_history.eventno !=
|
||||
ohisteventno) {
|
||||
el->el_history.eventno =
|
||||
ohisteventno;
|
||||
if (hist_get(el) == CC_ERROR)
|
||||
return (CC_ERROR);
|
||||
}
|
||||
el->el_line.cursor = ocursor;
|
||||
pchar = '?';
|
||||
} else {
|
||||
pchar = ':';
|
||||
}
|
||||
}
|
||||
ret = ce_inc_search(el, newdir);
|
||||
|
||||
if (ret == CC_ERROR && pchar == '?' && oldpchar == ':')
|
||||
/*
|
||||
* break abort of failed search at last
|
||||
* non-failed
|
||||
*/
|
||||
ret = CC_NORM;
|
||||
|
||||
}
|
||||
if (ret == CC_NORM || (ret == CC_ERROR && oldpatlen == 0)) {
|
||||
/* restore on normal return or error exit */
|
||||
pchar = oldpchar;
|
||||
el->el_search.patlen = oldpatlen;
|
||||
if (el->el_history.eventno != ohisteventno) {
|
||||
el->el_history.eventno = ohisteventno;
|
||||
if (hist_get(el) == CC_ERROR)
|
||||
return (CC_ERROR);
|
||||
}
|
||||
el->el_line.cursor = ocursor;
|
||||
if (ret == CC_ERROR)
|
||||
re_refresh(el);
|
||||
}
|
||||
if (done || ret != CC_NORM)
|
||||
return (ret);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cv_search():
|
||||
* Vi search.
|
||||
*/
|
||||
protected el_action_t
|
||||
cv_search(EditLine *el, int dir)
|
||||
{
|
||||
char ch;
|
||||
char tmpbuf[EL_BUFSIZ];
|
||||
int tmplen;
|
||||
|
||||
#ifdef ANCHOR
|
||||
tmpbuf[0] = '.';
|
||||
tmpbuf[1] = '*';
|
||||
#endif
|
||||
tmplen = LEN;
|
||||
|
||||
el->el_search.patdir = dir;
|
||||
|
||||
tmplen = c_gets(el, &tmpbuf[LEN],
|
||||
dir == ED_SEARCH_PREV_HISTORY ? "\n/" : "\n?" );
|
||||
if (tmplen == -1)
|
||||
return CC_REFRESH;
|
||||
|
||||
tmplen += LEN;
|
||||
ch = tmpbuf[tmplen];
|
||||
tmpbuf[tmplen] = '\0';
|
||||
|
||||
if (tmplen == LEN) {
|
||||
/*
|
||||
* Use the old pattern, but wild-card it.
|
||||
*/
|
||||
if (el->el_search.patlen == 0) {
|
||||
re_refresh(el);
|
||||
return (CC_ERROR);
|
||||
}
|
||||
#ifdef ANCHOR
|
||||
if (el->el_search.patbuf[0] != '.' &&
|
||||
el->el_search.patbuf[0] != '*') {
|
||||
(void) strncpy(tmpbuf, el->el_search.patbuf,
|
||||
sizeof(tmpbuf) - 1);
|
||||
el->el_search.patbuf[0] = '.';
|
||||
el->el_search.patbuf[1] = '*';
|
||||
(void) strncpy(&el->el_search.patbuf[2], tmpbuf,
|
||||
EL_BUFSIZ - 3);
|
||||
el->el_search.patlen++;
|
||||
el->el_search.patbuf[el->el_search.patlen++] = '.';
|
||||
el->el_search.patbuf[el->el_search.patlen++] = '*';
|
||||
el->el_search.patbuf[el->el_search.patlen] = '\0';
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
#ifdef ANCHOR
|
||||
tmpbuf[tmplen++] = '.';
|
||||
tmpbuf[tmplen++] = '*';
|
||||
#endif
|
||||
tmpbuf[tmplen] = '\0';
|
||||
(void) strncpy(el->el_search.patbuf, tmpbuf, EL_BUFSIZ - 1);
|
||||
el->el_search.patlen = tmplen;
|
||||
}
|
||||
el->el_state.lastcmd = (el_action_t) dir; /* avoid c_setpat */
|
||||
el->el_line.cursor = el->el_line.lastchar = el->el_line.buffer;
|
||||
if ((dir == ED_SEARCH_PREV_HISTORY ? ed_search_prev_history(el, 0) :
|
||||
ed_search_next_history(el, 0)) == CC_ERROR) {
|
||||
re_refresh(el);
|
||||
return (CC_ERROR);
|
||||
}
|
||||
if (ch == 0033) {
|
||||
re_refresh(el);
|
||||
return ed_newline(el, 0);
|
||||
}
|
||||
return (CC_REFRESH);
|
||||
}
|
||||
|
||||
|
||||
/* ce_search_line():
|
||||
* Look for a pattern inside a line
|
||||
*/
|
||||
protected el_action_t
|
||||
ce_search_line(EditLine *el, int dir)
|
||||
{
|
||||
char *cp = el->el_line.cursor;
|
||||
char *pattern = el->el_search.patbuf;
|
||||
char oc, *ocp;
|
||||
#ifdef ANCHOR
|
||||
ocp = &pattern[1];
|
||||
oc = *ocp;
|
||||
*ocp = '^';
|
||||
#else
|
||||
ocp = pattern;
|
||||
oc = *ocp;
|
||||
#endif
|
||||
|
||||
if (dir == ED_SEARCH_PREV_HISTORY) {
|
||||
for (; cp >= el->el_line.buffer; cp--) {
|
||||
if (el_match(cp, ocp)) {
|
||||
*ocp = oc;
|
||||
el->el_line.cursor = cp;
|
||||
return (CC_NORM);
|
||||
}
|
||||
}
|
||||
*ocp = oc;
|
||||
return (CC_ERROR);
|
||||
} else {
|
||||
for (; *cp != '\0' && cp < el->el_line.limit; cp++) {
|
||||
if (el_match(cp, ocp)) {
|
||||
*ocp = oc;
|
||||
el->el_line.cursor = cp;
|
||||
return (CC_NORM);
|
||||
}
|
||||
}
|
||||
*ocp = oc;
|
||||
return (CC_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cv_repeat_srch():
|
||||
* Vi repeat search
|
||||
*/
|
||||
protected el_action_t
|
||||
cv_repeat_srch(EditLine *el, int c)
|
||||
{
|
||||
|
||||
#ifdef SDEBUG
|
||||
(void) fprintf(el->el_errfile, "dir %d patlen %d patbuf %s\n",
|
||||
c, el->el_search.patlen, el->el_search.patbuf);
|
||||
#endif
|
||||
|
||||
el->el_state.lastcmd = (el_action_t) c; /* Hack to stop c_setpat */
|
||||
el->el_line.lastchar = el->el_line.buffer;
|
||||
|
||||
switch (c) {
|
||||
case ED_SEARCH_NEXT_HISTORY:
|
||||
return (ed_search_next_history(el, 0));
|
||||
case ED_SEARCH_PREV_HISTORY:
|
||||
return (ed_search_prev_history(el, 0));
|
||||
default:
|
||||
return (CC_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* cv_csearch():
|
||||
* Vi character search
|
||||
*/
|
||||
protected el_action_t
|
||||
cv_csearch(EditLine *el, int direction, int ch, int count, int tflag)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if (ch == 0)
|
||||
return CC_ERROR;
|
||||
|
||||
if (ch == -1) {
|
||||
char c;
|
||||
if (el_getc(el, &c) != 1)
|
||||
return ed_end_of_file(el, 0);
|
||||
ch = c;
|
||||
}
|
||||
|
||||
/* Save for ';' and ',' commands */
|
||||
el->el_search.chacha = ch;
|
||||
el->el_search.chadir = direction;
|
||||
el->el_search.chatflg = tflag;
|
||||
|
||||
cp = el->el_line.cursor;
|
||||
while (count--) {
|
||||
if (*cp == ch)
|
||||
cp += direction;
|
||||
for (;;cp += direction) {
|
||||
if (cp >= el->el_line.lastchar)
|
||||
return CC_ERROR;
|
||||
if (cp < el->el_line.buffer)
|
||||
return CC_ERROR;
|
||||
if (*cp == ch)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (tflag)
|
||||
cp -= direction;
|
||||
|
||||
el->el_line.cursor = cp;
|
||||
|
||||
if (el->el_chared.c_vcmd.action != NOP) {
|
||||
if (direction > 0)
|
||||
el->el_line.cursor++;
|
||||
cv_delfini(el);
|
||||
return CC_REFRESH;
|
||||
}
|
||||
return CC_CURSOR;
|
||||
}
|
66
extern/editline/src/search.h
vendored
Normal file
66
extern/editline/src/search.h
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
/* $NetBSD: search.h,v 1.8 2003/10/18 23:27:36 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Christos Zoulas of Cornell University.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)search.h 8.1 (Berkeley) 6/4/93
|
||||
*/
|
||||
|
||||
/*
|
||||
* el.search.h: Line and history searching utilities
|
||||
*/
|
||||
#ifndef _h_el_search
|
||||
#define _h_el_search
|
||||
|
||||
#include "histedit.h"
|
||||
|
||||
typedef struct el_search_t {
|
||||
char *patbuf; /* The pattern buffer */
|
||||
size_t patlen; /* Length of the pattern buffer */
|
||||
int patdir; /* Direction of the last search */
|
||||
int chadir; /* Character search direction */
|
||||
char chacha; /* Character we are looking for */
|
||||
char chatflg; /* 0 if f, 1 if t */
|
||||
} el_search_t;
|
||||
|
||||
|
||||
protected int el_match(const char *, const char *);
|
||||
protected int search_init(EditLine *);
|
||||
protected void search_end(EditLine *);
|
||||
protected int c_hmatch(EditLine *, const char *);
|
||||
protected void c_setpat(EditLine *);
|
||||
protected el_action_t ce_inc_search(EditLine *, int);
|
||||
protected el_action_t cv_search(EditLine *, int);
|
||||
protected el_action_t ce_search_line(EditLine *, int);
|
||||
protected el_action_t cv_repeat_srch(EditLine *, int);
|
||||
protected el_action_t cv_csearch(EditLine *, int, int, int, int);
|
||||
|
||||
#endif /* _h_el_search */
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user