mirror of https://git.tukaani.org/xz.git
Cleanups to message.c.
This commit is contained in:
parent
a8368b75cd
commit
ae65dcfde2
|
@ -102,7 +102,7 @@ my_time(void)
|
||||||
|
|
||||||
|
|
||||||
/// Wrapper for snprintf() to help constructing a string in pieces.
|
/// Wrapper for snprintf() to help constructing a string in pieces.
|
||||||
static void /* lzma_attribute((format(printf, 3, 4))) */
|
static void lzma_attribute((format(printf, 3, 4)))
|
||||||
my_snprintf(char **pos, size_t *left, const char *fmt, ...)
|
my_snprintf(char **pos, size_t *left, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
@ -123,6 +123,15 @@ my_snprintf(char **pos, size_t *left, const char *fmt, ...)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ugly hack to make it possible to use lzma_attribute((format(printf, 3, 4)))
|
||||||
|
// and thus catch stupid things, while still allowing format characters that
|
||||||
|
// are not in ISO C but are in POSIX. This has to be done after my_snprintf()
|
||||||
|
// has been defined.
|
||||||
|
#ifdef __GNUC__
|
||||||
|
# define my_snprintf __extension__ my_snprintf
|
||||||
|
# define my_printf __extension__ printf
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
message_init(const char *given_argv0)
|
message_init(const char *given_argv0)
|
||||||
|
@ -301,8 +310,6 @@ progress_sizes_helper(char **pos, size_t *left, uint64_t value, bool final)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// // At maximum of four significant digits is allowed for KiB.
|
|
||||||
// if (value < UINT64_C(1023900)) {
|
|
||||||
// At maximum of five significant digits is allowed for KiB.
|
// At maximum of five significant digits is allowed for KiB.
|
||||||
if (value < UINT64_C(10239900)) {
|
if (value < UINT64_C(10239900)) {
|
||||||
my_snprintf(pos, left, "%'.1f KiB",
|
my_snprintf(pos, left, "%'.1f KiB",
|
||||||
|
@ -832,20 +839,6 @@ message_help(bool long_help)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (long_help)
|
|
||||||
puts(_(
|
|
||||||
"\n"
|
|
||||||
" Resource usage options:\n"
|
|
||||||
"\n"
|
|
||||||
" -M, --memory=NUM use roughly NUM bytes of memory at maximum; 0 indicates\n"
|
|
||||||
" the default setting, which depends on the operation mode\n"
|
|
||||||
" and the amount of physical memory (RAM)\n"
|
|
||||||
" -T, --threads=NUM use a maximum of NUM (de)compression threads"
|
|
||||||
// " --threading=STR threading style; possible values are `auto' (default),\n"
|
|
||||||
// " `files', and `stream'
|
|
||||||
));
|
|
||||||
*/
|
|
||||||
if (long_help)
|
if (long_help)
|
||||||
puts(_("\n Other options:\n"));
|
puts(_("\n Other options:\n"));
|
||||||
|
|
||||||
|
@ -869,19 +862,15 @@ message_help(bool long_help)
|
||||||
puts(_("\nWith no FILE, or when FILE is -, read standard input.\n"));
|
puts(_("\nWith no FILE, or when FILE is -, read standard input.\n"));
|
||||||
|
|
||||||
if (long_help) {
|
if (long_help) {
|
||||||
// FIXME !!!
|
|
||||||
size_t mem_limit = hardware_memlimit_encoder() / (1024 * 1024);
|
|
||||||
if (mem_limit == 0)
|
|
||||||
mem_limit = 1;
|
|
||||||
|
|
||||||
// We use PRIu64 instead of %zu to support pre-C99 libc.
|
// We use PRIu64 instead of %zu to support pre-C99 libc.
|
||||||
// FIXME: Use ' but avoid warnings.
|
my_printf(_(
|
||||||
puts(_("On this system and configuration, the tool will use"));
|
"On this system and configuration, the tool will use at maximum of\n"
|
||||||
printf(_(" * roughly %" PRIu64 " MiB of memory at maximum; and\n"),
|
" * roughly %'" PRIu64 " MiB RAM for compression;\n"
|
||||||
(uint64_t)(mem_limit));
|
" * roughly %'" PRIu64 " MiB RAM for uncompression; and\n"),
|
||||||
printf(N_(" * at maximum of one thread for (de)compression.\n\n",
|
hardware_memlimit_encoder() / (1024 * 1024),
|
||||||
" * at maximum of %" PRIu64
|
hardware_memlimit_decoder() / (1024 * 1024));
|
||||||
" threads for (de)compression.\n\n",
|
my_printf(N_(" * one thread for (de)compression.\n\n",
|
||||||
|
" * %'" PRIu64 " threads for (de)compression.\n\n",
|
||||||
(uint64_t)(opt_threads)), (uint64_t)(opt_threads));
|
(uint64_t)(opt_threads)), (uint64_t)(opt_threads));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue