From fa9635f22ac175bace582885ca780d3eb511b578 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 12 Sep 2003 18:24:51 +0000 Subject: [PATCH] Remove K&R cruft. --- lib/progreloc.c | 2 +- lib/setenv.c | 2 +- lib/stpncpy.c | 6 ----- lib/strdup.c | 13 ++++------ lib/strtod.c | 21 +++------------- lib/strtoimax.c | 16 +----------- lib/strtol.c | 72 ++++++++++++------------------------------------------ lib/tempname.c | 6 +---- lib/userspec.c | 15 ++---------- lib/xgethostname.c | 2 +- lib/xmalloc.c | 14 +++-------- lib/xstrtod.c | 17 ++++--------- lib/xstrtol.c | 25 +++---------------- m4/mkstemp.m4 | 1 - m4/strdup.m4 | 5 ++-- m4/strtod.m4 | 3 +-- m4/strtoimax.m4 | 4 +-- m4/strtol.m4 | 5 ++-- m4/userspec.m4 | 5 ++-- m4/xalloc.m4 | 3 +-- m4/xstrtod.m4 | 6 ++--- m4/xstrtol.m4 | 4 +-- 22 files changed, 56 insertions(+), 191 deletions(-) diff --git a/lib/progreloc.c b/lib/progreloc.c index cda55a76e..13ecb436e 100644 --- a/lib/progreloc.c +++ b/lib/progreloc.c @@ -285,7 +285,7 @@ set_program_name_and_installdir (const char *argv0, /* 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; } diff --git a/lib/setenv.c b/lib/setenv.c index 0a28cb9fb..f185e04db 100644 --- a/lib/setenv.c +++ b/lib/setenv.c @@ -280,7 +280,7 @@ setenv (const char *name, const char *value, int replace) never made it. Nevertheless the POSIX.9 standard (POSIX bindings for Fortran 77) requires this function. */ int -clearenv () +clearenv (void) { LOCK; diff --git a/lib/stpncpy.c b/lib/stpncpy.c index 243cbc7bb..c302e398d 100644 --- a/lib/stpncpy.c +++ b/lib/stpncpy.c @@ -27,12 +27,6 @@ /* Specification. */ #include "stpncpy.h" -#ifdef _LIBC -# include -#else -# include -#endif - #ifndef weak_alias # define __stpncpy stpncpy #endif diff --git a/lib/strdup.c b/lib/strdup.c index 5aa09a652..28d2ba1aa 100644 --- 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 #endif -#if defined _LIBC || defined STDC_HEADERS -# include -# include -#else -char *malloc (); -char *memcpy (); -#endif +#include +#include #undef __strdup #undef strdup diff --git a/lib/strtod.c b/lib/strtod.c index 10edb5cfe..161f97a7b 100644 --- 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 @@ extern int errno; #include -#if HAVE_FLOAT_H -# include -#else -# define DBL_MAX 1.7976931348623159e+308 -# define DBL_MIN 2.2250738585072010e-308 -#endif - -#if STDC_HEADERS -# include -# include -#else -# define NULL 0 -# ifndef HUGE_VAL -# define HUGE_VAL HUGE -# endif -#endif +#include +#include +#include /* 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. */ diff --git a/lib/strtoimax.c b/lib/strtoimax.c index 555f2d5b5..4ce741cfd 100644 --- a/lib/strtoimax.c +++ b/lib/strtoimax.c @@ -27,20 +27,12 @@ # include #endif -#if HAVE_STDLIB_H -# include -#endif +#include /* 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 @@ unsigned long long strtoull (char const *, char **, int); #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 diff --git a/lib/strtol.c b/lib/strtol.c index 0c9c2767e..d556e9463 100644 --- 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 @@ -36,19 +37,10 @@ extern int errno; # define __set_errno(Val) errno = (Val) #endif -#ifdef HAVE_LIMITS_H -# include -#endif - -#ifdef STDC_HEADERS -# include -# include -# include -#else -# ifndef NULL -# define NULL 0 -# endif -#endif +#include +#include +#include +#include #ifdef USE_NUMBER_GROUPING # include "../locale/localeinfo.h" @@ -164,13 +156,6 @@ extern int errno; # 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 @@ extern int errno; # 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 @@ extern int errno; # 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 @@ extern int errno; 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 @@ noconv: /* 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); } diff --git a/lib/tempname.c b/lib/tempname.c index 13a8204a4..b3d0874ce 100644 --- a/lib/tempname.c +++ b/lib/tempname.c @@ -44,12 +44,8 @@ #endif #include - -#if STDC_HEADERS || _LIBC -# include -#endif - #include +#include #if HAVE_FCNTL_H || _LIBC # include diff --git a/lib/userspec.c b/lib/userspec.c index 19443ec91..6e58b486c 100644 --- a/lib/userspec.c +++ b/lib/userspec.c @@ -33,19 +33,8 @@ #endif #include - -#if HAVE_STRING_H -# include -#else -# include -# ifndef strchr -# define strchr index -# endif -#endif - -#if STDC_HEADERS -# include -#endif +#include +#include #if HAVE_UNISTD_H # include diff --git a/lib/xgethostname.c b/lib/xgethostname.c index 5178784ba..c0939945b 100644 --- a/lib/xgethostname.c +++ b/lib/xgethostname.c @@ -50,7 +50,7 @@ int gethostname (); If malloc fails, exit. Upon any other failure, return NULL. */ char * -xgethostname () +xgethostname (void) { char *hostname; size_t size; diff --git a/lib/xmalloc.c b/lib/xmalloc.c index ead50393d..82980ea58 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -21,16 +21,9 @@ # include #endif -#include - -#if STDC_HEADERS -# include -#else -void *calloc (); -void *malloc (); -void *realloc (); -void free (); -#endif +#include "xalloc.h" + +#include #include "gettext.h" #define _(msgid) gettext (msgid) @@ -38,7 +31,6 @@ void free (); #include "error.h" #include "exitfail.h" -#include "xalloc.h" #ifndef EXIT_FAILURE # define EXIT_FAILURE 1 diff --git a/lib/xstrtod.c b/lib/xstrtod.c index 4b4c12afb..8450829bd 100644 --- 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 #endif -#ifdef STDC_HEADERS -# include -#else -double strtod (); -#endif +#include "xstrtod.h" #include -#include #include -#include "xstrtod.h" +#include +#include /* Tell the compiler that non-default rounding modes are used. */ #if 199901 <= __STDC_VERSION__ @@ -43,10 +39,7 @@ double strtod (); 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; diff --git a/lib/xstrtol.c b/lib/xstrtol.c index 73d87bacb..4be09f169 100644 --- a/lib/xstrtol.c +++ b/lib/xstrtol.c @@ -33,21 +33,10 @@ need stderr defined if assertion checking is enabled. */ #include -#if STDC_HEADERS -# include -#endif - -#if HAVE_STRING_H -# include -#else -# include -# ifndef strchr -# define strchr index -# endif -#endif - #include #include +#include +#include #include #ifndef errno @@ -69,14 +58,6 @@ extern int errno; #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 @@ __xstrtol (const char *s, char **ptr, int strtol_base, char *program_name; int -main (int argc, char** argv) +main (int argc, char **argv) { strtol_error s_err; int i; diff --git a/m4/mkstemp.m4 b/m4/mkstemp.m4 index fd182935d..3d379fd2b 100644 --- a/m4/mkstemp.m4 +++ b/m4/mkstemp.m4 @@ -57,7 +57,6 @@ AC_DEFUN([gl_PREREQ_MKSTEMP], # 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) diff --git a/m4/strdup.m4 b/m4/strdup.m4 index 08087063d..effeb60ea 100644 --- 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 @@ AC_DEFUN([gl_FUNC_STRDUP], # Prerequisites of lib/strdup.c. AC_DEFUN([gl_PREREQ_STRDUP], [ - AC_REQUIRE([AC_HEADER_STDC]) : ]) diff --git a/m4/strtod.m4 b/m4/strtod.m4 index 809a83fa8..fb742f7d5 100644 --- 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 @@ AC_DEFUN([gl_FUNC_STRTOD], # 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) ]) diff --git a/m4/strtoimax.m4 b/m4/strtoimax.m4 index 7a338f2aa..2cc1776d7 100644 --- 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 @@ AC_DEFUN([gl_FUNC_STRTOIMAX], # 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]) ]) diff --git a/m4/strtol.m4 b/m4/strtol.m4 index 59a74f655..7740eccda 100644 --- 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 @@ AC_DEFUN([gl_FUNC_STRTOL], # 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) ]) diff --git a/m4/userspec.m4 b/m4/userspec.m4 index 862c87170..df78b83cc 100644 --- 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 @@ dnl the same distribution terms as the rest of that program. 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) ]) diff --git a/m4/xalloc.m4 b/m4/xalloc.m4 index 5dcb73053..9f6e87d03 100644 --- 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 @@ AC_DEFUN([gl_XALLOC], # 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]) ]) diff --git a/m4/xstrtod.m4 b/m4/xstrtod.m4 index 4056d8cf0..93528c2f5 100644 --- 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 @@ dnl the same distribution terms as the rest of that program. # Prerequisites of lib/xstrtod.c. AC_DEFUN([gl_XSTRTOD], [ - AC_REQUIRE([AC_HEADER_STDC]) + : ]) diff --git a/m4/xstrtol.m4 b/m4/xstrtol.m4 index 86d14b68c..a21ab2b05 100644 --- 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_DEFUN([gl_PREREQ_XSTRTOL], [ 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]) ]) -- 2.11.0