arrayfunc.h,variables.h,findcmd.h,bashline.h,trap.h,pathexp.h,externs.h,
pcomplete.h,bashhist.h,assoc.h,general.h,subst.h
- more `const' changes, remove `register'
+
+ 1/3
+ ---
+parse.y
+ - more `const' changes, remove `register'
+
+variables.h
+ - VARLIST: list_len and list_size now size_t
+
+variables.c
+ - vlist_alloc: take size_t parameter, changed callers
+ - vlist_realloc: take size_t parameter, changed callers
+
+lib/sh/stringvec.c,externs.h
+ - functions that take int size params now take size_t
+ - strvec_len: returns size_t
+
+lib/sh/stringlist.c,externs.h
+ - STRINGLIST: list_size and list_len now size_t
+ - functions that take int size params now take size_t
+
+variables.c,bashline.c,builtins/bind.def
+ - change strvec_ int parameters to size_t where it makes sense
+ - change strlist_ int parameters to size_t where it makes sense
+
+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
+
alias_expand (char *string)
{
-
register int i, j, start;
char *line, *token;
int line_len, tl, real_start, expand_next, expand_this_token;
static char **hostname_list = (char **)NULL;
/* The physical size of the above list. */
-static int hostname_list_size;
+static size_t hostname_list_size;
/* The number of hostnames in the above list. */
-static int hostname_list_length;
+static size_t hostname_list_length;
/* Whether or not HOSTNAME_LIST has been initialized. */
int hostname_list_initialized = 0;
/* braces.c -- code for doing word expansion in curly braces. */
-/* 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.
result = partial;
else
{
- register int lr, lp, j;
+ size_t lr, lp;
+ int j;
lr = strvec_len (result);
lp = strvec_len (partial);
static char **
array_concat (char **arr1, char **arr2)
{
- register int i, j, len, len1, len2;
- register char **result;
+ int i, j, len;
+ size_t len1, len2;
+ char **result;
if (arr1 == 0)
return (arr2); /* XXX - see if we can get away without copying? */
This file is bind.def, from which is created bind.c.
It implements the builtin "bind" 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.
/* Process the rest of the arguments as binding specifications. */
while (list)
{
- int olen, nlen, d, i;
+ size_t olen, nlen;
+ int d, i;
char **obindings, **nbindings;
obindings = rl_invoking_keyseqs (bash_execute_unix_command);
#if defined (EXTENDED_GLOB)
extended_glob = extglob_flag = EXTGLOB_DEFAULT;
#endif
+ glob_always_skip_dot_and_dotdot = 1; /* new default as of bash-5.2 */
#if defined (ARRAY_VARS)
expand_once_flag = assoc_expand_once = 0;
#include "common.h"
#include "bashgetopt.h"
-extern int find_reserved_word (char *);
-
/* For each word in LIST, find out what the shell is going to do with
it as a simple command. i.e., which file would this shell use to
execve, or if it is a builtin command, or an alias. Possible flag
int
shell_execve (char *command, char **args, char **env)
{
- int larray, i, fd;
+ int i, fd, sample_len;
char sample[HASH_BANG_BUFSIZ];
- int sample_len;
+ size_t larray;
SETOSTYPE (0); /* Some systems use for USG/POSIX semantics */
execve (command, args, env);
/* This is a general-purpose argv-style array struct. */
typedef struct _list_of_strings {
char **list;
- int list_size;
- int list_len;
+ size_t list_size;
+ size_t list_len;
} STRINGLIST;
typedef int sh_strlist_map_func_t (char *);
-extern STRINGLIST *strlist_create (int);
-extern STRINGLIST *strlist_resize (STRINGLIST *, int);
+extern STRINGLIST *strlist_create (size_t);
+extern STRINGLIST *strlist_resize (STRINGLIST *, size_t);
extern void strlist_flush (STRINGLIST *);
extern void strlist_dispose (STRINGLIST *);
extern int strlist_remove (STRINGLIST *, const char *);
/* declarations for functions defined in lib/sh/stringvec.c */
-extern char **strvec_create (int);
-extern char **strvec_resize (char **, int);
-extern char **strvec_mcreate (int);
-extern char **strvec_mresize (char **, int);
+extern char **strvec_create (size_t);
+extern char **strvec_resize (char **, size_t);
+extern char **strvec_mcreate (size_t);
+extern char **strvec_mresize (char **, size_t);
extern void strvec_flush (char **);
extern void strvec_dispose (char **);
extern int strvec_remove (char **, const char *);
-extern int strvec_len (char * const *);
+extern size_t strvec_len (char * const *);
extern int strvec_search (char **, const char *);
extern char **strvec_copy (char * const *);
extern int strvec_posixcmp (char **, char **);
extern void pop_stream (void);
extern int stream_on_stack (enum stream_type);
extern char *read_secondary_line (int);
-extern int find_reserved_word (char *);
+extern int find_reserved_word (const char *);
extern void gather_here_documents (void);
-extern void execute_variable_command (char *, char *);
+extern void execute_variable_command (const char *, const char *);
extern int *save_token_state (void);
extern void restore_token_state (int *);
/* stringlist.c - functions to handle a generic `list of strings' structure */
-/* Copyright (C) 2000-2019, 2022 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2019, 2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* Allocate a new STRINGLIST, with room for N strings. */
STRINGLIST *
-strlist_create (int n)
+strlist_create (size_t n)
{
STRINGLIST *ret;
register int i;
}
STRINGLIST *
-strlist_resize (STRINGLIST *sl, int n)
+strlist_resize (STRINGLIST *sl, size_t n)
{
register int i;
/* stringvec.c - functions for managing arrays of strings. */
-/* Copyright (C) 2000-2002,2022 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2002,2022-2023 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
/* Allocate an array of strings with room for N members. */
char **
-strvec_create (int n)
+strvec_create (size_t n)
{
return ((char **)xmalloc ((n) * sizeof (char *)));
}
/* Allocate an array of strings with room for N members. */
char **
-strvec_mcreate (int n)
+strvec_mcreate (size_t n)
{
return ((char **)malloc ((n) * sizeof (char *)));
}
char **
-strvec_resize (char **array, int nsize)
+strvec_resize (char **array, size_t nsize)
{
return ((char **)xrealloc (array, nsize * sizeof (char *)));
}
char **
-strvec_mresize (char **array, int nsize)
+strvec_mresize (char **array, size_t nsize)
{
return ((char **)realloc (array, nsize * sizeof (char *)));
}
/* Return the length of ARRAY, a NULL terminated array of char *. */
-int
+size_t
strvec_len (char * const *array)
{
register int i;
static int yylex (void);
static void push_heredoc (REDIRECT *);
-static char *mk_alexpansion (char *);
-static int alias_expand_token (char *);
+static char *mk_alexpansion (const char *);
+static int alias_expand_token (const char *);
static int time_command_acceptable (void);
-static int special_case_tokens (char *);
+static int special_case_tokens (const char *);
static int read_token (int);
static char *parse_matched_pair (int, int, int, int *, int);
static char *parse_comsub (int, int, int, int *, int);
static COMMAND *parse_cond_command (void);
#endif
#if defined (ARRAY_VARS)
-static int token_is_assignment (char *, int);
+static int token_is_assignment (const char *, int);
static int token_is_ident (char *, int);
#endif
static int read_token_word (int);
static char *error_token_from_token (int);
static char *error_token_from_text (void);
static void print_offending_line (void);
-static void report_syntax_error (char *);
+static void report_syntax_error (const char *);
static void handle_eof_input_unit (void);
static void prompt_again (int);
static int
yy_string_get (void)
{
- register char *string;
- register unsigned char c;
+ char *string;
+ unsigned char c;
string = bash_input.location.string;
}
void
-execute_variable_command (char *command, char *vname)
+execute_variable_command (const char *command, const char *vname)
{
char *last_lastarg;
sh_parser_state_t ps;
In a pattern list in a case statement (parser_state & PST_CASEPAT). */
static char *
-mk_alexpansion (char *s)
+mk_alexpansion (const char *s)
{
int l;
char *r;
}
static int
-alias_expand_token (char *tokstr)
+alias_expand_token (const char *tokstr)
{
char *expanded;
alias_t *ap;
*/
static int
-special_case_tokens (char *tokstr)
+special_case_tokens (const char *tokstr)
{
/* Posix grammar rule 6 */
if ((last_read_token == WORD) &&
substitution that will reallocate atoken. We don't want to write beyond
the end of an allocated buffer. */
static int
-token_is_assignment (char *t, int i)
+token_is_assignment (const char *t, int i)
{
int r;
char *atoken;
/* Return the index of TOKEN in the alist of reserved words, or -1 if
TOKEN is not a shell reserved word. */
int
-find_reserved_word (char *tokstr)
+find_reserved_word (const char *tokstr)
{
int i;
for (i = 0; word_token_alist[i].word; i++)
then place it in MESSAGE, otherwise pass NULL and this will figure
out an appropriate message for you. */
static void
-report_syntax_error (char *message)
+report_syntax_error (const char *message)
{
char *msg, *p;
--
./shopt.tests: line 106: shopt: xyz1: invalid shell option name
./shopt.tests: line 107: shopt: xyz1: invalid option name
-28c28
-< globskipdots off
----
-> globskipdots on
expand_aliases on
expand_aliases on
shell variables that are marked for export. */
char **export_env = (char **)NULL;
static int export_env_index;
-static int export_env_size;
+static size_t export_env_size;
#if defined (READLINE)
static int winsize_assignment; /* currently assigning to LINES or COLUMNS */
static void dispose_variable_value (SHELL_VAR *);
static void free_variable_hash_data (PTR_T);
-static VARLIST *vlist_alloc (int);
-static VARLIST *vlist_realloc (VARLIST *, int);
+static VARLIST *vlist_alloc (size_t);
+static VARLIST *vlist_realloc (VARLIST *, size_t);
static void vlist_add (VARLIST *, SHELL_VAR *, int);
static void flatten (HASH_TABLE *, sh_var_map_func_t *, VARLIST *, int);
/* **************************************************************** */
static VARLIST *
-vlist_alloc (int nentries)
+vlist_alloc (size_t nentries)
{
VARLIST *vlist;
}
static VARLIST *
-vlist_realloc (VARLIST *vlist, int n)
+vlist_realloc (VARLIST *vlist, size_t n)
{
if (vlist == 0)
return (vlist = vlist_alloc (n));
VAR_CONTEXT *v;
VARLIST *vlist;
SHELL_VAR **ret;
- int nentries;
+ size_t nentries;
for (nentries = 0, v = vc; v; v = v->down)
nentries += HASH_ENTRIES (v->table);
{
SHELL_VAR **varlist;
char **rlist;
- int vind, rind, plen;
+ int rind, plen;
+ size_t vind;
plen = STRLEN (prefix);
varlist = all_visible_variables ();
typedef struct _vlist {
SHELL_VAR **list;
- int list_size; /* allocated size */
- int list_len; /* current number of entries */
+ size_t list_size; /* allocated size */
+ size_t list_len; /* current number of entries */
} VARLIST;
/* The various attributes that a given variable can have. */