Skip to content

Commit

Permalink
src: Define X11_LOCALEDATADIR for BSD Compose data
Browse files Browse the repository at this point in the history
FreeBSD and NetBSD have X11 locale Compose data directories in
${X11_PREFIX}/lib/X11/locale instead of ${X11_PREFIX}/share/X11/locale:
https://github.com/freedesktop/xorg-lib-libX11/blob/20a3f99/configure.ac#L336-L340

BUG=#2478
  • Loading branch information
tsutsui authored and fujiwarat committed Feb 28, 2023
1 parent 7c8abbe commit ce5e2bb
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 14 deletions.
8 changes: 8 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,14 @@ else
fi
AC_SUBST(X11_PREFIX)

# Check locale dir for Compose files.
AC_CHECK_FILE($X11_PREFIX/share/X11/locale/locale.dir,
X11_LOCALEDATADIR="$X11_PREFIX/share/X11/locale",
[AC_CHECK_FILE($X11_PREFIX/lib/X11/locale/locale.dir,
X11_LOCALEDATADIR="$X11_PREFIX/lib/X11/locale",
X11_LOCALEDATADIR="$(datadir)/X11/locale")])
AC_SUBST(X11_LOCALEDATADIR)

if test x"$enable_wayland" = x"yes"; then
# Check for wayland
PKG_CHECK_MODULES(WAYLAND, [
Expand Down
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ AM_CPPFLAGS = \
-DIBUS_DISABLE_DEPRECATION_WARNINGS \
-DIBUS_COMPILATION \
-DISOCODES_PREFIX=\"$(ISOCODES_PREFIX)\" \
-DX11_DATA_PREFIX=\"$(X11_PREFIX)\" \
-DX11_LOCALEDATADIR=\"$(X11_LOCALEDATADIR)\" \
$(NULL)

# ibus library
Expand Down
6 changes: 2 additions & 4 deletions src/gencomposetable.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
#include "ibuscomposetable.h"
#include "ibusenginesimpleprivate.h"

#define X11_DATADIR X11_DATA_PREFIX "/share/X11/locale"


static void
save_compose_table_endianness (IBusComposeTableEx *compose_table,
Expand Down Expand Up @@ -84,7 +82,7 @@ main (int argc, char *argv[])
if (!path || !g_file_test (path, G_FILE_TEST_EXISTS)) {
g_clear_pointer (&path, g_free);
for (sys_lang = sys_langs; *sys_lang; sys_lang++) {
path = g_build_filename (X11_DATADIR, *sys_lang,
path = g_build_filename (X11_LOCALEDATADIR, *sys_lang,
"Compose", NULL);
if (!path)
continue;
Expand All @@ -93,7 +91,7 @@ main (int argc, char *argv[])
}
}
if (!path) {
g_warning ("en_US compose file is not found in %s.", X11_DATADIR);
g_warning ("en_US compose file is not found in %s.", X11_LOCALEDATADIR);
return 1;
} else {
g_debug ("Create a cache of %s", path);
Expand Down
5 changes: 2 additions & 3 deletions src/ibuscomposetable.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

#define IBUS_COMPOSE_TABLE_MAGIC "IBusComposeTable"
#define IBUS_COMPOSE_TABLE_VERSION (4)
#define X11_DATADIR X11_DATA_PREFIX "/share/X11/locale"
#define IBUS_MAX_COMPOSE_ALGORITHM_LEN 9

typedef struct {
Expand Down Expand Up @@ -285,7 +284,7 @@ expand_include_path (const char *include_path) {
case 'S': /* system compose dir */
o = out;
former = g_strndup (head, i - head);
out = g_strdup_printf ("%s%s%s", o, former, X11_DATADIR);
out = g_strdup_printf ("%s%s%s", o, former, X11_LOCALEDATADIR);
head = i + 2;
g_free (o);
g_free (former);
Expand Down Expand Up @@ -397,7 +396,7 @@ get_en_compose_file (void)
char * const *sys_lang = NULL;
char *path = NULL;
for (sys_lang = sys_langs; *sys_lang; sys_lang++) {
path = g_build_filename (X11_DATADIR, *sys_lang, "Compose", NULL);
path = g_build_filename (X11_LOCALEDATADIR, *sys_lang, "Compose", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS))
break;
g_clear_pointer (&path, g_free);
Expand Down
5 changes: 2 additions & 3 deletions src/ibusenginesimple.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <memory.h>
#include <stdlib.h>

#define X11_DATADIR X11_DATA_PREFIX "/share/X11/locale"
#define IBUS_ENGINE_SIMPLE_GET_PRIVATE(o) \
((IBusEngineSimplePrivate *)ibus_engine_simple_get_instance_private (o))

Expand Down Expand Up @@ -1440,7 +1439,7 @@ ibus_engine_simple_add_table_by_locale (IBusEngineSimple *simple,
for (sys_lang = sys_langs; *sys_lang; sys_lang++) {
if (g_ascii_strncasecmp (*lang, *sys_lang,
strlen (*sys_lang)) == 0) {
path = g_build_filename (X11_DATADIR,
path = g_build_filename (X11_LOCALEDATADIR,
*lang, "Compose", NULL);
break;
}
Expand All @@ -1462,7 +1461,7 @@ ibus_engine_simple_add_table_by_locale (IBusEngineSimple *simple,
ibus_engine_simple_add_compose_file (simple, path);
g_clear_pointer(&path, g_free);
} else {
path = g_build_filename (X11_DATADIR, locale, "Compose", NULL);
path = g_build_filename (X11_LOCALEDATADIR, locale, "Compose", NULL);
do {
if (g_file_test (path, G_FILE_TEST_EXISTS))
break;
Expand Down
2 changes: 1 addition & 1 deletion src/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ AM_CPPFLAGS = \
@GLIB2_CFLAGS@ \
@GIO2_CFLAGS@ \
-DIBUS_DISABLE_DEPRECATION_WARNINGS \
-DX11_DATA_PREFIX=\"$(X11_PREFIX)\" \
-DX11_LOCALEDATADIR=\"$(X11_LOCALEDATADIR)\" \
-I$(top_srcdir)/src \
-I$(top_builddir)/src \
$(NULL)
Expand Down
3 changes: 1 addition & 2 deletions src/tests/ibus-compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#define GREEN "\033[0;32m"
#define RED "\033[0;31m"
#define NC "\033[0m"
#define X11_DATADIR X11_DATA_PREFIX "/share/X11/locale"

IBusBus *m_bus;
gchar *m_compose_file;
Expand Down Expand Up @@ -36,7 +35,7 @@ get_compose_path ()
break;
if (g_strcmp0 (*l, "C") == 0)
break;
compose_path = g_build_filename (X11_DATADIR,
compose_path = g_build_filename (X11_LOCALEDATADIR,
*l,
"Compose",
NULL);
Expand Down

0 comments on commit ce5e2bb

Please sign in to comment.