liblzma: Prevent uninitialzed warning in mt stream encoder.
[xz/debian.git] / src / liblzma / lzma / fastpos_tablegen.c
blobd4484c82d0b51fd8911a5eb639ef242af5da92dd
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file fastpos_tablegen.c
4 /// \brief Generates the lzma_fastpos[] lookup table
5 ///
6 // Authors: Igor Pavlov
7 // Lasse Collin
8 //
9 // This file has been put into the public domain.
10 // You can do whatever you want with this file.
12 ///////////////////////////////////////////////////////////////////////////////
14 #include <inttypes.h>
15 #include <stdio.h>
16 #include "fastpos.h"
19 int
20 main(void)
22 uint8_t fastpos[1 << FASTPOS_BITS];
24 const uint8_t fast_slots = 2 * FASTPOS_BITS;
25 uint32_t c = 2;
27 fastpos[0] = 0;
28 fastpos[1] = 1;
30 for (uint8_t slot_fast = 2; slot_fast < fast_slots; ++slot_fast) {
31 const uint32_t k = 1 << ((slot_fast >> 1) - 1);
32 for (uint32_t j = 0; j < k; ++j, ++c)
33 fastpos[c] = slot_fast;
36 printf("/* This file has been automatically generated "
37 "by fastpos_tablegen.c. */\n\n"
38 "#include \"common.h\"\n"
39 "#include \"fastpos.h\"\n\n"
40 "const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = {");
42 for (size_t i = 0; i < (1 << FASTPOS_BITS); ++i) {
43 if (i % 16 == 0)
44 printf("\n\t");
46 printf("%3u", (unsigned int)(fastpos[i]));
48 if (i != (1 << FASTPOS_BITS) - 1)
49 printf(",");
52 printf("\n};\n");
54 return 0;