Files
ports/chinese/chinput3/files/patch-src_Chinput-3.0.2_src_init.c
T
Rong-En Fan 40cf78ae6a - Use correct locale zh_CN.GB2312 instead of invalid locale zh_CN.EUC
- Bump PORTREVISION

PR:		ports/122091
Submitted by:	Yuri <yuri at tsoft.com>
2008-04-06 11:58:29 +00:00

33 lines
1.1 KiB
C

--- src/Chinput-3.0.2/src/init.c.orig 2008-03-25 11:18:01.000000000 -0700
+++ src/Chinput-3.0.2/src/init.c 2008-03-25 12:23:41.000000000 -0700
@@ -94,6 +94,13 @@
load_font(&font_info, font_latin);
}
+static int is_locale_supported(char *locale) {
+ char *setlocale_string = setlocale(LC_ALL, locale);
+ int success = (setlocale_string != NULL && strcmp(setlocale_string, locale)==0 && XSupportsLocale());
+ if (!success && locale[0] != 0 && setlocale_string != NULL && setlocale_string[0] != 0) {
+ fprintf(stderr, "Error : requested locale '%s' not supported\n");
+ }
+}
void HZinitServerGC(void)
{
@@ -103,12 +110,9 @@
char fontname[256];
//create font set
- if(strcmp(setlocale(LC_ALL, gb18030locale), gb18030locale) ||
- !XSupportsLocale()){
- if(strcmp(setlocale(LC_ALL, gbklocale), gbklocale) ||
- !XSupportsLocale()){
- if(strcmp(setlocale(LC_ALL, gblocale), gblocale) ||
- !XSupportsLocale()){
+ if(!is_locale_supported(gb18030locale)){
+ if(!is_locale_supported(gbklocale)){
+ if(!is_locale_supported(gblocale)){
fprintf(stderr, "Error : Chinese Locale not supported!\n");
exit(1);
}