summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2010-10-12 11:16:51 +0100
committerColin Watson <cjwatson@debian.org>2010-10-12 11:16:51 +0100
commitb44fcf32603a6e20c200397b66b377566f66b564 (patch)
tree86a45889bc9e57389c00cc9307035890b2c8c3e1
parentd0b4f02ed5a0bcf246145993dab0524d606c7d2c (diff)
* lib/util.c (init_locale): New function.
* include/manconfig.h.in (init_locale): Add prototype. * src/Makefile.am (AM_CPPFLAGS): Move -DLOCALEDIR to ... * lib/Makefile.am (libman_la_CPPFLAGS): ... here. * src/accessdb.c (main), src/catman.c (main), src/globbing_test.c (main), src/lexgrog_test.c (main), src/man.c (main), src/manconv_main.c (main), src/mandb.c (main), src/manpath.c (main), src/whatis.c (main), src/zsoelim.c (main): Use init_locale. * lib/util.c (init_locale): Suppress warning message if DPKG_RUNNING_VERSION is set in the environment. * NEWS: Document this.
-rw-r--r--ChangeLog17
-rw-r--r--NEWS6
-rw-r--r--include/manconfig.h.in1
-rw-r--r--lib/Makefile.am3
-rw-r--r--lib/Makefile.in3
-rw-r--r--lib/util.c22
-rw-r--r--src/Makefile.am1
-rw-r--r--src/Makefile.in1
-rw-r--r--src/accessdb.c11
-rw-r--r--src/catman.c15
-rw-r--r--src/globbing_test.c11
-rw-r--r--src/lexgrog_test.c11
-rw-r--r--src/man.c10
-rw-r--r--src/manconv_main.c11
-rw-r--r--src/mandb.c12
-rw-r--r--src/manpath.c12
-rw-r--r--src/whatis.c11
-rw-r--r--src/zsoelim_main.c11
18 files changed, 60 insertions, 109 deletions
diff --git a/ChangeLog b/ChangeLog
index f5af990d..987d11ad 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+Tue Oct 12 11:16:31 BST 2010 Colin Watson <cjwatson@debian.org>
+
+ * lib/util.c (init_locale): New function.
+ * include/manconfig.h.in (init_locale): Add prototype.
+ * src/Makefile.am (AM_CPPFLAGS): Move -DLOCALEDIR to ...
+ * lib/Makefile.am (libman_la_CPPFLAGS): ... here.
+
+ * src/accessdb.c (main), src/catman.c (main), src/globbing_test.c
+ (main), src/lexgrog_test.c (main), src/man.c (main),
+ src/manconv_main.c (main), src/mandb.c (main), src/manpath.c
+ (main), src/whatis.c (main), src/zsoelim.c (main): Use
+ init_locale.
+
+ * lib/util.c (init_locale): Suppress warning message if
+ DPKG_RUNNING_VERSION is set in the environment.
+ * NEWS: Document this.
+
Mon Oct 11 09:38:03 BST 2010 Colin Watson <cjwatson@debian.org>
* docs/HACKING (Revision control): Update for restored bzr+ssh
diff --git a/NEWS b/NEWS
index c96ecd1a..83dbb941 100644
--- a/NEWS
+++ b/NEWS
@@ -31,6 +31,12 @@ Major changes since man-db 2.5.7:
to be translated, then please install GNU libintl separately
(http://www.gnu.org/software/gettext/).
+ o Warnings about unrecognised locales are now suppressed if the
+ DPKG_RUNNING_VERSION environment variable is set (i.e. man-db is
+ running within a Debian package's maintainer script), since the
+ system locales are often out of sync with the C library in that
+ context. Thanks to the Debian Perl maintainers for the idea.
+
man-db 2.5.7 (16 February 2010)
===============================
diff --git a/include/manconfig.h.in b/include/manconfig.h.in
index 78b5edf2..ef2fba5c 100644
--- a/include/manconfig.h.in
+++ b/include/manconfig.h.in
@@ -365,6 +365,7 @@ extern char *escape_shell (const char *unesc);
extern int remove_directory (const char *directory);
extern char *trim_spaces (const char *s);
extern char *lang_dir (const char *filename);
+extern char *init_locale (int category, const char *locale);
extern char *appendstr (char *, ...)
ATTRIBUTE_SENTINEL ATTRIBUTE_WARN_UNUSED_RESULT;
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 835bc925..3660f31a 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -25,7 +25,8 @@ dist_noinst_DATA = README
libman_la_CPPFLAGS = \
-I$(top_builddir)/include \
-I$(top_srcdir)/gnulib/lib \
- -I$(top_builddir)/gnulib/lib
+ -I$(top_builddir)/gnulib/lib \
+ -DLOCALEDIR=\"$(localedir)\"
libman_la_SOURCES = \
appendstr.c \
diff --git a/lib/Makefile.in b/lib/Makefile.in
index f8d49f2d..a1b2552e 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -1054,7 +1054,8 @@ dist_noinst_DATA = README
libman_la_CPPFLAGS = \
-I$(top_builddir)/include \
-I$(top_srcdir)/gnulib/lib \
- -I$(top_builddir)/gnulib/lib
+ -I$(top_builddir)/gnulib/lib \
+ -DLOCALEDIR=\"$(localedir)\"
libman_la_SOURCES = appendstr.c cleanup.c cleanup.h debug.c \
decompress.c decompress.h encodings.c encodings.h hashtable.c \
diff --git a/lib/util.c b/lib/util.c
index 1b31e7ae..b3fabc43 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -3,7 +3,7 @@
*
* Copyright (C) 1990, 1991 John W. Eaton.
* Copyright (C) 1994, 1995 Graeme W. Wilford. (Wilf.)
- * Copyright (C) 2001, 2002 Colin Watson.
+ * Copyright (C) 2001, 2002, 2004, 2007, 2008, 2010 Colin Watson.
*
* This file is part of man-db.
*
@@ -42,9 +42,13 @@
#include <sys/stat.h>
#include <dirent.h>
#include <unistd.h>
+#include <locale.h>
+
+#include "gettext.h"
#include "manconfig.h"
+#include "error.h"
#include "pipeline.h"
/*
@@ -227,3 +231,19 @@ char *lang_dir (const char *filename)
debug ("found lang dir element %s\n", ld);
return ld;
}
+
+char *init_locale (int category, const char *locale)
+{
+ char *ret = setlocale (category, locale);
+ if (!ret &&
+ !getenv ("MAN_NO_LOCALE_WARNING") &&
+ !getenv ("DPKG_RUNNING_VERSION"))
+ /* Obviously can't translate this. */
+ error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
+ "are correct");
+ setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
+ textdomain (PACKAGE);
+ return ret;
+}
diff --git a/src/Makefile.am b/src/Makefile.am
index 334c5ccb..f6dc429a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -42,7 +42,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/libdb \
-DCONFIG_FILE=\"$(config_file)\" \
- -DLOCALEDIR=\"$(localedir)\" \
-DAPROPOS=\"$(bindir)/$(TRANS_APROPOS)\" \
-DAPROPOS_NAME=\"$(TRANS_APROPOS)\" \
-DMAN=\"$(bindir)/$(TRANS_MAN)\" \
diff --git a/src/Makefile.in b/src/Makefile.in
index 02cc4744..0c9293c1 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1122,7 +1122,6 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/libdb \
-DCONFIG_FILE=\"$(config_file)\" \
- -DLOCALEDIR=\"$(localedir)\" \
-DAPROPOS=\"$(bindir)/$(TRANS_APROPOS)\" \
-DAPROPOS_NAME=\"$(TRANS_APROPOS)\" \
-DMAN=\"$(bindir)/$(TRANS_MAN)\" \
diff --git a/src/accessdb.c b/src/accessdb.c
index 30278539..47d7ae3c 100644
--- a/src/accessdb.c
+++ b/src/accessdb.c
@@ -37,7 +37,6 @@
#include "xvasprintf.h"
#include "gettext.h"
-#include <locale.h>
#define _(String) gettext (String)
#define N_(String) gettext_noop (String)
@@ -112,15 +111,7 @@ int main (int argc, char *argv[])
program_name = base_name (argv[0]);
init_debug ();
-
- if (!setlocale (LC_ALL, "") && !getenv ("MAN_NO_LOCALE_WARNING"))
- /* Obviously can't translate this. */
- error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
- "are correct");
- setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
- bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
- textdomain (PACKAGE);
+ init_locale (LC_ALL, "");
if (is_directory (FHS_CAT_ROOT) == 1)
cat_root = FHS_CAT_ROOT;
diff --git a/src/catman.c b/src/catman.c
index 53fd91b4..4e2625c5 100644
--- a/src/catman.c
+++ b/src/catman.c
@@ -67,7 +67,6 @@
#include "dirname.h"
#include "gettext.h"
-#include <locale.h>
#define _(String) gettext (String)
#define N_(String) gettext_noop (String)
@@ -413,19 +412,9 @@ int main (int argc, char *argv[])
init_debug ();
- /* initialise the locale */
- locale = xstrdup (setlocale (LC_ALL, ""));
- if (!locale) {
- /* Obviously can't translate this. */
- if (!getenv ("MAN_NO_LOCALE_WARNING"))
- error (0, 0, "can't set the locale; make sure $LC_* "
- "and $LANG are correct");
+ locale = xstrdup (init_locale (LC_ALL, ""));
+ if (!locale)
locale = xstrdup ("C");
- }
- setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
- bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
- textdomain (PACKAGE);
if (argp_parse (&argp, argc, argv, 0, 0, 0))
exit (FAIL);
diff --git a/src/globbing_test.c b/src/globbing_test.c
index ef13034f..9bd80b63 100644
--- a/src/globbing_test.c
+++ b/src/globbing_test.c
@@ -32,7 +32,6 @@
#include "dirname.h"
#include "gettext.h"
-#include <locale.h>
#define _(String) gettext (String)
#define N_(String) gettext_noop (String)
@@ -109,15 +108,7 @@ int main (int argc, char **argv)
program_name = base_name (argv[0]);
init_debug ();
-
- if (!setlocale (LC_ALL, "") && !getenv ("MAN_NO_LOCALE_WARNING"))
- /* Obviously can't translate this. */
- error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
- "are correct");
- setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
- bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
- textdomain (PACKAGE);
+ init_locale (LC_ALL, "");
if (argp_parse (&argp, argc, argv, 0, 0, 0))
exit (FAIL);
diff --git a/src/lexgrog_test.c b/src/lexgrog_test.c
index 3d604d7c..992b6910 100644
--- a/src/lexgrog_test.c
+++ b/src/lexgrog_test.c
@@ -35,7 +35,6 @@
#include "dirname.h"
#include "gettext.h"
-#include <locale.h>
#define _(String) gettext (String)
#define N_(String) gettext_noop (String)
@@ -136,15 +135,7 @@ int main (int argc, char **argv)
program_name = base_name (argv[0]);
init_debug ();
-
- if (!setlocale (LC_ALL, "") && !getenv ("MAN_NO_LOCALE_WARNING"))
- /* Obviously can't translate this. */
- error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
- "are correct");
- setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
- bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
- textdomain (PACKAGE);
+ init_locale (LC_ALL, "");
if (argp_parse (&argp, argc, argv, 0, 0, 0))
exit (FAIL);
diff --git a/src/man.c b/src/man.c
index 8eb4e827..38b4ba0c 100644
--- a/src/man.c
+++ b/src/man.c
@@ -984,15 +984,7 @@ int main (int argc, char *argv[])
init_debug ();
umask (022);
- /* initialise the locale */
- if (!setlocale (LC_ALL, "") && !getenv ("MAN_NO_LOCALE_WARNING"))
- /* Obviously can't translate this. */
- error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
- "are correct");
- setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
- bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
- textdomain (PACKAGE);
+ init_locale (LC_ALL, "");
internal_locale = setlocale (LC_MESSAGES, NULL);
/* Use LANGUAGE only when LC_MESSAGES locale category is
diff --git a/src/manconv_main.c b/src/manconv_main.c
index 0568657e..70915186 100644
--- a/src/manconv_main.c
+++ b/src/manconv_main.c
@@ -32,7 +32,6 @@
#include "dirname.h"
#include "gettext.h"
-#include <locale.h>
#define _(String) gettext (String)
#define N_(String) gettext_noop (String)
@@ -153,15 +152,7 @@ int main (int argc, char *argv[])
program_name = base_name (argv[0]);
init_debug ();
-
- if (!setlocale (LC_ALL, "") && !getenv ("MAN_NO_LOCALE_WARNING"))
- /* Obviously can't translate this. */
- error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
- "are correct");
- setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
- bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
- textdomain (PACKAGE);
+ init_locale (LC_ALL, "");
if (argp_parse (&argp, argc, argv, 0, 0, 0))
exit (FAIL);
diff --git a/src/mandb.c b/src/mandb.c
index b9ad91e4..53948063 100644
--- a/src/mandb.c
+++ b/src/mandb.c
@@ -48,7 +48,6 @@
#include "xgetcwd.h"
#include "gettext.h"
-#include <locale.h>
#define _(String) gettext (String)
#define N_(String) gettext_noop (String)
@@ -580,16 +579,7 @@ int main (int argc, char *argv[])
program_name = base_name (argv[0]);
init_debug ();
-
- /* initialise the locale */
- if (!setlocale (LC_ALL, "") && !getenv ("MAN_NO_LOCALE_WARNING"))
- /* Obviously can't translate this. */
- error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
- "are correct");
- setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
- bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
- textdomain (PACKAGE);
+ init_locale (LC_ALL, "");
if (argp_parse (&argp, argc, argv, 0, 0, 0))
exit (FAIL);
diff --git a/src/manpath.c b/src/manpath.c
index 52efbb0a..ff70a4f4 100644
--- a/src/manpath.c
+++ b/src/manpath.c
@@ -38,7 +38,6 @@
#include "dirname.h"
#include "gettext.h"
-#include <locale.h>
#define _(String) gettext (String)
#define N_(String) gettext_noop (String)
@@ -113,16 +112,7 @@ int main (int argc, char *argv[])
program_name = base_name (argv[0]);
init_debug ();
-
- /* initialise the locale */
- if (!setlocale (LC_ALL, "") && !getenv ("MAN_NO_LOCALE_WARNING"))
- /* Obviously can't translate this. */
- error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
- "are correct");
- setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
- bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
- textdomain (PACKAGE);
+ init_locale (LC_ALL, "");
if (argp_parse (&argp, argc, argv, 0, 0, 0))
exit (FAIL);
diff --git a/src/whatis.c b/src/whatis.c
index 1d8f6002..6dfccff0 100644
--- a/src/whatis.c
+++ b/src/whatis.c
@@ -704,16 +704,7 @@ int main (int argc, char *argv[])
}
init_debug ();
-
- /* initialise the locale */
- if (!setlocale (LC_ALL, "") && !getenv ("MAN_NO_LOCALE_WARNING"))
- /* Obviously can't translate this. */
- error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
- "are correct");
- setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
- bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
- textdomain (PACKAGE);
+ init_locale (LC_ALL, "");
internal_locale = setlocale (LC_MESSAGES, NULL);
/* Use LANGUAGE only when LC_MESSAGES locale category is
diff --git a/src/zsoelim_main.c b/src/zsoelim_main.c
index 5ad4d501..786bc37b 100644
--- a/src/zsoelim_main.c
+++ b/src/zsoelim_main.c
@@ -32,7 +32,6 @@
#include "dirname.h"
#include "gettext.h"
-#include <locale.h>
#define _(String) gettext (String)
#define N_(String) gettext_noop (String)
@@ -98,15 +97,7 @@ int main (int argc, char *argv[])
program_name = base_name (argv[0]);
init_debug ();
-
- if (!setlocale (LC_ALL, "") && !getenv ("MAN_NO_LOCALE_WARNING"))
- /* Obviously can't translate this. */
- error (0, 0, "can't set the locale; make sure $LC_* and $LANG "
- "are correct");
- setenv ("MAN_NO_LOCALE_WARNING", "1", 1);
- bindtextdomain (PACKAGE, LOCALEDIR);
- bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
- textdomain (PACKAGE);
+ init_locale (LC_ALL, "");
if (argp_parse (&argp, argc, argv, 0, 0, 0))
exit (FAIL);