summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-16 08:13:10 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-08-16 08:13:10 (GMT)
commit56ac2b6a5d6eb829a7da8eecc04cbf5f9339e61b (patch) (side-by-side diff)
tree5dc8009ac82abcfa8f22aa1ef38c85244af77a25
parentae9ea0011da4ba01e5639611d61c442af8d42817 (diff)
downloadgdbm-56ac2b6a5d6eb829a7da8eecc04cbf5f9339e61b.tar.gz
gdbm-56ac2b6a5d6eb829a7da8eecc04cbf5f9339e61b.tar.bz2
Internationalization.
* Makefile.am (SUBDIRS): Add po. (EXTRA_DIST): Add build-aux/config.rpath. * configure.ac (AC_CONFIG_FILES): Add po/Makefile.in. * bootstrap: New file. * src/Makefile.am (AM_CPPFLAGS): Define LOCALEDIR (noinst_HEADERS): Add gettext.h (LIBADD): New variable. * src/gettext.h: New file. * po/.cvsignore: New file. * po/Makevars: New file. * po/POTFILES.in: New file. * src/gdbmdefs.h: Define DEFAULT_TEXT_DOMAIN, _, N_ Include gettext.h * src/bucket.c: Add NLS markers. * src/falloc.c: Likewise. * src/findkey.c: Likewise. * src/gdbmerrno.c: Likewise. * src/gdbmfetch.c: Likewise. * src/gdbmseq.c: Likewise. * src/gdbmstore.c: Likewise. * src/update.c: Likewise. * src/testgdbm.c: Add NLS markers. (main): Initialize I18N.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--.cvsignore1
-rw-r--r--ChangeLog28
-rw-r--r--Makefile.am4
-rwxr-xr-xbootstrap3
-rw-r--r--configure.ac13
-rw-r--r--po/.cvsignore20
-rw-r--r--po/Makefile557
-rw-r--r--po/Makevars60
-rw-r--r--po/POTFILES.in23
-rw-r--r--src/Makefile.am5
-rw-r--r--src/bucket.c14
-rw-r--r--src/falloc.c12
-rw-r--r--src/findkey.c6
-rw-r--r--src/gdbmdefs.h5
-rw-r--r--src/gdbmerrno.c58
-rw-r--r--src/gdbmfetch.c2
-rw-r--r--src/gdbmseq.c2
-rw-r--r--src/gdbmstore.c6
-rw-r--r--src/gettext.h280
-rw-r--r--src/testgdbm.c243
-rw-r--r--src/update.c13
21 files changed, 1176 insertions, 179 deletions
diff --git a/.cvsignore b/.cvsignore
index 8685cda..9788ab7 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -1,5 +1,6 @@
.emacs*
*.tar.*
+ABOUT-NLS
Makefile
Makefile.in
aclocal.m4
diff --git a/ChangeLog b/ChangeLog
index 0758f83..0e9a917 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,31 @@
+2011-08-16 Sergey Poznyakoff <gray@gnu.org.ua>
+
+ Internationalization.
+
+ * Makefile.am (SUBDIRS): Add po.
+ (EXTRA_DIST): Add build-aux/config.rpath.
+ * configure.ac (AC_CONFIG_FILES): Add po/Makefile.in.
+ * bootstrap: New file.
+ * src/Makefile.am (AM_CPPFLAGS): Define LOCALEDIR
+ (noinst_HEADERS): Add gettext.h
+ (LIBADD): New variable.
+ * src/gettext.h: New file.
+ * po/.cvsignore: New file.
+ * po/Makevars: New file.
+ * po/POTFILES.in: New file.
+ * src/gdbmdefs.h: Define DEFAULT_TEXT_DOMAIN, _, N_
+ Include gettext.h
+ * src/bucket.c: Add NLS markers.
+ * src/falloc.c: Likewise.
+ * src/findkey.c: Likewise.
+ * src/gdbmerrno.c: Likewise.
+ * src/gdbmfetch.c: Likewise.
+ * src/gdbmseq.c: Likewise.
+ * src/gdbmstore.c: Likewise.
+ * src/update.c: Likewise.
+ * src/testgdbm.c: Add NLS markers.
+ (main): Initialize I18N.
+
2011-08-14 Sergey Poznyakoff <gray@gnu.org.ua>
* compat/Makefile.am (libgdbm_compat_la_LIBADD): Link against
diff --git a/Makefile.am b/Makefile.am
index dfeb571..8768298 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,14 +15,14 @@
# along with GDBM. If not, see <http://www.gnu.org/licenses/>. */
ACLOCAL_AMFLAGS = -I m4
-EXTRA_DIST = NOTE-WARNING
+EXTRA_DIST = build-aux/config.rpath NOTE-WARNING
if COMPAT_OPT
MAYBE_COMPAT = compat
endif
if ENABLE_EXPORT
MAYBE_EXPORT = export
endif
-SUBDIRS = src doc $(MAYBE_COMPAT) $(MAYBE_EXPORT) tests
+SUBDIRS = po src doc $(MAYBE_COMPAT) $(MAYBE_EXPORT) tests
DISTCHECK_CONFIGURE_FLAGS = --enable-libgdbm-compat
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..edef987
--- a/dev/null
+++ b/bootstrap
@@ -0,0 +1,3 @@
+#! /bin/sh
+test -d m4 || mkdir m4
+autoreconf -f -i -s \ No newline at end of file
diff --git a/configure.ac b/configure.ac
index fe009d5..23da438 100644
--- a/configure.ac
+++ b/configure.ac
@@ -76,7 +76,8 @@ AC_ARG_WITH([gdbm183-includedir],
[Build gdbmexport with gdbm.h in the specified directory.]),
[GDBM183_INCLUDEDIR=$withval],
[GDBM183_INCLUDEDIR="/usr/local/include"])
-
+
+dnl Check for programs
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
@@ -86,11 +87,15 @@ dnl AC_PROG_RANLIB
dnl AC_C_BIGENDIAN([])
AC_C_CONST
-AC_CHECK_HEADERS([stdlib.h string.h sys/file.h unistd.h fcntl.h sys/types.h memory.h sys/termios.h])
+dnl Internationalization macros.
+AM_GNU_GETTEXT([external], [need-ngettext])
+AM_GNU_GETTEXT_VERSION(0.18)
+
+AC_CHECK_HEADERS([stdlib.h string.h sys/file.h unistd.h fcntl.h sys/types.h memory.h sys/termios.h locale.h])
AC_CHECK_LIB(dbm, main)
AC_CHECK_LIB(ndbm, main)
-AC_CHECK_FUNCS([rename ftruncate flock lockf fsync])
+AC_CHECK_FUNCS([rename ftruncate flock lockf fsync setlocale])
if test x$mapped_io = xyes
then
@@ -109,7 +114,7 @@ AM_CONDITIONAL([ENABLE_EXPORT], [test "$want_export" = yes])
# Initialize the test suite.
AC_CONFIG_TESTDIR(tests)
-AC_CONFIG_FILES([tests/Makefile tests/atlocal])
+AC_CONFIG_FILES([tests/Makefile tests/atlocal po/Makefile.in])
AM_MISSING_PROG([AUTOM4TE], [autom4te])
AC_CONFIG_FILES([Makefile
diff --git a/po/.cvsignore b/po/.cvsignore
new file mode 100644
index 0000000..6c366a5
--- a/dev/null
+++ b/po/.cvsignore
@@ -0,0 +1,20 @@
+*.gmo
+*.mo
+*.po
+.reference
+Makefile
+Makefile.in
+Makefile.in.in
+Makevars.template
+POTFILES
+Rules-quot
+boldquot.sed
+gdbm.pot
+en@boldquot.header
+en@quot.header
+insert-header.sed
+insert-header.sin
+quot.sed
+remove-potcdate.sed
+remove-potcdate.sin
+stamp-po
diff --git a/po/Makefile b/po/Makefile
new file mode 100644
index 0000000..2a987f0
--- a/dev/null
+++ b/po/Makefile
@@ -0,0 +1,557 @@
+# Makefile for PO directory in any package using GNU gettext.
+# Copyright (C) 1995-1997, 2000-2007, 2009-2010 by Ulrich Drepper <drepper@gnu.ai.mit.edu>
+#
+# This file can be copied and used freely without restrictions. It can
+# be used in projects which are not available under the GNU General Public
+# License but which still want to provide support for the GNU gettext
+# functionality.
+# Please note that the actual code of GNU gettext is covered by the GNU
+# General Public License and is *not* in the public domain.
+#
+# Origin: gettext-0.18
+GETTEXT_MACRO_VERSION = 0.18
+
+PACKAGE = gdbm
+VERSION = 1.9.1
+PACKAGE_BUGREPORT = bug-gdbm@gnu.org
+
+SHELL = /bin/sh
+
+
+srcdir = .
+top_srcdir = ..
+
+
+prefix = /home/gray/alpha
+exec_prefix = ${prefix}
+datarootdir = ${prefix}/share
+datadir = ${datarootdir}
+localedir = ${datarootdir}/locale
+gettextsrcdir = $(datadir)/gettext/po
+
+INSTALL = /usr/bin/ginstall -c
+INSTALL_DATA = ${INSTALL} -m 644
+
+# We use $(mkdir_p).
+# In automake <= 1.9.x, $(mkdir_p) is defined either as "mkdir -p --" or as
+# "$(mkinstalldirs)" or as "$(install_sh) -d". For these automake versions,
+# ${SHELL} /home/gray/gnu/gdbm/build-aux/install-sh does not start with $(SHELL), so we add it.
+# In automake >= 1.10, /usr/bin/mkdir -p is derived from ${MKDIR_P}, which is defined
+# either as "/path/to/mkdir -p" or ".../install-sh -c -d". For these automake
+# versions, $(mkinstalldirs) and $(install_sh) are unused.
+mkinstalldirs = $(SHELL) ${SHELL} /home/gray/gnu/gdbm/build-aux/install-sh -d
+install_sh = $(SHELL) ${SHELL} /home/gray/gnu/gdbm/build-aux/install-sh
+MKDIR_P = /usr/bin/mkdir -p
+mkdir_p = /usr/bin/mkdir -p
+
+GMSGFMT_ = /usr/bin/msgfmt
+GMSGFMT_no = /usr/bin/msgfmt
+GMSGFMT_yes = /usr/bin/msgfmt
+GMSGFMT = $(GMSGFMT_$(USE_MSGCTXT))
+MSGFMT_ = /usr/bin/msgfmt
+MSGFMT_no = /usr/bin/msgfmt
+MSGFMT_yes = /usr/bin/msgfmt
+MSGFMT = $(MSGFMT_$(USE_MSGCTXT))
+XGETTEXT_ = /usr/bin/xgettext
+XGETTEXT_no = /usr/bin/xgettext
+XGETTEXT_yes = /usr/bin/xgettext
+XGETTEXT = $(XGETTEXT_$(USE_MSGCTXT))
+MSGMERGE = msgmerge
+MSGMERGE_UPDATE = /usr/bin/msgmerge --update
+MSGINIT = msginit
+MSGCONV = msgconv
+MSGFILTER = msgfilter
+
+POFILES =
+GMOFILES =
+UPDATEPOFILES =
+DUMMYPOFILES =
+DISTFILES.common = Makefile.in.in remove-potcdate.sin \
+$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3)
+DISTFILES = $(DISTFILES.common) Makevars POTFILES.in \
+$(POFILES) $(GMOFILES) \
+$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3)
+
+POTFILES = \
+ ../src/gdbmerrno.c \
+ ../src/bucket.c \
+ ../src/falloc.c \
+ ../src/findkey.c \
+ ../src/gdbmseq.c \
+ ../src/testgdbm.c \
+ ../src/update.c
+CATALOGS =
+
+# Makevars gets inserted here. (Don't remove this line!)
+# Gettext variables for GDBM
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GDBM is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GDBM is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GDBM. If not, see <http://www.gnu.org/licenses/>.
+
+# Usually the message domain is the same as the package name.
+DOMAIN = $(PACKAGE)
+
+# These two variables depend on the location of this directory.
+subdir = po
+top_builddir = ..
+
+# These options get passed to xgettext.
+XGETTEXT_OPTIONS = \
+ --keyword=_\
+ --keyword=N_\
+ --flag=_:1:pass-c-format\
+ --flag=N_:1:pass-c-format\
+ --flag=error:2:c-format
+
+# This is the copyright holder that gets inserted into the header of the
+# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
+# package. (Note that the msgstr strings, extracted from the package's
+# sources, belong to the copyright holder of the package.) Translators are
+# expected to transfer the copyright for their translations to this person
+# or entity, or to disclaim their copyright. The empty string stands for
+# the public domain; in this case the translators are expected to disclaim
+# their copyright.
+COPYRIGHT_HOLDER = Free Software Foundation, Inc.
+
+# This is the email address or URL to which the translators shall report
+# bugs in the untranslated strings:
+# - Strings which are not entire sentences, see the maintainer guidelines
+# in the GNU gettext documentation, section 'Preparing Strings'.
+# - Strings which use unclear terms or require additional context to be
+# understood.
+# - Strings which make invalid assumptions about notation of date, time or
+# money.
+# - Pluralisation problems.
+# - Incorrect English spelling.
+# - Incorrect formatting.
+# It can be your email address, or a mailing list address where translators
+# can write to without being subscribed, or the URL of a web page through
+# which the translators can contact you.
+MSGID_BUGS_ADDRESS = bug-gdbm@gnu.org
+
+# This is the list of locale categories, beyond LC_MESSAGES, for which the
+# message catalogs shall be used. It is usually empty.
+EXTRA_LOCALE_CATEGORIES =
+
+.SUFFIXES:
+.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-create .po-update
+
+.po.mo:
+ @echo "$(MSGFMT) -c -o $@ $<"; \
+ $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@
+
+.po.gmo:
+ @lang=`echo $* | sed -e 's,.*/,,'`; \
+ test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
+ echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o $${lang}.gmo $${lang}.po"; \
+ cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics --verbose -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo
+
+.sin.sed:
+ sed -e '/^#/d' $< > t-$@
+ mv t-$@ $@
+
+
+all: check-macro-version all-yes
+
+all-yes: stamp-po
+all-no:
+
+# Ensure that the gettext macros and this Makefile.in.in are in sync.
+check-macro-version:
+ @test "$(GETTEXT_MACRO_VERSION)" = "0.18" \
+ || { echo "*** error: gettext infrastructure mismatch: using a Makefile.in.in from gettext version $(GETTEXT_MACRO_VERSION) but the autoconf macros are from gettext version 0.18" 1>&2; \
+ exit 1; \
+ }
+
+# $(srcdir)/$(DOMAIN).pot is only created when needed. When xgettext finds no
+# internationalized messages, no $(srcdir)/$(DOMAIN).pot is created (because
+# we don't want to bother translators with empty POT files). We assume that
+# LINGUAS is empty in this case, i.e. $(POFILES) and $(GMOFILES) are empty.
+# In this case, stamp-po is a nop (i.e. a phony target).
+
+# stamp-po is a timestamp denoting the last time at which the CATALOGS have
+# been loosely updated. Its purpose is that when a developer or translator
+# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS,
+# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent
+# invocations of "make" will do nothing. This timestamp would not be necessary
+# if updating the $(CATALOGS) would always touch them; however, the rule for
+# $(POFILES) has been designed to not touch files that don't need to be
+# changed.
+stamp-po: $(srcdir)/$(DOMAIN).pot
+ test ! -f $(srcdir)/$(DOMAIN).pot || \
+ test -z "$(GMOFILES)" || $(MAKE) $(GMOFILES)
+ @test ! -f $(srcdir)/$(DOMAIN).pot || { \
+ echo "touch stamp-po" && \
+ echo timestamp > stamp-poT && \
+ mv stamp-poT stamp-po; \
+ }
+
+# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update',
+# otherwise packages like GCC can not be built if only parts of the source
+# have been downloaded.
+
+# This target rebuilds $(DOMAIN).pot; it is an expensive operation.
+# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed.
+$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed
+ if LC_ALL=C grep 'GNU gdbm' $(top_srcdir)/* 2>/dev/null | grep -v 'libtool:' >/dev/null; then \
+ package_gnu='GNU '; \
+ else \
+ package_gnu=''; \
+ fi; \
+ if test -n '$(MSGID_BUGS_ADDRESS)' || test '$(PACKAGE_BUGREPORT)' = '@'PACKAGE_BUGREPORT'@'; then \
+ msgid_bugs_address='$(MSGID_BUGS_ADDRESS)'; \
+ else \
+ msgid_bugs_address='$(PACKAGE_BUGREPORT)'; \
+ fi; \
+ case `$(XGETTEXT) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-5] | 0.1[0-5].* | 0.16 | 0.16.[0-1]*) \
+ $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
+ --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
+ --files-from=$(srcdir)/POTFILES.in \
+ --copyright-holder='$(COPYRIGHT_HOLDER)' \
+ --msgid-bugs-address="$$msgid_bugs_address" \
+ ;; \
+ *) \
+ $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \
+ --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \
+ --files-from=$(srcdir)/POTFILES.in \
+ --copyright-holder='$(COPYRIGHT_HOLDER)' \
+ --package-name="$${package_gnu}gdbm" \
+ --package-version='1.9.1' \
+ --msgid-bugs-address="$$msgid_bugs_address" \
+ ;; \
+ esac
+ test ! -f $(DOMAIN).po || { \
+ if test -f $(srcdir)/$(DOMAIN).pot; then \
+ sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \
+ sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \
+ if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \
+ rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \
+ else \
+ rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \
+ mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
+ fi; \
+ else \
+ mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \
+ fi; \
+ }
+
+# This rule has no dependencies: we don't need to update $(DOMAIN).pot at
+# every "make" invocation, only create it when it is missing.
+# Only "make $(DOMAIN).pot-update" or "make dist" will force an update.
+$(srcdir)/$(DOMAIN).pot:
+ $(MAKE) $(DOMAIN).pot-update
+
+# This target rebuilds a PO file if $(DOMAIN).pot has changed.
+# Note that a PO file is not touched if it doesn't need to be changed.
+$(POFILES): $(srcdir)/$(DOMAIN).pot
+ @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \
+ if test -f "$(srcdir)/$${lang}.po"; then \
+ test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
+ echo "$${cdcmd}$(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot"; \
+ cd $(srcdir) \
+ && { case `$(MSGMERGE_UPDATE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
+ $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) $${lang}.po $(DOMAIN).pot;; \
+ *) \
+ $(MSGMERGE_UPDATE) $(MSGMERGE_OPTIONS) --lang=$${lang} $${lang}.po $(DOMAIN).pot;; \
+ esac; \
+ }; \
+ else \
+ $(MAKE) $${lang}.po-create; \
+ fi
+
+
+install: install-exec install-data
+install-exec:
+install-data: install-data-yes
+ if test "$(PACKAGE)" = "gettext-tools"; then \
+ $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
+ for file in $(DISTFILES.common) Makevars.template; do \
+ $(INSTALL_DATA) $(srcdir)/$$file \
+ $(DESTDIR)$(gettextsrcdir)/$$file; \
+ done; \
+ for file in Makevars; do \
+ rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
+ done; \
+ else \
+ : ; \
+ fi
+install-data-no: all
+install-data-yes: all
+ @catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
+ dir=$(localedir)/$$lang/LC_MESSAGES; \
+ $(mkdir_p) $(DESTDIR)$$dir; \
+ if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \
+ $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \
+ echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \
+ for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
+ if test -n "$$lc"; then \
+ if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
+ link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
+ mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
+ mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
+ (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
+ for file in *; do \
+ if test -f $$file; then \
+ ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
+ fi; \
+ done); \
+ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
+ else \
+ if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
+ :; \
+ else \
+ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
+ mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
+ fi; \
+ fi; \
+ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
+ ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
+ ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \
+ cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
+ echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \
+ fi; \
+ done; \
+ done
+
+install-strip: install
+
+installdirs: installdirs-exec installdirs-data
+installdirs-exec:
+installdirs-data: installdirs-data-yes
+ if test "$(PACKAGE)" = "gettext-tools"; then \
+ $(mkdir_p) $(DESTDIR)$(gettextsrcdir); \
+ else \
+ : ; \
+ fi
+installdirs-data-no:
+installdirs-data-yes:
+ @catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
+ dir=$(localedir)/$$lang/LC_MESSAGES; \
+ $(mkdir_p) $(DESTDIR)$$dir; \
+ for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \
+ if test -n "$$lc"; then \
+ if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \
+ link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \
+ mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
+ mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
+ (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \
+ for file in *; do \
+ if test -f $$file; then \
+ ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \
+ fi; \
+ done); \
+ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \
+ else \
+ if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \
+ :; \
+ else \
+ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \
+ mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \
+ fi; \
+ fi; \
+ fi; \
+ done; \
+ done
+
+# Define this as empty until I found a useful application.
+installcheck:
+
+uninstall: uninstall-exec uninstall-data
+uninstall-exec:
+uninstall-data: uninstall-data-yes
+ if test "$(PACKAGE)" = "gettext-tools"; then \
+ for file in $(DISTFILES.common) Makevars.template; do \
+ rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \
+ done; \
+ else \
+ : ; \
+ fi
+uninstall-data-no:
+uninstall-data-yes:
+ catalogs='$(CATALOGS)'; \
+ for cat in $$catalogs; do \
+ cat=`basename $$cat`; \
+ lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \
+ for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \
+ rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \
+ done; \
+ done
+
+check: all
+
+info dvi ps pdf html tags TAGS ctags CTAGS ID:
+
+mostlyclean:
+ rm -f remove-potcdate.sed
+ rm -f stamp-poT
+ rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po
+ rm -fr *.o
+
+clean: mostlyclean
+
+distclean: clean
+ rm -f Makefile Makefile.in POTFILES *.mo
+
+maintainer-clean: distclean
+ @echo "This command is intended for maintainers to use;"
+ @echo "it deletes files that may require special tools to rebuild."
+ rm -f stamp-po $(GMOFILES)
+
+distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
+dist distdir:
+ $(MAKE) update-po
+ @$(MAKE) dist2
+# This is a separate target because 'update-po' must be executed before.
+dist2: stamp-po $(DISTFILES)
+ dists="$(DISTFILES)"; \
+ if test "$(PACKAGE)" = "gettext-tools"; then \
+ dists="$$dists Makevars.template"; \
+ fi; \
+ if test -f $(srcdir)/$(DOMAIN).pot; then \
+ dists="$$dists $(DOMAIN).pot stamp-po"; \
+ fi; \
+ if test -f $(srcdir)/ChangeLog; then \
+ dists="$$dists ChangeLog"; \
+ fi; \
+ for i in 0 1 2 3 4 5 6 7 8 9; do \
+ if test -f $(srcdir)/ChangeLog.$$i; then \
+ dists="$$dists ChangeLog.$$i"; \
+ fi; \
+ done; \
+ if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \
+ for file in $$dists; do \
+ if test -f $$file; then \
+ cp -p $$file $(distdir) || exit 1; \
+ else \
+ cp -p $(srcdir)/$$file $(distdir) || exit 1; \
+ fi; \
+ done
+
+update-po: Makefile
+ $(MAKE) $(DOMAIN).pot-update
+ test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES)
+ $(MAKE) update-gmo
+
+# General rule for creating PO files.
+
+.nop.po-create:
+ @lang=`echo $@ | sed -e 's/\.po-create$$//'`; \
+ echo "File $$lang.po does not exist. If you are a translator, you can create it through 'msginit'." 1>&2; \
+ exit 1
+
+# General rule for updating PO files.
+
+.nop.po-update:
+ @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \
+ if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \
+ tmpdir=`pwd`; \
+ echo "$$lang:"; \
+ test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \
+ echo "$${cdcmd}$(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \
+ cd $(srcdir); \
+ if { case `$(MSGMERGE) --version | sed 1q | sed -e 's,^[^0-9]*,,'` in \
+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-7] | 0.1[0-7].*) \
+ $(MSGMERGE) $(MSGMERGE_OPTIONS) -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
+ *) \
+ $(MSGMERGE) $(MSGMERGE_OPTIONS) --lang=$$lang -o $$tmpdir/$$lang.new.po $$lang.po $(DOMAIN).pot;; \
+ esac; \
+ }; then \
+ if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
+ rm -f $$tmpdir/$$lang.new.po; \
+ else \
+ if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
+ :; \
+ else \
+ echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
+ exit 1; \
+ fi; \
+ fi; \
+ else \
+ echo "msgmerge for $$lang.po failed!" 1>&2; \
+ rm -f $$tmpdir/$$lang.new.po; \
+ fi
+
+$(DUMMYPOFILES):
+
+update-gmo: Makefile $(GMOFILES)
+ @:
+
+# Recreate Makefile by invoking config.status. Explicitly invoke the shell,
+# because execution permission bits may not work on the current file system.
+# Use /bin/sh, which is the shell determined by autoconf for the use by its
+# scripts, not $(SHELL) which is hardwired to /bin/sh and may be deficient.
+Makefile: Makefile.in.in Makevars $(top_builddir)/config.status POTFILES.in
+ cd $(top_builddir) \
+ && /bin/sh ./config.status $(subdir)/$@.in po-directories
+
+force:
+
+# Tell versions [3.59,3.63) of GNU make not to export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
+# Special Makefile rules for English message catalogs with quotation marks.
+
+DISTFILES.common.extra1 = quot.sed boldquot.sed en@quot.header en@boldquot.header insert-header.sin Rules-quot
+
+.SUFFIXES: .insert-header .po-update-en
+
+en@quot.po-create:
+ $(MAKE) en@quot.po-update
+en@boldquot.po-create:
+ $(MAKE) en@boldquot.po-update
+
+en@quot.po-update: en@quot.po-update-en
+en@boldquot.po-update: en@boldquot.po-update-en
+
+.insert-header.po-update-en:
+ @lang=`echo $@ | sed -e 's/\.po-update-en$$//'`; \
+ if test "$(PACKAGE)" = "gettext"; then PATH=`pwd`/../src:$$PATH; GETTEXTLIBDIR=`cd $(top_srcdir)/src && pwd`; export GETTEXTLIBDIR; fi; \
+ tmpdir=`pwd`; \
+ echo "$$lang:"; \
+ ll=`echo $$lang | sed -e 's/@.*//'`; \
+ LC_ALL=C; export LC_ALL; \
+ cd $(srcdir); \
+ if $(MSGINIT) -i $(DOMAIN).pot --no-translator -l $$lang -o - 2>/dev/null | sed -f $$tmpdir/$$lang.insert-header | $(MSGCONV) -t UTF-8 | $(MSGFILTER) sed -f `echo $$lang | sed -e 's/.*@//'`.sed 2>/dev/null > $$tmpdir/$$lang.new.po; then \
+ if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \
+ rm -f $$tmpdir/$$lang.new.po; \
+ else \
+ if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \
+ :; \
+ else \
+ echo "creation of $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \
+ exit 1; \
+ fi; \
+ fi; \
+ else \
+ echo "creation of $$lang.po failed!" 1>&2; \
+ rm -f $$tmpdir/$$lang.new.po; \
+ fi
+
+en@quot.insert-header: insert-header.sin
+ sed -e '/^#/d' -e 's/HEADER/en@quot.header/g' $(srcdir)/insert-header.sin > en@quot.insert-header
+
+en@boldquot.insert-header: insert-header.sin
+ sed -e '/^#/d' -e 's/HEADER/en@boldquot.header/g' $(srcdir)/insert-header.sin > en@boldquot.insert-header
+
+mostlyclean: mostlyclean-quot
+mostlyclean-quot:
+ rm -f *.insert-header
diff --git a/po/Makevars b/po/Makevars
new file mode 100644
index 0000000..4005c14
--- a/dev/null
+++ b/po/Makevars
@@ -0,0 +1,60 @@
+# Gettext variables for GDBM
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GDBM is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GDBM is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GDBM. If not, see <http://www.gnu.org/licenses/>.
+
+# Usually the message domain is the same as the package name.
+DOMAIN = $(PACKAGE)
+
+# These two variables depend on the location of this directory.
+subdir = po
+top_builddir = ..
+
+# These options get passed to xgettext.
+XGETTEXT_OPTIONS = \
+ --keyword=_\
+ --keyword=N_\
+ --flag=_:1:pass-c-format\
+ --flag=N_:1:pass-c-format\
+ --flag=error:2:c-format
+
+# This is the copyright holder that gets inserted into the header of the
+# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
+# package. (Note that the msgstr strings, extracted from the package's
+# sources, belong to the copyright holder of the package.) Translators are
+# expected to transfer the copyright for their translations to this person
+# or entity, or to disclaim their copyright. The empty string stands for
+# the public domain; in this case the translators are expected to disclaim
+# their copyright.
+COPYRIGHT_HOLDER = Free Software Foundation, Inc.
+
+# This is the email address or URL to which the translators shall report
+# bugs in the untranslated strings:
+# - Strings which are not entire sentences, see the maintainer guidelines
+# in the GNU gettext documentation, section 'Preparing Strings'.
+# - Strings which use unclear terms or require additional context to be
+# understood.
+# - Strings which make invalid assumptions about notation of date, time or
+# money.
+# - Pluralisation problems.
+# - Incorrect English spelling.
+# - Incorrect formatting.
+# It can be your email address, or a mailing list address where translators
+# can write to without being subscribed, or the URL of a web page through
+# which the translators can contact you.
+MSGID_BUGS_ADDRESS = bug-gdbm@gnu.org
+
+# This is the list of locale categories, beyond LC_MESSAGES, for which the
+# message catalogs shall be used. It is usually empty.
+EXTRA_LOCALE_CATEGORIES =
diff --git a/po/POTFILES.in b/po/POTFILES.in
new file mode 100644
index 0000000..e4145ff
--- a/dev/null
+++ b/po/POTFILES.in
@@ -0,0 +1,23 @@
+# List of GDBM source files which contain translatable strings.
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# GDBM is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# GDBM is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GDBM. If not, see <http://www.gnu.org/licenses/>.
+
+src/gdbmerrno.c
+src/bucket.c
+src/falloc.c
+src/findkey.c
+src/gdbmseq.c
+src/testgdbm.c
+src/update.c \ No newline at end of file
diff --git a/src/Makefile.am b/src/Makefile.am
index c2c2483..db85972 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,13 +15,14 @@
# along with GDBM. If not, see <http://www.gnu.org/licenses/>.
# Flags
-AM_CPPFLAGS=-DIN_GDBM
+AM_CPPFLAGS=-DIN_GDBM -DLOCALEDIR=\"$(localedir)\"
# Headers
include_HEADERS = gdbm.h
noinst_HEADERS = \
gdbmconst.h\
gdbmdefs.h\
+ gettext.h\
proto.h\
systems.h
@@ -33,6 +34,8 @@ VI_REVISION = 0
VI_AGE = 0
lib_LTLIBRARIES = libgdbm.la
+LIBADD = @LTLIBINTL@
+
libgdbm_la_SOURCES = \
gdbmopen.c\
gdbmdelete.c\
diff --git a/src/bucket.c b/src/bucket.c
index f8c48b9..cda2389 100644
--- a/src/bucket.c
+++ b/src/bucket.c
@@ -64,7 +64,7 @@ _gdbm_get_bucket (GDBM_FILE dbf, int dir_index)
if (dbf->bucket_cache == NULL)
{
if(_gdbm_init_cache(dbf, DEFAULT_CACHESIZE) == -1)
- _gdbm_fatal(dbf, "couldn't init cache");
+ _gdbm_fatal(dbf, _("couldn't init cache"));
}
/* Is that one is not already current, we must find it. */
@@ -94,11 +94,11 @@ _gdbm_get_bucket (GDBM_FILE dbf, int dir_index)
/* Read the bucket. */
file_pos = __lseek (dbf, bucket_adr, L_SET);
if (file_pos != bucket_adr)
- _gdbm_fatal (dbf, "lseek error");
+ _gdbm_fatal (dbf, _("lseek error"));
num_bytes = __read (dbf, dbf->bucket, dbf->header->bucket_size);
if (num_bytes != dbf->header->bucket_size)
- _gdbm_fatal (dbf, "read error");
+ _gdbm_fatal (dbf, _("read error"));
}
return;
@@ -145,7 +145,7 @@ _gdbm_split_bucket (GDBM_FILE dbf, int next_insert)
if (dbf->bucket_cache == NULL)
{
if(_gdbm_init_cache(dbf, DEFAULT_CACHESIZE) == -1)
- _gdbm_fatal(dbf, "couldn't init cache");
+ _gdbm_fatal(dbf, _("couldn't init cache"));
}
while (dbf->bucket->count == dbf->header->bucket_elems)
@@ -185,7 +185,7 @@ _gdbm_split_bucket (GDBM_FILE dbf, int next_insert)
dir_size = dbf->header->dir_size * 2;
dir_adr = _gdbm_alloc (dbf, dir_size);
new_dir = (off_t *) malloc (dir_size);
- if (new_dir == NULL) _gdbm_fatal (dbf, "malloc error");
+ if (new_dir == NULL) _gdbm_fatal (dbf, _("malloc error"));
for (index = 0;
index < dbf->header->dir_size/sizeof (off_t); index++)
{
@@ -308,10 +308,10 @@ _gdbm_write_bucket (GDBM_FILE dbf, cache_elem *ca_entry)
file_pos = __lseek (dbf, ca_entry->ca_adr, L_SET);
if (file_pos != ca_entry->ca_adr)
- _gdbm_fatal (dbf, "lseek error");
+ _gdbm_fatal (dbf, _("lseek error"));
num_bytes = __write (dbf, ca_entry->ca_bucket, dbf->header->bucket_size);
if (num_bytes != dbf->header->bucket_size)
- _gdbm_fatal (dbf, "write error");
+ _gdbm_fatal (dbf, _("write error"));
ca_entry->ca_changed = FALSE;
ca_entry->ca_data.hash_val = -1;
ca_entry->ca_data.elem_loc = -1;
diff --git a/src/falloc.c b/src/falloc.c
index 2a54d53..d0af4a6 100644
--- a/src/falloc.c
+++ b/src/falloc.c
@@ -178,13 +178,13 @@ pop_avail_block (GDBM_FILE dbf)
/* Allocate space for the block. */
new_blk = (avail_block *) malloc (new_el.av_size);
- if (new_blk == NULL) _gdbm_fatal(dbf, "malloc failed");
+ if (new_blk == NULL) _gdbm_fatal(dbf, _("malloc failed"));
/* Read the block. */
file_pos = __lseek (dbf, new_el.av_adr, L_SET);
- if (file_pos != new_el.av_adr) _gdbm_fatal (dbf, "lseek error");
+ if (file_pos != new_el.av_adr) _gdbm_fatal (dbf, _("lseek error"));
num_bytes = __read (dbf, new_blk, new_el.av_size);
- if (num_bytes != new_el.av_size) _gdbm_fatal (dbf, "read error");
+ if (num_bytes != new_el.av_size) _gdbm_fatal (dbf, _("read error"));
/* Add the elements from the new block to the header. */
index = 0;
@@ -256,7 +256,7 @@ push_avail_block (GDBM_FILE dbf)
/* Split the header block. */
temp = (avail_block *) malloc (av_size);
- if (temp == NULL) _gdbm_fatal (dbf, "malloc error");
+ if (temp == NULL) _gdbm_fatal (dbf, _("malloc error"));
/* Set the size to be correct AFTER the pop_avail_block. */
temp->size = dbf->header->avail.size;
temp->count = 0;
@@ -279,9 +279,9 @@ push_avail_block (GDBM_FILE dbf)
/* Update the disk. */
file_pos = __lseek (dbf, av_adr, L_SET);
- if (file_pos != av_adr) _gdbm_fatal (dbf, "lseek error");
+ if (file_pos != av_adr) _gdbm_fatal (dbf, _("lseek error"));
num_bytes = __write (dbf, temp, av_size);
- if (num_bytes != av_size) _gdbm_fatal (dbf, "write error");
+ if (num_bytes != av_size) _gdbm_fatal (dbf, _("write error"));
free (temp);
}
diff --git a/src/findkey.c b/src/findkey.c
index 12c7226..7933c2f 100644
--- a/src/findkey.c
+++ b/src/findkey.c
@@ -54,15 +54,15 @@ _gdbm_read_entry (GDBM_FILE dbf, int elem_loc)
data_ca->dptr = (char *) malloc (1);
else
data_ca->dptr = (char *) malloc (key_size+data_size);
- if (data_ca->dptr == NULL) _gdbm_fatal (dbf, "malloc error");
+ if (data_ca->dptr == NULL) _gdbm_fatal (dbf, _("malloc error"));
/* Read into the cache. */
file_pos = __lseek (dbf, dbf->bucket->h_table[elem_loc].data_pointer, L_SET);
if (file_pos != dbf->bucket->h_table[elem_loc].data_pointer)
- _gdbm_fatal (dbf, "lseek error");
+ _gdbm_fatal (dbf, _("lseek error"));
num_bytes = __read (dbf, data_ca->dptr, key_size+data_size);
- if (num_bytes != key_size+data_size) _gdbm_fatal (dbf, "read error");
+ if (num_bytes != key_size+data_size) _gdbm_fatal (dbf, _("read error"));
return data_ca->dptr;
}
diff --git a/src/gdbmdefs.h b/src/gdbmdefs.h
index e45abf8..28995de 100644
--- a/src/gdbmdefs.h
+++ b/src/gdbmdefs.h
@@ -20,6 +20,11 @@
#include "systems.h"
#include "gdbmconst.h"
#include "gdbm.h"
+#define DEFAULT_TEXT_DOMAIN PACKAGE
+#include "gettext.h"
+
+#define _(s) gettext (s)
+#define N_(s) s
/* The type definitions are next. */
diff --git a/src/gdbmerrno.c b/src/gdbmerrno.c
index 00d9271..16c07c2 100644
--- a/src/gdbmerrno.c
+++ b/src/gdbmerrno.c
@@ -19,7 +19,7 @@
/* Include system configuration before all else. */
#include "autoconf.h"
-#include "gdbm.h"
+#include "gdbmdefs.h"
/* The dbm error number is placed in the variable GDBM_ERRNO. */
gdbm_error gdbm_errno = GDBM_NO_ERROR;
@@ -28,41 +28,41 @@ gdbm_error gdbm_errno = GDBM_NO_ERROR;
like. it must be in the same order as the error codes! */
const char * const gdbm_errlist[_GDBM_MAX_ERRNO+1] = {
- "No error", /* GDBM_NO_ERROR */
- "Malloc error", /* GDBM_MALLOC_ERROR */
- "Block size error", /* GDBM_BLOCK_SIZE_ERROR */
- "File open error", /* GDBM_FILE_OPEN_ERROR */
- "File write error", /* GDBM_FILE_WRITE_ERROR */
- "File seek error", /* GDBM_FILE_SEEK_ERROR */
- "File read error", /* GDBM_FILE_READ_ERROR */
- "Bad magic number", /* GDBM_BAD_MAGIC_NUMBER */
- "Empty database", /* GDBM_EMPTY_DATABASE */
- "Can't be reader", /* GDBM_CANT_BE_READER */
- "Can't be writer", /* GDBM_CANT_BE_WRITER */
- "Reader can't delete", /* GDBM_READER_CANT_DELETE */
- "Reader can't store", /* GDBM_READER_CANT_STORE */
- "Reader can't reorganize", /* GDBM_READER_CANT_REORGANIZE */
- "Unknown update", /* GDBM_UNKNOWN_UPDATE */
- "Item not found", /* GDBM_ITEM_NOT_FOUND */
- "Reorganize failed", /* GDBM_REORGANIZE_FAILED */
- "Cannot replace", /* GDBM_CANNOT_REPLACE */
- "Illegal data", /* GDBM_ILLEGAL_DATA */
- "Option already set", /* GDBM_OPT_ALREADY_SET */
- "Illegal option", /* GDBM_OPT_ILLEGAL */
- "Byte-swapped file", /* GDBM_BYTE_SWAPPED */
- "Wrong file offset", /* GDBM_BAD_FILE_OFFSET */
- "Bad file flags" /* GDBM_BAD_OPEN_FLAGS */
+ N_("No error"), /* GDBM_NO_ERROR */
+ N_("Malloc error"), /* GDBM_MALLOC_ERROR */
+ N_("Block size error"), /* GDBM_BLOCK_SIZE_ERROR */
+ N_("File open error"), /* GDBM_FILE_OPEN_ERROR */
+ N_("File write error"), /* GDBM_FILE_WRITE_ERROR */
+ N_("File seek error"), /* GDBM_FILE_SEEK_ERROR */
+ N_("File read error"), /* GDBM_FILE_READ_ERROR */
+ N_("Bad magic number"), /* GDBM_BAD_MAGIC_NUMBER */
+ N_("Empty database"), /* GDBM_EMPTY_DATABASE */
+ N_("Can't be reader"), /* GDBM_CANT_BE_READER */
+ N_("Can't be writer"), /* GDBM_CANT_BE_WRITER */
+ N_("Reader can't delete"), /* GDBM_READER_CANT_DELETE */
+ N_("Reader can't store"), /* GDBM_READER_CANT_STORE */
+ N_("Reader can't reorganize"), /* GDBM_READER_CANT_REORGANIZE */
+ N_("Unknown update"), /* GDBM_UNKNOWN_UPDATE */
+ N_("Item not found"), /* GDBM_ITEM_NOT_FOUND */
+ N_("Reorganize failed"), /* GDBM_REORGANIZE_FAILED */
+ N_("Cannot replace"), /* GDBM_CANNOT_REPLACE */
+ N_("Illegal data"), /* GDBM_ILLEGAL_DATA */
+ N_("Option already set"), /* GDBM_OPT_ALREADY_SET */
+ N_("Illegal option"), /* GDBM_OPT_ILLEGAL */
+ N_("Byte-swapped file"), /* GDBM_BYTE_SWAPPED */
+ N_("Wrong file offset"), /* GDBM_BAD_FILE_OFFSET */
+ N_("Bad file flags") /* GDBM_BAD_OPEN_FLAGS */
};
const char *
-gdbm_strerror(gdbm_error error)
+gdbm_strerror (gdbm_error error)
{
- if(((int)error < _GDBM_MIN_ERRNO) || ((int)error > _GDBM_MAX_ERRNO))
+ if (((int)error < _GDBM_MIN_ERRNO) || ((int)error > _GDBM_MAX_ERRNO))
{
- return("Unknown error");
+ return _("Unknown error");
}
else
{
- return(gdbm_errlist[(int)error]);
+ return gettext (gdbm_errlist[(int)error]);
}
}
diff --git a/src/gdbmfetch.c b/src/gdbmfetch.c
index 39c9cd2..9095d6d 100644
--- a/src/gdbmfetch.c
+++ b/src/gdbmfetch.c
@@ -53,7 +53,7 @@ gdbm_fetch (GDBM_FILE dbf, datum key)
return_val.dptr = (char *) malloc (1);
else
return_val.dptr = (char *) malloc (return_val.dsize);
- if (return_val.dptr == NULL) _gdbm_fatal (dbf, "malloc error");
+ if (return_val.dptr == NULL) _gdbm_fatal (dbf, _("malloc error"));
memcpy (return_val.dptr, find_data, return_val.dsize);
}
diff --git a/src/gdbmseq.c b/src/gdbmseq.c
index cd2421a..4323185 100644
--- a/src/gdbmseq.c
+++ b/src/gdbmseq.c
@@ -70,7 +70,7 @@ get_next_key (GDBM_FILE dbf, int elem_loc, datum *return_val)
return_val->dptr = (char *) malloc (1);
else
return_val->dptr = (char *) malloc (return_val->dsize);
- if (return_val->dptr == NULL) _gdbm_fatal (dbf, "malloc error");
+ if (return_val->dptr == NULL) _gdbm_fatal (dbf, _("malloc error"));
memcpy (return_val->dptr, find_data, return_val->dsize);
}
diff --git a/src/gdbmstore.c b/src/gdbmstore.c
index 35a6863..5f1bb67 100644
--- a/src/gdbmstore.c
+++ b/src/gdbmstore.c
@@ -138,11 +138,11 @@ gdbm_store (GDBM_FILE dbf, datum key, datum content, int flags)
/* Write the data to the file. */
file_pos = __lseek (dbf, file_adr, L_SET);
- if (file_pos != file_adr) _gdbm_fatal (dbf, "lseek error");
+ if (file_pos != file_adr) _gdbm_fatal (dbf, _("lseek error"));
num_bytes = __write (dbf, key.dptr, key.dsize);
- if (num_bytes != key.dsize) _gdbm_fatal (dbf, "write error");
+ if (num_bytes != key.dsize) _gdbm_fatal (dbf, _("write error"));
num_bytes = __write (dbf, content.dptr, content.dsize);
- if (num_bytes != content.dsize) _gdbm_fatal (dbf, "write error");
+ if (num_bytes != content.dsize) _gdbm_fatal (dbf, _("write error"));
/* Current bucket has changed. */
dbf->cache_entry->ca_changed = TRUE;
diff --git a/src/gettext.h b/src/gettext.h
new file mode 100644
index 0000000..e76b592
--- a/dev/null
+++ b/src/gettext.h
@@ -0,0 +1,280 @@
+/* Convenience header for conditional use of GNU <libintl.h>.
+ Copyright (C) 1995-1998, 2000-2002, 2004-2006, 2009 Free Software Foundation, Inc.
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU General Public
+ License along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+ USA. */
+
+#ifndef _LIBGETTEXT_H
+#define _LIBGETTEXT_H 1
+
+/* NLS can be disabled through the configure --disable-nls option. */
+#if ENABLE_NLS
+
+/* Get declarations of GNU message catalog functions. */
+# include <libintl.h>
+
+/* You can set the DEFAULT_TEXT_DOMAIN macro to specify the domain used by
+ the gettext() and ngettext() macros. This is an alternative to calling
+ textdomain(), and is useful for libraries. */
+# ifdef DEFAULT_TEXT_DOMAIN
+# undef gettext
+# define gettext(Msgid) \
+ dgettext (DEFAULT_TEXT_DOMAIN, Msgid)
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+ dngettext (DEFAULT_TEXT_DOMAIN, Msgid1, Msgid2, N)
+# endif
+
+#else
+
+/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which
+ chokes if dcgettext is defined as a macro. So include it now, to make
+ later inclusions of <locale.h> a NOP. We don't include <libintl.h>
+ as well because people using "gettext.h" will not include <libintl.h>,
+ and also including <libintl.h> would fail on SunOS 4, whereas <locale.h>
+ is OK. */
+#if defined(__sun)
+# include <locale.h>
+#endif
+
+/* Many header files from the libstdc++ coming with g++ 3.3 or newer include
+ <libintl.h>, which chokes if dcgettext is defined as a macro. So include
+ it now, to make later inclusions of <libintl.h> a NOP. */
+#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3)
+# include <cstdlib>
+# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H
+# include <libintl.h>
+# endif
+#endif
+
+/* Disabled NLS.
+ The casts to 'const char *' serve the purpose of producing warnings
+ for invalid uses of the value returned from these functions.
+ On pre-ANSI systems without 'const', the config.h file is supposed to
+ contain "#define const". */
+# undef gettext
+# define gettext(Msgid) ((const char *) (Msgid))
+# undef dgettext
+# define dgettext(Domainname, Msgid) ((void) (Domainname), gettext (Msgid))
+# undef dcgettext
+# define dcgettext(Domainname, Msgid, Category) \
+ ((void) (Category), dgettext (Domainname, Msgid))
+# undef ngettext
+# define ngettext(Msgid1, Msgid2, N) \
+ ((N) == 1 \
+ ? ((void) (Msgid2), (const char *) (Msgid1)) \
+ : ((void) (Msgid1), (const char *) (Msgid2)))
+# undef dngettext
+# define dngettext(Domainname, Msgid1, Msgid2, N) \
+ ((void) (Domainname), ngettext (Msgid1, Msgid2, N))
+# undef dcngettext
+# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
+ ((void) (Category), dngettext(Domainname, Msgid1, Msgid2, N))
+# undef textdomain
+# define textdomain(Domainname) ((const char *) (Domainname))
+# undef bindtextdomain
+# define bindtextdomain(Domainname, Dirname) \
+ ((void) (Domainname), (const char *) (Dirname))
+# undef bind_textdomain_codeset
+# define bind_textdomain_codeset(Domainname, Codeset) \
+ ((void) (Domainname), (const char *) (Codeset))
+
+#endif
+
+/* A pseudo function call that serves as a marker for the automated
+ extraction of messages, but does not call gettext(). The run-time
+ translation is done at a different place in the code.
+ The argument, String, should be a literal string. Concatenated strings
+ and other string expressions won't work.
+ The macro's expansion is not parenthesized, so that it is suitable as
+ initializer for static 'char[]' or 'const char[]' variables. */
+#define gettext_noop(String) String
+
+/* The separator between msgctxt and msgid in a .mo file. */
+#define GETTEXT_CONTEXT_GLUE "\004"
+
+/* Pseudo function calls, taking a MSGCTXT and a MSGID instead of just a
+ MSGID. MSGCTXT and MSGID must be string literals. MSGCTXT should be
+ short and rarely need to change.
+ The letter 'p' stands for 'particular' or 'special'. */
+#ifdef DEFAULT_TEXT_DOMAIN
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#else
+# define pgettext(Msgctxt, Msgid) \
+ pgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#endif
+#define dpgettext(Domainname, Msgctxt, Msgid) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, LC_MESSAGES)
+#define dcpgettext(Domainname, Msgctxt, Msgid, Category) \
+ pgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, Category)
+#ifdef DEFAULT_TEXT_DOMAIN
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (DEFAULT_TEXT_DOMAIN, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#else
+# define npgettext(Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (NULL, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#endif
+#define dnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dcnpgettext(Domainname, Msgctxt, Msgid, MsgidPlural, N, Category) \
+ npgettext_aux (Domainname, Msgctxt GETTEXT_CONTEXT_GLUE Msgid, Msgid, MsgidPlural, N, Category)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+pgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ int category)
+{
+ const char *translation = dcgettext (domain, msg_ctxt_id, category);
+ if (translation == msg_ctxt_id)
+ return msgid;
+ else
+ return translation;
+}
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+npgettext_aux (const char *domain,
+ const char *msg_ctxt_id, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ const char *translation =
+ dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+ if (translation == msg_ctxt_id || translation == msgid_plural)
+ return (n == 1 ? msgid : msgid_plural);
+ else
+ return translation;
+}
+
+/* The same thing extended for non-constant arguments. Here MSGCTXT and MSGID
+ can be arbitrary expressions. But for string literals these macros are
+ less efficient than those above. */
+
+#include <string.h>
+
+#define _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS \
+ (((__GNUC__ >= 3 || __GNUG__ >= 2) && !__STRICT_ANSI__) \
+ /* || __STDC_VERSION__ >= 199901L */ )
+
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+#include <stdlib.h>
+#endif
+
+#define pgettext_expr(Msgctxt, Msgid) \
+ dcpgettext_expr (NULL, Msgctxt, Msgid, LC_MESSAGES)
+#define dpgettext_expr(Domainname, Msgctxt, Msgid) \
+ dcpgettext_expr (Domainname, Msgctxt, Msgid, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcgettext (domain, msg_ctxt_id, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (translation != msg_ctxt_id)
+ return translation;
+ }
+ return msgid;
+}
+
+#define npgettext_expr(Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (NULL, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+#define dnpgettext_expr(Domainname, Msgctxt, Msgid, MsgidPlural, N) \
+ dcnpgettext_expr (Domainname, Msgctxt, Msgid, MsgidPlural, N, LC_MESSAGES)
+
+#ifdef __GNUC__
+__inline
+#else
+#ifdef __cplusplus
+inline
+#endif
+#endif
+static const char *
+dcnpgettext_expr (const char *domain,
+ const char *msgctxt, const char *msgid,
+ const char *msgid_plural, unsigned long int n,
+ int category)
+{
+ size_t msgctxt_len = strlen (msgctxt) + 1;
+ size_t msgid_len = strlen (msgid) + 1;
+ const char *translation;
+#if _LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ char msg_ctxt_id[msgctxt_len + msgid_len];
+#else
+ char buf[1024];
+ char *msg_ctxt_id =
+ (msgctxt_len + msgid_len <= sizeof (buf)
+ ? buf
+ : (char *) malloc (msgctxt_len + msgid_len));
+ if (msg_ctxt_id != NULL)
+#endif
+ {
+ memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
+ msg_ctxt_id[msgctxt_len - 1] = '\004';
+ memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
+ translation = dcngettext (domain, msg_ctxt_id, msgid_plural, n, category);
+#if !_LIBGETTEXT_HAVE_VARIABLE_SIZE_ARRAYS
+ if (msg_ctxt_id != buf)
+ free (msg_ctxt_id);
+#endif
+ if (!(translation == msg_ctxt_id || translation == msgid_plural))
+ return translation;
+ }
+ return (n == 1 ? msgid : msgid_plural);
+}
+
+#endif /* _LIBGETTEXT_H */
diff --git a/src/testgdbm.c b/src/testgdbm.c
index 276f649..fb6b846 100644
--- a/src/testgdbm.c
+++ b/src/testgdbm.c
@@ -32,6 +32,9 @@
# include <sys/termios.h>
#endif
#include <stdarg.h>
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
const char *progname; /* Program name */
@@ -75,10 +78,11 @@ print_bucket (FILE *fp, hash_bucket *bucket, char *mesg)
{
int index;
- fprintf (fp, "******* %s **********\n\nbits = %d\ncount= %d\nHash Table:\n",
+ fprintf (fp,
+ _("******* %s **********\n\nbits = %d\ncount= %d\nHash Table:\n"),
mesg, bucket->bucket_bits, bucket->count);
fprintf (fp,
- " # hash value key size data size data adr home\n");
+ _(" # hash value key size data size data adr home\n"));
for (index = 0; index < gdbm_file->header->bucket_elems; index++)
fprintf (fp, " %4d %12x %11d %11d %11lu %5d\n", index,
bucket->h_table[index].hash_value,
@@ -88,8 +92,8 @@ print_bucket (FILE *fp, hash_bucket *bucket, char *mesg)
bucket->h_table[index].hash_value %
gdbm_file->header->bucket_elems);
- fprintf (fp, "\nAvail count = %1d\n", bucket->av_count);
- fprintf (fp, "Avail adr size\n");
+ fprintf (fp, _("\nAvail count = %1d\n"), bucket->av_count);
+ fprintf (fp, _("Avail adr size\n"));
for (index = 0; index < bucket->av_count; index++)
fprintf (fp, "%9lu%9d\n",
(unsigned long) bucket->bucket_avail[index].av_adr,
@@ -113,7 +117,7 @@ _gdbm_avail_list_size (GDBM_FILE dbf, size_t min_size)
+ sizeof (avail_block));
av_stk = (avail_block *) malloc (size);
if (av_stk == NULL)
- error (2, "Out of memory");
+ error (2, _("Out of memory"));
/* Traverse the stack. */
while (temp)
@@ -148,7 +152,7 @@ _gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf)
avail_block *av_stk;
/* Print the the header avail block. */
- fprintf (fp, "\nheader block\nsize = %d\ncount = %d\n",
+ fprintf (fp, _("\nheader block\nsize = %d\ncount = %d\n"),
dbf->header->avail.size, dbf->header->avail.count);
for (temp = 0; temp < dbf->header->avail.count; temp++)
{
@@ -163,7 +167,7 @@ _gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf)
+ sizeof (avail_block));
av_stk = (avail_block *) malloc (size);
if (av_stk == NULL)
- error (2, "Out of memory");
+ error (2, _("Out of memory"));
/* Print the stack. */
while (temp)
@@ -181,8 +185,8 @@ _gdbm_print_avail_list (FILE *fp, GDBM_FILE dbf)
}
/* Print the block! */
- fprintf (fp, "\nblock = %d\nsize = %d\ncount = %d\n", temp,
- av_stk->size, av_stk->count);
+ fprintf (fp, _("\nblock = %d\nsize = %d\ncount = %d\n"), temp,
+ av_stk->size, av_stk->count);
for (temp = 0; temp < av_stk->count; temp++)
{
fprintf (fp, " %15d %10lu \n", av_stk->av_table[temp].av_size,
@@ -201,9 +205,8 @@ _gdbm_print_bucket_cache (FILE *fp, GDBM_FILE dbf)
if (dbf->bucket_cache != NULL)
{
- fprintf
- (fp,
- "Bucket Cache (size %d):\n Index: Address Changed Data_Hash \n",
+ fprintf (fp,
+ _("Bucket Cache (size %d):\n Index: Address Changed Data_Hash \n"),
dbf->cache_size);
for (index = 0; index < dbf->cache_size; index++)
{
@@ -211,33 +214,33 @@ _gdbm_print_bucket_cache (FILE *fp, GDBM_FILE dbf)
fprintf (fp, " %5d: %7lu %7s %x\n",
index,
(unsigned long) dbf->bucket_cache[index].ca_adr,
- (changed ? "True" : "False"),
+ (changed ? _("True") : _("False")),
dbf->bucket_cache[index].ca_data.hash_val);
}
}
else
- fprintf (fp, "Bucket cache has not been initialized.\n");
+ fprintf (fp, _("Bucket cache has not been initialized.\n"));
}
void
usage ()
{
- printf ("Usage: %s OPTIONS\n", progname);
- printf ("Test and modify a GDBM database.\n");
+ printf (_("Usage: %s OPTIONS\n"), progname);
+ printf (_("Test and modify a GDBM database.\n"));
printf ("\n");
- printf ("OPTIONS are:\n\n");
- printf (" -b SIZE set block size\n");
- printf (" -c SIZE set cache size\n");
- printf (" -g FILE operate on FILE instead of `junk.gdbm'\n");
- printf (" -h print this help summary\n");
- printf (" -l disable file locking\n");
- printf (" -m disable file mmap\n");
- printf (" -n create database\n");
- printf (" -r open database in read-only mode\n");
- printf (" -s synchronize to the disk after each write\n");
- printf (" -v print program version\n");
+ printf (_("OPTIONS are:\n\n"));
+ printf (_(" -b SIZE set block size\n"));
+ printf (_(" -c SIZE set cache size\n"));
+ printf (_(" -g FILE operate on FILE instead of `junk.gdbm'\n"));
+ printf (_(" -h print this help summary\n"));
+ printf (_(" -l disable file locking\n"));
+ printf (_(" -m disable file mmap\n"));
+ printf (_(" -n create database\n"));
+ printf (_(" -r open database in read-only mode\n"));
+ printf (_(" -s synchronize to the disk after each write\n"));
+ printf (_(" -v print program version\n"));
printf ("\n");
- printf ("Report bugs to <%s>.\n", PACKAGE_BUGREPORT);
+ printf (_("Report bugs to <%s>.\n"), PACKAGE_BUGREPORT);
}
void
@@ -276,7 +279,7 @@ read_from_file (const char *name, int replace)
fp = fopen (name, "r");
if (!fp)
{
- error (0, "cannot open file `%s' for reading: %s",
+ error (0, _("cannot open file `%s' for reading: %s"),
name, strerror (errno));
return;
}
@@ -287,7 +290,7 @@ read_from_file (const char *name, int replace)
if (!trimnl (buf))
{
- error (0, "%s:%d: line too long", name, line);
+ error (0, _("%s:%d: line too long"), name, line);
continue;
}
@@ -295,7 +298,7 @@ read_from_file (const char *name, int replace)
p = strchr (buf, ' ');
if (!p)
{
- error (0, "%s:%d: malformed line", name, line);
+ error (0, _("%s:%d: malformed line"), name, line);
continue;
}
@@ -306,7 +309,7 @@ read_from_file (const char *name, int replace)
data.dptr = p;
data.dsize = strlen (p) + data_z;
if (gdbm_store (gdbm_file, key, data, flag) != 0)
- error (0, "%d: item not inserted: %s",
+ error (0, _("%d: item not inserted: %s"),
line, gdbm_strerror (gdbm_errno));
}
fclose (fp);
@@ -364,7 +367,10 @@ void
count_handler (char *arg[NARGS] ARG_UNUSED, FILE *fp,
void *call_data ARG_UNUSED)
{
- fprintf (fp, "There are %d items in the database.\n", get_record_count ());
+ int count = get_record_count ();
+ fprintf (fp, ngettext ("There is %d item in the database.\n",
+ "There are %d items in the database.\n", count),
+ count);
}
/* d key - delete */
@@ -378,9 +384,9 @@ delete_handler (char *arg[NARGS], FILE *fp, void *call_data ARG_UNUSED)
if (gdbm_delete (gdbm_file, key_data) != 0)
{
if (gdbm_errno == GDBM_ITEM_NOT_FOUND)
- error (0, "Item not found");
+ error (0, _("Item not found"));
else
- error (0, "Can't delete: %s", gdbm_strerror (gdbm_errno));
+ error (0, _("Can't delete: %s"), gdbm_strerror (gdbm_errno));
}
}
@@ -399,7 +405,7 @@ fetch_handler (char *arg[NARGS], FILE *fp, void *call_data ARG_UNUSED)
free (return_data.dptr);
}
else
- fprintf (stderr, "No such item found.\n");
+ fprintf (stderr, _("No such item found.\n"));
}
/* n [key] - next key */
@@ -424,7 +430,7 @@ nextkey_handler (char *arg[NARGS], FILE *fp, void *call_data ARG_UNUSED)
}
else
{
- fprintf (stderr, "No such item found.\n");
+ fprintf (stderr, _("No such item found.\n"));
free (key_data.dptr);
key_data.dptr = NULL;
}
@@ -442,7 +448,7 @@ store_handler (char *arg[NARGS], FILE *fp, void *call_data ARG_UNUSED)
data.dptr = arg[1];
data.dsize = strlen (arg[1]) + data_z;
if (gdbm_store (gdbm_file, key, data, GDBM_REPLACE) != 0)
- fprintf (stderr, "Item not inserted.\n");
+ fprintf (stderr, _("Item not inserted.\n"));
}
/* 1 - begin iteration */
@@ -461,7 +467,7 @@ firstkey_handler (char *arg[NARGS], FILE *fp, void *call_data ARG_UNUSED)
free (return_data.dptr);
}
else
- fprintf (fp, "No such item found.\n");
+ fprintf (fp, _("No such item found.\n"));
}
/* 2 - continue iteration */
@@ -480,7 +486,7 @@ next_on_last_handler (char *arg[NARGS] ARG_UNUSED, FILE *fp,
free (return_data.dptr);
}
else
- fprintf (stderr, "No such item found.\n");
+ fprintf (stderr, _("No such item found.\n"));
}
/* r - reorganize */
@@ -489,9 +495,9 @@ reorganize_handler (char *arg[NARGS] ARG_UNUSED, FILE *fp ARG_UNUSED,
void *call_data ARG_UNUSED)
{
if (gdbm_reorganize (gdbm_file))
- fprintf (stderr, "Reorganization failed.\n");
+ fprintf (stderr, _("Reorganization failed.\n"));
else
- fprintf (stderr, "Reorganization succeeded.\n");
+ fprintf (stderr, _("Reorganization succeeded.\n"));
}
/* A - print available list */
@@ -523,10 +529,10 @@ void
print_current_bucket_handler (char *arg[NARGS] ARG_UNUSED, FILE *fp,
void *call_data ARG_UNUSED)
{
- print_bucket (fp, gdbm_file->bucket, "Current bucket");
- fprintf (fp, "\n current directory entry = %d.\n",
+ print_bucket (fp, gdbm_file->bucket, _("Current bucket"));
+ fprintf (fp, _("\n current directory entry = %d.\n"),
gdbm_file->bucket_dir);
- fprintf (fp, " current bucket address = %lu.\n",
+ fprintf (fp, _(" current bucket address = %lu.\n"),
(unsigned long) gdbm_file->cache_entry->ca_adr);
}
@@ -537,7 +543,7 @@ getnum (int *pnum, char *arg, char **endp)
unsigned long x = strtoul (arg, &p, 10);
if (*p && !isspace (*p))
{
- printf ("not a number (stopped near %s)\n", p);
+ printf (_("not a number (stopped near %s)\n"), p);
return 1;
}
while (*p && isspace (*p))
@@ -546,7 +552,7 @@ getnum (int *pnum, char *arg, char **endp)
*endp = p;
else if (*p)
{
- printf ("not a number (stopped near %s)\n", p);
+ printf (_("not a number (stopped near %s)\n"), p);
return 1;
}
*pnum = x;
@@ -565,7 +571,7 @@ print_bucket_begin (char *arg[NARGS], size_t *exp_count, void **data ARG_UNUSED)
if (temp >= gdbm_file->header->dir_size / 4)
{
- fprintf (stderr, "Not a bucket.\n");
+ fprintf (stderr, _("Not a bucket.\n"));
return 1;
}
_gdbm_get_bucket (gdbm_file, temp);
@@ -590,8 +596,8 @@ print_dir_handler (char *arg[NARGS] ARG_UNUSED, FILE *out,
{
int i;
- fprintf (out, "Hash table directory.\n");
- fprintf (out, " Size = %d. Bits = %d. \n\n",
+ fprintf (out, _("Hash table directory.\n"));
+ fprintf (out, _(" Size = %d. Bits = %d. \n\n"),
gdbm_file->header->dir_size, gdbm_file->header->dir_bits);
for (i = 0; i < gdbm_file->header->dir_size / 4; i++)
@@ -610,20 +616,20 @@ print_header_begin (char *arg[NARGS], size_t *exp_count, void **data ARG_UNUSED)
void
print_header_handler (char *arg[NARGS] ARG_UNUSED, FILE *fp, void *call_data)
{
- fprintf (fp, "\nFile Header: \n\n");
- fprintf (fp, " table = %lu\n",
+ fprintf (fp, _("\nFile Header: \n\n"));
+ fprintf (fp, _(" table = %lu\n"),
(unsigned long) gdbm_file->header->dir);
- fprintf (fp, " table size = %d\n", gdbm_file->header->dir_size);
- fprintf (fp, " table bits = %d\n", gdbm_file->header->dir_bits);
- fprintf (fp, " block size = %d\n", gdbm_file->header->block_size);
- fprintf (fp, " bucket elems = %d\n", gdbm_file->header->bucket_elems);
- fprintf (fp, " bucket size = %d\n", gdbm_file->header->bucket_size);
- fprintf (fp, " header magic = %x\n", gdbm_file->header->header_magic);
- fprintf (fp, " next block = %lu\n",
+ fprintf (fp, _(" table size = %d\n"), gdbm_file->header->dir_size);
+ fprintf (fp, _(" table bits = %d\n"), gdbm_file->header->dir_bits);
+ fprintf (fp, _(" block size = %d\n"), gdbm_file->header->block_size);
+ fprintf (fp, _(" bucket elems = %d\n"), gdbm_file->header->bucket_elems);
+ fprintf (fp, _(" bucket size = %d\n"), gdbm_file->header->bucket_size);
+ fprintf (fp, _(" header magic = %x\n"), gdbm_file->header->header_magic);
+ fprintf (fp, _(" next block = %lu\n"),
(unsigned long) gdbm_file->header->next_block);
- fprintf (fp, " avail size = %d\n", gdbm_file->header->avail.size);
- fprintf (fp, " avail count = %d\n", gdbm_file->header->avail.count);
- fprintf (fp, " avail nx blk = %lu\n",
+ fprintf (fp, _(" avail size = %d\n"), gdbm_file->header->avail.size);
+ fprintf (fp, _(" avail count = %d\n"), gdbm_file->header->avail.count);
+ fprintf (fp, _(" avail nx blk = %lu\n"),
(unsigned long) gdbm_file->header->avail.next_block);
}
@@ -635,7 +641,7 @@ hash_handler (char *arg[NARGS], FILE *fp, void *call_data)
key.dptr = arg[0];
key.dsize = strlen (arg[0]) + key_z;
- fprintf (fp, "hash value = %x. \n", _gdbm_hash (key));
+ fprintf (fp, _("hash value = %x. \n"), _gdbm_hash (key));
}
/* K - print the bucket cache */
@@ -691,7 +697,7 @@ list_handler (char *arg[NARGS] ARG_UNUSED, FILE *fp, void *call_data)
data = gdbm_fetch (gdbm_file, key);
if (!data.dptr)
- error (0, "cannot fetch data (key %.*s)", key.dsize, key.dptr);
+ error (0, _("cannot fetch data (key %.*s)"), key.dsize, key.dptr);
else
{
fprintf (fp, "%.*s %.*s\n", key.dsize, key.dptr, data.dsize,
@@ -724,7 +730,7 @@ export_handler (char *arg[NARGS], FILE *fp, void *call_data ARG_UNUSED)
flags = GDBM_NEWDB;
if (gdbm_export (gdbm_file, arg[0], flags, 0600) == -1)
- error (0, "gdbm_export failed, %s", gdbm_strerror (gdbm_errno));
+ error (0, _("gdbm_export failed, %s"), gdbm_strerror (gdbm_errno));
}
/* i file [replace] - import from a flat file */
@@ -737,17 +743,23 @@ import_handler (char *arg[NARGS], FILE *fp, void *call_data ARG_UNUSED)
flag = GDBM_REPLACE;
if (gdbm_import (gdbm_file, arg[0], flag) == -1)
- error (0, "gdbm_import failed, %s", gdbm_strerror (gdbm_errno));
+ error (0, _("gdbm_import failed, %s"), gdbm_strerror (gdbm_errno));
}
+static const char *
+boolstr(int val)
+{
+ return val ? _("yes") : _("no");
+}
+
/* S - print current program status */
void
status_handler (char *arg[NARGS] ARG_UNUSED, FILE *fp,
void *call_data ARG_UNUSED)
{
- fprintf (fp, "Database file: %s\n", file_name);
- fprintf (fp, "Zero terminated keys: %s\n", key_z ? "yes" : "no");
- fprintf (fp, "Zero terminated data: %s\n", data_z ? "yes" : "no");
+ fprintf (fp, _("Database file: %s\n"), file_name);
+ fprintf (fp, _("Zero terminated keys: %s\n"), boolstr (key_z));
+ fprintf (fp, _("Zero terminated data: %s\n"), boolstr (data_z));
}
/* z - toggle key nul-termination */
@@ -756,7 +768,7 @@ key_z_handler (char *arg[NARGS] ARG_UNUSED, FILE *fp,
void *call_data ARG_UNUSED)
{
key_z = !key_z;
- fprintf (fp, "Zero terminated keys: %s\n", key_z ? "yes" : "no");
+ fprintf (fp, _("Zero terminated keys: %s\n"), boolstr (key_z));
}
/* Z - toggle data nul-termination */
@@ -765,7 +777,7 @@ data_z_handler (char *arg[NARGS] ARG_UNUSED, FILE *fp,
void *call_data ARG_UNUSED)
{
data_z = !data_z;
- fprintf (fp, "Zero terminated data: %s\n", data_z ? "yes" : "no");
+ fprintf (fp, "Zero terminated data: %s\n", boolstr (data_z));
}
@@ -785,60 +797,58 @@ struct command
struct command command_tab[] = {
{ 'c', NULL, count_handler, NULL,
- { NULL, NULL, }, "count (number of entries)" },
+ { NULL, NULL, }, N_("count (number of entries)") },
{ 'd', NULL, delete_handler, NULL,
- { "key", NULL, }, "delete" },
+ { N_("key"), NULL, }, N_("delete") },
{ 'e', NULL, export_handler, NULL,
- { "file", "[truncate]", }, "export" },
+ { N_("file"), "[truncate]", }, N_("export") },
{ 'f', NULL, fetch_handler, NULL,
- { "key", NULL }, "fetch" },
+ { N_("key"), NULL }, N_("fetch") },
{ 'i', NULL, import_handler, NULL,
- { "file", "[replace]", }, "import" },
+ { N_("file"), "[replace]", }, N_("import") },
{ 'l', list_begin, list_handler, NULL,
- { NULL, NULL }, "list" },
+ { NULL, NULL }, N_("list") },
{ 'n', NULL, nextkey_handler, NULL,
- { "[key]", NULL }, "nextkey" },
- { 'q', NULL, quit_handler, NULL,
- { NULL, NULL }, "quit" },
+ { N_("[key]"), NULL }, N_("nextkey") },
{ 's', NULL, store_handler, NULL,
- { "key", "data" }, "store" },
+ { N_("key"), N_("data") }, N_("store") },
{ '1', NULL, firstkey_handler, NULL,
- { NULL, NULL }, "firstkey" },
+ { NULL, NULL }, N_("firstkey") },
{ '2', NULL, next_on_last_handler, NULL,
{ NULL, NULL, },
- "nextkey on last key (from n, 1 or 2)" },
+ N_("nextkey on last key (from n, 1 or 2)") },
{ '<', NULL, read_handler, NULL,
- { "file", "[replace]" },
- "read entries from file and store" },
+ { N_("file"), "[replace]" },
+ N_("read entries from file and store") },
{ 'r', NULL, reorganize_handler, NULL,
- { NULL, NULL, }, "reorganize" },
+ { NULL, NULL, }, N_("reorganize") },
{ 'z', NULL, key_z_handler, NULL,
- { NULL, NULL }, "toggle key nul-termination" },
+ { NULL, NULL }, N_("toggle key nul-termination") },
{ 'A', avail_begin, avail_handler, NULL,
- { NULL, NULL, }, "print avail list" },
+ { NULL, NULL, }, N_("print avail list") },
{ 'B', print_bucket_begin, print_current_bucket_handler, NULL,
- { "bucket-number", NULL, }, "print a bucket" },
+ { N_("bucket-number"), NULL, }, N_("print a bucket") },
{ 'C', print_current_bucket_begin, print_current_bucket_handler, NULL,
{ NULL, NULL, },
- "print current bucket" },
+ N_("print current bucket") },
{ 'D', print_dir_begin, print_dir_handler, NULL,
- { NULL, NULL, }, "print hash directory" },
+ { NULL, NULL, }, N_("print hash directory") },
{ 'F', print_header_begin , print_header_handler, NULL,
- { NULL, NULL, }, "print file header" },
+ { NULL, NULL, }, N_("print file header") },
{ 'H', NULL, hash_handler, NULL,
- { "key", NULL, }, "hash value of key" },
+ { N_("key"), NULL, }, N_("hash value of key") },
{ 'K', print_cache_begin, print_cache_handler, NULL,
- { NULL, NULL, }, "print the bucket cache" },
+ { NULL, NULL, }, N_("print the bucket cache") },
{ 'S', NULL, status_handler, NULL,
- { NULL, NULL }, "print current program status" },
+ { NULL, NULL }, N_("print current program status") },
{ 'V', NULL, print_version_handler, NULL,
- { NULL, NULL, }, "print version of gdbm" },
+ { NULL, NULL, }, N_("print version of gdbm") },
{ 'Z', NULL, data_z_handler, NULL,
- { NULL, NULL }, "toggle data nul-termination" },
+ { NULL, NULL }, N_("toggle data nul-termination") },
{ '?', help_begin, help_handler, NULL,
- { NULL, NULL, }, "print this help list" },
+ { NULL, NULL, }, N_("print this help list") },
{ 'q', NULL, quit_handler, NULL,
- { NULL, NULL, }, "quit the program" },
+ { NULL, NULL, }, N_("quit the program") },
{ 0 }
};
@@ -865,11 +875,11 @@ help_handler (char *arg[NARGS], FILE *fp, void *call_data)
int n = fprintf (fp, " %c", cmd->abbrev);
for (i = 0; i < NARGS && cmd->args[i]; i++)
- n += fprintf (fp, " %s", cmd->args[i]);
+ n += fprintf (fp, " %s", gettext (cmd->args[i]));
if (n < CMDCOLS)
fprintf (fp, "%*.s", CMDCOLS-n, "");
- fprintf (fp, " %s", cmd->doc);
+ fprintf (fp, " %s", gettext (cmd->doc));
fputc ('\n', fp);
}
}
@@ -880,7 +890,7 @@ find_command (char *p)
struct command *cmd;
if (p[1])
{
- printf ("Multicharacter commands are not yet implemented.\n");
+ printf (_("Multicharacter commands are not yet implemented.\n"));
return NULL;
}
for (cmd = command_tab; cmd->abbrev; cmd++)
@@ -931,6 +941,11 @@ main (int argc, char *argv[])
progname++;
else
progname = argv[0];
+
+#ifdef HAVE_SETLOCALE
+ setlocale (LC_ALL, "");
+#endif
+ bindtextdomain (PACKAGE, LOCALEDIR);
/* Argument checking. */
if (argc == 2)
@@ -965,21 +980,21 @@ main (int argc, char *argv[])
case 's':
if (reader)
- error (2, "-s is incompatible with -r");
+ error (2, _("-s is incompatible with -r"));
flags = flags | GDBM_SYNC;
break;
case 'r':
if (newdb)
- error (2, "-r is incompatible with -n");
+ error (2, _("-r is incompatible with -n"));
reader = TRUE;
break;
case 'n':
if (reader)
- error (2, "-n is incompatible with -r");
+ error (2, _("-n is incompatible with -r"));
newdb = TRUE;
break;
@@ -1001,7 +1016,7 @@ main (int argc, char *argv[])
exit (0);
default:
- error (2, "unknown option; try `%s -h' for more info\n", progname);
+ error (2, _("unknown option; try `%s -h' for more info\n"), progname);
}
if (file_name == NULL)
@@ -1025,17 +1040,17 @@ main (int argc, char *argv[])
gdbm_open (file_name, block_size, GDBM_WRCREAT | flags, 00664, NULL);
}
if (gdbm_file == NULL)
- error (2, "gdbm_open failed: %s", gdbm_strerror (gdbm_errno));
+ error (2, _("gdbm_open failed: %s"), gdbm_strerror (gdbm_errno));
if (gdbm_setopt (gdbm_file, GDBM_CACHESIZE, &cache_size, sizeof (int)) ==
-1)
- error (2, "gdbm_setopt failed: %s", gdbm_strerror (gdbm_errno));
+ error (2, _("gdbm_setopt failed: %s"), gdbm_strerror (gdbm_errno));
signal (SIGPIPE, SIG_IGN);
/* Welcome message. */
if (interactive)
- printf ("\nWelcome to the gdbm test program. Type ? for help.\n\n");
+ printf (_("\nWelcome to the gdbm test program. Type ? for help.\n\n"));
while (1)
{
@@ -1068,8 +1083,8 @@ main (int argc, char *argv[])
if (!cmd)
{
error (0,
- interactive ? "Invalid command. Try ? for help." :
- "Unknown command");
+ interactive ? _("Invalid command. Try ? for help.") :
+ _("Unknown command"));
continue;
}
@@ -1084,12 +1099,12 @@ main (int argc, char *argv[])
/* Optional argument */
break;
if (!interactive)
- error (1, "%c: not enough arguments", cmd->abbrev);
+ error (1, _("%c: not enough arguments"), cmd->abbrev);
printf ("%s? ", arg);
if (fgets (argbuf[i], sizeof argbuf[i], stdin) == NULL)
- error (1, "unexpected eof");
+ error (1, _("unexpected eof"));
trimnl (argbuf[i]);
args[i] = argbuf[i];
@@ -1110,7 +1125,7 @@ main (int argc, char *argv[])
out = popen (pager, "w");
if (!out)
{
- error (0, "cannot run pager `%s': %s", pager,
+ error (0, _("cannot run pager `%s': %s"), pager,
strerror (errno));
pager = NULL;
}
diff --git a/src/update.c b/src/update.c
index b814415..9ae3732 100644
--- a/src/update.c
+++ b/src/update.c
@@ -33,10 +33,10 @@ write_header (GDBM_FILE dbf)
off_t file_pos; /* Return value for lseek. */
file_pos = __lseek (dbf, 0L, L_SET);
- if (file_pos != 0) _gdbm_fatal (dbf, "lseek error");
+ if (file_pos != 0) _gdbm_fatal (dbf, _("lseek error"));
num_bytes = __write (dbf, dbf->header, dbf->header->block_size);
if (num_bytes != dbf->header->block_size)
- _gdbm_fatal (dbf, "write error");
+ _gdbm_fatal (dbf, _("write error"));
/* Sync the file if fast_write is FALSE. */
if (dbf->fast_write == FALSE)
@@ -80,10 +80,10 @@ _gdbm_end_update (GDBM_FILE dbf)
if (dbf->directory_changed)
{
file_pos = __lseek (dbf, dbf->header->dir, L_SET);
- if (file_pos != dbf->header->dir) _gdbm_fatal (dbf, "lseek error");
+ if (file_pos != dbf->header->dir) _gdbm_fatal (dbf, _("lseek error"));
num_bytes = __write (dbf, dbf->dir, dbf->header->dir_size);
if (num_bytes != dbf->header->dir_size)
- _gdbm_fatal (dbf, "write error");
+ _gdbm_fatal (dbf, _("write error"));
dbf->directory_changed = FALSE;
if (!dbf->header_changed && dbf->fast_write == FALSE)
__fsync (dbf);
@@ -108,10 +108,7 @@ _gdbm_fatal (GDBM_FILE dbf, const char *val)
(*dbf->fatal_err) (val);
else
{
- write (STDERR_FILENO, "gdbm fatal: ", 12);
- if (val != NULL)
- write (STDERR_FILENO, val, strlen(val));
- write (STDERR_FILENO, "\n", 1);
+ fprintf (stderr, _("gdbm fatal: %s\n"), val ? val : "");
}
exit (1);
/* NOTREACHED */

Return to:

Send suggestions and report system problems to the System administrator.