bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/4] Remove no-longer-used K&R cruft


From: Paul Eggert
Subject: [PATCH 2/4] Remove no-longer-used K&R cruft
Date: Sun, 26 Mar 2023 16:50:05 -0700

Since we now assume C89 function prototypes anyway,
remove no-longer-used cruft that is used only for
ports to compilers requiring K&R style.
---
 aclocal.m4                 | 35 +--------------------
 builtins/common.c          | 23 ++------------
 builtins/mkbuiltins.c      |  4 ---
 builtins/printf.def        | 10 ++----
 config-bot.h               | 11 -------
 configure.ac               |  3 +-
 error.c                    | 29 ++++++++----------
 examples/loadables/finfo.c | 30 ------------------
 general.h                  |  4 ---
 include/memalloc.h         |  4 ---
 include/stdc.h             | 18 -----------
 jobs.h                     |  2 +-
 lib/doc-support/getopt.h   | 20 ++++--------
 lib/readline/bind.c        | 21 -------------
 lib/readline/complete.c    |  4 ---
 lib/readline/display.c     | 57 ----------------------------------
 lib/readline/examples/rl.c |  5 ---
 lib/readline/funmap.c      |  4 ---
 lib/readline/histlib.h     |  3 --
 lib/readline/parens.c      |  4 ---
 lib/readline/readline.h    |  4 ---
 lib/readline/rldefs.h      | 12 +-------
 lib/readline/rlprivate.h   |  6 ----
 lib/readline/rlstdc.h      | 20 ------------
 lib/readline/util.c        | 63 --------------------------------------
 lib/sh/dprintf.c           |  9 ++----
 lib/sh/fdprintf.c          | 16 ++--------
 lib/sh/snprintf.c          | 11 ++-----
 lib/sh/strindex.c          |  4 +--
 lib/sh/xstrchr.c           |  6 ----
 lib/termcap/termcap.h      | 24 ---------------
 m4/iconv.m4                |  4 ---
 pcomplete.c                |  9 ++----
 print_cmd.c                | 25 ++-------------
 34 files changed, 41 insertions(+), 463 deletions(-)

diff --git a/aclocal.m4 b/aclocal.m4
index e6e18737..b8f67e75 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -69,11 +69,7 @@ AC_DEFUN(BASH_DECL_PRINTF,
 AC_CACHE_VAL(bash_cv_printf_declared,
 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
 #include <stdio.h>
-#ifdef __STDC__
 typedef int (*_bashfunc)(const char *, ...);
-#else
-typedef int (*_bashfunc)();
-#endif
 #include <stdlib.h>
 int
 main()
@@ -566,12 +562,7 @@ AC_CACHE_VAL(bash_cv_getenv_redef,
 #  endif
 #endif
 char *
-getenv (name)
-#if defined (__linux__) || defined (__bsdi__) || defined (convex)
-     const char *name;
-#else
-     char const *name;
-#endif /* !__linux__ && !__bsdi__ && !convex */
+getenv (const char *name)
 {
 return "42";
 }
@@ -601,7 +592,6 @@ fi
 # We should check for putenv before calling this
 AC_DEFUN(BASH_FUNC_STD_PUTENV,
 [
-AC_REQUIRE([AC_C_PROTOTYPES])
 AC_CACHE_CHECK([for standard-conformant putenv declaration], 
bash_cv_std_putenv,
 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #if HAVE_STDLIB_H
@@ -615,11 +605,7 @@ AC_CACHE_CHECK([for standard-conformant putenv 
declaration], bash_cv_std_putenv,
 #    define const
 #  endif
 #endif
-#ifdef PROTOTYPES
 extern int putenv (char *);
-#else
-extern int putenv ();
-#endif
 ]], [[return (putenv == 0);]] )],
 [bash_cv_std_putenv=yes], [bash_cv_std_putenv=no]
 )])
@@ -631,7 +617,6 @@ fi
 # We should check for unsetenv before calling this
 AC_DEFUN(BASH_FUNC_STD_UNSETENV,
 [
-AC_REQUIRE([AC_C_PROTOTYPES])
 AC_CACHE_CHECK([for standard-conformant unsetenv declaration], 
bash_cv_std_unsetenv,
 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #if HAVE_STDLIB_H
@@ -645,11 +630,7 @@ AC_CACHE_CHECK([for standard-conformant unsetenv 
declaration], bash_cv_std_unset
 #    define const
 #  endif
 #endif
-#ifdef PROTOTYPES
 extern int unsetenv (const char *);
-#else
-extern int unsetenv ();
-#endif
 ]], [[return (unsetenv == 0);]] )],
 [bash_cv_std_unsetenv=yes], [bash_cv_std_unsetenv=no]
 )])
@@ -2091,31 +2072,17 @@ AC_DEFUN([BASH_FUNC_VSNPRINTF],
   if test X$ac_cv_func_vsnprintf = Xyes; then
     AC_CACHE_CHECK([for standard-conformant vsnprintf], 
[bash_cv_func_vsnprintf],
       [AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#if HAVE_STDARG_H
 #include <stdarg.h>
-#else
-#include <varargs.h>
-#endif
 #include <stdio.h>
 #include <stdlib.h>
 
 static int
-#if HAVE_STDARG_H
 foo(const char *fmt, ...)
-#else
-foo(format, va_alist)
-     const char *format;
-     va_dcl
-#endif
 {
   va_list args;
   int n;
 
-#if HAVE_STDARG_H
   va_start(args, fmt);
-#else
-  va_start(args);
-#endif
   n = vsnprintf(0, 0, fmt, args);
   va_end (args);
   return n;
diff --git a/builtins/common.c b/builtins/common.c
index 2679fae3..79e61887 100644
--- a/builtins/common.c
+++ b/builtins/common.c
@@ -34,12 +34,7 @@
 #include <signal.h>
 
 #include <errno.h>
-
-#if defined (PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  include <varargs.h>
-#endif
+#include <stdarg.h>
 
 #include "../bashansi.h"
 #include "../bashintl.h"
@@ -100,19 +95,13 @@ builtin_error_prolog (void)
 }
 
 void
-#if defined (PREFER_STDARG)
 builtin_error (const char *format, ...)
-#else
-builtin_error (format, va_alist)
-     const char *format;
-     va_dcl
-#endif
 {
   va_list args;
 
   builtin_error_prolog ();
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   va_end (args);
@@ -120,20 +109,14 @@ builtin_error (format, va_alist)
 }
 
 void
-#if defined (PREFER_STDARG)
 builtin_warning (const char *format, ...)
-#else
-builtin_warning (format, va_alist)
-     const char *format;
-     va_dcl
-#endif
 {
   va_list args;
 
   builtin_error_prolog ();
   fprintf (stderr, _("warning: "));
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   va_end (args);
diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c
index 7b7f68ce..78c7a999 100644
--- a/builtins/mkbuiltins.c
+++ b/builtins/mkbuiltins.c
@@ -61,10 +61,6 @@ extern int errno;
 
 static char *xmalloc (size_t), *xrealloc (void *, size_t);
 
-#if !defined (__STDC__) && !defined (strcpy)
-extern char *strcpy ();
-#endif /* !__STDC__ && !strcpy */
-
 #define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
 
diff --git a/builtins/printf.def b/builtins/printf.def
index 6a4dac07..2a6e2658 100644
--- a/builtins/printf.def
+++ b/builtins/printf.def
@@ -68,11 +68,7 @@ $END
 #  define INT_MIN              (-2147483647-1)
 #endif
 
-#if defined (PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  include <varargs.h>
-#endif
+#include <stdarg.h>
 
 #include <stdio.h>
 #include <chartypes.h>
@@ -1233,7 +1229,7 @@ vbprintf (const char *format, ...)
   size_t nlen;
   int blen;
 
-  SH_VA_START (args, format);
+  va_start (args, format);
   blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
   va_end (args);
 
@@ -1242,7 +1238,7 @@ vbprintf (const char *format, ...)
     {
       vbsize = ((nlen + 63) >> 6) << 6;
       vbuf = (char *)xrealloc (vbuf, vbsize);
-      SH_VA_START (args, format);
+      va_start (args, format);
       blen = vsnprintf (vbuf + vblen, vbsize - vblen, format, args);
       va_end (args);
     }
diff --git a/config-bot.h b/config-bot.h
index a687e402..07e910f1 100644
--- a/config-bot.h
+++ b/config-bot.h
@@ -36,17 +36,6 @@
 #  define HAVE_BSD_PGRP
 #endif
 
-/* Try this without testing __STDC__ for the time being. */
-#if defined (HAVE_STDARG_H)
-#  define PREFER_STDARG
-#  define USE_VARARGS
-#else
-#  if defined (HAVE_VARARGS_H)
-#    define PREFER_VARARGS
-#    define USE_VARARGS
-#  endif
-#endif
-
 #if defined (HAVE_SYS_SOCKET_H) && defined (HAVE_GETPEERNAME) && defined 
(HAVE_NETINET_IN_H)
 #  define HAVE_NETWORK
 #endif
diff --git a/configure.ac b/configure.ac
index da2bd944..343320ec 100644
--- a/configure.ac
+++ b/configure.ac
@@ -759,7 +759,6 @@ AC_C_INLINE
 AC_C_BIGENDIAN
 AC_C_STRINGIZE
 AC_TYPE_LONG_DOUBLE
-AC_C_PROTOTYPES
 AC_C_CHAR_UNSIGNED
 AC_C_VOLATILE
 AC_C_RESTRICT
@@ -773,7 +772,7 @@ AC_HEADER_MAJOR
 
 BASH_HEADER_INTTYPES
 
-AC_CHECK_HEADERS(unistd.h stdlib.h stdarg.h varargs.h limits.h string.h \
+AC_CHECK_HEADERS(unistd.h stdlib.h limits.h string.h \
                 memory.h locale.h termcap.h termio.h termios.h dlfcn.h \
                 stdbool.h stddef.h stdint.h netdb.h pwd.h grp.h strings.h \
                 regex.h syslog.h ulimit.h)
diff --git a/error.c b/error.c
index 76d20529..366d012f 100644
--- a/error.c
+++ b/error.c
@@ -27,12 +27,7 @@
 #  include <unistd.h>
 #endif
 
-#if defined (PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  include <varargs.h>
-#endif
-
+#include <stdarg.h>
 #include <stdio.h>
 
 #include <errno.h>
@@ -143,7 +138,7 @@ programming_error (const char *format, ...)
   give_terminal_to (shell_pgrp, 0);
 #endif /* JOB_CONTROL */
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   fprintf (stderr, "\n");
@@ -178,7 +173,7 @@ report_error (const char *format, ...)
 
   error_prolog (1);
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   fprintf (stderr, "\n");
@@ -199,7 +194,7 @@ fatal_error (const char *format, ...)
 
   error_prolog (0);
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   fprintf (stderr, "\n");
@@ -215,7 +210,7 @@ internal_error (const char *format, ...)
 
   error_prolog (1);
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   fprintf (stderr, "\n");
@@ -231,7 +226,7 @@ internal_warning (const char *format, ...)
   error_prolog (1);
   fprintf (stderr, _("warning: "));
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   fprintf (stderr, "\n");
@@ -248,7 +243,7 @@ internal_inform (const char *format, ...)
   /* TRANSLATORS: this is a prefix for informational messages. */
   fprintf (stderr, _("INFORM: "));
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   fprintf (stderr, "\n");
@@ -265,7 +260,7 @@ internal_debug (const char *format, ...)
   error_prolog (1);
   fprintf (stderr, _("DEBUG warning: "));
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   fprintf (stderr, "\n");
@@ -285,7 +280,7 @@ sys_error (const char *format, ...)
   e = errno;
   error_prolog (0);
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   fprintf (stderr, ": %s\n", strerror (e));
@@ -319,7 +314,7 @@ parser_error (int lineno, const char *format, ...)
   else
     fprintf (stderr, "%s: %s:%s%d: ", ename, iname, gnu_error_format ? "" : 
_(" line "), lineno);
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   fprintf (stderr, "\n");
@@ -367,7 +362,7 @@ itrace (const char *format, ...)
 
   fprintf(stderr, "TRACE: pid %ld: ", (long)getpid());
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stderr, format, args);
   fprintf (stderr, "\n");
@@ -395,7 +390,7 @@ trace (const char *format, ...)
 
   fprintf(tracefp, "TRACE: pid %ld: ", (long)getpid());
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (tracefp, format, args);
   fprintf (tracefp, "\n");
diff --git a/examples/loadables/finfo.c b/examples/loadables/finfo.c
index 24f20186..f4a3251d 100644
--- a/examples/loadables/finfo.c
+++ b/examples/loadables/finfo.c
@@ -444,12 +444,7 @@ struct builtin finfo_struct = {
 #endif
 
 #ifdef NOBUILTIN
-#if defined (PREFER_STDARG)
 #  include <stdarg.h>
-#else
-#  if defined (PREFER_VARARGS)
-#    include <varargs.h>
-#  endif
 #endif
 
 char *this_command_name;
@@ -576,43 +571,18 @@ sh_getopt (int c, char **v, char *o)
        return r;
 }
 
-#if defined (USE_VARARGS)
 void
-#if defined (PREFER_STDARG)
 builtin_error (const char *format, ...)
-#else
-builtin_error (format, va_alist)
-     const char *format;
-     va_dcl
-#endif
 {
   va_list args;
 
   if (this_command_name && *this_command_name)
     fprintf (stderr, "%s: ", this_command_name);
 
-#if defined (PREFER_STDARG)
   va_start (args, format);
-#else
-  va_start (args);
-#endif
-
   vfprintf (stderr, format, args);
   va_end (args);
   fprintf (stderr, "\n");
 }
-#else
-void
-builtin_error (format, arg1, arg2, arg3, arg4, arg5)
-     char *format, *arg1, *arg2, *arg3, *arg4, *arg5;
-{
-  if (this_command_name && *this_command_name)
-    fprintf (stderr, "%s: ", this_command_name);
-
-  fprintf (stderr, format, arg1, arg2, arg3, arg4, arg5);
-  fprintf (stderr, "\n");
-  fflush (stderr);
-}
-#endif /* !USE_VARARGS */
 
 #endif
diff --git a/general.h b/general.h
index 2232fabd..eb296f56 100644
--- a/general.h
+++ b/general.h
@@ -258,11 +258,7 @@ typedef int sh_builtin_func_t (WORD_LIST *); /* 
sh_wlist_func_t */
 #define HIGH_FD_MAX    256
 
 /* The type of function passed as the fourth argument to qsort(3). */
-#ifdef __STDC__
 typedef int QSFUNC (const void *, const void *);
-#else
-typedef int QSFUNC ();
-#endif 
 
 /* Some useful definitions for Unix pathnames.  Argument convention:
    x == string, c == character */
diff --git a/include/memalloc.h b/include/memalloc.h
index 4ec98e8f..419dcb37 100644
--- a/include/memalloc.h
+++ b/include/memalloc.h
@@ -46,11 +46,7 @@
 #    endif /* !IBMESA */
 #  else  /* !HAVE_ALLOCA_H || C_ALLOCA */
 #    if !defined (alloca)
-#      if defined (__STDC__)
 extern void *alloca (size_t);
-#      else
-extern char *alloca ();
-#      endif /* !__STDC__ */
 #    endif /* !alloca */
 #  endif /* !HAVE_ALLOCA_H || C_ALLOCA */
 #endif /* !__GNUC__ || C_ALLOCA */
diff --git a/include/stdc.h b/include/stdc.h
index d9bcc6e0..7f6b4b4d 100644
--- a/include/stdc.h
+++ b/include/stdc.h
@@ -24,18 +24,6 @@
 
 /* Adapted from BSD /usr/include/sys/cdefs.h. */
 
-/* A function can be defined using prototypes and compile on both ANSI C
-   and traditional C compilers with something like this:
-       extern char *func PARAMS((char *, char *, int)); */
-
-#if !defined (PARAMS)
-#  if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) || 
defined (PROTOTYPES)
-#    define PARAMS(protos) protos
-#  else 
-#    define PARAMS(protos) ()
-#  endif
-#endif
-
 /* Fortify, at least, has trouble with this definition */
 #if defined (HAVE_STRINGIZE)
 #  define CPP_STRING(x) #x
@@ -86,10 +74,4 @@
 #  define INLINE
 #endif
 
-#if defined (PREFER_STDARG)
-#  define SH_VA_START(va, arg)  va_start(va, arg)
-#else
-#  define SH_VA_START(va, arg)  va_start(va)
-#endif
-
 #endif /* !_STDC_H_ */
diff --git a/jobs.h b/jobs.h
index de5a9ecf..ead92213 100644
--- a/jobs.h
+++ b/jobs.h
@@ -257,7 +257,7 @@ extern void terminate_stopped_jobs (void);
 extern void hangup_all_jobs (void);
 extern void kill_current_pipeline (void);
 
-#if defined (__STDC__) && defined (pid_t)
+#if defined (pid_t)
 extern int get_job_by_pid (int, int, PROCESS **);
 extern void describe_pid (int);
 #else
diff --git a/lib/doc-support/getopt.h b/lib/doc-support/getopt.h
index 5c045337..009e1629 100644
--- a/lib/doc-support/getopt.h
+++ b/lib/doc-support/getopt.h
@@ -97,15 +97,14 @@ struct option
 #define required_argument      1
 #define optional_argument      2
 
-#if __STDC__
-#if defined(__GNU_LIBRARY__)
-/* Many other libraries have conflicting prototypes for getopt, with
+/* Some ancient libraries have conflicting prototypes for getopt, with
    differences in the consts, in stdlib.h.  To avoid compilation
-   errors, only prototype getopt for the GNU C library.  */
+   errors, rename getopt to something else.  */
+#ifndef getopt
+# define getopt replace_getopt
+#endif
 extern int getopt (int argc, char *const *argv, const char *shortopts);
-#else /* not __GNU_LIBRARY__ */
-extern int getopt ();
-#endif /* not __GNU_LIBRARY__ */
+
 extern int getopt_long (int argc, char *const *argv, const char *shortopts,
                        const struct option *longopts, int *longind);
 extern int getopt_long_only (int argc, char *const *argv,
@@ -117,13 +116,6 @@ extern int _getopt_internal (int argc, char *const *argv,
                             const char *shortopts,
                             const struct option *longopts, int *longind,
                             int long_only);
-#else /* not __STDC__ */
-extern int getopt ();
-extern int getopt_long ();
-extern int getopt_long_only ();
-
-extern int _getopt_internal ();
-#endif /* not __STDC__ */
 
 #ifdef __cplusplus
 }
diff --git a/lib/readline/bind.c b/lib/readline/bind.c
index 524ef34a..4948ad7b 100644
--- a/lib/readline/bind.c
+++ b/lib/readline/bind.c
@@ -65,20 +65,12 @@ extern int errno;
 #include "rlshell.h"
 #include "xmalloc.h"
 
-#if !defined (strchr) && !defined (__STDC__)
-extern char *strchr (), *strrchr ();
-#endif /* !strchr && !__STDC__ */
-
 /* Variables exported by this file. */
 Keymap rl_binding_keymap;
 
 static int _rl_skip_to_delim (char *, int, int);
 
-#if defined (USE_VARARGS) && defined (PREFER_STDARG)
 static void _rl_init_file_error (const char *, ...)  __attribute__((__format__ 
(printf, 1, 2)));
-#else
-static void _rl_init_file_error ();
-#endif
 
 static rl_command_func_t *_rl_function_of_keyseq_internal (const char *, 
size_t, Keymap, int *);
 
@@ -1129,24 +1121,11 @@ _rl_read_init_file (const char *filename, int 
include_level)
 }
 
 static void
-#if defined (PREFER_STDARG)
 _rl_init_file_error (const char *format, ...)
-#else
-_rl_init_file_error (va_alist)
-     va_dcl
-#endif
 {
   va_list args;
-#if defined (PREFER_VARARGS)
-  char *format;
-#endif
 
-#if defined (PREFER_STDARG)
   va_start (args, format);
-#else
-  va_start (args);
-  format = va_arg (args, char *);
-#endif
 
   fprintf (stderr, "readline: ");
   if (currently_reading_init_file)
diff --git a/lib/readline/complete.c b/lib/readline/complete.c
index 2016d393..07441cbd 100644
--- a/lib/readline/complete.c
+++ b/lib/readline/complete.c
@@ -77,11 +77,7 @@ extern int errno;
 #  include "colors.h"
 #endif
 
-#ifdef __STDC__
 typedef int QSFUNC (const void *, const void *);
-#else
-typedef int QSFUNC ();
-#endif
 
 #ifdef HAVE_LSTAT
 #  define LSTAT lstat
diff --git a/lib/readline/display.c b/lib/readline/display.c
index ce9dacd8..e57514b1 100644
--- a/lib/readline/display.c
+++ b/lib/readline/display.c
@@ -59,10 +59,6 @@
 #include "rlprivate.h"
 #include "xmalloc.h"
 
-#if !defined (strchr) && !defined (__STDC__)
-extern char *strchr (), *strrchr ();
-#endif /* !strchr && !__STDC__ */
-
 static void putc_face (int, int, char *);
 static void puts_face (const char *, const char *, int);
 static void norm_face (char *, int);
@@ -3019,29 +3015,15 @@ rl_character_len (int c, int pos)
    mini-modeline. */
 static int msg_saved_prompt = 0;
 
-#if defined (USE_VARARGS)
 int
-#if defined (PREFER_STDARG)
 rl_message (const char *format, ...)
-#else
-rl_message (va_alist)
-     va_dcl
-#endif
 {
   va_list args;
-#if defined (PREFER_VARARGS)
-  char *format;
-#endif
 #if defined (HAVE_VSNPRINTF)
   int bneed;
 #endif
 
-#if defined (PREFER_STDARG)
   va_start (args, format);
-#else
-  va_start (args);
-  format = va_arg (args, char *);
-#endif
 
   if (msg_buf == 0)
     msg_buf = xmalloc (msg_bufsiz = 128);
@@ -3054,12 +3036,7 @@ rl_message (va_alist)
       msg_buf = xrealloc (msg_buf, msg_bufsiz);
       va_end (args);
 
-#if defined (PREFER_STDARG)
       va_start (args, format);
-#else
-      va_start (args);
-      format = va_arg (args, char *);
-#endif
       vsnprintf (msg_buf, msg_bufsiz - 1, format, args);
     }
 #else
@@ -3090,40 +3067,6 @@ rl_message (va_alist)
 
   return 0;
 }
-#else /* !USE_VARARGS */
-int
-rl_message (format, arg1, arg2)
-     char *format;
-{
-  if (msg_buf == 0)
-    msg_buf = xmalloc (msg_bufsiz = 128);
-
-  sprintf (msg_buf, format, arg1, arg2);
-  msg_buf[msg_bufsiz - 1] = '\0';      /* overflow? */
-
-  rl_display_prompt = msg_buf;
-  if (saved_local_prompt == 0)
-    {
-      rl_save_prompt ();
-      msg_saved_prompt = 1;
-    }
-  else if (local_prompt != saved_local_prompt)
-    {
-      FREE (local_prompt);
-      FREE (local_prompt_prefix);
-      local_prompt = (char *)NULL;
-    }
-  local_prompt = expand_prompt (msg_buf, 0, &prompt_visible_length,
-                                           &prompt_last_invisible,
-                                           &prompt_invis_chars_first_line,
-                                           &prompt_physical_chars);
-  local_prompt_prefix = (char *)NULL;
-  local_prompt_len = local_prompt ? strlen (local_prompt) : 0;
-  (*rl_redisplay_function) ();
-      
-  return 0;
-}
-#endif /* !USE_VARARGS */
 
 /* How to clear things from the "echo-area". */
 int
diff --git a/lib/readline/examples/rl.c b/lib/readline/examples/rl.c
index 726ca951..7cda32c0 100644
--- a/lib/readline/examples/rl.c
+++ b/lib/readline/examples/rl.c
@@ -54,11 +54,6 @@ extern void exit();
 
 extern int optind;
 extern char *optarg;
-
-#if !defined (strchr) && !defined (__STDC__)
-extern char *strrchr();
-#endif
-
 static char *progname;
 static char *deftext;
 
diff --git a/lib/readline/funmap.c b/lib/readline/funmap.c
index 0095c6bf..affa0fdc 100644
--- a/lib/readline/funmap.c
+++ b/lib/readline/funmap.c
@@ -40,11 +40,7 @@
 
 #include "xmalloc.h"
 
-#ifdef __STDC__
 typedef int QSFUNC (const void *, const void *);
-#else
-typedef int QSFUNC ();
-#endif
 
 extern int _rl_qsort_string_compare (char **, char **);
 
diff --git a/lib/readline/histlib.h b/lib/readline/histlib.h
index 7189a07c..da8e6533 100644
--- a/lib/readline/histlib.h
+++ b/lib/readline/histlib.h
@@ -56,9 +56,6 @@
 #endif
 
 #ifndef member
-#  if !defined (strchr) && !defined (__STDC__)
-extern char *strchr ();
-#  endif /* !strchr && !__STDC__ */
 #define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
 #endif
 
diff --git a/lib/readline/parens.c b/lib/readline/parens.c
index 38b5e703..7f1e93f4 100644
--- a/lib/readline/parens.c
+++ b/lib/readline/parens.c
@@ -47,10 +47,6 @@
 #  include <strings.h>
 #endif /* !HAVE_STRING_H */
 
-#if !defined (strchr) && !defined (__STDC__)
-extern char *strchr (), *strrchr ();
-#endif /* !strchr && !__STDC__ */
-
 #include "readline.h"
 #include "rlprivate.h"
 
diff --git a/lib/readline/readline.h b/lib/readline/readline.h
index 259e6b4b..c75ebc3c 100644
--- a/lib/readline/readline.h
+++ b/lib/readline/readline.h
@@ -404,11 +404,7 @@ extern void rl_activate_mark (void);
 extern void rl_deactivate_mark (void);
 extern int rl_mark_active_p (void);
 
-#if defined (USE_VARARGS) && defined (PREFER_STDARG)
 extern int rl_message (const char *, ...)  __attribute__((__format__ (printf, 
1, 2)));
-#else
-extern int rl_message ();
-#endif
 
 extern int rl_show_char (int);
 
diff --git a/lib/readline/rldefs.h b/lib/readline/rldefs.h
index c67b3857..1ef0fbf7 100644
--- a/lib/readline/rldefs.h
+++ b/lib/readline/rldefs.h
@@ -63,17 +63,7 @@
 #  include <strings.h>
 #endif /* !HAVE_STRING_H */
 
-#if !defined (strchr) && !defined (__STDC__)
-extern char *strchr (), *strrchr ();
-#endif /* !strchr && !__STDC__ */
-
-#if defined (PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  if defined (PREFER_VARARGS)
-#    include <varargs.h>
-#  endif
-#endif
+#include <stdarg.h>
 
 #if defined (HAVE_STRCASECMP)
 #define _rl_stricmp strcasecmp
diff --git a/lib/readline/rlprivate.h b/lib/readline/rlprivate.h
index e97ea90e..bd617781 100644
--- a/lib/readline/rlprivate.h
+++ b/lib/readline/rlprivate.h
@@ -459,15 +459,9 @@ extern UNDO_LIST *_rl_copy_undo_list (UNDO_LIST *);
 extern void _rl_free_undo_list (UNDO_LIST *);
 
 /* util.c */
-#if defined (USE_VARARGS) && defined (PREFER_STDARG)
 extern void _rl_ttymsg (const char *, ...)  __attribute__((__format__ (printf, 
1, 2)));
 extern void _rl_errmsg (const char *, ...)  __attribute__((__format__ (printf, 
1, 2)));
 extern void _rl_trace (const char *, ...)  __attribute__((__format__ (printf, 
1, 2)));
-#else
-extern void _rl_ttymsg ();
-extern void _rl_errmsg ();
-extern void _rl_trace ();
-#endif
 extern void _rl_audit_tty (char *);
 
 extern int _rl_tropen (void);
diff --git a/lib/readline/rlstdc.h b/lib/readline/rlstdc.h
index 2aaa30ba..dd559cbc 100644
--- a/lib/readline/rlstdc.h
+++ b/lib/readline/rlstdc.h
@@ -28,30 +28,10 @@
    and traditional C compilers with something like this:
        extern char *func PARAMS((char *, char *, int)); */
 
-#if !defined (PARAMS)
-#  if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus)
-#    define PARAMS(protos) protos
-#  else
-#    define PARAMS(protos) ()
-#  endif
-#endif
-
 #ifndef __attribute__
 #  if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8)
 #    define __attribute__(x)
 #  endif
 #endif
 
-/* Moved from config.h.in because readline.h:rl_message depends on these
-   defines. */
-#if defined (__STDC__) && defined (HAVE_STDARG_H)
-#  define PREFER_STDARG
-#  define USE_VARARGS
-#else
-#  if defined (HAVE_VARARGS_H)
-#    define PREFER_VARARGS
-#    define USE_VARARGS
-#  endif
-#endif
-
 #endif /* !_RL_STDC_H_ */
diff --git a/lib/readline/util.c b/lib/readline/util.c
index b68abdc6..8d45fd0e 100644
--- a/lib/readline/util.c
+++ b/lib/readline/util.c
@@ -229,26 +229,12 @@ rl_tilde_expand (int ignore, int key)
   return (0);
 }
 
-#if defined (USE_VARARGS)
 void
-#if defined (PREFER_STDARG)
 _rl_ttymsg (const char *format, ...)
-#else
-_rl_ttymsg (va_alist)
-     va_dcl
-#endif
 {
   va_list args;
-#if defined (PREFER_VARARGS)
-  char *format;
-#endif
 
-#if defined (PREFER_STDARG)
   va_start (args, format);
-#else
-  va_start (args);
-  format = va_arg (args, char *);
-#endif
 
   fprintf (stderr, "readline: ");
   vfprintf (stderr, format, args);
@@ -261,24 +247,11 @@ _rl_ttymsg (va_alist)
 }
 
 void
-#if defined (PREFER_STDARG)
 _rl_errmsg (const char *format, ...)
-#else
-_rl_errmsg (va_alist)
-     va_dcl
-#endif
 {
   va_list args;
-#if defined (PREFER_VARARGS)
-  char *format;
-#endif
 
-#if defined (PREFER_STDARG)
   va_start (args, format);
-#else
-  va_start (args);
-  format = va_arg (args, char *);
-#endif
 
   fprintf (stderr, "readline: ");
   vfprintf (stderr, format, args);
@@ -288,27 +261,6 @@ _rl_errmsg (va_alist)
   va_end (args);
 }
 
-#else /* !USE_VARARGS */
-void
-_rl_ttymsg (format, arg1, arg2)
-     char *format;
-{
-  fprintf (stderr, "readline: ");
-  fprintf (stderr, format, arg1, arg2);
-  fprintf (stderr, "\n");
-
-  rl_forced_update_display ();
-}
-
-void
-_rl_errmsg (format, arg1, arg2)
-     char *format;
-{
-  fprintf (stderr, "readline: ");
-  fprintf (stderr, format, arg1, arg2);
-  fprintf (stderr, "\n");
-}
-#endif /* !USE_VARARGS */
 
 /* **************************************************************** */
 /*                                                                 */
@@ -507,28 +459,14 @@ _rl_savestring (const char *s)
 }
 
 #if defined (DEBUG)
-#if defined (USE_VARARGS)
 static FILE *_rl_tracefp;
 
 void
-#if defined (PREFER_STDARG)
 _rl_trace (const char *format, ...)
-#else
-_rl_trace (va_alist)
-     va_dcl
-#endif
 {
   va_list args;
-#if defined (PREFER_VARARGS)
-  char *format;
-#endif
 
-#if defined (PREFER_STDARG)
   va_start (args, format);
-#else
-  va_start (args);
-  format = va_arg (args, char *);
-#endif
 
   if (_rl_tracefp == 0)
     _rl_tropen ();
@@ -574,7 +512,6 @@ _rl_settracefp (FILE *fp)
 {
   _rl_tracefp = fp;
 }
-#endif
 #endif /* DEBUG */
 
 
diff --git a/lib/sh/dprintf.c b/lib/sh/dprintf.c
index 9d95834c..377ce19b 100644
--- a/lib/sh/dprintf.c
+++ b/lib/sh/dprintf.c
@@ -28,12 +28,7 @@
 #  include <unistd.h>
 #endif
 
-#if defined (PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  include <varargs.h>
-#endif
-
+#include <stdarg.h>
 #include <stdio.h>
 
 int
@@ -52,7 +47,7 @@ dprintf(int fd, const char *format, ...)
       return -1;
     }
 
-  SH_VA_START (args, format);
+  va_start (args, format);
   rc = vfprintf (fp, format, args);
   fflush (fp);
   va_end (args);
diff --git a/lib/sh/fdprintf.c b/lib/sh/fdprintf.c
index 27d3a4b0..64e3b29b 100644
--- a/lib/sh/fdprintf.c
+++ b/lib/sh/fdprintf.c
@@ -28,23 +28,11 @@
 #  include <unistd.h>
 #endif
 
-#if defined (PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  include <varargs.h>
-#endif
-
+#include <stdarg.h>
 #include <stdio.h>
 
 int
-#if defined (PREFER_STDARG)
 fdprintf(int fd, const char *format, ...)
-#else
-fdprintf(fd, format, va_alist)
-     int fd;
-     const char *format;
-     va_dcl
-#endif
 {
   FILE *fp;
   int fd2, rc, r2;
@@ -59,7 +47,7 @@ fdprintf(fd, format, va_alist)
       return -1;
     }
 
-  SH_VA_START (args, format);
+  va_start (args, format);
   rc = vfprintf (fp, format, args);
   fflush (fp);
   va_end (args);
diff --git a/lib/sh/snprintf.c b/lib/sh/snprintf.c
index 891ba91b..6d0db2e6 100644
--- a/lib/sh/snprintf.c
+++ b/lib/sh/snprintf.c
@@ -77,7 +77,6 @@
 #endif
 #define HAVE_ISINF_IN_LIBC
 #define HAVE_ISNAN_IN_LIBC
-#define PREFER_STDARG
 #define HAVE_STRINGIZE
 #define HAVE_LIMITS_H
 #define HAVE_STDDEF_H
@@ -89,11 +88,7 @@
 
 #include <bashtypes.h>
 
-#if defined(PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  include <varargs.h>
-#endif
+#include <stdarg.h>
 
 #ifdef HAVE_LIMITS_H
 #  include <limits.h>
@@ -1669,7 +1664,7 @@ snprintf(char *string, size_t length, const char * 
format, ...)
   int rval;
   va_list args;
 
-  SH_VA_START(args, format);
+  va_start (args, format);
 
   if (string == 0 && length != 0)
     return 0;
@@ -1705,7 +1700,7 @@ asprintf(char **stringp, const char * format, ...)
   int rval;
   va_list args;
 
-  SH_VA_START(args, format);
+  va_start (args, format);
 
   rval = vasprintf (stringp, format, args);
 
diff --git a/lib/sh/strindex.c b/lib/sh/strindex.c
index 5cb80ad3..bed8fa7a 100644
--- a/lib/sh/strindex.c
+++ b/lib/sh/strindex.c
@@ -30,9 +30,7 @@
    match in s1.  The compare is case insensitive.  This is a
    case-insensitive strstr(3). */
 char *
-strindex (s1, s2)
-     const char *s1;
-     const char *s2;
+strindex (const char *s1, const char *s2)
 {
   register int i, l, len, c;
 
diff --git a/lib/sh/xstrchr.c b/lib/sh/xstrchr.c
index 6dd4d8ed..9ae9cf96 100644
--- a/lib/sh/xstrchr.c
+++ b/lib/sh/xstrchr.c
@@ -34,13 +34,7 @@
    legacy strchr() might return the wrong value. */
 
 char *
-#if defined (PROTOTYPES)
 xstrchr (const char *s, int c)
-#else
-xstrchr (s, c)
-     const char *s;
-     int c;
-#endif
 {
 #if HANDLE_MULTIBYTE
   char *pos;
diff --git a/lib/termcap/termcap.h b/lib/termcap/termcap.h
index b0e3061f..dd39f813 100644
--- a/lib/termcap/termcap.h
+++ b/lib/termcap/termcap.h
@@ -19,8 +19,6 @@
 #ifndef _TERMCAP_H
 #define _TERMCAP_H 1
 
-#if __STDC__
-
 extern int tgetent (char *buffer, const char *termtype);
 
 extern int tgetnum (const char *name);
@@ -38,26 +36,4 @@ extern char *BC;
 
 extern char *tgoto (const char *cstring, int hpos, int vpos);
 
-#else /* not __STDC__ */
-
-extern int tgetent ();
-
-extern int tgetnum ();
-extern int tgetflag ();
-extern char *tgetstr ();
-
-extern char PC;
-extern short ospeed;
-
-extern void tputs ();
-
-extern char *tparam ();
-
-extern char *UP;
-extern char *BC;
-
-extern char *tgoto ();
-
-#endif /* not __STDC__ */
-
 #endif /* not _TERMCAP_H */
diff --git a/m4/iconv.m4 b/m4/iconv.m4
index a285e9da..2485b6bb 100644
--- a/m4/iconv.m4
+++ b/m4/iconv.m4
@@ -258,11 +258,7 @@ extern
 #ifdef __cplusplus
 "C"
 #endif
-#if defined(__STDC__) || defined(_MSC_VER) || defined(__cplusplus)
 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, 
size_t *outbytesleft);
-#else
-size_t iconv();
-#endif
            ]],
            [[]])],
         [am_cv_proto_iconv_arg1=""],
diff --git a/pcomplete.c b/pcomplete.c
index 3d54d296..e79b8a71 100644
--- a/pcomplete.c
+++ b/pcomplete.c
@@ -30,12 +30,7 @@
 #endif
 
 #include <signal.h>
-
-#if defined (PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  include <varargs.h>
-#endif
+#include <stdarg.h>
 
 #include "posixtime.h"
 
@@ -198,7 +193,7 @@ debug_printf (const char *format, ...)
   if (progcomp_debug == 0)
     return;
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   fprintf (stdout, "DEBUG: ");
   vfprintf (stdout, format, args);
diff --git a/print_cmd.c b/print_cmd.c
index 1aefead4..2410b8a2 100644
--- a/print_cmd.c
+++ b/print_cmd.c
@@ -29,11 +29,7 @@
 #  include <unistd.h>
 #endif
 
-#if defined (PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  include <varargs.h>
-#endif
+#include <stdarg.h>
 
 #include "bashansi.h"
 #include "bashintl.h"
@@ -1446,7 +1442,7 @@ cprintf (const char *control, ...)
   size_t arg_len;
   va_list args;
 
-  SH_VA_START (args, control);
+  va_start (args, control);
 
   arg_len = strlen (control);
   the_printed_command_resize (arg_len + 1);
@@ -1544,28 +1540,13 @@ the_printed_command_resize (size_t length)
     }
 }
 
-#if defined (HAVE_VPRINTF)
-/* ``If vprintf is available, you may assume that vfprintf and vsprintf are
-     also available.'' */
-
 static void
 xprintf (const char *format, ...)
 {
   va_list args;
 
-  SH_VA_START (args, format);
+  va_start (args, format);
 
   vfprintf (stdout, format, args);
   va_end (args);
 }
-
-#else
-
-static void
-xprintf (format, arg1, arg2, arg3, arg4, arg5)
-     const char *format;
-{
-  printf (format, arg1, arg2, arg3, arg4, arg5);
-}
-
-#endif /* !HAVE_VPRINTF */
-- 
2.39.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]