mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-08-07 02:32:27 +02:00
Bash-5.3-rc2 release
This commit is contained in:
@@ -809,7 +809,7 @@ rl_redisplay (void)
|
||||
{
|
||||
int in, out, c, linenum, cursor_linenum;
|
||||
int inv_botlin, lb_botlin, lb_linenum, o_cpos;
|
||||
int newlines, lpos, temp, num, prompt_lines_estimate;
|
||||
int newlines, lpos, temp, num;
|
||||
char *prompt_this_line;
|
||||
char cur_face;
|
||||
int hl_begin, hl_end;
|
||||
@@ -1014,9 +1014,6 @@ rl_redisplay (void)
|
||||
on the first and last prompt lines; change that to use
|
||||
local_prompt_invis_chars */
|
||||
|
||||
/* This is zero-based, used to set the newlines */
|
||||
prompt_lines_estimate = lpos / _rl_screenwidth;
|
||||
|
||||
/* what if lpos is already >= _rl_screenwidth before we start drawing the
|
||||
contents of the command line? */
|
||||
if (lpos >= _rl_screenwidth)
|
||||
@@ -1908,7 +1905,6 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
|
||||
if (newwidth > 0)
|
||||
{
|
||||
int i, j;
|
||||
char *optr;
|
||||
|
||||
puts_face (new, new_face, newbytes);
|
||||
_rl_last_c_pos = newwidth;
|
||||
|
||||
@@ -79,9 +79,11 @@ main (int c, char **v)
|
||||
/* Set the default locale values according to environment variables. */
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
#if defined (SIGWINCH)
|
||||
/* Handle window size changes when readline is not active and reading
|
||||
characters. */
|
||||
signal (SIGWINCH, sighandler);
|
||||
#endif
|
||||
|
||||
/* Install the line handler. */
|
||||
rl_callback_handler_install (prompt, cb_linehandler);
|
||||
|
||||
@@ -679,7 +679,7 @@ history_expand_internal (const char *string, int start, int qc, int *end_index_p
|
||||
case 's':
|
||||
{
|
||||
char *new_event;
|
||||
int delimiter, failed, si, l_temp, ws, we;
|
||||
int delimiter, failed, si, l_temp, we;
|
||||
|
||||
if (c == 's')
|
||||
{
|
||||
@@ -778,7 +778,6 @@ history_expand_internal (const char *string, int start, int qc, int *end_index_p
|
||||
{
|
||||
for (; temp[si] && fielddelim (temp[si]); si++)
|
||||
;
|
||||
ws = si;
|
||||
we = history_tokenize_word (temp, si);
|
||||
}
|
||||
|
||||
|
||||
+22
-3
@@ -182,6 +182,7 @@ history_filename (const char *filename)
|
||||
return (return_val);
|
||||
}
|
||||
|
||||
#if defined (DEBUG)
|
||||
static char *
|
||||
history_backupfile (const char *filename)
|
||||
{
|
||||
@@ -208,6 +209,7 @@ history_backupfile (const char *filename)
|
||||
ret[len+1] = '\0';
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
static char *
|
||||
history_tempfile (const char *filename)
|
||||
@@ -267,6 +269,7 @@ read_history_range (const char *filename, int from, int to)
|
||||
register char *line_start, *line_end, *p;
|
||||
char *input, *buffer, *bufend, *last_ts;
|
||||
int file, current_line, chars_read, has_timestamps, reset_comment_char;
|
||||
int skipblanks, default_skipblanks;
|
||||
struct stat finfo;
|
||||
size_t file_size;
|
||||
#if defined (EFBIG)
|
||||
@@ -380,6 +383,9 @@ read_history_range (const char *filename, int from, int to)
|
||||
has_timestamps = HIST_TIMESTAMP_START (buffer);
|
||||
history_multiline_entries += has_timestamps && history_write_timestamps;
|
||||
|
||||
/* default is to skip blank lines unless history entries are multiline */
|
||||
default_skipblanks = history_multiline_entries == 0;
|
||||
|
||||
/* Skip lines until we are at FROM. */
|
||||
if (has_timestamps)
|
||||
last_ts = buffer;
|
||||
@@ -405,6 +411,8 @@ read_history_range (const char *filename, int from, int to)
|
||||
}
|
||||
}
|
||||
|
||||
skipblanks = default_skipblanks;
|
||||
|
||||
/* If there are lines left to gobble, then gobble them now. */
|
||||
for (line_end = line_start; line_end < bufend; line_end++)
|
||||
if (*line_end == '\n')
|
||||
@@ -415,10 +423,16 @@ read_history_range (const char *filename, int from, int to)
|
||||
else
|
||||
*line_end = '\0';
|
||||
|
||||
if (*line_start)
|
||||
if (*line_start || skipblanks == 0)
|
||||
{
|
||||
if (HIST_TIMESTAMP_START(line_start) == 0)
|
||||
{
|
||||
/* If we have multiline entries (default_skipblanks == 0), we
|
||||
don't want to skip blanks here, since we turned that on at
|
||||
the last timestamp line. Consider doing this even if
|
||||
default_skipblanks == 1 in order not to lose blank lines in
|
||||
commands. */
|
||||
skipblanks = default_skipblanks;
|
||||
if (last_ts == NULL && history_length > 0 && history_multiline_entries)
|
||||
_hs_append_history_line (history_length - 1, line_start);
|
||||
else
|
||||
@@ -433,6 +447,9 @@ read_history_range (const char *filename, int from, int to)
|
||||
{
|
||||
last_ts = line_start;
|
||||
current_line--;
|
||||
/* Even if we're not skipping blank lines by default, we want
|
||||
to skip leading blank lines after a timestamp. */
|
||||
skipblanks = 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -470,6 +487,7 @@ history_rename (const char *old, const char *new)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined (DEBUG)
|
||||
/* Save FILENAME to BACK, handling case where FILENAME is a symlink
|
||||
(e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */
|
||||
static int
|
||||
@@ -488,6 +506,7 @@ histfile_backup (const char *filename, const char *back)
|
||||
#endif
|
||||
return (history_rename (filename, back));
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Restore ORIG from BACKUP handling case where ORIG is a symlink
|
||||
(e.g., ~/.bash_history -> .histfiles/.bash_history.$HOSTNAME) */
|
||||
@@ -708,13 +727,13 @@ static int
|
||||
history_write_slow (int fd, HIST_ENTRY **the_history, int nelements, int overwrite)
|
||||
{
|
||||
FILE *fp;
|
||||
int i, j, e;
|
||||
int i, e;
|
||||
|
||||
fp = fdopen (fd, overwrite ? "w" : "a");
|
||||
if (fp == 0)
|
||||
return -1;
|
||||
|
||||
for (j = 0, i = history_length - nelements; i < history_length; i++)
|
||||
for (i = history_length - nelements; i < history_length; i++)
|
||||
{
|
||||
if (history_write_timestamps && the_history[i]->timestamp && the_history[i]->timestamp[0])
|
||||
fprintf (fp, "%s\n", the_history[i]->timestamp);
|
||||
|
||||
@@ -202,7 +202,7 @@ using_history (void)
|
||||
int
|
||||
history_total_bytes (void)
|
||||
{
|
||||
register int i, result;
|
||||
int i, result;
|
||||
|
||||
for (i = result = 0; the_history && the_history[i]; i++)
|
||||
result += HISTENT_BYTES (the_history[i]);
|
||||
@@ -545,7 +545,7 @@ void
|
||||
_hs_replace_history_data (int which, histdata_t *old, histdata_t *new)
|
||||
{
|
||||
HIST_ENTRY *entry;
|
||||
register int i, last;
|
||||
int i, last;
|
||||
|
||||
if (which < -2 || which >= history_length || history_length == 0 || the_history == 0)
|
||||
return;
|
||||
@@ -581,7 +581,7 @@ _hs_replace_history_data (int which, histdata_t *old, histdata_t *new)
|
||||
int
|
||||
_hs_search_history_data (histdata_t *needle)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
HIST_ENTRY *entry;
|
||||
|
||||
if (history_length == 0 || the_history == 0)
|
||||
@@ -605,10 +605,11 @@ HIST_ENTRY *
|
||||
remove_history (int which)
|
||||
{
|
||||
HIST_ENTRY *return_value;
|
||||
register int i;
|
||||
#if 1
|
||||
int nentries;
|
||||
HIST_ENTRY **start, **end;
|
||||
#else
|
||||
int i;
|
||||
#endif
|
||||
|
||||
if (which < 0 || which >= history_length || history_length == 0 || the_history == 0)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* input.c -- character input functions for readline. */
|
||||
|
||||
/* Copyright (C) 1994-2022 Free Software Foundation, Inc.
|
||||
/* Copyright (C) 1994-2025 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.
|
||||
@@ -554,15 +554,15 @@ reset_alarm ()
|
||||
timerclear (&it.it_value);
|
||||
setitimer (ITIMER_REAL, &it, NULL);
|
||||
}
|
||||
# else
|
||||
# if defined (__MINGW32_MAJOR_VERSION)
|
||||
# else /* !HAVE_SETITIMER */
|
||||
# if defined (__MINGW32_MAJOR_VERSION)
|
||||
/* mingw.org's MinGW doesn't have alarm(3). */
|
||||
unsigned int
|
||||
alarm (unsigned int seconds)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
# endif /* __MINGW32_MAJOR_VERSION */
|
||||
|
||||
static int
|
||||
set_alarm (unsigned int *secs, unsigned int *usecs)
|
||||
@@ -578,8 +578,8 @@ reset_alarm ()
|
||||
{
|
||||
alarm (0);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
# endif /* !HAVE_SETITIMER */
|
||||
#endif /* RL_TIMEOUT_USE_SIGALRM */
|
||||
|
||||
/* Set a timeout which will be used for the next call of `readline
|
||||
()'. When (0, 0) are specified the timeout is cleared. */
|
||||
@@ -921,7 +921,7 @@ rl_getc (FILE *stream)
|
||||
|
||||
/* fprintf(stderr, "rl_getc: result = %d errno = %d\n", result, errno); */
|
||||
|
||||
handle_error:
|
||||
/* Handle errors here. */
|
||||
osig = _rl_caught_signal;
|
||||
ostate = rl_readline_state;
|
||||
|
||||
|
||||
@@ -1366,6 +1366,7 @@ readline_default_bindings (void)
|
||||
rl_tty_set_default_bindings (_rl_keymap);
|
||||
}
|
||||
|
||||
#if defined (DEBUG)
|
||||
/* Reset the default bindings for the terminal special characters we're
|
||||
interested in back to rl_insert and read the new ones. */
|
||||
static void
|
||||
@@ -1377,6 +1378,7 @@ reset_default_bindings (void)
|
||||
rl_tty_set_default_bindings (_rl_keymap);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Bind some common arrow key sequences in MAP. */
|
||||
static void
|
||||
|
||||
@@ -590,7 +590,6 @@ rl_history_search_internal (int count, int dir)
|
||||
{
|
||||
HIST_ENTRY *temp;
|
||||
int ret, oldpos, newcol;
|
||||
char *t;
|
||||
|
||||
oldpos = where_history (); /* where are we now? */
|
||||
temp = (HIST_ENTRY *)NULL;
|
||||
@@ -650,6 +649,7 @@ rl_history_search_internal (int count, int dir)
|
||||
else
|
||||
{
|
||||
#if 0
|
||||
char *t;
|
||||
t = strstr (rl_line_buffer, history_search_string); /* XXX */
|
||||
rl_point = t ? (int)(t - rl_line_buffer) + _rl_history_search_len : rl_end;
|
||||
#else
|
||||
|
||||
@@ -118,8 +118,10 @@ sh_single_quote (char *string)
|
||||
/* Set the environment variables LINES and COLUMNS to lines and cols,
|
||||
respectively. */
|
||||
static char setenv_buf[INT_STRLEN_BOUND (int) + 1];
|
||||
#if defined (HAVE_PUTENV) && !defined (HAVE_SETENV)
|
||||
static char putenv_buf1[INT_STRLEN_BOUND (int) + 6 + 1]; /* sizeof("LINES=") == 6 */
|
||||
static char putenv_buf2[INT_STRLEN_BOUND (int) + 8 + 1]; /* sizeof("COLUMNS=") == 8 */
|
||||
#endif
|
||||
|
||||
void
|
||||
sh_set_lines_and_columns (int lines, int cols)
|
||||
|
||||
+12
-4
@@ -102,12 +102,20 @@ static char *term_string_buffer = (char *)NULL;
|
||||
|
||||
static int tcap_initialized;
|
||||
|
||||
#if !defined (__linux__) && !defined (NCURSES_VERSION)
|
||||
# if defined (__EMX__) || defined (NEED_EXTERN_PC)
|
||||
/* Systems for which PC/BC/UP are defined in the curses library and need an
|
||||
extern definition here. */
|
||||
#if !defined (__linux__) && !defined (__gnu_hurd__) && !defined (NCURSES_VERSION)
|
||||
# define NEED_EXTERN_PC
|
||||
#endif /* !__linux__ && !__gnu_hurd__ && !NCURSES_VERSION */
|
||||
|
||||
#if defined (__EMX__)
|
||||
# define NEED_EXTERN_PC
|
||||
#endif
|
||||
|
||||
#if defined (NEED_EXTERN_PC)
|
||||
extern
|
||||
# endif /* __EMX__ || NEED_EXTERN_PC */
|
||||
# endif /* NEED_EXTERN_PC */
|
||||
char PC, *BC, *UP;
|
||||
#endif /* !__linux__ && !NCURSES_VERSION */
|
||||
|
||||
/* Some strings to control terminal actions. These are output by tputs (). */
|
||||
char *_rl_term_clreol;
|
||||
|
||||
+1
-1
@@ -292,7 +292,7 @@ _rl_strpbrk (const char *string1, const char *string2)
|
||||
register const char *scan;
|
||||
#if defined (HANDLE_MULTIBYTE)
|
||||
mbstate_t ps;
|
||||
register int i, v;
|
||||
int v;
|
||||
|
||||
memset (&ps, 0, sizeof (mbstate_t));
|
||||
#endif
|
||||
|
||||
+70
-53
@@ -57,8 +57,41 @@ void zreset (void);
|
||||
|
||||
int zungetc (int);
|
||||
|
||||
/* Provide one character of pushback whether we are using read or zread. */
|
||||
static int zpushedchar = -1;
|
||||
/* Provide 16 bytes of pushback whether we are using read or zread. Only used
|
||||
by the read builtin when reading invalid multibyte characters. */
|
||||
#define ZPUSHSIZE 16
|
||||
|
||||
static size_t zpushind, zpopind;
|
||||
static unsigned char zpushbuf[ZPUSHSIZE];
|
||||
static unsigned char zbufchar;
|
||||
|
||||
static inline int
|
||||
zbufpop(unsigned char *cp)
|
||||
{
|
||||
if (zpushind == zpopind)
|
||||
return (0);
|
||||
*cp = zpushbuf[zpopind++];
|
||||
if (zpopind == zpushind)
|
||||
zpopind = zpushind = 0; /* reset, buffer empty */
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int
|
||||
zbufpush(int c)
|
||||
{
|
||||
if (zpushind == ZPUSHSIZE - 1)
|
||||
return 0;
|
||||
zpushbuf[zpushind++] = c;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Add C to the pushback buffer. Can't push back EOF */
|
||||
int
|
||||
zungetc (int c)
|
||||
{
|
||||
zbufpush (c);
|
||||
return c;
|
||||
}
|
||||
|
||||
/* Read LEN bytes from FD into BUF. Retry the read on EINTR. Any other
|
||||
error causes the loop to break. */
|
||||
@@ -69,11 +102,10 @@ zread (int fd, char *buf, size_t len)
|
||||
|
||||
check_signals (); /* check for signals before a blocking read */
|
||||
|
||||
/* If we pushed a char back, return it immediately */
|
||||
if (zpushedchar != -1)
|
||||
/* If we pushed chars back, return the oldest one immediately */
|
||||
if (zbufpop (&zbufchar))
|
||||
{
|
||||
*buf = (unsigned char)zpushedchar;
|
||||
zpushedchar = -1;
|
||||
*buf = zbufchar;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -114,11 +146,10 @@ zreadretry (int fd, char *buf, size_t len)
|
||||
ssize_t r;
|
||||
int nintr;
|
||||
|
||||
/* If we pushed a char back, return it immediately */
|
||||
if (zpushedchar != -1)
|
||||
/* If we pushed chars back, return the oldest one immediately */
|
||||
if (zbufpop (&zbufchar))
|
||||
{
|
||||
*buf = (unsigned char)zpushedchar;
|
||||
zpushedchar = -1;
|
||||
*buf = zbufchar;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -143,14 +174,13 @@ zreadintr (int fd, char *buf, size_t len)
|
||||
{
|
||||
check_signals ();
|
||||
|
||||
/* If we pushed a char back, return it immediately */
|
||||
if (zpushedchar != -1)
|
||||
{
|
||||
*buf = (unsigned char)zpushedchar;
|
||||
zpushedchar = -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If we pushed chars back, return the oldest one immediately */
|
||||
if (zbufpop (&zbufchar))
|
||||
{
|
||||
*buf = zbufchar;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (read (fd, buf, len));
|
||||
}
|
||||
|
||||
@@ -166,14 +196,13 @@ zreadc (int fd, char *cp)
|
||||
{
|
||||
ssize_t nr;
|
||||
|
||||
/* If we pushed a char back, return it immediately */
|
||||
if (zpushedchar != -1 && cp)
|
||||
{
|
||||
*cp = (unsigned char)zpushedchar;
|
||||
zpushedchar = -1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* If we pushed chars back, return the oldest one immediately */
|
||||
if (cp && zbufpop (&zbufchar))
|
||||
{
|
||||
*cp = zbufchar;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lind == lused || lused == 0)
|
||||
{
|
||||
nr = zread (fd, lbuf, sizeof (lbuf));
|
||||
@@ -197,12 +226,11 @@ zreadcintr (int fd, char *cp)
|
||||
{
|
||||
ssize_t nr;
|
||||
|
||||
/* If we pushed a char back, return it immediately */
|
||||
if (zpushedchar != -1 && cp)
|
||||
{
|
||||
*cp = (unsigned char)zpushedchar;
|
||||
zpushedchar = -1;
|
||||
return 1;
|
||||
/* If we pushed chars back, return the oldest one immediately */
|
||||
if (cp && zbufpop (&zbufchar))
|
||||
{
|
||||
*cp = zbufchar;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lind == lused || lused == 0)
|
||||
@@ -228,11 +256,11 @@ zreadn (int fd, char *cp, size_t len)
|
||||
{
|
||||
ssize_t nr;
|
||||
|
||||
if (zpushedchar != -1 && cp)
|
||||
{
|
||||
*cp = zpushedchar;
|
||||
zpushedchar = -1;
|
||||
return 1;
|
||||
/* If we pushed chars back, return the oldest one immediately */
|
||||
if (cp && zbufpop (&zbufchar))
|
||||
{
|
||||
*cp = zbufchar;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (lind == lused || lused == 0)
|
||||
@@ -253,25 +281,11 @@ zreadn (int fd, char *cp, size_t len)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
zungetc (int c)
|
||||
{
|
||||
if (zpushedchar == -1)
|
||||
{
|
||||
zpushedchar = c;
|
||||
return c;
|
||||
}
|
||||
|
||||
if (c == EOF || lind == 0)
|
||||
return (EOF);
|
||||
lbuf[--lind] = c; /* XXX */
|
||||
return c;
|
||||
}
|
||||
|
||||
void
|
||||
zreset (void)
|
||||
{
|
||||
lind = lused = 0;
|
||||
zpushind = zpopind = 0;
|
||||
}
|
||||
|
||||
/* Sync the seek pointer for FD so that the kernel's idea of the last char
|
||||
@@ -287,5 +301,8 @@ zsyncfd (int fd)
|
||||
r = lseek (fd, -off, SEEK_CUR);
|
||||
|
||||
if (r != -1)
|
||||
lused = lind = 0;
|
||||
{
|
||||
lused = lind = 0;
|
||||
zpushind = zpopind = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user