some fixes for static analysis findings; fix for brace expansion being too greedy checking sequence expressions; fix for strip targets when cross-compiling

This commit is contained in:
Chet Ramey
2025-05-19 09:10:57 -04:00
parent 535a8150b6
commit 870ad4c92b
21 changed files with 819 additions and 39 deletions
+1 -5
View File
@@ -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;
+1 -2
View File
@@ -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);
}
+6 -2
View File
@@ -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)
@@ -485,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
@@ -503,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) */
@@ -723,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);
+5 -4
View File
@@ -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 -1
View File
@@ -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;
+2
View File
@@ -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
+1 -1
View File
@@ -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
+2
View File
@@ -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
View File
@@ -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
View File
@@ -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