summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Drake <michael.drake@codethink.co.uk>2017-04-06 16:55:12 (GMT)
committer Michael Drake <michael.drake@codethink.co.uk>2017-04-06 16:55:12 (GMT)
commitc9b99d28a0be8eb76c6eb0575c7a51b524da832c (patch)
tree5e7c740650663bce303ae12d49db843fee3f536a
parentaf6ab260260383f86b2dde2c2973ad59f7c42d05 (diff)
downloadlibnsgif-c9b99d28a0be8eb76c6eb0575c7a51b524da832c.tar.gz
libnsgif-c9b99d28a0be8eb76c6eb0575c7a51b524da832c.tar.bz2
LZW decoder: Slight code clarity and comment improvement.
-rw-r--r--src/lzw.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/lzw.c b/src/lzw.c
index 6ad95aa..743f4d3 100644
--- a/src/lzw.c
+++ b/src/lzw.c
@@ -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;