summaryrefslogtreecommitdiffstats
path: root/compat/memcmp.c
diff options
context:
space:
mode:
authorstanton <stanton>1999-04-16 00:46:29 (GMT)
committerstanton <stanton>1999-04-16 00:46:29 (GMT)
commit97464e6cba8eb0008cf2727c15718671992b913f (patch)
treece9959f2747257d98d52ec8d18bf3b0de99b9535 /compat/memcmp.c
parenta8c96ddb94d1483a9de5e340b740cb74ef6cafa7 (diff)
downloadtcl-97464e6cba8eb0008cf2727c15718671992b913f.zip
tcl-97464e6cba8eb0008cf2727c15718671992b913f.tar.gz
tcl-97464e6cba8eb0008cf2727c15718671992b913f.tar.bz2
merged tcl 8.1 branch back into the main trunk
Diffstat (limited to 'compat/memcmp.c')
-rw-r--r--compat/memcmp.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/compat/memcmp.c b/compat/memcmp.c
new file mode 100644
index 0000000..09a5724
--- /dev/null
+++ b/compat/memcmp.c
@@ -0,0 +1,61 @@
+/*
+ * memcmp.c --
+ *
+ * Source code for the "memcmp" library routine.
+ *
+ * Copyright (c) 1998 Sun Microsystems, Inc.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+ *
+ * SCCS: @(#) memcmp.c 1.2 98/01/19 10:48:58
+ */
+
+#include "tcl.h"
+#include "tclPort.h"
+
+/*
+ * Here is the prototype just in case it is not included
+ * in tclPort.h.
+ */
+
+int memcmp _ANSI_ARGS_((CONST VOID *s1,
+ CONST VOID *s2, size_t n));
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * memcmp --
+ *
+ * Compares two bytes sequences.
+ *
+ * Results:
+ * compares its arguments, looking at the first n
+ * bytes (each interpreted as an unsigned char), and returns
+ * an integer less than, equal to, or greater than 0, accord-
+ * ing as s1 is less than, equal to, or
+ * greater than s2 when taken to be unsigned 8 bit numbers.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+memcmp(s1, s2, n)
+ CONST VOID *s1; /* First string. */
+ CONST VOID *s2; /* Second string. */
+ size_t n; /* Length to compare. */
+{
+ unsigned char u1, u2;
+
+ for ( ; n-- ; s1++, s2++) {
+ u1 = * (unsigned char *) s1;
+ u2 = * (unsigned char *) s2;
+ if ( u1 != u2) {
+ return (u1-u2);
+ }
+ }
+ return 0;
+}