From xemacs-m  Tue Jul 29 01:52:58 1997
Received: from mercury.Sun.COM (mercury.Sun.COM [192.9.25.1])
	by xemacs.org (8.8.5/8.8.5) with SMTP id BAA27344
	for <xemacs-beta@xemacs.org>; Tue, 29 Jul 1997 01:52:58 -0500 (CDT)
Received: from Eng.Sun.COM ([129.146.1.25]) by mercury.Sun.COM (SMI-8.6/mail.byaddr) with SMTP id XAA13804; Mon, 28 Jul 1997 23:52:25 -0700
Received: from kindra.eng.sun.com by Eng.Sun.COM (SMI-8.6/SMI-5.3)
	id XAA15474; Mon, 28 Jul 1997 23:52:24 -0700
Received: from xemacs.eng.sun.com by kindra.eng.sun.com (SMI-8.6/SMI-SVR4)
	id XAA05631; Mon, 28 Jul 1997 23:52:22 -0700
Received: by xemacs.eng.sun.com (SMI-8.6/SMI-SVR4)
	id XAA21984; Mon, 28 Jul 1997 23:52:18 -0700
Date: Mon, 28 Jul 1997 23:52:18 -0700
Message-Id: <199707290652.XAA21984@xemacs.eng.sun.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
From: Martin Buchholz <mrb@Eng.Sun.COM>
To: "Stephen J. Turnbull" <turnbull@turnbull.sk.tsukuba.ac.jp>
Cc: xemacs-beta@xemacs.org
Subject: 20.3-b14 input-method-xlib.c: null XIM status area crashes XEmacs
In-Reply-To: <m0wsnGE-00006qC@turnbull.sk.tsukuba.ac.jp>
References: <m0wsnGE-00006qC@turnbull.sk.tsukuba.ac.jp>
X-Mailer: VM 6.33 under 20.3 "Vienna" XEmacs  Lucid (beta14)
Reply-To: Martin Buchholz <mrb@Eng.Sun.COM>

I have made the proposed change to input-method-xlib.c, except without
the #ifdef's.  XEmacs will now never use empty preedit and status
areas.  In beta 16.

I have also modified event-Xt.c so that XLookupString will get used
instead of XmbLookupString if the current frame has no input context.

This is tricky code and hard to test.  I have no convenient access to
kinput2 or non-Solaris xlib.  In my opinion both kinput2 and xlib are
buggy.  The `Sun' distribution of XEmacs uses --with-xim=motif, so
others should help maintain --with-xim=xlib.

Martin

>>>>> "SJT" == Stephen J Turnbull <turnbull@turnbull.sk.tsukuba.ac.jp> writes:

SJT> (For Martin Buchholz, mostly, I guess.)
SJT> XEmacs 20.3-b14 (configure --with-mule --with-xim=xlib) crashes on the
SJT> first keystroke input when using 
SJT>   o kinput2 (version 2.0 fix 3 (1997/02/03) options: [Canna2] [DEBUG]),
SJT>   o running on Debian Linux 1.3, kernel 2.0.29,
SJT>   o using a TCP connection to a remote cannaserver,
SJT>   o locale services are provided by "liblocale.so".
SJT> Full configuration from Installation is at the end, followed by the
SJT> C source for liblocale.so (originally a patch for Netscape
SJT> internationalization).  XEmacs's version string is

SJT> XEmacs 20.3 "Vienna" [Lucid] (i586-pc-linux, Mule) of Tue Jul 29 1997 on tanko

SJT> Typical sequence to reproduce the crash:

SJT> tanko# kinput2 -cannaserver turnbull -trace
SJT> tanko# export XMODIFIERS='@im=kinput2'
SJT> tanko# export LD_PRELOAD=/usr/local/lib/liblocale.so
SJT> tanko# cd /usr/local/xemacs-20.3-b14/src; xemacs &

SJT> and type Ctrl-X in the XEmacs window (intending to continue with
SJT> Ctrl-F filename, but I don't get that far).

SJT> This is due to a NULL xic being passed to XmbLookupString, when
SJT> XCreateIC fails because kinput2 receives null StatusArea and
SJT> PreeditArea rectangles from XEmacs.  The following patch fixes the
SJT> problem in this case, but cannot be relied upon if XCreateIC (or
SJT> XOpenIM, possibly) fails for some other reason.  This patch makes
SJT> kinput2 usable in most circumstances.  However, any failure of
SJT> XCreateIC will still result in a crash on keyboard input.

SJT> --- src/DIST/input-method-xlib.c	Tue Jul 29 01:57:53 1997
SJT> +++ src/input-method-xlib.c	Tue Jul 29 02:04:25 1997
SJT> @@ -154,7 +154,12 @@
SJT>    XIC xic;
SJT>    Widget w = FRAME_X_TEXT_WIDGET (f);
SJT>    Window win = XtWindow (w);
SJT> +#ifdef KINPUT2_IC_ERROR_FIXED
SJT>    XRectangle p_area = {0,0,0,0}, s_area={0,0,0,0};
SJT> +#else
SJT> +  /* kinput2, at least, insists on these being non-null */
SJT> +  XRectangle p_area = {0,0,1,1}, s_area={0,0,1,1};
SJT> +#endif
SJT>    XPoint spot = {0,0};
SJT>    XIMStyle style;
SJT>    XVaNestedList p_list, s_list;

SJT> ChangeLog entry:

SJT> Mon Jul 28 19:28:08 1997  Stephen J Turnbull  <turnbull@sk.tsukuba.ac.jp>

