changeset 4691:ce37d22a271f

Remove K&R cruft.
author Paul Eggert <eggert@cs.ucla.edu>
date Fri, 12 Sep 2003 18:24:51 +0000
parents 41205f607f6d
children bd40222323f2
files lib/progreloc.c lib/setenv.c lib/stpncpy.c lib/strdup.c lib/strtod.c lib/strtoimax.c lib/strtol.c lib/tempname.c lib/userspec.c lib/xgethostname.c lib/xmalloc.c lib/xstrtod.c lib/xstrtol.c m4/mkstemp.m4 m4/strdup.m4 m4/strtod.m4 m4/strtoimax.m4 m4/strtol.m4 m4/userspec.m4 m4/xalloc.m4 m4/xstrtod.m4 m4/xstrtol.m4
diffstat 22 files changed, 55 insertions(+), 190 deletions(-) [+]
line wrap: on
line diff
--- a/lib/progreloc.c
+++ b/lib/progreloc.c
@@ -285,7 +285,7 @@
 /* Return the full pathname of the current executable, based on the earlier
    call to set_program_name_and_installdir.  Return NULL if unknown.  */
 char *
-get_full_program_name ()
+get_full_program_name (void)
 {
   return executable_fullname;
 }
--- a/lib/setenv.c
+++ b/lib/setenv.c
@@ -280,7 +280,7 @@
    never made it.  Nevertheless the POSIX.9 standard (POSIX bindings
    for Fortran 77) requires this function.  */
 int
-clearenv ()
+clearenv (void)
 {
   LOCK;
 
--- a/lib/stpncpy.c
+++ b/lib/stpncpy.c
@@ -27,12 +27,6 @@
 /* Specification.  */
 #include "stpncpy.h"
 
-#ifdef _LIBC
-# include <string.h>
-#else
-# include <sys/types.h>
-#endif
-
 #ifndef weak_alias
 # define __stpncpy stpncpy
 #endif
--- a/lib/strdup.c
+++ b/lib/strdup.c
@@ -1,4 +1,6 @@
-/* Copyright (C) 1991, 1996, 1997, 1998, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003 Free Software
+   Foundation, Inc.
+
    This file is part of the GNU C Library.
 
    This program is free software; you can redistribute it and/or modify
@@ -19,13 +21,8 @@
 #include <config.h>
 #endif
 
-#if defined _LIBC || defined  STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#else
-char *malloc ();
-char *memcpy ();
-#endif
+#include <stdlib.h>
+#include <string.h>
 
 #undef __strdup
 #undef strdup
--- a/lib/strtod.c
+++ b/lib/strtod.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1997, 1999, 2003 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -37,22 +37,9 @@
 
 #include <math.h>
 
-#if HAVE_FLOAT_H
-# include <float.h>
-#else
-# define DBL_MAX 1.7976931348623159e+308
-# define DBL_MIN 2.2250738585072010e-308
-#endif
-
-#if STDC_HEADERS
-# include <stdlib.h>
-# include <string.h>
-#else
-# define NULL 0
-# ifndef HUGE_VAL
-#  define HUGE_VAL HUGE
-# endif
-#endif
+#include <float.h>
+#include <stdlib.h>
+#include <string.h>
 
 /* Convert NPTR to a double.  If ENDPTR is not NULL, a pointer to the
    character after the last one used in the number is put in *ENDPTR.  */
--- a/lib/strtoimax.c
+++ b/lib/strtoimax.c
@@ -27,20 +27,12 @@
 # include <stdint.h>
 #endif
 
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
 
 /* Verify a requirement at compile-time (unlike assert, which is runtime).  */
 #define verify(name, assertion) struct name { char a[(assertion) ? 1 : -1]; }
 
 #ifdef UNSIGNED
-# ifndef HAVE_DECL_STRTOUL
-"this configure-time declaration test was not run"
-# endif
-# if !HAVE_DECL_STRTOUL
-unsigned long strtoul (char const *, char **, int);
-# endif
 # ifndef HAVE_DECL_STRTOULL
 "this configure-time declaration test was not run"
 # endif
@@ -50,12 +42,6 @@
 
 #else
 
-# ifndef HAVE_DECL_STRTOL
-"this configure-time declaration test was not run"
-# endif
-# if !HAVE_DECL_STRTOL
-long strtol (char const *, char **, int);
-# endif
 # ifndef HAVE_DECL_STRTOLL
 "this configure-time declaration test was not run"
 # endif
--- a/lib/strtol.c
+++ b/lib/strtol.c
@@ -1,5 +1,8 @@
 /* Convert string representation of a number into an integer value.
-   Copyright (C) 1991, 92, 94, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
+
+   Copyright (C) 1991, 1992, 1994, 1995, 1996, 1997, 1998, 1999, 2003
+   Free Software Foundation, Inc.
+
    NOTE: The canonical source of this file is maintained with the GNU C
    Library.  Bugs can be reported to bug-glibc@gnu.org.
 
@@ -23,8 +26,6 @@
 
 #ifdef _LIBC
 # define USE_NUMBER_GROUPING
-# define STDC_HEADERS
-# define HAVE_LIMITS_H
 #endif
 
 #include <ctype.h>
@@ -36,19 +37,10 @@
 # define __set_errno(Val) errno = (Val)
 #endif
 
-#ifdef HAVE_LIMITS_H
-# include <limits.h>
-#endif
-
-#ifdef STDC_HEADERS
-# include <stddef.h>
-# include <stdlib.h>
-# include <string.h>
-#else
-# ifndef NULL
-#  define NULL 0
-# endif
-#endif
+#include <limits.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
 
 #ifdef USE_NUMBER_GROUPING
 # include "../locale/localeinfo.h"
@@ -164,13 +156,6 @@
 # endif
 #else
 # define LONG long
-
-# ifndef ULONG_MAX
-#  define ULONG_MAX ((unsigned long) ~(unsigned long) 0)
-# endif
-# ifndef LONG_MAX
-#  define LONG_MAX ((long int) (ULONG_MAX >> 1))
-# endif
 # define STRTOL_LONG_MIN LONG_MIN
 # define STRTOL_LONG_MAX LONG_MAX
 # define STRTOL_ULONG_MAX ULONG_MAX
@@ -186,7 +171,7 @@
 # define _NL_CURRENT(category, item) \
   (current->values[_NL_ITEM_INDEX (item)].string)
 # define LOCALE_PARAM , loc
-# define LOCALE_PARAM_DECL __locale_t loc;
+# define LOCALE_PARAM_DECL , __locale_t loc
 #else
 # define LOCALE_PARAM
 # define LOCALE_PARAM_DECL
@@ -230,15 +215,9 @@
 # endif
 #endif
 
-/* For compilers which are ansi but don't define __STDC__, like SGI
-   Irix-4.0.5 cc, also check whether PROTOTYPES is defined. */
-#if defined (__STDC__) || defined (PROTOTYPES)
-# define INTERNAL(X) INTERNAL1(X)
-# define INTERNAL1(X) __##X##_internal
-# define WEAKNAME(X) WEAKNAME1(X)
-#else
-# define INTERNAL(X) __/**/X/**/_internal
-#endif
+#define INTERNAL(X) INTERNAL1(X)
+#define INTERNAL1(X) __##X##_internal
+#define WEAKNAME(X) WEAKNAME1(X)
 
 #ifdef USE_NUMBER_GROUPING
 /* This file defines a function to check for correct grouping.  */
@@ -255,12 +234,8 @@
    one converted is stored in *ENDPTR.  */
 
 INT
-INTERNAL (strtol) (nptr, endptr, base, group LOCALE_PARAM)
-     const STRING_TYPE *nptr;
-     STRING_TYPE **endptr;
-     int base;
-     int group;
-     LOCALE_PARAM_DECL
+INTERNAL (strtol) (const STRING_TYPE *nptr, STRING_TYPE **endptr,
+		   int base, int group LOCALE_PARAM_DECL)
 {
   int negative;
   register unsigned LONG int cutoff;
@@ -445,28 +420,13 @@
 
 /* External user entry point.  */
 
-#if _LIBC - 0 == 0
-# undef PARAMS
-# if defined (__STDC__) && __STDC__
-#  define PARAMS(Args) Args
-# else
-#  define PARAMS(Args) ()
-# endif
-
-/* Prototype.  */
-INT strtol PARAMS ((const STRING_TYPE *nptr, STRING_TYPE **endptr, int base));
-#endif
-
 
 INT
 #ifdef weak_function
 weak_function
 #endif
-strtol (nptr, endptr, base LOCALE_PARAM)
-     const STRING_TYPE *nptr;
-     STRING_TYPE **endptr;
-     int base;
-     LOCALE_PARAM_DECL
+strtol (const STRING_TYPE *nptr, STRING_TYPE **endptr,
+	int base LOCALE_PARAM_DECL)
 {
   return INTERNAL (strtol) (nptr, endptr, base, 0 LOCALE_PARAM);
 }
--- a/lib/tempname.c
+++ b/lib/tempname.c
@@ -44,12 +44,8 @@
 #endif
 
 #include <stddef.h>
-
-#if STDC_HEADERS || _LIBC
-# include <string.h>
-#endif
-
 #include <stdlib.h>
+#include <string.h>
 
 #if HAVE_FCNTL_H || _LIBC
 # include <fcntl.h>
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -33,19 +33,8 @@
 #endif
 
 #include <limits.h>
-
-#if HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-# ifndef strchr
-#  define strchr index
-# endif
-#endif
-
-#if STDC_HEADERS
-# include <stdlib.h>
-#endif
+#include <stdlib.h>
+#include <string.h>
 
 #if HAVE_UNISTD_H
 # include <unistd.h>
--- a/lib/xgethostname.c
+++ b/lib/xgethostname.c
@@ -50,7 +50,7 @@
    If malloc fails, exit.
    Upon any other failure, return NULL.  */
 char *
-xgethostname ()
+xgethostname (void)
 {
   char *hostname;
   size_t size;
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -21,16 +21,9 @@
 # include <config.h>
 #endif
 
-#include <sys/types.h>
+#include "xalloc.h"
 
-#if STDC_HEADERS
-# include <stdlib.h>
-#else
-void *calloc ();
-void *malloc ();
-void *realloc ();
-void free ();
-#endif
+#include <stdlib.h>
 
 #include "gettext.h"
 #define _(msgid) gettext (msgid)
@@ -38,7 +31,6 @@
 
 #include "error.h"
 #include "exitfail.h"
-#include "xalloc.h"
 
 #ifndef EXIT_FAILURE
 # define EXIT_FAILURE 1
--- a/lib/xstrtod.c
+++ b/lib/xstrtod.c
@@ -1,5 +1,5 @@
 /* xstrtod.c - error-checking interface to strtod
-   Copyright (C) 1996, 1999, 2000 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1999, 2000, 2003 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -21,16 +21,12 @@
 # include <config.h>
 #endif
 
-#ifdef STDC_HEADERS
-# include <stdlib.h>
-#else
-double strtod ();
-#endif
+#include "xstrtod.h"
 
 #include <errno.h>
+#include <limits.h>
 #include <stdio.h>
-#include <limits.h>
-#include "xstrtod.h"
+#include <stdlib.h>
 
 /* Tell the compiler that non-default rounding modes are used.  */
 #if 199901 <= __STDC_VERSION__
@@ -43,10 +39,7 @@
    non-zero and don't modify *RESULT upon any failure.  */
 
 int
-xstrtod (str, ptr, result)
-     const char *str;
-     const char **ptr;
-     double *result;
+xstrtod (char const *str, char const **ptr, double *result)
 {
   double val;
   char *terminator;
--- a/lib/xstrtol.c
+++ b/lib/xstrtol.c
@@ -33,21 +33,10 @@
    need stderr defined if assertion checking is enabled.  */
 #include <stdio.h>
 
-#if STDC_HEADERS
-# include <stdlib.h>
-#endif
-
-#if HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-# ifndef strchr
-#  define strchr index
-# endif
-#endif
-
 #include <assert.h>
 #include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
 
 #include <errno.h>
 #ifndef errno
@@ -69,14 +58,6 @@
 
 #include "xstrtol.h"
 
-#if !HAVE_DECL_STRTOL && !defined strtol
-long int strtol ();
-#endif
-
-#if !HAVE_DECL_STRTOUL && !defined strtoul
-unsigned long int strtoul ();
-#endif
-
 #if !HAVE_DECL_STRTOIMAX && !defined strtoimax
 intmax_t strtoimax ();
 #endif
@@ -266,7 +247,7 @@
 char *program_name;
 
 int
-main (int argc, char** argv)
+main (int argc, char **argv)
 {
   strtol_error s_err;
   int i;
--- a/m4/mkstemp.m4
+++ b/m4/mkstemp.m4
@@ -57,7 +57,6 @@
 # Prerequisites of lib/tempname.c.
 AC_DEFUN([jm_PREREQ_TEMPNAME],
 [
-  AC_REQUIRE([AC_HEADER_STDC])
   AC_REQUIRE([AC_HEADER_STAT])
   AC_CHECK_HEADERS_ONCE(fcntl.h sys/time.h unistd.h)
   AC_CHECK_HEADERS(stdint.h)
--- a/m4/strdup.m4
+++ b/m4/strdup.m4
@@ -1,5 +1,5 @@
-# strdup.m4 serial 1
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# strdup.m4 serial 2
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
@@ -16,7 +16,6 @@
 
 # Prerequisites of lib/strdup.c.
 AC_DEFUN([gl_PREREQ_STRDUP], [
-  AC_REQUIRE([AC_HEADER_STDC])
   :
 ])
 
--- a/m4/strtod.m4
+++ b/m4/strtod.m4
@@ -1,4 +1,4 @@
-# strtod.m4 serial 2
+# strtod.m4 serial 3
 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -20,6 +20,5 @@
 # The need for pow() is already handled by AC_FUNC_STRTOD.
 AC_DEFUN([gl_PREREQ_STRTOD], [
   AC_REQUIRE([AC_HEADER_STDC])
-  AC_CHECK_HEADERS(float.h)
   AC_CHECK_FUNCS_ONCE(isascii)
 ])
--- a/m4/strtoimax.m4
+++ b/m4/strtoimax.m4
@@ -1,4 +1,4 @@
-# strtoimax.m4 serial 2
+# strtoimax.m4 serial 3
 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -32,8 +32,6 @@
 # Prerequisites of lib/strtoimax.c.
 AC_DEFUN([gl_PREREQ_STRTOIMAX], [
   jm_AC_TYPE_INTMAX_T
-  AC_CHECK_HEADERS_ONCE(stdlib.h)
-  AC_CHECK_DECLS_ONCE(strtol)
   AC_CHECK_DECLS(strtoll)
   AC_REQUIRE([jm_AC_TYPE_LONG_LONG])
 ])
--- a/m4/strtol.m4
+++ b/m4/strtol.m4
@@ -1,5 +1,5 @@
-# strtol.m4 serial 1
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# strtol.m4 serial 2
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
@@ -17,6 +17,5 @@
 # Prerequisites of lib/strtol.c.
 AC_DEFUN([gl_PREREQ_STRTOL], [
   AC_REQUIRE([AC_HEADER_STDC])
-  AC_CHECK_HEADERS_ONCE(limits.h)
   AC_CHECK_FUNCS_ONCE(isascii)
 ])
--- a/m4/userspec.m4
+++ b/m4/userspec.m4
@@ -1,4 +1,4 @@
-# userspec.m4 serial 2
+# userspec.m4 serial 3
 dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -9,7 +9,6 @@
 AC_DEFUN([gl_USERSPEC],
 [
   dnl Prerequisites of lib/userspec.c.
-  AC_REQUIRE([AC_HEADER_STDC])
   AC_REQUIRE([AC_FUNC_ALLOCA])
-  AC_CHECK_HEADERS_ONCE(string.h sys/param.h unistd.h)
+  AC_CHECK_HEADERS_ONCE(sys/param.h unistd.h)
 ])
--- a/m4/xalloc.m4
+++ b/m4/xalloc.m4
@@ -1,4 +1,4 @@
-# xalloc.m4 serial 2
+# xalloc.m4 serial 3
 dnl Copyright (C) 2002-2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -14,7 +14,6 @@
 
 # Prerequisites of lib/xmalloc.c.
 AC_DEFUN([gl_PREREQ_XMALLOC], [
-  AC_REQUIRE([AC_HEADER_STDC])
   AC_REQUIRE([jm_FUNC_MALLOC])
   AC_REQUIRE([jm_FUNC_REALLOC])
 ])
--- a/m4/xstrtod.m4
+++ b/m4/xstrtod.m4
@@ -1,5 +1,5 @@
-# xstrtod.m4 serial 1
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# xstrtod.m4 serial 2
+dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
 dnl Public License, this file may be distributed as part of a program
@@ -9,5 +9,5 @@
 # Prerequisites of lib/xstrtod.c.
 AC_DEFUN([gl_XSTRTOD],
 [
-  AC_REQUIRE([AC_HEADER_STDC])
+  :
 ])
--- a/m4/xstrtol.m4
+++ b/m4/xstrtol.m4
@@ -1,4 +1,4 @@
-# xstrtol.m4 serial 2
+# xstrtol.m4 serial 3
 dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
 dnl This file is free software, distributed under the terms of the GNU
 dnl General Public License.  As a special exception to the GNU General
@@ -24,9 +24,7 @@
 [
   AC_REQUIRE([gl_PREREQ_XSTRTOL_H])
   AC_REQUIRE([AC_HEADER_STDC])
-  AC_CHECK_HEADERS_ONCE(string.h)
   AC_CHECK_FUNCS_ONCE(isascii)
-  AC_CHECK_DECLS_ONCE(strtol strtoul)
   AC_CHECK_DECLS([strtoimax, strtoumax])
 ])