]> git.ipfire.org Git - thirdparty/xz.git/log
thirdparty/xz.git
2 years agoCMake: Require that the C compiler supports C99 or a newer standard.
Lasse Collin [Mon, 27 Feb 2023 16:38:35 +0000 (18:38 +0200)] 
CMake: Require that the C compiler supports C99 or a newer standard.

Thanks to autoantwort for reporting the issue and suggesting
a different patch:
https://github.com/tukaani-project/xz/pull/42

2 years agoTests: Small tweak to test-vli.c.
Jia Tan [Fri, 24 Feb 2023 10:10:37 +0000 (18:10 +0800)] 
Tests: Small tweak to test-vli.c.

The static global variables can be disabled if encoders and decoders
are not built. If they are not disabled and -Werror is used, it will
cause an usused warning as an error.

2 years agoliblzma: Replace '\n' -> newline in filter.h documentation.
Jia Tan [Mon, 6 Feb 2023 13:46:43 +0000 (21:46 +0800)] 
liblzma: Replace '\n' -> newline in filter.h documentation.

The '\n' renders as a newline when the comments are converted to html
by Doxygen.

2 years agoliblzma: Shorten return description for two functions in filter.h.
Jia Tan [Mon, 6 Feb 2023 13:45:37 +0000 (21:45 +0800)] 
liblzma: Shorten return description for two functions in filter.h.

Shorten the description for lzma_raw_encoder_memusage() and
lzma_raw_decoder_memusage().

2 years agoliblzma: Reword a few lines in filter.h
Jia Tan [Mon, 6 Feb 2023 13:44:45 +0000 (21:44 +0800)] 
liblzma: Reword a few lines in filter.h

2 years agoliblzma: Improve documentation in filter.h.
Jia Tan [Mon, 6 Feb 2023 13:35:06 +0000 (21:35 +0800)] 
liblzma: Improve documentation in filter.h.

All functions now explicitly specify parameter and return values.
The notes and code annotations were moved before the parameter and
return value descriptions for consistency.

Also, the description above lzma_filter_encoder_is_supported() about
not being able to list available filters was removed since
lzma_str_list_filters() will do this.

2 years agoUpdate THANKS.
Lasse Collin [Thu, 23 Feb 2023 18:46:16 +0000 (20:46 +0200)] 
Update THANKS.

2 years agoliblzma: Avoid null pointer + 0 (undefined behavior in C).
Lasse Collin [Tue, 21 Feb 2023 20:57:10 +0000 (22:57 +0200)] 
liblzma: Avoid null pointer + 0 (undefined behavior in C).

In the C99 and C17 standards, section 6.5.6 paragraph 8 means that
adding 0 to a null pointer is undefined behavior. As of writing,
"clang -fsanitize=undefined" (Clang 15) diagnoses this. However,
I'm not aware of any compiler that would take advantage of this
when optimizing (Clang 15 included). It's good to avoid this anyway
since compilers might some day infer that pointer arithmetic implies
that the pointer is not NULL. That is, the following foo() would then
unconditionally return 0, even for foo(NULL, 0):

    void bar(char *a, char *b);

    int foo(char *a, size_t n)
    {
        bar(a, a + n);
        return a == NULL;
    }

In contrast to C, C++ explicitly allows null pointer + 0. So if
the above is compiled as C++ then there is no undefined behavior
in the foo(NULL, 0) call.

To me it seems that changing the C standard would be the sane
thing to do (just add one sentence) as it would ensure that a huge
amount of old code won't break in the future. Based on web searches
it seems that a large number of codebases (where null pointer + 0
occurs) are being fixed instead to be future-proof in case compilers
will some day optimize based on it (like making the above foo(NULL, 0)
return 0) which in the worst case will cause security bugs.

Some projects don't plan to change it. For example, gnulib and thus
many GNU tools currently require that null pointer + 0 is defined:

    https://lists.gnu.org/archive/html/bug-gnulib/2021-11/msg00000.html

    https://www.gnu.org/software/gnulib/manual/html_node/Other-portability-assumptions.html

In XZ Utils null pointer + 0 issue should be fixed after this
commit. This adds a few if-statements and thus branches to avoid
null pointer + 0. These check for size > 0 instead of ptr != NULL
because this way bugs where size > 0 && ptr == NULL will likely
get caught quickly. None of them are in hot spots so it shouldn't
matter for performance.

A little less readable version would be replacing

    ptr + offset

with

    offset != 0 ? ptr + offset : ptr

or creating a macro for it:

    #define my_ptr_add(ptr, offset) \
            ((offset) != 0 ? ((ptr) + (offset)) : (ptr))

Checking for offset != 0 instead of ptr != NULL allows GCC >= 8.1,
Clang >= 7, and Clang-based ICX to optimize it to the very same code
as ptr + offset. That is, it won't create a branch. So for hot code
this could be a good solution to avoid null pointer + 0. Unfortunately
other compilers like ICC 2021 or MSVC 19.33 (VS2022) will create a
branch from my_ptr_add().

Thanks to Marcin Kowalczyk for reporting the problem:
https://github.com/tukaani-project/xz/issues/36

2 years agoliblzma: Adjust container.h for consistency with filter.h.
Jia Tan [Mon, 6 Feb 2023 16:00:44 +0000 (00:00 +0800)] 
liblzma: Adjust container.h for consistency with filter.h.

2 years agoliblzma: Fix small typos and reword a few things in filter.h.
Jia Tan [Mon, 6 Feb 2023 16:00:09 +0000 (00:00 +0800)] 
liblzma: Fix small typos and reword a few things in filter.h.

2 years agoliblzma: Convert list of flags in lzma_mt to bulleted list.
Jia Tan [Mon, 6 Feb 2023 15:42:08 +0000 (23:42 +0800)] 
liblzma: Convert list of flags in lzma_mt to bulleted list.

2 years agoliblzma: Fix typo in documentation in container.h
Jia Tan [Thu, 26 Jan 2023 15:17:41 +0000 (23:17 +0800)] 
liblzma: Fix typo in documentation in container.h

lzma_microlzma_decoder -> lzma_microlzma_encoder

2 years agoliblzma: Improve documentation for container.h
Jia Tan [Thu, 26 Jan 2023 15:16:34 +0000 (23:16 +0800)] 
liblzma: Improve documentation for container.h

Standardizing each function to always specify parameters and return
values. Also moved the parameters and return values to the end of each
function description.

2 years agoCMake: Add LZIP decoder test to list of tests.
Jia Tan [Wed, 22 Feb 2023 12:59:41 +0000 (20:59 +0800)] 
CMake: Add LZIP decoder test to list of tests.

2 years agoUpdate THANKS.
Lasse Collin [Fri, 17 Feb 2023 18:56:49 +0000 (20:56 +0200)] 
Update THANKS.

2 years agoBuild: Use only the generic symbol versioning on MicroBlaze.
Lasse Collin [Fri, 17 Feb 2023 18:48:28 +0000 (20:48 +0200)] 
Build: Use only the generic symbol versioning on MicroBlaze.

On MicroBlaze, GCC 12 is broken in sense that
__has_attribute(__symver__) returns true but it still doesn't
support the __symver__ attribute even though the platform is ELF
and symbol versioning is supported if using the traditional
__asm__(".symver ...") method. Avoiding the traditional method is
good because it breaks LTO (-flto) builds with GCC.

See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101766

For now the only extra symbols in liblzma_linux.map are the
compatibility symbols with the patch that spread from RHEL/CentOS 7.
These require the use of __symver__ attribute or __asm__(".symver ...")
in the C code. Compatibility with the patch from CentOS 7 doesn't
seem valuable on MicroBlaze so use liblzma_generic.map on MicroBlaze
instead. It doesn't require anything special in the C code and thus
no LTO issues either.

An alternative would be to detect support for __symver__
attribute in configure.ac and CMakeLists.txt and fall back
to __asm__(".symver ...") but then LTO would be silently broken
on MicroBlaze. It sounds likely that MicroBlaze is a special
case so let's treat it as a such because that is simpler. If
a similar issue exists on some other platform too then hopefully
someone will report it and this can be reconsidered.

(This doesn't do the same fix in CMakeLists.txt. Perhaps it should
but perhaps CMake build of liblzma doesn't matter much on MicroBlaze.
The problem breaks the build so it's easy to notice and can be fixed
later.)

Thanks to Vincent Fazio for reporting the problem and proposing
a patch (in the end that solution wasn't used):
https://github.com/tukaani-project/xz/pull/32

2 years agoliblzma: Very minor API doc tweaks.
Lasse Collin [Thu, 16 Feb 2023 19:09:00 +0000 (21:09 +0200)] 
liblzma: Very minor API doc tweaks.

Use "member" to refer to struct members as that's the term used
by the C standard.

Use lzma_options_delta.dist and such in docs so that in Doxygen's
HTML output they will link to the doc of the struct member.

Clean up a few trailing white spaces too.

2 years agoliblzma: Adjust spacing in doc headers in bcj.h.
Jia Tan [Thu, 16 Feb 2023 16:54:33 +0000 (00:54 +0800)] 
liblzma: Adjust spacing in doc headers in bcj.h.

2 years agoliblzma: Adjust documentation in bcj.h for consistent style.
Jia Tan [Thu, 16 Feb 2023 16:44:44 +0000 (00:44 +0800)] 
liblzma: Adjust documentation in bcj.h for consistent style.

2 years agoliblzma: Rename field => member in documentation.
Jia Tan [Thu, 16 Feb 2023 16:36:05 +0000 (00:36 +0800)] 
liblzma: Rename field => member in documentation.

Also adjusted preset value => preset level.

2 years agoliblzma: Silence a warning from MSVC.
Lasse Collin [Thu, 16 Feb 2023 15:59:50 +0000 (17:59 +0200)] 
liblzma: Silence a warning from MSVC.

It gives C4146 here since unary minus with unsigned integer
is still unsigned (which is the intention here). Doing it
with substraction makes it clearer and avoids the warning.

Thanks to Nathan Moinvaziri for reporting this.

2 years agoliblzma: Improve documentation for stream_flags.h
Jia Tan [Thu, 16 Feb 2023 13:04:54 +0000 (21:04 +0800)] 
liblzma: Improve documentation for stream_flags.h

Standardizing each function to always specify parameters and return
values. Also moved the parameters and return values to the end of each
function description.

A few small things were reworded and long sentences broken up.

2 years agoliblzma: Improve documentation in lzma12.h.
Jia Tan [Tue, 14 Feb 2023 13:50:16 +0000 (21:50 +0800)] 
liblzma: Improve documentation in lzma12.h.

All functions now explicitly specify parameter and return values.

2 years agoliblzma: Improve documentation in check.h.
Jia Tan [Fri, 27 Jan 2023 14:44:06 +0000 (22:44 +0800)] 
liblzma: Improve documentation in check.h.

All functions now explicitly specify parameter and return values.
Also moved the note about SHA-256 functions not being exported to the
top of the file.

2 years agoliblzma: Improve documentation in index.h
Jia Tan [Wed, 8 Feb 2023 13:33:52 +0000 (21:33 +0800)] 
liblzma: Improve documentation in index.h

All functions now explicitly specify parameter and return values.

2 years agoliblzma: Reword a comment in index.h.
Jia Tan [Wed, 8 Feb 2023 12:35:32 +0000 (20:35 +0800)] 
liblzma: Reword a comment in index.h.

2 years agoliblzma: Omit lzma_index_iter's internal field from Doxygen docs.
Jia Tan [Wed, 8 Feb 2023 12:30:23 +0000 (20:30 +0800)] 
liblzma: Omit lzma_index_iter's internal field from Doxygen docs.

Add \private above this field and its sub-fields since it is not meant
to be modified by users.

2 years agoliblzma: Fix documentation for LZMA_MEMLIMIT_ERROR.
Jia Tan [Sat, 21 Jan 2023 13:32:03 +0000 (21:32 +0800)] 
liblzma: Fix documentation for LZMA_MEMLIMIT_ERROR.

LZMA_MEMLIMIT_ERROR was missing the "<" character needed to put
documentation after a member.

2 years agoliblzma: Improve documentation for base.h.
Jia Tan [Fri, 20 Jan 2023 16:29:38 +0000 (00:29 +0800)] 
liblzma: Improve documentation for base.h.

Standardizing each function to always specify params and return values.
Also fixed a small grammar mistake.

2 years agoliblzma: Minor improvements to vli.h.
Jia Tan [Mon, 13 Feb 2023 16:08:33 +0000 (00:08 +0800)] 
liblzma: Minor improvements to vli.h.

Added [out] annotations to parameters that are pointers and can have
their value changed. Also added a clarification to lzma_vli_is_valid.

2 years agoliblzma: Add comments for macros in delta.h.
Jia Tan [Fri, 10 Feb 2023 13:38:02 +0000 (21:38 +0800)] 
liblzma: Add comments for macros in delta.h.

Document LZMA_DELTA_DIST_MIN and LZMA_DELTA_DIST_MAX for completeness
and to avoid Doxygen warnings.

2 years agoliblzma: Improve documentation in index_hash.h.
Jia Tan [Fri, 10 Feb 2023 13:35:23 +0000 (21:35 +0800)] 
liblzma: Improve documentation in index_hash.h.

All functions now explicitly specify parameter and return values.
Also reworded the description of lzma_index_hash_init() for readability.

2 years agoliblzma: Fix bug in lzma_str_from_filters() not checking filters[] length.
Jia Tan [Thu, 2 Feb 2023 16:33:32 +0000 (00:33 +0800)] 
liblzma: Fix bug in lzma_str_from_filters() not checking filters[] length.

The bug is only a problem in applications that do not properly terminate
the filters[] array with LZMA_VLI_UNKNOWN or have more than
LZMA_FILTERS_MAX filters. This bug does not affect xz.

2 years agoTests: Create test_filter_str.c.
Jia Tan [Thu, 2 Feb 2023 16:32:47 +0000 (00:32 +0800)] 
Tests: Create test_filter_str.c.

Tests lzma_str_to_filters(), lzma_str_from_filters(), and
lzma_str_list_filters() API functions.

2 years agoliblzma: Fix typos in comments in string_conversion.c.
Jia Tan [Sun, 22 Jan 2023 00:49:00 +0000 (08:49 +0800)] 
liblzma: Fix typos in comments in string_conversion.c.

2 years agoliblzma: Clarify block encoder and decoder documentation.
Jia Tan [Thu, 2 Feb 2023 16:20:20 +0000 (00:20 +0800)] 
liblzma: Clarify block encoder and decoder documentation.

Added a few sentences to the description for lzma_block_encoder() and
lzma_block_decoder() to highlight that the Block Header must be coded
before calling these functions.

2 years agoUpdate lzma_block documentation for lzma_block_uncomp_encode().
Jia Tan [Thu, 2 Feb 2023 16:12:24 +0000 (00:12 +0800)] 
Update lzma_block documentation for lzma_block_uncomp_encode().

2 years agoliblzma: Minor edits to lzma_block header_size documentation.
Jia Tan [Thu, 2 Feb 2023 16:11:37 +0000 (00:11 +0800)] 
liblzma: Minor edits to lzma_block header_size documentation.

2 years agoliblzma: Enumerate functions that read version in lzma_block.
Jia Tan [Thu, 2 Feb 2023 16:11:07 +0000 (00:11 +0800)] 
liblzma: Enumerate functions that read version in lzma_block.

2 years agoliblzma: Clarify comment in block.h.
Jia Tan [Thu, 2 Feb 2023 16:10:34 +0000 (00:10 +0800)] 
liblzma: Clarify comment in block.h.

2 years agoliblzma: Improve documentation for block.h.
Jia Tan [Thu, 2 Feb 2023 16:07:23 +0000 (00:07 +0800)] 
liblzma: Improve documentation for block.h.

Standardizing each function to always specify params and return values.
Output pointer parameters are also marked with doxygen style [out] to
make it clear. Any note sections were also moved above the parameter and
return sections for consistency.

2 years agoliblzma: Clarify a comment about LZMA_STR_NO_VALIDATION.
Jia Tan [Wed, 1 Feb 2023 15:38:30 +0000 (23:38 +0800)] 
liblzma: Clarify a comment about LZMA_STR_NO_VALIDATION.

The flag description for LZMA_STR_NO_VALIDATION was previously confusing
about the treatment for filters than cannot be used with .xz format
(lzma1) without using LZMA_STR_ALL_FILTERS. Now, it is clear that
LZMA_STR_NO_VALIDATION is not a super set of LZMA_STR_ALL_FILTERS.

2 years agoTranslations: Add Brazilian Portuguese translation of man pages.
Jia Tan [Fri, 27 Jan 2023 12:14:51 +0000 (20:14 +0800)] 
Translations: Add Brazilian Portuguese translation of man pages.

Thanks to Rafael Fontenelle.

2 years agoliblzma: Fix documentation in filter.h for lzma_str_to_filters()
Jia Tan [Tue, 24 Jan 2023 12:48:50 +0000 (20:48 +0800)] 
liblzma: Fix documentation in filter.h for lzma_str_to_filters()

The previous documentation for lzma_str_to_filters() was technically
correct, but misleading. lzma_str_to_filters() returns NULL on success,
which is in practice always defined to 0. This is the same value as
LZMA_OK, but lzma_str_to_filters() does not return lzma_ret so we should
be more clear.

2 years agoxz: Refactor duplicated check for custom suffix when using --format=raw
Jia Tan [Sat, 7 Jan 2023 13:55:06 +0000 (21:55 +0800)] 
xz: Refactor duplicated check for custom suffix when using --format=raw

2 years agoliblzma: Set documentation on all reserved fields to private.
Jia Tan [Fri, 20 Jan 2023 13:53:14 +0000 (21:53 +0800)] 
liblzma: Set documentation on all reserved fields to private.

This prevents the reserved fields from being part of the generated
Doxygen documentation.

2 years agoliblzma: Highlight liblzma API headers should not be included directly.
Jia Tan [Wed, 21 Dec 2022 15:59:43 +0000 (23:59 +0800)] 
liblzma: Highlight liblzma API headers should not be included directly.

This improves the generated Doxygen HTML files to better highlight
how to properly use the liblzma API header files.

2 years agotuklib_physmem: Silence warning from -Wcast-function-type on MinGW-w64.
Jia Tan [Thu, 19 Jan 2023 12:35:09 +0000 (20:35 +0800)] 
tuklib_physmem: Silence warning from -Wcast-function-type on MinGW-w64.

tuklib_physmem depends on GetProcAddress() for both MSVC and MinGW-w64
to retrieve a function address. The proper way to do this is to cast the
return value to the type of function pointer retrieved. Unfortunately,
this causes a cast-function-type warning, so the best solution is to
simply ignore the warning.

2 years agoxz: Add missing comment for coder_set_compression_settings()
Jia Tan [Mon, 16 Jan 2023 13:35:45 +0000 (21:35 +0800)] 
xz: Add missing comment for coder_set_compression_settings()

2 years agoxz: Do not set compression settings with raw format in list mode.
Jia Tan [Mon, 16 Jan 2023 12:55:10 +0000 (20:55 +0800)] 
xz: Do not set compression settings with raw format in list mode.

Calling coder_set_compression_settings() in list mode with verbose mode
on caused the filter chain and memory requirements to print. This was
unnecessary since the command results in an error and not consistent
with other formats like lzma and alone.

2 years agoTranslations: Update the Brazilian Portuguese translation.
Jia Tan [Fri, 13 Jan 2023 12:37:06 +0000 (20:37 +0800)] 
Translations: Update the Brazilian Portuguese translation.

2 years agoBuild: Omit -Wmissing-noreturn from the default warnings.
Lasse Collin [Thu, 12 Jan 2023 11:04:05 +0000 (13:04 +0200)] 
Build: Omit -Wmissing-noreturn from the default warnings.

It's not that important. It can be annoying in builds that
disable many features since in those cases the tests programs
will correctly trigger this warning with Clang.

2 years agoxz: Use ssize_t for the to-be-ignored return value from write(fd, ptr, 1).
Lasse Collin [Thu, 12 Jan 2023 04:05:58 +0000 (06:05 +0200)] 
xz: Use ssize_t for the to-be-ignored return value from write(fd, ptr, 1).

It makes no difference here as the return value fits into an int
too and it then gets ignored but this looks better.

2 years agoxz: Silence warnings from -Wsign-conversion in a 32-bit build.
Lasse Collin [Thu, 12 Jan 2023 04:01:12 +0000 (06:01 +0200)] 
xz: Silence warnings from -Wsign-conversion in a 32-bit build.

2 years agoliblzma: Silence another warning from -Wsign-conversion in a 32-bit build.
Lasse Collin [Thu, 12 Jan 2023 03:38:48 +0000 (05:38 +0200)] 
liblzma: Silence another warning from -Wsign-conversion in a 32-bit build.

It doesn't warn on a 64-bit system because truncating
a ptrdiff_t (signed long) to uint32_t is diagnosed under
-Wconversion by GCC and -Wshorten-64-to-32 by Clang.

2 years agoliblzma: Silence a warning from -Wsign-conversion in a 32-bit build.
Lasse Collin [Thu, 12 Jan 2023 02:46:45 +0000 (04:46 +0200)] 
liblzma: Silence a warning from -Wsign-conversion in a 32-bit build.

2 years agoBuild: Make configure add more warning flags for GCC and Clang.
Lasse Collin [Thu, 12 Jan 2023 02:17:24 +0000 (04:17 +0200)] 
Build: Make configure add more warning flags for GCC and Clang.

-Wstrict-aliasing was removed from the list since it is enabled
by -Wall already.

A normal build is clean with these on GNU/Linux x86-64 with
GCC 12.2.0 and Clang 14.0.6.

2 years agoTests: Fix warnings from clang --Wassign-enum.
Lasse Collin [Thu, 12 Jan 2023 02:14:18 +0000 (04:14 +0200)] 
Tests: Fix warnings from clang --Wassign-enum.

Explicitly casting the integer to lzma_check silences the warning.
Since such an invalid value is needed in multiple tests, a constant
INVALID_LZMA_CHECK_ID was added to tests.h.

The use of 0x1000 for lzma_block.check wasn't optimal as if
the underlying type is a char then 0x1000 will be truncated to 0.
However, in these test cases the value is ignored, thus even with
such truncation the test would have passed.

2 years agoTests: Silence warnings from -Wsign-conversion.
Lasse Collin [Thu, 12 Jan 2023 01:51:07 +0000 (03:51 +0200)] 
Tests: Silence warnings from -Wsign-conversion.

Note that assigning an unsigned int to lzma_check doesn't warn
on GNU/Linux x86-64 since the enum type is unsigned on that
platform. The enum can be signed on some other platform though
so it's best to use enumeration type lzma_check in these situations.

2 years agoliblzma: Silence warnings from clang -Wconditional-uninitialized.
Lasse Collin [Thu, 12 Jan 2023 01:19:59 +0000 (03:19 +0200)] 
liblzma: Silence warnings from clang -Wconditional-uninitialized.

This is similar to 2ce4f36f179a81d0c6e182a409f363df759d1ad0.
The actual initialization of the variables is done inside
mythread_sync() macro. Clang doesn't seem to see that
the initialization code inside the macro is always executed.

2 years agoFix warnings from clang -Wdocumentation.
Lasse Collin [Thu, 12 Jan 2023 01:11:40 +0000 (03:11 +0200)] 
Fix warnings from clang -Wdocumentation.

2 years agoTests: test_lzip_decoder: Remove trailing white-space.
Lasse Collin [Thu, 12 Jan 2023 01:04:28 +0000 (03:04 +0200)] 
Tests: test_lzip_decoder: Remove trailing white-space.

2 years agoTests: test_lzip_decoder: Silence warnings from -Wsign-conversion.
Lasse Collin [Thu, 12 Jan 2023 01:03:55 +0000 (03:03 +0200)] 
Tests: test_lzip_decoder: Silence warnings from -Wsign-conversion.

2 years agoBump version and soname for 5.4.1. v5.4.1
Lasse Collin [Wed, 11 Jan 2023 16:52:54 +0000 (18:52 +0200)] 
Bump version and soname for 5.4.1.

2 years agoAdd NEWS for 5.4.1.
Jia Tan [Wed, 11 Jan 2023 15:58:16 +0000 (23:58 +0800)] 
Add NEWS for 5.4.1.

2 years agosysdefs.h: Don't include strings.h anymore.
Lasse Collin [Tue, 10 Jan 2023 09:56:11 +0000 (11:56 +0200)] 
sysdefs.h: Don't include strings.h anymore.

On some platforms src/xz/suffix.c may need <strings.h> for
strcasecmp() but suffix.c includes the header when it needs it.

Unless there is an old system that otherwise supports enough C99
to build XZ Utils but doesn't have C89/C90-compatible <string.h>,
there should be no need to include <strings.h> in sysdefs.h.

2 years agoxz: Include <strings.h> in suffix.c if needed for strcasecmp().
Lasse Collin [Tue, 10 Jan 2023 09:23:41 +0000 (11:23 +0200)] 
xz: Include <strings.h> in suffix.c if needed for strcasecmp().

SUSv2 and POSIX.1‐2017 declare only a few functions in <strings.h>.
Of these, strcasecmp() is used on some platforms in suffix.c.
Nothing else in the project needs <strings.h> (at least if
building on a modern system).

sysdefs.h currently includes <strings.h> if HAVE_STRINGS_H is
defined and suffix.c relied on this.

Note that dos/config.h doesn't #define HAVE_STRINGS_H even though
DJGPP does have strings.h. It isn't needed with DJGPP as strcasecmp()
is also in <string.h> in DJGPP.

2 years agoxz: Fix warning -Wformat-nonliteral on clang in message.c.
Jia Tan [Wed, 11 Jan 2023 14:46:48 +0000 (22:46 +0800)] 
xz: Fix warning -Wformat-nonliteral on clang in message.c.

clang and gcc differ in how they handle -Wformat-nonliteral. gcc will
allow a non-literal format string as long as the function takes its
format arguments as a va_list.

2 years agoTests: Fix test_filter_flags copy/paste error.
Jia Tan [Wed, 11 Jan 2023 12:58:31 +0000 (20:58 +0800)] 
Tests: Fix test_filter_flags copy/paste error.

2 years agoTests: Fix type-limits warning in test_filter_flags.
Jia Tan [Wed, 11 Jan 2023 12:42:29 +0000 (20:42 +0800)] 
Tests: Fix type-limits warning in test_filter_flags.

This only occurs in test_filter_flags when the BCJ filters are not
configured and built. In this case, ARRAY_SIZE() returns 0 and causes a
type-limits warning with the loop variable since an unsigned number will
always be >= 0.

2 years agoliblzma: CLMUL CRC64: Work around a bug in MSVC, second attempt.
Lasse Collin [Tue, 10 Jan 2023 20:14:03 +0000 (22:14 +0200)] 
liblzma: CLMUL CRC64: Work around a bug in MSVC, second attempt.

This affects only 32-bit x86 builds. x86-64 is OK as is.

I still cannot easily test this myself. The reporter has tested
this and it passes the tests included in the CMake build and
performance is good: raw CRC64 is 2-3 times faster than the
C version of the slice-by-four method. (Note that liblzma doesn't
include a MSVC-compatible version of the 32-bit x86 assembly code
for the slice-by-four method.)

Thanks to Iouri Kharon for figuring out a fix, testing, and
benchmarking.

2 years agoTests: Fix unused function warning in test_block_header.
Jia Tan [Tue, 10 Jan 2023 17:18:50 +0000 (01:18 +0800)] 
Tests: Fix unused function warning in test_block_header.

One of the global arrays of filters was only used in a test that
required both encoders and decoders to be configured in the build.

2 years agoTests: Fix unused function warning in test_index_hash.
Jia Tan [Tue, 10 Jan 2023 17:08:03 +0000 (01:08 +0800)] 
Tests: Fix unused function warning in test_index_hash.

test_index_hash does not use fill_index_hash() unless both encoders
and decoders are configured in the build.

2 years agoWindows: Update INSTALL-MSVC.txt to recommend CMake over project files.
Lasse Collin [Mon, 9 Jan 2023 22:33:14 +0000 (00:33 +0200)] 
Windows: Update INSTALL-MSVC.txt to recommend CMake over project files.

2 years agoRevert "liblzma: CLMUL CRC64: Workaround a bug in MSVC (VS2015-2022)."
Lasse Collin [Tue, 10 Jan 2023 10:47:16 +0000 (12:47 +0200)] 
Revert "liblzma: CLMUL CRC64: Workaround a bug in MSVC (VS2015-2022)."

This reverts commit 36edc65ab4cf10a131f239acbd423b4510ba52d5.

It was reported that it wasn't a good enough fix and MSVC
still produced (different kind of) bad code when building
for 32-bit x86 if optimizations are enabled.

Thanks to Iouri Kharon.

2 years agosysdefs.h: Fix a comment.
Lasse Collin [Tue, 10 Jan 2023 08:05:13 +0000 (10:05 +0200)] 
sysdefs.h: Fix a comment.

2 years agosysdefs.h: Don't include memory.h anymore even if it were available.
Lasse Collin [Tue, 10 Jan 2023 08:04:06 +0000 (10:04 +0200)] 
sysdefs.h: Don't include memory.h anymore even if it were available.

It quite probably was never needed, that is, any system where memory.h
was required likely couldn't compile XZ Utils for other reasons anyway.

XZ Utils 5.2.6 and later source packages were generated using
Autoconf 2.71 which no longer defines HAVE_MEMORY_H. So the code
being removed is no longer used anyway.

2 years agoCMake/Windows: Add a workaround for windres from GNU binutils.
Lasse Collin [Tue, 10 Jan 2023 06:50:26 +0000 (08:50 +0200)] 
CMake/Windows: Add a workaround for windres from GNU binutils.

This is combined from the following commits in the master branch:
443dfebced041adc88f10d824188eeef5b5821a9
6b117d3b1fe91eb26d533ab16a2e552f84148d47
5e34774c31d1b7509b5cb77a3be9973adec59ea0

Thanks to Iouri Kharon for the bug report, the original patch,
and testing.

2 years agoTests: test_filter_flags: Clean up minor issues.
Lasse Collin [Fri, 6 Jan 2023 20:53:38 +0000 (22:53 +0200)] 
Tests: test_filter_flags: Clean up minor issues.

Here are the list of the most significant issues addressed:
- Avoid using internal common.h header. It's not good to copy the
constants like this but common.h cannot be included for use outside
of liblzma. This is the quickest thing to do that could be fixed later.

- Omit the INIT_FILTER macro. Initialization should be done with just
regular designated initializers.

- Use start_offset = 257 for BCJ tests. It demonstrates that Filter
Flags encoder and decoder don't validate the options thoroughly.
257 is valid only for the x86 filter. This is a bit silly but
not a significant problem in practice because the encoder and
decoder initialization functions will catch bad alignment still.
Perhaps this should be fixed but it's not urgent and doesn't need
to be in 5.4.x.

- Various tweaks to comments such as filter id -> Filter ID

2 years agoTests: Refactors existing filter flags tests.
Jia Tan [Thu, 29 Dec 2022 15:33:33 +0000 (23:33 +0800)] 
Tests: Refactors existing filter flags tests.

Converts the existing filter flags tests into tuktests.

2 years agoTests: tuktest.h: Support tuktest_malloc(0).
Lasse Collin [Sat, 7 Jan 2023 22:32:29 +0000 (00:32 +0200)] 
Tests: tuktest.h: Support tuktest_malloc(0).

It's not needed in XZ Utils at least for now. It's good to support
it still because if such use is needed later, it wouldn't be
caught on GNU/Linux since malloc(0) from glibc returns non-NULL.

2 years agoCMake: Update cmake_minimum_required from 3.13...3.16 to 3.13...3.25.
Lasse Collin [Sat, 7 Jan 2023 19:57:11 +0000 (21:57 +0200)] 
CMake: Update cmake_minimum_required from 3.13...3.16 to 3.13...3.25.

The changes listed on cmake-policies(7) for versions 3.17 to 3.25
shouldn't affect this project.

2 years agoUpdate THANKS.
Lasse Collin [Sat, 7 Jan 2023 22:24:23 +0000 (00:24 +0200)] 
Update THANKS.

2 years agoUpdate THANKS.
Lasse Collin [Sat, 7 Jan 2023 17:50:35 +0000 (19:50 +0200)] 
Update THANKS.

2 years agoCMake: Fix a copypaste error in xzdec Windows resource file handling.
Lasse Collin [Mon, 9 Jan 2023 09:27:24 +0000 (11:27 +0200)] 
CMake: Fix a copypaste error in xzdec Windows resource file handling.

It was my mistake. Thanks to Iouri Kharon for the bug report.

2 years agoCMake/Windows: Add resource files to xz.exe and xzdec.exe.
Lasse Collin [Sat, 7 Jan 2023 17:50:03 +0000 (19:50 +0200)] 
CMake/Windows: Add resource files to xz.exe and xzdec.exe.

The command line tools cannot be built with MSVC for now but
they can be built with MinGW-w64.

Thanks to Iouri Kharon for the bug report and the original patch.

2 years agoliblzma: CLMUL CRC64: Workaround a bug in MSVC (VS2015-2022).
Lasse Collin [Mon, 9 Jan 2023 10:22:05 +0000 (12:22 +0200)] 
liblzma: CLMUL CRC64: Workaround a bug in MSVC (VS2015-2022).

I haven't tested with MSVC myself and there doesn't seem to be
information about the problem online, so I'm relying on the bug report.

Thanks to Iouri Kharon for the bug report and the patch.

2 years agoBuild: Require that _mm_set_epi64x() is usable to enable CLMUL support.
Lasse Collin [Sat, 7 Jan 2023 17:31:15 +0000 (19:31 +0200)] 
Build: Require that _mm_set_epi64x() is usable to enable CLMUL support.

VS2013 doesn't have _mm_set_epi64x() so this way CLMUL gets
disabled with VS2013.

Thanks to Iouri Kharon for the bug report.

2 years agoTests: Creates test_index_hash.c
Jia Tan [Wed, 28 Dec 2022 16:25:18 +0000 (00:25 +0800)] 
Tests: Creates test_index_hash.c

Tests all API functions exported from index_hash.h. Does not have a
dedicated test for lzma_index_hash_end.

[Minor edits were made by Lasse Collin.]

2 years agoliblzma: Remove common.h include from common/index.h.
Jia Tan [Thu, 5 Jan 2023 12:57:25 +0000 (20:57 +0800)] 
liblzma: Remove common.h include from common/index.h.

common/index.h is needed by liblzma internally and tests. common.h will
include and define many things that are not needed by the tests.

Also, this prevents include order problems because both common.h and
lzma.h define LZMA_API. On most platforms it results only in a warning
but on Windows it would break the build as the definition in common.h
must be used only for building liblzma itself.

2 years agoliblzma: Add NULL check to lzma_index_hash_append.
Jia Tan [Wed, 17 Aug 2022 12:20:16 +0000 (20:20 +0800)] 
liblzma: Add NULL check to lzma_index_hash_append.

This is for consistency with lzma_index_append.

2 years agoliblzma: Replaced hardcoded 0x0 index indicator byte with macro
Jia Tan [Wed, 17 Aug 2022 09:59:51 +0000 (17:59 +0800)] 
liblzma: Replaced hardcoded 0x0 index indicator byte with macro

2 years agoStyle: Change #if !defined() to #ifndef in mythread.h.
Jia Tan [Fri, 6 Jan 2023 12:43:31 +0000 (20:43 +0800)] 
Style: Change #if !defined() to #ifndef in mythread.h.

2 years agoBuild: Add missing stream_decoder_mt.c to .vcxproj files.
Jia Tan [Fri, 6 Jan 2023 12:35:55 +0000 (20:35 +0800)] 
Build: Add missing stream_decoder_mt.c to .vcxproj files.

The line in the .vcxproj files for building with was missing in 5.4.0.
Thank to Hajin Jang for reporting the issue.

2 years agoUpdate THANKS.
Lasse Collin [Wed, 4 Jan 2023 20:40:54 +0000 (22:40 +0200)] 
Update THANKS.

2 years agoTests: Adjust style in test_compress.sh.
Lasse Collin [Wed, 4 Jan 2023 16:40:28 +0000 (18:40 +0200)] 
Tests: Adjust style in test_compress.sh.

2 years agoTests: Replace non portable shell parameter expansion
Jia Tan [Wed, 4 Jan 2023 15:58:58 +0000 (23:58 +0800)] 
Tests: Replace non portable shell parameter expansion

The shell parameter expansion using # and ## is not supported in
Solaris 10 Bourne shell (/bin/sh). Even though this is POSIX, it is not fully
portable, so we should avoid it.

2 years agoTranslations: Add Korean translation of man pages.
Jia Tan [Tue, 3 Jan 2023 13:02:38 +0000 (21:02 +0800)] 
Translations: Add Korean translation of man pages.

Thanks to Seong-ho Cho

2 years agoTranslations: Update the Esperanto translation.
Jia Tan [Tue, 3 Jan 2023 12:47:27 +0000 (20:47 +0800)] 
Translations: Update the Esperanto translation.

2 years agoBuild: Fix config.h comments.
Lasse Collin [Mon, 2 Jan 2023 15:05:07 +0000 (17:05 +0200)] 
Build: Fix config.h comments.