Posted to tcl by GPS at Fri Jun 06 21:09:54 GMT 2008view raw
- + Status status = XBufferOverflow;
- +
- + while (status == XBufferOverflow) {
- + len = Xutf8LookupString(winPtr->inputContext, &eventPtr->xkey,
- + Tcl_DStringValue(dsPtr), len, NULL, &status);
- + Tcl_DStringSetLength(dsPtr, len);
- + }
- This is from libX11-1.1.3/src/xlibi18n/ICWrap.c:
- Xutf8LookupString(..) {
- if (ic->core.im) {
- if (ic->methods->utf8_lookup_string)
- return (*ic->methods->utf8_lookup_string) (ic, ev, buffer, nbytes,
- keysym, status);
- else if (ic->methods->mb_lookup_string)
- return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
- keysym, status);
- }
- return XLookupNone;
- }
- I'm guessing it's unlikely for ic->core.im to be false, but it might be good to be protective. The way the while loop is coded, the XBufferOverflow state would continue forever. One problem is: Xlib.h:#define XLookupNone 1
- So it's somewhat error prone. The return would be 1, which is interpretted as a length, and the XBufferOverflow state continues. Unless I'm missing something this seems off. Perhaps one way around it is to initialize the status to something other than XBufferOverflow, perhaps 0 or -1, assuming the XBufferOverflow-like macros don't use those values.