]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
final set of ANSI C changes
authorChet Ramey <chet.ramey@case.edu>
Thu, 5 Jan 2023 20:09:06 +0000 (15:09 -0500)
committerChet Ramey <chet.ramey@case.edu>
Thu, 5 Jan 2023 20:09:06 +0000 (15:09 -0500)
84 files changed:
CWRU/CWRU.chlog
Makefile.in
alias.c
arrayfunc.c
bashhist.c
bashline.c
builtins/common.c
builtins/declare.def
builtins/enable.def
builtins/evalfile.c
builtins/evalstring.c
builtins/exit.def
builtins/fc.def
builtins/hash.def
builtins/help.def
builtins/mapfile.def
builtins/pushd.def
builtins/read.def
builtins/set.def
builtins/shopt.def
builtins/ulimit.def
builtins/wait.def
execute_cmd.c
expr.c
externs.h
findcmd.c
general.c
input.c
jobs.c
lib/glob/glob.c
lib/glob/gm_loop.c
lib/glob/sm_loop.c
lib/glob/smatch.c
lib/glob/xmbsrtowcs.c
lib/readline/bind.c
lib/readline/complete.c
lib/readline/histexpand.c
lib/readline/histfile.c
lib/readline/history.c
lib/readline/histsearch.c
lib/readline/isearch.c
lib/readline/kill.c
lib/readline/macro.c
lib/readline/mbutil.c
lib/readline/misc.c
lib/readline/readline.c
lib/readline/readline.h
lib/readline/rlprivate.h
lib/readline/search.c
lib/readline/signals.c
lib/readline/text.c
lib/readline/undo.c
lib/readline/util.c
lib/readline/vi_mode.c
lib/sh/getenv.c
lib/sh/makepath.c
lib/sh/mbscasecmp.c
lib/sh/oslib.c
lib/sh/pathphys.c
lib/sh/shquote.c
lib/sh/snprintf.c
lib/sh/spell.c
lib/sh/stringlist.c
lib/sh/strtrans.c
lib/sh/tmpfile.c
lib/sh/ufuncs.c
lib/sh/utf8.c
lib/sh/zgetline.c
lib/sh/zmapfd.c
lib/tilde/tilde.c
locale.c
make_cmd.c
parse.y
pathexp.c
pathexp.h
pcomplete.c
print_cmd.c
shell.c
stringlib.c
subst.c
subst.h
unwind_prot.c
unwind_prot.h
variables.c

index bad18c8c3d2d8d4e257e0ef0bf8301fe53d4b74d..222fc2c1a9d8f057ea27f643c68ea4d261726647 100644 (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'
index 0b4df73a7a69d301390b98d1e7c32aeedce39b81..b7d92fd455583978e172f143471511c5fd088e0c 100644 (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)
diff --git a/alias.c b/alias.c
index 1c2a1303dee8f7550a802c83e7371fc0407ececa..cb52507c9c30f5e1986414acbe51f6d99c0e1d24 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -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) */
index b1e68b74ff000759734b2acecdc848279a4adcc4..543663ad89ebaf7df3d2e58a3523c54afa46f866 100644 (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
index c05e3c3926d1e6788fb9041a9633e5b58bc1ead0..955097eb7a04fb1c2fed28e0a77107035028c780 100644 (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;
 
index 45046aee8b708509def69f9d438a59dee8f0ad2d..611829528d5390665950aa411071afc8192408cc 100644 (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;
index da8b5faed970273994a5652031ceba7e4178206a..69e3fc764f460149fe69d6299d7ecbde3f670ae9 100644 (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;
index c8643760f47d60f4f35545d8ac16d100174ae96d..f7dac7287509824cbfe53585a3fcb6e405289532 100644 (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);*/
 
index cabb4a7a94ee5dca51b56d8462dd511559bd8317..6b5b5d9f80502bb00d6843175199d5539d4413b0 100644 (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)
index 071947a574799254508a19007975d6a819fb1dc7..f694794fca82e839d0c54094ec69dac1d36bf9f7 100644 (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.
 
index 718ff393d1ee21838c0fe980a32d412d01bebbb4..243becbca8dcb7688543a504a773169c0138072e 100644 (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;
index a1469cdd182bcc15491f064cd6a82a23565178e3..72816a800af70d5b3dac8e950a011f71a1d168d1 100644 (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;
 
index bd321b7306c0a546c031f9b0e4c4994587191a8a..e2b5b8ead8655aa8f0027ae190a1935d637bb1fe 100644 (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;
index cb5f8941b757203a3f07910332ebb2c47d30ec86..699c8dd28d03d5c922ad12e49d8573c54add2307 100644 (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 *);
index d588979c01f2a68ecd50e1957cf072de39a695fb..40eb5fb39f40c0caa5532c05187e4bfea9f1e833 100644 (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];
 
index 05c2e4b61f4bc3e3ba43c45771ad48c0ff749282..b488fca7bd3de25e1394a6f3f53de91674e35b8e 100644 (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;
index 668e3da6ae42e7c89aa3bbcf478025d45bc2fef3..cc9e5d62989219f2704d491af435b7932496feab 100644 (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;
index 51b21f6e790d2ba21de29488cbe418bfc8ea96a2..7e122c3bd04d323efa46aa991be835fa42f2bf8a 100644 (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 ();
index da92d1c6833cc23716724a249e8349cbceb95bd6..5852a8e68e8f24a52e54d9f8f6d870f251888443 100644 (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++)
index 8ecc56157c49cb6e9da149341d80feaa22567dac..e9d5b8c81b6294cfae14be4771ea39c8b57b0c58 100644 (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++)
index 5f0e1379e86f61e4845f8d254caca57e77c5fa45..11c55c91b4206196081fee0c534d470474fd3981 100644 (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
index 782f0aa1c108dfe2f1403261e1bf19811a23b59a..d9d168ca9bc8f73dee2af0cdf344c466b24c3a87 100644 (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;
 
index 61ceb61b77941540aee0b881aa7ba7a5ce2cf519..a30ec61d0b4acbeae5603c262beffb5896f8938d 100644 (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);
diff --git a/expr.c b/expr.c
index 3ff34fb150a40b90e0d882a0544344c1cd1390f7..a8c2aa91cfe321c20d0aae58f3fd4524aa759a4d 100644 (file)
--- a/expr.c
+++ b/expr.c
@@ -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"));
index db287a419d14149e2e40783a6ce60e520dd1d6c8..d38bcb7f29247f5971834f0be8dc06821ee32d79 100644 (file)
--- a/externs.h
+++ b/externs.h
@@ -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);
index 9b211047acdf2575adb88b4f22a8feff29c8e1e4..186871ace6f3993b21135bb8c1d5935af931025f 100644 (file)
--- a/findcmd.c
+++ b/findcmd.c
@@ -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
index 24d7426bce9b1eccdf5b9e0332d802631ce91b2f..be883cf81a1d2f058c1654f6b2a25b4ecd57e605 100644 (file)
--- a/general.c
+++ b/general.c
@@ -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++)
     {
diff --git a/input.c b/input.c
index c48e1cfced0813046436066d2d0df94574e473b6..0e569e7d313f3c84b8609f5efc27753fb19031fd 100644 (file)
--- a/input.c
+++ b/input.c
@@ -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)
diff --git a/jobs.c b/jobs.c
index 294e286cbdacf43dfac78f4fb9fd85bb2fb3833f..70b2fd4bf5f828016230aadc9e22290c7a3b0bb0 100644 (file)
--- a/jobs.c
+++ b/jobs.c
@@ -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)
        {
index eaca7783ea30c8739ecb7ce99db51dd1353d0fc3..f9a73b8092f018abec8876b4466ea372839e4342 100644 (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;
index ac516f82c785766eff1274b8b0c08851516bf0fc..840631dab1782a9eb4c0a4f46d8b630cf41b3a56 100644 (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);
index 61591215431987c26598b87b616fd8fbb6772fe2..c79097e1e862317afd69175e70d460e2ad89d113 100644 (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.
    
index eb105c05933bc63bb5decc355c6ada29cd13114a..411d9f5b8b1d24170e26a6b544d2ccee6be1508b 100644 (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;
 
index 3ae56710d036b8962af71b37866afd3420077707..d81aafb954994a809d678eca4d5101ab2c20d0ef 100644 (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. */
index 971116a90c58ef1ad5d27b4718f6db89fc7b6026..157efb2a41f4b0ecaa36923af3dec478041f780d 100644 (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)
index 61461c90e637e0b6f63e7d593878cf17bd555578..72a42696e08113879b400a5f660640fe4f0a6629 100644 (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. */
index 35fe3fe7b62df68ede67eb466608c272743d169a..4e9d4477be2a52d6baa43c0c3a36468a2384116d 100644 (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++)
index 3bfec5500db515ebafc2310555019711bdd93f4a..531e20957124040e5d21730e5319422ba045f82f 100644 (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 ();
index 81d4c1687b659045f9da5b3b82c58ff9bb4d37b7..781f124a04b208a1b4d2bfc73c564ec54a7fdc7d 100644 (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)
index b62c06b7bf066a32fcc4b24bc8b3aa8c8910488c..7e5b2501755fbef075daa6d0cc9b23a8836675d2 100644 (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;
index 8e7fc01bdded7cf788dd7e851d75099e6a5a4512..17751e77dd4ec330532473baf1bf7533731e6b2e 100644 (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
index 995212564b3df682738f2f2b8e699048867964c0..659e57fd4cc6a41f6294dd5427e0091379a51a92 100644 (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)
index 231a24bcda3d2a865f7c4890010cfd0e8dcd5ca5..9ac258d51abfca8e6a7317fd0904b3a6e315e1a9 100644 (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;
index 32228bbf6367f5c5c6f46472b64192cff3f97484..11cf2293b198343a5d93e59e4d72b79d99f52d8e 100644 (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]);
index dddd499c0e08ff24a6b8d9ac97b436143d67bbb8..e9bbfa260d3dc352f420eddbb6706133ae5481af 100644 (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)
index bfdb4205cd53f3e76a0280e421217ad8c554f80e..65eb54e9e2db7da3f60ce87677c3f6f5d07111e7 100644 (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;
index cac269f0b433ca795a929e0c4c4ebde42446f7de..259e6b4b29b78cdf8e0632f9f51c6333bf730e56 100644 (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;
 
index 806766131a0d6b4085b4775a6f8be1ed954949ad..15a75c5bb28bf1dcb8d028eb1e00596e6293f448 100644 (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;
 
index eea2301115ef6b9e757b50db93b98c20cab7215a..43c66b1bc1d68593e6a0971687228a2e375f7343 100644 (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 *);
index 9df365e48e4cd5b0602668e579f1274a43c647d8..ec835e5aa68ebacaa498f942282860e4db949c59 100644 (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)
index 91c3f330d897d03c88ad3459fbcdf090acb4f2fd..abe99b341435ab63c4dd21963106413957ecc568 100644 (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.      
index e4c457dce328a210c0a77e94903421f3f3251b74..c9c2a5b2d327ecda500eda00dcdd2bee247c23bb 100644 (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);
index 2e986db0a5ed34350ce5155ec66468adfc7e8de2..d481b8561eff7e44cc24b3caa23aa601978db4cb 100644 (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)
index 3a033bab46f8eb9c3eca32145adc0fe325bdf0be..41164dc26ceb2fee2c2dcf63f25e5cec58c1eb56 100644 (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;
index 8f4510ae1d27b0a8f30e7d3b8f6a113815d49c79..6917f075af18b4b4b4fd3c3dbf06b540bb7bb82b 100644 (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
index 448554a8cbc3c19327efd324439041eb6df8fbf9..af3adefae11b3cd9551fda9506337caaf1af1d4b 100644 (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')
index 9aa6a2ff99da51dc48cbdc42255156db1f1455c9..908529cbb12cb1d3ddfb085131d7ef9953024a35 100644 (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.
 
 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;
index b9919c718c89fbc213839c0f74b91bd07bee7d73..ab7924dfde607b664918e36aea845475672cce4a 100644 (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);
index b0ffdb99fe2e0e018186e9bd9bb5de0e7ecb0230..0e78ad58d1af60af3a56e3b43516f6cd9a7578a3 100644 (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);
 
index adf441c15456c7b85f4ebb2db371ae3e073d76cc..4617932ea0066777a386a7e45d6b21772acc6f67 100644 (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);
index 678048c280aef7134ce19bc66c15ce7f56af10d3..68258e460a208effc8a5dfc1aa2d0a104c299980 100644 (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);
index 7e197bbbd58166f63d734efd41b34092149e029e..eb215b84a916f9b14f3e8109c1cd2d8478cb50c7 100644 (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;
index 6cc2fac700a86112be6140593681b843fee6c734..61e41bf3358f498265cca196a0204d0513c2f159 100644 (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;
index 29e3081297aa769d1cd400a2ab8f950518e73360..0cb66ed0a804ff55a616b2fd45aac6d11a243717 100644 (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)
index 9736e06d03ba967dd4aad58460c3d8611b5686c0..18582b104c5fbe54c54f59bcf1e749974f82f7cd 100644 (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);
index ebdae226d987be7f4e0071f66aa161ea8b375c91..247224d66ec25c104776f9ee2774c220286167db 100644 (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
 
index f762b8843e250eefb9a329c7f0256ce8233e0b1a..c550330184fad77e9f56b0a88f7399d86e39fa66 100644 (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++)
     {
index fd33440c34fd58244807a27ff8050b482ce87fb5..0bb10dfb522a686334ca69d168f8ec591f08160d 100644 (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))
index f577a1b39c1799512fc44fe3380de121031372eb..f2e1ea4da5693c81d470cb9875f8f2f8c35a8a3f 100644 (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;
index d678a31ab2735a95b60906fd979e60cfe63c8056..70e6225470d7dcc03ab00272569104e8b2c9864a 100644 (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);
index 60e08a698161eefa01a8244c47a72feae63c374c..e4050c7390e7b1cc8adc1c7ab97a388da22efb03 100644 (file)
--- a/locale.c
+++ b/locale.c
@@ -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)
index 90abdcf7e22ff64e5504605b2f1fe266f1de1d47..499163b24ace4af352a4718fb655c8a9c3a304e6 100644 (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));
diff --git a/parse.y b/parse.y
index 2fffd2b47e2561a97e511ac8ef37c575b62c125d..61183c4281407ad17f4d3f81019619078d3677f5 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -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;
 
index 81cf543a9aa70f11b41b7691cb2af3c879d8a8e0..38e5b8a01ff527f284fc013a1dea9aefa14dc364 100644 (file)
--- a/pathexp.c
+++ b/pathexp.c
@@ -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++)
     ;
index e78db524db00ff5e89f7e77e9d747059786ade2a..6a549912e419fe98be1189e9e9e48c0b2af42e4f 100644 (file)
--- a/pathexp.h
+++ b/pathexp.h
@@ -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 *);
index 737b6cf6047132e788db3515f1a66c4219aa676f..cba3c4dcbdaee5838a76d713ae0ef9e1f12d71fe 100644 (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;
index a32ebc116659a4d1a6f75b86150040b6c779595b..d6bc11df254e0ca22c1484ccc2804f34585e9210 100644 (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. */
diff --git a/shell.c b/shell.c
index 66194b26b127ba30b351a4985409226821c2a120..a64e8e0035b235b47abdf7da97ab2314c04a1e20 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -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))
index 068cd6a3dc23472975ef58c961fe5096ba6ba3e4..a09af58246369310dc39dcb8b8496a4cfbccbc06 100644 (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)
        {
diff --git a/subst.c b/subst.c
index a3b59c21454077b1352b3418404202369e8ab95c..fd8f6d37a7b1e8086bff852fca83a1e68da6fe04 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -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)
diff --git a/subst.h b/subst.h
index a59d20eccc83721d1ac40c4635228422314867e5..c8c0adde046c1203c50bb1c7440a4c4947720fa8 100644 (file)
--- a/subst.h
+++ b/subst.h
@@ -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 *);
 
index aa523d693b0dcb27f55a61ec3a9a74b8e15f455c..c471b98a0ed943dbc5015052e2a6f4ee041565d7 100644 (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;
index a5dfeeeae3aefda0a1cf27ba54c91e5d20588a39..7493c22e3516646f394da26118b446343fcfe00c 100644 (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()
index 8f112807350336935cb706526005511605f74c13..a643185dc3ca8a414f7882b65105b15a52675363 100644 (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