bug-gnulib
[Top][All Lists]
Advanced

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

[Bug-gnulib] md5, sha patches to assume C89 or better


From: Paul Eggert
Subject: [Bug-gnulib] md5, sha patches to assume C89 or better
Date: 09 Sep 2003 15:07:05 -0700
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

I installed this:

2003-09-09  Paul Eggert  <address@hidden>

        * lib/md5.h: Include <limits.h> unconditionally.
        (UINT_MAX_32_BITS): Don't worry about non-__STDC__ case.
        (__P): Remove; all uses removed.
        * lib/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.
        * lib/sha.h (__P): Remove all uses.  (It wasn't defined??)
        * lib/sha.c: Include "sha.h" first.
        Include <stdlib.h>, <string.h> unconditionally.
        * m4/md5.m4 (gl_MD5): Don't check for limits.h, standard C headers,
        memcpy.
        * m4/sha.m4 (gl_SHA): Don't check for standard Cheaders, memcpy.

Index: lib/md5.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/md5.h,v
retrieving revision 1.12
diff -p -u -r1.12 md5.h
--- lib/md5.h   14 Aug 2003 23:12:50 -0000      1.12
+++ lib/md5.h   9 Sep 2003 22:01:56 -0000
@@ -22,10 +22,7 @@
 #define _MD5_H 1
 
 #include <stdio.h>
-
-#if defined HAVE_LIMITS_H || _LIBC
-# include <limits.h>
-#endif
+#include <limits.h>
 
 /* 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 <limits.h>) 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 ((cons
 
    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
 
    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 */
Index: lib/md5.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/md5.c,v
retrieving revision 1.14
diff -p -u -r1.14 md5.c
--- lib/md5.c   14 Aug 2003 23:12:50 -0000      1.14
+++ lib/md5.c   9 Sep 2003 22:01:56 -0000
@@ -24,12 +24,13 @@
 # include <config.h>
 #endif
 
+#include "md5.h"
+
 #include <sys/types.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-#include "md5.h"
 #include "unlocked-io.h"
 
 #ifdef _LIBC
@@ -70,8 +71,7 @@ static const unsigned char fillbuf[64] =
 /* 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;
Index: lib/sha.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/sha.h,v
retrieving revision 1.1
diff -p -u -r1.1 sha.h
--- lib/sha.h   20 Sep 2000 08:06:06 -0000      1.1
+++ lib/sha.h   9 Sep 2003 22:01:56 -0000
@@ -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 sh
 
    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
 
    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
Index: lib/sha.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/sha.c,v
retrieving revision 1.10
diff -p -u -r1.10 sha.c
--- lib/sha.c   16 Aug 2003 04:05:01 -0000      1.10
+++ lib/sha.c   9 Sep 2003 22:01:57 -0000
@@ -11,19 +11,13 @@
 # include <config.h>
 #endif
 
+#include "sha.h"
+
 #include <sys/types.h>
 
-#if STDC_HEADERS || defined _LIBC
-# include <stdlib.h>
-# include <string.h>
-#else
-# ifndef HAVE_MEMCPY
-#  define memcpy(d, s, n) bcopy ((s), (d), (n))
-# endif
-#endif
+#include <stdlib.h>
+#include <string.h>
 
-#include "md5.h"
-#include "sha.h"
 #include "unlocked-io.h"
 
 /*
Index: m4/md5.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/md5.m4,v
retrieving revision 1.2
diff -p -u -r1.2 md5.m4
--- m4/md5.m4   15 Jan 2003 12:47:26 -0000      1.2
+++ m4/md5.m4   9 Sep 2003 22:01:57 -0000
@@ -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.
 ])
Index: m4/sha.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/sha.m4,v
retrieving revision 1.1
diff -p -u -r1.1 sha.m4
--- m4/sha.m4   31 Dec 2002 13:42:07 -0000      1.1
+++ m4/sha.m4   9 Sep 2003 22:01:57 -0000
@@ -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 r
 AC_DEFUN([gl_SHA],
 [
   dnl Prerequisites of lib/sha.c.
-  AC_REQUIRE([AC_HEADER_STDC])
-  AC_CHECK_FUNCS_ONCE(memcpy)
+  :
 ])




reply via email to

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