Commit 9354351f authored by Matthias Hopf's avatar Matthias Hopf

Bug #3104: Compose table cache for faster X11 application starts. Part 1:...

Bug #3104: Compose table cache for faster X11 application starts. Part 1: Pointerless compose data structure, using indices instead of pointers, needed for mmap()ing data structure.
parent b18713ec
......@@ -1264,6 +1264,12 @@ extern int _XOpenFile(
int /* flags */
);
extern int _XOpenFileMode(
_Xconst char* /* path */,
int /* flags */,
mode_t /* mode */
);
extern void* _XFopenFile(
_Xconst char* /* path */,
_Xconst char* /* mode */
......@@ -1274,6 +1280,7 @@ extern int _XAccessFile(
);
#else
#define _XOpenFile(path,flags) open(path,flags)
#define _XOpenFileMode(path,flags,mode) open(path,flags,mode)
#define _XFopenFile(path,mode) fopen(path,mode)
#endif
......
......@@ -49,7 +49,8 @@ _XimLocalFilter(d, w, ev, 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->xkey.keycode == 0)
return (False);
......@@ -74,7 +75,7 @@ _XimLocalFilter(d, w, ev, client_data)
if(ic->private.local.brl_committing) {
ic->private.local.brl_committed =
ic->private.local.brl_committing;
ic->private.local.composed = NULL;
ic->private.local.composed = 0;
ev->type = KeyPress;
ev->xkey.keycode = 0;
_XPutBackEvent(d, ev);
......@@ -85,22 +86,21 @@ _XimLocalFilter(d, w, ev, client_data)
}
if( (ev->type != KeyPress)
|| (((Xim)ic->core.im)->private.local.top == (DefTree *)NULL) )
|| (((Xim)ic->core.im)->private.local.top == 0 ) )
return(False);
for(p = ic->private.local.context; p; p = p->next) {
if(((ev->xkey.state & p->modifier_mask) == p->modifier) &&
(keysym == p->keysym)) {
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(p) { /* Matched */
if(p->succession) { /* Intermediate */
ic->private.local.context = p->succession;
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;
......
......@@ -97,7 +97,7 @@ _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;
......@@ -152,8 +152,9 @@ _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;
......
......@@ -78,23 +78,29 @@ _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) 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);
......@@ -327,6 +333,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;
......
......@@ -56,13 +56,15 @@ _XimLocalMbLookupString(xic, ev, buffer, bytes, keysym, 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)
( (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;
......@@ -79,13 +81,13 @@ _XimLocalMbLookupString(xic, ev, buffer, bytes, keysym, status)
if(status) *status = XLookupChars;
memcpy(buffer, mb, ret);
} else { /* Composed Event */
ret = strlen(ic->private.local.composed->mb);
ret = strlen(&mb[b[ic->private.local.composed].mb]);
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;
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;
......@@ -133,6 +135,8 @@ _XimLocalWcLookupString(xic, ev, buffer, wlen, keysym, 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;
......@@ -153,14 +157,14 @@ _XimLocalWcLookupString(xic, ev, buffer, wlen, keysym, status)
} else
if(status) *status = XLookupChars;
} else { /* Composed Event */
ret = _Xwcslen(ic->private.local.composed->wc);
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;
......@@ -208,6 +212,8 @@ _XimLocalUtf8LookupString(xic, ev, buffer, bytes, keysym, 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;
......@@ -225,13 +231,13 @@ _XimLocalUtf8LookupString(xic, ev, buffer, bytes, keysym, status)
buffer[1] = 0x80 | ((BRL_UC_ROW >> 8) & 0x30) | (pattern >> 6);
buffer[2] = 0x80 | (pattern & 0x3f);
} else { /* Composed Event */
ret = strlen(ic->private.local.composed->utf8);
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;
......
......@@ -422,11 +422,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;
......@@ -438,8 +440,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;
};
......@@ -536,20 +538,24 @@ parseline(
token = nexttoken(fp, tokenbuf, &lastch);
if (token == STRING) {
if( (rhs_string_mb = Xmalloc(strlen(tokenbuf) + 1)) == NULL )
goto error;
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) {
......@@ -563,14 +569,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 ) {
goto error;
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 {
......@@ -581,62 +586,70 @@ 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_wc_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 );
goto error;
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;
p->ks = rhs_keysym;
/* 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:
while (token != ENDOFLINE && token != ENDOFFILE) {
......
......@@ -522,9 +522,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) \
......@@ -536,6 +536,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;
......@@ -552,7 +553,7 @@ 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)
......@@ -570,7 +571,7 @@ IC_RealGetPreviousChar(Xic ic, unsigned short pos)
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];
}
}
......@@ -1193,13 +1194,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;
}
......@@ -1207,12 +1209,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;
}
......@@ -1220,14 +1223,15 @@ 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;
}
......@@ -1256,6 +1260,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))
......@@ -1358,11 +1363,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)
......
......@@ -62,6 +62,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);
}
......@@ -70,14 +72,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;
}
......@@ -107,11 +109,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 *
......@@ -154,6 +157,7 @@ _XimThaiCreateIC(
XIMResourceList res;
unsigned int num;
int len;
DefTree *tree;
if((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) {
return ((XIC)NULL);
......@@ -163,30 +167,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;
......
......@@ -3388,6 +3388,26 @@ int _XOpenFile(path, flags)
return ret;
}
int _XOpenFileMode(path, flags, mode)
_Xconst char* path;
int flags;
mode_t mode;
{
char buf[MAX_PATH];
char* bufp = NULL;
int ret = -1;
UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
if (AccessFile (path, buf, MAX_PATH, &bufp))
ret = open (bufp, flags, mode);
(void) SetErrorMode (olderror);
if (bufp != buf) Xfree (bufp);
return ret;
}
void* _XFopenFile(path, mode)
_Xconst char* path;
_Xconst char* mode;
......
......@@ -40,21 +40,36 @@ THIS SOFTWARE.
#define COMPOSE_FILE "Compose"
/*
* Data Structure for Local Processing
* Data Structures for Local Processing
*/
typedef INT32 DTIndex;
typedef INT32 DTCharIndex;
typedef BITS32 DTModifier;
typedef struct _DefTree {
struct _DefTree *next; /* another Key definition */
struct _DefTree *succession; /* successive Key Sequence */
DTIndex next;
DTIndex succession; /* successive Key Sequence */
/* Key definitions */
unsigned modifier_mask;
unsigned modifier;
DTModifier modifier_mask;
DTModifier modifier;
KeySym keysym; /* leaf only */
char *mb;
wchar_t *wc; /* make from mb */
char *utf8; /* make from mb */