Deleted Added
full compact
2c2
< * Copyright (C) 1995-1996 Jean-loup Gailly
---
> * Copyright (C) 1995-1998 Jean-loup Gailly
32c32
< /* $FreeBSD: head/lib/libz/trees.c 21673 1997-01-14 07:20:47Z jkh $ */
---
> /* $FreeBSD: head/lib/libz/trees.c 33908 1998-02-28 06:08:17Z steve $ */
33a34,35
> /* #define GEN_TREES_H */
>
59c61
< local int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
---
> local const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
62c64
< local int extra_dbits[D_CODES] /* extra bits for each distance code */
---
> local const int extra_dbits[D_CODES] /* extra bits for each distance code */
65c67
< local int extra_blbits[BL_CODES]/* extra bits for each bit length code */
---
> local const int extra_blbits[BL_CODES]/* extra bits for each bit length code */
68c70
< local uch bl_order[BL_CODES]
---
> local const uch bl_order[BL_CODES]
82a85,89
> #define DIST_CODE_LEN 512 /* see definition of array dist_code below */
>
> #if defined(GEN_TREES_H) || !defined(STDC)
> /* non ANSI compilers may not accept trees.h */
>
95,96c102,103
< local uch dist_code[512];
< /* distance codes. The first 256 values correspond to the distances
---
> uch _dist_code[DIST_CODE_LEN];
> /* Distance codes. The first 256 values correspond to the distances
101c108
< local uch length_code[MAX_MATCH-MIN_MATCH+1];
---
> uch _length_code[MAX_MATCH-MIN_MATCH+1];
109a117,120
> #else
> # include "trees.h"
> #endif /* GEN_TREES_H */
>
111,112c122,123
< ct_data *static_tree; /* static tree or NULL */
< intf *extra_bits; /* extra bits for each code or NULL */
---
> const ct_data *static_tree; /* static tree or NULL */
> const intf *extra_bits; /* extra bits for each code or NULL */
125c136
< {(ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
---
> {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS};
150a162,165
> #ifdef GEN_TREES_H
> local void gen_trees_header OF((void));
> #endif
>
157c172
< { if (verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
---
> { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \
161,167d175
< #define d_code(dist) \
< ((dist) < 256 ? dist_code[dist] : dist_code[256+((dist)>>7)])
< /* Mapping from a distance to a distance code. dist is the distance - 1 and
< * must not have side effects. dist_code[256] and dist_code[257] are never
< * used.
< */
<
229,231c237
< * Initialize the various 'constant' tables. In a multi-threaded environment,
< * this function may be called by two threads concurrently, but this is
< * harmless since both invocations do exactly the same thing.
---
> * Initialize the various 'constant' tables.
234a241
> #if defined(GEN_TREES_H) || !defined(STDC)
251c258
< length_code[length++] = (uch)code;
---
> _length_code[length++] = (uch)code;
259c266
< length_code[length-1] = (uch)code;
---
> _length_code[length-1] = (uch)code;
266c273
< dist_code[dist++] = (uch)code;
---
> _dist_code[dist++] = (uch)code;
274c281
< dist_code[256 + dist++] = (uch)code;
---
> _dist_code[256 + dist++] = (uch)code;
297a305,309
>
> # ifdef GEN_TREES_H
> gen_trees_header();
> # endif
> #endif /* defined(GEN_TREES_H) || !defined(STDC) */
300a313,373
> * Genererate the file trees.h describing the static trees.
> */
> #ifdef GEN_TREES_H
> # ifndef DEBUG
> # include <stdio.h>
> # endif
>
> # define SEPARATOR(i, last, width) \
> ((i) == (last)? "\n};\n\n" : \
> ((i) % (width) == (width)-1 ? ",\n" : ", "))
>
> void gen_trees_header()
> {
> FILE *header = fopen("trees.h", "w");
> int i;
>
> Assert (header != NULL, "Can't open trees.h");
> fprintf(header,
> "/* header created automatically with -DGEN_TREES_H */\n\n");
>
> fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n");
> for (i = 0; i < L_CODES+2; i++) {
> fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code,
> static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5));
> }
>
> fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n");
> for (i = 0; i < D_CODES; i++) {
> fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code,
> static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5));
> }
>
> fprintf(header, "const uch _dist_code[DIST_CODE_LEN] = {\n");
> for (i = 0; i < DIST_CODE_LEN; i++) {
> fprintf(header, "%2u%s", _dist_code[i],
> SEPARATOR(i, DIST_CODE_LEN-1, 20));
> }
>
> fprintf(header, "const uch _length_code[MAX_MATCH-MIN_MATCH+1]= {\n");
> for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) {
> fprintf(header, "%2u%s", _length_code[i],
> SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20));
> }
>
> fprintf(header, "local const int base_length[LENGTH_CODES] = {\n");
> for (i = 0; i < LENGTH_CODES; i++) {
> fprintf(header, "%1u%s", base_length[i],
> SEPARATOR(i, LENGTH_CODES-1, 20));
> }
>
> fprintf(header, "local const int base_dist[D_CODES] = {\n");
> for (i = 0; i < D_CODES; i++) {
> fprintf(header, "%5u%s", base_dist[i],
> SEPARATOR(i, D_CODES-1, 10));
> }
>
> fclose(header);
> }
> #endif /* GEN_TREES_H */
>
> /* ===========================================================================
416,421c489,494
< ct_data *tree = desc->dyn_tree;
< int max_code = desc->max_code;
< ct_data *stree = desc->stat_desc->static_tree;
< intf *extra = desc->stat_desc->extra_bits;
< int base = desc->stat_desc->extra_base;
< int max_length = desc->stat_desc->max_length;
---
> ct_data *tree = desc->dyn_tree;
> int max_code = desc->max_code;
> const ct_data *stree = desc->stat_desc->static_tree;
> const intf *extra = desc->stat_desc->extra_bits;
> int base = desc->stat_desc->extra_base;
> int max_length = desc->stat_desc->max_length;
545,547c618,620
< ct_data *tree = desc->dyn_tree;
< ct_data *stree = desc->stat_desc->static_tree;
< int elems = desc->stat_desc->elems;
---
> ct_data *tree = desc->dyn_tree;
> const ct_data *stree = desc->stat_desc->static_tree;
> int elems = desc->stat_desc->elems;
968c1041
< s->dyn_ltree[length_code[lc]+LITERALS+1].Freq++;
---
> s->dyn_ltree[_length_code[lc]+LITERALS+1].Freq++;
971a1045
> #ifdef TRUNCATE_BLOCK
973c1047
< if (s->level > 2 && (s->last_lit & 0xfff) == 0) {
---
> if ((s->last_lit & 0x1fff) == 0 && s->level > 2) {
987a1062
> #endif
1017c1092
< code = length_code[lc];
---
> code = _length_code[lc];