Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / sbr / uleq.c
1 /* uleq.c - "unsigned" lexical compare */
2 #ifndef lint
3 static char ident[] = "@(#)$Id: uleq.c,v 1.7 1992/12/15 00:20:22 jromine Exp $";
4 #endif  /* lint */
5
6 #define TO_LOWER 040
7 #define NO_MASK  000
8 #include <ctype.h>
9
10 uleq (c1, c2)
11 register char  *c1,
12                *c2;
13 {
14     register int    c,
15                     mask;
16
17     if (!c1)
18         c1 = "";
19     if (!c2)
20         c2 = "";
21
22     while (c = *c1++)
23     {
24 #ifdef LOCALE
25         c &= 0xff;
26         mask = *c2 & 0xff;
27         c = (isalpha(c) && isupper(c)) ? tolower(c) : c;
28         mask = (isalpha(mask) && isupper(mask)) ? tolower(mask) : mask;
29         if (c != mask)
30 #else
31         mask = (isalpha(c) && isalpha(*c2)) ?  TO_LOWER : NO_MASK;
32         if ((c | mask) != (*c2 | mask))
33 #endif
34             return 0;
35         else
36             c2++;
37     }
38     return (*c2 == 0);
39 }