1
0
mirror of https://git.tukaani.org/xz.git synced 2025-02-21 07:58:27 +00:00

lzmainfo: Use tuklib_mbstr_wrap for --help text

Some languages have so long strings that they need to be wrapped.
This commit is contained in:
Lasse Collin 2025-01-29 20:50:03 +02:00
parent c56eb47076
commit 7d73ff7a9d
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
3 changed files with 32 additions and 10 deletions

View File

@ -2016,8 +2016,12 @@ if(XZ_TOOL_LZMAINFO AND HAVE_DECODERS)
src/common/sysdefs.h
src/common/tuklib_common.h
src/common/tuklib_config.h
src/common/tuklib_mbstr.h
src/common/tuklib_mbstr_nonprint.c
src/common/tuklib_mbstr_nonprint.h
src/common/tuklib_mbstr_width.c
src/common/tuklib_mbstr_wrap.c
src/common/tuklib_mbstr_wrap.h
src/common/tuklib_exit.c
src/common/tuklib_exit.h
src/common/tuklib_gettext.h

View File

@ -7,6 +7,8 @@ lzmainfo_SOURCES = \
lzmainfo.c \
../common/tuklib_progname.c \
../common/tuklib_mbstr_nonprint.c \
../common/tuklib_mbstr_width.c \
../common/tuklib_mbstr_wrap.c \
../common/tuklib_exit.c
if COND_W32

View File

@ -18,6 +18,7 @@
#include "tuklib_gettext.h"
#include "tuklib_progname.h"
#include "tuklib_mbstr_nonprint.h"
#include "tuklib_mbstr_wrap.h"
#include "tuklib_exit.h"
#ifdef TUKLIB_DOSLIKE
@ -30,21 +31,36 @@ tuklib_attr_noreturn
static void
help(void)
{
// We don't need automatic word-wrapping here. A few strings are
// the same as in xz/message.c but here we need to add the newlines
// with putchar('\n'). This way translators won't get two variants
// of the same string: one without and another with \n at the end.
// A few languages use so long strings that we need automatic
// wrapping. A few strings are the same as in xz/message.c and
// should be kept in sync.
static const struct tuklib_wrap_opt wrap0 = { 0, 0, 0, 0, 79 };
int e = 0;
printf(_("Usage: %s [--help] [--version] [FILE]...\n"), progname);
puts(_("Show information stored in the .lzma file header."));
puts(_("With no FILE, or when FILE is -, read standard input."));
e |= tuklib_wraps(stdout, &wrap0,
W_("Show information stored in the .lzma file header."));
e |= tuklib_wraps(stdout, &wrap0,
W_("With no FILE, or when FILE is -, read standard input."));
putchar('\n');
printf(_("Report bugs to <%s> (in English or Finnish)."),
e |= tuklib_wrapf(stdout, &wrap0,
W_("Report bugs to <%s> (in English or Finnish)."),
PACKAGE_BUGREPORT);
putchar('\n');
printf(_("%s home page: <%s>"), PACKAGE_NAME, PACKAGE_URL);
putchar('\n');
e |= tuklib_wrapf(stdout, &wrap0,
W_("%s home page: <%s>"), PACKAGE_NAME, PACKAGE_URL);
if (e != 0) {
// Avoid new translatable strings by printing the message
// in pieces.
fprintf(stderr, _("%s: "), progname);
fprintf(stderr, _("Error printing the help text "
"(error code %d)"), e);
fprintf(stderr, "\n");
}
tuklib_exit(EXIT_SUCCESS, EXIT_FAILURE, true);
}