]> granicus.if.org Git - neomutt/commitdiff
Fix strncasecmp and strcasecmp replacement functions. Problem noted
authorThomas Roessler <roessler@does-not-exist.org>
Mon, 3 Jan 2000 10:15:35 +0000 (10:15 +0000)
committerThomas Roessler <roessler@does-not-exist.org>
Mon, 3 Jan 2000 10:15:35 +0000 (10:15 +0000)
by Stu Heiss <stu@jpusa1.chi.il.us>.

strcasecmp.c

index 7578d0c7bf36b85447fedd81b9a11b63b6d023d9..d96895ea19dbcaf50071a0b46d1d7c5df9c2bc4a 100644 (file)
@@ -5,33 +5,36 @@
 
 int strncasecmp (char *s1, char *s2, size_t n)
 {
-    register int c1, c2, l = 0;
-
-    while (*s1 && *s2 && l < n)
-    {
-      c1 = tolower (*s1);
-      c2 = tolower (*s2);
-      if (c1 != c2)
-       return (c1 - c2);
-      s1++;
-      s2++;
-      l++;
-    }
+  register int c1, c2, l = 0;
+  
+  while (*s1 && *s2 && l < n)
+  {
+    c1 = tolower (*s1);
+    c2 = tolower (*s2);
+    if (c1 != c2)
+      return (c1 - c2);
+    s1++;
+    s2++;
+    l++;
+  }
+  if (l == n)
     return (int) (0);
+  else
+    return (int) (*s1 - *s2);
 }
 
 int strcasecmp (char *s1, char *s2)
 {
-    register int c1, c2;
-
-    while (*s1 && *s2)
-    {
-      c1 = tolower (*s1);
-      c2 = tolower (*s2);
-      if (c1 != c2)
-       return (c1 - c2);
-      s1++;
-      s2++;
-    }                                                                           
-    return (int) (*s1 - *s2);
+  register int c1, c2;
+  
+  while (*s1 && *s2)
+  {
+    c1 = tolower (*s1);
+    c2 = tolower (*s2);
+    if (c1 != c2)
+      return (c1 - c2);
+    s1++;
+    s2++;
+  }                                                                           
+  return (int) (*s1 - *s2);
 }