X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmemchr.c;h=4b28e481f88e4789c52e74bf14483b924e38c64e;hb=a76a349e949dfad5716eb3893052070b770e949f;hp=dc3bec7c85068a4c8c5c468dd3c834c05cd0dda2;hpb=dbfc0605348ea299fadfe8a436e7e6c0127a7307;p=gnulib.git diff --git a/lib/memchr.c b/lib/memchr.c index dc3bec7c8..4b28e481f 100644 --- a/lib/memchr.c +++ b/lib/memchr.c @@ -1,5 +1,5 @@ -/* Copyright (C) 1991, 1993 Free Software Foundation, Inc. - Based on strlen implemention by Torbjorn Granlund (tege@sics.se), +/* Copyright (C) 1991,93,96,97,99,2000 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); adaptation to memchr suggested by Dick Karpinski (dick@cca.ucsf.edu), @@ -20,10 +20,11 @@ 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, 675 Mass Ave, Cambridge, MA 02139, USA. */ +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, +USA. */ #ifdef HAVE_CONFIG_H -#include +# include #endif #undef __ptr_t @@ -33,36 +34,50 @@ Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ # define __ptr_t char * #endif /* C++ or ANSI C. */ -#if defined (_LIBC) +#if defined _LIBC # include +# include +#else +# define reg_char char +#endif + +#if HAVE_STDLIB_H || defined _LIBC +# include #endif -#if defined (HAVE_LIMITS_H) || defined (_LIBC) +#if HAVE_LIMITS_H || defined _LIBC # include #endif #define LONG_MAX_32_BITS 2147483647 #ifndef LONG_MAX -#define LONG_MAX LONG_MAX_32_BITS +# define LONG_MAX LONG_MAX_32_BITS #endif #include +#if HAVE_BP_SYM_H || defined _LIBC +# include +#else +# define BP_SYM(sym) sym +#endif +#undef memchr +#undef __memchr /* Search no more than N bytes of S for C. */ - __ptr_t -memchr (s, c, n) +__memchr (s, c_in, n) const __ptr_t s; - int c; + int c_in; size_t n; { const unsigned char *char_ptr; const unsigned long int *longword_ptr; unsigned long int longword, magic_bits, charmask; + unsigned reg_char c; - c = (unsigned char) c; + c = (unsigned char) c_in; /* Handle the first few characters by reading one character at a time. Do this until CHAR_PTR is aligned on a longword boundary. */ @@ -196,3 +211,6 @@ memchr (s, c, n) return 0; } +#ifdef weak_alias +weak_alias (__memchr, BP_SYM (memchr)) +#endif