Remove K&R cruft.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 9 Sep 2003 22:22:46 +0000 (22:22 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 9 Sep 2003 22:22:46 +0000 (22:22 +0000)
lib/memchr.c
lib/memcmp.c
lib/memcoll.c
lib/memcpy.c
lib/memmove.c
lib/memrchr.c
lib/memset.c
m4/memchr.m4
m4/memcmp.m4
m4/memcoll.m4
m4/memrchr.m4

index 4b28e481f88e4789c52e74bf14483b924e38c64e..ae232ae3439e64233406579a621e5e91e6e9d81a 100644 (file)
@@ -1,4 +1,6 @@
-/* Copyright (C) 1991,93,96,97,99,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003 Free
+   Software Foundation, Inc.
+
    Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
    with help from Dan Sahlin (dan@sics.se) and
    commentary by Jim Blandy (jimb@ai.mit.edu);
@@ -27,34 +29,19 @@ USA.  */
 # include <config.h>
 #endif
 
-#undef __ptr_t
-#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
-# define __ptr_t void *
-#else /* Not C++ or ANSI C.  */
-# define __ptr_t char *
-#endif /* C++ or ANSI C.  */
+#include <string.h>
 
 #if defined _LIBC
-# include <string.h>
 # include <memcopy.h>
 #else
 # define reg_char char
 #endif
 
-#if HAVE_STDLIB_H || defined _LIBC
-# include <stdlib.h>
-#endif
-
-#if HAVE_LIMITS_H || defined _LIBC
-# include <limits.h>
-#endif
+#include <limits.h>
+#include <stdlib.h>
 
 #define LONG_MAX_32_BITS 2147483647
 
-#ifndef LONG_MAX
-# define LONG_MAX LONG_MAX_32_BITS
-#endif
-
 #include <sys/types.h>
 #if HAVE_BP_SYM_H || defined _LIBC
 # include <bp-sym.h>
@@ -66,11 +53,8 @@ USA.  */
 #undef __memchr
 
 /* Search no more than N bytes of S for C.  */
-__ptr_t
-__memchr (s, c_in, n)
-     const __ptr_t s;
-     int c_in;
-     size_t n;
+void *
+__memchr (void const *s, int c_in, size_t n)
 {
   const unsigned char *char_ptr;
   const unsigned long int *longword_ptr;
@@ -86,7 +70,7 @@ __memchr (s, c_in, n)
                 & (sizeof (longword) - 1)) != 0;
        --n, ++char_ptr)
     if (*char_ptr == c)
-      return (__ptr_t) char_ptr;
+      return (void *) char_ptr;
 
   /* All these elucidatory comments refer to 4-byte longwords,
      but the theory applies equally well to 8-byte longwords.  */
@@ -177,22 +161,22 @@ __memchr (s, c_in, n)
          const unsigned char *cp = (const unsigned char *) (longword_ptr - 1);
 
          if (cp[0] == c)
-           return (__ptr_t) cp;
+           return (void *) cp;
          if (cp[1] == c)
-           return (__ptr_t) &cp[1];
+           return (void *) &cp[1];
          if (cp[2] == c)
-           return (__ptr_t) &cp[2];
+           return (void *) &cp[2];
          if (cp[3] == c)
-           return (__ptr_t) &cp[3];
+           return (void *) &cp[3];
 #if LONG_MAX > 2147483647
          if (cp[4] == c)
-           return (__ptr_t) &cp[4];
+           return (void *) &cp[4];
          if (cp[5] == c)
-           return (__ptr_t) &cp[5];
+           return (void *) &cp[5];
          if (cp[6] == c)
-           return (__ptr_t) &cp[6];
+           return (void *) &cp[6];
          if (cp[7] == c)
-           return (__ptr_t) &cp[7];
+           return (void *) &cp[7];
 #endif
        }
 
@@ -204,7 +188,7 @@ __memchr (s, c_in, n)
   while (n-- > 0)
     {
       if (*char_ptr == c)
-       return (__ptr_t) char_ptr;
+       return (void *) char_ptr;
       else
        ++char_ptr;
     }
index 5756bc0a47c4610a03a24e34ede0e8171dd1f63c..1d2947e6649f710dc5801859a2abffac6cdf023d 100644 (file)
@@ -1,4 +1,6 @@
-/* Copyright (C) 1991, 1993, 1995, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1995, 1997, 1998, 2003 Free Software
+   Foundation, Inc.
+
    Contributed by Torbjorn Granlund (tege@sics.se).
 
    NOTE: The canonical source of this file is maintained with the GNU C Library.
 # include "config.h"
 #endif
 
-#undef __ptr_t
-#if defined __cplusplus || (defined __STDC__ && __STDC__)
-# define __ptr_t       void *
-#else /* Not C++ or ANSI C.  */
-# undef        const
-# define const
-# define __ptr_t       char *
-#endif /* C++ or ANSI C.  */
-
-#ifndef __P
-# if defined __GNUC__ || (defined __STDC__ && __STDC__)
-#  define __P(args) args
-# else
-#  define __P(args) ()
-# endif  /* GCC.  */
-#endif  /* Not __P.  */
-
-#if defined HAVE_STRING_H || defined _LIBC
-# include <string.h>
-#endif
+#include <string.h>
 
 #undef memcmp
 
@@ -103,8 +86,6 @@ typedef unsigned char byte;
    A and B are known to be different.
    This is needed only on little-endian machines.  */
 
-static int memcmp_bytes __P((op_t, op_t));
-
 # ifdef  __GNUC__
 __inline
 # endif
@@ -127,8 +108,6 @@ memcmp_bytes (long unsigned int a, long unsigned int b)
 }
 #endif
 
-static int memcmp_common_alignment __P((long, long, size_t));
-
 /* memcmp_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN `op_t'
    objects (not LEN bytes!).  Both SRCP1 and SRCP2 should be aligned for
    memory operations on `op_t's.  */
@@ -214,8 +193,6 @@ memcmp_common_alignment (long int srcp1, long int srcp2, size_t len)
   return 0;
 }
 
-static int memcmp_not_common_alignment __P((long, long, size_t));
-
 /* memcmp_not_common_alignment -- Compare blocks at SRCP1 and SRCP2 with LEN
    `op_t' objects (not LEN bytes!).  SRCP2 should be aligned for memory
    operations on `op_t', but SRCP1 *should be unaligned*.  */
index 38d2bdfbda520b7ac3f412ae19c69b721c5144f1..34ae767dbdbb800cc491f5dedace0ed602375fda 100644 (file)
@@ -28,9 +28,7 @@
 extern int errno;
 #endif
 
-#if HAVE_STRING_H
-# include <string.h>
-#endif
+#include <string.h>
 
 /* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according
    to the LC_COLLATE locale.  S1 and S2 do not overlap, and are not
index 2ccd71875924967640de05ea78fdb154a0a181a7..fdca8de2c80d99ec4017477507a1ed5ac6f75ea2 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1997, 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
 # include <config.h>
 #endif
 
+#include <stddef.h>
+
 /* Copy LEN bytes starting at SRCADDR to DESTADDR.  Result undefined
    if the source overlaps with the destination.
    Return DESTADDR. */
 
-char *
-memcpy (char *destaddr, const char *srcaddr, int len)
+void *
+memcpy (void *destaddr, void const *srcaddr, size_t len)
 {
   char *dest = destaddr;
+  char const *src = srcaddr;
 
   while (len-- > 0)
-    *destaddr++ = *srcaddr++;
-  return dest;
+    *dest++ = *src++;
+  return destaddr;
 }
index ea38e8df549e9e1210c0a38bbe8ed08e45a93603..79cc7827396c0ffbe75e932f8b9d93a27994b6e1 100644 (file)
@@ -7,13 +7,13 @@
 # include <config.h>
 #endif
 
+#include <stddef.h>
+
 void *
-memmove (dest, source, length)
-     char *dest;
-     const char *source;
-     unsigned length;
+memmove (void *dest0, void const *source0, size_t length)
 {
-  char *d0 = dest;
+  char *dest = dest0;
+  char const *source = source0;
   if (source < dest)
     /* Moving from low mem to hi mem; start at end.  */
     for (source += length, dest += length; length; --length)
@@ -24,5 +24,5 @@ memmove (dest, source, length)
       for (; length; --length)
        *dest++ = *source++;
     }
-  return (void *) d0;
+  return dest0;
 }
index 9f29900f85b7fed6926a7c44a40add500cfd4f7a..7d702f35e1dca00df87b49ffda197976afc6094c 100644 (file)
@@ -1,5 +1,8 @@
 /* memrchr -- find the last occurrence of a byte in a memory block
-   Copyright (C) 1991, 93, 96, 97, 99, 2000 Free Software Foundation, Inc.
+
+   Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003 Free
+   Software Foundation, Inc.
+
    Based on strlen implementation by Torbjorn Granlund (tege@sics.se),
    with help from Dan Sahlin (dan@sics.se) and
    commentary by Jim Blandy (jimb@ai.mit.edu);
 #endif
 
 #include <stdlib.h>
-
-#undef __ptr_t
-#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
-# define __ptr_t void *
-#else /* Not C++ or ANSI C.  */
-# define __ptr_t char *
-#endif /* C++ or ANSI C.  */
+#include <string.h>
 
 #if defined (_LIBC)
-# include <string.h>
 # include <memcopy.h>
 #else
 # define reg_char char
 #endif
 
-#if defined (HAVE_LIMITS_H) || defined (_LIBC)
-# include <limits.h>
-#endif
+#include <limits.h>
 
 #define LONG_MAX_32_BITS 2147483647
 
-#ifndef LONG_MAX
-# define LONG_MAX LONG_MAX_32_BITS
-#endif
-
 #include <sys/types.h>
 
 #undef __memrchr
 #endif
 
 /* Search no more than N bytes of S for C.  */
-__ptr_t
-__memrchr (s, c_in, n)
-     const __ptr_t s;
-     int c_in;
-     size_t n;
+void *
+__memrchr (void const *s, int c_in, size_t n)
 {
   const unsigned char *char_ptr;
   const unsigned long int *longword_ptr;
@@ -80,7 +67,7 @@ __memrchr (s, c_in, n)
                 & (sizeof (longword) - 1)) != 0;
        --n)
     if (*--char_ptr == c)
-      return (__ptr_t) char_ptr;
+      return (void *) char_ptr;
 
   /* All these elucidatory comments refer to 4-byte longwords,
      but the theory applies equally well to 8-byte longwords.  */
@@ -172,22 +159,22 @@ __memrchr (s, c_in, n)
 
 #if LONG_MAX > 2147483647
          if (cp[7] == c)
-           return (__ptr_t) &cp[7];
+           return (void *) &cp[7];
          if (cp[6] == c)
-           return (__ptr_t) &cp[6];
+           return (void *) &cp[6];
          if (cp[5] == c)
-           return (__ptr_t) &cp[5];
+           return (void *) &cp[5];
          if (cp[4] == c)
-           return (__ptr_t) &cp[4];
+           return (void *) &cp[4];
 #endif
          if (cp[3] == c)
-           return (__ptr_t) &cp[3];
+           return (void *) &cp[3];
          if (cp[2] == c)
-           return (__ptr_t) &cp[2];
+           return (void *) &cp[2];
          if (cp[1] == c)
-           return (__ptr_t) &cp[1];
+           return (void *) &cp[1];
          if (cp[0] == c)
-           return (__ptr_t) cp;
+           return (void *) cp;
        }
 
       n -= sizeof (longword);
@@ -198,7 +185,7 @@ __memrchr (s, c_in, n)
   while (n-- > 0)
     {
       if (*--char_ptr == c)
-       return (__ptr_t) char_ptr;
+       return (void *) char_ptr;
     }
 
   return 0;
index 5744bcbf7585dde15683be2084be2255657e9989..d7321b200e91d5cb4ad12935f2afc50fd52e4518 100644 (file)
@@ -1,5 +1,5 @@
 /* memset.c -- set an area of memory to a given value
-   Copyright (C) 1991 Free Software Foundation, Inc.
+   Copyright (C) 1991, 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
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
-char *
-memset (char *str, int c, unsigned int len)
+#include <stddef.h>
+
+void *
+memset (void *str, int c, size_t len)
 {
   register char *st = str;
 
index 7b6cfc43d5b4830dc43931967bb4dbce58f9814d..60a06c271caccc1338af557ae25d1e8447f9bcd3 100644 (file)
@@ -1,5 +1,5 @@
-# memchr.m4 serial 1
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# memchr.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,6 +16,5 @@ AC_DEFUN([gl_FUNC_MEMCHR],
 
 # Prerequisites of lib/memchr.c.
 AC_DEFUN([jm_PREREQ_MEMCHR], [
-  AC_CHECK_HEADERS_ONCE(limits.h stdlib.h)
   AC_CHECK_HEADERS(bp-sym.h)
 ])
index 4442e47b6945300103ffb255dc32eb78502a76cb..90d8bb30f21259b5e0471841f4bc42e053fc79d0 100644 (file)
@@ -1,5 +1,5 @@
-# memcmp.m4 serial 8
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# memcmp.m4 serial 9
+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,4 @@ AC_DEFUN([jm_FUNC_MEMCMP],
 ])
 
 # Prerequisites of lib/memcmp.c.
-AC_DEFUN([gl_PREREQ_MEMCMP], [
-  AC_CHECK_HEADERS_ONCE(string.h)
-])
+AC_DEFUN([gl_PREREQ_MEMCMP], [:])
index 23f56af17769cde67bed1207a4769773c80c8d62..131841a403ffb70fb79e603d34048e83db4b6468 100644 (file)
@@ -1,5 +1,5 @@
-# memcoll.m4 serial 2
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# memcoll.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
 dnl Public License, this file may be distributed as part of a program
@@ -10,6 +10,5 @@ AC_DEFUN([gl_MEMCOLL],
 [
   dnl Prerequisites of lib/memcoll.c.
   AC_REQUIRE([AC_FUNC_MEMCMP])
-  AC_CHECK_HEADERS_ONCE(string.h)
   AC_FUNC_STRCOLL
 ])
index c489ec3d3fabee793efd9c0d753593053b056374..dfb0583acc2073e5edc34a1d98b1c6078ab9b13d 100644 (file)
@@ -1,5 +1,5 @@
-# memrchr.m4 serial 1
-dnl Copyright (C) 2002 Free Software Foundation, Inc.
+# memrchr.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
@@ -18,6 +18,4 @@ AC_DEFUN([gl_FUNC_MEMRCHR],
 ])
 
 # Prerequisites of lib/memrchr.c.
-AC_DEFUN([gl_PREREQ_MEMRCHR], [
-  AC_CHECK_HEADERS_ONCE(limits.h)
-])
+AC_DEFUN([gl_PREREQ_MEMRCHR], [:])