File: strcas.c

package info (click to toggle)
uucp 1.06.1-9
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 4,000 kB
  • ctags: 2,994
  • sloc: ansic: 52,080; sh: 3,837; makefile: 634; perl: 199
file content (33 lines) | stat: -rw-r--r-- 523 bytes parent folder | download | duplicates (14)
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
/* strcas.c
   Compare two strings case insensitively.  */

#include "uucp.h"
#include <ctype.h>

int
strcasecmp (z1, z2)
     const char *z1;
     const char *z2;
{
  char b1, b2;

  while ((b1 = *z1++) != '\0')
    {
      b2 = *z2++;
      if (b2 == '\0')
	return 1;
      if (b1 != b2)
	{
	  if (isupper (BUCHAR (b1)))
	    b1 = tolower (BUCHAR (b1));
	  if (isupper (BUCHAR (b2)))
	    b2 = tolower (BUCHAR (b2));
	  if (b1 != b2)
	    return b1 - b2;
	}
    }
  if (*z2 == '\0')
    return 0;
  else
    return -1;
}