driver: don't list specials that was appeared in path
[k8muffin.git] / src / translit.h
blobebb2dca8737b3ef7aa23b49a7bd2610237e6e1eb
1 /* coded by Ketmar // Vampire Avalon (psyc://ketmar.no-ip.org/~Ketmar)
2 * Understanding is not required. Only obedience.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef _TRANSLIT_H_
18 #define _TRANSLIT_H_
21 // free() the result (it will never be NULL)
22 // also converts to lower case
23 extern char *translitstr (const char *src);
26 /****************************************************************************/
27 /* char up/down */
28 /****************************************************************************/
29 /* koi8-u */
30 static inline int le2lower (int ch) {
31 ch &= 0xff;
32 if (ch < 128) {
33 if (ch >= 'A' && ch <= 'Z') ch += 32;
34 } else {
35 if (ch >= 224 && ch <= 255) ch -= 32;
36 else {
37 switch (ch) {
38 case 179: case 180: case 182: case 183: case 189: ch -= 16; break;
42 return ch;
46 static inline int le2upper (int ch) {
47 ch &= 0xff;
48 if (ch < 128) {
49 if (ch >= 'a' && ch <= 'z') ch -= 32;
50 } else {
51 if (ch >= 192 && ch <= 223) ch += 32;
52 else {
53 switch (ch) {
54 case 163: case 164: case 166: case 167: case 173: ch += 16; break;
58 return ch;
62 static inline int leIsAlpha (int ch) {
63 ch &= 0xff;
64 if (ch >= 'A' && ch <= 'Z') return 1;
65 if (ch >= 'a' && ch <= 'z') return 1;
66 if (ch >= 192) return 1;
67 switch (ch) {
68 case 163: case 164: case 166: case 167: case 173:
69 case 179: case 180: case 182: case 183: case 189:
70 return 1;
72 return 0;
77 static inline int leIsDigit (int ch) { return ch >= '0' && ch <= '9'; }
78 static inline int leIsXDigit (int ch) { ch = le2upper(ch); return leIsDigit(ch) || (ch >= 'A' && ch <= 'F'); }
79 static inline int leIsAlNum (int ch) { return leIsDigit(ch) || leIsAlpha(ch); }
80 static inline int leIsUpper (int ch) { return leIsAlpha(ch) && ch == le2upper(ch); }
81 static inline int leIsLower (int ch) { return leIsAlpha(ch) && ch == le2lower(ch); }
82 static inline int leIsSpace (int ch) { return (ch && (ch&0xff) <= 32); }
85 #endif