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
8 struct suffix_pair isn't needed in compresed_name()
9 so get rid of it there.
12 diff --git a/src/xz/suffix.c b/src/xz/suffix.c
13 index f795e2a..c89f67f 100644
17 static char *custom_suffix = NULL;
21 - const char *compressed;
22 - const char *uncompressed;
26 /// \brief Test if the char is a directory separator
29 @@ -86,7 +80,10 @@ test_suffix(const char *suffix, const char *src_name, size_t src_len)
31 uncompressed_name(const char *src_name, const size_t src_len)
33 - static const struct suffix_pair suffixes[] = {
34 + static const struct {
35 + const char *compressed;
36 + const char *uncompressed;
39 { ".txz", ".tar" }, // .txz abbreviation for .txt.gz is rare.
41 @@ -145,25 +142,25 @@ static char *
42 compressed_name(const char *src_name, const size_t src_len)
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] = {
71 // --format=raw requires specifying the suffix
72 // manually or using stdout.
78 @@ -171,14 +168,13 @@ compressed_name(const char *src_name, const size_t src_len)
79 assert(opt_format != FORMAT_AUTO);
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];
85 - for (size_t i = 0; suffixes[i].compressed != NULL; ++i) {
86 - if (test_suffix(suffixes[i].compressed, src_name, src_len)
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);
97 @@ -202,7 +198,7 @@ compressed_name(const char *src_name, const size_t src_len)
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);
105 char *dest_name = xmalloc(src_len + suffix_len + 1);