summaryrefslogtreecommitdiffstats
path: root/gettext-tools/src/msgfmt.c
diff options
context:
space:
mode:
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);