summaryrefslogtreecommitdiffstats
path: root/compat/memcmp.c
diff options
context:
space:
mode:
authorstanton <stanton@noemail.net>1999-04-16 00:46:29 (GMT)
committerstanton <stanton@noemail.net>1999-04-16 00:46:29 (GMT)
commit98569293dc21e22480004e4e3f2ce85ec0bfd80f (patch)
treece9959f2747257d98d52ec8d18bf3b0de99b9535 /compat/memcmp.c
parent6a4a1d8213f4de5bce0eaafa8f4d86117022bf1a (diff)
downloadtcl-98569293dc21e22480004e4e3f2ce85ec0bfd80f.zip
tcl-98569293dc21e22480004e4e3f2ce85ec0bfd80f.tar.gz
tcl-98569293dc21e22480004e4e3f2ce85ec0bfd80f.tar.bz2
merged tcl 8.1 branch back into the main trunk
FossilOrigin-Name: f3b32fb71c9011ac220779bd9dbe5617c9dc87d9
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;
+}