Commit Graph

1677 Commits

Author SHA1 Message Date
Jia Tan 880adb5aa2 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.
2023-02-03 21:42:14 +08:00
Jia Tan b5b1b1f061 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.
2023-02-03 21:42:07 +08:00
Jia Tan e904e778b8 Translations: Add Brazilian Portuguese translation of man pages.
Thanks to Rafael Fontenelle.
2023-02-03 21:39:59 +08:00
Jia Tan e9c47e79c9 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.
2023-02-03 21:38:26 +08:00
Jia Tan 99575947a5 xz: Refactor duplicated check for custom suffix when using --format=raw 2023-02-03 21:38:26 +08:00
Jia Tan 76dec92fcc liblzma: Set documentation on all reserved fields to private.
This prevents the reserved fields from being part of the generated
Doxygen documentation.
2023-02-03 21:38:26 +08:00
Jia Tan bd213d06eb 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.
2023-02-03 21:38:26 +08:00
Jia Tan 257dbff0ba 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.
2023-02-03 21:38:13 +08:00
Jia Tan 720ad4a442 xz: Add missing comment for coder_set_compression_settings() 2023-02-03 21:11:32 +08:00
Jia Tan 88dc191634 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.
2023-02-03 21:11:11 +08:00
Jia Tan 039e0ab13e Translations: Update the Brazilian Portuguese translation. 2023-02-03 21:10:57 +08:00
Lasse Collin 718f7a60e7 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.
2023-02-03 21:10:47 +08:00
Lasse Collin 3ccedb0972 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.
2023-02-03 21:10:42 +08:00
Lasse Collin 09fbd2f052 xz: Silence warnings from -Wsign-conversion in a 32-bit build. 2023-02-03 21:10:38 +08:00
Lasse Collin 683d3f178e 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.
2023-02-03 21:10:30 +08:00
Lasse Collin 2b8062ef94 liblzma: Silence a warning from -Wsign-conversion in a 32-bit build. 2023-02-03 21:10:25 +08:00
Lasse Collin b16b9c0d22 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.
2023-02-03 21:10:19 +08:00
Lasse Collin c47ecd6d39 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.
2023-02-03 21:10:06 +08:00
Lasse Collin 34e13ce015 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.
2023-02-03 21:10:01 +08:00
Lasse Collin 6671d0fe46 liblzma: Silence warnings from clang -Wconditional-uninitialized.
This is similar to 2ce4f36f17.
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.
2023-02-03 21:09:42 +08:00
Lasse Collin d3e833ca1d Fix warnings from clang -Wdocumentation. 2023-02-03 21:09:35 +08:00
Lasse Collin 977dd2e26b Tests: test_lzip_decoder: Remove trailing white-space. 2023-02-03 21:09:12 +08:00
Lasse Collin c55157ed74 Tests: test_lzip_decoder: Silence warnings from -Wsign-conversion. 2023-02-03 21:07:57 +08:00
Lasse Collin 18b845e697 Bump version and soname for 5.4.1. 2023-01-11 18:52:54 +02:00
Jia Tan 4080bbb844 Add NEWS for 5.4.1. 2023-01-11 18:52:23 +02:00
Lasse Collin 674c89fdb8 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.
2023-01-11 17:49:59 +02:00
Lasse Collin 2a6b938084 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.
2023-01-11 17:49:59 +02:00
Jia Tan aea639e81b 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.
2023-01-11 17:31:54 +02:00
Jia Tan e3b42bfcb0 Tests: Fix test_filter_flags copy/paste error. 2023-01-11 17:31:54 +02:00
Jia Tan 21625b7e11 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.
2023-01-11 17:31:54 +02:00
Lasse Collin c337983e92 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.
2023-01-11 17:31:54 +02:00
Jia Tan b7fb438ea0 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.
2023-01-11 17:31:54 +02:00
Jia Tan 68e9ef036d 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.
2023-01-11 17:31:54 +02:00
Lasse Collin a387707cd8 Windows: Update INSTALL-MSVC.txt to recommend CMake over project files. 2023-01-11 17:30:30 +02:00
Lasse Collin 52902ad695 Revert "liblzma: CLMUL CRC64: Workaround a bug in MSVC (VS2015-2022)."
This reverts commit 36edc65ab4.

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.
2023-01-10 12:51:19 +02:00
Lasse Collin e81b9fc48c sysdefs.h: Fix a comment. 2023-01-10 10:26:59 +02:00
Lasse Collin 6e89ab58b0 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.
2023-01-10 10:26:59 +02:00
Lasse Collin 65c59ad429 CMake/Windows: Add a workaround for windres from GNU binutils.
This is combined from the following commits in the master branch:
443dfebced
6b117d3b1f
5e34774c31

Thanks to Iouri Kharon for the bug report, the original patch,
and testing.
2023-01-10 08:50:26 +02:00
Lasse Collin 43521e77ac 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
2023-01-09 16:58:27 +02:00
Jia Tan 6b44cead95 Tests: Refactors existing filter flags tests.
Converts the existing filter flags tests into tuktests.
2023-01-09 16:58:27 +02:00
Lasse Collin 1bbefa9659 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.
2023-01-09 16:58:27 +02:00
Lasse Collin ce3a3fbc7c 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.
2023-01-09 16:58:27 +02:00
Lasse Collin 99fcd57f2e Update THANKS. 2023-01-09 16:58:27 +02:00
Lasse Collin c0c13d9d82 Update THANKS. 2023-01-09 16:58:27 +02:00
Lasse Collin 3d45987451 CMake: Fix a copypaste error in xzdec Windows resource file handling.
It was my mistake. Thanks to Iouri Kharon for the bug report.
2023-01-09 16:58:27 +02:00
Lasse Collin 706bce5018 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.
2023-01-09 16:58:27 +02:00
Lasse Collin e96dee55df 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.
2023-01-09 16:58:27 +02:00
Lasse Collin 52bc1ee34d 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.
2023-01-09 16:58:27 +02:00
Jia Tan bad44cfe19 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.]
2023-01-09 16:56:07 +02:00
Jia Tan 692ccdf551 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.
2023-01-09 16:37:19 +02:00