aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2015-02-05 06:15:33 +0000
committerlloyd <[email protected]>2015-02-05 06:15:33 +0000
commit2c14faf0aa1cfe0f8d70af1938dcad5b4d6d3b59 (patch)
treea3c7fb8f328a20c5a13dc796d9397d6a295e2000
parentba20c74752581c559332defe3e1b83d5b7901d43 (diff)
Fix build problem with recent LZMA library.
Fix retreival of LZMA and bzip2 compressors from make_compressor. Allow setting compression level from command line.
-rw-r--r--src/cmd/compress.cpp8
-rw-r--r--src/lib/compression/compression.cpp4
-rw-r--r--src/lib/compression/lzma/lzma.cpp9
3 files changed, 11 insertions, 10 deletions
diff --git a/src/cmd/compress.cpp b/src/cmd/compress.cpp
index 646a4d587..d7456fc31 100644
--- a/src/cmd/compress.cpp
+++ b/src/cmd/compress.cpp
@@ -35,9 +35,9 @@ void do_compress(Transform& comp, std::ifstream& in, std::ostream& out)
int compress(int argc, char* argv[])
{
- if(argc != 2 && argc != 3)
+ if(argc != 2 && argc != 3 && argc != 4)
{
- std::cout << "Usage: " << argv[0] << " input [type]\n";
+ std::cout << "Usage: " << argv[0] << " input [type] [level]\n";
return 1;
}
@@ -50,8 +50,8 @@ int compress(int argc, char* argv[])
return 1;
}
- const size_t level = 9;
- const std::string suffix = argc == 3 ? argv[2] : "gz";
+ const std::string suffix = argc >= 3 ? argv[2] : "gz";
+ const size_t level = argc >= 4 ? to_u32bit(argv[3]) : 9;
std::unique_ptr<Transform> compress(make_compressor(suffix, level));
diff --git a/src/lib/compression/compression.cpp b/src/lib/compression/compression.cpp
index 600f2c3ae..8e976d572 100644
--- a/src/lib/compression/compression.cpp
+++ b/src/lib/compression/compression.cpp
@@ -47,9 +47,9 @@ Transform* make_compressor(const std::string& type, size_t level)
if(type == "gzip" || type == "gz")
return get_transform("Gzip" + comp_suffix);
if(type == "bzip2" || type == "bz2")
- return get_transform("Bzip2", comp_suffix);
+ return get_transform("Bzip2" + comp_suffix);
if(type == "lzma" || type == "xz")
- return get_transform("LZMA", comp_suffix);
+ return get_transform("LZMA" + comp_suffix);
return nullptr;
}
diff --git a/src/lib/compression/lzma/lzma.cpp b/src/lib/compression/lzma/lzma.cpp
index c7e6ab815..93a969d70 100644
--- a/src/lib/compression/lzma/lzma.cpp
+++ b/src/lib/compression/lzma/lzma.cpp
@@ -23,10 +23,11 @@ class LZMA_Stream : public Zlib_Style_Stream<lzma_stream, byte>
public:
LZMA_Stream()
{
- streamp()->allocator = new ::lzma_allocator;
- streamp()->allocator->opaque = alloc();
- streamp()->allocator->alloc = Compression_Alloc_Info::malloc<size_t>;
- streamp()->allocator->free = Compression_Alloc_Info::free;
+ auto a = new ::lzma_allocator;
+ a->opaque = alloc();
+ a->alloc = Compression_Alloc_Info::malloc<size_t>;
+ a->free = Compression_Alloc_Info::free;
+ streamp()->allocator = a;
}
~LZMA_Stream()