Run through indent

This commit is contained in:
Glenn L McGrath 2002-08-22 13:21:26 +00:00
parent b37367aa77
commit d827e8b665

View File

@ -387,6 +387,7 @@ static ulg updcrc(uch *s, unsigned n)
static ulg crc = (ulg) 0xffffffffL; /* shift register contents */ static ulg crc = (ulg) 0xffffffffL; /* shift register contents */
register ulg c; /* temporary variable */ register ulg c; /* temporary variable */
static unsigned long crc_32_tab[256]; static unsigned long crc_32_tab[256];
if (crc_table_empty) { if (crc_table_empty) {
unsigned long csr; /* crc shift register */ unsigned long csr; /* crc shift register */
const unsigned long e = 0xedb88320L; /* polynomial exclusive-or pattern */ const unsigned long e = 0xedb88320L; /* polynomial exclusive-or pattern */
@ -901,7 +902,6 @@ static int longest_match(IPos cur_match)
register int len; /* length of current match */ register int len; /* length of current match */
int best_len = prev_length; /* best match length so far */ int best_len = prev_length; /* best match length so far */
IPos limit = IPos limit =
strstart > (IPos) MAX_DIST ? strstart - (IPos) MAX_DIST : NIL; strstart > (IPos) MAX_DIST ? strstart - (IPos) MAX_DIST : NIL;
/* Stop when cur_match becomes <= limit. To simplify the code, /* Stop when cur_match becomes <= limit. To simplify the code,
* we prevent matches with the string of window index 0. * we prevent matches with the string of window index 0.
@ -921,8 +921,7 @@ static int longest_match(IPos cur_match)
if (prev_length >= good_match) { if (prev_length >= good_match) {
chain_length >>= 2; chain_length >>= 2;
} }
Assert(strstart <= window_size - MIN_LOOKAHEAD, Assert(strstart <= window_size - MIN_LOOKAHEAD, "insufficient lookahead");
"insufficient lookahead");
do { do {
Assert(cur_match < strstart, "no future"); Assert(cur_match < strstart, "no future");
@ -951,8 +950,7 @@ static int longest_match(IPos cur_match)
} while (*++scan == *++match && *++scan == *++match && } while (*++scan == *++match && *++scan == *++match &&
*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match &&
*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match &&
*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend);
scan < strend);
len = MAX_MATCH - (int) (strend - scan); len = MAX_MATCH - (int) (strend - scan);
scan = strend - MAX_MATCH; scan = strend - MAX_MATCH;
@ -1007,7 +1005,6 @@ static void fill_window()
{ {
register unsigned n, m; register unsigned n, m;
unsigned more = unsigned more =
(unsigned) (window_size - (ulg) lookahead - (ulg) strstart); (unsigned) (window_size - (ulg) lookahead - (ulg) strstart);
/* Amount of free space at the end of the window. */ /* Amount of free space at the end of the window. */
@ -1100,8 +1097,7 @@ static ulg deflate()
match_length = lookahead; match_length = lookahead;
/* Ignore a length 3 match if it is too distant: */ /* Ignore a length 3 match if it is too distant: */
if (match_length == MIN_MATCH if (match_length == MIN_MATCH && strstart - match_start > TOO_FAR) {
&& strstart - match_start > TOO_FAR) {
/* If prev_match is also MIN_MATCH, match_start is garbage /* If prev_match is also MIN_MATCH, match_start is garbage
* but we will ignore the current match anyway. * but we will ignore the current match anyway.
*/ */
@ -1116,8 +1112,7 @@ static ulg deflate()
check_match(strstart - 1, prev_match, prev_length); check_match(strstart - 1, prev_match, prev_length);
flush = flush =
ct_tally(strstart - 1 - prev_match, ct_tally(strstart - 1 - prev_match, prev_length - MIN_MATCH);
prev_length - MIN_MATCH);
/* Insert in hash table all strings up to the end of the match. /* Insert in hash table all strings up to the end of the match.
* strstart-1 and strstart are already inserted. * strstart-1 and strstart are already inserted.
@ -1201,9 +1196,6 @@ typedef struct dirent dir_type;
typedef RETSIGTYPE(*sig_type) (int); typedef RETSIGTYPE(*sig_type) (int);
/* ======================================================================== */ /* ======================================================================== */
// int main (argc, argv)
// int argc;
// char **argv;
int gzip_main(int argc, char **argv) int gzip_main(int argc, char **argv)
{ {
int result; int result;
@ -1224,8 +1216,15 @@ int gzip_main(int argc, char **argv)
force = 1; force = 1;
break; break;
/* Ignore 1-9 (compression level) options */ /* Ignore 1-9 (compression level) options */
case '1': case '2': case '3': case '4': case '5': case '1':
case '6': case '7': case '8': case '9': case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
break; break;
case 'q': case 'q':
break; break;
@ -1296,7 +1295,8 @@ int gzip_main(int argc, char **argv)
/* Open output file */ /* Open output file */
#if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1) #if (__GLIBC__ >= 2) && (__GLIBC_MINOR__ >= 1)
outFileNum = open(path, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW); outFileNum =
open(path, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW);
#else #else
outFileNum = open(path, O_RDWR | O_CREAT | O_EXCL); outFileNum = open(path, O_RDWR | O_CREAT | O_EXCL);
#endif #endif
@ -1313,7 +1313,8 @@ int gzip_main(int argc, char **argv)
} }
if (path == NULL && isatty(outFileNum) && force == 0) { if (path == NULL && isatty(outFileNum) && force == 0) {
error_msg("compressed data not written to a terminal. Use -f to force compression."); error_msg
("compressed data not written to a terminal. Use -f to force compression.");
free(path); free(path);
continue; continue;
} }
@ -1429,12 +1430,14 @@ typedef uch extra_bits_t;
/* extra bits for each length code */ /* extra bits for each length code */
static const extra_bits_t extra_lbits[LENGTH_CODES] static const extra_bits_t extra_lbits[LENGTH_CODES]
= { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4,
4, 4, 5, 5, 5, 5, 0 }; 4, 4, 5, 5, 5, 5, 0
};
/* extra bits for each distance code */ /* extra bits for each distance code */
static const extra_bits_t extra_dbits[D_CODES] static const extra_bits_t extra_dbits[D_CODES]
= { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9,
10, 10, 11, 11, 12, 12, 13, 13 }; 10, 10, 11, 11, 12, 12, 13, 13
};
/* extra bits for each bit length code */ /* extra bits for each bit length code */
static const extra_bits_t extra_blbits[BL_CODES] static const extra_bits_t extra_blbits[BL_CODES]
@ -1487,9 +1490,14 @@ static const extra_bits_t extra_blbits[BL_CODES]
#define REPZ_3_10 17 #define REPZ_3_10 17
/* repeat a zero length 3-10 times (3 bits of repeat count) */ /* repeat a zero length 3-10 times (3 bits of repeat count) */
#define REPZ_11_138 18 #define REPZ_11_138 18
/* repeat a zero length 11-138 times (7 bits of repeat count) *//* =========================================================================== /* repeat a zero length 11-138 times (7 bits of repeat count) */
/* ===========================================================================
* Local data * Local data
*//* Data structure describing a single value and its code string. */ typedef struct ct_data { */
/* Data structure describing a single value and its code string. */
typedef struct ct_data {
union { union {
ush freq; /* frequency count */ ush freq; /* frequency count */
ush code; /* bit string */ ush code; /* bit string */
@ -1541,14 +1549,16 @@ typedef struct tree_desc {
static tree_desc l_desc = static tree_desc l_desc =
{ dyn_ltree, static_ltree, extra_lbits, LITERALS + 1, L_CODES, { dyn_ltree, static_ltree, extra_lbits, LITERALS + 1, L_CODES,
MAX_BITS, 0 }; MAX_BITS, 0
};
static tree_desc d_desc = static tree_desc d_desc =
{ dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0 }; { dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0 };
static tree_desc bl_desc = static tree_desc bl_desc =
{ bl_tree, (ct_data *) 0, extra_blbits, 0, BL_CODES, MAX_BL_BITS, { bl_tree, (ct_data *) 0, extra_blbits, 0, BL_CODES, MAX_BL_BITS,
0 }; 0
};
static ush bl_count[MAX_BITS + 1]; static ush bl_count[MAX_BITS + 1];
@ -1902,12 +1912,10 @@ static void gen_bitlen(tree_desc *desc)
if (m > max_code) if (m > max_code)
continue; continue;
if (tree[m].Len != (unsigned) bits) { if (tree[m].Len != (unsigned) bits) {
Trace( Trace((stderr, "code %d bits %d->%d\n", m, tree[m].Len,
(stderr, "code %d bits %d->%d\n", m, tree[m].Len,
bits)); bits));
opt_len += opt_len +=
((long) bits - ((long) bits - (long) tree[m].Len) * (long) tree[m].Freq;
(long) tree[m].Len) * (long) tree[m].Freq;
tree[m].Len = (ush) bits; tree[m].Len = (ush) bits;
} }
n--; n--;
@ -2030,8 +2038,7 @@ static void build_tree(tree_desc *desc)
#ifdef DUMP_BL_TREE #ifdef DUMP_BL_TREE
if (tree == bl_tree) { if (tree == bl_tree) {
fprintf(stderr, "\nnode %d(%d), sons %d(%d) %d(%d)", fprintf(stderr, "\nnode %d(%d), sons %d(%d) %d(%d)",
node, tree[node].Freq, n, tree[n].Freq, m, node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq);
tree[m].Freq);
} }
#endif #endif
/* and insert the new node in the heap */ /* and insert the new node in the heap */
@ -2184,9 +2191,7 @@ static const int build_bl_tree()
} }
/* Update opt_len to include the bit length tree and counts */ /* Update opt_len to include the bit length tree and counts */
opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4; opt_len += 3 * (max_blindex + 1) + 5 + 5 + 4;
Tracev( Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", opt_len, static_len));
(stderr, "\ndyn trees: dyn %ld, stat %ld", opt_len,
static_len));
return max_blindex; return max_blindex;
} }
@ -2200,8 +2205,7 @@ static void send_all_trees(int lcodes, int dcodes, int blcodes)
{ {
int rank; /* index in bl_order */ int rank; /* index in bl_order */
Assert(lcodes >= 257 && dcodes >= 1 Assert(lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
&& blcodes >= 4, "not enough codes");
Assert(lcodes <= L_CODES && dcodes <= D_CODES Assert(lcodes <= L_CODES && dcodes <= D_CODES
&& blcodes <= BL_CODES, "too many codes"); && blcodes <= BL_CODES, "too many codes");
Tracev((stderr, "\nbl counts: ")); Tracev((stderr, "\nbl counts: "));
@ -2242,9 +2246,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
Tracev((stderr, "\nlit data: dyn %ld, stat %ld", opt_len, static_len)); Tracev((stderr, "\nlit data: dyn %ld, stat %ld", opt_len, static_len));
build_tree((tree_desc *) (&d_desc)); build_tree((tree_desc *) (&d_desc));
Tracev( Tracev((stderr, "\ndist data: dyn %ld, stat %ld", opt_len, static_len));
(stderr, "\ndist data: dyn %ld, stat %ld", opt_len,
static_len));
/* At this point, opt_len and static_len are the total bit lengths of /* At this point, opt_len and static_len are the total bit lengths of
* the compressed block data, excluding the tree representations. * the compressed block data, excluding the tree representations.
*/ */
@ -2258,8 +2260,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
opt_lenb = (opt_len + 3 + 7) >> 3; opt_lenb = (opt_len + 3 + 7) >> 3;
static_lenb = (static_len + 3 + 7) >> 3; static_lenb = (static_len + 3 + 7) >> 3;
Trace( Trace((stderr,
(stderr,
"\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ", "\nopt %lu(%lu) stat %lu(%lu) stored %lu lit %u dist %u ",
opt_lenb, opt_len, static_lenb, static_len, stored_len, opt_lenb, opt_len, static_lenb, static_len, stored_len,
last_lit, last_dist)); last_lit, last_dist));
@ -2271,8 +2272,7 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
* and if the zip file can be seeked (to rewrite the local header), * and if the zip file can be seeked (to rewrite the local header),
* the whole file is transformed into a stored file: * the whole file is transformed into a stored file:
*/ */
if (stored_len <= opt_lenb && eof && compressed_len == 0L if (stored_len <= opt_lenb && eof && compressed_len == 0L && seekable()) {
&& seekable()) {
/* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */ /* Since LIT_BUFSIZE <= 2*WSIZE, the input data must be there: */
if (buf == (char *) 0) if (buf == (char *) 0)
error_msg("block vanished"); error_msg("block vanished");
@ -2297,15 +2297,13 @@ static ulg flush_block(char *buf, ulg stored_len, int eof)
} else if (static_lenb == opt_lenb) { } else if (static_lenb == opt_lenb) {
send_bits((STATIC_TREES << 1) + eof, 3); send_bits((STATIC_TREES << 1) + eof, 3);
compress_block((ct_data *) static_ltree, compress_block((ct_data *) static_ltree, (ct_data *) static_dtree);
(ct_data *) static_dtree);
compressed_len += 3 + static_len; compressed_len += 3 + static_len;
} else { } else {
send_bits((DYN_TREES << 1) + eof, 3); send_bits((DYN_TREES << 1) + eof, 3);
send_all_trees(l_desc.max_code + 1, d_desc.max_code + 1, send_all_trees(l_desc.max_code + 1, d_desc.max_code + 1,
max_blindex + 1); max_blindex + 1);
compress_block((ct_data *) dyn_ltree, compress_block((ct_data *) dyn_ltree, (ct_data *) dyn_dtree);
(ct_data *) dyn_dtree);
compressed_len += 3 + opt_len; compressed_len += 3 + opt_len;
} }
Assert(compressed_len == bits_sent, "bad compressed size"); Assert(compressed_len == bits_sent, "bad compressed size");
@ -2363,8 +2361,7 @@ static int ct_tally(int dist, int lc)
(ulg) dyn_dtree[dcode].Freq * (5L + extra_dbits[dcode]); (ulg) dyn_dtree[dcode].Freq * (5L + extra_dbits[dcode]);
} }
out_length >>= 3; out_length >>= 3;
Trace( Trace((stderr,
(stderr,
"\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ", "\nlast_lit %u, last_dist %u, in %ld, out ~%ld(%ld%%) ",
last_lit, last_dist, in_length, out_length, last_lit, last_dist, in_length, out_length,
100L - out_length * 100L / in_length)); 100L - out_length * 100L / in_length));