OSDN Git Service

2005-05-18 Thomas Koenig <Thomas.Koenig@online.de>
[pf3gnuchains/gcc-fork.git] / libiberty / memchr.c
index 93ef43d..451f817 100644 (file)
@@ -1,56 +1,28 @@
 /*
-FUNCTION
-       <<memchr>>---find character in memory
 
-INDEX
-       memchr
+@deftypefn Supplemental void* memchr (const void *@var{s}, int @var{c}, size_t @var{n})
 
-ANSI_SYNOPSIS
-       #include <string.h>
-       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 <string.h>
-       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, <<NULL>> 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 <<NULL>> is returned.  
-
-PORTABILITY
-<<memchr>>  requires no supporting OS subroutines.
-
-QUICKREF
-       memchr ansi pure
+@end deftypefn
 
 */
 
 #include <ansidecl.h>
-#ifdef __STDC__
 #include <stddef.h>
-#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;