bash-4.4 rc1 release

This commit is contained in:
Chet Ramey
2016-02-23 11:23:40 -05:00
parent 54a5fbe126
commit 690150f9e5
253 changed files with 54541 additions and 51806 deletions
+1 -1
View File
@@ -110,7 +110,7 @@ _print_malloc_stats (s, fp)
}
fprintf (fp, "\nTotal bytes in use: %lu, total bytes free: %lu\n",
totused, totfree);
fprintf (fp, "\nTotal bytes requested by application: %lu\n", _mstats.bytesreq);
fprintf (fp, "\nTotal bytes requested by application: %lu\n", (unsigned long)_mstats.bytesreq);
fprintf (fp, "Total mallocs: %d, total frees: %d, total reallocs: %d (%d copies)\n",
_mstats.nmal, _mstats.nfre, _mstats.nrealloc, _mstats.nrcopy);
fprintf (fp, "Total sbrks: %d, total bytes via sbrk: %d\n",
+1 -1
View File
@@ -290,7 +290,7 @@ _register_dump_table(fp)
{
entry = mem_table[i];
if (entry.mem)
fprintf (fp, "%s[%d] %p:%d:%s:%s:%s:%d:%d:%d\n",
fprintf (fp, "%s[%d] %p:%zu:%s:%s:%s:%d:%d:%d\n",
(i == table_bucket_index) ? "*" : "",
i,
entry.mem, entry.size,
+2 -2
View File
@@ -52,10 +52,10 @@ mtrace_alloc (tag, mem, size, file, line)
_mtrace_fp = stderr;
if (_mtrace_verbose)
fprintf (_mtrace_fp, "alloc: %s: %p (%d bytes) from '%s:%d'\n",
fprintf (_mtrace_fp, "alloc: %s: %p (%zu bytes) from '%s:%d'\n",
tag, mem, size, file ? file : "unknown", line);
else
fprintf (_mtrace_fp, "alloc:%p:%d:%s:%d\n",
fprintf (_mtrace_fp, "alloc:%p:%zu:%s:%d\n",
mem, size, file ? file : "unknown", line);
}
+68 -16
View File
@@ -1,6 +1,6 @@
/* bind.c -- key binding and startup file support for the readline library. */
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
/* Copyright (C) 1987-2016 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.
@@ -74,8 +74,13 @@ Keymap rl_binding_keymap;
static int _rl_skip_to_delim PARAMS((char *, int, int));
#if defined (USE_VARARGS) && defined (PREFER_STDARG)
static void _rl_init_file_error (const char *, ...) __attribute__((__format__ (printf, 1, 2)));
#else
static void _rl_init_file_error ();
#endif
static char *_rl_read_file PARAMS((char *, size_t *));
static void _rl_init_file_error PARAMS((const char *));
static int _rl_read_init_file PARAMS((const char *, int));
static int glean_key_from_name PARAMS((char *));
@@ -989,14 +994,35 @@ _rl_read_init_file (filename, include_level)
}
static void
_rl_init_file_error (msg)
const char *msg;
#if defined (PREFER_STDARG)
_rl_init_file_error (const char *format, ...)
#else
_rl_init_file_error (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: ");
if (currently_reading_init_file)
_rl_errmsg ("%s: line %d: %s\n", current_readline_init_file,
current_readline_init_lineno, msg);
else
_rl_errmsg ("%s", msg);
fprintf (stderr, "%s: line %d: ", current_readline_init_file,
current_readline_init_lineno);
vfprintf (stderr, format, args);
fprintf (stderr, "\n");
fflush (stderr);
va_end (args);
}
/* **************************************************************** */
@@ -1216,7 +1242,7 @@ handle_parser_directive (statement)
}
/* display an error message about the unknown parser directive */
_rl_init_file_error ("unknown parser directive");
_rl_init_file_error ("%s: unknown parser directive", directive);
return (1);
}
@@ -1262,7 +1288,7 @@ rl_parse_and_bind (string)
{
char *funname, *kname;
register int c, i;
int key, equivalency;
int key, equivalency, foundmod, foundsep;
while (string && whitespace (*string))
string++;
@@ -1292,7 +1318,7 @@ rl_parse_and_bind (string)
/* If we didn't find a closing quote, abort the line. */
if (string[i] == '\0')
{
_rl_init_file_error ("no closing `\"' in key binding");
_rl_init_file_error ("%s: no closing `\"' in key binding", string);
return 1;
}
else
@@ -1304,6 +1330,8 @@ rl_parse_and_bind (string)
equivalency = (c == ':' && string[i + 1] == '=');
foundsep = c != 0;
/* Mark the end of the command (or keyname). */
if (string[i])
string[i++] = '\0';
@@ -1393,6 +1421,12 @@ remove_trailing:
return 0;
}
if (foundsep == 0)
{
_rl_init_file_error ("%s: no key sequence terminator", string);
return 1;
}
/* If this is a new-style key-binding, then do the binding with
rl_bind_keyseq (). Otherwise, let the older code deal with it. */
if (*string == '"')
@@ -1449,11 +1483,24 @@ remove_trailing:
key = glean_key_from_name (kname);
/* Add in control and meta bits. */
foundmod = 0;
if (substring_member_of_array (string, _rl_possible_control_prefixes))
key = CTRL (_rl_to_upper (key));
{
key = CTRL (_rl_to_upper (key));
foundmod = 1;
}
if (substring_member_of_array (string, _rl_possible_meta_prefixes))
key = META (key);
{
key = META (key);
foundmod = 1;
}
if (foundmod == 0 && kname != string)
{
_rl_init_file_error ("%s: unknown key modifier", string);
return 1;
}
/* Temporary. Handle old-style keyname with macro-binding. */
if (*funname == '\'' || *funname == '"')
@@ -1480,6 +1527,7 @@ remove_trailing:
#endif /* PREFIX_META_HACK */
else
rl_bind_key (key, rl_named_function (funname));
return 0;
}
@@ -1681,10 +1729,14 @@ rl_variable_bind (name, value)
i = find_string_var (name);
/* For the time being, unknown variable names or string names without a
handler function are simply ignored. */
/* For the time being, string names without a handler function are simply
ignored. */
if (i < 0 || string_varlist[i].set_func == 0)
return 0;
{
if (i < 0)
_rl_init_file_error ("%s: unknown variable name", name);
return 0;
}
v = (*string_varlist[i].set_func) (value);
return v;
+1 -1
View File
@@ -1,6 +1,6 @@
/* callback.c -- functions to use readline as an X `callback' mechanism. */
/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 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.
+1 -1
View File
@@ -1,6 +1,6 @@
/* chardefs.h -- Character definitions for readline. */
/* Copyright (C) 1994-2009 Free Software Foundation, Inc.
/* Copyright (C) 1994-2015 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.
+2 -2
View File
@@ -2,8 +2,8 @@
Modified by Chet Ramey for Readline.
Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012 Free Software Foundation,
Inc.
Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
+2 -2
View File
@@ -2,8 +2,8 @@
Modified by Chet Ramey for Readline.
Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012 Free Software Foundation,
Inc.
Copyright (C) 1985, 1988, 1990-1991, 1995-2010, 2012, 2015
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
+111 -13
View File
@@ -1,6 +1,6 @@
/* display.c -- readline redisplay facility. */
/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 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.
@@ -192,6 +192,8 @@ static int prompt_multibyte_chars;
/* Number of lines currently on screen minus 1. */
int _rl_vis_botlin = 0;
static int _rl_inv_botlin = 0;
/* Variables used only in this file. */
/* The last left edge of text that was displayed. This is used when
doing horizontal scrolling. It shifts in thirds of a screenwidth. */
@@ -580,13 +582,13 @@ rl_redisplay ()
int inv_botlin, lb_botlin, lb_linenum, o_cpos;
int newlines, lpos, temp, n0, num, prompt_lines_estimate;
char *prompt_this_line;
int mb_cur_max = MB_CUR_MAX;
#if defined (HANDLE_MULTIBYTE)
wchar_t wc;
size_t wc_bytes;
int wc_width;
mbstate_t ps;
int _rl_wrapped_multicolumn = 0;
int mb_cur_max = MB_CUR_MAX;
#endif
if (_rl_echoing_p == 0)
@@ -737,6 +739,8 @@ rl_redisplay ()
/* inv_lbreaks[i] is where line i starts in the buffer. */
inv_lbreaks[newlines = 0] = 0;
/* lpos is a physical cursor position, so it needs to be adjusted by the
number of invisible characters in the prompt, per line */
lpos = prompt_physical_chars + modmark;
#if defined (HANDLE_MULTIBYTE)
@@ -757,6 +761,16 @@ rl_redisplay ()
while (lpos >= _rl_screenwidth)
{
int z, p;
int nocorrect, wadjust;
nocorrect = 0;
/* Adjust depending on the invisible characters in the line. We use a
heuristic based on experience: invisible characters nearly always
appear in the first and last lines of the prompt */
wadjust = (newlines == 0)
? prompt_invis_chars_first_line
: ((newlines == prompt_lines_estimate) ? wrap_offset : prompt_invis_chars_first_line);
/* fix from Darin Johnson <darin@acuson.com> for prompt string with
invisible characters that is longer than the screen width. The
prompt_invis_chars_first_line variable could be made into an array
@@ -767,11 +781,14 @@ rl_redisplay ()
#if defined (HANDLE_MULTIBYTE)
if (mb_cur_max > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
{
nocorrect = 1;
n0 = num;
temp = local_prompt_len;
while (num < temp)
{
z = _rl_col_width (local_prompt, n0, num, 1);
/* This has to take invisible characters in the prompt into
account. */
z = _rl_col_width (local_prompt, n0, num, 1) - wadjust;
if (z > _rl_screenwidth)
{
num = _rl_find_prev_mbchar (local_prompt, num, MB_FIND_ANY);
@@ -798,16 +815,18 @@ rl_redisplay ()
/* Now account for invisible characters in the current line. */
/* XXX - this assumes that the invisible characters may be split, but only
between the first and the last lines. */
temp += (newlines == 0) ? prompt_invis_chars_first_line
: ((newlines == prompt_lines_estimate) ? wrap_offset : prompt_invis_chars_first_line);
if (nocorrect == 0)
temp += wadjust;
inv_lbreaks[++newlines] = temp;
#if defined (HANDLE_MULTIBYTE)
/* lpos is a physical cursor position, so it needs to take the invisible
characters into account. */
if (mb_cur_max > 1 && rl_byte_oriented == 0 && prompt_multibyte_chars > 0)
lpos -= _rl_col_width (local_prompt, n0, num, 1);
lpos -= _rl_col_width (local_prompt, n0, num, 1) - wadjust;
else
#endif
lpos -= _rl_screenwidth;
lpos -= _rl_screenwidth - wadjust;
}
prompt_last_screen_line = newlines;
@@ -999,7 +1018,7 @@ rl_redisplay ()
lb_linenum = newlines;
}
inv_botlin = lb_botlin = newlines;
inv_botlin = lb_botlin = _rl_inv_botlin = newlines;
CHECK_INV_LBREAKS ();
inv_lbreaks[newlines+1] = out;
cursor_linenum = lb_linenum;
@@ -1029,9 +1048,11 @@ rl_redisplay ()
not the first. */
if (out >= _rl_screenchars)
{
#if defined (HANDLE_MULTIBYTE)
if (mb_cur_max > 1 && rl_byte_oriented == 0)
out = _rl_find_prev_mbchar (line, _rl_screenchars, MB_FIND_ANY);
else
#endif
out = _rl_screenchars - 1;
}
@@ -1616,6 +1637,11 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
if (_rl_last_v_pos != current_line)
{
_rl_move_vert (current_line);
/* We have moved up to a new screen line. This line may or may not have
invisible characters on it, but we do our best to recalculate
visible_wrap_offset based on what we know. */
if (current_line == 0)
visible_wrap_offset = prompt_invis_chars_first_line; /* XXX */
if ((MB_CUR_MAX == 1 || rl_byte_oriented) && current_line == 0 && visible_wrap_offset)
_rl_last_c_pos += visible_wrap_offset;
}
@@ -1627,16 +1653,31 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
string, then redraw the entire prompt string. We can only do this
reliably if the terminal supports a `cr' capability.
This can also happen if the prompt string has changed, and the first
difference in the line is in the middle of the prompt string, after a
sequence of invisible characters (worst case) and before the end of
the prompt. In this case, we have to redraw the entire prompt string
so that the entire sequence of invisible characters is drawn. We need
to handle the worst case, when the difference is after (or in the middle
of) a sequence of invisible characters that changes the text color and
before the sequence that restores the text color to normal. Then we have
to make sure that the lines still differ -- if they don't, we can
return immediately.
This is not an efficiency hack -- there is a problem with redrawing
portions of the prompt string if they contain terminal escape
sequences (like drawing the `unbold' sequence without a corresponding
`bold') that manifests itself on certain terminals. */
lendiff = local_prompt_len;
if (lendiff > nmax)
lendiff = nmax;
od = ofd - old; /* index of first difference in visible line */
nd = nfd - new;
if (current_line == 0 && !_rl_horizontal_scroll_mode &&
_rl_term_cr && lendiff > prompt_visible_length && _rl_last_c_pos > 0 &&
od >= lendiff && _rl_last_c_pos < PROMPT_ENDING_INDEX)
(((od > 0 || nd > 0) && (od < PROMPT_ENDING_INDEX || nd < PROMPT_ENDING_INDEX)) ||
((od >= lendiff) && _rl_last_c_pos < PROMPT_ENDING_INDEX)))
{
#if defined (__MSDOS__)
putc ('\r', rl_outstream);
@@ -1655,6 +1696,43 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
}
else
_rl_last_c_pos = lendiff + modmark;
/* Now if we have printed the prompt string because the first difference
was within the prompt, see if we need to recompute where the lines
differ. Check whether where we are now is past the last place where
the old and new lines are the same and short-circuit now if we are. */
if ((od < PROMPT_ENDING_INDEX || nd < PROMPT_ENDING_INDEX) &&
omax == nmax &&
lendiff > (ols-old) && lendiff > (nls-new))
return;
/* XXX - we need to fix up our calculations if we are now past the
old ofd/nfd and the prompt length (or line length) has changed.
We punt on the problem and do a dumb update. We'd like to be able
to just output the prompt from the beginning of the line up to the
first difference, but you don't know the number of invisible
characters in that case.
This needs a lot of work to be efficient. */
if ((od < PROMPT_ENDING_INDEX || nd < PROMPT_ENDING_INDEX))
{
nfd = new + lendiff; /* number of characters we output above */
nd = lendiff;
/* Do a dumb update and return */
temp = ne - nfd;
if (temp > 0)
{
_rl_output_some_chars (nfd, temp);
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
_rl_last_c_pos += _rl_col_width (new, nd, ne - new, 1);
else
_rl_last_c_pos += temp;
}
if (nmax < omax)
goto clear_rest_of_line; /* XXX */
else
return;
}
}
o_cpos = _rl_last_c_pos;
@@ -1816,11 +1894,15 @@ update_line (old, new, current_line, omax, nmax, inv_botlin)
char in the current line (which implies we just output some invisible
characters) we need to adjust _rl_last_c_pos, since it represents
a physical character position. */
/* The current_line*rl_screenwidth+prompt_invis_chars_first_line is a
crude attempt to compute how far into the new line buffer we are.
It doesn't work well in the face of multibyte characters and needs
to be rethought. XXX */
if ((MB_CUR_MAX > 1 && rl_byte_oriented == 0) &&
current_line == prompt_last_screen_line && wrap_offset &&
displaying_prompt_first_line &&
wrap_offset != prompt_invis_chars_first_line &&
((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth))))
((nfd-new) < (prompt_last_invisible-(current_line*_rl_screenwidth+prompt_invis_chars_first_line))))
{
_rl_last_c_pos -= wrap_offset - prompt_invis_chars_first_line;
cpos_adjusted = 1;
@@ -2039,7 +2121,8 @@ rl_redraw_prompt_last_line ()
(Well, when we don't have multibyte characters, _rl_last_c_pos is a
buffer index.)
DATA is the contents of the screen line of interest; i.e., where
the movement is being done. */
the movement is being done.
DATA is always the visible line or the invisible line */
void
_rl_move_cursor_relative (new, data)
int new;
@@ -2049,6 +2132,7 @@ _rl_move_cursor_relative (new, data)
int woff; /* number of invisible chars on current line */
int cpos, dpos; /* current and desired cursor positions */
int adjust;
int in_invisline;
woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
cpos = _rl_last_c_pos;
@@ -2087,14 +2171,28 @@ _rl_move_cursor_relative (new, data)
if (displaying_prompt_first_line == 0)
adjust = 0;
/* yet another special case: printing the last line of a prompt with
multibyte characters and invisible characters whose printable length
exceeds the screen width with the last invisible character
(prompt_last_invisible) in the last line. IN_INVISLINE is the
offset of DATA in invisible_line */
in_invisline = 0;
if (data > invisible_line && data < invisible_line+inv_lbreaks[_rl_inv_botlin+1])
in_invisline = data - invisible_line;
/* 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. */
/* NEW is relative to the current displayed line, while
PROMPT_LAST_INVISIBLE is relative to the entire (wrapped) line.
Need a way to reconcile these two variables by turning NEW into a
buffer position relative to the start of the line */
if (adjust && ((new > prompt_last_invisible) || /* XXX - don't use woff here */
(prompt_physical_chars >= _rl_screenwidth &&
(new+in_invisline > prompt_last_invisible) || /* invisible line */
(prompt_physical_chars >= _rl_screenwidth && /* visible line */
_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-(vis_lbreaks[_rl_last_v_pos])-wrap_offset))))
/* XXX last comparison might need to be >= */
{
dpos -= woff;
+1 -1
View File
@@ -12,7 +12,7 @@ This document describes the GNU History library
a programming tool that provides a consistent user interface for
recalling lines of previously typed input.
Copyright @copyright{} 1988--2014 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2016 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
+2 -1
View File
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
Copyright (C) 1988-2014 Free Software Foundation, Inc.
Copyright (C) 1988-2016 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@@ -242,6 +242,7 @@ is greater than the history length, return a @code{NULL} pointer.
@deftypefun time_t history_get_time (HIST_ENTRY *entry)
Return the time stamp associated with the history entry @var{entry}.
If the timestamp is missing or invalid, return 0.
@end deftypefun
@deftypefun int history_total_bytes (void)
+2 -2
View File
@@ -1,7 +1,7 @@
@ignore
This file documents the user interface to the GNU History library.
Copyright (C) 1988--2014 Free Software Foundation, Inc.
Copyright (C) 1988--2016 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
Permission is granted to make and distribute verbatim copies of this manual
@@ -102,7 +102,7 @@ associated with each history entry is written to the history file,
marked with the history comment character.
When the history file is read, lines beginning with the history
comment character followed immediately by a digit are interpreted
as timestamps for the previous history line.
as timestamps for the following history entry.
The builtin command @code{fc} may be used to list or edit and re-execute
a portion of the history list.
+1 -1
View File
@@ -13,7 +13,7 @@ This manual describes the GNU Readline Library
consistency of user interface across discrete programs which provide
a command line interface.
Copyright @copyright{} 1988--2014 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2016 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
+1 -1
View File
@@ -7,7 +7,7 @@ This document describes the GNU Readline Library, a utility for aiding
in the consistency of user interface across discrete programs that need
to provide a command line interface.
Copyright (C) 1988--2014 Free Software Foundation, Inc.
Copyright (C) 1988--2016 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
+4 -3
View File
@@ -9,7 +9,7 @@ use these features. There is a document entitled "readline.texinfo"
which contains both end-user and programmer documentation for the
GNU Readline Library.
Copyright (C) 1988--2014 Free Software Foundation, Inc.
Copyright (C) 1988--2016 Free Software Foundation, Inc.
Authored by Brian Fox and Chet Ramey.
@@ -608,8 +608,9 @@ Acceptable @code{keymap} names are
@code{vi-move},
@code{vi-command}, and
@code{vi-insert}.
@code{vi} is equivalent to @code{vi-command}; @code{emacs} is
equivalent to @code{emacs-standard}. The default value is @code{emacs}.
@code{vi} is equivalent to @code{vi-command} (@code{vi-move} is also a
synonym); @code{emacs} is equivalent to @code{emacs-standard}.
The default value is @code{emacs}.
The value of the @code{editing-mode} variable also affects the
default keymap.
+1 -1
View File
@@ -12,7 +12,7 @@ This manual describes the end user interface of the GNU Readline Library
consistency of user interface across discrete programs which provide
a command line interface.
Copyright @copyright{} 1988--2014 Free Software Foundation, Inc.
Copyright @copyright{} 1988--2016 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
+6 -6
View File
@@ -1,10 +1,10 @@
@ignore
Copyright (C) 1988-2015 Free Software Foundation, Inc.
Copyright (C) 1988-2016 Free Software Foundation, Inc.
@end ignore
@set EDITION 6.4
@set VERSION 6.4
@set UPDATED 28 May 2015
@set UPDATED-MONTH May 2015
@set EDITION 7.0
@set VERSION 7.0
@set UPDATED 25 January 2016
@set UPDATED-MONTH January 2016
@set LASTCHANGE Thu May 28 16:58:07 EDT 2015
@set LASTCHANGE Mon Jan 25 10:08:41 EST 2016
+1 -1
View File
@@ -1,6 +1,6 @@
/* funmap.c -- attach names to functions. */
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 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.
+1 -1
View File
@@ -1,6 +1,6 @@
/* histexpand.c -- history expansion. */
/* Copyright (C) 1989-2012 Free Software Foundation, Inc.
/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
+37 -8
View File
@@ -1,6 +1,6 @@
/* histfile.c - functions to manipulate the history file. */
/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
/* Copyright (C) 1989-2016 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -107,9 +107,19 @@ extern int errno;
# define PATH_MAX 1024 /* default */
#endif
extern void _hs_append_history_line PARAMS((int, const char *));
/* history file version; currently unused */
int history_file_version = 1;
/* If non-zero, we write timestamps to the history file in history_do_write() */
int history_write_timestamps = 0;
/* If non-zero, we assume that a history file that starts with a timestamp
uses timestamp-delimited entries and can include multi-line history
entries. Used by read_history_range */
int history_multiline_entries = 0;
/* Immediately after a call to read_history() or read_history_range(), this
will return the number of lines just read from the history file in that
call. */
@@ -259,7 +269,7 @@ read_history_range (filename, from, to)
{
register char *line_start, *line_end, *p;
char *input, *buffer, *bufend, *last_ts;
int file, current_line, chars_read;
int file, current_line, chars_read, has_timestamps, reset_comment_char;
struct stat finfo;
size_t file_size;
#if defined (EFBIG)
@@ -336,6 +346,19 @@ read_history_range (filename, from, to)
bufend = buffer + chars_read;
current_line = 0;
/* Heuristic: the history comment character rarely changes, so assume we
have timestamps if the buffer starts with `#[:digit:]' and temporarily
set history_comment_char so timestamp parsing works right */
reset_comment_char = 0;
if (history_comment_char == '\0' && buffer[0] == '#' && isdigit ((unsigned char)buffer[1]))
{
history_comment_char = '#';
reset_comment_char = 1;
}
has_timestamps = HIST_TIMESTAMP_START (buffer);
history_multiline_entries += has_timestamps && history_write_timestamps;
/* Skip lines until we are at FROM. */
for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
if (*line_end == '\n')
@@ -362,7 +385,10 @@ read_history_range (filename, from, to)
{
if (HIST_TIMESTAMP_START(line_start) == 0)
{
add_history (line_start);
if (last_ts == NULL && history_multiline_entries)
_hs_append_history_line (history_length - 1, line_start);
else
add_history (line_start);
if (last_ts)
{
add_history_time (last_ts);
@@ -385,6 +411,8 @@ read_history_range (filename, from, to)
}
history_lines_read_from_file = current_line;
if (reset_comment_char)
history_comment_char = '\0';
FREE (input);
#ifndef HISTORY_USE_MMAP
@@ -447,7 +475,7 @@ history_truncate_file (fname, lines)
int lines;
{
char *buffer, *filename, *tempname, *bp, *bp1; /* bp1 == bp+1 */
int file, chars_read, rv, orig_lines, exists;
int file, chars_read, rv, orig_lines, exists, r;
struct stat finfo;
size_t file_size;
@@ -583,7 +611,7 @@ history_truncate_file (fname, lines)
with a shared history file, we don't want to leave the history file
owned by root. */
if (rv == 0 && exists)
chown (filename, finfo.st_uid, finfo.st_gid);
r = chown (filename, finfo.st_uid, finfo.st_gid);
xfree (filename);
FREE (tempname);
@@ -613,10 +641,11 @@ history_do_write (filename, nelements, overwrite)
mode = overwrite ? O_WRONLY|O_CREAT|O_TRUNC|O_BINARY : O_WRONLY|O_APPEND|O_BINARY;
#endif
histname = history_filename (filename);
tempname = (overwrite && histname) ? history_tempfile (histname) : 0;
output = tempname ? tempname : histname;
exists = histname ? (stat (histname, &finfo) == 0) : 0;
tempname = (overwrite && exists && S_ISREG (finfo.st_mode)) ? history_tempfile (histname) : 0;
output = tempname ? tempname : histname;
file = output ? open (output, mode, 0600) : -1;
rv = 0;
@@ -729,7 +758,7 @@ mmap_error:
with a shared history file, we don't want to leave the history file
owned by root. */
if (rv == 0 && exists)
chown (histname, finfo.st_uid, finfo.st_gid);
mode = chown (histname, finfo.st_uid, finfo.st_gid);
FREE (histname);
FREE (tempname);
+25 -1
View File
@@ -1,6 +1,6 @@
/* history.c -- standalone history library */
/* Copyright (C) 1989-2011 Free Software Foundation, Inc.
/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -407,6 +407,30 @@ replace_history_entry (which, line, data)
return (old_value);
}
/* Append LINE to the history line at offset WHICH, adding a newline to the
end of the current line first. This can be used to construct multi-line
history entries while reading lines from the history file. */
void
_hs_append_history_line (which, line)
int which;
const char *line;
{
HIST_ENTRY *hent;
size_t newlen, curlen;
char *newline;
hent = the_history[which];
curlen = strlen (hent->line);
newlen = curlen + strlen (line) + 2;
newline = realloc (hent->line, newlen);
if (newline)
{
hent->line = newline;
hent->line[curlen++] = '\n';
strcpy (hent->line + curlen, line);
}
}
/* Replace the DATA in the specified history entries, replacing OLD with
NEW. WHICH says which one(s) to replace: WHICH == -1 means to replace
all of the history entries where entry->data == OLD; WHICH == -2 means
+5 -1
View File
@@ -1,6 +1,6 @@
/* history.h -- the names of functions that you can call in history. */
/* Copyright (C) 1989-2009 Free Software Foundation, Inc.
/* Copyright (C) 1989-2015 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -263,6 +263,10 @@ extern int history_quotes_inhibit_expansion;
extern int history_write_timestamps;
/* These two are undocumented; the second is reserved for future use */
extern int history_multiline_entries;
extern int history_file_version;
/* Backwards compatibility */
extern int max_input_history;
+12 -2
View File
@@ -6,7 +6,7 @@
/* */
/* **************************************************************** */
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 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.
@@ -560,8 +560,12 @@ add_character:
if (wstart >= 0)
cxt->search_string[cxt->search_string_index = wstart] = '\0';
else
rl_ding ();
cxt->search_string[cxt->search_string_index = 0] = '\0';
}
if (cxt->search_string_index == 0)
rl_ding ();
break;
case -4: /* C-G, abort */
@@ -654,6 +658,12 @@ add_character:
for (cxt->sflags &= ~(SF_FOUND|SF_FAILED);; )
{
if (cxt->search_string_index == 0)
{
cxt->sflags |= SF_FAILED;
break;
}
limit = cxt->sline_len - cxt->search_string_index + 1;
/* Search the current line. */
+1 -1
View File
@@ -1,6 +1,6 @@
/* kill.c -- kill ring management. */
/* Copyright (C) 1994 Free Software Foundation, Inc.
/* Copyright (C) 1994-2015 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.
+2 -2
View File
@@ -1,6 +1,6 @@
/* mbutil.c -- readline multibyte character utility functions */
/* Copyright (C) 2001-2009 Free Software Foundation, Inc.
/* Copyright (C) 2001-2015 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.
@@ -145,7 +145,7 @@ _rl_find_next_mbchar_internal (string, seed, count, find_non_zero)
return point;
}
static int
/*static*/ int
_rl_find_prev_mbchar_internal (string, seed, find_non_zero)
char *string;
int seed, find_non_zero;
+1 -1
View File
@@ -1,6 +1,6 @@
/* misc.c -- miscellaneous bindable readline functions. */
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 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.
+1 -1
View File
@@ -1,6 +1,6 @@
/* parens.c -- implementation of matching parentheses feature. */
/* Copyright (C) 1987, 1989, 1992-2009 Free Software Foundation, Inc.
/* Copyright (C) 1987, 1989, 1992-2015 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.
+2 -3
View File
@@ -1,7 +1,7 @@
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
/* Copyright (C) 1987-2016 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.
@@ -563,8 +563,7 @@ readline_internal_charloop ()
{
/* Then initialize the argument and number of keys read. */
_rl_reset_argument ();
rl_key_sequence_length = 0;
rl_executing_keyseq[0] = 0;
rl_executing_keyseq[rl_key_sequence_length = 0] = '\0';
}
RL_SETSTATE(RL_STATE_READCMD);
+1 -1
View File
@@ -1,6 +1,6 @@
/* Readline.h -- the names of functions callable from within readline. */
/* Copyright (C) 1987-2013 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 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.
+1 -1
View File
@@ -1,6 +1,6 @@
/* rlconf.h -- readline configuration definitions */
/* Copyright (C) 1992-2012 Free Software Foundation, Inc.
/* Copyright (C) 1992-2015 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.
+1 -1
View File
@@ -1,6 +1,6 @@
/* rlmbutil.h -- utility functions for multibyte characters. */
/* Copyright (C) 2001-2009 Free Software Foundation, Inc.
/* Copyright (C) 2001-2015 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.
+1 -1
View File
@@ -1,7 +1,7 @@
/* rlprivate.h -- functions and variables global to the readline library,
but not intended for use by applications. */
/* Copyright (C) 1999-2012 Free Software Foundation, Inc.
/* Copyright (C) 1999-2015 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.
+1 -1
View File
@@ -1,7 +1,7 @@
/* rltty.c -- functions to prepare and restore the terminal for readline's
use. */
/* Copyright (C) 1992-2005 Free Software Foundation, Inc.
/* Copyright (C) 1992-2015 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.
+1 -1
View File
@@ -1,6 +1,6 @@
/* search.c - code for non-incremental searching in emacs and vi modes. */
/* Copyright (C) 1992-2013 Free Software Foundation, Inc.
/* Copyright (C) 1992-2015 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.
+1 -1
View File
@@ -1,6 +1,6 @@
/* signals.c -- signal handling support for readline. */
/* Copyright (C) 1987-2011 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 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.
+1 -1
View File
@@ -1,6 +1,6 @@
/* tcap.h -- termcap library functions and variables. */
/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
/* Copyright (C) 1996-2015 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.
+1 -1
View File
@@ -1,6 +1,6 @@
/* terminal.c -- controlling the terminal with termcap. */
/* Copyright (C) 1996-2009 Free Software Foundation, Inc.
/* Copyright (C) 1996-2015 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.
+3 -1
View File
@@ -1,6 +1,6 @@
/* text.c -- text handling commands for readline. */
/* Copyright (C) 1987-2010 Free Software Foundation, Inc.
/* Copyright (C) 1987-2016 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.
@@ -931,6 +931,8 @@ rl_insert (count, c)
/* setting rl_pending_input inhibits setting rl_last_func so we do it
ourselves here */
rl_last_func = rl_insert;
_rl_reset_argument ();
rl_executing_keyseq[rl_key_sequence_length = 0] = '\0';
r = rl_execute_next (n);
}
+2 -3
View File
@@ -1,7 +1,6 @@
/* readline.c -- a general facility for reading lines of input
with emacs style editing and completion. */
/* undo.c - manage list of changes to lines, offering opportunity to undo them */
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 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.
+4 -2
View File
@@ -1,6 +1,6 @@
/* util.c -- readline utility functions */
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 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.
@@ -198,12 +198,14 @@ rl_tilde_expand (ignore, key)
xfree (homedir);
return (0);
}
else if (rl_line_buffer[start] != '~')
else if (start >= 0 && rl_line_buffer[start] != '~')
{
for (; !whitespace (rl_line_buffer[start]) && start >= 0; start--)
;
start++;
}
else if (start < 0)
start = 0;
end = start;
do
+1 -1
View File
@@ -1,7 +1,7 @@
/* vi_mode.c -- A vi emulation mode for Bash.
Derived from code written by Jeff Sparkes (jsparkes@bnr.ca). */
/* Copyright (C) 1987-2012 Free Software Foundation, Inc.
/* Copyright (C) 1987-2015 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.
+4
View File
@@ -409,12 +409,14 @@ shmatch.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
shquote.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h
shquote.o: ${BASHINCDIR}/ansi_stdlib.h ${topdir}/xmalloc.h
shquote.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
shtty.o: ${BASHINCDIR}/shtty.h
shtty.o: ${BASHINCDIR}/stdc.h
snprintf.o: ${BASHINCDIR}/stdc.h ${topdir}/bashansi.h ${topdir}/xmalloc.h
snprintf.o: ${BASHINCDIR}/ansi_stdlib.h ${BASHINCDIR}/chartypes.h
snprintf.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
snprintf.o: ${BASHINCDIR}/typemax.h
spell.o: ${topdir}/bashtypes.h
@@ -493,6 +495,7 @@ strtrans.o: ${topdir}/array.h ${topdir}/hashlib.h ${topdir}/quit.h
strtrans.o: ${topdir}/unwind_prot.h ${topdir}/dispose_cmd.h
strtrans.o: ${topdir}/make_cmd.h ${topdir}/subst.h ${topdir}/sig.h
strtrans.o: ${BUILD_DIR}/pathnames.h ${topdir}/externs.h
strtrans.o: ${BASHINCDIR}/shmbutil.h ${BASHINCDIR}/shmbchar.h
#strtrans.o: ${BUILD_DIR}/version.h
times.o: ${BASHINCDIR}/systimes.h
@@ -603,6 +606,7 @@ fnxform.o: ${topdir}/bashtypes.h
fnxform.o: ${topdir}/bashintl.h ${LIBINTL_H} ${BASHINCDIR}/gettext.h
shmbchar.o: ${BASHINCDIR}/shmbchar.h
shmbchar.o: ${BASHINCDIR}/shmbutil.h
unicode.o: ${topdir}/bashansi.h ${BASHINCDIR}/ansi_stdlib.h
unicode.o: ${BASHINCDIR}/stdc.h
+2 -1
View File
@@ -109,10 +109,11 @@ sh_modcase (string, pat, flags)
int inword, c, nc, nop, match, usewords;
char *ret, *s;
wchar_t wc;
int mb_cur_max;
#if defined (HANDLE_MULTIBYTE)
wchar_t nwc;
char mb[MB_LEN_MAX+1];
int mlen, mb_cur_max;
int mlen;
size_t m;
mbstate_t state;
#endif
+1 -1
View File
@@ -1,6 +1,6 @@
/* mbscasecmp - case-insensitive multibyte string comparison. */
/* Copyright (C) 2009 Free Software Foundation, Inc.
/* Copyright (C) 2009-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,6 +1,6 @@
/* mbscmp - multibyte string comparison. */
/* Copyright (C) 1995 Free Software Foundation, Inc.
/* Copyright (C) 1995-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2001, 2006, 2009, 2010, 2012 Free Software Foundation, Inc.
/* Copyright (C) 2001, 2006, 2009, 2010, 2012, 2015 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,6 +1,6 @@
/* shquote - functions to quote and dequote strings */
/* Copyright (C) 1999 Free Software Foundation, Inc.
/* Copyright (C) 1999-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,6 +1,6 @@
/* strtrans.c - Translate and untranslate strings with ANSI-C escape sequences. */
/* Copyright (C) 2000-2011 Free Software Foundation, Inc.
/* Copyright (C) 2000-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+6 -1
View File
@@ -2,7 +2,7 @@
* tmpfile.c - functions to create and safely open temp files for the shell.
*/
/* Copyright (C) 2000 Free Software Foundation, Inc.
/* Copyright (C) 2000-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -47,6 +47,11 @@ extern int errno;
#define DEFAULT_TMPDIR "." /* bogus default, should be changed */
#define DEFAULT_NAMEROOT "shtmp"
/* Use ANSI-C rand() interface if random(3) is not available */
#if !HAVE_RANDOM
#define random() rand()
#endif
extern pid_t dollar_dollar_pid;
static char *get_sys_tmpdir __P((void));
+1 -1
View File
@@ -1,6 +1,6 @@
/* unicode.c - functions to convert unicode characters */
/* Copyright (C) 2010-2012 Free Software Foundation, Inc.
/* Copyright (C) 2010-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,6 +1,6 @@
/* winsize.c - handle window size changes and information. */
/* Copyright (C) 2005 Free Software Foundation, Inc.
/* Copyright (C) 2005-2015 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.