home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / compiler / clib / memcmp.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-09  |  1.3 KB  |  71 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: memcmp.c,v 1.2 1996/12/12 16:11:41 aros Exp $
  4.  
  5.     Desc: ANSI C function memcmp()
  6.     Lang: english
  7. */
  8. #include <exec/types.h>
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13. #include <string.h>
  14.  
  15.     int memcmp (
  16.  
  17. /*  SYNOPSIS */
  18.     const void * s1,
  19.     const void * s2,
  20.     size_t         n)
  21.  
  22. /*  FUNCTION
  23.     Calculate s1 - s2 for the n bytes after s1 and s2 and stop when
  24.     the difference is not 0.
  25.  
  26.     INPUTS
  27.     s1, s2 - Begin of the memory areas to compare
  28.     n - The number of bytes to compare
  29.  
  30.     RESULT
  31.     The difference of the memory areas. The difference is 0, if both
  32.     are equal, < 0 if s1 < s2 and > 0 if s1 > s2. Note that it may be
  33.     greater then 1 or less than -1.
  34.  
  35.     NOTES
  36.     This function is not part of a library and may thus be called
  37.     any time.
  38.  
  39.     EXAMPLE
  40.  
  41.     BUGS
  42.  
  43.     SEE ALSO
  44.     strcmp(), strncmp(), strcasecmp() strncasecmp()
  45.  
  46.     INTERNALS
  47.  
  48.     HISTORY
  49.     24-12-95    digulla created
  50.  
  51. ******************************************************************************/
  52. {
  53.     const UBYTE * str1,
  54.         * str2;
  55.     int       diff;
  56.  
  57.     str1 = s1;
  58.     str2 = s2;
  59.  
  60.     while (n && !(diff = *str1 - *str2))
  61.     {
  62.     str1 ++;
  63.     str2 ++;
  64.     n --;
  65.     }
  66.  
  67.     /* Now return the difference. */
  68.     return diff;
  69. } /* memcmp */
  70.  
  71.