Add/update copyright notice in all source code files.
[mmh] / sbr / uprf.c
1
2 /*
3  * uprf.c -- "unsigned" lexical prefix
4  *
5  * $Id$
6  *
7  * This code is Copyright (c) 2002, by the authors of nmh.  See the
8  * COPYRIGHT file in the root directory of the nmh distribution for
9  * complete copyright information.
10  */
11
12 #include <h/mh.h>
13
14 #define TO_LOWER 040
15 #define NO_MASK  000
16
17
18 int
19 uprf (char *c1, char *c2)
20 {
21     int c, mask;
22
23     if (!(c1 && c2))
24         return 0;
25
26     while ((c = *c2++))
27     {
28 #ifdef LOCALE
29         c &= 0xff;
30         mask = *c1 & 0xff;
31         c = (isalpha(c) && isupper(c)) ? tolower(c) : c;
32         mask = (isalpha(mask) && isupper(mask)) ? tolower(mask) : mask;
33         if (c != mask)
34 #else
35         mask = (isalpha(c) && isalpha(*c1)) ?  TO_LOWER : NO_MASK;
36         if ((c | mask) != (*c1 | mask))
37 #endif
38             return 0;
39         else
40             c1++;
41     }
42     return 1;
43 }