[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/4] Port more functions etc. to C23
From: |
Paul Eggert |
Subject: |
[PATCH 1/4] Port more functions etc. to C23 |
Date: |
Sun, 26 Mar 2023 16:50:04 -0700 |
Port more function definitions and declarations to C23.
This includes adding a return type when it defaulted to int.
Add some casts to and from GENERIC_LIST * that are needed
now that the list functions are prototyped.
This does not finish the job, as some trickier functions
still won't work with C23. However, one step at a time.
---
aclocal.m4 | 20 ++++--------
array.c | 3 ++
array2.c | 5 ++-
braces.c | 4 +--
builtins/common.c | 2 +-
builtins/getopts.def | 16 +++------
builtins/mkbuiltins.c | 2 +-
builtins/psize-posix.c | 1 +
examples/loadables/bsdos.glue.c | 31 ++++++------------
examples/loadables/finfo.c | 54 ++++++++++---------------------
examples/loadables/getconf.c | 3 +-
examples/loadables/id.c | 4 +--
examples/loadables/pathchk.c | 3 +-
examples/loadables/pushd.def | 42 +++++++++---------------
examples/loadables/tee.c | 2 +-
examples/loadables/tty.c | 2 +-
execute_cmd.c | 2 +-
expr.c | 12 +++++--
externs.h | 10 +++---
include/memalloc.h | 14 +++-----
input.c | 1 +
lib/glob/glob.c | 5 ++-
lib/glob/gm_loop.c | 11 ++-----
lib/glob/ndir.h | 9 +++---
lib/glob/strmatch.c | 5 ++-
lib/malloc/memtest.c | 1 +
lib/readline/bind.c | 4 +--
lib/readline/doc/hstech.texi | 5 ++-
lib/readline/doc/rltech.texi | 18 ++++-------
lib/readline/examples/fileman.c | 14 +++-----
lib/readline/examples/histexamp.c | 4 +--
lib/readline/examples/rl.c | 4 +--
lib/readline/examples/rlcat.c | 10 ++----
lib/readline/rltty.c | 3 +-
lib/readline/text.c | 3 +-
lib/sh/getcwd.c | 5 ++-
lib/sh/snprintf.c | 1 +
lib/sh/strftime.c | 4 +--
lib/sh/stringlist.c | 2 +-
lib/sh/stringvec.c | 2 +-
lib/termcap/termcap.c | 5 ++-
lib/termcap/tparam.c | 5 ++-
lib/tilde/shell.c | 2 +-
lib/tilde/tilde.c | 3 +-
pcomplete.c | 2 +-
shell.c | 2 +-
subst.c | 7 ++--
support/bashversion.c | 4 +--
support/endian.c | 5 ++-
support/memtest.c | 1 +
support/mksignames.c | 7 ++--
support/printenv.c | 4 +--
support/recho.c | 9 ++----
support/rlvers.sh | 1 +
support/version2.c | 3 +-
support/xcase.c | 4 +--
support/zecho.c | 4 +--
tests/misc/regress/getdate.y | 7 ++--
variables.c | 3 +-
version.c | 3 +-
60 files changed, 164 insertions(+), 260 deletions(-)
diff --git a/aclocal.m4 b/aclocal.m4
index 37546c6c..e6e18737 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -432,6 +432,7 @@ AC_CACHE_VAL(bash_cv_sizeof_rlim_cur,
#endif
#include <stdlib.h>
#include <sys/resource.h>
+int
main()
{
struct rlimit r;
@@ -457,6 +458,7 @@ AC_CACHE_VAL(bash_cv_sizeof_quad_t,
#include <stdint.h>
#endif
+int
main()
{
#if HAVE_QUAD_T
@@ -841,9 +843,7 @@ AC_CACHE_VAL(bash_cv_func_strcoll_broken,
#include <stdlib.h>
int
-main(c, v)
-int c;
-char *v[];
+main (int c, char **v)
{
int r1, r2;
char *deflocale, *defcoll;
@@ -1345,15 +1345,13 @@ AC_CACHE_VAL(bash_cv_must_reinstall_sighandlers,
#endif
#include <stdlib.h>
-typedef void sigfunc();
+typedef void sigfunc (int);
volatile int nsigint;
#ifdef HAVE_POSIX_SIGNALS
sigfunc *
-set_signal_handler(sig, handler)
- int sig;
- sigfunc *handler;
+set_signal_handler (int sig, sigfunc *handler)
{
struct sigaction act, oact;
act.sa_handler = handler;
@@ -1836,9 +1834,7 @@ bash_cv_wcwidth_broken,
#include <wchar.h>
int
-main(c, v)
-int c;
-char **v;
+main (int c, char **v)
{
int w;
@@ -2156,9 +2152,7 @@ AC_CACHE_VAL(bash_cv_wexitstatus_offset,
#include <sys/wait.h>
int
-main(c, v)
- int c;
- char **v;
+main (int c, char **v)
{
pid_t pid, p;
int s, i, n;
diff --git a/array.c b/array.c
index 61894e0b..6f8926eb 100644
--- a/array.c
+++ b/array.c
@@ -1119,6 +1119,7 @@ quote_string(char *s)
return savestring(s);
}
+int
print_element(ARRAY_ELEMENT *ae)
{
char lbuf[INT_STRLEN_BOUND (intmax_t) + 1];
@@ -1128,12 +1129,14 @@ print_element(ARRAY_ELEMENT *ae)
element_value(ae));
}
+int
print_array(ARRAY *a)
{
printf("\n");
array_walk(a, print_element, (void *)NULL);
}
+int
main(int c, char **v)
{
ARRAY *a, *new_a, *copy_of_a;
diff --git a/array2.c b/array2.c
index 2988f3b1..3b6a62e7 100644
--- a/array2.c
+++ b/array2.c
@@ -789,9 +789,7 @@ array_to_kvpair_list (ARRAY *a)
}
ARRAY *
-array_assign_list (array, list)
-ARRAY *array;
-WORD_LIST *list;
+array_assign_list (ARRAY *array, WORD_LIST *list)
{
register WORD_LIST *l;
register arrayind_t i;
@@ -1194,6 +1192,7 @@ print_array(ARRAY *a)
array_walk(a, print_element, (void *)NULL);
}
+int
main(int c, char **v)
{
ARRAY *a, *new_a, *copy_of_a;
diff --git a/braces.c b/braces.c
index e21160c1..4715e5b4 100644
--- a/braces.c
+++ b/braces.c
@@ -81,8 +81,7 @@ static char **array_concat (char **, char **);
#if 0
static void
-dump_result (a)
- char **a;
+dump_result (char **a)
{
int i;
@@ -794,6 +793,7 @@ internal_error (char *format, char *arg1, char *arg2)
fprintf (stderr, "\n");
}
+int
main (int c, char **v)
{
char example[256];
diff --git a/builtins/common.c b/builtins/common.c
index 69e3fc76..2679fae3 100644
--- a/builtins/common.c
+++ b/builtins/common.c
@@ -389,7 +389,7 @@ remember_args (WORD_LIST *list, int destructive)
{
dispose_words (rest_of_args);
rest_of_args = copy_word_list (list);
- posparam_count += list_length (list);
+ posparam_count += list_length ((GENERIC_LIST *) list);
}
if (destructive)
diff --git a/builtins/getopts.def b/builtins/getopts.def
index fc4142b0..2fa68b9c 100644
--- a/builtins/getopts.def
+++ b/builtins/getopts.def
@@ -93,16 +93,14 @@ static int dogetopts (int, char **);
/* getopts_reset is magic code for when OPTIND is reset. N is the
value that has just been assigned to OPTIND. */
void
-getopts_reset (newind)
- int newind;
+getopts_reset (int newind)
{
sh_optind = newind;
sh_badopt = 0;
}
static int
-getopts_unbind_variable (name)
- char *name;
+getopts_unbind_variable (char *name)
{
#if 0
return (unbind_variable (name));
@@ -112,8 +110,7 @@ getopts_unbind_variable (name)
}
static int
-getopts_bind_variable (name, value)
- char *name, *value;
+getopts_bind_variable (char *name, char *value)
{
SHELL_VAR *v;
@@ -159,9 +156,7 @@ getopts_bind_variable (name, value)
*/
static int
-dogetopts (argc, argv)
- int argc;
- char **argv;
+dogetopts (int argc, char **argv)
{
int ret, special_error, old_opterr, i, n;
char strval[2], numval[16];
@@ -312,8 +307,7 @@ dogetopts (argc, argv)
/* The getopts builtin. Build an argv, and call dogetopts with it. */
int
-getopts_builtin (list)
- WORD_LIST *list;
+getopts_builtin (WORD_LIST *list)
{
char **av;
int ac, ret;
diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c
index 2ba37471..7b7f68ce 100644
--- a/builtins/mkbuiltins.c
+++ b/builtins/mkbuiltins.c
@@ -59,7 +59,7 @@
extern int errno;
#endif
-static char *xmalloc (), *xrealloc ();
+static char *xmalloc (size_t), *xrealloc (void *, size_t);
#if !defined (__STDC__) && !defined (strcpy)
extern char *strcpy ();
diff --git a/builtins/psize-posix.c b/builtins/psize-posix.c
index 13abe2ca..1eadd083 100644
--- a/builtins/psize-posix.c
+++ b/builtins/psize-posix.c
@@ -22,6 +22,7 @@
#include <unistd.h>
#include <stdlib.h>
+int
main(int c, char **v)
{
char *p;
diff --git a/examples/loadables/bsdos.glue.c b/examples/loadables/bsdos.glue.c
index 9df731b7..4cbb6e83 100644
--- a/examples/loadables/bsdos.glue.c
+++ b/examples/loadables/bsdos.glue.c
@@ -33,8 +33,7 @@ builtin_error (const char *format, ...)
}
int
-no_options(list)
-WORD_LIST *list;
+no_options (WORD_LIST *list)
{
reset_internal_getopt ();
if (internal_getopt (list, "") != -1)
@@ -46,9 +45,7 @@ WORD_LIST *list;
}
int
-legal_number (string, result)
- char *string;
- long *result;
+legal_number (char *string, long *result)
{
long value;
char *ep;
@@ -75,8 +72,7 @@ legal_number (string, result)
/* Return the number of elements in LIST, a generic list. */
int
-list_length (list)
- GENERIC_LIST *list;
+list_length (GENERIC_LIST *list)
{
register int i;
@@ -85,8 +81,7 @@ list_length (list)
}
GENERIC_LIST *
-reverse_list (list)
- GENERIC_LIST *list;
+reverse_list (GENERIC_LIST *list)
{
register GENERIC_LIST *next, *prev;
@@ -101,8 +96,7 @@ reverse_list (list)
}
WORD_DESC *
-make_bare_word (string)
- char *string;
+make_bare_word (char *string)
{
WORD_DESC *temp;
@@ -119,9 +113,7 @@ make_bare_word (string)
return (temp);
}
WORD_LIST *
-make_word_list (word, link)
- WORD_DESC *word;
- WORD_LIST *link;
+make_word_list (WORD_DESC *word, WORD_LIST *link)
{
WORD_LIST *temp;
@@ -140,16 +132,13 @@ builtin_usage()
}
char *
-xmalloc(s)
- size_t s;
+xmalloc (size_t s)
{
return (malloc (s));
}
WORD_LIST *
-argv_to_word_list (array, copy, starting_index)
- char **array;
- int copy, starting_index;
+argv_to_word_list (char **array, int copy, int starting_index)
{
WORD_LIST *list;
WORD_DESC *w;
@@ -178,9 +167,7 @@ argv_to_word_list (array, copy, starting_index)
in the list in *IP, if IP is non-null. A convenience function for
loadable builtins; also used by `test'. */
char **
-make_builtin_argv (list, ip)
- WORD_LIST *list;
- int *ip;
+make_builtin_argv (WORD_LIST *list, int *ip)
{
char **argv;
diff --git a/examples/loadables/finfo.c b/examples/loadables/finfo.c
index 6491ef0e..24f20186 100644
--- a/examples/loadables/finfo.c
+++ b/examples/loadables/finfo.c
@@ -96,8 +96,7 @@ static int pmask;
#define OPTIONS "acdgiflmnopsuACGMP:U"
static int
-octal(s)
-char *s;
+octal (char *s)
{
int r;
@@ -108,9 +107,7 @@ char *s;
}
static int
-finfo_main(argc, argv)
-int argc;
-char **argv;
+finfo_main (int argc, char **argv)
{
register int i;
int mode, flags, opt;
@@ -162,8 +159,7 @@ char **argv;
}
static struct stat *
-getstat(f)
-char *f;
+getstat (char *f)
{
static struct stat st;
int fd, r;
@@ -190,8 +186,7 @@ char *f;
}
static int
-printfinfo(f)
-char *f;
+printfinfo (char *f)
{
struct stat *st;
@@ -200,15 +195,13 @@ char *f;
}
static int
-getperm(m)
-int m;
+getperm (int m)
{
return (m & (S_IRWXU|S_IRWXG|S_IRWXO|S_ISUID|S_ISGID));
}
static void
-perms(m)
-int m;
+perms (int m)
{
char ubits[4], gbits[4], obits[4]; /* u=rwx,g=rwx,o=rwx */
int i;
@@ -251,8 +244,7 @@ int m;
}
static void
-printmode(mode)
-int mode;
+printmode (int mode)
{
if (S_ISBLK(mode))
printf("S_IFBLK ");
@@ -277,8 +269,7 @@ int mode;
}
static int
-printst(st)
-struct stat *st;
+printst (struct stat *st)
{
struct passwd *pw;
struct group *gr;
@@ -314,9 +305,7 @@ struct stat *st;
}
static int
-printsome(f, flags)
-char *f;
-int flags;
+printsome (char *f, int flags)
{
struct stat *st;
struct passwd *pw;
@@ -400,8 +389,7 @@ int flags;
#ifndef NOBUILTIN
int
-finfo_builtin(list)
- WORD_LIST *list;
+finfo_builtin (WORD_LIST *list)
{
int c, r;
char **v;
@@ -466,9 +454,8 @@ struct builtin finfo_struct = {
char *this_command_name;
-main(argc, argv)
-int argc;
-char **argv;
+int
+main (int argc, char **argv)
{
this_command_name = argv[0];
exit(finfo_main(argc, argv));
@@ -482,8 +469,7 @@ builtin_usage()
#ifndef HAVE_STRERROR
char *
-strerror(e)
-int e;
+strerror (int e)
{
static char ebuf[40];
extern int sys_nerr;
@@ -498,8 +484,7 @@ int e;
#endif
char *
-xmalloc(s)
-size_t s;
+xmalloc (ssize_t s)
{
char *ret;
extern char *malloc();
@@ -512,8 +497,7 @@ size_t s;
}
char *
-base_pathname(p)
-char *p;
+base_pathname (char *p)
{
char *t;
@@ -523,9 +507,7 @@ char *p;
}
int
-legal_number (string, result)
- char *string;
- long *result;
+legal_number (char *string, long *resuls)
{
int sign;
long value;
@@ -584,9 +566,7 @@ extern int optind;
extern char *optarg;
int
-sh_getopt(c, v, o)
-int c;
-char **v, *o;
+sh_getopt (int c, char **v, char *o)
{
int r;
diff --git a/examples/loadables/getconf.c b/examples/loadables/getconf.c
index 7edfbc96..0fcbbb56 100644
--- a/examples/loadables/getconf.c
+++ b/examples/loadables/getconf.c
@@ -1135,7 +1135,8 @@ getconf_builtin (WORD_LIST *list)
}
list = loptend;
- if ((aflag == 0 && list == 0) || (aflag && list) || list_length(list) > 2)
+ if ((aflag == 0 && list == 0) || (aflag && list)
+ || list_length ((GENERIC_LIST *) list) > 2)
{
builtin_usage();
return (EX_USAGE);
diff --git a/examples/loadables/id.c b/examples/loadables/id.c
index f46f75ce..98c37ea3 100644
--- a/examples/loadables/id.c
+++ b/examples/loadables/id.c
@@ -41,9 +41,9 @@
#endif
#if !defined (HAVE_GETPW_DECLS)
-extern struct passwd *getpwuid ();
+extern struct passwd *getpwuid (uid_t);
#endif
-extern struct group *getgrgid ();
+extern struct group *getgrgid (gid_t);
#include "shell.h"
#include "builtins.h"
diff --git a/examples/loadables/pathchk.c b/examples/loadables/pathchk.c
index 174ba976..59abd9b4 100644
--- a/examples/loadables/pathchk.c
+++ b/examples/loadables/pathchk.c
@@ -99,8 +99,7 @@ extern char *strerror (int);
static int validate_path (char *, int);
int
-pathchk_builtin (list)
- WORD_LIST *list;
+pathchk_builtin (WORD_LIST *list)
{
int retval, pflag, opt;
diff --git a/examples/loadables/pushd.def b/examples/loadables/pushd.def
index 87300dca..55bc2e1c 100644
--- a/examples/loadables/pushd.def
+++ b/examples/loadables/pushd.def
@@ -127,12 +127,12 @@ static int directory_list_size;
/* Offset to the end of the list. */
static int directory_list_offset;
-static void pushd_error ();
+static void pushd_error (int, char *);
static void clear_directory_stack ();
-static int cd_to_string ();
-static int change_to_temp ();
-static int get_dirstack_index ();
-static void add_dirstack_element ();
+static int cd_to_string (char *);
+static int change_to_temp (char *);
+static int get_dirstack_index (int, int, int *);
+static void add_dirstack_element (char *);
#define NOCD 0x01
#define ROTATE 0x02
@@ -140,8 +140,7 @@ static void add_dirstack_element ();
#define CLEARSTAK 0x08
int
-pushd_builtin (list)
- WORD_LIST *list;
+pushd_builtin (WORD_LIST *list)
{
char *temp, *current_directory, *top;
int j, flags;
@@ -274,8 +273,7 @@ pushd_builtin (list)
If LIST is non-null it should consist of a word +N or -N, which says
what element to delete from the stack. The default is the top one. */
int
-popd_builtin (list)
- WORD_LIST *list;
+popd_builtin (WORD_LIST *list)
{
register int i;
long which;
@@ -351,8 +349,7 @@ popd_builtin (list)
/* Print the current list of directories on the directory stack. */
int
-dirs_builtin (list)
- WORD_LIST *list;
+dirs_builtin (WORD_LIST *list)
{
int flags, desired_index, index_flag, vflag;
long i;
@@ -460,9 +457,7 @@ dirs_builtin (list)
}
static void
-pushd_error (offset, arg)
- int offset;
- char *arg;
+pushd_error (int offset, char *arg)
{
if (offset == 0)
builtin_error ("directory stack empty");
@@ -486,8 +481,7 @@ clear_directory_stack ()
so if the result is EXECUTION_FAILURE then an error message has already
been printed. */
static int
-cd_to_string (name)
- char *name;
+cd_to_string (char *name)
{
WORD_LIST *tlist;
int result;
@@ -499,8 +493,7 @@ cd_to_string (name)
}
static int
-change_to_temp (temp)
- char *temp;
+change_to_temp (char *temp)
{
int tt;
@@ -513,8 +506,7 @@ change_to_temp (temp)
}
static void
-add_dirstack_element (dir)
- char *dir;
+add_dirstack_element (char *dir)
{
int j;
@@ -527,8 +519,7 @@ add_dirstack_element (dir)
}
static int
-get_dirstack_index (ind, sign, indexp)
- int ind, sign, *indexp;
+get_dirstack_index (int ind, int sign, int *indexp)
{
if (indexp)
*indexp = sign > 0 ? 1 : 2;
@@ -548,8 +539,7 @@ get_dirstack_index (ind, sign, indexp)
}
char *
-get_dirstack_element (ind, sign)
- int ind, sign;
+get_dirstack_element (int ind, int sign)
{
int i;
@@ -559,9 +549,7 @@ get_dirstack_element (ind, sign)
}
void
-set_dirstack_element (ind, sign, value)
- int ind, sign;
- char *value;
+set_dirstack_element (int ind, int sign, char *value)
{
int i;
diff --git a/examples/loadables/tee.c b/examples/loadables/tee.c
index 9f26b2d4..c74cb647 100644
--- a/examples/loadables/tee.c
+++ b/examples/loadables/tee.c
@@ -58,7 +58,7 @@ static FLIST *tee_flist;
extern int interrupt_immediately;
-extern char *strerror ();
+extern char *strerror (int);
int
tee_builtin (WORD_LIST *list)
diff --git a/examples/loadables/tty.c b/examples/loadables/tty.c
index b717766a..27a851bf 100644
--- a/examples/loadables/tty.c
+++ b/examples/loadables/tty.c
@@ -28,7 +28,7 @@
#include "bashgetopt.h"
#include "common.h"
-extern char *ttyname ();
+extern char *ttyname (int);
int
tty_builtin (WORD_LIST *list)
diff --git a/execute_cmd.c b/execute_cmd.c
index 7a861826..6546ea8c 100644
--- a/execute_cmd.c
+++ b/execute_cmd.c
@@ -3365,7 +3365,7 @@ execute_select_command (SELECT_COM *select_command)
/* command and arithmetic substitution, parameter and variable expansion,
word splitting, pathname expansion, and quote removal. */
list = releaser = expand_words_no_vars (select_command->map_list);
- list_len = list_length (list);
+ list_len = list_length ((GENERIC_LIST *) list);
if (list == 0 || list_len == 0)
{
if (list)
diff --git a/expr.c b/expr.c
index 1b4e4658..164e031e 100644
--- a/expr.c
+++ b/expr.c
@@ -1615,6 +1615,9 @@ strlong (char *num)
}
#if defined (EXPR_TEST)
+
+#include <stdarg.h>
+
void *
xmalloc (size_t n)
{
@@ -1634,6 +1637,7 @@ char *get_string_value () { return 0; }
procenv_t top_level;
+int
main (int argc, char **argv)
{
register int i;
@@ -1655,11 +1659,13 @@ main (int argc, char **argv)
}
int
-builtin_error (format, arg1, arg2, arg3, arg4, arg5)
- char *format;
+builtin_error (const char *format, ...)
{
+ va_list args;
+ va_start (args, format);
fprintf (stderr, "expr: ");
- fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
+ vfprintf (stderr, format, args);
+ va_end (args);
fprintf (stderr, "\n");
return 0;
}
diff --git a/externs.h b/externs.h
index a5945060..919cf333 100644
--- a/externs.h
+++ b/externs.h
@@ -152,12 +152,10 @@ extern int locale_decpoint (void);
/* Declarations for functions defined in list.c. */
extern void list_walk (GENERIC_LIST *, sh_glist_func_t *);
extern void wlist_walk (WORD_LIST *, sh_icpfunc_t *);
-/* type punning used to pass arbitrary list types to list_reverse, et al so
- there are no prototypes. */
-extern GENERIC_LIST *list_reverse ();
-extern int list_length ();
-extern GENERIC_LIST *list_append ();
-extern GENERIC_LIST *list_remove (); /* unused */
+extern GENERIC_LIST *list_reverse (GENERIC_LIST *);
+extern int list_length (GENERIC_LIST *);
+extern GENERIC_LIST *list_append (GENERIC_LIST *, GENERIC_LIST *);
+extern GENERIC_LIST *list_remove (GENERIC_LIST **, sh_gcp_func_t *, char *);
/* unused */
/* Declarations for functions defined in stringlib.c */
extern int find_string_in_alist (char *, STRING_INT_ALIST *, int);
diff --git a/include/memalloc.h b/include/memalloc.h
index 57318b9d..4ec98e8f 100644
--- a/include/memalloc.h
+++ b/include/memalloc.h
@@ -45,17 +45,13 @@
# include <alloca.h>
# endif /* !IBMESA */
# else /* !HAVE_ALLOCA_H || C_ALLOCA */
-# if defined (__hpux) && defined (__STDC__) && !defined (alloca)
-extern void *alloca ();
-# else
-# if !defined (alloca)
-# if defined (__STDC__)
+# if !defined (alloca)
+# if defined (__STDC__)
extern void *alloca (size_t);
-# else
+# else
extern char *alloca ();
-# endif /* !__STDC__ */
-# endif /* !alloca */
-# endif /* !__hpux || !__STDC__ && !alloca */
+# endif /* !__STDC__ */
+# endif /* !alloca */
# endif /* !HAVE_ALLOCA_H || C_ALLOCA */
#endif /* !__GNUC__ || C_ALLOCA */
diff --git a/input.c b/input.c
index f739de18..ad0d2f68 100644
--- a/input.c
+++ b/input.c
@@ -632,6 +632,7 @@ BASH_INPUT bash_input;
struct stat dsb; /* can be used from gdb */
/* imitate /bin/cat */
+int
main(int argc, char **argv)
{
register int i;
diff --git a/lib/glob/glob.c b/lib/glob/glob.c
index f9a73b80..4f7b746b 100644
--- a/lib/glob/glob.c
+++ b/lib/glob/glob.c
@@ -1550,9 +1550,8 @@ only_filename:
#if defined (TEST)
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char **argv)
{
unsigned int i;
diff --git a/lib/glob/gm_loop.c b/lib/glob/gm_loop.c
index 840631da..583ba2f4 100644
--- a/lib/glob/gm_loop.c
+++ b/lib/glob/gm_loop.c
@@ -18,8 +18,7 @@
#if EXTENDED_GLOB
int
-EXTGLOB_PATTERN_P (pat)
- const CHAR *pat;
+EXTGLOB_PATTERN_P (const CHAR *pat)
{
switch (pat[0])
{
@@ -42,9 +41,7 @@ EXTGLOB_PATTERN_P (pat)
versions. FLAGS is a subset of strmatch flags; used to do case-insensitive
matching for now. */
int
-MATCH_PATTERN_CHAR (pat, string, flags)
- CHAR *pat, *string;
- int flags;
+MATCH_PATTERN_CHAR (CHAR *pat, CHAR *string, int flags)
{
CHAR c;
@@ -71,9 +68,7 @@ MATCH_PATTERN_CHAR (pat, string, flags)
}
int
-MATCHLEN (pat, max)
- CHAR *pat;
- size_t max;
+MATCHLEN (CHAR *pat, size_t max)
{
CHAR c;
int matlen, bracklen, in_cclass, in_collsym, in_equiv;
diff --git a/lib/glob/ndir.h b/lib/glob/ndir.h
index 31261eb0..60c8137a 100644
--- a/lib/glob/ndir.h
+++ b/lib/glob/ndir.h
@@ -42,9 +42,10 @@ typedef struct {
char dd_buf[DIRBLKSIZ]; /* Directory block. */
} DIR;
-extern DIR *opendir ();
-extern struct direct *readdir ();
-extern long telldir ();
-extern void seekdir (), closedir ();
+extern DIR *opendir (const char *);
+extern struct direct *readdir (DIR *);
+extern long telldir (DIR *);
+extern void seekdir (DIR *, long);
+int closedir (DIR *);
#define rewinddir(dirp) seekdir (dirp, 0L)
diff --git a/lib/glob/strmatch.c b/lib/glob/strmatch.c
index 5a2c15f9..076ef2cf 100644
--- a/lib/glob/strmatch.c
+++ b/lib/glob/strmatch.c
@@ -50,9 +50,8 @@ wcsmatch (wchar_t *wpattern, wchar_t *wstring, int flags)
#endif
#ifdef TEST
-main (c, v)
- int c;
- char **v;
+int
+main (int c, char **v)
{
char *string, *pat;
diff --git a/lib/malloc/memtest.c b/lib/malloc/memtest.c
index 911567f9..9d537446 100644
--- a/lib/malloc/memtest.c
+++ b/lib/malloc/memtest.c
@@ -35,6 +35,7 @@
static char xp[64];
+int
main(int c, char **v)
{
char *p;
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index 54ee5cde..524ef34a 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -1167,9 +1167,7 @@ _rl_init_file_error (va_alist)
/* **************************************************************** */
static int
-parse_comparison_op (s, indp)
- const char *s;
- int *indp;
+parse_comparison_op (const char *s, int *indp)
{
int i, peekc, op;
diff --git a/lib/readline/doc/hstech.texi b/lib/readline/doc/hstech.texi
index 7a6d7627..5d4efe53 100644
--- a/lib/readline/doc/hstech.texi
+++ b/lib/readline/doc/hstech.texi
@@ -517,9 +517,8 @@ The following program demonstrates simple use of the
@sc{gnu} History Library.
#include <stdio.h>
#include <readline/history.h>
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char **argv)
@{
char line[1024], *t;
int len, done = 0;
diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi
index f40bc2bd..0ba1510e 100644
--- a/lib/readline/doc/rltech.texi
+++ b/lib/readline/doc/rltech.texi
@@ -2425,8 +2425,8 @@ COMMAND commands[] = @{
@};
/* Forward declarations. */
-char *stripwhite ();
-COMMAND *find_command ();
+char *stripwhite (char *);
+COMMAND *find_command (char *);
/* The name of this program, as taken from argv[0]. */
char *progname;
@@ -2435,8 +2435,7 @@ char *progname;
int done;
char *
-dupstr (s)
- char *s;
+dupstr (char *s)
@{
char *r;
@@ -2445,9 +2444,8 @@ dupstr (s)
return (r);
@}
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char **argv)
@{
char *line, *s;
@@ -2523,8 +2521,7 @@ execute_line (line)
/* Look up NAME as the name of a command, and return a pointer to that
command. Return a NULL pointer if NAME isn't a command name. */
COMMAND *
-find_command (name)
- char *name;
+find_command (char *name)
@{
register int i;
@@ -2538,8 +2535,7 @@ find_command (name)
/* Strip whitespace from the start and end of STRING. Return a pointer
into STRING. */
char *
-stripwhite (string)
- char *string;
+stripwhite (char *string)
@{
register char *s, *t;
diff --git a/lib/readline/examples/fileman.c b/lib/readline/examples/fileman.c
index 2a8b097a..25085beb 100644
--- a/lib/readline/examples/fileman.c
+++ b/lib/readline/examples/fileman.c
@@ -105,8 +105,8 @@ COMMAND commands[] = {
};
/* Forward declarations. */
-char *stripwhite ();
-COMMAND *find_command ();
+char *stripwhite (char *);
+COMMAND *find_command (char *);
/* The name of this program, as taken from argv[0]. */
char *progname;
@@ -126,9 +126,7 @@ dupstr (s)
}
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
char *line, *s;
@@ -202,8 +200,7 @@ execute_line (line)
/* Look up NAME as the name of a command, and return a pointer to that
command. Return a NULL pointer if NAME isn't a command name. */
COMMAND *
-find_command (name)
- char *name;
+find_command (char *name)
{
register int i;
@@ -217,8 +214,7 @@ find_command (name)
/* Strip whitespace from the start and end of STRING. Return a pointer
into STRING. */
char *
-stripwhite (string)
- char *string;
+stripwhite (char *string)
{
register char *s, *t;
diff --git a/lib/readline/examples/histexamp.c
b/lib/readline/examples/histexamp.c
index b321dd0b..b97ee66a 100644
--- a/lib/readline/examples/histexamp.c
+++ b/lib/readline/examples/histexamp.c
@@ -32,9 +32,7 @@
#include <string.h>
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
char line[1024], *t;
int len, done;
diff --git a/lib/readline/examples/rl.c b/lib/readline/examples/rl.c
index 39e5b8eb..726ca951 100644
--- a/lib/readline/examples/rl.c
+++ b/lib/readline/examples/rl.c
@@ -82,9 +82,7 @@ usage()
}
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
char *temp, *prompt;
struct stat sb;
diff --git a/lib/readline/examples/rlcat.c b/lib/readline/examples/rlcat.c
index aabe0ca3..211416cc 100644
--- a/lib/readline/examples/rlcat.c
+++ b/lib/readline/examples/rlcat.c
@@ -64,7 +64,7 @@ extern int errno;
extern int optind;
extern char *optarg;
-static int stdcat();
+static int stdcat (int, char **);
static char *progname;
static int vflag;
@@ -76,9 +76,7 @@ usage()
}
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
char *temp;
int opt, Vflag, Nflag;
@@ -155,9 +153,7 @@ fcopy(fp)
}
int
-stdcat (argc, argv)
- int argc;
- char **argv;
+stdcat (int argc, char **argv)
{
int i, fd, r;
char *s;
diff --git a/lib/readline/rltty.c b/lib/readline/rltty.c
index d9b0cd1c..1bb2338c 100644
--- a/lib/readline/rltty.c
+++ b/lib/readline/rltty.c
@@ -80,8 +80,7 @@ static int ksrflow;
/* Dummy call to force a backgrounded readline to stop before it tries
to get the tty settings. */
static void
-set_winsize (tty)
- int tty;
+set_winsize (int tty)
{
#if defined (TIOCGWINSZ)
struct winsize w;
diff --git a/lib/readline/text.c b/lib/readline/text.c
index abe99b34..62e4da2a 100644
--- a/lib/readline/text.c
+++ b/lib/readline/text.c
@@ -1764,8 +1764,7 @@ _rl_char_search (int count, int fdir, int bdir)
#if defined (READLINE_CALLBACKS)
static int
-_rl_char_search_callback (data)
- _rl_callback_generic_arg *data;
+_rl_char_search_callback (_rl_callback_generic_arg *data)
{
_rl_callback_func = 0;
_rl_want_redisplay = 1;
diff --git a/lib/sh/getcwd.c b/lib/sh/getcwd.c
index 1a39b9f6..8bd6c31f 100644
--- a/lib/sh/getcwd.c
+++ b/lib/sh/getcwd.c
@@ -325,9 +325,8 @@ getcwd (char *buf, size_t size)
#if defined (TEST)
# include <stdio.h>
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char **argv)
{
char b[PATH_MAX];
diff --git a/lib/sh/snprintf.c b/lib/sh/snprintf.c
index 68258e46..891ba91b 100644
--- a/lib/sh/snprintf.c
+++ b/lib/sh/snprintf.c
@@ -1757,6 +1757,7 @@ xfree(void *x)
}
/* set of small tests for snprintf() */
+int
main(int c, char **v)
{
char holder[100];
diff --git a/lib/sh/strftime.c b/lib/sh/strftime.c
index 60bee79f..ef1440c8 100644
--- a/lib/sh/strftime.c
+++ b/lib/sh/strftime.c
@@ -981,9 +981,7 @@ static char *array[] =
/* main routine. */
int
-main(argc, argv)
-int argc;
-char **argv;
+main (int argc, char **argv)
{
long time();
diff --git a/lib/sh/stringlist.c b/lib/sh/stringlist.c
index 61e41bf3..f08691b1 100644
--- a/lib/sh/stringlist.c
+++ b/lib/sh/stringlist.c
@@ -253,7 +253,7 @@ strlist_from_word_list (WORD_LIST *list, int alloc, int
starting_index, int *ip)
*ip = 0;
return ((STRINGLIST *)0);
}
- slen = list_length (list);
+ slen = list_length ((GENERIC_LIST *) list);
ret = (STRINGLIST *)xmalloc (sizeof (STRINGLIST));
ret->list = strvec_from_word_list (list, alloc, starting_index, &len);
ret->list_size = slen + starting_index;
diff --git a/lib/sh/stringvec.c b/lib/sh/stringvec.c
index 2e71fe5d..8b3929cc 100644
--- a/lib/sh/stringvec.c
+++ b/lib/sh/stringvec.c
@@ -206,7 +206,7 @@ strvec_from_word_list (WORD_LIST *list, int alloc, int
starting_index, int *ip)
int count;
char **array;
- count = list_length (list);
+ count = list_length ((GENERIC_LIST *) list);
array = (char **)xmalloc ((1 + count + starting_index) * sizeof (char *));
for (count = 0; count < starting_index; count++)
diff --git a/lib/termcap/termcap.c b/lib/termcap/termcap.c
index 87fae05f..51e26b6f 100644
--- a/lib/termcap/termcap.c
+++ b/lib/termcap/termcap.c
@@ -770,9 +770,8 @@ gobble_line (fd, bufp, append_end)
#include <stdio.h>
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, int argv)
{
char *term;
char *buf;
diff --git a/lib/termcap/tparam.c b/lib/termcap/tparam.c
index c4bff088..72fa558d 100644
--- a/lib/termcap/tparam.c
+++ b/lib/termcap/tparam.c
@@ -328,9 +328,8 @@ tparam1 (string, outstring, len, up, left, argp)
#ifdef DEBUG
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char **argv)
{
char buf[50];
int args[3];
diff --git a/lib/tilde/shell.c b/lib/tilde/shell.c
index 9805a924..de974366 100644
--- a/lib/tilde/shell.c
+++ b/lib/tilde/shell.c
@@ -45,7 +45,7 @@
#include <pwd.h>
#if !defined (HAVE_GETPW_DECLS)
-extern struct passwd *getpwuid ();
+extern struct passwd *getpwuid (uid_t);
#endif /* !HAVE_GETPW_DECLS */
char *
diff --git a/lib/tilde/tilde.c b/lib/tilde/tilde.c
index c31f9213..84137c00 100644
--- a/lib/tilde/tilde.c
+++ b/lib/tilde/tilde.c
@@ -50,7 +50,7 @@
#include "tilde.h"
#if defined (TEST) || defined (STATIC_MALLOC)
-static void *xmalloc (), *xrealloc ();
+static void *xmalloc (size_t), *xrealloc (void *, int);
#else
# include "xmalloc.h"
#endif /* TEST || STATIC_MALLOC */
@@ -423,6 +423,7 @@ tilde_expand_word (const char *filename)
#undef NULL
#include <stdio.h>
+int
main (int argc, char **argv)
{
char *result, line[512];
diff --git a/pcomplete.c b/pcomplete.c
index 9eb20eae..3d54d296 100644
--- a/pcomplete.c
+++ b/pcomplete.c
@@ -893,7 +893,7 @@ gen_wordlist_matches (COMPSPEC *cs, const char *text)
l2 = expand_words_shellexp (l);
dispose_words (l);
- nw = list_length (l2);
+ nw = list_length ((GENERIC_LIST *) l2);
sl = strlist_create (nw + 1);
ntxt = bash_dequote_text (text);
diff --git a/shell.c b/shell.c
index 28940ad1..993b9a1f 100644
--- a/shell.c
+++ b/shell.c
@@ -94,7 +94,7 @@ extern int get_tty_state (void);
#endif
#if !defined (HAVE_GETPW_DECLS)
-extern struct passwd *getpwuid ();
+extern struct passwd *getpwuid (uid_t);
#endif /* !HAVE_GETPW_DECLS */
#if !defined (errno)
diff --git a/subst.c b/subst.c
index a2b719ff..f45e29b8 100644
--- a/subst.c
+++ b/subst.c
@@ -12053,7 +12053,9 @@ glob_expand_word_list (WORD_LIST *tlist, int eflags)
if (glob_list)
{
- output_list = (WORD_LIST *)list_append (glob_list, output_list);
+ output_list = ((WORD_LIST *)
+ list_append ((GENERIC_LIST *) glob_list,
+ (GENERIC_LIST *) output_list));
PREPEND_LIST (tlist, disposables);
}
else if (fail_glob_expansion != 0)
@@ -12532,7 +12534,8 @@ shell_expand_word_list (WORD_LIST *tlist, int eflags)
}
expanded = REVERSE_LIST (temp_list, WORD_LIST *);
- new_list = (WORD_LIST *)list_append (expanded, new_list);
+ new_list = (WORD_LIST *)list_append ((GENERIC_LIST *) expanded,
+ (GENERIC_LIST *) new_list);
}
if (orig_list)
diff --git a/support/bashversion.c b/support/bashversion.c
index 63a634d0..fe11f5ea 100644
--- a/support/bashversion.c
+++ b/support/bashversion.c
@@ -60,9 +60,7 @@ usage()
}
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
int opt, oflags;
char dv[128], *rv;
diff --git a/support/endian.c b/support/endian.c
index 3c92ae8f..27f5b125 100644
--- a/support/endian.c
+++ b/support/endian.c
@@ -39,9 +39,8 @@ char nstring[9];
/* Stuff "1234" into a long, and compare it against a character string
"1234". If the results are EQ, the machine is big endian like a 68000
or Sparc, otherwise it is little endian, like a Vax, or 386. */
-main (argc, argv)
- int argc;
- char **argv;
+int
+main (int argc, char **argv)
{
#if defined (__STDC__)
register size_t i;
diff --git a/support/memtest.c b/support/memtest.c
index 39ffd0f3..80cafa23 100644
--- a/support/memtest.c
+++ b/support/memtest.c
@@ -37,6 +37,7 @@ int interrupt_immediately = 0;
static char xp[64];
+int
main(int c, char **v)
{
char *p;
diff --git a/support/mksignames.c b/support/mksignames.c
index 0a48cee4..98c4c743 100644
--- a/support/mksignames.c
+++ b/support/mksignames.c
@@ -45,8 +45,7 @@ extern char *signal_names[];
char *progname;
void
-write_signames (stream)
- FILE *stream;
+write_signames (FILE *stream)
{
register int i;
@@ -71,9 +70,7 @@ write_signames (stream)
}
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
char *stream_name;
FILE *stream;
diff --git a/support/printenv.c b/support/printenv.c
index 154e086c..c055ec17 100644
--- a/support/printenv.c
+++ b/support/printenv.c
@@ -34,9 +34,7 @@
extern char **environ;
int
-main (argc, argv)
- int argc;
- char **argv;
+main (int argc, char **argv)
{
register char **envp, *eval;
int len;
diff --git a/support/recho.c b/support/recho.c
index 7e3c6bc6..f4a36084 100644
--- a/support/recho.c
+++ b/support/recho.c
@@ -31,12 +31,10 @@
#include "bashansi.h"
#include <stdio.h>
-void strprint();
+void strprint (char *);
int
-main(argc, argv)
-int argc;
-char **argv;
+main (int argc, char **argv)
{
register int i;
@@ -49,8 +47,7 @@ char **argv;
}
void
-strprint(str)
-char *str;
+strprint (char *str)
{
register unsigned char *s;
diff --git a/support/rlvers.sh b/support/rlvers.sh
index 64cadc77..03ed901f 100644
--- a/support/rlvers.sh
+++ b/support/rlvers.sh
@@ -78,6 +78,7 @@ cat > $TDIR/rlvers.c << EOF
#include <stdio.h>
extern char *rl_library_version;
+int
main()
{
printf("%s\n", rl_library_version ? rl_library_version : "0");
diff --git a/support/version2.c b/support/version2.c
index 83e2b13f..dd14dcd0 100644
--- a/support/version2.c
+++ b/support/version2.c
@@ -77,8 +77,7 @@ shell_version_string ()
}
void
-show_shell_version (extended)
- int extended;
+show_shell_version (int extended)
{
printf (_("GNU bash, version %s (%s)\n"), shell_version_string (), MACHTYPE);
if (extended)
diff --git a/support/xcase.c b/support/xcase.c
index 527840db..86d48b60 100644
--- a/support/xcase.c
+++ b/support/xcase.c
@@ -42,9 +42,7 @@ extern int optind;
#define UPPER 2
int
-main(ac, av)
-int ac;
-char **av;
+main (int ac, char **av)
{
int c, x;
int op;
diff --git a/support/zecho.c b/support/zecho.c
index f3a4fe03..9237783e 100644
--- a/support/zecho.c
+++ b/support/zecho.c
@@ -26,9 +26,7 @@
#include <stdio.h>
int
-main(argc, argv)
-int argc;
-char **argv;
+main (int argc, char **argv)
{
argv++;
diff --git a/tests/misc/regress/getdate.y b/tests/misc/regress/getdate.y
index 1df37738..5b0c288e 100644
--- a/tests/misc/regress/getdate.y
+++ b/tests/misc/regress/getdate.y
@@ -111,7 +111,7 @@ static int mdays[12] =
{31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
#define epoch 1970
-extern struct tm *localtime();
+extern struct tm *localtime (const time_t *);
static time_t
dateconv(mm, dd, yy, h, m, s, mer, zone, dayflag)
@@ -545,9 +545,8 @@ struct timeb *now;
yyerror(s) char *s;
{}
-main(c, v)
-int c;
-char **v;
+int
+main (int c, char **v)
{
printf("%d\n", getdate(v[1], (struct timeb *)0));
}
diff --git a/variables.c b/variables.c
index 9f944067..1d67cc8c 100644
--- a/variables.c
+++ b/variables.c
@@ -2445,8 +2445,7 @@ find_function_def (const char *name)
/* Return the value of VAR. VAR is assumed to have been the result of a
lookup without any subscript, if arrays are compiled into the shell. */
char *
-get_variable_value (var)
- SHELL_VAR *var;
+get_variable_value (SHELL_VAR *var)
{
if (var == 0)
return ((char *)NULL);
diff --git a/version.c b/version.c
index 5bb456ac..90aab5c9 100644
--- a/version.c
+++ b/version.c
@@ -80,8 +80,7 @@ shell_version_string ()
}
void
-show_shell_version (extended)
- int extended;
+show_shell_version (int extended)
{
printf (_("GNU bash, version %s (%s)\n"), shell_version_string (), MACHTYPE);
if (extended)
--
2.39.2