From: Paul Eggert Date: Thu, 3 Feb 2005 20:38:14 +0000 (+0000) Subject: * modules/chdir-long (Depends-on): Add memrchr. X-Git-Tag: cvs-readonly~3549 X-Git-Url: http://erislabs.net/gitweb/?a=commitdiff_plain;h=018039820ee41e5d8a9a7352ae55bc3eb14bac3c;p=gnulib.git * modules/chdir-long (Depends-on): Add memrchr. * modules/memrchr (Files): Add lib/memrchr.h. (Include): "memrchr.h". * lib/memrchr.h: New file. * lib/chdir-long.c: Include it. * lib/memrchr.c [!defined _LIBC]: Include it rather than Don't bother including stddef.h. * m4/memrchr.m4 (gl_FUNC_MEMRCHR): Add AC_LIBSOURCES, for memrchr.h. --- diff --git a/ChangeLog b/ChangeLog index 0699106a4..840fc3157 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-02-03 Paul Eggert + + * modules/chdir-long (Depends-on): Add memrchr. + * modules/memrchr (Files): Add lib/memrchr.h. + (Include): "memrchr.h". + 2005-01-28 Paul Eggert Sync from coreutils. diff --git a/lib/ChangeLog b/lib/ChangeLog index 9164b7892..2982b480b 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,10 @@ +2005-02-03 Paul Eggert + + * memrchr.h: New file. + * chdir-long.c: Include it. + * memrchr.c [!defined _LIBC]: Include it rather than + Don't bother including stddef.h. + 2005-02-03 Sergey Poznyakoff * argp-help.c (__argp_help): Create a fake struct argp_state and diff --git a/lib/chdir-long.c b/lib/chdir-long.c index 6c8d79f7a..4702432a7 100644 --- a/lib/chdir-long.c +++ b/lib/chdir-long.c @@ -30,6 +30,7 @@ #include #include +#include "memrchr.h" #include "openat.h" #ifndef O_DIRECTORY diff --git a/lib/memrchr.c b/lib/memrchr.c index e34d65ed0..ae8dabcd0 100644 --- a/lib/memrchr.c +++ b/lib/memrchr.c @@ -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 (tege@sics.se), with help from Dan Sahlin (dan@sics.se) and @@ -27,13 +27,11 @@ # include #endif -#include - -#include - #if defined _LIBC +# include # include #else +# include "memrchr.h" # define reg_char char #endif diff --git a/lib/memrchr.h b/lib/memrchr.h new file mode 100644 index 000000000..6a8e8153a --- /dev/null +++ b/lib/memrchr.h @@ -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 +#else +# include + +/* Search backwards through a block for a byte (specified as an int). */ +void *memrchr (void const *, int, size_t); + +#endif diff --git a/m4/ChangeLog b/m4/ChangeLog index 7a5e35cd2..d02029b19 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,7 @@ +2005-02-03 Paul Eggert + + * memrchr.m4 (gl_FUNC_MEMRCHR): Add AC_LIBSOURCES, for memrchr.h. + 2005-01-28 Paul Eggert Sync from coreutils. diff --git a/m4/memrchr.m4 b/m4/memrchr.m4 index 06a9b1ee7..8ce7d9e46 100644 --- a/m4/memrchr.m4 +++ b/m4/memrchr.m4 @@ -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 to declare memrchr(). AC_REQUIRE([AC_GNU_SOURCE]) diff --git a/modules/chdir-long b/modules/chdir-long index c82f5fcbe..a069cf959 100644 --- a/modules/chdir-long +++ b/modules/chdir-long @@ -8,6 +8,7 @@ m4/chdir-long.m4 Depends-on: openat +memrchr configure.ac: gl_FUNC_CHDIR_LONG diff --git a/modules/memrchr b/modules/memrchr index eccad32aa..618c38951 100644 --- a/modules/memrchr +++ b/modules/memrchr @@ -3,6 +3,7 @@ memrchr() function: scan memory for a byte, from the right end. Files: lib/memrchr.c +lib/memrchr.h m4/memrchr.m4 Depends-on: @@ -13,10 +14,10 @@ gl_FUNC_MEMRCHR Makefile.am: Include: +"memrchr.h" License: LGPL Maintainer: Jim Meyering, glibc -