final set of ANSI C changes

This commit is contained in:
Chet Ramey
2023-01-05 15:09:06 -05:00
parent 5b512e1121
commit 2e725f7346
84 changed files with 390 additions and 347 deletions
+3 -4
View File
@@ -1,6 +1,6 @@
/* bind.c -- key binding and startup file support for the readline library. */
/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
/* Copyright (C) 1987-2023 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.
@@ -1247,7 +1247,7 @@ const char *rl_readline_name = "other";
/* Stack of previous values of parsing_conditionalized_out. */
static unsigned char *if_stack = (unsigned char *)NULL;
static int if_stack_depth;
static int if_stack_size;
static size_t if_stack_size;
/* Push _rl_parsing_conditionalized_out, and set parser state based
on ARGS. */
@@ -1672,7 +1672,6 @@ rl_parse_and_bind (char *string)
if (_rl_stricmp (string, "set") == 0)
{
char *var, *value, *e;
int s;
var = string + i;
/* Make VAR point to start of variable name. */
@@ -1850,7 +1849,7 @@ rl_parse_and_bind (char *string)
if (*funname == '\'' || *funname == '"')
{
char useq[2];
int fl = strlen (funname);
size_t fl = strlen (funname);
useq[0] = key; useq[1] = '\0';
if (fl && funname[fl - 1] == *funname)
+4 -2
View File
@@ -2467,7 +2467,8 @@ rl_filename_completion_function (const char *text, int state)
static char *users_dirname = (char *)NULL;
static int filename_len;
char *temp, *dentry, *convfn;
int dirlen, dentlen, convlen;
size_t dirlen;
int dentlen, convlen;
int tilde_dirname;
struct dirent *entry;
@@ -2588,6 +2589,7 @@ rl_filename_completion_function (const char *text, int state)
/* Now that we have some state, we can read the directory. */
entry = (struct dirent *)NULL;
convfn = dentry = 0;
while (directory && (entry = readdir (directory)))
{
convfn = dentry = entry->d_name;
@@ -2837,7 +2839,7 @@ rl_menu_complete (int count, int ignore)
static int full_completion = 0; /* set to 1 if menu completion should reinitialize on next call */
static int orig_start, orig_end;
static char quote_char;
static int delimiter, cstate;
static int delimiter;
/* The first time through, we generate the list of matches and set things
up to insert them. */
+12 -10
View File
@@ -1,6 +1,6 @@
/* histexpand.c -- history expansion. */
/* Copyright (C) 1989-2021 Free Software Foundation, Inc.
/* Copyright (C) 1989-2021,2023 Free Software Foundation, Inc.
This file contains the GNU History Library (History), a set of
routines for managing the text of previously typed lines.
@@ -532,7 +532,7 @@ history_expand_internal (const char *string, int start, int qc, int *end_index_p
int i, n, starting_index;
int substitute_globally, subst_bywords, want_quotes, print_only;
char *event, *temp, *result, *tstr, *t, c, *word_spec;
int result_len;
size_t result_len;
#if defined (HANDLE_MULTIBYTE)
mbstate_t ps;
@@ -881,7 +881,7 @@ history_expand_internal (const char *string, int start, int qc, int *end_index_p
#define ADD_STRING(s) \
do \
{ \
int sl = strlen (s); \
size_t sl = strlen (s); \
j += sl; \
if (j >= result_len) \
{ \
@@ -906,12 +906,13 @@ history_expand_internal (const char *string, int start, int qc, int *end_index_p
int
history_expand (char *hstring, char **output)
{
register int j;
int i, r, l, passc, cc, modified, eindex, only_printing, dquote, squote, flag;
int j;
int i, r, passc, cc, modified, eindex, only_printing, dquote, squote, flag;
size_t l;
char *string;
/* The output string, and its length. */
int result_len;
size_t result_len;
char *result;
#if defined (HANDLE_MULTIBYTE)
@@ -1418,7 +1419,7 @@ history_arg_extract (int first, int last, const char *string)
{
register int i, len;
char *result;
int size, offset;
size_t size, offset;
char **list;
/* XXX - think about making history_tokenize return a struct array,
@@ -1475,7 +1476,7 @@ history_arg_extract (int first, int last, const char *string)
static int
history_tokenize_word (const char *string, int ind)
{
register int i, j;
int i, j;
int delimiter, nestdelim, delimopen;
i = ind;
@@ -1627,7 +1628,8 @@ static char **
history_tokenize_internal (const char *string, int wind, int *indp)
{
char **result;
register int i, start, result_index, size;
int i, start, result_index;
size_t size;
/* If we're searching for a string that's not part of a word (e.g., " "),
make sure we set *INDP to a reasonable value. */
@@ -1636,7 +1638,7 @@ history_tokenize_internal (const char *string, int wind, int *indp)
/* Get a token, and stuff it into RESULT. The tokens are split
exactly where the shell would split them. */
for (i = result_index = size = 0, result = (char **)NULL; string[i]; )
for (i = result_index = 0, size = 0, result = (char **)NULL; string[i]; )
{
/* Skip leading whitespace. */
for (; string[i] && fielddelim (string[i]); i++)
+4 -6
View File
@@ -153,7 +153,7 @@ history_filename (const char *filename)
{
char *return_val;
const char *home;
int home_len;
size_t home_len;
return_val = filename ? savestring (filename) : (char *)NULL;
@@ -190,7 +190,6 @@ history_backupfile (const char *filename)
char *ret, linkbuf[PATH_MAX+1];
size_t len;
ssize_t n;
struct stat fs;
fn = filename;
#if defined (HAVE_READLINK)
@@ -218,7 +217,6 @@ history_tempfile (const char *filename)
char *ret, linkbuf[PATH_MAX+1];
size_t len;
ssize_t n;
struct stat fs;
int pid;
fn = filename;
@@ -680,7 +678,7 @@ history_do_write (const char *filename, int nelements, int overwrite)
register int i;
char *output, *tempname, *histname;
int file, mode, rv, exists;
struct stat finfo, nfinfo;
struct stat finfo;
#ifdef HISTORY_USE_MMAP
size_t cursize;
@@ -718,8 +716,8 @@ history_do_write (const char *filename, int nelements, int overwrite)
Suggested by Peter Ho (peter@robosts.oxford.ac.uk). */
{
HIST_ENTRY **the_history; /* local */
register int j;
int buffer_size;
size_t j;
size_t buffer_size;
char *buffer;
the_history = history_list ();
-2
View File
@@ -283,8 +283,6 @@ add_history (const char *string)
if (history_stifled && (history_length == history_max_entries))
{
register int i;
/* If the history is stifled, and history_length is zero,
and it equals history_max_entries, we don't save items. */
if (history_length == 0)
+5 -4
View File
@@ -66,10 +66,11 @@ static int history_search_internal (const char *, int, int);
static int
history_search_internal (const char *string, int direction, int flags)
{
register int i, reverse;
register char *line;
register int line_index;
int string_len, anchored, patsearch;
int i, reverse;
char *line;
int line_index;
size_t string_len;
int anchored, patsearch;
HIST_ENTRY **the_history; /* local */
i = history_offset;
+5 -5
View File
@@ -6,7 +6,7 @@
/* */
/* **************************************************************** */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2021,2023 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.
@@ -340,7 +340,7 @@ _rl_search_getchar (_rl_search_cxt *cxt)
int
_rl_isearch_dispatch (_rl_search_cxt *cxt, int c)
{
int n, wstart, wlen, limit, cval, incr;
int n, wstart, wlen, limit, cval;
char *paste;
size_t pastelen;
int j;
@@ -725,13 +725,13 @@ opcode_dispatch:
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
int j;
int w;
if (cxt->mb[0] == 0 || cxt->mb[1] == 0)
cxt->search_string[cxt->search_string_index++] = cxt->mb[0];
else
for (j = 0; j < wlen; )
cxt->search_string[cxt->search_string_index++] = cxt->mb[j++];
for (w = 0; w < wlen; )
cxt->search_string[cxt->search_string_index++] = cxt->mb[w++];
}
else
#endif
+5 -5
View File
@@ -1,6 +1,6 @@
/* kill.c -- kill ring management. */
/* Copyright (C) 1994-2021 Free Software Foundation, Inc.
/* Copyright (C) 1994-2023 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.
@@ -756,8 +756,8 @@ _rl_bracketed_text (size_t *lenp)
int
rl_bracketed_paste_begin (int count, int key)
{
int retval, c;
size_t len, cap;
int retval;
size_t len;
char *buf;
buf = _rl_bracketed_text (&len);
@@ -774,7 +774,7 @@ int
_rl_read_bracketed_paste_prefix (int c)
{
char pbuf[BRACK_PASTE_SLEN+1], *pbpref;
int key, ind, j;
int key, ind;
pbpref = BRACK_PASTE_PREF; /* XXX - debugging */
if (c != pbpref[0])
@@ -846,7 +846,7 @@ _rl_bracketed_read_key ()
int
_rl_bracketed_read_mbstring (char *mb, int mlen)
{
int c, r;
int c;
c = _rl_bracketed_read_key ();
if (c < 0)
+1 -1
View File
@@ -69,7 +69,7 @@ static int executing_macro_index;
static char *current_macro = (char *)NULL;
/* The size of the buffer allocated to current_macro. */
static int current_macro_size;
static size_t current_macro_size;
/* The index at which characters are being added to current_macro. */
static int current_macro_index;
+2 -3
View File
@@ -1,6 +1,6 @@
/* mbutil.c -- readline multibyte character utility functions */
/* Copyright (C) 2001-2021 Free Software Foundation, Inc.
/* Copyright (C) 2001-2021,2023 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.
@@ -244,7 +244,6 @@ _rl_test_nonzero (const char *string, int ind, int len)
static int
_rl_find_prev_utf8char (const char *string, int seed, int find_non_zero)
{
char *s;
unsigned char b;
int save, prev;
size_t len;
@@ -476,7 +475,7 @@ _rl_char_value (const char *buf, int ind)
size_t tmp;
WCHAR_T wc;
mbstate_t ps;
int l;
size_t l;
if (MB_LEN_MAX == 1 || rl_byte_oriented)
return ((WCHAR_T) buf[ind]);
-2
View File
@@ -383,8 +383,6 @@ rl_maybe_save_line (void)
int
_rl_free_saved_history_line (void)
{
UNDO_LIST *orig;
if (_rl_saved_line_for_history)
{
if (rl_undo_list && rl_undo_list == (UNDO_LIST *)_rl_saved_line_for_history->data)
+2 -2
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-2022 Free Software Foundation, Inc.
/* Copyright (C) 1987-2023 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.
@@ -262,7 +262,7 @@ _rl_keyseq_cxt *_rl_kscxt = 0;
int rl_executing_key;
char *rl_executing_keyseq = 0;
int _rl_executing_keyseq_size = 0;
size_t _rl_executing_keyseq_size = 0;
struct _rl_cmd _rl_pending_command;
struct _rl_cmd *_rl_command_to_execute = (struct _rl_cmd *)NULL;
+1 -1
View File
@@ -939,7 +939,7 @@ struct readline_state {
char *prompt;
/* global state */
int rlstate;
int rlstate; /* XXX -- needs to be unsigned long */
int done;
Keymap kmap;
+1 -1
View File
@@ -570,7 +570,7 @@ extern procenv_t _rl_top_level;
extern _rl_keyseq_cxt *_rl_kscxt;
extern int _rl_keyseq_timeout;
extern int _rl_executing_keyseq_size;
extern size_t _rl_executing_keyseq_size;
extern rl_hook_func_t *_rl_internal_startup_hook;
+1 -1
View File
@@ -65,7 +65,7 @@ static int _rl_history_search_len;
static int _rl_history_search_flags;
static char *history_search_string;
static int history_string_size;
static size_t history_string_size;
static void make_history_line_current (HIST_ENTRY *);
static int noninc_search_from_pos (char *, int, int, int, int *);
-1
View File
@@ -622,7 +622,6 @@ rl_check_signals (void)
/* **************************************************************** */
#if defined (HAVE_POSIX_SIGNALS)
static sigset_t sigint_set, sigint_oset;
static sigset_t sigwinch_set, sigwinch_oset;
#else /* !HAVE_POSIX_SIGNALS */
# if defined (HAVE_BSD_SIGNALS)
+1 -1
View File
@@ -1,6 +1,6 @@
/* text.c -- text handling commands for readline. */
/* Copyright (C) 1987-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2021,2023 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
@@ -116,7 +116,7 @@ _rl_free_undo_list (UNDO_LIST *ul)
void
rl_free_undo_list (void)
{
UNDO_LIST *release, *orig_list;
UNDO_LIST *orig_list;
orig_list = rl_undo_list;
_rl_free_undo_list (rl_undo_list);
+2 -1
View File
@@ -321,7 +321,8 @@ _rl_errmsg (format, arg1, arg2)
char *
_rl_strindex (const char *s1, const char *s2)
{
register int i, l, len;
int i;
size_t l, len;
for (i = 0, l = strlen (s2), len = strlen (s1); (len - i) >= l; i++)
if (_rl_strnicmp (s1 + i, s2, l) == 0)
+1 -3
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-2021 Free Software Foundation, Inc.
/* Copyright (C) 1987-2021,2023 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.
@@ -101,7 +101,6 @@ static int vi_replace_count;
/* If non-zero, we have text inserted after a c[motion] command that put
us implicitly into insert mode. Some people want this text to be
attached to the command so that it is `redoable' with `.'. */
static int vi_continued_command;
static char *vi_insert_buffer;
static int vi_insert_buffer_size;
@@ -1340,7 +1339,6 @@ _rl_vi_domove_callback (_rl_vimotion_cxt *m)
int
rl_vi_domove (int x, int *ignore)
{
int r;
_rl_vimotion_cxt *m;
m = _rl_vimvcxt;