aboutsummaryrefslogtreecommitdiff
path: root/src/xz/list.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xz/list.c')
-rw-r--r--src/xz/list.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/xz/list.c b/src/xz/list.c
index b532a25b..ee61aeb9 100644
--- a/src/xz/list.c
+++ b/src/xz/list.c
@@ -52,10 +52,13 @@ typedef struct {
uint64_t memusage;
/// The filter chain of this Block in human-readable form
- char filter_chain[FILTERS_STR_SIZE];
+ char *filter_chain;
} block_header_info;
+#define BLOCK_HEADER_INFO_INIT { .filter_chain = NULL }
+#define block_header_info_end(bhi) free((bhi)->filter_chain)
+
/// Strings ending in a colon. These are used for lines like
/// " Foo: 123 MiB". These are grouped because translated strings
@@ -566,10 +569,19 @@ parse_block_header(file_pair *pair, const lzma_index_iter *iter,
}
// Convert the filter chain to human readable form.
- message_filters_to_str(bhi->filter_chain, filters, false);
+ const lzma_ret str_ret = lzma_str_from_filters(
+ &bhi->filter_chain, filters,
+ LZMA_STR_DECODER | LZMA_STR_GETOPT_LONG, NULL);
// Free the memory allocated by lzma_block_header_decode().
lzma_filters_free(filters, NULL);
+
+ // Check if the stringification succeeded.
+ if (str_ret != LZMA_OK) {
+ message_error("%s: %s", pair->src_name, message_strm(str_ret));
+ return true;
+ }
+
return false;
data_error:
@@ -864,9 +876,6 @@ print_info_adv(xz_file_info *xfi, file_pair *pair)
// Cache the verbosity level to a local variable.
const bool detailed = message_verbosity_get() >= V_DEBUG;
- // Information collected from Block Headers
- block_header_info bhi;
-
// Print information about the Blocks but only if there is
// at least one Block.
if (lzma_index_block_count(xfi->idx) > 0) {
@@ -916,8 +925,11 @@ print_info_adv(xz_file_info *xfi, file_pair *pair)
// Iterate over the Blocks.
while (!lzma_index_iter_next(&iter, LZMA_INDEX_ITER_BLOCK)) {
+ // If in detailed mode, collect the information from
+ // Block Header before starting to print the next line.
+ block_header_info bhi = BLOCK_HEADER_INFO_INIT;
if (detailed && parse_details(pair, &iter, &bhi, xfi))
- return true;
+ return true;
const char *cols1[4] = {
uint64_to_str(iter.stream.number, 0),
@@ -1001,6 +1013,7 @@ print_info_adv(xz_file_info *xfi, file_pair *pair)
}
putchar('\n');
+ block_header_info_end(&bhi);
}
}
@@ -1058,9 +1071,9 @@ print_info_robot(xz_file_info *xfi, file_pair *pair)
iter.stream.padding);
lzma_index_iter_rewind(&iter);
- block_header_info bhi;
while (!lzma_index_iter_next(&iter, LZMA_INDEX_ITER_BLOCK)) {
+ block_header_info bhi = BLOCK_HEADER_INFO_INIT;
if (message_verbosity_get() >= V_DEBUG
&& parse_details(
pair, &iter, &bhi, xfi))
@@ -1091,6 +1104,7 @@ print_info_robot(xz_file_info *xfi, file_pair *pair)
bhi.filter_chain);
putchar('\n');
+ block_header_info_end(&bhi);
}
}