aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2008-10-03 07:06:48 +0300
committerLasse Collin <lasse.collin@tukaani.org>2008-10-03 07:06:48 +0300
commitfcfb86c7770328cfffa2e83b176af9a1ba2d9128 (patch)
treebc3bb3e2a6b59e735c6b9643b5dc4e86f59537bd /src
parentInitial changes to change the suffix of the new format to .xz. (diff)
downloadxz-fcfb86c7770328cfffa2e83b176af9a1ba2d9128.tar.xz
Fixed suffix handling with --format=raw.
Diffstat (limited to 'src')
-rw-r--r--src/lzma/suffix.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/lzma/suffix.c b/src/lzma/suffix.c
index 41b4c352..460acee2 100644
--- a/src/lzma/suffix.c
+++ b/src/lzma/suffix.c
@@ -72,12 +72,22 @@ uncompressed_name(const char *src_name, const size_t src_len)
const char *new_suffix = "";
size_t new_len = 0;
- for (size_t i = 0; i < ARRAY_SIZE(suffixes); ++i) {
- new_len = test_suffix(suffixes[i].compressed,
- src_name, src_len);
- if (new_len != 0) {
- new_suffix = suffixes[i].uncompressed;
- break;
+ 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) {
+ new_len = test_suffix(suffixes[i].compressed,
+ src_name, src_len);
+ if (new_len != 0) {
+ new_suffix = suffixes[i].uncompressed;
+ break;
+ }
}
}
@@ -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,
// since the suffix handling when decoding is weird now.
if (opt_format == FORMAT_RAW && opt_suffix == NULL) {
- errmsg(V_ERROR, _("%s: With --format=raw, --suffix=.SUF is "
- "required unless writing to stdout"),
- src_name);
+ errmsg(V_ERROR, _("%s: With --format=raw, "
+ "--suffix=.SUF is required unless "
+ "writing to stdout"), src_name);
return NULL;
}