gtk+3: fix dependencies for new gnome/accessibility/at-spi2-core
[oi-userland.git] / components / x11 / libX11 / patches / 12.im-ximcp.patch
bloba14a6885d553cf3196f2e285d27e20f039a72c3d
1 ###############################################################################
2 # Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
4 # Permission is hereby granted, free of charge, to any person obtaining a
5 # copy of this software and associated documentation files (the "Software"),
6 # to deal in the Software without restriction, including without limitation
7 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 # and/or sell copies of the Software, and to permit persons to whom the
9 # Software is furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice (including the next
12 # paragraph) shall be included in all copies or substantial portions of the
13 # Software.
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 # DEALINGS IN THE SOFTWARE.
24 diff --git a/modules/im/ximcp/imImSw.c b/modules/im/ximcp/imImSw.c
25 index 28b1725..327736e 100644
26 --- a/modules/im/ximcp/imImSw.c
27 +++ b/modules/im/ximcp/imImSw.c
28 @@ -48,7 +48,9 @@ _XimCheckIfDefault(
31 XimImsportSW _XimImSportRec[] = {
32 +#ifdef USE_R6_LOCALIM
33 { _XimCheckIfLocalProcessing, _XimLocalOpenIM, _XimLocalIMFree },
34 +#endif
35 { _XimCheckIfThaiProcessing, _XimThaiOpenIM, _XimThaiIMFree },
36 { _XimCheckIfDefault, _XimProtoOpenIM, _XimProtoIMFree },
37 { NULL, NULL, NULL },
38 diff --git a/modules/im/ximcp/imThaiFlt.c b/modules/im/ximcp/imThaiFlt.c
39 index f134e84..898fc1f 100644
40 --- libX11-1.6.2/modules/im/ximcp/imThaiFlt.c.~1~ 2013-09-09 05:37:20.000000000 +0400
41 +++ libX11-1.6.2/modules/im/ximcp/imThaiFlt.c 2015-02-04 12:03:13.672449821 +0300
42 @@ -76,6 +76,12 @@
43 #include "XimThai.h"
44 #include "XlcPubI.h"
46 +#ifdef sun
47 +# include "XlcGeneric.h"
48 +# if !defined(X_LOCALE)
49 +# define STDCVT
50 +# endif
51 +#endif
53 #define SPACE 32
55 @@ -516,6 +522,48 @@
56 (wchar_t)(c) : \
57 ((0x0A1<=(c)) ? ((wchar_t)(c)-0xA0+0x0E00) : 0))
59 +#ifdef sun
60 +static int
61 +wc2tis(XLCd lcd, unsigned char* ch, wchar_t wc)
63 +#ifdef STDCVT
64 + if (XLC_GENERIC(lcd, use_stdc_env) == True)
65 + return wctomb((char*)ch, wc);
66 + else
67 +#endif
68 + {
69 + wchar_t wc_mask = (1<<XLC_GENERIC(lcd, wc_shift_bits))-1;
70 + ( 0<=wc && wc<=0x7F ) ? (*ch=(unsigned char)wc) : (*ch= (unsigned char)(wc&wc_mask|0x80));//GR 0x80
71 + }
72 + return 1;
76 +static int
77 +tis2wc(XLCd lcd, wchar_t *pwc, unsigned char* ch)
79 +#ifdef STDCVT
80 + if (XLC_GENERIC(lcd, use_stdc_env) == True)
81 + return mbtowc(pwc, (char*)ch, 1);
82 + else
83 +#endif
84 + {
85 + wchar_t wc_mask = (1<<XLC_GENERIC(lcd, wc_shift_bits))-1;
86 + CodeSet GR_codeset = XLC_GENERIC(lcd, initial_state_GR);
87 + if ( 0<=*ch && *ch<=0x7F ) {
88 + *pwc=(wchar_t)*ch;
89 + return 0;
90 + } else {
91 + if (0xA1<=*ch) {
92 + *pwc = (wchar_t)*ch&wc_mask|GR_codeset->wc_encoding;
93 + return 1;
94 + } else
95 + return 0;
96 + }
97 + }
99 +#endif
102 * Macros to save and recall last input character in XIC
104 @@ -1210,6 +1258,42 @@
105 return;
108 +#ifdef sun
109 +static Bool
110 +is_utf8_locale(void)
112 + const char* locale;
113 + locale = getenv("LC_ALL");
114 + if (!locale || !*locale) {
115 + locale = getenv("LC_CTYPE");
116 + if (!locale || !*locale) {
117 + locale = getenv("LANG");
120 + if (locale && *locale) {
121 + /* The most general syntax of a locale:
122 + language[_territory][.codeset][@modifier]
123 + To retrieve the codeset, search the first dot. Stop searching when
124 + a '@' is encountered. */
125 + const char* cp = locale;
126 + for (; *cp != '\0' && *cp != '@'; cp++) {
127 + if (*cp == '.') {
128 + const char* encoding = ++cp;
129 + for (; *cp != '\0' && *cp != '@'; cp++);
130 + /* Check it for "UTF-8", which is the only official IANA name of
131 + UTF-8. Also check for the lowercase-no-dashes version, which is
132 + what some SystemV systems use. */
133 + if ((cp-encoding == 5 && !strncmp(encoding, "UTF-8", 5))
134 + || (cp-encoding == 4 && !strncmp(encoding, "utf8", 4)))
135 + return True; /* it's UTF-8 */
136 + break; /* not UTF-8 */
140 + return False;
142 +#endif
145 * Helper functions for _XimThaiFilter()
147 @@ -1217,8 +1301,20 @@
148 ThaiFltAcceptInput(Xic ic, unsigned char new_char, KeySym symbol)
150 DefTreeBase *b = &ic->private.local.base;
151 +#ifdef sun
152 + if (is_utf8_locale()) {
153 + b->wc[b->tree[ic->private.local.composed].wc+0] = tis2ucs(new_char);
154 + b->wc[b->tree[ic->private.local.composed].wc+1] = '\0';
155 + } else {
156 + wchar_t *wcTmp = NULL;
157 + wcTmp = &(b->wc[b->tree[ic->private.local.composed].wc+0]);
158 + tis2wc(ic->core.im->core.lcd, wcTmp, &new_char);
159 + *(wcTmp+1) = '\0';
161 +#else
162 b->wc[b->tree[ic->private.local.composed].wc+0] = tis2ucs(new_char);
163 b->wc[b->tree[ic->private.local.composed].wc+1] = '\0';
164 +#endif
166 if ((new_char <= 0x1f) || (new_char == 0x7f))
167 b->tree[ic->private.local.composed].keysym = symbol;
168 @@ -1233,9 +1329,23 @@
170 DefTreeBase *b = &ic->private.local.base;
171 if (!IC_DeletePreviousChar(ic)) return False;
172 +#ifdef sun
173 + if (is_utf8_locale()) {
174 + b->wc[b->tree[ic->private.local.composed].wc+0] = tis2ucs(new_char);
175 + b->wc[b->tree[ic->private.local.composed].wc+1] = tis2ucs(previous_char);
176 + b->wc[b->tree[ic->private.local.composed].wc+2] = '\0';
177 + } else {
178 + wchar_t *wcTmp = NULL;
179 + wcTmp = &(b->wc[b->tree[ic->private.local.composed].wc+0]);
180 + tis2wc(ic->core.im->core.lcd, wcTmp, &new_char);
181 + tis2wc(ic->core.im->core.lcd, (wcTmp+1), &previous_char);
182 + *(wcTmp+2) = '\0';
184 +#else
185 b->wc[b->tree[ic->private.local.composed].wc+0] = tis2ucs(new_char);
186 b->wc[b->tree[ic->private.local.composed].wc+1] = tis2ucs(previous_char);
187 b->wc[b->tree[ic->private.local.composed].wc+2] = '\0';
188 +#endif
190 b->tree[ic->private.local.composed].keysym = NoSymbol;
192 @@ -1247,8 +1357,20 @@
194 DefTreeBase *b = &ic->private.local.base;
195 if (!IC_DeletePreviousChar(ic)) return False;
196 +#ifdef sun
197 + if (is_utf8_locale()) {
198 + b->wc[b->tree[ic->private.local.composed].wc+0] = tis2ucs(new_char);
199 + b->wc[b->tree[ic->private.local.composed].wc+1] = '\0';
200 + } else {
201 + wchar_t *wcTmp = NULL;
202 + wcTmp = &(b->wc[b->tree[ic->private.local.composed].wc+0]);
203 + tis2wc(ic->core.im->core.lcd, wcTmp, &new_char);
204 + *(wcTmp+1) = '\0';
206 +#else
207 b->wc[b->tree[ic->private.local.composed].wc+0] = tis2ucs(new_char);
208 b->wc[b->tree[ic->private.local.composed].wc+1] = '\0';
209 +#endif
211 if ((new_char <= 0x1f) || (new_char == 0x7f))
212 b->tree[ic->private.local.composed].keysym = symbol;
213 @@ -1374,7 +1496,15 @@
215 isc_mode = IC_IscMode(ic);
216 if (!(previous_char = IC_GetPreviousChar(ic))) previous_char = ' ';
217 +#ifdef sun
218 + if (is_utf8_locale()) {
219 + new_char = ucs2tis(wbuf[0]);
220 + } else {
221 + wc2tis(ic->core.im->core.lcd, &new_char, wbuf[0]);
223 +#else
224 new_char = ucs2tis(wbuf[0]);
225 +#endif
226 isReject = True;
227 if (THAI_isaccepted(new_char, previous_char, isc_mode)) {
228 ThaiFltAcceptInput(ic, new_char, symbol);