summaryrefslogtreecommitdiffstats
path: root/gettext-tools/src/msgfmt.c
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2016-05-16 17:08:09 +0900
committerDaiki Ueno <ueno@gnu.org>2016-05-16 17:39:38 +0900
commite26b846fe273243b446cc02a027cc1a715734d1f (patch)
tree07223e40fad19a8fa85e68d05d8ab1aa7e89d842 /gettext-tools/src/msgfmt.c
parentcd95c539516127b153ab21b57a1ceaa0e731ec4c (diff)
downloadexternal_gettext-e26b846fe273243b446cc02a027cc1a715734d1f.zip
external_gettext-e26b846fe273243b446cc02a027cc1a715734d1f.tar.gz
external_gettext-e26b846fe273243b446cc02a027cc1a715734d1f.tar.bz2
msgfmt, xgettext: Respect XDG_DATA_DIRS
Suggested in https://savannah.gnu.org/bugs/?47123 * autogen.sh (GNULIB_MODULES_TOOLS_FOR_SRC): Add 'xmemdup0'. * gettext-tools/gnulib-lib/.gitignore: Ignore files brought by gnulib-tool. * gettext-tools/gnulib-tests/.gitignore: Likewise. * gettext-tools/src/search-path.c: New file. * gettext-tools/src/search-path.h: New file. * gettext-tools/src/Makefile.am (noinst_HEADERS): Add search-path.h. (libgettextsrc_la_SOURCES): Add search-path.c. * gettext-tools/src/msgfmt.c: Include "search-path.h". (main): Use get_search_path to locate ITS directories. * gettext-tools/src/xgettext.c: Include "search-path.h". (main): Use get_search_path to locate ITS directories.
Diffstat (limited to 'gettext-tools/src/msgfmt.c')
-rw-r--r--gettext-tools/src/msgfmt.c47
1 files changed, 24 insertions, 23 deletions
diff --git a/gettext-tools/src/msgfmt.c b/gettext-tools/src/msgfmt.c
index 7055fa0..ff4084b 100644
--- a/gettext-tools/src/msgfmt.c
+++ b/gettext-tools/src/msgfmt.c
@@ -65,6 +65,7 @@
#include "concat-filename.h"
#include "its.h"
#include "locating-rule.h"
+#include "search-path.h"
#include "gettext.h"
#define _(str) gettext (str)
@@ -664,31 +665,27 @@ There is NO WARRANTY, to the extent permitted by law.\n\
if (xml_mode)
{
- const char *gettextdatadir;
- char *versioned_gettextdatadir;
- char *its_dirs[2] = { NULL, NULL };
+ char **its_dirs;
+ char **dirs;
locating_rule_list_ty *its_locating_rules;
const char *its_basename;
- size_t i;
-
- /* Make it possible to override the locator file location. This
- is necessary for running the testsuite before "make
- install". */
- gettextdatadir = getenv ("GETTEXTDATADIR");
- if (gettextdatadir == NULL || gettextdatadir[0] == '\0')
- gettextdatadir = relocate (GETTEXTDATADIR);
-
- its_dirs[0] = xconcatenated_filename (gettextdatadir, "its", NULL);
-
- versioned_gettextdatadir =
- xasprintf ("%s%s", relocate (GETTEXTDATADIR), PACKAGE_SUFFIX);
- its_dirs[1] = xconcatenated_filename (versioned_gettextdatadir, "its",
- NULL);
- free (versioned_gettextdatadir);
+ its_dirs = get_search_path ("its");
its_locating_rules = locating_rule_list_alloc ();
- for (i = 0; i < SIZEOF (its_dirs); i++)
- locating_rule_list_add_from_directory (its_locating_rules, its_dirs[i]);
+ for (dirs = its_dirs; *dirs != NULL; dirs++)
+ {
+ /* Make it possible to override the locator file location. This
+ is necessary for running the testsuite before "make
+ install". */
+ char *relocated = relocate (*dirs);
+ if (relocated != *dirs)
+ {
+ free (*dirs);
+ *dirs = relocated;
+ }
+
+ locating_rule_list_add_from_directory (its_locating_rules, *dirs);
+ }
its_basename = locating_rule_list_locate (its_locating_rules,
xml_template_name,
@@ -699,7 +696,7 @@ There is NO WARRANTY, to the extent permitted by law.\n\
size_t j;
xml_its_rules = its_rule_list_alloc ();
- for (j = 0; j < SIZEOF (its_dirs); j++)
+ for (j = 0; its_dirs[j] != NULL; j++)
{
char *its_filename =
xconcatenated_filename (its_dirs[j], its_basename, NULL);
@@ -712,7 +709,7 @@ There is NO WARRANTY, to the extent permitted by law.\n\
if (ok)
break;
}
- if (j == SIZEOF (its_dirs))
+ if (its_dirs[j] == NULL)
{
its_rule_list_free (xml_its_rules);
xml_its_rules = NULL;
@@ -720,6 +717,10 @@ There is NO WARRANTY, to the extent permitted by law.\n\
}
locating_rule_list_free (its_locating_rules);
+ for (dirs = its_dirs; *dirs != NULL; dirs++)
+ free (*dirs);
+ free (its_dirs);
+
if (xml_its_rules == NULL)
error (EXIT_FAILURE, 0, _("cannot locate ITS rules for %s"),
xml_template_name);