aboutsummaryrefslogtreecommitdiff
path: root/src/xz/suffix.c
diff options
context:
space:
mode:
authorJia Tan <jiat0218@gmail.com>2023-01-07 21:55:06 +0800
committerJia Tan <jiat0218@gmail.com>2023-02-03 21:38:26 +0800
commit99575947a58a60416c570eb78038d18a1ea4cef4 (patch)
tree9064bc92eb57e358ac30ccbdacf4eb8247dfc1ed /src/xz/suffix.c
parentliblzma: Set documentation on all reserved fields to private. (diff)
downloadxz-99575947a58a60416c570eb78038d18a1ea4cef4.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.c26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/xz/suffix.c b/src/xz/suffix.c
index 09add381..6ce97878 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;
+}