Changed msg_style and msg_delim to be file static to m_getfld.c
[mmh] / sbr / uprf.c
1
2 /*
3  * uprf.c -- "unsigned" lexical prefix
4  *
5  * This code is Copyright (c) 2002, by the authors of nmh.  See the
6  * COPYRIGHT file in the root directory of the nmh distribution for
7  * complete copyright information.
8  */
9
10 #include <h/mh.h>
11
12 #ifndef LOCALE
13 # define TO_LOWER 040
14 # define NO_MASK  000
15 #endif
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 }