Moved var declarations out of for-loops. Makes pre-C99 compilers happier.
authorRyan C. Gordon <icculus@icculus.org>
Tue, 16 Nov 2010 06:06:28 +0000 (01:06 -0500)
committerRyan C. Gordon <icculus@icculus.org>
Tue, 16 Nov 2010 06:06:28 +0000 (01:06 -0500)
21 files changed:
src/liblzma/check/sha256.c
src/liblzma/common/block_buffer_encoder.c
src/liblzma/common/block_header_decoder.c
src/liblzma/common/block_header_encoder.c
src/liblzma/common/filter_common.c
src/liblzma/common/filter_decoder.c
src/liblzma/common/filter_encoder.c
src/liblzma/common/stream_decoder.c
src/liblzma/common/stream_encoder.c
src/liblzma/delta/delta_decoder.c
src/liblzma/delta/delta_encoder.c
src/liblzma/lz/lz_encoder_mf.c
src/liblzma/lzma/lzma_common.h
src/liblzma/lzma/lzma_decoder.c
src/liblzma/lzma/lzma_encoder.c
src/liblzma/lzma/lzma_encoder_optimum_fast.c
src/liblzma/lzma/lzma_encoder_optimum_normal.c
src/liblzma/rangecoder/range_common.h
src/liblzma/rangecoder/range_encoder.h
src/liblzma/simple/ia64.c
src/liblzma/simple/x86.c

index 04231db..7c09c12 100644 (file)
@@ -90,7 +90,8 @@ transform(uint32_t state[static 8], const uint32_t data[static 16])
        memcpy(T, state, sizeof(T));
 
        // 64 operations, partially loop unrolled
-       for (unsigned int j = 0; j < 64; j += 16) {
+       unsigned int j;
+       for (j = 0; j < 64; j += 16) {
                R( 0); R( 1); R( 2); R( 3);
                R( 4); R( 5); R( 6); R( 7);
                R( 8); R( 9); R(10); R(11);
@@ -117,8 +118,9 @@ process(lzma_check_state *check)
 
 #else
        uint32_t data[16];
+       size_t i;
 
-       for (size_t i = 0; i < 16; ++i)
+       for (i = 0; i < 16; ++i)
                data[i] = bswap32(check->buffer.u32[i]);
 
        transform(check->state.sha256.state, data);
@@ -194,7 +196,8 @@ lzma_sha256_finish(lzma_check_state *check)
 
        process(check);
 
-       for (size_t i = 0; i < 8; ++i)
+       size_t i;
+       for (i = 0; i < 8; ++i)
                check->buffer.u32[i] = conv32be(check->state.sha256.state[i]);
 
        return;
index a8f71c2..7b2639b 100644 (file)
@@ -275,7 +275,8 @@ lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
        // Block Padding. No buffer overflow here, because we already adjusted
        // out_size so that (out_size - out_start) is a multiple of four.
        // Thus, if the buffer is full, the loop body can never run.
-       for (size_t i = (size_t)(block->compressed_size); i & 3; ++i) {
+       size_t i;
+       for (i = (size_t)(block->compressed_size); i & 3; ++i) {
                assert(*out_pos < out_size);
                out[(*out_pos)++] = 0x00;
        }
index 2c9573e..9cd6fc0 100644 (file)
@@ -20,7 +20,8 @@ free_properties(lzma_block *block, lzma_allocator *allocator)
        // Free allocated filter options. The last array member is not
        // touched after the initialization in the beginning of
        // lzma_block_header_decode(), so we don't need to touch that here.
-       for (size_t i = 0; i < LZMA_FILTERS_MAX; ++i) {
+       size_t i;
+       for (i = 0; i < LZMA_FILTERS_MAX; ++i) {
                lzma_free(block->filters[i].options, allocator);
                block->filters[i].id = LZMA_VLI_UNKNOWN;
                block->filters[i].options = NULL;
@@ -41,7 +42,8 @@ lzma_block_header_decode(lzma_block *block,
 
        // Initialize the filter options array. This way the caller can
        // safely free() the options even if an error occurs in this function.
-       for (size_t i = 0; i <= LZMA_FILTERS_MAX; ++i) {
+       size_t i;
+       for (i = 0; i <= LZMA_FILTERS_MAX; ++i) {
                block->filters[i].id = LZMA_VLI_UNKNOWN;
                block->filters[i].options = NULL;
        }
@@ -91,7 +93,7 @@ lzma_block_header_decode(lzma_block *block,
 
        // Filter Flags
        const size_t filter_count = (in[1] & 3) + 1;
-       for (size_t i = 0; i < filter_count; ++i) {
+       for (i = 0; i < filter_count; ++i) {
                const lzma_ret ret = lzma_filter_flags_decode(
                                &block->filters[i], allocator,
                                in, &in_pos, in_size);
index 707dd0c..c20c981 100644 (file)
@@ -45,7 +45,8 @@ lzma_block_header_size(lzma_block *block)
        if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN)
                return LZMA_PROG_ERROR;
 
-       for (size_t i = 0; block->filters[i].id != LZMA_VLI_UNKNOWN; ++i) {
+       size_t i;
+       for (i = 0; block->filters[i].id != LZMA_VLI_UNKNOWN; ++i) {
                // Don't allow too many filters.
                if (i == LZMA_FILTERS_MAX)
                        return LZMA_PROG_ERROR;
index b157c62..10df53c 100644 (file)
@@ -249,8 +249,9 @@ lzma_raw_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
 
        // Set the filter functions and copy the options pointer.
        lzma_filter_info filters[LZMA_FILTERS_MAX + 1];
+       size_t i;
        if (is_encoder) {
-               for (size_t i = 0; i < count; ++i) {
+               for (i = 0; i < count; ++i) {
                        // The order of the filters is reversed in the
                        // encoder. It allows more efficient handling
                        // of the uncompressed data.
@@ -266,7 +267,7 @@ lzma_raw_coder_init(lzma_next_coder *next, lzma_allocator *allocator,
                        filters[j].options = options[i].options;
                }
        } else {
-               for (size_t i = 0; i < count; ++i) {
+               for (i = 0; i < count; ++i) {
                        const lzma_filter_coder *const fc
                                        = coder_find(options[i].id);
                        if (fc == NULL || fc->init == NULL)
index 1ebbe2a..6e312d1 100644 (file)
@@ -120,7 +120,8 @@ static const lzma_filter_decoder decoders[] = {
 static const lzma_filter_decoder *
 decoder_find(lzma_vli id)
 {
-       for (size_t i = 0; i < ARRAY_SIZE(decoders); ++i)
+       size_t i;
+       for (i = 0; i < ARRAY_SIZE(decoders); ++i)
                if (decoders[i].id == id)
                        return decoders + i;
 
index 635d812..7fa5bef 100644 (file)
@@ -153,7 +153,8 @@ static const lzma_filter_encoder encoders[] = {
 static const lzma_filter_encoder *
 encoder_find(lzma_vli id)
 {
-       for (size_t i = 0; i < ARRAY_SIZE(encoders); ++i)
+       size_t i;
+       for (i = 0; i < ARRAY_SIZE(encoders); ++i)
                if (encoders[i].id == id)
                        return encoders + i;
 
@@ -185,7 +186,8 @@ lzma_filters_update(lzma_stream *strm, const lzma_filter *filters)
                ++count;
 
        lzma_filter reversed_filters[LZMA_FILTERS_MAX + 1];
-       for (size_t i = 0; i < count; ++i)
+       size_t i;
+       for (i = 0; i < count; ++i)
                reversed_filters[count - i - 1] = filters[i];
 
        reversed_filters[count].id = LZMA_VLI_UNKNOWN;
index 37ea71e..4aec56a 100644 (file)
@@ -224,7 +224,8 @@ 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)
+               size_t i;
+               for (i = 0; i < LZMA_FILTERS_MAX; ++i)
                        lzma_free(filters[i].options, allocator);
 
                coder->block_options.filters = NULL;
index 48d91da..e7b32c3 100644 (file)
@@ -215,7 +215,8 @@ stream_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
        lzma_next_end(&coder->index_encoder, allocator);
        lzma_index_end(coder->index, allocator);
 
-       for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
+       size_t i;
+       for (i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
                lzma_free(coder->filters[i].options, allocator);
 
        lzma_free(coder, allocator);
@@ -255,7 +256,8 @@ stream_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
        }
 
        // Free the copy of the old chain and make a copy of the new chain.
-       for (size_t i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
+       size_t i;
+       for (i = 0; coder->filters[i].id != LZMA_VLI_UNKNOWN; ++i)
                lzma_free(coder->filters[i].options, allocator);
 
        return lzma_filters_copy(filters, coder->filters, allocator);
index 2cf60d5..bcb6447 100644 (file)
@@ -18,8 +18,9 @@ static void
 decode_buffer(lzma_coder *coder, uint8_t *buffer, size_t size)
 {
        const size_t distance = coder->distance;
+       size_t i;
 
-       for (size_t i = 0; i < size; ++i) {
+       for (i = 0; i < size; ++i) {
                buffer[i] += coder->history[(distance + coder->pos) & 0xFF];
                coder->history[coder->pos-- & 0xFF] = buffer[i];
        }
index ea1cc2c..99b1922 100644 (file)
@@ -22,8 +22,9 @@ copy_and_encode(lzma_coder *coder,
                const uint8_t *restrict in, uint8_t *restrict out, size_t size)
 {
        const size_t distance = coder->distance;
+       size_t i;
 
-       for (size_t i = 0; i < size; ++i) {
+       for (i = 0; i < size; ++i) {
                const uint8_t tmp = coder->history[
                                (distance + coder->pos) & 0xFF];
                coder->history[coder->pos-- & 0xFF] = in[i];
@@ -38,8 +39,9 @@ static void
 encode_in_place(lzma_coder *coder, uint8_t *buffer, size_t size)
 {
        const size_t distance = coder->distance;
+       size_t i;
 
-       for (size_t i = 0; i < size; ++i) {
+       for (i = 0; i < size; ++i) {
                const uint8_t tmp = coder->history[
                                (distance + coder->pos) & 0xFF];
                coder->history[coder->pos-- & 0xFF] = buffer[i];
index f82a1c1..addb5c9 100644 (file)
@@ -118,8 +118,9 @@ normalize(lzma_mf *mf)
 
        const uint32_t count = mf->hash_size_sum + mf->sons_count;
        uint32_t *hash = mf->hash;
+       uint32_t i;
 
-       for (uint32_t i = 0; i < count; ++i) {
+       for (i = 0; i < count; ++i) {
                // If the distance is greater than the dictionary size,
                // we can simply mark the hash element as empty.
                //
index 09efd38..d9f51e5 100644 (file)
@@ -132,9 +132,10 @@ literal_init(probability (*probs)[LITERAL_CODER_SIZE],
        assert(lc + lp <= LZMA_LCLP_MAX);
 
        const uint32_t coders = 1U << (lc + lp);
+       uint32_t i, j;
 
-       for (uint32_t i = 0; i < coders; ++i)
-               for (uint32_t j = 0; j < LITERAL_CODER_SIZE; ++j)
+       for (i = 0; i < coders; ++i)
+               for (j = 0; j < LITERAL_CODER_SIZE; ++j)
                        bit_reset(probs[i][j]);
 
        return;
index d61b7de..4d5770e 100644 (file)
@@ -854,6 +854,7 @@ static void
 lzma_decoder_reset(lzma_coder *coder, const void *opt)
 {
        const lzma_options_lzma *options = opt;
+       uint32_t i, j, pos_state;
 
        // NOTE: We assume that lc/lp/pb are valid since they were
        // successfully decoded with lzma_lzma_decode_properties().
@@ -879,8 +880,8 @@ lzma_decoder_reset(lzma_coder *coder, const void *opt)
        rc_reset(coder->rc);
 
        // Bit and bittree decoders
-       for (uint32_t i = 0; i < STATES; ++i) {
-               for (uint32_t j = 0; j <= coder->pos_mask; ++j) {
+       for (i = 0; i < STATES; ++i) {
+               for (j = 0; j <= coder->pos_mask; ++j) {
                        bit_reset(coder->is_match[i][j]);
                        bit_reset(coder->is_rep0_long[i][j]);
                }
@@ -891,10 +892,10 @@ lzma_decoder_reset(lzma_coder *coder, const void *opt)
                bit_reset(coder->is_rep2[i]);
        }
 
-       for (uint32_t i = 0; i < DIST_STATES; ++i)
+       for (i = 0; i < DIST_STATES; ++i)
                bittree_reset(coder->dist_slot[i], DIST_SLOT_BITS);
 
-       for (uint32_t i = 0; i < FULL_DISTANCES - DIST_MODEL_END; ++i)
+       for (i = 0; i < FULL_DISTANCES - DIST_MODEL_END; ++i)
                bit_reset(coder->pos_special[i]);
 
        bittree_reset(coder->pos_align, ALIGN_BITS);
@@ -906,7 +907,7 @@ lzma_decoder_reset(lzma_coder *coder, const void *opt)
        bit_reset(coder->rep_len_decoder.choice);
        bit_reset(coder->rep_len_decoder.choice2);
 
-       for (uint32_t pos_state = 0; pos_state < num_pos_states; ++pos_state) {
+       for (pos_state = 0; pos_state < num_pos_states; ++pos_state) {
                bittree_reset(coder->match_len_decoder.low[pos_state],
                                LEN_LOW_BITS);
                bittree_reset(coder->match_len_decoder.mid[pos_state],
index 0f91653..7d84dcb 100644 (file)
@@ -456,7 +456,8 @@ length_encoder_reset(lzma_length_encoder *lencoder,
        bit_reset(lencoder->choice);
        bit_reset(lencoder->choice2);
 
-       for (size_t pos_state = 0; pos_state < num_pos_states; ++pos_state) {
+       size_t pos_state;
+       for (pos_state = 0; pos_state < num_pos_states; ++pos_state) {
                bittree_reset(lencoder->low[pos_state], LEN_LOW_BITS);
                bittree_reset(lencoder->mid[pos_state], LEN_MID_BITS);
        }
@@ -464,7 +465,7 @@ length_encoder_reset(lzma_length_encoder *lencoder,
        bittree_reset(lencoder->high, LEN_HIGH_BITS);
 
        if (!fast_mode)
-               for (size_t pos_state = 0; pos_state < num_pos_states;
+               for (pos_state = 0; pos_state < num_pos_states;
                                ++pos_state)
                        length_update_prices(lencoder, pos_state);
 
@@ -487,14 +488,15 @@ lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options)
 
        // State
        coder->state = STATE_LIT_LIT;
-       for (size_t i = 0; i < REPS; ++i)
+       size_t i, j;
+       for (i = 0; i < REPS; ++i)
                coder->reps[i] = 0;
 
        literal_init(coder->literal, options->lc, options->lp);
 
        // Bit encoders
-       for (size_t i = 0; i < STATES; ++i) {
-               for (size_t j = 0; j <= coder->pos_mask; ++j) {
+       for (i = 0; i < STATES; ++i) {
+               for (j = 0; j <= coder->pos_mask; ++j) {
                        bit_reset(coder->is_match[i][j]);
                        bit_reset(coder->is_rep0_long[i][j]);
                }
@@ -505,11 +507,11 @@ lzma_lzma_encoder_reset(lzma_coder *coder, const lzma_options_lzma *options)
                bit_reset(coder->is_rep2[i]);
        }
 
-       for (size_t i = 0; i < FULL_DISTANCES - DIST_MODEL_END; ++i)
+       for (i = 0; i < FULL_DISTANCES - DIST_MODEL_END; ++i)
                bit_reset(coder->dist_special[i]);
 
        // Bit tree encoders
-       for (size_t i = 0; i < DIST_STATES; ++i)
+       for (i = 0; i < DIST_STATES; ++i)
                bittree_reset(coder->dist_slot[i], DIST_SLOT_BITS);
 
        bittree_reset(coder->dist_align, ALIGN_BITS);
index 92bbdf7..843036a 100644 (file)
@@ -45,8 +45,9 @@ lzma_lzma_optimum_fast(lzma_coder *restrict coder, lzma_mf *restrict mf,
        // Look for repeated matches; scan the previous four match distances
        uint32_t rep_len = 0;
        uint32_t rep_index = 0;
+       uint32_t i;
 
-       for (uint32_t i = 0; i < REPS; ++i) {
+       for (i = 0; i < REPS; ++i) {
                // Pointer to the beginning of the match candidate
                const uint8_t *const buf_back = buf - coder->reps[i] - 1;
 
@@ -154,7 +155,7 @@ lzma_lzma_optimum_fast(lzma_coder *restrict coder, lzma_mf *restrict mf,
 
        const uint32_t limit = len_main - 1;
 
-       for (uint32_t i = 0; i < REPS; ++i) {
+       for (i = 0; i < REPS; ++i) {
                const uint8_t *const buf_back = buf - coder->reps[i] - 1;
 
                if (not_equal_16(buf, buf_back))
index 0dd5f73..5521a4d 100644 (file)
@@ -131,13 +131,15 @@ get_dist_len_price(const lzma_coder *const coder, const uint32_t dist,
 static void
 fill_dist_prices(lzma_coder *coder)
 {
-       for (uint32_t dist_state = 0; dist_state < DIST_STATES; ++dist_state) {
+       uint32_t dist_state, i;
+       for (dist_state = 0; dist_state < DIST_STATES; ++dist_state) {
 
                uint32_t *const dist_slot_prices
                                = coder->dist_slot_prices[dist_state];
 
                // Price to encode the dist_slot.
-               for (uint32_t dist_slot = 0;
+               uint32_t dist_slot;
+               for (dist_slot = 0;
                                dist_slot < coder->dist_table_size; ++dist_slot)
                        dist_slot_prices[dist_slot] = rc_bittree_price(
                                        coder->dist_slot[dist_state],
@@ -146,7 +148,7 @@ fill_dist_prices(lzma_coder *coder)
                // For matches with distance >= FULL_DISTANCES, add the price
                // of the direct bits part of the match distance. (Align bits
                // are handled by fill_align_prices()).
-               for (uint32_t dist_slot = DIST_MODEL_END;
+               for (dist_slot = DIST_MODEL_END;
                                dist_slot < coder->dist_table_size;
                                ++dist_slot)
                        dist_slot_prices[dist_slot] += rc_direct_price(
@@ -155,7 +157,7 @@ fill_dist_prices(lzma_coder *coder)
                // Distances in the range [0, 3] are fully encoded with
                // dist_slot, so they are used for coder->dist_prices
                // as is.
-               for (uint32_t i = 0; i < DIST_MODEL_START; ++i)
+               for (i = 0; i < DIST_MODEL_START; ++i)
                        coder->dist_prices[dist_state][i]
                                        = dist_slot_prices[i];
        }
@@ -163,7 +165,7 @@ fill_dist_prices(lzma_coder *coder)
        // Distances in the range [4, 127] depend on dist_slot and
        // dist_special. We do this in a loop separate from the above
        // loop to avoid redundant calls to get_dist_slot().
-       for (uint32_t i = DIST_MODEL_START; i < FULL_DISTANCES; ++i) {
+       for (i = DIST_MODEL_START; i < FULL_DISTANCES; ++i) {
                const uint32_t dist_slot = get_dist_slot(i);
                const uint32_t footer_bits = ((dist_slot >> 1) - 1);
                const uint32_t base = (2 | (dist_slot & 1)) << footer_bits;
@@ -171,7 +173,7 @@ fill_dist_prices(lzma_coder *coder)
                                coder->dist_special + base - dist_slot - 1,
                                footer_bits, i - base);
 
-               for (uint32_t dist_state = 0; dist_state < DIST_STATES;
+               for (dist_state = 0; dist_state < DIST_STATES;
                                ++dist_state)
                        coder->dist_prices[dist_state][i]
                                        = price + coder->dist_slot_prices[
@@ -186,7 +188,8 @@ fill_dist_prices(lzma_coder *coder)
 static void
 fill_align_prices(lzma_coder *coder)
 {
-       for (uint32_t i = 0; i < ALIGN_SIZE; ++i)
+       uint32_t i;
+       for (i = 0; i < ALIGN_SIZE; ++i)
                coder->align_prices[i] = rc_bittree_reverse_price(
                                coder->dist_align, ALIGN_BITS, i);
 
@@ -296,8 +299,9 @@ helper1(lzma_coder *restrict coder, lzma_mf *restrict mf,
 
        uint32_t rep_lens[REPS];
        uint32_t rep_max_index = 0;
+       uint32_t i;
 
-       for (uint32_t i = 0; i < REPS; ++i) {
+       for (i = 0; i < REPS; ++i) {
                const uint8_t *const buf_back = buf - coder->reps[i] - 1;
 
                if (not_equal_16(buf, buf_back)) {
@@ -378,7 +382,7 @@ helper1(lzma_coder *restrict coder, lzma_mf *restrict mf,
 
        coder->opts[1].pos_prev = 0;
 
-       for (uint32_t i = 0; i < REPS; ++i)
+       for (i = 0; i < REPS; ++i)
                coder->opts[0].backs[i] = coder->reps[i];
 
        uint32_t len = len_end;
@@ -387,7 +391,7 @@ helper1(lzma_coder *restrict coder, lzma_mf *restrict mf,
        } while (--len >= 2);
 
 
-       for (uint32_t i = 0; i < REPS; ++i) {
+       for (i = 0; i < REPS; ++i) {
                uint32_t rep_len = rep_lens[i];
                if (rep_len < 2)
                        continue;
@@ -416,7 +420,7 @@ helper1(lzma_coder *restrict coder, lzma_mf *restrict mf,
 
        len = rep_lens[0] >= 2 ? rep_lens[0] + 1 : 2;
        if (len <= len_main) {
-               uint32_t i = 0;
+               i = 0;
                while (len > coder->matches[i].len)
                        ++i;
 
@@ -452,6 +456,7 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
        uint32_t new_len = coder->longest_match_length;
        uint32_t pos_prev = coder->opts[cur].pos_prev;
        lzma_lzma_state state;
+       uint32_t i;
 
        if (coder->opts[cur].prev_1_is_literal) {
                --pos_prev;
@@ -497,7 +502,6 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
                if (pos < REPS) {
                        reps[0] = coder->opts[pos_prev].backs[pos];
 
-                       uint32_t i;
                        for (i = 1; i <= pos; ++i)
                                reps[i] = coder->opts[pos_prev].backs[i - 1];
 
@@ -507,14 +511,14 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
                } else {
                        reps[0] = pos - REPS;
 
-                       for (uint32_t i = 1; i < REPS; ++i)
+                       for (i = 1; i < REPS; ++i)
                                reps[i] = coder->opts[pos_prev].backs[i - 1];
                }
        }
 
        coder->opts[cur].state = state;
 
-       for (uint32_t i = 0; i < REPS; ++i)
+       for (i = 0; i < REPS; ++i)
                coder->opts[cur].backs[i] = reps[i];
 
        const uint32_t cur_price = coder->opts[cur].price;
@@ -606,8 +610,9 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
 
 
        uint32_t start_len = 2; // speed optimization
+       uint32_t rep_index;
 
-       for (uint32_t rep_index = 0; rep_index < REPS; ++rep_index) {
+       for (rep_index = 0; rep_index < REPS; ++rep_index) {
                const uint8_t *const buf_back = buf - reps[rep_index] - 1;
                if (not_equal_16(buf, buf_back))
                        continue;
@@ -717,11 +722,12 @@ helper2(lzma_coder *coder, uint32_t *reps, const uint8_t *buf,
                while (len_end < cur + new_len)
                        coder->opts[++len_end].price = RC_INFINITY_PRICE;
 
-               uint32_t i = 0;
+               i = 0;
                while (start_len > coder->matches[i].len)
                        ++i;
 
-               for (uint32_t len_test = start_len; ; ++len_test) {
+               uint32_t len_test;
+               for (len_test = start_len; ; ++len_test) {
                        const uint32_t cur_back = coder->matches[i].dist;
                        uint32_t cur_and_len_price = normal_match_price
                                        + get_dist_len_price(coder,
index 0e64241..c910ba8 100644 (file)
 // This does the same for a complete bit tree.
 // (A tree represented as an array.)
 #define bittree_reset(probs, bit_levels) \
-       for (uint32_t bt_i = 0; bt_i < (1 << (bit_levels)); ++bt_i) \
-               bit_reset((probs)[bt_i])
+       do { \
+               uint32_t bt_i; \
+               for (bt_i = 0; bt_i < (1 << (bit_levels)); ++bt_i) \
+                       bit_reset((probs)[bt_i]); \
+       } while (0)
 
 
 //////////////////////
index 1e1c369..e9614f2 100644 (file)
@@ -115,7 +115,8 @@ rc_direct(lzma_range_encoder *rc,
 static inline void
 rc_flush(lzma_range_encoder *rc)
 {
-       for (size_t i = 0; i < 5; ++i)
+       size_t i;
+       for (i = 0; i < 5; ++i)
                rc->symbols[rc->count++] = RC_FLUSH;
 }
 
index fd263d4..5125d80 100644 (file)
@@ -31,16 +31,18 @@ ia64_code(lzma_simple *simple lzma_attribute((unused)),
                const uint32_t instr_template = buffer[i] & 0x1F;
                const uint32_t mask = BRANCH_TABLE[instr_template];
                uint32_t bit_pos = 5;
+               size_t slot;
 
-               for (size_t slot = 0; slot < 3; ++slot, bit_pos += 41) {
+               for (slot = 0; slot < 3; ++slot, bit_pos += 41) {
                        if (((mask >> slot) & 1) == 0)
                                continue;
 
                        const size_t byte_pos = (bit_pos >> 3);
                        const uint32_t bit_res = bit_pos & 0x7;
                        uint64_t instruction = 0;
+                       size_t j;
 
-                       for (size_t j = 0; j < 6; ++j)
+                       for (j = 0; j < 6; ++j)
                                instruction += (uint64_t)(
                                                buffer[i + j + byte_pos])
                                                << (8 * j);
@@ -73,7 +75,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));
index 5d1509b..54639c6 100644 (file)
@@ -59,7 +59,8 @@ x86_code(lzma_simple *simple, uint32_t now_pos, bool is_encoder,
                if (offset > 5) {
                        prev_mask = 0;
                } else {
-                       for (uint32_t i = 0; i < offset; ++i) {
+                       uint32_t i;
+                       for (i = 0; i < offset; ++i) {
                                prev_mask &= 0x77;
                                prev_mask <<= 1;
                        }