bug-coreutils
[Top][All Lists]
Advanced

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

memrchr.h change imported from gnulib


From: Paul Eggert
Subject: memrchr.h change imported from gnulib
Date: Thu, 03 Feb 2005 13:51:34 -0800
User-agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux)

I installed this to work around the memrchr declaration problem that
occurs on Solaris, Cygwin, etc.  This uses the same imperfect solution
(adding memrchr.h) that we already use for several other GNU
extensions, but it's better than nothing.

2005-02-03  Paul Eggert  <address@hidden>

        * lib/memrchr.h: New file.
        * lib/chdir-long.c: Include it.
        * lib/memrchr.c [!defined _LIBC]: Include it rather than <string.h>.
        Don't bother including stddef.h.
        * m4/memrchr.m4 (gl_FUNC_MEMRCHR): Add AC_LIBSOURCES, for memrchr.h.
        * src/system.h: Include "memrchr.h".
        (memrchr) [!HAVE_DECL_MEMRCHR]: Remove decl.

--- /dev/null   2003-03-18 13:55:57 -0800
+++ lib/memrchr.h       2005-02-03 12:28:12 -0800
@@ -0,0 +1,27 @@
+/* memrchr -- Find the last occurrence of a byte in a memory block.
+
+   Copyright (C) 2005 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
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#if HAVE_DECL_MEMRCHR
+# include <string.h>
+#else
+# include <stddef.h>
+
+/* Search backwards through a block for a byte (specified as an int).  */
+void *memrchr (void const *, int, size_t);
+
+#endif
Index: lib/chdir-long.c
===================================================================
RCS file: /fetish/cu/lib/chdir-long.c,v
retrieving revision 1.4
diff -p -u -r1.4 chdir-long.c
--- lib/chdir-long.c    19 Jan 2005 10:21:43 -0000      1.4
+++ lib/chdir-long.c    3 Feb 2005 21:26:46 -0000
@@ -30,6 +30,7 @@
 #include <assert.h>
 #include <limits.h>
 
+#include "memrchr.h"
 #include "openat.h"
 
 #ifndef O_DIRECTORY
Index: lib/memrchr.c
===================================================================
RCS file: /fetish/cu/lib/memrchr.c,v
retrieving revision 1.7
diff -p -u -r1.7 memrchr.c
--- lib/memrchr.c       2 Aug 2004 05:21:47 -0000       1.7
+++ lib/memrchr.c       3 Feb 2005 21:26:46 -0000
@@ -1,7 +1,7 @@
 /* memrchr -- find the last occurrence of a byte in a memory block
 
-   Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004 Free
-   Software Foundation, Inc.
+   Copyright (C) 1991, 1993, 1996, 1997, 1999, 2000, 2003, 2004, 2005
+   Free Software Foundation, Inc.
 
    Based on strlen implementation by Torbjorn Granlund (address@hidden),
    with help from Dan Sahlin (address@hidden) and
@@ -27,13 +27,11 @@
 # include <config.h>
 #endif
 
-#include <string.h>
-
-#include <stddef.h>
-
 #if defined _LIBC
+# include <string.h>
 # include <memcopy.h>
 #else
+# include "memrchr.h"
 # define reg_char char
 #endif
 
Index: m4/memrchr.m4
===================================================================
RCS file: /fetish/cu/m4/memrchr.m4,v
retrieving revision 1.3
diff -p -u -r1.3 memrchr.m4
--- m4/memrchr.m4       23 Jan 2005 09:07:57 -0000      1.3
+++ m4/memrchr.m4       3 Feb 2005 21:26:46 -0000
@@ -1,11 +1,13 @@
-# memrchr.m4 serial 3
-dnl Copyright (C) 2002, 2003 Free Software Foundation, Inc.
+# memrchr.m4 serial 4
+dnl Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
 
 AC_DEFUN([gl_FUNC_MEMRCHR],
 [
+  AC_LIBSOURCES([memrchr.c, memrchr.h])
+
   dnl Persuade glibc <string.h> to declare memrchr().
   AC_REQUIRE([AC_GNU_SOURCE])
 
Index: src/system.h
===================================================================
RCS file: /fetish/cu/src/system.h,v
retrieving revision 1.99
diff -p -u -r1.99 system.h
--- src/system.h        24 Jan 2005 08:27:15 -0000      1.99
+++ src/system.h        3 Feb 2005 21:27:26 -0000
@@ -1,5 +1,5 @@
 /* system-dependent definitions for fileutils, textutils, and sh-utils 
packages.
-   Copyright (C) 1989, 1991-2004 Free Software Foundation, Inc.
+   Copyright (C) 1989, 1991-2005 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
@@ -114,9 +114,7 @@ struct utimbuf
    memcpy otherwise.  */
 
 #include <string.h>
-#if ! HAVE_DECL_MEMRCHR
-void *memrchr (const void *, int, size_t);
-#endif
+#include "memrchr.h"
 
 #include <errno.h>
 





reply via email to

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