Commit 1baa27d0 authored by Ulrich Sibiller's avatar Ulrich Sibiller

update files from modules dir of libX11 1.3.4

parent da3e7fd2
/*
* Copyright 1991, 1992 Sun Microsystems, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/******************************************************************
Copyright 1991, 1992 by Sun Microsystems, Inc.
Copyright 1992, 1993, 1994 by FUJITSU LIMITED
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear
in supporting documentation, and that the name of Sun Microsystems, Inc.
and FUJITSU LIMITED not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.
Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
the suitability of this software for any purpose.
in supporting documentation, and that the name of FUJITSU LIMITED
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
FUJITSU LIMITED makes no representations about the suitability of
this software for any purpose.
It is provided "as is" without express or implied warranty.
Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
Takashi Fujiwara FUJITSU LIMITED
......@@ -947,6 +968,8 @@ _XimProtoSetFocus(
(void)_XimWrite(im, len, (XPointer)buf);
_XimFlush(im);
MARK_FOCUSED(ic);
_XimRegisterFilter(ic);
return;
}
......@@ -992,6 +1015,8 @@ _XimProtoUnsetFocus(
(void)_XimWrite(im, len, (XPointer)buf);
_XimFlush(im);
UNMARK_FOCUSED(ic);
_XimUnregisterFilter(ic);
return;
}
......
/*
* Copyright 1990, 1991, 1992 Sun Microsystems, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/******************************************************************
Copyright 1990, 1991, 1992 by Sun Microsystems, Inc.
Copyright 1992, 1993, 1994 by FUJITSU LIMITED
Copyright 1993, 1994 by Sony Corporation
Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting documentation, and
that the name of Sun Microsystems, Inc., FUJITSU LIMITED and Sony
Corporation not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.
Sun Microsystems, Inc., FUJITSU LIMITED and Sony Corporation makes no
representations about the suitability of this software for any purpose. It
is provided "as is" without express or implied warranty.
Sun Microsystems Inc., FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc.,
FUJITSU LIMITED AND SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
OF THIS SOFTWARE.
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in
supporting documentation, and that the names of Digital, FUJITSU
LIMITED and Sony Corporation not be used in advertising or publicity
pertaining to distribution of the software without specific, written
prior permission.
DIGITAL, FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL, FUJITSU LIMITED
AND SONY CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
Takashi Fujiwara FUJITSU LIMITED
......@@ -73,7 +93,7 @@ _XimSetHeader(
return;
}
Private char
Public char
_XimGetMyEndian(void)
{
CARD16 test_card = 1;
......@@ -166,7 +186,7 @@ Private Bool
_XimCheckTransport(
char *address,
int address_len,
char *transport,
const char *transport,
int len,
char **trans_addr)
{
......
......@@ -213,8 +213,13 @@ _XimRespSyncReply(
Xic ic,
BITMASK16 mode)
{
if (mode & XimSYNCHRONUS) /* SYNC Request */
if (mode & XimSYNCHRONUS) /* SYNC Request */ {
if (IS_FOCUSED(ic))
MARK_NEED_SYNC_REPLY(ic);
else
_XimProcSyncReply((Xim)ic->core.im, ic);
}
return True;
}
......@@ -463,7 +468,7 @@ _XimGetWindowEventmask(
Xim im = (Xim )ic->core.im;
XWindowAttributes atr;
if (!_XGetWindowAttributes(im->core.display, ic->core.focus_window, &atr))
if (!XGetWindowAttributes(im->core.display, ic->core.focus_window, &atr))
return 0;
return (EVENTMASK)atr.your_event_mask;
}
......@@ -885,13 +890,8 @@ _Ximctsconvert(
}
Public int
_Ximctstombs(xim, from, from_len, to, to_len, state)
XIM xim;
char *from;
int from_len;
char *to;
int to_len;
Status *state;
_Ximctstombs(XIM xim, char *from, int from_len,
char *to, int to_len, Status *state)
{
return _Ximctsconvert(((Xim)xim)->private.proto.ctom_conv,
from, from_len, to, to_len, state);
......
......@@ -61,8 +61,7 @@ _XimRegProtoIntrCallback(
}
Public void
_XimFreeProtoIntrCallback(im)
Xim im;
_XimFreeProtoIntrCallback(Xim im)
{
register XimProtoIntrRec *rec, *next;
......@@ -97,8 +96,7 @@ _XimTransportIntr(
}
Public Bool
_XimDispatchInit(im)
Xim im;
_XimDispatchInit(Xim im)
{
if (_XimRegisterDispatcher(im, _XimTransportIntr, (XPointer)im))
return True;
......
......@@ -48,7 +48,7 @@ PERFORMANCE OF THIS SOFTWARE.
typedef struct _XIM_QueryExtRec {
Bool is_support;
char *name;
const char *name;
int name_len;
CARD16 major_opcode;
CARD16 minor_opcode;
......
......@@ -108,7 +108,7 @@ _XimFilterPropertyNotify(
}
lock = True;
for( ii = 0; ii < nitems; ii++ ) {
for( ii = 0; ii < nitems; ii++, atoms ) {
if(XGetSelectionOwner (display, atoms[ii])) {
for( icb = callback_list; icb; icb = icb->next ) {
if( !icb->call && !icb->destroy ) {
......@@ -268,8 +268,7 @@ _XimUnRegisterIMInstantiateCallback(
Public void
_XimResetIMInstantiateCallback( xim )
Xim xim;
_XimResetIMInstantiateCallback(Xim xim)
{
char locale[XIM_MAXLCNAMELEN];
XimInstCallback icb;
......
......@@ -73,8 +73,7 @@ _XimSetIMStructureList(
}
Public void
_XimDestroyIMStructureList(im)
Xim im;
_XimDestroyIMStructureList(Xim im)
{
register int i;
......@@ -88,8 +87,7 @@ _XimDestroyIMStructureList(im)
}
Public void
_XimServerDestroy(im_2_destroy)
Xim im_2_destroy;
_XimServerDestroy(Xim im_2_destroy)
{
register int i;
Xim im;
......@@ -123,7 +121,7 @@ _XimServerDestroy(im_2_destroy)
#ifdef XIM_CONNECTABLE
Public void
_XimServerReconectableDestroy()
_XimServerReconectableDestroy(void)
{
register int i;
Xim im;
......@@ -149,10 +147,10 @@ _XimServerReconectableDestroy()
}
#endif /* XIM_CONNECTABLE */
Private char *
Private const char *
_XimStrstr(
register char *src,
register char *dest)
register const char *src,
register const char *dest)
{
int len;
......@@ -169,10 +167,10 @@ Private char *
_XimMakeImName(
XLCd lcd)
{
char* begin = NULL;
char* end = NULL;
const char* begin = NULL;
const char* end = NULL;
char* ret = NULL;
char* ximmodifier = XIMMODIFIER;
const char* ximmodifier = XIMMODIFIER;
if(lcd->core->modifiers != NULL && *lcd->core->modifiers != '\0') {
begin = _XimStrstr(lcd->core->modifiers, ximmodifier);
......@@ -257,8 +255,7 @@ Error1:
}
Public Bool
_XInitIM(lcd)
XLCd lcd;
_XInitIM(XLCd lcd)
{
if(lcd == (XLCd)NULL)
return False;
......
......@@ -38,43 +38,67 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Ximint.h"
Bool
_XimLocalFilter(d, w, ev, client_data)
Display *d;
Window w;
XEvent *ev;
XPointer client_data;
_XimLocalFilter(Display *d, Window w, XEvent *ev, XPointer client_data)
{
Xic ic = (Xic)client_data;
KeySym keysym;
static char buf[256];
DefTree *p;
DefTree *b = ic->private.local.base.tree;
DTIndex t;
if( (ev->type != KeyPress)
|| (ev->xkey.keycode == 0)
|| (((Xim)ic->core.im)->private.local.top == (DefTree *)NULL) )
return(False);
if(ev->xkey.keycode == 0)
return (False);
XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL);
if(IsModifierKey(keysym))
return (False);
for(p = ic->private.local.context; p; p = p->next) {
if(((ev->xkey.state & p->modifier_mask) == p->modifier) &&
(keysym == p->keysym)) {
break;
if(keysym >= XK_braille_dot_1 && keysym <= XK_braille_dot_8) {
if(ev->type == KeyPress) {
ic->private.local.brl_pressed |=
1<<(keysym-XK_braille_dot_1);
} else {
if(!ic->private.local.brl_committing
|| ev->xkey.time - ic->private.local.brl_release_start > 300) {
ic->private.local.brl_committing = ic->private.local.brl_pressed;
ic->private.local.brl_release_start = ev->xkey.time;
}
ic->private.local.brl_pressed &= ~(1<<(keysym-XK_braille_dot_1));
if(!ic->private.local.brl_pressed) {
if(ic->private.local.brl_committing) {
ic->private.local.brl_committed =
ic->private.local.brl_committing;
ic->private.local.composed = 0;
ev->type = KeyPress;
ev->xkey.keycode = 0;
_XPutBackEvent(d, ev);
}
}
}
return(True);
}
if( (ev->type != KeyPress)
|| (((Xim)ic->core.im)->private.local.top == 0 ) )
return(False);
if(p) { /* Matched */
if(p->succession) { /* Intermediate */
ic->private.local.context = p->succession;
for(t = ic->private.local.context; t; t = b[t].next) {
if(((ev->xkey.state & b[t].modifier_mask) == b[t].modifier) &&
(keysym == b[t].keysym))
break;
}
if(t) { /* Matched */
if(b[t].succession) { /* Intermediate */
ic->private.local.context = b[t].succession;
return(True);
} else { /* Terminate (reached to leaf) */
ic->private.local.composed = p;
ic->private.local.composed = t;
ic->private.local.brl_committed = 0;
/* return back to client KeyPressEvent keycode == 0 */
ev->xkey.keycode = 0;
_XPutBackEvent(d, ev);
XPutBackEvent(d, ev);
/* initialize internal state for next key sequence */
ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
return(True);
......
......@@ -34,9 +34,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Ximint.h"
Public char *
_XimLocalGetICValues(xic, values)
XIC xic;
XIMArg *values;
_XimLocalGetICValues(XIC xic, XIMArg *values)
{
Xic ic = (Xic)xic;
XimDefICValues ic_values;
......
......@@ -85,7 +85,7 @@ _XimLocalSetFocus(
if (ic->core.focus_window)
_XRegisterFilterByType(ic->core.im->core.display,
ic->core.focus_window, KeyPress, KeyPress,
ic->core.focus_window, KeyPress, KeyRelease,
_XimLocalFilter, (XPointer)ic);
return;
}
......@@ -95,8 +95,11 @@ _XimLocalReset(
XIC xic)
{
Xic ic = (Xic)xic;
ic->private.local.composed = (DefTree *)NULL;
ic->private.local.composed = 0;
ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
ic->private.local.brl_pressed = 0;
ic->private.local.brl_committing = 0;
ic->private.local.brl_committed = 0;
}
Private char *
......@@ -147,8 +150,12 @@ _XimLocalCreateIC(
ic->methods = &Local_ic_methods;
ic->core.im = im;
ic->private.local.base = ((Xim)im)->private.local.base;
ic->private.local.context = ((Xim)im)->private.local.top;
ic->private.local.composed = (DefTree *)NULL;
ic->private.local.composed = 0;
ic->private.local.brl_pressed = 0;
ic->private.local.brl_committing = 0;
ic->private.local.brl_committed = 0;
num = im->core.ic_num_resources;
len = sizeof(XIMResource) * num;
......
......@@ -48,10 +48,55 @@ THIS SOFTWARE.
#include "XlcPubI.h"
#include "Ximint.h"
#include <ctype.h>
#include <assert.h>
#ifdef COMPOSECACHE
# include <sys/types.h>
# include <sys/stat.h>
# include <sys/mman.h>
# include <langinfo.h>
#endif
#ifdef COMPOSECACHE
/* include trailing '/' for cache directory, file prefix otherwise */
#define XIM_GLOBAL_CACHE_DIR "/var/cache/libx11/compose/"
#define XIM_HOME_CACHE_DIR "/.compose-cache/"
#define XIM_CACHE_MAGIC ('X' | 'i'<<8 | 'm'<<16 | 'C'<<24)
#define XIM_CACHE_VERSION 4
#define XIM_CACHE_TREE_ALIGNMENT 4
#define XIM_HASH_PRIME_1 13
#define XIM_HASH_PRIME_2 1234096939
typedef INT32 DTStructIndex;
struct _XimCacheStruct {
INT32 id;
INT32 version;
DTStructIndex tree;
DTStructIndex mb;
DTStructIndex wc;
DTStructIndex utf8;
DTStructIndex size;
DTIndex top;
DTIndex treeused;
DTCharIndex mbused;
DTCharIndex wcused;
DTCharIndex utf8used;
char fname[1];
/* char encoding[1] */
};
Private struct _XimCacheStruct* _XimCache_mmap = NULL;
Private DefTreeBase _XimCachedDefaultTreeBase;
Private int _XimCachedDefaultTreeRefcount = 0;
#endif
Public Bool
_XimCheckIfLocalProcessing(im)
Xim im;
_XimCheckIfLocalProcessing(Xim im)
{
FILE *fp;
char *name;
......@@ -76,23 +121,37 @@ _XimCheckIfLocalProcessing(im)
Private void
XimFreeDefaultTree(
DefTree *top)
DefTreeBase *b)
{
if (!top) return;
if (top->succession) XimFreeDefaultTree(top->succession);
if (top->next) XimFreeDefaultTree(top->next);
if (top->mb) Xfree(top->mb);
if (top->wc) Xfree(top->wc);
if (top->utf8) Xfree(top->utf8);
Xfree(top);
if (!b) return;
if (b->tree == NULL) return;
#ifdef COMPOSECACHE
if (b->tree == _XimCachedDefaultTreeBase.tree) {
_XimCachedDefaultTreeRefcount--;
/* No deleting, it's a cache after all. */
return;
}
#endif
Xfree (b->tree);
if (b->mb) Xfree (b->mb);
if (b->wc) Xfree (b->wc);
if (b->utf8) Xfree (b->utf8);
b->tree = NULL;
b->mb = NULL;
b->wc = NULL;
b->utf8 = NULL;
b->treeused = b->treesize = 0;
b->mbused = b->mbsize = 0;
b->wcused = b->wcsize = 0;
b->utf8used = b->utf8size = 0;
}
Public void
_XimLocalIMFree(
Xim im)
{
XimFreeDefaultTree(im->private.local.top);
im->private.local.top = NULL;
XimFreeDefaultTree(&im->private.local.base);
im->private.local.top = 0;
if(im->core.im_resources) {
Xfree(im->core.im_resources);
......@@ -211,28 +270,282 @@ _XimLocalSetIMValues(
return(name);
}
#ifdef COMPOSECACHE
Private Bool
_XimReadCachedDefaultTree(
int fd_cache,
const char *name,
const char *encoding,
DTStructIndex size)
{
struct _XimCacheStruct* m;
int namelen = strlen (name) + 1;
int encodinglen = strlen (encoding) + 1;
m = mmap (NULL, size, PROT_READ, MAP_PRIVATE, fd_cache, 0);
if (m == NULL || m == MAP_FAILED)
return False;
assert (m->id == XIM_CACHE_MAGIC);
assert (m->version == XIM_CACHE_VERSION);
if (size != m->size ||
size < XOffsetOf (struct _XimCacheStruct, fname) + namelen + encodinglen) {
fprintf (stderr, "Ignoring broken XimCache %s [%s]\n", name, encoding);
munmap (m, size);
return False;
}
if (strncmp (name, m->fname, namelen) != 0) {
/* m->fname may *not* be terminated - but who cares here */
fprintf (stderr, "Filename hash clash - expected %s, got %s\n",
name, m->fname);
munmap (m, size);
return False;
}
if (strncmp (encoding, m->fname + namelen, encodinglen) != 0) {
/* m->fname+namelen may *not* be terminated - but who cares here */
fprintf (stderr, "Enoding hash clash - expected %s, got %s\n",
encoding, m->fname + namelen);
munmap (m, size);
return False;
}
_XimCache_mmap = m;
_XimCachedDefaultTreeBase.tree = (DefTree *) (((char *) m) + m->tree);
_XimCachedDefaultTreeBase.mb = (((char *) m) + m->mb);
_XimCachedDefaultTreeBase.wc = (wchar_t *) (((char *) m) + m->wc);
_XimCachedDefaultTreeBase.utf8 = (((char *) m) + m->utf8);
_XimCachedDefaultTreeBase.treeused = m->treeused;
_XimCachedDefaultTreeBase.mbused = m->mbused;
_XimCachedDefaultTreeBase.wcused = m->wcused;
_XimCachedDefaultTreeBase.utf8used = m->utf8used;
/* treesize etc. is ignored because only used during parsing */
_XimCachedDefaultTreeRefcount = 0;
/* fprintf (stderr, "read cached tree at %p: %s\n", (void *) m, name); */
return True;
}
Private unsigned int strToHash (
const char *name)
{
unsigned int hash = 0;
while (*name)
hash = hash * XIM_HASH_PRIME_1 + *(unsigned const char *)name++;
return hash % XIM_HASH_PRIME_2;
}
/* Returns read-only fd of cache file, -1 if none.
* Sets *res to cache filename if safe. Sets *size to file size of cache. */
Private int _XimCachedFileName (
const char *dir, const char *name,
const char *intname, const char *encoding,
uid_t uid, int isglobal, char **res, off_t *size)
{
struct stat st_name, st;
int fd;
unsigned int len, hash, hash2;
struct _XimCacheStruct *m;
/* There are some races here with 'dir', but we are either in our own home
* or the global cache dir, and not inside some public writable dir */
/* fprintf (stderr, "XimCachedFileName for dir %s name %s intname %s encoding %s uid %d\n", dir, name, intname, encoding, uid); */
if (stat (name, &st_name) == -1 || ! S_ISREG (st_name.st_mode)
|| stat (dir, &st) == -1 || ! S_ISDIR (st.st_mode) || st.st_uid != uid
|| (st.st_mode & 0022) != 0000) {
*res = NULL;
return -1;
}
len = strlen (dir);
hash = strToHash (intname);
hash2 = strToHash (encoding);
*res = Xmalloc (len + 1 + 27 + 1); /* Max VERSION 9999 */
if (len == 0 || dir [len-1] != '/')
sprintf (*res, "%s/%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(),
XIM_CACHE_VERSION, (unsigned int)sizeof (DefTree), hash, hash2);
else
sprintf (*res, "%s%c%d_%03x_%08x_%08x", dir, _XimGetMyEndian(),
XIM_CACHE_VERSION, (unsigned int)sizeof (DefTree), hash, hash2);
/* fprintf (stderr, "-> %s\n", *res); */
if ( (fd = _XOpenFile (*res, O_RDONLY)) == -1)
return -1;
if (fstat (fd, &st) == -1) {
Xfree (*res);
*res = NULL;
close (fd);
return -1;
}
*size = st.st_size;
if (! S_ISREG (st.st_mode) || st.st_uid != uid
|| (st.st_mode & 0022) != 0000 || st.st_mtime <= st_name.st_mtime
|| (st.st_mtime < time (NULL) - 24*60*60 && ! isglobal)) {
close (fd);
if (unlink (*res) != 0) {
Xfree (*res);
*res = NULL; /* cache is not safe */
}
return -1;
}
m = mmap (NULL, sizeof (struct _XimCacheStruct), PROT_READ, MAP_PRIVATE,
fd, 0);
if (m == NULL || m == MAP_FAILED) {
close (fd);
Xfree (*res);
*res = NULL;
return -1;
}
if (*size < sizeof (struct _XimCacheStruct) || m->id != XIM_CACHE_MAGIC) {
munmap (m, sizeof (struct _XimCacheStruct));
close (fd);
fprintf (stderr, "Ignoring broken XimCache %s\n", *res);
Xfree (*res);
*res = NULL;
return -1;
}
if (m->version != XIM_CACHE_VERSION) {
munmap (m, sizeof (struct _XimCacheStruct));
close (fd);
if (unlink (*res) != 0) {
Xfree (*res);
*res = NULL; /* cache is not safe */
}
return -1;
}
munmap (m, sizeof (struct _XimCacheStruct));
return fd;
}
Private Bool _XimLoadCache (
int fd,
const char *name,
const char *encoding,
off_t size,
Xim im)
{
if (_XimCache_mmap ||
_XimReadCachedDefaultTree (fd, name, encoding, size)) {
_XimCachedDefaultTreeRefcount++;
memcpy (&im->private.local.base, &_XimCachedDefaultTreeBase,
sizeof (_XimCachedDefaultTreeBase));
im->private.local.top = _XimCache_mmap->top;
return True;
}
return False;
}
Private void
_XimWriteCachedDefaultTree(
const char *name,
const char *encoding,
const char *cachename,
Xim im)
{
int fd;
FILE *fp;
struct _XimCacheStruct *m;
int msize = (XOffsetOf(struct _XimCacheStruct, fname)
+ strlen(name) + strlen(encoding) + 2
+ XIM_CACHE_TREE_ALIGNMENT-1) & -XIM_CACHE_TREE_ALIGNMENT;
DefTreeBase *b = &im->private.local.base;
if (! b->tree && ! (b->tree = Xmalloc (sizeof(DefTree))) )
return;
if (! b->mb && ! (b->mb = Xmalloc (1)) )
return;
if (! b->wc && ! (b->wc = Xmalloc (sizeof(wchar_t))) )
return;
if (! b->utf8 && ! (b->utf8 = Xmalloc (1)) )
return;
/* First entry is always unused */
memset (b->tree, 0, sizeof(DefTree));
b->mb[0] = 0;
b->wc[0] = 0;
b->utf8[0] = 0;
m = Xmalloc (msize);
memset (m, 0, msize);
m->id = XIM_CACHE_MAGIC;
m->version = XIM_CACHE_VERSION;
m->top = im->private.local.top;
m->treeused = b->treeused;
m->mbused = b->mbused;
m->wcused = b->wcused;
m->utf8used = b->utf8used;
/* Tree first, then wide chars, then the rest due to alignment */
m->tree = msize;
m->wc = msize + sizeof (DefTree) * m->treeused;
m->mb = m->wc + sizeof (wchar_t) * m->wcused;
m->utf8 = m->mb + m->mbused;
m->size = m->utf8 + m->utf8used;
strcpy (m->fname, name);
strcpy (m->fname+strlen(name)+1, encoding);
/* This STILL might be racy on NFS */
if ( (fd = _XOpenFileMode (cachename, O_WRONLY | O_CREAT | O_EXCL,
0600)) < 0)
return;
if (! (fp = fdopen (fd, "wb")) ) {
close (fd);
return;
}
fwrite (m, msize, 1, fp);
fwrite (im->private.local.base.tree, sizeof(DefTree), m->treeused, fp);
fwrite (im->private.local.base.wc, sizeof(wchar_t), m->wcused, fp);
fwrite (im->private.local.base.mb, 1, m->mbused, fp);
fwrite (im->private.local.base.utf8, 1, m->utf8used, fp);
if (fclose (fp) != 0)
unlink (cachename);
_XimCache_mmap = m;
memcpy (&_XimCachedDefaultTreeBase, &im->private.local.base,
sizeof (_XimCachedDefaultTreeBase));
/* fprintf (stderr, "wrote tree %s size %ld to %s\n", name, m->size, cachename); */
}
#endif
Private void
_XimCreateDefaultTree(
Xim im)
{
FILE *fp = NULL;
char *name, *tmpname = NULL;
char *name, *tmpname = NULL, *intname;
char *cachename = NULL;
/* Should use getpwent() instead of $HOME (cross-platform?) */
char *home = getenv("HOME");
char *cachedir = NULL;
char *tmpcachedir = NULL;
int hl = home ? strlen (home) : 0;
#ifdef COMPOSECACHE
const char *encoding = nl_langinfo (CODESET);
uid_t euid = geteuid ();
gid_t egid = getegid ();
int cachefd = -1;
off_t size;
#endif
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) {
int fd;
strcpy(name, home);
strcpy(name + hl, "/.XCompose");
fp = _XFopenFile (name, "r");
if (fp == (FILE *) NULL) {
Xfree(name);
if ( (fd = _XOpenFile (name, O_RDONLY)) < 0) {
Xfree (name);
name = tmpname = NULL;
}
} else
close (fd);
}
}
}
......@@ -240,19 +553,94 @@ _XimCreateDefaultTree(
if (name == (char *) NULL) {
tmpname = name = _XlcFileName(im->core.lcd, COMPOSE_FILE);
}
intname = name;
#ifdef COMPOSECACHE
if (getuid () == euid && getgid () == egid && euid != 0) {
char *c;
/* Usage: XCOMPOSECACHE=<cachedir>[=<filename>]
* cachedir: directory of cache files
* filename: internally used name for cache file */
cachedir = getenv("XCOMPOSECACHE");
if (cachedir && (c = strchr (cachedir, '='))) {
tmpcachedir = strdup (cachedir);
intname = tmpcachedir + (c-cachedir) + 1;
tmpcachedir[c-cachedir] = '\0';
cachedir = tmpcachedir;
}
}
if (name == (char *) NULL)
if (! cachedir) {
cachefd = _XimCachedFileName (XIM_GLOBAL_CACHE_DIR, name, intname,
encoding, 0, 1, &cachename, &size);
if (cachefd != -1) {
if (_XimLoadCache (cachefd, intname, encoding, size, im)) {
if (tmpcachedir)
Xfree (tmpcachedir);
if (tmpname)
Xfree (tmpname);
if (cachename)
Xfree (cachename);
close (cachefd);
return;
if (fp == (FILE *) NULL) {
fp = _XFopenFile (name, "r");
}
if (tmpname != (char *) NULL) {
Xfree(tmpname);
close (cachefd);
}
if (cachename)
Xfree (cachename);
cachename = NULL;
}
if (getuid () == euid && getgid () == egid && euid != 0 && home) {
if (! cachedir) {
tmpcachedir = cachedir = Xmalloc (hl+strlen(XIM_HOME_CACHE_DIR)+1);
strcpy (cachedir, home);
strcat (cachedir, XIM_HOME_CACHE_DIR);
}
cachefd = _XimCachedFileName (cachedir, name, intname, encoding,
euid, 0, &cachename, &size);
if (cachefd != -1) {
if (_XimLoadCache (cachefd, intname, encoding, size, im)) {
if (tmpcachedir)
Xfree (tmpcachedir);
if (tmpname)
Xfree (tmpname);
if (cachename)
Xfree (cachename);
close (cachefd);
return;
}
close (cachefd);
}
}
if (fp == (FILE *) NULL)
#endif
if (! (fp = _XFopenFile (name, "r"))) {
if (tmpcachedir)
Xfree (tmpcachedir);
if (tmpname)
Xfree (tmpname);
if (cachename)
Xfree (cachename);
return;
}
_XimParseStringFile(fp, im);
fclose(fp);
#ifdef COMPOSECACHE
if (cachename) {
assert (euid != 0);
_XimWriteCachedDefaultTree (intname, encoding, cachename, im);
}
#endif
if (tmpcachedir)
Xfree (tmpcachedir);
if (tmpname)
Xfree (tmpname);
if (cachename)
Xfree (cachename);
}
Private XIMMethodsRec Xim_im_local_methods = {
......@@ -325,6 +713,11 @@ _XimLocalOpenIM(
goto Open_Error;
private->ucstoutf8_conv = conv;
private->base.treeused = 1;
private->base.mbused = 1;
private->base.wcused = 1;
private->base.utf8used = 1;
_XimCreateDefaultTree(im);
im->methods = &Xim_im_local_methods;
......
......@@ -40,32 +40,47 @@ PERFORMANCE OF THIS SOFTWARE.
#include <nx-X11/Xutil.h>
#include "Xlibint.h"
#include "Xlcint.h"
#include "XlcPubI.h"
#include "Ximint.h"
Public int
_XimLocalMbLookupString(xic, ev, buffer, bytes, keysym, status)
XIC xic;
XKeyEvent *ev;
char *buffer;
int bytes;
KeySym *keysym;
Status *status;
_XimLocalMbLookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
KeySym *keysym, Status *status)
{
Xic ic = (Xic)xic;
int ret;
DefTree *b = ic->private.local.base.tree;
char *mb = ic->private.local.base.mb;
if(ev->type != KeyPress) {
if(status) *status = XLookupNone;
return(0);
}
if(ev->keycode == 0 && ic->private.local.composed != NULL) { /* Composed Event */
ret = strlen(ic->private.local.composed->mb);
if(ev->keycode == 0 &&
( (ic->private.local.composed != 0)
||(ic->private.local.brl_committed != 0))) {
if (ic->private.local.brl_committed != 0) { /* Braille Event */
unsigned char pattern = ic->private.local.brl_committed;
char mb[XLC_PUBLIC(ic->core.im->core.lcd, mb_cur_max)];
ret = _Xlcwctomb(ic->core.im->core.lcd, mb, BRL_UC_ROW | pattern);
if(ret > bytes) {
if(status) *status = XBufferOverflow;
return(ret);
}
memcpy(buffer, ic->private.local.composed->mb, ret);
if(keysym) *keysym = ic->private.local.composed->ks;
if(keysym) {
*keysym = XK_braille_blank | pattern;
if(status) *status = XLookupBoth;
} else
if(status) *status = XLookupChars;
memcpy(buffer, mb, ret);
} else { /* Composed Event */
ret = strlen(&mb[b[ic->private.local.composed].mb]);
if(ret > bytes) {
if(status) *status = XBufferOverflow;
return(ret);
}
memcpy(buffer, &mb[b[ic->private.local.composed].mb], ret);
if(keysym) *keysym = b[ic->private.local.composed].ks;
if (ret > 0) {
if (keysym && *keysym != NoSymbol) {
if(status) *status = XLookupBoth;
......@@ -79,6 +94,7 @@ _XimLocalMbLookupString(xic, ev, buffer, bytes, keysym, status)
if(status) *status = XLookupNone;
}
}
}
return (ret);
} else { /* Throughed Event */
ret = _XimLookupMBText(ic, ev, buffer, bytes, keysym, NULL);
......@@ -102,30 +118,41 @@ _XimLocalMbLookupString(xic, ev, buffer, bytes, keysym, status)
}
Public int
_XimLocalWcLookupString(xic, ev, buffer, wlen, keysym, status)
XIC xic;
XKeyEvent *ev;
wchar_t *buffer;
int wlen;
KeySym *keysym;
Status *status;
_XimLocalWcLookupString(XIC xic, XKeyEvent *ev, wchar_t *buffer, int wlen,
KeySym *keysym, Status *status)
{
Xic ic = (Xic)xic;
int ret;
DefTree *b = ic->private.local.base.tree;
wchar_t *wc = ic->private.local.base.wc;
if(ev->type != KeyPress) {
if(status) *status = XLookupNone;
return(0);
}
if(ev->keycode == 0) { /* Composed Event */
ret = _Xwcslen(ic->private.local.composed->wc);
if(ev->keycode == 0) {
if (ic->private.local.brl_committed != 0) { /* Braille Event */
unsigned char pattern = ic->private.local.brl_committed;
ret = 1;
if (ret > wlen) {
if(status) *status = XBufferOverflow;
return (ret);
}
*buffer = BRL_UC_ROW | pattern;
if(keysym) {
*keysym = XK_braille_blank | pattern;
if(status) *status = XLookupBoth;
} else
if(status) *status = XLookupChars;
} else { /* Composed Event */
ret = _Xwcslen(&wc[b[ic->private.local.composed].wc]);
if(ret > wlen) {
if(status) *status = XBufferOverflow;
return (ret);
}
memcpy((char *)buffer, (char *)ic->private.local.composed->wc,
memcpy((char *)buffer, (char *)&wc[b[ic->private.local.composed].wc],
ret * sizeof(wchar_t));
if(keysym) *keysym = ic->private.local.composed->ks;
if(keysym) *keysym = b[ic->private.local.composed].ks;
if (ret > 0) {
if (keysym && *keysym != NoSymbol) {
if(status) *status = XLookupBoth;
......@@ -139,6 +166,7 @@ _XimLocalWcLookupString(xic, ev, buffer, wlen, keysym, status)
if(status) *status = XLookupNone;
}
}
}
return (ret);
} else { /* Throughed Event */
ret = _XimLookupWCText(ic, ev, buffer, wlen, keysym, NULL);
......@@ -162,29 +190,37 @@ _XimLocalWcLookupString(xic, ev, buffer, wlen, keysym, status)
}
Public int
_XimLocalUtf8LookupString(xic, ev, buffer, bytes, keysym, status)
XIC xic;
XKeyEvent *ev;
char *buffer;
int bytes;
KeySym *keysym;
Status *status;
_XimLocalUtf8LookupString(XIC xic, XKeyEvent *ev, char *buffer, int bytes,
KeySym *keysym, Status *status)
{
Xic ic = (Xic)xic;
int ret;
DefTree *b = ic->private.local.base.tree;
char *utf8 = ic->private.local.base.utf8;
if(ev->type != KeyPress) {
if(status) *status = XLookupNone;
return(0);
}
if(ev->keycode == 0) { /* Composed Event */
ret = strlen(ic->private.local.composed->utf8);
if(ev->keycode == 0) {
if (ic->private.local.brl_committed != 0) { /* Braille Event */
unsigned char pattern = ic->private.local.brl_committed;
ret = 3;
if (ret > bytes) {
if(status) *status = XBufferOverflow;
return (ret);
}
buffer[0] = 0xe0 | ((BRL_UC_ROW >> 12) & 0x0f);
buffer[1] = 0x80 | ((BRL_UC_ROW >> 8) & 0x30) | (pattern >> 6);
buffer[2] = 0x80 | (pattern & 0x3f);
} else { /* Composed Event */
ret = strlen(&utf8[b[ic->private.local.composed].utf8]);
if(ret > bytes) {
if(status) *status = XBufferOverflow;
return (ret);
}
memcpy(buffer, ic->private.local.composed->utf8, ret);
if(keysym) *keysym = ic->private.local.composed->ks;
memcpy(buffer, &utf8[b[ic->private.local.composed].utf8], ret);
if(keysym) *keysym = b[ic->private.local.composed].ks;
if (ret > 0) {
if (keysym && *keysym != NoSymbol) {
if(status) *status = XLookupBoth;
......@@ -198,6 +234,7 @@ _XimLocalUtf8LookupString(xic, ev, buffer, bytes, keysym, status)
if(status) *status = XLookupNone;
}
}
}
return (ret);
} else { /* Throughed Event */
ret = _XimLookupUTF8Text(ic, ev, buffer, bytes, keysym, NULL);
......@@ -287,26 +324,16 @@ _XimLcctsconvert(
}
Public int
_XimLcctstombs(xim, from, from_len, to, to_len, state)
XIM xim;
char *from;
int from_len;
char *to;
int to_len;
Status *state;
_XimLcctstombs(XIM xim, char *from, int from_len,
char *to, int to_len, Status *state)
{
return _XimLcctsconvert(((Xim)xim)->private.local.ctom_conv,
from, from_len, to, to_len, state);
}
Public int
_XimLcctstowcs(xim, from, from_len, to, to_len, state)
XIM xim;
char *from;
int from_len;
wchar_t *to;
int to_len;
Status *state;
_XimLcctstowcs(XIM xim, char *from, int from_len,
wchar_t *to, int to_len, Status *state)
{
Xim im = (Xim)xim;
XlcConv conv = im->private.local.ctow_conv;
......@@ -368,13 +395,8 @@ _XimLcctstowcs(xim, from, from_len, to, to_len, state)
}
Public int
_XimLcctstoutf8(xim, from, from_len, to, to_len, state)
XIM xim;
char *from;
int from_len;
char *to;
int to_len;
Status *state;
_XimLcctstoutf8(XIM xim, char *from, int from_len,
char *to, int to_len, Status *state)
{
return _XimLcctsconvert(((Xim)xim)->private.local.ctoutf8_conv,
from, from_len, to, to_len, state);
......
......@@ -42,6 +42,8 @@ OR PERFORMANCE OF THIS SOFTWARE.
#include <sys/stat.h>
#include <stdio.h>
#define XLC_BUFSIZE 256
extern int _Xmbstowcs(
wchar_t *wstr,
char *str,
......@@ -276,38 +278,33 @@ static long
modmask(
char *name)
{
long mask;
struct _modtbl {
char *name;
const char name[6];
long mask;
};
struct _modtbl *p;
static struct _modtbl tbl[] = {
static const struct _modtbl tbl[] = {
{ "Ctrl", ControlMask },
{ "Lock", LockMask },
{ "Caps", LockMask },
{ "Shift", ShiftMask },
{ "Alt", Mod1Mask },
{ "Meta", Mod1Mask },
{ NULL, 0 }};
p = tbl;
mask = 0;
for (p = tbl; p->name != NULL; p++) {
if (strcmp(name, p->name) == 0) {
mask = p->mask;
break;
}
}
return(mask);
{ "Meta", Mod1Mask }};
int i, num_entries = sizeof (tbl) / sizeof (tbl[0]);
for (i = 0; i < num_entries; i++)
if (!strcmp (name, tbl[i].name))
return tbl[i].mask;
return 0;
}
static char*
TransFileName(Xim im, char *name)
{
char *home = NULL, *lcCompose = NULL;
char dir[XLC_BUFSIZE];
char *i = name, *ret, *j;
int l = 0;
......@@ -328,6 +325,10 @@ TransFileName(Xim im, char *name)
if (lcCompose)
l += strlen(lcCompose);
break;
case 'S':
xlocaledir(dir, XLC_BUFSIZE);
l += strlen(dir);
break;
}
} else {
l++;
......@@ -359,6 +360,10 @@ TransFileName(Xim im, char *name)
Xfree(lcCompose);
}
break;
case 'S':
strcpy(j, dir);
j += strlen(dir);
break;
}
i++;
} else {
......@@ -420,11 +425,13 @@ parseline(
char* tokenbuf)
{
int token;
unsigned modifier_mask;
unsigned modifier;
unsigned tmp;
DTModifier modifier_mask;
DTModifier modifier;
DTModifier tmp;
KeySym keysym = NoSymbol;
DefTree **top = &im->private.local.top;
DTIndex *top = &im->private.local.top;
DefTreeBase *b = &im->private.local.base;
DTIndex t;
DefTree *p = NULL;
Bool exclam, tilde;
KeySym rhs_keysym = 0;
......@@ -436,8 +443,8 @@ parseline(
char local_utf8_buf[LOCAL_UTF8_BUFSIZE], *rhs_string_utf8;
struct DefBuffer {
unsigned modifier_mask;
unsigned modifier;
DTModifier modifier_mask;
DTModifier modifier;
KeySym keysym;
};
......@@ -467,6 +474,7 @@ parseline(
if (infp == NULL)
goto error;
_XimParseStringFile(infp, im);
fclose(infp);
return (0);
} else if ((token == KEY) && (strcmp("None", tokenbuf) == 0)) {
modifier = 0;
......@@ -534,20 +542,24 @@ parseline(
token = nexttoken(fp, tokenbuf, &lastch);
if (token == STRING) {
if( (rhs_string_mb = Xmalloc(strlen(tokenbuf) + 1)) == NULL )
l = strlen(tokenbuf) + 1;
while (b->mbused + l > b->mbsize) {
b->mbsize = b->mbsize ? b->mbsize * 1.5 : 1024;
if (! (b->mb = Xrealloc (b->mb, b->mbsize)) )
goto error;
}
rhs_string_mb = &b->mb[b->mbused];
b->mbused += l;
strcpy(rhs_string_mb, tokenbuf);
token = nexttoken(fp, tokenbuf, &lastch);
if (token == KEY) {
rhs_keysym = XStringToKeysym(tokenbuf);
if (rhs_keysym == NoSymbol) {
Xfree(rhs_string_mb);
goto error;
}
token = nexttoken(fp, tokenbuf, &lastch);
}
if (token != ENDOFLINE && token != ENDOFFILE) {
Xfree(rhs_string_mb);
goto error;
}
} else if (token == KEY) {
......@@ -561,14 +573,13 @@ parseline(
}
l = get_mb_string(im, local_mb_buf, rhs_keysym);
if (l == 0) {
rhs_string_mb = Xmalloc(1);
} else {
rhs_string_mb = Xmalloc(l + 1);
}
if( rhs_string_mb == NULL ) {
while (b->mbused + l + 1 > b->mbsize) {
b->mbsize = b->mbsize ? b->mbsize * 1.5 : 1024;
if (! (b->mb = Xrealloc (b->mb, b->mbsize)) )
goto error;
}
rhs_string_mb = &b->mb[b->mbused];
b->mbused += l + 1;
memcpy(rhs_string_mb, local_mb_buf, l);
rhs_string_mb[l] = '\0';
} else {
......@@ -579,61 +590,69 @@ parseline(
if (l == LOCAL_WC_BUFSIZE - 1) {
local_wc_buf[l] = (wchar_t)'\0';
}
if( (rhs_string_wc = (wchar_t *)Xmalloc((l + 1) * sizeof(wchar_t))) == NULL ) {
Xfree( rhs_string_mb );
return( 0 );
while (b->wcused + l + 1 > b->wcsize) {
b->wcsize = b->wcsize ? b->wcsize * 1.5 : 512;
if (! (b->wc = Xrealloc (b->wc, sizeof(wchar_t) * b->wcsize)) )
goto error;
}
rhs_string_wc = &b->wc[b->wcused];
b->wcused += l + 1;
memcpy((char *)rhs_string_wc, (char *)local_wc_buf, (l + 1) * sizeof(wchar_t) );
l = _Xmbstoutf8(local_utf8_buf, rhs_string_mb, LOCAL_UTF8_BUFSIZE - 1);
if (l == LOCAL_UTF8_BUFSIZE - 1) {
local_utf8_buf[l] = '\0';
}
if( (rhs_string_utf8 = (char *)Xmalloc(l + 1)) == NULL ) {
Xfree( rhs_string_wc );
Xfree( rhs_string_mb );
return( 0 );
while (b->utf8used + l + 1 > b->utf8size) {
b->utf8size = b->utf8size ? b->utf8size * 1.5 : 1024;
if (! (b->utf8 = Xrealloc (b->utf8, b->utf8size)) )
goto error;
}
rhs_string_utf8 = &b->utf8[b->utf8used];
b->utf8used += l + 1;
memcpy(rhs_string_utf8, local_utf8_buf, l + 1);
for (i = 0; i < n; i++) {
for (p = *top; p; p = p->next) {
if (buf[i].keysym == p->keysym &&
buf[i].modifier == p->modifier &&
buf[i].modifier_mask == p->modifier_mask) {
for (t = *top; t; t = b->tree[t].next) {
if (buf[i].keysym == b->tree[t].keysym &&
buf[i].modifier == b->tree[t].modifier &&
buf[i].modifier_mask == b->tree[t].modifier_mask) {
break;
}
}
if (p) {
if (t) {
p = &b->tree[t];
top = &p->succession;
} else {
if( (p = (DefTree*)Xmalloc(sizeof(DefTree))) == NULL ) {
Xfree( rhs_string_mb );
while (b->treeused >= b->treesize) {
DefTree *old = b->tree;
int oldsize = b->treesize;
b->treesize = b->treesize ? b->treesize * 1.5 : 256;
if (! (b->tree = Xrealloc (b->tree, sizeof(DefTree) * b->treesize)) )
goto error;
if (top >= (DTIndex *) old && top < (DTIndex *) &old[oldsize])
top = (DTIndex *) (((char *) top) + (((char *)b->tree)-(char *)old));
}
p = &b->tree[b->treeused];
p->keysym = buf[i].keysym;
p->modifier = buf[i].modifier;
p->modifier_mask = buf[i].modifier_mask;
p->succession = NULL;
p->succession = 0;
p->next = *top;
p->mb = NULL;
p->wc = NULL;
p->utf8 = NULL;
p->mb = 0;
p->wc = 0;
p->utf8 = 0;
p->ks = NoSymbol;
*top = p;
*top = b->treeused;
top = &p->succession;
b->treeused++;
}
}
if( p->mb != NULL )
Xfree( p->mb );
p->mb = rhs_string_mb;
if( p->wc != NULL )
Xfree( p->wc );
p->wc = rhs_string_wc;
if( p->utf8 != NULL )
Xfree( p->utf8 );
p->utf8 = rhs_string_utf8;
/* old entries no longer freed... */
p->mb = rhs_string_mb - b->mb;
p->wc = rhs_string_wc - b->wc;
p->utf8 = rhs_string_utf8 - b->utf8;
p->ks = rhs_keysym;
return(n);
error:
......
......@@ -38,9 +38,7 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Ximint.h"
Public char *
_XimLocalSetICValues(xic, values)
XIC xic;
XIMArg *values;
_XimLocalSetICValues(XIC xic, XIMArg *values)
{
XimDefICValues ic_values;
Xic ic = (Xic)xic;
......
......@@ -40,8 +40,10 @@ PERFORMANCE OF THIS SOFTWARE.
#include "Ximint.h"
#include "Xresource.h"
#define GET_NAME(x) name_table + x.name_offset
typedef struct _XimValueOffsetInfo {
char *name;
unsigned short name_offset;
XrmQuark quark;
unsigned int offset;
Bool (*defaults)(
......@@ -204,54 +206,136 @@ _XimSetProtoResource(im)
}
#endif /* XIM_CONNECTABLE */
static char *supported_local_im_values_list[] = {
XNQueryInputStyle,
XNResourceName,
XNResourceClass,
XNDestroyCallback,
XNQueryIMValuesList,
XNQueryICValuesList,
XNVisiblePosition,
(char *)NULL
static const char name_table[] =
/* 0 */ XNQueryInputStyle"\0"
/* 16 */ XNClientWindow"\0"
/* 29 */ XNInputStyle"\0"
/* 40 */ XNFocusWindow"\0"
/* 52 */ XNResourceName"\0"
/* 65 */ XNResourceClass"\0"
/* 79 */ XNGeometryCallback"\0"
/* 96 */ XNDestroyCallback"\0"
/* 112 */ XNFilterEvents"\0"
/* 125 */ XNPreeditStartCallback"\0"
/* 146 */ XNPreeditDoneCallback"\0"
/* 166 */ XNPreeditDrawCallback"\0"
/* 186 */ XNPreeditCaretCallback"\0"
/* 207 */ XNPreeditStateNotifyCallback"\0"
/* 234 */ XNPreeditAttributes"\0"
/* 252 */ XNStatusStartCallback"\0"
/* 272 */ XNStatusDoneCallback"\0"
/* 291 */ XNStatusDrawCallback"\0"
/* 310 */ XNStatusAttributes"\0"
/* 327 */ XNArea"\0"
/* 332 */ XNAreaNeeded"\0"
/* 343 */ XNSpotLocation"\0"
/* 356 */ XNColormap"\0"
/* 365 */ XNStdColormap"\0"
/* 377 */ XNForeground"\0"
/* 388 */ XNBackground"\0"
/* 399 */ XNBackgroundPixmap"\0"
/* 416 */ XNFontSet"\0"
/* 424 */ XNLineSpace"\0"
/* 434 */ XNCursor"\0"
/* 441 */ XNQueryIMValuesList"\0"
/* 459 */ XNQueryICValuesList"\0"
/* 477 */ XNVisiblePosition"\0"
/* 493 */ XNStringConversionCallback"\0"
/* 518 */ XNStringConversion"\0"
/* 535 */ XNResetState"\0"
/* 546 */ XNHotKey"\0"
/* 553 */ XNHotKeyState"\0"
/* 565 */ XNPreeditState
;
#define OFFSET_XNQUERYINPUTSTYLE 0
#define OFFSET_XNCLIENTWINDOW 16
#define OFFSET_XNINPUTSTYLE 29
#define OFFSET_XNFOCUSWINDOW 40
#define OFFSET_XNRESOURCENAME 52
#define OFFSET_XNRESOURCECLASS 65
#define OFFSET_XNGEOMETRYCALLBACK 79
#define OFFSET_XNDESTROYCALLBACK 96
#define OFFSET_XNFILTEREVENTS 112
#define OFFSET_XNPREEDITSTARTCALLBACK 125
#define OFFSET_XNPREEDITDONECALLBACK 146
#define OFFSET_XNPREEDITDRAWCALLBACK 166
#define OFFSET_XNPREEDITCARETCALLBACK 186
#define OFFSET_XNPREEDITSTATENOTIFYCALLBACK 207
#define OFFSET_XNPREEDITATTRIBUTES 234
#define OFFSET_XNSTATUSSTARTCALLBACK 252
#define OFFSET_XNSTATUSDONECALLBACK 272
#define OFFSET_XNSTATUSDRAWCALLBACK 291
#define OFFSET_XNSTATUSATTRIBUTES 310
#define OFFSET_XNAREA 327
#define OFFSET_XNAREANEEDED 332
#define OFFSET_XNSPOTLOCATION 343
#define OFFSET_XNCOLORMAP 356
#define OFFSET_XNSTDCOLORMAP 365
#define OFFSET_XNFOREGROUND 377
#define OFFSET_XNBACKGROUND 388
#define OFFSET_XNBACKGROUNDPIXMAP 399
#define OFFSET_XNFONTSET 416
#define OFFSET_XNLINESPACE 424
#define OFFSET_XNCURSOR 434
#define OFFSET_XNQUERYIMVALUESLIST 441
#define OFFSET_XNQUERYICVALUESLIST 459
#define OFFSET_XNVISIBLEPOSITION 477
#define OFFSET_XNSTRINGCONVERSIONCALLBACK 493
#define OFFSET_XNSTRINGCONVERSION 518
#define OFFSET_XNRESETSTATE 535
#define OFFSET_XNHOTKEY 546
#define OFFSET_XNHOTKEYSTATE 553
#define OFFSET_XNPREEDITSTATE 565
/* offsets into name_table */
static const unsigned short supported_local_im_values_list[] = {
OFFSET_XNQUERYINPUTSTYLE,
OFFSET_XNRESOURCENAME,
OFFSET_XNRESOURCECLASS,
OFFSET_XNDESTROYCALLBACK,
OFFSET_XNQUERYIMVALUESLIST,
OFFSET_XNQUERYICVALUESLIST,
OFFSET_XNVISIBLEPOSITION
};
static char *supported_local_ic_values_list[] = {
XNInputStyle,
XNClientWindow,
XNFocusWindow,
XNResourceName,
XNResourceClass,
XNGeometryCallback,
XNFilterEvents,
XNDestroyCallback,
XNStringConversionCallback,
XNStringConversion,
XNResetState,
XNHotKey,
XNHotKeyState,
XNPreeditAttributes,
XNStatusAttributes,
XNArea,
XNAreaNeeded,
XNSpotLocation,
XNColormap,
XNStdColormap,
XNForeground,
XNBackground,
XNBackgroundPixmap,
XNFontSet,
XNLineSpace,
XNCursor,
XNPreeditStartCallback,
XNPreeditDoneCallback,
XNPreeditDrawCallback,
XNPreeditCaretCallback,
XNStatusStartCallback,
XNStatusDoneCallback,
XNStatusDrawCallback,
XNPreeditState,
XNPreeditStateNotifyCallback,
(char *)NULL
/* offsets into name_table */
static const unsigned short supported_local_ic_values_list[] = {
OFFSET_XNINPUTSTYLE,
OFFSET_XNCLIENTWINDOW,
OFFSET_XNFOCUSWINDOW,
OFFSET_XNRESOURCENAME,
OFFSET_XNRESOURCECLASS,
OFFSET_XNGEOMETRYCALLBACK,
OFFSET_XNFILTEREVENTS,
OFFSET_XNDESTROYCALLBACK,
OFFSET_XNSTRINGCONVERSIONCALLBACK,
OFFSET_XNSTRINGCONVERSIONCALLBACK,
OFFSET_XNRESETSTATE,
OFFSET_XNHOTKEY,
OFFSET_XNHOTKEYSTATE,
OFFSET_XNPREEDITATTRIBUTES,
OFFSET_XNSTATUSATTRIBUTES,
OFFSET_XNAREA,
OFFSET_XNAREANEEDED,
OFFSET_XNSPOTLOCATION,
OFFSET_XNCOLORMAP,
OFFSET_XNSTDCOLORMAP,
OFFSET_XNFOREGROUND,
OFFSET_XNBACKGROUND,
OFFSET_XNBACKGROUNDPIXMAP,
OFFSET_XNFONTSET,
OFFSET_XNLINESPACE,
OFFSET_XNCURSOR,
OFFSET_XNPREEDITSTARTCALLBACK,
OFFSET_XNPREEDITDONECALLBACK,
OFFSET_XNPREEDITDRAWCALLBACK,
OFFSET_XNPREEDITCARETCALLBACK,
OFFSET_XNSTATUSSTARTCALLBACK,
OFFSET_XNSTATUSDONECALLBACK,
OFFSET_XNSTATUSDRAWCALLBACK,
OFFSET_XNPREEDITSTATE,
OFFSET_XNPREEDITSTATENOTIFYCALLBACK
};
static XIMStyle const supported_local_styles[] = {
......@@ -310,7 +394,7 @@ _XimDefaultIMValues(
int len;
XPointer tmp;
n = XIMNumber(supported_local_im_values_list) - 1;
n = XIMNumber(supported_local_im_values_list);
len = sizeof(XIMValuesList) + sizeof(char **) * n;
if(!(tmp = (XPointer)Xmalloc(len))) {
return False;
......@@ -323,8 +407,8 @@ _XimDefaultIMValues(
values_list->supported_values
= (char **)((char *)tmp + sizeof(XIMValuesList));
for(i = 0; i < n; i++) {
values_list->supported_values[i]
= supported_local_im_values_list[i];
values_list->supported_values[i] =
(char *)name_table + supported_local_im_values_list[i];
}
}
......@@ -347,7 +431,7 @@ _XimDefaultICValues(
int len;
XPointer tmp;
n = XIMNumber(supported_local_ic_values_list) - 1;
n = XIMNumber(supported_local_ic_values_list);
len = sizeof(XIMValuesList) + sizeof(char **) * n;
if(!(tmp = (XPointer)Xmalloc(len))) {
return False;
......@@ -360,8 +444,8 @@ _XimDefaultICValues(
values_list->supported_values
= (char **)((char *)tmp + sizeof(XIMValuesList));
for(i = 0; i < n; i++) {
values_list->supported_values[i]
= supported_local_ic_values_list[i];
values_list->supported_values[i] =
(char *)name_table + supported_local_ic_values_list[i];
}
}
......@@ -510,7 +594,7 @@ _XimDefaultArea(
if(XGetGeometry(im->core.display, (Drawable)ic->core.focus_window,
&root_return, &x_return, &y_return, &width_return,
&height_return, &border_width_return, &depth_return)
== (Status)NULL) {
== (Status)Success) {
return True;
}
area.x = 0;
......@@ -539,7 +623,7 @@ _XimDefaultColormap(
return True;
}
if(XGetWindowAttributes(im->core.display, ic->core.client_window,
&win_attr) == (Status)NULL) {
&win_attr) == (Status)Success) {
return True;
}
......@@ -1437,247 +1521,245 @@ static XIMResource ic_inner_resources[] = {
};
static XimValueOffsetInfoRec im_attr_info[] = {
{XNQueryInputStyle, 0,
{OFFSET_XNQUERYINPUTSTYLE, 0,
XOffsetOf(XimDefIMValues, styles),
_XimDefaultStyles, NULL, _XimDecodeStyles},
{XNDestroyCallback, 0,
{OFFSET_XNDESTROYCALLBACK, 0,
XOffsetOf(XimDefIMValues, destroy_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback},
{XNResourceName, 0,
{OFFSET_XNRESOURCENAME, 0,
XOffsetOf(XimDefIMValues, res_name),
NULL, _XimEncodeString, _XimDecodeString},
{XNResourceClass, 0,
{OFFSET_XNRESOURCECLASS, 0,
XOffsetOf(XimDefIMValues, res_class),
NULL, _XimEncodeString, _XimDecodeString},
{XNQueryIMValuesList, 0,
{OFFSET_XNQUERYIMVALUESLIST, 0,
XOffsetOf(XimDefIMValues, im_values_list),
_XimDefaultIMValues, NULL, _XimDecodeValues},
{XNQueryICValuesList, 0,
{OFFSET_XNQUERYICVALUESLIST, 0,
XOffsetOf(XimDefIMValues, ic_values_list),
_XimDefaultICValues, NULL, _XimDecodeValues},
{XNVisiblePosition, 0,
{OFFSET_XNVISIBLEPOSITION, 0,
XOffsetOf(XimDefIMValues, visible_position),
_XimDefaultVisiblePos, NULL, _XimDecodeBool}
};
static XimValueOffsetInfoRec ic_attr_info[] = {
{XNInputStyle, 0,
{OFFSET_XNINPUTSTYLE, 0,
XOffsetOf(XimDefICValues, input_style),
NULL, _XimEncodeStyle, _XimDecodeStyle},
{XNClientWindow, 0,
{OFFSET_XNCLIENTWINDOW, 0,
XOffsetOf(XimDefICValues, client_window),
NULL, _XimEncodeWindow, _XimDecodeWindow},
{XNFocusWindow, 0,
{OFFSET_XNFOCUSWINDOW, 0,
XOffsetOf(XimDefICValues, focus_window),
_XimDefaultFocusWindow, _XimEncodeWindow, _XimDecodeWindow},
{XNResourceName, 0,
{OFFSET_XNRESOURCENAME, 0,
XOffsetOf(XimDefICValues, res_name),
_XimDefaultResName, _XimEncodeString, _XimDecodeString},
{XNResourceClass, 0,
{OFFSET_XNRESOURCECLASS, 0,
XOffsetOf(XimDefICValues, res_class),
_XimDefaultResClass, _XimEncodeString, _XimDecodeString},
{XNGeometryCallback, 0,
{OFFSET_XNGEOMETRYCALLBACK, 0,
XOffsetOf(XimDefICValues, geometry_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback},
{XNFilterEvents, 0,
{OFFSET_XNFILTEREVENTS, 0,
XOffsetOf(XimDefICValues, filter_events),
NULL, NULL, _XimDecodeLong},
{XNDestroyCallback, 0,
{OFFSET_XNDESTROYCALLBACK, 0,
XOffsetOf(XimDefICValues, destroy_callback),
_XimDefaultDestroyCB, _XimEncodeCallback, _XimDecodeCallback},
{XNStringConversionCallback, 0,
{OFFSET_XNSTRINGCONVERSIONCALLBACK, 0,
XOffsetOf(XimDefICValues, string_conversion_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback},
{XNStringConversion, 0,
{OFFSET_XNSTRINGCONVERSION, 0,
XOffsetOf(XimDefICValues, string_conversion),
NULL, _XimEncodeStringConv, _XimDecodeStringConv},
{XNResetState, 0,
{OFFSET_XNRESETSTATE, 0,
XOffsetOf(XimDefICValues, reset_state),
_XimDefaultResetState, _XimEncodeResetState, _XimDecodeResetState},
{XNHotKey, 0,
{OFFSET_XNHOTKEY, 0,
XOffsetOf(XimDefICValues, hotkey),
NULL, _XimEncodeHotKey, _XimDecodeHotKey},
{XNHotKeyState, 0,
{OFFSET_XNHOTKEYSTATE, 0,
XOffsetOf(XimDefICValues, hotkey_state),
_XimDefaultHotKeyState, _XimEncodeHotKetState, _XimDecodeHotKetState},
{XNPreeditAttributes, 0,
{OFFSET_XNPREEDITATTRIBUTES, 0,
XOffsetOf(XimDefICValues, preedit_attr),
_XimDefaultNest, _XimEncodeNest, _XimDecodeNest},
{XNStatusAttributes, 0,
{OFFSET_XNSTATUSATTRIBUTES, 0,
XOffsetOf(XimDefICValues, status_attr),
_XimDefaultNest, _XimEncodeNest, _XimDecodeNest},
};
static XimValueOffsetInfoRec ic_pre_attr_info[] = {
{XNArea, 0,
{OFFSET_XNAREA, 0,
XOffsetOf(ICPreeditAttributes, area),
_XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle},
{XNAreaNeeded, 0,
{OFFSET_XNAREANEEDED, 0,
XOffsetOf(ICPreeditAttributes, area_needed),
NULL, _XimEncodeRectangle, _XimDecodeRectangle},
{XNSpotLocation, 0,
{OFFSET_XNSPOTLOCATION, 0,
XOffsetOf(ICPreeditAttributes, spot_location),
NULL, _XimEncodeSpot, _XimDecodeSpot},
{XNColormap, 0,
{OFFSET_XNCOLORMAP, 0,
XOffsetOf(ICPreeditAttributes, colormap),
_XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap},
{XNStdColormap, 0,
{OFFSET_XNSTDCOLORMAP, 0,
XOffsetOf(ICPreeditAttributes, std_colormap),
_XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap},
{XNForeground, 0,
{OFFSET_XNFOREGROUND, 0,
XOffsetOf(ICPreeditAttributes, foreground),
_XimDefaultFg, _XimEncodeLong, _XimDecodeLong},
{XNBackground, 0,
{OFFSET_XNBACKGROUND, 0,
XOffsetOf(ICPreeditAttributes, background),
_XimDefaultBg, _XimEncodeLong, _XimDecodeLong},
{XNBackgroundPixmap, 0,
{OFFSET_XNBACKGROUNDPIXMAP, 0,
XOffsetOf(ICPreeditAttributes, background_pixmap),
_XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap},
{XNFontSet, 0,
{OFFSET_XNFONTSET, 0,
XOffsetOf(ICPreeditAttributes, fontset),
_XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet},
{XNLineSpace, 0,
{OFFSET_XNLINESPACE, 0,
XOffsetOf(ICPreeditAttributes, line_spacing),
_XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace},
{XNCursor, 0,
{OFFSET_XNCURSOR, 0,
XOffsetOf(ICPreeditAttributes, cursor),
_XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor},
{XNPreeditStartCallback, 0,
{OFFSET_XNPREEDITSTARTCALLBACK, 0,
XOffsetOf(ICPreeditAttributes, start_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback},
{XNPreeditDoneCallback, 0,
{OFFSET_XNPREEDITDONECALLBACK, 0,
XOffsetOf(ICPreeditAttributes, done_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback},
{XNPreeditDrawCallback, 0,
{OFFSET_XNPREEDITDRAWCALLBACK, 0,
XOffsetOf(ICPreeditAttributes, draw_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback},
{XNPreeditCaretCallback, 0,
{OFFSET_XNPREEDITCARETCALLBACK, 0,
XOffsetOf(ICPreeditAttributes, caret_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback},
{XNPreeditState, 0,
{OFFSET_XNPREEDITSTATE, 0,
XOffsetOf(ICPreeditAttributes, preedit_state),
_XimDefaultPreeditState, _XimEncodePreeditState,_XimDecodePreeditState},
{XNPreeditStateNotifyCallback, 0,
{OFFSET_XNPREEDITSTATENOTIFYCALLBACK, 0,
XOffsetOf(ICPreeditAttributes, state_notify_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback},
};
static XimValueOffsetInfoRec ic_sts_attr_info[] = {
{XNArea, 0,
{OFFSET_XNAREA, 0,
XOffsetOf(ICStatusAttributes, area),
_XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle},
{XNAreaNeeded, 0,
{OFFSET_XNAREANEEDED, 0,
XOffsetOf(ICStatusAttributes, area_needed),
NULL, _XimEncodeRectangle, _XimDecodeRectangle},
{XNColormap, 0,
{OFFSET_XNCOLORMAP, 0,
XOffsetOf(ICStatusAttributes, colormap),
_XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap},
{XNStdColormap, 0,
{OFFSET_XNSTDCOLORMAP, 0,
XOffsetOf(ICStatusAttributes, std_colormap),
_XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap},
{XNForeground, 0,
{OFFSET_XNFOREGROUND, 0,
XOffsetOf(ICStatusAttributes, foreground),
_XimDefaultFg, _XimEncodeLong, _XimDecodeLong},
{XNBackground, 0,
{OFFSET_XNBACKGROUND, 0,
XOffsetOf(ICStatusAttributes, background),
_XimDefaultBg, _XimEncodeLong, _XimDecodeLong},
{XNBackgroundPixmap, 0,
{OFFSET_XNBACKGROUNDPIXMAP, 0,
XOffsetOf(ICStatusAttributes, background_pixmap),
_XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap},
{XNFontSet, 0,
{OFFSET_XNFONTSET, 0,
XOffsetOf(ICStatusAttributes, fontset),
_XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet},
{XNLineSpace, 0,
{OFFSET_XNLINESPACE, 0,
XOffsetOf(ICStatusAttributes, line_spacing),
_XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace},
{XNCursor, 0,
{OFFSET_XNCURSOR, 0,
XOffsetOf(ICStatusAttributes, cursor),
_XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor},
{XNStatusStartCallback, 0,
{OFFSET_XNSTATUSSTARTCALLBACK, 0,
XOffsetOf(ICStatusAttributes, start_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback},
{XNStatusDoneCallback, 0,
{OFFSET_XNSTATUSDONECALLBACK, 0,
XOffsetOf(ICStatusAttributes, done_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback},
{XNStatusDrawCallback, 0,
{OFFSET_XNSTATUSDRAWCALLBACK, 0,
XOffsetOf(ICStatusAttributes, draw_callback),
NULL, _XimEncodeCallback, _XimDecodeCallback}
};
typedef struct _XimIMMode {
char *name;
XrmQuark quark;
unsigned short name_offset;
unsigned short mode;
} XimIMMode;
static XimIMMode im_mode[] = {
{XNQueryInputStyle, 0,
static const XimIMMode im_mode[] = {
{OFFSET_XNQUERYINPUTSTYLE,
(XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
{XNDestroyCallback, 0,
{OFFSET_XNDESTROYCALLBACK,
(XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
{XNResourceName, 0,
{OFFSET_XNRESOURCENAME,
(XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
{XNResourceClass, 0,
{OFFSET_XNRESOURCECLASS,
(XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
{XNQueryIMValuesList, 0,
{OFFSET_XNQUERYIMVALUESLIST,
(XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
{XNQueryICValuesList, 0,
{OFFSET_XNQUERYICVALUESLIST,
(XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
{XNVisiblePosition, 0,
{OFFSET_XNVISIBLEPOSITION,
(XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)}
};
typedef struct _XimICMode {
char *name;
XrmQuark quark;
unsigned short name_offset;
unsigned short preedit_callback_mode;
unsigned short preedit_position_mode;
unsigned short preedit_area_mode;
......@@ -1689,8 +1771,8 @@ typedef struct _XimICMode {
unsigned short status_none_mode;
} XimICMode;
static XimICMode ic_mode[] = {
{XNInputStyle, 0,
static const XimICMode ic_mode[] = {
{OFFSET_XNINPUTSTYLE,
(XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
......@@ -1700,7 +1782,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
(XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
(XIM_MODE_STS_CREATE | XIM_MODE_STS_GET)},
{XNClientWindow, 0,
{OFFSET_XNCLIENTWINDOW,
(XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
......@@ -1710,7 +1792,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
(XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
0},
{XNFocusWindow, 0,
{OFFSET_XNFOCUSWINDOW,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1720,7 +1802,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNResourceName, 0,
{OFFSET_XNRESOURCENAME,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1730,7 +1812,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNResourceClass, 0,
{OFFSET_XNRESOURCECLASS,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1740,7 +1822,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNGeometryCallback, 0,
{OFFSET_XNGEOMETRYCALLBACK,
0,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1750,7 +1832,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0,
0},
{XNFilterEvents, 0,
{OFFSET_XNFILTEREVENTS,
XIM_MODE_PRE_GET,
XIM_MODE_PRE_GET,
XIM_MODE_PRE_GET,
......@@ -1760,7 +1842,7 @@ static XimICMode ic_mode[] = {
XIM_MODE_STS_GET,
XIM_MODE_STS_GET,
XIM_MODE_STS_GET},
{XNDestroyCallback, 0,
{OFFSET_XNDESTROYCALLBACK,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1770,7 +1852,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNStringConversionCallback, 0,
{OFFSET_XNSTRINGCONVERSIONCALLBACK,
(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1780,7 +1862,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNStringConversion, 0,
{OFFSET_XNSTRINGCONVERSION,
XIM_MODE_PRE_SET,
XIM_MODE_PRE_SET,
XIM_MODE_PRE_SET,
......@@ -1790,7 +1872,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNResetState, 0,
{OFFSET_XNRESETSTATE,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1800,7 +1882,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNHotKey, 0,
{OFFSET_XNHOTKEY,
(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1810,7 +1892,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNHotKeyState, 0,
{OFFSET_XNHOTKEYSTATE,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1820,7 +1902,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNPreeditAttributes, 0,
{OFFSET_XNPREEDITATTRIBUTES,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1830,7 +1912,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNStatusAttributes, 0,
{OFFSET_XNSTATUSATTRIBUTES,
0,
0,
0,
......@@ -1840,7 +1922,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNArea, 0,
{OFFSET_XNAREA,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1850,7 +1932,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0,
0},
{XNAreaNeeded, 0,
{OFFSET_XNAREANEEDED,
0,
0,
(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1860,7 +1942,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0,
0},
{XNSpotLocation, 0,
{OFFSET_XNSPOTLOCATION,
0, /*(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),*/
(XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
0,
......@@ -1870,7 +1952,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNColormap, 0,
{OFFSET_XNCOLORMAP,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1880,7 +1962,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNStdColormap, 0,
{OFFSET_XNSTDCOLORMAP,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1890,7 +1972,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNForeground, 0,
{OFFSET_XNFOREGROUND,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1900,7 +1982,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNBackground, 0,
{OFFSET_XNBACKGROUND,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1910,7 +1992,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNBackgroundPixmap, 0,
{OFFSET_XNBACKGROUNDPIXMAP,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1920,7 +2002,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNFontSet, 0,
{OFFSET_XNFONTSET,
0,
(XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1930,7 +2012,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNLineSpace, 0,
{OFFSET_XNLINESPACE,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1940,7 +2022,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNCursor, 0,
{OFFSET_XNCURSOR,
0,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -1950,7 +2032,7 @@ static XimICMode ic_mode[] = {
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
(XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
0},
{XNPreeditStartCallback, 0,
{OFFSET_XNPREEDITSTARTCALLBACK,
(XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
0,
0,
......@@ -1960,7 +2042,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNPreeditDoneCallback, 0,
{OFFSET_XNPREEDITDONECALLBACK,
(XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
0,
0,
......@@ -1970,7 +2052,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNPreeditDrawCallback, 0,
{OFFSET_XNPREEDITDRAWCALLBACK,
(XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
0,
0,
......@@ -1980,7 +2062,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNPreeditCaretCallback, 0,
{OFFSET_XNPREEDITCARETCALLBACK,
(XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
0,
0,
......@@ -1990,7 +2072,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNPreeditState, 0,
{OFFSET_XNPREEDITSTATE,
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -2000,7 +2082,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNPreeditStateNotifyCallback, 0,
{OFFSET_XNPREEDITSTATENOTIFYCALLBACK,
(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
(XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
......@@ -2010,7 +2092,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNStatusStartCallback, 0,
{OFFSET_XNSTATUSSTARTCALLBACK,
0,
0,
0,
......@@ -2020,7 +2102,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNStatusDoneCallback, 0,
{OFFSET_XNSTATUSDONECALLBACK,
0,
0,
0,
......@@ -2030,7 +2112,7 @@ static XimICMode ic_mode[] = {
0,
0,
0},
{XNStatusDrawCallback, 0,
{OFFSET_XNSTATUSDRAWCALLBACK,
0,
0,
0,
......@@ -2042,6 +2124,12 @@ static XimICMode ic_mode[] = {
0}
};
/* the quarks are separated from im_mode/ic_mode so those arrays
* can be const.
*/
static XrmQuark im_mode_quark[sizeof(im_mode) / sizeof(im_mode[0])];
static XrmQuark ic_mode_quark[sizeof(ic_mode) / sizeof(ic_mode[0])];
Private Bool
_XimSetResourceList(
XIMResourceList *res_list,
......@@ -2154,7 +2242,7 @@ Public XIMResourceList
_XimGetResourceListRec(
XIMResourceList res_list,
unsigned int list_num,
char *name)
const char *name)
{
XrmQuark quark = XrmStringToQuark(name);
......@@ -2232,7 +2320,7 @@ _XimSetIMMode(
for(i = 0; i < n; i++) {
if(!(res = _XimGetResourceListRecByQuark(res_list,
list_num, im_mode[i].quark))) {
list_num, im_mode_quark[i]))) {
continue;
}
res->mode = im_mode[i].mode;
......@@ -2290,10 +2378,7 @@ Public int
}
Public void
_XimSetICMode(res_list, list_num, style)
XIMResourceList res_list;
unsigned int list_num;
XIMStyle style;
_XimSetICMode(XIMResourceList res_list, unsigned int list_num, XIMStyle style)
{
XIMResourceList res;
unsigned int n = XIMNumber(ic_mode);
......@@ -2325,7 +2410,7 @@ _XimSetICMode(res_list, list_num, style)
for(i = 0; i < n; i++) {
if(!(res = _XimGetResourceListRecByQuark(res_list,
list_num, ic_mode[i].quark))) {
list_num, ic_mode_quark[i]))) {
continue;
}
res->mode = ( (*(unsigned short *)((char *)&ic_mode[i] + pre_offset))
......@@ -2700,7 +2785,7 @@ _XimEncodeLocalTopValue(
if (flag) {
_XRegisterFilterByType(ic->core.im->core.display,
ic->core.focus_window,
KeyPress, KeyPress, _XimLocalFilter, (XPointer)ic);
KeyPress, KeyRelease, _XimLocalFilter, (XPointer)ic);
}
} else if (res->xrm_name == XrmStringToQuark(XNFocusWindow)) {
if (ic->core.client_window) {
......@@ -2711,7 +2796,7 @@ _XimEncodeLocalTopValue(
ic->core.focus_window = (Window)p->value;
if (flag) {
_XRegisterFilterByType(ic->core.im->core.display,
ic->core.focus_window, KeyPress, KeyPress,
ic->core.focus_window, KeyPress, KeyRelease,
_XimLocalFilter, (XPointer)ic);
}
} else
......@@ -2928,13 +3013,8 @@ _XimDecodeLocalICAttr(
}
Public char *
_XimGetICValueData(ic, top, res_list, list_num, values, mode)
Xic ic;
XPointer top;
XIMResourceList res_list;
unsigned int list_num;
XIMArg *values;
unsigned long mode;
_XimGetICValueData(Xic ic, XPointer top, XIMResourceList res_list,
unsigned int list_num, XIMArg *values, unsigned long mode)
{
register XIMArg *p;
XIMResourceList res;
......@@ -2982,9 +3062,7 @@ _XimGetICValueData(ic, top, res_list, list_num, values, mode)
}
Public void
_XimGetCurrentIMValues(im, im_values)
Xim im;
XimDefIMValues *im_values;
_XimGetCurrentIMValues(Xim im, XimDefIMValues *im_values)
{
bzero((char *)im_values, sizeof(XimDefIMValues));
......@@ -2998,9 +3076,7 @@ _XimGetCurrentIMValues(im, im_values)
}
Public void
_XimSetCurrentIMValues(im, im_values)
Xim im;
XimDefIMValues *im_values;
_XimSetCurrentIMValues(Xim im, XimDefIMValues *im_values)
{
im->core.styles = im_values->styles;
im->core.im_values_list = im_values->im_values_list;
......@@ -3012,9 +3088,7 @@ _XimSetCurrentIMValues(im, im_values)
}
Public void
_XimGetCurrentICValues(ic, ic_values)
Xic ic;
XimDefICValues *ic_values;
_XimGetCurrentICValues(Xic ic, XimDefICValues *ic_values)
{
bzero((char *)ic_values, sizeof(XimDefICValues));
......@@ -3067,7 +3141,7 @@ _XimInitialIMOffsetInfo(void)
register int i;
for(i = 0; i < n; i++) {
im_attr_info[i].quark = XrmStringToQuark(im_attr_info[i].name);
im_attr_info[i].quark = XrmStringToQuark(GET_NAME(im_attr_info[i]));
}
}
......@@ -3079,17 +3153,17 @@ _XimInitialICOffsetInfo(void)
n = XIMNumber(ic_attr_info);
for(i = 0; i < n; i++) {
ic_attr_info[i].quark = XrmStringToQuark(ic_attr_info[i].name);
ic_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_attr_info[i]));
}
n = XIMNumber(ic_pre_attr_info);
for(i = 0; i < n; i++) {
ic_pre_attr_info[i].quark = XrmStringToQuark(ic_pre_attr_info[i].name);
ic_pre_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_pre_attr_info[i]));
}
n = XIMNumber(ic_sts_attr_info);
for(i = 0; i < n; i++) {
ic_sts_attr_info[i].quark = XrmStringToQuark(ic_sts_attr_info[i].name);
ic_sts_attr_info[i].quark = XrmStringToQuark(GET_NAME(ic_sts_attr_info[i]));
}
}
......@@ -3100,7 +3174,7 @@ _XimInitialIMMode(void)
register int i;
for(i = 0; i < n; i++) {
im_mode[i].quark = XrmStringToQuark(im_mode[i].name);
im_mode_quark[i] = XrmStringToQuark(GET_NAME(im_mode[i]));
}
}
......@@ -3111,7 +3185,7 @@ _XimInitialICMode(void)
register int i;
for(i = 0; i < n; i++) {
ic_mode[i].quark = XrmStringToQuark(ic_mode[i].name);
ic_mode_quark[i] = XrmStringToQuark(GET_NAME(ic_mode[i]));
}
}
......
......@@ -520,9 +520,9 @@ Private Bool ThaiComposeConvert(
* Macros to save and recall last input character in XIC
*/
#define IC_SavePreviousChar(ic,ch) \
(*((ic)->private.local.context->mb) = (char) (ch))
((ic)->private.local.base.mb[(ic)->private.local.base.tree[(ic)->private.local.context].mb] = (char) (ch))
#define IC_ClearPreviousChar(ic) \
(*((ic)->private.local.context->mb) = 0)
((ic)->private.local.base.mb[(ic)->private.local.base.tree[(ic)->private.local.context].mb] = 0)
#define IC_GetPreviousChar(ic) \
(IC_RealGetPreviousChar(ic,1))
#define IC_GetContextChar(ic) \
......@@ -534,6 +534,7 @@ Private unsigned char
IC_RealGetPreviousChar(Xic ic, unsigned short pos)
{
XICCallback* cb = &ic->core.string_conversion_callback;
DefTreeBase *b = &ic->private.local.base;
if (cb && cb->callback) {
XIMStringConversionCallbackStruct screc;
......@@ -550,25 +551,49 @@ IC_RealGetPreviousChar(Xic ic, unsigned short pos)
(cb->callback)((XIC)ic, cb->client_data, (XPointer)&screc);
if (!screc.text)
return (unsigned char) *((ic)->private.local.context->mb);
return (unsigned char) b->mb[b->tree[(ic)->private.local.context].mb];
if ((screc.text->feedback &&
*screc.text->feedback == XIMStringConversionLeftEdge) ||
screc.text->length < 1)
{
c = 0;
} else {
Xim im;
XlcConv conv;
int from_left;
int to_left;
char *from_buf;
char *to_buf;
im = (Xim) XIMOfIC((XIC)ic);
if (screc.text->encoding_is_wchar) {
c = ucs2tis(screc.text->string.wcs[0]);
XFree(screc.text->string.wcs);
conv = _XlcOpenConverter(im->core.lcd, XlcNWideChar,
im->core.lcd, XlcNCharSet);
from_buf = (char *) screc.text->string.wcs;
from_left = screc.text->length * sizeof(wchar_t);
} else {
c = screc.text->string.mbs[0];
XFree(screc.text->string.mbs);
conv = _XlcOpenConverter(im->core.lcd, XlcNMultiByte,
im->core.lcd, XlcNCharSet);
from_buf = screc.text->string.mbs;
from_left = screc.text->length;
}
to_buf = (char *)&c;
to_left = 1;
_XlcResetConverter(conv);
if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
(XPointer *)&to_buf, &to_left, NULL, 0) < 0)
{
c = (unsigned char) b->mb[b->tree[(ic)->private.local.context].mb];
}
_XlcCloseConverter(conv);
XFree(screc.text->string.mbs);
}
XFree(screc.text);
return c;
} else {
return (unsigned char) *((ic)->private.local.context->mb);
return (unsigned char) b->mb[b->tree[(ic)->private.local.context].mb];
}
}
......@@ -1191,13 +1216,14 @@ Private void InitIscMode(Xic ic)
Private Bool
ThaiFltAcceptInput(Xic ic, unsigned char new_char, KeySym symbol)
{
ic->private.local.composed->wc[0] = tis2ucs(new_char);
ic->private.local.composed->wc[1] = '\0';
DefTreeBase *b = &ic->private.local.base;
b->wc[b->tree[ic->private.local.composed].wc+0] = tis2ucs(new_char);
b->wc[b->tree[ic->private.local.composed].wc+1] = '\0';
if ((new_char <= 0x1f) || (new_char == 0x7f))
ic->private.local.composed->keysym = symbol;
b->tree[ic->private.local.composed].keysym = symbol;
else
ic->private.local.composed->keysym = NoSymbol;
b->tree[ic->private.local.composed].keysym = NoSymbol;
return True;
}
......@@ -1205,12 +1231,13 @@ ThaiFltAcceptInput(Xic ic, unsigned char new_char, KeySym symbol)
Private Bool
ThaiFltReorderInput(Xic ic, unsigned char previous_char, unsigned char new_char)
{
DefTreeBase *b = &ic->private.local.base;
if (!IC_DeletePreviousChar(ic)) return False;
ic->private.local.composed->wc[0] = tis2ucs(new_char);
ic->private.local.composed->wc[1] = tis2ucs(previous_char);
ic->private.local.composed->wc[2] = '\0';
b->wc[b->tree[ic->private.local.composed].wc+0] = tis2ucs(new_char);
b->wc[b->tree[ic->private.local.composed].wc+1] = tis2ucs(previous_char);
b->wc[b->tree[ic->private.local.composed].wc+2] = '\0';
ic->private.local.composed->keysym = NoSymbol;
b->tree[ic->private.local.composed].keysym = NoSymbol;
return True;
}
......@@ -1218,27 +1245,40 @@ ThaiFltReorderInput(Xic ic, unsigned char previous_char, unsigned char new_char)
Private Bool
ThaiFltReplaceInput(Xic ic, unsigned char new_char, KeySym symbol)
{
DefTreeBase *b = &ic->private.local.base;
if (!IC_DeletePreviousChar(ic)) return False;
ic->private.local.composed->wc[0] = tis2ucs(new_char);
ic->private.local.composed->wc[1] = '\0';
b->wc[b->tree[ic->private.local.composed].wc+0] = tis2ucs(new_char);
b->wc[b->tree[ic->private.local.composed].wc+1] = '\0';
if ((new_char <= 0x1f) || (new_char == 0x7f))
ic->private.local.composed->keysym = symbol;
b->tree[ic->private.local.composed].keysym = symbol;
else
ic->private.local.composed->keysym = NoSymbol;
b->tree[ic->private.local.composed].keysym = NoSymbol;
return True;
}
Private unsigned
NumLockMask(Display *d)
{
int i;
XModifierKeymap *map = XGetModifierMapping (d);
KeyCode numlock_keycode = XKeysymToKeycode (d, XK_Num_Lock);
if (numlock_keycode == NoSymbol)
return 0;
for (i = 0; i < 8; i++) {
if (map->modifiermap[map->max_keypermod * i] == numlock_keycode)
return 1 << i;
}
return 0;
}
/*
* Filter function for TACTIS
*/
Bool
_XimThaiFilter(d, w, ev, client_data)
Display *d;
Window w;
XEvent *ev;
XPointer client_data;
_XimThaiFilter(Display *d, Window w, XEvent *ev, XPointer client_data)
{
Xic ic = (Xic)client_data;
KeySym symbol;
......@@ -1254,6 +1294,7 @@ XPointer client_data;
#endif
wchar_t wbuf[10];
Bool isReject;
DefTreeBase *b = &ic->private.local.base;
if ((ev->type != KeyPress)
|| (ev->xkey.keycode == 0))
......@@ -1264,7 +1305,7 @@ XPointer client_data;
XwcLookupString((XIC)ic, &ev->xkey, wbuf, sizeof(wbuf) / sizeof(wbuf[0]),
&symbol, NULL);
if ((ev->xkey.state & (AllMods & ~ShiftMask)) ||
if ((ev->xkey.state & (AllMods & ~(ShiftMask|LockMask|NumLockMask(d)))) ||
((symbol >> 8 == 0xFF) &&
((XK_BackSpace <= symbol && symbol <= XK_Clear) ||
(symbol == XK_Return) ||
......@@ -1356,11 +1397,11 @@ XPointer client_data;
return True;
}
_Xlcwcstombs(ic->core.im->core.lcd, ic->private.local.composed->mb,
ic->private.local.composed->wc, 10);
_Xlcwcstombs(ic->core.im->core.lcd, &b->mb[b->tree[ic->private.local.composed].mb],
&b->wc[b->tree[ic->private.local.composed].wc], 10);
_Xlcmbstoutf8(ic->core.im->core.lcd, ic->private.local.composed->utf8,
ic->private.local.composed->mb, 10);
_Xlcmbstoutf8(ic->core.im->core.lcd, &b->utf8[b->tree[ic->private.local.composed].utf8],
&b->mb[b->tree[ic->private.local.composed].mb], 10);
/* Remember the last character inputted
* (as fallback in case StringConversionCallback is not provided)
......
......@@ -60,6 +60,8 @@ _XimThaiDestroyIC(
XIC xic)
{
Xic ic = (Xic)xic;
DefTreeBase *b = &ic->private.local.base;
if(((Xim)ic->core.im)->private.local.current_ic == (XIC)ic) {
_XimThaiUnSetFocus(xic);
}
......@@ -68,14 +70,14 @@ _XimThaiDestroyIC(
ic->private.local.ic_resources = NULL;
}
Xfree(ic->private.local.context->mb);
Xfree(ic->private.local.context->wc);
Xfree(ic->private.local.context->utf8);
Xfree(ic->private.local.context);
Xfree(ic->private.local.composed->mb);
Xfree(ic->private.local.composed->wc);
Xfree(ic->private.local.composed->utf8);
Xfree(ic->private.local.composed);
if (b->tree) Xfree (b->tree);
if (b->mb) Xfree (b->mb);
if (b->wc) Xfree (b->wc);
if (b->utf8) Xfree (b->utf8);
b->tree = NULL;
b->mb = NULL;
b->wc = NULL;
b->utf8 = NULL;
return;
}
......@@ -105,11 +107,12 @@ _XimThaiReset(
XIC xic)
{
Xic ic = (Xic)xic;
DefTreeBase *b = &ic->private.local.base;
ic->private.local.thai.comp_state = 0;
ic->private.local.thai.keysym = 0;
ic->private.local.composed->mb[0] = '\0';
ic->private.local.composed->wc[0] = 0;
ic->private.local.composed->utf8[0] = '\0';
b->mb[b->tree[ic->private.local.composed].mb] = '\0';
b->wc[b->tree[ic->private.local.composed].wc] = '\0';
b->utf8[b->tree[ic->private.local.composed].utf8] = '\0';
}
Private char *
......@@ -152,6 +155,7 @@ _XimThaiCreateIC(
XIMResourceList res;
unsigned int num;
int len;
DefTree *tree;
if((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) {
return ((XIC)NULL);
......@@ -161,30 +165,23 @@ _XimThaiCreateIC(
ic->methods = &Thai_ic_methods;
ic->core.im = im;
ic->core.filter_events = KeyPressMask;
if ((ic->private.local.context = (DefTree *)Xmalloc(sizeof(DefTree)))
== (DefTree *)NULL)
goto Set_Error;
if ((ic->private.local.context->mb = (char *)Xmalloc(10))
== (char *)NULL)
goto Set_Error;
if ((ic->private.local.context->wc = (wchar_t *)Xmalloc(10*sizeof(wchar_t)))
== (wchar_t *)NULL)
goto Set_Error;
if ((ic->private.local.context->utf8 = (char *)Xmalloc(10))
== (char *)NULL)
goto Set_Error;
if ((ic->private.local.composed = (DefTree *)Xmalloc(sizeof(DefTree)))
== (DefTree *)NULL)
if (! (ic->private.local.base.tree = tree = (DefTree *)Xmalloc(sizeof(DefTree)*3)) )
goto Set_Error;
if ((ic->private.local.composed->mb = (char *)Xmalloc(10))
== (char *)NULL)
if (! (ic->private.local.base.mb = (char *)Xmalloc(21)) )
goto Set_Error;
if ((ic->private.local.composed->wc = (wchar_t *)Xmalloc(10*sizeof(wchar_t)))
== (wchar_t *)NULL)
if (! (ic->private.local.base.wc = (wchar_t*)Xmalloc(sizeof(wchar_t)*21)) )
goto Set_Error;
if ((ic->private.local.composed->utf8 = (char *)Xmalloc(10))
== (char *)NULL)
if (! (ic->private.local.base.utf8 = (char *)Xmalloc(21)) )
goto Set_Error;
ic->private.local.context = 1;
tree[1].mb = 1;
tree[1].wc = 1;
tree[1].utf8 = 1;
ic->private.local.composed = 2;
tree[2].mb = 11;
tree[2].wc = 11;
tree[2].utf8 = 11;
ic->private.local.thai.comp_state = 0;
ic->private.local.thai.keysym = 0;
......
......@@ -59,21 +59,25 @@ Private XIMMethodsRec Xim_im_thai_methods = {
#define THAI_LANGUAGE_NAME "th"
Bool
_XimCheckIfThaiProcessing(im)
Xim im;
_XimCheckIfThaiProcessing(Xim im)
{
char *language;
_XGetLCValues(im->core.lcd, XlcNLanguage, &language, NULL);
if(strcmp(language, THAI_LANGUAGE_NAME) == 0) {
if(strcmp(language, THAI_LANGUAGE_NAME) == 0 &&
(strcmp(im->core.im_name, "") == 0 ||
strcmp(im->core.im_name, "BasicCheck") == 0 ||
strcmp(im->core.im_name, "Strict") == 0 ||
strcmp(im->core.im_name, "Thaicat") == 0 ||
strcmp(im->core.im_name, "Passthrough") == 0))
{
return(True);
}
return(False);
}
Public Bool
_XimThaiOpenIM(im)
Xim im;
_XimThaiOpenIM(Xim im)
{
XLCd lcd = im->core.lcd;
XlcConv conv;
......@@ -142,8 +146,7 @@ Open_Error :
}
Public void
_XimThaiIMFree(im)
Xim im;
_XimThaiIMFree(Xim im)
{
if(im->core.im_resources) {
Xfree(im->core.im_resources);
......@@ -213,8 +216,7 @@ _XimThaiIMFree(im)
}
Public Status
_XimThaiCloseIM(xim)
XIM xim;
_XimThaiCloseIM(XIM xim)
{
Xim im = (Xim)xim;
XIC ic;
......
/*
* Copyright 1992 Sun Microsystems, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/******************************************************************
Copyright 1992 by Sun Microsystems, Inc.
Copyright 1992, 1993, 1994 by FUJITSU LIMITED
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear
in supporting documentation, and that the name of Sun Microsystems, Inc.
and FUJITSU LIMITED not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.
Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
the suitability of this software for any purpose.
in supporting documentation, and that the name of FUJITSU LIMITED
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
FUJITSU LIMITED makes no representations about the suitability of
this software for any purpose.
It is provided "as is" without express or implied warranty.
Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
Takashi Fujiwara FUJITSU LIMITED
......@@ -153,6 +174,8 @@ _XimXConnect(Xim im)
event.xclient.data.l[0] = (CARD32)spec->lib_connect_wid;
event.xclient.data.l[1] = spec->major_code;
event.xclient.data.l[2] = spec->minor_code;
event.xclient.data.l[3] = 0;
event.xclient.data.l[4] = 0;
if(event.xclient.data.l[1] == 1 || event.xclient.data.l[1] == 2) {
XWindowAttributes atr;
......@@ -353,6 +376,7 @@ _XimXGetReadData(
(void)memcpy(buf, prop_ret, (int)nitems);
*ret_len = (int)nitems;
if (bytes_after_ret > 0) {
XFree(prop_ret);
XGetWindowProperty(im->core.display,
spec->lib_connect_wid, prop, 0L,
((length + bytes_after_ret + 3)/ 4), True, AnyPropertyType,
......@@ -459,9 +483,7 @@ _XimXFlush(Xim im)
}
Public Bool
_XimXConf(im, address)
Xim im;
char *address;
_XimXConf(Xim im, char *address)
{
XSpecRec *spec;
......
/*
* Copyright 1992 Sun Microsystems, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/******************************************************************
Copyright 1992 by Sun Microsystems, Inc.
Copyright 1992, 1993, 1994 by FUJITSU LIMITED
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear
in supporting documentation, and that the name of Sun Microsystems, Inc.
and FUJITSU LIMITED not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.
Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
the suitability of this software for any purpose.
in supporting documentation, and that the name of FUJITSU LIMITED
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
FUJITSU LIMITED makes no representations about the suitability of
this software for any purpose.
It is provided "as is" without express or implied warranty.
Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
Takashi Fujiwara FUJITSU LIMITED
......@@ -74,10 +95,7 @@ _XimTransConnect(
spec->trans_conn = NULL;
if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
{
sleep(1);
continue;
}
else
break;
}
......
/*
* Copyright 1992 Sun Microsystems, Inc. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
/******************************************************************
Copyright 1992 by Sun Microsystems, Inc.
Copyright 1992, 1993, 1994 by FUJITSU LIMITED
Permission to use, copy, modify, distribute, and sell this software
and its documentation for any purpose is hereby granted without fee,
provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear
in supporting documentation, and that the name of Sun Microsystems, Inc.
and FUJITSU LIMITED not be used in advertising or publicity pertaining to
distribution of the software without specific, written prior permission.
Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
the suitability of this software for any purpose.
in supporting documentation, and that the name of FUJITSU LIMITED
not be used in advertising or publicity pertaining to distribution
of the software without specific, written prior permission.
FUJITSU LIMITED makes no representations about the suitability of
this software for any purpose.
It is provided "as is" without express or implied warranty.
Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
EVENT SHALL FUJITSU LIMITED BE LIABLE FOR ANY SPECIAL, INDIRECT OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
Takashi Fujiwara FUJITSU LIMITED
......@@ -55,15 +76,13 @@ Public TransportSW _XimTransportRec[] = {
};
Public Bool
_XimConnect(im)
Xim im;
_XimConnect(Xim im)
{
return im->private.proto.connect(im);
}
Public Bool
_XimShutdown(im)
Xim im;
_XimShutdown(Xim im)
{
return im->private.proto.shutdown(im);
}
......@@ -212,15 +231,8 @@ _XimCallDispatcher(
}
Public int
_XimRead(im, len, buf, buf_size, predicate, arg)
Xim im;
INT16 *len;
XPointer buf;
int buf_size;
Bool (*predicate)(
Xim, INT16, XPointer, XPointer
);
XPointer arg;
_XimRead(Xim im, INT16 *len, XPointer buf, int buf_size,
Bool (*predicate)(Xim, INT16, XPointer, XPointer), XPointer arg)
{
INT16 read_len;
int ret_code;
......@@ -252,16 +264,14 @@ _XimRegisterDispatcher(
}
Public void
_XimFlush(im)
Xim im;
_XimFlush(Xim im)
{
im->private.proto.flush(im);
return;
}
Public Bool
_XimFilterWaitEvent(im)
Xim im;
_XimFilterWaitEvent(Xim im)
{
INT16 read_len;
CARD32 reply32[BUFSIZE/4];
......
......@@ -44,7 +44,7 @@
#define MB_LEN_MAX 6
#endif
#if !defined(macII) && !defined(Lynx_22) && !defined(X_LOCALE)
#if !defined(Lynx_22) && !defined(X_LOCALE)
#define STDCVT
#endif
......
......@@ -53,13 +53,13 @@
#include "XlcGeneric.h"
#include <stdio.h>
#if !defined(macII) && !defined(Lynx_22) && !defined(X_LOCALE)
#if !defined(Lynx_22) && !defined(X_LOCALE)
#define STDCVT
#endif
typedef struct _CTDataRec {
char *name;
char *encoding; /* Compound Text encoding */
const char *name;
const char *encoding; /* Compound Text encoding */
} CTDataRec, *CTData;
static CTDataRec directionality_data[] =
......
......@@ -39,7 +39,7 @@
#include "XlcGeneric.h"
#include <stdio.h>
#if !defined(macII) && !defined(X_LOCALE)
#if !defined(X_LOCALE)
#define STDCVT
#endif
......
/* $TOG: $ */
/******************************************************************
Copyright 1993 by SunSoft, Inc.
......@@ -50,13 +49,21 @@ _XlcUtf8Loader(
return lcd;
/* The official IANA name for UTF-8 is "UTF-8" in upper case with a dash. */
if (!XLC_PUBLIC_PART(lcd)->codeset ||
(_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "UTF-8"))) {
if (!XLC_PUBLIC_PART(lcd)->codeset) {
_XlcDestroyLC(lcd);
return (XLCd) NULL;
}
else if (!_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "UTF-8")) {
_XlcAddUtf8LocaleConverters(lcd);
}
else if (!_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "GB18030")) {
_XlcAddGB18030LocaleConverters(lcd);
}
else {
_XlcDestroyLC(lcd);
return (XLCd) NULL;
}
_XlcAddUtf8Converters(lcd);
return lcd;
......
......@@ -410,11 +410,10 @@ set_fontset_extents(
}
}
if(font_set->vrotate_num > 0) {
if(font_set->vrotate_num > 0 && font_set->vrotate != NULL) {
font_data = (FontData) font_set->vrotate;
font_data_count = font_set->vrotate_num;
for( ; font_data_count-- ; font_data++) {
if(font_data != NULL)
if(font_data->font != NULL) {
check_fontset_extents(&overall, &logical_ascent,
&logical_descent,
......@@ -569,6 +568,9 @@ get_rotate_fontname(
if((ptr = strchr(ptr, '-'))) {
*ptr = '\0';
} else {
field_num++; /* Count last field */
break;
}
}
......@@ -613,7 +615,8 @@ get_rotate_fontname(
for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD &&
fields[field_num] ; field_num++) {
sprintf(rotate_font_ptr, "%s-%s", rotate_font_ptr, fields[field_num]);
strcat(rotate_font_ptr, "-");
strcat(rotate_font_ptr, fields[field_num]);
}
if(pattern)
......@@ -1614,7 +1617,7 @@ static XOCMethodsRec oc_generic_methods = {
};
typedef struct _XOCMethodsListRec {
char *name;
const char *name;
XOCMethods methods;
} XOCMethodsListRec, *XOCMethodsList;
......
......@@ -365,7 +365,7 @@ _XomInitConverter(
{
XOCGenericPart *gen = XOC_GENERIC(oc);
XlcConv *convp;
char *conv_type;
const char *conv_type;
XlcConv conv;
XLCd lcd;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment