Attached is a proposed patch to fix the XIM protocol in Thai XIM. It's composed of: - a patch to use safe values in Thai XIM which should work regardless of the signness of XIMStringConversionPosition, and in accordance with the re-interpretation of the protocol, - a patch to Xlib.h to change typedef of XIMStringConversionPosition to (signed) short.
I have also prepared another patch for GTK+ imxim, which depends on whether the latter patch to Xlib.h is applied. I'll post it as a follow-up to GNOME bug #101814 soon. -Thep. On Mon, Feb 17, 2003 at 11:02:45PM +0700, Theppitak Karoonboonyanan wrote: > Since the release date of XFree86 4.3.0 is very close, I think this > issue needs clarification, rather than leaving it partially done. > > If there is no objection, I will patch Xlib.h so > XIMStringConversionPosition becomes (signed) short. > > However, another question is raised: > > How is the backward range boundary counted? > > For example: given a text buffer > ABC|DE > [012|34] <-- index > where '|' means caret position (currently 3), > if I want to retrieve "BC", how should I pass the parameter? > a) position = 0, factor = 2, dir = BackwardChar > b) position = -1, factor = 2, dir = BackwardChar > For a): > because saying "starting position = 0" means absolute index 3, counting > backward by factor 2 we get (3,1), sorting the range we get (1,3), and > "BC" is got. > For b): > "starting position = -1" means absolute index 2, counting backward by > factor 2 we get (2,0), and "CB" is got in that direction, meaning "BC" in > logical order. > > Thanks, > -Thep.
diff -Nuar xc/lib/X11/imThaiFlt.c xc.thximconv3/lib/X11/imThaiFlt.c --- xc/lib/X11/imThaiFlt.c 2003-02-20 17:14:49.000000000 +0700 +++ xc.thximconv3/lib/X11/imThaiFlt.c 2003-02-20 17:20:52.000000000 +0700 @@ -602,11 +602,11 @@ #define IC_GetContextChar(ic) \ (IC_RealGetPreviousChar(ic,2)) #define IC_DeletePreviousChar(ic) \ - (IC_RealDeletePreviousChar(ic,1)) + (IC_RealDeletePreviousChar(ic)) Private unsigned char #if NeedFunctionPrototypes -IC_RealGetPreviousChar(Xic ic, XIMStringConversionPosition pos) +IC_RealGetPreviousChar(Xic ic, unsigned short pos) #else IC_RealGetPreviousChar(ic, pos) Xic ic; @@ -619,10 +619,13 @@ XIMStringConversionCallbackStruct screc; unsigned char c; - screc.position = pos; + /* Use a safe value of position = 0 and stretch the range to desired + * place, as XIM protocol is unclear here whether it could be negative + */ + screc.position = 0; screc.direction = XIMBackwardChar; screc.operation = XIMStringConversionRetrieval; - screc.factor = 1; + screc.factor = pos; screc.text = 0; (cb->callback)((XIC)ic, cb->client_data, (XPointer)&screc); @@ -651,11 +654,10 @@ Private unsigned char #if NeedFunctionPrototypes -IC_RealDeletePreviousChar(Xic ic, XIMStringConversionPosition pos) +IC_RealDeletePreviousChar(Xic ic) #else -IC_RealDeletePreviousChar(ic, pos) +IC_RealDeletePreviousChar(ic) Xic ic; - XIMStringConversionPosition pos; #endif { XICCallback* cb = &ic->core.string_conversion_callback; @@ -664,7 +666,7 @@ XIMStringConversionCallbackStruct screc; unsigned char c; - screc.position = pos; + screc.position = 0; screc.direction = XIMBackwardChar; screc.operation = XIMStringConversionSubstitution; screc.factor = 1; diff -Nuar xc/lib/X11/Xlib.h xc.thximconv3/lib/X11/Xlib.h --- xc/lib/X11/Xlib.h 2003-02-20 17:16:07.000000000 +0700 +++ xc.thximconv3/lib/X11/Xlib.h 2003-02-20 17:14:08.000000000 +0700 @@ -1303,7 +1303,7 @@ } string; } XIMStringConversionText; -typedef unsigned short XIMStringConversionPosition; +typedef short XIMStringConversionPosition; typedef unsigned short XIMStringConversionType;