liblzma: Replaced hardcoded 0x0 index indicator byte with macro
This commit is contained in:
parent
dfecda8752
commit
203b008eb2
@ -22,6 +22,9 @@
|
|||||||
/// Maximum Unpadded Size
|
/// Maximum Unpadded Size
|
||||||
#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
|
#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
|
||||||
|
|
||||||
|
/// Index Indicator based on xz specification
|
||||||
|
#define INDEX_INDICATOR 0
|
||||||
|
|
||||||
|
|
||||||
/// Get the size of the Index Padding field. This is needed by Index encoder
|
/// Get the size of the Index Padding field. This is needed by Index encoder
|
||||||
/// and decoder, but applications should have no use for this.
|
/// and decoder, but applications should have no use for this.
|
||||||
|
@ -80,7 +80,7 @@ index_decode(void *coder_ptr, const lzma_allocator *allocator,
|
|||||||
// format". One could argue that the application should
|
// format". One could argue that the application should
|
||||||
// verify the Index Indicator before trying to decode the
|
// verify the Index Indicator before trying to decode the
|
||||||
// Index, but well, I suppose it is simpler this way.
|
// Index, but well, I suppose it is simpler this way.
|
||||||
if (in[(*in_pos)++] != 0x00)
|
if (in[(*in_pos)++] != INDEX_INDICATOR)
|
||||||
return LZMA_DATA_ERROR;
|
return LZMA_DATA_ERROR;
|
||||||
|
|
||||||
coder->sequence = SEQ_COUNT;
|
coder->sequence = SEQ_COUNT;
|
||||||
|
@ -65,7 +65,7 @@ index_encode(void *coder_ptr,
|
|||||||
while (*out_pos < out_size)
|
while (*out_pos < out_size)
|
||||||
switch (coder->sequence) {
|
switch (coder->sequence) {
|
||||||
case SEQ_INDICATOR:
|
case SEQ_INDICATOR:
|
||||||
out[*out_pos] = 0x00;
|
out[*out_pos] = INDEX_INDICATOR;
|
||||||
++*out_pos;
|
++*out_pos;
|
||||||
coder->sequence = SEQ_COUNT;
|
coder->sequence = SEQ_COUNT;
|
||||||
break;
|
break;
|
||||||
|
@ -190,7 +190,7 @@ lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in,
|
|||||||
switch (index_hash->sequence) {
|
switch (index_hash->sequence) {
|
||||||
case SEQ_BLOCK:
|
case SEQ_BLOCK:
|
||||||
// Check the Index Indicator is present.
|
// Check the Index Indicator is present.
|
||||||
if (in[(*in_pos)++] != 0x00)
|
if (in[(*in_pos)++] != INDEX_INDICATOR)
|
||||||
return LZMA_DATA_ERROR;
|
return LZMA_DATA_ERROR;
|
||||||
|
|
||||||
index_hash->sequence = SEQ_COUNT;
|
index_hash->sequence = SEQ_COUNT;
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "stream_decoder.h"
|
#include "stream_decoder.h"
|
||||||
#include "block_decoder.h"
|
#include "block_decoder.h"
|
||||||
|
#include "index.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -164,7 +165,7 @@ stream_decode(void *coder_ptr, const lzma_allocator *allocator,
|
|||||||
|
|
||||||
if (coder->pos == 0) {
|
if (coder->pos == 0) {
|
||||||
// Detect if it's Index.
|
// Detect if it's Index.
|
||||||
if (in[*in_pos] == 0x00) {
|
if (in[*in_pos] == INDEX_INDICATOR) {
|
||||||
coder->sequence = SEQ_INDEX;
|
coder->sequence = SEQ_INDEX;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -887,7 +887,7 @@ decode_block_header(struct lzma_stream_coder *coder,
|
|||||||
|
|
||||||
if (coder->pos == 0) {
|
if (coder->pos == 0) {
|
||||||
// Detect if it's Index.
|
// Detect if it's Index.
|
||||||
if (in[*in_pos] == 0x00)
|
if (in[*in_pos] == INDEX_INDICATOR)
|
||||||
return LZMA_INDEX_DETECTED;
|
return LZMA_INDEX_DETECTED;
|
||||||
|
|
||||||
// Calculate the size of the Block Header. Note that
|
// Calculate the size of the Block Header. Note that
|
||||||
|
Loading…
Reference in New Issue
Block a user