summaryrefslogtreecommitdiffstats
path: root/Utilities/cmliblzma/liblzma/simple
diff options
context:
space:
mode:
authorDaniel Pfeifer <daniel@pfeifer-mail.de>2014-07-13 20:21:58 (GMT)
committerBrad King <brad.king@kitware.com>2014-07-29 12:44:36 (GMT)
commit7a92eddbcb2b2e6419062538e346908f0e502586 (patch)
treeb1985ad4a8904211f12cb07742a9d776fa28152f /Utilities/cmliblzma/liblzma/simple
parentb2a07ca49c66665f5b51b592f44ecc4f66c7556b (diff)
downloadCMake-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/simple')
-rw-r--r--Utilities/cmliblzma/liblzma/simple/arm.c2
-rw-r--r--Utilities/cmliblzma/liblzma/simple/armthumb.c2
-rw-r--r--Utilities/cmliblzma/liblzma/simple/ia64.c22
-rw-r--r--Utilities/cmliblzma/liblzma/simple/simple_coder.c18
-rw-r--r--Utilities/cmliblzma/liblzma/simple/simple_decoder.c5
-rw-r--r--Utilities/cmliblzma/liblzma/simple/sparc.c3
-rw-r--r--Utilities/cmliblzma/liblzma/simple/x86.c19
7 files changed, 46 insertions, 25 deletions
diff --git a/Utilities/cmliblzma/liblzma/simple/arm.c b/Utilities/cmliblzma/liblzma/simple/arm.c
index a84702a..8dcba39 100644
--- a/Utilities/cmliblzma/liblzma/simple/arm.c
+++ b/Utilities/cmliblzma/liblzma/simple/arm.c
@@ -22,12 +22,12 @@ arm_code(lzma_simple *simple lzma_attribute((__unused__)),
size_t i;
for (i = 0; i + 4 <= size; i += 4) {
if (buffer[i + 3] == 0xEB) {
+ uint32_t dest;
uint32_t src = (buffer[i + 2] << 16)
| (buffer[i + 1] << 8)
| (buffer[i + 0]);
src <<= 2;
- uint32_t dest;
if (is_encoder)
dest = now_pos + (uint32_t)(i) + 8 + src;
else
diff --git a/Utilities/cmliblzma/liblzma/simple/armthumb.c b/Utilities/cmliblzma/liblzma/simple/armthumb.c
index 4b49175..4b890a3 100644
--- a/Utilities/cmliblzma/liblzma/simple/armthumb.c
+++ b/Utilities/cmliblzma/liblzma/simple/armthumb.c
@@ -23,6 +23,7 @@ armthumb_code(lzma_simple *simple lzma_attribute((__unused__)),
for (i = 0; i + 4 <= size; i += 2) {
if ((buffer[i + 1] & 0xF8) == 0xF0
&& (buffer[i + 3] & 0xF8) == 0xF8) {
+ uint32_t dest;
uint32_t src = ((buffer[i + 1] & 0x7) << 19)
| (buffer[i + 0] << 11)
| ((buffer[i + 3] & 0x7) << 8)
@@ -30,7 +31,6 @@ armthumb_code(lzma_simple *simple lzma_attribute((__unused__)),
src <<= 1;
- uint32_t dest;
if (is_encoder)
dest = now_pos + (uint32_t)(i) + 4 + src;
else
diff --git a/Utilities/cmliblzma/liblzma/simple/ia64.c b/Utilities/cmliblzma/liblzma/simple/ia64.c
index ce3692b..c537cac 100644
--- a/Utilities/cmliblzma/liblzma/simple/ia64.c
+++ b/Utilities/cmliblzma/liblzma/simple/ia64.c
@@ -28,36 +28,42 @@ ia64_code(lzma_simple *simple lzma_attribute((__unused__)),
size_t i;
for (i = 0; i + 16 <= size; i += 16) {
+ size_t slot;
+
const uint32_t instr_template = buffer[i] & 0x1F;
const uint32_t mask = BRANCH_TABLE[instr_template];
uint32_t bit_pos = 5;
- for (size_t slot = 0; slot < 3; ++slot, bit_pos += 41) {
- if (((mask >> slot) & 1) == 0)
- continue;
-
+ for (slot = 0; slot < 3; ++slot, bit_pos += 41) {
const size_t byte_pos = (bit_pos >> 3);
const uint32_t bit_res = bit_pos & 0x7;
uint64_t instruction = 0;
+ uint64_t inst_norm;
+ size_t j;
+
+ if (((mask >> slot) & 1) == 0)
+ continue;
- for (size_t j = 0; j < 6; ++j)
+ for (j = 0; j < 6; ++j)
instruction += (uint64_t)(
buffer[i + j + byte_pos])
<< (8 * j);
- uint64_t inst_norm = instruction >> bit_res;
+ inst_norm = instruction >> bit_res;
if (((inst_norm >> 37) & 0xF) == 0x5
&& ((inst_norm >> 9) & 0x7) == 0
/* && (inst_norm & 0x3F)== 0 */
) {
+ uint32_t dest;
+ size_t j;
+
uint32_t src = (uint32_t)(
(inst_norm >> 13) & 0xFFFFF);
src |= ((inst_norm >> 36) & 1) << 20;
src <<= 4;
- uint32_t dest;
if (is_encoder)
dest = now_pos + (uint32_t)(i) + src;
else
@@ -73,7 +79,7 @@ ia64_code(lzma_simple *simple lzma_attribute((__unused__)),
instruction &= (1 << bit_res) - 1;
instruction |= (inst_norm << bit_res);
- for (size_t j = 0; j < 6; j++)
+ for (j = 0; j < 6; j++)
buffer[i + j + byte_pos] = (uint8_t)(
instruction
>> (8 * j));
diff --git a/Utilities/cmliblzma/liblzma/simple/simple_coder.c b/Utilities/cmliblzma/liblzma/simple/simple_coder.c
index a02b039..d147d4b 100644
--- a/Utilities/cmliblzma/liblzma/simple/simple_coder.c
+++ b/Utilities/cmliblzma/liblzma/simple/simple_coder.c
@@ -71,6 +71,9 @@ simple_code(lzma_coder *coder, lzma_allocator *allocator,
size_t in_size, uint8_t *restrict out,
size_t *restrict out_pos, size_t out_size, lzma_action action)
{
+ size_t out_avail;
+ size_t buf_avail;
+
// TODO: Add partial support for LZMA_SYNC_FLUSH. We can support it
// in cases when the filter is able to filter everything. With most
// simple filters it can be done at offset that is a multiple of 2,
@@ -105,9 +108,13 @@ simple_code(lzma_coder *coder, lzma_allocator *allocator,
// more data to out[] hopefully filling it completely. Then filter
// the data in out[]. This step is where most of the data gets
// filtered if the buffer sizes used by the application are reasonable.
- const size_t out_avail = out_size - *out_pos;
- const size_t buf_avail = coder->size - coder->pos;
+ out_avail = out_size - *out_pos;
+ buf_avail = coder->size - coder->pos;
if (out_avail > buf_avail || buf_avail == 0) {
+ size_t size;
+ size_t filtered;
+ size_t unfiltered;
+
// Store the old position so that we know from which byte
// to start filtering.
const size_t out_start = *out_pos;
@@ -130,11 +137,10 @@ simple_code(lzma_coder *coder, lzma_allocator *allocator,
}
// Filter out[].
- const size_t size = *out_pos - out_start;
- const size_t filtered = call_filter(
- coder, out + out_start, size);
+ size = *out_pos - out_start;
+ filtered = call_filter(coder, out + out_start, size);
- const size_t unfiltered = size - filtered;
+ unfiltered = size - filtered;
assert(unfiltered <= coder->allocated / 2);
// Now we can update coder->pos and coder->size, because
diff --git a/Utilities/cmliblzma/liblzma/simple/simple_decoder.c b/Utilities/cmliblzma/liblzma/simple/simple_decoder.c
index 0beccd3..034e158 100644
--- a/Utilities/cmliblzma/liblzma/simple/simple_decoder.c
+++ b/Utilities/cmliblzma/liblzma/simple/simple_decoder.c
@@ -17,14 +17,15 @@ extern lzma_ret
lzma_simple_props_decode(void **options, lzma_allocator *allocator,
const uint8_t *props, size_t props_size)
{
+ lzma_options_bcj *opt;
+
if (props_size == 0)
return LZMA_OK;
if (props_size != 4)
return LZMA_OPTIONS_ERROR;
- lzma_options_bcj *opt = lzma_alloc(
- sizeof(lzma_options_bcj), allocator);
+ opt = lzma_alloc(sizeof(lzma_options_bcj), allocator);
if (opt == NULL)
return LZMA_MEM_ERROR;
diff --git a/Utilities/cmliblzma/liblzma/simple/sparc.c b/Utilities/cmliblzma/liblzma/simple/sparc.c
index 8270d6a..0ddd2ac 100644
--- a/Utilities/cmliblzma/liblzma/simple/sparc.c
+++ b/Utilities/cmliblzma/liblzma/simple/sparc.c
@@ -26,6 +26,8 @@ sparc_code(lzma_simple *simple lzma_attribute((__unused__)),
|| (buffer[i] == 0x7F
&& (buffer[i + 1] & 0xC0) == 0xC0)) {
+ uint32_t dest;
+
uint32_t src = ((uint32_t)buffer[i + 0] << 24)
| ((uint32_t)buffer[i + 1] << 16)
| ((uint32_t)buffer[i + 2] << 8)
@@ -33,7 +35,6 @@ sparc_code(lzma_simple *simple lzma_attribute((__unused__)),
src <<= 2;
- uint32_t dest;
if (is_encoder)
dest = now_pos + (uint32_t)(i) + src;
else
diff --git a/Utilities/cmliblzma/liblzma/simple/x86.c b/Utilities/cmliblzma/liblzma/simple/x86.c
index 5d1509b..101d8ed 100644
--- a/Utilities/cmliblzma/liblzma/simple/x86.c
+++ b/Utilities/cmliblzma/liblzma/simple/x86.c
@@ -36,30 +36,36 @@ x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
uint32_t prev_mask = simple->prev_mask;
uint32_t prev_pos = simple->prev_pos;
+ size_t limit;
+ size_t buffer_pos;
+
if (size < 5)
return 0;
if (now_pos - prev_pos > 5)
prev_pos = now_pos - 5;
- const size_t limit = size - 5;
- size_t buffer_pos = 0;
+ limit = size - 5;
+ buffer_pos = 0;
while (buffer_pos <= limit) {
+ uint32_t offset;
+ uint32_t i;
+
uint8_t b = buffer[buffer_pos];
if (b != 0xE8 && b != 0xE9) {
++buffer_pos;
continue;
}
- const uint32_t offset = now_pos + (uint32_t)(buffer_pos)
+ offset = now_pos + (uint32_t)(buffer_pos)
- prev_pos;
prev_pos = now_pos + (uint32_t)(buffer_pos);
if (offset > 5) {
prev_mask = 0;
} else {
- for (uint32_t i = 0; i < offset; ++i) {
+ for (i = 0; i < offset; ++i) {
prev_mask &= 0x77;
prev_mask <<= 1;
}
@@ -78,6 +84,8 @@ x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
uint32_t dest;
while (true) {
+ uint32_t i;
+
if (is_encoder)
dest = src + (now_pos + (uint32_t)(
buffer_pos) + 5);
@@ -88,8 +96,7 @@ x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
if (prev_mask == 0)
break;
- const uint32_t i = MASK_TO_BIT_NUMBER[
- prev_mask >> 1];
+ i = MASK_TO_BIT_NUMBER[prev_mask >> 1];
b = (uint8_t)(dest >> (24 - i * 8));