Reformated comments and long lines
[mmh] / sbr / uprf.c
1 /*
2 ** uprf.c -- "unsigned" lexical prefix
3 **
4 ** This code is Copyright (c) 2002, by the authors of nmh.  See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
7 */
8
9 #include <h/mh.h>
10
11 #define TO_LOWER 040
12 #define NO_MASK  000
13
14
15 int
16 uprf (char *c1, char *c2)
17 {
18         int c, mask;
19
20         if (!(c1 && c2))
21                 return 0;
22
23         while ((c = *c2++)) {
24 #ifdef LOCALE
25                 c &= 0xff;
26                 mask = *c1 & 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(*c1)) ?  TO_LOWER : NO_MASK;
32                 if ((c | mask) != (*c1 | mask))
33 #endif
34                         return 0;
35                 else
36                         c1++;
37         }
38         return 1;
39 }