Remove MERGE_ALT_FORM merge mode
[platform/upstream/libxkbcommon.git] / src / misc.c
1 /************************************************************
2 Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
3
4 Permission to use, copy, modify, and distribute this
5 software and its documentation for any purpose and without
6 fee is hereby granted, provided that the above copyright
7 notice appear in all copies and that both that copyright
8 notice and this permission notice appear in supporting
9 documentation, and that the name of Silicon Graphics not be
10 used in advertising or publicity pertaining to distribution
11 of the software without specific prior written permission.
12 Silicon Graphics makes no representation about the suitability
13 of this software for any purpose. It is provided "as is"
14 without any express or implied warranty.
15
16 SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17 SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19 GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21 DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22 OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
23 THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
25 ********************************************************/
26
27 #include "xkb-priv.h"
28 #include "alloc.h"
29
30 unsigned
31 _XkbcKSCheckCase(xkb_keysym_t ks)
32 {
33     unsigned set = (ks & (~0xff)) >> 8;
34     unsigned rtrn = 0;
35
36     switch (set) {
37     case 0: /* latin 1 */
38         if ((ks >= XKB_KEY_A && ks <= XKB_KEY_Z) ||
39             (ks >= XKB_KEY_Agrave && ks <= XKB_KEY_THORN && ks != XKB_KEY_multiply))
40             rtrn |= _XkbKSUpper;
41         if ((ks >= XKB_KEY_a && ks <= XKB_KEY_z) ||
42             (ks >= XKB_KEY_agrave && ks <= XKB_KEY_ydiaeresis))
43             rtrn |= _XkbKSLower;
44         break;
45     case 1: /* latin 2 */
46         if ((ks >= XKB_KEY_Aogonek && ks <= XKB_KEY_Zabovedot && ks != XKB_KEY_breve) ||
47             (ks >= XKB_KEY_Racute && ks<=XKB_KEY_Tcedilla))
48             rtrn |= _XkbKSUpper;
49         if ((ks >= XKB_KEY_aogonek && ks <= XKB_KEY_zabovedot && ks != XKB_KEY_caron) ||
50             (ks >= XKB_KEY_racute && ks <= XKB_KEY_tcedilla))
51             rtrn |= _XkbKSLower;
52         break;
53     case 2: /* latin 3 */
54         if ((ks >= XKB_KEY_Hstroke && ks <= XKB_KEY_Jcircumflex) ||
55             (ks >= XKB_KEY_Cabovedot && ks <= XKB_KEY_Scircumflex))
56             rtrn |= _XkbKSUpper;
57         if ((ks >= XKB_KEY_hstroke && ks <= XKB_KEY_jcircumflex) ||
58             (ks >= XKB_KEY_cabovedot && ks <= XKB_KEY_scircumflex))
59             rtrn |= _XkbKSLower;
60         break;
61     case 3: /* latin 4 */
62         if ((ks >= XKB_KEY_Rcedilla && ks <= XKB_KEY_Tslash) ||
63             (ks == XKB_KEY_ENG) ||
64             (ks >= XKB_KEY_Amacron && ks <= XKB_KEY_Umacron))
65             rtrn |= _XkbKSUpper;
66         if ((ks >= XKB_KEY_rcedilla && ks <= XKB_KEY_tslash) ||
67             (ks == XKB_KEY_eng) ||
68             (ks >= XKB_KEY_amacron && ks <= XKB_KEY_umacron))
69             rtrn |= _XkbKSLower;
70         break;
71     case 6: /* Cyrillic */
72         if ((ks >= XKB_KEY_Serbian_DJE && ks <= XKB_KEY_Serbian_DZE) ||
73             (ks >= XKB_KEY_Cyrillic_YU && ks <= XKB_KEY_Cyrillic_HARDSIGN))
74             rtrn |= _XkbKSUpper;
75         if ((ks >= XKB_KEY_Serbian_dje && ks <= XKB_KEY_Serbian_dze) ||
76             (ks >= XKB_KEY_Cyrillic_yu && ks <= XKB_KEY_Cyrillic_hardsign))
77             rtrn |= _XkbKSLower;
78         break;
79     case 7: /* Greek */
80         if ((ks >= XKB_KEY_Greek_ALPHAaccent &&
81              ks <= XKB_KEY_Greek_OMEGAaccent) ||
82             (ks >= XKB_KEY_Greek_ALPHA && ks <= XKB_KEY_Greek_OMEGA))
83             rtrn |= _XkbKSUpper;
84         if ((ks >= XKB_KEY_Greek_alphaaccent &&
85              ks <= XKB_KEY_Greek_omegaaccent) ||
86             (ks >= XKB_KEY_Greek_alpha && ks <= XKB_KEY_Greek_OMEGA))
87             rtrn |= _XkbKSLower;
88         break;
89     case 18: /* latin 8 */
90         if ((ks == XKB_KEY_Wcircumflex) ||
91             (ks == XKB_KEY_Ycircumflex) ||
92             (ks == XKB_KEY_Babovedot) ||
93             (ks == XKB_KEY_Dabovedot) ||
94             (ks == XKB_KEY_Fabovedot) ||
95             (ks == XKB_KEY_Mabovedot) ||
96             (ks == XKB_KEY_Pabovedot) ||
97             (ks == XKB_KEY_Sabovedot) ||
98             (ks == XKB_KEY_Tabovedot) ||
99             (ks == XKB_KEY_Wdiaeresis) ||
100             (ks == XKB_KEY_Ygrave))
101             rtrn |= _XkbKSUpper;
102         if ((ks == XKB_KEY_wcircumflex) ||
103             (ks == XKB_KEY_ycircumflex) ||
104             (ks == XKB_KEY_babovedot) ||
105             (ks == XKB_KEY_dabovedot) ||
106             (ks == XKB_KEY_fabovedot) ||
107             (ks == XKB_KEY_mabovedot) ||
108             (ks == XKB_KEY_pabovedot) ||
109             (ks == XKB_KEY_sabovedot) ||
110             (ks == XKB_KEY_tabovedot) ||
111             (ks == XKB_KEY_wdiaeresis) ||
112             (ks == XKB_KEY_ygrave))
113             rtrn |= _XkbKSLower;
114         break;
115     case 19: /* latin 9 */
116         if (ks == XKB_KEY_OE || ks == XKB_KEY_Ydiaeresis)
117             rtrn |= _XkbKSUpper;
118         if (ks == XKB_KEY_oe)
119             rtrn |= _XkbKSLower;
120         break;
121     }
122
123     return rtrn;
124 }