[packages/dmenu] upstream fixes for IME segfault; drop patch commented out for 9 years; rel 2

atler atler at pld-linux.org
Sun Mar 1 00:24:05 CET 2020


commit eabd440c09edcf8881d3d7c37441a2bc3a179dd1
Author: Jan Palus <atler at pld-linux.org>
Date:   Sun Mar 1 00:22:19 2020 +0100

    upstream fixes for IME segfault; drop patch commented out for 9 years; rel 2

 dmenu-xmms.patch                          | 136 ------------------------------
 dmenu.spec                                |  11 ++-
 fix-crash-when-XOpenIM-returns-NULL.patch |  39 +++++++++
 improve-xopenim-error-message.patch       |  28 ++++++
 revert-IME-support.patch                  |  61 ++++++++++++++
 5 files changed, 135 insertions(+), 140 deletions(-)
---
diff --git a/dmenu.spec b/dmenu.spec
index 3dc9ab9..33549e1 100644
--- a/dmenu.spec
+++ b/dmenu.spec
@@ -3,12 +3,14 @@ Summary(hu.UTF-8):	dmenu egy általános menü X-hez
 Summary(pl.UTF-8):	System menu dla X
 Name:		dmenu
 Version:	4.9
-Release:	1
+Release:	2
 License:	MIT
 Group:		Applications
 Source0:	http://dl.suckless.org/tools/%{name}-%{version}.tar.gz
 # Source0-md5:	9a537ec9a3a2ce9f08963d66b56cc030
-Patch0:		dmenu-xmms.patch
+Patch0:		fix-crash-when-XOpenIM-returns-NULL.patch
+Patch1:		improve-xopenim-error-message.patch
+Patch2:		revert-IME-support.patch
 URL:		http://tools.suckless.org/dmenu
 BuildRequires:	fontconfig-devel
 BuildRequires:	freetype-devel
@@ -36,8 +38,9 @@ użytkownika pozycji menu.
 
 %prep
 %setup -q
-
-# %patch0 -p1
+%patch0 -p1
+%patch1 -p1
+%patch2 -p1
 
 %build
 cat << 'EOF' >> config.mk
diff --git a/dmenu-xmms.patch b/dmenu-xmms.patch
deleted file mode 100644
index d121307..0000000
--- a/dmenu-xmms.patch
+++ /dev/null
@@ -1,136 +0,0 @@
-This patch is based on
-http://tools.suckless.org/dmenu/patches/xmms-like_pattern_matching
-
-diff -up dmenu-4.1.1/config.def.h dmenu-4.1.1_xmms/config.def.h
---- dmenu-4.1.1/config.def.h	2009-04-18 13:50:04.000000000 +0200
-+++ dmenu-4.1.1_xmms/config.def.h	2009-11-19 21:31:17.000000000 +0100
-@@ -7,3 +7,4 @@ static const char *normfgcolor = "#00000
- static const char *selbgcolor  = "#0066ff";
- static const char *selfgcolor  = "#ffffff";
- static unsigned int spaceitem  = 30; /* px between menu items */
-+static unsigned int maxtokens  = 16; /* max. tokens for pattern matching */
-diff -up dmenu-4.1.1/dmenu.1 dmenu-4.1.1_xmms/dmenu.1
---- dmenu-4.1.1/dmenu.1	2009-04-18 13:50:04.000000000 +0200
-+++ dmenu-4.1.1_xmms/dmenu.1	2009-11-19 21:14:24.000000000 +0100
-@@ -11,6 +11,7 @@ dmenu \- dynamic menu
- .RB [ \-p " <prompt>"]
- .RB [ \-sb " <color>"]
- .RB [ \-sf " <color>"]
-+.RB [ \-xs ]
- .RB [ \-v ]
- .SH DESCRIPTION
- .SS Overview
-@@ -44,6 +45,9 @@ defines the selected background color (#
- .B \-sf <color>
- defines the selected foreground color (#RGB, #RRGGBB, and color names are supported).
- .TP
-+.B \-xs
-+xmms-like pattern matching.
-+.TP
- .B \-v
- prints version information to standard output, then exits.
- .SH USAGE
-diff -u dmenu-4.1.1/dmenu.c.orig dmenu-4.1.1/dmenu.c
---- dmenu-4.1.1/dmenu.c.orig	2010-05-29 13:56:51.000000000 +0200
-+++ dmenu-4.1.1/dmenu.c	2010-07-05 22:23:30.000000000 +0200
-@@ -75,6 +75,7 @@
- /* variables */
- static char *maxname = NULL;
- static char *prompt = NULL;
-+static char **tokens = NULL;
- static char text[4096];
- static int cmdw = 0;
- static int promptw = 0;
-@@ -84,6 +85,7 @@
- static unsigned int mw, mh;
- static unsigned int numlockmask = 0;
- static Bool running = True;
-+static Bool xmms = False;
- static Display *dpy;
- static DC dc;
- static Item *allitems = NULL;  /* first of all items */
-@@ -578,22 +580,55 @@
- 	drawmenu();
- }
- 
-+unsigned int tokenize(char *pat, char **tok)
-+{
-+	unsigned int i = 0;
-+	char tmp[4096] = {0};
-+
-+	strncpy(tmp, pat, strlen(pat));
-+	tok[0] = strtok(tmp, " ");
-+
-+	while(tok[i] && i < maxtokens)
-+		tok[++i] = strtok(NULL, " ");
-+	return i;
-+}
-+
- void
- match(char *pattern) {
--	unsigned int plen;
-+	unsigned int plen, tokencnt = 0;
-+	char append = 0;
- 	Item *i, *itemend, *lexact, *lprefix, *lsubstr, *exactend, *prefixend, *substrend;
- 
- 	if(!pattern)
- 		return;
--	plen = strlen(pattern);
-+
-+	if(!xmms)
-+		tokens[(tokencnt = 1)-1] = pattern;
-+	else
-+		if(!(tokencnt = tokenize(pattern, tokens)))
-+			tokens[(tokencnt = 1)-1] = "";
- 	item = lexact = lprefix = lsubstr = itemend = exactend = prefixend = substrend = NULL;
--	for(i = allitems; i; i = i->next)
--		if(!fstrncmp(pattern, i->text, plen + 1))
-+	for(i = allitems; i; i = i->next) {
-+		for(int j = 0; j < tokencnt; ++j) {
-+			plen = strlen(tokens[j]);
-+			if(!fstrncmp(tokens[j], i->text, plen + 1))
-+				append = !append || append > 1 ? 1 : append;
-+			else if(!fstrncmp(tokens[j], i->text, plen ))
-+				append = !append || append > 2 ? 2 : append;
-+			else if(fstrstr(i->text, tokens[j]))
-+				append = append > 0 && append < 3 ? append : 3;
-+			else {
-+				append = 0;
-+				break;
-+			}
-+		}
-+		if(append == 1)
- 			appenditem(i, &lexact, &exactend);
--		else if(!fstrncmp(pattern, i->text, plen))
-+		else if(append == 2)
- 			appenditem(i, &lprefix, &prefixend);
--		else if(fstrstr(i->text, pattern))
-+		else if(append == 3)
- 			appenditem(i, &lsubstr, &substrend);
-+	}
- 	if(lexact) {
- 		item = lexact;
- 		itemend = exactend;
-@@ -748,6 +783,7 @@
- 	if(prompt)
- 		promptw = MIN(textw(prompt), mw / 5);
- 	text[0] = '\0';
-+	tokens = malloc((xmms?maxtokens:1)*sizeof(char*));
- 	match(text);
- 	XMapRaised(dpy, win);
- }
-@@ -806,11 +842,13 @@
- 		else if(!strcmp(argv[i], "-sf")) {
- 			if(++i < argc) selfgcolor = argv[i];
- 		}
-+		else if(!strcmp(argv[i], "-xs"))
-+			xmms = True;
- 		else if(!strcmp(argv[i], "-v"))
- 			eprint("dmenu-"VERSION", © 2006-2010 dmenu engineers, see LICENSE for details\n");
- 		else
- 			eprint("usage: dmenu [-i] [-b] [-e <xid>] [-l <lines>] [-fn <font>] [-nb <color>]\n"
--			       "             [-nf <color>] [-p <prompt>] [-sb <color>] [-sf <color>] [-v]\n");
-+			       "             [-nf <color>] [-p <prompt>] [-sb <color>] [-sf <color>] [-xs] [-v]\n");
- 	if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
- 		fprintf(stderr, "warning: no locale support\n");
- 	if(!(dpy = XOpenDisplay(NULL)))
diff --git a/fix-crash-when-XOpenIM-returns-NULL.patch b/fix-crash-when-XOpenIM-returns-NULL.patch
new file mode 100644
index 0000000..919035a
--- /dev/null
+++ b/fix-crash-when-XOpenIM-returns-NULL.patch
@@ -0,0 +1,39 @@
+From f5036b90efd9423d805923a0bc73cd54e30e72ab Mon Sep 17 00:00:00 2001
+From: Hiltjo Posthuma <hiltjo at codemadness.org>
+Date: Tue, 12 Feb 2019 19:10:43 +0100
+Subject: [PATCH 2/5] fix crash when XOpenIM returns NULL
+
+for example when IME variables are set, but the program is not started (yet).
+
+Signed-off-by: Jan Palus <atler at pld-linux.org>
+---
+ dmenu.c | 13 +++++++++++--
+ 1 file changed, 11 insertions(+), 2 deletions(-)
+
+diff --git a/dmenu.c b/dmenu.c
+index f803149..ae56f4f 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -664,8 +664,17 @@ setup(void)
+ 	                    CWOverrideRedirect | CWBackPixel | CWEventMask, &swa);
+ 	XSetClassHint(dpy, win, &ch);
+ 
+-	/* open input methods */
+-	xim = XOpenIM(dpy, NULL, NULL, NULL);
++
++	/* input methods */
++	if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
++		XSetLocaleModifiers("@im=local");
++		if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
++			XSetLocaleModifiers("@im=");
++			if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
++				die("XOpenIM failed. Could not open input device.\n");
++		}
++	}
++
+ 	xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
+ 	                XNClientWindow, win, XNFocusWindow, win, NULL);
+ 
+-- 
+2.25.1
+
diff --git a/improve-xopenim-error-message.patch b/improve-xopenim-error-message.patch
new file mode 100644
index 0000000..f596736
--- /dev/null
+++ b/improve-xopenim-error-message.patch
@@ -0,0 +1,28 @@
+From a9b1de384ae1ad30805e893af5cd6ea9b87c89da Mon Sep 17 00:00:00 2001
+From: Hiltjo Posthuma <hiltjo at codemadness.org>
+Date: Tue, 12 Feb 2019 22:58:35 +0100
+Subject: [PATCH 4/5] improve xopenim error message
+
+die() already prints a newline.
+
+Signed-off-by: Jan Palus <atler at pld-linux.org>
+---
+ dmenu.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/dmenu.c b/dmenu.c
+index ae56f4f..3bfd74d 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -671,7 +671,7 @@ setup(void)
+ 		if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
+ 			XSetLocaleModifiers("@im=");
+ 			if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
+-				die("XOpenIM failed. Could not open input device.\n");
++				die("XOpenIM failed: could not open input device");
+ 		}
+ 	}
+ 
+-- 
+2.25.1
+
diff --git a/revert-IME-support.patch b/revert-IME-support.patch
new file mode 100644
index 0000000..909e3a1
--- /dev/null
+++ b/revert-IME-support.patch
@@ -0,0 +1,61 @@
+From db6093f6ec1bb884f7540f2512935b5254750b30 Mon Sep 17 00:00:00 2001
+From: Hiltjo Posthuma <hiltjo at codemadness.org>
+Date: Sun, 3 Mar 2019 13:08:54 +0100
+Subject: [PATCH] revert IME support
+
+dmenu will not handle IME support (st will, atleast for now).
+
+revert parts of commit 377bd37e212b1ec4c03a481245603c6560d0be22
+this commit also broke input focus.
+---
+ dmenu.c | 15 +++------------
+ 1 file changed, 3 insertions(+), 12 deletions(-)
+
+diff --git a/dmenu.c b/dmenu.c
+index 3bfd74d..65f25ce 100644
+--- a/dmenu.c
++++ b/dmenu.c
+@@ -553,7 +553,7 @@ run(void)
+ 	XEvent ev;
+ 
+ 	while (!XNextEvent(dpy, &ev)) {
+-		if (XFilterEvent(&ev, None))
++		if (XFilterEvent(&ev, win))
+ 			continue;
+ 		switch(ev.type) {
+ 		case DestroyNotify:
+@@ -666,20 +666,13 @@ setup(void)
+ 
+ 
+ 	/* input methods */
+-	if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
+-		XSetLocaleModifiers("@im=local");
+-		if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL) {
+-			XSetLocaleModifiers("@im=");
+-			if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
+-				die("XOpenIM failed: could not open input device");
+-		}
+-	}
++	if ((xim = XOpenIM(dpy, NULL, NULL, NULL)) == NULL)
++		die("XOpenIM failed: could not open input device");
+ 
+ 	xic = XCreateIC(xim, XNInputStyle, XIMPreeditNothing | XIMStatusNothing,
+ 	                XNClientWindow, win, XNFocusWindow, win, NULL);
+ 
+ 	XMapRaised(dpy, win);
+-	XSetInputFocus(dpy, win, RevertToParent, CurrentTime);
+ 	if (embed) {
+ 		XSelectInput(dpy, parentwin, FocusChangeMask | SubstructureNotifyMask);
+ 		if (XQueryTree(dpy, parentwin, &dw, &w, &dws, &du) && dws) {
+@@ -745,8 +738,6 @@ main(int argc, char *argv[])
+ 
+ 	if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
+ 		fputs("warning: no locale support\n", stderr);
+-	if (!XSetLocaleModifiers(""))
+-		fputs("warning: no locale modifiers support\n", stderr);
+ 	if (!(dpy = XOpenDisplay(NULL)))
+ 		die("cannot open display");
+ 	screen = DefaultScreen(dpy);
+-- 
+2.25.1
+
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/dmenu.git/commitdiff/eabd440c09edcf8881d3d7c37441a2bc3a179dd1



More information about the pld-cvs-commit mailing list