summaryrefslogtreecommitdiffabout
path: root/src
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 /src
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 (limited to 'src') (more/less context) (ignore whitespace changes)
-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
12 files changed, 473 insertions, 173 deletions
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.