]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
more ANSI/ISO C changes; start on converting the unwind-protect framework to ANSI C
authorChet Ramey <chet.ramey@case.edu>
Wed, 29 Mar 2023 19:43:46 +0000 (15:43 -0400)
committerChet Ramey <chet.ramey@case.edu>
Wed, 29 Mar 2023 19:43:46 +0000 (15:43 -0400)
41 files changed:
CWRU/CWRU.chlog
aclocal.m4
builtins/common.c
builtins/mkbuiltins.c
builtins/printf.def
config-bot.h
configure
configure.ac
error.c
execute_cmd.c
general.h
include/memalloc.h
include/stdc.h
jobs.h
lib/malloc/alloca.c
lib/malloc/imalloc.h
lib/malloc/malloc.c
lib/malloc/shmalloc.h
lib/malloc/xmalloc.c
lib/readline/bind.c
lib/readline/complete.c
lib/readline/display.c
lib/readline/examples/rl.c
lib/readline/funmap.c
lib/readline/histlib.h
lib/readline/parens.c
lib/readline/readline.h
lib/readline/rldefs.h
lib/readline/rlprivate.h
lib/readline/rlstdc.h
lib/readline/util.c
lib/sh/dprintf.c
lib/sh/fdprintf.c [deleted file]
lib/sh/snprintf.c
lib/sh/vprint.c
lib/termcap/termcap.h
m4/iconv.m4
pcomplete.c
print_cmd.c
unwind_prot.c
unwind_prot.h

index 44d61616de33f0d357321e92483372b3a34dd4ba..403f645f5f3783010b40e9a4d6d79a89e275bad4 100644 (file)
@@ -5884,4 +5884,36 @@ builtins/common.c,examples/loadables/getconf.c
 execute_cmd.c,pcomplete.c,subst.c
 lib/sh/stringlist.c,lib/sh/stringvec.c
        - changes and casts now that the generic list functions are prototyped
+         From Paul Eggert <eggert@cs.ucla.edu>
+
+                                  3/29
+                                  ----
+aclocal.m4,configure.ac
+builtins/common.c,builtins/mkbuiltins.c,builtins/printf.def
+include/memalloc.h,include/stdc.h
+general.h,jobs.h
+pcomplete.c,print_cmd.c
+m4/iconv.m4
+lib/readline/bind.c,lib/readline/complete.c,lib/readline/display.c
+lib/readline/funmap.c,lib/readline/util.c,lib/readline/parens.c
+lib/readline/histlib.h
+lib/readline/readline.h,lib/readline/rldefs.h,lib/readline/rlstdc.h,lib/readline/rlprivate.h
+lib/sh/dprintf.c,lib/sh/snprintf.c,lib/sh/vprintf.c
+lib/malloc/shmalloc.h,lib/malloc/imalloc.h,lib/malloc/xmalloc.c
+lib/termcap/termcap.h
+       - stdarg: since we now assume C89 for prototypes at least, always
+         prefer stdarg to old-style varargs
+       - SH_VA_START: now use plain old va_start
+       - don't bother with extern declarations for standard C89 functions
+         From Paul Eggert <eggert@cs.ucla.edu>
+
+config-bot.h
+       - PREFER_STDARG: remove
+
+builtins/mkbuiltins.c
+execute_cmd.c,unwind_prot.c
+unwind_prot.h
+       - start on ANSI/ISO C changes for the unwind-protect framework
+       - introduce new unwind-protect function pointer type to replace
+         Function
          From Paul Eggert <eggert@cs.ucla.edu>
index 9387a1172b421fdf115b7e8263de38ac87244813..2a86c70c6922068e8f083ff1c89c089bcd16f4fb 100644 (file)
@@ -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()
@@ -594,7 +590,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,7 +610,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
@@ -2065,31 +2059,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;
index 52a1f68a156cd9979aca14405029db024130c5bf..e540296150bfdefe91837c8fc80f7423d232537a 100644 (file)
 #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);
index 7b7f68cebcc90e5fe08478895bb27033099ce7d5..d0d5559ff917fcf9fa8f783c707e9f3919d19014 100644 (file)
@@ -1,7 +1,7 @@
 /* mkbuiltins.c - Create builtins.c, builtext.h, and builtdoc.c from
    a single source file called builtins.def. */
 
-/* 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.
 
 extern int errno;
 #endif
 
-static char *xmalloc (size_t), *xrealloc (void *, size_t);
-
-#if !defined (__STDC__) && !defined (strcpy)
-extern char *strcpy ();
-#endif /* !__STDC__ && !strcpy */
+static void *xmalloc (size_t);
+static void *xrealloc (void *, size_t);
 
 #define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
@@ -456,7 +453,6 @@ array_free (ARRAY *array)
 /* **************************************************************** */
 
 /* The definition of a function. */
-typedef int Function ();
 typedef int mk_handler_func_t (char *, DEF_FILE *, char *);
 
 /* Structure handles processor directives. */
@@ -995,25 +991,25 @@ file_error (char *filename)
 
 static void memory_error_and_abort (void);
 
-static char *
+static void *
 xmalloc (size_t bytes)
 {
-  char *temp = (char *)malloc (bytes);
+  void *temp = malloc (bytes);
 
   if (!temp)
     memory_error_and_abort ();
   return (temp);
 }
 
-static char *
+static void *
 xrealloc (void *pointer, size_t bytes)
 {
-  char *temp;
+  void *temp;
 
   if (!pointer)
-    temp = (char *)malloc (bytes);
+    temp = malloc (bytes);
   else
-    temp = (char *)realloc (pointer, bytes);
+    temp = realloc (pointer, bytes);
 
   if (!temp)
     memory_error_and_abort ();
index 4f8cb3b5aba7a83944bccb98571640afd851dd4b..c0610a34819608f40418cb1459850f07a8134cf6 100644 (file)
@@ -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>
@@ -1229,7 +1225,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);
 
@@ -1238,7 +1234,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);
     }
index a687e402940dfb3ce64c2afa6ea18c4c2998f09e..07e910f1ecd00daa3c1631e36ac92e83649bcee6 100644 (file)
 #  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
index 6193d3044840773d36ee3078185ed63f1e325ef8..74dc82e8077cfd8a998c88bf2b9377d523795e18 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac for Bash 5.2, version 5.048.
+# From configure.ac for Bash 5.2, version 5.049.
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.71 for bash 5.2-maint.
 #
@@ -7402,15 +7402,6 @@ printf "%s\n" "#define HAVE_LONG_DOUBLE 1" >>confdefs.h
 
   fi
 
-if test "$ac_prog_cc_stdc" != no; then
-
-printf "%s\n" "#define PROTOTYPES 1" >>confdefs.h
-
-
-printf "%s\n" "#define __PROTOTYPES 1" >>confdefs.h
-
-fi
-
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether char is unsigned" >&5
 printf %s "checking whether char is unsigned... " >&6; }
 if test ${ac_cv_c_char_unsigned+y}
@@ -11324,11 +11315,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
 
 int
 main (void)
@@ -14228,12 +14215,6 @@ if test "x$ac_cv_header_stdlib_h" = xyes
 then :
   printf "%s\n" "#define HAVE_STDLIB_H 1" >>confdefs.h
 
-fi
-ac_fn_c_check_header_compile "$LINENO" "stdarg.h" "ac_cv_header_stdarg_h" "$ac_includes_default"
-if test "x$ac_cv_header_stdarg_h" = xyes
-then :
-  printf "%s\n" "#define HAVE_STDARG_H 1" >>confdefs.h
-
 fi
 ac_fn_c_check_header_compile "$LINENO" "varargs.h" "ac_cv_header_varargs_h" "$ac_includes_default"
 if test "x$ac_cv_header_varargs_h" = xyes
@@ -20375,31 +20356,17 @@ else $as_nop
   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
-#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;
@@ -20498,7 +20465,6 @@ fi
 
 if test "$ac_cv_func_putenv" = "yes"; then
 
-
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for standard-conformant putenv declaration" >&5
 printf %s "checking for standard-conformant putenv declaration... " >&6; }
 if test ${bash_cv_std_putenv+y}
@@ -20547,7 +20513,6 @@ printf "%s\n" "#define HAVE_STD_PUTENV 1" >>confdefs.h
 fi
 if test "$ac_cv_func_unsetenv" = "yes"; then
 
-
 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for standard-conformant unsetenv declaration" >&5
 printf %s "checking for standard-conformant unsetenv declaration... " >&6; }
 if test ${bash_cv_std_unsetenv+y}
index a933af901ddb8e06a4460509819ced71d935e3d5..68c38c09da0656f31cdc0f2e5e95d1e32689cb0e 100644 (file)
@@ -21,7 +21,7 @@ dnl Process this file with autoconf to produce a configure script.
 #   You should have received a copy of the GNU General Public License
 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-AC_REVISION([for Bash 5.2, version 5.048])dnl
+AC_REVISION([for Bash 5.2, version 5.049])dnl
 
 define(bashvers, 5.2)
 define(relstatus, maint)
@@ -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 varargs.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 76d20529f3456580e7beba57b5e6a66bc0940776..366d012f52f95aa5e75abc89c9ef27cdfa518276 100644 (file)
--- a/error.c
+++ b/error.c
 #  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");
index e135d3602b0353076034ccc2270ffa7b6abd65ce..88f195a5b05cdc0bf80b5f6ad6a97504146c9204 100644 (file)
@@ -123,7 +123,7 @@ static int shell_control_structure (enum command_type);
 static void cleanup_redirects (REDIRECT *);
 
 #if defined (JOB_CONTROL)
-static int restore_signal_mask (sigset_t *);
+static void restore_signal_mask (void *);
 #endif
 
 static int builtin_status (int);
@@ -505,10 +505,10 @@ dispose_partial_redirects (void)
 #if defined (JOB_CONTROL)
 /* A function to restore the signal mask to its proper value when the shell
    is interrupted or errors occur while creating a pipeline. */
-static int
-restore_signal_mask (sigset_t *set)
+static void
+restore_signal_mask (void *set)
 {
-  return (sigprocmask (SIG_SETMASK, set, (sigset_t *)NULL));
+  sigprocmask (SIG_SETMASK, set, NULL);
 }
 #endif /* JOB_CONTROL */
 
@@ -1103,7 +1103,7 @@ execute_command_internal (COMMAND *command, int asynchronous, int pipe_in, int p
     {
       nfifo = num_fifos ();
       if (nfifo > ofifo)
-       close_new_fifos ((void *)ofifo_list, osize);
+       close_new_fifos (ofifo_list, osize);
       free (ofifo_list);
       discard_unwind_frame ("internal_fifos");
     }
@@ -4908,8 +4908,11 @@ execute_builtin (sh_builtin_func_t *builtin, WORD_LIST *words, int flags, int su
 }
 
 static void
-maybe_restore_getopt_state (sh_getopt_state_t *gs)
+maybe_restore_getopt_state (void *arg)
 {
+  sh_getopt_state_t *gs;
+
+  gs = arg;
   /* If we have a local copy of OPTIND and it's at the right (current)
      context, then we restore getopt's internal state.  If not, we just
      let it go.  We know there is a local OPTIND if gs->gs_flags & 1.
index b92c3e234a977a4a3ffadf4af48a68a33d24f223..16d7c09385229d27d02812e576acb08854d14388 100644 (file)
--- a/general.h
+++ b/general.h
@@ -249,11 +249,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 */
index 6a08ac9a79a64875a36c17050045f1ba3d962d02..e850e8a114d509f6ba79985b91ffd0165bb28aac 100644 (file)
 #    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 */
index d9bcc6e01abc4d7e9cd29157afe48f58a8620e90..7948b4f8b6607df633b670df3d54e6ab04aa6a67 100644 (file)
@@ -1,7 +1,7 @@
 /* stdc.h -- macros to make source compile on both ANSI C and K&R C
    compilers. */
 
-/* Copyright (C) 1993-2021 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2021,2023 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
 #  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 de5a9ecf0015a8ba30c8798aaa34d5ee93ba6370..2beee642043755f6932a7e781b35abe262312e2c 100644 (file)
--- a/jobs.h
+++ b/jobs.h
@@ -1,6 +1,6 @@
 /* jobs.h -- structures and definitions used by the jobs.c file. */
 
-/* Copyright (C) 1993-202 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
@@ -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
index 7627e1649a26211df6634a7795028513a55cb36e..0a12b0630b1c32619efb8d01a89a545b3136da77 100644 (file)
@@ -57,11 +57,7 @@ long i00afunc ();
 #define ADDRESS_FUNCTION(arg) &(arg)
 #endif /* CRAY && CRAY_STACKSEG_END */
 
-#if __STDC__
 typedef void *pointer;
-#else
-typedef char *pointer;
-#endif
 
 #define        NULL    0
 
index 16c0c67177dea088615e60f80c93070dabcf3f3a..00f23a32d7f94a7d17091a9049adfcb3031e3fb0 100644 (file)
 
 /* Generic pointer type. */
 #ifndef PTR_T
-#  if defined (__STDC__)
-#    define PTR_T void *
-#  else
-#    define PTR_T char *
-#  endif
+#  define PTR_T void *
 #endif
 
 #if !defined (NULL)
 #  endif /* HAVE_BCOPY */
 #endif /* !__GNUC__ */
 
-#if !defined (PARAMS)
-#  if defined (__STDC__) || defined (__GNUC__) || defined (__cplusplus) || defined (PROTOTYPES)
-#    define PARAMS(protos) protos
-#  else 
-#    define PARAMS(protos) ()
-#  endif
-#endif
-
 /* Use Duff's device for good zeroing/copying performance.  DO NOT call the
    Duff's device macros with NBYTES == 0. */
 
index 180c3dc4b164e4f5a0f4c59167c20a56ecd8210b..f57e3aeafd519de28229d9a4bbead346f86d6a84 100644 (file)
@@ -387,7 +387,7 @@ xbotch (PTR_T mem, int e, const char *s, const char *file, int line)
    assumed to not be busy; the caller (morecore()) checks for this. 
    BUSY[NU] must be set to 1. */
 static void
-bcoalesce (register int nu)
+bcoalesce (int nu)
 {
   register union mhead *mp, *mp1, *mp2;
   register int nbuck;
@@ -455,7 +455,7 @@ bcoalesce (register int nu)
    is assumed to be empty.  Must be called with signals blocked (e.g.,
    by morecore()).  BUSY[NU] must be set to 1. */
 static void
-bsplit (register int nu)
+bsplit (int nu)
 {
   register union mhead *mp;
   int nbuck, nblks, split_max;
@@ -616,7 +616,7 @@ morecore (int nu)
   sigset_t set, oset;
   int blocked_sigs;
 
-  /* Block all signals in case we are executed from a signal handler. */
+  /* Block signals in case we are executed from a signal handler. */
   blocked_sigs = 0;
 #ifdef SHELL
 #  if defined (SIGCHLD)
index 1213169d1af660348b804295cfed23b7ddcc154d..5ea2c56e6cf8bdbc3c024c1ddfee44e484998e37 100644 (file)
 
 /* Generic pointer type. */
 #ifndef PTR_T
-
-#if defined (__STDC__)
 #  define PTR_T void *
-#else
-#  define PTR_T char *
-#endif
-
 #endif /* PTR_T */
 
-
 extern PTR_T sh_malloc (size_t, const char *, int);
 extern PTR_T sh_realloc (PTR_T, size_t, const char *, int);
 extern void sh_free (PTR_T, const char *, int);
index de8f38345d4f292f78f4aed86924a96489ecbfca..59759834f628b3845e387e8900a91cb5319631ee 100644 (file)
 
 /* Generic pointer type. */
 #ifndef PTR_T
-
-#if defined (__STDC__)
 #  define PTR_T void *
-#else
-#  define PTR_T char *
-#endif
-
 #endif /* PTR_T */
 
 /* **************************************************************** */
index 524ef34a4979a9d668fcb921e836563acb5335a7..ee6d6e1746eb8497108b82d95aff6f040c642206 100644 (file)
@@ -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,25 +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)
     fprintf (stderr, "%s: line %d: ", current_readline_init_file,
index ce9b8cd0093d2bdf81f1ee97a6aafd99a0798e9f..bf7cc85673bae4a7bd31802caa08ccd7587311b4 100644 (file)
@@ -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
index ce9dacd830d03b92a7b8de7259f753808e737d81..fb10c60a3fe872faa54a503721ab0653ddac83ae 100644 (file)
@@ -1,6 +1,6 @@
 /* display.c -- readline redisplay facility. */
 
-/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library    
    for reading lines of text with interactive input and history editing.
 #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
index 39e5b8ebb5d1be6b748a9d8bab3d3feb190e0784..e04bbd6a58ad21385d87f7f0078642a709644d11 100644 (file)
@@ -5,7 +5,7 @@
  * usage: rl [-p prompt] [-u unit] [-d default] [-n nchars]
  */
 
-/* Copyright (C) 1987-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library for
    reading lines of text with interactive input and history editing.
@@ -55,10 +55,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;
 
index 0095c6bfafb7905bd6b285f77939ca4e75e48fc3..affa0fdcf1a74d32fb68671afa8ef8b7e63c66bb 100644 (file)
 
 #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 **);
 
index 7189a07c1239865dfd42e179eb0e3137ca4de06d..da8e6533dd5fd78ff013d746b2d659b8289d0252 100644 (file)
@@ -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
 
index 38b5e703775ef92d091f848fd21af2e921c5b935..7f1e93f4fc4ac1ca65c9da0a45539f9ef8a4e933 100644 (file)
 #  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"
 
index 259e6b4b29b78cdf8e0632f9f51c6333bf730e56..48f1210a2233c63e8b323db84ed44d80fcd658b2 100644 (file)
@@ -1,6 +1,6 @@
 /* Readline.h -- the names of functions callable from within readline. */
 
-/* Copyright (C) 1987-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1987-2023 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.      
@@ -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);
 
index c67b3857ed564fcb4707ce0337e9273e0ee94abe..1ef0fbf7555bdec726cf4b3b2167c5840dbaa0e0 100644 (file)
 #  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
index e97ea90e8ded739085994dfa24b451c0f9024053..5c0592b9cb07865eac0b33d62d8485d7e458d904 100644 (file)
@@ -1,7 +1,7 @@
 /* rlprivate.h -- functions and variables global to the readline library,
                  but not intended for use by applications. */
 
-/* Copyright (C) 1999-2022 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2023 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.
@@ -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);
index 2aaa30babfbdd7e86eed5062b7324e819d5f68e8..0e5c4f47f8ee0bb2146046ed3d8fd4321032cd8b 100644 (file)
@@ -1,6 +1,6 @@
 /* stdc.h -- macros to make source compile on both ANSI C and K&R C compilers. */
 
-/* Copyright (C) 1993-2009 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2009,2023 Free Software Foundation, Inc.
 
    This file is part of the GNU Readline Library (Readline), a library
    for reading lines of text with interactive input and history editing.      
 #  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_ */
index b68abdc6844a68a30ccb56700dae33ea29a856f0..61c40be5068489c607847d31f908fe75f9ebfa0c 100644 (file)
@@ -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,28 +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 */
-
 /* **************************************************************** */
 /*                                                                 */
 /*                     String Utility Functions                    */
@@ -507,28 +458,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 +511,6 @@ _rl_settracefp (FILE *fp)
 {
   _rl_tracefp = fp;
 }
-#endif
 #endif /* DEBUG */
 
 
index 9d95834c17e7de0d1a80fb4fbddd8432e8e37f39..1e345a9ff0ff3e38409f28eec9807f1a1da6227c 100644 (file)
@@ -1,6 +1,6 @@
 /* dprintf -- printf to a file descriptor */
 
-/* Copyright (C) 2008-2010,2022 Free Software Foundation, Inc.
+/* Copyright (C) 2008-2010,2022,2023 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
 #  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
deleted file mode 100644 (file)
index 27d3a4b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-/* fdprintf -- printf to a file descriptor */
-
-/* Copyright (C) 2008,2009 Free Software Foundation, Inc.
-
-   This file is part of GNU Bash, the Bourne Again SHell.
-
-   Bash is free software: you can redistribute it and/or modify
-   it under the terms of the GNU General Public License as published by
-   the Free Software Foundation, either version 3 of the License, or
-   (at your option) any later version.
-
-   Bash is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-   GNU General Public License for more details.
-
-   You should have received a copy of the GNU General Public License
-   along with Bash.  If not, see <http://www.gnu.org/licenses/>.
-*/
-                                 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
-#include <stdc.h>
-
-#if defined (HAVE_UNISTD_H)
-#  include <unistd.h>
-#endif
-
-#if defined (PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  include <varargs.h>
-#endif
-
-#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;
-  va_list args;
-
-  if ((fd2 = dup(fd)) < 0)
-    return -1;
-  fp = fdopen (fd2, "w");
-  if (fp == 0)
-    {
-      close (fd2);
-      return -1;
-    }
-
-  SH_VA_START (args, format);
-  rc = vfprintf (fp, format, args);
-  fflush (fp);
-  va_end (args);
-
-  r2 = fclose (fp);    /* check here */
-
-  return rc;
-}           
index 68258e460a208effc8a5dfc1aa2d0a104c299980..a356cb70e6c0ed449fb2764c955c6d5a2e5cabcc 100644 (file)
@@ -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
 
 #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);
 
index b4c09e89d7068e973566f709acd7cce92436e285..1d60e4f2aa611998b1b2f600e52f23b1543a5582 100644 (file)
 #include <stdio.h>
 
 #if !defined (NULL)
-#  if defined (__STDC__)
-#    define NULL ((void *)0)
-#  else
-#    define NULL 0x0
-#  endif /* __STDC__ */
+#  define NULL 0
 #endif /* !NULL */
 
 /*
index b0e3061fe58ce4520c97637fc8f78a8342e498af..a12a5c70731b769ca5455ace59ed4f9f4edf67f0 100644 (file)
@@ -1,6 +1,6 @@
 /* termcap.h - public declarations for termcap library. */
 
-/* Copyright (C) 1991, 1992, 1995, 2001, 2005, 2006, 2008,2009 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2009,2023 Free Software Foundation, Inc.
 
    Bash is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -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 */
index a285e9daa5ea78453c0db5bb1640f7d59b7aa000..2485b6bb8043ea6698da0461dc0f2657c88f6d2d 100644 (file)
@@ -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=""],
index ecdf4475efd9d30b12cf2c10a2333690c38d2801..b9ca25b17efc78f42add52976d456b36374fd83e 100644 (file)
 
 #include <signal.h>
 
-#if defined (PREFER_STDARG)
-#  include <stdarg.h>
-#else
-#  include <varargs.h>
-#endif
+#include <stdarg.h>
 
 #include "posixtime.h"
 
@@ -198,7 +194,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);
index 1aefead40cbce5e29e17ec0c1a6fa964bf496954..2410b8a2a1392b118ace933da3bc812380c884d2 100644 (file)
 #  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 */
index c471b98a0ed943dbc5015052e2a6f4ee041565d7..c0d384fe6c871368cf143c80b7f64dee21430aa3 100644 (file)
@@ -3,7 +3,7 @@
 /* I can't stand it anymore!  Please can't we just write the
    whole Unix system in lisp or something? */
 
-/* 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.
 
@@ -77,13 +77,12 @@ typedef union uwp {
   } sv;
 } UNWIND_ELT;
 
-static void without_interrupts (VFunction *, char *, char *);
-static void unwind_frame_discard_internal (char *, char *);
-static void unwind_frame_run_internal (char *, char *);
+static void unwind_frame_discard_internal (char *);
+static void unwind_frame_run_internal (char *);
 static void add_unwind_protect_internal (Function *, char *);
-static void remove_unwind_protect_internal (char *, char *);
-static void run_unwind_protects_internal (char *, char *);
-static void clear_unwind_protects_internal (char *, char *);
+static void remove_unwind_protect_internal (void);
+static void run_unwind_protects_internal (void);
+static void clear_unwind_protects_internal (int);
 static inline void restore_variable (SAVED_VAR *);
 static void unwind_protect_mem_internal (char *, char *);
 
@@ -108,19 +107,11 @@ uwp_init (void)
   ocache_create (uwcache, UNWIND_ELT, UWCACHESIZE);
 }
 
-/* Run a function without interrupts.  This relies on the fact that the
-   FUNCTION cannot call QUIT (). */
-static void
-without_interrupts (VFunction *function, char *arg1, char *arg2)
-{
-  (*function)(arg1, arg2);
-}
-
 /* Start the beginning of a region. */
 void
 begin_unwind_frame (char *tag)
 {
-  add_unwind_protect ((Function *)NULL, tag);
+  add_unwind_protect (NULL, tag);
 }
 
 /* Discard the unwind protects back to TAG. */
@@ -128,7 +119,7 @@ void
 discard_unwind_frame (char *tag)
 {
   if (unwind_protect_list)
-    without_interrupts (unwind_frame_discard_internal, tag, (char *)NULL);
+    unwind_frame_discard_internal (tag);
 }
 
 /* Run the unwind protects back to TAG. */
@@ -136,14 +127,14 @@ void
 run_unwind_frame (char *tag)
 {
   if (unwind_protect_list)
-    without_interrupts (unwind_frame_run_internal, tag, (char *)NULL);
+    unwind_frame_run_internal (tag);
 }
 
 /* Add the function CLEANUP with ARG to the list of unwindable things. */
 void
 add_unwind_protect (Function *cleanup, char *arg)
 {
-  without_interrupts (add_unwind_protect_internal, (char *)cleanup, arg);
+  add_unwind_protect_internal (cleanup, arg);
 }
 
 /* Remove the top unwind protect from the list. */
@@ -151,8 +142,7 @@ void
 remove_unwind_protect (void)
 {
   if (unwind_protect_list)
-    without_interrupts
-      (remove_unwind_protect_internal, (char *)NULL, (char *)NULL);
+    remove_unwind_protect_internal ();
 }
 
 /* Run the list of cleanup functions in unwind_protect_list. */
@@ -160,22 +150,15 @@ void
 run_unwind_protects (void)
 {
   if (unwind_protect_list)
-    without_interrupts
-      (run_unwind_protects_internal, (char *)NULL, (char *)NULL);
+    run_unwind_protects_internal ();
 }
 
 /* Erase the unwind-protect list.  If flags is 1, free the elements. */
 void
 clear_unwind_protect_list (int flags)
 {
-  char *flag;
-
   if (unwind_protect_list)
-    {
-      flag = flags ? "" : (char *)NULL;
-      without_interrupts
-        (clear_unwind_protects_internal, flag, (char *)NULL);
-    }
+    clear_unwind_protects_internal (flags);
 }
 
 int
@@ -218,7 +201,7 @@ add_unwind_protect_internal (Function *cleanup, char *arg)
 }
 
 static void
-remove_unwind_protect_internal (char *ignore1, char *ignore2)
+remove_unwind_protect_internal (void)
 {
   UNWIND_ELT *elt;
 
@@ -231,24 +214,24 @@ remove_unwind_protect_internal (char *ignore1, char *ignore2)
 }
 
 static void
-run_unwind_protects_internal (char *ignore1, char *ignore2)
+run_unwind_protects_internal (void)
 {
-  unwind_frame_run_internal ((char *) NULL, (char *) NULL);
+  unwind_frame_run_internal (NULL);
 }
 
 static void
-clear_unwind_protects_internal (char *flag, char *ignore)
+clear_unwind_protects_internal (int flag)
 {
   if (flag)
     {
       while (unwind_protect_list)
-       remove_unwind_protect_internal ((char *)NULL, (char *)NULL);
+       remove_unwind_protect_internal ();
     }
   unwind_protect_list = (UNWIND_ELT *)NULL;
 }
 
 static void
-unwind_frame_discard_internal (char *tag, char *ignore)
+unwind_frame_discard_internal (char *tag)
 {
   UNWIND_ELT *elt;
   int found;
@@ -281,7 +264,7 @@ restore_variable (SAVED_VAR *sv)
 }
 
 static void
-unwind_frame_run_internal (char *tag, char *ignore)
+unwind_frame_run_internal (char *tag)
 {
   UNWIND_ELT *elt;
   int found;
@@ -341,7 +324,7 @@ unwind_protect_mem_internal (char *var, char *psize)
 void
 unwind_protect_mem (char *var, int size)
 {
-  without_interrupts (unwind_protect_mem_internal, var, (char *) &size);
+  unwind_protect_mem_internal (var, (char *) &size);
 }
 
 #if defined (DEBUG)
index 7493c22e3516646f394da26118b446343fcfe00c..27fb820611e570d54d74a54e6b677b674ac2f158 100644 (file)
@@ -1,6 +1,6 @@
 /* unwind_prot.h - Macros and functions for hacking unwind protection. */
 
-/* Copyright (C) 1993-2020 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2023 Free Software Foundation, Inc.
 
    This file is part of GNU Bash, the Bourne Again SHell.
 
 #if !defined (_UNWIND_PROT_H)
 #define _UNWIND_PROT_H
 
+/* Generic function type void (*) (void *) for all unwind cleanups. A
+   cleanup function does not return a value and takes a single generic
+   pointer argument. This type works fine for arbitrary pointers; if a
+   cleanup function needs to take an int argument, it's passed through
+   a cast to intptr_t, an integer type that's safe to convert to and
+   from a pointer. */
+typedef void sh_uwfunc_t (void *);
+
 extern void uwp_init (void);
 
 /* Run a function without interrupts. */
@@ -39,6 +47,7 @@ extern int unwind_protect_tag_on_stack (const char *);
 
 /* How to protect a variable.  */
 #define unwind_protect_var(X) unwind_protect_mem ((char *)&(X), sizeof (X))
+
 extern void unwind_protect_mem (char *, int);
 
 /* Backwards compatibility */