tools/xz: add some upstream patches
[openwrt/openwrt.git] / tools / xz / patches / 000-upstream-001-check_compress.patch
1 From: Lasse Collin <lasse.collin@tukaani.org>
2 Date: Fri, 4 Feb 2011 09:29:47 +0000 (+0200)
3 Subject: xz: Check if the file already has custom suffix when compressing.
4 X-Git-Url: http://repo.or.cz/w/xz.git/commitdiff_plain/8930c7ae3f82bdae15aa129f01de08be23d7e8d7
5
6 xz: Check if the file already has custom suffix when compressing.
7
8 Now "xz -S .test foo.test" refuses to compress the
9 file because it already has the suffix .test. The man
10 page had it documented this way already.
11 ---
12
13 diff --git a/src/xz/suffix.c b/src/xz/suffix.c
14 index ea86c1a..f795e2a 100644
15 --- a/src/xz/suffix.c
16 +++ b/src/xz/suffix.c
17 @@ -183,6 +183,15 @@ compressed_name(const char *src_name, const size_t src_len)
18 }
19 }
20
21 + if (custom_suffix != NULL) {
22 + if (test_suffix(custom_suffix, src_name, src_len) != 0) {
23 + message_warning(_("%s: File already has `%s' "
24 + "suffix, skipping"), src_name,
25 + custom_suffix);
26 + return NULL;
27 + }
28 + }
29 +
30 // TODO: Hmm, maybe it would be better to validate this in args.c,
31 // since the suffix handling when decoding is weird now.
32 if (opt_format == FORMAT_RAW && custom_suffix == NULL) {