summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in18
-rw-r--r--NEWS3
-rw-r--r--bindtextdomain.c83
-rw-r--r--configure.in19
-rw-r--r--debian/changelog3
-rw-r--r--debian/control2
-rw-r--r--hacklocaledir.c113
-rw-r--r--help2man.texi18
-rw-r--r--po/help2man.pot28
9 files changed, 133 insertions, 154 deletions
diff --git a/Makefile.in b/Makefile.in
index 7ed91e8..b26e052 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -30,7 +30,7 @@ MSGFMT = @MSGFMT@
MKINSTALLDIRS = $(srcdir)/mkinstalldirs
target = help2man
-preload = hacklocaledir
+preload = bindtextdomain
all: $(target) man info @extra_make_all@
@@ -82,20 +82,21 @@ uninstall:
clean:
-rm -f $(target) $(preload).so
+ -rm -rf localetmp
mostlyclean: clean
- cd $(srcdir) && rm -f $(target).dvi $(target).aux $(target).cp \
- $(target).cps $(target).fn $(target).ky $(target).log \
- $(target).pg $(target).toc $(target).tp $(target).vr po/*.po~
+ rm -f $(target).dvi $(target).aux $(target).cp $(target).cps \
+ $(target).fn $(target).ky $(target).log $(target).pg $(target).toc \
+ $(target).tp $(target).vr po/*.po~
distclean: mostlyclean
-rm -rf config.cache config.log config.status Makefile autom4te.cache
realclean: distclean
- cd $(srcdir) && rm -f $(target).info $(target).1 $(target).*.1 po/*.gmo
+ rm -f $(target).info $(target).1 $(target).*.1 po/*.gmo
maintainer-clean: realclean
- rm -f configure
+ rm -f $(srcdir)/configure
$(target): $(srcdir)/$(target).PL
$(PERL) $? @extra_extract_args@
@@ -114,8 +115,9 @@ man_l10n: $(addprefix $(target).,$(addsuffix .1,$(LINGUAS)))
$(target).%.1: $(srcdir)/$(target).PL $(srcdir)/$(target).%.h2m $(srcdir)/po/%.po
lang=$(patsubst $(target).%.1,%,$@); \
$(MAKE) $(target) $(preload).so po/$$lang.gmo && \
- LD_PRELOAD="./$(preload).so preloadable_libintl.so" \
- TEXTDOMAIN=help2man \
+ $(MKINSTALLDIRS) localetmp/$$lang/LC_MESSAGES && \
+ $(INSTALL_DATA) po/$$lang.gmo localetmp/$$lang/LC_MESSAGES/$(target).mo && \
+ LD_PRELOAD=./$(preload).so LOCALEDIR=localetmp TEXTDOMAIN=help2man \
./$(target) --include=$(srcdir)/$(target).$$lang.h2m \
--output=$@ ./$(target)
diff --git a/NEWS b/NEWS
index d426f0e..5afed49 100644
--- a/NEWS
+++ b/NEWS
@@ -1,4 +1,4 @@
-Version 1.37 October 30, 2009
+Version 1.37 November 14, 2009
* Update GPL to v3.
* Add --version-string option.
@@ -6,6 +6,7 @@ Version 1.37 October 30, 2009
* Add line breaks into bug reporting section.
* Add Brazilian Portuguese and German translations.
* Select a reasonable configure default for --enable-nls.
+ * Revise preload mechanism to not require preloadable libintl.
Version 1.36 October 17, 2005
diff --git a/bindtextdomain.c b/bindtextdomain.c
new file mode 100644
index 0000000..60471bd
--- /dev/null
+++ b/bindtextdomain.c
@@ -0,0 +1,83 @@
+/*
+ * Nasty preload hack to allow message catalogs to be read from the build tree.
+ *
+ * export LD_PRELOAD=/usr/lib/help2man/bindtextdomain.so
+ * export TEXTDOMAIN=program
+ * export LOCALEDIR=${DESTDIR}/usr/share/locale
+ */
+
+#define _GNU_SOURCE
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <dlfcn.h>
+
+#define PRELOAD "bindtextdomain.so"
+
+static void die(char const *msg)
+{
+ fprintf(stderr, PRELOAD ": %s\n", msg);
+ exit(1);
+}
+
+static char *e_textdomain = 0;
+static char *e_localedir = 0;
+static char *(*r_textdomain)(char const *) = 0;
+static char *(*r_bindtextdomain)(char const *, char const *) = 0;
+static char *(*r_bind_textdomain_codeset)(char const *, char const *) = 0;
+
+void setup()
+{
+ static int done = 0;
+ if (done++)
+ return;
+
+ if (!(e_textdomain = getenv("TEXTDOMAIN")))
+ die("TEXTDOMAIN not set");
+
+ if (!(e_localedir = getenv("LOCALEDIR")))
+ die("LOCALEDIR not set");
+
+ if (!(r_textdomain = dlsym(RTLD_NEXT, "textdomain")))
+ die("can't find symbol \"textdomain\"");
+
+ if (!(r_bindtextdomain = dlsym(RTLD_NEXT, "bindtextdomain")))
+ die("can't find symbol \"bindtextdomain\"");
+
+ if (!(r_bind_textdomain_codeset = dlsym(RTLD_NEXT,
+ "bind_textdomain_codeset")))
+ die("can't find symbol \"bind_textdomain_codeset\"");
+}
+
+char *textdomain(char const *domainname)
+{
+ char *r;
+ setup();
+ r = r_textdomain(domainname);
+ if (domainname && !strcmp(domainname, e_textdomain))
+ r_bindtextdomain(domainname, e_localedir);
+
+ return r;
+}
+
+char *bindtextdomain(char const *domainname, char const *dirname)
+{
+ char const *dir = dirname;
+ setup();
+ if (domainname && !strcmp(domainname, e_textdomain))
+ dir = e_localedir;
+
+ return r_bindtextdomain(domainname, dir);
+}
+
+char *bind_textdomain_codeset(char const *domainname, char const *codeset)
+{
+ char *r;
+ setup();
+ r = r_bind_textdomain_codeset(domainname, codeset);
+ if (domainname && !strcmp(domainname, e_textdomain))
+ r_bindtextdomain(domainname, e_localedir);
+
+ return r;
+}
diff --git a/configure.in b/configure.in
index 3be80ed..e2553ea 100644
--- a/configure.in
+++ b/configure.in
@@ -9,15 +9,13 @@ AC_PATH_PROG(MSGFMT, msgfmt)
AC_PROG_CC
AC_SEARCH_LIBS(dlsym, dl)
-
-AC_MSG_CHECKING([for pre-loadable libintl])
-preload=`LD_PRELOAD="preloadable_libintl.so" sh -c 'echo yes' 2>/dev/null`
-AC_MSG_RESULT(${preload:=no})
+AC_SEARCH_LIBS(bindtextdomain, intl)
nls_default=yes
-test "$ac_cv_module_Locale__gettext" = no && nls_default=no
+test "x$ac_cv_module_Locale__gettext" = xno && nls_default=no
test -z "$MSGFMT" && nls_default=no
-test "$preload" = no && nls_default=no
+test "x$ac_cv_search_dlsym" = xno && nls_default=no
+test "x$ac_cv_search_bindtextdomain" = xno && nls_default=no
AC_ARG_ENABLE([nls], AC_HELP_STRING([--enable-nls],
[enable support for generating localised pages]),
@@ -29,13 +27,16 @@ AC_SUBST(extra_extract_args, '')
if test "$ac_cv_enable_nls" = yes
then
# note: the following tests should match what is used to set nls_default above
- test "$ac_cv_module_Locale__gettext" = no &&
+ test "x$ac_cv_module_Locale__gettext" = xno &&
AC_MSG_ERROR([perl module Locale::gettext required])
test -z "$MSGFMT" && AC_MSG_ERROR([gettext required])
- test "$preload" = no &&
- AC_MSG_ERROR([libpreloadable_libintl.so required (gettext 0.12+)])
+ test "x$ac_cv_search_dlsym" = xno &&
+ AC_MSG_ERROR([dlsym() required])
+
+ test "x$ac_cv_search_bindtextdomain" = xno &&
+ AC_MSG_ERROR([bindtextdomain() required])
extra_make_all='preload man_l10n'
extra_make_install='install_preload install_l10n'
diff --git a/debian/changelog b/debian/changelog
index 4d9f299..0728d64 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -22,8 +22,9 @@ help2man (1.37.1) unstable; urgency=low
* Select a reasonable configure default for --enable-nls.
* Parse program output and include files in the chartset given by --locale.
* Conditionally include gettext support at extraction, rather than run-time.
+ * Revise preload mechanism to not require preloadable libintl.
- -- Brendan O'Dea <bod@debian.org> Fri, 30 Oct 2009 17:54:15 +1100
+ -- Brendan O'Dea <bod@debian.org> Sat, 14 Nov 2009 17:44:42 +1100
help2man (1.36.4+nmu1) unstable; urgency=low
diff --git a/debian/control b/debian/control
index 5b36292..06d4dbc 100644
--- a/debian/control
+++ b/debian/control
@@ -3,7 +3,7 @@ Section: devel
Priority: optional
Maintainer: Brendan O'Dea <bod@debian.org>
Standards-Version: 3.5.1
-Build-Depends: perl (>= 5.6.0-18), debhelper (>= 3.0.5), gettext (>= 0.12.1), liblocale-gettext-perl
+Build-Depends: perl (>= 5.8.0-7), debhelper (>= 3.0.5), gettext (>= 0.12.1), liblocale-gettext-perl
Vcs-Git: git://git.debian.org/users/bod/help2man.git
Vcs-Browser: http://git.debian.org/?p=users/bod/help2man.git
diff --git a/hacklocaledir.c b/hacklocaledir.c
deleted file mode 100644
index 25e40f6..0000000
--- a/hacklocaledir.c
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Nasty preload hack to allow message catalogs to be read from the "po"
- * subdir of the build tree.
- *
- * export LD_PRELOAD="hacklocaledir.so preloadable_libintl.so"
- * export TEXTDOMAIN=program
- */
-
-#define _GNU_SOURCE
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-#include <dlfcn.h>
-
-#define PRELOAD "hacklocaledir.so"
-
-static void *xmalloc(size_t len)
-{
- void *r = malloc(len);
- if (!r)
- {
- fprintf(stderr, PRELOAD ": can't malloc %d bytes (%s)\n", len,
- strerror(errno));
- exit(1);
- }
-
- return r;
-}
-
-int __open(char const *path, int flags, mode_t mode)
-{
- static int (*open)(char const *, int, mode_t) = 0;
- static char const *textdomain = 0;
- static char const *localedir = 0;
- static size_t localedirlen;
- static char *match = 0;
- static size_t matchlen;
- char *newpath = 0;
- int r;
-
- if (!open && !(open = dlsym(RTLD_NEXT, "open")))
- {
- fprintf(stderr, PRELOAD ": can't find open(): %s\n", dlerror());
- return -1;
- }
-
- if (textdomain || (textdomain = getenv("TEXTDOMAIN")))
- {
- size_t pathlen = strlen(path);
- char const *check;
-
- if (!localedir)
- {
- if (!(localedir = getenv("LOCALEDIR")))
- localedir = "po";
-
- localedirlen = strlen(localedir);
- }
-
- if (!match)
- {
- matchlen = sizeof("/LC_MESSAGES/")-1 + strlen(textdomain)
- + sizeof(".mo")-1;
-
- match = xmalloc(matchlen + 1);
- strcpy(match, "/LC_MESSAGES/");
- strcat(match, textdomain);
- strcat(match, ".mo");
- }
-
- if (*path == '/' && pathlen > matchlen &&
- !strcmp(check = (path + pathlen - matchlen), match))
- {
- char const *p = path;
- char const *locale = 0;
- do {
- locale = p + 1;
- p = strchr(locale, '/');
- } while (p && p < check);
-
- if (locale)
- {
- size_t len = strcspn(locale, "/");
- newpath = xmalloc(localedirlen + 1 + len + sizeof(".gmo"));
- strcpy(newpath, localedir);
- strcat(newpath, "/");
- strncat(newpath, locale, len);
- strcat(newpath, ".gmo");
-
- if (access(newpath, R_OK))
- {
- free(newpath);
- newpath = 0;
- }
- }
- }
- }
-
- r = (*open)(newpath ? newpath : path, flags, mode);
- if (newpath)
- {
- fprintf(stderr, "note: mapped %s to %s\n", path, newpath);
- free(newpath);
- }
-
- return r;
-}
-
-int open(char const *path, int flags, mode_t mode)
- __attribute__((weak, alias("__open")));
diff --git a/help2man.texi b/help2man.texi
index 8d3189b..3b15237 100644
--- a/help2man.texi
+++ b/help2man.texi
@@ -392,20 +392,24 @@ will not be (if installed at all) correct for the version of the
program being built.
A preloadable library is provided with @command{help2man} which will
-intercept @code{open(2)} calls for message catalogs for the domain
-given by @env{$TEXTDOMAIN} and re-map the requests to the appropriate
-file under @code{./po} (or @env{$LOCALEDIR} if given).
+intercept @code{gettext} calls configuring the location of message
+catalogs for the domain given by @env{$TEXTDOMAIN} and override the
+location to the path given by @env{$LOCALEDIR}.
So for example:
@example
-LD_PRELOAD="hacklocaledir.so preloadable_libintl.so" TEXTDOMAIN=@var{prog} \
+mkdir -p tmp/fr/LC_MESSAGES
+cp po/fr.gmo tmp/fr/LC_MESSAGES/@var{prog}.mo
+LD_PRELOAD="/usr/lib/help2man/bindtextdomain.so" \
+ LOCALEDIR=tmp \
+ TEXTDOMAIN=@var{prog} \
help2man -L fr_FR@@euro -i @var{prog}.fr.h2m -o @var{prog}.fr.1 @var{prog}
+rm -rf tmp
@end example
-will translate requests by @var{prog} for
-@samp{/usr/share/locale/fr/LC_MESSGAES/@var{PROG}.mo} to
-@samp{po/fr.gmo}.
+will cause @var{prog} to load the message catalog from @samp{tmp}
+rather than @samp{/usr/share/locale}.
Notes:
@itemize @bullet
diff --git a/po/help2man.pot b/po/help2man.pot
index 1d695ab..1bb0899 100644
--- a/po/help2man.pot
+++ b/po/help2man.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: Brendan O'Dea <bug-help2man@gnu.org>\n"
-"POT-Creation-Date: 2009-10-30 17:42+1100\n"
+"POT-Creation-Date: 2009-11-14 17:05+1100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -81,7 +81,7 @@ msgstr ""
msgid "%s: can't create %s (%s)"
msgstr ""
-#: help2man:282 help2man:581
+#: help2man:282 help2man:577
msgid "NAME"
msgstr ""
@@ -110,11 +110,11 @@ msgstr ""
msgid "or"
msgstr ""
-#: help2man:347 help2man:581
+#: help2man:347 help2man:577
msgid "SYNOPSIS"
msgstr ""
-#: help2man:351 help2man:581
+#: help2man:351 help2man:577
msgid "DESCRIPTION"
msgstr ""
@@ -138,31 +138,31 @@ msgstr ""
msgid "This +is +free +software"
msgstr ""
-#: help2man:384 help2man:581
+#: help2man:388 help2man:577
msgid "OPTIONS"
msgstr ""
-#: help2man:389 help2man:582
+#: help2man:393 help2man:578
msgid "EXAMPLES"
msgstr ""
-#: help2man:396 help2man:584
+#: help2man:400 help2man:580
msgid "COPYRIGHT"
msgstr ""
-#: help2man:425 help2man:584
+#: help2man:406 help2man:580
msgid "REPORTING BUGS"
msgstr ""
-#: help2man:432 help2man:584
+#: help2man:412 help2man:580
msgid "AUTHOR"
msgstr ""
-#: help2man:556 help2man:584
+#: help2man:552 help2man:580
msgid "SEE ALSO"
msgstr ""
-#: help2man:560
+#: help2man:556
#, perl-format
msgid ""
"The full documentation for\n"
@@ -178,17 +178,17 @@ msgid ""
"should give you access to the complete manual.\n"
msgstr ""
-#: help2man:612
+#: help2man:608
#, perl-format
msgid "%s: error writing to %s (%s)"
msgstr ""
-#: help2man:637
+#: help2man:633
#, perl-format
msgid "%s: can't get `%s' info from %s"
msgstr ""
-#: help2man:638
+#: help2man:634
msgid ""
"\n"
"Try `--no-discard-stderr' if option outputs to stderr"