its: Prepare for shipping ITS files

This commit is contained in:
Daiki Ueno 2015-09-30 10:43:15 +09:00
parent 05050ea4fb
commit 8e699312de
5 changed files with 59 additions and 30 deletions

View File

@ -461,6 +461,11 @@ AC_SUBST([ARCHIVE_FORMAT])
ARCHIVE_VERSION=0.19.5
AC_SUBST([ARCHIVE_VERSION])
PACKAGE_SUFFIX="-$ARCHIVE_VERSION"
AC_SUBST([PACKAGE_SUFFIX])
AC_DEFINE_UNQUOTED(PACKAGE_SUFFIX, "$PACKAGE_SUFFIX",
[Define to the suffix of this package])
dnl Check for tools needed for formatting the documentation.
ac_aux_dir_abs=`cd $ac_aux_dir && pwd`
AC_PATH_PROG([DVIPS], [dvips], [$ac_aux_dir_abs/missing dvips])
@ -519,6 +524,8 @@ AC_CONFIG_FILES([intl/Makefile:../gettext-runtime/intl/Makefile.in], [
mv intl/Makefile.tmp intl/Makefile
])
AC_CONFIG_FILES([its/Makefile])
AC_CONFIG_FILES([gnulib-lib/Makefile])
AC_CONFIG_FILES([libgrep/Makefile])

View File

@ -74,8 +74,6 @@ struct locating_rule_ty
struct locating_rule_list_ty
{
char *base;
struct locating_rule_ty *items;
size_t nitems;
size_t nitems_max;
@ -157,7 +155,7 @@ locating_rule_match (struct locating_rule_ty *rule,
return NULL;
}
char *
const char *
locating_rule_list_locate (struct locating_rule_list_ty *rules,
const char *path)
{
@ -168,7 +166,7 @@ locating_rule_list_locate (struct locating_rule_list_ty *rules,
{
target = locating_rule_match (&rules->items[i], path);
if (target != NULL)
return xconcatenated_filename (rules->base, target, NULL);
return target;
}
return NULL;
@ -306,7 +304,7 @@ locating_rule_list_add_file (struct locating_rule_list_ty *rules,
return true;
}
static bool
bool
locating_rule_list_add_directory (struct locating_rule_list_ty *rules,
const char *directory)
{
@ -349,16 +347,13 @@ locating_rule_list_add_directory (struct locating_rule_list_ty *rules,
}
struct locating_rule_list_ty *
locating_rule_list_alloc (const char *base, const char *directory)
locating_rule_list_alloc (void)
{
struct locating_rule_list_ty *result;
xmlCheckVersion (LIBXML_VERSION);
result = XCALLOC (1, struct locating_rule_list_ty);
result->base = xstrdup (base);
locating_rule_list_add_directory (result, directory);
return result;
}
@ -366,8 +361,6 @@ locating_rule_list_alloc (const char *base, const char *directory)
void
locating_rule_list_destroy (struct locating_rule_list_ty *rules)
{
free (rules->base);
while (rules->nitems-- > 0)
locating_rule_destroy (&rules->items[rules->nitems]);
free (rules->items);

View File

@ -27,18 +27,20 @@ extern "C" {
typedef struct locating_rule_list_ty locating_rule_list_ty;
/* Creates a fresh locating_rule_list_ty with the base URI BASE, and loads
the locating rules from the files in DIRECTORY. */
extern struct locating_rule_list_ty *locating_rule_list_alloc (const char *base,
const char *directory);
/* Creates a fresh locating_rule_list_ty. */
extern struct locating_rule_list_ty *locating_rule_list_alloc (void);
extern bool
locating_rule_list_add_directory (locating_rule_list_ty *rules,
const char *directory);
/* Determines the location of resource associated with PATH, accoding
to the loaded locating rules. */
extern char *locating_rule_list_locate (locating_rule_list_ty *locators,
const char *path);
extern const char *locating_rule_list_locate (locating_rule_list_ty *rules,
const char *path);
/* Releases memory allocated for LOCATORS. */
extern void locating_rule_list_free (locating_rule_list_ty *locators);
/* Releases memory allocated for RULES. */
extern void locating_rule_list_free (locating_rule_list_ty *rules);
#ifdef __cplusplus
}

View File

@ -78,6 +78,8 @@
/* A convenience macro. I don't like writing gettext() every time. */
#define _(str) gettext (str)
#define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
#include "x-c.h"
#include "x-po.h"
@ -316,6 +318,7 @@ main (int argc, char *argv[])
bool sort_by_msgid = false;
bool sort_by_filepos = false;
bool its = false;
char *its_dirs[2] = { NULL, NULL };
const char *file_name;
const char *files_from = NULL;
string_list_ty *file_list;
@ -719,7 +722,7 @@ xgettext cannot work without keywords to look for"));
if (its)
{
const char *gettextdatadir;
char *itsdir;
char *versioned_gettextdatadir;
/* Make it possible to override the locator file location. This
is necessary for running the testsuite before "make
@ -728,9 +731,17 @@ xgettext cannot work without keywords to look for"));
if (gettextdatadir == NULL || gettextdatadir[0] == '\0')
gettextdatadir = relocate (GETTEXTDATADIR);
itsdir = xconcatenated_filename (gettextdatadir, "its", NULL);
its_locating_rules = locating_rule_list_alloc (itsdir, itsdir);
free (itsdir);
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_locating_rules = locating_rule_list_alloc ();
for (i = 0; i < SIZEOF (its_dirs); i++)
locating_rule_list_add_directory (its_locating_rules, its_dirs[i]);
}
/* Determine extractor from language. */
@ -872,20 +883,30 @@ This version was built without iconv()."),
if (language == NULL && its_locating_rules != NULL)
{
char *its_filename = NULL;
its_filename = locating_rule_list_locate (its_locating_rules,
filename);
if (its_filename != NULL)
const char *its_basename =
locating_rule_list_locate (its_locating_rules, filename);
if (its_basename != NULL)
{
size_t j;
its_rules = its_rule_list_alloc ();
if (!its_rule_list_add_file (its_rules, its_filename))
for (j = 0; j < SIZEOF (its_dirs); j++)
{
char *its_filename =
xconcatenated_filename (its_dirs[j], its_basename,
NULL);
bool result =
its_rule_list_add_file (its_rules, its_filename);
free (its_filename);
if (result)
break;
}
if (j == SIZEOF (its_dirs))
{
its_rule_list_free (its_rules);
its_rules = NULL;
}
}
free (its_filename);
}
if (its_rules == NULL)
@ -961,6 +982,9 @@ warning: file '%s' extension '%s' is unknown; will try C"), filename, extension)
if (its_locating_rules)
locating_rule_list_free (its_locating_rules);
for (i = 0; i < SIZEOF (its_dirs); i++)
free (its_dirs[i]);
exit (EXIT_SUCCESS);
}

View File

@ -1,6 +1,9 @@
# Variable needed by LTLIBINTL.
top_builddir=../..
# Variable needed by xgettext.
GETTEXTDATADIR="$top_builddir"
OBJEXT="@OBJEXT@"
EXEEXT="@EXEEXT@"
CC="@CC@"