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
+20
View File
@@ -4931,3 +4931,23 @@ builtins/shopt.def
- reset_shopt_options: set glob_always_skip_dot_and_dotdot to 1,
since that's the current default in lib/glob/glob.c
1/4
---
execute_cmd.c,parse.y,general.c,make_cmd.c,print_cmd.c,variables.c,expr.c
jobs.c,subst.c,input.c,unwind_prot.c,pathexp.c,pathexp.h,alias.c,bashline.c
bashhist.c,lib/sh/shquote.c,externs.h,stringlib.c,locale.c,findcmd.c
builtins/common.c,builtins/declare.def,builtins/enable.def,builtins/fc.def
lib/sh/zmapfd.c,builtins/help.def,builtins/mapfile.def,builtins/read.def
builtins/shopt.def,lib/glob/glob.c,lib/glob/smatch.c,lib/glob/sm_loop.c
lib/glob/xmbsrtowcs.c,lib/glob/gmisc.c,lib/glob/gm_loop.c
lib/sh/getenv.c,lib/sh/makepath.c,lib/sh/pathphys.c,lib/sh/tmpfile.c
lib/sh/stringlib.c,lib/sh/spell.c,lib/sh/strtrans.c,lib/sh/zgetline.c
lib/sh/mbscasecmp.c,lib/sh/utf8.c
lib/readline/readline.c,lib/readline/rlprivate.h,lib/readline/vi_mode.c
lib/readline/complete.c,lib/readline/bind.c,lib/readline/isearch.c
lib/readline/util.c,lib/readline/kill.c,lib/readline/macro.c
lib/readline/text.c,lib/readline/histexpand.c,lib/readline/histfile.c
lib/readline/mbutil.c,lib/tilde/tilde.c
- size_t changes
- remove some unused variables
- remove `register'
+1 -1
View File
@@ -176,7 +176,7 @@ GCC_LINT_FLAGS = -O -Wall -Wshadow -Wpointer-arith -Wcast-qual -Wno-parentheses
-Wcast-align -Wstrict-prototypes -Wconversion -Wformat \
-Wformat-nonliteral -Wmissing-braces -Wuninitialized \
-Wmissing-declarations -Winline \
-Wmissing-prototypes -Wtraditional -Wredundant-decls \
-Wmissing-prototypes -Wredundant-decls \
-Wformat-security -pedantic
GCC_LINT_CFLAGS = $(BASE_CCFLAGS) $(CPPFLAGS) $(GCC_LINT_FLAGS)
+6 -5
View File
@@ -215,7 +215,7 @@ static alias_t **
map_over_aliases (sh_alias_map_func_t *function)
{
register int i;
register BUCKET_CONTENTS *tlist;
BUCKET_CONTENTS *tlist;
alias_t *alias, **list;
int list_index;
@@ -464,9 +464,10 @@ char *
alias_expand (char *string)
{
register int i, j, start;
int i, start;
char *line, *token;
int line_len, tl, real_start, expand_next, expand_this_token;
size_t j, line_len;
int tl, real_start, expand_next, expand_this_token;
alias_t *alias;
line_len = strlen (string) + 1;
@@ -545,7 +546,7 @@ alias_expand (char *string)
(alias = find_alias (token)))
{
char *v;
int vlen, llen;
size_t vlen, llen;
v = alias->value;
vlen = strlen (v);
@@ -562,7 +563,7 @@ alias_expand (char *string)
}
else
{
int llen, tlen;
size_t llen, tlen;
llen = strlen (line);
tlen = i - real_start; /* tlen == strlen(token) */
+1 -1
View File
@@ -795,7 +795,7 @@ assign_compound_array_list (SHELL_VAR *var, WORD_LIST *nlist, int flags)
savecmd = this_command_name;
if (integer_p (var))
this_command_name = (char *)NULL; /* no command name for errors */
this_command_name = 0; /* no command name for errors */
if (assoc_p (var))
bind_assoc_var_internal (var, nhash, akey, val, iflags);
else
+2 -1
View File
@@ -853,7 +853,8 @@ bash_syslog_history (const char *line)
void
bash_add_history (char *line)
{
int add_it, offset, curlen, is_comment;
int add_it, offset, is_comment;
size_t curlen;
HIST_ENTRY *current, *old;
char *chars_to_add, *new_line;
+27 -24
View File
@@ -259,7 +259,7 @@ static int bash_possible_variable_completions (int, int);
static int bash_complete_command (int, int);
static int bash_possible_command_completions (int, int);
static int completion_glob_pattern (char *);
static int completion_glob_pattern (const char *);
static char *glob_complete_word (const char *, int);
static int bash_glob_completion_internal (int);
static int bash_glob_complete_word (int, int);
@@ -1329,10 +1329,9 @@ bash_transpose_shellwords (int count, int key)
static int
bash_spell_correct_shellword (int count, int key)
{
int opoint, wbeg, wend;
int wbeg, wend;
char *text, *newdir;
opoint = rl_point;
while (count)
{
bash_backward_shellword (1, key);
@@ -1870,7 +1869,7 @@ bash_default_completion (const char *text, int start, int end, int qc, int compf
/* This could be a globbing pattern, so try to expand it using pathname
expansion. */
if (!matches && completion_glob_pattern ((char *)text))
if (!matches && completion_glob_pattern (text))
{
matches = rl_completion_matches (text, glob_complete_word);
/* A glob expression that matches more than one filename is problematic.
@@ -1948,7 +1947,8 @@ command_word_completion_function (const char *hint_text, int state)
static char *dequoted_hint = (char *)NULL;
static char *directory_part = (char *)NULL;
static char **glob_matches = (char **)NULL;
static int path_index, hint_len, istate, igncase;
static int path_index, istate, igncase;
static size_t hint_len;
static int mapping_over, local_index, searching_path, hint_is_dir;
static int old_glob_ignore_case, globpat;
static SHELL_VAR **varlist = (SHELL_VAR **)NULL;
@@ -1983,7 +1983,7 @@ command_word_completion_function (const char *hint_text, int state)
glob_matches = (char **)NULL;
}
globpat = completion_glob_pattern ((char *)hint_text);
globpat = completion_glob_pattern (hint_text);
/* If this is an absolute program name, do not check it against
aliases, reserved words, functions or builtins. We must check
@@ -2558,7 +2558,7 @@ bash_servicename_completion_function (const char *text, int state)
#else
static char *sname = (char *)NULL;
static struct servent *srvent;
static int snamelen;
static size_t snamelen;
char *value;
char **alist, *aentry;
int afound;
@@ -2614,7 +2614,7 @@ bash_groupname_completion_function (const char *text, int state)
#else
static char *gname = (char *)NULL;
static struct group *grent;
static int gnamelen;
static size_t gnamelen;
char *value;
if (state == 0)
@@ -2801,7 +2801,7 @@ tcsh_magic_space (int count, int ignore)
static int
history_and_alias_expand_line (int count, int ignore)
{
char *new_line, *t;
char *new_line;
new_line = 0;
#if defined (BANG_HISTORY)
@@ -2940,7 +2940,7 @@ static void
_ignore_completion_names (char **names, sh_ignore_func_t *name_func)
{
char **newnames;
int idx, nidx;
size_t idx, nidx;
char **oldnames;
int oidx;
@@ -3029,7 +3029,7 @@ static int
name_is_acceptable (const char *name)
{
struct ign *p;
int nlen;
size_t nlen;
for (nlen = strlen (name), p = fignore.ignores; p->val; p++)
{
@@ -3128,7 +3128,7 @@ bash_ignore_everything (char **names)
static char *
restore_tilde (const char *val, char *directory_part)
{
int l, vl, dl2, xl;
size_t l, vl, dl2, xl;
char *dh2, *expdir, *ret, *v;
vl = strlen (val);
@@ -3482,7 +3482,7 @@ bash_directory_completion_hook (char **dirname)
if (no_symbolic_links == 0 && (local_dirname[0] != '.' || local_dirname[1]))
{
char *temp1, *temp2;
int len1, len2;
size_t len1, len2;
/* If we have a relative path
(local_dirname[0] != '/' && local_dirname[0] != '.')
@@ -3556,8 +3556,8 @@ bash_directory_completion_hook (char **dirname)
}
static char **history_completion_array = (char **)NULL;
static int harry_size;
static int harry_len;
static size_t harry_size;
static size_t harry_len;
static void
build_history_completion_array (void)
@@ -3608,7 +3608,8 @@ build_history_completion_array (void)
static char *
history_completion_generator (const char *hint_text, int state)
{
static int local_index, len;
static int local_index;
static size_t len;
static const char *text;
/* If this is the first call to the generator, then initialize the
@@ -3819,7 +3820,7 @@ bash_complete_command_internal (int what_to_do)
}
static int
completion_glob_pattern (char *string)
completion_glob_pattern (const char *string)
{
return (glob_pattern_p (string) == 1);
}
@@ -3832,7 +3833,7 @@ glob_complete_word (const char *text, int state)
{
static char **matches = (char **)NULL;
static int ind;
int glen;
size_t glen;
char *ret, *ttext;
if (state == 0)
@@ -4007,7 +4008,8 @@ static char *
bash_dequote_filename (char *text, int quote_char)
{
char *ret, *p, *r;
int l, quoted;
int quoted;
size_t l;
l = strlen (text);
ret = (char *)xmalloc (l + 1);
@@ -4054,7 +4056,7 @@ static char *
quote_word_break_chars (char *text)
{
char *ret, *r, *s;
int l;
size_t l;
l = strlen (text);
ret = (char *)xmalloc ((2 * l) + 1);
@@ -4149,7 +4151,8 @@ bash_check_expchar (char *dirname, int need_closer, int *nextp, int *closerp)
static void
set_filename_quote_chars (int expchar, int nextch, int closer)
{
int i, j, c;
size_t i, j;
int c;
if (rl_filename_quote_characters && *rl_filename_quote_characters)
{
@@ -4190,8 +4193,8 @@ static char *
bash_quote_filename (char *s, int rtype, char *qcp)
{
char *rtext, *mtext, *ret;
int rlen, cs;
int expchar, nextch, closer;
size_t rlen;
int cs, expchar, nextch, closer;
rtext = (char *)NULL;
@@ -4380,7 +4383,7 @@ bash_execute_unix_command (int count, int key)
register int i, r;
intmax_t mi;
sh_parser_state_t ps;
char *cmd, *value, *ce, old_ch;
char *cmd, *value, *ce;
SHELL_VAR *v;
char ibuf[INT_STRLEN_BOUND(int) + 1];
Keymap cmd_xmap;
+5 -5
View File
@@ -1,6 +1,6 @@
/* common.c - utility functions for all builtins */
/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -639,9 +639,10 @@ set_working_directory (const char *name)
int
get_job_by_name (const char *name, int flags)
{
register int i, wl, cl, match, job;
register PROCESS *p;
register JOB *j;
int i, match, job;
size_t wl, cl;
PROCESS *p;
JOB *j;
job = NO_JOB;
wl = strlen (name);
@@ -1034,7 +1035,6 @@ builtin_unbind_variable (const char *vname)
int
builtin_arrayref_flags (WORD_DESC *w, int baseflags)
{
char *t;
int vflags;
vflags = baseflags;
+2 -2
View File
@@ -1,7 +1,7 @@
This file is declare.def, from which is created declare.c.
It implements the builtins "declare" and "local" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -865,7 +865,7 @@ restart_new_var_name:
simple_array_assign = 1;
else if ((making_array_special || creating_array || array_exists) && offset)
{
int vlen;
size_t vlen;
vlen = STRLEN (value);
/*itrace("declare_builtin: name = %s value = %s flags = %d", name, value, wflags);*/
+5 -3
View File
@@ -1,7 +1,7 @@
This file is enable.def, from which is created enable.c.
It implements the builtin "enable" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -319,7 +319,8 @@ dyn_load_builtin (WORD_LIST *list, int flags, char *filename)
WORD_LIST *l;
void *handle;
int total, size, new, replaced, r;
int total, new, replaced, r;
size_t size;
char *struct_name, *name, *funcname;
sh_load_func_t *loadfunc;
struct builtin **new_builtins, *b, *new_shell_builtins, *old_builtin;
@@ -528,7 +529,8 @@ dyn_unload_builtin (char *name)
void *handle;
char *funcname;
sh_unload_func_t *unloadfunc;
int ref, i, size;
int ref, i;
size_t size;
b = builtin_address_internal (name, 1);
if (b == 0)
+1 -1
View File
@@ -1,6 +1,6 @@
/* evalfile.c - read and evaluate commands from a file or file descriptor */
/* Copyright (C) 1996-2017,2022 Free Software Foundation, Inc.
/* Copyright (C) 1996-2017,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+2 -2
View File
@@ -1,6 +1,6 @@
/* evalstring.c - evaluate a string as one or more shell commands. */
/* Copyright (C) 1996-2022 Free Software Foundation, Inc.
/* Copyright (C) 1996-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -716,7 +716,7 @@ int
open_redir_file (REDIRECT *r, char **fnp)
{
char *fn;
int fd, rval;
int fd;
if (r->instruction != r_input_direction)
return -1;
-2
View File
@@ -48,8 +48,6 @@ $END
#include "common.h"
#include "builtext.h" /* for jobs_builtin */
extern int check_jobs_at_exit;
static int exit_or_logout (WORD_LIST *);
static int sourced_logout;
+8 -5
View File
@@ -1,7 +1,7 @@
This file is fc.def, from which is created fc.c.
It implements the builtin "fc" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -94,7 +94,9 @@ extern int errno;
#define HN_LISTING 0x01
#define HN_FIRST 0x02
#ifndef HAVE_UNISTD_H
extern int unlink (const char *);
#endif
extern FILE *sh_mktmpfp (char *, int, char **);
@@ -549,9 +551,10 @@ fc_number (WORD_LIST *list)
static int
fc_gethnum (char *command, HIST_ENTRY **hlist, int mode)
{
int sign, n, clen, rh;
register int i, j, last_hist, real_last, listing;
register char *s;
int sign, n, rh;
size_t clen;
int i, j, last_hist, real_last, listing;
char *s;
listing = mode & HN_LISTING;
sign = 1;
@@ -733,7 +736,7 @@ fc_dosubs (char *command, REPL *subs)
static void
fc_replhist (char *command)
{
int n;
size_t n;
if (command == 0 || *command == '\0')
return;
+1 -3
View File
@@ -1,7 +1,7 @@
This file is hash.def, from which is created hash.c.
It implements the builtin "hash" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -68,8 +68,6 @@ $END
#include "common.h"
#include "bashgetopt.h"
extern int dot_found_in_search;
static int add_hashed_command (char *, int);
static int print_hash_info (BUCKET_CONTENTS *);
static int print_portable_hash_info (BUCKET_CONTENTS *);
+10 -8
View File
@@ -1,7 +1,7 @@
This file is help.def, from which is created help.c.
It implements the builtin "help" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -80,7 +80,7 @@ extern const char * const bash_copyright;
extern const char * const bash_license;
static void show_builtin_command_help (void);
static int open_helpfile (char *);
static int open_helpfile (const char *);
static void show_desc (char *, int);
static void show_manpage (char *, int);
static void show_longdoc (int);
@@ -93,7 +93,8 @@ help_builtin (WORD_LIST *list)
{
register int i;
char *pattern, *name;
int plen, match_found, sflag, dflag, mflag, m, pass, this_found;
int match_found, sflag, dflag, mflag, m, pass, this_found;
size_t plen;
dflag = sflag = mflag = 0;
reset_internal_getopt ();
@@ -211,7 +212,7 @@ builtin_help (void)
}
static int
open_helpfile (char *name)
open_helpfile (const char *name)
{
int fd;
@@ -290,10 +291,11 @@ static void
show_manpage (char *name, int i)
{
register int j;
char **doc, *line;
char * const *doc;
char *line;
int fd, usefile;
doc = (char **)shell_builtins[i].long_doc;
doc = shell_builtins[i].long_doc;
usefile = (doc && doc[0] && *doc[0] == '/' && doc[1] == (char *)NULL);
if (usefile)
@@ -362,7 +364,7 @@ static void
dispcolumn (int i, char *buf, size_t bufsize, int width, int height)
{
int j;
int dispcols;
size_t dispcols;
char *helpdoc;
/* first column */
@@ -500,7 +502,7 @@ wdispcolumn (int i, char *buf, size_t bufsize, int width, int height)
static void
show_builtin_command_help (void)
{
int i, j;
int i;
int height, width;
char *t, blurb[128];
+2 -4
View File
@@ -2,7 +2,7 @@ This file is mapfile.def, from which is created mapfile.c.
It implements the builtin "mapfile" in Bash.
Copyright (C) 2005-2006 Rocky Bernstein for Free Software Foundation, Inc.
Copyright (C) 2008-2022 Free Software Foundation, Inc.
Copyright (C) 2008-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -104,8 +104,6 @@ static int run_callback (const char *, unsigned int, const char *);
#define MAPF_CLEARARRAY 0x01
#define MAPF_CHOP 0x02
static int delim;
static int
run_callback (const char *callback, unsigned int curindex, const char *curline)
{
@@ -224,7 +222,7 @@ mapfile (int fd, long line_count_goal, long origin, long nskip, long callback_qu
int
mapfile_builtin (WORD_LIST *list)
{
int opt, code, fd, flags;
int opt, code, fd, flags, delim;
intmax_t intval;
long lines, origin, nskip, callback_quantum;
char *array_name, *callback;
+1 -1
View File
@@ -152,7 +152,7 @@ extern int errno;
static char **pushd_directory_list = (char **)NULL;
/* Number of existing slots in this list. */
static int directory_list_size;
static size_t directory_list_size;
/* Offset to the end of the list. */
static int directory_list_offset;
+11 -11
View File
@@ -141,7 +141,6 @@ static void reset_timeout (void);
sh_timer *read_timeout;
static int reading, tty_modified;
static SigHandler *old_alrm;
static unsigned char delim;
static struct ttsave termsave;
@@ -204,8 +203,9 @@ read_builtin_timeout (int fd)
int
read_builtin (WORD_LIST *list)
{
register char *varname;
int size, nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2, nflag;
char *varname;
int nr, pass_next, saw_escape, eof, opt, retval, code, print_ps2, nflag;
size_t size;
volatile int i;
int input_is_tty, input_is_pipe, unbuffered_read, skip_ctlesc, skip_ctlnul;
int raw, edit, nchars, silent, have_timeout, ignore_delim, fd;
@@ -691,9 +691,9 @@ read_builtin (WORD_LIST *list)
if (retval <= 0)
{
int t;
int x;
t = errno;
x = errno;
if (retval < 0 && errno == EINTR)
{
check_signals (); /* in case we didn't call zread via zreadc */
@@ -710,7 +710,7 @@ read_builtin (WORD_LIST *list)
ttyrestore (&termsave); /* fix terminal before exiting */
CHECK_TERMSIG;
eof = 1;
errno = t; /* preserve it for the error message below */
errno = x; /* preserve it for the error message below */
break;
}
@@ -725,13 +725,13 @@ read_builtin (WORD_LIST *list)
/* XXX -- use i + mb_cur_max (at least 4) for multibyte/read_mbchar */
if (i + (mb_cur_max > 4 ? mb_cur_max : 4) >= size)
{
char *t;
t = (char *)xrealloc (input_string, size += 128);
char *x;
x = (char *)xrealloc (input_string, size += 128);
/* Only need to change unwind-protect if input_string changes */
if (t != input_string)
if (x != input_string)
{
input_string = t;
input_string = x;
remove_unwind_protect ();
add_unwind_protect (xfree, input_string);
}
@@ -1165,7 +1165,7 @@ static char *
edit_line (char *p, char *itext)
{
char *ret;
int len;
size_t len;
if (bash_readline_initialized == 0)
initialize_readline ();
+3 -2
View File
@@ -1,7 +1,7 @@
This file is set.def, from which is created set.c.
It implements the "set" and "unset" builtins in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -527,7 +527,8 @@ set_shellopts (void)
{
char *value;
char tflag[N_O_OPTIONS];
int vsize, i, vptr, *ip, exported;
int i, *ip, exported;
size_t vsize, vptr;
SHELL_VAR *v;
for (vsize = i = 0; o_options[i].name; i++)
+6 -5
View File
@@ -1,7 +1,7 @@
This file is shopt.def, from which is created shopt.c.
It implements the Bash `shopt' builtin.
Copyright (C) 1994-2022 Free Software Foundation, Inc.
Copyright (C) 1994-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -651,8 +651,7 @@ set_compatibility_level (char *option_name, int mode)
/* If we're unsetting one of the compatibility options, make sure the
current value is in the range of the compatNN space. */
if (mode == 0)
oldval = shell_compatibility_level;
oldval = (mode == 0) ? shell_compatibility_level : 0;
/* If we're setting something, redo some of the work we did above in
toggle_shopt(). Unset everything and reset the appropriate option
@@ -762,7 +761,8 @@ char **
get_shopt_options (void)
{
char **ret;
int n, i;
int i;
size_t n;
n = sizeof (shopt_vars) / sizeof (shopt_vars[0]);
ret = strvec_create (n + 1);
@@ -813,7 +813,8 @@ set_bashopts (void)
{
char *value;
char tflag[N_SHOPT_OPTIONS];
int vsize, i, vptr, *ip, exported;
int i, exported;
size_t vsize, vptr;
SHELL_VAR *v;
for (vsize = i = 0; shopt_vars[i].name; i++)
+2 -2
View File
@@ -1,7 +1,7 @@
This file is ulimit.def, from which is created ulimit.c.
It implements the builtin "ulimit" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -299,7 +299,7 @@ typedef struct _cmd {
static ULCMD *cmdlist;
static int ncmd;
static int cmdlistsz;
static size_t cmdlistsz;
#if !defined (HAVE_RESOURCE) && !defined (HAVE_ULIMIT)
long
+2 -2
View File
@@ -1,7 +1,7 @@
This file is wait.def, from which is created wait.c.
It implements the builtin "wait" in Bash.
Copyright (C) 1987-2022 Free Software Foundation, Inc.
Copyright (C) 1987-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -333,7 +333,7 @@ static int
set_waitlist (WORD_LIST *list)
{
sigset_t set, oset;
int job, r, njob;
int job, njob;
intmax_t pid;
WORD_LIST *l;
+3 -2
View File
@@ -1369,6 +1369,7 @@ time_command (COMMAND *command, int asynchronous, int pipe_in, int pipe_out, str
#endif
}
rv = EXECUTION_SUCCESS; /* suppress uninitialized use warnings */
old_flags = command->flags;
COPY_PROCENV (top_level, save_top_level);
command->flags &= ~(CMD_TIME_PIPELINE|CMD_TIME_POSIX);
@@ -5721,7 +5722,7 @@ execute_shell_script (char *sample, int sample_len,
size_increment = 1;
/* Now the argument, if any. */
for (firstarg = (char *)NULL, start = i; WHITECHAR(i); i++)
for (firstarg = NULL, start = i; WHITECHAR(i); i++)
;
/* If there is more text on the line, then it is an argument for the
@@ -5880,7 +5881,7 @@ shell_execve (char *command, char **args, char **env)
if (sample_len > 2 && sample[0] == '#' && sample[1] == '!')
{
char *interp;
int ilen;
size_t ilen;
interp = getinterp (sample, sample_len, (int *)NULL);
ilen = strlen (interp);
+13 -12
View File
@@ -182,7 +182,8 @@ static int already_expanded;
static struct lvalue curlval = {0, 0, 0, -1};
static struct lvalue lastlval = {0, 0, 0, -1};
static int _is_arithop (int);
static int is_arithop (int);
static int is_multiop (int);
static void readtok (void); /* lexical analyzer */
static void init_lvalue (struct lvalue *);
@@ -223,7 +224,7 @@ static intmax_t exp0 (void);
/* Global var which contains the stack of expression contexts. */
static EXPR_CONTEXT **expr_stack;
static int expr_depth; /* Location in the stack. */
static int expr_stack_size; /* Number of slots already allocated. */
static size_t expr_stack_size; /* Number of slots already allocated. */
#if defined (ARRAY_VARS)
extern const char * const bash_badsub_errmsg;
@@ -951,7 +952,7 @@ ipow (intmax_t base, intmax_t exp)
static intmax_t
exppower (void)
{
register intmax_t val1, val2, c;
register intmax_t val1, val2;
val1 = expunary ();
while (curtok == POWER)
@@ -1233,7 +1234,7 @@ expr_streval (char *tok, int e, struct lvalue *lvalue)
}
static inline int
_is_multiop (int c)
is_multiop (int c)
{
switch (c)
{
@@ -1259,7 +1260,7 @@ _is_multiop (int c)
}
static inline int
_is_arithop (int c)
is_arithop (int c)
{
switch (c)
{
@@ -1295,14 +1296,14 @@ _is_arithop (int c)
static void
readtok (void)
{
register char *cp, *xp;
register unsigned char c, c1;
register int e;
struct lvalue lval;
char *cp, *xp;
unsigned char c, c1;
int e;
/* Skip leading whitespace. */
cp = tp;
c = e = 0;
c = 0;
e = 0;
while (cp && (c = *cp) && (cr_whitespace (c)))
cp++;
@@ -1477,11 +1478,11 @@ readtok (void)
assigntok = c; /* a OP= b */
c = OP_ASSIGN;
}
else if (_is_arithop (c) == 0)
else if (is_arithop (c) == 0)
{
cp--;
/* use curtok, since it hasn't been copied to lasttok yet */
if (curtok == 0 || _is_arithop (curtok) || _is_multiop (curtok))
if (curtok == 0 || is_arithop (curtok) || is_multiop (curtok))
evalerror (_("arithmetic syntax error: operand expected"));
else
evalerror (_("arithmetic syntax error: invalid arithmetic operator"));
+2 -2
View File
@@ -344,7 +344,7 @@ extern int sh_mbsnlen (const char *, size_t, int);
/* declarations for functions defined in lib/sh/shquote.c */
extern char *sh_single_quote (const char *);
extern char *sh_double_quote (const char *);
extern char *sh_mkdoublequoted (const char *, int, int);
extern char *sh_mkdoublequoted (const char *, size_t, int);
extern char *sh_un_double_quote (char *);
extern char *sh_backslash_quote (char *, const char *, int);
extern char *sh_backslash_quote_for_double_quotes (char *, int);
@@ -531,7 +531,7 @@ extern int zcatfd (int, int, const char *);
extern ssize_t zgetline (int, char **, size_t *, int, int);
/* declarations for functions defined in lib/sh/zmapfd.c */
extern int zmapfd (int, char **, char *);
extern int zmapfd (int, char **, const char *);
/* declarations for functions defined in lib/sh/zread.c */
extern ssize_t zread (int, char *, size_t);
+8 -6
View File
@@ -55,7 +55,7 @@ extern int errno;
static char *_find_user_command_internal (const char *, int);
static char *find_user_command_internal (const char *, int);
static char *find_user_command_in_path (const char *, char *, int, int *);
static char *find_in_path_element (const char *, char *, int, int, struct stat *, int *);
static char *find_in_path_element (const char *, char *, int, size_t, struct stat *, int *);
static char *find_absolute_program (const char *, int);
static char *get_next_path_element (char *, int *);
@@ -402,12 +402,13 @@ char *
user_command_matches (const char *name, int flags, int state)
{
register int i;
int path_index, name_len;
int path_index;
size_t name_len;
char *path_list, *path_element, *match;
struct stat dotinfo;
static char **match_list = NULL;
static int match_list_size = 0;
static int match_index = 0;
static size_t match_list_size = 0;
static size_t match_index = 0;
if (state == 0)
{
@@ -500,7 +501,7 @@ find_absolute_program (const char *name, int flags)
}
static char *
find_in_path_element (const char *name, char *path, int flags, int name_len, struct stat *dotinfop, int *rflagsp)
find_in_path_element (const char *name, char *path, int flags, size_t name_len, struct stat *dotinfop, int *rflagsp)
{
int status;
char *full_path, *xpath;
@@ -585,7 +586,8 @@ static char *
find_user_command_in_path (const char *name, char *path_list, int flags, int *rflagsp)
{
char *full_path, *path;
int path_index, name_len, rflags;
int path_index, rflags;
size_t name_len;
struct stat dotinfo;
/* We haven't started looking, so we certainly haven't seen
+3 -3
View File
@@ -410,8 +410,8 @@ legal_alias_name (const char *string, int flags)
int
assignment (const char *string, int flags)
{
register unsigned char c;
register int newi, indx;
unsigned char c;
int newi, indx;
c = string[indx = 0];
@@ -1116,7 +1116,7 @@ bash_tilde_find_word (const char *s, int flags, int *lenp)
{
const char *r;
char *ret;
int l;
size_t l;
for (r = s; *r && *r != '/'; r++)
{
+2 -1
View File
@@ -189,7 +189,8 @@ make_buffered_stream (int fd, char *buffer, size_t bufsize)
bp->b_fd = fd;
bp->b_buffer = buffer;
bp->b_size = bufsize;
bp->b_used = bp->b_inputp = bp->b_flag = 0;
bp->b_used = 0;
bp->b_inputp = bp->b_flag = 0;
if (bufsize == 1)
bp->b_flag |= B_UNBUFF;
if (O_TEXT && (fcntl (fd, F_GETFL) & O_TEXT) != 0)
+5 -5
View File
@@ -3,7 +3,7 @@
/* This file works with both POSIX and BSD systems. It implements job
control. */
/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -1195,7 +1195,6 @@ cleanup_dead_jobs (void)
{
register int i;
int os;
PROCESS *discard;
if (js.j_jobslots == 0 || jobs_list_frozen)
return;
@@ -2063,8 +2062,9 @@ list_all_jobs (int format)
pid_t
make_child (char *command, int flags)
{
int async_p, forksleep;
sigset_t set, oset, termset, chldset, oset_copy;
int async_p;
unsigned int forksleep;
sigset_t set, oset, oset_copy;
pid_t pid;
SigHandler *oterm;
@@ -4174,7 +4174,7 @@ notify_of_job_status (void)
queue_sigchld++;
/* XXX could use js.j_firstj here */
for (job = 0, dir = (char *)NULL; job < js.j_jobslots; job++)
for (job = 0, dir = NULL; job < js.j_jobslots; job++)
{
if (jobs[job] && IS_NOTIFIED (job) == 0)
{
+19 -25
View File
@@ -1,6 +1,6 @@
/* glob.c -- file-name wildcard pattern matching for Bash.
Copyright (C) 1985-2022 Free Software Foundation, Inc.
Copyright (C) 1985-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne-Again SHell.
@@ -266,8 +266,6 @@ extglob_skipname (char *pat, char *dname, int flags)
static int
skipname (char *pat, char *dname, int flags)
{
int i;
#if EXTENDED_GLOB
if (extglob_pattern_p (pat)) /* XXX */
return (extglob_skipname (pat, dname, flags));
@@ -306,8 +304,6 @@ skipname (char *pat, char *dname, int flags)
static int
wskipname (wchar_t *pat, wchar_t *dname, int flags)
{
int i;
if (glob_always_skip_dot_and_dotdot && WDOT_OR_DOTDOT (dname))
return 1;
@@ -485,7 +481,6 @@ wdequote_pathname (char *pathname)
mbstate_t ps;
size_t len, n;
wchar_t *wpathname;
int i, j;
wchar_t *orig_wpathname;
if (mbsmbchar (pathname) == 0)
@@ -580,7 +575,7 @@ glob_testdir (char *dir, int flags)
static struct globval *
finddirs (char *pat, char *sdir, int flags, struct globval **ep, int *np)
{
char **r, *n;
char **r;
int ndirs;
struct globval *ret, *e, *g;
@@ -654,14 +649,13 @@ char **
glob_vector (char *pat, char *dir, int flags)
{
DIR *d;
register struct dirent *dp;
struct globval *lastlink, *e, *dirlist;
register struct globval *nextlink;
register char *nextname, *npat, *subdir;
unsigned int count;
int lose, skip, ndirs, isdir, sdlen, add_current, patlen;
register char **name_vector;
register unsigned int i;
struct dirent *dp;
struct globval *nextlink, *lastlink, *e, *dirlist;
char *nextname, *npat, *subdir;
unsigned int count, i;
int lose, skip, ndirs, isdir, add_current;
size_t patlen, sdlen;
char **name_vector;
int mflags; /* Flags passed to strmatch (). */
int pflags; /* flags passed to sh_makepath () */
int hasglob; /* return value from glob_pattern_p */
@@ -670,7 +664,8 @@ glob_vector (char *pat, char *dir, int flags)
char *convfn;
lastlink = 0;
count = lose = skip = add_current = 0;
count = 0;
lose = skip = add_current = 0;
firstmalloc = 0;
nalloca = 0;
@@ -713,7 +708,7 @@ glob_vector (char *pat, char *dir, int flags)
hasglob = 0;
if (skip == 0 && ((hasglob = glob_pattern_p (pat)) == 0 || hasglob == 2))
{
int dirlen;
size_t dirlen;
struct stat finfo;
if (glob_testdir (dir, 0) < 0)
@@ -1035,7 +1030,8 @@ glob_vector (char *pat, char *dir, int flags)
static char **
glob_dir_to_array (char *dir, char **array, int flags)
{
register unsigned int i, l;
unsigned int i;
size_t l;
int add_slash;
char **result, *new;
struct stat sb;
@@ -1125,7 +1121,7 @@ glob_filename (char *pathname, int flags)
char **result, **new_result;
unsigned int result_size;
char *directory_name, *filename, *dname, *fn;
unsigned int directory_len;
size_t directory_len;
int free_dirname; /* flag */
int dflags, hasglob;
@@ -1184,7 +1180,7 @@ glob_filename (char *pathname, int flags)
if (directory_len > 0 && (hasglob = glob_pattern_p (directory_name)) == 1)
{
char **directories, *d, *p;
register unsigned int i;
unsigned int i;
int all_starstar, last_starstar;
all_starstar = last_starstar = 0;
@@ -1220,7 +1216,7 @@ glob_filename (char *pathname, int flags)
so we can compensate if filename is [star][star] */
if ((flags & GX_GLOBSTAR) && all_starstar == 0)
{
int dl, prev;
size_t dl, prev;
prev = dl = directory_len;
while (dl >= 4 && d[dl - 1] == '/' &&
d[dl - 2] == '*' &&
@@ -1306,8 +1302,6 @@ glob_filename (char *pathname, int flags)
/* Special handling for symlinks to directories with globstar on */
if (all_starstar && (dflags & GX_NULLDIR) == 0)
{
int dlen;
/* If we have a directory name that is not null (GX_NULLDIR above)
and is a symlink to a directory, we return the symlink if
we're not `descending' into it (filename[0] == 0) and return
@@ -1350,7 +1344,7 @@ glob_filename (char *pathname, int flags)
else
{
char **array;
register unsigned int l;
unsigned int l;
/* If we're expanding **, we don't need to glue the directory
name to the results; we've already done it in glob_vector */
@@ -1374,7 +1368,7 @@ glob_filename (char *pathname, int flags)
NULL_PLACEHOLDER (temp_results))
#undef NULL_PLACEHOLDER
{
register int i, n;
int i, n;
for (n = 0; temp_results[n] && *temp_results[n] == 0; n++)
;
i = n;
+2 -2
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 1991-2017 Free Software Foundation, Inc.
/* Copyright (C) 1991-2017,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -76,7 +76,7 @@ MATCHLEN (pat, max)
size_t max;
{
CHAR c;
int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
int matlen, bracklen, in_cclass, in_collsym, in_equiv;
if (*pat == 0)
return (0);
+1 -1
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 1991-2022 Free Software Foundation, Inc.
/* Copyright (C) 1991-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -4
View File
@@ -1,7 +1,7 @@
/* strmatch.c -- ksh-like extended pattern matching for the shell and filename
globbing. */
/* Copyright (C) 1991-2022 Free Software Foundation, Inc.
/* Copyright (C) 1991-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -103,7 +103,6 @@ charcmp (int c1, int c2, int forcecoll)
{
static char s1[2] = { ' ', '\0' };
static char s2[2] = { ' ', '\0' };
int ret;
/* Eight bits only. Period. */
c1 &= 0xFF;
@@ -379,7 +378,6 @@ charcmp_wc (wint_t c1, wint_t c2, int forcecoll)
{
static wchar_t s1[2] = { L' ', L'\0' };
static wchar_t s2[2] = { L' ', L'\0' };
int r;
if (c1 == c2)
return 0;
@@ -582,7 +580,6 @@ xstrmatch (char *pattern, char *string, int flags)
int ret;
size_t n;
wchar_t *wpattern, *wstring;
size_t plen, slen, mplen, mslen;
glob_recursion_depth = 0;
-1
View File
@@ -419,7 +419,6 @@ xwcsrtombs (char *dest, const wchar_t **srcp, size_t len, mbstate_t *ps)
size_t cur_max; /* XXX - locale_cur_max */
char buf[64], *destptr, *tmp_dest;
unsigned char uc;
mbstate_t prev_state;
cur_max = MB_CUR_MAX;
if (cur_max > sizeof (buf)) /* Holy cow. */
+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;
+3 -2
View File
@@ -1,7 +1,7 @@
/* getenv.c - get environment variable value from the shell's variable
list. */
/* Copyright (C) 1997-2002 Free Software Foundation, Inc.
/* Copyright (C) 1997-2002,2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -70,7 +70,8 @@ getenv (const char *name)
}
else if (environ)
{
register int i, len;
int i;
size_t len;
/* In some cases, s5r3 invokes getenv() before main(); BSD systems
using gprof also exhibit this behavior. This means that
+2 -2
View File
@@ -1,6 +1,6 @@
/* makepath.c - glue PATH and DIR together into a full pathname. */
/* Copyright (C) 1987-2020,2022 Free Software Foundation, Inc.
/* Copyright (C) 1987-2020,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -69,7 +69,7 @@ static char *nullpath = "";
char *
sh_makepath (const char *path, const char *dir, int flags)
{
int dirlen, pathlen;
size_t dirlen, pathlen;
char *ret, *xpath, *xdir, *r, *s;
if (path == 0 || *path == '\0')
+5 -3
View File
@@ -1,6 +1,6 @@
/* mbscasecmp - case-insensitive multibyte string comparison. */
/* Copyright (C) 2009-2022 Free Software Foundation, Inc.
/* Copyright (C) 2009-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -33,8 +33,10 @@
int
mbscasecmp (const char *mbs1, const char *mbs2)
{
int len1, len2, mb_cur_max;
wchar_t c1, c2, l1, l2;
size_t len1, len2;
int mb_cur_max;
wchar_t c1, c2;
wint_t l1, l2;
mbstate_t state1 = { 0 }, state2 = { 0 };
len1 = len2 = 0;
+3 -3
View File
@@ -56,7 +56,7 @@ extern int errno;
char *
strchr (const char *string, int c)
{
register char *s;
char *s;
for (s = string; s && *s; s++)
if (*s == c)
@@ -68,9 +68,9 @@ strchr (const char *string, int c)
char *
strrchr (const char *string, int c)
{
register char *s, *t;
char *s, *t;
for (s = string, t = (char *)NULL; s && *s; s++)
for (s = string, t = NULL; s && *s; s++)
if (*s == c)
t = s;
return (t);
+4 -3
View File
@@ -1,6 +1,6 @@
/* pathphys.c -- return pathname with all symlinks expanded. */
/* Copyright (C) 2000-2020,2022 Free Software Foundation, Inc.
/* Copyright (C) 2000-2020,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -49,7 +49,7 @@ extern int errno;
extern char *get_working_directory (char *);
static inline int
_path_readlink (char *path, char *buf, int bufsiz)
_path_readlink (char *path, char *buf, size_t bufsiz)
{
#ifdef HAVE_READLINK
return readlink (path, buf, bufsiz);
@@ -73,7 +73,8 @@ sh_physpath (char *path, int flags)
{
char tbuf[PATH_MAX+1], linkbuf[PATH_MAX+1];
char *result, *p, *q, *qsave, *qbase, *workpath;
int double_slash_path, linklen, nlink;
int double_slash_path, nlink;
size_t linklen;
linklen = strlen (path);
+6 -5
View File
@@ -94,7 +94,7 @@ static const char bstab[256] =
char *
sh_single_quote (const char *string)
{
register int c;
int c;
char *result, *r;
const char *s;
@@ -133,7 +133,7 @@ sh_single_quote (const char *string)
char *
sh_double_quote (const char *string)
{
register unsigned char c;
unsigned char c;
int mb_cur_max;
char *result, *r;
size_t slen;
@@ -178,11 +178,12 @@ sh_double_quote (const char *string)
/* Turn S into a simple double-quoted string. If FLAGS is non-zero, quote
double quote characters in S with backslashes. */
char *
sh_mkdoublequoted (const char *s, int slen, int flags)
sh_mkdoublequoted (const char *s, size_t slen, int flags)
{
char *r, *ret;
const char *send;
int rlen, mb_cur_max;
int mb_cur_max;
size_t rlen;
DECLARE_MBSTATE;
send = s + slen;
@@ -218,7 +219,7 @@ sh_mkdoublequoted (const char *s, int slen, int flags)
char *
sh_un_double_quote (char *string)
{
register int c, pass_next;
int c, pass_next;
char *result, *r, *s;
r = result = (char *)xmalloc (strlen (string) + 1);
+1 -1
View File
@@ -1135,7 +1135,7 @@ static char *
groupnum (char *s)
{
char *se, *ret, *re, *g;
int len, slen;
size_t len, slen;
if (grouping == 0 || *grouping <= 0 || *grouping == CHAR_MAX)
return ((char *)NULL);
+2 -2
View File
@@ -1,6 +1,6 @@
/* spell.c -- spelling correction for pathnames. */
/* Copyright (C) 2000-2022 Free Software Foundation, Inc.
/* Copyright (C) 2000-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -184,7 +184,7 @@ spdist(char *cur, char *new)
char *
dirspell (char *dirname)
{
int n;
size_t n;
char *guess;
n = (strlen (dirname) * 3 + 1) / 2 + 1;
+8 -8
View File
@@ -40,7 +40,7 @@ STRINGLIST *
strlist_create (size_t n)
{
STRINGLIST *ret;
register int i;
int i;
ret = (STRINGLIST *)xmalloc (sizeof (STRINGLIST));
if (n)
@@ -62,7 +62,7 @@ strlist_create (size_t n)
STRINGLIST *
strlist_resize (STRINGLIST *sl, size_t n)
{
register int i;
size_t i;
if (sl == 0)
return (sl = strlist_create (n));
@@ -114,7 +114,7 @@ STRINGLIST *
strlist_copy (STRINGLIST *sl)
{
STRINGLIST *new;
register int i;
int i;
if (sl == 0)
return ((STRINGLIST *)0);
@@ -139,7 +139,7 @@ STRINGLIST *
strlist_merge (STRINGLIST *m1, STRINGLIST *m2)
{
STRINGLIST *sl;
int i, n, l1, l2;
size_t i, n, l1, l2;
l1 = m1 ? m1->list_len : 0;
l2 = m2 ? m2->list_len : 0;
@@ -158,7 +158,7 @@ strlist_merge (STRINGLIST *m1, STRINGLIST *m2)
STRINGLIST *
strlist_append (STRINGLIST *m1, STRINGLIST *m2)
{
register int i, n, len1, len2;
size_t i, n, len1, len2;
if (m1 == 0)
return (m2 ? strlist_copy (m2) : (STRINGLIST *)0);
@@ -181,7 +181,7 @@ strlist_append (STRINGLIST *m1, STRINGLIST *m2)
STRINGLIST *
strlist_prefix_suffix (STRINGLIST *sl, const char *prefix, const char *suffix)
{
int plen, slen, tlen, llen, i;
size_t plen, slen, tlen, llen, i;
char *t;
if (sl == 0 || sl->list == 0 || sl->list_len == 0)
@@ -213,7 +213,7 @@ strlist_prefix_suffix (STRINGLIST *sl, const char *prefix, const char *suffix)
void
strlist_print (STRINGLIST *sl, const char *prefix)
{
register int i;
int i;
if (sl == 0)
return;
@@ -224,7 +224,7 @@ strlist_print (STRINGLIST *sl, const char *prefix)
void
strlist_walk (STRINGLIST *sl, sh_strlist_map_func_t *func)
{
register int i;
int i;
if (sl == 0)
return;
+12 -9
View File
@@ -1,6 +1,6 @@
/* strtrans.c - Translate and untranslate strings with ANSI-C escape sequences. */
/* Copyright (C) 2000-2015,2022 Free Software Foundation, Inc.
/* Copyright (C) 2000-2015,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -51,16 +51,17 @@ char *
ansicstr (const char *string, int len, int flags, int *sawc, int *rlen)
{
int c, temp;
char *ret, *r, *s;
char *ret, *r;
const char *s;
unsigned long v;
size_t clen;
int b, mb_cur_max;
int mb_cur_max;
#if defined (HANDLE_MULTIBYTE)
wchar_t wc;
#endif
if (string == 0 || *string == '\0')
return ((char *)NULL);
return ((char *)0);
mb_cur_max = MB_CUR_MAX;
#if defined (HANDLE_MULTIBYTE)
@@ -71,7 +72,7 @@ ansicstr (const char *string, int len, int flags, int *sawc, int *rlen)
#else
ret = (char *)xmalloc (2*len + 1); /* 2*len for possible CTLESC */
#endif
for (r = ret, s = (char *)string; s && *s; )
for (r = ret, s = string; s && *s; )
{
c = *s++;
if (c != '\\' || *s == '\0')
@@ -227,8 +228,9 @@ ansicstr (const char *string, int len, int flags, int *sawc, int *rlen)
char *
ansic_quote (const char *str, int flags, int *rlen)
{
char *r, *ret, *s;
int l, rsize;
char *r, *ret;
const char *s;
size_t l, rsize;
unsigned char c;
size_t clen;
int b;
@@ -246,9 +248,10 @@ ansic_quote (const char *str, int flags, int *rlen)
*r++ = '$';
*r++ = '\'';
for (s = (char *)str; c = *s; s++)
for (s = str; c = *s; s++)
{
b = l = 1; /* 1 == add backslash; 0 == no backslash */
b = 1; /* 1 == add backslash; 0 == no backslash */
l = 1;
clen = 1;
switch (c)
+4 -3
View File
@@ -2,7 +2,7 @@
* tmpfile.c - functions to create and safely open temp files for the shell.
*/
/* Copyright (C) 2000-2020,2022 Free Software Foundation, Inc.
/* Copyright (C) 2000-2020,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -278,11 +278,12 @@ sh_mktmpfp (const char *nameroot, int flags, char **namep)
char *
sh_mktmpdir (const char *nameroot, int flags)
{
char *filename, *tdir, *dirname;
char *filename;
#ifdef USE_MKDTEMP
char *tdir, *dirname;
const char *lroot;
int fd, tdlen;
#ifdef USE_MKDTEMP
filename = (char *)xmalloc (PATH_MAX + 1);
tdir = get_tmpdir (flags);
tdlen = strlen (tdir);
+2 -1
View File
@@ -87,10 +87,11 @@ int
fsleep(unsigned int sec, unsigned int usec)
{
int e, r;
sigset_t blocked_sigs, prevmask;
sigset_t blocked_sigs;
#if defined (HAVE_PSELECT)
struct timespec ts;
#else
sigset_t prevmask;
struct timeval tv;
#endif
+2 -2
View File
@@ -48,7 +48,7 @@ utf8_mbscmp (const char *s1, const char *s2)
char *
utf8_mbsmbchar (const char *str)
{
register char *s;
char *s;
for (s = (char *)str; *s; s++)
if ((*s & 0xc0) == 0x80)
@@ -59,7 +59,7 @@ utf8_mbsmbchar (const char *str)
int
utf8_mbsnlen(const char *src, size_t srclen, int maxlen)
{
register int sind, count;
int sind, count;
for (sind = count = 0; src[sind] && sind <= maxlen; sind++)
{
+3 -3
View File
@@ -1,7 +1,7 @@
/* zgetline - read a line of input from a specified file descriptor and return
a pointer to a newly-allocated buffer containing the data. */
/* Copyright (C) 2008-2020,2022 Free Software Foundation, Inc.
/* Copyright (C) 2008-2020,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -63,8 +63,8 @@ typedef ssize_t creadfunc_t (int, char *);
ssize_t
zgetline (int fd, char **lineptr, size_t *n, int delim, int unbuffered_read)
{
int retval;
size_t nr;
ssize_t retval;
ssize_t nr;
char *line, c;
if (lineptr == 0 || n == 0 || (*lineptr == 0 && *n != 0))
+1 -1
View File
@@ -45,7 +45,7 @@ extern ssize_t zread (int, char *, size_t);
/* Dump contents of file descriptor FD to *OSTR. FN is the filename for
error messages (not used right now). */
int
zmapfd (int fd, char **ostr, char *fn)
zmapfd (int fd, char **ostr, const char *fn)
{
ssize_t nr;
int rval;
+2 -2
View File
@@ -1,6 +1,6 @@
/* tilde.c -- Tilde expansion code (~/foo := $HOME/foo). */
/* Copyright (C) 1988-2020 Free Software Foundation, Inc.
/* Copyright (C) 1988-2020,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.
@@ -318,7 +318,7 @@ static char *
glue_prefix_and_suffix (char *prefix, const char *suffix, int suffind)
{
char *ret;
int plen, slen;
size_t plen, slen;
plen = (prefix && *prefix) ? strlen (prefix) : 0;
slen = strlen (suffix + suffind);
+14 -1
View File
@@ -360,27 +360,40 @@ static int
reset_locale_vars (void)
{
char *t, *x;
int retval;
#if defined (HAVE_SETLOCALE)
if (lang == 0 || *lang == '\0')
maybe_make_export_env (); /* trust that this will change environment for setlocale */
if (setlocale (LC_ALL, lang ? lang : "") == 0)
return 0;
retval = 1;
x = 0;
# if defined (LC_CTYPE)
x = setlocale (LC_CTYPE, get_locale_var ("LC_CTYPE"));
if (x == 0)
retval = 0;
# endif
# if defined (LC_COLLATE)
t = setlocale (LC_COLLATE, get_locale_var ("LC_COLLATE"));
if (t == 0)
retval = 0;
# endif
# if defined (LC_MESSAGES)
t = setlocale (LC_MESSAGES, get_locale_var ("LC_MESSAGES"));
if (t == 0)
retval = 0;
# endif
# if defined (LC_NUMERIC)
t = setlocale (LC_NUMERIC, get_locale_var ("LC_NUMERIC"));
if (t == 0)
retval = 0;
# endif
# if defined (LC_TIME)
t = setlocale (LC_TIME, get_locale_var ("LC_TIME"));
if (t == 0)
retval = 0;
# endif
locale_setblanks ();
@@ -394,7 +407,7 @@ reset_locale_vars (void)
# endif
u32reset ();
#endif
return 1;
return retval;
}
#if defined (TRANSLATABLE_STRINGS)
+9 -6
View File
@@ -1,7 +1,7 @@
/* make_cmd.c -- Functions for making instances of the various
parser constructs. */
/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -511,9 +511,11 @@ make_simple_command (ELEMENT element, COMMAND *command)
void
make_here_document (REDIRECT *temp, int lineno)
{
int kill_leading, redir_len;
int kill_leading;
size_t redir_len;
char *redir_word, *document, *full_line;
int document_index, document_size, delim_unquoted;
int document_index, delim_unquoted;
size_t document_size;
if (temp->instruction != r_deblank_reading_until &&
temp->instruction != r_reading_until)
@@ -525,7 +527,8 @@ make_here_document (REDIRECT *temp, int lineno)
kill_leading = temp->instruction == r_deblank_reading_until;
full_line = document = (char *)NULL;
document_index = document_size = 0;
document_index = 0;
document_size = 0;
delim_unquoted = (temp->redirectee.filename->flags & W_QUOTED) == 0;
@@ -566,7 +569,7 @@ make_here_document (REDIRECT *temp, int lineno)
while (full_line = read_secondary_line (delim_unquoted))
{
register char *line;
int len;
size_t len;
here_doc_first_line = 0;
line = full_line;
@@ -639,7 +642,7 @@ make_redirection (REDIRECTEE source, enum r_instruction instruction, REDIRECTEE
{
REDIRECT *temp;
WORD_DESC *w;
int wlen;
size_t wlen;
intmax_t lfd;
temp = (REDIRECT *)xmalloc (sizeof (REDIRECT));
+4 -9
View File
@@ -1,6 +1,6 @@
/* parse.y - Yacc grammar for bash. */
/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -1514,7 +1514,7 @@ static int
yy_readline_get (void)
{
SigHandler *old_sigint;
int line_len;
size_t line_len;
unsigned char c;
if (current_readline_line == 0)
@@ -2150,7 +2150,6 @@ char *
read_secondary_line (int remove_quoted_newline)
{
char *ret;
int n, c;
prompt_string_pointer = &ps2_prompt;
if (SHOULD_PROMPT ())
@@ -3015,7 +3014,7 @@ static int open_brace_count;
static char *
mk_alexpansion (const char *s)
{
int l;
size_t l;
char *r;
l = strlen (s);
@@ -4342,7 +4341,7 @@ parse_string_to_command (char *string, int flags)
sh_input_line_state_t ls;
int nc, sflags;
size_t slen;
char *ret, *ep;
char *ep;
COMMAND *cmd;
if (*string == 0)
@@ -5803,7 +5802,6 @@ decode_prompt_string (char *string)
/* Try to quote anything the user can set in the file system */
if (promptvars || posixly_correct)
{
char *t;
t = sh_strvis (temp);
temp = sh_backslash_quote_for_double_quotes (t, 0);
free (t);
@@ -5885,7 +5883,6 @@ decode_prompt_string (char *string)
second argument of Q_DOUBLE_QUOTES if we use this
function here. */
{
char *t;
t = sh_strvis (t_string);
temp = sh_backslash_quote_for_double_quotes (t, 0);
free (t);
@@ -6570,8 +6567,6 @@ save_parser_state (sh_parser_state_t *ps)
void
restore_parser_state (sh_parser_state_t *ps)
{
int i;
if (ps == 0)
return;
+1 -1
View File
@@ -498,7 +498,7 @@ static void
ignore_globbed_names (char **names, sh_ignore_func_t *name_func)
{
char **newnames;
int n, i;
size_t n, i;
for (i = 0; names[i]; i++)
;
+2 -1
View File
@@ -82,7 +82,8 @@ extern char **shell_glob_filename (const char *, int);
struct ign {
char *val;
int len, flags;
size_t len;
int flags;
};
typedef int sh_iv_item_func_t (struct ign *);
+24 -15
View File
@@ -76,7 +76,7 @@
#endif
#define STRDUP(x) ((x) ? savestring (x) : (char *)NULL)
typedef SHELL_VAR **SVFUNC ();
typedef SHELL_VAR **SVFUNC (void);
#ifndef HAVE_STRPBRK
extern char *strpbrk (char *, char *);
@@ -247,7 +247,7 @@ clean_itemlist (ITEMLIST *itp)
static int
shouldexp_filterpat (char *s)
{
register char *p;
char *p;
for (p = s; p && *p; p++)
{
@@ -319,7 +319,8 @@ STRINGLIST *
completions_to_stringlist (char **matches)
{
STRINGLIST *sl;
int mlen, i, n;
int i, n;
size_t mlen;
mlen = (matches == 0) ? 0 : strvec_len (matches);
sl = strlist_create (mlen + 1);
@@ -350,7 +351,8 @@ it_init_aliases (ITEMLIST *itp)
{
#ifdef ALIAS
alias_t **alias_list;
register int i, n;
int i;
size_t n;
STRINGLIST *sl;
alias_list = all_aliases ();
@@ -379,7 +381,8 @@ init_itemlist_from_varlist (ITEMLIST *itp, SVFUNC *svfunc)
{
SHELL_VAR **vlist;
STRINGLIST *sl;
register int i, n;
int i;
size_t n;
vlist = (*svfunc) ();
if (vlist == 0)
@@ -430,7 +433,8 @@ static int
it_init_builtins (ITEMLIST *itp)
{
STRINGLIST *sl;
register int i, n;
int i;
size_t n;
sl = strlist_create (num_shell_builtins);
for (i = n = 0; i < num_shell_builtins; i++)
@@ -446,7 +450,8 @@ static int
it_init_enabled (ITEMLIST *itp)
{
STRINGLIST *sl;
register int i, n;
int i;
size_t n;
sl = strlist_create (num_shell_builtins);
for (i = n = 0; i < num_shell_builtins; i++)
@@ -464,7 +469,8 @@ static int
it_init_disabled (ITEMLIST *itp)
{
STRINGLIST *sl;
register int i, n;
int i;
size_t n;
sl = strlist_create (num_shell_builtins);
for (i = n = 0; i < num_shell_builtins; i++)
@@ -498,7 +504,8 @@ static int
it_init_helptopics (ITEMLIST *itp)
{
STRINGLIST *sl;
register int i, n;
int i;
size_t n;
sl = strlist_create (num_shell_builtins);
for (i = n = 0; i < num_shell_builtins; i++)
@@ -528,8 +535,8 @@ it_init_joblist (ITEMLIST *itp, int jstate)
{
#if defined (JOB_CONTROL)
STRINGLIST *sl;
register int i;
register PROCESS *p;
int i;
PROCESS *p;
char *s, *t;
JOB *j;
JOB_STATE ws; /* wanted state */
@@ -585,7 +592,8 @@ static int
it_init_keywords (ITEMLIST *itp)
{
STRINGLIST *sl;
register int i, n;
int i;
size_t n;
for (n = 0; word_token_alist[n].word; n++)
;
@@ -653,7 +661,7 @@ static STRINGLIST *
gen_matches_from_itemlist (ITEMLIST *itp, const char *text)
{
STRINGLIST *ret, *sl;
int tlen, i, n;
size_t tlen, i, n;
char *ntxt;
if ((itp->flags & (LIST_DIRTY|LIST_DYNAMIC)) ||
@@ -864,7 +872,7 @@ gen_wordlist_matches (COMPSPEC *cs, const char *text)
{
WORD_LIST *l, *l2;
STRINGLIST *sl;
int nw, tlen;
size_t nw, tlen;
char *ntxt; /* dequoted TEXT to use in comparisons */
if (cs->words == 0 || cs->words[0] == '\0')
@@ -1158,7 +1166,8 @@ gen_command_matches (COMPSPEC *cs, const char *cmd, const char *text,
int nw, int cw)
{
char *csbuf, *cscmd, *t;
int cmdlen, cmdsize, n, ws, we;
int ws, we;
size_t cmdlen, cmdsize, n;
WORD_LIST *cmdlist, *cl;
WORD_DESC *tw;
STRINGLIST *sl;
+12 -24
View File
@@ -1,6 +1,6 @@
/* print_command -- A way to make readable commands from a command tree. */
/* Copyright (C) 1989-2022 Free Software Foundation, Inc.
/* Copyright (C) 1989-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -65,7 +65,7 @@ static void reset_locals (void);
static void newline (char *);
static void indent (int);
static void semicolon (void);
static void the_printed_command_resize (int);
static void the_printed_command_resize (size_t);
static void make_command_string_internal (COMMAND *);
static void _print_word_list (WORD_LIST *, char *, PFUNC *);
@@ -101,7 +101,7 @@ static void print_function_def (FUNCTION_DEF *);
#define PRINTED_COMMAND_GROW_SIZE 128
char *the_printed_command = (char *)NULL;
int the_printed_command_size = 0;
size_t the_printed_command_size = 0;
int command_string_index = 0;
int xtrace_fd = -1;
@@ -132,7 +132,7 @@ static int group_command_nesting;
/* A buffer to indicate the indirection level (PS4) when set -x is enabled. */
static char *indirection_string = 0;
static int indirection_stringsiz = 0;
static size_t indirection_stringsiz = 0;
/* Print COMMAND (a command tree) on standard output. */
void
@@ -436,7 +436,8 @@ indirection_level_string (void)
register int i, j;
char *ps4;
char ps4_firstc[MB_LEN_MAX+1];
int ps4_firstc_len, ps4_len, ineed, old;
size_t ps4_firstc_len, ps4_len, ineed;
int old;
DECLARE_MBSTATE;
ps4 = get_string_value ("PS4");
@@ -1004,7 +1005,6 @@ static void
print_redirection_list (REDIRECT *redirects)
{
REDIRECT *heredocs, *hdtail, *newredir;
char *rw;
heredocs = (REDIRECT *)NULL;
hdtail = heredocs;
@@ -1029,19 +1029,6 @@ print_redirection_list (REDIRECT *redirects)
else
hdtail = heredocs = newredir;
}
#if 0
/* Remove this heuristic now that the command printing code doesn't
unconditionally put in the redirector file descriptor. */
else if (redirects->instruction == r_duplicating_output_word && (redirects->flags & REDIR_VARASSIGN) == 0 && redirects->redirector.dest == 1)
{
/* Temporarily translate it as the execution code does. */
rw = redirects->redirectee.filename->word;
if (rw && *rw != '-' && DIGIT (*rw) == 0 && EXPCHAR (*rw) == 0)
redirects->instruction = r_err_and_out;
print_redirection (redirects);
redirects->instruction = r_duplicating_output_word;
}
#endif
else
print_redirection (redirects);
@@ -1428,7 +1415,7 @@ newline (char *string)
}
static char *indentation_string;
static int indentation_size;
static size_t indentation_size;
static void
indent (int amount)
@@ -1457,9 +1444,10 @@ semicolon (void)
static void
cprintf (const char *control, ...)
{
register const char *s;
const char *s;
char char_arg[2], *argp, intbuf[INT_STRLEN_BOUND (unsigned int) + 1];
int digit_arg, arg_len, c;
int digit_arg, c;
size_t arg_len;
va_list args;
SH_VA_START (args, control);
@@ -1539,7 +1527,7 @@ cprintf (const char *control, ...)
/* Ensure that there is enough space to stuff LENGTH characters into
THE_PRINTED_COMMAND. */
static void
the_printed_command_resize (int length)
the_printed_command_resize (size_t length)
{
if (the_printed_command == 0)
{
@@ -1549,7 +1537,7 @@ the_printed_command_resize (int length)
}
else if ((command_string_index + length) >= the_printed_command_size)
{
int new;
size_t new;
new = command_string_index + length + 1;
/* Round up to the next multiple of PRINTED_COMMAND_GROW_SIZE. */
+6 -6
View File
@@ -435,7 +435,7 @@ main (int argc, char **argv, char **env)
arg_index = 1;
if (arg_index > argc)
arg_index = argc;
command_execution_string = shell_script_filename = (char *)NULL;
command_execution_string = shell_script_filename = NULL;
want_pending_command = locally_skip_execution = read_from_stdin = 0;
default_input = stdin;
#if defined (BUFFERED_INPUT)
@@ -522,7 +522,7 @@ main (int argc, char **argv, char **env)
}
arg_index++;
}
this_command_name = (char *)NULL;
this_command_name = NULL;
/* First, let the outside world know about our interactive status.
A shell is interactive if the `-i' flag was given, or if all of
@@ -775,7 +775,7 @@ main (int argc, char **argv, char **env)
#if defined (BUFFERED_INPUT)
default_buffered_input = fileno (stdin); /* == 0 */
#else
setbuf (default_input, (char *)NULL);
setbuf (default_input, NULL);
#endif /* !BUFFERED_INPUT */
read_from_stdin = 1;
}
@@ -1035,7 +1035,7 @@ sh_exit (int s)
{
#if defined (MALLOC_DEBUG) && defined (USING_BASH_MALLOC)
if (malloc_trace_at_exit && (subshell_environment & (SUBSHELL_COMSUB|SUBSHELL_PROCSUB)) == 0)
trace_malloc_stats (get_name_for_error (), (char *)NULL);
trace_malloc_stats (get_name_for_error (), NULL);
/* mlocation_write_table (); */
#endif
@@ -1308,7 +1308,7 @@ uidget (void)
FREE (current_user.user_name);
FREE (current_user.shell);
FREE (current_user.home_dir);
current_user.user_name = current_user.shell = current_user.home_dir = (char *)NULL;
current_user.user_name = current_user.shell = current_user.home_dir = NULL;
}
current_user.uid = u;
current_user.gid = getgid ();
@@ -1588,7 +1588,7 @@ open_shell_script (char *script_name)
if (exec_argv0)
{
free (exec_argv0);
exec_argv0 = (char *)NULL;
exec_argv0 = NULL;
}
if (file_isdir (filename))
+8 -7
View File
@@ -81,7 +81,7 @@ find_token_in_alist (int token, STRING_INT_ALIST *alist, int flags)
if (alist[i].token == token)
return (savestring (alist[i].word));
}
return ((char *)NULL);
return (NULL);
}
int
@@ -117,8 +117,8 @@ find_index_in_alist (char *string, STRING_INT_ALIST *alist, int flags)
char *
substring (const char *string, int start, int end)
{
register int len;
register char *result;
int len;
char *result;
len = end - start;
result = (char *)xmalloc (len + 1);
@@ -135,11 +135,11 @@ strsub (const char *string, const char *pat, const char *rep, int global)
{
size_t patlen, replen, templen, tempsize, i;
int repl;
char *temp, *r;
char *temp, *r;;
patlen = strlen (pat);
replen = strlen (rep);
for (temp = (char *)NULL, i = templen = tempsize = 0, repl = 1; string[i]; )
for (temp = NULL, i = templen = tempsize = 0, repl = 1; string[i]; )
{
if (repl && STREQN (string + i, pat, patlen))
{
@@ -177,7 +177,8 @@ strsub (const char *string, const char *pat, const char *rep, int global)
char *
strcreplace (const char *string, int c, const char *text, int flags)
{
char *ret, *r, *p, *t;
char *ret, *r, *t;
const char *p;
size_t len, rlen, ind, tlen;
int do_glob, escape_backslash;
@@ -188,7 +189,7 @@ strcreplace (const char *string, int c, const char *text, int flags)
rlen = len + strlen (string) + 2;
ret = (char *)xmalloc (rlen);
for (p = (char *)string, r = ret; p && *p; )
for (p = string, r = ret; p && *p; )
{
if (*p == c)
{
+7 -9
View File
@@ -197,10 +197,6 @@ extern int wordexp_only;
extern int singlequote_translations;
extern int extended_quote;
#if defined (JOB_CONTROL) && defined (PROCESS_SUBSTITUTION)
extern PROCESS *last_procsub_child;
#endif
#if !defined (HAVE_WCSDUP) && defined (HANDLE_MULTIBYTE)
extern wchar_t *wcsdup (const wchar_t *);
#endif
@@ -1324,7 +1320,7 @@ extract_delimited_string (const char *string, int *sindex, char *opener, char *a
size_t slen;
char *t, *result;
int pass_character, nesting_level, in_comment;
int len_closer, len_opener, len_alt_opener;
size_t len_closer, len_opener, len_alt_opener;
DECLARE_MBSTATE;
slen = strlen (string + *sindex) + *sindex;
@@ -2496,8 +2492,8 @@ char_is_quoted (char *string, int eindex)
int
unclosed_pair (char *string, int eindex, char *openstr)
{
int i, pass_next, openc, olen;
size_t slen;
int i, pass_next, openc;
size_t olen, slen;
DECLARE_MBSTATE;
slen = strlen (string);
@@ -5340,7 +5336,7 @@ match_upattern (char *string, char *pat, int mtype, char **sp, char **ep)
#if defined (HANDLE_MULTIBYTE)
#define WFOLD(c) (match_ignore_case && iswupper (c) ? towlower (c) : (c))
#define WFOLD(c) (match_ignore_case && iswupper (c) ? towlower (c) : (wint_t)(c))
/* Match WPAT anywhere in WSTRING and return the match boundaries.
This returns 1 in case of a successful match, 0 otherwise. Wide
@@ -7391,6 +7387,8 @@ parameter_brace_expand_indir (char *name, int var_is_special, int quoted, int pf
WORD_DESC *w;
SHELL_VAR *v;
v = 0; /* silence a maybe-uninitialized warning */
/* See if it's a nameref first, behave in ksh93-compatible fashion.
There is at least one incompatibility: given ${!foo[0]} where foo=bar,
bash performs an indirect lookup on foo[0] and expands the result;
@@ -12628,7 +12626,7 @@ do_assignment_statements (WORD_LIST *varlist, char *command, int is_nullcmd)
static WORD_LIST *
expand_word_list_internal (WORD_LIST *list, int eflags)
{
WORD_LIST *new_list, *temp_list;
WORD_LIST *new_list;
tempenv_assign_error = 0;
if (list == 0)
+3
View File
@@ -229,6 +229,9 @@ extern char *quote_escapes (const char *);
/* And remove such quoted special characters. */
extern char *remove_quoted_escapes (char *);
/* Quote escape characters on the rhs of a word expansion. */
extern char *quote_rhs (const char *);
/* Remove CTLNUL characters from STRING unless they are quoted with CTLESC. */
extern char *remove_quoted_nulls (char *);
+2 -1
View File
@@ -318,7 +318,8 @@ unwind_frame_run_internal (char *tag, char *ignore)
static void
unwind_protect_mem_internal (char *var, char *psize)
{
int size, allocated;
int size;
size_t allocated;
UNWIND_ELT *elt;
size = *(int *) psize;
-1
View File
@@ -33,7 +33,6 @@ extern void run_unwind_protects (void);
extern void clear_unwind_protect_list (int);
extern int have_unwind_protects (void);
extern int unwind_protect_tag_on_stack (const char *);
extern void uwp_init (void);
/* Define for people who like their code to look a certain way. */
#define end_unwind_frame()
+10 -6
View File
@@ -789,7 +789,7 @@ get_bash_name (void)
{
/* Fast path for common case. */
char *cdir;
int len;
size_t len;
cdir = get_string_value ("PWD");
if (cdir)
@@ -2218,7 +2218,6 @@ char *
nameref_transform_name (const char *name, int flags)
{
SHELL_VAR *v;
char *newname;
v = 0;
if (flags & ASS_MKLOCAL)
@@ -2847,7 +2846,8 @@ make_variable_value (SHELL_VAR *var, const char *value, int flags)
{
char *retval, *oval;
intmax_t lval, rval;
int expok, olen, op;
int expok, op;
size_t olen;
/* If this variable has had its type set to integer (via `declare -i'),
then do expression evaluation on it and store the result. The
@@ -4334,8 +4334,8 @@ all_variables_matching_prefix (const char *prefix)
{
SHELL_VAR **varlist;
char **rlist;
int rind, plen;
size_t vind;
int rind;
size_t plen, vind;
plen = STRLEN (prefix);
varlist = all_visible_variables ();
@@ -4398,7 +4398,9 @@ static void
push_posix_temp_var (PTR_T data)
{
SHELL_VAR *var, *v;
#if 0
HASH_TABLE *binding_table;
#endif
var = (SHELL_VAR *)data;
@@ -4410,11 +4412,13 @@ push_posix_temp_var (PTR_T data)
/* XXX - do we need to worry about array variables here? */
#if 0
/* If this modifies an existing local variable, v->context will be non-zero.
If it comes back with v->context == 0, we bound at the global context.
Set binding_table appropriately. It doesn't matter whether it's correct
if the variable is local, only that it's not global_variables->table */
binding_table = v->context ? shell_variables->table : global_variables->table;
#endif
/* global variables are no longer temporary and don't need propagating. */
if (v->context == 0)
@@ -5375,7 +5379,7 @@ struct saved_dollar_vars {
};
static struct saved_dollar_vars *dollar_arg_stack = (struct saved_dollar_vars *)NULL;
static int dollar_arg_stack_slots;
static size_t dollar_arg_stack_slots;
static int dollar_arg_stack_index;
/* Functions to manipulate dollar_vars array. Need to keep these in sync with