~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to strings/memcmp.c

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2000 MySQL AB
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
 
 
16
 
/* memcmp(lhs, rhs, len)
17
 
   compares the two memory areas lhs[0..len-1]  ??  rhs[0..len-1].   It
18
 
   returns  an integer less than, equal to, or greater than 0 according
19
 
   as lhs[-] is lexicographically less than, equal to, or greater  than
20
 
   rhs[-].  Note  that this is not at all the same as bcmp, which tells
21
 
   you *where* the difference is but not what.
22
 
 
23
 
   Note:  suppose we have int x, y;  then memcmp(&x, &y, sizeof x) need
24
 
   not bear any relation to x-y.  This is because byte order is machine
25
 
   dependent, and also, some machines have integer representations that
26
 
   are shorter than a machine word and two equal  integers  might  have
27
 
   different  values  in the spare bits.  On a ones complement machine,
28
 
   -0 == 0, but the bit patterns are different.
29
 
*/
30
 
 
31
 
#include "strings.h"
32
 
 
33
 
#if !defined(HAVE_MEMCPY)
34
 
 
35
 
int memcmp(lhs, rhs, len)
36
 
     register char *lhs, *rhs;
37
 
     register int len;
38
 
{
39
 
  while (--len >= 0)
40
 
    if (*lhs++ != *rhs++) return (uchar) lhs[-1] - (uchar) rhs[-1];
41
 
  return 0;
42
 
}
43
 
 
44
 
#endif