[Libreoffice-commits] .: liblangtag/liblangtag-0.2-datadir.patch
Eike Rathke
erack at kemper.freedesktop.org
Wed Jun 13 08:21:14 PDT 2012
liblangtag/liblangtag-0.2-datadir.patch | 91 ++++++++++++++++++++++++++++----
1 file changed, 80 insertions(+), 11 deletions(-)
New commits:
commit 22b151a35ab940166bdc690364052184b1f5851f
Author: Eike Rathke <erack at redhat.com>
Date: Wed Jun 13 17:19:44 2012 +0200
implemented lt_db_set_datadir() override
+ added lt_db_set_datadir() and lb_db_get_datadir() functions to point to
liblangtag data and override REGDATADIR define
- removed LIBO_LANGTAG_DATADIR environment variable hack
diff --git a/liblangtag/liblangtag-0.2-datadir.patch b/liblangtag/liblangtag-0.2-datadir.patch
index 061f530..55b2a3a 100644
--- a/liblangtag/liblangtag-0.2-datadir.patch
+++ b/liblangtag/liblangtag-0.2-datadir.patch
@@ -1,35 +1,104 @@
+--- misc/liblangtag-0.2/liblangtag/lt-database.c 2012-01-31 11:27:16.000000000 +0100
++++ misc/build/liblangtag-0.2/liblangtag/lt-database.c 2012-06-12 01:32:57.354123185 +0200
+@@ -26,6 +26,7 @@
+ #include "lt-mem.h"
+ #include "lt-ext-module.h"
+ #include "lt-database.h"
++#include <string.h>
+
+
+ /**
+@@ -44,10 +45,41 @@
+ static lt_grandfathered_db_t *__db_grandfathered = NULL;
+ static lt_redundant_db_t *__db_redundant = NULL;
+
++/* this is a hack and might need some proper runtime de/allocation, but ... */
++#define DATADIR_MAX_PATH_LEN 512
++static char lt_db_datadir[DATADIR_MAX_PATH_LEN] = { 0 };
++
+
+ /*< private >*/
+
+ /*< public >*/
++
++/**
++ * lt_db_set_datadir:
++ *
++ * Set the directory where database files are installed.
++ * This overrides the default prefix= location if called before
++ * lt_db_initialize().
++ */
++void
++lt_db_set_datadir(const char* path)
++{
++ strncpy( lt_db_datadir, path, DATADIR_MAX_PATH_LEN-1);
++ lt_db_datadir[DATADIR_MAX_PATH_LEN-1] = 0;
++}
++
++/**
++ * lt_db_get_datadir:
++ *
++ * Obtain the directory where database files are installed.
++ * Only if set with lt_db_set_datadir().
++ */
++const char*
++lt_db_get_datadir(void)
++{
++ return lt_db_datadir;
++}
++
+ /**
+ * lt_db_initialize:
+ *
+--- misc/liblangtag-0.2/liblangtag/lt-database.h 2012-01-31 11:27:04.000000000 +0100
++++ misc/build/liblangtag-0.2/liblangtag/lt-database.h 2012-06-12 00:23:04.345618028 +0200
+@@ -37,6 +37,8 @@
+
+ G_BEGIN_DECLS
+
++void lt_db_set_datadir (const char*);
++const char* lt_db_get_datadir (void);
+ void lt_db_initialize (void);
+ void lt_db_finalize (void);
+ lt_lang_db_t *lt_db_get_lang (void);
--- misc/liblangtag-0.2/liblangtag/lt-xml.c 2012-02-02 09:54:51.000000000 +0100
-+++ misc/build/liblangtag-0.2/liblangtag/lt-xml.c 2012-06-04 17:39:32.010299830 +0200
-@@ -45,6 +45,14 @@
++++ misc/build/liblangtag-0.2/liblangtag/lt-xml.c 2012-06-12 00:23:04.477618565 +0200
+@@ -45,7 +45,20 @@
G_LOCK_DEFINE_STATIC (lt_xml);
-+static const char* get_datadir()
++
++/* defined in lt-database.c */
++extern const char* lt_db_get_datadir(void);
++
+ /*< private >*/
++static const char*
++lt_xml_get_datadir()
+{
-+ const char* pEnv = getenv( "LIBO_LANGTAG_DATADIR");
-+ if (pEnv && *pEnv)
-+ return pEnv;
++ const char* datadir = lt_db_get_datadir();
++ if (datadir && *datadir)
++ return datadir;
+ return REGDATADIR;
+}
+
- /*< private >*/
static gboolean
lt_xml_read_subtag_registry(lt_xml_t *xml,
-@@ -62,7 +70,7 @@
+ GError **error)
+@@ -62,7 +75,7 @@
if (!g_file_test(regfile, G_FILE_TEST_EXISTS)) {
g_free(regfile);
#endif
- regfile = g_build_filename(REGDATADIR, "language-subtag-registry.xml", NULL);
-+ regfile = g_build_filename(get_datadir(), "language-subtag-registry.xml", NULL);
++ regfile = g_build_filename(lt_xml_get_datadir(), "language-subtag-registry.xml", NULL);
#ifdef GNOME_ENABLE_DEBUG
}
#endif
-@@ -120,7 +128,7 @@
+@@ -120,7 +133,7 @@
if (!g_file_test(regfile, G_FILE_TEST_EXISTS)) {
g_free(regfile);
#endif
- regfile = g_build_filename(REGDATADIR, "common", "bcp47", filename, NULL);
-+ regfile = g_build_filename(get_datadir(), "common", "bcp47", filename, NULL);
++ regfile = g_build_filename(lt_xml_get_datadir(), "common", "bcp47", filename, NULL);
#ifdef GNOME_ENABLE_DEBUG
}
#endif
More information about the Libreoffice-commits
mailing list