New implementation of long variable names. Each variable has a
[pspp-builds.git] / src / str.c
index 089ace32e26a400945762df8c6a3cc80bd8e5daf..0ad0e2f5899647d7b923afd1fe59e9d7f8ec6bef 100644 (file)
--- a/src/str.c
+++ b/src/str.c
@@ -95,7 +95,7 @@ mm_reverse (void *p, size_t nbytes)
    HAYSTACK_LEN.  Returns a pointer to the needle found. */
 char *
 mm_find_reverse (const char *haystack, size_t haystack_len,
-        const char *needle, size_t needle_len)
+                 const char *needle, size_t needle_len)
 {
   int i;
   for (i = haystack_len - needle_len; i >= 0; i--)
@@ -104,6 +104,26 @@ mm_find_reverse (const char *haystack, size_t haystack_len,
   return 0;
 }
 
+/* Compares the SIZE bytes in A to those in B, disregarding case,
+   and returns a strcmp()-type result. */
+int
+mm_case_compare (const void *a_, const void *b_, size_t size)
+{
+  const unsigned char *a = a_;
+  const unsigned char *b = b_;
+
+  while (size-- > 0) 
+    {
+      unsigned char ac = toupper (*a++);
+      unsigned char bc = toupper (*b++);
+
+      if (ac != bc) 
+        return ac > bc ? 1 : -1;
+    }
+
+  return 0;
+}
+
 /* Compares A of length A_LEN to B of length B_LEN.  The shorter
    string is considered to be padded with spaces to the length of
    the longer. */