summaryrefslogtreecommitdiff
path: root/Build/source/extra/xz/src
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2011-05-22 17:21:15 +0000
committerKarl Berry <karl@freefriends.org>2011-05-22 17:21:15 +0000
commit2cbb4825525837b568e36617fbf5b28e62cb08ac (patch)
treeead017ac2c8201cfec013bd2c2fca3d1dfc4e87b /Build/source/extra/xz/src
parent5cfd5ce05eb8d9e1294d7e2e60e111d85d45e7f6 (diff)
update to xz 5.0.3
git-svn-id: svn://tug.org/texlive/trunk@22565 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/extra/xz/src')
-rw-r--r--Build/source/extra/xz/src/liblzma/Makefile.am2
-rw-r--r--Build/source/extra/xz/src/liblzma/Makefile.in2
-rw-r--r--Build/source/extra/xz/src/liblzma/api/lzma/block.h1
-rw-r--r--Build/source/extra/xz/src/liblzma/api/lzma/container.h12
-rw-r--r--Build/source/extra/xz/src/liblzma/api/lzma/filter.h8
-rw-r--r--Build/source/extra/xz/src/liblzma/api/lzma/subblock.h200
-rw-r--r--Build/source/extra/xz/src/liblzma/api/lzma/version.h2
-rw-r--r--Build/source/extra/xz/src/liblzma/common/alone_decoder.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/common/alone_encoder.c4
-rw-r--r--Build/source/extra/xz/src/liblzma/common/block_buffer_encoder.c18
-rw-r--r--Build/source/extra/xz/src/liblzma/common/block_encoder.c7
-rw-r--r--Build/source/extra/xz/src/liblzma/common/common.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/common/common.h2
-rw-r--r--Build/source/extra/xz/src/liblzma/common/filter_common.c6
-rw-r--r--Build/source/extra/xz/src/liblzma/common/index_decoder.c9
-rw-r--r--Build/source/extra/xz/src/liblzma/common/index_encoder.c11
-rw-r--r--Build/source/extra/xz/src/liblzma/common/stream_buffer_encoder.c23
-rw-r--r--Build/source/extra/xz/src/liblzma/common/stream_encoder.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/delta/delta_encoder.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/lz/lz_decoder.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/lz/lz_encoder.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/lzma/lzma2_encoder.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/simple/arm.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/simple/armthumb.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/simple/ia64.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/simple/powerpc.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/simple/simple_coder.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/simple/sparc.c2
-rw-r--r--Build/source/extra/xz/src/liblzma/subblock/Makefile.inc20
-rw-r--r--Build/source/extra/xz/src/liblzma/subblock/subblock_decoder.c630
-rw-r--r--Build/source/extra/xz/src/liblzma/subblock/subblock_decoder.h22
-rw-r--r--Build/source/extra/xz/src/liblzma/subblock/subblock_decoder_helper.c70
-rw-r--r--Build/source/extra/xz/src/liblzma/subblock/subblock_decoder_helper.h29
-rw-r--r--Build/source/extra/xz/src/liblzma/subblock/subblock_encoder.c984
-rw-r--r--Build/source/extra/xz/src/liblzma/subblock/subblock_encoder.h21
-rw-r--r--Build/source/extra/xz/src/lzmainfo/lzmainfo.c4
-rw-r--r--Build/source/extra/xz/src/scripts/xzgrep.in4
-rw-r--r--Build/source/extra/xz/src/xz/coder.c2
-rw-r--r--Build/source/extra/xz/src/xz/file_io.c2
-rw-r--r--Build/source/extra/xz/src/xz/hardware.h2
-rw-r--r--Build/source/extra/xz/src/xz/message.c8
-rw-r--r--Build/source/extra/xz/src/xz/message.h18
-rw-r--r--Build/source/extra/xz/src/xz/options.c6
-rw-r--r--Build/source/extra/xz/src/xz/signals.c2
-rw-r--r--Build/source/extra/xz/src/xz/util.h6
-rw-r--r--Build/source/extra/xz/src/xz/xz.12
-rw-r--r--Build/source/extra/xz/src/xzdec/xzdec.c6
47 files changed, 119 insertions, 2052 deletions
diff --git a/Build/source/extra/xz/src/liblzma/Makefile.am b/Build/source/extra/xz/src/liblzma/Makefile.am
index 813dc406760..7b3d69ae9f4 100644
--- a/Build/source/extra/xz/src/liblzma/Makefile.am
+++ b/Build/source/extra/xz/src/liblzma/Makefile.am
@@ -24,7 +24,7 @@ liblzma_la_CPPFLAGS = \
-I$(top_srcdir)/src/liblzma/simple \
-I$(top_srcdir)/src/common \
-DTUKLIB_SYMBOL_PREFIX=lzma_
-liblzma_la_LDFLAGS = -no-undefined -version-info 5:2:0
+liblzma_la_LDFLAGS = -no-undefined -version-info 5:3:0
include $(srcdir)/common/Makefile.inc
include $(srcdir)/check/Makefile.inc
diff --git a/Build/source/extra/xz/src/liblzma/Makefile.in b/Build/source/extra/xz/src/liblzma/Makefile.in
index 7a9e268c452..06ccaac0944 100644
--- a/Build/source/extra/xz/src/liblzma/Makefile.in
+++ b/Build/source/extra/xz/src/liblzma/Makefile.in
@@ -609,7 +609,7 @@ liblzma_la_CPPFLAGS = \
-I$(top_srcdir)/src/common \
-DTUKLIB_SYMBOL_PREFIX=lzma_
-liblzma_la_LDFLAGS = -no-undefined -version-info 5:2:0 \
+liblzma_la_LDFLAGS = -no-undefined -version-info 5:3:0 \
$(am__append_38)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = liblzma.pc
diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/block.h b/Build/source/extra/xz/src/liblzma/api/lzma/block.h
index 3019bf916fe..8a4bf2323cc 100644
--- a/Build/source/extra/xz/src/liblzma/api/lzma/block.h
+++ b/Build/source/extra/xz/src/liblzma/api/lzma/block.h
@@ -483,6 +483,7 @@ extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size)
*
* \return - LZMA_OK: Encoding was successful.
* - LZMA_BUF_ERROR: Not enough output buffer space.
+ * - LZMA_UNSUPPORTED_CHECK
* - LZMA_OPTIONS_ERROR
* - LZMA_MEM_ERROR
* - LZMA_DATA_ERROR
diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/container.h b/Build/source/extra/xz/src/liblzma/api/lzma/container.h
index 83e70b44f22..7a9ffc64578 100644
--- a/Build/source/extra/xz/src/liblzma/api/lzma/container.h
+++ b/Build/source/extra/xz/src/liblzma/api/lzma/container.h
@@ -66,6 +66,10 @@
* This function is a wrapper for lzma_raw_encoder_memusage().
*
* \param preset Compression preset (level and possible flags)
+ *
+ * \return Number of bytes of memory required for the given
+ * preset when encoding. If an error occurs, for example
+ * due to unsupported preset, UINT64_MAX is returned.
*/
extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset)
lzma_nothrow lzma_attr_pure;
@@ -77,6 +81,11 @@ extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset)
* This function is a wrapper for lzma_raw_decoder_memusage().
*
* \param preset Compression preset (level and possible flags)
+ *
+ * \return Number of bytes of memory required to decompress a file
+ * that was compressed using the given preset. If an error
+ * occurs, for example due to unsupported preset, UINT64_MAX
+ * is returned.
*/
extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset)
lzma_nothrow lzma_attr_pure;
@@ -148,6 +157,7 @@ extern LZMA_API(lzma_ret) lzma_easy_encoder(
*
* \return - LZMA_OK: Encoding was successful.
* - LZMA_BUF_ERROR: Not enough output buffer space.
+ * - LZMA_UNSUPPORTED_CHECK
* - LZMA_OPTIONS_ERROR
* - LZMA_MEM_ERROR
* - LZMA_DATA_ERROR
@@ -171,6 +181,7 @@ extern LZMA_API(lzma_ret) lzma_easy_buffer_encode(
*
* \return - LZMA_OK: Initialization was successful.
* - LZMA_MEM_ERROR
+ * - LZMA_UNSUPPORTED_CHECK
* - LZMA_OPTIONS_ERROR
* - LZMA_PROG_ERROR
*/
@@ -250,6 +261,7 @@ extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size)
*
* \return - LZMA_OK: Encoding was successful.
* - LZMA_BUF_ERROR: Not enough output buffer space.
+ * - LZMA_UNSUPPORTED_CHECK
* - LZMA_OPTIONS_ERROR
* - LZMA_MEM_ERROR
* - LZMA_DATA_ERROR
diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/filter.h b/Build/source/extra/xz/src/liblzma/api/lzma/filter.h
index efd036f7f04..e0bc163ad35 100644
--- a/Build/source/extra/xz/src/liblzma/api/lzma/filter.h
+++ b/Build/source/extra/xz/src/liblzma/api/lzma/filter.h
@@ -131,7 +131,9 @@ extern LZMA_API(lzma_ret) lzma_filters_copy(const lzma_filter *src,
* .id == LZMA_VLI_UNKNOWN.
*
* \return Number of bytes of memory required for the given
- * filter chain when encoding.
+ * filter chain when encoding. If an error occurs,
+ * for example due to unsupported filter chain,
+ * UINT64_MAX is returned.
*/
extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters)
lzma_nothrow lzma_attr_pure;
@@ -148,7 +150,9 @@ extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters)
* .id == LZMA_VLI_UNKNOWN.
*
* \return Number of bytes of memory required for the given
- * filter chain when decoding.
+ * filter chain when decoding. If an error occurs,
+ * for example due to unsupported filter chain,
+ * UINT64_MAX is returned.
*/
extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters)
lzma_nothrow lzma_attr_pure;
diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/subblock.h b/Build/source/extra/xz/src/liblzma/api/lzma/subblock.h
deleted file mode 100644
index 4ffb049824b..00000000000
--- a/Build/source/extra/xz/src/liblzma/api/lzma/subblock.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/**
- * \file lzma/subblock.h
- * \brief Subblock filter
- */
-
-/*
- * Author: Lasse Collin
- *
- * This file has been put into the public domain.
- * You can do whatever you want with this file.
- *
- * See ../lzma.h for information about liblzma as a whole.
- */
-
-#ifndef LZMA_H_INTERNAL
-# error Never include this file directly. Use <lzma.h> instead.
-#endif
-
-
-/**
- * \brief Filter ID
- *
- * Filter ID of the Subblock filter. This is used as lzma_filter.id.
- */
-#define LZMA_FILTER_SUBBLOCK LZMA_VLI_C(0x01)
-
-
-/**
- * \brief Subfilter mode
- *
- * See lzma_options_subblock.subfilter_mode for details.
- */
-typedef enum {
- LZMA_SUBFILTER_NONE,
- /**<
- * No Subfilter is in use.
- */
-
- LZMA_SUBFILTER_SET,
- /**<
- * New Subfilter has been requested to be initialized.
- */
-
- LZMA_SUBFILTER_RUN,
- /**<
- * Subfilter is active.
- */
-
- LZMA_SUBFILTER_FINISH
- /**<
- * Subfilter has been requested to be finished.
- */
-} lzma_subfilter_mode;
-
-
-/**
- * \brief Options for the Subblock filter
- *
- * Specifying options for the Subblock filter is optional: if the pointer
- * options is NULL, no subfilters are allowed and the default value is used
- * for subblock_data_size.
- */
-typedef struct {
- /* Options for encoder and decoder */
-
- /**
- * \brief Allowing subfilters
- *
- * If this true, subfilters are allowed.
- *
- * In the encoder, if this is set to false, subfilter_mode and
- * subfilter_options are completely ignored.
- */
- lzma_bool allow_subfilters;
-
- /* Options for encoder only */
-
- /**
- * \brief Alignment
- *
- * The Subblock filter encapsulates the input data into Subblocks.
- * Each Subblock has a header which takes a few bytes of space.
- * When the output of the Subblock encoder is fed to another filter
- * that takes advantage of the alignment of the input data (e.g. LZMA),
- * the Subblock filter can add padding to keep the actual data parts
- * in the Subblocks aligned correctly.
- *
- * The alignment should be a positive integer. Subblock filter will
- * add enough padding between Subblocks so that this is true for
- * every payload byte:
- * input_offset % alignment == output_offset % alignment
- *
- * The Subblock filter assumes that the first output byte will be
- * written to a position in the output stream that is properly
- * aligned. This requirement is automatically met when the start
- * offset of the Stream or Block is correctly told to Block or
- * Stream encoder.
- */
- uint32_t alignment;
-# define LZMA_SUBBLOCK_ALIGNMENT_MIN 1
-# define LZMA_SUBBLOCK_ALIGNMENT_MAX 32
-# define LZMA_SUBBLOCK_ALIGNMENT_DEFAULT 4
-
- /**
- * \brief Size of the Subblock Data part of each Subblock
- *
- * This value is re-read every time a new Subblock is started.
- *
- * Bigger values
- * - save a few bytes of space;
- * - increase latency in the encoder (but no effect for decoding);
- * - decrease memory locality (increased cache pollution) in the
- * encoder (no effect in decoding).
- */
- uint32_t subblock_data_size;
-# define LZMA_SUBBLOCK_DATA_SIZE_MIN 1
-# define LZMA_SUBBLOCK_DATA_SIZE_MAX (UINT32_C(1) << 28)
-# define LZMA_SUBBLOCK_DATA_SIZE_DEFAULT 4096
-
- /**
- * \brief Run-length encoder remote control
- *
- * The Subblock filter has an internal run-length encoder (RLE). It
- * can be useful when the data includes byte sequences that repeat
- * very many times. The RLE can be used also when a Subfilter is
- * in use; the RLE will be applied to the output of the Subfilter.
- *
- * Note that in contrast to traditional RLE, this RLE is intended to
- * be used only when there's a lot of data to be repeated. If the
- * input data has e.g. 500 bytes of NULs now and then, this RLE
- * is probably useless, because plain LZMA should provide better
- * results.
- *
- * Due to above reasons, it was decided to keep the implementation
- * of the RLE very simple. When the rle variable is non-zero, it
- * subblock_data_size must be a multiple of rle. Once the Subblock
- * encoder has got subblock_data_size bytes of input, it will check
- * if the whole buffer of the last subblock_data_size can be
- * represented with repeats of chunks having size of rle bytes.
- *
- * If there are consecutive identical buffers of subblock_data_size
- * bytes, they will be encoded using a single repeat entry if
- * possible.
- *
- * If need arises, more advanced RLE can be implemented later
- * without breaking API or ABI.
- */
- uint32_t rle;
-# define LZMA_SUBBLOCK_RLE_OFF 0
-# define LZMA_SUBBLOCK_RLE_MIN 1
-# define LZMA_SUBBLOCK_RLE_MAX 256
-
- /**
- * \brief Subfilter remote control
- *
- * When the Subblock filter is initialized, this variable must be
- * LZMA_SUBFILTER_NONE or LZMA_SUBFILTER_SET.
- *
- * When subfilter_mode is LZMA_SUBFILTER_NONE, the application may
- * put Subfilter options to subfilter_options structure, and then
- * set subfilter_mode to LZMA_SUBFILTER_SET. No new input data will
- * be read until the Subfilter has been enabled. Once the Subfilter
- * has been enabled, liblzma will set subfilter_mode to
- * LZMA_SUBFILTER_RUN.
- *
- * When subfilter_mode is LZMA_SUBFILTER_RUN, the application may
- * set subfilter_mode to LZMA_SUBFILTER_FINISH. All the input
- * currently available will be encoded before unsetting the
- * Subfilter. Application must not change the amount of available
- * input until the Subfilter has finished. Once the Subfilter has
- * finished, liblzma will set subfilter_mode to LZMA_SUBFILTER_NONE.
- *
- * If the intent is to have Subfilter enabled to the very end of
- * the data, it is not needed to separately disable Subfilter with
- * LZMA_SUBFILTER_FINISH. Using LZMA_FINISH as the second argument
- * of lzma_code() will make the Subblock encoder to disable the
- * Subfilter once all the data has been ran through the Subfilter.
- *
- * After the first call with LZMA_SYNC_FLUSH or LZMA_FINISH, the
- * application must not change subfilter_mode until LZMA_STREAM_END.
- * Setting LZMA_SUBFILTER_SET/LZMA_SUBFILTER_FINISH and
- * LZMA_SYNC_FLUSH/LZMA_FINISH _at the same time_ is fine.
- *
- * \note This variable is ignored if allow_subfilters is false.
- */
- lzma_subfilter_mode subfilter_mode;
-
- /**
- * \brief Subfilter and its options
- *
- * When no Subfilter is used, the data is copied as is into Subblocks.
- * Setting a Subfilter allows encoding some parts of the data with
- * an additional filter. It is possible to many different Subfilters
- * in the same Block, although only one can be used at once.
- *
- * \note This variable is ignored if allow_subfilters is false.
- */
- lzma_filter subfilter_options;
-
-} lzma_options_subblock;
diff --git a/Build/source/extra/xz/src/liblzma/api/lzma/version.h b/Build/source/extra/xz/src/liblzma/api/lzma/version.h
index 4959f6e8dbe..92266637760 100644
--- a/Build/source/extra/xz/src/liblzma/api/lzma/version.h
+++ b/Build/source/extra/xz/src/liblzma/api/lzma/version.h
@@ -22,7 +22,7 @@
*/
#define LZMA_VERSION_MAJOR 5
#define LZMA_VERSION_MINOR 0
-#define LZMA_VERSION_PATCH 2
+#define LZMA_VERSION_PATCH 3
#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE
#ifndef LZMA_VERSION_COMMIT
diff --git a/Build/source/extra/xz/src/liblzma/common/alone_decoder.c b/Build/source/extra/xz/src/liblzma/common/alone_decoder.c
index 039b4285954..678c79e6543 100644
--- a/Build/source/extra/xz/src/liblzma/common/alone_decoder.c
+++ b/Build/source/extra/xz/src/liblzma/common/alone_decoder.c
@@ -46,7 +46,7 @@ struct lzma_coder_s {
static lzma_ret
alone_decode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((unused)),
+ lzma_allocator *allocator lzma_attribute((__unused__)),
const uint8_t *restrict in, size_t *restrict in_pos,
size_t in_size, uint8_t *restrict out,
size_t *restrict out_pos, size_t out_size,
diff --git a/Build/source/extra/xz/src/liblzma/common/alone_encoder.c b/Build/source/extra/xz/src/liblzma/common/alone_encoder.c
index d8c0170f023..eb1697e9975 100644
--- a/Build/source/extra/xz/src/liblzma/common/alone_encoder.c
+++ b/Build/source/extra/xz/src/liblzma/common/alone_encoder.c
@@ -32,7 +32,7 @@ struct lzma_coder_s {
static lzma_ret
alone_encode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((unused)),
+ lzma_allocator *allocator lzma_attribute((__unused__)),
const uint8_t *restrict in, size_t *restrict in_pos,
size_t in_size, uint8_t *restrict out,
size_t *restrict out_pos, size_t out_size,
@@ -103,7 +103,7 @@ alone_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
if (options->dict_size < LZMA_DICT_SIZE_MIN)
return LZMA_OPTIONS_ERROR;
- // Round up to to the next 2^n or 2^n + 2^(n - 1) depending on which
+ // Round up to the next 2^n or 2^n + 2^(n - 1) depending on which
// one is the next unless it is UINT32_MAX. While the header would
// allow any 32-bit integer, we do this to keep the decoder of liblzma
// accepting the resulting files.
diff --git a/Build/source/extra/xz/src/liblzma/common/block_buffer_encoder.c b/Build/source/extra/xz/src/liblzma/common/block_buffer_encoder.c
index a8f71c2140e..519c6a684d7 100644
--- a/Build/source/extra/xz/src/liblzma/common/block_buffer_encoder.c
+++ b/Build/source/extra/xz/src/liblzma/common/block_buffer_encoder.c
@@ -226,16 +226,23 @@ lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
const uint8_t *in, size_t in_size,
uint8_t *out, size_t *out_pos, size_t out_size)
{
- // Sanity checks
- if (block == NULL || block->filters == NULL
- || (in == NULL && in_size != 0) || out == NULL
+ // Validate the arguments.
+ if (block == NULL || (in == NULL && in_size != 0) || out == NULL
|| out_pos == NULL || *out_pos > out_size)
return LZMA_PROG_ERROR;
- // Check the version field.
+ // The contents of the structure may depend on the version so
+ // check the version before validating the contents of *block.
if (block->version != 0)
return LZMA_OPTIONS_ERROR;
+ if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX
+ || block->filters == NULL)
+ return LZMA_PROG_ERROR;
+
+ if (!lzma_check_is_supported(block->check))
+ return LZMA_UNSUPPORTED_CHECK;
+
// Size of a Block has to be a multiple of four, so limit the size
// here already. This way we don't need to check it again when adding
// Block Padding.
@@ -243,8 +250,7 @@ lzma_block_buffer_encode(lzma_block *block, lzma_allocator *allocator,
// Get the size of the Check field.
const size_t check_size = lzma_check_size(block->check);
- if (check_size == UINT32_MAX)
- return LZMA_PROG_ERROR;
+ assert(check_size != UINT32_MAX);
// Reserve space for the Check field.
if (out_size - *out_pos <= check_size)
diff --git a/Build/source/extra/xz/src/liblzma/common/block_encoder.c b/Build/source/extra/xz/src/liblzma/common/block_encoder.c
index ca5152357e7..1eeb502b7f8 100644
--- a/Build/source/extra/xz/src/liblzma/common/block_encoder.c
+++ b/Build/source/extra/xz/src/liblzma/common/block_encoder.c
@@ -144,7 +144,7 @@ block_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
block_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
- const lzma_filter *filters lzma_attribute((unused)),
+ const lzma_filter *filters lzma_attribute((__unused__)),
const lzma_filter *reversed_filters)
{
if (coder->sequence != SEQ_CODE)
@@ -161,6 +161,11 @@ lzma_block_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
{
lzma_next_coder_init(&lzma_block_encoder_init, next, allocator);
+ if (block == NULL)
+ return LZMA_PROG_ERROR;
+
+ // The contents of the structure may depend on the version so
+ // check the version first.
if (block->version != 0)
return LZMA_OPTIONS_ERROR;
diff --git a/Build/source/extra/xz/src/liblzma/common/common.c b/Build/source/extra/xz/src/liblzma/common/common.c
index 0408e15328b..b9e38602736 100644
--- a/Build/source/extra/xz/src/liblzma/common/common.c
+++ b/Build/source/extra/xz/src/liblzma/common/common.c
@@ -35,7 +35,7 @@ lzma_version_string(void)
// Memory allocation //
///////////////////////
-extern void * lzma_attribute((malloc))
+extern void * lzma_attribute((__malloc__)) lzma_attr_alloc_size(1)
lzma_alloc(size_t size, lzma_allocator *allocator)
{
// Some malloc() variants return NULL if called with size == 0.
diff --git a/Build/source/extra/xz/src/liblzma/common/common.h b/Build/source/extra/xz/src/liblzma/common/common.h
index b819432371d..45aba4f06b2 100644
--- a/Build/source/extra/xz/src/liblzma/common/common.h
+++ b/Build/source/extra/xz/src/liblzma/common/common.h
@@ -205,7 +205,7 @@ struct lzma_internal_s {
/// Allocates memory
extern void *lzma_alloc(size_t size, lzma_allocator *allocator)
- lzma_attribute((malloc)) lzma_attr_alloc_size(1);
+ lzma_attribute((__malloc__)) lzma_attr_alloc_size(1);
/// Frees memory
extern void lzma_free(void *ptr, lzma_allocator *allocator);
diff --git a/Build/source/extra/xz/src/liblzma/common/filter_common.c b/Build/source/extra/xz/src/liblzma/common/filter_common.c
index b157c6280f8..7c95b05f2a3 100644
--- a/Build/source/extra/xz/src/liblzma/common/filter_common.c
+++ b/Build/source/extra/xz/src/liblzma/common/filter_common.c
@@ -43,7 +43,7 @@ static const struct {
.changes_size = true,
},
#endif
-#ifdef HAVE_DECODER_LZMA2
+#if defined(HAVE_ENCODER_LZMA2) || defined(HAVE_DECODER_LZMA2)
{
.id = LZMA_FILTER_LZMA2,
.options_size = sizeof(lzma_options_lzma),
@@ -52,7 +52,7 @@ static const struct {
.changes_size = true,
},
#endif
-#ifdef HAVE_DECODER_X86
+#if defined(HAVE_ENCODER_X86) || defined(HAVE_DECODER_X86)
{
.id = LZMA_FILTER_X86,
.options_size = sizeof(lzma_options_bcj),
@@ -70,7 +70,7 @@ static const struct {
.changes_size = false,
},
#endif
-#ifdef HAVE_DECODER_IA64
+#if defined(HAVE_ENCODER_IA64) || defined(HAVE_DECODER_IA64)
{
.id = LZMA_FILTER_IA64,
.options_size = sizeof(lzma_options_bcj),
diff --git a/Build/source/extra/xz/src/liblzma/common/index_decoder.c b/Build/source/extra/xz/src/liblzma/common/index_decoder.c
index a6bc650e046..83c8a3af1db 100644
--- a/Build/source/extra/xz/src/liblzma/common/index_decoder.c
+++ b/Build/source/extra/xz/src/liblzma/common/index_decoder.c
@@ -56,10 +56,11 @@ struct lzma_coder_s {
static lzma_ret
index_decode(lzma_coder *coder, lzma_allocator *allocator,
const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out lzma_attribute((unused)),
- size_t *restrict out_pos lzma_attribute((unused)),
- size_t out_size lzma_attribute((unused)),
- lzma_action action lzma_attribute((unused)))
+ size_t in_size,
+ uint8_t *restrict out lzma_attribute((__unused__)),
+ size_t *restrict out_pos lzma_attribute((__unused__)),
+ size_t out_size lzma_attribute((__unused__)),
+ lzma_action action lzma_attribute((__unused__)))
{
// Similar optimization as in index_encoder.c
const size_t in_start = *in_pos;
diff --git a/Build/source/extra/xz/src/liblzma/common/index_encoder.c b/Build/source/extra/xz/src/liblzma/common/index_encoder.c
index c10d7afa06b..45919f094c4 100644
--- a/Build/source/extra/xz/src/liblzma/common/index_encoder.c
+++ b/Build/source/extra/xz/src/liblzma/common/index_encoder.c
@@ -42,12 +42,13 @@ struct lzma_coder_s {
static lzma_ret
index_encode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((unused)),
- const uint8_t *restrict in lzma_attribute((unused)),
- size_t *restrict in_pos lzma_attribute((unused)),
- size_t in_size lzma_attribute((unused)),
+ lzma_allocator *allocator lzma_attribute((__unused__)),
+ const uint8_t *restrict in lzma_attribute((__unused__)),
+ size_t *restrict in_pos lzma_attribute((__unused__)),
+ size_t in_size lzma_attribute((__unused__)),
uint8_t *restrict out, size_t *restrict out_pos,
- size_t out_size, lzma_action action lzma_attribute((unused)))
+ size_t out_size,
+ lzma_action action lzma_attribute((__unused__)))
{
// Position where to start calculating CRC32. The idea is that we
// need to call lzma_crc32() only once per call to index_encode().
diff --git a/Build/source/extra/xz/src/liblzma/common/stream_buffer_encoder.c b/Build/source/extra/xz/src/liblzma/common/stream_buffer_encoder.c
index f727d8542b3..2450ee2e1fa 100644
--- a/Build/source/extra/xz/src/liblzma/common/stream_buffer_encoder.c
+++ b/Build/source/extra/xz/src/liblzma/common/stream_buffer_encoder.c
@@ -51,6 +51,9 @@ lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,
|| out_pos_ptr == NULL || *out_pos_ptr > out_size)
return LZMA_PROG_ERROR;
+ if (!lzma_check_is_supported(check))
+ return LZMA_UNSUPPORTED_CHECK;
+
// Note for the paranoids: Index encoder prevents the Stream from
// getting too big and still being accepted with LZMA_OK, and Block
// encoder catches if the input is too big. So we don't need to
@@ -81,26 +84,32 @@ lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,
out_pos += LZMA_STREAM_HEADER_SIZE;
- // Block
+ // Encode a Block but only if there is at least one byte of input.
lzma_block block = {
.version = 0,
.check = check,
.filters = filters,
};
- return_if_error(lzma_block_buffer_encode(&block, allocator,
- in, in_size, out, &out_pos, out_size));
+ if (in_size > 0)
+ return_if_error(lzma_block_buffer_encode(&block, allocator,
+ in, in_size, out, &out_pos, out_size));
// Index
{
- // Create an Index with one Record.
+ // Create an Index. It will have one Record if there was
+ // at least one byte of input to encode. Otherwise the
+ // Index will be empty.
lzma_index *i = lzma_index_init(allocator);
if (i == NULL)
return LZMA_MEM_ERROR;
- lzma_ret ret = lzma_index_append(i, allocator,
- lzma_block_unpadded_size(&block),
- block.uncompressed_size);
+ lzma_ret ret = LZMA_OK;
+
+ if (in_size > 0)
+ ret = lzma_index_append(i, allocator,
+ lzma_block_unpadded_size(&block),
+ block.uncompressed_size);
// If adding the Record was successful, encode the Index
// and get its size which will be stored into Stream Footer.
diff --git a/Build/source/extra/xz/src/liblzma/common/stream_encoder.c b/Build/source/extra/xz/src/liblzma/common/stream_encoder.c
index 48d91da7933..97a7a23a813 100644
--- a/Build/source/extra/xz/src/liblzma/common/stream_encoder.c
+++ b/Build/source/extra/xz/src/liblzma/common/stream_encoder.c
@@ -280,6 +280,7 @@ lzma_stream_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
next->end = &stream_encoder_end;
next->update = &stream_encoder_update;
+ next->coder->filters[0].id = LZMA_VLI_UNKNOWN;
next->coder->block_encoder = LZMA_NEXT_CODER_INIT;
next->coder->index_encoder = LZMA_NEXT_CODER_INIT;
next->coder->index = NULL;
@@ -289,7 +290,6 @@ lzma_stream_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
next->coder->sequence = SEQ_STREAM_HEADER;
next->coder->block_options.version = 0;
next->coder->block_options.check = check;
- next->coder->filters[0].id = LZMA_VLI_UNKNOWN;
// Initialize the Index
lzma_index_end(next->coder->index, allocator);
diff --git a/Build/source/extra/xz/src/liblzma/delta/delta_encoder.c b/Build/source/extra/xz/src/liblzma/delta/delta_encoder.c
index ea1cc2cb020..15c7951e104 100644
--- a/Build/source/extra/xz/src/liblzma/delta/delta_encoder.c
+++ b/Build/source/extra/xz/src/liblzma/delta/delta_encoder.c
@@ -85,7 +85,7 @@ delta_encode(lzma_coder *coder, lzma_allocator *allocator,
static lzma_ret
delta_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
- const lzma_filter *filters_null lzma_attribute((unused)),
+ const lzma_filter *filters_null lzma_attribute((__unused__)),
const lzma_filter *reversed_filters)
{
// Delta doesn't and will never support changing the options in
diff --git a/Build/source/extra/xz/src/liblzma/lz/lz_decoder.c b/Build/source/extra/xz/src/liblzma/lz/lz_decoder.c
index 2c57355125f..d74085cf447 100644
--- a/Build/source/extra/xz/src/liblzma/lz/lz_decoder.c
+++ b/Build/source/extra/xz/src/liblzma/lz/lz_decoder.c
@@ -126,7 +126,7 @@ decode_buffer(lzma_coder *coder,
static lzma_ret
lz_decode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((unused)),
+ lzma_allocator *allocator lzma_attribute((__unused__)),
const uint8_t *restrict in, size_t *restrict in_pos,
size_t in_size, uint8_t *restrict out,
size_t *restrict out_pos, size_t out_size,
diff --git a/Build/source/extra/xz/src/liblzma/lz/lz_encoder.c b/Build/source/extra/xz/src/liblzma/lz/lz_encoder.c
index 273f577b69b..e2406965882 100644
--- a/Build/source/extra/xz/src/liblzma/lz/lz_encoder.c
+++ b/Build/source/extra/xz/src/liblzma/lz/lz_encoder.c
@@ -480,7 +480,7 @@ lz_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
lz_encoder_update(lzma_coder *coder, lzma_allocator *allocator,
- const lzma_filter *filters_null lzma_attribute((unused)),
+ const lzma_filter *filters_null lzma_attribute((__unused__)),
const lzma_filter *reversed_filters)
{
if (coder->lz.options_update == NULL)
diff --git a/Build/source/extra/xz/src/liblzma/lzma/lzma2_encoder.c b/Build/source/extra/xz/src/liblzma/lzma/lzma2_encoder.c
index b48e0d6894f..992720ca6d5 100644
--- a/Build/source/extra/xz/src/liblzma/lzma/lzma2_encoder.c
+++ b/Build/source/extra/xz/src/liblzma/lzma/lzma2_encoder.c
@@ -374,7 +374,7 @@ lzma_lzma2_props_encode(const void *options, uint8_t *out)
const lzma_options_lzma *const opt = options;
uint32_t d = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN);
- // Round up to to the next 2^n - 1 or 2^n + 2^(n - 1) - 1 depending
+ // Round up to the next 2^n - 1 or 2^n + 2^(n - 1) - 1 depending
// on which one is the next:
--d;
d |= d >> 2;
diff --git a/Build/source/extra/xz/src/liblzma/simple/arm.c b/Build/source/extra/xz/src/liblzma/simple/arm.c
index 8fcf6437491..a84702ac62f 100644
--- a/Build/source/extra/xz/src/liblzma/simple/arm.c
+++ b/Build/source/extra/xz/src/liblzma/simple/arm.c
@@ -15,7 +15,7 @@
static size_t
-arm_code(lzma_simple *simple lzma_attribute((unused)),
+arm_code(lzma_simple *simple lzma_attribute((__unused__)),
uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
diff --git a/Build/source/extra/xz/src/liblzma/simple/armthumb.c b/Build/source/extra/xz/src/liblzma/simple/armthumb.c
index eb6a69d1282..4b49175fec4 100644
--- a/Build/source/extra/xz/src/liblzma/simple/armthumb.c
+++ b/Build/source/extra/xz/src/liblzma/simple/armthumb.c
@@ -15,7 +15,7 @@
static size_t
-armthumb_code(lzma_simple *simple lzma_attribute((unused)),
+armthumb_code(lzma_simple *simple lzma_attribute((__unused__)),
uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
diff --git a/Build/source/extra/xz/src/liblzma/simple/ia64.c b/Build/source/extra/xz/src/liblzma/simple/ia64.c
index fd263d4aea0..ce3692b98f1 100644
--- a/Build/source/extra/xz/src/liblzma/simple/ia64.c
+++ b/Build/source/extra/xz/src/liblzma/simple/ia64.c
@@ -15,7 +15,7 @@
static size_t
-ia64_code(lzma_simple *simple lzma_attribute((unused)),
+ia64_code(lzma_simple *simple lzma_attribute((__unused__)),
uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
diff --git a/Build/source/extra/xz/src/liblzma/simple/powerpc.c b/Build/source/extra/xz/src/liblzma/simple/powerpc.c
index aaa14f22197..6f8351176c5 100644
--- a/Build/source/extra/xz/src/liblzma/simple/powerpc.c
+++ b/Build/source/extra/xz/src/liblzma/simple/powerpc.c
@@ -15,7 +15,7 @@
static size_t
-powerpc_code(lzma_simple *simple lzma_attribute((unused)),
+powerpc_code(lzma_simple *simple lzma_attribute((__unused__)),
uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
diff --git a/Build/source/extra/xz/src/liblzma/simple/simple_coder.c b/Build/source/extra/xz/src/liblzma/simple/simple_coder.c
index 06db86ec2d0..37de7fa1a0c 100644
--- a/Build/source/extra/xz/src/liblzma/simple/simple_coder.c
+++ b/Build/source/extra/xz/src/liblzma/simple/simple_coder.c
@@ -212,7 +212,7 @@ simple_coder_end(lzma_coder *coder, lzma_allocator *allocator)
static lzma_ret
simple_coder_update(lzma_coder *coder, lzma_allocator *allocator,
- const lzma_filter *filters_null lzma_attribute((unused)),
+ const lzma_filter *filters_null lzma_attribute((__unused__)),
const lzma_filter *reversed_filters)
{
// No update support, just call the next filter in the chain.
diff --git a/Build/source/extra/xz/src/liblzma/simple/sparc.c b/Build/source/extra/xz/src/liblzma/simple/sparc.c
index 808a59aaac7..8270d6ab19f 100644
--- a/Build/source/extra/xz/src/liblzma/simple/sparc.c
+++ b/Build/source/extra/xz/src/liblzma/simple/sparc.c
@@ -15,7 +15,7 @@
static size_t
-sparc_code(lzma_simple *simple lzma_attribute((unused)),
+sparc_code(lzma_simple *simple lzma_attribute((__unused__)),
uint32_t now_pos, bool is_encoder,
uint8_t *buffer, size_t size)
{
diff --git a/Build/source/extra/xz/src/liblzma/subblock/Makefile.inc b/Build/source/extra/xz/src/liblzma/subblock/Makefile.inc
deleted file mode 100644
index a4710cc5955..00000000000
--- a/Build/source/extra/xz/src/liblzma/subblock/Makefile.inc
+++ /dev/null
@@ -1,20 +0,0 @@
-##
-## Author: Lasse Collin
-##
-## This file has been put into the public domain.
-## You can do whatever you want with this file.
-##
-
-if COND_ENCODER_SUBBLOCK
-liblzma_la_SOURCES += \
- subblock/subblock_encoder.c \
- subblock/subblock_encoder.h
-endif
-
-if COND_DECODER_SUBBLOCK
-liblzma_la_SOURCES += \
- subblock/subblock_decoder.c \
- subblock/subblock_decoder.h \
- subblock/subblock_decoder_helper.c \
- subblock/subblock_decoder_helper.h
-endif
diff --git a/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder.c b/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder.c
deleted file mode 100644
index e055cee3ea7..00000000000
--- a/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder.c
+++ /dev/null
@@ -1,630 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file subblock_decoder.c
-/// \brief Decoder of the Subblock filter
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "subblock_decoder.h"
-#include "subblock_decoder_helper.h"
-#include "filter_decoder.h"
-
-
-/// Maximum number of consecutive Subblocks with Subblock Type Padding
-#define PADDING_MAX 31
-
-
-struct lzma_coder_s {
- lzma_next_coder next;
-
- enum {
- // These require that there is at least one input
- // byte available.
- SEQ_FLAGS,
- SEQ_FILTER_FLAGS,
- SEQ_FILTER_END,
- SEQ_REPEAT_COUNT_1,
- SEQ_REPEAT_COUNT_2,
- SEQ_REPEAT_COUNT_3,
- SEQ_REPEAT_SIZE,
- SEQ_REPEAT_READ_DATA,
- SEQ_SIZE_1,
- SEQ_SIZE_2,
- SEQ_SIZE_3, // This must be right before SEQ_DATA.
-
- // These don't require any input to be available.
- SEQ_DATA,
- SEQ_REPEAT_FAST,
- SEQ_REPEAT_NORMAL,
- } sequence;
-
- /// Number of bytes left in the current Subblock Data field.
- size_t size;
-
- /// Number of consecutive Subblocks with Subblock Type Padding
- uint32_t padding;
-
- /// True when .next.code() has returned LZMA_STREAM_END.
- bool next_finished;
-
- /// True when the Subblock decoder has detected End of Payload Marker.
- /// This may become true before next_finished becomes true.
- bool this_finished;
-
- /// True if Subfilters are allowed.
- bool allow_subfilters;
-
- /// Indicates if at least one byte of decoded output has been
- /// produced after enabling Subfilter.
- bool got_output_with_subfilter;
-
- /// Possible subfilter
- lzma_next_coder subfilter;
-
- /// Filter Flags decoder is needed to parse the ID and Properties
- /// of the subfilter.
- lzma_next_coder filter_flags_decoder;
-
- /// The filter_flags_decoder stores its results here.
- lzma_filter filter_flags;
-
- /// Options for the Subblock decoder helper. This is used to tell
- /// the helper when it should return LZMA_STREAM_END to the subfilter.
- lzma_options_subblock_helper helper;
-
- struct {
- /// How many times buffer should be repeated
- size_t count;
-
- /// Size of the buffer
- size_t size;
-
- /// Position in the buffer
- size_t pos;
-
- /// Buffer to hold the data to be repeated
- uint8_t buffer[LZMA_SUBBLOCK_RLE_MAX];
- } repeat;
-
- /// Temporary buffer needed when the Subblock filter is not the last
- /// filter in the chain. The output of the next filter is first
- /// decoded into buffer[], which is then used as input for the actual
- /// Subblock decoder.
- struct {
- size_t pos;
- size_t size;
- uint8_t buffer[LZMA_BUFFER_SIZE];
- } temp;
-};
-
-
-/// Values of valid Subblock Flags
-enum {
- FLAG_PADDING,
- FLAG_EOPM,
- FLAG_DATA,
- FLAG_REPEAT,
- FLAG_SET_SUBFILTER,
- FLAG_END_SUBFILTER,
-};
-
-
-/// Calls the subfilter and updates coder->uncompressed_size.
-static lzma_ret
-subfilter_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- assert(coder->subfilter.code != NULL);
-
- // Call the subfilter.
- const lzma_ret ret = coder->subfilter.code(
- coder->subfilter.coder, allocator,
- in, in_pos, in_size, out, out_pos, out_size, action);
-
- return ret;
-}
-
-
-static lzma_ret
-decode_buffer(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *in, size_t *in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- while (*out_pos < out_size && (*in_pos < in_size
- || coder->sequence >= SEQ_DATA))
- switch (coder->sequence) {
- case SEQ_FLAGS: {
- // Do the correct action depending on the Subblock Type.
- switch (in[*in_pos] >> 4) {
- case FLAG_PADDING:
- // Only check that reserved bits are zero.
- if (++coder->padding > PADDING_MAX
- || in[*in_pos] & 0x0F)
- return LZMA_DATA_ERROR;
- ++*in_pos;
- break;
-
- case FLAG_EOPM:
- // There must be no Padding before EOPM.
- if (coder->padding != 0)
- return LZMA_DATA_ERROR;
-
- // Check that reserved bits are zero.
- if (in[*in_pos] & 0x0F)
- return LZMA_DATA_ERROR;
-
- // There must be no Subfilter enabled.
- if (coder->subfilter.code != NULL)
- return LZMA_DATA_ERROR;
-
- ++*in_pos;
- return LZMA_STREAM_END;
-
- case FLAG_DATA:
- // First four bits of the Subblock Data size.
- coder->size = in[*in_pos] & 0x0F;
- ++*in_pos;
- coder->got_output_with_subfilter = true;
- coder->sequence = SEQ_SIZE_1;
- break;
-
- case FLAG_REPEAT:
- // First four bits of the Repeat Count. We use
- // coder->size as a temporary place for it.
- coder->size = in[*in_pos] & 0x0F;
- ++*in_pos;
- coder->got_output_with_subfilter = true;
- coder->sequence = SEQ_REPEAT_COUNT_1;
- break;
-
- case FLAG_SET_SUBFILTER: {
- if (coder->padding != 0 || (in[*in_pos] & 0x0F)
- || coder->subfilter.code != NULL
- || !coder->allow_subfilters)
- return LZMA_DATA_ERROR;
-
- assert(coder->filter_flags.options == NULL);
- abort();
-// return_if_error(lzma_filter_flags_decoder_init(
-// &coder->filter_flags_decoder,
-// allocator, &coder->filter_flags));
-
- coder->got_output_with_subfilter = false;
-
- ++*in_pos;
- coder->sequence = SEQ_FILTER_FLAGS;
- break;
- }
-
- case FLAG_END_SUBFILTER: {
- if (coder->padding != 0 || (in[*in_pos] & 0x0F)
- || coder->subfilter.code == NULL
- || !coder->got_output_with_subfilter)
- return LZMA_DATA_ERROR;
-
- // Tell the helper filter to indicate End of Input
- // to our subfilter.
- coder->helper.end_was_reached = true;
-
- size_t dummy = 0;
- const lzma_ret ret = subfilter_decode(coder, allocator,
- NULL, &dummy, 0, out, out_pos,out_size,
- action);
-
- // If we didn't reach the end of the subfilter's output
- // yet, return to the application. On the next call we
- // will get to this same switch-case again, because we
- // haven't updated *in_pos yet.
- if (ret != LZMA_STREAM_END)
- return ret;
-
- // Free Subfilter's memory. This is a bit debatable,
- // since we could avoid some malloc()/free() calls
- // if the same Subfilter gets used soon again. But
- // if Subfilter isn't used again, we could leave
- // a memory-hogging filter dangling until someone
- // frees Subblock filter itself.
- lzma_next_end(&coder->subfilter, allocator);
-
- // Free memory used for subfilter options. This is
- // safe, because we don't support any Subfilter that
- // would allow pointers in the options structure.
- lzma_free(coder->filter_flags.options, allocator);
- coder->filter_flags.options = NULL;
-
- ++*in_pos;
-
- break;
- }
-
- default:
- return LZMA_DATA_ERROR;
- }
-
- break;
- }
-
- case SEQ_FILTER_FLAGS: {
- const lzma_ret ret = coder->filter_flags_decoder.code(
- coder->filter_flags_decoder.coder, allocator,
- in, in_pos, in_size, NULL, NULL, 0, LZMA_RUN);
- if (ret != LZMA_STREAM_END)
- return ret == LZMA_OPTIONS_ERROR
- ? LZMA_DATA_ERROR : ret;
-
- // Don't free the filter_flags_decoder. It doesn't take much
- // memory and we may need it again.
-
- // Initialize the Subfilter. Subblock and Copy filters are
- // not allowed.
- if (coder->filter_flags.id == LZMA_FILTER_SUBBLOCK)
- return LZMA_DATA_ERROR;
-
- coder->helper.end_was_reached = false;
-
- lzma_filter filters[3] = {
- {
- .id = coder->filter_flags.id,
- .options = coder->filter_flags.options,
- }, {
- .id = LZMA_FILTER_SUBBLOCK_HELPER,
- .options = &coder->helper,
- }, {
- .id = LZMA_VLI_UNKNOWN,
- .options = NULL,
- }
- };
-
- // Optimization: We know that LZMA uses End of Payload Marker
- // (not End of Input), so we can omit the helper filter.
- if (filters[0].id == LZMA_FILTER_LZMA1)
- filters[1].id = LZMA_VLI_UNKNOWN;
-
- return_if_error(lzma_raw_decoder_init(
- &coder->subfilter, allocator, filters));
-
- coder->sequence = SEQ_FLAGS;
- break;
- }
-
- case SEQ_FILTER_END:
- // We are in the beginning of a Subblock. The next Subblock
- // whose type is not Padding, must indicate end of Subfilter.
- if (in[*in_pos] == (FLAG_PADDING << 4)) {
- ++*in_pos;
- break;
- }
-
- if (in[*in_pos] != (FLAG_END_SUBFILTER << 4))
- return LZMA_DATA_ERROR;
-
- coder->sequence = SEQ_FLAGS;
- break;
-
- case SEQ_REPEAT_COUNT_1:
- case SEQ_SIZE_1:
- // We use the same code to parse
- // - the Size (28 bits) in Subblocks of type Data; and
- // - the Repeat count (28 bits) in Subblocks of type
- // Repeating Data.
- coder->size |= (size_t)(in[*in_pos]) << 4;
- ++*in_pos;
- ++coder->sequence;
- break;
-
- case SEQ_REPEAT_COUNT_2:
- case SEQ_SIZE_2:
- coder->size |= (size_t)(in[*in_pos]) << 12;
- ++*in_pos;
- ++coder->sequence;
- break;
-
- case SEQ_REPEAT_COUNT_3:
- case SEQ_SIZE_3:
- coder->size |= (size_t)(in[*in_pos]) << 20;
- ++*in_pos;
-
- // The real value is the stored value plus one.
- ++coder->size;
-
- // This moves to SEQ_REPEAT_SIZE or SEQ_DATA. That's why
- // SEQ_DATA must be right after SEQ_SIZE_3 in coder->sequence.
- ++coder->sequence;
- break;
-
- case SEQ_REPEAT_SIZE:
- // Move the Repeat Count to the correct variable and parse
- // the Size of the Data to be repeated.
- coder->repeat.count = coder->size;
- coder->repeat.size = (size_t)(in[*in_pos]) + 1;
- coder->repeat.pos = 0;
-
- // The size of the Data field must be bigger than the number
- // of Padding bytes before this Subblock.
- if (coder->repeat.size <= coder->padding)
- return LZMA_DATA_ERROR;
-
- ++*in_pos;
- coder->padding = 0;
- coder->sequence = SEQ_REPEAT_READ_DATA;
- break;
-
- case SEQ_REPEAT_READ_DATA: {
- // Fill coder->repeat.buffer[].
- const size_t in_avail = in_size - *in_pos;
- const size_t out_avail
- = coder->repeat.size - coder->repeat.pos;
- const size_t copy_size = MIN(in_avail, out_avail);
-
- memcpy(coder->repeat.buffer + coder->repeat.pos,
- in + *in_pos, copy_size);
- *in_pos += copy_size;
- coder->repeat.pos += copy_size;
-
- if (coder->repeat.pos == coder->repeat.size) {
- coder->repeat.pos = 0;
-
- if (coder->repeat.size == 1
- && coder->subfilter.code == NULL)
- coder->sequence = SEQ_REPEAT_FAST;
- else
- coder->sequence = SEQ_REPEAT_NORMAL;
- }
-
- break;
- }
-
- case SEQ_DATA: {
- // The size of the Data field must be bigger than the number
- // of Padding bytes before this Subblock.
- assert(coder->size > 0);
- if (coder->size <= coder->padding)
- return LZMA_DATA_ERROR;
-
- coder->padding = 0;
-
- // Limit the amount of input to match the available
- // Subblock Data size.
- size_t in_limit;
- if (in_size - *in_pos > coder->size)
- in_limit = *in_pos + coder->size;
- else
- in_limit = in_size;
-
- if (coder->subfilter.code == NULL) {
- const size_t copy_size = lzma_bufcpy(
- in, in_pos, in_limit,
- out, out_pos, out_size);
-
- coder->size -= copy_size;
- } else {
- const size_t in_start = *in_pos;
- const lzma_ret ret = subfilter_decode(
- coder, allocator,
- in, in_pos, in_limit,
- out, out_pos, out_size,
- action);
-
- // Update the number of unprocessed bytes left in
- // this Subblock. This assert() is true because
- // in_limit prevents *in_pos getting too big.
- assert(*in_pos - in_start <= coder->size);
- coder->size -= *in_pos - in_start;
-
- if (ret == LZMA_STREAM_END) {
- // End of Subfilter can occur only at
- // a Subblock boundary.
- if (coder->size != 0)
- return LZMA_DATA_ERROR;
-
- // We need a Subblock with Unset
- // Subfilter before more data.
- coder->sequence = SEQ_FILTER_END;
- break;
- }
-
- if (ret != LZMA_OK)
- return ret;
- }
-
- // If we couldn't process the whole Subblock Data yet, return.
- if (coder->size > 0)
- return LZMA_OK;
-
- coder->sequence = SEQ_FLAGS;
- break;
- }
-
- case SEQ_REPEAT_FAST: {
- // Optimization for cases when there is only one byte to
- // repeat and no Subfilter.
- const size_t out_avail = out_size - *out_pos;
- const size_t copy_size = MIN(coder->repeat.count, out_avail);
-
- memset(out + *out_pos, coder->repeat.buffer[0], copy_size);
-
- *out_pos += copy_size;
- coder->repeat.count -= copy_size;
-
- if (coder->repeat.count != 0)
- return LZMA_OK;
-
- coder->sequence = SEQ_FLAGS;
- break;
- }
-
- case SEQ_REPEAT_NORMAL:
- do {
- // Cycle the repeat buffer if needed.
- if (coder->repeat.pos == coder->repeat.size) {
- if (--coder->repeat.count == 0) {
- coder->sequence = SEQ_FLAGS;
- break;
- }
-
- coder->repeat.pos = 0;
- }
-
- if (coder->subfilter.code == NULL) {
- lzma_bufcpy(coder->repeat.buffer,
- &coder->repeat.pos,
- coder->repeat.size,
- out, out_pos, out_size);
- } else {
- const lzma_ret ret = subfilter_decode(
- coder, allocator,
- coder->repeat.buffer,
- &coder->repeat.pos,
- coder->repeat.size,
- out, out_pos, out_size,
- action);
-
- if (ret == LZMA_STREAM_END) {
- // End of Subfilter can occur only at
- // a Subblock boundary.
- if (coder->repeat.pos
- != coder->repeat.size
- || --coder->repeat
- .count != 0)
- return LZMA_DATA_ERROR;
-
- // We need a Subblock with Unset
- // Subfilter before more data.
- coder->sequence = SEQ_FILTER_END;
- break;
-
- } else if (ret != LZMA_OK) {
- return ret;
- }
- }
- } while (*out_pos < out_size);
-
- break;
-
- default:
- return LZMA_PROG_ERROR;
- }
-
- return LZMA_OK;
-}
-
-
-static lzma_ret
-subblock_decode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- if (coder->next.code == NULL)
- return decode_buffer(coder, allocator, in, in_pos, in_size,
- out, out_pos, out_size, action);
-
- while (*out_pos < out_size) {
- if (!coder->next_finished
- && coder->temp.pos == coder->temp.size) {
- coder->temp.pos = 0;
- coder->temp.size = 0;
-
- const lzma_ret ret = coder->next.code(
- coder->next.coder,
- allocator, in, in_pos, in_size,
- coder->temp.buffer, &coder->temp.size,
- LZMA_BUFFER_SIZE, action);
-
- if (ret == LZMA_STREAM_END)
- coder->next_finished = true;
- else if (coder->temp.size == 0 || ret != LZMA_OK)
- return ret;
- }
-
- if (coder->this_finished) {
- if (coder->temp.pos != coder->temp.size)
- return LZMA_DATA_ERROR;
-
- if (coder->next_finished)
- return LZMA_STREAM_END;
-
- return LZMA_OK;
- }
-
- const lzma_ret ret = decode_buffer(coder, allocator,
- coder->temp.buffer, &coder->temp.pos,
- coder->temp.size,
- out, out_pos, out_size, action);
-
- if (ret == LZMA_STREAM_END)
- // The next coder in the chain hasn't finished
- // yet. If the input data is valid, there
- // must be no more output coming, but the
- // next coder may still need a litle more
- // input to detect End of Payload Marker.
- coder->this_finished = true;
- else if (ret != LZMA_OK)
- return ret;
- else if (coder->next_finished && *out_pos < out_size)
- return LZMA_DATA_ERROR;
- }
-
- return LZMA_OK;
-}
-
-
-static void
-subblock_decoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
- lzma_next_end(&coder->subfilter, allocator);
- lzma_next_end(&coder->filter_flags_decoder, allocator);
- lzma_free(coder->filter_flags.options, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-extern lzma_ret
-lzma_subblock_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &subblock_decode;
- next->end = &subblock_decoder_end;
-
- next->coder->next = LZMA_NEXT_CODER_INIT;
- next->coder->subfilter = LZMA_NEXT_CODER_INIT;
- next->coder->filter_flags_decoder = LZMA_NEXT_CODER_INIT;
-
- } else {
- lzma_next_end(&next->coder->subfilter, allocator);
- lzma_free(next->coder->filter_flags.options, allocator);
- }
-
- next->coder->filter_flags.options = NULL;
-
- next->coder->sequence = SEQ_FLAGS;
- next->coder->padding = 0;
- next->coder->next_finished = false;
- next->coder->this_finished = false;
- next->coder->temp.pos = 0;
- next->coder->temp.size = 0;
-
- if (filters[0].options != NULL)
- next->coder->allow_subfilters = ((lzma_options_subblock *)(
- filters[0].options))->allow_subfilters;
- else
- next->coder->allow_subfilters = false;
-
- return lzma_next_filter_init(
- &next->coder->next, allocator, filters + 1);
-}
diff --git a/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder.h b/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder.h
deleted file mode 100644
index d1030b2b94f..00000000000
--- a/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder.h
+++ /dev/null
@@ -1,22 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file subblock_decoder.h
-/// \brief Decoder of the Subblock filter
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_SUBBLOCK_DECODER_H
-#define LZMA_SUBBLOCK_DECODER_H
-
-#include "common.h"
-
-
-extern lzma_ret lzma_subblock_decoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-#endif
diff --git a/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder_helper.c b/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder_helper.c
deleted file mode 100644
index 2a864eddad9..00000000000
--- a/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder_helper.c
+++ /dev/null
@@ -1,70 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file subblock_decoder_helper.c
-/// \brief Helper filter for the Subblock decoder
-///
-/// This filter is used to indicate End of Input for subfilters needing it.
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "subblock_decoder_helper.h"
-
-
-struct lzma_coder_s {
- const lzma_options_subblock_helper *options;
-};
-
-
-static lzma_ret
-helper_decode(lzma_coder *coder,
- lzma_allocator *allocator lzma_attribute((unused)),
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size,
- lzma_action action lzma_attribute((unused)))
-{
- // If end_was_reached is true, we cannot have any input.
- assert(!coder->options->end_was_reached || *in_pos == in_size);
-
- // We can safely copy as much as possible, because we are never
- // given more data than a single Subblock Data field.
- lzma_bufcpy(in, in_pos, in_size, out, out_pos, out_size);
-
- // Return LZMA_STREAM_END when instructed so by the Subblock decoder.
- return coder->options->end_was_reached ? LZMA_STREAM_END : LZMA_OK;
-}
-
-
-static void
-helper_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_free(coder, allocator);
- return;
-}
-
-
-extern lzma_ret
-lzma_subblock_decoder_helper_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters)
-{
- // This is always the last filter in the chain.
- assert(filters[1].init == NULL);
-
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &helper_decode;
- next->end = &helper_end;
- }
-
- next->coder->options = filters[0].options;
-
- return LZMA_OK;
-}
diff --git a/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder_helper.h b/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder_helper.h
deleted file mode 100644
index 18dcbb39a39..00000000000
--- a/Build/source/extra/xz/src/liblzma/subblock/subblock_decoder_helper.h
+++ /dev/null
@@ -1,29 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file subblock_decoder_helper.h
-/// \brief Helper filter for the Subblock decoder
-///
-/// This filter is used to indicate End of Input for subfilters needing it.
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_SUBBLOCK_DECODER_HELPER_H
-#define LZMA_SUBBLOCK_DECODER_HELPER_H
-
-#include "common.h"
-
-
-typedef struct {
- bool end_was_reached;
-} lzma_options_subblock_helper;
-
-
-extern lzma_ret lzma_subblock_decoder_helper_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-#endif
diff --git a/Build/source/extra/xz/src/liblzma/subblock/subblock_encoder.c b/Build/source/extra/xz/src/liblzma/subblock/subblock_encoder.c
deleted file mode 100644
index 4f71f99cc63..00000000000
--- a/Build/source/extra/xz/src/liblzma/subblock/subblock_encoder.c
+++ /dev/null
@@ -1,984 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file subblock_encoder.c
-/// \brief Encoder of the Subblock filter
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include "subblock_encoder.h"
-#include "filter_encoder.h"
-
-
-/// Maximum number of repeats that a single Repeating Data can indicate.
-/// This is directly from the file format specification.
-#define REPEAT_COUNT_MAX (1U << 28)
-
-/// Number of bytes the data chunk (not including the header part) must be
-/// before we care about alignment. This is somewhat arbitrary. It just
-/// doesn't make sense to waste bytes for alignment when the data chunk
-/// is very small.
-#define MIN_CHUNK_SIZE_FOR_ALIGN 4
-
-/// Number of bytes of the header part of Subblock Type `Data'. This is
-/// used as the `skew' argument for subblock_align().
-#define ALIGN_SKEW_DATA 4
-
-/// Like above but for Repeating Data.
-#define ALIGN_SKEW_REPEATING_DATA 5
-
-/// Writes one byte to output buffer and updates the alignment counter.
-#define write_byte(b) \
-do { \
- assert(*out_pos < out_size); \
- out[*out_pos] = b; \
- ++*out_pos; \
- ++coder->alignment.out_pos; \
-} while (0)
-
-
-struct lzma_coder_s {
- lzma_next_coder next;
- bool next_finished;
-
- enum {
- SEQ_FILL,
- SEQ_FLUSH,
- SEQ_RLE_COUNT_0,
- SEQ_RLE_COUNT_1,
- SEQ_RLE_COUNT_2,
- SEQ_RLE_COUNT_3,
- SEQ_RLE_SIZE,
- SEQ_RLE_DATA,
- SEQ_DATA_SIZE_0,
- SEQ_DATA_SIZE_1,
- SEQ_DATA_SIZE_2,
- SEQ_DATA_SIZE_3,
- SEQ_DATA,
- SEQ_SUBFILTER_INIT,
- SEQ_SUBFILTER_FLAGS,
- } sequence;
-
- /// Pointer to the options given by the application. This is used
- /// for two-way communication with the application.
- lzma_options_subblock *options;
-
- /// Position in various arrays.
- size_t pos;
-
- /// Holds subblock.size - 1 or rle.size - 1 when encoding size
- /// of Data or Repeat Count.
- uint32_t tmp;
-
- struct {
- /// This is a copy of options->alignment, or
- /// LZMA_SUBBLOCK_ALIGNMENT_DEFAULT if options is NULL.
- uint32_t multiple;
-
- /// Number of input bytes which we have processed and started
- /// writing out. 32-bit integer is enough since we care only
- /// about the lowest bits when fixing alignment.
- uint32_t in_pos;
-
- /// Number of bytes written out.
- uint32_t out_pos;
- } alignment;
-
- struct {
- /// Pointer to allocated buffer holding the Data field
- /// of Subblock Type "Data".
- uint8_t *data;
-
- /// Number of bytes in the buffer.
- size_t size;
-
- /// Allocated size of the buffer.
- size_t limit;
-
- /// Number of input bytes that we have already read but
- /// not yet started writing out. This can be different
- /// to `size' when using Subfilter. That's why we track
- /// in_pending separately for RLE (see below).
- uint32_t in_pending;
- } subblock;
-
- struct {
- /// Buffer to hold the data that may be coded with
- /// Subblock Type `Repeating Data'.
- uint8_t buffer[LZMA_SUBBLOCK_RLE_MAX];
-
- /// Number of bytes in buffer[].
- size_t size;
-
- /// Number of times the first `size' bytes of buffer[]
- /// will be repeated.
- uint64_t count;
-
- /// Like subblock.in_pending above, but for RLE.
- uint32_t in_pending;
- } rle;
-
- struct {
- enum {
- SUB_NONE,
- SUB_SET,
- SUB_RUN,
- SUB_FLUSH,
- SUB_FINISH,
- SUB_END_MARKER,
- } mode;
-
- /// This is a copy of options->allow_subfilters. We use
- /// this to verify that the application doesn't change
- /// the value of allow_subfilters.
- bool allow;
-
- /// When this is true, application is not allowed to modify
- /// options->subblock_mode. We may still modify it here.
- bool mode_locked;
-
- /// True if we have encoded at least one byte of data with
- /// the Subfilter.
- bool got_input;
-
- /// Track the amount of input available once
- /// LZMA_SUBFILTER_FINISH has been enabled.
- /// This is needed for sanity checking (kind
- /// of duplicating what common/code.c does).
- size_t in_avail;
-
- /// Buffer for the Filter Flags field written after
- /// the `Set Subfilter' indicator.
- uint8_t *flags;
-
- /// Size of Filter Flags field.
- uint32_t flags_size;
-
- /// Pointers to Subfilter.
- lzma_next_coder subcoder;
-
- } subfilter;
-
- /// Temporary buffer used when we are not the last filter in the chain.
- struct {
- size_t pos;
- size_t size;
- uint8_t buffer[LZMA_BUFFER_SIZE];
- } temp;
-};
-
-
-/// \brief Aligns the output buffer
-///
-/// Aligns the output buffer so that after skew bytes the output position is
-/// a multiple of coder->alignment.multiple.
-static bool
-subblock_align(lzma_coder *coder, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size,
- size_t chunk_size, uint32_t skew)
-{
- assert(*out_pos < out_size);
-
- // Fix the alignment only if it makes sense at least a little.
- if (chunk_size >= MIN_CHUNK_SIZE_FOR_ALIGN) {
- const uint32_t target = coder->alignment.in_pos
- % coder->alignment.multiple;
-
- while ((coder->alignment.out_pos + skew)
- % coder->alignment.multiple != target) {
- // Zero indicates padding.
- write_byte(0x00);
-
- // Check if output buffer got full and indicate it to
- // the caller.
- if (*out_pos == out_size)
- return true;
- }
- }
-
- // Output buffer is not full.
- return false;
-}
-
-
-/// \brief Checks if buffer contains repeated data
-///
-/// \param needle Buffer containing a single repeat chunk
-/// \param needle_size Size of needle in bytes
-/// \param buf Buffer to search for repeated needles
-/// \param buf_chunks Buffer size is buf_chunks * needle_size.
-///
-/// \return True if the whole buf is filled with repeated needles.
-///
-static bool
-is_repeating(const uint8_t *restrict needle, size_t needle_size,
- const uint8_t *restrict buf, size_t buf_chunks)
-{
- while (buf_chunks-- != 0) {
- if (memcmp(buf, needle, needle_size) != 0)
- return false;
-
- buf += needle_size;
- }
-
- return true;
-}
-
-
-/// \brief Optimizes the repeating style and updates coder->sequence
-static void
-subblock_rle_flush(lzma_coder *coder)
-{
- // The Subblock decoder can use memset() when the size of the data
- // being repeated is one byte, so we check if the RLE buffer is
- // filled with a single repeating byte.
- if (coder->rle.size > 1) {
- const uint8_t b = coder->rle.buffer[0];
- size_t i = 0;
- while (true) {
- if (coder->rle.buffer[i] != b)
- break;
-
- if (++i == coder->rle.size) {
- // TODO Integer overflow check maybe,
- // although this needs at least 2**63 bytes
- // of input until it gets triggered...
- coder->rle.count *= coder->rle.size;
- coder->rle.size = 1;
- break;
- }
- }
- }
-
- if (coder->rle.count == 1) {
- // The buffer should be repeated only once. It is
- // waste of space to use Repeating Data. Instead,
- // write a regular Data Subblock. See SEQ_RLE_COUNT_0
- // in subblock_buffer() for more info.
- coder->tmp = coder->rle.size - 1;
- } else if (coder->rle.count > REPEAT_COUNT_MAX) {
- // There's so much to repeat that it doesn't fit into
- // 28-bit integer. We will write two or more Subblocks
- // of type Repeating Data.
- coder->tmp = REPEAT_COUNT_MAX - 1;
- } else {
- coder->tmp = coder->rle.count - 1;
- }
-
- coder->sequence = SEQ_RLE_COUNT_0;
-
- return;
-}
-
-
-/// \brief Resizes coder->subblock.data for a new size limit
-static lzma_ret
-subblock_data_size(lzma_coder *coder, lzma_allocator *allocator,
- size_t new_limit)
-{
- // Verify that the new limit is valid.
- if (new_limit < LZMA_SUBBLOCK_DATA_SIZE_MIN
- || new_limit > LZMA_SUBBLOCK_DATA_SIZE_MAX)
- return LZMA_OPTIONS_ERROR;
-
- // Ff the new limit is different than the previous one, we need
- // to reallocate the data buffer.
- if (new_limit != coder->subblock.limit) {
- lzma_free(coder->subblock.data, allocator);
- coder->subblock.data = lzma_alloc(new_limit, allocator);
- if (coder->subblock.data == NULL)
- return LZMA_MEM_ERROR;
- }
-
- coder->subblock.limit = new_limit;
-
- return LZMA_OK;
-}
-
-
-static lzma_ret
-subblock_buffer(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- // Changing allow_subfilter is not allowed.
- if (coder->options != NULL && coder->subfilter.allow
- != coder->options->allow_subfilters)
- return LZMA_PROG_ERROR;
-
- // Check if we need to do something special with the Subfilter.
- if (coder->subfilter.allow) {
- assert(coder->options != NULL);
-
- // See if subfilter_mode has been changed.
- switch (coder->options->subfilter_mode) {
- case LZMA_SUBFILTER_NONE:
- if (coder->subfilter.mode != SUB_NONE)
- return LZMA_PROG_ERROR;
- break;
-
- case LZMA_SUBFILTER_SET:
- if (coder->subfilter.mode_locked
- || coder->subfilter.mode != SUB_NONE)
- return LZMA_PROG_ERROR;
-
- coder->subfilter.mode = SUB_SET;
- coder->subfilter.got_input = false;
-
- if (coder->sequence == SEQ_FILL)
- coder->sequence = SEQ_FLUSH;
-
- break;
-
- case LZMA_SUBFILTER_RUN:
- if (coder->subfilter.mode != SUB_RUN)
- return LZMA_PROG_ERROR;
-
- break;
-
- case LZMA_SUBFILTER_FINISH: {
- const size_t in_avail = in_size - *in_pos;
-
- if (coder->subfilter.mode == SUB_RUN) {
- if (coder->subfilter.mode_locked)
- return LZMA_PROG_ERROR;
-
- coder->subfilter.mode = SUB_FINISH;
- coder->subfilter.in_avail = in_avail;
-
- } else if (coder->subfilter.mode != SUB_FINISH
- || coder->subfilter.in_avail
- != in_avail) {
- return LZMA_PROG_ERROR;
- }
-
- break;
- }
-
- default:
- return LZMA_OPTIONS_ERROR;
- }
-
- // If we are sync-flushing or finishing, the application may
- // no longer change subfilter_mode. Note that this check is
- // done after checking the new subfilter_mode above; this
- // way the application may e.g. set LZMA_SUBFILTER_SET and
- // LZMA_SYNC_FLUSH at the same time, but it cannot modify
- // subfilter_mode on the later lzma_code() calls before
- // we have returned LZMA_STREAM_END.
- if (action != LZMA_RUN)
- coder->subfilter.mode_locked = true;
- }
-
- // Main loop
- while (*out_pos < out_size)
- switch (coder->sequence) {
- case SEQ_FILL:
- // Grab the new Subblock Data Size and reallocate the buffer.
- if (coder->subblock.size == 0 && coder->options != NULL
- && coder->options->subblock_data_size
- != coder->subblock.limit)
- return_if_error(subblock_data_size(coder,
- allocator, coder->options
- ->subblock_data_size));
-
- if (coder->subfilter.mode == SUB_NONE) {
- assert(coder->subfilter.subcoder.code == NULL);
-
- // No Subfilter is enabled, just copy the data as is.
- coder->subblock.in_pending += lzma_bufcpy(
- in, in_pos, in_size,
- coder->subblock.data,
- &coder->subblock.size,
- coder->subblock.limit);
-
- // If we ran out of input before the whole buffer
- // was filled, return to application.
- if (coder->subblock.size < coder->subblock.limit
- && action == LZMA_RUN)
- return LZMA_OK;
-
- } else {
- assert(coder->options->subfilter_mode
- != LZMA_SUBFILTER_SET);
-
- // Using LZMA_FINISH automatically toggles
- // LZMA_SUBFILTER_FINISH.
- //
- // NOTE: It is possible that application had set
- // LZMA_SUBFILTER_SET and LZMA_FINISH at the same
- // time. In that case it is possible that we will
- // cycle to LZMA_SUBFILTER_RUN, LZMA_SUBFILTER_FINISH,
- // and back to LZMA_SUBFILTER_NONE in a single
- // Subblock encoder function call.
- if (action == LZMA_FINISH) {
- coder->options->subfilter_mode
- = LZMA_SUBFILTER_FINISH;
- coder->subfilter.mode = SUB_FINISH;
- }
-
- const size_t in_start = *in_pos;
-
- const lzma_ret ret = coder->subfilter.subcoder.code(
- coder->subfilter.subcoder.coder,
- allocator, in, in_pos, in_size,
- coder->subblock.data,
- &coder->subblock.size,
- coder->subblock.limit,
- coder->subfilter.mode == SUB_FINISH
- ? LZMA_FINISH : action);
-
- const size_t in_used = *in_pos - in_start;
- coder->subblock.in_pending += in_used;
- if (in_used > 0)
- coder->subfilter.got_input = true;
-
- coder->subfilter.in_avail = in_size - *in_pos;
-
- if (ret == LZMA_STREAM_END) {
- // All currently available input must have
- // been processed.
- assert(*in_pos == in_size);
-
- // Flush now. Even if coder->subblock.size
- // happened to be zero, we still need to go
- // to SEQ_FLUSH to possibly finish RLE or
- // write the Subfilter Unset indicator.
- coder->sequence = SEQ_FLUSH;
-
- if (coder->subfilter.mode == SUB_RUN) {
- // Flushing with Subfilter enabled.
- assert(action == LZMA_SYNC_FLUSH);
- coder->subfilter.mode = SUB_FLUSH;
- break;
- }
-
- // Subfilter finished its job.
- assert(coder->subfilter.mode == SUB_FINISH
- || action == LZMA_FINISH);
-
- // At least one byte of input must have been
- // encoded with the Subfilter. This is
- // required by the file format specification.
- if (!coder->subfilter.got_input)
- return LZMA_PROG_ERROR;
-
- // We don't strictly need to do this, but
- // doing it sounds like a good idea, because
- // otherwise the Subfilter's memory could be
- // left allocated for long time, and would
- // just waste memory.
- lzma_next_end(&coder->subfilter.subcoder,
- allocator);
-
- // We need to flush the currently buffered
- // data and write Unset Subfilter marker.
- // Note that we cannot set
- // coder->options->subfilter_mode to
- // LZMA_SUBFILTER_NONE yet, because we
- // haven't written the Unset Subfilter
- // marker yet.
- coder->subfilter.mode = SUB_END_MARKER;
- coder->sequence = SEQ_FLUSH;
- break;
- }
-
- // Return if we couldn't fill the buffer or
- // if an error occurred.
- if (coder->subblock.size < coder->subblock.limit
- || ret != LZMA_OK)
- return ret;
- }
-
- coder->sequence = SEQ_FLUSH;
-
- // SEQ_FILL doesn't produce any output so falling through
- // to SEQ_FLUSH is safe.
- assert(*out_pos < out_size);
-
- // Fall through
-
- case SEQ_FLUSH:
- if (coder->options != NULL) {
- // Update the alignment variable.
- coder->alignment.multiple = coder->options->alignment;
- if (coder->alignment.multiple
- < LZMA_SUBBLOCK_ALIGNMENT_MIN
- || coder->alignment.multiple
- > LZMA_SUBBLOCK_ALIGNMENT_MAX)
- return LZMA_OPTIONS_ERROR;
-
- // Run-length encoder
- //
- // First check if there is some data pending and we
- // have an obvious need to flush it immediately.
- if (coder->rle.count > 0
- && (coder->rle.size
- != coder->options->rle
- || coder->subblock.size
- % coder->rle.size)) {
- subblock_rle_flush(coder);
- break;
- }
-
- // Grab the (possibly new) RLE chunk size and
- // validate it.
- coder->rle.size = coder->options->rle;
- if (coder->rle.size > LZMA_SUBBLOCK_RLE_MAX)
- return LZMA_OPTIONS_ERROR;
-
- if (coder->subblock.size != 0
- && coder->rle.size
- != LZMA_SUBBLOCK_RLE_OFF
- && coder->subblock.size
- % coder->rle.size == 0) {
-
- // Initialize coder->rle.buffer if we don't
- // have RLE already running.
- if (coder->rle.count == 0)
- memcpy(coder->rle.buffer,
- coder->subblock.data,
- coder->rle.size);
-
- // Test if coder->subblock.data is repeating.
- // If coder->rle.count would overflow, we
- // force flushing. Forced flushing shouldn't
- // really happen in real-world situations.
- const size_t count = coder->subblock.size
- / coder->rle.size;
- if (UINT64_MAX - count > coder->rle.count
- && is_repeating(
- coder->rle.buffer,
- coder->rle.size,
- coder->subblock.data,
- count)) {
- coder->rle.count += count;
- coder->rle.in_pending += coder
- ->subblock.in_pending;
- coder->subblock.in_pending = 0;
- coder->subblock.size = 0;
-
- } else if (coder->rle.count > 0) {
- // It's not repeating or at least not
- // with the same byte sequence as the
- // earlier Subblock Data buffers. We
- // have some data pending in the RLE
- // buffer already, so do a flush.
- // Once flushed, we will check again
- // if the Subblock Data happens to
- // contain a different repeating
- // sequence.
- subblock_rle_flush(coder);
- break;
- }
- }
- }
-
- // If we now have some data left in coder->subblock, the RLE
- // buffer is empty and we must write a regular Subblock Data.
- if (coder->subblock.size > 0) {
- assert(coder->rle.count == 0);
- coder->tmp = coder->subblock.size - 1;
- coder->sequence = SEQ_DATA_SIZE_0;
- break;
- }
-
- // Check if we should enable Subfilter.
- if (coder->subfilter.mode == SUB_SET) {
- if (coder->rle.count > 0)
- subblock_rle_flush(coder);
- else
- coder->sequence = SEQ_SUBFILTER_INIT;
- break;
- }
-
- // Check if we have just finished Subfiltering.
- if (coder->subfilter.mode == SUB_END_MARKER) {
- if (coder->rle.count > 0) {
- subblock_rle_flush(coder);
- break;
- }
-
- coder->options->subfilter_mode = LZMA_SUBFILTER_NONE;
- coder->subfilter.mode = SUB_NONE;
-
- write_byte(0x50);
- if (*out_pos == out_size)
- return LZMA_OK;
- }
-
- // Check if we have already written everything.
- if (action != LZMA_RUN && *in_pos == in_size
- && (coder->subfilter.mode == SUB_NONE
- || coder->subfilter.mode == SUB_FLUSH)) {
- if (coder->rle.count > 0) {
- subblock_rle_flush(coder);
- break;
- }
-
- if (action == LZMA_SYNC_FLUSH) {
- if (coder->subfilter.mode == SUB_FLUSH)
- coder->subfilter.mode = SUB_RUN;
-
- coder->subfilter.mode_locked = false;
- coder->sequence = SEQ_FILL;
-
- } else {
- assert(action == LZMA_FINISH);
-
- // Write EOPM.
- // NOTE: No need to use write_byte() here
- // since we are finishing.
- out[*out_pos] = 0x10;
- ++*out_pos;
- }
-
- return LZMA_STREAM_END;
- }
-
- // Otherwise we have more work to do.
- coder->sequence = SEQ_FILL;
- break;
-
- case SEQ_RLE_COUNT_0:
- assert(coder->rle.count > 0);
-
- if (coder->rle.count == 1) {
- // The buffer should be repeated only once. Fix
- // the alignment and write the first byte of
- // Subblock Type `Data'.
- if (subblock_align(coder, out, out_pos, out_size,
- coder->rle.size, ALIGN_SKEW_DATA))
- return LZMA_OK;
-
- write_byte(0x20 | (coder->tmp & 0x0F));
-
- } else {
- // We have something to actually repeat, which should
- // mean that it takes less space with run-length
- // encoding.
- if (subblock_align(coder, out, out_pos, out_size,
- coder->rle.size,
- ALIGN_SKEW_REPEATING_DATA))
- return LZMA_OK;
-
- write_byte(0x30 | (coder->tmp & 0x0F));
- }
-
- // NOTE: If we have to write more than one Repeating Data
- // due to rle.count > REPEAT_COUNT_MAX, the subsequent
- // Repeating Data Subblocks may get wrong alignment, because
- // we add rle.in_pending to alignment.in_pos at once instead
- // of adding only as much as this particular Repeating Data
- // consumed input data. Correct alignment is always restored
- // after all the required Repeating Data Subblocks have been
- // written. This problem occurs in such a weird cases that
- // it's not worth fixing.
- coder->alignment.out_pos += coder->rle.size;
- coder->alignment.in_pos += coder->rle.in_pending;
- coder->rle.in_pending = 0;
-
- coder->sequence = SEQ_RLE_COUNT_1;
- break;
-
- case SEQ_RLE_COUNT_1:
- write_byte(coder->tmp >> 4);
- coder->sequence = SEQ_RLE_COUNT_2;
- break;
-
- case SEQ_RLE_COUNT_2:
- write_byte(coder->tmp >> 12);
- coder->sequence = SEQ_RLE_COUNT_3;
- break;
-
- case SEQ_RLE_COUNT_3:
- write_byte(coder->tmp >> 20);
-
- // Again, see if we are writing regular Data or Repeating Data.
- // In the former case, we skip SEQ_RLE_SIZE.
- if (coder->rle.count == 1)
- coder->sequence = SEQ_RLE_DATA;
- else
- coder->sequence = SEQ_RLE_SIZE;
-
- if (coder->rle.count > REPEAT_COUNT_MAX)
- coder->rle.count -= REPEAT_COUNT_MAX;
- else
- coder->rle.count = 0;
-
- break;
-
- case SEQ_RLE_SIZE:
- assert(coder->rle.size >= LZMA_SUBBLOCK_RLE_MIN);
- assert(coder->rle.size <= LZMA_SUBBLOCK_RLE_MAX);
- write_byte(coder->rle.size - 1);
- coder->sequence = SEQ_RLE_DATA;
- break;
-
- case SEQ_RLE_DATA:
- lzma_bufcpy(coder->rle.buffer, &coder->pos, coder->rle.size,
- out, out_pos, out_size);
- if (coder->pos < coder->rle.size)
- return LZMA_OK;
-
- coder->pos = 0;
- coder->sequence = SEQ_FLUSH;
- break;
-
- case SEQ_DATA_SIZE_0:
- // We need four bytes for the Size field.
- if (subblock_align(coder, out, out_pos, out_size,
- coder->subblock.size, ALIGN_SKEW_DATA))
- return LZMA_OK;
-
- coder->alignment.out_pos += coder->subblock.size;
- coder->alignment.in_pos += coder->subblock.in_pending;
- coder->subblock.in_pending = 0;
-
- write_byte(0x20 | (coder->tmp & 0x0F));
- coder->sequence = SEQ_DATA_SIZE_1;
- break;
-
- case SEQ_DATA_SIZE_1:
- write_byte(coder->tmp >> 4);
- coder->sequence = SEQ_DATA_SIZE_2;
- break;
-
- case SEQ_DATA_SIZE_2:
- write_byte(coder->tmp >> 12);
- coder->sequence = SEQ_DATA_SIZE_3;
- break;
-
- case SEQ_DATA_SIZE_3:
- write_byte(coder->tmp >> 20);
- coder->sequence = SEQ_DATA;
- break;
-
- case SEQ_DATA:
- lzma_bufcpy(coder->subblock.data, &coder->pos,
- coder->subblock.size, out, out_pos, out_size);
- if (coder->pos < coder->subblock.size)
- return LZMA_OK;
-
- coder->subblock.size = 0;
- coder->pos = 0;
- coder->sequence = SEQ_FLUSH;
- break;
-
- case SEQ_SUBFILTER_INIT: {
- assert(coder->subblock.size == 0);
- assert(coder->subblock.in_pending == 0);
- assert(coder->rle.count == 0);
- assert(coder->rle.in_pending == 0);
- assert(coder->subfilter.mode == SUB_SET);
- assert(coder->options != NULL);
-
- // There must be a filter specified.
- if (coder->options->subfilter_options.id == LZMA_VLI_UNKNOWN)
- return LZMA_OPTIONS_ERROR;
-
- // Initialize a raw encoder to work as a Subfilter.
- lzma_filter options[2];
- options[0] = coder->options->subfilter_options;
- options[1].id = LZMA_VLI_UNKNOWN;
-
- return_if_error(lzma_raw_encoder_init(
- &coder->subfilter.subcoder, allocator,
- options));
-
- // Encode the Filter Flags field into a buffer. This should
- // never fail since we have already successfully initialized
- // the Subfilter itself. Check it still, and return
- // LZMA_PROG_ERROR instead of whatever the ret would say.
- lzma_ret ret = lzma_filter_flags_size(
- &coder->subfilter.flags_size, options);
- assert(ret == LZMA_OK);
- if (ret != LZMA_OK)
- return LZMA_PROG_ERROR;
-
- coder->subfilter.flags = lzma_alloc(
- coder->subfilter.flags_size, allocator);
- if (coder->subfilter.flags == NULL)
- return LZMA_MEM_ERROR;
-
- // Now we have a big-enough buffer. Encode the Filter Flags.
- // Like above, this should never fail.
- size_t dummy = 0;
- ret = lzma_filter_flags_encode(options, coder->subfilter.flags,
- &dummy, coder->subfilter.flags_size);
- assert(ret == LZMA_OK);
- assert(dummy == coder->subfilter.flags_size);
- if (ret != LZMA_OK || dummy != coder->subfilter.flags_size)
- return LZMA_PROG_ERROR;
-
- // Write a Subblock indicating a new Subfilter.
- write_byte(0x40);
-
- coder->options->subfilter_mode = LZMA_SUBFILTER_RUN;
- coder->subfilter.mode = SUB_RUN;
- coder->alignment.out_pos += coder->subfilter.flags_size;
- coder->sequence = SEQ_SUBFILTER_FLAGS;
-
- // It is safe to fall through because SEQ_SUBFILTER_FLAGS
- // uses lzma_bufcpy() which doesn't write unless there is
- // output space.
- }
-
- // Fall through
-
- case SEQ_SUBFILTER_FLAGS:
- // Copy the Filter Flags to the output stream.
- lzma_bufcpy(coder->subfilter.flags, &coder->pos,
- coder->subfilter.flags_size,
- out, out_pos, out_size);
- if (coder->pos < coder->subfilter.flags_size)
- return LZMA_OK;
-
- lzma_free(coder->subfilter.flags, allocator);
- coder->subfilter.flags = NULL;
-
- coder->pos = 0;
- coder->sequence = SEQ_FILL;
- break;
-
- default:
- return LZMA_PROG_ERROR;
- }
-
- return LZMA_OK;
-}
-
-
-static lzma_ret
-subblock_encode(lzma_coder *coder, lzma_allocator *allocator,
- const uint8_t *restrict in, size_t *restrict in_pos,
- size_t in_size, uint8_t *restrict out,
- size_t *restrict out_pos, size_t out_size, lzma_action action)
-{
- if (coder->next.code == NULL)
- return subblock_buffer(coder, allocator, in, in_pos, in_size,
- out, out_pos, out_size, action);
-
- while (*out_pos < out_size
- && (*in_pos < in_size || action != LZMA_RUN)) {
- if (!coder->next_finished
- && coder->temp.pos == coder->temp.size) {
- coder->temp.pos = 0;
- coder->temp.size = 0;
-
- const lzma_ret ret = coder->next.code(coder->next.coder,
- allocator, in, in_pos, in_size,
- coder->temp.buffer, &coder->temp.size,
- LZMA_BUFFER_SIZE, action);
- if (ret == LZMA_STREAM_END) {
- assert(action != LZMA_RUN);
- coder->next_finished = true;
- } else if (coder->temp.size == 0 || ret != LZMA_OK) {
- return ret;
- }
- }
-
- const lzma_ret ret = subblock_buffer(coder, allocator,
- coder->temp.buffer, &coder->temp.pos,
- coder->temp.size, out, out_pos, out_size,
- coder->next_finished ? LZMA_FINISH : LZMA_RUN);
- if (ret == LZMA_STREAM_END) {
- assert(action != LZMA_RUN);
- assert(coder->next_finished);
- return LZMA_STREAM_END;
- }
-
- if (ret != LZMA_OK)
- return ret;
- }
-
- return LZMA_OK;
-}
-
-
-static void
-subblock_encoder_end(lzma_coder *coder, lzma_allocator *allocator)
-{
- lzma_next_end(&coder->next, allocator);
- lzma_next_end(&coder->subfilter.subcoder, allocator);
- lzma_free(coder->subblock.data, allocator);
- lzma_free(coder->subfilter.flags, allocator);
- lzma_free(coder, allocator);
- return;
-}
-
-
-extern lzma_ret
-lzma_subblock_encoder_init(lzma_next_coder *next, lzma_allocator *allocator,
- const lzma_filter_info *filters)
-{
- if (next->coder == NULL) {
- next->coder = lzma_alloc(sizeof(lzma_coder), allocator);
- if (next->coder == NULL)
- return LZMA_MEM_ERROR;
-
- next->code = &subblock_encode;
- next->end = &subblock_encoder_end;
-
- next->coder->next = LZMA_NEXT_CODER_INIT;
- next->coder->subblock.data = NULL;
- next->coder->subblock.limit = 0;
- next->coder->subfilter.subcoder = LZMA_NEXT_CODER_INIT;
- } else {
- lzma_next_end(&next->coder->subfilter.subcoder,
- allocator);
- lzma_free(next->coder->subfilter.flags, allocator);
- }
-
- next->coder->subfilter.flags = NULL;
-
- next->coder->next_finished = false;
- next->coder->sequence = SEQ_FILL;
- next->coder->options = filters[0].options;
- next->coder->pos = 0;
-
- next->coder->alignment.in_pos = 0;
- next->coder->alignment.out_pos = 0;
- next->coder->subblock.size = 0;
- next->coder->subblock.in_pending = 0;
- next->coder->rle.count = 0;
- next->coder->rle.in_pending = 0;
- next->coder->subfilter.mode = SUB_NONE;
- next->coder->subfilter.mode_locked = false;
-
- next->coder->temp.pos = 0;
- next->coder->temp.size = 0;
-
- // Grab some values from the options structure if it is available.
- size_t subblock_size_limit;
- if (next->coder->options != NULL) {
- if (next->coder->options->alignment
- < LZMA_SUBBLOCK_ALIGNMENT_MIN
- || next->coder->options->alignment
- > LZMA_SUBBLOCK_ALIGNMENT_MAX) {
- subblock_encoder_end(next->coder, allocator);
- return LZMA_OPTIONS_ERROR;
- }
- next->coder->alignment.multiple
- = next->coder->options->alignment;
- next->coder->subfilter.allow
- = next->coder->options->allow_subfilters;
- subblock_size_limit = next->coder->options->subblock_data_size;
- } else {
- next->coder->alignment.multiple
- = LZMA_SUBBLOCK_ALIGNMENT_DEFAULT;
- next->coder->subfilter.allow = false;
- subblock_size_limit = LZMA_SUBBLOCK_DATA_SIZE_DEFAULT;
- }
-
- return_if_error(subblock_data_size(next->coder, allocator,
- subblock_size_limit));
-
- return lzma_next_filter_init(
- &next->coder->next, allocator, filters + 1);
-}
diff --git a/Build/source/extra/xz/src/liblzma/subblock/subblock_encoder.h b/Build/source/extra/xz/src/liblzma/subblock/subblock_encoder.h
deleted file mode 100644
index ddbfe64bce8..00000000000
--- a/Build/source/extra/xz/src/liblzma/subblock/subblock_encoder.h
+++ /dev/null
@@ -1,21 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-/// \file subblock_encoder.h
-/// \brief Encoder of the Subblock filter
-//
-// Author: Lasse Collin
-//
-// This file has been put into the public domain.
-// You can do whatever you want with this file.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef LZMA_SUBBLOCK_ENCODER_H
-#define LZMA_SUBBLOCK_ENCODER_H
-
-#include "common.h"
-
-extern lzma_ret lzma_subblock_encoder_init(lzma_next_coder *next,
- lzma_allocator *allocator, const lzma_filter_info *filters);
-
-#endif
diff --git a/Build/source/extra/xz/src/lzmainfo/lzmainfo.c b/Build/source/extra/xz/src/lzmainfo/lzmainfo.c
index 3100dc631af..b0ccdfb430e 100644
--- a/Build/source/extra/xz/src/lzmainfo/lzmainfo.c
+++ b/Build/source/extra/xz/src/lzmainfo/lzmainfo.c
@@ -26,7 +26,7 @@
#endif
-static void lzma_attribute((noreturn))
+static void lzma_attribute((__noreturn__))
help(void)
{
printf(
@@ -45,7 +45,7 @@ _("Usage: %s [--help] [--version] [FILE]...\n"
}
-static void lzma_attribute((noreturn))
+static void lzma_attribute((__noreturn__))
version(void)
{
puts("lzmainfo (" PACKAGE_NAME ") " LZMA_VERSION_STRING);
diff --git a/Build/source/extra/xz/src/scripts/xzgrep.in b/Build/source/extra/xz/src/scripts/xzgrep.in
index a8b8117a0c1..ae30725c69f 100644
--- a/Build/source/extra/xz/src/scripts/xzgrep.in
+++ b/Build/source/extra/xz/src/scripts/xzgrep.in
@@ -27,7 +27,7 @@
xz='@xz@ --format=auto'
unset GZIP BZIP BZIP2
-case ${0##/*} in
+case ${0##*/} in
*egrep*) prog=xzegrep; grep=${GREP:-egrep};;
*fgrep*) prog=xzfgrep; grep=${GREP:-fgrep};;
*) prog=xzgrep; grep=${GREP:-grep};;
@@ -35,7 +35,7 @@ esac
version="$prog (@PACKAGE_NAME@) @VERSION@"
-usage="Usage: ${0##/*} [OPTION]... [-e] PATTERN [FILE]...
+usage="Usage: ${0##*/} [OPTION]... [-e] PATTERN [FILE]...
Look for instances of PATTERN in the input FILEs, using their
uncompressed contents if they are compressed.
diff --git a/Build/source/extra/xz/src/xz/coder.c b/Build/source/extra/xz/src/xz/coder.c
index 5182dddc3ff..b123ec5bf2b 100644
--- a/Build/source/extra/xz/src/xz/coder.c
+++ b/Build/source/extra/xz/src/xz/coder.c
@@ -102,7 +102,7 @@ coder_add_filter(lzma_vli id, void *options)
}
-static void lzma_attribute((noreturn))
+static void lzma_attribute((__noreturn__))
memlimit_too_small(uint64_t memory_usage)
{
message(V_ERROR, _("Memory usage limit is too low for the given "
diff --git a/Build/source/extra/xz/src/xz/file_io.c b/Build/source/extra/xz/src/xz/file_io.c
index 09edcca69eb..f9b7f305e09 100644
--- a/Build/source/extra/xz/src/xz/file_io.c
+++ b/Build/source/extra/xz/src/xz/file_io.c
@@ -53,7 +53,7 @@ static bool io_write_buf(file_pair *pair, const uint8_t *buf, size_t size);
extern void
io_init(void)
{
- // Make sure that stdin, stdout, and and stderr are connected to
+ // Make sure that stdin, stdout, and stderr are connected to
// a valid file descriptor. Exit immediately with exit code ERROR
// if we cannot make the file descriptors valid. Maybe we should
// print an error message, but our stderr could be screwed anyway.
diff --git a/Build/source/extra/xz/src/xz/hardware.h b/Build/source/extra/xz/src/xz/hardware.h
index bed952b07d2..ad526f260bc 100644
--- a/Build/source/extra/xz/src/xz/hardware.h
+++ b/Build/source/extra/xz/src/xz/hardware.h
@@ -35,4 +35,4 @@ extern void hardware_memlimit_set(uint64_t new_memlimit,
extern uint64_t hardware_memlimit_get(enum operation_mode mode);
/// Display the amount of RAM and memory usage limits and exit.
-extern void hardware_memlimit_show(void) lzma_attribute((noreturn));
+extern void hardware_memlimit_show(void) lzma_attribute((__noreturn__));
diff --git a/Build/source/extra/xz/src/xz/message.c b/Build/source/extra/xz/src/xz/message.c
index 38cce4a1b0f..80c86a49c3d 100644
--- a/Build/source/extra/xz/src/xz/message.c
+++ b/Build/source/extra/xz/src/xz/message.c
@@ -94,7 +94,7 @@ static volatile sig_atomic_t progress_needs_updating = false;
/// Signal handler for SIGALRM
static void
-progress_signal_handler(int sig lzma_attribute((unused)))
+progress_signal_handler(int sig lzma_attribute((__unused__)))
{
progress_needs_updating = true;
return;
@@ -726,7 +726,11 @@ vmessage(enum message_verbosity v, const char *fmt, va_list ap)
progress_flush(false);
- fprintf(stderr, "%s: ", progname);
+ // TRANSLATORS: This is the program name in the beginning
+ // of the line in messages. Usually it becomes "xz: ".
+ // This is a translatable string because French needs
+ // a space before a colon.
+ fprintf(stderr, _("%s: "), progname);
vfprintf(stderr, fmt, ap);
fputc('\n', stderr);
diff --git a/Build/source/extra/xz/src/xz/message.h b/Build/source/extra/xz/src/xz/message.h
index e3fca3cc42c..74599bd978a 100644
--- a/Build/source/extra/xz/src/xz/message.h
+++ b/Build/source/extra/xz/src/xz/message.h
@@ -45,7 +45,7 @@ extern enum message_verbosity message_verbosity_get(void);
///
/// This doesn't touch the exit status.
extern void message(enum message_verbosity verbosity, const char *fmt, ...)
- lzma_attribute((format(printf, 2, 3)));
+ lzma_attribute((__format__(__printf__, 2, 3)));
/// \brief Prints a warning and possibly sets exit status
@@ -53,7 +53,7 @@ extern void message(enum message_verbosity verbosity, const char *fmt, ...)
/// The message is printed only if verbosity level is at least V_WARNING.
/// The exit status is set to WARNING unless it was already at ERROR.
extern void message_warning(const char *fmt, ...)
- lzma_attribute((format(printf, 1, 2)));
+ lzma_attribute((__format__(__printf__, 1, 2)));
/// \brief Prints an error message and sets exit status
@@ -61,25 +61,25 @@ extern void message_warning(const char *fmt, ...)
/// The message is printed only if verbosity level is at least V_ERROR.
/// The exit status is set to ERROR.
extern void message_error(const char *fmt, ...)
- lzma_attribute((format(printf, 1, 2)));
+ lzma_attribute((__format__(__printf__, 1, 2)));
/// \brief Prints an error message and exits with EXIT_ERROR
///
/// The message is printed only if verbosity level is at least V_ERROR.
extern void message_fatal(const char *fmt, ...)
- lzma_attribute((format(printf, 1, 2)))
- lzma_attribute((noreturn));
+ lzma_attribute((__format__(__printf__, 1, 2)))
+ lzma_attribute((__noreturn__));
/// Print an error message that an internal error occurred and exit with
/// EXIT_ERROR.
-extern void message_bug(void) lzma_attribute((noreturn));
+extern void message_bug(void) lzma_attribute((__noreturn__));
/// Print a message that establishing signal handlers failed, and exit with
/// exit status ERROR.
-extern void message_signal_handler(void) lzma_attribute((noreturn));
+extern void message_signal_handler(void) lzma_attribute((__noreturn__));
/// Convert lzma_ret to a string.
@@ -116,11 +116,11 @@ extern void message_try_help(void);
/// Prints the version number to stdout and exits with exit status SUCCESS.
-extern void message_version(void) lzma_attribute((noreturn));
+extern void message_version(void) lzma_attribute((__noreturn__));
/// Print the help message.
-extern void message_help(bool long_help) lzma_attribute((noreturn));
+extern void message_help(bool long_help) lzma_attribute((__noreturn__));
/// \brief Set the total number of files to be processed
diff --git a/Build/source/extra/xz/src/xz/options.c b/Build/source/extra/xz/src/xz/options.c
index 379a2e46dc0..f21a0ba5106 100644
--- a/Build/source/extra/xz/src/xz/options.c
+++ b/Build/source/extra/xz/src/xz/options.c
@@ -150,7 +150,7 @@ enum {
static void
set_delta(void *options, uint32_t key, uint64_t value,
- const char *valuestr lzma_attribute((unused)))
+ const char *valuestr lzma_attribute((__unused__)))
{
lzma_options_delta *opt = options;
switch (key) {
@@ -194,7 +194,7 @@ enum {
static void
set_bcj(void *options, uint32_t key, uint64_t value,
- const char *valuestr lzma_attribute((unused)))
+ const char *valuestr lzma_attribute((__unused__)))
{
lzma_options_bcj *opt = options;
switch (key) {
@@ -241,7 +241,7 @@ enum {
};
-static void lzma_attribute((noreturn))
+static void lzma_attribute((__noreturn__))
error_lzma_preset(const char *valuestr)
{
message_fatal(_("Unsupported LZMA1/LZMA2 preset: %s"), valuestr);
diff --git a/Build/source/extra/xz/src/xz/signals.c b/Build/source/extra/xz/src/xz/signals.c
index 4d6a9da3162..de213644d00 100644
--- a/Build/source/extra/xz/src/xz/signals.c
+++ b/Build/source/extra/xz/src/xz/signals.c
@@ -179,7 +179,7 @@ signals_exit(void)
// console window.
static BOOL WINAPI
-signal_handler(DWORD type lzma_attribute((unused)))
+signal_handler(DWORD type lzma_attribute((__unused__)))
{
// Since we don't get a signal number which we could raise() at
// signals_exit() like on POSIX, just set the exit status to
diff --git a/Build/source/extra/xz/src/xz/util.h b/Build/source/extra/xz/src/xz/util.h
index 4b2d3e2f573..a2516bf9680 100644
--- a/Build/source/extra/xz/src/xz/util.h
+++ b/Build/source/extra/xz/src/xz/util.h
@@ -20,11 +20,11 @@
/// \brief Safe realloc() that never returns NULL
extern void *xrealloc(void *ptr, size_t size)
- lzma_attribute((malloc)) lzma_attr_alloc_size(2);
+ lzma_attribute((__malloc__)) lzma_attr_alloc_size(2);
/// \brief Safe strdup() that never returns NULL
-extern char *xstrdup(const char *src) lzma_attribute((malloc));
+extern char *xstrdup(const char *src) lzma_attribute((__malloc__));
/// \brief Fancy version of strtoull()
@@ -102,7 +102,7 @@ extern const char *uint64_to_nicestr(uint64_t value,
/// A maximum of *left bytes is written starting from *pos. *pos and *left
/// are updated accordingly.
extern void my_snprintf(char **pos, size_t *left, const char *fmt, ...)
- lzma_attribute((format(printf, 3, 4)));
+ lzma_attribute((__format__(__printf__, 3, 4)));
/// \brief Check if filename is empty and print an error message
diff --git a/Build/source/extra/xz/src/xz/xz.1 b/Build/source/extra/xz/src/xz/xz.1
index cba1d077c2d..f1c9135d159 100644
--- a/Build/source/extra/xz/src/xz/xz.1
+++ b/Build/source/extra/xz/src/xz/xz.1
@@ -866,7 +866,7 @@ This is equivalent to specifying \fB\-\-memlimit\-compress=\fIlimit
\fB\-\-memlimit\-decompress=\fIlimit\fR.
.TP
.B \-\-no\-adjust
-Display an error and exit if the compression settings exceed the
+Display an error and exit if the compression settings exceed
the memory usage limit.
The default is to adjust the settings downwards so
that the memory usage limit is not exceeded.
diff --git a/Build/source/extra/xz/src/xzdec/xzdec.c b/Build/source/extra/xz/src/xzdec/xzdec.c
index fd015076de9..b7830db4b52 100644
--- a/Build/source/extra/xz/src/xzdec/xzdec.c
+++ b/Build/source/extra/xz/src/xzdec/xzdec.c
@@ -40,7 +40,7 @@
static unsigned int display_errors = 2;
-static void lzma_attribute((format(printf, 1, 2)))
+static void lzma_attribute((__format__(__printf__, 1, 2)))
my_errorf(const char *fmt, ...)
{
va_list ap;
@@ -57,7 +57,7 @@ my_errorf(const char *fmt, ...)
}
-static void lzma_attribute((noreturn))
+static void lzma_attribute((__noreturn__))
help(void)
{
printf(
@@ -81,7 +81,7 @@ PACKAGE_NAME " home page: <" PACKAGE_URL ">\n", progname);
}
-static void lzma_attribute((noreturn))
+static void lzma_attribute((__noreturn__))
version(void)
{
printf(TOOL_FORMAT "dec (" PACKAGE_NAME ") " LZMA_VERSION_STRING "\n"