os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/compat/memcmp.c
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/compat/memcmp.c Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,62 @@
1.4 +/*
1.5 + * memcmp.c --
1.6 + *
1.7 + * Source code for the "memcmp" library routine.
1.8 + *
1.9 + * Copyright (c) 1998 Sun Microsystems, Inc.
1.10 + *
1.11 + * See the file "license.terms" for information on usage and redistribution
1.12 + * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
1.13 + *
1.14 + * SCCS: @(#) memcmp.c 1.2 98/01/19 10:48:58
1.15 + */
1.16 +
1.17 +#include "tcl.h"
1.18 +#include "tclPort.h"
1.19 +
1.20 +/*
1.21 + * Here is the prototype just in case it is not included
1.22 + * in tclPort.h.
1.23 + */
1.24 +
1.25 +int memcmp _ANSI_ARGS_((CONST VOID *s1,
1.26 + CONST VOID *s2, size_t n));
1.27 +
1.28 +/*
1.29 + *----------------------------------------------------------------------
1.30 + *
1.31 + * memcmp --
1.32 + *
1.33 + * Compares two bytes sequences.
1.34 + *
1.35 + * Results:
1.36 + * compares its arguments, looking at the first n
1.37 + * bytes (each interpreted as an unsigned char), and returns
1.38 + * an integer less than, equal to, or greater than 0, accord-
1.39 + * ing as s1 is less than, equal to, or
1.40 + * greater than s2 when taken to be unsigned 8 bit numbers.
1.41 + *
1.42 + * Side effects:
1.43 + * None.
1.44 + *
1.45 + *----------------------------------------------------------------------
1.46 + */
1.47 +
1.48 +int
1.49 +memcmp(s1, s2, n)
1.50 + CONST VOID *s1; /* First string. */
1.51 + CONST VOID *s2; /* Second string. */
1.52 + size_t n; /* Length to compare. */
1.53 +{
1.54 + CONST unsigned char *ptr1 = (CONST unsigned char *) s1;
1.55 + CONST unsigned char *ptr2 = (CONST unsigned char *) s2;
1.56 +
1.57 + for ( ; n-- ; ptr1++, ptr2++) {
1.58 + unsigned char u1 = *s1, u2 = *s2;
1.59 +
1.60 + if ( u1 != u2) {
1.61 + return (u1-u2);
1.62 + }
1.63 + }
1.64 + return 0;
1.65 +}