]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
commit bash-20100826 snapshot
authorChet Ramey <chet.ramey@case.edu>
Tue, 13 Dec 2011 03:04:56 +0000 (22:04 -0500)
committerChet Ramey <chet.ramey@case.edu>
Tue, 13 Dec 2011 03:04:56 +0000 (22:04 -0500)
17 files changed:
CWRU/CWRU.chlog
CWRU/CWRU.chlog~
doc/bash.1
doc/bashref.texi
doc/bashref.texi~
doc/version.texi
doc/version.texi~
lib/readline/doc/readline.3
lib/readline/doc/readline.3~
lib/readline/doc/rluser.texi
lib/readline/doc/rluser.texi~
lib/readline/doc/version.texi
lib/readline/doc/version.texi~
lib/readline/isearch.c
lib/readline/isearch.c~ [new file with mode: 0644]
lib/readline/rlprivate.h
lib/readline/rlprivate.h~

index bf7abe207f9191ab80ae2f5093b0dfa601415003..68b83600dee4b447a86b69843ff61c2657ae34d1 100644 (file)
@@ -10359,3 +10359,16 @@ pathexp.c
          flag to skip over extended globbing patterns in variables like
          HISTIGNORE and GLOBIGNORE.  Fixes bug reported by Dimitar DIMITROV
          <mitkofr@yahoo.fr> and Greg Wooledge <wooledg@eeg.ccf.org>
+
+                                  8/28
+                                  ----
+lib/readline/rlprivate.h
+       - add member to search_cxt to save _rl_keymap
+       - new flag for isearch context: SF_CHGKMAP, set if we changed the
+         keymap while reading a character for the search string that
+         translated to a command
+
+lib/readline/isearch.c
+       - save current readline keymap in cxt->keymap in _rl_scxt_alloc
+       - in _rl_isearch_dispatch, only check for cxt->lastc as a member of
+         cxt->search_terminators if it's > 0 (i.e., not an isearch opcode)
index f0e3ad65449f2919242de87294963e24043b4d70..6aa07bcb9c4581cb48e95480d5356c0abae71eba 100644 (file)
@@ -10340,7 +10340,7 @@ bashhist.c
 
 shell.h,parse.y
        - add prompt_string_pointer to the parser_state struct saved and
-         restored by {save,restore}_parser_state.  Fixes part of bug exposed
+         restored by {save,restore}_parser_state.  Fixes both bugs exposed
          by bash_completion and completion of open backquotes reported by
          Egmont Koblinger <egmont@gmail.com>
 
@@ -10359,3 +10359,13 @@ pathexp.c
          flag to skip over extended globbing patterns in variables like
          HISTIGNORE and GLOBIGNORE.  Fixes bug reported by Dimitar DIMITROV
          <mitkofr@yahoo.fr> and Greg Wooledge <wooledg@eeg.ccf.org>
+
+                                  8/28
+                                  ----
+lib/readline/rlprivate.h
+       - add member to search_cxt to save _rl_keymap
+
+lib/readline/isearch.c
+       - save current readline keymap in cxt->keymap in _rl_scxt_alloc
+       - in _rl_isearch_dispatch, only check for cxt->lastc as a member of
+         cxt->search_terminators if it's > 0 (i.e., not an isearch opcode)
index 33b0d30983ab42ae33b46f9ec3a308a1ae121d72..1f935acf9e7a4867d401ec50845745576512ac51 100644 (file)
@@ -5,12 +5,12 @@
 .\"    Case Western Reserve University
 .\"    chet@po.cwru.edu
 .\"
-.\"    Last Change: Tue Aug  3 15:24:33 EDT 2010
+.\"    Last Change: Sat Aug 28 18:55:45 EDT 2010
 .\"
 .\" bash_builtins, strip all but Built-Ins section
 .if \n(zZ=1 .ig zZ
 .if \n(zY=1 .ig zY
-.TH BASH 1 "2010 August 3" "GNU Bash-4.2"
+.TH BASH 1 "2010 August 28" "GNU Bash-4.2"
 .\"
 .\" There's some problem with having a `@'
 .\" in a tagged paragraph with the BSD man macros.
@@ -408,7 +408,7 @@ No other startup files are read.
 .PP
 .B Bash
 attempts to determine when it is being run with its standard input
-connected to a network connection, as if by the remote shell
+connected to a network connection, as when executed by the remote shell
 daemon, usually \fIrshd\fP, or the secure shell daemon \fIsshd\fP.
 If
 .B bash
@@ -938,7 +938,7 @@ command (see
 below).
 The file descriptors can be utilized as arguments to shell commands
 and redirections using standard word expansions.
-The process id of the shell spawned to execute the coprocess is
+The process ID of the shell spawned to execute the coprocess is
 available as the value of the variable \fINAME\fP_PID.
 The \fBwait\fP
 builtin command may be used to wait for the coprocess to terminate.
@@ -1213,7 +1213,7 @@ builtin commands.
 In the context where an assignment statement is assigning a value
 to a shell variable or array index, the += operator can be used to
 append to or add to the variable's previous value.
-When += is applied to a variable for which the integer attribute has been
+When += is applied to a variable for which the \fIinteger\fP attribute has been
 set, \fIvalue\fP is evaluated as an arithmetic expression and added to the
 variable's current value, which is also evaluated.
 When += is applied to an array variable using compound assignment (see
@@ -1373,7 +1373,7 @@ reading any startup files.
 This variable is read-only.
 .TP
 .B BASHPID
-Expands to the process id of the current \fBbash\fP process.
+Expands to the process ID of the current \fBbash\fP process.
 This differs from \fB$$\fP under certain circumstances, such as subshells
 that do not require \fBbash\fP to be re-initialized.
 .TP
@@ -2680,7 +2680,7 @@ a level of variable indirection is introduced.
 expanded and that value is used in the rest of the substitution, rather
 than the value of \fIparameter\fP itself.
 This is known as \fIindirect expansion\fP.
-The exceptions to this are the expansions of ${!\fIprefix\fP*} and
+The exceptions to this are the expansions of ${\fB!\\fPfIprefix\fP\fB*\fP} and
 ${\fB!\fP\fIname\fP[\fI@\fP]} described below.
 The exclamation point must immediately follow the left brace in order to
 introduce indirection.
@@ -2740,7 +2740,7 @@ ${\fIparameter\fP\fB:\fP\fIoffset\fP}
 .TP
 ${\fIparameter\fP\fB:\fP\fIoffset\fP\fB:\fP\fIlength\fP}
 .PD
-\fBSubstring Expansion.\fP
+\fBSubstring Expansion\fP.
 Expands to up to \fIlength\fP characters of \fIparameter\fP
 starting at the character specified by \fIoffset\fP.
 If \fIlength\fP is omitted, expands to the substring of
@@ -2778,7 +2778,7 @@ ${\fB!\fP\fIprefix\fP\fB*\fP}
 .TP
 ${\fB!\fP\fIprefix\fP\fB@\fP}
 .PD
-\fBNames matching prefix.\fP
+\fBNames matching prefix\fP.
 Expands to the names of variables whose names begin with \fIprefix\fP,
 separated by the first character of the
 .SM
@@ -2792,7 +2792,7 @@ ${\fB!\fP\fIname\fP[\fI@\fP]}
 .TP
 ${\fB!\fP\fIname\fP[\fI*\fP]}
 .PD
-\fBList of array keys.\fP
+\fBList of array keys\fP.
 If \fIname\fP is an array variable, expands to the list of array indices
 (keys) assigned in \fIname\fP.
 If \fIname\fP is not an array, expands to 0 if \fIname\fP is set and null
@@ -2801,7 +2801,7 @@ When \fI@\fP is used and the expansion appears within double quotes, each
 key expands to a separate word.
 .TP
 ${\fB#\fP\fIparameter\fP}
-\fBParameter length.\fP
+\fBParameter length\fP.
 The length in characters of the value of \fIparameter\fP is substituted.
 If
 .I parameter
@@ -2823,7 +2823,7 @@ ${\fIparameter\fP\fB#\fP\fIword\fP}
 .TP
 ${\fIparameter\fP\fB##\fP\fIword\fP}
 .PD
-\fBRemove matching prefix pattern.\fP
+\fBRemove matching prefix pattern\fP.
 The 
 .I word
 is expanded to produce a pattern just as in pathname
@@ -2856,7 +2856,7 @@ ${\fIparameter\fP\fB%\fP\fIword\fP}
 .TP
 ${\fIparameter\fP\fB%%\fP\fIword\fP}
 .PD
-\fBRemove matching suffix pattern.\fP
+\fBRemove matching suffix pattern\fP.
 The \fIword\fP is expanded to produce a pattern just as in
 pathname expansion.
 If the pattern matches a trailing portion of the expanded value of
@@ -2883,7 +2883,7 @@ the pattern removal operation is applied to each member of the
 array in turn, and the expansion is the resultant list.
 .TP
 ${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
-\fBPattern substitution.\fP
+\fBPattern substitution\fP.
 The \fIpattern\fP is expanded to produce a pattern just as in
 pathname expansion.
 \fIParameter\fP is expanded and the longest match of \fIpattern\fP
@@ -2922,7 +2922,7 @@ ${\fIparameter\fP\fB,\fP\fIpattern\fP}
 .TP
 ${\fIparameter\fP\fB,,\fP\fIpattern\fP}
 .PD
-\fBCase modification.\fP
+\fBCase modification\fP.
 This expansion modifies the case of alphabetic characters in \fIparameter\fP.
 The \fIpattern\fP is expanded to produce a pattern just as in
 pathname expansion.
@@ -3786,7 +3786,7 @@ function become the positional parameters
 during its execution.
 The special parameter
 .B #
-is updated to reflect the change.  Special parameter 0
+is updated to reflect the change.  Special parameter \fB0\fP
 is unchanged.
 The first element of the
 .SM
@@ -3956,7 +3956,7 @@ The value of a variable is evaluated as an arithmetic expression
 when it is referenced, or when a variable which has been given the
 \fIinteger\fP attribute using \fBdeclare -i\fP is assigned a value.
 A null value evaluates to 0.
-A shell variable need not have its integer attribute
+A shell variable need not have its \fIinteger\fP attribute
 turned on to be used in an expression.
 .PP
 Constants with a leading 0 are interpreted as octal numbers.
@@ -4308,8 +4308,8 @@ subshell environment.  Changes made to the subshell environment
 cannot affect the shell's execution environment.
 .PP
 Subshells spawned to execute command substitutions inherit the value of
-the \fB\-e\fP option from the parent shell.  When not in posix mode,
-Bash clears the \fB\-e\fP option in such subshells.
+the \fB\-e\fP option from the parent shell.  When not in \fIposix\fP mode,
+\fBbash\fP clears the \fB\-e\fP option in such subshells.
 .PP
 If a command is followed by a \fB&\fP and job control is not active, the
 default standard input for the command is the empty file \fI/dev/null\fP.
@@ -4804,7 +4804,7 @@ shell, unless the
 option is given at shell invocation.
 Line editing is also used when using the \fB\-e\fP option to the
 \fBread\fP builtin.
-By default, the line editing commands are similar to those of emacs.
+By default, the line editing commands are similar to those of Emacs.
 A vi-style line editing interface is also available.
 Line editing can be enabled at any time using the
 .B \-o emacs
@@ -4825,7 +4825,7 @@ options to the
 builtin.
 .SS "Readline Notation"
 .PP
-In this section, the emacs-style notation is used to denote
+In this section, the Emacs-style notation is used to denote
 keystrokes.  Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
 means Control\-N.  Similarly, 
 .I meta
@@ -5142,7 +5142,7 @@ mapped to \fBself-insert\fP.
 .TP
 .B editing\-mode (emacs)
 Controls whether readline begins with a set of key bindings similar
-to \fIemacs\fP or \fIvi\fP.
+to \fIEmacs\fP or \fIvi\fP.
 .B editing\-mode
 can be set to either
 .B emacs
@@ -5165,11 +5165,11 @@ key the terminal claims to support when it is called.  On many terminals,
 the meta key is used to send eight-bit characters.
 .TP
 .B expand\-tilde (Off)
-If set to \fBon\fP, tilde expansion is performed when readline
+If set to \fBOn\fP, tilde expansion is performed when readline
 attempts word completion.
 .TP
 .B history\-preserve\-point (Off)
-If set to \fBon\fP, the history code attempts to place point at the
+If set to \fBOn\fP, the history code attempts to place point at the
 same location on each history line retrieved with \fBprevious-history\fP
 or \fBnext-history\fP.
 .TP
@@ -5241,7 +5241,7 @@ If set to \fBOn\fP, readline will display completions with matches
 sorted horizontally in alphabetical order, rather than down the screen.
 .TP 
 .B revert\-all\-at\-newline (Off)
-If set to \fBon\fP, readline will undo all changes to history lines 
+If set to \fBOn\fP, readline will undo all changes to history lines 
 before returning when \fBaccept\-line\fP is executed.  By default,
 history lines may be modified and retain individual undo lists across
 calls to \fBreadline\fP.
@@ -5249,7 +5249,7 @@ calls to \fBreadline\fP.
 .B show\-all\-if\-ambiguous (Off)
 This alters the default behavior of the completion functions.  If
 set to
-.BR on ,
+.BR On ,
 words which have more than one possible completion cause the
 matches to be listed immediately instead of ringing the bell.
 .TP
@@ -5257,7 +5257,7 @@ matches to be listed immediately instead of ringing the bell.
 This alters the default behavior of the completion functions in
 a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
 If set to
-.BR on ,
+.BR On ,
 words which have more than one possible completion without any
 possible partial completion (the possible completions don't share
 a common prefix) cause the matches to be listed immediately instead
@@ -5317,7 +5317,7 @@ library sets the \fIapplication name\fP, and an initialization
 file can test for a particular value.
 This could be used to bind key sequences to functions useful for
 a specific program.  For instance, the following command adds a
-key sequence that quotes the current or previous word in Bash:
+key sequence that quotes the current or previous word in \fBbash\fP:
 .sp 1
 .RS
 .nf
@@ -5755,7 +5755,7 @@ through the list.
 This command is intended to be bound to \fBTAB\fP, but is unbound
 by default.
 .TP
-.B menu\-complete-\backward
+.B menu\-complete\-backward
 Identical to \fBmenu\-complete\fP, but moves backward through the list
 of possible completions, as if \fBmenu\-complete\fP had been given a
 negative argument.  This command is unbound by default.
@@ -5892,7 +5892,7 @@ character.  A negative count searches for previous occurrences.
 A character is read and point is moved to the previous occurrence of that
 character.  A negative count searches for subsequent occurrences.
 .TP
-.B skip\-csi\-sequence ()
+.B skip\-csi\-sequence
 Read enough characters to consume a multi-key sequence such as those
 defined for keys like Home and End.  Such sequences begin with a
 Control Sequence Indicator (CSI), usually ESC\-[.  If this sequence is
@@ -5976,7 +5976,7 @@ If the command word is a full pathname, a compspec for the full
 pathname is searched for first.
 If no compspec is found for the full pathname, an attempt is made to
 find a compspec for the portion following the final slash.
-If those searches to not result in a compspec, any compspec defined with
+If those searches do not result in a compspec, any compspec defined with
 the \fB\-D\fP option to \fBcomplete\fP is used as the default.
 .PP
 Once a compspec has been found, it is used to generate the list of
@@ -7670,7 +7670,7 @@ return value greater than zero.
 .SM
 .B OPTIND
 is set to the index of the first non-option argument,
-and \fBname\fP is set to ?.
+and \fIname\fP is set to ?.
 .sp 1
 .B getopts
 normally parses the positional parameters, but if more arguments are
@@ -8419,10 +8419,10 @@ the return status is false.
 Any command associated with the \fBRETURN\fP trap is executed
 before execution resumes after the function or script.
 .TP
-\fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\fP] [\fIarg\fP ...]
+\fBset\fP [\fB\-\-abefhkmnptuvxBCEHPT\fP] [\fB\-o\fP \fIoption\-name\fP] [\fIarg\fP ...]
 .PD 0
 .TP
-\fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\fP] [\fIarg\fP ...]
+\fBset\fP [\fB+abefhkmnptuvxBCEHPT\fP] [\fB+o\fP \fIoption\-name\fP] [\fIarg\fP ...]
 .PD
 Without options, the name and value of each shell variable are displayed
 in a format that can be reused as input
@@ -8904,20 +8904,21 @@ easy re-editing of multi-line commands.
 If set,
 .B bash
 changes its behavior to that of version 3.1 with respect to quoted
-arguments to the conditional command's =~ operator.
+arguments to the conditional command's \fB=~\fP operator.
 .TP 8
 .B compat32
 If set,
 .B bash
 changes its behavior to that of version 3.2 with respect to locale-specific
-string comparison when using the conditional command's < and > operators.
+string comparison when using the conditional command's \fB<\fP and \fB>\fP
+operators.
 .TP 8
 .B compat40
 If set,
 .B bash
 changes its behavior to that of version 4.0 with respect to locale-specific
-string comparison when using the conditional command's < and > operators
-and the effect of interrupting a command list.
+string comparison when using the conditional command's \fB<\fP and \fB>\fP
+operators and the effect of interrupting a command list.
 .TP 8
 .B compat41
 @item compat41
@@ -9720,7 +9721,7 @@ as an argument to the
 .B .
 builtin command
 .IP \(bu
-Specifying a filename containing a slash as an argument to the
+specifying a filename containing a slash as an argument to the
 .B \-p
 option to the
 .B hash
@@ -9747,7 +9748,7 @@ options to the
 .B enable
 builtin command
 .IP \(bu
-Using the \fBenable\fP builtin command to enable disabled shell builtins
+using the \fBenable\fP builtin command to enable disabled shell builtins
 .IP \(bu
 specifying the
 .B \-p
index 1a94dc0391910e5914a0bb60b7c1680da4edebcc..2f457515b2d91844bfe508b82615c43fc5593e13 100644 (file)
@@ -1135,7 +1135,7 @@ command (@pxref{Redirections}).
 The file descriptors can be utilized as arguments to shell commands
 and redirections using standard word expansions.
 
-The process id of the shell spawned to execute the coprocess is
+The process ID of the shell spawned to execute the coprocess is
 available as the value of the variable @var{NAME}_PID.
 The @code{wait}
 builtin command may be used to wait for the coprocess to terminate.
@@ -1382,7 +1382,7 @@ In the context where an assignment statement is assigning a value
 to a shell variable or array index (@pxref{Arrays}), the @samp{+=}
 operator can be used to   
 append to or add to the variable's previous value.
-When @samp{+=} is applied to a variable for which the integer attribute
+When @samp{+=} is applied to a variable for which the @var{integer} attribute
 has been set, @var{value} is evaluated as an arithmetic expression and
 added to the variable's current value, which is also evaluated.
 When @samp{+=} is applied to an array variable using compound assignment
@@ -1717,7 +1717,7 @@ Bash uses the value of the variable formed from the rest of
 expanded and that value is used in the rest of the substitution, rather
 than the value of @var{parameter} itself.
 This is known as @code{indirect expansion}.
-The exceptions to this are the expansions of $@{!@var{prefix*}@}
+The exceptions to this are the expansions of $@{!@var{prefix}@*}
 and $@{!@var{name}[@@]@}
 described below.
 The exclamation point must immediately follow the left brace in order to
@@ -3061,7 +3061,7 @@ invocation if a new set of parameters is to be used.
 When the end of options is encountered, @code{getopts} exits with a
 return value greater than zero.
 @env{OPTIND} is set to the index of the first non-option argument,
-and @code{name} is set to @samp{?}.
+and @var{name} is set to @samp{?}.
 
 @code{getopts}
 normally parses the positional parameters, but if more arguments are
@@ -4141,8 +4141,8 @@ parameters, or to display the names and values of shell variables.
 @item set
 @btindex set
 @example
-set [--abefhkmnptuvxBCEHPT] [-o @var{option}] [@var{argument} @dots{}]
-set [+abefhkmnptuvxBCEHPT] [+o @var{option}] [@var{argument} @dots{}]
+set [--abefhkmnptuvxBCEHPT] [-o @var{option-name}] [@var{argument} @dots{}]
+set [+abefhkmnptuvxBCEHPT] [+o @var{option-name}] [@var{argument} @dots{}]
 @end example
 
 If no options or arguments are supplied, @code{set} displays the names
@@ -4503,18 +4503,19 @@ easy re-editing of multi-line commands.
 @item compat31
 If set, Bash
 changes its behavior to that of version 3.1 with respect to quoted
-arguments to the conditional command's =~ operator.
+arguments to the conditional command's @samp{=~} operator.
 
 @item compat32
 If set, Bash
 changes its behavior to that of version 3.2 with respect to locale-specific
-string comparison when using the conditional command's < and > operators.
+string comparison when using the conditional command's @samp{<} and @samp{>}
+operators.
 
 @item compat40
 If set, Bash
 changes its behavior to that of version 4.0 with respect to locale-specific
-string comparison when using the conditional command's < and > operators
-and the effect of interrupting a command list.
+string comparison when using the conditional command's @samp{<} and @samp{>}
+operators and the effect of interrupting a command list.
 
 @item compat41
 If set, Bash, when in posix mode, treats a single quote in a double-quoted
@@ -4850,13 +4851,13 @@ starts up, each shell option in the list will be enabled before
 reading any startup files.  This variable is readonly.
 
 @item BASHPID
-Expands to the process id of the current Bash process.
+Expands to the process ID of the current Bash process.
 This differs from @code{$$} under certain circumstances, such as subshells
 that do not require Bash to be re-initialized.
 
 @item BASH_ALIASES
 An associative array variable whose members correspond to the internal
-list of aliases as maintained by the @code{alias} builtin
+list of aliases as maintained by the @code{alias} builtin.
 (@pxref{Bourne Shell Builtins}).
 Elements added to this array appear in the alias list; unsetting array
 elements cause aliases to be removed from the alias list.
@@ -5728,7 +5729,7 @@ No other startup files are read.
 @subsubheading Invoked by remote shell daemon
 
 Bash attempts to determine when it is being run with its standard input
-connected to a network connection, as if by the remote shell
+connected to a network connection, as when executed by the remote shell
 daemon, usually @code{rshd}, or the secure shell daemon @code{sshd}.
 If Bash determines it is being run in
 this fashion, it reads and executes commands from @file{~/.bashrc}, if that
@@ -6132,7 +6133,7 @@ The value of a variable is evaluated as an arithmetic expression
 when it is referenced, or when a variable which has been given the  
 @var{integer} attribute using @samp{declare -i} is assigned a value.
 A null value evaluates to 0.
-A shell variable need not have its integer attribute turned on
+A shell variable need not have its @var{integer} attribute turned on
 to be used in an expression.
 
 Constants with a leading 0 are interpreted as octal numbers.
index db249617c0e05162e657cbf33ab59d658f70b7f9..1a94dc0391910e5914a0bb60b7c1680da4edebcc 100644 (file)
@@ -5058,7 +5058,7 @@ it is subsequently reset.
 @item EMACS
 If Bash finds this variable in the environment when the shell
 starts with value @samp{t}, it assumes that the shell is running in an
-emacs shell buffer and disables line editing.
+Emacs shell buffer and disables line editing.
 
 @item ENV
 Similar to @code{BASH_ENV}; used when the shell is invoked in
@@ -5728,7 +5728,7 @@ No other startup files are read.
 @subsubheading Invoked by remote shell daemon
 
 Bash attempts to determine when it is being run with its standard input
-connected to a network connection, as if by the remote shell
+connected to a network connection, as if by the remote shell
 daemon, usually @code{rshd}, or the secure shell daemon @code{sshd}.
 If Bash determines it is being run in
 this fashion, it reads and executes commands from @file{~/.bashrc}, if that
index b88cc4623d2b94db5e927abb1e58030572b65349..061b86ac9751245933e2b8d9ae4562c1d9c1ca51 100644 (file)
@@ -2,9 +2,9 @@
 Copyright (C) 1988-2010 Free Software Foundation, Inc.
 @end ignore
 
-@set LASTCHANGE Wed Jul 21 08:54:40 EDT 2010
+@set LASTCHANGE Sat Aug 28 18:56:04 EDT 2010
 
 @set EDITION 4.2
 @set VERSION 4.2
-@set UPDATED 21 July 2010
-@set UPDATED-MONTH July 2010
+@set UPDATED 28 August 2010
+@set UPDATED-MONTH August 2010
index 3f0094003b6aac82c2528e7335144ba3c2f9574d..b88cc4623d2b94db5e927abb1e58030572b65349 100644 (file)
@@ -2,9 +2,9 @@
 Copyright (C) 1988-2010 Free Software Foundation, Inc.
 @end ignore
 
-@set LASTCHANGE Sat Jun 12 15:35:23 EDT 2010
+@set LASTCHANGE Wed Jul 21 08:54:40 EDT 2010
 
-@set EDITION 4.1
-@set VERSION 4.1
-@set UPDATED 12 June 2010
-@set UPDATED-MONTH June 2010
+@set EDITION 4.2
+@set VERSION 4.2
+@set UPDATED 21 July 2010
+@set UPDATED-MONTH July 2010
index e83e39061e84031fc90335dd9114b0adbee122fd..60a9caf8081d2cef7fe39e506ebdb0acaba80668 100644 (file)
@@ -6,9 +6,9 @@
 .\"    Case Western Reserve University
 .\"    chet@ins.CWRU.Edu
 .\"
-.\"    Last Change: Thu Apr 22 18:59:21 EDT 2010
+.\"    Last Change: Sat Aug 28 18:56:32 EDT 2010
 .\"
-.TH READLINE 3 "2010 April 22" "GNU Readline 6.2"
+.TH READLINE 3 "2010 August 28" "GNU Readline 6.2"
 .\"
 .\" File Name macro.  This used to be `.PN', for Path Name,
 .\" but Sun doesn't seem to like that very much.
@@ -76,7 +76,7 @@ is read with a non\-empty line, it is
 treated as a newline.
 .SH NOTATION
 .LP
-An emacs-style notation is used to denote
+An Emacs-style notation is used to denote
 keystrokes.  Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
 means Control\-N.  Similarly, 
 .I meta
@@ -407,7 +407,7 @@ mapped to \fBself-insert\fP.
 .TP
 .B editing\-mode (emacs)
 Controls whether readline begins with a set of key bindings similar
-to emacs or vi.
+to \fIEmacs\fP or \fIvi\fP.
 .B editing\-mode
 can be set to either
 .B emacs
@@ -430,11 +430,11 @@ key the terminal claims to support when it is called.  On many terminals,
 the meta key is used to send eight-bit characters.
 .TP
 .B expand\-tilde (Off)
-If set to \fBon\fP, tilde expansion is performed when readline
+If set to \fBOn\fP, tilde expansion is performed when readline
 attempts word completion.
 .TP
 .B history\-preserve\-point (Off)
-If set to \fBon\fP, the history code attempts to place point at the 
+If set to \fBOn\fP, the history code attempts to place point at the 
 same location on each history line retrieved with \fBprevious-history\fP 
 or \fBnext-history\fP.
 .TP
@@ -506,7 +506,7 @@ If set to \fBOn\fP, readline will display completions with matches
 sorted horizontally in alphabetical order, rather than down the screen.
 .TP
 .B revert\-all\-at\-newline (Off)
-If set to \fBon\fP, readline will undo all changes to history lines
+If set to \fBOn\fP, readline will undo all changes to history lines
 before returning when \fBaccept\-line\fP is executed.  By default,
 history lines may be modified and retain individual undo lists across
 calls to \fBreadline\fP.
@@ -514,7 +514,7 @@ calls to \fBreadline\fP.
 .B show\-all\-if\-ambiguous (Off)
 This alters the default behavior of the completion functions.  If
 set to
-.BR on ,
+.BR On ,
 words which have more than one possible completion cause the
 matches to be listed immediately instead of ringing the bell.
 .TP
@@ -522,7 +522,7 @@ matches to be listed immediately instead of ringing the bell.
 This alters the default behavior of the completion functions in
 a fashion similar to \fBshow\-all\-if\-ambiguous\fP.
 If set to
-.BR on , 
+.BR On , 
 words which have more than one possible completion without any
 possible partial completion (the possible completions don't share 
 a common prefix) cause the matches to be listed immediately instead
@@ -582,7 +582,7 @@ library sets the \fIapplication name\fP, and an initialization
 file can test for a particular value.
 This could be used to bind key sequences to functions useful for
 a specific program.  For instance, the following command adds a
-key sequence that quotes the current or previous word in Bash:
+key sequence that quotes the current or previous word in \fBbash\fP:
 .sp 1
 .RS
 .nf
@@ -962,7 +962,7 @@ through the list.
 This command is intended to be bound to \fBTAB\fP, but is unbound
 by default.
 .TP
-.B menu\-complete-\backward
+.B menu\-complete\-backward
 Identical to \fBmenu\-complete\fP, but moves backward through the list
 of possible completions, as if \fBmenu\-complete\fP had been given a
 negative argument.  This command is unbound by default.
@@ -1040,7 +1040,7 @@ character.  A negative count searches for previous occurrences.
 A character is read and point is moved to the previous occurrence of that
 character.  A negative count searches for subsequent occurrences.
 .TP
-.B skip\-csi\-sequence ()
+.B skip\-csi\-sequence
 Read enough characters to consume a multi-key sequence such as those
 defined for keys like Home and End.  Such sequences begin with a
 Control Sequence Indicator (CSI), usually ESC\-[.  If this sequence is
index d729fd1f02d2e4f23d431c127d2ef8d709d7dee1..e83e39061e84031fc90335dd9114b0adbee122fd 100644 (file)
@@ -8,7 +8,7 @@
 .\"
 .\"    Last Change: Thu Apr 22 18:59:21 EDT 2010
 .\"
-.TH READLINE 3 "2010 April 22" "GNU Readline 6.1"
+.TH READLINE 3 "2010 April 22" "GNU Readline 6.2"
 .\"
 .\" File Name macro.  This used to be `.PN', for Path Name,
 .\" but Sun doesn't seem to like that very much.
index 173d1bbb883e41728dd6c9dac1edb047b4880734..f34aad515aa4677c34acd292dae4d7a6447f4ec7 100644 (file)
@@ -51,7 +51,7 @@ Command line editing is enabled by default when using an interactive shell,
 unless the @option{--noediting} option is supplied at shell invocation.
 Line editing is also used when using the @option{-e} option to the
 @code{read} builtin command (@pxref{Bash Builtins}).
-By default, the line editing commands are similar to those of emacs.
+By default, the line editing commands are similar to those of Emacs.
 A vi-style line editing interface is also available.
 Line editing can be enabled at any time using the @option{-o emacs} or
 @option{-o vi} options to the @code{set} builtin command
index 82cbb05ff866507a02026e8e0c126f4bfde8ed48..173d1bbb883e41728dd6c9dac1edb047b4880734 100644 (file)
@@ -446,6 +446,12 @@ If set to @samp{on}, Readline performs filename matching and completion
 in a case-insensitive fashion.
 The default value is @samp{off}.
 
+@item completion-map-case
+@vindex completion-map-case
+If set to @samp{on}, and @var{completion-ignore-case} is enabled, Readline
+treats hyphens (@samp{-}) and underscores (@samp{_}) as equivalent when
+performing case-insensitive filename matching and completion.
+
 @item completion-prefix-display-length
 @vindex completion-prefix-display-length
 The length in characters of the common prefix of a list of possible
index f25776752171971ae9caa6d514bbb9f8dd5cae82..181e4ad2f5535812bee03633847e6ab34c445be2 100644 (file)
@@ -4,7 +4,7 @@ Copyright (C) 1988-2010 Free Software Foundation, Inc.
 
 @set EDITION 6.2
 @set VERSION 6.2
-@set UPDATED August 12 2010
+@set UPDATED August 28 2010
 @set UPDATED-MONTH August 2010
 
-@set LASTCHANGE Thu Aug 12 22:24:28 EDT 2010
+@set LASTCHANGE Sat Aug 28 18:57:07 EDT 2010
index 59ea6cdcb1ebe77a6125eccb3e457e09f39462bf..f25776752171971ae9caa6d514bbb9f8dd5cae82 100644 (file)
@@ -4,7 +4,7 @@ Copyright (C) 1988-2010 Free Software Foundation, Inc.
 
 @set EDITION 6.2
 @set VERSION 6.2
-@set UPDATED August 3 2010
+@set UPDATED August 12 2010
 @set UPDATED-MONTH August 2010
 
-@set LASTCHANGE Tue Aug  3 15:30:05 EDT 2010
+@set LASTCHANGE Thu Aug 12 22:24:28 EDT 2010
index f3f46a71b34438dc059a8a2cd4bb8bb1f0cef760..ddaf0af74d9b3028b3fff62454fa80fa07b33de4 100644 (file)
@@ -104,6 +104,8 @@ _rl_scxt_alloc (type, flags)
 
   cxt->save_undo_list = 0;
 
+  cxt->keymap = _rl_keymap;
+
   cxt->history_pos = 0;
   cxt->direction = 0;
 
@@ -336,10 +338,24 @@ _rl_isearch_dispatch (cxt, c)
       return -1;
     }
 
+#if 0
+  /* If we are moving into a new keymap, modify cxt->keymap and go on.
+     This can be a problem if c == ESC and we want to terminate the
+     incremental search */
+  if (c >= 0 && cxt->keymap[c].type == ISKMAP && strchr (cxt->search_terminators, cxt->lastc) == 0)
+    {
+      cxt->keymap = FUNCTION_TO_KEYMAP (cxt->keymap, c);
+      cxt->sflags |= SF_CHGKMAP;
+      /* XXX - we should probably save this sequence, so we can do
+        something useful if this doesn't end up mapping to a command. */
+      return 1;
+    }
+#endif
+
   /* Translate the keys we do something with to opcodes. */
-  if (c >= 0 && _rl_keymap[c].type == ISFUNC)
+  if (c >= 0 && cxt->keymap[c].type == ISFUNC)
     {
-      f = _rl_keymap[c].function;
+      f = cxt->keymap[c].function;
 
       if (f == rl_reverse_search_history)
        cxt->lastc = (cxt->sflags & SF_REVERSE) ? -1 : -2;
@@ -359,7 +375,7 @@ _rl_isearch_dispatch (cxt, c)
      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))
+  if (cxt->lastc > 0 && 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
@@ -399,6 +415,16 @@ _rl_isearch_dispatch (cxt, c)
        return (0);
       }
 
+#if 0
+  /* If we changed the keymap earlier while translating a key sequence into
+     a command, restore it now that we've succeeded. */
+  if (cxt->sflags & SF_CHGKMAP)
+    {
+      cxt->keymap = _rl_keymap;
+      cxt->sflags &= ~SF_CHGKMAP;
+    }
+#endif
+
   /* Now dispatch on the character.  `Opcodes' affect the search string or
      state.  Other characters are added to the string.  */
   switch (cxt->lastc)
diff --git a/lib/readline/isearch.c~ b/lib/readline/isearch.c~
new file mode 100644 (file)
index 0000000..b9c176f
--- /dev/null
@@ -0,0 +1,700 @@
+/* isearch.c - incremental searching */
+
+/* **************************************************************** */
+/*                                                                 */
+/*                     I-Search and Searching                      */
+/*                                                                 */
+/* **************************************************************** */
+
+/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+
+   This file is part of the GNU Readline Library (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 3 of the License, 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.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#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.  Now part of isearch context. */
+/* static char *prev_line_found; */
+
+/* Last search string and its length. */
+static char *last_isearch_string;
+static int last_isearch_string_len;
+
+static char * const 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->keymap = _rl_keymap;
+
+  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);
+
+  xfree (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);
+  xfree (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;
+
+  if (c < 0)
+    {
+      cxt->sflags |= SF_FAILED;
+      cxt->history_pos = cxt->last_found_line;
+      return -1;
+    }
+
+#if 0
+  /* If we are moving into a new keymap, modify cxt->keymap and go on */
+  if (c >= 0 && cxt->keymap[c].type == ISKMAP && strchr (cxt->search_terminators, cxt->lastc) == 0)
+    {
+      cxt->keymap = FUNCTION_TO_KEYMAP (cxt->keymap, c);
+      cxt->sflags |= SF_CHGKMAP;
+      /* XXX - we should probably save this sequence, so we can do
+        something useful if this doesn't end up mapping to a command.
+        This can be a problem if c == ESC and we want to terminate
+        the incremental search */
+      return 1;
+    }
+#endif
+
+  /* Translate the keys we do something with to opcodes. */
+  if (c >= 0 && cxt->keymap[c].type == ISFUNC)
+    {
+      f = cxt->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 (cxt->lastc > 0 && 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 LASTC; 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);
+      }
+
+#if 0
+  /* If we changed the keymap earlier while translating a key sequence into
+     a command, restore it now that we've succeeded. */
+  if (cxt->sflags & SF_CHGKMAP)
+    {
+      cxt->keymap = _rl_keymap;
+      cxt->sflags &= ~SF_CHGKMAP;
+    }
+#endif
+
+  /* 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
index b2e3f6b123040ba26aada13fb809c7f028b9b2b8..312aca82532d0990e0a58d5b7de212fa690e026d 100644 (file)
@@ -56,6 +56,7 @@
 #define SF_REVERSE             0x01
 #define SF_FOUND               0x02
 #define SF_FAILED              0x04
+#define SF_CHGKMAP             0x08
 
 typedef struct  __rl_search_context
 {
@@ -79,6 +80,8 @@ typedef struct  __rl_search_context
 
   UNDO_LIST *save_undo_list;
 
+  Keymap keymap;       /* used when dispatching commands in search string */
+
   int history_pos;
   int direction;
 
index 655a33a6235f3ada7f91829a6fb5e033b317325d..3f657c7853cc3eb917912f217374953650154884 100644 (file)
@@ -79,6 +79,8 @@ typedef struct  __rl_search_context
 
   UNDO_LIST *save_undo_list;
 
+  Keymap keymap;       /* used when dispatching commands in search string */
+
   int history_pos;
   int direction;
 
@@ -495,6 +497,6 @@ extern int _rl_undo_group_level;
 
 /* vi_mode.c */
 extern int _rl_vi_last_command;
-extern _rl_vimotion_cxt *_rl_vimv_cxt;
+extern _rl_vimotion_cxt *_rl_vimvcxt;
 
 #endif /* _RL_PRIVATE_H_ */