added i18n support

CVS patchset: 2477
CVS date: 1998/10/22 18:32:50
This commit is contained in:
ewt 1998-10-22 18:32:50 +00:00
parent c272e2a2fc
commit 1bf1381215
6 changed files with 50 additions and 364 deletions

View File

@ -1,345 +0,0 @@
# Makefile.in generated automatically by automake 1.3 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# Makefile for popt library.
SHELL = /bin/sh
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@
sbindir = @sbindir@
libexecdir = @libexecdir@
datadir = @datadir@
sysconfdir = @sysconfdir@
sharedstatedir = @sharedstatedir@
localstatedir = @localstatedir@
libdir = @libdir@
infodir = @infodir@
mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DISTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
ACLOCAL = @ACLOCAL@
AUTOCONF = @AUTOCONF@
AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
CC = @CC@
CPP = @CPP@
MAKEINFO = @MAKEINFO@
PACKAGE = @PACKAGE@
RANLIB = @RANLIB@
TARGET = @TARGET@
U = @U@
VERSION = @VERSION@
AUTOMAKE_OPTIONS = 1.3 foreign
INCLUDES = -I$(top_srcdir)
noinst_HEADERS = popt.h
noinst_LIBRARIES = libpopt.a
libpopt_a_SOURCES = popt.c findme.c poptparse.c poptconfig.c popthelp.c
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
LIBRARIES = $(noinst_LIBRARIES)
DEFS = @DEFS@ -I. -I$(srcdir) -I.
CPPFLAGS = @CPPFLAGS@
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
libpopt_a_LIBADD =
libpopt_a_OBJECTS = popt.o findme.o poptparse.o poptconfig.o popthelp.o
AR = ar
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(noinst_HEADERS)
DIST_COMMON = README COPYING Makefile.am Makefile.in acconfig.h \
aclocal.m4 config.h.in configure.in install-sh missing mkinstalldirs \
stamp-h.in
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP = --best
DEP_FILES = .deps/findme.P .deps/popt.P .deps/poptconfig.P \
.deps/popthelp.P .deps/poptparse.P
SOURCES = $(libpopt_a_SOURCES)
OBJECTS = $(libpopt_a_OBJECTS)
all: Makefile $(LIBRARIES) $(HEADERS) config.h
.SUFFIXES:
.SUFFIXES: .S .c .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
cd $(top_builddir) \
&& CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status
$(ACLOCAL_M4): configure.in
cd $(srcdir) && $(ACLOCAL)
config.status: $(srcdir)/configure
$(SHELL) ./config.status --recheck
$(srcdir)/configure: $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
cd $(srcdir) && $(AUTOCONF)
config.h: stamp-h
@:
stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status
cd $(top_builddir) \
&& CONFIG_FILES= CONFIG_HEADERS=config.h \
$(SHELL) ./config.status
@echo timestamp > stamp-h
$(srcdir)/config.h.in: $(srcdir)/stamp-h.in
$(srcdir)/stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) acconfig.h
cd $(top_srcdir) && $(AUTOHEADER)
@echo timestamp > $(srcdir)/stamp-h.in
mostlyclean-hdr:
clean-hdr:
distclean-hdr:
-rm -f config.h
maintainer-clean-hdr:
mostlyclean-noinstLIBRARIES:
clean-noinstLIBRARIES:
-test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
distclean-noinstLIBRARIES:
maintainer-clean-noinstLIBRARIES:
.s.o:
$(COMPILE) -c $<
.S.o:
$(COMPILE) -c $<
mostlyclean-compile:
-rm -f *.o core *.core
clean-compile:
distclean-compile:
-rm -f *.tab.c
maintainer-clean-compile:
libpopt.a: $(libpopt_a_OBJECTS) $(libpopt_a_DEPENDENCIES)
-rm -f libpopt.a
$(AR) cru libpopt.a $(libpopt_a_OBJECTS) $(libpopt_a_LIBADD)
$(RANLIB) libpopt.a
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP)
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \
|| (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) -o $$here/TAGS)
mostlyclean-tags:
clean-tags:
distclean-tags:
-rm -f TAGS ID
maintainer-clean-tags:
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
-rm -rf $(distdir)
GZIP=$(GZIP) $(TAR) zxf $(distdir).tar.gz
mkdir $(distdir)/=build
mkdir $(distdir)/=inst
dc_install_base=`cd $(distdir)/=inst && pwd`; \
cd $(distdir)/=build \
&& ../configure --srcdir=.. --prefix=$$dc_install_base \
&& $(MAKE) \
&& $(MAKE) dvi \
&& $(MAKE) check \
&& $(MAKE) install \
&& $(MAKE) installcheck \
&& $(MAKE) dist
-rm -rf $(distdir)
@echo "========================"; \
echo "$(distdir).tar.gz is ready for distribution"; \
echo "========================"
dist: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
dist-all: distdir
-chmod -R a+r $(distdir)
GZIP=$(GZIP) $(TAR) chozf $(distdir).tar.gz $(distdir)
-rm -rf $(distdir)
distdir: $(DISTFILES)
-rm -rf $(distdir)
mkdir $(distdir)
-chmod 777 $(distdir)
here=`cd $(top_builddir) && pwd`; \
top_distdir=`cd $(distdir) && pwd`; \
distdir=`cd $(distdir) && pwd`; \
cd $(top_srcdir) \
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign Makefile
@for file in $(DISTFILES); do \
d=$(srcdir); \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file; \
done
DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :)
-include $(DEP_FILES)
mostlyclean-depend:
clean-depend:
distclean-depend:
maintainer-clean-depend:
-rm -rf .deps
%.o: %.c
@echo '$(COMPILE) -c $<'; \
$(COMPILE) -Wp,-MD,.deps/$(*F).P -c $<
%.lo: %.c
@echo '$(LTCOMPILE) -c $<'; \
$(LTCOMPILE) -Wp,-MD,.deps/$(*F).p -c $<
@-sed -e 's/^\([^:]*\)\.o:/\1.lo \1.o:/' \
< .deps/$(*F).p > .deps/$(*F).P
@-rm -f .deps/$(*F).p
info:
dvi:
check: all
$(MAKE)
installcheck:
install-exec:
@$(NORMAL_INSTALL)
install-data:
@$(NORMAL_INSTALL)
install: install-exec install-data all
@:
uninstall:
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
installdirs:
mostlyclean-generic:
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f Makefile $(DISTCLEANFILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-hdr mostlyclean-noinstLIBRARIES \
mostlyclean-compile mostlyclean-tags mostlyclean-depend \
mostlyclean-generic
clean: clean-hdr clean-noinstLIBRARIES clean-compile clean-tags \
clean-depend clean-generic mostlyclean
distclean: distclean-hdr distclean-noinstLIBRARIES distclean-compile \
distclean-tags distclean-depend distclean-generic clean
-rm -f config.status
maintainer-clean: maintainer-clean-hdr maintainer-clean-noinstLIBRARIES \
maintainer-clean-compile maintainer-clean-tags \
maintainer-clean-depend maintainer-clean-generic \
distclean
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
-rm -f config.status
.PHONY: mostlyclean-hdr distclean-hdr clean-hdr maintainer-clean-hdr \
mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
maintainer-clean-compile tags mostlyclean-tags distclean-tags \
clean-tags maintainer-clean-tags distdir mostlyclean-depend \
distclean-depend clean-depend maintainer-clean-depend info dvi \
installcheck install-exec install-data install uninstall all \
installdirs mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

View File

@ -12,12 +12,21 @@
/* Define to 1 if ANSI function prototypes are usable. */
#undef PROTOTYPES
/* Define if you have the dgettext function. */
#undef HAVE_DGETTEXT
/* Define if you have the gettext function. */
#undef HAVE_GETTEXT
/* Define if you have the strerror function. */
#undef HAVE_STRERROR
/* Define if you have the <alloca.h> header file. */
#undef HAVE_ALLOCA_H
/* Define if you have the <libintl.h> header file. */
#undef HAVE_LIBINTL_H
/* Define if you have the <string.h> header file. */
#undef HAVE_STRING_H

View File

@ -38,7 +38,7 @@ else
fi
AC_SUBST(TARGET)
AC_CHECK_HEADERS(unistd.h alloca.h)
AC_CHECK_HEADERS(unistd.h alloca.h libintl.h)
AC_MSG_CHECKING(for /usr/ucblib in LIBS)
if test -d /usr/ucblib ; then
if test "$build" = "mips-sni-sysv4" ; then
@ -53,6 +53,8 @@ else
fi
AC_CHECK_FUNCS(strerror)
AC_CHECK_FUNCS(gettext)
AC_CHECK_FUNCS(dgettext)
AC_CHECK_FUNC(setreuid, [], [
AC_CHECK_LIB(ucb, setreuid, [if echo $LIBS | grep -- -lucb >/dev/null ;then :; else LIBS="$LIBS -lc -lucb" USEUCB=y;fi])
])

View File

@ -31,7 +31,7 @@ static char * strerror(int errno) {
if ((0 <= errno) && (errno < sys_nerr))
return sys_errlist[errno];
else
return "unknown errno";
return POPT_("unknown errno");
}
#endif
@ -404,8 +404,7 @@ int poptGetNextOpt(poptContext con) {
break;
default:
/* XXX I18N? */
fprintf(stdout, "option type (%d) not implemented in popt\n",
fprintf(stdout, POPT_("option type (%d) not implemented in popt\n"),
opt->argInfo & POPT_ARG_MASK);
exit(1);
}
@ -529,21 +528,21 @@ char * poptBadOption(poptContext con, int flags) {
const char * poptStrerror(const int error) {
switch (error) {
case POPT_ERROR_NOARG:
return "missing argument";
return POPT_("missing argument");
case POPT_ERROR_BADOPT:
return "unknown option";
return POPT_("unknown option");
case POPT_ERROR_OPTSTOODEEP:
return "aliases nested too deeply";
return POPT_("aliases nested too deeply");
case POPT_ERROR_BADQUOTE:
return "error in paramter quoting";
return POPT_("error in paramter quoting");
case POPT_ERROR_BADNUMBER:
return "invalid numeric value";
return POPT_("invalid numeric value");
case POPT_ERROR_OVERFLOW:
return "number too large or too small";
return POPT_("number too large or too small");
case POPT_ERROR_ERRNO:
return strerror(errno);
default:
return "unknown error";
return POPT_("unknown error");
}
}

View File

@ -26,23 +26,26 @@ static void displayArgs(poptContext con, enum poptCallbackReason foo,
struct poptOption poptHelpOptions[] = {
{ NULL, '\0', POPT_ARG_CALLBACK, &displayArgs, '\0', NULL },
{ "help", '?', 0, NULL, '?', "Show this help message" },
{ "usage", '\0', 0, NULL, 'u', "Display brief usage message" },
{ "help", '?', 0, NULL, '?', N_("Show this help message") },
{ "usage", '\0', 0, NULL, 'u', N_("Display brief usage message") },
{ NULL, '\0', 0, NULL, 0 }
} ;
static const char * getArgDescrip(const struct poptOption * opt) {
if (!(opt->argInfo & POPT_ARG_MASK)) return NULL;
if (opt->argDescrip) return opt->argDescrip;
return "ARG";
if (opt == (poptHelpOptions + 1) || opt == (poptHelpOptions + 2))
if (opt->argDescrip) return POPT_(opt->argDescrip);
if (opt->argDescrip) return _(opt->argDescrip);
return POPT_("ARG");
}
static void singleOptionHelp(FILE * f, int maxLeftCol,
const struct poptOption * opt) {
int indentLength = maxLeftCol + 5;
int lineLength = 79 - indentLength;
const char * help = opt->descrip;
const char * help = _(opt->descrip);
int helpLength;
const char * ch;
char format[10];
@ -131,7 +134,7 @@ static void singleTableHelp(FILE * f, const struct poptOption * table,
while (opt->longName || opt->shortName || opt->arg) {
if ((opt->argInfo & POPT_ARG_MASK) == POPT_ARG_INCLUDE_TABLE) {
if (opt->descrip)
fprintf(f, "\n%s\n", opt->descrip);
fprintf(f, "\n%s\n", _(opt->descrip));
singleTableHelp(f, opt->arg, left);
}
opt++;
@ -142,7 +145,7 @@ static int showHelpIntro(poptContext con, FILE * f) {
int len = 6;
char * fn;
fprintf(f, "Usage:");
fprintf(f, POPT_("Usage:"));
if (!(con->flags & POPT_CONTEXT_KEEP_FIRST)) {
fn = con->optionStack->argv[0];
if (strchr(fn, '/')) fn = strchr(fn, '/') + 1;
@ -160,7 +163,7 @@ void poptPrintHelp(poptContext con, FILE * f, int flags) {
if (con->otherHelp)
fprintf(f, " %s\n", con->otherHelp);
else
fprintf(f, " [OPTION...]\n");
fprintf(f, " %s\n", POPT_("[OPTION...]"));
leftColWidth = maxArgWidth(con->options);
singleTableHelp(f, con->options, leftColWidth);

View File

@ -43,4 +43,22 @@ struct poptContext_s {
char * otherHelp;
};
#ifdef HAVE_LIBINTL_H
#include <libintl.h>
#endif
#ifdef HAVE_GETTEXT
#define _(foo) gettext(foo)
#else
#define _(foo) (foo)
#endif
#ifdef HAVE_DGETTEXT
#define POPT_(foo) dgettext("popt", foo)
#else
#define POPT_(foo) (foo)
#endif
#define N_(foo) (foo)
#endif