Patch to compile xz-5.0.3 on gcc-2.95
$Keywords: compile xz utils, gcc-2.95, source patch, old gcc, ancient gcc, g++, lzma $
Source code of XZ Utils
heavily relies on newer C extensions, such as
C++ style comments, variable declaration in middle of a block,
labelled struct initializer, ++ on enum.
You can't even ./configure
on
ancient environment
such as NetBSD 1.6 (with bundled gcc-2.95.3).
The patch below made it successfully compile and
pass make check
with gcc-2.95.3 .
./configure
options
env ac_cv_prog_cc_c99= CPPFLAGS='-Drestrict=__restrict__ -Dlzma_nothrow=' \
CC=g++ CFLAGS="-fpermissive" \
./configure --prefix=/usr/local \
--mandir=/usr/local/man --docdir=/usr/local/doc/xz --disable-nls --enable-shared
Arcane options for configure
:
ac_cv_prog_cc_c99=
to skip C99 compiler detection (fails on missing stdbool.h)
-Drestrict=__restrict__
to use gcc extension
-Dlzma_nothrow=
to ignore exceptional exception throwing
g++
defaults to -pedantic-errors
, so use
-fpermissive
to make (void *)
assignable.
The hardest part was the disappearing lzma_crc64_table[][]
symbol,
which was caused by the compiler nicely optimizing out the
seems-to-be unreferenced table to nothing.
Fortunate was the gcc-2.95 was ready for copying struct
s
which xz code uses all over.
diff -ru -p xz-5.0.3/src/common/sysdefs.h xz-5.0.3-g2++/src/common/sysdefs.h
--- xz-5.0.3/src/common/sysdefs.h Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/common/sysdefs.h Fri Dec 12 14:00:56 2014
@@ -139,7 +139,7 @@
#ifdef HAVE_STDBOOL_H
# include
#else
-# if ! HAVE__BOOL
+# if ! defined(HAVE__BOOL) || ! HAVE__BOOL
typedef unsigned char _Bool;
# endif
# define bool _Bool
diff -ru -p xz-5.0.3/src/liblzma/check/crc32_table_be.h xz-5.0.3-g2++/src/liblzma/check/crc32_table_be.h
--- xz-5.0.3/src/liblzma/check/crc32_table_be.h Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/check/crc32_table_be.h Fri Dec 12 14:32:40 2014
@@ -1,6 +1,6 @@
/* This file has been automatically generated by crc32_tablegen.c. */
-const uint32_t lzma_crc32_table[8][256] = {
+extern const uint32_t lzma_crc32_table[8][256] = {
{
0x00000000, 0x96300777, 0x2C610EEE, 0xBA510999,
0x19C46D07, 0x8FF46A70, 0x35A563E9, 0xA395649E,
diff -ru -p xz-5.0.3/src/liblzma/check/crc32_table_le.h xz-5.0.3-g2++/src/liblzma/check/crc32_table_le.h
--- xz-5.0.3/src/liblzma/check/crc32_table_le.h Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/check/crc32_table_le.h Fri Dec 12 14:32:51 2014
@@ -1,6 +1,6 @@
/* This file has been automatically generated by crc32_tablegen.c. */
-const uint32_t lzma_crc32_table[8][256] = {
+extern const uint32_t lzma_crc32_table[8][256] = {
{
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
diff -ru -p xz-5.0.3/src/liblzma/check/crc32_tablegen.c xz-5.0.3-g2++/src/liblzma/check/crc32_tablegen.c
--- xz-5.0.3/src/liblzma/check/crc32_tablegen.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/check/crc32_tablegen.c Fri Dec 12 14:33:13 2014
@@ -56,7 +56,7 @@ print_crc32_table(void)
{
printf("/* This file has been automatically generated by "
"crc32_tablegen.c. */\n\n"
- "const uint32_t lzma_crc32_table[8][256] = {\n\t{");
+ "extern const uint32_t lzma_crc32_table[8][256] = {\n\t{");
for (size_t s = 0; s < 8; ++s) {
for (size_t b = 0; b < 256; ++b) {
diff -ru -p xz-5.0.3/src/liblzma/check/crc64_table_be.h xz-5.0.3-g2++/src/liblzma/check/crc64_table_be.h
--- xz-5.0.3/src/liblzma/check/crc64_table_be.h Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/check/crc64_table_be.h Fri Dec 12 14:31:19 2014
@@ -1,6 +1,6 @@
/* This file has been automatically generated by crc64_tablegen.c. */
-const uint64_t lzma_crc64_table[4][256] = {
+extern const uint64_t lzma_crc64_table[4][256] = {
{
UINT64_C(0x0000000000000000), UINT64_C(0x6F5FA703BE4C2EB3),
UINT64_C(0x5BA040A8573684F4), UINT64_C(0x34FFE7ABE97AAA47),
diff -ru -p xz-5.0.3/src/liblzma/check/crc64_table_le.h xz-5.0.3-g2++/src/liblzma/check/crc64_table_le.h
--- xz-5.0.3/src/liblzma/check/crc64_table_le.h Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/check/crc64_table_le.h Fri Dec 12 14:29:44 2014
@@ -1,6 +1,6 @@
/* This file has been automatically generated by crc64_tablegen.c. */
-const uint64_t lzma_crc64_table[4][256] = {
+extern const uint64_t lzma_crc64_table[4][256] = {
{
UINT64_C(0x0000000000000000), UINT64_C(0xB32E4CBE03A75F6F),
UINT64_C(0xF4843657A840A05B), UINT64_C(0x47AA7AE9ABE7FF34),
diff -ru -p xz-5.0.3/src/liblzma/check/crc64_tablegen.c xz-5.0.3-g2++/src/liblzma/check/crc64_tablegen.c
--- xz-5.0.3/src/liblzma/check/crc64_tablegen.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/check/crc64_tablegen.c Fri Dec 12 14:32:01 2014
@@ -55,7 +55,7 @@ print_crc64_table(void)
{
printf("/* This file has been automatically generated by "
"crc64_tablegen.c. */\n\n"
- "const uint64_t lzma_crc64_table[4][256] = {\n\t{");
+ "extern const uint64_t lzma_crc64_table[4][256] = {\n\t{");
for (size_t s = 0; s < 4; ++s) {
for (size_t b = 0; b < 256; ++b) {
diff -ru -p xz-5.0.3/src/liblzma/check/sha256.c xz-5.0.3-g2++/src/liblzma/check/sha256.c
--- xz-5.0.3/src/liblzma/check/sha256.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/check/sha256.c Thu Oct 4 01:58:21 2012
@@ -81,7 +81,7 @@ static const uint32_t SHA256_K[64] = {
static void
-transform(uint32_t state[static 8], const uint32_t data[static 16])
+transform(uint32_t state[8], const uint32_t data[16])
{
uint32_t W[16];
uint32_t T[8];
diff -ru -p xz-5.0.3/src/liblzma/common/alone_decoder.c xz-5.0.3-g2++/src/liblzma/common/alone_decoder.c
--- xz-5.0.3/src/liblzma/common/alone_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/alone_decoder.c Fri Dec 12 17:14:01 2014
@@ -15,16 +15,17 @@
#include "lz_decoder.h"
+enum lzma_coder_sequence_e {
+ SEQ_PROPERTIES,
+ SEQ_DICTIONARY_SIZE,
+ SEQ_UNCOMPRESSED_SIZE,
+ SEQ_CODER_INIT,
+ SEQ_CODE,
+};
struct lzma_coder_s {
lzma_next_coder next;
- enum {
- SEQ_PROPERTIES,
- SEQ_DICTIONARY_SIZE,
- SEQ_UNCOMPRESSED_SIZE,
- SEQ_CODER_INIT,
- SEQ_CODE,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
/// Position in the header fields
size_t pos;
@@ -124,14 +125,10 @@ alone_decode(lzma_coder *coder,
if (coder->memusage > coder->memlimit)
return LZMA_MEMLIMIT_ERROR;
- lzma_filter_info filters[2] = {
- {
- .init = &lzma_lzma_decoder_init,
- .options = &coder->options,
- }, {
- .init = NULL,
- }
- };
+ lzma_filter_info filters[2];
+ filters[0].init = &lzma_lzma_decoder_init;
+ filters[0].options = &coder->options;
+ filters[1].init = NULL;
const lzma_ret ret = lzma_next_filter_init(&coder->next,
allocator, filters);
@@ -197,7 +194,7 @@ lzma_alone_decoder_init(lzma_next_coder
return LZMA_PROG_ERROR;
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -223,7 +220,7 @@ lzma_alone_decoder_init(lzma_next_coder
extern LZMA_API(lzma_ret)
lzma_alone_decoder(lzma_stream *strm, uint64_t memlimit)
{
- lzma_next_strm_init(lzma_alone_decoder_init, strm, memlimit);
+ lzma_next_strm_init1(lzma_alone_decoder_init, strm, memlimit);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff -ru -p xz-5.0.3/src/liblzma/common/alone_encoder.c xz-5.0.3-g2++/src/liblzma/common/alone_encoder.c
--- xz-5.0.3/src/liblzma/common/alone_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/alone_encoder.c Thu Oct 4 00:23:38 2012
@@ -17,13 +17,14 @@
#define ALONE_HEADER_SIZE (1 + 4 + 8)
+enum lzma_coder_sequence_e {
+ SEQ_HEADER,
+ SEQ_CODE,
+};
struct lzma_coder_s {
lzma_next_coder next;
- enum {
- SEQ_HEADER,
- SEQ_CODE,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
size_t header_pos;
uint8_t header[ALONE_HEADER_SIZE];
@@ -81,7 +82,7 @@ alone_encoder_init(lzma_next_coder *next
lzma_next_coder_init(&alone_encoder_init, next, allocator);
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -124,10 +125,12 @@ alone_encoder_init(lzma_next_coder *next
// Initialize the LZMA encoder.
const lzma_filter_info filters[2] = {
{
- .init = &lzma_lzma_encoder_init,
- .options = (void *)(options),
+ /*.id =*/0,
+ /*.init =*/ (lzma_init_function)&lzma_lzma_encoder_init,
+ /*.options =*/ (void *)(options),
}, {
- .init = NULL,
+ /*.id =*/0,
+ /*.init =*/ NULL,
}
};
@@ -148,7 +151,7 @@ lzma_alone_encoder_init(lzma_next_coder
extern LZMA_API(lzma_ret)
lzma_alone_encoder(lzma_stream *strm, const lzma_options_lzma *options)
{
- lzma_next_strm_init(alone_encoder_init, strm, options);
+ lzma_next_strm_init1(alone_encoder_init, strm, options);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff -ru -p xz-5.0.3/src/liblzma/common/auto_decoder.c xz-5.0.3-g2++/src/liblzma/common/auto_decoder.c
--- xz-5.0.3/src/liblzma/common/auto_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/auto_decoder.c Thu Oct 4 01:29:29 2012
@@ -14,6 +14,11 @@
#include "alone_decoder.h"
+enum lzma_coder_sequence_e {
+ SEQ_INIT,
+ SEQ_CODE,
+ SEQ_FINISH,
+};
struct lzma_coder_s {
/// Stream decoder or LZMA_Alone decoder
lzma_next_coder next;
@@ -21,11 +26,7 @@ struct lzma_coder_s {
uint64_t memlimit;
uint32_t flags;
- enum {
- SEQ_INIT,
- SEQ_CODE,
- SEQ_FINISH,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
};
@@ -155,7 +156,7 @@ auto_decoder_init(lzma_next_coder *next,
return LZMA_OPTIONS_ERROR;
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -177,7 +178,7 @@ auto_decoder_init(lzma_next_coder *next,
extern LZMA_API(lzma_ret)
lzma_auto_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)
{
- lzma_next_strm_init(auto_decoder_init, strm, memlimit, flags);
+ lzma_next_strm_init2(auto_decoder_init, strm, memlimit, flags);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff -ru -p xz-5.0.3/src/liblzma/common/block_buffer_encoder.c xz-5.0.3-g2++/src/liblzma/common/block_buffer_encoder.c
--- xz-5.0.3/src/liblzma/common/block_buffer_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/block_buffer_encoder.c Thu Oct 4 00:26:47 2012
@@ -89,7 +89,7 @@ block_encode_uncompressed(lzma_block *bl
// all, but LZMA2 always requires a dictionary, so use the minimum
// value to minimize memory usage of the decoder.
lzma_options_lzma lzma2 = {
- .dict_size = LZMA_DICT_SIZE_MIN,
+ /*.dict_size =*/ LZMA_DICT_SIZE_MIN,
};
lzma_filter filters[2];
diff -ru -p xz-5.0.3/src/liblzma/common/block_decoder.c xz-5.0.3-g2++/src/liblzma/common/block_decoder.c
--- xz-5.0.3/src/liblzma/common/block_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/block_decoder.c Thu Oct 4 01:31:31 2012
@@ -15,12 +15,13 @@
#include "check.h"
+enum lzma_coder_sequence_e {
+ SEQ_CODE,
+ SEQ_PADDING,
+ SEQ_CHECK,
+};
struct lzma_coder_s {
- enum {
- SEQ_CODE,
- SEQ_PADDING,
- SEQ_CHECK,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
/// The filters in the chain; initialized with lzma_raw_decoder_init().
lzma_next_coder next;
@@ -193,7 +194,7 @@ lzma_block_decoder_init(lzma_next_coder
// Allocate and initialize *next->coder if needed.
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -233,7 +234,7 @@ lzma_block_decoder_init(lzma_next_coder
extern LZMA_API(lzma_ret)
lzma_block_decoder(lzma_stream *strm, lzma_block *block)
{
- lzma_next_strm_init(lzma_block_decoder_init, strm, block);
+ lzma_next_strm_init1(lzma_block_decoder_init, strm, block);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff -ru -p xz-5.0.3/src/liblzma/common/block_encoder.c xz-5.0.3-g2++/src/liblzma/common/block_encoder.c
--- xz-5.0.3/src/liblzma/common/block_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/block_encoder.c Thu Oct 4 00:29:47 2012
@@ -15,6 +15,11 @@
#include "check.h"
+enum lzma_coder_sequence_e {
+ SEQ_CODE,
+ SEQ_PADDING,
+ SEQ_CHECK,
+};
struct lzma_coder_s {
/// The filters in the chain; initialized with lzma_raw_decoder_init().
lzma_next_coder next;
@@ -24,11 +29,7 @@ struct lzma_coder_s {
/// has been finished.
lzma_block *block;
- enum {
- SEQ_CODE,
- SEQ_PADDING,
- SEQ_CHECK,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
/// Compressed Size calculated while encoding
lzma_vli compressed_size;
@@ -179,7 +180,7 @@ lzma_block_encoder_init(lzma_next_coder
// Allocate and initialize *next->coder if needed.
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -208,7 +209,7 @@ lzma_block_encoder_init(lzma_next_coder
extern LZMA_API(lzma_ret)
lzma_block_encoder(lzma_stream *strm, lzma_block *block)
{
- lzma_next_strm_init(lzma_block_encoder_init, strm, block);
+ lzma_next_strm_init1(lzma_block_encoder_init, strm, block);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff -ru -p xz-5.0.3/src/liblzma/common/common.c xz-5.0.3-g2++/src/liblzma/common/common.c
--- xz-5.0.3/src/liblzma/common/common.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/common.c Wed Oct 3 23:43:53 2012
@@ -86,6 +86,21 @@ lzma_bufcpy(const uint8_t *restrict in,
return copy_size;
}
+extern lzma_next_coder
+_lzma_next_coder_init_func()
+{
+ static const lzma_next_coder ret = {
+ /*.coder =*/ NULL,
+ /*.id =*/ LZMA_VLI_UNKNOWN,
+ /*.init =*/ (uintptr_t)(NULL),
+ /*.code =*/ NULL,
+ /*.end =*/ NULL,
+ /*.get_check =*/ NULL,
+ /*.memconfig =*/ NULL,
+ /*.update =*/ NULL,
+ };
+ return ret;
+}
extern lzma_ret
lzma_next_filter_init(lzma_next_coder *next, lzma_allocator *allocator,
@@ -148,7 +163,7 @@ lzma_strm_init(lzma_stream *strm)
return LZMA_PROG_ERROR;
if (strm->internal == NULL) {
- strm->internal = lzma_alloc(sizeof(lzma_internal),
+ strm->internal = (lzma_internal *)lzma_alloc(sizeof(lzma_internal),
strm->allocator);
if (strm->internal == NULL)
return LZMA_MEM_ERROR;
diff -ru -p xz-5.0.3/src/liblzma/common/common.h xz-5.0.3-g2++/src/liblzma/common/common.h
--- xz-5.0.3/src/liblzma/common/common.h Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/common.h Fri Dec 12 17:25:41 2014
@@ -36,7 +36,7 @@
// These allow helping the compiler in some often-executed branches, whose
// result is almost always the same.
-#ifdef __GNUC__
+#if __GNUC__ >= 3
# define likely(expr) __builtin_expect(expr, true)
# define unlikely(expr) __builtin_expect(expr, false)
#else
@@ -157,21 +157,22 @@ struct lzma_next_coder_s {
/// Macro to initialize lzma_next_coder structure
+/// converted to func for __GNUC__<3
#define LZMA_NEXT_CODER_INIT \
- (lzma_next_coder){ \
- .coder = NULL, \
- .init = (uintptr_t)(NULL), \
- .id = LZMA_VLI_UNKNOWN, \
- .code = NULL, \
- .end = NULL, \
- .get_check = NULL, \
- .memconfig = NULL, \
- .update = NULL, \
- }
+ _lzma_next_coder_init_func()
+extern lzma_next_coder _lzma_next_coder_init_func(void);
/// Internal data for lzma_strm_init, lzma_code, and lzma_end. A pointer to
/// this is stored in lzma_stream.
+enum lzma_internal_sequence_e {
+ ISEQ_RUN,
+ ISEQ_SYNC_FLUSH,
+ ISEQ_FULL_FLUSH,
+ ISEQ_FINISH,
+ ISEQ_END,
+ ISEQ_ERROR,
+};
struct lzma_internal_s {
/// The actual coder that should do something useful
lzma_next_coder next;
@@ -180,14 +181,7 @@ struct lzma_internal_s {
/// so that the actual coders can rely on e.g. that LZMA_SYNC_FLUSH
/// is used on every call to lzma_code until next.code has returned
/// LZMA_STREAM_END.
- enum {
- ISEQ_RUN,
- ISEQ_SYNC_FLUSH,
- ISEQ_FULL_FLUSH,
- ISEQ_FINISH,
- ISEQ_END,
- ISEQ_ERROR,
- } sequence;
+ enum lzma_internal_sequence_e sequence;
/// A copy of lzma_stream avail_in. This is used to verify that the
/// amount of input doesn't change once e.g. LZMA_FINISH has been
@@ -270,11 +264,31 @@ do { \
/// (The function being called will use lzma_next_coder_init()). If
/// initialization fails, memory that wasn't freed by func() is freed
/// along strm->internal.
-#define lzma_next_strm_init(func, strm, ...) \
+#define lzma_next_strm_init1(func, strm, p1) \
+do { \
+ return_if_error(lzma_strm_init(strm)); \
+ const lzma_ret ret_ = func(&(strm)->internal->next, \
+ (strm)->allocator, (p1)); \
+ if (ret_ != LZMA_OK) { \
+ lzma_end(strm); \
+ return ret_; \
+ } \
+} while (0)
+#define lzma_next_strm_init2(func, strm, p1,p2) \
+do { \
+ return_if_error(lzma_strm_init(strm)); \
+ const lzma_ret ret_ = func(&(strm)->internal->next, \
+ (strm)->allocator, (p1),(p2)); \
+ if (ret_ != LZMA_OK) { \
+ lzma_end(strm); \
+ return ret_; \
+ } \
+} while (0)
+#define lzma_next_strm_init3(func, strm, p1,p2,p3) \
do { \
return_if_error(lzma_strm_init(strm)); \
const lzma_ret ret_ = func(&(strm)->internal->next, \
- (strm)->allocator, __VA_ARGS__); \
+ (strm)->allocator, (p1),(p2),(p3)); \
if (ret_ != LZMA_OK) { \
lzma_end(strm); \
return ret_; \
diff -ru -p xz-5.0.3/src/liblzma/common/filter_common.c xz-5.0.3-g2++/src/liblzma/common/filter_common.c
--- xz-5.0.3/src/liblzma/common/filter_common.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/filter_common.c Wed Oct 3 23:55:11 2012
@@ -36,87 +36,87 @@ static const struct {
} features[] = {
#if defined (HAVE_ENCODER_LZMA1) || defined(HAVE_DECODER_LZMA1)
{
- .id = LZMA_FILTER_LZMA1,
- .options_size = sizeof(lzma_options_lzma),
- .non_last_ok = false,
- .last_ok = true,
- .changes_size = true,
+ /*.id =*/ LZMA_FILTER_LZMA1,
+ /*.options_size =*/ sizeof(lzma_options_lzma),
+ /*.non_last_ok =*/ false,
+ /*.last_ok =*/ true,
+ /*.changes_size =*/ true,
},
#endif
#if defined(HAVE_ENCODER_LZMA2) || defined(HAVE_DECODER_LZMA2)
{
- .id = LZMA_FILTER_LZMA2,
- .options_size = sizeof(lzma_options_lzma),
- .non_last_ok = false,
- .last_ok = true,
- .changes_size = true,
+ /*.id =*/ LZMA_FILTER_LZMA2,
+ /*.options_size =*/ sizeof(lzma_options_lzma),
+ /*.non_last_ok =*/ false,
+ /*.last_ok =*/ true,
+ /*.changes_size =*/ true,
},
#endif
#if defined(HAVE_ENCODER_X86) || defined(HAVE_DECODER_X86)
{
- .id = LZMA_FILTER_X86,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
+ /*.id =*/ LZMA_FILTER_X86,
+ /*.options_size =*/ sizeof(lzma_options_bcj),
+ /*.non_last_ok =*/ true,
+ /*.last_ok =*/ false,
+ /*.changes_size =*/ false,
},
#endif
#if defined(HAVE_ENCODER_POWERPC) || defined(HAVE_DECODER_POWERPC)
{
- .id = LZMA_FILTER_POWERPC,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
+ /*.id =*/ LZMA_FILTER_POWERPC,
+ /*.options_size =*/ sizeof(lzma_options_bcj),
+ /*.non_last_ok =*/ true,
+ /*.last_ok =*/ false,
+ /*.changes_size =*/ false,
},
#endif
#if defined(HAVE_ENCODER_IA64) || defined(HAVE_DECODER_IA64)
{
- .id = LZMA_FILTER_IA64,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
+ /*.id =*/ LZMA_FILTER_IA64,
+ /*.options_size =*/ sizeof(lzma_options_bcj),
+ /*.non_last_ok =*/ true,
+ /*.last_ok =*/ false,
+ /*.changes_size =*/ false,
},
#endif
#if defined(HAVE_ENCODER_ARM) || defined(HAVE_DECODER_ARM)
{
- .id = LZMA_FILTER_ARM,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
+ /*.id =*/ LZMA_FILTER_ARM,
+ /*.options_size =*/ sizeof(lzma_options_bcj),
+ /*.non_last_ok =*/ true,
+ /*.last_ok =*/ false,
+ /*.changes_size =*/ false,
},
#endif
#if defined(HAVE_ENCODER_ARMTHUMB) || defined(HAVE_DECODER_ARMTHUMB)
{
- .id = LZMA_FILTER_ARMTHUMB,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
+ /*.id =*/ LZMA_FILTER_ARMTHUMB,
+ /*.options_size =*/ sizeof(lzma_options_bcj),
+ /*.non_last_ok =*/ true,
+ /*.last_ok =*/ false,
+ /*.changes_size =*/ false,
},
#endif
#if defined(HAVE_ENCODER_SPARC) || defined(HAVE_DECODER_SPARC)
{
- .id = LZMA_FILTER_SPARC,
- .options_size = sizeof(lzma_options_bcj),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
+ /*.id =*/ LZMA_FILTER_SPARC,
+ /*.options_size =*/ sizeof(lzma_options_bcj),
+ /*.non_last_ok =*/ true,
+ /*.last_ok =*/ false,
+ /*.changes_size =*/ false,
},
#endif
#if defined(HAVE_ENCODER_DELTA) || defined(HAVE_DECODER_DELTA)
{
- .id = LZMA_FILTER_DELTA,
- .options_size = sizeof(lzma_options_delta),
- .non_last_ok = true,
- .last_ok = false,
- .changes_size = false,
+ /*.id =*/ LZMA_FILTER_DELTA,
+ /*.options_size =*/ sizeof(lzma_options_delta),
+ /*.non_last_ok =*/ true,
+ /*.last_ok =*/ false,
+ /*.changes_size =*/ false,
},
#endif
{
- .id = LZMA_VLI_UNKNOWN
+ /*.id =*/ LZMA_VLI_UNKNOWN
}
};
diff -ru -p xz-5.0.3/src/liblzma/common/filter_decoder.c xz-5.0.3-g2++/src/liblzma/common/filter_decoder.c
--- xz-5.0.3/src/liblzma/common/filter_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/filter_decoder.c Thu Oct 4 01:33:47 2012
@@ -44,74 +44,74 @@ typedef struct {
static const lzma_filter_decoder decoders[] = {
#ifdef HAVE_DECODER_LZMA1
{
- .id = LZMA_FILTER_LZMA1,
- .init = &lzma_lzma_decoder_init,
- .memusage = &lzma_lzma_decoder_memusage,
- .props_decode = &lzma_lzma_props_decode,
+ /*.id =*/ LZMA_FILTER_LZMA1,
+ /*.init =*/ &lzma_lzma_decoder_init,
+ /*.memusage =*/ &lzma_lzma_decoder_memusage,
+ /*.props_decode =*/ &lzma_lzma_props_decode,
},
#endif
#ifdef HAVE_DECODER_LZMA2
{
- .id = LZMA_FILTER_LZMA2,
- .init = &lzma_lzma2_decoder_init,
- .memusage = &lzma_lzma2_decoder_memusage,
- .props_decode = &lzma_lzma2_props_decode,
+ /*.id =*/ LZMA_FILTER_LZMA2,
+ /*.init =*/ &lzma_lzma2_decoder_init,
+ /*.memusage =*/ &lzma_lzma2_decoder_memusage,
+ /*.props_decode =*/ &lzma_lzma2_props_decode,
},
#endif
#ifdef HAVE_DECODER_X86
{
- .id = LZMA_FILTER_X86,
- .init = &lzma_simple_x86_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
+ /*.id =*/ LZMA_FILTER_X86,
+ /*.init =*/ &lzma_simple_x86_decoder_init,
+ /*.memusage =*/ NULL,
+ /*.props_decode =*/ &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_POWERPC
{
- .id = LZMA_FILTER_POWERPC,
- .init = &lzma_simple_powerpc_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
+ /*.id =*/ LZMA_FILTER_POWERPC,
+ /*.init =*/ &lzma_simple_powerpc_decoder_init,
+ /*.memusage =*/ NULL,
+ /*.props_decode =*/ &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_IA64
{
- .id = LZMA_FILTER_IA64,
- .init = &lzma_simple_ia64_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
+ /*.id =*/ LZMA_FILTER_IA64,
+ /*.init =*/ &lzma_simple_ia64_decoder_init,
+ /*.memusage =*/ NULL,
+ /*.props_decode =*/ &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_ARM
{
- .id = LZMA_FILTER_ARM,
- .init = &lzma_simple_arm_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
+ /*.id =*/ LZMA_FILTER_ARM,
+ /*.init =*/ &lzma_simple_arm_decoder_init,
+ /*.memusage =*/ NULL,
+ /*.props_decode =*/ &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_ARMTHUMB
{
- .id = LZMA_FILTER_ARMTHUMB,
- .init = &lzma_simple_armthumb_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
+ /*.id =*/ LZMA_FILTER_ARMTHUMB,
+ /*.init =*/ &lzma_simple_armthumb_decoder_init,
+ /*.memusage =*/ NULL,
+ /*.props_decode =*/ &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_SPARC
{
- .id = LZMA_FILTER_SPARC,
- .init = &lzma_simple_sparc_decoder_init,
- .memusage = NULL,
- .props_decode = &lzma_simple_props_decode,
+ /*.id =*/ LZMA_FILTER_SPARC,
+ /*.init =*/ &lzma_simple_sparc_decoder_init,
+ /*.memusage =*/ NULL,
+ /*.props_decode =*/ &lzma_simple_props_decode,
},
#endif
#ifdef HAVE_DECODER_DELTA
{
- .id = LZMA_FILTER_DELTA,
- .init = &lzma_delta_decoder_init,
- .memusage = &lzma_delta_coder_memusage,
- .props_decode = &lzma_delta_props_decode,
+ /*.id =*/ LZMA_FILTER_DELTA,
+ /*.init =*/ &lzma_delta_decoder_init,
+ /*.memusage =*/ &lzma_delta_coder_memusage,
+ /*.props_decode =*/ &lzma_delta_props_decode,
},
#endif
};
@@ -147,7 +147,7 @@ lzma_raw_decoder_init(lzma_next_coder *n
extern LZMA_API(lzma_ret)
lzma_raw_decoder(lzma_stream *strm, const lzma_filter *options)
{
- lzma_next_strm_init(lzma_raw_decoder_init, strm, options);
+ lzma_next_strm_init1(lzma_raw_decoder_init, strm, options);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff -ru -p xz-5.0.3/src/liblzma/common/filter_encoder.c xz-5.0.3-g2++/src/liblzma/common/filter_encoder.c
--- xz-5.0.3/src/liblzma/common/filter_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/filter_encoder.c Thu Oct 4 00:40:40 2012
@@ -56,95 +56,101 @@ typedef struct {
static const lzma_filter_encoder encoders[] = {
#ifdef HAVE_ENCODER_LZMA1
{
- .id = LZMA_FILTER_LZMA1,
- .init = &lzma_lzma_encoder_init,
- .memusage = &lzma_lzma_encoder_memusage,
- .chunk_size = NULL, // FIXME
- .props_size_get = NULL,
- .props_size_fixed = 5,
- .props_encode = &lzma_lzma_props_encode,
+ /*.id =*/ LZMA_FILTER_LZMA1,
+ /*.init =*/ &lzma_lzma_encoder_init,
+ /*.memusage =*/ &lzma_lzma_encoder_memusage,
+ /*.chunk_size =*/ NULL, // FIXME
+ /*.props_size_get =*/ NULL,
+ /*.props_size_fixed =*/ 5,
+ /*.props_encode =*/ &lzma_lzma_props_encode,
},
#endif
#ifdef HAVE_ENCODER_LZMA2
{
- .id = LZMA_FILTER_LZMA2,
- .init = &lzma_lzma2_encoder_init,
- .memusage = &lzma_lzma2_encoder_memusage,
- .chunk_size = NULL, // FIXME
- .props_size_get = NULL,
- .props_size_fixed = 1,
- .props_encode = &lzma_lzma2_props_encode,
+ /*.id =*/ LZMA_FILTER_LZMA2,
+ /*.init =*/ &lzma_lzma2_encoder_init,
+ /*.memusage =*/ &lzma_lzma2_encoder_memusage,
+ /*.chunk_size =*/ NULL, // FIXME
+ /*.props_size_get =*/ NULL,
+ /*.props_size_fixed =*/ 1,
+ /*.props_encode =*/ &lzma_lzma2_props_encode,
},
#endif
#ifdef HAVE_ENCODER_X86
{
- .id = LZMA_FILTER_X86,
- .init = &lzma_simple_x86_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
+ /*.id =*/ LZMA_FILTER_X86,
+ /*.init =*/ &lzma_simple_x86_encoder_init,
+ /*.memusage =*/ NULL,
+ /*.chunk_size =*/ NULL,
+ /*.props_size_get =*/ &lzma_simple_props_size,
+ /*.props_size_fixed =*/ 0, /*?*/
+ /*.props_encode =*/ &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_POWERPC
{
- .id = LZMA_FILTER_POWERPC,
- .init = &lzma_simple_powerpc_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
+ /*.id =*/ LZMA_FILTER_POWERPC,
+ /*.init =*/ &lzma_simple_powerpc_encoder_init,
+ /*.memusage =*/ NULL,
+ /*.chunk_size =*/ NULL,
+ /*.props_size_get =*/ &lzma_simple_props_size,
+ /*.props_size_fixed =*/ 0, /*?*/
+ /*.props_encode =*/ &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_IA64
{
- .id = LZMA_FILTER_IA64,
- .init = &lzma_simple_ia64_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
+ /*.id =*/ LZMA_FILTER_IA64,
+ /*.init =*/ &lzma_simple_ia64_encoder_init,
+ /*.memusage =*/ NULL,
+ /*.chunk_size =*/ NULL,
+ /*.props_size_get =*/ &lzma_simple_props_size,
+ /*.props_size_fixed =*/ 0, /*?*/
+ /*.props_encode =*/ &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_ARM
{
- .id = LZMA_FILTER_ARM,
- .init = &lzma_simple_arm_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
+ /*.id =*/ LZMA_FILTER_ARM,
+ /*.init =*/ &lzma_simple_arm_encoder_init,
+ /*.memusage =*/ NULL,
+ /*.chunk_size =*/ NULL,
+ /*.props_size_get =*/ &lzma_simple_props_size,
+ /*.props_size_fixed =*/ 0, /*?*/
+ /*.props_encode =*/ &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_ARMTHUMB
{
- .id = LZMA_FILTER_ARMTHUMB,
- .init = &lzma_simple_armthumb_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
+ /*.id =*/ LZMA_FILTER_ARMTHUMB,
+ /*.init =*/ &lzma_simple_armthumb_encoder_init,
+ /*.memusage =*/ NULL,
+ /*.chunk_size =*/ NULL,
+ /*.props_size_get =*/ &lzma_simple_props_size,
+ /*.props_size_fixed =*/ 0, /*?*/
+ /*.props_encode =*/ &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_SPARC
{
- .id = LZMA_FILTER_SPARC,
- .init = &lzma_simple_sparc_encoder_init,
- .memusage = NULL,
- .chunk_size = NULL,
- .props_size_get = &lzma_simple_props_size,
- .props_encode = &lzma_simple_props_encode,
+ /*.id =*/ LZMA_FILTER_SPARC,
+ /*.init =*/ &lzma_simple_sparc_encoder_init,
+ /*.memusage =*/ NULL,
+ /*.chunk_size =*/ NULL,
+ /*.props_size_get =*/ &lzma_simple_props_size,
+ /*.props_size_fixed =*/ 0, /*?*/
+ /*.props_encode =*/ &lzma_simple_props_encode,
},
#endif
#ifdef HAVE_ENCODER_DELTA
{
- .id = LZMA_FILTER_DELTA,
- .init = &lzma_delta_encoder_init,
- .memusage = &lzma_delta_coder_memusage,
- .chunk_size = NULL,
- .props_size_get = NULL,
- .props_size_fixed = 1,
- .props_encode = &lzma_delta_props_encode,
+ /*.id =*/ LZMA_FILTER_DELTA,
+ /*.init =*/ &lzma_delta_encoder_init,
+ /*.memusage =*/ &lzma_delta_coder_memusage,
+ /*.chunk_size =*/ NULL,
+ /*.props_size_get =*/ NULL,
+ /*.props_size_fixed =*/ 1,
+ /*.props_encode =*/ &lzma_delta_props_encode,
},
#endif
};
@@ -207,7 +213,7 @@ lzma_raw_encoder_init(lzma_next_coder *n
extern LZMA_API(lzma_ret)
lzma_raw_encoder(lzma_stream *strm, const lzma_filter *options)
{
- lzma_next_strm_init(lzma_raw_coder_init, strm, options,
+ lzma_next_strm_init3(lzma_raw_coder_init, strm, options,
(lzma_filter_find)(&encoder_find), true);
strm->internal->supported_actions[LZMA_RUN] = true;
diff -ru -p xz-5.0.3/src/liblzma/common/index.c xz-5.0.3-g2++/src/liblzma/common/index.c
--- xz-5.0.3/src/liblzma/common/index.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/index.c Fri Dec 12 17:34:30 2014
@@ -342,7 +342,7 @@ index_stream_init(lzma_vli compressed_ba
lzma_vli stream_number, lzma_vli block_number_base,
lzma_allocator *allocator)
{
- index_stream *s = lzma_alloc(sizeof(index_stream), allocator);
+ index_stream *s = (index_stream *)lzma_alloc(sizeof(index_stream), allocator);
if (s == NULL)
return NULL;
@@ -370,7 +370,7 @@ index_stream_init(lzma_vli compressed_ba
static void
index_stream_end(void *node, lzma_allocator *allocator)
{
- index_stream *s = node;
+ index_stream *s = (index_stream *)node;
index_tree_end(&s->groups, allocator, NULL);
return;
}
@@ -379,7 +379,7 @@ index_stream_end(void *node, lzma_alloca
static lzma_index *
index_init_plain(lzma_allocator *allocator)
{
- lzma_index *i = lzma_alloc(sizeof(lzma_index), allocator);
+ lzma_index *i = (lzma_index *)lzma_alloc(sizeof(lzma_index), allocator);
if (i != NULL) {
index_tree_init(&i->streams);
i->uncompressed_size = 0;
@@ -672,7 +672,7 @@ lzma_index_append(lzma_index *i, lzma_al
++g->last;
} else {
// We need to allocate a new group.
- g = lzma_alloc(sizeof(index_group)
+ g = (index_group *)lzma_alloc(sizeof(index_group)
+ i->prealloc * sizeof(index_record),
allocator);
if (g == NULL)
@@ -739,19 +739,19 @@ typedef struct {
/// Simplest iterative traversal of the source tree wouldn't work, because
/// we update the pointers in nodes when moving them to the destination tree.
static void
-index_cat_helper(const index_cat_info *info, index_stream *this)
+index_cat_helper(const index_cat_info *info, index_stream *this_)
{
- index_stream *left = (index_stream *)(this->node.left);
- index_stream *right = (index_stream *)(this->node.right);
+ index_stream *left = (index_stream *)(this_->node.left);
+ index_stream *right = (index_stream *)(this_->node.right);
if (left != NULL)
index_cat_helper(info, left);
- this->node.uncompressed_base += info->uncompressed_size;
- this->node.compressed_base += info->file_size;
- this->number += info->stream_number_add;
- this->block_number_base += info->block_number_add;
- index_tree_append(info->streams, &this->node);
+ this_->node.uncompressed_base += info->uncompressed_size;
+ this_->node.compressed_base += info->file_size;
+ this_->number += info->stream_number_add;
+ this_->block_number_base += info->block_number_add;
+ index_tree_append(info->streams, &this_->node);
if (right != NULL)
index_cat_helper(info, right);
@@ -796,7 +796,7 @@ lzma_index_cat(lzma_index *restrict dest
assert(g->node.left == NULL);
assert(g->node.right == NULL);
- index_group *newg = lzma_alloc(sizeof(index_group)
+ index_group *newg = (index_group *)lzma_alloc(sizeof(index_group)
+ (g->last + 1)
* sizeof(index_record),
allocator);
@@ -832,11 +832,11 @@ lzma_index_cat(lzma_index *restrict dest
// Add all the Streams from src to dest. Update the base offsets
// of each Stream from src.
const index_cat_info info = {
- .uncompressed_size = dest->uncompressed_size,
- .file_size = dest_file_size,
- .stream_number_add = dest->streams.count,
- .block_number_add = dest->record_count,
- .streams = &dest->streams,
+ /*.uncompressed_size =*/ dest->uncompressed_size,
+ /*.file_size =*/ dest_file_size,
+ /*.block_number_add =*/ dest->record_count,
+ /*.stream_number_add =*/ dest->streams.count,
+ /*.streams =*/ &dest->streams,
};
index_cat_helper(&info, (index_stream *)(src->streams.root));
@@ -881,7 +881,7 @@ index_dup_stream(const index_stream *src
// Allocate memory for the Records. We put all the Records into
// a single group. It's simplest and also tends to make
// lzma_index_locate() a little bit faster with very big Indexes.
- index_group *destg = lzma_alloc(sizeof(index_group)
+ index_group *destg = (index_group *)lzma_alloc(sizeof(index_group)
+ src->record_count * sizeof(index_record),
allocator);
if (destg == NULL) {
@@ -903,7 +903,7 @@ index_dup_stream(const index_stream *src
memcpy(destg->records + i, srcg->records,
(srcg->last + 1) * sizeof(index_record));
i += srcg->last + 1;
- srcg = index_tree_next(&srcg->node);
+ srcg = (index_group *)index_tree_next(&srcg->node);
} while (srcg != NULL);
assert(i == destg->allocated);
@@ -942,7 +942,7 @@ lzma_index_dup(const lzma_index *src, lz
index_tree_append(&dest->streams, &deststream->node);
- srcstream = index_tree_next(&srcstream->node);
+ srcstream = (index_stream *)index_tree_next(&srcstream->node);
} while (srcstream != NULL);
return dest;
@@ -970,9 +970,9 @@ enum {
static void
iter_set_info(lzma_index_iter *iter)
{
- const lzma_index *i = iter->internal[ITER_INDEX].p;
- const index_stream *stream = iter->internal[ITER_STREAM].p;
- const index_group *group = iter->internal[ITER_GROUP].p;
+ const lzma_index *i = (lzma_index *)iter->internal[ITER_INDEX].p;
+ const index_stream *stream = (index_stream *)iter->internal[ITER_STREAM].p;
+ const index_group *group = (index_group *)iter->internal[ITER_GROUP].p;
const size_t record = iter->internal[ITER_RECORD].s;
// lzma_index_iter.internal must not contain a pointer to the last
@@ -1097,8 +1097,8 @@ lzma_index_iter_next(lzma_index_iter *it
if ((unsigned int)(mode) > LZMA_INDEX_ITER_NONEMPTY_BLOCK)
return true;
- const lzma_index *i = iter->internal[ITER_INDEX].p;
- const index_stream *stream = iter->internal[ITER_STREAM].p;
+ const lzma_index *i = (lzma_index *)iter->internal[ITER_INDEX].p;
+ const index_stream *stream = (index_stream *)iter->internal[ITER_STREAM].p;
const index_group *group = NULL;
size_t record = iter->internal[ITER_RECORD].s;
@@ -1110,11 +1110,11 @@ lzma_index_iter_next(lzma_index_iter *it
// for explanation.
switch (iter->internal[ITER_METHOD].s) {
case ITER_METHOD_NORMAL:
- group = iter->internal[ITER_GROUP].p;
+ group = (index_group *)iter->internal[ITER_GROUP].p;
break;
case ITER_METHOD_NEXT:
- group = index_tree_next(iter->internal[ITER_GROUP].p);
+ group = (index_group *)index_tree_next((index_tree_node *)iter->internal[ITER_GROUP].p);
break;
case ITER_METHOD_LEFTMOST:
@@ -1134,7 +1134,7 @@ again:
// about the first a Block, skip Streams that have
// no Blocks.
while (stream->groups.leftmost == NULL) {
- stream = index_tree_next(&stream->node);
+ stream = (index_stream *)index_tree_next(&stream->node);
if (stream == NULL)
return true;
}
@@ -1156,14 +1156,14 @@ again:
// If group is not NULL, this Stream has at least one Block
// and thus at least one group. Find the next group.
if (group != NULL)
- group = index_tree_next(&group->node);
+ group = (index_group *)index_tree_next(&group->node);
if (group == NULL) {
// This Stream has no more Records. Find the next
// Stream. If we are being asked to return information
// about a Block, we skip empty Streams.
do {
- stream = index_tree_next(&stream->node);
+ stream = (index_stream *)index_tree_next(&stream->node);
if (stream == NULL)
return true;
} while (mode >= LZMA_INDEX_ITER_BLOCK
@@ -1200,19 +1200,19 @@ again:
extern LZMA_API(lzma_bool)
lzma_index_iter_locate(lzma_index_iter *iter, lzma_vli target)
{
- const lzma_index *i = iter->internal[ITER_INDEX].p;
+ const lzma_index *i = (lzma_index *)iter->internal[ITER_INDEX].p;
// If the target is past the end of the file, return immediately.
if (i->uncompressed_size <= target)
return true;
// Locate the Stream containing the target offset.
- const index_stream *stream = index_tree_locate(&i->streams, target);
+ const index_stream *stream = (index_stream *)index_tree_locate(&i->streams, target);
assert(stream != NULL);
target -= stream->node.uncompressed_base;
// Locate the group containing the target offset.
- const index_group *group = index_tree_locate(&stream->groups, target);
+ const index_group *group = (index_group *)index_tree_locate(&stream->groups, target);
assert(group != NULL);
// Use binary search to locate the exact Record. It is the first
diff -ru -p xz-5.0.3/src/liblzma/common/index_decoder.c xz-5.0.3-g2++/src/liblzma/common/index_decoder.c
--- xz-5.0.3/src/liblzma/common/index_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/index_decoder.c Thu Oct 4 01:35:58 2012
@@ -14,17 +14,18 @@
#include "check.h"
+enum lzma_coder_sequence_e {
+ SEQ_INDICATOR,
+ SEQ_COUNT,
+ SEQ_MEMUSAGE,
+ SEQ_UNPADDED,
+ SEQ_UNCOMPRESSED,
+ SEQ_PADDING_INIT,
+ SEQ_PADDING,
+ SEQ_CRC32,
+};
struct lzma_coder_s {
- enum {
- SEQ_INDICATOR,
- SEQ_COUNT,
- SEQ_MEMUSAGE,
- SEQ_UNPADDED,
- SEQ_UNCOMPRESSED,
- SEQ_PADDING_INIT,
- SEQ_PADDING,
- SEQ_CRC32,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
/// Memory usage limit
uint64_t memlimit;
@@ -270,7 +271,7 @@ index_decoder_init(lzma_next_coder *next
return LZMA_PROG_ERROR;
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -289,7 +290,7 @@ index_decoder_init(lzma_next_coder *next
extern LZMA_API(lzma_ret)
lzma_index_decoder(lzma_stream *strm, lzma_index **i, uint64_t memlimit)
{
- lzma_next_strm_init(index_decoder_init, strm, i, memlimit);
+ lzma_next_strm_init2(index_decoder_init, strm, i, memlimit);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff -ru -p xz-5.0.3/src/liblzma/common/index_encoder.c xz-5.0.3-g2++/src/liblzma/common/index_encoder.c
--- xz-5.0.3/src/liblzma/common/index_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/index_encoder.c Fri Dec 12 17:38:53 2014
@@ -15,16 +15,17 @@
#include "check.h"
+enum lzma_coder_sequence_e {
+ SEQ_INDICATOR,
+ SEQ_COUNT,
+ SEQ_UNPADDED,
+ SEQ_UNCOMPRESSED,
+ SEQ_NEXT,
+ SEQ_PADDING,
+ SEQ_CRC32,
+};
struct lzma_coder_s {
- enum {
- SEQ_INDICATOR,
- SEQ_COUNT,
- SEQ_UNPADDED,
- SEQ_UNCOMPRESSED,
- SEQ_NEXT,
- SEQ_PADDING,
- SEQ_CRC32,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
/// Index being encoded
const lzma_index *index;
@@ -110,7 +111,8 @@ index_encode(lzma_coder *coder,
coder->pos = 0;
// Advance to SEQ_UNCOMPRESSED or SEQ_NEXT.
- ++coder->sequence;
+ /*++coder->sequence;*/
+ coder->sequence = (coder->sequence == SEQ_UNPADDED)?SEQ_UNCOMPRESSED:SEQ_NEXT;
break;
}
@@ -190,7 +192,7 @@ lzma_index_encoder_init(lzma_next_coder
return LZMA_PROG_ERROR;
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -207,7 +209,7 @@ lzma_index_encoder_init(lzma_next_coder
extern LZMA_API(lzma_ret)
lzma_index_encoder(lzma_stream *strm, const lzma_index *i)
{
- lzma_next_strm_init(lzma_index_encoder_init, strm, i);
+ lzma_next_strm_init1(lzma_index_encoder_init, strm, i);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_FINISH] = true;
diff -ru -p xz-5.0.3/src/liblzma/common/index_hash.c xz-5.0.3-g2++/src/liblzma/common/index_hash.c
--- xz-5.0.3/src/liblzma/common/index_hash.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/index_hash.c Thu Oct 4 01:38:34 2012
@@ -34,16 +34,17 @@ typedef struct {
} lzma_index_hash_info;
+enum lzma_index_hash_sequence_e {
+ SEQ_BLOCK,
+ SEQ_COUNT,
+ SEQ_UNPADDED,
+ SEQ_UNCOMPRESSED,
+ SEQ_PADDING_INIT,
+ SEQ_PADDING,
+ SEQ_CRC32,
+};
struct lzma_index_hash_s {
- enum {
- SEQ_BLOCK,
- SEQ_COUNT,
- SEQ_UNPADDED,
- SEQ_UNCOMPRESSED,
- SEQ_PADDING_INIT,
- SEQ_PADDING,
- SEQ_CRC32,
- } sequence;
+ enum lzma_index_hash_sequence_e sequence;
/// Information collected while decoding the actual Blocks.
lzma_index_hash_info blocks;
@@ -73,7 +74,7 @@ extern LZMA_API(lzma_index_hash *)
lzma_index_hash_init(lzma_index_hash *index_hash, lzma_allocator *allocator)
{
if (index_hash == NULL) {
- index_hash = lzma_alloc(sizeof(lzma_index_hash), allocator);
+ index_hash = (lzma_index_hash *)lzma_alloc(sizeof(lzma_index_hash), allocator);
if (index_hash == NULL)
return NULL;
}
diff -ru -p xz-5.0.3/src/liblzma/common/stream_buffer_encoder.c xz-5.0.3-g2++/src/liblzma/common/stream_buffer_encoder.c
--- xz-5.0.3/src/liblzma/common/stream_buffer_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/stream_buffer_encoder.c Fri Dec 12 17:41:13 2014
@@ -73,9 +73,10 @@ lzma_stream_buffer_encode(lzma_filter *f
out_size -= LZMA_STREAM_HEADER_SIZE;
// Encode the Stream Header.
- lzma_stream_flags stream_flags = {
- .version = 0,
- .check = check,
+ lzma_stream_flags stream_flags;
+ {
+ stream_flags.version = 0;
+ stream_flags.check = check;
};
if (lzma_stream_header_encode(&stream_flags, out + out_pos)
@@ -85,10 +86,11 @@ lzma_stream_buffer_encode(lzma_filter *f
out_pos += LZMA_STREAM_HEADER_SIZE;
// Encode a Block but only if there is at least one byte of input.
- lzma_block block = {
- .version = 0,
- .check = check,
- .filters = filters,
+ lzma_block block;
+ {
+ block.version = 0;
+ block.check = check;
+ block.filters = filters;
};
if (in_size > 0)
diff -ru -p xz-5.0.3/src/liblzma/common/stream_decoder.c xz-5.0.3-g2++/src/liblzma/common/stream_decoder.c
--- xz-5.0.3/src/liblzma/common/stream_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/stream_decoder.c Thu Oct 4 01:40:15 2012
@@ -14,15 +14,16 @@
#include "block_decoder.h"
+enum lzma_coder_sequence_e {
+ SEQ_STREAM_HEADER,
+ SEQ_BLOCK_HEADER,
+ SEQ_BLOCK,
+ SEQ_INDEX,
+ SEQ_STREAM_FOOTER,
+ SEQ_STREAM_PADDING,
+};
struct lzma_coder_s {
- enum {
- SEQ_STREAM_HEADER,
- SEQ_BLOCK_HEADER,
- SEQ_BLOCK,
- SEQ_INDEX,
- SEQ_STREAM_FOOTER,
- SEQ_STREAM_PADDING,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
/// Block or Metadata decoder. This takes little memory and the same
/// data structure can be used to decode every Block Header, so it's
@@ -413,7 +414,7 @@ lzma_stream_decoder_init(lzma_next_coder
return LZMA_OPTIONS_ERROR;
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -442,7 +443,7 @@ lzma_stream_decoder_init(lzma_next_coder
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;
diff -ru -p xz-5.0.3/src/liblzma/common/stream_encoder.c xz-5.0.3-g2++/src/liblzma/common/stream_encoder.c
--- xz-5.0.3/src/liblzma/common/stream_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/stream_encoder.c Fri Dec 12 17:43:27 2014
@@ -15,15 +15,17 @@
#include "index_encoder.h"
+enum lzma_coder_sequence_e {
+ SEQ_STREAM_HEADER,
+ SEQ_BLOCK_INIT,
+ SEQ_BLOCK_HEADER,
+ SEQ_BLOCK_ENCODE,
+ SEQ_INDEX_ENCODE,
+ SEQ_STREAM_FOOTER,
+ SEQ_STREAM_INVALID,
+};
struct lzma_coder_s {
- enum {
- SEQ_STREAM_HEADER,
- SEQ_BLOCK_INIT,
- SEQ_BLOCK_HEADER,
- SEQ_BLOCK_ENCODE,
- SEQ_INDEX_ENCODE,
- SEQ_STREAM_FOOTER,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
/// True if Block encoder has been initialized by
/// lzma_stream_encoder_init() or stream_encoder_update()
@@ -99,7 +101,13 @@ stream_encode(lzma_coder *coder, lzma_al
return LZMA_STREAM_END;
coder->buffer_pos = 0;
- ++coder->sequence;
+ /*++coder->sequence;*/
+ switch (coder->sequence) {
+ case SEQ_STREAM_HEADER: coder->sequence=SEQ_BLOCK_INIT; break;
+ case SEQ_BLOCK_HEADER: coder->sequence=SEQ_BLOCK_ENCODE; break;
+ case SEQ_STREAM_FOOTER: coder->sequence=SEQ_STREAM_INVALID; break;
+ default: assert(0); return LZMA_PROG_ERROR;
+ }
break;
case SEQ_BLOCK_INIT: {
@@ -185,9 +193,9 @@ stream_encode(lzma_coder *coder, lzma_al
// Encode the Stream Footer into coder->buffer.
const lzma_stream_flags stream_flags = {
- .version = 0,
- .backward_size = lzma_index_size(coder->index),
- .check = coder->block_options.check,
+ /*.version =*/ 0,
+ /*.backward_size =*/ lzma_index_size(coder->index),
+ /*.check =*/ coder->block_options.check,
};
if (lzma_stream_footer_encode(&stream_flags, coder->buffer)
@@ -272,7 +280,7 @@ lzma_stream_encoder_init(lzma_next_coder
return LZMA_PROG_ERROR;
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -299,8 +307,9 @@ lzma_stream_encoder_init(lzma_next_coder
// Encode the Stream Header
lzma_stream_flags stream_flags = {
- .version = 0,
- .check = check,
+ /*.version =*/ 0,
+ /*.backward_size =*/ 0,
+ /*.check =*/ check,
};
return_if_error(lzma_stream_header_encode(
&stream_flags, next->coder->buffer));
@@ -320,7 +329,7 @@ extern LZMA_API(lzma_ret)
lzma_stream_encoder(lzma_stream *strm,
const lzma_filter *filters, lzma_check check)
{
- lzma_next_strm_init(lzma_stream_encoder_init, strm, filters, check);
+ lzma_next_strm_init2(lzma_stream_encoder_init, strm, filters, check);
strm->internal->supported_actions[LZMA_RUN] = true;
strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;
diff -ru -p xz-5.0.3/src/liblzma/common/stream_flags_decoder.c xz-5.0.3-g2++/src/liblzma/common/stream_flags_decoder.c
--- xz-5.0.3/src/liblzma/common/stream_flags_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/common/stream_flags_decoder.c Thu Oct 4 01:56:45 2012
@@ -21,7 +21,14 @@ stream_flags_decode(lzma_stream_flags *o
return true;
options->version = 0;
- options->check = in[1] & 0x0F;
+ /*options->check = in[1] & 0x0F;*/
+ switch (in[1] & 0x0F) {
+ case 0: options->check = LZMA_CHECK_NONE; break;
+ case 1: options->check = LZMA_CHECK_CRC32; break;
+ case 4: options->check = LZMA_CHECK_CRC64; break;
+ case 10: options->check = LZMA_CHECK_SHA256; break;
+ default: options->check = LZMA_CHECK_NONE; break;
+ }
return false;
}
diff -ru -p xz-5.0.3/src/liblzma/delta/delta_common.c xz-5.0.3-g2++/src/liblzma/delta/delta_common.c
--- xz-5.0.3/src/liblzma/delta/delta_common.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/delta/delta_common.c Thu Oct 4 03:28:32 2012
@@ -29,7 +29,7 @@ lzma_delta_coder_init(lzma_next_coder *n
{
// Allocate memory for the decoder if needed.
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -43,7 +43,7 @@ lzma_delta_coder_init(lzma_next_coder *n
return LZMA_OPTIONS_ERROR;
// Set the delta distance.
- const lzma_options_delta *opt = filters[0].options;
+ const lzma_options_delta *opt = (lzma_options_delta *)filters[0].options;
next->coder->distance = opt->dist;
// Initialize the rest of the variables.
@@ -59,7 +59,7 @@ lzma_delta_coder_init(lzma_next_coder *n
extern uint64_t
lzma_delta_coder_memusage(const void *options)
{
- const lzma_options_delta *opt = options;
+ const lzma_options_delta *opt = (lzma_options_delta *)options;
if (opt == NULL || opt->type != LZMA_DELTA_TYPE_BYTE
|| opt->dist < LZMA_DELTA_DIST_MIN
diff -ru -p xz-5.0.3/src/liblzma/delta/delta_decoder.c xz-5.0.3-g2++/src/liblzma/delta/delta_decoder.c
--- xz-5.0.3/src/liblzma/delta/delta_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/delta/delta_decoder.c Thu Oct 4 03:30:22 2012
@@ -63,7 +63,7 @@ lzma_delta_props_decode(void **options,
return LZMA_OPTIONS_ERROR;
lzma_options_delta *opt
- = lzma_alloc(sizeof(lzma_options_delta), allocator);
+ = (lzma_options_delta *)lzma_alloc(sizeof(lzma_options_delta), allocator);
if (opt == NULL)
return LZMA_MEM_ERROR;
diff -ru -p xz-5.0.3/src/liblzma/delta/delta_encoder.c xz-5.0.3-g2++/src/liblzma/delta/delta_encoder.c
--- xz-5.0.3/src/liblzma/delta/delta_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/delta/delta_encoder.c Thu Oct 4 03:29:32 2012
@@ -114,7 +114,7 @@ lzma_delta_props_encode(const void *opti
if (lzma_delta_coder_memusage(options) == UINT64_MAX)
return LZMA_PROG_ERROR;
- const lzma_options_delta *opt = options;
+ const lzma_options_delta *opt = (lzma_options_delta *)options;
out[0] = opt->dist - LZMA_DELTA_DIST_MIN;
return LZMA_OK;
diff -ru -p xz-5.0.3/src/liblzma/lz/lz_decoder.c xz-5.0.3-g2++/src/liblzma/lz/lz_decoder.c
--- xz-5.0.3/src/liblzma/lz/lz_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/lz/lz_decoder.c Thu Oct 4 02:14:31 2012
@@ -199,6 +199,19 @@ lz_decoder_end(lzma_coder *coder, lzma_a
}
+/* functionize LZMA_LZ_DECODER_INIT */
+extern lzma_lz_decoder
+_lzma_lz_decoder_init_func(void)
+{
+ static lzma_lz_decoder ret = {
+ /*.coder =*/ NULL,
+ /*.code =*/ NULL,
+ /*.reset =*/ NULL,
+ /*.set_uncompressed =*/ NULL,
+ /*.end =*/ NULL,
+ };
+ return ret;
+}
extern lzma_ret
lzma_lz_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
const lzma_filter_info *filters,
@@ -208,7 +221,7 @@ lzma_lz_decoder_init(lzma_next_coder *ne
{
// Allocate the base structure if it isn't already allocated.
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -251,7 +264,7 @@ lzma_lz_decoder_init(lzma_next_coder *ne
if (next->coder->dict.size != lz_options.dict_size) {
lzma_free(next->coder->dict.buf, allocator);
next->coder->dict.buf
- = lzma_alloc(lz_options.dict_size, allocator);
+ = (uint8_t *)lzma_alloc(lz_options.dict_size, allocator);
if (next->coder->dict.buf == NULL)
return LZMA_MEM_ERROR;
diff -ru -p xz-5.0.3/src/liblzma/lz/lz_decoder.h xz-5.0.3-g2++/src/liblzma/lz/lz_decoder.h
--- xz-5.0.3/src/liblzma/lz/lz_decoder.h Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/lz/lz_decoder.h Thu Oct 4 02:13:18 2012
@@ -72,15 +72,9 @@ typedef struct {
} lzma_lz_decoder;
-#define LZMA_LZ_DECODER_INIT \
- (lzma_lz_decoder){ \
- .coder = NULL, \
- .code = NULL, \
- .reset = NULL, \
- .set_uncompressed = NULL, \
- .end = NULL, \
- }
-
+extern lzma_lz_decoder
+_lzma_lz_decoder_init_func(void);
+#define LZMA_LZ_DECODER_INIT _lzma_lz_decoder_init_func()
extern lzma_ret lzma_lz_decoder_init(lzma_next_coder *next,
lzma_allocator *allocator, const lzma_filter_info *filters,
diff -ru -p xz-5.0.3/src/liblzma/lz/lz_encoder.c xz-5.0.3-g2++/src/liblzma/lz/lz_encoder.c
--- xz-5.0.3/src/liblzma/lz/lz_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/lz/lz_encoder.c Thu Oct 4 02:04:26 2012
@@ -365,7 +365,7 @@ lz_encoder_init(lzma_mf *mf, lzma_alloca
{
// Allocate the history buffer.
if (mf->buffer == NULL) {
- mf->buffer = lzma_alloc(mf->size, allocator);
+ mf->buffer = (uint8_t *)lzma_alloc(mf->size, allocator);
if (mf->buffer == NULL)
return true;
}
@@ -392,7 +392,7 @@ lz_encoder_init(lzma_mf *mf, lzma_alloca
#endif
if (mf->hash == NULL) {
- mf->hash = lzma_alloc(alloc_count * sizeof(uint32_t),
+ mf->hash = (uint32_t *)lzma_alloc(alloc_count * sizeof(uint32_t),
allocator);
if (mf->hash == NULL)
return true;
@@ -442,12 +442,13 @@ extern uint64_t
lzma_lz_encoder_memusage(const lzma_lz_options *lz_options)
{
// Old buffers must not exist when calling lz_encoder_prepare().
- lzma_mf mf = {
- .buffer = NULL,
- .hash = NULL,
- .hash_size_sum = 0,
- .sons_count = 0,
- };
+ lzma_mf mf;
+ {
+ mf.buffer = NULL,
+ mf.hash = NULL,
+ mf.hash_size_sum = 0,
+ mf.sons_count = 0;
+ }
// Setup the size information into mf.
if (lz_encoder_prepare(&mf, NULL, lz_options))
@@ -508,7 +509,7 @@ lzma_lz_encoder_init(lzma_next_coder *ne
// Allocate and initialize the base data structure.
if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
diff -ru -p xz-5.0.3/src/liblzma/lzma/lzma2_decoder.c xz-5.0.3-g2++/src/liblzma/lzma/lzma2_decoder.c
--- xz-5.0.3/src/liblzma/lzma/lzma2_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/lzma/lzma2_decoder.c Thu Oct 4 03:26:20 2012
@@ -16,20 +16,21 @@
#include "lzma_decoder.h"
+enum lzma_coder_sequence_e {
+ SEQ_CONTROL,
+ SEQ_UNCOMPRESSED_1,
+ SEQ_UNCOMPRESSED_2,
+ SEQ_COMPRESSED_0,
+ SEQ_COMPRESSED_1,
+ SEQ_PROPERTIES,
+ SEQ_LZMA,
+ SEQ_COPY,
+};
struct lzma_coder_s {
- enum sequence {
- SEQ_CONTROL,
- SEQ_UNCOMPRESSED_1,
- SEQ_UNCOMPRESSED_2,
- SEQ_COMPRESSED_0,
- SEQ_COMPRESSED_1,
- SEQ_PROPERTIES,
- SEQ_LZMA,
- SEQ_COPY,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
/// Sequence after the size fields have been decoded.
- enum sequence next_sequence;
+ enum lzma_coder_sequence_e next_sequence;
/// LZMA decoder
lzma_lz_decoder lzma;
@@ -225,7 +226,7 @@ lzma2_decoder_init(lzma_lz_decoder *lz,
const void *opt, lzma_lz_options *lz_options)
{
if (lz->coder == NULL) {
- lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ lz->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (lz->coder == NULL)
return LZMA_MEM_ERROR;
@@ -235,7 +236,7 @@ lzma2_decoder_init(lzma_lz_decoder *lz,
lz->coder->lzma = LZMA_LZ_DECODER_INIT;
}
- const lzma_options_lzma *options = opt;
+ const lzma_options_lzma *options = (lzma_options_lzma *)opt;
lz->coder->sequence = SEQ_CONTROL;
lz->coder->need_properties = true;
@@ -283,7 +284,7 @@ lzma_lzma2_props_decode(void **options,
if (props[0] > 40)
return LZMA_OPTIONS_ERROR;
- lzma_options_lzma *opt = lzma_alloc(
+ lzma_options_lzma *opt = (lzma_options_lzma *)lzma_alloc(
sizeof(lzma_options_lzma), allocator);
if (opt == NULL)
return LZMA_MEM_ERROR;
diff -ru -p xz-5.0.3/src/liblzma/lzma/lzma2_encoder.c xz-5.0.3-g2++/src/liblzma/lzma/lzma2_encoder.c
--- xz-5.0.3/src/liblzma/lzma/lzma2_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/lzma/lzma2_encoder.c Thu Oct 4 03:23:02 2012
@@ -17,14 +17,15 @@
#include "lzma2_encoder.h"
+enum lzma_coder_sequence_e {
+ SEQ_INIT,
+ SEQ_LZMA_ENCODE,
+ SEQ_LZMA_COPY,
+ SEQ_UNCOMPRESSED_HEADER,
+ SEQ_UNCOMPRESSED_COPY,
+};
struct lzma_coder_s {
- enum {
- SEQ_INIT,
- SEQ_LZMA_ENCODE,
- SEQ_LZMA_COPY,
- SEQ_UNCOMPRESSED_HEADER,
- SEQ_UNCOMPRESSED_COPY,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
/// LZMA encoder
lzma_coder *lzma;
@@ -281,7 +282,7 @@ lzma2_encoder_options_update(lzma_coder
// Look if there are new options. At least for now,
// only lc/lp/pb can be changed.
- const lzma_options_lzma *opt = filter->options;
+ const lzma_options_lzma *opt = (lzma_options_lzma *)filter->options;
if (coder->opt_cur.lc != opt->lc || coder->opt_cur.lp != opt->lp
|| coder->opt_cur.pb != opt->pb) {
// Validate the options.
@@ -311,7 +312,7 @@ lzma2_encoder_init(lzma_lz_encoder *lz,
return LZMA_PROG_ERROR;
if (lz->coder == NULL) {
- lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ lz->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (lz->coder == NULL)
return LZMA_MEM_ERROR;
@@ -371,7 +372,7 @@ lzma_lzma2_encoder_memusage(const void *
extern lzma_ret
lzma_lzma2_props_encode(const void *options, uint8_t *out)
{
- const lzma_options_lzma *const opt = options;
+ const lzma_options_lzma *const opt = (lzma_options_lzma *)options;
uint32_t d = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN);
// Round up to the next 2^n - 1 or 2^n + 2^(n - 1) - 1 depending
diff -ru -p xz-5.0.3/src/liblzma/lzma/lzma_common.h xz-5.0.3-g2++/src/liblzma/lzma/lzma_common.h
--- xz-5.0.3/src/liblzma/lzma/lzma_common.h Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/lzma/lzma_common.h Thu Oct 4 02:54:32 2012
@@ -53,21 +53,19 @@ is_lclppb_valid(const lzma_options_lzma
///
/// The event names are in from STATE_oldest_older_previous. REP means
/// either short or long repeated match, and NONLIT means any non-literal.
-typedef enum {
- STATE_LIT_LIT,
- STATE_MATCH_LIT_LIT,
- STATE_REP_LIT_LIT,
- STATE_SHORTREP_LIT_LIT,
- STATE_MATCH_LIT,
- STATE_REP_LIT,
- STATE_SHORTREP_LIT,
- STATE_LIT_MATCH,
- STATE_LIT_LONGREP,
- STATE_LIT_SHORTREP,
- STATE_NONLIT_MATCH,
- STATE_NONLIT_REP,
-} lzma_lzma_state;
-
+typedef int lzma_lzma_state;
+#define STATE_LIT_LIT 0
+#define STATE_MATCH_LIT_LIT 1
+#define STATE_REP_LIT_LIT 2
+#define STATE_SHORTREP_LIT_LIT 3
+#define STATE_MATCH_LIT 4
+#define STATE_REP_LIT 5
+#define STATE_SHORTREP_LIT 6
+#define STATE_LIT_MATCH 7
+#define STATE_LIT_LONGREP 8
+#define STATE_LIT_SHORTREP 9
+#define STATE_NONLIT_MATCH 10
+#define STATE_NONLIT_REP 11
/// Total number of states
#define STATES 12
diff -ru -p xz-5.0.3/src/liblzma/lzma/lzma_decoder.c xz-5.0.3-g2++/src/liblzma/lzma/lzma_decoder.c
--- xz-5.0.3/src/liblzma/lzma/lzma_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/lzma/lzma_decoder.c Thu Oct 4 03:19:50 2012
@@ -161,6 +161,27 @@ typedef struct {
} lzma_length_decoder;
+enum lzma_coder_sequence_e {
+ SEQ_NORMALIZE,
+ SEQ_IS_MATCH,
+ seq_8(SEQ_LITERAL),
+ seq_8(SEQ_LITERAL_MATCHED),
+ SEQ_LITERAL_WRITE,
+ SEQ_IS_REP,
+ seq_len(SEQ_MATCH_LEN),
+ seq_6(SEQ_POS_SLOT),
+ SEQ_POS_MODEL,
+ SEQ_DIRECT,
+ seq_4(SEQ_ALIGN),
+ SEQ_EOPM,
+ SEQ_IS_REP0,
+ SEQ_SHORTREP,
+ SEQ_IS_REP0_LONG,
+ SEQ_IS_REP1,
+ SEQ_IS_REP2,
+ seq_len(SEQ_REP_LEN),
+ SEQ_COPY,
+};
struct lzma_coder_s {
///////////////////
// Probabilities //
@@ -237,27 +258,7 @@ struct lzma_coder_s {
////////////////////////////////
/// Position where to continue the decoder loop
- enum {
- SEQ_NORMALIZE,
- SEQ_IS_MATCH,
- seq_8(SEQ_LITERAL),
- seq_8(SEQ_LITERAL_MATCHED),
- SEQ_LITERAL_WRITE,
- SEQ_IS_REP,
- seq_len(SEQ_MATCH_LEN),
- seq_6(SEQ_POS_SLOT),
- SEQ_POS_MODEL,
- SEQ_DIRECT,
- seq_4(SEQ_ALIGN),
- SEQ_EOPM,
- SEQ_IS_REP0,
- SEQ_SHORTREP,
- SEQ_IS_REP0_LONG,
- SEQ_IS_REP1,
- SEQ_IS_REP2,
- seq_len(SEQ_REP_LEN),
- SEQ_COPY,
- } sequence;
+ enum lzma_coder_sequence_e sequence;
/// Base of the current probability tree
probability *probs;
@@ -340,6 +341,20 @@ lzma_decode(lzma_coder *restrict coder,
// The main decoder loop. The "switch" is used to restart the decoder at
// correct location. Once restarted, the "switch" is no longer used.
+ static const lzma_lzma_state next_state[] = {
+ STATE_LIT_LIT,
+ STATE_LIT_LIT,
+ STATE_LIT_LIT,
+ STATE_LIT_LIT,
+ STATE_MATCH_LIT_LIT,
+ STATE_REP_LIT_LIT,
+ STATE_SHORTREP_LIT_LIT,
+ STATE_MATCH_LIT,
+ STATE_REP_LIT,
+ STATE_SHORTREP_LIT,
+ STATE_MATCH_LIT,
+ STATE_REP_LIT
+ };
switch (coder->sequence)
while (true) {
// Calculate new pos_state. This is skipped on the first loop
@@ -453,20 +468,6 @@ lzma_decode(lzma_coder *restrict coder,
// Use a lookup table to update to literal state,
// since compared to other state updates, this would
// need two branches.
- static const lzma_lzma_state next_state[] = {
- STATE_LIT_LIT,
- STATE_LIT_LIT,
- STATE_LIT_LIT,
- STATE_LIT_LIT,
- STATE_MATCH_LIT_LIT,
- STATE_REP_LIT_LIT,
- STATE_SHORTREP_LIT_LIT,
- STATE_MATCH_LIT,
- STATE_REP_LIT,
- STATE_SHORTREP_LIT,
- STATE_MATCH_LIT,
- STATE_REP_LIT
- };
state = next_state[state];
case SEQ_LITERAL_WRITE:
@@ -853,7 +854,7 @@ lzma_lzma_decoder_uncompressed(void *cod
static void
lzma_decoder_reset(lzma_coder *coder, const void *opt)
{
- const lzma_options_lzma *options = opt;
+ const lzma_options_lzma *options = (lzma_options_lzma *)opt;
// NOTE: We assume that lc/lp/pb are valid since they were
// successfully decoded with lzma_lzma_decode_properties().
@@ -937,7 +938,7 @@ lzma_lzma_decoder_create(lzma_lz_decoder
const void *opt, lzma_lz_options *lz_options)
{
if (lz->coder == NULL) {
- lz->coder = lzma_alloc(sizeof(lzma_coder), allocator);
+ lz->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (lz->coder == NULL)
return LZMA_MEM_ERROR;
@@ -948,7 +949,7 @@ lzma_lzma_decoder_create(lzma_lz_decoder
// All dictionary sizes are OK here. LZ decoder will take care of
// the special cases.
- const lzma_options_lzma *options = opt;
+ const lzma_options_lzma *options = (lzma_options_lzma *)opt;
lz_options->dict_size = options->dict_size;
lz_options->preset_dict = options->preset_dict;
lz_options->preset_dict_size = options->preset_dict_size;
@@ -964,7 +965,7 @@ static lzma_ret
lzma_decoder_init(lzma_lz_decoder *lz, lzma_allocator *allocator,
const void *options, lzma_lz_options *lz_options)
{
- if (!is_lclppb_valid(options))
+ if (!is_lclppb_valid((lzma_options_lzma *)options))
return LZMA_PROG_ERROR;
return_if_error(lzma_lzma_decoder_create(
@@ -1009,7 +1010,7 @@ lzma_lzma_lclppb_decode(lzma_options_lzm
extern uint64_t
lzma_lzma_decoder_memusage_nocheck(const void *options)
{
- const lzma_options_lzma *const opt = options;
+ const lzma_options_lzma *const opt = (lzma_options_lzma *)options;
return sizeof(lzma_coder) + lzma_lz_decoder_memusage(opt->dict_size);
}
@@ -1017,7 +1018,7 @@ lzma_lzma_decoder_memusage_nocheck(const
extern uint64_t
lzma_lzma_decoder_memusage(const void *options)
{
- if (!is_lclppb_valid(options))
+ if (!is_lclppb_valid((lzma_options_lzma *)options))
return UINT64_MAX;
return lzma_lzma_decoder_memusage_nocheck(options);
@@ -1032,7 +1033,7 @@ lzma_lzma_props_decode(void **options, l
return LZMA_OPTIONS_ERROR;
lzma_options_lzma *opt
- = lzma_alloc(sizeof(lzma_options_lzma), allocator);
+ = (lzma_options_lzma *)lzma_alloc(sizeof(lzma_options_lzma), allocator);
if (opt == NULL)
return LZMA_MEM_ERROR;
diff -ru -p xz-5.0.3/src/liblzma/lzma/lzma_encoder.c xz-5.0.3-g2++/src/liblzma/lzma/lzma_encoder.c
--- xz-5.0.3/src/liblzma/lzma/lzma_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/lzma/lzma_encoder.c Thu Oct 4 02:59:30 2012
@@ -550,7 +550,7 @@ lzma_lzma_encoder_create(lzma_coder **co
{
// Allocate lzma_coder if it wasn't already allocated.
if (*coder_ptr == NULL) {
- *coder_ptr = lzma_alloc(sizeof(lzma_coder), allocator);
+ *coder_ptr = (lzma_coder *)lzma_alloc(sizeof(lzma_coder), allocator);
if (*coder_ptr == NULL)
return LZMA_MEM_ERROR;
}
@@ -609,7 +609,7 @@ lzma_encoder_init(lzma_lz_encoder *lz, l
{
lz->code = &lzma_encode;
return lzma_lzma_encoder_create(
- &lz->coder, allocator, options, lz_options);
+ (lzma_coder **)&lz->coder, allocator, (lzma_options_lzma *)options, lz_options);
}
@@ -625,11 +625,11 @@ lzma_lzma_encoder_init(lzma_next_coder *
extern uint64_t
lzma_lzma_encoder_memusage(const void *options)
{
- if (!is_options_valid(options))
+ if (!is_options_valid((lzma_options_lzma *)options))
return UINT64_MAX;
lzma_lz_options lz_options;
- set_lz_options(&lz_options, options);
+ set_lz_options(&lz_options, (lzma_options_lzma *)options);
const uint64_t lz_memusage = lzma_lz_encoder_memusage(&lz_options);
if (lz_memusage == UINT64_MAX)
@@ -656,7 +656,7 @@ lzma_lzma_lclppb_encode(const lzma_optio
extern lzma_ret
lzma_lzma_props_encode(const void *options, uint8_t *out)
{
- const lzma_options_lzma *const opt = options;
+ const lzma_options_lzma *const opt = (lzma_options_lzma *)options;
if (lzma_lzma_lclppb_encode(opt, out))
return LZMA_PROG_ERROR;
diff -ru -p xz-5.0.3/src/liblzma/lzma/lzma_encoder_presets.c xz-5.0.3-g2++/src/liblzma/lzma/lzma_encoder_presets.c
--- xz-5.0.3/src/liblzma/lzma/lzma_encoder_presets.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/lzma/lzma_encoder_presets.c Thu Oct 4 03:07:32 2012
@@ -30,14 +30,17 @@ lzma_lzma_preset(lzma_options_lzma *opti
options->lp = LZMA_LP_DEFAULT;
options->pb = LZMA_PB_DEFAULT;
- options->dict_size = UINT32_C(1) << (uint8_t []){
- 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 }[level];
+ {
+ static const uint8_t l2s[] = { 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 };
+ options->dict_size = UINT32_C(1) << l2s[level];
+ }
if (level <= 3) {
+ static const uint8_t l2d[] = { 4, 8, 24, 48 };
options->mode = LZMA_MODE_FAST;
options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4;
options->nice_len = level <= 1 ? 128 : 273;
- options->depth = (uint8_t []){ 4, 8, 24, 48 }[level];
+ options->depth = l2d[level];
} else {
options->mode = LZMA_MODE_NORMAL;
options->mf = LZMA_MF_BT4;
diff -ru -p xz-5.0.3/src/liblzma/rangecoder/range_encoder.h xz-5.0.3-g2++/src/liblzma/rangecoder/range_encoder.h
--- xz-5.0.3/src/liblzma/rangecoder/range_encoder.h Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/rangecoder/range_encoder.h Thu Oct 4 02:28:12 2012
@@ -24,6 +24,12 @@
#define RC_SYMBOLS_MAX 58
+typedef uint32_t lzma_range_encoder_symbols_e;
+#define RC_BIT_0 0
+#define RC_BIT_1 1
+#define RC_DIRECT_0 2
+#define RC_DIRECT_1 3
+#define RC_FLUSH 4
typedef struct {
uint64_t low;
uint64_t cache_size;
@@ -37,13 +43,7 @@ typedef struct {
size_t pos;
/// Symbols to encode
- enum {
- RC_BIT_0,
- RC_BIT_1,
- RC_DIRECT_0,
- RC_DIRECT_1,
- RC_FLUSH,
- } symbols[RC_SYMBOLS_MAX];
+ lzma_range_encoder_symbols_e symbols[RC_SYMBOLS_MAX];
/// Probabilities associated with RC_BIT_0 or RC_BIT_1
probability *probs[RC_SYMBOLS_MAX];
diff -ru -p xz-5.0.3/src/liblzma/simple/simple_coder.c xz-5.0.3-g2++/src/liblzma/simple/simple_coder.c
--- xz-5.0.3/src/liblzma/simple/simple_coder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/simple/simple_coder.c Thu Oct 4 03:32:26 2012
@@ -235,7 +235,7 @@ lzma_simple_coder_init(lzma_next_coder *
// need twice the size of unfiltered_max, because then it
// is always possible to filter at least unfiltered_max bytes
// more data in coder->buffer[] if it can be filled completely.
- next->coder = lzma_alloc(sizeof(lzma_coder)
+ next->coder = (lzma_coder *)lzma_alloc(sizeof(lzma_coder)
+ 2 * unfiltered_max, allocator);
if (next->coder == NULL)
return LZMA_MEM_ERROR;
@@ -250,7 +250,7 @@ lzma_simple_coder_init(lzma_next_coder *
// Allocate memory for filter-specific data structure.
if (simple_size > 0) {
- next->coder->simple = lzma_alloc(
+ next->coder->simple = (lzma_simple *)lzma_alloc(
simple_size, allocator);
if (next->coder->simple == NULL)
return LZMA_MEM_ERROR;
@@ -260,7 +260,7 @@ lzma_simple_coder_init(lzma_next_coder *
}
if (filters[0].options != NULL) {
- const lzma_options_bcj *simple = filters[0].options;
+ const lzma_options_bcj *simple = (lzma_options_bcj *)filters[0].options;
next->coder->now_pos = simple->start_offset;
if (next->coder->now_pos & (alignment - 1))
return LZMA_OPTIONS_ERROR;
diff -ru -p xz-5.0.3/src/liblzma/simple/simple_decoder.c xz-5.0.3-g2++/src/liblzma/simple/simple_decoder.c
--- xz-5.0.3/src/liblzma/simple/simple_decoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/simple/simple_decoder.c Thu Oct 4 03:34:41 2012
@@ -23,7 +23,7 @@ lzma_simple_props_decode(void **options,
if (props_size != 4)
return LZMA_OPTIONS_ERROR;
- lzma_options_bcj *opt = lzma_alloc(
+ lzma_options_bcj *opt = (lzma_options_bcj *)lzma_alloc(
sizeof(lzma_options_bcj), allocator);
if (opt == NULL)
return LZMA_MEM_ERROR;
diff -ru -p xz-5.0.3/src/liblzma/simple/simple_encoder.c xz-5.0.3-g2++/src/liblzma/simple/simple_encoder.c
--- xz-5.0.3/src/liblzma/simple/simple_encoder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/liblzma/simple/simple_encoder.c Thu Oct 4 03:33:52 2012
@@ -16,7 +16,7 @@
extern lzma_ret
lzma_simple_props_size(uint32_t *size, const void *options)
{
- const lzma_options_bcj *const opt = options;
+ const lzma_options_bcj *const opt = (lzma_options_bcj *)options;
*size = (opt == NULL || opt->start_offset == 0) ? 0 : 4;
return LZMA_OK;
}
@@ -25,7 +25,7 @@ lzma_simple_props_size(uint32_t *size, c
extern lzma_ret
lzma_simple_props_encode(const void *options, uint8_t *out)
{
- const lzma_options_bcj *const opt = options;
+ const lzma_options_bcj *const opt = (lzma_options_bcj *)options;
// The default start offset is zero, so we don't need to store any
// options unless the start offset is non-zero.
diff -ru -p xz-5.0.3/src/lzmainfo/lzmainfo.c xz-5.0.3-g2++/src/lzmainfo/lzmainfo.c
--- xz-5.0.3/src/lzmainfo/lzmainfo.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/lzmainfo/lzmainfo.c Fri Dec 12 16:28:17 2014
@@ -109,7 +109,7 @@ lzmainfo(const char *name, FILE *f)
return true;
}
- lzma_filter filter = { .id = LZMA_FILTER_LZMA1 };
+ lzma_filter filter = { /*.id =*/ LZMA_FILTER_LZMA1 };
// Parse the first five bytes.
switch (lzma_properties_decode(&filter, NULL, buf, 5)) {
diff -ru -p xz-5.0.3/src/xz/args.c xz-5.0.3-g2++/src/xz/args.c
--- xz-5.0.3/src/xz/args.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/xz/args.c Fri Dec 12 14:35:37 2014
@@ -450,7 +450,7 @@ parse_environment(args_info *args, char
// Allocate memory to hold pointers to the arguments. Add one to get
// space for the terminating NULL (if some systems happen to need it).
- char **argv = xmalloc(((size_t)(argc) + 1) * sizeof(char *));
+ char **argv = (char**)xmalloc(((size_t)(argc) + 1) * sizeof(char *));
argv[0] = argv0;
argv[argc] = NULL;
diff -ru -p xz-5.0.3/src/xz/coder.c xz-5.0.3-g2++/src/xz/coder.c
--- xz-5.0.3/src/xz/coder.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/xz/coder.c Fri Dec 12 14:39:12 2014
@@ -215,7 +215,7 @@ coder_set_compression_settings(void)
// Decrease the dictionary size until we meet the memory
// usage limit. First round down to full mebibytes.
- lzma_options_lzma *opt = filters[i].options;
+ lzma_options_lzma *opt = (lzma_options_lzma *)filters[i].options;
const uint32_t orig_dict_size = opt->dict_size;
opt->dict_size &= ~((UINT32_C(1) << 20) - 1);
while (true) {
@@ -297,7 +297,7 @@ is_format_lzma(void)
return false;
// Decode the LZMA1 properties.
- lzma_filter filter = { .id = LZMA_FILTER_LZMA1 };
+ lzma_filter filter = { /*.id =*/ LZMA_FILTER_LZMA1, NULL };
if (lzma_properties_decode(&filter, NULL, in_buf.u8, 5) != LZMA_OK)
return false;
@@ -305,7 +305,7 @@ is_format_lzma(void)
// sizes that are 2^n or 2^n + 2^(n-1) or UINT32_MAX. LZMA_Alone
// created only files with 2^n, but accepts any dictionary size.
// If someone complains, this will be reconsidered.
- lzma_options_lzma *opt = filter.options;
+ lzma_options_lzma *opt = (lzma_options_lzma *)filter.options;
const uint32_t dict_size = opt->dict_size;
free(opt);
@@ -358,7 +358,7 @@ coder_init(file_pair *pair)
break;
case FORMAT_LZMA:
- ret = lzma_alone_encoder(&strm, filters[0].options);
+ ret = lzma_alone_encoder(&strm, (lzma_options_lzma *)filters[0].options);
break;
case FORMAT_RAW:
diff -ru -p xz-5.0.3/src/xz/file_io.c xz-5.0.3-g2++/src/xz/file_io.c
--- xz-5.0.3/src/xz/file_io.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/xz/file_io.c Fri Dec 12 14:42:57 2014
@@ -518,13 +518,15 @@ io_open_src(const char *src_name)
static file_pair pair;
pair = (file_pair){
- .src_name = src_name,
- .dest_name = NULL,
- .src_fd = -1,
- .dest_fd = -1,
- .src_eof = false,
- .dest_try_sparse = false,
- .dest_pending_sparse = 0,
+ /*.src_name =*/ src_name,
+ /*.dest_name =*/ NULL,
+ /*.src_fd =*/ -1,
+ /*.dest_fd =*/ -1,
+ /*.src_eof =*/ false,
+ /*.dest_try_sparse =*/ false,
+ /*.dest_pending_sparse =*/ 0,
+ /*struct stat src_st;*/
+ /*struct stat dest_st;*/
};
// Block the signals, for which we have a custom signal handler, so
diff -ru -p xz-5.0.3/src/xz/main.c xz-5.0.3-g2++/src/xz/main.c
--- xz-5.0.3/src/xz/main.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/xz/main.c Fri Dec 12 14:44:56 2014
@@ -71,7 +71,7 @@ read_name(const args_info *args)
// executing this function, no files are open for writing, and thus
// there's no need to cleanup anything before exiting.
if (name == NULL)
- name = xmalloc(size);
+ name = (char *)xmalloc(size);
// Write position in name
size_t pos = 0;
@@ -131,7 +131,7 @@ read_name(const args_info *args)
// with '\0'.
if (pos == size) {
size *= 2;
- name = xrealloc(name, size);
+ name = (char *)xrealloc(name, size);
}
}
diff -ru -p xz-5.0.3/src/xz/message.c xz-5.0.3-g2++/src/xz/message.c
--- xz-5.0.3/src/xz/message.c Sat May 21 21:12:43 2011
+++ xz-5.0.3-g2++/src/xz/message.c Fri Dec 12 15:00:08 2014
@@ -172,9 +172,10 @@ message_init(void)
extern void
message_verbosity_increase(void)
{
- if (verbosity < V_DEBUG)
- ++verbosity;
-
+ if (verbosity == V_SILENT ) { verbosity = V_ERROR ; return; }
+ if (verbosity == V_ERROR ) { verbosity = V_WARNING; return; }
+ if (verbosity == V_WARNING) { verbosity = V_VERBOSE; return; }
+ if (verbosity == V_VERBOSE) { verbosity = V_DEBUG ; return; }
return;
}
@@ -182,9 +183,10 @@ message_verbosity_increase(void)
extern void
message_verbosity_decrease(void)
{
- if (verbosity > V_SILENT)
- --verbosity;
-
+ if (verbosity == V_DEBUG ) { verbosity = V_VERBOSE; return; }
+ if (verbosity == V_VERBOSE) { verbosity = V_WARNING; return; }
+ if (verbosity == V_WARNING) { verbosity = V_ERROR ; return; }
+ if (verbosity == V_ERROR ) { verbosity = V_SILENT ; return; }
return;
}
@@ -923,7 +925,7 @@ message_filters_to_str(char buf[FILTERS_
switch (filters[i].id) {
case LZMA_FILTER_LZMA1:
case LZMA_FILTER_LZMA2: {
- const lzma_options_lzma *opt = filters[i].options;
+ const lzma_options_lzma *opt = (lzma_options_lzma *)filters[i].options;
const char *mode = NULL;
const char *mf = NULL;
@@ -1010,7 +1012,7 @@ message_filters_to_str(char buf[FILTERS_
"sparc",
};
- const lzma_options_bcj *opt = filters[i].options;
+ const lzma_options_bcj *opt = (lzma_options_bcj *)filters[i].options;
my_snprintf(&pos, &left, "%s", bcj_names[filters[i].id
- LZMA_FILTER_X86]);
@@ -1023,7 +1025,7 @@ message_filters_to_str(char buf[FILTERS_
}
case LZMA_FILTER_DELTA: {
- const lzma_options_delta *opt = filters[i].options;
+ const lzma_options_delta *opt = (lzma_options_delta *)filters[i].options;
my_snprintf(&pos, &left, "delta=dist=%" PRIu32,
opt->dist);
break;
diff -ru -p xz-5.0.3/src/xz/options.c xz-5.0.3-g2++/src/xz/options.c
--- xz-5.0.3/src/xz/options.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/xz/options.c Fri Dec 12 15:33:15 2014
@@ -152,7 +152,7 @@ static void
set_delta(void *options, uint32_t key, uint64_t value,
const char *valuestr lzma_attribute((__unused__)))
{
- lzma_options_delta *opt = options;
+ lzma_options_delta *opt = (lzma_options_delta *)options;
switch (key) {
case OPT_DIST:
opt->dist = value;
@@ -170,11 +170,11 @@ options_delta(const char *str)
{ NULL, NULL, 0, 0 }
};
- lzma_options_delta *options = xmalloc(sizeof(lzma_options_delta));
+ lzma_options_delta *options = (lzma_options_delta *)xmalloc(sizeof(lzma_options_delta));
*options = (lzma_options_delta){
// It's hard to give a useful default for this.
- .type = LZMA_DELTA_TYPE_BYTE,
- .dist = LZMA_DELTA_DIST_MIN,
+ /*.type =*/ LZMA_DELTA_TYPE_BYTE,
+ /*.dist =*/ LZMA_DELTA_DIST_MIN,
};
parse_options(str, opts, &set_delta, options);
@@ -196,7 +196,7 @@ static void
set_bcj(void *options, uint32_t key, uint64_t value,
const char *valuestr lzma_attribute((__unused__)))
{
- lzma_options_bcj *opt = options;
+ lzma_options_bcj *opt = (lzma_options_bcj *)options;
switch (key) {
case OPT_START_OFFSET:
opt->start_offset = value;
@@ -213,9 +213,9 @@ options_bcj(const char *str)
{ NULL, NULL, 0, 0 }
};
- lzma_options_bcj *options = xmalloc(sizeof(lzma_options_bcj));
+ lzma_options_bcj *options = (lzma_options_bcj *)xmalloc(sizeof(lzma_options_bcj));
*options = (lzma_options_bcj){
- .start_offset = 0,
+ /*.start_offset =*/ 0,
};
parse_options(str, opts, &set_bcj, options);
@@ -251,7 +251,7 @@ error_lzma_preset(const char *valuestr)
static void
set_lzma(void *options, uint32_t key, uint64_t value, const char *valuestr)
{
- lzma_options_lzma *opt = options;
+ lzma_options_lzma *opt = (lzma_options_lzma *)options;
switch (key) {
case OPT_PRESET: {
@@ -272,7 +272,7 @@ set_lzma(void *options, uint32_t key, ui
error_lzma_preset(valuestr);
}
- if (lzma_lzma_preset(options, preset))
+ if (lzma_lzma_preset((lzma_options_lzma *)options, preset))
error_lzma_preset(valuestr);
break;
@@ -345,7 +345,7 @@ options_lzma(const char *str)
{ NULL, NULL, 0, 0 }
};
- lzma_options_lzma *options = xmalloc(sizeof(lzma_options_lzma));
+ lzma_options_lzma *options = (lzma_options_lzma *)xmalloc(sizeof(lzma_options_lzma));
if (lzma_lzma_preset(options, LZMA_PRESET_DEFAULT))
message_bug();
diff -ru -p xz-5.0.3/src/xz/util.c xz-5.0.3-g2++/src/xz/util.c
--- xz-5.0.3/src/xz/util.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/src/xz/util.c Fri Dec 12 16:09:34 2014
@@ -192,7 +192,13 @@ uint64_to_nicestr(uint64_t value, enum n
double d = (double)(value);
do {
d /= 1024.0;
- ++unit;
+ /*++unit*/;
+ switch(unit) {
+ case NICESTR_B: unit=NICESTR_KIB; break;
+ case NICESTR_KIB: unit=NICESTR_MIB; break;
+ case NICESTR_MIB: unit=NICESTR_GIB; break;
+ case NICESTR_GIB: unit=NICESTR_TIB; break;
+ }
} while (unit < unit_min || (d > 9999.9 && unit < unit_max));
if (thousand == WORKS)
diff -ru -p xz-5.0.3/tests/test_block_header.c xz-5.0.3-g2++/tests/test_block_header.c
--- xz-5.0.3/tests/test_block_header.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/tests/test_block_header.c Fri Dec 12 16:42:39 2014
@@ -21,58 +21,58 @@ static lzma_options_lzma opt_lzma;
static lzma_filter filters_none[1] = {
{
- .id = LZMA_VLI_UNKNOWN,
+ /*.id =*/ LZMA_VLI_UNKNOWN,
},
};
static lzma_filter filters_one[2] = {
{
- .id = LZMA_FILTER_LZMA2,
- .options = &opt_lzma,
+ /*.id =*/ LZMA_FILTER_LZMA2,
+ /*.options =*/ &opt_lzma,
}, {
- .id = LZMA_VLI_UNKNOWN,
+ /*.id =*/ LZMA_VLI_UNKNOWN,
}
};
static lzma_filter filters_four[5] = {
{
- .id = LZMA_FILTER_X86,
- .options = NULL,
+ /*.id =*/ LZMA_FILTER_X86,
+ /*.options =*/ NULL,
}, {
- .id = LZMA_FILTER_X86,
- .options = NULL,
+ /*.id =*/ LZMA_FILTER_X86,
+ /*.options =*/ NULL,
}, {
- .id = LZMA_FILTER_X86,
- .options = NULL,
+ /*.id =*/ LZMA_FILTER_X86,
+ /*.options =*/ NULL,
}, {
- .id = LZMA_FILTER_LZMA2,
- .options = &opt_lzma,
+ /*.id =*/ LZMA_FILTER_LZMA2,
+ /*.options =*/ &opt_lzma,
}, {
- .id = LZMA_VLI_UNKNOWN,
+ /*.id =*/ LZMA_VLI_UNKNOWN,
}
};
static lzma_filter filters_five[6] = {
{
- .id = LZMA_FILTER_X86,
- .options = NULL,
+ /*.id =*/ LZMA_FILTER_X86,
+ /*.options =*/ NULL,
}, {
- .id = LZMA_FILTER_X86,
- .options = NULL,
+ /*.id =*/ LZMA_FILTER_X86,
+ /*.options =*/ NULL,
}, {
- .id = LZMA_FILTER_X86,
- .options = NULL,
+ /*.id =*/ LZMA_FILTER_X86,
+ /*.options =*/ NULL,
}, {
- .id = LZMA_FILTER_X86,
- .options = NULL,
+ /*.id =*/ LZMA_FILTER_X86,
+ /*.options =*/ NULL,
}, {
- .id = LZMA_FILTER_LZMA2,
- .options = &opt_lzma,
+ /*.id =*/ LZMA_FILTER_LZMA2,
+ /*.options =*/ &opt_lzma,
}, {
- .id = LZMA_VLI_UNKNOWN,
+ /*.id =*/ LZMA_VLI_UNKNOWN,
}
};
@@ -110,10 +110,12 @@ static void
test1(void)
{
known_options = (lzma_block){
- .check = LZMA_CHECK_NONE,
- .compressed_size = LZMA_VLI_UNKNOWN,
- .uncompressed_size = LZMA_VLI_UNKNOWN,
- .filters = NULL,
+ /*.version*/ 0,
+ /*.header_size*/ 0,
+ /*.check =*/ LZMA_CHECK_NONE,
+ /*.compressed_size =*/ LZMA_VLI_UNKNOWN,
+ /*.uncompressed_size =*/ LZMA_VLI_UNKNOWN,
+ /*.filters =*/ NULL,
};
expect(lzma_block_header_size(&known_options) == LZMA_PROG_ERROR);
@@ -155,10 +157,12 @@ static void
test2(void)
{
known_options = (lzma_block){
- .check = LZMA_CHECK_CRC32,
- .compressed_size = LZMA_VLI_UNKNOWN,
- .uncompressed_size = LZMA_VLI_UNKNOWN,
- .filters = filters_four,
+ /*.version*/ 0,
+ /*.header_size*/ 0,
+ /*.check =*/ LZMA_CHECK_CRC32,
+ /*.compressed_size =*/ LZMA_VLI_UNKNOWN,
+ /*.uncompressed_size =*/ LZMA_VLI_UNKNOWN,
+ /*.filters =*/ filters_four,
};
expect(lzma_block_header_size(&known_options) == LZMA_OK);
@@ -181,10 +185,12 @@ static void
test3(void)
{
known_options = (lzma_block){
- .check = LZMA_CHECK_CRC32,
- .compressed_size = LZMA_VLI_UNKNOWN,
- .uncompressed_size = LZMA_VLI_UNKNOWN,
- .filters = filters_one,
+ /*.version*/ 0,
+ /*.header_size*/ 0,
+ /*.check =*/ LZMA_CHECK_CRC32,
+ /*.compressed_size =*/ LZMA_VLI_UNKNOWN,
+ /*.uncompressed_size =*/ LZMA_VLI_UNKNOWN,
+ /*.filters =*/ filters_one,
};
expect(lzma_block_header_size(&known_options) == LZMA_OK);
diff -ru -p xz-5.0.3/tests/test_filter_flags.c xz-5.0.3-g2++/tests/test_filter_flags.c
--- xz-5.0.3/tests/test_filter_flags.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/tests/test_filter_flags.c Fri Dec 12 16:34:41 2014
@@ -117,8 +117,8 @@ test_delta(void)
// Test 2
lzma_options_delta options = {
- .type = LZMA_DELTA_TYPE_BYTE,
- .dist = 0
+ /*.type =*/ LZMA_DELTA_TYPE_BYTE,
+ /*.dist =*/ 0
};
known_flags.options = &options;
expect(encode(99));
diff -ru -p xz-5.0.3/tests/test_stream_flags.c xz-5.0.3-g2++/tests/test_stream_flags.c
--- xz-5.0.3/tests/test_stream_flags.c Sat May 21 21:12:31 2011
+++ xz-5.0.3-g2++/tests/test_stream_flags.c Fri Dec 12 17:59:00 2014
@@ -167,7 +167,7 @@ main(void)
// Valid headers
known_flags.backward_size = 1024;
for (lzma_check check = LZMA_CHECK_NONE;
- check <= LZMA_CHECK_ID_MAX; ++check) {
+ check <= LZMA_CHECK_ID_MAX; check=check+1) {
test_header();
test_footer();
}