xz: Avoid printf formats like %2$s

It's a POSIX feature that isn't in standard C. It's not available on
Windows. Even MinGW-w64 with __USE_MINGW_ANSI_STDIO doesn't support
it even though it supports POSIX %'d for thousand separators.

Gettext's <libintl.h> provides overrides for printf and other functions
which do support the %2$s formats. Translations use them. But xz should
work on Windows without <libintl.h> too.

Fixes: 3e9177fd20
This commit is contained in:
Lasse Collin 2025-01-04 15:02:16 +02:00
parent 63b246c90e
commit 5651d15303
No known key found for this signature in database
GPG Key ID: 38EE757D69184620
1 changed files with 32 additions and 19 deletions

View File

@ -1087,11 +1087,14 @@ message_help(bool long_help)
"all pending data is flushed out")); "all pending data is flushed out"));
e |= tuklib_wrapf(stdout, &wrap2, e |= tuklib_wrapf(stdout, &wrap2,
" --memlimit-compress=%1$s\n" " --memlimit-compress=%s\n"
" --memlimit-decompress=%1$s\n" " --memlimit-decompress=%s\n"
" --memlimit-mt-decompress=%1$s\n" " --memlimit-mt-decompress=%s\n"
"-M, --memlimit=%1$s\v%2$s\r" "-M, --memlimit=%s\v%s\r"
" --no-adjust\v%3$s", " --no-adjust\v%s",
_("LIMIT"),
_("LIMIT"),
_("LIMIT"),
_("LIMIT"), _("LIMIT"),
// xgettext:no-c-format // xgettext:no-c-format
W_("set memory usage limit for compression, " W_("set memory usage limit for compression, "
@ -1113,13 +1116,15 @@ message_help(bool long_help)
e |= tuklib_wrapf(stdout, &wrap2, e |= tuklib_wrapf(stdout, &wrap2,
"\n" "\n"
"--filters=%1$s\v%2$s\r" "--filters=%s\v%s\r"
"--filters1=%1$s ... --filters9=%1$s\v%3$s\r" "--filters1=%s ... --filters9=%s\v%s\r"
"--filters-help\v%4$s", "--filters-help\v%s",
_("FILTERS"), _("FILTERS"),
W_("set the filter chain using the " W_("set the filter chain using the "
"liblzma filter string syntax; " "liblzma filter string syntax; "
"use --filters-help for more information"), "use --filters-help for more information"),
_("FILTERS"),
_("FILTERS"),
W_("set additional filter chains using the " W_("set additional filter chains using the "
"liblzma filter string syntax to use " "liblzma filter string syntax to use "
"with --block-list"), "with --block-list"),
@ -1130,10 +1135,11 @@ message_help(bool long_help)
|| defined(HAVE_ENCODER_LZMA2) || defined(HAVE_DECODER_LZMA2) || defined(HAVE_ENCODER_LZMA2) || defined(HAVE_DECODER_LZMA2)
e |= tuklib_wrapf(stdout, &wrap2, e |= tuklib_wrapf(stdout, &wrap2,
"\n" "\n"
"--lzma1[=%1$s]\n" "--lzma1[=%s]\n"
"--lzma2[=%1$s]\v%2$s", "--lzma2[=%s]\v%s",
// TRANSLATORS: Short for OPTIONS. // TRANSLATORS: Short for OPTIONS.
_("OPTS"), _("OPTS"),
_("OPTS"),
// TRANSLATORS: Use semicolon (or its fullwidth form) // TRANSLATORS: Use semicolon (or its fullwidth form)
// in "(valid values; default)" even if it is weird in // in "(valid values; default)" even if it is weird in
// your language. There are non-translatable strings // your language. There are non-translatable strings
@ -1176,23 +1182,30 @@ message_help(bool long_help)
e |= tuklib_wrapf(stdout, &wrap2, e |= tuklib_wrapf(stdout, &wrap2,
"\n" "\n"
"--x86[=%1$s]\v%2$s\r" "--x86[=%s]\v%s\r"
"--arm[=%1$s]\v%3$s\r" "--arm[=%s]\v%s\r"
"--armthumb[=%1$s]\v%4$s\r" "--armthumb[=%s]\v%s\r"
"--arm64[=%1$s]\v%5$s\r" "--arm64[=%s]\v%s\r"
"--powerpc[=%1$s]\v%6$s\r" "--powerpc[=%s]\v%s\r"
"--ia64[=%1$s]\v%7$s\r" "--ia64[=%s]\v%s\r"
"--sparc[=%1$s]\v%8$s\r" "--sparc[=%s]\v%s\r"
"--riscv[=%1$s]\v%9$s\r" "--riscv[=%s]\v%s\r"
"\v%10$s", "\v%s",
_("OPTS"), _("OPTS"),
W_("x86 BCJ filter (32-bit and 64-bit)"), W_("x86 BCJ filter (32-bit and 64-bit)"),
_("OPTS"),
W_("ARM BCJ filter"), W_("ARM BCJ filter"),
_("OPTS"),
W_("ARM-Thumb BCJ filter"), W_("ARM-Thumb BCJ filter"),
_("OPTS"),
W_("ARM64 BCJ filter"), W_("ARM64 BCJ filter"),
_("OPTS"),
W_("PowerPC BCJ filter (big endian only)"), W_("PowerPC BCJ filter (big endian only)"),
_("OPTS"),
W_("IA-64 (Itanium) BCJ filter"), W_("IA-64 (Itanium) BCJ filter"),
_("OPTS"),
W_("SPARC BCJ filter"), W_("SPARC BCJ filter"),
_("OPTS"),
W_("RISC-V BCJ filter"), W_("RISC-V BCJ filter"),
W_("Valid OPTS for all BCJ filters:")); W_("Valid OPTS for all BCJ filters:"));
e |= tuklib_wrapf(stdout, &wrap3, e |= tuklib_wrapf(stdout, &wrap3,