Lines 136-146
Link Here
|
136 |
int nmissing, pixel_size = 0, buf_size = 0; |
136 |
int nmissing, pixel_size = 0, buf_size = 0; |
137 |
char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE]; |
137 |
char weight[FONT_ELEMENT_SIZE], slant[FONT_ELEMENT_SIZE]; |
138 |
char * orig_locale = ""; |
138 |
char * orig_locale = ""; |
|
|
139 |
char orig_storage[128] = { 0 }; |
139 |
|
140 |
|
140 |
#ifdef HAVE_SETLOCALE |
141 |
#ifdef HAVE_SETLOCALE |
141 |
if (utf8mode) { |
142 |
if (utf8mode) { |
142 |
orig_locale = setlocale(LC_CTYPE, NULL); |
143 |
orig_locale = setlocale(LC_CTYPE, NULL); |
143 |
setlocale(LC_CTYPE, "UTF-8"); |
144 |
setlocale(LC_CTYPE, "UTF-8"); |
|
|
145 |
memcpy(orig_storage, orig_locale, |
146 |
strlen(orig_locale) > 127 ? 127 : strlen(orig_locale)); |
147 |
orig_locale = orig_storage; |
148 |
/* |
149 |
* man setlocale says, that returned string |
150 |
* is pointer to a static storage. So --- simply keep a copy |
151 |
* of original string between further calls to setlocale. |
152 |
* |
153 |
* It appears, that area, being pointed to by orig_locale (got |
154 |
* from 1st call to setlocale) is changed after subsequent call, |
155 |
* thus string in orig_locale is invalid, causing |
156 |
* setlocale(LC_CTYPE, orig_locale) |
157 |
* to fallback to "C" locale. And this causes invalid FontSet to |
158 |
* be returned => wrong window titles ;) |
159 |
*/ |
144 |
} |
160 |
} |
145 |
#endif // HAVE_SETLOCALE |
161 |
#endif // HAVE_SETLOCALE |
146 |
fs = XCreateFontSet(display, |
162 |
fs = XCreateFontSet(display, |