summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--src/lzw.c10
2 files changed, 7 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 54a25b3..d56698b 100644
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@
# Component settings
COMPONENT := nsgif
-COMPONENT_VERSION := 0.1.4
+COMPONENT_VERSION := 0.2.0
# Default to a static library
COMPONENT_TYPE ?= lib-static
diff --git a/src/lzw.c b/src/lzw.c
index 6ad95aa..d65f77e 100644
--- a/src/lzw.c
+++ b/src/lzw.c
@@ -167,8 +167,8 @@ static inline lzw_result lzw__next_code(
/* Fast path: code fully inside this sub-block */
const uint8_t *data = ctx->sb_data + (ctx->sb_bit >> 3);
switch (byte_advance) {
- case 2: code |= data[2] << 16;
- case 1: code |= data[1] << 8;
+ case 2: code |= data[2] << 16; /* Fall through */
+ case 1: code |= data[1] << 8; /* Fall through */
case 0: code |= data[0] << 0;
}
ctx->sb_bit += code_size;
@@ -316,6 +316,7 @@ lzw_result lzw_decode(struct lzw_ctx *ctx,
return res;
}
+ /* Handle the new code */
if (code_new == clear_code) {
/* Got Clear code */
return lzw__clear_codes(ctx, stack_pos_out);
@@ -323,11 +324,11 @@ lzw_result lzw_decode(struct lzw_ctx *ctx,
} else if (code_new == ctx->eoi_code) {
/* Got End of Information code */
return LZW_EOI_CODE;
- }
- if (code_new > current_entry) {
+ } else if (code_new > current_entry) {
/* Code is invalid */
return LZW_BAD_CODE;
+
} else if (code_new < current_entry) {
/* Code is in table */
code_out = code_new;
@@ -357,6 +358,7 @@ lzw_result lzw_decode(struct lzw_ctx *ctx,
}
}
+ /* Store details of this code as "previous code" to the context. */
ctx->previous_code_first = table[code_new].first_value;
ctx->previous_code = code_new;