Add --no-adjust.

This commit is contained in:
Lasse Collin 2010-06-15 14:06:29 +03:00
parent 2130926dd1
commit c15c42abb3
5 changed files with 28 additions and 9 deletions

View File

@ -45,6 +45,7 @@ parse_real(args_info *args, int argc, char **argv)
OPT_NO_SPARSE, OPT_NO_SPARSE,
OPT_FILES, OPT_FILES,
OPT_FILES0, OPT_FILES0,
OPT_NO_ADJUST,
OPT_INFO_MEMORY, OPT_INFO_MEMORY,
OPT_ROBOT, OPT_ROBOT,
}; };
@ -74,6 +75,7 @@ parse_real(args_info *args, int argc, char **argv)
// Basic compression settings // Basic compression settings
{ "format", required_argument, NULL, 'F' }, { "format", required_argument, NULL, 'F' },
{ "check", required_argument, NULL, 'C' }, { "check", required_argument, NULL, 'C' },
{ "no-adjust", no_argument, NULL, OPT_NO_ADJUST },
{ "memory", required_argument, NULL, 'M' }, { "memory", required_argument, NULL, 'M' },
{ "threads", required_argument, NULL, 'T' }, { "threads", required_argument, NULL, 'T' },
@ -367,6 +369,10 @@ parse_real(args_info *args, int argc, char **argv)
break; break;
case OPT_NO_ADJUST:
opt_auto_adjust = false;
break;
default: default:
message_try_help(); message_try_help();
tuklib_exit(E_ERROR, E_ERROR, false); tuklib_exit(E_ERROR, E_ERROR, false);

View File

@ -22,8 +22,8 @@ enum coder_init_ret {
enum operation_mode opt_mode = MODE_COMPRESS; enum operation_mode opt_mode = MODE_COMPRESS;
enum format_type opt_format = FORMAT_AUTO; enum format_type opt_format = FORMAT_AUTO;
bool opt_auto_adjust = true;
/// Stream used to communicate with liblzma /// Stream used to communicate with liblzma
@ -42,10 +42,6 @@ static size_t filters_count = 0;
/// Number of the preset (0-9) /// Number of the preset (0-9)
static size_t preset_number = 6; static size_t preset_number = 6;
/// True if we should auto-adjust the compression settings to use less memory
/// if memory usage limit is too low for the original settings.
static bool auto_adjust = true;
/// Indicate if no preset has been explicitly given. In that case, if we need /// Indicate if no preset has been explicitly given. In that case, if we need
/// to auto-adjust for lower memory usage, we won't print a warning. /// to auto-adjust for lower memory usage, we won't print a warning.
static bool preset_default = true; static bool preset_default = true;
@ -191,7 +187,7 @@ coder_set_compression_settings(void)
// If --no-auto-adjust was used or we didn't find LZMA1 or // If --no-auto-adjust was used or we didn't find LZMA1 or
// LZMA2 as the last filter, give an error immediately. // LZMA2 as the last filter, give an error immediately.
// --format=raw implies --no-auto-adjust. // --format=raw implies --no-auto-adjust.
if (!auto_adjust || opt_format == FORMAT_RAW) if (!opt_auto_adjust || opt_format == FORMAT_RAW)
memlimit_too_small(memory_usage); memlimit_too_small(memory_usage);
assert(opt_mode == MODE_COMPRESS); assert(opt_mode == MODE_COMPRESS);

View File

@ -37,6 +37,10 @@ extern enum operation_mode opt_mode;
/// This is set in args.c. /// This is set in args.c.
extern enum format_type opt_format; extern enum format_type opt_format;
/// If true, the compression settings are automatically adjusted down if
/// they exceed the memory usage limit.
extern bool opt_auto_adjust;
/// Set the integrity check type used when compressing /// Set the integrity check type used when compressing
extern void coder_set_check(lzma_check check); extern void coder_set_check(lzma_check check);

View File

@ -1137,10 +1137,14 @@ message_help(bool long_help)
" -e, --extreme use more CPU time when encoding to increase compression\n" " -e, --extreme use more CPU time when encoding to increase compression\n"
" ratio without increasing memory usage of the decoder")); " ratio without increasing memory usage of the decoder"));
if (long_help) if (long_help) {
puts(_(
" --no-adjust if compression settings exceed the memory usage limit,\n"
" give an error instead of adjusting the settings downwards"));
puts(_( // xgettext:no-c-format puts(_( // xgettext:no-c-format
" -M, --memory=NUM use roughly NUM bytes of memory at maximum; 0 indicates\n" " -M, --memory=NUM use roughly NUM bytes of memory at maximum; 0 indicates\n"
" the default setting, which is 40 % of total RAM")); " the default setting, which is 40 % of total RAM"));
}
if (long_help) { if (long_help) {
puts(_( puts(_(

View File

@ -5,7 +5,7 @@
.\" This file has been put into the public domain. .\" This file has been put into the public domain.
.\" You can do whatever you want with this file. .\" You can do whatever you want with this file.
.\" .\"
.TH XZ 1 "2010-06-01" "Tukaani" "XZ Utils" .TH XZ 1 "2010-06-15" "Tukaani" "XZ Utils"
.SH NAME .SH NAME
xz, unxz, xzcat, lzma, unlzma, lzcat \- Compress or decompress .xz and .lzma files xz, unxz, xzcat, lzma, unlzma, lzcat \- Compress or decompress .xz and .lzma files
.SH SYNOPSIS .SH SYNOPSIS
@ -210,7 +210,9 @@ When compressing, if the selected compression settings exceed the memory
usage limit, the settings are automatically adjusted downwards and a notice usage limit, the settings are automatically adjusted downwards and a notice
about this is displayed. As an exception, if the memory usage limit is about this is displayed. As an exception, if the memory usage limit is
exceeded when compressing with exceeded when compressing with
.BR \-\-format=raw , .B \-\-format=raw
or
.BR \-\-no\-adjust ,
an error is displayed and an error is displayed and
.B xz .B xz
will exit with exit status will exit with exit status
@ -617,6 +619,13 @@ of the compressor or decompressor (exception: compressor memory usage may
increase a little with presets \fB\-0\fR ... \fB\-2\fR). The downside is that increase a little with presets \fB\-0\fR ... \fB\-2\fR). The downside is that
the compression time will increase dramatically (it can easily double). the compression time will increase dramatically (it can easily double).
.TP .TP
.B \-\-no\-adjust
Display an error and exit if the compression settings exceed the
the memory usage limit. The default is to adjust the settings downwards so
that the memory usage limit is not exceeded. Automatic adjusting is
always disabled when creating raw streams
.RB ( \-\-format=raw ).
.TP
\fB\-M\fR \fIlimit\fR, \fB\-\-memory=\fIlimit \fB\-M\fR \fIlimit\fR, \fB\-\-memory=\fIlimit
Set the memory usage limit. If this option is specified multiple times, Set the memory usage limit. If this option is specified multiple times,
the last one takes effect. The the last one takes effect. The