diff --git a/lzw.c b/lzw.c index 3cdf11ced750bde2c37acaf370e24416316f72c7..7fc7c4cd1b7678fd148a57a76d2e2e10b25ae968 100644 --- a/lzw.c +++ b/lzw.c @@ -11,8 +11,7 @@ /* bit lengths > 12 are not allowed => EarlyChange doesn't matter here */ -typedef struct LZW_context_S -{ +struct context { /* * Storing byte sequences represented by each LZW code. * @@ -45,11 +44,11 @@ typedef struct LZW_context_S /* * EarlyChange = 1 means the bit size is increased "one code early". - * Early change = 0 is "code length increases shall be postponed as + * EarlyChange = 0 is "code length increases shall be postponed as * long as possible". */ int earlychange; -} LZW_context_T; +}; /* @@ -57,7 +56,7 @@ typedef struct LZW_context_S */ static void -lzw_clear_table(LZW_context_T *ctx) +lzw_clear_table(struct context *ctx) { ctx->next = 258; } @@ -67,7 +66,7 @@ lzw_clear_table(LZW_context_T *ctx) * byte to be filled in later. */ static void -lzw_table_extend(LZW_context_T *ctx, int code) +lzw_table_extend(struct context *ctx, int code) { ctx->table[ctx->next].prefix = code; ctx->table[ctx->next].first = ctx->table[code].first; @@ -82,7 +81,7 @@ lzw_table_extend(LZW_context_T *ctx, int code) * Returns the number of bytes written. */ static size_t -lzw_code_string(LZW_context_T *ctx, int code, uint8_t *buf) +lzw_code_string(struct context *ctx, int code, uint8_t *buf) { size_t i, n; @@ -103,7 +102,7 @@ lzw_code_string(LZW_context_T *ctx, int code, uint8_t *buf) */ HParser *p_lzwdata; -static LZW_context_T *context; +static struct context *context; /* @@ -113,7 +112,7 @@ static LZW_context_T *context; static HParsedToken* act_clear(const HParseResult *p, void *u) { - LZW_context_T * ctx = u; + struct context *ctx = u; lzw_clear_table(ctx); return H_MAKE_BYTES(NULL, 0); } @@ -121,28 +120,28 @@ act_clear(const HParseResult *p, void *u) static bool validate_code9(HParseResult *p, void *u) { - LZW_context_T * ctx = u; + struct context *ctx = u; return (ctx->next < BITLIMIT_9); } static bool validate_code10(HParseResult *p, void *u) { - LZW_context_T * ctx = u; + struct context *ctx = u; return (ctx->next >= BITLIMIT_9 && ctx->next < BITLIMIT_10); } static bool validate_code11(HParseResult *p, void *u) { - LZW_context_T * ctx = u; + struct context *ctx = u; return (ctx->next >= BITLIMIT_10 && ctx->next < BITLIMIT_11); } static bool validate_code12(HParseResult *p, void *u) { - LZW_context_T * ctx = u; + struct context *ctx = u; return (ctx->next >= BITLIMIT_11 && ctx->next < BITLIMIT_12); } @@ -164,7 +163,7 @@ static bool validate_output(HParseResult *p, void *u) { uint64_t code = H_CAST_UINT(p->ast); - LZW_context_T *ctx = u; + struct context *ctx = u; return (code != 256 && code != 257 && code < ctx->next); } @@ -173,7 +172,7 @@ static HParsedToken* act_output(const HParseResult *p, void *u) { uint64_t code = H_CAST_UINT(p->ast); - LZW_context_T * ctx = u; + struct context *ctx = u; assert(ctx->next >= 258); assert(ctx->next <= 4096); @@ -209,7 +208,7 @@ static HParsedToken * act_lzwblock(const HParseResult *p, void *u) { HCountedArray *seq = H_CAST_SEQ(p->ast); - LZW_context_T *ctx = u; + struct context *ctx = u; uint8_t *buf, *cur; size_t sz, i; int code;