1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

Fixed suffix handling with --format=raw.

This commit is contained in:
Lasse Collin 2008-10-03 07:06:48 +03:00
parent bd137524f2
commit fcfb86c777

View file

@ -72,6 +72,15 @@ uncompressed_name(const char *src_name, const size_t src_len)
const char *new_suffix = ""; const char *new_suffix = "";
size_t new_len = 0; size_t new_len = 0;
if (opt_format == FORMAT_RAW) {
// Don't check for known suffixes when --format=raw was used.
if (opt_suffix == NULL) {
errmsg(V_ERROR, _("%s: With --format=raw, "
"--suffix=.SUF is required unless "
"writing to stdout"), src_name);
return NULL;
}
} else {
for (size_t i = 0; i < ARRAY_SIZE(suffixes); ++i) { for (size_t i = 0; i < ARRAY_SIZE(suffixes); ++i) {
new_len = test_suffix(suffixes[i].compressed, new_len = test_suffix(suffixes[i].compressed,
src_name, src_len); src_name, src_len);
@ -80,6 +89,7 @@ uncompressed_name(const char *src_name, const size_t src_len)
break; break;
} }
} }
}
if (new_len == 0 && opt_suffix != NULL) if (new_len == 0 && opt_suffix != NULL)
new_len = test_suffix(opt_suffix, src_name, src_len); new_len = test_suffix(opt_suffix, src_name, src_len);
@ -154,9 +164,9 @@ compressed_name(const char *src_name, const size_t src_len)
// TODO: Hmm, maybe it would be better to validate this in args.c, // TODO: Hmm, maybe it would be better to validate this in args.c,
// since the suffix handling when decoding is weird now. // since the suffix handling when decoding is weird now.
if (opt_format == FORMAT_RAW && opt_suffix == NULL) { if (opt_format == FORMAT_RAW && opt_suffix == NULL) {
errmsg(V_ERROR, _("%s: With --format=raw, --suffix=.SUF is " errmsg(V_ERROR, _("%s: With --format=raw, "
"required unless writing to stdout"), "--suffix=.SUF is required unless "
src_name); "writing to stdout"), src_name);
return NULL; return NULL;
} }