commit bash-20090730 snapshot

This commit is contained in:
Chet Ramey
2011-12-08 20:13:24 -05:00
parent dfc21851b5
commit 9dd88db757
38 changed files with 7519 additions and 68 deletions
+79
View File
@@ -8266,3 +8266,82 @@ execute_cmd.c
trap for the eval/source/command builtins in the same way as we
temporarily disable and restore the setting of the -e option.
Fixes bug reported by Henning Garus <henning.garus@googlemail.com>
7/27
----
shell.c
- add fflush(stdout) and fflush(stderr) to exit_shell before closing
any file descriptors at exit time (e.g., coproc pipes)
7/30
----
lib/readline/complete.c
- new function rl_backward_menu_complete, just passes negative count
argument to rl_menu_complete
- change rl_menu_complete to act appropriately if rl_last_command is
rl_backward_menu_complete, so we can cycle forward and backward
through the list of completions
lib/readline/doc/{readline.3,rluser.texi},doc/bash.1
- document new "menu-complete-backward" bindable readline function.
Suggested by Jason Spiro <jasonspiro04@gmail.com>
lib/readline/vi_keymap.c
- add binding of C-n to menu-complete and C-p to menu-complete-backward
in vi-insert keymap, as suggested by Jason Spiro
<jasonspiro04@gmail.com>
pcomplete.c
- fixed a bug in programmable_completions: the options it returned from
the compspec it found were set before generating the completions,
which meant that any changes made by "compopt" were overridden and
only in effect for the duration of the executing shell function
rather than the entire completion. Fixes bug reported by Ville
Skytta <ville.skytta@iki.fi>
7/31
----
lib/readline/keymaps.c
- fixed memory leak in rl_discard_keymap by freeing storage associated
with hierarchical keymaps
- new convenience function, rl_free_keymap, that calls rl_discard_keymap
and frees the keymap passed as an argument
lib/readline/util.c
- new bindable keymap function, _rl_null_function, to be used internally
lib/readline/rlprivate.h
- extern declaration for _rl_null_function
lib/readline/bind.c
- fix rl_generic_bind in the case where we are trying to override a
keymap with a null function (e.g., when trying to unbind it). We
can't use a NULL function pointer in ANYOTHERKEY since that's
indistinguishable from the keymap not having been overridden at all.
We use _rl_null_function instead, which simply does nothing. We
could add an rl_ding to it later. Fixes problem with hitting ESC
repeatedly while in vi command mode reported by James Rowell
<jrjimmy801-misc1@yahoo.com>
builtins/bind.def
- call rl_bind_keyseq instead of rl_set_key for -r option
lib/readline/readline.c
- Set vi_movement_keymap[ESC] to _rl_null_function after binding the
arrow keys in bind_arrow_keys() to allow vi-mode users to hit ESC
multiple times in vi command mode while still allowing the arrow
keys to work
8/2
---
bashline.c
- fix clear_hostname_list by setting hostname_list_initialized to 0
after freeing all list members. Fixes bug reported by Freddy
Vulto <fvulto@gmail.com>
lib/readline/display.c
- in update_line, if we copy data from one line to another because we
are wrapping a multibyte character from, say, the first line to the
second, we need to update OMAX and the line indices to account for
the moved data. Bug report and fix from Martin Hamrle
<martin.hamrle@gmail.com>
+80
View File
@@ -8258,3 +8258,83 @@ lib/readline/complete.c
and unset RL_STATE_COMPLETING while generating the list of matches.
Fixes debian bug #538013 reported by Jerome Reybert
<jreybert@gmail.com>
7/25
----
execute_cmd.c
- change execute_builtin to temporarily turn off and restore the ERR
trap for the eval/source/command builtins in the same way as we
temporarily disable and restore the setting of the -e option.
Fixes bug reported by Henning Garus <henning.garus@googlemail.com>
7/27
----
shell.c
- add fflush(stdout) and fflush(stderr) to exit_shell before closing
any file descriptors at exit time (e.g., coproc pipes)
7/30
----
lib/readline/complete.c
- new function rl_backward_menu_complete, just passes negative count
argument to rl_menu_complete
- change rl_menu_complete to act appropriately if rl_last_command is
rl_backward_menu_complete, so we can cycle forward and backward
through the list of completions
lib/readline/doc/{readline.3,rluser.texi},doc/bash.1
- document new "menu-complete-backward" bindable readline function.
Suggested by Jason Spiro <jasonspiro04@gmail.com>
lib/readline/vi_keymap.c
- add binding of C-n to menu-complete and C-p to menu-complete-backward
in vi-insert keymap, as suggested by Jason Spiro
<jasonspiro04@gmail.com>
pcomplete.c
- fixed a bug in programmable_completions: the options it returned from
the compspec it found were set before generating the completions,
which meant that any changes made by "compopt" were overridden and
only in effect for the duration of the executing shell function
rather than the entire completion. Fixes bug reported by Ville
Skytta <ville.skytta@iki.fi>
7/31
----
lib/readline/keymaps.c
- fixed memory leak in rl_discard_keymap by freeing storage associated
with hierarchical keymaps
- new convenience function, rl_free_keymap, that calls rl_discard_keymap
and frees the keymap passed as an argument
lib/readline/util.c
- new bindable keymap function, _rl_null_function, to be used internally
lib/readline/rlprivate.h
- extern declaration for _rl_null_function
lib/readline/bind.c
- fix rl_generic_bind in the case where we are trying to override a
keymap with a null function (e.g., when trying to unbind it). We
can't use a NULL function pointer in ANYOTHERKEY since that's
indistinguishable from the keymap not having been overridden at all.
We use _rl_null_function instead, which simply does nothing. We
could add an rl_ding to it later. Fixes problem with hitting ESC
repeatedly while in vi command mode reported by James Rowell
<jrjimmy801-misc1@yahoo.com>
builtins/bind.def
- call rl_bind_keyseq instead of rl_set_key for -r option
lib/readline/readline.c
- Set vi_movement_keymap[ESC] to _rl_null_function after binding the
arrow keys in bind_arrow_keys() to allow vi-mode users to hit ESC
multiple times in vi command mode while still allowing the arrow
keys to work
8/2
---
bashline.c
- fix clear_hostname_list by setting hostname_list_initialized to 0
after freeing all list members. Fixes bug reported by Freddy
Vulto <fvulto@gmail.com>
+1 -1
View File
@@ -752,7 +752,7 @@ clear_hostname_list ()
return;
for (i = 0; i < hostname_list_length; i++)
free (hostname_list[i]);
hostname_list_length = 0;
hostname_list_length = hostname_list_initialized = 0;
}
/* Return a NULL terminated list of hostnames which begin with TEXT.
+3
View File
@@ -82,6 +82,9 @@
extern int bash_brace_completion __P((int, int));
#endif /* BRACE_COMPLETION */
/* To avoid including curses.h/term.h/termcap.h and that whole mess. */
extern int tputs __P((const char *string, int nlines, int (*outx)(int)));
/* Forward declarations */
/* Functions bound to keys in Readline for Bash users. */
+1 -1
View File
@@ -255,7 +255,7 @@ bind_builtin (list)
if ((flags & RFLAG) && remove_seq)
{
if (rl_set_key (remove_seq, (rl_command_func_t *)NULL, rl_get_keymap ()) != 0)
if (rl_bind_keyseq (remove_seq, (rl_command_func_t *)NULL) != 0)
{
builtin_error (_("`%s': cannot unbind"), remove_seq);
BIND_RETURN (EXECUTION_FAILURE);
+332
View File
@@ -0,0 +1,332 @@
This file is bind.def, from which is created bind.c.
It implements the builtin "bind" in Bash.
Copyright (C) 1987-2009 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 3 of the License, 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. If not, see <http://www.gnu.org/licenses/>.
$PRODUCES bind.c
#include <config.h>
$BUILTIN bind
$DEPENDS_ON READLINE
$FUNCTION bind_builtin
$SHORT_DOC bind [-lpvsPVS] [-m keymap] [-f filename] [-q name] [-u name] [-r keyseq] [-x keyseq:shell-command] [keyseq:readline-function or readline-command]
Set Readline key bindings and variables.
Bind a key sequence to a Readline function or a macro, or set a
Readline variable. The non-option argument syntax is equivalent to
that found in ~/.inputrc, but must be passed as a single argument:
e.g., bind '"\C-x\C-r": re-read-init-file'.
Options:
-m keymap Use KEYMAP as the keymap for the duration of this
command. Acceptable keymap names are emacs,
emacs-standard, emacs-meta, emacs-ctlx, vi, vi-move,
vi-command, and vi-insert.
-l List names of functions.
-P List function names and bindings.
-p List functions and bindings in a form that can be
reused as input.
-S List key sequences that invoke macros and their values
-s List key sequences that invoke macros and their values
in a form that can be reused as input.
-V List variable names and values
-v List variable names and values in a form that can
be reused as input.
-q function-name Query about which keys invoke the named function.
-u function-name Unbind all keys which are bound to the named function.
-r keyseq Remove the binding for KEYSEQ.
-f filename Read key bindings from FILENAME.
-x keyseq:shell-command Cause SHELL-COMMAND to be executed when
KEYSEQ is entered.
Exit Status:
bind returns 0 unless an unrecognized option is given or an error occurs.
$END
#if defined (READLINE)
#if defined (HAVE_UNISTD_H)
# ifdef _MINIX
# include <sys/types.h>
# endif
# include <unistd.h>
#endif
#include <stdio.h>
#include <errno.h>
#if !defined (errno)
extern int errno;
#endif /* !errno */
#include <readline/readline.h>
#include <readline/history.h>
#include "../bashintl.h"
#include "../shell.h"
#include "../bashline.h"
#include "bashgetopt.h"
#include "common.h"
static int query_bindings __P((char *));
static int unbind_command __P((char *));
extern int no_line_editing;
#define BIND_RETURN(x) do { return_code = x; goto bind_exit; } while (0)
#define LFLAG 0x0001
#define PFLAG 0x0002
#define FFLAG 0x0004
#define VFLAG 0x0008
#define QFLAG 0x0010
#define MFLAG 0x0020
#define RFLAG 0x0040
#define PPFLAG 0x0080
#define VVFLAG 0x0100
#define SFLAG 0x0200
#define SSFLAG 0x0400
#define UFLAG 0x0800
#define XFLAG 0x1000
int
bind_builtin (list)
WORD_LIST *list;
{
int return_code;
Keymap kmap, saved_keymap;
int flags, opt;
char *initfile, *map_name, *fun_name, *unbind_name, *remove_seq, *cmd_seq;
if (no_line_editing)
{
#if 0
builtin_error (_("line editing not enabled"));
return (EXECUTION_FAILURE);
#else
builtin_warning (_("line editing not enabled"));
#endif
}
kmap = saved_keymap = (Keymap) NULL;
flags = 0;
initfile = map_name = fun_name = unbind_name = remove_seq = (char *)NULL;
return_code = EXECUTION_SUCCESS;
if (bash_readline_initialized == 0)
initialize_readline ();
begin_unwind_frame ("bind_builtin");
unwind_protect_var (rl_outstream);
rl_outstream = stdout;
reset_internal_getopt ();
while ((opt = internal_getopt (list, "lvpVPsSf:q:u:m:r:x:")) != EOF)
{
switch (opt)
{
case 'l':
flags |= LFLAG;
break;
case 'v':
flags |= VFLAG;
break;
case 'p':
flags |= PFLAG;
break;
case 'f':
flags |= FFLAG;
initfile = list_optarg;
break;
case 'm':
flags |= MFLAG;
map_name = list_optarg;
break;
case 'q':
flags |= QFLAG;
fun_name = list_optarg;
break;
case 'u':
flags |= UFLAG;
unbind_name = list_optarg;
break;
case 'r':
flags |= RFLAG;
remove_seq = list_optarg;
break;
case 'V':
flags |= VVFLAG;
break;
case 'P':
flags |= PPFLAG;
break;
case 's':
flags |= SFLAG;
break;
case 'S':
flags |= SSFLAG;
break;
case 'x':
flags |= XFLAG;
cmd_seq = list_optarg;
break;
default:
builtin_usage ();
BIND_RETURN (EX_USAGE);
}
}
list = loptend;
/* First, see if we need to install a special keymap for this
command. Then start on the arguments. */
if ((flags & MFLAG) && map_name)
{
kmap = rl_get_keymap_by_name (map_name);
if (!kmap)
{
builtin_error (_("`%s': invalid keymap name"), map_name);
BIND_RETURN (EXECUTION_FAILURE);
}
}
if (kmap)
{
saved_keymap = rl_get_keymap ();
rl_set_keymap (kmap);
}
/* XXX - we need to add exclusive use tests here. It doesn't make sense
to use some of these options together. */
/* Now hack the option arguments */
if (flags & LFLAG)
rl_list_funmap_names ();
if (flags & PFLAG)
rl_function_dumper (1);
if (flags & PPFLAG)
rl_function_dumper (0);
if (flags & SFLAG)
rl_macro_dumper (1);
if (flags & SSFLAG)
rl_macro_dumper (0);
if (flags & VFLAG)
rl_variable_dumper (1);
if (flags & VVFLAG)
rl_variable_dumper (0);
if ((flags & FFLAG) && initfile)
{
if (rl_read_init_file (initfile) != 0)
{
builtin_error (_("%s: cannot read: %s"), initfile, strerror (errno));
BIND_RETURN (EXECUTION_FAILURE);
}
}
if ((flags & QFLAG) && fun_name)
return_code = query_bindings (fun_name);
if ((flags & UFLAG) && unbind_name)
return_code = unbind_command (unbind_name);
if ((flags & RFLAG) && remove_seq)
{
if (rl_set_key (remove_seq, (rl_command_func_t *)NULL, rl_get_keymap ()) != 0)
{
builtin_error (_("`%s': cannot unbind"), remove_seq);
BIND_RETURN (EXECUTION_FAILURE);
}
}
if (flags & XFLAG)
return_code = bind_keyseq_to_unix_command (cmd_seq);
/* Process the rest of the arguments as binding specifications. */
while (list)
{
rl_parse_and_bind (list->word->word);
list = list->next;
}
bind_exit:
if (saved_keymap)
rl_set_keymap (saved_keymap);
run_unwind_frame ("bind_builtin");
return (sh_chkwrite (return_code));
}
static int
query_bindings (name)
char *name;
{
rl_command_func_t *function;
char **keyseqs;
int j;
function = rl_named_function (name);
if (function == 0)
{
builtin_error (_("`%s': unknown function name"), name);
return EXECUTION_FAILURE;
}
keyseqs = rl_invoking_keyseqs (function);
if (!keyseqs)
{
printf (_("%s is not bound to any keys.\n"), name);
return EXECUTION_FAILURE;
}
printf (_("%s can be invoked via "), name);
for (j = 0; j < 5 && keyseqs[j]; j++)
printf ("\"%s\"%s", keyseqs[j], keyseqs[j + 1] ? ", " : ".\n");
if (keyseqs[j])
printf ("...\n");
strvec_dispose (keyseqs);
return EXECUTION_SUCCESS;
}
static int
unbind_command (name)
char *name;
{
rl_command_func_t *function;
function = rl_named_function (name);
if (function == 0)
{
builtin_error (_("`%s': unknown function name"), name);
return EXECUTION_FAILURE;
}
rl_unbind_function_in_map (function, rl_get_keymap ());
return EXECUTION_SUCCESS;
}
#endif /* READLINE */
+6 -2
View File
@@ -3164,7 +3164,11 @@ RREEAADDLLIINNEE
moves _n positions forward in the list of matches; a negative
argument may be used to move backward through the list. This
command is intended to be bound to TTAABB, but is unbound by
default.
default.cc
mmeennuu--ccoommpplleettee--kkrrdd
Identicwwal to mmeennuu--ccoommpplleettee, but moves backward through the list
of possible completions, as if mmeennuu--ccoommpplleettee had been given a
negative argument. This command is unbound by default.
ddeelleettee--cchhaarr--oorr--lliisstt
Deletes the character under the cursor if not at the beginning
or end of the line (like ddeelleettee--cchhaarr). If at the end of the
@@ -5238,4 +5242,4 @@ BBUUGGSS
GNU Bash-4.0 2009 June 17 BASH(1)
GNU Bash-4.0 2009 July 30 BASH(1)
+9 -3
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Wed Jun 17 08:51:11 EDT 2009
.\" Last Change: Thu Jul 30 09:25:13 EDT 2009
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2009 June 17" "GNU Bash-4.0"
.TH BASH 1 "2009 July 30" "GNU Bash-4.0"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -1847,7 +1847,8 @@ adds the contents of the new file to the existing list.
If
.SM
.B HOSTFILE
is set, but has no value, \fBbash\fP attempts to read
is set, but has no value, or does not name a readable file,
\fBbash\fP attempts to read
.FN /etc/hosts
to obtain the list of possible hostname completions.
When
@@ -5494,6 +5495,11 @@ through the list.
This command is intended to be bound to \fBTAB\fP, but is unbound
by default.
.TP
.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.
.TP
.B delete\-char\-or\-list
Deletes the character under the cursor if not at the beginning or
end of the line (like \fBdelete\-char\fP).
+11 -5
View File
@@ -5,12 +5,12 @@
.\" Case Western Reserve University
.\" chet@po.cwru.edu
.\"
.\" Last Change: Tue May 26 17:03:43 EDT 2009
.\" Last Change: Thu Jul 30 09:25:13 EDT 2009
.\"
.\" bash_builtins, strip all but Built-Ins section
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2009 May 26" "GNU Bash-4.0"
.TH BASH 1 "2009 July 30" "GNU Bash-4.0"
.\"
.\" There's some problem with having a `@'
.\" in a tagged paragraph with the BSD man macros.
@@ -5494,6 +5494,11 @@ through the list.
This command is intended to be bound to \fBTAB\fP, but is unbound
by default.
.TP
.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.
.TP
.B delete\-char\-or\-list
Deletes the character under the cursor if not at the beginning or
end of the line (like \fBdelete\-char\fP).
@@ -8273,9 +8278,10 @@ and group ids to be set to the real user and group ids.
Exit after reading and executing one command.
.TP 8
.B \-u
Treat unset variables as an error when performing
Treat unset variables and parameters other than the special
parameters "@" and "*" as an error when performing
parameter expansion. If expansion is attempted on an
unset variable, the shell prints an error message, and,
unset variable or parameter, the shell prints an error message, and,
if not interactive, exits with a non-zero status.
.TP 8
.B \-v
@@ -8942,7 +8948,7 @@ These are the same conditions obeyed by the \fBerrexit\fP option.
.if n .sp 1
Signals ignored upon entry to the shell cannot be trapped or reset.
Trapped signals that are not being ignored are reset to their original
values in a subshell or subshell environment.
values in a subshell or subshell environment when one is created.
The return status is false if any
.I sigspec
is invalid; otherwise
+2 -1
View File
@@ -4974,7 +4974,8 @@ is running;
the next time hostname completion is attempted after the
value is changed, Bash adds the contents of the new file to the
existing list.
If @env{HOSTFILE} is set, but has no value, Bash attempts to read
If @env{HOSTFILE} is set, but has no value, or does not name a readable file,
Bash attempts to read
@file{/etc/hosts} to obtain the list of possible hostname completions.
When @env{HOSTFILE} is unset, the hostname list is cleared.
+3 -2
View File
@@ -3196,7 +3196,7 @@ These are the same conditions obeyed by the @code{errexit} option.
Signals ignored upon entry to the shell cannot be trapped or reset.
Trapped signals that are not being ignored are reset to their original
values in a subshell or subshell environment.
values in a subshell or subshell environment when one is created.
The return status is zero unless a @var{sigspec} does not specify a
valid signal.
@@ -4150,7 +4150,8 @@ and group ids to be set to the real user and group ids.
Exit after reading and executing one command.
@item -u
Treat unset variables as an error when performing parameter expansion.
Treat unset variables and parameters other than the special parameters
@samp{@@} or @samp{*} as an error when performing parameter expansion.
An error message will be written to the standard error, and a non-interactive
shell will exit.
+7
View File
@@ -418,6 +418,13 @@ rl_generic_bind (type, keyseq, data, map)
{
map = FUNCTION_TO_KEYMAP (map, ic);
ic = ANYOTHERKEY;
/* If we're trying to override a keymap with a null function
(e.g., trying to unbind it), we can't use a null pointer
here because that's indistinguishable from having not been
overridden. We use a special bindable function that does
nothing. */
if (type == ISFUNC && data == 0)
data = (char *)_rl_null_function;
}
map[ic].function = KEYMAP_TO_FUNCTION (data);
+2367
View File
File diff suppressed because it is too large Load Diff
+10 -1
View File
@@ -2330,7 +2330,7 @@ rl_menu_complete (count, ignore)
/* The first time through, we generate the list of matches and set things
up to insert them. */
if (rl_last_func != rl_menu_complete || full_completion)
if ((rl_last_func != rl_menu_complete && rl_last_func != rl_backward_menu_complete) || full_completion)
{
/* Clean up from previous call, if any. */
FREE (orig_text);
@@ -2470,3 +2470,12 @@ rl_menu_complete (count, ignore)
completion_changed_buffer = 1;
return (0);
}
int
rl_backward_menu_complete (count, key)
int count, key;
{
/* Positive arguments to backward-menu-complete translate into negative
arguments for menu-complete, and vice versa. */
return (rl_menu_complete (-count, key));
}
+7 -4
View File
@@ -1319,7 +1319,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (tempwidth > 0)
{
int count;
int count, i;
bytes = ret;
for (count = 0; count < bytes; count++)
putc (new[count], rl_outstream);
@@ -1330,10 +1330,13 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (ret != 0 && bytes != 0)
{
if (MB_INVALIDCH (ret))
memmove (old+bytes, old+1, strlen (old+1));
else
memmove (old+bytes, old+ret, strlen (old+ret));
ret = 1;
memmove (old+bytes, old+ret, strlen (old+ret));
memcpy (old, new, bytes);
/* Fix up indices if we copy data from one line to another */
omax += bytes - ret;
for (i = current_line+1; i < inv_botlin+1; i++)
vis_lbreaks[i] += bytes - ret;
}
}
else
+54 -22
View File
@@ -960,6 +960,11 @@ rl_redisplay ()
#define VIS_LINE(line) ((line) > _rl_vis_botlin) ? "" : VIS_CHARS(line)
#define INV_LINE(line) (invisible_line + inv_lbreaks[line])
#define OLD_CPOS_IN_PROMPT() (cpos_adjusted == 0 && \
_rl_last_c_pos != o_cpos && \
_rl_last_c_pos > wrap_offset && \
o_cpos < prompt_last_invisible)
/* For each line in the buffer, do the updating display. */
for (linenum = 0; linenum <= inv_botlin; linenum++)
{
@@ -982,13 +987,7 @@ rl_redisplay ()
time update_line is called, then we can assume in our
calculations that o_cpos does not need to be adjusted by
wrap_offset. */
/* XXX - if this is changed, change the version down below in
the horizontal scrolling section as well. */
if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
cpos_adjusted == 0 &&
_rl_last_c_pos != o_cpos &&
_rl_last_c_pos > wrap_offset &&
o_cpos < prompt_last_invisible)
if (linenum == 0 && (MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
else if (linenum == prompt_last_screen_line && prompt_physical_chars > _rl_screenwidth &&
(MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
@@ -1205,14 +1204,8 @@ rl_redisplay ()
_rl_screenwidth + (lmargin ? 0 : wrap_offset),
0);
/* This should be identical to the code above in the non-horizontal
scrolling section. */
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
cpos_adjusted == 0 &&
_rl_last_c_pos != o_cpos &&
_rl_last_c_pos > wrap_offset &&
o_cpos < prompt_last_invisible)
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) && OLD_CPOS_IN_PROMPT())
_rl_last_c_pos -= prompt_invis_chars_first_line; /* XXX - was wrap_offset */
/* If the visible new line is shorter than the old, but the number
of invisible characters is greater, and we are at the end of
@@ -1326,7 +1319,7 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (tempwidth > 0)
{
int count;
int count, i;
bytes = ret;
for (count = 0; count < bytes; count++)
putc (new[count], rl_outstream);
@@ -1337,10 +1330,15 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (ret != 0 && bytes != 0)
{
if (MB_INVALIDCH (ret))
memmove (old+bytes, old+1, strlen (old+1));
else
memmove (old+bytes, old+ret, strlen (old+ret));
ret = 1;
memmove (old+bytes, old+ret, strlen (old+ret));
memcpy (old, new, bytes);
#if 0
/* Fix up indices if we copy data from one line to another */
omax += bytes - ret;
for (i = current_line+1; i < inv_botlin+1; i++)
vis_lbreaks[i] += bytes - ret;
#endif
}
}
else
@@ -1906,6 +1904,7 @@ _rl_move_cursor_relative (new, data)
register int i;
int woff; /* number of invisible chars on current line */
int cpos, dpos; /* current and desired cursor positions */
int adjust;
woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
cpos = _rl_last_c_pos;
@@ -1921,15 +1920,34 @@ _rl_move_cursor_relative (new, data)
as long as we are past them and they are counted by _rl_col_width. */
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
dpos = _rl_col_width (data, 0, new);
adjust = 1;
/* Try to short-circuit common cases and eliminate a bunch of multibyte
character function calls. */
/* 1. prompt string */
if (new == local_prompt_len && memcmp (data, local_prompt, new) == 0)
{
dpos = prompt_visible_length;
cpos_adjusted = 1;
adjust = 0;
}
/* 2. prompt_string + line contents */
else if (new > local_prompt_len && local_prompt && memcmp (data, local_prompt, local_prompt_len) == 0)
{
dpos = prompt_visible_length + _rl_col_width (data, local_prompt_len, new);
cpos_adjusted = 1;
adjust = 0;
}
else
dpos = _rl_col_width (data, 0, new);
/* Use NEW when comparing against the last invisible character in the
prompt string, since they're both buffer indices and DPOS is a
desired display position. */
if ((new > prompt_last_invisible) || /* XXX - don't use woff here */
if (adjust && ((new > prompt_last_invisible) || /* XXX - don't use woff here */
(prompt_physical_chars >= _rl_screenwidth &&
_rl_last_v_pos == prompt_last_screen_line &&
wrap_offset >= woff && dpos >= woff &&
new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset)))
new > (prompt_last_invisible-(_rl_screenwidth*_rl_last_v_pos)-wrap_offset))))
/* XXX last comparison might need to be >= */
{
dpos -= woff;
@@ -2593,6 +2611,20 @@ _rl_ttymsg ("_rl_col_width: called with MB_CUR_MAX == 1");
point = 0;
max = end;
/* Try to short-circuit common cases. The adjustment to remove wrap_offset
is done by the caller. */
/* 1. prompt string */
if (start == 0 && end == local_prompt_len && memcmp (str, local_prompt, local_prompt_len) == 0)
return (prompt_visible_length + wrap_offset);
/* 2. prompt string + line contents */
else if (start == 0 && end > local_prompt_len && local_prompt && memcmp (str, local_prompt, local_prompt_len) == 0)
{
tmp = prompt_visible_length + wrap_offset;
/* XXX - try to call ourselves recursively with non-prompt portion */
tmp += _rl_col_width (str, local_prompt_len, end);
return (tmp);
}
while (point < start)
{
tmp = mbrlen (str + point, max, &ps);
+7 -2
View File
@@ -6,9 +6,9 @@
.\" Case Western Reserve University
.\" chet@ins.CWRU.Edu
.\"
.\" Last Change: Thu May 8 09:29:59 EDT 2008
.\" Last Change: Thu Jul 30 09:22:50 EDT 2009
.\"
.TH READLINE 3 "2008 May 8" "GNU Readline 6.0"
.TH READLINE 3 "2009 Jul 30" "GNU Readline 6.0"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
@@ -924,6 +924,11 @@ through the list.
This command is intended to be bound to \fBTAB\fP, but is unbound
by default.
.TP
.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.
.TP
.B delete\-char\-or\-list
Deletes the character under the cursor if not at the beginning or
end of the line (like \fBdelete-char\fP).
+8 -2
View File
@@ -622,7 +622,7 @@ Readline which keymap to use.
@deftypefun Keymap rl_make_bare_keymap (void)
Returns a new, empty keymap. The space for the keymap is allocated with
@code{malloc()}; the caller should free it by calling
@code{rl_discard_keymap()} when done.
@code{rl_free_keymap()} when done.
@end deftypefun
@deftypefun Keymap rl_copy_keymap (Keymap map)
@@ -636,7 +636,13 @@ the Meta digits bound to produce numeric arguments.
@end deftypefun
@deftypefun void rl_discard_keymap (Keymap keymap)
Free the storage associated with @var{keymap}.
Free the storage associated with the data in @var{keymap}.
The caller should free @var{keymap}.
@end deftypefun
@deftypefun void rl_free_keymap (Keymap keymap)
Free all storage associated with @var{keymap}. This calls
@code{rl_discard_keymap} to free subordindate keymaps and macros.
@end deftypefun
Readline has several internal keymaps. These functions allow you to
File diff suppressed because it is too large Load Diff
+5
View File
@@ -1292,6 +1292,11 @@ through the list.
This command is intended to be bound to @key{TAB}, but is unbound
by default.
@item menu-complete-backward ()
Identical to @code{menu-complete}, but moves backward through the list
of possible completions, as if @code{menu-complete} had been given a
negative argument.
@item delete-char-or-list ()
Deletes the character under the cursor if not at the beginning or
end of the line (like @code{delete-char}).
+3 -3
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2009 Free Software Foundation, Inc.
@set EDITION 6.0
@set VERSION 6.0
@set UPDATED 28 October 2008
@set UPDATED-MONTH October 2008
@set UPDATED 31 July 2009
@set UPDATED-MONTH July 2009
@set LASTCHANGE Tue Oct 28 11:25:24 EDT 2008
@set LASTCHANGE Fri Jul 31 20:18:23 EDT 2009
+10
View File
@@ -0,0 +1,10 @@
@ignore
Copyright (C) 1988-2009 Free Software Foundation, Inc.
@end ignore
@set EDITION 6.0
@set VERSION 6.0
@set UPDATED 30 July 2009
@set UPDATED-MONTH July 2009
@set LASTCHANGE Thu Jul 30 09:23:36 EDT 2009
+1
View File
@@ -105,6 +105,7 @@ static const FUNMAP default_funmap[] = {
{ "kill-region", rl_kill_region },
{ "kill-word", rl_kill_word },
{ "menu-complete", rl_menu_complete },
{ "menu-complete-backward", rl_backward_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 },
+15 -3
View File
@@ -57,8 +57,9 @@ Keymap
rl_make_bare_keymap ()
{
register int i;
Keymap keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
Keymap keymap;
keymap = (Keymap)xmalloc (KEYMAP_SIZE * sizeof (KEYMAP_ENTRY));
for (i = 0; i < KEYMAP_SIZE; i++)
{
keymap[i].type = ISFUNC;
@@ -76,7 +77,8 @@ rl_make_bare_keymap ()
return (keymap);
}
/* Return a new keymap which is a copy of MAP. */
/* Return a new keymap which is a copy of MAP. Just copies pointers, does
not copy text of macros or descend into child keymaps. */
Keymap
rl_copy_keymap (map)
Keymap map;
@@ -128,7 +130,7 @@ rl_discard_keymap (map)
{
int i;
if (!map)
if (map == 0)
return;
for (i = 0; i < KEYMAP_SIZE; i++)
@@ -140,6 +142,7 @@ rl_discard_keymap (map)
case ISKMAP:
rl_discard_keymap ((Keymap)map[i].function);
free ((char *)map[i].function);
break;
case ISMACR:
@@ -148,3 +151,12 @@ rl_discard_keymap (map)
}
}
}
/* Convenience function that discards, then frees, MAP. */
void
rl_free_keymap (map)
Keymap map;
{
rl_discard_keymap (map);
free ((char *)map);
}
+150
View File
@@ -0,0 +1,150 @@
/* keymaps.c -- Functions and keymaps for the GNU Readline library. */
/* Copyright (C) 1988,1989-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
#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;
}
}
}
+4
View File
@@ -1169,6 +1169,10 @@ bind_arrow_keys ()
#if defined (VI_MODE)
bind_arrow_keys_internal (vi_movement_keymap);
/* Unbind vi_movement_keymap[ESC] to allow users to repeatedly hit ESC
in vi command mode while still allowing the arrow keys to work. */
if (vi_movement_keymap[ESC].type == ISKMAP)
rl_bind_keyseq_in_map ("\033", (rl_command_func_t *)NULL, vi_movement_keymap);
bind_arrow_keys_internal (vi_insertion_keymap);
#endif
}
File diff suppressed because it is too large Load Diff
+1
View File
@@ -151,6 +151,7 @@ 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));
extern int rl_backward_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));
+1
View File
@@ -349,6 +349,7 @@ extern void _rl_trace ();
extern int _rl_tropen PARAMS((void));
extern int _rl_abort_internal PARAMS((void));
extern int _rl_null_function PARAMS((int, int));
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));
+2
View File
@@ -300,6 +300,8 @@ extern void _rl_signal_handler PARAMS((int));
extern void _rl_block_sigint PARAMS((void));
extern void _rl_release_sigint PARAMS((void));
extern void _rl_block_sigwinch PARAMS((void));
extern void _rl_release_sigwinch PARAMS((void));
/* terminal.c */
extern void _rl_get_screen_size PARAMS((int, int));
+7
View File
@@ -120,6 +120,13 @@ rl_abort (count, key)
return (_rl_abort_internal ());
}
int
_rl_null_function (count, key)
int count, key;
{
return 0;
}
int
rl_tty_status (count, key)
int count, key;
+512
View File
@@ -0,0 +1,512 @@
/* util.c -- readline utility functions */
/* 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 <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"
/* **************************************************************** */
/* */
/* Utility Functions */
/* */
/* **************************************************************** */
/* Return 0 if C is not a member of the class of characters that belong
in words, or 1 if it is. */
int _rl_allow_pathname_alphabetic_chars = 0;
static const char * const pathname_alphabetic_chars = "/-_=~.#$";
int
rl_alphabetic (c)
int c;
{
if (ALPHABETIC (c))
return (1);
return (_rl_allow_pathname_alphabetic_chars &&
strchr (pathname_alphabetic_chars, c) != NULL);
}
#if defined (HANDLE_MULTIBYTE)
int
_rl_walphabetic (wc)
wchar_t wc;
{
int c;
if (iswalnum (wc))
return (1);
c = wc & 0177;
return (_rl_allow_pathname_alphabetic_chars &&
strchr (pathname_alphabetic_chars, c) != NULL);
}
#endif
/* How to abort things. */
int
_rl_abort_internal ()
{
rl_ding ();
rl_clear_message ();
_rl_reset_argument ();
rl_clear_pending_input ();
RL_UNSETSTATE (RL_STATE_MACRODEF);
while (rl_executing_macro)
_rl_pop_executing_macro ();
rl_last_func = (rl_command_func_t *)NULL;
longjmp (_rl_top_level, 1);
return (0);
}
int
rl_abort (count, key)
int count, key;
{
return (_rl_abort_internal ());
}
int
_rl_null_func (count, key)
int count, key;
{
return 0;
}
int
rl_tty_status (count, key)
int count, key;
{
#if defined (TIOCSTAT)
ioctl (1, TIOCSTAT, (char *)0);
rl_refresh_line (count, key);
#else
rl_ding ();
#endif
return 0;
}
/* Return a copy of the string between FROM and TO.
FROM is inclusive, TO is not. */
char *
rl_copy_text (from, to)
int from, to;
{
register int length;
char *copy;
/* Fix it if the caller is confused. */
if (from > to)
SWAP (from, to);
length = to - from;
copy = (char *)xmalloc (1 + length);
strncpy (copy, rl_line_buffer + from, length);
copy[length] = '\0';
return (copy);
}
/* Increase the size of RL_LINE_BUFFER until it has enough space to hold
LEN characters. */
void
rl_extend_line_buffer (len)
int len;
{
while (len >= rl_line_buffer_len)
{
rl_line_buffer_len += DEFAULT_BUFFER_SIZE;
rl_line_buffer = (char *)xrealloc (rl_line_buffer, rl_line_buffer_len);
}
_rl_set_the_line ();
}
/* A function for simple tilde expansion. */
int
rl_tilde_expand (ignore, key)
int ignore, key;
{
register int start, end;
char *homedir, *temp;
int len;
end = rl_point;
start = end - 1;
if (rl_point == rl_end && rl_line_buffer[rl_point] == '~')
{
homedir = tilde_expand ("~");
_rl_replace_text (homedir, start, end);
xfree (homedir);
return (0);
}
else if (rl_line_buffer[start] != '~')
{
for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--)
;
start++;
}
end = start;
do
end++;
while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end);
if (whitespace (rl_line_buffer[end]) || end >= rl_end)
end--;
/* If the first character of the current word is a tilde, perform
tilde expansion and insert the result. If not a tilde, do
nothing. */
if (rl_line_buffer[start] == '~')
{
len = end - start + 1;
temp = (char *)xmalloc (len + 1);
strncpy (temp, rl_line_buffer + start, len);
temp[len] = '\0';
homedir = tilde_expand (temp);
xfree (temp);
_rl_replace_text (homedir, start, end);
xfree (homedir);
}
return (0);
}
#if defined (USE_VARARGS)
void
#if defined (PREFER_STDARG)
_rl_ttymsg (const char *format, ...)
#else
_rl_ttymsg (va_alist)
va_dcl
#endif
{
va_list args;
#if defined (PREFER_VARARGS)
char *format;
#endif
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
format = va_arg (args, char *);
#endif
fprintf (stderr, "readline: ");
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
fflush (stderr);
va_end (args);
rl_forced_update_display ();
}
void
#if defined (PREFER_STDARG)
_rl_errmsg (const char *format, ...)
#else
_rl_errmsg (va_alist)
va_dcl
#endif
{
va_list args;
#if defined (PREFER_VARARGS)
char *format;
#endif
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
format = va_arg (args, char *);
#endif
fprintf (stderr, "readline: ");
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
fflush (stderr);
va_end (args);
}
#else /* !USE_VARARGS */
void
_rl_ttymsg (format, arg1, arg2)
char *format;
{
fprintf (stderr, "readline: ");
fprintf (stderr, format, arg1, arg2);
fprintf (stderr, "\n");
rl_forced_update_display ();
}
void
_rl_errmsg (format, arg1, arg2)
char *format;
{
fprintf (stderr, "readline: ");
fprintf (stderr, format, arg1, arg2);
fprintf (stderr, "\n");
}
#endif /* !USE_VARARGS */
/* **************************************************************** */
/* */
/* String Utility Functions */
/* */
/* **************************************************************** */
/* Determine if s2 occurs in s1. If so, return a pointer to the
match in s1. The compare is case insensitive. */
char *
_rl_strindex (s1, s2)
register const char *s1, *s2;
{
register int i, l, len;
for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
if (_rl_strnicmp (s1 + i, s2, l) == 0)
return ((char *) (s1 + i));
return ((char *)NULL);
}
#ifndef HAVE_STRPBRK
/* Find the first occurrence in STRING1 of any character from STRING2.
Return a pointer to the character in STRING1. */
char *
_rl_strpbrk (string1, string2)
const char *string1, *string2;
{
register const char *scan;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
register int i, v;
memset (&ps, 0, sizeof (mbstate_t));
#endif
for (; *string1; string1++)
{
for (scan = string2; *scan; scan++)
{
if (*string1 == *scan)
return ((char *)string1);
}
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
v = _rl_get_char_len (string1, &ps);
if (v > 1)
string1 += v - 1; /* -1 to account for auto-increment in loop */
}
#endif
}
return ((char *)NULL);
}
#endif
#if !defined (HAVE_STRCASECMP)
/* Compare at most COUNT characters from string1 to string2. Case
doesn't matter. */
int
_rl_strnicmp (string1, string2, count)
char *string1, *string2;
int count;
{
register char ch1, ch2;
while (count)
{
ch1 = *string1++;
ch2 = *string2++;
if (_rl_to_upper(ch1) == _rl_to_upper(ch2))
count--;
else
break;
}
return (count);
}
/* strcmp (), but caseless. */
int
_rl_stricmp (string1, string2)
char *string1, *string2;
{
register char ch1, ch2;
while (*string1 && *string2)
{
ch1 = *string1++;
ch2 = *string2++;
if (_rl_to_upper(ch1) != _rl_to_upper(ch2))
return (1);
}
return (*string1 - *string2);
}
#endif /* !HAVE_STRCASECMP */
/* Stupid comparison routine for qsort () ing strings. */
int
_rl_qsort_string_compare (s1, s2)
char **s1, **s2;
{
#if defined (HAVE_STRCOLL)
return (strcoll (*s1, *s2));
#else
int result;
result = **s1 - **s2;
if (result == 0)
result = strcmp (*s1, *s2);
return result;
#endif
}
/* Function equivalents for the macros defined in chardefs.h. */
#define FUNCTION_FOR_MACRO(f) int (f) (c) int c; { return f (c); }
FUNCTION_FOR_MACRO (_rl_digit_p)
FUNCTION_FOR_MACRO (_rl_digit_value)
FUNCTION_FOR_MACRO (_rl_lowercase_p)
FUNCTION_FOR_MACRO (_rl_pure_alphabetic)
FUNCTION_FOR_MACRO (_rl_to_lower)
FUNCTION_FOR_MACRO (_rl_to_upper)
FUNCTION_FOR_MACRO (_rl_uppercase_p)
/* A convenience function, to force memory deallocation to be performed
by readline. DLLs on Windows apparently require this. */
void
rl_free (mem)
void *mem;
{
if (mem)
free (mem);
}
/* Backwards compatibility, now that savestring has been removed from
all `public' readline header files. */
#undef _rl_savestring
char *
_rl_savestring (s)
const char *s;
{
return (strcpy ((char *)xmalloc (1 + (int)strlen (s)), (s)));
}
#if defined (USE_VARARGS)
static FILE *_rl_tracefp;
void
#if defined (PREFER_STDARG)
_rl_trace (const char *format, ...)
#else
_rl_trace (va_alist)
va_dcl
#endif
{
va_list args;
#if defined (PREFER_VARARGS)
char *format;
#endif
#if defined (PREFER_STDARG)
va_start (args, format);
#else
va_start (args);
format = va_arg (args, char *);
#endif
if (_rl_tracefp == 0)
_rl_tropen ();
vfprintf (_rl_tracefp, format, args);
fprintf (_rl_tracefp, "\n");
fflush (_rl_tracefp);
va_end (args);
}
int
_rl_tropen ()
{
char fnbuf[128];
if (_rl_tracefp)
fclose (_rl_tracefp);
sprintf (fnbuf, "/var/tmp/rltrace.%ld", getpid());
unlink(fnbuf);
_rl_tracefp = fopen (fnbuf, "w+");
return _rl_tracefp != 0;
}
int
_rl_trclose ()
{
int r;
r = fclose (_rl_tracefp);
_rl_tracefp = 0;
return r;
}
#endif
+2 -2
View File
@@ -326,9 +326,9 @@ KEYMAP_ENTRY_ARRAY vi_insertion_keymap = {
{ ISFUNC, rl_insert }, /* Control-k */
{ ISFUNC, rl_insert }, /* Control-l */
{ ISFUNC, rl_newline }, /* Control-m */
{ ISFUNC, rl_insert }, /* Control-n */
{ ISFUNC, rl_menu_complete}, /* Control-n */
{ ISFUNC, rl_insert }, /* Control-o */
{ ISFUNC, rl_insert }, /* Control-p */
{ ISFUNC, rl_backward_menu_complete }, /* Control-p */
{ ISFUNC, rl_insert }, /* Control-q */
{ ISFUNC, rl_reverse_search_history }, /* Control-r */
{ ISFUNC, rl_forward_search_history }, /* Control-s */
+6 -6
View File
@@ -653,7 +653,7 @@ gen_matches_from_itemlist (itp, text)
if ((itp->flags & (LIST_DIRTY|LIST_DYNAMIC)) ||
(itp->flags & LIST_INITIALIZED) == 0)
{
if (itp->flags & (LIST_DIRTY | LIST_DYNAMIC))
if (itp->flags & (LIST_DIRTY|LIST_DYNAMIC))
clean_itemlist (itp);
if ((itp->flags & LIST_INITIALIZED) == 0)
initialize_itemlist (itp);
@@ -1437,16 +1437,16 @@ programmable_completions (cmd, word, start, end, foundp)
pcomp_curcs = cs;
pcomp_curcmd = cmd;
/* Signal the caller that we found a COMPSPEC for this command, and pass
back any meta-options associated with the compspec. */
if (foundp)
*foundp = 1|cs->options;
ret = gen_compspec_completions (cs, cmd, word, start, end);
pcomp_curcs = oldcs;
pcomp_curcmd = oldcmd;
/* Signal the caller that we found a COMPSPEC for this command, and pass
back any meta-options associated with the compspec. */
if (foundp)
*foundp = 1|cs->options;
compspec_dispose (cs);
if (ret)
+6 -5
View File
@@ -1032,6 +1032,7 @@ gen_shell_function_matches (cs, text, line, ind, lwords, nw, cw)
cmdlist = build_arg_list (funcname, text, lwords, cw);
pps = &ps;
save_parser_state (pps);
begin_unwind_frame ("gen-shell-function-matches");
add_unwind_protect (restore_parser_state, (char *)pps);
add_unwind_protect (dispose_words, (char *)cmdlist);
@@ -1436,16 +1437,16 @@ programmable_completions (cmd, word, start, end, foundp)
pcomp_curcs = cs;
pcomp_curcmd = cmd;
/* Signal the caller that we found a COMPSPEC for this command, and pass
back any meta-options associated with the compspec. */
if (foundp)
*foundp = 1|cs->options;
ret = gen_compspec_completions (cs, cmd, word, start, end);
pcomp_curcs = oldcs;
pcomp_curcmd = oldcmd;
/* Signal the caller that we found a COMPSPEC for this command, and pass
back any meta-options associated with the compspec. */
if (foundp)
*foundp = 1|cs->options;
compspec_dispose (cs);
if (ret)
+3
View File
@@ -892,6 +892,9 @@ void
exit_shell (s)
int s;
{
fflush (stdout); /* XXX */
fflush (stderr);
/* Do trap[0] if defined. Allow it to override the exit status
passed to us. */
if (signal_is_trapped (0))
+129
View File
@@ -314,6 +314,135 @@ static WORD_LIST *expand_word_list_internal __P((WORD_LIST *, int));
/* */
/* **************************************************************** */
#if defined (DEBUG)
void
dump_word_flags (flags)
int flags;
{
int f;
f = flags;
fprintf (stderr, "%d -> ", f);
if (f & W_ASSIGNASSOC)
{
f &= ~W_ASSIGNASSOC;
fprintf (stderr, "W_ASSIGNASSOC%s", f ? "|" : "");
}
if (f & W_HASCTLESC)
{
f &= ~W_HASCTLESC;
fprintf (stderr, "W_HASCTLESC%s", f ? "|" : "");
}
if (f & W_NOPROCSUB)
{
f &= ~W_NOPROCSUB;
fprintf (stderr, "W_NOPROCSUB%s", f ? "|" : "");
}
if (f & W_DQUOTE)
{
f &= ~W_DQUOTE;
fprintf (stderr, "W_DQUOTE%s", f ? "|" : "");
}
if (f & W_HASQUOTEDNULL)
{
f &= ~W_HASQUOTEDNULL;
fprintf (stderr, "W_HASQUOTEDNULL%s", f ? "|" : "");
}
if (f & W_ASSIGNARG)
{
f &= ~W_ASSIGNARG;
fprintf (stderr, "W_ASSIGNARG%s", f ? "|" : "");
}
if (f & W_ASSNBLTIN)
{
f &= ~W_ASSNBLTIN;
fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : "");
}
if (f & W_COMPASSIGN)
{
f &= ~W_COMPASSIGN;
fprintf (stderr, "W_COMPASSIGN%s", f ? "|" : "");
}
if (f & W_NOEXPAND)
{
f &= ~W_NOEXPAND;
fprintf (stderr, "W_NOEXPAND%s", f ? "|" : "");
}
if (f & W_ITILDE)
{
f &= ~W_ITILDE;
fprintf (stderr, "W_ITILDE%s", f ? "|" : "");
}
if (f & W_NOTILDE)
{
f &= ~W_NOTILDE;
fprintf (stderr, "W_NOTILDE%s", f ? "|" : "");
}
if (f & W_ASSIGNRHS)
{
f &= ~W_ASSIGNRHS;
fprintf (stderr, "W_ASSIGNRHS%s", f ? "|" : "");
}
if (f & W_NOCOMSUB)
{
f &= ~W_NOCOMSUB;
fprintf (stderr, "W_NOCOMSUB%s", f ? "|" : "");
}
if (f & W_DOLLARSTAR)
{
f &= ~W_DOLLARSTAR;
fprintf (stderr, "W_DOLLARSTAR%s", f ? "|" : "");
}
if (f & W_DOLLARAT)
{
f &= ~W_DOLLARAT;
fprintf (stderr, "W_DOLLARAT%s", f ? "|" : "");
}
if (f & W_TILDEEXP)
{
f &= ~W_TILDEEXP;
fprintf (stderr, "W_TILDEEXP%s", f ? "|" : "");
}
if (f & W_NOSPLIT2)
{
f &= ~W_NOSPLIT2;
fprintf (stderr, "W_NOSPLIT2%s", f ? "|" : "");
}
if (f & W_NOGLOB)
{
f &= ~W_NOGLOB;
fprintf (stderr, "W_NOGLOB%s", f ? "|" : "");
}
if (f & W_NOSPLIT)
{
f &= ~W_NOSPLIT;
fprintf (stderr, "W_NOSPLIT%s", f ? "|" : "");
}
if (f & W_GLOBEXP)
{
f &= ~W_GLOBEXP;
fprintf (stderr, "W_GLOBEXP%s", f ? "|" : "");
}
if (f & W_ASSIGNMENT)
{
f &= ~W_ASSIGNMENT;
fprintf (stderr, "W_ASSIGNMENT%s", f ? "|" : "");
}
if (f & W_QUOTED)
{
f &= ~W_QUOTED;
fprintf (stderr, "W_QUOTED%s", f ? "|" : "");
}
if (f & W_HASDOLLAR)
{
f &= ~W_HASDOLLAR;
fprintf (stderr, "W_HASDOLLAR%s", f ? "|" : "");
}
fprintf (stderr, "\n");
fflush (stderr);
}
#endif
#ifdef INCLUDE_UNUSED
static char *
quoted_substring (string, start, end)
+38 -3
View File
@@ -221,9 +221,11 @@ static SHELL_VAR *get_groupset __P((SHELL_VAR *));
static SHELL_VAR *build_hashcmd __P((SHELL_VAR *));
static SHELL_VAR *get_hashcmd __P((SHELL_VAR *));
static SHELL_VAR *assign_hashcmd __P((SHELL_VAR *, char *, arrayind_t, char *));
# if defined (ALIAS)
static SHELL_VAR *build_aliasvar __P((SHELL_VAR *));
static SHELL_VAR *get_aliasvar __P((SHELL_VAR *));
static SHELL_VAR *assign_aliasvar __P((SHELL_VAR *, char *, arrayind_t, char *));
# endif
#endif
static SHELL_VAR *get_funcname __P((SHELL_VAR *));
@@ -252,6 +254,7 @@ static SHELL_VAR **fapply __P((sh_var_map_func_t *));
static int visible_var __P((SHELL_VAR *));
static int visible_and_exported __P((SHELL_VAR *));
static int export_environment_candidate __P((SHELL_VAR *));
static int local_and_exported __P((SHELL_VAR *));
static int variable_in_context __P((SHELL_VAR *));
#if defined (ARRAY_VARS)
@@ -375,10 +378,17 @@ initialize_shell_variables (env, privmode)
}
# endif
#endif
#if 0
else if (legal_identifier (name))
#else
else
#endif
{
temp_var = bind_variable (name, string, 0);
VSETATTR (temp_var, (att_exported | att_imported));
if (legal_identifier (name))
VSETATTR (temp_var, (att_exported | att_imported));
else
VSETATTR (temp_var, (att_exported | att_imported | att_invisible));
array_needs_making = 1;
}
@@ -867,7 +877,7 @@ make_vers_array ()
vv = make_new_array_variable ("BASH_VERSINFO");
av = array_cell (vv);
strcpy (d, dist_version);
s = xstrchr (d, '.');
s = strchr (d, '.');
if (s)
*s++ = '\0';
array_insert (av, 0, d);
@@ -1548,6 +1558,7 @@ assign_hashcmd (self, value, ind, key)
return (build_hashcmd (self));
}
#if defined (ALIAS)
static SHELL_VAR *
build_aliasvar (self)
SHELL_VAR *self;
@@ -1600,6 +1611,8 @@ assign_aliasvar (self, value, ind, key)
add_alias (key, value);
return (build_aliasvar (self));
}
#endif /* ALIAS */
#endif /* ARRAY_VARS */
/* If ARRAY_VARS is not defined, this just returns the name of any
@@ -1695,7 +1708,9 @@ initialize_dynamic_variables ()
v = init_dynamic_array_var ("BASH_LINENO", get_self, null_array_assign, att_noassign|att_nounset);
v = init_dynamic_assoc_var ("BASH_CMDS", get_hashcmd, assign_hashcmd, att_nofree);
# if defined (ALIAS)
v = init_dynamic_assoc_var ("BASH_ALIASES", get_aliasvar, assign_aliasvar, att_nofree);
# endif
#endif
v = init_funcname_var ();
@@ -3082,6 +3097,16 @@ visible_and_exported (var)
return (invisible_p (var) == 0 && exported_p (var));
}
/* Candidate variables for the export environment are either valid variables
with the export attribute or invalid variables inherited from the initial
environment and simply passed through. */
static int
export_environment_candidate (var)
SHELL_VAR *var;
{
return (exported_p (var) && (invisible_p (var) == 0 || imported_p (var)));
}
/* Return non-zero if VAR is a local variable in the current context and
is exported. */
static int
@@ -3438,7 +3463,11 @@ make_var_export_array (vcxt)
char **list;
SHELL_VAR **vars;
#if 0
vars = map_over (visible_and_exported, vcxt);
#else
vars = map_over (export_environment_candidate, vcxt);
#endif
if (vars == 0)
return (char **)NULL;
@@ -3587,7 +3616,7 @@ maybe_make_export_env ()
}
export_env[export_env_index = 0] = (char *)NULL;
/* Make a dummy variable context from the temporary_env, stick it on
/* Make a dummy variable context from the temporary_env, stick it on
the front of shell_variables, call make_var_export_array on the
whole thing to flatten it, and convert the list of SHELL_VAR *s
to the form needed by the environment. */
@@ -4275,6 +4304,12 @@ sv_hostfile (name)
clear_hostname_list ();
else
hostname_list_initialized = 0;
#if 0
#if defined (PROGRAMMABLE_COMPLETION)
set_itemlist_dirty (&it_hostnames);
#endif
#endif
}
#if defined (STRICT_POSIX)