diff options
author | Michael Drake <michael.drake@codethink.co.uk> | 2017-04-06 17:55:12 +0100 |
---|---|---|
committer | Michael Drake <michael.drake@codethink.co.uk> | 2017-04-06 17:55:12 +0100 |
commit | c9b99d28a0be8eb76c6eb0575c7a51b524da832c (patch) | |
tree | 5e7c740650663bce303ae12d49db843fee3f536a | |
parent | af6ab260260383f86b2dde2c2973ad59f7c42d05 (diff) | |
download | libnsgif-c9b99d28a0be8eb76c6eb0575c7a51b524da832c.tar.gz libnsgif-c9b99d28a0be8eb76c6eb0575c7a51b524da832c.tar.bz2 |
LZW decoder: Slight code clarity and comment improvement.
-rw-r--r-- | src/lzw.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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; |