diff options
author | Jia Tan <jiat0218@gmail.com> | 2023-04-17 22:22:45 +0800 |
---|---|---|
committer | Jia Tan <jiat0218@gmail.com> | 2023-07-17 23:34:55 +0800 |
commit | 3d21da5cff4b511633cb6e0d8a1090485c0c1059 (patch) | |
tree | c8779217e4f710845930750ef01af26c7e15129e /src | |
parent | Tests: Use new --filters option in test_compress.sh (diff) | |
download | xz-3d21da5cff4b511633cb6e0d8a1090485c0c1059.tar.xz |
xz: Separate string to filter conversion into a helper function.
Converting from string to filter will also need to be done for block
specific filter chains.
Diffstat (limited to 'src')
-rw-r--r-- | src/xz/coder.c | 33 |
1 files changed, 20 insertions, 13 deletions
diff --git a/src/xz/coder.c b/src/xz/coder.c index b998cb2b..159b7d8b 100644 --- a/src/xz/coder.c +++ b/src/xz/coder.c @@ -137,20 +137,12 @@ coder_add_filter(lzma_vli id, void *options) } -extern void -coder_add_filters_from_str(const char *filter_str) +static void +str_to_filter(const char *str, lzma_filter *filter, uint32_t flags) { - // Forget presets and previously defined filter chain. See - // coder_add_filter() above for why preset_number must be reset too. - forget_filter_chain(); - preset_number = LZMA_PRESET_DEFAULT; - - string_to_filter_used = true; - - // Include LZMA_STR_ALL_FILTERS so this can be used with --format=raw. int error_pos; - const char *err = lzma_str_to_filters(filter_str, &error_pos, - filters, LZMA_STR_ALL_FILTERS, NULL); + const char *err = lzma_str_to_filters(str, &error_pos, filter, + flags, NULL); if (err != NULL) { // FIXME? The message in err isn't translated. @@ -159,10 +151,25 @@ coder_add_filters_from_str(const char *filter_str) // liblzma might not be worth it especially since on some // OSes it adds extra dependencies to translation libraries. message(V_ERROR, _("Error in --filters=FILTERS option:")); - message(V_ERROR, "%s", filter_str); + message(V_ERROR, "%s", str); message(V_ERROR, "%*s^", error_pos, ""); message_fatal("%s", err); } +} + + +extern void +coder_add_filters_from_str(const char *filter_str) +{ + // Forget presets and previously defined filter chain. See + // coder_add_filter() above for why preset_number must be reset too. + forget_filter_chain(); + preset_number = LZMA_PRESET_DEFAULT; + + string_to_filter_used = true; + + // Include LZMA_STR_ALL_FILTERS so this can be used with --format=raw. + str_to_filter(filter_str, filters, LZMA_STR_ALL_FILTERS); // Set the filters_count to be the number of filters converted from // the string. |