File: strcasecmp.c

package info (click to toggle)
mutt 1.5.20-9%2Bsqueeze3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 15,060 kB
  • ctags: 5,313
  • sloc: ansic: 79,584; sh: 4,606; perl: 958; makefile: 720; yacc: 318; awk: 17
file content (40 lines) | stat: -rw-r--r-- 801 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include <ctype.h>
#include <sys/types.h>

/* UnixWare doesn't have these functions in its standard C library */

int strncasecmp (char *s1, char *s2, size_t n)
{
  register int c1, c2, l = 0;
  
  while (*s1 && *s2 && l < n)
  {
    c1 = tolower ((unsigned char) *s1);
    c2 = tolower ((unsigned char) *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 ((unsigned char) *s1);
    c2 = tolower ((unsigned char) *s2);
    if (c1 != c2)
      return (c1 - c2);
    s1++;
    s2++;
  }                                                                           
  return (int) (*s1 - *s2);
}