diff options
author | Jia Tan <jiat0218@gmail.com> | 2023-01-07 21:55:06 +0800 |
---|---|---|
committer | Jia Tan <jiat0218@gmail.com> | 2023-01-21 22:10:51 +0800 |
commit | cc5aa9ab138beeecaee5a1e81197591893ee9ca0 (patch) | |
tree | a26ab6b7deb69a6e2a47ea7503191570d34043dc /src/xz/suffix.c | |
parent | liblzma: Set documentation on all reserved fields to private. (diff) | |
download | xz-cc5aa9ab138beeecaee5a1e81197591893ee9ca0.tar.xz |
xz: Refactor duplicated check for custom suffix when using --format=raw
Diffstat (limited to 'src/xz/suffix.c')
-rw-r--r-- | src/xz/suffix.c | 26 |
1 files changed, 8 insertions, 18 deletions
diff --git a/src/xz/suffix.c b/src/xz/suffix.c index 09add381..a9cdbd8a 100644 --- a/src/xz/suffix.c +++ b/src/xz/suffix.c @@ -131,15 +131,7 @@ uncompressed_name(const char *src_name, const size_t src_len) const char *new_suffix = ""; size_t new_len = 0; - if (opt_format == FORMAT_RAW) { - // Don't check for known suffixes when --format=raw was used. - if (custom_suffix == NULL) { - message_error(_("%s: With --format=raw, " - "--suffix=.SUF is required unless " - "writing to stdout"), src_name); - return NULL; - } - } else { + if (opt_format != FORMAT_RAW) { for (size_t i = 0; i < ARRAY_SIZE(suffixes); ++i) { new_len = test_suffix(suffixes[i].compressed, src_name, src_len); @@ -262,15 +254,6 @@ compressed_name(const char *src_name, 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 && custom_suffix == NULL) { - message_error(_("%s: With --format=raw, " - "--suffix=.SUF is required unless " - "writing to stdout"), src_name); - return NULL; - } - const char *suffix = custom_suffix != NULL ? custom_suffix : suffixes[0]; size_t suffix_len = strlen(suffix); @@ -409,3 +392,10 @@ suffix_set(const char *suffix) custom_suffix = xstrdup(suffix); return; } + + +extern bool +suffix_is_set(void) +{ + return custom_suffix == NULL; +} |