From b258c18a6f1cbb23ab21f55325ddaeccf9005cba Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 9 Sep 2003 23:31:14 +0000 Subject: [PATCH] Remove K&R cruft. --- ChangeLog | 6 ++- config/ChangeLog | 4 ++ lib/ChangeLog | 149 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/md5.c | 33 ++++-------- lib/md5.h | 45 ++++------------- lib/sha.h | 18 +++---- m4/ChangeLog | 45 ++++++++++++++++- m4/md5.m4 | 7 +-- m4/sha.m4 | 7 ++- 9 files changed, 235 insertions(+), 79 deletions(-) diff --git a/ChangeLog b/ChangeLog index f516b1212..43b7650fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2003-09-09 Paul Eggert + + * README: New section: portability guidelines. + 2003-09-07 Paul Eggert * modules/time_r: Depend on 'restrict'. Fix from Simon Josefsson in @@ -9,7 +13,7 @@ * modules/time_r: New file. * modules/mktime, modules/strftime, modules/timegm: Depend on time_r. * modules/timegm: Depend on mktime. Change maintainer to "all, glibc". - + 2003-08-31 Simon Josefsson * modules/timegm: New file. diff --git a/config/ChangeLog b/config/ChangeLog index 3fad679fb..faff92790 100644 --- a/config/ChangeLog +++ b/config/ChangeLog @@ -1,3 +1,7 @@ +2003-09-09 Paul Eggert + + * srclist.txt: Do not get getopt.h or getopt1.c from libc. + 2003-09-08 Karl Berry * config.sub, config.guess, srclistvars.sh: update from savannah diff --git a/lib/ChangeLog b/lib/ChangeLog index 7573a8589..32a2b8066 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,152 @@ +2003-09-09 Paul Eggert + + More K&R removal. + + * acosl.c (main): Use a prototype. + * asinl.c, cosl.c, expl.c, frexpl.c, ldexpl.c, sinl.c, + tanl.c: Likewise. + + * getloadavg.c (getloadavg, main): Define via prototypes. + + * getopt.h (struct option.name): Assume C89, and use 'const'. + (getopt, etopt_long, getopt_long_only, _getopt_internal) + [defined __GNU_LIBRARY__]: Assume C89, so we can always declare + with a prototype. + * getopt.c (const): Remove macro. + Include unconditionally. + (my_index): Remove; all uses changed to strchr. + (strlen): Remove decl. + (exchange): Remove forward decl; no longer needed. + (exchange, _getopt_initialize, _getopt_internal, getopt, main): + Define with prototype. + * getopt1.c (const): Remove macro. + (getopt_long, getopt_long_only, main): Define with prototype. + + * getugroups.c: Include unconditionally. + + * getusershell.c: Include unconditionally. + (getusershell, setusershell, endusershell, readname, main): + Define with prototypes. + + * group-member.c: Include group-member.h first. + Include unconditionally. + + * hard-locale.c: Include hard-locale.h first. + Include , unconditionally. + + * hash.c (free, malloc): Remove decls. + Include unconditionally. + + * human.c: Include , unconditionally. + (getenv): Do not declare. + + * idcache.c: Include unconditionally. + + * long-options.c: Include long-options.h first, to test interface. + Include unconditionally. + + * makepath.c: Include makepath.h first, to test interface. + Include and unconditionally. + + * linebuffer.c: Include . + (free): Remove decl. + + * malloc.c: Include , for malloc; don't bother with stddef.h. + rpl_malloc returns void *, not char *. + * realloc.c (rpl_realloc): Likewise. Also, define with a prototype. + + * md5.h: Include unconditionally. + (UINT_MAX_32_BITS): Don't worry about non-__STDC__ case. + (__P): Remove; all uses removed. + * md5.c: Include "md5.h" first. + (md5_init_ctx, md5_read_ctx, md5_finish_ctx, md5_stream, + md5_buffer, md5_process_bytes, md5_process_block): + Define with prototypes. + * sha.h (__P): Remove all uses. (It wasn't defined??) + * sha.c: Include "sha.h" first. + Include , unconditionally. + + * memchr.c (__ptr_t): Remove; all uses changed to void *. + * memcmp.c (__ptr_t): Likewise. + * memrchr.c (__ptr_t): Likewise. + * memchr.c, memcmp.c, memcoll.c, memrchr.c: + Include unconditionally. + * memchr.c, memrchr.c: Include unconditionally. + * memchr.c: Include unconditionally. + * memchr.c (LONG_MAX): Remove. + * memrchr.c (LONG_MAX): Likewise. + * memchr.c (__memchr): Define via a prototype. + * memrchr.c (__memrchr): Likewise. + * memcmp.c (__P): Remove, and remove all uses. + (memcmp_bytes, memcmp_common_alignment, memcmp_not_common_alignment): + Remove forward decls; no longer needed. + * memcpy.c, memmove.c, memset.c: Include . + Use types required by C89 in prototype. + + * mkdir.c: Include , unconditionally. + * savedir.c: Likewise. + * mkdir.c (free): Remove decl. + * rmdir.c (rmdir): Define with a prototype. + * savedir.c: Include savedir.h first, to test interface. + + * mktime.c (STDC_HEADERS): Remove. + Include , unconditionally. + + * modechange.c: Include unconditionally. + (malloc): Remove decl. + + * mountlist.c: Include , unconditionally. + (free): Remove decl. + + * obstack.h (PTR_INT_TYPE) [!defined __PTRDIFF_TYPE__]: + Define to ptrdiff_t, without bothering to check HAVE_STDDEF_H. + (This type really should be intptr_t, but that's a C99ism.) + (_obstack_memcpy): Remove: all uses changed to memcpy. + Include unconditionally. + (struct obstack): Assume __STDC__ for types of members + chunkfun, freefun, extra_arg. + (_obstack_newchunk, _obstack_free, _obstack_begin, _obstack_begin_1, + _obstack_memory_used, obstack_alloc_failed_handler, obstack_init, + obstack_begin, obstack_specify_allocation, + obstack_specify_allocation_with_arg, obstack_chunkfun, + obstack_freefun, obstack_free) [! (defined __STDC__ && __STDC__)]: + Remove unprototyped decls and the macros that use them. + * obstack.c (POINTER): Remove. All uses changed to void *. + (obstack_alloc_failed_handler, CALL_CHUNKFUN, CALL_FREEFUN, + _obstack_begin, _obstack_begin_1, _obstack_allocated_p) + (defined __STDC__ && __STDC__)]: + Remove nonprototyped code. + Include unconditionally. + (_obstack_begin, _obstack_begin_1, _obstack_newchunk, + _obstack_allocated_p, _obstack_free, obstack_free, + _obstack_memory_used, print_and_abort): + Define using prototypes. + (obstack_1grow, obstack_1grow_fast, obstack_alloc, obstack_base, + obstack_blank, obstack_blank_fast, obstack_copy, obstack_copy0, + obstack_finish, obstack_grow, obstack_grow0, obstack_make_room, + obstack_next_free, obstack_object_size, obstack_room) [0]: + Remove unused, unprototyped code. + + * path-concat.c: Include , unconditionally. + + * physmem.c (physmem_total, physmem_available, main): Define + with prototypes. + + The following changes are not K&R related: + + * group-member.h: Include , so that this file is + self-contained. + * makepath.h: Likewise. + + * getusershell.c (readname, default_index, line_size, readname): + Use size_t, not int, for sizes. + (readname): If the size overflows, report an error instead of + looping forever. + +2003-09-09 Derek Robert Price + + * getndelim2.c: Assume stdlib.h per the C89 spec. + 2003-09-08 Paul Eggert Assume C89 or better; remove K&R cruft. diff --git a/lib/md5.c b/lib/md5.c index 4feb32d20..2fc652cea 100644 --- a/lib/md5.c +++ b/lib/md5.c @@ -24,12 +24,13 @@ # include #endif +#include "md5.h" + #include #include #include -#include "md5.h" #include "unlocked-io.h" #ifdef _LIBC @@ -70,8 +71,7 @@ static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ }; /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ void -md5_init_ctx (ctx) - struct md5_ctx *ctx; +md5_init_ctx (struct md5_ctx *ctx) { ctx->A = 0x67452301; ctx->B = 0xefcdab89; @@ -88,9 +88,7 @@ md5_init_ctx (ctx) IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void * -md5_read_ctx (ctx, resbuf) - const struct md5_ctx *ctx; - void *resbuf; +md5_read_ctx (const struct md5_ctx *ctx, void *resbuf) { ((md5_uint32 *) resbuf)[0] = SWAP (ctx->A); ((md5_uint32 *) resbuf)[1] = SWAP (ctx->B); @@ -106,9 +104,7 @@ md5_read_ctx (ctx, resbuf) IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ void * -md5_finish_ctx (ctx, resbuf) - struct md5_ctx *ctx; - void *resbuf; +md5_finish_ctx (struct md5_ctx *ctx, void *resbuf) { /* Take yet unprocessed bytes into account. */ md5_uint32 bytes = ctx->buflen; @@ -137,9 +133,7 @@ md5_finish_ctx (ctx, resbuf) resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ int -md5_stream (stream, resblock) - FILE *stream; - void *resblock; +md5_stream (FILE *stream, void *resblock) { struct md5_ctx ctx; char buffer[BLOCKSIZE + 72]; @@ -206,10 +200,7 @@ md5_stream (stream, resblock) output yields to the wanted ASCII representation of the message digest. */ void * -md5_buffer (buffer, len, resblock) - const char *buffer; - size_t len; - void *resblock; +md5_buffer (const char *buffer, size_t len, void *resblock) { struct md5_ctx ctx; @@ -225,10 +216,7 @@ md5_buffer (buffer, len, resblock) void -md5_process_bytes (buffer, len, ctx) - const void *buffer; - size_t len; - struct md5_ctx *ctx; +md5_process_bytes (const void *buffer, size_t len, struct md5_ctx *ctx) { /* When we already have some bits in our internal buffer concatenate both inputs first. */ @@ -312,10 +300,7 @@ md5_process_bytes (buffer, len, ctx) It is assumed that LEN % 64 == 0. */ void -md5_process_block (buffer, len, ctx) - const void *buffer; - size_t len; - struct md5_ctx *ctx; +md5_process_block (const void *buffer, size_t len, struct md5_ctx *ctx) { md5_uint32 correct_words[16]; const md5_uint32 *words = buffer; diff --git a/lib/md5.h b/lib/md5.h index fda0ba4ed..3a417c0d5 100644 --- a/lib/md5.h +++ b/lib/md5.h @@ -22,10 +22,7 @@ #define _MD5_H 1 #include - -#if defined HAVE_LIMITS_H || _LIBC -# include -#endif +#include /* The following contortions are an attempt to use the C preprocessor to determine an unsigned integral type that is 32 bits wide. An @@ -39,20 +36,7 @@ typedef uint32_t md5_uint32; typedef uintptr_t md5_uintptr; #else -# if defined __STDC__ && __STDC__ -# define UINT_MAX_32_BITS 4294967295U -# else -# define UINT_MAX_32_BITS 0xFFFFFFFF -# endif - -/* If UINT_MAX isn't defined, assume it's a 32-bit type. - This should be valid for all systems GNU cares about because - that doesn't include 16-bit systems, and only modern systems - (that certainly have ) have 64+-bit integral types. */ - -# ifndef UINT_MAX -# define UINT_MAX UINT_MAX_32_BITS -# endif +# define UINT_MAX_32_BITS 4294967295U # if UINT_MAX == UINT_MAX_32_BITS typedef unsigned int md5_uint32; @@ -74,13 +58,6 @@ typedef uintptr_t md5_uintptr; typedef unsigned long int md5_uintptr; #endif -#undef __P -#if defined (__STDC__) && __STDC__ -#define __P(x) x -#else -#define __P(x) () -#endif - /* Structure to save state of computation between the single steps. */ struct md5_ctx { @@ -101,21 +78,21 @@ struct md5_ctx /* Initialize structure containing state of computation. (RFC 1321, 3.3: Step 3) */ -extern void md5_init_ctx __P ((struct md5_ctx *ctx)); +extern void md5_init_ctx (struct md5_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ -extern void md5_process_block __P ((const void *buffer, size_t len, - struct md5_ctx *ctx)); +extern void md5_process_block (const void *buffer, size_t len, + struct md5_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ -extern void md5_process_bytes __P ((const void *buffer, size_t len, - struct md5_ctx *ctx)); +extern void md5_process_bytes (const void *buffer, size_t len, + struct md5_ctx *ctx); /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little @@ -124,7 +101,7 @@ extern void md5_process_bytes __P ((const void *buffer, size_t len, IMPORTANT: On some systems it is required that RESBUF be correctly aligned for a 32 bits value. */ -extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf)); +extern void *md5_finish_ctx (struct md5_ctx *ctx, void *resbuf); /* Put result from CTX in first 16 bytes following RESBUF. The result is @@ -133,19 +110,19 @@ extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf)); IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ -extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf)); +extern void *md5_read_ctx (const struct md5_ctx *ctx, void *resbuf); /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ -extern int md5_stream __P ((FILE *stream, void *resblock)); +extern int md5_stream (FILE *stream, void *resblock); /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ -extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock)); +extern void *md5_buffer (const char *buffer, size_t len, void *resblock); /* The following is from gnupg-1.0.2's cipher/bithelp.h. */ /* Rotate a 32 bit integer by n bytes */ diff --git a/lib/sha.h b/lib/sha.h index 2ee17f212..238b0739c 100644 --- a/lib/sha.h +++ b/lib/sha.h @@ -29,18 +29,18 @@ struct sha_ctx initialization function update the context for the next LEN bytes starting at BUFFER. It is necessary that LEN is a multiple of 64!!! */ -extern void sha_process_block __P ((const void *buffer, size_t len, - struct sha_ctx *ctx)); +extern void sha_process_block (const void *buffer, size_t len, + struct sha_ctx *ctx); /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ -extern void sha_process_bytes __P((const void *buffer, size_t len, - struct sha_ctx *ctx)); +extern void sha_process_bytes (const void *buffer, size_t len, + struct sha_ctx *ctx); /* Initialize structure containing state of computation. */ -extern void sha_init_ctx __P ((struct sha_ctx *ctx)); +extern void sha_init_ctx (struct sha_ctx *ctx); /* Process the remaining bytes in the buffer and put result from CTX in first 16 bytes following RESBUF. The result is always in little @@ -49,7 +49,7 @@ extern void sha_init_ctx __P ((struct sha_ctx *ctx)); IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ -extern void *sha_finish_ctx __P ((struct sha_ctx *ctx, void *resbuf)); +extern void *sha_finish_ctx (struct sha_ctx *ctx, void *resbuf); /* Put result from CTX in first 16 bytes following RESBUF. The result is @@ -58,18 +58,18 @@ extern void *sha_finish_ctx __P ((struct sha_ctx *ctx, void *resbuf)); IMPORTANT: On some systems it is required that RESBUF is correctly aligned for a 32 bits value. */ -extern void *sha_read_ctx __P ((const struct sha_ctx *ctx, void *resbuf)); +extern void *sha_read_ctx (const struct sha_ctx *ctx, void *resbuf); /* Compute MD5 message digest for bytes read from STREAM. The resulting message digest number will be written into the 16 bytes beginning at RESBLOCK. */ -extern int sha_stream __P ((FILE *stream, void *resblock)); +extern int sha_stream (FILE *stream, void *resblock); /* Compute MD5 message digest for LEN bytes beginning at BUFFER. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ -extern void *sha_buffer __P ((const char *buffer, size_t len, void *resblock)); +extern void *sha_buffer (const char *buffer, size_t len, void *resblock); #endif diff --git a/m4/ChangeLog b/m4/ChangeLog index 682391b2b..6b5e2e70a 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,44 @@ +2003-09-09 Paul Eggert + + * getopt.m4 (gl_GETOPT): Don't check for string.h. + * getugroups.m4 (gl_GETUGROUPS): Do not check for standard C headers + or for string.h. + * getusershell.m4 (gl_PREREQ_GETUSERSHELL): Do not check for stdlib.h. + * group-member.m4 (gl_PREREQ_GROUP_MEMBER): Do not require standard C + headers. + * hard-locale.m4 (gl_HARD_LOCALE): Do not check for stdlib.h, + string.h. + * hash.m4 (gl_HASH): Do not check for stdlib.h, malloc, free. + * human.m4 (gl_HUMAN): Do not check for stdlib.h, string.h, getenv. + * idcache.m4 (gl_IDCACHE): Do not check for standard C headers, + or for string.h. + * long-options.m4 (gl_LONG_OPTIONS): Do not check for stdlib.h. + * mkpath.m4 (gl_MAKEPATH): Do not check for string.h or standard + C headers. + * md5.m4 (gl_MD5): Don't check for limits.h, standard C headers, + memcpy. + * sha.m4 (gl_SHA): Don't check for standard Cheaders, memcpy. + * memrchr.m4 (jm_PREREQ_MEMCHR): Don't check for limits.h, stdlib.h. + * memcmp.m4 (gl_PREREQ_MEMCMP): Don't check for string.h. + * memcoll.m4 (gl_MEMCOLL): Likewise. + * memrchr.c (gl_PREREQ_MEMRCHR): Don't check for limits.h. + * mkdir-slash.m4 (gl_PREREQ_MKDIR): Don't check for stdlib.h, + string.h, free. + * mktime.m4 (gl_PREREQ_MKTIME): Don't check for standard C headers. + * modechange.m4 (gl_MODECHANGE): Don't check for standard C headers. + * mountlist.m4 (gl_PREREQ_MOUNTLIST_EXTRA): Don't check for standard + C orders, or for string.h. + * obstack.m4 (gl_OBSTACK): Don't check for stddefe.h, string.h. + (gl_PREREQ_OBSTACK): Don't check for stdlib.h. + * path-concat.m4 (gl_PATH_CONCAT): Don't check for standard C + headers, memory.h, stdlib.h, string.h, strings.h. + * savedir.m4 (gl_SAVEDIR): Don't check for standard C headers. + +2003-09-09 Derek Robert Price + + * getndelim2.m4 (gl_PREREQ_GETNDELIM2): Assume stdlib.h per the + C89 spec. + 2003-09-08 Paul Eggert Assume C89 or better; remove K&R cruft. @@ -15,10 +56,10 @@ do not check for doprnt or vprintf. * fnmatch.m4 (gl_PREREQ_FNMATCH_EXTRA): Remove. All uses removed. * getdate.m4 (gl_GETDATE): Don't check for stdlib.h or string.h. - + 2003-09-06 Paul Eggert - * time_4.m4: New file. + * time_r.m4: New file. * mktime.m4 (gl_PREREQ_MKTIME): Remove check for limits.h. * timegm.m4 (gl_FUNC_TIMEGM): Assume that timegm is buggy if mktime is. Check for timegm declaration. diff --git a/m4/md5.m4 b/m4/md5.m4 index 5d0899868..743099022 100644 --- a/m4/md5.m4 +++ b/m4/md5.m4 @@ -1,4 +1,4 @@ -# md5.m4 serial 2 +# md5.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 @@ -10,9 +10,6 @@ AC_DEFUN([gl_MD5], [ dnl Prerequisites of lib/md5.h. AC_REQUIRE([AC_C_INLINE]) - AC_CHECK_HEADERS_ONCE(limits.h) - dnl Prerequisites of lib/md5.c. - AC_REQUIRE([AC_HEADER_STDC]) - AC_CHECK_FUNCS_ONCE(memcpy) + dnl No prerequisites of lib/md5.c. ]) diff --git a/m4/sha.m4 b/m4/sha.m4 index c218fec2f..6eadd2df6 100644 --- a/m4/sha.m4 +++ b/m4/sha.m4 @@ -1,5 +1,5 @@ -# sha.m4 serial 1 -dnl Copyright (C) 2002 Free Software Foundation, Inc. +# sha.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,6 +9,5 @@ dnl the same distribution terms as the rest of that program. AC_DEFUN([gl_SHA], [ dnl Prerequisites of lib/sha.c. - AC_REQUIRE([AC_HEADER_STDC]) - AC_CHECK_FUNCS_ONCE(memcpy) + : ]) -- 2.11.0