From 91b0f909393476f39ed5865dfe4b27c244ba3c48 Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 20 Jul 2014 21:47:09 -0500 Subject: [PATCH] cleanups --- NEWS | 2 +- include/wimlib.h | 14 +++++++++----- include/wimlib/lz_mf.h | 1 + src/compress.c | 5 ++--- src/lz_lcp_interval_tree.c | 2 +- src/lzms-compress.c | 12 ++++++------ src/lzx-compress.c | 2 +- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 921e1662..1eef2859 100644 --- a/NEWS +++ b/NEWS @@ -2,7 +2,7 @@ Version 1.7.1-BETA: Made more improvements to the compression algorithms. The default compression mode for wimcapture is now LZX compression in - its default mode, which is the the same as '--compress=maximum'. + its default mode, which is the same as '--compress=maximum'. You can now specify an optional integer compression level to the '--compress' or '--solid-compress' options; e.g. '--compress=lzx:75'. diff --git a/include/wimlib.h b/include/wimlib.h index 17e59574..4ac826a5 100644 --- a/include/wimlib.h +++ b/include/wimlib.h @@ -3678,6 +3678,8 @@ wimlib_resolve_image(WIMStruct *wim, const wimlib_tchar *image_name_or_num); /** + * @ingroup G_general + * * Sets the file to which the library will print error and warning messages. * * This version of the function takes a C library FILE * opened for @@ -3695,6 +3697,8 @@ extern int wimlib_set_error_file(FILE *fp); /** + * @ingroup G_general + * * Sets the path to the file to which the library will print error and warning * messages. The library will open this file for appending. * @@ -4291,9 +4295,10 @@ struct wimlib_decompressor; * wimlib_create_compressor(). * * @param ctype - * Compression type for which to set the default compression level. Or, if - * this is the special value -1, the default compression levels for all - * known compression types will be set. + * Compression type for which to set the default compression level, as one + * of the ::wimlib_compression_type constants. Or, if this is the special + * value -1, the default compression levels for all known compression types + * will be set. * @param compression_level * The default compression level to set. If 0, the "default default" level * is restored. Otherwise, a higher value indicates higher compression. @@ -4306,8 +4311,7 @@ struct wimlib_decompressor; * @p ctype was neither a supported compression type nor -1. */ extern int -wimlib_set_default_compression_level(enum wimlib_compression_type ctype, - unsigned int compression_level); +wimlib_set_default_compression_level(int ctype, unsigned int compression_level); /** * Returns the approximate number of bytes needed to allocate a compressor with diff --git a/include/wimlib/lz_mf.h b/include/wimlib/lz_mf.h index c94fce7a..221418d6 100644 --- a/include/wimlib/lz_mf.h +++ b/include/wimlib/lz_mf.h @@ -83,6 +83,7 @@ struct lz_mf; /* Representation of a Lempel-Ziv match. */ struct lz_match { + /* The number of bytes matched. */ u32 len; diff --git a/src/compress.c b/src/compress.c index bea8ea5a..75f92f13 100644 --- a/src/compress.c +++ b/src/compress.c @@ -65,10 +65,9 @@ compressor_ctype_valid(int ctype) } WIMLIBAPI int -wimlib_set_default_compression_level(enum wimlib_compression_type ctype, - unsigned int compression_level) +wimlib_set_default_compression_level(int ctype, unsigned int compression_level) { - if ((int)ctype == -1) { + if (ctype == -1) { for (int i = 0; i < ARRAY_LEN(default_compression_levels); i++) default_compression_levels[i] = compression_level; } else { diff --git a/src/lz_lcp_interval_tree.c b/src/lz_lcp_interval_tree.c index a6c72d59..7c0135a2 100644 --- a/src/lz_lcp_interval_tree.c +++ b/src/lz_lcp_interval_tree.c @@ -426,7 +426,7 @@ lz_lcpit_get_matches(struct lz_mf *_mf, struct lz_match matches[]) interval = next_interval; } - /* We're already visited the current lcp-interval. */ + /* We've already visited the current lcp-interval. */ /* Extract the LCP of this lcp-interval. */ lcp = intervals[interval] & LZ_LCPIT_LCP_MASK; diff --git a/src/lzms-compress.c b/src/lzms-compress.c index f417fa52..871c12c7 100644 --- a/src/lzms-compress.c +++ b/src/lzms-compress.c @@ -873,10 +873,10 @@ lzms_match_chooser_reverse_list(struct lzms_compressor *ctx, unsigned cur_pos) }; } -/* This is similar to lzx_choose_near_optimal_match() in lzx-compress.c. +/* This is similar to lzx_choose_near_optimal_item() in lzx-compress.c. * Read that one if you want to understand it. */ static struct lz_match -lzms_get_near_optimal_match(struct lzms_compressor *ctx) +lzms_get_near_optimal_item(struct lzms_compressor *ctx) { u32 num_matches; struct lz_match *matches; @@ -1133,7 +1133,7 @@ lzms_get_near_optimal_match(struct lzms_compressor *ctx) static void lzms_encode(struct lzms_compressor *ctx) { - struct lz_match match; + struct lz_match item; /* Load window into the match-finder. */ lz_mf_load_window(ctx->mf, ctx->window, ctx->window_size); @@ -1143,11 +1143,11 @@ lzms_encode(struct lzms_compressor *ctx) ctx->optimum_end_idx = 0; while (ctx->cur_window_pos != ctx->window_size) { - match = lzms_get_near_optimal_match(ctx); - if (match.len <= 1) + item = lzms_get_near_optimal_item(ctx); + if (item.len <= 1) lzms_encode_literal(ctx, ctx->window[ctx->cur_window_pos]); else - lzms_encode_lz_match(ctx, match.len, match.offset); + lzms_encode_lz_match(ctx, item.len, item.offset); } } diff --git a/src/lzx-compress.c b/src/lzx-compress.c index 75104574..db0e7c10 100644 --- a/src/lzx-compress.c +++ b/src/lzx-compress.c @@ -109,7 +109,7 @@ * that position at previous positions in the window. With LZX, the minimum * match length is 2 and the maximum match length is 257. The only restriction * on offsets is that LZX does not allow the last 2 bytes of the window to match - * the the beginning of the window. + * the beginning of the window. * * There are a number of algorithms that can be used for this, including hash * chains, binary trees, and suffix arrays. Binary trees generally work well -- 2.43.0