* gettext-tools/src/color.h (style_file_prepare): Add arguments.
* gettext-tools/src/color.c: Don't include relocatable.h.
(style_file_lookup): Add stylesdir_after_install argument.
(style_file_prepare): Add arguments.
* gettext-tools/src/write-catalog.c: Include relocatable.h.
(GETTEXTSTYLESDIR): New macro.
(msgdomain_list_print): Update style_file_prepare calls.
* gettext-tools/tests/init-env.in (GETTEXTSTYLESDIR): New environment variable.
/* Color and styling handling.
- Copyright (C) 2006-2008, 2015-2016 Free Software Foundation, Inc.
+ Copyright (C) 2006-2008, 2019 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
#include "term-ostream.h"
#include "xalloc.h"
-#include "relocatable.h"
#include "filename.h"
#include "concat-filename.h"
/* Lookup the location of the style file. */
static const char *
-style_file_lookup (const char *file_name)
+style_file_lookup (const char *file_name, const char *stylesdir_after_install)
{
if (!IS_PATH_WITH_DIR (file_name))
{
if (stat (file_name, &statbuf) < 0)
{
/* ... but it exists in the styles installation location... */
- const char *gettextstylesdir = relocate (GETTEXTDATADIR "/styles");
char *possible_file_name =
- xconcatenated_filename (gettextstylesdir, file_name, NULL);
+ xconcatenated_filename (stylesdir_after_install, file_name, NULL);
if (stat (possible_file_name, &statbuf) >= 0)
{
/* Assign a default value to style_file_name if necessary. */
void
-style_file_prepare ()
+style_file_prepare (const char *style_file_envvar,
+ const char *stylesdir_envvar,
+ const char *stylesdir_after_install,
+ const char *default_style_file)
{
if (style_file_name == NULL)
{
- const char *user_preference = getenv ("PO_STYLE");
+ const char *user_preference = getenv (style_file_envvar);
if (user_preference != NULL && user_preference[0] != '\0')
- style_file_name = style_file_lookup (xstrdup (user_preference));
+ style_file_name =
+ style_file_lookup (xstrdup (user_preference),
+ stylesdir_after_install);
else
{
- const char *gettextdatadir;
+ const char *stylesdir;
- /* Make it possible to override the po-default.css location. This is
- necessary for running the testsuite before "make install". */
- gettextdatadir = getenv ("GETTEXTDATADIR");
- if (gettextdatadir == NULL || gettextdatadir[0] == '\0')
- gettextdatadir = relocate (GETTEXTDATADIR);
+ /* Make it possible to override the default style file location. This
+ is necessary for running the testsuite before "make install". */
+ stylesdir = getenv (stylesdir_envvar);
+ if (stylesdir == NULL || stylesdir[0] == '\0')
+ stylesdir = stylesdir_after_install;
style_file_name =
- xconcatenated_filename (gettextdatadir, "styles/po-default.css",
+ xconcatenated_filename (stylesdir, default_style_file,
NULL);
}
}
else
- style_file_name = style_file_lookup (style_file_name);
+ style_file_name =
+ style_file_lookup (style_file_name, stylesdir_after_install);
}
/* Color and styling handling.
- Copyright (C) 2006, 2015-2016 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2019 Free Software Foundation, Inc.
Written by Bruno Haible <bruno@clisp.org>, 2006.
This program is free software: you can redistribute it and/or modify
/* Print a color test page. */
extern void print_color_test (void);
-/* Assign a default value to style_file_name if necessary. */
-extern void style_file_prepare (void);
+/* Assign a default value to style_file_name if necessary.
+ STYLE_FILE_ENVVAR is an environment variable that, when set to a non-empty
+ value, specifies the style file to use. This environment variable is meant
+ to be set by the user.
+ STYLESDIR_ENVVAR is an environment variable that, when set to a non-empty
+ value, specifies the directory with the styles files, or NULL. This is
+ necessary for running the testsuite before "make install".
+ STYLESDIR_AFTER_INSTALL is the directory with the styles files after
+ "make install".
+ DEFAULT_STYLE_FILE is the file name of the default style file, relative to
+ STYLESDIR. */
+extern void style_file_prepare (const char *style_file_envvar,
+ const char *stylesdir_envvar,
+ const char *stylesdir_after_install,
+ const char *default_style_file);
#ifdef __cplusplus
/* GNU gettext - internationalization aids
- Copyright (C) 1995-1998, 2000-2008, 2012, 2015-2016 Free Software
+ Copyright (C) 1995-1998, 2000-2008, 2012, 2019 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
# include "fd-ostream.h"
# include "color.h"
+# include "relocatable.h"
# include "po-charset.h"
# include "msgl-iconv.h"
+# define GETTEXTSTYLESDIR GETTEXTDATADIR "/styles"
+
#endif
filename = _("standard output");
}
- style_file_prepare ();
+ style_file_prepare ("PO_STYLE",
+ "GETTEXTSTYLESDIR", relocate (GETTEXTSTYLESDIR),
+ "po-default.css");
stream = term_styled_ostream_create (fd, filename, style_file_name);
if (stream == NULL)
stream = fd_ostream_create (fd, filename, true);
mdlp = iconv_msgdomain_list (mdlp, po_charset_utf8, false, NULL);
}
- style_file_prepare ();
+ style_file_prepare ("PO_STYLE",
+ "GETTEXTSTYLESDIR", relocate (GETTEXTSTYLESDIR),
+ "po-default.css");
html_stream = html_styled_ostream_create (stream, style_file_name);
output_syntax->print (mdlp, html_stream, page_width, debug);
ostream_free (html_stream);
GETTEXTDATADIR="$wabs_top_srcdir"
export GETTEXTDATADIR
+# Variable needed for checking output with --color.
+GETTEXTSTYLESDIR="$GETTEXTDATADIR/styles"
+export GETTEXTSTYLESDIR
+
: ${GETTEXT=tstgettext}
: ${NGETTEXT=tstngettext}
: ${XGETTEXT=xgettext}