]> icculus.org git repositories - icculus/xz.git/blob - src/liblzma/rangecoder/price_table_gen.c
Omit invalid space from printf() format string
[icculus/xz.git] / src / liblzma / rangecoder / price_table_gen.c
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 /// \file       price_table_gen.c
4 /// \brief      Probability price table generator
5 ///
6 /// Compiling: gcc -std=c99 -o price_table_gen price_table_gen.c
7 //
8 //  Copyright (C) 2007 Lasse Collin
9 //
10 //  This library is free software; you can redistribute it and/or
11 //  modify it under the terms of the GNU Lesser General Public
12 //  License as published by the Free Software Foundation; either
13 //  version 2.1 of the License, or (at your option) any later version.
14 //
15 //  This library is distributed in the hope that it will be useful,
16 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 //  Lesser General Public License for more details.
19 //
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #include <sys/types.h>
23 #include <inttypes.h>
24 #include <stdio.h>
25 #include "range_common.h"
26 #include "price_table_init.c"
27
28
29 int
30 main(void)
31 {
32         lzma_rc_init();
33
34         printf("/* This file has been automatically generated by "
35                         "price_table_gen.c. */\n\n"
36                         "#include \"range_encoder.h\"\n\n"
37                         "const uint32_t lzma_rc_prob_prices["
38                         "BIT_MODEL_TOTAL >> MOVE_REDUCING_BITS] = {");
39
40         const size_t array_size = sizeof(lzma_rc_prob_prices)
41                         / sizeof(lzma_rc_prob_prices[0]);
42         for (size_t i = 0; i < array_size; ++i) {
43                 if (i % 8 == 0)
44                         printf("\n\t");
45
46                 printf("%4" PRIu32, lzma_rc_prob_prices[i]);
47
48                 if (i != array_size - 1)
49                         printf(",");
50         }
51
52         printf("\n};\n");
53
54         return 0;
55 }