Commit Graph

1965 Commits

Author SHA1 Message Date
Lasse Collin 5e7a8c0869 xzless: Use --show-preproc-errors with "less" 632 and newer.
This makes "less" show a warning if a decompression error occurred.

(cherry picked from commit fd0692b052)
2024-05-07 18:06:55 +03:00
Lasse Collin c692bd42be Build: Update visibility.m4 from Gnulib
This fixes the syntax of the "serial" line and renames
a temporary variable.
2024-05-07 16:23:46 +03:00
Jia Tan 6e8732c5a3 Bump version and soname for 5.4.6. 2024-01-26 19:41:20 +08:00
Jia Tan 6532f55caa Add NEWS for 5.4.6. 2024-01-26 18:54:24 +08:00
Jia Tan 8b1a2798ad Docs: Update .xz file format specification to 1.2.0.
The new RISC-V filter was added to the specification, in addition to
updating the specification URL.
2024-01-24 21:13:55 +08:00
Jia Tan 55285900b3 xz: Update website URLs in the man pages. 2024-01-24 21:13:52 +08:00
Jia Tan a670f69521 liblzma: Update website URL. 2024-01-24 21:13:49 +08:00
Jia Tan 05aeda9612 Docs: Update website URLs. 2024-01-24 21:13:43 +08:00
Jia Tan 3cc54f1c0b Build: Update website URL. 2024-01-24 21:13:10 +08:00
Jia Tan 82f5515de6 Translations: Update the French translation. 2023-12-22 20:02:06 +08:00
Jia Tan 9e96ca8c48 xz: Add a comment to Capsicum sandbox setup.
This comment is repeated in xzdec.c to help remind us why all the
capabilities are removed from stdin in certain situations.
2023-12-22 20:02:06 +08:00
Jia Tan 8191720eac liblzma: Set all values in lzma_lz_encoder to NULL after allocation.
The first member of lzma_lz_encoder doesn't necessarily need to be set
to NULL since it will always be set before anything tries to use it.
However the function pointer members must be set to NULL since other
functions rely on this NULL value to determine if this behavior is
supported or not.

This fixes a somewhat serious bug, where the options_update() and
set_out_limit() function pointers are not set to NULL. This seems to
have been forgotten since these function pointers were added many years
after the original two (code() and end()).

The problem is that by not setting this to NULL we are relying on the
memory allocation to zero things out if lzma_filters_update() is called
on a LZMA1 encoder. The function pointer for set_out_limit() is less
serious because there is not an API function that could call this in an
incorrect way. set_out_limit() is only called by the MicroLZMA encoder,
which must use LZMA1 where set_out_limit() is always set. Its currently
not possible to call set_out_limit() on an LZMA2 encoder at this time.

So calling lzma_filters_update() on an LZMA1 encoder had undefined
behavior since its possible that memory could be manipulated so the
options_update member pointed to a different instruction sequence.

This is unlikely to be a bug in an existing application since it relies
on calling lzma_filters_update() on an LZMA1 encoder in the first place.
For instance, it does not affect xz because lzma_filters_update() can
only be used when encoding to the .xz format.
2023-12-22 20:02:06 +08:00
Jia Tan 0ba5dd7ba1 liblzma: Tweak a comment. 2023-12-22 20:02:06 +08:00
Jia Tan 27ab54af84 liblzma: Make parameter names in function definition match declaration.
lzma_raw_encoder() and lzma_raw_encoder_init() used "options" as the
parameter name instead of "filters" (used by the declaration). "filters"
is more clear since the parameter represents the list of filters passed
to the raw encoder, each of which contains filter options.
2023-12-22 20:02:06 +08:00
Jia Tan 019afd72e0 liblzma: Improve lzma encoder init function consistency.
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-22 20:02:06 +08:00
Jia Tan 6af9a4cbe5 Docs: Update repository URL in Changelog. 2023-12-22 20:02:06 +08:00
Jia Tan 3f51a4415a Tests: Silence -Wsign-conversion warning on GCC version < 10.
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-22 20:02:06 +08:00
Jia Tan 932f02990c Update THANKS. 2023-12-22 20:02:06 +08:00
Kian-Meng Ang b26d5d547f Tests: Fix typos 2023-12-22 20:02:06 +08:00
Jia Tan 7dc466d621 xz: Use is_tty() in message.c. 2023-12-22 20:02:06 +08:00
Jia Tan 0ecfaa6df9 xz: Create separate is_tty() function.
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-22 20:02:06 +08:00
Jia Tan 9a300c9068 tuklib_integer: Fix typo discovered by codespell.
Based on internet dictionary searches, 'choise' is an outdated spelling
of 'choice'.
2023-12-22 20:02:06 +08:00
Jia Tan 9b469da8f3 Tests: Fix typo in a comment. 2023-12-22 20:02:06 +08:00
Jia Tan afcb30fcad Tests: Create test_suffix.sh.
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-22 20:02:06 +08:00
Jia Tan 87c956d4c4 xz: Fix suffix check.
The suffix refactor done in 99575947a5
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-22 20:02:06 +08:00
Jia Tan 84196e8c09 liblzma: Add missing comments to lz_encoder.h. 2023-12-22 20:02:03 +08:00
Jia Tan 49053c0a64 Bump version and soname for 5.4.5. 2023-11-01 20:26:15 +08:00
Jia Tan 84c0cfc556 Add NEWS for 5.4.5. 2023-11-01 20:26:12 +08:00
Lasse Collin d90ed84db9 liblzma: Fix compilation of fastpos_tablegen.c.
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-11-01 20:22:15 +08:00
Jia Tan 9b1268538b Build: Fix text wrapping in an output message. 2023-10-31 21:55:21 +08:00
Lasse Collin 068ee436f4 liblzma: Use lzma_always_inline in memcmplen.h. 2023-10-31 18:44:59 +08:00
Lasse Collin 6cdf0a7b79 liblzma: #define lzma_always_inline in common.h. 2023-10-31 18:44:59 +08:00
Lasse Collin 33daad3961 liblzma: Use lzma_attr_visibility_hidden on private extern declarations.
These variables are internal to liblzma and not exposed in the API.
2023-10-31 18:44:59 +08:00
Lasse Collin 6961a5ac7d liblzma: #define lzma_attr_visibility_hidden in common.h.
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-31 18:44:59 +08:00
Lasse Collin 5b9e167649 liblzma: Refer to MinGW-w64 instead of MinGW in the API headers.
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-31 18:44:59 +08:00
Lasse Collin 36fabdbe67 CMake: Use -D_FILE_OFFSET_BITS=64 if (and only if) needed.
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-31 18:44:59 +08:00
Lasse Collin 989c8c354c CMake: Generate and install liblzma.pc if not using MSVC.
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-31 18:44:59 +08:00
Lasse Collin 983f3b458d CMake: Rearrange the PACKAGE_ variables.
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-31 18:44:59 +08:00
Lasse Collin 4083c8e950 liblzma: Add Cflags.private to liblzma.pc.in for MSYS2.
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-31 18:44:59 +08:00
Lasse Collin 661549ecb7 CMake: Create liblzma.def when building liblzma.dll with MinGW-w64. 2023-10-31 18:44:59 +08:00
Lasse Collin 0e546eb4da CMake: Change one CMAKE_CURRENT_SOURCE_DIR to CMAKE_CURRENT_LIST_DIR.
In this case they have identical values.
2023-10-31 18:44:59 +08:00
Lasse Collin da4d04e4d6 CMake/Windows: Fix the import library filename.
Both PREFIX and IMPORT_PERFIX have to be set to "" to get
liblzma.dll and liblzma.dll.a.
2023-10-31 18:44:59 +08:00
Lasse Collin 007558a358 CMake: Don't shadow the cache entry ENABLE_THREADS with a normal variable.
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-31 18:44:59 +08:00
Lasse Collin 7d01de67ee CMake: Edit threading related messages.
It's mostly to change from "thread method" to "threading method".
2023-10-31 18:44:59 +08:00
Lasse Collin f8edcf3da6 CMake: Use FATAL_ERROR if user-supplied options aren't understood.
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-31 18:44:59 +08:00
Jia Tan 1695021e4a CMake: Add ALLOW_CLMUL_CRC option to enable/disable CLMUL.
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-31 18:44:59 +08:00
Lasse Collin 5056bc5107 tuklib_integer: Revise unaligned reads and writes on strict-align archs.
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-31 18:44:59 +08:00
Lasse Collin 9e14743ee5 tuklib_integer: Add missing write64be and write64le fallback functions. 2023-10-31 18:44:59 +08:00
Jia Tan 4cc91ceb39 Build: Update visibility.m4 from Gnulib.
Updating from version 6 -> 8 from upstream. Declarations for variables
and function bodies were added to avoid unnecessary failures with
-Werror.
2023-10-31 18:44:59 +08:00
Lasse Collin 1824a6007c Update THANKS. 2023-10-31 18:44:59 +08:00