SHA256
1
0
forked from pool/fcitx

Accepting request 150476 from M17N

(forwarded request 150475 from MargueriteSu)

OBS-URL: https://build.opensuse.org/request/show/150476
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/fcitx?expand=0&rev=20
This commit is contained in:
Stephan Kulow 2013-01-31 15:27:30 +00:00 committed by Git OBS Bridge
commit 91859a3f67
3 changed files with 88 additions and 1 deletions

View File

@ -0,0 +1,71 @@
diff --git a/src/module/xkb/xkb.c b/src/module/xkb/xkb.c
index d5d928d..36025bb 100644
--- a/src/module/xkb/xkb.c
+++ b/src/module/xkb/xkb.c
@@ -176,37 +176,50 @@ static char* FcitxXkbFindXkbRulesFile(FcitxXkb* xkb)
} else {
int count = 0, i = 0;
const char* base = XLIBDIR;
+ char *parent_to_free = NULL;
while (base[i]) {
if (base[i] == '/')
count++;
i++;
}
+ /**
+ * guess X11 data base directory.
+ **/
if (count >= 3) {
// .../usr/lib/X11 -> /usr/share/X11/xkb vs
// .../usr/X11/lib -> /usr/X11/share/X11/xkb
const char* delta = StringEndsWith(base, "X11") ?
"/../../share/X11" : "/../share/X11";
- char *tmppath;
- fcitx_utils_alloc_cat_str(tmppath, base, delta,
- "/xkb/rules/", rulesName, ".xml");
- if(fcitx_utils_isreg(tmppath)) {
- rulesFile = realpath(tmppath, NULL);
- free(tmppath);
- } else {
- fcitx_utils_alloc_cat_str(tmppath, base, "/X11/xkb/rules/",
- rulesName, ".xml");
- if(fcitx_utils_isreg(tmppath)) {
- rulesFile = realpath(tmppath, NULL);
- free(tmppath);
+ fcitx_utils_alloc_cat_str(parent_to_free, base, delta);
+ if(!fcitx_utils_isdir(parent_to_free)) {
+ // fallback to ${base}/X11
+ fcitx_utils_set_cat_str(parent_to_free, base, "/X11");
+ if(!fcitx_utils_isdir(parent_to_free)) {
+ free(parent_to_free);
+ parent_to_free = NULL;
}
}
}
- if(!rulesFile) {
- fcitx_utils_alloc_cat_str(rulesFile,
- "/usr/share/X11/xkb/rules/",
- rulesName, ".xml");
+ const char *parent_path;
+ if (parent_to_free) {
+ /**
+ * Found a existing dir, simplify it.
+ * Using realpath() on rules files' name can change the base
+ * name of the file (due to symlink), so it is only safe
+ * to do it for directory's name. T-T..
+ **/
+ char *tmp = realpath(parent_to_free, NULL);
+ parent_path = tmp;
+ free(parent_to_free);
+ parent_to_free = tmp;
+ } else {
+ // last fallback for known rules name.
+ parent_path = "/usr/share/X11";
}
+ fcitx_utils_alloc_cat_str(rulesFile, parent_path,
+ "/xkb/rules/", rulesName, ".xml");
+ fcitx_utils_free(parent_to_free);
}
free(rulesName);
} else {

View File

@ -1,3 +1,12 @@
-------------------------------------------------------------------
Wed Jan 30 18:24:37 UTC 2013 - i@marguerite.su
- fix bnc#801318: xkeyboard-config symlink breaks fcitx in detecting xkb rule files.
* bnc801318-fcitx-4.2.7-xkb-rule-symlink-detection.patch
* remove next release
- fix bnc#801319: invalid /etc/xdg/autostart/fcitx-autostart.desktop breaks ibus
* leave fcitx-autostart.desktop only for fedora.
-------------------------------------------------------------------
Wed Jan 30 08:54:58 UTC 2013 - coolo@suse.com

View File

@ -40,6 +40,9 @@ Patch1: fcitx-4.2.7-compat-12.2.patch
Patch2: fcitx-4.2.7-compat-qt474.patch
# fix-for-openSUSE wengxt@gmail.com - fix gcc 4.6 builds
Patch3: fcitx-4.2.7-compat-gcc46.patch
# fix-for-openSUSE wengxt@gmail.com - xkeyboard-config in SUSE use symlink for xkb rule files,
# which caused fcitx unexpected behavior in keyboard layout handling.
Patch4: bnc801318-fcitx-4.2.7-xkb-rule-symlink-detection.patch
BuildRequires: cairo-devel
%if 0%{?suse_version}
BuildRequires: dbus-1-devel
@ -366,6 +369,7 @@ You can either use this package for download from kde-look.org using knewstaff i
%patch2 -p1
%patch3 -p1
%endif
%patch4 -p1
%build
mkdir build
@ -465,6 +469,9 @@ pushd %{buildroot}%{_sysconfdir}/X11/xim.d/
popd
done
popd
# bnc#801319 remove the unneeded fcitx-autostart.desktop which blocks ibus from starting.
rm -rf %{buildroot}%{_sysconfdir}/xdg/autostart/%{name}-autostart.desktop
%endif
%if 0%{?fedora_version}
@ -589,8 +596,8 @@ update-desktop-database %{_datadir}/applications &>/dev/null ||
%if 0%{?fedora_version}
%config %{_sysconfdir}/X11/xinit/xinput.d/
%{_docdir}/packages/%{name}/
%endif
%config %{_sysconfdir}/xdg/autostart/%{name}-autostart.desktop
%endif
# excludes
%exclude %{_datadir}/%{name}/pinyin