summaryrefslogtreecommitdiffstats
path: root/tcl8.6/compat/memcmp.c
diff options
context:
space:
mode:
authorWilliam Joye <wjoye@cfa.harvard.edu>2016-10-18 17:31:11 (GMT)
committerWilliam Joye <wjoye@cfa.harvard.edu>2016-10-18 17:31:11 (GMT)
commit066971b1e6e77991d9161bb0216a63ba94ea04f9 (patch)
tree6de02f79b7a4bb08a329581aa67b444fb9001bfd /tcl8.6/compat/memcmp.c
parentba065c2de121da1c1dfddd0aa587d10e7e150f05 (diff)
parent9966985d896629eede849a84f18e406d1164a16c (diff)
downloadblt-066971b1e6e77991d9161bb0216a63ba94ea04f9.zip
blt-066971b1e6e77991d9161bb0216a63ba94ea04f9.tar.gz
blt-066971b1e6e77991d9161bb0216a63ba94ea04f9.tar.bz2
Merge commit '9966985d896629eede849a84f18e406d1164a16c' as 'tcl8.6'
Diffstat (limited to 'tcl8.6/compat/memcmp.c')
-rw-r--r--tcl8.6/compat/memcmp.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/tcl8.6/compat/memcmp.c b/tcl8.6/compat/memcmp.c
new file mode 100644
index 0000000..c4e25a8
--- /dev/null
+++ b/tcl8.6/compat/memcmp.c
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+#include "tclPort.h"
+
+/*
+ * Here is the prototype just in case it is not included in tclPort.h.
+ */
+
+int memcmp(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, according as s1 is less than, equal to, or greater
+ * than s2 when taken to be unsigned 8 bit numbers.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+int
+memcmp(
+ const void *s1, /* First string. */
+ const void *s2, /* Second string. */
+ size_t n) /* Length to compare. */
+{
+ const unsigned char *ptr1 = (const unsigned char *) s1;
+ const unsigned char *ptr2 = (const unsigned char *) s2;
+
+ for ( ; n-- ; ptr1++, ptr2++) {
+ unsigned char u1 = *ptr1, u2 = *ptr2;
+
+ if (u1 != u2) {
+ return (u1-u2);
+ }
+ }
+ return 0;
+}
+
+/*
+ * Local Variables:
+ * mode: c
+ * c-basic-offset: 4
+ * fill-column: 78
+ * End:
+ */