aboutsummaryrefslogtreecommitdiff
path: root/src/liblzma/simple/simple_coder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2007-12-11 16:49:19 +0200
committerLasse Collin <lasse.collin@tukaani.org>2007-12-11 16:49:19 +0200
commit3e16d51dd645667b05ff826665b1fc353aa41cd9 (patch)
tree2ce26b05eacbec07557f3e4cbe0982dea05ec675 /src/liblzma/simple/simple_coder.c
parentGet rid of no-NLS gnulib. I don't know how to get it (diff)
downloadxz-3e16d51dd645667b05ff826665b1fc353aa41cd9.tar.xz
Remove uncompressed size tracking from the filter encoders.
It's not strictly needed there, and just complicates the code. LZ encoder never even had this feature. The primary reason to have uncompressed size tracking in filter encoders was validating that the application doesn't give different amount of input that it had promised. A side effect was to validate internal workings of liblzma. Uncompressed size tracking is still present in the Block encoder. Maybe it should be added to LZMA_Alone and raw encoders too. It's simpler to have one coder just to validate the uncompressed size instead of having it in every filter.
Diffstat (limited to '')
-rw-r--r--src/liblzma/simple/simple_coder.c29
1 files changed, 4 insertions, 25 deletions
diff --git a/src/liblzma/simple/simple_coder.c b/src/liblzma/simple/simple_coder.c
index f60dff34..6ecd119e 100644
--- a/src/liblzma/simple/simple_coder.c
+++ b/src/liblzma/simple/simple_coder.c
@@ -39,44 +39,23 @@ copy_or_code(lzma_coder *coder, lzma_allocator *allocator,
if (coder->next.code == NULL) {
const size_t in_avail = in_size - *in_pos;
- if (coder->is_encoder) {
- if (action == LZMA_FINISH) {
- // If uncompressed size is known and the
- // amount of available input doesn't match
- // the uncompressed size, return an error.
- if (coder->uncompressed_size
- != LZMA_VLI_VALUE_UNKNOWN
- && coder->uncompressed_size
- != in_avail)
- return LZMA_DATA_ERROR;
-
- } else if (coder->uncompressed_size
- < (lzma_vli)(in_avail)) {
- // There is too much input available.
- return LZMA_DATA_ERROR;
- }
- } else {
+ if (!coder->is_encoder) {
// Limit in_size so that we don't copy too much.
if ((lzma_vli)(in_avail) > coder->uncompressed_size)
in_size = *in_pos + (size_t)(
coder->uncompressed_size);
}
- // Store the old position so we can update uncompressed_size.
const size_t out_start = *out_pos;
-
- // Copy the data
bufcpy(in, in_pos, in_size, out, out_pos, out_size);
- // Update uncompressed_size.
- if (coder->uncompressed_size != LZMA_VLI_VALUE_UNKNOWN)
- coder->uncompressed_size -= *out_pos - out_start;
-
// Check if end of stream was reached.
if (coder->is_encoder) {
if (action == LZMA_FINISH && *in_pos == in_size)
coder->end_was_reached = true;
- } else {
+ } else if (coder->uncompressed_size
+ != LZMA_VLI_VALUE_UNKNOWN) {
+ coder->uncompressed_size -= *out_pos - out_start;
if (coder->uncompressed_size == 0)
coder->end_was_reached = true;
}