diff options
author | Daniel Pfeifer <daniel@pfeifer-mail.de> | 2014-07-13 20:21:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-07-29 12:44:36 (GMT) |
commit | 7a92eddbcb2b2e6419062538e346908f0e502586 (patch) | |
tree | b1985ad4a8904211f12cb07742a9d776fa28152f /Utilities/cmliblzma/liblzma/common/stream_decoder.c | |
parent | b2a07ca49c66665f5b51b592f44ecc4f66c7556b (diff) | |
download | CMake-7a92eddbcb2b2e6419062538e346908f0e502586.zip CMake-7a92eddbcb2b2e6419062538e346908f0e502586.tar.gz CMake-7a92eddbcb2b2e6419062538e346908f0e502586.tar.bz2 |
liblzma: Port from C99 to C89/90
Remove use of designated initializers and declarations of variables
after statements. Leave "//" comments as-is for now.
Diffstat (limited to 'Utilities/cmliblzma/liblzma/common/stream_decoder.c')
-rw-r--r-- | Utilities/cmliblzma/liblzma/common/stream_decoder.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Utilities/cmliblzma/liblzma/common/stream_decoder.c b/Utilities/cmliblzma/liblzma/common/stream_decoder.c index 37ea71e..56a009b 100644 --- a/Utilities/cmliblzma/liblzma/common/stream_decoder.c +++ b/Utilities/cmliblzma/liblzma/common/stream_decoder.c @@ -106,6 +106,8 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator, while (true) switch (coder->sequence) { case SEQ_STREAM_HEADER: { + lzma_ret ret; + // Copy the Stream Header to the internal buffer. lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos, LZMA_STREAM_HEADER_SIZE); @@ -117,7 +119,7 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator, coder->pos = 0; // Decode the Stream Header. - const lzma_ret ret = lzma_stream_header_decode( + ret = lzma_stream_header_decode( &coder->stream_flags, coder->buffer); if (ret != LZMA_OK) return ret == LZMA_FORMAT_ERROR && !coder->first_stream @@ -154,6 +156,11 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator, // Fall through case SEQ_BLOCK_HEADER: { + lzma_filter filters[LZMA_FILTERS_MAX + 1]; + uint64_t memusage; + lzma_ret ret; + size_t i; + if (*in_pos >= in_size) return LZMA_OK; @@ -188,7 +195,6 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator, // Set up a buffer to hold the filter chain. Block Header // decoder will initialize all members of this array so // we don't need to do it here. - lzma_filter filters[LZMA_FILTERS_MAX + 1]; coder->block_options.filters = filters; // Decode the Block Header. @@ -196,9 +202,7 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator, allocator, coder->buffer)); // Check the memory usage limit. - const uint64_t memusage = lzma_raw_decoder_memusage(filters); - lzma_ret ret; - + memusage = lzma_raw_decoder_memusage(filters); if (memusage == UINT64_MAX) { // One or more unknown Filter IDs. ret = LZMA_OPTIONS_ERROR; @@ -224,7 +228,7 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator, // Free the allocated filter options since they are needed // only to initialize the Block decoder. - for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i) + for (i = 0; i < LZMA_FILTERS_MAX; ++i) lzma_free(filters[i].options, allocator); coder->block_options.filters = NULL; @@ -260,6 +264,8 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator, } case SEQ_INDEX: { + lzma_ret ret; + // If we don't have any input, don't call // lzma_index_hash_decode() since it would return // LZMA_BUF_ERROR, which we must not do here. @@ -268,7 +274,7 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator, // Decode the Index and compare it to the hash calculated // from the sizes of the Blocks (if any). - const lzma_ret ret = lzma_index_hash_decode(coder->index_hash, + ret = lzma_index_hash_decode(coder->index_hash, in, in_pos, in_size); if (ret != LZMA_STREAM_END) return ret; @@ -279,6 +285,9 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator, // Fall through case SEQ_STREAM_FOOTER: { + lzma_stream_flags footer_flags; + lzma_ret ret; + // Copy the Stream Footer to the internal buffer. lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos, LZMA_STREAM_HEADER_SIZE); @@ -292,8 +301,7 @@ stream_decode(lzma_coder *coder, lzma_allocator *allocator, // Decode the Stream Footer. The decoder gives // LZMA_FORMAT_ERROR if the magic bytes don't match, // so convert that return code to LZMA_DATA_ERROR. - lzma_stream_flags footer_flags; - const lzma_ret ret = lzma_stream_footer_decode( + ret = lzma_stream_footer_decode( &footer_flags, coder->buffer); if (ret != LZMA_OK) return ret == LZMA_FORMAT_ERROR @@ -442,7 +450,7 @@ lzma_stream_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, extern LZMA_API(lzma_ret) lzma_stream_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags) { - lzma_next_strm_init(lzma_stream_decoder_init, strm, memlimit, flags); + lzma_next_strm_init2(lzma_stream_decoder_init, strm, memlimit, flags); strm->internal->supported_actions[LZMA_RUN] = true; strm->internal->supported_actions[LZMA_FINISH] = true; |