diff options
Diffstat (limited to 'modules/im/ximcp/imLcIm.c')
-rw-r--r-- | modules/im/ximcp/imLcIm.c | 86 |
1 files changed, 56 insertions, 30 deletions
diff --git a/modules/im/ximcp/imLcIm.c b/modules/im/ximcp/imLcIm.c index 8c64cf83..2e622f62 100644 --- a/modules/im/ximcp/imLcIm.c +++ b/modules/im/ximcp/imLcIm.c @@ -32,7 +32,7 @@ THIS SOFTWARE. frankyling@hgrd01.enet.dec.com ******************************************************************/ -/* $XFree86: xc/lib/X11/imLcIm.c,v 1.10 2002/09/21 02:46:04 dawes Exp $ */ +/* $XFree86: xc/lib/X11/imLcIm.c,v 1.12 2003/09/06 14:06:32 pascal Exp $ */ #include <stdio.h> /* @@ -74,8 +74,8 @@ _XimCheckIfLocalProcessing(im) } Private void -XimFreeDefaultTree(top) - DefTree *top; +XimFreeDefaultTree( + DefTree *top) { if (!top) return; if (top->succession) XimFreeDefaultTree(top->succession); @@ -87,8 +87,8 @@ XimFreeDefaultTree(top) } Public void -_XimLocalIMFree(im) - Xim im; +_XimLocalIMFree( + Xim im) { XimFreeDefaultTree(im->private.local.top); if(im->core.im_resources) { @@ -159,8 +159,8 @@ _XimLocalIMFree(im) } Private Status -_XimLocalCloseIM(xim) - XIM xim; +_XimLocalCloseIM( + XIM xim) { Xim im = (Xim)xim; XIC ic; @@ -180,9 +180,9 @@ _XimLocalCloseIM(xim) } Public char * -_XimLocalGetIMValues(xim, values) - XIM xim; - XIMArg *values; +_XimLocalGetIMValues( + XIM xim, + XIMArg *values) { Xim im = (Xim)xim; XimDefIMValues im_values; @@ -193,9 +193,9 @@ _XimLocalGetIMValues(xim, values) } Public char * -_XimLocalSetIMValues(xim, values) - XIM xim; - XIMArg *values; +_XimLocalSetIMValues( + XIM xim, + XIMArg *values) { Xim im = (Xim)xim; XimDefIMValues im_values; @@ -209,20 +209,46 @@ _XimLocalSetIMValues(xim, values) } Private void -_XimCreateDefaultTree(im) - Xim im; +_XimCreateDefaultTree( + Xim im) { - FILE *fp; - char *name; - - name = _XlcFileName(im->core.lcd, COMPOSE_FILE); - if (name == (char *)NULL) - return; - fp = _XFopenFile (name, "r"); - Xfree(name); - if (fp == (FILE *)NULL) - return; - _XimParseStringFile(fp, &im->private.local.top); + FILE *fp = NULL; + char *name, *tmpname = NULL; + + name = getenv("XCOMPOSEFILE"); + + if (name == (char *) NULL) { + char *home = getenv("HOME"); + if (home != (char *) NULL) { + int hl = strlen(home); + tmpname = name = Xmalloc(hl + 10 + 1); + if (name != (char *) NULL) { + strcpy(name, home); + strcpy(name + hl, "/.XCompose"); + fp = _XFopenFile (name, "r"); + if (fp == (FILE *) NULL) { + Xfree(name); + name = tmpname = NULL; + } + } + } + } + + if (name == (char *) NULL) { + tmpname = name = _XlcFileName(im->core.lcd, COMPOSE_FILE); + } + + if (name == (char *) NULL) + return; + if (fp == (FILE *) NULL) { + fp = _XFopenFile (name, "r"); + } + if (tmpname != (char *) NULL) { + Xfree(tmpname); + } + if (fp == (FILE *) NULL) + return; + _XimParseStringFile(fp, im); fclose(fp); } @@ -237,8 +263,8 @@ Private XIMMethodsRec Xim_im_local_methods = { }; Public Bool -_XimLocalOpenIM(im) - Xim im; +_XimLocalOpenIM( + Xim im) { XLCd lcd = im->core.lcd; XlcConv conv; @@ -264,8 +290,6 @@ _XimLocalOpenIM(im) } _XimSetCurrentIMValues(im, &im_values); - _XimCreateDefaultTree(im); - if (!(conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte))) goto Open_Error; private->ctom_conv = conv; @@ -298,6 +322,8 @@ _XimLocalOpenIM(im) goto Open_Error; private->ucstoutf8_conv = conv; + _XimCreateDefaultTree(im); + im->methods = &Xim_im_local_methods; private->current_ic = (XIC)NULL; |