aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2023-12-22liblzma: Improve lzma encoder init function consistency.Jia Tan1-0/+3
lzma_encoder_init() did not check for NULL options, but lzma2_encoder_init() did. This is more of a code style improvement than anything else to help make lzma_encoder_init() and lzma2_encoder_init() more similar.
2023-12-22Docs: Update repository URL in Changelog.Jia Tan1-1/+1
2023-12-22Tests: Silence -Wsign-conversion warning on GCC version < 10.Jia Tan1-1/+1
Since GCC version 10, GCC no longer complains about simple implicit integer conversions with Arithmetic operators. For instance: uint8_t a = 5; uint32_t b = a + 5; Give a warning on GCC 9 and earlier but this: uint8_t a = 5; uint32_t b = (a + 5) * 2; Gives a warning with GCC 10+.
2023-12-22Update THANKS.Jia Tan1-0/+1
2023-12-22Tests: Fix typosKian-Meng Ang2-3/+3
2023-12-22xz: Use is_tty() in message.c.Jia Tan1-1/+1
2023-12-22xz: Create separate is_tty() function.Jia Tan2-2/+37
The new is_tty() will report if a file descriptor is a terminal or not. On POSIX systems, it is a wrapper around isatty(). However, the native Windows implementation of isatty() will return true for all character devices, not just terminals. So is_tty() has a special case for Windows so it can use alternative Windows API functions to determine if a file descriptor is a terminal. This fixes a bug with MSVC and MinGW-w64 builds that refused to read from or write to non-terminal character devices because xz thought it was a terminal. For instance: xz foo -c > /dev/null would fail because /dev/null was assumed to be a terminal.
2023-12-22tuklib_integer: Fix typo discovered by codespell.Jia Tan1-1/+1
Based on internet dictionary searches, 'choise' is an outdated spelling of 'choice'.
2023-12-22Tests: Fix typo in a comment.Jia Tan1-1/+1
2023-12-22Tests: Create test_suffix.sh.Jia Tan2-0/+191
This tests some complicated interactions with the --suffix= option. The suffix option must be used with --format=raw, but can optionally be used to override the default .xz suffix. This test also verifies some recent bugs have been correctly solved and to hopefully avoid further regressions in the future.
2023-12-22xz: Fix suffix check.Jia Tan1-8/+22
The suffix refactor done in 99575947a58a60416c570eb78038d18a1ea4cef4 had a small regression where raw format compression to standard out failed if a suffix was not set. In this case, setting the suffix did not make sense since a file is not created. Now, xz should only fail when a suffix is not provided when it is actually needed. For instance: echo "foo" | xz --format=raw --lzma2 | wc -c does not need a suffix check since it creates no files. But: xz --format=raw --lzma2 --suffix=.bar foo Needs the suffix to be set since it must create foo.bar.
2023-12-22liblzma: Add missing comments to lz_encoder.h.Jia Tan1-1/+5
2023-11-01Bump version and soname for 5.4.5.larhzu/v5.4.5Jia Tan2-2/+2
2023-11-01Add NEWS for 5.4.5.Jia Tan1-0/+74
2023-11-01liblzma: Fix compilation of fastpos_tablegen.c.Lasse Collin1-0/+2
The macro lzma_attr_visibility_hidden has to be defined to make fastpos.h usable. The visibility attribute is irrelevant to fastpos_tablegen.c so simply #define the macro to an empty value. fastpos_tablegen.c is never built by the included build systems and so the problem wasn't noticed earlier. It's just a standalone program for generating fastpos_table.c. Fixes: https://github.com/tukaani-project/xz/pull/69 Thanks to GitHub user Jamaika1.
2023-10-31Build: Fix text wrapping in an output message.Jia Tan1-4/+5
2023-10-31liblzma: Use lzma_always_inline in memcmplen.h.Lasse Collin1-2/+1
2023-10-31liblzma: #define lzma_always_inline in common.h.Lasse Collin1-0/+17
2023-10-31liblzma: Use lzma_attr_visibility_hidden on private extern declarations.Lasse Collin5-0/+13
These variables are internal to liblzma and not exposed in the API.
2023-10-31liblzma: #define lzma_attr_visibility_hidden in common.h.Lasse Collin1-0/+11
In ELF shared libs: -fvisibility=hidden affects definitions of symbols but not declarations.[*] This doesn't affect direct calls to functions inside liblzma as a linker can replace a call to lzma_foo@plt with a call directly to lzma_foo when -fvisibility=hidden is used. [*] It has to be like this because otherwise every installed header file would need to explictly set the symbol visibility to default. When accessing extern variables that aren't defined in the same translation unit, compiler assumes that the variable has the default visibility and thus indirection is needed. Unlike function calls, linker cannot optimize this. Using __attribute__((__visibility__("hidden"))) with the extern variable declarations tells the compiler that indirection isn't needed because the definition is in the same shared library. About 15+ years ago, someone told me that it would be good if the CRC tables would be defined in the same translation unit as the C code of the CRC functions. While I understood that it could help a tiny amount, I didn't want to change the code because a separate translation unit for the CRC tables was needed for the x86 assembly code anyway. But when visibility attributes are supported, simply marking the extern declaration with the hidden attribute will get identical result. When there are only a few affected variables, this is trivial to do. I wish I had understood this back then already.
2023-10-31liblzma: Refer to MinGW-w64 instead of MinGW in the API headers.Lasse Collin2-3/+3
MinGW (formely a MinGW.org Project, later the MinGW.OSDN Project at <https://osdn.net/projects/mingw/>) has GCC 9.2.0 as the most recent GCC package (released 2021-02-02). The project might still be alive but majority of people have switched to MinGW-w64. Thus it seems clearer to refer to MinGW-w64 in our API headers too. Building with MinGW is likely to still work but I haven't tested it in the recent years.
2023-10-31CMake: Use -D_FILE_OFFSET_BITS=64 if (and only if) needed.Lasse Collin2-1/+58
A CMake option LARGE_FILE_SUPPORT is created if and only if -D_FILE_OFFSET_BITS=64 affects sizeof(off_t). This is needed on many 32-bit platforms and even with 64-bit builds with MinGW-w64 to get support for files larger than 2 GiB.
2023-10-31CMake: Generate and install liblzma.pc if not using MSVC.Lasse Collin1-0/+21
Autotools based build uses -pthread and thus adds it to Libs.private in liblzma.pc. CMake doesn't use -pthread at all if pthread functions are available in libc so Libs.private doesn't get -pthread either.
2023-10-31CMake: Rearrange the PACKAGE_ variables.Lasse Collin1-11/+15
The windres workaround now replaces spaces with \x20 so the package name isn't repeated. These changes will help with creation of liblzma.pc.
2023-10-31liblzma: Add Cflags.private to liblzma.pc.in for MSYS2.Lasse Collin1-0/+1
It properly adds -DLZMA_API_STATIC when compiling code that will be linked against static liblzma. Having it there on systems other than Windows does no harm. See: https://www.msys2.org/docs/pkgconfig/
2023-10-31CMake: Create liblzma.def when building liblzma.dll with MinGW-w64.Lasse Collin2-0/+46
2023-10-31CMake: Change one CMAKE_CURRENT_SOURCE_DIR to CMAKE_CURRENT_LIST_DIR.Lasse Collin1-1/+1
In this case they have identical values.
2023-10-31CMake/Windows: Fix the import library filename.Lasse Collin1-0/+1
Both PREFIX and IMPORT_PERFIX have to be set to "" to get liblzma.dll and liblzma.dll.a.
2023-10-31CMake: Don't shadow the cache entry ENABLE_THREADS with a normal variable.Lasse Collin1-3/+7
Using set(ENABLE_THREADS "posix") is confusing because it sets a new normal variable and leaves the cache entry with the same name unchanged. The intent wasn't to change the cache entry so this switches to a different variable name.
2023-10-31CMake: Edit threading related messages.Lasse Collin1-9/+10
It's mostly to change from "thread method" to "threading method".
2023-10-31CMake: Use FATAL_ERROR if user-supplied options aren't understood.Lasse Collin1-14/+14
This way typos are caught quickly and compounding error messages are avoided (a single typo could cause more than one error). This keeps using SEND_ERROR when the system is lacking a feature (like threading library or sandboxing method). This way the whole configuration log will be generated in case someone wishes to report a problem upstream.
2023-10-31CMake: Add ALLOW_CLMUL_CRC option to enable/disable CLMUL.Jia Tan1-17/+23
The option is enabled by default, but will only be visible to a user listing cache variables or using a CMake GUI application if the immintrin.h header file is found. This mirrors our Autotools build --disable-clmul-crc functionality.
2023-10-31tuklib_integer: Revise unaligned reads and writes on strict-align archs.Lasse Collin1-67/+189
In XZ Utils context this doesn't matter much because unaligned reads and writes aren't used in hot code when TUKLIB_FAST_UNALIGNED_ACCESS isn't #defined.
2023-10-31tuklib_integer: Add missing write64be and write64le fallback functions.Lasse Collin1-0/+34
2023-10-31Build: Update visibility.m4 from Gnulib.Jia Tan1-2/+7
Updating from version 6 -> 8 from upstream. Declarations for variables and function bodies were added to avoid unnecessary failures with -Werror.
2023-10-31Update THANKS.Lasse Collin1-0/+1
2023-10-31CMake: Rename xz and man page symlink custom targets.Jia Tan1-3/+3
The Ninja Generator for CMake cannot have a custom target and its BYPRODUCTS have the same name. This has prevented Ninja builds on Unix-like systems since the xz symlinks were introduced in 80a1a8bb838842a2be343bd88ad1462c21c5e2c9.
2023-10-31CMake: Fix Windows build with Clang/LLVM 17.Lasse Collin1-12/+14
llvm-windres 17.0.0 has more accurate emulation of GNU windres, so the hack for GNU windres must now be used with llvm-windres too. LLVM 16.0.6 has the old behavior and there likely won't be more 16.x releases. So we can simply check for >= 17.0.0. The workaround must not be used with Clang that is acting in MSVC mode. This checks for the known environments that need the workaround instead of using "NOT MSVC". See also: https://github.com/llvm/llvm-project/commit/2bcc0fdc58a220cb9921b47ec8a32c85f2511a47
2023-10-31liblzma: Avoid compiler warning without creating extra symbol.Jia Tan1-4/+2
When the generic fast crc64 method is used, then we omit lzma_crc64_table[][]. The C standards don't allow an empty translation unit which can be avoided by declaring something, without exporting any symbols.
2023-10-31Build: Update the comment about -Werror usage in checks.Lasse Collin1-2/+8
2023-10-31Build: Fix underquoted AC_LANG_SOURCE.Lasse Collin1-1/+1
It made no practical difference in this case.
2023-10-31Build: Silence Autoconf warning.Lasse Collin1-3/+2
There was a use of AC_COMPILE_IFELSE that didn't use AC_LANG_SOURCE and Autoconf warned about this. The omission had been intentional but it turned out that this didn't do what I thought it would. Autoconf 2.71 manual gives an impression that AC_LANG_SOURCE inserts all #defines that have been made with AC_DEFINE so far (confdefs.h). The idea was that omitting AC_LANG_SOURCE would mean that only the exact code included in the AC_COMPILE_IFELSE call would be compiled. With C programs this is not true: the #defines get added without AC_LANG_SOURCE too. There seems to be no neat way to avoid this. Thus, with the C language at least, adding AC_LANG_SOURCE makes no other difference than silencing a warning from Autoconf. The generated "configure" remains identical. (Docs of AC_LANG_CONFTEST say that the #defines have been inserted since Autoconf 2.63b and that AC_COMPILE_IFELSE uses AC_LANG_CONFTEST. So the behavior is documented if one also reads the docs of macros that one isn't calling directly.) Any extra code, including #defines, can cause problems for these two tests because these tests must use -Werror. CC=clang CFLAGS=-Weverything is the most extreme example. It enables -Wreserved-macro-identifier which warns about It's possible to write a test file that passes -Weverything but it becomes impossible when Autoconf inserts confdefs.h. So this commit adds AC_LANG_SOURCE to silence Autoconf warnings. A different solution is needed for -Werror tests.
2023-10-31Build: Remove Gnulib dependency from tests.Jia Tan1-6/+1
The tests do not use any Gnulib replacements so they do not need to link libgnu.a or have /lib in the include path.
2023-10-31CMake: Remove /lib from tests include path.Jia Tan1-1/+0
The tests never included anything from /lib, so this was not needed.
2023-10-31sysdefs.h: Update the comment about __USE_MINGW_ANSI_STDIO.Lasse Collin1-1/+9
2023-10-31xz: Windows: Don't (de)compress to special files like "con" or "nul".Lasse Collin1-7/+28
Before this commit, the following writes "foo" to the console and deletes the input file: echo foo | xz > con_xz xz --suffix=_xz --decompress con_xz It cannot happen without --suffix because names like con.xz are also special and so attempting to decompress con.xz (or compress con to con.xz) will already fail when opening the input file. Similar thing is possible when compressing. The following writes to "nul" and the input file "n" is deleted. echo foo | xz > n xz --suffix=ul n Now xz checks if the destination is a special file before continuing. DOS/DJGPP version had a check for this but Windows (and OS/2) didn't.
2023-10-31CMake: Wrap two overlong lines that are possible to wrap.Lasse Collin1-2/+4
2023-10-31CMake: Add a comment about threads on Cygwin.Lasse Collin1-0/+1
2023-10-31CMake: Bump maximum policy version to 3.27.Lasse Collin1-1/+1
There are several new policies. CMP0149 may affect the Windows SDK version that CMake will choose by default. The new behavior is more predictable, always choosing the latest SDK version by default. The other new policies shouldn't affect this package.
2023-10-31Doxygen: Add more C macro names to PREDEFINED.Lasse Collin1-2/+5
2023-10-31liblzma: Move a few __attribute__ uses in function declarations.Lasse Collin3-7/+10
The API headers have many attributes but these were left as is for now.
2023-10-31xz, xzdec, lzmainfo: Use tuklib_attr_noreturn.Lasse Collin7-25/+37
For compatibility with C23's [[noreturn]], tuklib_attr_noreturn must be at the beginning of declaration (before "extern" or "static", and even before any GNU C's __attribute__). This commit also moves all other function attributes to the beginning of function declarations. "extern" is kept at the beginning of a line so the attributes are listed on separate lines before "extern" or "static".
2023-10-31Remove incorrect uses of __attribute__((__malloc__)).Lasse Collin3-6/+6
xrealloc() is obviously incorrect, modern GCC docs even mention realloc() as an example where this attribute cannot be used. liblzma's lzma_alloc() and lzma_alloc_zero() would be correct uses most of the time but custom allocators may use a memory pool or otherwise hold the pointer so aliasing issues could happen in theory. The xstrdup() case likely was correct but I removed it anyway. Now there are no __malloc__ attributes left in the code. The allocations aren't in hot paths so this should make no practical difference.
2023-10-31Update THANKS.Lasse Collin1-0/+1
2023-10-31Update THANKS.Lasse Collin1-0/+1
2023-10-31liblzma: Mark crc64_clmul() with __attribute__((__no_sanitize_address__)).Lasse Collin1-0/+8
Thanks to Agostino Sarubbo. Fixes: https://github.com/tukaani-project/xz/issues/62
2023-10-31CMake: Fix time.h checks not running on second CMake run.Jia Tan1-8/+10
If CMake was configured more than once, HAVE_CLOCK_GETTIME and HAVE_CLOCK_MONOTONIC would not be set as compile definitions. The check for librt being needed to provide HAVE_CLOCK_GETTIME was also simplified.
2023-10-31CMake: Fix unconditionally defining HAVE_CLOCK_MONOTONIC.Jia Tan1-5/+3
If HAVE_CLOCK_GETTIME was defined, then HAVE_CLOCK_MONOTONIC was always added as a compile definition even if the check for it failed.
2023-10-31xz: Refactor thousand separator detection and disable it on MSVC.Lasse Collin1-44/+45
Now the two variations of the format strings are created with a macro, and the whole detection code can be easily disabled on platforms where thousand separator formatting is known to not work (MSVC has no support, and on DJGPP 2.05 it can have problems in some cases).
2023-10-31xz: Fix a too relaxed assertion and remove uses of SSIZE_MAX.Lasse Collin2-5/+4
SSIZE_MAX isn't readily available on MSVC. Removing it means that there is one thing less to worry when porting to MSVC.
2023-10-31Tests: Improve invalid unpadded size check in test_lzma_index_append().Jia Tan1-3/+23
This check was extended to test the code added to fix a failing assert in 68bda971bb8b666a009331455fcedb4e18d837a4.
2023-10-26Tests: Improve comments in test_index.c.Jia Tan1-3/+3
2023-10-26Update THANKS.Jia Tan1-0/+1
2023-10-26liblzma: Update assert in vli_ceil4().Jia Tan1-1/+1
The argument to vli_ceil4() should always guarantee the return value is also a valid lzma_vli. Thus the highest three valid lzma_vli values are invalid arguments. All uses of the function ensure this so the assert is updated to match this.
2023-10-26liblzma: Add overflow check for Unpadded size in lzma_index_append().Jia Tan1-0/+6
This was not a security bug since there was no path to overflow UINT64_MAX in lzma_index_append() or when it calls index_file_size(). The bug was discovered by a failing assert() in vli_ceil4() when called from index_file_size() when unpadded_sum (the sum of the compressed size of current Stream and the unpadded_size parameter) exceeds LZMA_VLI_MAX. Previously, the unpadded_size parameter was checked to be not greater than UNPADDED_SIZE_MAX, but no check was done once compressed_base was added. This could not have caused an integer overflow in index_file_size() when called by lzma_index_append(). The calculation for file_size breaks down into the sum of: - Compressed base from all previous Streams - 2 * LZMA_STREAM_HEADER_SIZE (size of the current Streams header and footer) - stream_padding (can be set by lzma_index_stream_padding()) - Compressed base from the current Stream - Unpadded size (parameter to lzma_index_append()) The sum of everything except for Unpadded size must be less than LZMA_VLI_MAX. This is guarenteed by overflow checks in the functions that can set these values including lzma_index_stream_padding(), lzma_index_append(), and lzma_index_cat(). The maximum value for Unpadded size is enforced by lzma_index_append() to be less than or equal UNPADDED_SIZE_MAX. Thus, the sum cannot exceed UINT64_MAX since LZMA_VLI_MAX is half of UINT64_MAX. Thanks to Joona Kannisto for reporting this.
2023-10-26Translations: Update the Esperanto translation.Jia Tan1-18/+29
2023-10-26Docs: Update INSTALL for --enable-threads method win95.Jia Tan1-2/+4
The Autotools build allows win95 threads and --enable-small together now if the compiler supports __attribute__((__constructor__)).
2023-10-26CMake: Conditionally allow win95 threads and --enable-small.Jia Tan1-8/+19
2023-10-26Build: Conditionally allow win95 threads and --enable-small.Jia Tan1-8/+13
When the compiler supports __attribute__((__constructor__)) mythread_once() is never used, even with --enable-small. A configuration with win95 threads and --enable-small will compile and be thread safe so it can be allowed. This isn't a very common configuration since MSVC does not support __attribute__((__constructor__)), but MINGW32 and CLANG32 environments for MSYS2 can use win95 threads and have __attribute__((__constructor__)) support.
2023-10-26mythread.h: Fix typo error in Vista threads mythread_once().Jamaika11-1/+1
The "once_" variable was accidentally referred to as just "once". This prevented building with Vista threads when HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR was not defined.
2023-10-26Tests: Style fixes to test_lzip_decoder.c.Jia Tan1-12/+24
2023-10-26Translations: Update the Chinese (simplified) translation.Jia Tan1-1/+1
2023-08-02xz: Omit an empty paragraph on the man page.Lasse Collin1-1/+0
2023-08-02Bump version and soname for 5.4.4.larhzu/v5.4.4Jia Tan2-2/+2
2023-08-02Add NEWS for 5.4.4.Jia Tan1-0/+43
2023-08-02build-aux/manconv.sh: Fix US-ASCII and UTF-8 output.Lasse Collin1-2/+2
groff defaults to SGR escapes. Using -P-c passes -c to grotty which restores the old behavior. Perhaps there is a better way to get pure plain text output but this works for now.
2023-08-01Update THANKS.Lasse Collin1-0/+1
2023-08-01Update THANKS.Lasse Collin1-0/+1
2023-08-01mythread.h: Disable signal functions in builds targeting Wasm + WASI.ChanTsune1-1/+1
signal.h in WASI SDK doesn't currently provide sigprocmask() or sigset_t. liblzma doesn't need them so this change makes liblzma and xzdec build against WASI SDK. xz doesn't build yet and the tests don't either as tuktest needs setjmp() which isn't (yet?) implemented in WASI SDK. Closes: https://github.com/tukaani-project/xz/pull/57 See also: https://github.com/tukaani-project/xz/pull/56 (The original commit was edited a little by Lasse Collin.)
2023-08-01Docs: Fix typos found by codespellDimitri Papadopoulos Orfanos18-29/+29
2023-08-01Update .gitignore.Jia Tan1-0/+4
2023-08-01CMake: Conditionally allow the creation of broken symlinks.Jia Tan1-7/+75
The CMake build will try to create broken symlinks on Unix and Unix-like platforms. Cygwin and MSYS2 are Unix-like, but may not be able to create broken symlinks. The value of the CYGWIN or MSYS environment variables determine if broken symlinks are valid. The default for MSYS2 does not allow for broken symlinks, so the CMake build has been broken for MSYS2 since commit 80a1a8bb838842a2be343bd88ad1462c21c5e2c9.
2023-08-01liblzma: Prevent an empty translation unit in Windows builds.Jia Tan1-1/+5
To workaround Automake lacking Windows resource compiler support, an empty source file is compiled to overwrite the resource files for static library builds. Translation units without an external declaration are not allowed by the C standard and result in a warning when used with -Wempty-translation-unit (Clang) or -pedantic (GCC).
2023-08-01Tests: Skip .lz files in test_files.sh if not configured.Jia Tan1-1/+1
Previously if the lzip decoder was not configured then test_files.sh would pass the lzip tests instead of skipping them.
2023-08-01Tests: Add ARM64 filter test to test_compress.sh.Jia Tan1-0/+1
2023-07-31Translations: Update the Vietnamese translation.Jia Tan1-17/+28
2023-07-31Translations: Update the Croatian translation.Jia Tan1-19/+30
2023-07-31Translations: Update the Korean man page translations.Jia Tan1-626/+629
2023-07-31Translations: Update the Korean translation.Jia Tan1-17/+28
2023-07-31Translations: Update the Polish translation.Jia Tan1-18/+29
2023-07-31Translations: Update the German man page translations.Jia Tan1-626/+629
2023-07-31Translations: Update the German translation.Jia Tan1-18/+29
2023-07-31Translations: Update the Chinese (simplified) translation.Jia Tan1-18/+29
2023-07-31Translations: Update the Swedish translation.Jia Tan1-18/+29
2023-07-31Translations: Update the Ukrainian man page translations.Jia Tan1-625/+628
2023-07-31Translations: Update the Ukrainian translation.Jia Tan1-17/+28
2023-07-31Translations: Update the Spanish translation.Jia Tan1-18/+29
2023-07-31Translations: Update the Romanian translation.Jia Tan1-18/+30
2023-07-31Translations: Update the Romanian man page translations.Jia Tan1-625/+629
2023-07-18xz: Update man page Authors and date.Jia Tan1-2/+3
2023-07-18xz: Slight reword in xz man page for consistency.Jia Tan1-1/+1
Changed will print => prints in xz --robot --version description to match --robot --info-memory description.
2023-07-18liblzma: Improve comment in string_conversion.c.Jia Tan1-2/+2
The comment used "flag" when referring to decoder options. Just referring to them as options is more clear and consistent.
2023-07-18liblzma: Reword lzma_str_list_filters() documentation.Jia Tan1-1/+1
Reword "options required" to "options read". The previous wording may have suggested that the options listed were all required when the filters are used for encoding or decoding. Now it should be more clear that the options listed are the ones relevant for encoding or decoding.
2023-07-18xz: Translate the second "%s: " in message.c since French needs "%s : ".Lasse Collin1-1/+1
This string is used to print a filename when using "xz -v" and stderr isn't a terminal.
2023-07-18xz: Make "%s: %s" translatable because French needs "%s : %s".Lasse Collin4-14/+18
2023-07-18liblzma: Tweak #if condition in memcmplen.h.Lasse Collin1-2/+2
Maybe ICC always #defines _MSC_VER on Windows but now it's very clear which code will get used.
2023-07-18liblzma: Omit unnecessary parenthesis in a preprocessor directive.Lasse Collin1-2/+2
2023-07-18liblzma: Prevent warning for MSYS2 Windows build.Jia Tan1-2/+4
In lzma_memcmplen(), the <intrin.h> header file is only included if _MSC_VER and _M_X64 are both defined but _BitScanForward64() was previously used if _M_X64 was defined. GCC for MSYS2 defines _M_X64 but not _MSC_VER so _BitScanForward64() was used without including <intrin.h>. Now, lzma_memcmplen() will use __builtin_ctzll() for MSYS2 GCC builds as expected.
2023-07-18Docs: Add a new section to INSTALL for Tests.Jia Tan1-17/+64
The new Tests section describes basic information about the tests, how to run them, and important details when cross compiling. We have had a few questions about how to compile the tests without running them, so hopefully this information will help others with the same question in the future. Fixes: https://github.com/tukaani-project/xz/issues/54
2023-07-18Docs: Update README.Jia Tan1-0/+4
This adds an entry to "Other implementations of the .xz format" for XZ for Java.
2023-07-18xz: Fix typo in man page.Jia Tan1-1/+1
The Memory limit information section described three output columns when it actually has six. This was reworded to "multiple" to make it more future proof.
2023-07-18Tests: Improve feature testing for skipping.Jia Tan2-3/+3
Fixed a bug where test_compress_* would all fail if arm64 or armthumb filters were enabled for compression but arm was disabled. Since the grep tests only checked for "define HAVE_ENCODER_ARM", this would match on HAVE_ENCODER_ARM64 or HAVE_ENCODER_ARMTHUMB. Now the config.h feature test requires " 1" at the end to prevent the prefix problem. have_feature() was also updated for this even though there were known current bugs affecting it. This is just in case future features have a similar prefix problem.
2023-07-18Translations: Update the Chinese (traditional) translation.Jia Tan1-282/+377
2023-07-18Translations: Update the Vietnamese translation.Jia Tan1-271/+349
2023-07-18Tests: Fix memory leaks in test_index.Jia Tan1-0/+11
Several tests were missing calls to lzma_index_end() to clean up the lzma_index structs. The memory leaks were discovered by using -fsanitize=address with GCC.
2023-07-18Tests: Fix memory leaks in test_block_header.Jia Tan1-16/+22
test_block_header was not properly freeing the filter options between calls to lzma_block_header_decode(). The memory leaks were discovered by using -fsanitize=address with GCC.
2023-07-18liblzma: Prevent uninitialzed warning in mt stream encoder.Jia Tan1-1/+1
This change only impacts the compiler warning since it was impossible for the wait_abs struct in stream_encode_mt() to be used before it was initialized since mythread_condtime_set() will always be called before mythread_cond_timedwait(). Since the mythread.h code is different between the POSIX and Windows versions, this warning was only present on Windows builds. Thanks to Arthur S for reporting the warning and providing an initial patch.
2023-07-18Update THANKS.Jia Tan1-0/+1
2023-07-18CMake: Protects against double find_packageBenjamin Buch1-7/+9
Boost iostream uses `find_package` in quiet mode and then again uses `find_package` with required. This second call triggers a `add_library cannot create imported target "LibLZMA::LibLZMA" because another target with the same name already exists.` This can simply be fixed by skipping the alias part on secondary `find_package` runs.
2023-07-18Translations: Update the Esperanto translation.Jia Tan1-93/+92
2023-07-18Translations: Update the Croatian translation.Jia Tan1-1/+1
2023-07-18Translations: Update the Chinese (simplified) translation.Jia Tan1-160/+157
2023-07-18Translations: Update German translation of man pages.Jia Tan1-40/+12
2023-07-18Translations: Update the German translation.Jia Tan1-95/+94
2023-07-18Translations: Update the Croatian translation.Jia Tan1-94/+93
2023-07-18Translations: Update Korean translation of man pages.Jia Tan1-2446/+567
2023-07-18Translations: Update the Korean translation.Jia Tan1-161/+158
2023-07-18Translations: Update the Spanish translation.Jia Tan1-161/+158
2023-07-18Translations: Update the Romanian translation.Jia Tan1-97/+98
2023-07-18Translations: Update Romanian translation of man pages.Jia Tan1-9/+10
2023-07-18Translations: Update Ukrainian translation of man pages.Jia Tan1-6/+6
2023-07-18Translations: Update the Ukrainian translation.Jia Tan1-162/+159
2023-07-18Translations: Update the Polish translation.Jia Tan1-161/+155
2023-07-18Translations: Update the Swedish translation.Jia Tan1-161/+158
2023-07-18Translations: Update the Esperanto translation.Jia Tan1-17/+17
2023-07-18liblzma: Adds lzma_nothrow to MicroLZMA API functions.Jia Tan1-2/+3
None of the liblzma functions may throw an exception, so this attribute should be applied to all liblzma API functions.
2023-05-04Translations: Update the Croatian translation.larhzu/v5.4.3Jia Tan1-3/+3
2023-05-04Bump version and soname for 5.4.3.Jia Tan2-2/+2
2023-05-04Add NEWS for 5.4.3.Jia Tan1-0/+10
2023-05-03tuklib_integer.h: Fix a recent copypaste error in Clang detection.Lasse Collin1-2/+2
Wrong line was changed in 7062348bf35c1e4cbfee00ad9fffb4a21aa6eff7. Also, this has >= instead of == since ints larger than 32 bits would work too even if not relevant in practice.
2023-04-25Update THANKS.Jia Tan1-0/+1
2023-04-25Windows: Include <intrin.h> when needed.Jia Tan2-0/+16
Legacy Windows did not need to #include <intrin.h> to use the MSVC intrinsics. Newer versions likely just issue a warning, but the MSVC documentation says to include the header file for the intrinsics we use. GCC and Clang can "pretend" to be MSVC on Windows, so extra checks are needed in tuklib_integer.h to only include <intrin.h> when it will is actually needed.
2023-04-25tuklib_integer: Use __builtin_clz() with Clang.Jia Tan1-3/+3
Clang has support for __builtin_clz(), but previously Clang would fallback to either the MSVC intrinsic or the regular C code. This was discovered due to a bug where a new version of Clang required the <intrin.h> header file in order to use the MSVC intrinsics. Thanks to Anton Kochkov for notifying us about the bug.
2023-04-25liblzma: Update project maintainers in lzma.h.Lasse Collin1-1/+1
AUTHORS was updated earlier, lzma.h was simply forgotten.
2023-04-25liblzma: Cleans up old commented out code.Jia Tan1-11/+0
2023-04-25CMake: Update liblzma-config.cmake generation.Jia Tan1-11/+22
Now that the threading is configurable, the liblzma CMake package only needs the threading library when using POSIX threads.
2023-04-25CMake: Allows setting thread method.Jia Tan1-40/+104
The thread method is now configurable for the CMake build. It matches the Autotools build by allowing ON (pick the best threading method), OFF (no threading), posix, win95, and vista. If both Windows and posix threading are both available, then ON will choose Windows threading. Windows threading will also not use: target_link_libraries(liblzma Threads::Threads) since on systems like MinGW-w64 it would link the posix threads without purpose.
2023-04-25CMake: Only build xzdec if decoders are enabled.Jia Tan1-1/+1
2023-04-25Build: Removes redundant check for LZMA1 filter support.Jia Tan1-4/+1
2023-04-25CMake: Bump maximum policy version to 3.26.Lasse Collin1-1/+1
It adds only one new policy related to FOLDERS which we don't use. This makes it clear that the code is compatible with the policies up to 3.26.
2023-04-25CMake: Conditionally build xz list.* files if decoders are enabled.Jia Tan1-2/+7
2023-04-25CMake: Allow configuring features as cache variables.Jia Tan1-137/+391
This allows users to change the features they build either in CMakeCache.txt or by using a CMake GUI. The sources built for liblzma are affected by this too, so only the necessary files will be compiled.
2023-03-21Build: Add a comment that AC_PROG_CC_C99 is needed for Autoconf 2.69.Lasse Collin1-0/+3
It's obsolete in Autoconf >= 2.70 and just an alias for AC_PROG_CC but Autoconf 2.69 requires AC_PROG_CC_C99 to get a C99 compiler.
2023-03-21Build: configure.ac: Use AS_IF and AS_CASE where required.Lasse Collin1-15/+15
This makes no functional difference in the generated configure (at least with the Autotools versions I have installed) but this change might prevent future bugs like the one that was just fixed in the commit 5a5bd7f871818029d5ccbe189f087f591258c294.
2023-03-21Update THANKS.Lasse Collin1-0/+1
2023-03-21Build: Fix --disable-threads breaking the building of shared libs.Lasse Collin1-8/+8
This is broken in the releases 5.2.6 to 5.4.2. A workaround for these releases is to pass EGREP='grep -E' as an argument to configure in addition to --disable-threads. The problem appeared when m4/ax_pthread.m4 was updated in the commit 6629ed929cc7d45a11e385f357ab58ec15e7e4ad which introduced the use of AC_EGREP_CPP. AC_EGREP_CPP calls AC_REQUIRE([AC_PROG_EGREP]) to set the shell variable EGREP but this was only executed if POSIX threads were enabled. Libtool code also has AC_REQUIRE([AC_PROG_EGREP]) but Autoconf omits it as AC_PROG_EGREP has already been required earlier. Thus, if not using POSIX threads, the shell variable EGREP would be undefined in the Libtool code in configure. ax_pthread.m4 is fine. The bug was in configure.ac which called AX_PTHREAD conditionally in an incorrect way. Using AS_CASE ensures that all AC_REQUIREs get always run. Thanks to Frank Busse for reporting the bug. Fixes: https://github.com/tukaani-project/xz/issues/45
2023-03-19liblzma: Silence -Wsign-conversion in SSE2 code in memcmplen.h.Lasse Collin1-1/+2
Thanks to Christian Hesse for reporting the issue. Fixes: https://github.com/tukaani-project/xz/issues/44
2023-03-18Bump version and soname for 5.4.2.larhzu/v5.4.2Jia Tan2-2/+2
2023-03-18Add NEWS for 5.4.2.Jia Tan1-0/+48
2023-03-18Update the copy of GNU GPLv3 from gnu.org to COPYING.GPLv3.Lasse Collin1-4/+4
2023-03-18Change a few HTTP URLs to HTTPS.Lasse Collin8-19/+19
The xz man page timestamp was intentionally left unchanged.
2023-03-18CMake: Fix typo in a comment.Jia Tan1-1/+1
2023-03-18Windows: build.bash: Copy liblzma API docs to the output package.Lasse Collin1-1/+2
2023-03-17Windows: Add microlzma_*.c to the VS project files.Lasse Collin6-0/+12
These should have been included in 5.3.2alpha already.
2023-03-17CMake: Add microlzma_*.c to the build.Lasse Collin1-0/+2
These should have been included in 5.3.2alpha already.
2023-03-17Build: Update comments about unaligned access to mention 64-bit.Lasse Collin2-6/+5
2023-03-17Tests: Update .gitignore.Lasse Collin1-1/+2
2023-03-17po4a/update-po: Display the script name consistently in error messages.Lasse Collin1-1/+1
2023-03-17Doc: Rename Doxygen HTML doc directory name liblzma => api.Jia Tan5-22/+22
When the docs are installed, calling the directory "liblzma" is confusing since multiple other files in the doc directory are for liblzma. This should also make it more natural for distros when they package the documentation.
2023-03-17liblzma: Remove note from lzma_options_bcj about the ARM64 exception.Jia Tan1-1/+1
This was left in by mistake since an early version of the ARM64 filter used a different struct for its options.
2023-03-17COPYING: Add a note about the included Doxygen-generated HTML.Lasse Collin1-0/+11
2023-03-17Doc: Update PACKAGERS with details about liblzma API docs install.Jia Tan1-6/+16
2023-03-17liblzma: Add set lzma.h as the main page for Doxygen documentation.Jia Tan15-29/+2
The \mainpage command is used in the first block of comments in lzma.h. This changes the previously nearly empty index.html to use the first comment block in lzma.h for its contents. lzma.h is no longer documented separately, but this is for the better since lzma.h only defined a few macros that users do not need to use. The individual API header files all have a disclaimer that they should not be #included directly, so there should be no confusion on the fact that lzma.h should be the only header used by applications. Additionally, the note "See ../lzma.h for information about liblzma as a whole." was removed since lzma.h is now the main page of the generated HTML and does not have its own page anymore. So it would be confusing in the HTML version and was only a "nice to have" when browsing the source files.
2023-03-17Build: Generate doxygen documentation in autogen.sh.Jia Tan1-6/+29
Another command line option (--no-doxygen) was added to disable creating the doxygen documenation in cases where it not wanted or if the doxygen tool is not installed.
2023-03-17Build: Create doxygen/update-doxygen script.Jia Tan2-0/+112
This is a helper script to generate the Doxygen documentation. It can be run in 'liblzma' or 'internal' mode by setting the first argument. It will default to 'liblzma' mode and only generate documentation for the liblzma API header files. The helper script will be run during the custom mydist hook when we create releases. This hook already alters the source directory, so its fine to do it here too. This way, we can include the Doxygen generated files in the distrubtion and when installing. In 'liblzma' mode, the JavaScript is stripped from the .html files and the .js files are removed. This avoids license hassle from jQuery and other libraries that Doxygen 1.9.6 puts into jquery.js in minified form.
2023-03-17Build: Install Doxygen docs and include in distribution if generated.Jia Tan1-0/+18
Added a install-data-local target to install the Doxygen documentation only when it has been generated. In order to correctly remove the docs, a corresponding uninstall-local target was added. If the doxygen docs exist in the source tree, they will also be included in the distribution now too.
2023-03-17Doxygen: Refactor Doxyfile.in to doxygen/Doxyfile.Jia Tan5-1237/+2686
Instead of having Doxyfile.in configured by Autoconf, the Doxyfile can have the tags that need to be configured piped into the doxygen command through stdin with the overrides after Doxyfile's contents. Going forward, the documentation should be generated in two different modes: liblzma or internal. liblzma is useful for most users. It is the documentation for just the liblzma API header files. This is the default. internal is for people who want to understand how xz and liblzma work. It might be useful for people who want to contribute to the project.
2023-03-13Tests: Remove unused macros and functions.Jia Tan1-75/+0
2023-03-13Tests: Refactors existing lzma_index tests.Jia Tan1-544/+1492
Converts the existing lzma_index tests into tuktests and covers every API function from index.h except for lzma_file_info_decoder, which can be tested in the future.
2023-03-11xz: Make Capsicum sandbox more strict with stdin and stdout.Lasse Collin1-0/+8
2023-03-11xz: Don't fail if Capsicum is enabled but kernel doesn't support it.Lasse Collin1-3/+12
(This commit combines related commits from the master branch.) If Capsicum support is missing from the kernel or xz is being run in an emulator that lacks Capsicum suport, the syscalls will fail and set errno to ENOSYS. Previously xz would display and error and exit, making xz unusable. Now it will check for ENOSYS and run without sandbox support. Other tools like ssh behave similarly. Displaying a warning for missing Capsicum support was considered but such extra output would quickly become annoying. It would also break test_scripts.sh in "make check". Also move cap_enter() to be the first step instead of the last one. This matches the example in the cap_rights_limit(2) man page. With the current code it shouldn't make any practical difference though. Thanks to Xin Li for the bug report, suggesting a fix, and testing: https://github.com/tukaani-project/xz/pull/43 Thanks to Jia Tan for most of the original commits.
2023-03-07Build: Adjust CMake version search regex.Jia Tan1-0/+2
Now, the LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, and LZMA_VERSION_PATCH macros do not need to be on consecutive lines in version.h. They can be separated by more whitespace, comments, or even other content, as long as they appear in the proper order (major, minor, patch).
2023-03-07liblzma: Improve documentation for version.h.Jia Tan1-7/+22
Specified parameter and return values for API functions and documented a few more of the macros.
2023-03-07liblzma: Clarify lzma_lzma_preset() documentation in lzma12.h.Jia Tan1-0/+5
lzma_lzma_preset() does not guarentee that the lzma_options_lzma are usable in an encoder even if it returns false (success). If liblzma is built with default configurations, then the options will always be usable. However if the match finders hc3, hc4, or bt4 are disabled, then the options may not be usable depending on the preset level requested. The documentation was updated to reflect this complexity, since this behavior was unclear before.
2023-03-07CMake: Require that the C compiler supports C99 or a newer standard.Lasse Collin1-0/+8
Thanks to autoantwort for reporting the issue and suggesting a different patch: https://github.com/tukaani-project/xz/pull/42
2023-03-07Tests: Small tweak to test-vli.c.Jia Tan1-0/+2
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.
2023-03-07liblzma: Replace '\n' -> newline in filter.h documentation.Jia Tan1-1/+1
The '\n' renders as a newline when the comments are converted to html by Doxygen.
2023-03-07liblzma: Shorten return description for two functions in filter.h.Jia Tan1-6/+2
Shorten the description for lzma_raw_encoder_memusage() and lzma_raw_decoder_memusage().
2023-03-07liblzma: Reword a few lines in filter.hJia Tan1-5/+5
2023-03-07liblzma: Improve documentation in filter.h.Jia Tan1-83/+143
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.
2023-03-07Update THANKS.Lasse Collin1-0/+1
2023-03-07liblzma: Avoid null pointer + 0 (undefined behavior in C).Lasse Collin10-23/+77
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
2023-03-07liblzma: Adjust container.h for consistency with filter.h.Jia Tan1-11/+9
2023-03-07liblzma: Fix small typos and reword a few things in filter.h.Jia Tan1-7/+6
2023-03-07liblzma: Convert list of flags in lzma_mt to bulleted list.Jia Tan1-3/+6
2023-03-07liblzma: Fix typo in documentation in container.hJia Tan1-1/+1
lzma_microlzma_decoder -> lzma_microlzma_encoder
2023-03-07liblzma: Improve documentation for container.hJia Tan1-53/+93
Standardizing each function to always specify parameters and return values. Also moved the parameters and return values to the end of each function description.
2023-03-07CMake: Add LZIP decoder test to list of tests.Jia Tan1-0/+1
2023-03-07Update THANKS.Lasse Collin1-0/+1
2023-03-07Build: Use only the generic symbol versioning on MicroBlaze.Lasse Collin1-2/+10
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