Hello List:

I have been compiling some of the suckless utilities in a PogoPlug device. It 
runs Linux and there is a tool chain available for download, including the 
development libraries for X. However, I noticed that st dumps core upon start, 
hence I decided to investigate.   (On an unrelated issue, the same problem 
seems 
to occur in dmenu version 4.0, 3.0 worked fine in the same environment). 

On stack trace I discovered that it was failing on XCreateIC, it as because the 
previous call, XOpenIM was returning null back. To make a long story short, it 
seems to be an issue with the setlocale call. The following fix (attached) is 
based on a similar fix for fltk which I found while researching on the problem.

On the suckless website stated to post it here, hence this email. The 
developers responsible for st might want to check it out, but certainly I hope 
that it helps.

Luis Anaya

                                          
--- st-0.2/st.c	Sat Jan 21 22:43:03 2012
+++ st-0.2_modified/st.c	Tue Mar  6 05:23:12 2012
@@ -1695,6 +1695,7 @@
 	XSetWindowAttributes attrs;
 	Cursor cursor;
 	Window parent;
+	
 
 	if(!(xw.dpy = XOpenDisplay(NULL)))
 		die("Can't open display\n");
@@ -1738,9 +1739,23 @@
 
 	/* input methods */
 	xw.xim = XOpenIM(xw.dpy, NULL, NULL, NULL);
-	xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
+       
+
+        if (xw.xim == NULL) {
+	  XSetLocaleModifiers("@im=local");
+	  /* Second try */
+	  xw.xim= XOpenIM(xw.dpy, NULL, NULL, NULL);
+	} 
+
+	if (xw.xim != NULL) 
+	  xw.xic = XCreateIC(xw.xim, XNInputStyle, XIMPreeditNothing
 					   | XIMStatusNothing, XNClientWindow, xw.win,
 					   XNFocusWindow, xw.win, NULL);
+	else {
+	  die("Context could not be opened\n");
+	}
+					   
+					   
 	/* gc */
 	dc.gc = XCreateGC(xw.dpy, xw.win, 0, NULL);
 	
@@ -2101,8 +2116,9 @@
 	}
 
  run:
-	setlocale(LC_CTYPE, "");
-	tnew(80, 24);
+       
+	setlocale(LC_CTYPE, NULL);
+       	tnew(80, 24);
 	ttynew();
 	xinit();
 	selinit();

Reply via email to