e4e2c79c62e5060be16f0c2b25e473b98e5f19cf
[openwrt/svn-archive/archive.git] / tools / xz / patches / 000-upstream-002-clean_suffix.patch
1 From: Lasse Collin <lasse.collin@tukaani.org>
2 Date: Fri, 4 Feb 2011 20:49:31 +0000 (+0200)
3 Subject: xz: Clean up suffix.c.
4 X-Git-Url: http://repo.or.cz/w/xz.git/commitdiff_plain/96f94bc925d579a700147fa5d7793b64d69cfc18
5
6 xz: Clean up suffix.c.
7
8 struct suffix_pair isn't needed in compresed_name()
9 so get rid of it there.
10 ---
11
12 diff --git a/src/xz/suffix.c b/src/xz/suffix.c
13 index f795e2a..c89f67f 100644
14 --- a/src/xz/suffix.c
15 +++ b/src/xz/suffix.c
16 @@ -21,12 +21,6 @@
17 static char *custom_suffix = NULL;
18
19
20 -struct suffix_pair {
21 - const char *compressed;
22 - const char *uncompressed;
23 -};
24 -
25 -
26 /// \brief Test if the char is a directory separator
27 static bool
28 is_dir_sep(char c)
29 @@ -86,7 +80,10 @@ test_suffix(const char *suffix, const char *src_name, size_t src_len)
30 static char *
31 uncompressed_name(const char *src_name, const size_t src_len)
32 {
33 - static const struct suffix_pair suffixes[] = {
34 + static const struct {
35 + const char *compressed;
36 + const char *uncompressed;
37 + } suffixes[] = {
38 { ".xz", "" },
39 { ".txz", ".tar" }, // .txz abbreviation for .txt.gz is rare.
40 { ".lzma", "" },
41 @@ -145,25 +142,25 @@ static char *
42 compressed_name(const char *src_name, const size_t src_len)
43 {
44 // The order of these must match the order in args.h.
45 - static const struct suffix_pair all_suffixes[][3] = {
46 + static const char *const all_suffixes[][3] = {
47 {
48 - { ".xz", "" },
49 - { ".txz", ".tar" },
50 - { NULL, NULL }
51 + ".xz",
52 + ".txz",
53 + NULL
54 }, {
55 - { ".lzma", "" },
56 - { ".tlz", ".tar" },
57 - { NULL, NULL }
58 + ".lzma",
59 + ".tlz",
60 + NULL
61 /*
62 }, {
63 - { ".gz", "" },
64 - { ".tgz", ".tar" },
65 - { NULL, NULL }
66 + ".gz",
67 + ".tgz",
68 + NULL
69 */
70 }, {
71 // --format=raw requires specifying the suffix
72 // manually or using stdout.
73 - { NULL, NULL }
74 + NULL
75 }
76 };
77
78 @@ -171,14 +168,13 @@ compressed_name(const char *src_name, const size_t src_len)
79 assert(opt_format != FORMAT_AUTO);
80
81 const size_t format = opt_format - 1;
82 - const struct suffix_pair *const suffixes = all_suffixes[format];
83 + const char *const *suffixes = all_suffixes[format];
84
85 - for (size_t i = 0; suffixes[i].compressed != NULL; ++i) {
86 - if (test_suffix(suffixes[i].compressed, src_name, src_len)
87 - != 0) {
88 + for (size_t i = 0; suffixes[i] != NULL; ++i) {
89 + if (test_suffix(suffixes[i], src_name, src_len) != 0) {
90 message_warning(_("%s: File already has `%s' "
91 "suffix, skipping"), src_name,
92 - suffixes[i].compressed);
93 + suffixes[i]);
94 return NULL;
95 }
96 }
97 @@ -202,7 +198,7 @@ compressed_name(const char *src_name, const size_t src_len)
98 }
99
100 const char *suffix = custom_suffix != NULL
101 - ? custom_suffix : suffixes[0].compressed;
102 + ? custom_suffix : suffixes[0];
103 const size_t suffix_len = strlen(suffix);
104
105 char *dest_name = xmalloc(src_len + suffix_len + 1);