mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-06 03:40:50 +02:00
fourth set of ANSI C changes: size_t; rest globskipdots to enabled default in subshells
This commit is contained in:
@@ -4902,3 +4902,32 @@ subst.c,findcmd.c
|
||||
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
|
||||
|
||||
|
||||
@@ -464,7 +464,6 @@ char *
|
||||
|
||||
alias_expand (char *string)
|
||||
{
|
||||
|
||||
register int i, j, start;
|
||||
char *line, *token;
|
||||
int line_len, tl, real_start, expand_next, expand_this_token;
|
||||
|
||||
+2
-2
@@ -753,10 +753,10 @@ display_shell_version (int count, int c)
|
||||
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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
|
||||
@@ -304,7 +304,8 @@ expand_amble (char *text, size_t tlen, int flags)
|
||||
result = partial;
|
||||
else
|
||||
{
|
||||
register int lr, lp, j;
|
||||
size_t lr, lp;
|
||||
int j;
|
||||
|
||||
lr = strvec_len (result);
|
||||
lp = strvec_len (partial);
|
||||
@@ -711,8 +712,9 @@ comsub:
|
||||
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? */
|
||||
|
||||
+3
-2
@@ -1,7 +1,7 @@
|
||||
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.
|
||||
|
||||
@@ -276,7 +276,8 @@ bind_builtin (WORD_LIST *list)
|
||||
/* 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);
|
||||
|
||||
@@ -383,6 +383,7 @@ reset_shopt_options (void)
|
||||
#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;
|
||||
|
||||
@@ -76,8 +76,6 @@ $END
|
||||
#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
|
||||
|
||||
+2
-2
@@ -5836,9 +5836,9 @@ initialize_subshell (void)
|
||||
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);
|
||||
|
||||
@@ -387,14 +387,14 @@ extern size_t strftime (char *, size_t, const char *, const struct tm *);
|
||||
/* 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 *);
|
||||
@@ -408,14 +408,14 @@ extern void strlist_sort (STRINGLIST *);
|
||||
|
||||
/* 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 **);
|
||||
|
||||
@@ -102,9 +102,9 @@ extern void push_stream (int);
|
||||
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 *);
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
/* Allocate a new STRINGLIST, with room for N strings. */
|
||||
|
||||
STRINGLIST *
|
||||
strlist_create (int n)
|
||||
strlist_create (size_t n)
|
||||
{
|
||||
STRINGLIST *ret;
|
||||
register int i;
|
||||
@@ -60,7 +60,7 @@ strlist_create (int n)
|
||||
}
|
||||
|
||||
STRINGLIST *
|
||||
strlist_resize (STRINGLIST *sl, int n)
|
||||
strlist_resize (STRINGLIST *sl, size_t n)
|
||||
{
|
||||
register int i;
|
||||
|
||||
|
||||
+6
-6
@@ -1,6 +1,6 @@
|
||||
/* 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.
|
||||
|
||||
@@ -34,32 +34,32 @@
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -174,10 +174,10 @@ static int reserved_word_acceptable (int);
|
||||
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);
|
||||
@@ -198,7 +198,7 @@ static int cond_skip_newlines (void);
|
||||
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);
|
||||
@@ -207,7 +207,7 @@ static void discard_parser_constructs (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);
|
||||
@@ -1622,8 +1622,8 @@ with_input_from_stdin (void)
|
||||
static int
|
||||
yy_string_get (void)
|
||||
{
|
||||
register char *string;
|
||||
register unsigned char c;
|
||||
char *string;
|
||||
unsigned char c;
|
||||
|
||||
string = bash_input.location.string;
|
||||
|
||||
@@ -2805,7 +2805,7 @@ discard_until (int character)
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -3013,7 +3013,7 @@ static int open_brace_count;
|
||||
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;
|
||||
@@ -3035,7 +3035,7 @@ mk_alexpansion (char *s)
|
||||
}
|
||||
|
||||
static int
|
||||
alias_expand_token (char *tokstr)
|
||||
alias_expand_token (const char *tokstr)
|
||||
{
|
||||
char *expanded;
|
||||
alias_t *ap;
|
||||
@@ -3150,7 +3150,7 @@ time_command_acceptable (void)
|
||||
*/
|
||||
|
||||
static int
|
||||
special_case_tokens (char *tokstr)
|
||||
special_case_tokens (const char *tokstr)
|
||||
{
|
||||
/* Posix grammar rule 6 */
|
||||
if ((last_read_token == WORD) &&
|
||||
@@ -4768,7 +4768,7 @@ parse_cond_command (void)
|
||||
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;
|
||||
@@ -5367,7 +5367,7 @@ reserved_word_acceptable (int toksym)
|
||||
/* 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++)
|
||||
@@ -6172,7 +6172,7 @@ print_offending_line (void)
|
||||
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;
|
||||
|
||||
|
||||
@@ -304,9 +304,5 @@ xtrace off
|
||||
--
|
||||
./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
|
||||
|
||||
+8
-7
@@ -175,7 +175,7 @@ int shell_level = 0;
|
||||
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 */
|
||||
@@ -284,8 +284,8 @@ static SHELL_VAR *bind_variable_internal (const char *, const char *, HASH_TABLE
|
||||
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);
|
||||
@@ -4037,7 +4037,7 @@ set_func_auto_export (const char *name)
|
||||
/* **************************************************************** */
|
||||
|
||||
static VARLIST *
|
||||
vlist_alloc (int nentries)
|
||||
vlist_alloc (size_t nentries)
|
||||
{
|
||||
VARLIST *vlist;
|
||||
|
||||
@@ -4051,7 +4051,7 @@ vlist_alloc (int nentries)
|
||||
}
|
||||
|
||||
static VARLIST *
|
||||
vlist_realloc (VARLIST *vlist, int n)
|
||||
vlist_realloc (VARLIST *vlist, size_t n)
|
||||
{
|
||||
if (vlist == 0)
|
||||
return (vlist = vlist_alloc (n));
|
||||
@@ -4090,7 +4090,7 @@ map_over (sh_var_map_func_t *function, VAR_CONTEXT *vc)
|
||||
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);
|
||||
@@ -4334,7 +4334,8 @@ all_variables_matching_prefix (const char *prefix)
|
||||
{
|
||||
SHELL_VAR **varlist;
|
||||
char **rlist;
|
||||
int vind, rind, plen;
|
||||
int rind, plen;
|
||||
size_t vind;
|
||||
|
||||
plen = STRLEN (prefix);
|
||||
varlist = all_visible_variables ();
|
||||
|
||||
+2
-2
@@ -95,8 +95,8 @@ typedef struct variable {
|
||||
|
||||
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. */
|
||||
|
||||
Reference in New Issue
Block a user