X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=libiberty%2Fmemchr.c;h=451f817d3203fdfe420d2caee873619ede70bea7;hb=2ba1fcba384fb6390f858783fbabc0137a9e9007;hp=93ef43d3f88d5584fefba1ee61ed067781a80426;hpb=28e9041cc224267271fbcd8db22bea115912365b;p=pf3gnuchains%2Fgcc-fork.git diff --git a/libiberty/memchr.c b/libiberty/memchr.c index 93ef43d3f88..451f817d320 100644 --- a/libiberty/memchr.c +++ b/libiberty/memchr.c @@ -1,56 +1,28 @@ /* -FUNCTION - <>---find character in memory -INDEX - memchr +@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n}) -ANSI_SYNOPSIS - #include - void *memchr(const void *<[src]>, int <[c]>, size_t <[length]>); +This function searches memory starting at @code{*@var{s}} for the +character @var{c}. The search only ends with the first occurrence of +@var{c}, or after @var{length} characters; in particular, a null +character does not terminate the search. If the character @var{c} is +found within @var{length} characters of @code{*@var{s}}, a pointer +to the character is returned. If @var{c} is not found, then @code{NULL} is +returned. -TRAD_SYNOPSIS - #include - void *memchr(<[src]>, <[c]>, <[length]>) - void *<[src]>; - void *<[c]>; - size_t <[length]>; - -DESCRIPTION - This function searches memory starting at <<*<[src]>>> for the - character <[c]>. The search only ends with the first - occurrence of <[c]>, or after <[length]> characters; in - particular, <> does not terminate the search. - -RETURNS - If the character <[c]> is found within <[length]> characters - of <<*<[src]>>>, a pointer to the character is returned. If - <[c]> is not found, then <> is returned. - -PORTABILITY -<> requires no supporting OS subroutines. - -QUICKREF - memchr ansi pure +@end deftypefn */ #include -#ifdef __STDC__ #include -#else -#define size_t unsigned long -#endif PTR -memchr (src_void, c, length) - register CONST PTR src_void; - int c; - size_t length; +memchr (register const PTR src_void, int c, size_t length) { - CONST unsigned char *src = (CONST unsigned char *)src_void; + const unsigned char *src = (const unsigned char *)src_void; - while (--length >= 0) + while (length-- > 0) { if (*src == c) return (PTR)src;