bash-4.3-beta overlay

This commit is contained in:
Chet Ramey
2013-08-12 19:18:42 -04:00
parent 25eee30b53
commit 1442f67c40
64 changed files with 3022 additions and 1530 deletions
+5 -1
View File
@@ -43,7 +43,11 @@
#define STREQ(a, b) ((a)[0] == (b)[0] && strcmp(a, b) == 0)
#define STREQN(a, b, n) ((a)[0] == (b)[0] && strncmp(a, b, n) == 0)
int glob_asciirange = 0;
#ifndef GLOBASCII_DEFAULT
# define GLOBASCII_DEFAULT 0
#endif
int glob_asciirange = GLOBASCII_DEFAULT;
/* We use strcoll(3) for range comparisons in bracket expressions,
even though it can have unwanted side effects in locales
+1
View File
@@ -1330,6 +1330,7 @@ remove_trailing:
{
i = _rl_skip_to_delim (value, 1, *value);
value[i] = '\0';
value++; /* skip past the quote */
}
else
goto remove_trailing;
+6 -1
View File
@@ -167,13 +167,18 @@ _rl_print_color_indicator (char *f)
{
colored_filetype = C_DIR;
#if defined (S_ISVTX)
if ((mode & S_ISVTX) && (mode & S_IWOTH)
&& is_colored (C_STICKY_OTHER_WRITABLE))
colored_filetype = C_STICKY_OTHER_WRITABLE;
else if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE))
else
#endif
if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE))
colored_filetype = C_OTHER_WRITABLE;
#if defined (S_ISVTX)
else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY))
colored_filetype = C_STICKY;
#endif
}
else if (S_ISLNK (mode))
colored_filetype = ((linkok == 0
+5 -1
View File
@@ -2132,13 +2132,17 @@ rl_completion_matches (text, entry_function)
xfree (match_list);
match_list = 0;
match_list_size = 0;
matches = 0;
RL_CHECK_SIGNALS ();
}
if (matches + 1 == match_list_size)
if (matches + 1 >= match_list_size)
match_list = (char **)xrealloc
(match_list, ((match_list_size += 10) + 1) * sizeof (char *));
if (match_list == 0)
return (match_list);
match_list[++matches] = string;
match_list[matches + 1] = (char *)NULL;
}
+100 -5
View File
@@ -612,6 +612,7 @@ means that vi mode is active.
* Miscellaneous Functions:: Functions that don't fall into any category.
* Alternate Interface:: Using Readline in a `callback' fashion.
* A Readline Example:: An example Readline function.
* Alternate Interface Example:: An example program using the alternate interface.
@end menu
@node Function Naming
@@ -1293,8 +1294,9 @@ are functions available to make this easy.
@deftypefun void rl_callback_handler_install (const char *prompt, rl_vcpfunc_t *lhandler)
Set up the terminal for readline I/O and display the initial
expanded value of @var{prompt}. Save the value of @var{lhandler} to
use as a function to call when a complete line of input has been entered.
The function takes the text of the line as an argument.
use as a handler function to call when a complete line of input has been
entered.
The handler function receives the text of the line as an argument.
@end deftypefun
@deftypefun void rl_callback_read_char (void)
@@ -1302,14 +1304,15 @@ Whenever an application determines that keyboard input is available, it
should call @code{rl_callback_read_char()}, which will read the next
character from the current input source.
If that character completes the line, @code{rl_callback_read_char} will
invoke the @var{lhandler} function saved by @code{rl_callback_handler_install}
to process the line.
invoke the @var{lhandler} function installed by
@code{rl_callback_handler_install} to process the line.
Before calling the @var{lhandler} function, the terminal settings are
reset to the values they had before calling
@code{rl_callback_handler_install}.
If the @var{lhandler} function returns,
and the line handler remains installed,
the terminal settings are modified for Readline's use again.
@code{EOF} is indicated by calling @var{lhandler} with a
@code{EOF} is indicated by calling @var{lhandler} with a
@code{NULL} line.
@end deftypefun
@@ -1389,6 +1392,98 @@ invert_case_line (count, key)
@}
@end example
@node Alternate Interface Example
@subsection Alternate Interface Example
Here is a complete program that illustrates Readline's alternate interface.
It reads lines from the terminal and displays them, providing the
standard history and TAB completion functions.
It understands the EOF character or "exit" to exit the program.
@example
/* Standard include files. stdio.h is required. */
#include <stdlib.h>
#include <unistd.h>
/* Used for select(2) */
#include <sys/types.h>
#include <sys/select.h>
#include <stdio.h>
/* Standard readline include files. */
#include <readline/readline.h>
#include <readline/history.h>
static void cb_linehandler (char *);
int running;
const char *prompt = "rltest$ ";
/* Callback function called for each line when accept-line executed, EOF
seen, or EOF character read. This sets a flag and returns; it could
also call exit(3). */
static void
cb_linehandler (char *line)
@{
/* Can use ^D (stty eof) or `exit' to exit. */
if (line == NULL || strcmp (line, "exit") == 0)
@{
if (line == 0)
printf ("\n");
printf ("exit\n");
/* This function needs to be called to reset the terminal settings,
and calling it from the line handler keeps one extra prompt from
being displayed. */
rl_callback_handler_remove ();
running = 0;
@}
else
@{
if (*line)
add_history (line);
printf ("input line: %s\n", line);
free (line);
@}
@}
int
main (int c, char **v)
@{
fd_set fds;
int r;
/* Install the line handler. */
rl_callback_handler_install (prompt, cb_linehandler);
/* Enter a simple event loop. This waits until something is available
to read on readline's input stream (defaults to standard input) and
calls the builtin character read callback to read it. It does not
have to modify the user's terminal settings. */
running = 1;
while (running)
@{
FD_ZERO (&fds);
FD_SET (fileno (rl_instream), &fds);
r = select (FD_SETSIZE, &fds, NULL, NULL, NULL);
if (r < 0)
@{
perror ("rltest: select");
rl_callback_handler_remove ();
break;
@}
if (FD_ISSET (fileno (rl_instream), &fds))
rl_callback_read_char ();
@}
printf ("rltest: Event loop has exited\n");
return 0;
@}
@end example
@node Readline Signal Handling
@section Readline Signal Handling
+6 -6
View File
@@ -1,10 +1,10 @@
@ignore
Copyright (C) 1988-2012 Free Software Foundation, Inc.
Copyright (C) 1988-2013 Free Software Foundation, Inc.
@end ignore
@set EDITION 6.2
@set VERSION 6.2
@set UPDATED 15 November 2012
@set UPDATED-MONTH November 2012
@set EDITION 6.3
@set VERSION 6.3
@set UPDATED 26 May 2013
@set UPDATED-MONTH May 2013
@set LASTCHANGE Thu Nov 15 21:03:04 EST 2012
@set LASTCHANGE Sat May 25 17:02:56 EDT 2013
+81
View File
@@ -0,0 +1,81 @@
/* Standard include files. stdio.h is required. */
#include <stdlib.h>
#include <unistd.h>
/* Used for select(2) */
#include <sys/types.h>
#include <sys/select.h>
#include <stdio.h>
/* Standard readline include files. */
#include <readline/readline.h>
#include <readline/history.h>
static void cb_linehandler (char *);
int running;
const char *prompt = "rltest$ ";
/* Callback function called for each line when accept-line executed, EOF
seen, or EOF character read. This sets a flag and returns; it could
also call exit(3). */
static void
cb_linehandler (char *line)
{
/* Can use ^D (stty eof) or `exit' to exit. */
if (line == NULL || strcmp (line, "exit") == 0)
{
if (line == 0)
printf ("\n");
printf ("exit\n");
/* This function needs to be called to reset the terminal settings,
and calling it from the line handler keeps one extra prompt from
being displayed. */
rl_callback_handler_remove ();
running = 0;
}
else
{
if (*line)
add_history (line);
printf ("input line: %s\n", line);
free (line);
}
}
int
main (int c, char **v)
{
fd_set fds;
int r;
/* Install the line handler. */
rl_callback_handler_install (prompt, cb_linehandler);
/* Enter a simple event loop. This waits until something is available
to read on readline's input stream (defaults to standard input) and
calls the builtin character read callback to read it. It does not
have to modify the user's terminal settings. */
running = 1;
while (running)
{
FD_ZERO (&fds);
FD_SET (fileno (rl_instream), &fds);
r = select (FD_SETSIZE, &fds, NULL, NULL, NULL);
if (r < 0)
{
perror ("rltest: select");
rl_callback_handler_remove ();
break;
}
if (FD_ISSET (fileno (rl_instream), &fds))
rl_callback_read_char ();
}
printf ("rltest: Event loop has exited\n");
return 0;
}
+6 -3
View File
@@ -411,14 +411,16 @@ history_truncate_file (fname, lines)
truncate to. */
if (bp > buffer && ((file = open (filename, O_WRONLY|O_TRUNC|O_BINARY, 0600)) != -1))
{
write (file, bp, chars_read - (bp - buffer));
if (write (file, bp, chars_read - (bp - buffer)) < 0)
rv = errno;
#if defined (__BEOS__)
/* BeOS ignores O_TRUNC. */
ftruncate (file, chars_read - (bp - buffer));
#endif
close (file);
if (close (file) < 0 && rv == 0)
rv = errno;
}
truncate_exit:
@@ -547,7 +549,8 @@ mmap_error:
#endif
}
close (file);
if (close (file) < 0 && rv == 0)
rv = errno;
if (rv != 0 && output && bakname)
rename (bakname, output);
+1 -1
View File
@@ -318,7 +318,7 @@ add_history_time (string)
{
HIST_ENTRY *hs;
if (string == 0)
if (string == 0 || history_length < 1)
return;
hs = the_history[history_length - 1];
FREE (hs->timestamp);
+8 -5
View File
@@ -397,8 +397,8 @@ readline_internal_setup ()
_rl_out_stream = rl_outstream;
/* Enable the meta key only for the duration of readline(), if this
terminal has one. */
if (_rl_enable_meta)
terminal has one and the terminal has been initialized */
if (_rl_enable_meta & RL_ISSTATE (RL_STATE_TERMPREPPED))
_rl_enable_meta_key ();
if (rl_startup_hook)
@@ -406,7 +406,7 @@ readline_internal_setup ()
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode)
rl_vi_insert_mode (1, 'i');
rl_vi_insertion_mode (1, 'i'); /* don't want to reset last */
#endif /* VI_MODE */
/* If we're not echoing, we still want to at least print a prompt, because
@@ -469,7 +469,9 @@ readline_internal_teardown (eof)
if (rl_undo_list)
rl_free_undo_list ();
/* Disable the meta key, if this terminal has one. */
/* Disable the meta key, if this terminal has one and we were told to use it.
The check whether or not we sent the enable string is in
_rl_disable_meta_key(); the flag is set in _rl_enable_meta_key */
_rl_disable_meta_key ();
/* Restore normal cursor, if available. */
@@ -821,7 +823,7 @@ _rl_dispatch_subseq (key, map, got_subseq)
rl_dispatching = 1;
RL_SETSTATE(RL_STATE_DISPATCHING);
(*func) (rl_numeric_arg * rl_arg_sign, key);
r = (*func) (rl_numeric_arg * rl_arg_sign, key);
RL_UNSETSTATE(RL_STATE_DISPATCHING);
rl_dispatching = 0;
@@ -957,6 +959,7 @@ _rl_dispatch_subseq (key, map, got_subseq)
#if defined (VI_MODE)
if (rl_editing_mode == vi_mode && _rl_keymap == vi_movement_keymap &&
key != ANYOTHERKEY &&
rl_key_sequence_length == 1 && /* XXX */
_rl_vi_textmod_command (key))
_rl_vi_set_last (key, rl_numeric_arg, rl_arg_sign);
#endif
+10 -1
View File
@@ -141,10 +141,19 @@ _rl_signal_handler (sig)
#if defined (SIGWINCH)
if (sig == SIGWINCH)
rl_resize_terminal ();
{
rl_resize_terminal ();
/* XXX - experimental for now */
/* Call a signal hook because though we called the original signal handler
in rl_sigwinch_handler below, we will not resend the signal to
ourselves. */
if (rl_signal_event_hook)
(*rl_signal_event_hook) ();
}
else
#endif
_rl_handle_signal (sig);
SIGHANDLER_RETURN;
}
+15 -2
View File
@@ -39,6 +39,7 @@
#include <shmbchar.h>
#include <shmbutil.h>
#include <chartypes.h>
#include <typemax.h>
#include <glob/strmatch.h>
@@ -68,6 +69,10 @@
extern char *substring __P((char *, int, int));
#ifndef UCHAR_MAX
# define UCHAR_MAX TYPE_MAXIMUM(unsigned char)
#endif
#if defined (HANDLE_MULTIBYTE)
static wchar_t
cval (s, i)
@@ -141,8 +146,10 @@ sh_modcase (string, pat, flags)
if (iswalnum (wc) == 0)
{
inword = 0;
#if 0
ADVANCE_CHAR (ret, end, start);
continue;
#endif
}
if (pat)
@@ -203,8 +210,11 @@ sh_modcase (string, pat, flags)
else
nop = flags;
if (MB_CUR_MAX == 1 || is_basic ((int)wc))
/* Need to check UCHAR_MAX since wc may have already been converted to a
wide character by cval() */
if (MB_CUR_MAX == 1 || (wc <= UCHAR_MAX && is_basic ((int)wc)))
{
singlebyte:
switch (nop)
{
default:
@@ -221,7 +231,10 @@ sh_modcase (string, pat, flags)
{
m = mbrtowc (&wc, string + start, end - start, &state);
if (MB_INVALIDCH (m))
wc = (wchar_t)string[start];
{
wc = (unsigned char)string[start];
goto singlebyte;
}
else if (MB_NULLWCH (m))
wc = L'\0';
switch (nop)
+1 -1
View File
@@ -269,7 +269,7 @@ sh_realpath (pathname, resolved)
wd = get_working_directory ("sh_realpath");
if (wd == 0)
return ((char *)NULL);
tdir = sh_makepath ((char *)pathname, wd, 0);
tdir = sh_makepath (wd, (char *)pathname, 0);
free (wd);
}
else
+9
View File
@@ -94,6 +94,15 @@ sh_single_quote (string)
result = (char *)xmalloc (3 + (4 * strlen (string)));
r = result;
if (string[0] == '\'' && string[1] == 0)
{
*r++ = '\\';
*r++ = '\'';
*r++ = 0;
return result;
}
*r++ = '\'';
for (s = string; s && (c = *s); s++)